annotate gnv-artifacts/src/main/java/de/intevation/gnv/state/MeasurementState.java @ 1102:aaacced2a0cc

Fixed an ArrayIndexOutOfBounds exception that occured while initializing the ParameterMatrix (issue281). gnv-artifacts/trunk@1228 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 28 Jun 2010 10:25:55 +0000
parents 9981452c7e75
children f953c9a559d8
rev   line source
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.state;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
652
078ba6799bd2 Cleanup imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
3 import de.intevation.artifactdatabase.XMLUtils;
078ba6799bd2 Cleanup imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
4
785
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
5 import de.intevation.artifacts.CallContext;
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import de.intevation.artifacts.CallMeta;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import de.intevation.gnv.artifacts.ressource.RessourceFactory;
652
078ba6799bd2 Cleanup imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
9
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import de.intevation.gnv.geobackend.base.Result;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import de.intevation.gnv.geobackend.base.ResultDescriptor;
652
078ba6799bd2 Cleanup imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
12
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import de.intevation.gnv.state.describedata.ExtendedKeyValueData;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import de.intevation.gnv.state.describedata.KeyValueDescibeData;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import de.intevation.gnv.state.describedata.NamedArrayList;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import de.intevation.gnv.state.describedata.NamedCollection;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
785
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
18 import de.intevation.gnv.state.exception.StateException;
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
19
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
20 import de.intevation.gnv.utils.InputValidator;
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
21
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import java.util.ArrayList;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 import java.util.Arrays;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 import java.util.Collection;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 import java.util.Iterator;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 import java.util.List;
785
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
27 import java.util.Locale;
1030
c07d9f9a738c Removed bugs that existed in the caching mechanism (issue264, issue268).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 836
diff changeset
28 import java.util.TreeMap;
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 import org.apache.log4j.Logger;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 import org.w3c.dom.Document;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 import org.w3c.dom.Element;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 import org.w3c.dom.Node;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 /**
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
37 * This state handles input of measurements relating to a parameter. The user
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
38 * interface description created by this class represents a matrix - each
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
39 * parameter in a single row, each measurement in a column. An invalid
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
40 * measurement column for a specific parameter is marked as disabled and should
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
41 * not be selected.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
42 *
780
c4156275c1e1 Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 744
diff changeset
43 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 */
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 public class MeasurementState
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 extends DefaultState
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 private static Logger logger = Logger.getLogger(MeasurementState.class);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 public static final String SQL_KEY_PARAMETERID = "PARAMETERID";
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51
785
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
52 public static final String SEPARATOR = ";";
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
53
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
55 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
56 * This class is used to generate the Matrix in <code>MinMaxDateState</code>.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
57 * Parameter and Measurements are stored in separate lists and can be
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
58 * requested via different methods.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
59 *
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
60 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
61 */
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 private class ParameterMatrix {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 private final Logger logger =
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 Logger.getLogger(ParameterMatrix.class);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 private List measurements;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 private List mDescriptions;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 private List parameters;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 private boolean[][] values;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
71 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
72 * Constructs a new matrix.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
73 *
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
74 * @param data A collection containing the measurements.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
75 * @param parameter An array of parameters.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
76 */
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 public ParameterMatrix(Collection data, String[] parameter) {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 measurements = new ArrayList(data.size());
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 mDescriptions = new ArrayList(data.size());
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 parameters = new ArrayList(parameter.length);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 values = new boolean[data.size()][parameter.length];
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 for (int i = 0; i < data.size(); i++) {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 Arrays.fill(values[i], false);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 initParameters(parameter);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 initMeasurements(data);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
91 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
92 * Initialize the measurements used in this matrix.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
93 *
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
94 * @param data The measurements.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
95 */
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 private void initMeasurements(Collection data) {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 Iterator iter = data.iterator();
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 while (iter.hasNext()) {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 ExtendedKeyValueData value = (ExtendedKeyValueData) iter.next();
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 String key = value.getKey();
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 String val = value.getValue();
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 String parameter = value.getParameter();
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 int i = measurements.indexOf(key);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 int j = parameters.indexOf(parameter);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 int tmp = mDescriptions.indexOf(val);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 if (i < 0) {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 measurements.add(key);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 i = measurements.indexOf(key);
1102
aaacced2a0cc Fixed an ArrayIndexOutOfBounds exception that occured while initializing the ParameterMatrix (issue281).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1038
diff changeset
111
aaacced2a0cc Fixed an ArrayIndexOutOfBounds exception that occured while initializing the ParameterMatrix (issue281).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1038
diff changeset
112 mDescriptions.add(val);
aaacced2a0cc Fixed an ArrayIndexOutOfBounds exception that occured while initializing the ParameterMatrix (issue281).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1038
diff changeset
113 tmp = mDescriptions.indexOf(val);
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116 if (j < 0) {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 logger.warn("Not a valid parameter: " + parameter);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120 if (i >= 0 && i < measurements.size() && j >= 0
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 && j < parameters.size())
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 values[i][j] = true;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
128 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
129 * Initialize the parameters used in this matrix.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
130 *
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
131 * @param parameter Parameters.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
132 */
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133 private void initParameters(String[] parameter) {
785
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
134 for (String param: parameter) {
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
135 parameters.add(param);
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
139 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
140 * Returns the number of measurements.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
141 *
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
142 * @return the number of measurements.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
143 */
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 public int measurementSize() {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
145 if (measurements != null)
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146 return measurements.size();
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 return 0;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
151 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
152 * Returns the number of parameters.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
153 *
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
154 * @return number of parameters.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
155 */
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156 public int parameterSize() {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 if (parameters != null)
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 return parameters.size();
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 return 0;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
163 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
164 * Returns the measurement at idx.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
165 *
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
166 * @param idx Index.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
167 * @return the measurement.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
168 */
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
169 public String getMeasurement(int idx) {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
170 if (idx >= 0 && idx < measurements.size())
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
171 return (String) measurements.get(idx);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173 logger.warn("Index is out of bounds: " + idx);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
174 return "";
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
175 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
176
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
177 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
178 * Returns the parameter at idx.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
179 *
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
180 * @param idx Index
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
181 * @return the parameter.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
182 */
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
183 public String getParameter(int idx) {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
184 if (idx >= 0 && idx < parameters.size()) {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
185 return (String) parameters.get(idx);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
186 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
187
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
188 logger.warn("Index is out of bounds: " + idx);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
189 return "";
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
190 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
191
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
192 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
193 * Returns a description text for a specific measurement.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
194 *
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
195 * @param idx Index of a measurement.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
196 * @return measurement's description.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
197 */
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
198 public String getMDescription(int idx) {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
199 if (mDescriptions != null) {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200 return (String) mDescriptions.get(idx);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
202
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203 return null;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
204 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
205
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
206 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
207 * This method returns true, if a measurement is valid for a specific
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
208 * parameter - otherwise false.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
209 *
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
210 * @param i Index of a measurement column.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
211 * @param j Index of a parameter row.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
212 * @return true, if valid, else false.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
213 */
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214 public boolean isValid(int i, int j) {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
215 if (i < 0 || i > measurements.size()
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
216 || j < 0 || j > parameters.size())
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
217 {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
218 logger.warn("Index out of bounds: " + i + "|" + j);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
219 return false;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
220 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
221
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
222 return values[i][j];
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
223 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
224 } // End of ParameterMatrix
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
225
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
226
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
227 public MeasurementState() {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
228 super();
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
229 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
230
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
231 @Override
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
232 protected NamedCollection<KeyValueDescibeData> extractKVP(
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
233 Collection<Result> result,
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
234 String keyid,
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
235 String valueid
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
236 ) {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
237 NamedCollection<KeyValueDescibeData> kvdd =
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
238 new NamedArrayList<KeyValueDescibeData>(dataName, result.size());
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
239
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
240 kvdd.setMultiSelect(true);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
241
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
242 int keyPos = -1;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
243 int valPos = -1;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
244 int parPos = -1;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
245
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
246 for (Result res: result) {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
247 if (keyPos < 0 || valPos < 0 || parPos < 0) {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
248 ResultDescriptor rd = res.getResultDescriptor();
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
249
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
250 keyPos = rd.getColumnIndex(keyid);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
251 valPos = rd.getColumnIndex(valueid);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
252 parPos = rd.getColumnIndex(SQL_KEY_PARAMETERID);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
253 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
254
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
255 kvdd.add(new ExtendedKeyValueData(
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
256 res.getString(keyPos),
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
257 res.getString(valPos),
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
258 getID(),
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
259 res.getString(parPos)));
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
260 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
261
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
262 return kvdd;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
263 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
264
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
265
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
266 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
267 * This method create the user interface description for measurement and
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
268 * parameters as matrix. A row for each parameter, a column for each
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
269 * measurement.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
270 */
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
271 @Override
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
272 protected void appendToDynamicNode(
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
273 XMLUtils.ElementCreator artCreator,
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
274 XMLUtils.ElementCreator creator,
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
275 Document document,
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
276 Node dynamicNode,
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
277 CallMeta callMeta,
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
278 Object o
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
279 ) {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
280 NamedArrayList all = (NamedArrayList) o;
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
281 String name = all.getName();
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
282 RessourceFactory factory = RessourceFactory.getInstance();
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
283
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
284 Element matrixNode = creator.create("group");
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
285 Element matrixLabel = creator.create("label");
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
286 matrixLabel.setTextContent(factory.getRessource(
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
287 callMeta.getLanguages(), all.getName(), all.getName()));
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
288 creator.addAttr(matrixNode, "mode", "matrix");
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
289 matrixNode.appendChild(matrixLabel);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
290
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
291 InputData inputParam = inputData.get("parameterid");
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
292 ParameterMatrix matrix = new ParameterMatrix(all, inputParam.splitValue());
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
293
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
294 int measurements = matrix.measurementSize();
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
295 int parameters = matrix.parameterSize();
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
296
744
6290ab85782b Changed the structure for parameter/measurement matrix in the describe document (issue199).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
297 for (int i = 0; i < parameters; i++) {
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
298 Element select = creator.create("select");
785
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
299 String param = matrix.getParameter(i);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
300 creator.addAttr(select, "label", inputParam.getDescription(param));
650
1946c4e9a878 Added missing parameter name in describe document (issue185).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 634
diff changeset
301 creator.addAttr(select, "ref", name);
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
302
744
6290ab85782b Changed the structure for parameter/measurement matrix in the describe document (issue199).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
303 for (int j = 0; j < measurements; j++) {
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
304 Element item = creator.create("item");
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
305 Element label = creator.create("label");
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
306 Element value = creator.create("value");
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
307
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
308 creator.addAttr(item, "ref", name);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
309 creator.addAttr(
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
310 item,
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
311 "parameter",
744
6290ab85782b Changed the structure for parameter/measurement matrix in the describe document (issue199).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
312 matrix.getMDescription(j));
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
313
744
6290ab85782b Changed the structure for parameter/measurement matrix in the describe document (issue199).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
314 if (!matrix.isValid(j, i)) {
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
315 creator.addAttr(item, "disabled", "true");
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
316 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
317 else {
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
318 creator.addAttr(item, "disabled", "false");
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
319 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
320
785
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
321 String tmpValue = matrix.getMeasurement(j) + ";" + param;
744
6290ab85782b Changed the structure for parameter/measurement matrix in the describe document (issue199).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
322 label.setTextContent(matrix.getMDescription(j));
785
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
323 value.setTextContent(tmpValue);
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
324
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
325 item.appendChild(label);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
326 item.appendChild(value);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
327 select.appendChild(item);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
328 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
329
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
330 matrixNode.appendChild(select);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
331 }
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
332
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
333 dynamicNode.appendChild(matrixNode);
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
334 }
785
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
335
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
336
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
337 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
338 * This feed takes some input data storing measurement ids and parameter ids
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
339 * and put them into ExtendedInputData objects to save the relation between
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
340 * a measurement and the parameter it belongs to.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
341 */
785
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
342 @Override
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
343 public Document feed(
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
344 CallContext context,
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
345 Collection<InputData> input,
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
346 String uuid)
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
347 throws StateException
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
348 {
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
349 RessourceFactory resFactory = RessourceFactory.getInstance();
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
350 Locale[] serverLocales = resFactory.getLocales();
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
351 Locale locale = context.getMeta().getPreferredLocale(
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
352 serverLocales);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
353
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
354 if (input == null) {
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
355 String msg = resFactory.getRessource(
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
356 locale,
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
357 EXCEPTION_NO_INPUT,
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
358 EXCEPTION_NO_INPUT);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
359 logger.warn(msg);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
360 return feedFailure(msg);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
361 }
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
362
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
363 for(InputData item: input) {
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
364 String name = item.getName();
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
365 InputValue inputValue = inputValues.get(name);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
366
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
367 String[] tupel = extractValuesAndParams(item.getValue());
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
368 String type = inputValue.getType();
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
369
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
370 if (inputValue == null) {
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
371 String msg = resFactory.getRessource(
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
372 locale,
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
373 EXCEPTION_INVALID_INPUT,
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
374 EXCEPTION_INVALID_INPUT);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
375 logger.warn(msg);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
376 return feedFailure(msg);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
377 }
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
378
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
379 if (!InputValidator.isInputValid(tupel[0], type)) {
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
380 String msg = resFactory.getRessource(
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
381 locale,
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
382 EXCEPTION_INVALID_INPUT,
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
383 EXCEPTION_INVALID_INPUT);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
384 logger.warn(msg);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
385 return feedFailure(msg);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
386 }
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
387
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
388 if (inputData == null) {
1030
c07d9f9a738c Removed bugs that existed in the caching mechanism (issue264, issue268).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 836
diff changeset
389 inputData = new TreeMap<String, InputData>();
785
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
390 }
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
391
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
392 ExtendedInputData extended = new ExtendedInputData(
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
393 name,
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
394 tupel[0],
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
395 item.getObject(),
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
396 tupel[1]);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
397
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
398 if (name.equals(dataName)) {
1038
9981452c7e75 First step: Added a new state handling the selection between vector or scalar and a new transition in timeseries to provide vector values (issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1030
diff changeset
399 String[] desc = getDescriptionForInputData(
9981452c7e75 First step: Added a new state handling the selection between vector or scalar and a new transition in timeseries to provide vector values (issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1030
diff changeset
400 extended, context, uuid);
785
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
401 extended.setDescription(desc);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
402 }
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
403
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
404 inputData.put(name, extended);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
405 }
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
406
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
407 return feedSuccess();
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
408 }
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
409
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
410
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
411 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
412 * Extract parameter ids and measurement ids from DefaultInputData objects
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
413 * and return an array. In the first position of this array, the measurement
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
414 * ids are placed, in the second position the parameter ids - all separated
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
415 * by a character.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
416 *
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
417 * @param tmp String containing measurement ids and parameter ids.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
418 * @return An array with separated measurements and parameters.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
419 */
785
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
420 protected String[] extractValuesAndParams(String tmp) {
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
421 String[] array = tmp.split(DefaultInputData.VALUE_SEPARATOR);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
422
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
423 String[] extracted = new String[2];
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
424 for (String item: array) {
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
425 String[] tupel = item.split(ExtendedInputData.SEPARATOR);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
426
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
427 if (extracted[0] == null) {
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
428 extracted[0] = tupel[0];
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
429 }
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
430 else {
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
431 extracted[0] +=
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
432 DefaultInputData.VALUE_SEPARATOR + tupel[0];
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
433 }
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
434
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
435 if (extracted[1] == null) {
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
436 extracted[1] = tupel[1];
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
437 }
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
438 else {
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
439 extracted[1] += DefaultInputData.VALUE_SEPARATOR + tupel[1];
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
440 }
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
441 }
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
442
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
443 logger.debug("VALUES RESULT: " + extracted[0]);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
444 logger.debug("PARAMS RESULT: " + extracted[1]);
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
445
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
446 return extracted;
e764cab8c885 Save the relation between selected measurement and the parameter it belongs to (issue210). TODO: Adapt sql statements.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
447 }
634
58c32df1a44d Improved the describe document so that we are able to render a measurement-parameter-matrix with these data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
448 }
836
05bf8534a35a Using unix line endings only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 815
diff changeset
449 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org