annotate gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputStateBase.java @ 626:61f688a69a55

Split up export modes from output modes. gnv-artifacts/trunk@700 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 23 Feb 2010 11:47:08 +0000
parents 93978859fa9e
children f4331a0df032
rev   line source
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2 *
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
3 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
4 package de.intevation.gnv.state;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
6 import java.io.OutputStream;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
7 import java.util.ArrayList;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8 import java.util.Collection;
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
9 import java.util.HashMap;
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
10 import java.util.Iterator;
626
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
11 import java.util.List;
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12 import java.util.Locale;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13
626
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
14 import javax.xml.xpath.XPathConstants;
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
15
480
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
16 import org.apache.log4j.Logger;
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17 import org.w3c.dom.Document;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 import org.w3c.dom.Element;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 import org.w3c.dom.Node;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 import org.w3c.dom.NodeList;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 610
diff changeset
22 import de.intevation.artifactdatabase.Config;
626
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
23 import de.intevation.artifactdatabase.XMLUtils;
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 610
diff changeset
24 import de.intevation.artifacts.CallContext;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 610
diff changeset
25 import de.intevation.artifacts.CallMeta;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 610
diff changeset
26 import de.intevation.gnv.artifacts.cache.CacheFactory;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 610
diff changeset
27 import de.intevation.gnv.artifacts.ressource.RessourceFactory;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 610
diff changeset
28 import de.intevation.gnv.geobackend.base.Result;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 610
diff changeset
29 import de.intevation.gnv.geobackend.base.query.QueryExecutor;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 610
diff changeset
30 import de.intevation.gnv.geobackend.base.query.QueryExecutorFactory;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 610
diff changeset
31 import de.intevation.gnv.geobackend.base.query.exception.QueryException;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 610
diff changeset
32 import de.intevation.gnv.state.describedata.MinMaxDescribeData;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 610
diff changeset
33 import de.intevation.gnv.state.exception.StateException;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 610
diff changeset
34 import de.intevation.gnv.utils.InputValidator;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 610
diff changeset
35
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 * @author Tim Englich <tim.englich@intevation.de>
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 *
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 */
480
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
40 public abstract class OutputStateBase
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
41 extends StateBase
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
42 implements OutputState
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
43 {
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
44 public static final String XPATH_OUTPUT_MODE =
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
45 "/art:action/art:out/@name";
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
46
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
47 public static final String XPATH_MIME_TYPE =
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
48 "/art:action/art:out/art:mime-type/@value";
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49
626
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
50 public static final String XPATH_EXPORTS =
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
51 "exportModes/export";
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
52
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 * The UID of this Class
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 private static final long serialVersionUID = -1718732895737303823L;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
58 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 * the logger, used to log exceptions and additonaly information
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61 private static Logger log = Logger.getLogger(OutputStateBase.class);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
64 * The different Outputmodes which are provided by an OutputState
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
65 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
66 protected Collection<OutputMode> outputModes = null;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68 protected String queryODVID = null;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
69
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
70 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
71 * Constructor
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
72 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
73 public OutputStateBase() {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
74 super();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
75 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
76
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
77 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
78 * @see de.intevation.gnv.state.OutputState#getOutputModes()
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
79 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
80 public Collection<OutputMode> getOutputModes() {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
81 log.debug("OutputStateBase.getOutputModes");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
82 return this.outputModes;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
83 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
84
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
85 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
86 * @see de.intevation.gnv.state.StateBase#setup(org.w3c.dom.Node)
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
87 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
88 @Override
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
89 public void setup(Node configuration) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
90 log.debug("OutputStateBase.setup");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
91 super.setup(configuration);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
92
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
93 this.queryODVID = Config.getStringXPath(configuration,"queryID-odv");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
94
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
95 NodeList outputModeList = Config.getNodeSetXPath(configuration,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
96 "outputsModes/outputsMode");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
97 if (outputModeList != null) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
98 log.debug(outputModeList.getLength() + " were found.");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
99 this.outputModes = new ArrayList<OutputMode>(outputModeList
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
100 .getLength());
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
101 for (int i = 0; i < outputModeList.getLength(); i++) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
102 Element currentNode = (Element)outputModeList.item(i);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
103 String name = currentNode.getAttribute("name");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
104 String description =currentNode.getAttribute("description");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
105 String mimeType = currentNode.getAttribute("mime-type");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
106 NodeList inputValuesList = Config.getNodeSetXPath(currentNode,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
107 "parameters/inputvalue");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
108 Collection<InputValue> inputParameters = null;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
109 if (inputValuesList != null) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
110 inputParameters = new ArrayList<InputValue>(inputValuesList
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
111 .getLength());
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
112 for (int j = 0; j < inputValuesList.getLength(); j++) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
113 Element currentInputValuesNode = (Element)inputValuesList.item(j);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
114 String inputValueName = currentInputValuesNode.getAttribute("name");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
115 String inputValueType = currentInputValuesNode.getAttribute("type");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
116 String defaultValue =currentInputValuesNode.getAttribute("value");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
117 boolean isMultiselect = false;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
118 InputValue inputValue = new DefaultInputValue(
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
119 inputValueName, inputValueType, defaultValue,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
120 isMultiselect);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
121 inputParameters.add(inputValue);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
122 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
123 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
124
626
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
125 // parse export modes
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
126 List<ExportMode> exportList = null;
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
127 NodeList exports = (NodeList) XMLUtils.xpath(
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
128 currentNode, XPATH_EXPORTS, XPathConstants.NODESET);
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
129
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
130 if (exports != null) {
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
131 int exportSize = exports.getLength();
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
132
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
133 exportList = new ArrayList<ExportMode>(exportSize);
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
134 for (int k = 0; k < exportSize; k++) {
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
135 Element exp = (Element) exports.item(k);
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
136 String expName = exp.getAttribute("name");
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
137 String expDesc = exp.getAttribute("description");
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
138 String expMime = exp.getAttribute("mime-type");
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
139
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
140 exportList.add(
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
141 new DefaultExportMode(expName, expDesc, expMime));
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
142 }
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
143 }
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
144
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
145 OutputMode outputMode = new DefaultOutputMode(name,
626
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
146 description, mimeType, inputParameters, exportList);
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
147 log.debug(outputMode.toString());
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
148 this.outputModes.add(outputMode);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
149
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
150 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
151 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
152 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
153
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
154 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
155 * @see de.intevation.gnv.state.StateBase#advance()
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
156 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
157 @Override
493
cef17cc90fd0 Changed some method signatures of the State interface. Use CallContext objects instead of CallMeta objects which are a subset of CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 480
diff changeset
158 public void advance(String uuid, CallContext context)
cef17cc90fd0 Changed some method signatures of the State interface. Use CallContext objects instead of CallMeta objects which are a subset of CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 480
diff changeset
159 throws StateException
cef17cc90fd0 Changed some method signatures of the State interface. Use CallContext objects instead of CallMeta objects which are a subset of CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 480
diff changeset
160 {
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
161 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
162
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
163 @Override
493
cef17cc90fd0 Changed some method signatures of the State interface. Use CallContext objects instead of CallMeta objects which are a subset of CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 480
diff changeset
164 public void initialize(String uuid, CallContext context)
cef17cc90fd0 Changed some method signatures of the State interface. Use CallContext objects instead of CallMeta objects which are a subset of CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 480
diff changeset
165 throws StateException
cef17cc90fd0 Changed some method signatures of the State interface. Use CallContext objects instead of CallMeta objects which are a subset of CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 480
diff changeset
166 {
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
167 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
168
480
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
169 public void out(
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
170 Document format,
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
171 Collection<InputData> inputData,
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
172 OutputStream outputStream,
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
173 String uuid,
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
174 CallMeta callMeta
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
175 )
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
176 throws StateException
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
177 {
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
178 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
179
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
180 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
181 * @see de.intevation.gnv.state.OutputState#out(java.lang.String,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
182 * java.util.Collection, java.io.OutputStream)
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
183 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
184 public void out(String outputMode, Collection<InputData> inputData,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
185 OutputStream outputStream) throws StateException {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
186 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
187
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
188 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
189 * @return
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
190 */
439
8975de9d7483 Loop through configuration to chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 429
diff changeset
191 protected Object getChartResult(String uuid, CallContext callContext) {
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
192 log.debug("OutputStateBase.getChartResult");
439
8975de9d7483 Loop through configuration to chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 429
diff changeset
193 Object result = null;
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
194 if (CacheFactory.getInstance().isInitialized()) {
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
195 String key = "chart_" + getHash();
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
196 log.debug("Hash for Queryelements: " + key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
197 net.sf.ehcache.Element value = CacheFactory.getInstance().getCache().get(key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
198 if (value != null) {
439
8975de9d7483 Loop through configuration to chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 429
diff changeset
199 result = value.getObjectValue();
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
200 }else{
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
201 result = this.getData(this.queryID);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
202 if (CacheFactory.getInstance().isInitialized()) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
203 CacheFactory.getInstance().getCache().put(new net.sf.ehcache.Element(key, result));
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
204 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
205
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
206 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
207 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
208 return result;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
209 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
210
439
8975de9d7483 Loop through configuration to chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 429
diff changeset
211 protected Object getChartFromCache(String uuid, CallContext callContext) {
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
212 log.debug("Fetch chart [" + uuid + "] from cache");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
213 CacheFactory cacheFactory = CacheFactory.getInstance();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
214 if (cacheFactory.isInitialized()) {
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
215 String key = "chart_" + getHash();
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
216 net.sf.ehcache.Element object = cacheFactory.getCache().get(key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
217
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
218 if (object != null) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
219 return object.getObjectValue();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
220 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
221 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
222 return null;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
223 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
224
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
225 protected Collection<Result> getODVResult(String uuid) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
226 log.debug("OutputStateBase.getODVResult");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
227 // TODO add Caching? I think it's not nessessary
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
228 Collection<Result> returnValue = null;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
229 if (this.queryODVID != null){
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
230 returnValue = this.getData(this.queryODVID);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
231 }else{
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
232 log.warn("No Query for ODV Data is defined.");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
233 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
234 return returnValue;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
235 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
236
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
237 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
238 * @param returnValue
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
239 * @return
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
240 */
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 610
diff changeset
241 protected Collection<Result> getData(String queryID) {
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
242 log.debug("OutputStateBase.getData");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
243 Collection<Result> returnValue = null;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
244 try {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
245 String[] filterValues = this.generateFilterValuesFromInputData();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
246 try {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
247 QueryExecutor queryExecutor = QueryExecutorFactory
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
248 .getInstance()
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
249 .getQueryExecutor();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
250 returnValue = queryExecutor.executeQuery(queryID,filterValues);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
251 } catch (RuntimeException e) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
252 log.error(e, e);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
253 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
254 } catch (QueryException e) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
255 log.error(e, e);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
256 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
257 return returnValue;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
258 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
259
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
260 protected void removeChartResult(String uuid) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
261 log.debug("OutputStateBase.getChartResult");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
262 if (CacheFactory.getInstance().isInitialized()) {
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
263 String key = "chart_" + getHash();
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
264 log.debug("Hash for Queryelements: " + key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
265 net.sf.ehcache.Element value = CacheFactory.getInstance().getCache().get(key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
266 if (value != null) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
267 CacheFactory.getInstance().getCache().remove(key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
268 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
269 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
270 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
271
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
272 protected void removeChart(String uuid) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
273 log.debug("OutputStateBase.removeChart from cache");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
274
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
275 CacheFactory cacheFactory = CacheFactory.getInstance();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
276 if (cacheFactory.isInitialized()) {
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
277 String key = "chart_" + getHash();
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
278 net.sf.ehcache.Element object = cacheFactory.getCache().get(key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
279 if (object != null)
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
280 cacheFactory.getCache().remove(key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
281 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
282 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
283
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
284 protected void purifyChart(Object chart, String uuid) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
285 log.debug("Prufify chart [" + uuid + "]");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
286 CacheFactory cacheFactory = CacheFactory.getInstance();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
287 if (cacheFactory.isInitialized()) {
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
288 String key = "chart_" + getHash();
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
289 cacheFactory.getCache().put(new net.sf.ehcache.Element(key, chart));
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
290 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
291 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
292
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
293
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
294 @Override
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
295 public void feed(Collection<InputData> inputData, String uuid)
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
296 throws StateException
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
297 {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
298 putInputData(inputData, uuid);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
299 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
300
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
301 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
302 * @see de.intevation.gnv.state.StateBase#putInputData(java.util.Collection, java.lang.String)
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
303 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
304 @Override
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
305 public void putInputData(Collection<InputData> inputData,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
306 String uuid)
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
307 throws StateException {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
308 log.debug("OutputStateBase.putInputData");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
309 this.removeChartResult(uuid);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
310 this.removeChart(uuid);
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
311
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
312 if (inputData != null) {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
313 Iterator<InputData> it = inputData.iterator();
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
314 InputValidator iv = new InputValidator();
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
315 while (it.hasNext()) {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
316 InputData tmpItem = it.next();
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
317 Object tmpObj = tmpItem.getObject();
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
318 InputValue inputValue = this.inputValues.get(tmpItem.getName());
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
319 if (inputValue != null) {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
320 if (this.inputData == null) {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
321 this.inputData = new HashMap<String, InputData>(
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
322 inputData.size());
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
323 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
324
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
325 boolean valid = iv.isInputValid(tmpItem.getValue(),
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
326 inputValue.getType());
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
327 if (valid) {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
328 if (tmpItem.getName().equals(MINVALUEFIELDNAME)){
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
329 String minValue = tmpItem.getValue();
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
330 String maxValue = getInputValue4ID(inputData, MAXVALUEFIELDNAME);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
331 valid = iv.isInputValid(maxValue,inputValue.getType());
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
332 if (!valid){
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
333 String errMsg = "Wrong input for " + tmpItem.getValue()
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
334 + " is not an " + inputValue.getType()
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
335 + " Value.";
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
336 log.warn(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
337 throw new StateException(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
338 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
339
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
340 valid = iv.isInputValid(minValue,
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
341 maxValue,
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
342 inputValue.getType());
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
343 if (!valid){
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
344 String errMsg = "MaxValue-Input is less than MinValue-Input ";
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
345 log.warn(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
346 throw new StateException(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
347 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
348 }else if (tmpItem.getName().equals(MAXVALUEFIELDNAME)){
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
349 String minValue = getInputValue4ID(inputData, MINVALUEFIELDNAME);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
350 String maxValue = tmpItem.getValue();
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
351 valid = iv.isInputValid(minValue,inputValue.getType());
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
352 if (!valid){
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
353 String errMsg = "Wrong input for " + tmpItem.getValue()
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
354 + " is not an " + inputValue.getType()
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
355 + " Value.";
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
356 log.warn(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
357 throw new StateException(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
358 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
359
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
360 valid = iv.isInputValid(minValue,
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
361 maxValue,
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
362 inputValue.getType());
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
363 if (!valid){
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
364 String errMsg = "MaxValue-Input is less than MinValue-Input ";
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
365 log.warn(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
366 throw new StateException(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
367 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
368 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
369 this.inputData.put(tmpItem.getName(), tmpItem);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
370 } else {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
371 String errMsg = "Wrong input for " + tmpItem.getValue()
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
372 + " is not an " + inputValue.getType()
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
373 + " Value.";
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
374 log.warn(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
375 throw new StateException(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
376 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
377
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
378 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
379 else if (tmpObj != null && tmpObj instanceof MinMaxDescribeData) {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
380 MinMaxDescribeData data = (MinMaxDescribeData) tmpObj;
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
381 if (this.inputData == null) {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
382 this.inputData = new HashMap<String, InputData>(inputData.size());
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
383 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
384 this.inputData.put(tmpItem.getName(), tmpItem);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
385 this.inputData.put("minvalue", new DefaultInputData("minvalue", (String) data.getMinValue()));
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
386 this.inputData.put("maxvalue", new DefaultInputData("maxvalue", (String) data.getMaxValue()));
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
387 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
388 else {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
389
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
390 String errMsg = "No Inputvalue given for Inputdata "
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
391 + tmpItem.getName();
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
392 log.warn(errMsg + "Value will be ignored");
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
393
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
394 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
395 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
396 } else {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
397 log.warn("No Inputdata given");
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
398 }
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
399 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
400
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
401 public void out(String outputMode, Collection<InputData> inputData,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
402 OutputStream outputStream, String uuid, CallMeta callMeta)
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
403 throws StateException {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
404 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
405
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
406
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
407 protected String getMessage(Locale locale, String key, String value) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
408 return RessourceFactory.getInstance().getRessource(
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
409 locale,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
410 key,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
411 value
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
412 );
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
413 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
414 }
626
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
415 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

http://dive4elements.wald.intevation.org