annotate gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputStateBase.java @ 483:c8089cd7d777

Added explicit index scheme to palette classes to allow external references. gnv-artifacts/trunk@558 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 18 Jan 2010 10:56:41 +0000
parents 211cad2fb5ba
children cef17cc90fd0
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
480
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
6 import de.intevation.artifactdatabase.Config;
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
7
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
8 import de.intevation.artifacts.CallContext;
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
9 import de.intevation.artifacts.CallMeta;
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
10
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
11 import de.intevation.gnv.artifacts.cache.CacheFactory;
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
12
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
13 import de.intevation.gnv.artifacts.ressource.RessourceFactory;
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
14
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
15 import de.intevation.gnv.geobackend.base.Result;
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
16
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
17 import de.intevation.gnv.geobackend.base.query.QueryExecutor;
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
18 import de.intevation.gnv.geobackend.base.query.QueryExecutorFactory;
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
19
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
20 import de.intevation.gnv.geobackend.base.query.exception.QueryException;
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
21
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
22 import de.intevation.gnv.state.exception.StateException;
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
23
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 import java.io.OutputStream;
480
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
25
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26 import java.util.ArrayList;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 import java.util.Collection;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 import java.util.Locale;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29
480
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
30 import org.apache.log4j.Logger;
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 import org.w3c.dom.Document;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 import org.w3c.dom.Element;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 import org.w3c.dom.Node;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 import org.w3c.dom.NodeList;
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 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 * @author Tim Englich <tim.englich@intevation.de>
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 *
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 */
480
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
41 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
42 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
43 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
44 {
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
45 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
46 "/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
47
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
48 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
49 "/art:action/art:out/art:mime-type/@value";
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 * The UID of this Class
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 private static final long serialVersionUID = -1718732895737303823L;
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 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57 * the logger, used to log exceptions and additonaly information
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 private static Logger log = Logger.getLogger(OutputStateBase.class);
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 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62 * The different Outputmodes which are provided by an OutputState
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 protected Collection<OutputMode> outputModes = null;
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 String queryODVID = 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 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
69 * Constructor
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 public OutputStateBase() {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
72 super();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
73 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
74
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 * @see de.intevation.gnv.state.OutputState#getOutputModes()
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 public Collection<OutputMode> getOutputModes() {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
79 log.debug("OutputStateBase.getOutputModes");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
80 return this.outputModes;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
81 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
82
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 * @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
85 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
86 @Override
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
87 public void setup(Node configuration) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
88 log.debug("OutputStateBase.setup");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
89 super.setup(configuration);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
90
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
91 this.queryODVID = Config.getStringXPath(configuration,"queryID-odv");
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 NodeList outputModeList = Config.getNodeSetXPath(configuration,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
94 "outputsModes/outputsMode");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
95 if (outputModeList != null) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
96 log.debug(outputModeList.getLength() + " were found.");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
97 this.outputModes = new ArrayList<OutputMode>(outputModeList
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
98 .getLength());
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
99 for (int i = 0; i < outputModeList.getLength(); i++) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
100 Element currentNode = (Element)outputModeList.item(i);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
101 String name = currentNode.getAttribute("name");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
102 String description =currentNode.getAttribute("description");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
103 String mimeType = currentNode.getAttribute("mime-type");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
104 NodeList inputValuesList = Config.getNodeSetXPath(currentNode,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
105 "parameters/inputvalue");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
106 Collection<InputValue> inputParameters = null;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
107 if (inputValuesList != null) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
108 inputParameters = new ArrayList<InputValue>(inputValuesList
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
109 .getLength());
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
110 for (int j = 0; j < inputValuesList.getLength(); j++) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
111 Element currentInputValuesNode = (Element)inputValuesList.item(j);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
112 String inputValueName = currentInputValuesNode.getAttribute("name");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
113 String inputValueType = currentInputValuesNode.getAttribute("type");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
114 String defaultValue =currentInputValuesNode.getAttribute("value");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
115 boolean isMultiselect = false;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
116 InputValue inputValue = new DefaultInputValue(
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
117 inputValueName, inputValueType, defaultValue,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
118 isMultiselect);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
119 inputParameters.add(inputValue);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
120 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
121 }
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 OutputMode outputMode = new DefaultOutputMode(name,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
124 description, mimeType, inputParameters);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
125 log.debug(outputMode.toString());
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
126 this.outputModes.add(outputMode);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
127
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
128 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
129 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
130 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
131
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
132 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
133 * @see de.intevation.gnv.state.StateBase#advance()
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
134 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
135 @Override
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
136 public void advance(String uuid, CallMeta callMeta)
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
137 throws StateException {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
138 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
139
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
140 @Override
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
141 public void initialize(String uuid, CallMeta callMeta)
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
142 throws StateException {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
143 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
144
480
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
145 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
146 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
147 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
148 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
149 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
150 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
151 )
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
152 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
153 {
335
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
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 * @see de.intevation.gnv.state.OutputState#out(java.lang.String,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
158 * java.util.Collection, java.io.OutputStream)
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
159 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
160 public void out(String outputMode, Collection<InputData> inputData,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
161 OutputStream outputStream) throws StateException {
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
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
164 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
165 * @return
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
166 */
439
8975de9d7483 Loop through configuration to chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 429
diff changeset
167 protected Object getChartResult(String uuid, CallContext callContext) {
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
168 log.debug("OutputStateBase.getChartResult");
439
8975de9d7483 Loop through configuration to chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 429
diff changeset
169 Object result = null;
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
170 if (CacheFactory.getInstance().isInitialized()) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
171 String key = uuid + super.getID();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
172 log.debug("Hash for Queryelements: " + key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
173 net.sf.ehcache.Element value = CacheFactory.getInstance().getCache().get(key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
174 if (value != null) {
439
8975de9d7483 Loop through configuration to chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 429
diff changeset
175 result = value.getObjectValue();
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
176 }else{
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
177 result = this.getData(this.queryID);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
178 if (CacheFactory.getInstance().isInitialized()) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
179 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
180 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
181
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
182 }
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 return result;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
185 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
186
439
8975de9d7483 Loop through configuration to chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 429
diff changeset
187 protected Object getChartFromCache(String uuid, CallContext callContext) {
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
188 log.debug("Fetch chart [" + uuid + "] from cache");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
189 CacheFactory cacheFactory = CacheFactory.getInstance();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
190 if (cacheFactory.isInitialized()) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
191 String key = "chart_" + uuid + super.getID();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
192 net.sf.ehcache.Element object = cacheFactory.getCache().get(key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
193
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
194 if (object != null) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
195 return object.getObjectValue();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
196 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
197 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
198 return null;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
199 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
200
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
201 protected Collection<Result> getODVResult(String uuid) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
202 log.debug("OutputStateBase.getODVResult");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
203 // TODO add Caching? I think it's not nessessary
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
204 Collection<Result> returnValue = null;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
205 if (this.queryODVID != null){
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
206 returnValue = this.getData(this.queryODVID);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
207 }else{
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
208 log.warn("No Query for ODV Data is defined.");
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 return returnValue;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
211 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
212
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
213 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
214 * @param returnValue
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
215 * @return
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
216 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
217 private Collection<Result> getData(String queryID) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
218 log.debug("OutputStateBase.getData");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
219 Collection<Result> returnValue = null;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
220 try {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
221 String[] filterValues = this.generateFilterValuesFromInputData();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
222 try {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
223 QueryExecutor queryExecutor = QueryExecutorFactory
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
224 .getInstance()
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
225 .getQueryExecutor();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
226 returnValue = queryExecutor.executeQuery(queryID,filterValues);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
227 } catch (RuntimeException e) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
228 log.error(e, e);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
229 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
230 } catch (QueryException e) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
231 log.error(e, e);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
232 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
233 return returnValue;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
234 }
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 protected void removeChartResult(String uuid) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
237 log.debug("OutputStateBase.getChartResult");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
238 if (CacheFactory.getInstance().isInitialized()) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
239 String key = uuid + super.getID();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
240 log.debug("Hash for Queryelements: " + key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
241 net.sf.ehcache.Element value = CacheFactory.getInstance().getCache().get(key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
242 if (value != null) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
243 CacheFactory.getInstance().getCache().remove(key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
244 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
245 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
246 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
247
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
248 protected void removeChart(String uuid) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
249 log.debug("OutputStateBase.removeChart from cache");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
250
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
251 CacheFactory cacheFactory = CacheFactory.getInstance();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
252 if (cacheFactory.isInitialized()) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
253 String key = "chart_" + uuid + super.getID();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
254 net.sf.ehcache.Element object = cacheFactory.getCache().get(key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
255 if (object != null)
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
256 cacheFactory.getCache().remove(key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
257 }
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 purifyChart(Object chart, String uuid) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
261 log.debug("Prufify chart [" + uuid + "]");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
262 CacheFactory cacheFactory = CacheFactory.getInstance();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
263 if (cacheFactory.isInitialized()) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
264 String key = "chart_" + uuid + getID();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
265 cacheFactory.getCache().put(new net.sf.ehcache.Element(key, chart));
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
266 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
267 }
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 * @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
271 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
272 @Override
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
273 public void putInputData(Collection<InputData> inputData,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
274 String uuid)
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
275 throws StateException {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
276 log.debug("OutputStateBase.putInputData");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
277 this.removeChartResult(uuid);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
278 this.removeChart(uuid);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
279 super.putInputData(inputData, uuid);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
280 }
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 public void out(String outputMode, Collection<InputData> inputData,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
283 OutputStream outputStream, String uuid, CallMeta callMeta)
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
284 throws StateException {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
285 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
286
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
287
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
288 protected String getMessage(Locale locale, String key, String value) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
289 return RessourceFactory.getInstance().getRessource(
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
290 locale,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
291 key,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
292 value
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
293 );
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
294 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
295 }

http://dive4elements.wald.intevation.org