annotate gnv-artifacts/src/main/java/de/intevation/gnv/state/MeasurementState.java @ 1117:dec4257ad570

Changed imports to fit new positions of XMLUtils and Config gnv-artifacts/trunk@1478 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 15 Mar 2011 16:13:39 +0000
parents f953c9a559d8
children
rev   line source
1115
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1102
diff changeset
1 /*
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1102
diff changeset
2 * Copyright (c) 2010 by Intevation GmbH
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1102
diff changeset
3 *
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1102
diff changeset
4 * This program is free software under the LGPL (>=v2.1)
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1102
diff changeset
5 * Read the file LGPL.txt coming with the software for details
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1102
diff changeset
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1102
diff changeset
7 */
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1102
diff changeset
8
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
9 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
10
1117
dec4257ad570 Changed imports to fit new positions of XMLUtils and Config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1115
diff changeset
11 import de.intevation.artifacts.common.utils.XMLUtils;
652
078ba6799bd2 Cleanup imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
12
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
13 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
14 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
15
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.artifacts.ressource.RessourceFactory;
652
078ba6799bd2 Cleanup imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
17
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
18 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
19 import de.intevation.gnv.geobackend.base.ResultDescriptor;
652
078ba6799bd2 Cleanup imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
20
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
21 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
22 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
23 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
24 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
25
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
26 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
27
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
28 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
29
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
30 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
31 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
32 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
33 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
34 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
35 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
36 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
37
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
38 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
39
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
40 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
41 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
42 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
43
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 /**
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
45 * 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
46 * 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
47 * 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
48 * 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
49 * not be selected.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
50 *
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
51 * @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
52 */
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
53 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
54 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
55 {
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
56 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
57
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
58 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
59
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
60 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
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
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
63 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
64 * 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
65 * 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
66 * requested via different methods.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
67 *
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
68 * @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
69 */
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
70 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
71 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
72 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
73
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
74 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
75 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
76 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
77 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
78
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
79 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
80 * Constructs a new matrix.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
81 *
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
82 * @param data A collection containing the measurements.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
83 * @param parameter An array of parameters.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
84 */
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
85 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
86 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
87 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
88 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
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 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
91 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
92 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
93 }
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
94
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
95 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
96 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
97 }
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
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
99 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
100 * Initialize the measurements used in this matrix.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
101 *
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
102 * @param data The measurements.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
103 */
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
104 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
105 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
106 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
107 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
108 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
109 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
110 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
111
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
112 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
113 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
114 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
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 (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
117 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
118 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
119
aaacced2a0cc Fixed an ArrayIndexOutOfBounds exception that occured while initializing the ParameterMatrix (issue281).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1038
diff changeset
120 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
121 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
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
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 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
125 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
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
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
128 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
129 && 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
130 {
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
131 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
132 }
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 }
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
134 }
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
135
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
136 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
137 * Initialize the parameters used in this matrix.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
138 *
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
139 * @param parameter Parameters.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
140 */
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
141 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
142 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
143 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
144 }
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 }
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
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
147 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
148 * Returns the number of measurements.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
149 *
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
150 * @return the number of measurements.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
151 */
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
152 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
153 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
154 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
155
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 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
157 }
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
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
159 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
160 * Returns the number of parameters.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
161 *
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
162 * @return number of parameters.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
163 */
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
164 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
165 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
166 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
167
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
168 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
169 }
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
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
171 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
172 * Returns the measurement at idx.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
173 *
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
174 * @param idx Index.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
175 * @return the measurement.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
176 */
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
177 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
178 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
179 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
180
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
181 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
182 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
183 }
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
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
185 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
186 * Returns the parameter at idx.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
187 *
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
188 * @param idx Index
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
189 * @return the parameter.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
190 */
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
191 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
192 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
193 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
194 }
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
195
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
196 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
197 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
198 }
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
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
200 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
201 * Returns a description text for a specific measurement.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
202 *
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
203 * @param idx Index of a measurement.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
204 * @return measurement's description.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
205 */
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
206 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
207 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
208 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
209 }
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
210
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
211 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
212 }
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
213
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
214 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
215 * 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
216 * parameter - otherwise false.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
217 *
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
218 * @param i Index of a measurement column.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
219 * @param j Index of a parameter row.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
220 * @return true, if valid, else false.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
221 */
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
222 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
223 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
224 || 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
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 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
227 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
228 }
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 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
231 }
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 } // 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
233
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
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 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
236 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
237 }
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
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 @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
240 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
241 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
242 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
243 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
244 ) {
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 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
246 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
247
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 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
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 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
251 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
252 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
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 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
255 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
256 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
257
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 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
259 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
260 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
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
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 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
264 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
265 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
266 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
267 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
268 }
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
269
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
270 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
271 }
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
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
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
274 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
275 * 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
276 * 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
277 * measurement.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
278 */
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
279 @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
280 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
281 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
282 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
283 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
284 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
285 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
286 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
287 ) {
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 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
289 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
290 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
291
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 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
293 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
294 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
295 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
296 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
297 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
298
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
299 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
300 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
301
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 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
303 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
304
744
6290ab85782b Changed the structure for parameter/measurement matrix in the describe document (issue199).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
305 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
306 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
307 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
308 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
309 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
310
744
6290ab85782b Changed the structure for parameter/measurement matrix in the describe document (issue199).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
311 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
312 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
313 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
314 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
315
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 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
317 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
318 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
319 "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
320 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
321
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 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
323 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
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 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
326 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
327 }
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
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
329 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
330 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
331 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
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 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
334 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
335 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
336 }
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
337
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
338 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
339 }
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
340
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
341 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
342 }
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
343
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
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
345 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
346 * 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
347 * 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
348 * a measurement and the parameter it belongs to.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
349 */
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
350 @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
351 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
352 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
353 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
354 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
355 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
356 {
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 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
358 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
359 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
360 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
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 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
363 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
364 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
365 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
366 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
367 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
368 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
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
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 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
372 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
373 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
374
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 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
376 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
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 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
379 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
380 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
381 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
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 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
384 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
385 }
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 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
388 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
389 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
390 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
391 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
392 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
393 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
394 }
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
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 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
397 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
398 }
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
399
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
400 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
401 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
402 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
403 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
404 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
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 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
407 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
408 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
409 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
410 }
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
411
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
412 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
413 }
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
414
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
415 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
416 }
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
417
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
418
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
419 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
420 * 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
421 * 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
422 * 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
423 * by a character.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
424 *
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
425 * @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
426 * @return An array with separated measurements and parameters.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 785
diff changeset
427 */
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
428 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
429 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
430
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 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
432 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
433 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
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[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
436 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
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[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
440 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
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 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
444 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
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 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
447 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
448 }
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
449 }
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
450
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
451 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
452 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
453
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
454 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
455 }
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
456 }
836
05bf8534a35a Using unix line endings only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 815
diff changeset
457 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org