annotate gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputStateBase.java @ 1139:3a28fef65500

dummy merge for repo head
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:15:16 +0200
parents dec4257ad570
children
rev   line source
1115
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1060
diff changeset
1 /*
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1060
diff changeset
2 * Copyright (c) 2010 by Intevation GmbH
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1060
diff changeset
3 *
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1060
diff changeset
4 * This program is free software under the LGPL (>=v2.1)
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1060
diff changeset
5 * Read the file LGPL.txt coming with the software for details
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1060
diff changeset
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1060
diff changeset
7 */
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1060
diff changeset
8
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 package de.intevation.gnv.state;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11 import java.io.OutputStream;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12 import java.util.ArrayList;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13 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
14 import java.util.HashMap;
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
15 import java.util.Iterator;
626
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
16 import java.util.List;
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17 import java.util.Locale;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18
626
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
19 import javax.xml.xpath.XPathConstants;
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
20
631
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
21 import net.sf.ehcache.Cache;
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
22
480
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
23 import org.apache.log4j.Logger;
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 import org.w3c.dom.Document;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
25 import org.w3c.dom.Element;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26 import org.w3c.dom.Node;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 import org.w3c.dom.NodeList;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28
1117
dec4257ad570 Changed imports to fit new positions of XMLUtils and Config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1115
diff changeset
29 import de.intevation.artifacts.common.utils.Config;
dec4257ad570 Changed imports to fit new positions of XMLUtils and Config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1115
diff changeset
30 import de.intevation.artifacts.common.utils.XMLUtils;
818
8dc820099306 BUGFIX: Chartresults where stored in Cache using null-Value as Key.
Tim Englich <tim.englich@intevation.de>
parents: 815
diff changeset
31 import de.intevation.artifacts.CallContext;
8dc820099306 BUGFIX: Chartresults where stored in Cache using null-Value as Key.
Tim Englich <tim.englich@intevation.de>
parents: 815
diff changeset
32 import de.intevation.artifacts.CallMeta;
8dc820099306 BUGFIX: Chartresults where stored in Cache using null-Value as Key.
Tim Englich <tim.englich@intevation.de>
parents: 815
diff changeset
33 import de.intevation.gnv.artifacts.cache.CacheFactory;
8dc820099306 BUGFIX: Chartresults where stored in Cache using null-Value as Key.
Tim Englich <tim.englich@intevation.de>
parents: 815
diff changeset
34 import de.intevation.gnv.artifacts.ressource.RessourceFactory;
8dc820099306 BUGFIX: Chartresults where stored in Cache using null-Value as Key.
Tim Englich <tim.englich@intevation.de>
parents: 815
diff changeset
35 import de.intevation.gnv.geobackend.base.Result;
8dc820099306 BUGFIX: Chartresults where stored in Cache using null-Value as Key.
Tim Englich <tim.englich@intevation.de>
parents: 815
diff changeset
36 import de.intevation.gnv.geobackend.base.query.QueryExecutor;
8dc820099306 BUGFIX: Chartresults where stored in Cache using null-Value as Key.
Tim Englich <tim.englich@intevation.de>
parents: 815
diff changeset
37 import de.intevation.gnv.geobackend.base.query.QueryExecutorFactory;
8dc820099306 BUGFIX: Chartresults where stored in Cache using null-Value as Key.
Tim Englich <tim.englich@intevation.de>
parents: 815
diff changeset
38 import de.intevation.gnv.geobackend.base.query.exception.QueryException;
8dc820099306 BUGFIX: Chartresults where stored in Cache using null-Value as Key.
Tim Englich <tim.englich@intevation.de>
parents: 815
diff changeset
39 import de.intevation.gnv.state.describedata.MinMaxDescribeData;
8dc820099306 BUGFIX: Chartresults where stored in Cache using null-Value as Key.
Tim Englich <tim.englich@intevation.de>
parents: 815
diff changeset
40 import de.intevation.gnv.state.exception.StateException;
8dc820099306 BUGFIX: Chartresults where stored in Cache using null-Value as Key.
Tim Englich <tim.englich@intevation.de>
parents: 815
diff changeset
41 import de.intevation.gnv.utils.InputValidator;
8dc820099306 BUGFIX: Chartresults where stored in Cache using null-Value as Key.
Tim Englich <tim.englich@intevation.de>
parents: 815
diff changeset
42
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 /**
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
44 * This is the default implementation of <code>OutputState</code>. Artifacts
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
45 * having reached this state or a subclass of this state are able to produce
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
46 * some output (e.g. chart, histograms, statistic, etc).
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
47 *
780
c4156275c1e1 Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 779
diff changeset
48 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
c4156275c1e1 Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 779
diff changeset
49 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 725
diff changeset
50 *
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 */
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 725
diff changeset
52 public abstract class OutputStateBase
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 725
diff changeset
53 extends StateBase
480
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
54 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
55 {
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
56 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
57 "/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
58
639
a94ed2755480 Implemented SVG export for histograms.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 631
diff changeset
59 public static final String XPATH_EXPORT_MODE =
a94ed2755480 Implemented SVG export for histograms.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 631
diff changeset
60 "/art:action/art:out/art:export/@name";
a94ed2755480 Implemented SVG export for histograms.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 631
diff changeset
61
480
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
62 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
63 "/art:action/art:out/art:mime-type/@value";
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
64
626
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
65 public static final String XPATH_EXPORTS =
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
66 "exportModes/export";
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
67
335
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 * The UID of this Class
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 private static final long serialVersionUID = -1718732895737303823L;
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 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
74 * the logger, used to log exceptions and additonaly information
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 private static Logger log = Logger.getLogger(OutputStateBase.class);
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 /**
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
79 * The different Outputmodes which are provided by an OutputState
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
80 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
81 protected Collection<OutputMode> outputModes = null;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 725
diff changeset
82
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
83 protected String queryODVID = null;
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 * Constructor
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 public OutputStateBase() {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
89 super();
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
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
92 public Collection<OutputMode> getOutputModes() {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
93 log.debug("OutputStateBase.getOutputModes");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
94 return this.outputModes;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
95 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
96
815
22c18083225e Removed compiler warnings while JavaDoc generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
97
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
98 @Override
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
99 public void setup(Node configuration) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
100 log.debug("OutputStateBase.setup");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
101 super.setup(configuration);
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 725
diff changeset
102
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
103 this.queryODVID = Config.getStringXPath(configuration,"queryID-odv");
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 725
diff changeset
104
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
105 NodeList outputModeList = Config.getNodeSetXPath(configuration,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
106 "outputsModes/outputsMode");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
107 if (outputModeList != null) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
108 log.debug(outputModeList.getLength() + " were found.");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
109 this.outputModes = new ArrayList<OutputMode>(outputModeList
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
110 .getLength());
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
111 for (int i = 0; i < outputModeList.getLength(); i++) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
112 Element currentNode = (Element)outputModeList.item(i);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
113 String name = currentNode.getAttribute("name");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
114 String description =currentNode.getAttribute("description");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
115 String mimeType = currentNode.getAttribute("mime-type");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
116 NodeList inputValuesList = Config.getNodeSetXPath(currentNode,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
117 "parameters/inputvalue");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
118 Collection<InputValue> inputParameters = null;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
119 if (inputValuesList != null) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
120 inputParameters = new ArrayList<InputValue>(inputValuesList
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
121 .getLength());
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
122 for (int j = 0; j < inputValuesList.getLength(); j++) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
123 Element currentInputValuesNode = (Element)inputValuesList.item(j);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
124 String inputValueName = currentInputValuesNode.getAttribute("name");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
125 String inputValueType = currentInputValuesNode.getAttribute("type");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
126 String defaultValue =currentInputValuesNode.getAttribute("value");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
127 boolean isMultiselect = false;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
128 InputValue inputValue = new DefaultInputValue(
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
129 inputValueName, inputValueType, defaultValue,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
130 isMultiselect);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
131 inputParameters.add(inputValue);
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 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
134
626
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
135 // parse export modes
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
136 List<ExportMode> exportList = null;
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
137 NodeList exports = (NodeList) XMLUtils.xpath(
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
138 currentNode, XPATH_EXPORTS, XPathConstants.NODESET);
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 if (exports != null) {
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
141 int exportSize = exports.getLength();
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 exportList = new ArrayList<ExportMode>(exportSize);
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
144 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
145 Element exp = (Element) exports.item(k);
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
146 String expName = exp.getAttribute("name");
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
147 String expDesc = exp.getAttribute("description");
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
148 String expMime = exp.getAttribute("mime-type");
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
149
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
150 exportList.add(
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
151 new DefaultExportMode(expName, expDesc, expMime));
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
152 }
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
153 }
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
154
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
155 OutputMode outputMode = new DefaultOutputMode(name,
626
61f688a69a55 Split up export modes from output modes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 616
diff changeset
156 description, mimeType, inputParameters, exportList);
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
157 log.debug(outputMode.toString());
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
158 this.outputModes.add(outputMode);
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 }
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
815
22c18083225e Removed compiler warnings while JavaDoc generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
164
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
165 @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
166 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
167 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
168 {
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
169 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
170
815
22c18083225e Removed compiler warnings while JavaDoc generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
171
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
172 @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
173 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
174 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
175 {
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
176 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
177
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
178 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
179 * This method needs to be defined by concrete subclasses. Nothing is done
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
180 * here.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
181 */
480
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
182 public void out(
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 725
diff changeset
183 Document format,
480
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
184 Collection<InputData> inputData,
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 725
diff changeset
185 OutputStream outputStream,
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 725
diff changeset
186 String uuid,
480
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
187 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
188 )
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 725
diff changeset
189 throws StateException
480
211cad2fb5ba Rebased "Horizonalschnitte" to own state class to break from the not
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 439
diff changeset
190 {
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
191 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
192
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
193 /**
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
194 * This method needs to be defined by concrete subclasses. Nothing is done
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
195 * here.
335
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 public void out(String outputMode, Collection<InputData> inputData,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
198 OutputStream outputStream) throws StateException {
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 /**
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
202 * Returns the data used to create charts. If a cache is configured, try to
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
203 * fetch the data from cache. The database is queried if the data is not in
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
204 * cache yet, or if no cache is configured. If the cache is configured, but
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
205 * the data is not in cache yet, put it into cache for a faster access
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
206 * in a later time.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
207 *
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
208 * @param uuid The uuid of an artifact.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
209 * @param callContext The CallContext.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
210 * @return the chart data.
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
211 */
439
8975de9d7483 Loop through configuration to chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 429
diff changeset
212 protected Object getChartResult(String uuid, CallContext callContext) {
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
213 log.debug("OutputStateBase.getChartResult");
631
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
214 CacheFactory factory = CacheFactory.getInstance();
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
215
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
216 if (factory.isInitialized()) {
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
217 // we use a cache
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
218 log.info("Using cache.");
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
219 Cache cache = factory.getCache();
1060
cc4ec127d666 Remove the elements of an outdated state from cache if its endOfLife method is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1030
diff changeset
220 String key = "chart_" + getHash();
631
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
221
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
222 net.sf.ehcache.Element value = cache.get(key);
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
223 if (value != null) {
631
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
224 log.debug("Found element in cache.");
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
225 return value.getObjectValue();
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
226 }
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
227 else {
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
228 log.debug("Element not in cache, we need to ask the database");
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
229 Object result = getData(queryID);
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
230 cache.put(new net.sf.ehcache.Element(key, result));
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
231
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
232 return result;
335
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 }
631
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
235 else {
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
236 // we don't use a cache, so we have to query the database every
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
237 // single time
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
238 log.info("Not using a cache.");
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
239 return getData(queryID);
f4331a0df032 Chart and histogram output are working without using a cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 626
diff changeset
240 }
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
241 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
242
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
243 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
244 * This method should no longer be used, because it is not good to put a
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
245 * chart into cache. Parameter changes done by the user wouldn't be detected
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
246 * proper.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
247 * @deprecated
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
248 */
439
8975de9d7483 Loop through configuration to chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 429
diff changeset
249 protected Object getChartFromCache(String uuid, CallContext callContext) {
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
250 log.debug("Fetch chart [" + uuid + "] from cache");
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()) {
1060
cc4ec127d666 Remove the elements of an outdated state from cache if its endOfLife method is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1030
diff changeset
253 String key = "chart_" + getHash();
335
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
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
256 if (object != null) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
257 return object.getObjectValue();
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 return null;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
261 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 725
diff changeset
262
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
263 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
264 * Retrieves the data used to create an ODV export.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
265 *
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
266 * @param uuid
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
267 * @return odv data.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
268 */
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
269 protected Collection<Result> getODVResult(String uuid) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
270 log.debug("OutputStateBase.getODVResult");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
271 // TODO add Caching? I think it's not nessessary
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
272 Collection<Result> returnValue = null;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
273 if (this.queryODVID != null){
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
274 returnValue = this.getData(this.queryODVID);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
275 }else{
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
276 log.warn("No Query for ODV Data is defined.");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
277 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
278 return returnValue;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
279 }
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 /**
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
282 * Retrieve data from database with help of queryID.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
283 *
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
284 * @param queryID A query id defined in sql statements properties file.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
285 * @return some data.
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
286 */
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 610
diff changeset
287 protected Collection<Result> getData(String queryID) {
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
288 log.debug("OutputStateBase.getData");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
289 Collection<Result> returnValue = null;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
290 try {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
291 String[] filterValues = this.generateFilterValuesFromInputData();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
292 try {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
293 QueryExecutor queryExecutor = QueryExecutorFactory
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
294 .getInstance()
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
295 .getQueryExecutor();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
296 returnValue = queryExecutor.executeQuery(queryID,filterValues);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
297 } catch (RuntimeException e) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
298 log.error(e, e);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
299 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
300 } catch (QueryException e) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
301 log.error(e, e);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
302 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
303 return returnValue;
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
304 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 725
diff changeset
305
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
306 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
307 * This method removes the data used for creating charts from cache.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
308 *
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
309 */
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
310 protected void removeChartResult(String uuid) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
311 log.debug("OutputStateBase.getChartResult");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
312 if (CacheFactory.getInstance().isInitialized()) {
1060
cc4ec127d666 Remove the elements of an outdated state from cache if its endOfLife method is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1030
diff changeset
313 String key = "chart_" + getHash();
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
314 log.debug("Hash for Queryelements: " + key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
315 net.sf.ehcache.Element value = CacheFactory.getInstance().getCache().get(key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
316 if (value != null) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
317 CacheFactory.getInstance().getCache().remove(key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
318 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
319 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
320 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
321
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
322 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
323 * This method should no longer be used. It removes a chart from cache.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
324 *
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 796
diff changeset
325 * @deprecated
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
326 */
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
327 protected void removeChart(String uuid) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
328 log.debug("OutputStateBase.removeChart from cache");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
329
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
330 CacheFactory cacheFactory = CacheFactory.getInstance();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
331 if (cacheFactory.isInitialized()) {
1060
cc4ec127d666 Remove the elements of an outdated state from cache if its endOfLife method is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1030
diff changeset
332 String key = "chart_" + getHash();
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
333 net.sf.ehcache.Element object = cacheFactory.getCache().get(key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
334 if (object != null)
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
335 cacheFactory.getCache().remove(key);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
336 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
337 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
338
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
339 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
340 * This is an internal method used while database query.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
341 */
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
342 protected void purifyChart(Object chart, String uuid) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
343 log.debug("Prufify chart [" + uuid + "]");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
344 CacheFactory cacheFactory = CacheFactory.getInstance();
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
345 if (cacheFactory.isInitialized()) {
1060
cc4ec127d666 Remove the elements of an outdated state from cache if its endOfLife method is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1030
diff changeset
346 String key = "chart_" + getHash();
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
347 cacheFactory.getCache().put(new net.sf.ehcache.Element(key, chart));
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
348 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
349 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
350
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
351
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
352 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
353 * Use this method to feed a state with new data.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
354 */
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
355 @Override
725
dde7f51dbe1e Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 639
diff changeset
356 public Document feed(
dde7f51dbe1e Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 639
diff changeset
357 CallContext context,
dde7f51dbe1e Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 639
diff changeset
358 Collection<InputData> inputData,
dde7f51dbe1e Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 639
diff changeset
359 String uuid)
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
360 throws StateException
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
361 {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
362 putInputData(inputData, uuid);
725
dde7f51dbe1e Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 639
diff changeset
363
dde7f51dbe1e Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 639
diff changeset
364 return feedSuccess();
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
365 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
366
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
367 /**
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
368 * This method is used to put new data into a next state. The difference
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
369 * between this method and feed is, that this method should be used to
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
370 * transfer some old input data required by this state. New data need to be
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
371 * inserted via feed!
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
372 */
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
373 @Override
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 725
diff changeset
374 public void putInputData(Collection<InputData> inputData,
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
375 String uuid)
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
376 throws StateException {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
377 log.debug("OutputStateBase.putInputData");
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
378 this.removeChartResult(uuid);
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
379 this.removeChart(uuid);
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
380
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
381 if (inputData != null) {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
382 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
383 InputValidator iv = new InputValidator();
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
384 while (it.hasNext()) {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
385 InputData tmpItem = it.next();
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
386 Object tmpObj = tmpItem.getObject();
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
387 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
388 if (inputValue != null) {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
389 if (this.inputData == null) {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
390 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
391 inputData.size());
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
392 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
393
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
394 boolean valid = InputValidator.isInputValid(tmpItem.getValue(),
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
395 inputValue.getType());
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
396 if (valid) {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
397 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
398 String minValue = tmpItem.getValue();
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
399 String maxValue = getInputValue4ID(inputData, MAXVALUEFIELDNAME);
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
400 valid = InputValidator.isInputValid(maxValue,inputValue.getType());
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
401 if (!valid){
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
402 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
403 + " 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
404 + " Value.";
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
405 log.warn(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
406 throw new StateException(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
407 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
408
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
409 valid = InputValidator.isInputValid(minValue,
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
410 maxValue,
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
411 inputValue.getType());
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
412 if (!valid){
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
413 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
414 log.warn(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
415 throw new StateException(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
416 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
417 }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
418 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
419 String maxValue = tmpItem.getValue();
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
420 valid = InputValidator.isInputValid(minValue,inputValue.getType());
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
421 if (!valid){
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
422 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
423 + " 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
424 + " Value.";
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
425 log.warn(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
426 throw new StateException(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
427 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
428
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
429 valid = InputValidator.isInputValid(minValue,
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
430 maxValue,
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
431 inputValue.getType());
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
432 if (!valid){
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
433 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
434 log.warn(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
435 throw new StateException(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
436 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
437 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
438 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
439 } else {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
440 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
441 + " 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
442 + " Value.";
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
443 log.warn(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
444 throw new StateException(errMsg);
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
445 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
446
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 725
diff changeset
447 }
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
448 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
449 MinMaxDescribeData data = (MinMaxDescribeData) tmpObj;
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
450 if (this.inputData == null) {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
451 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
452 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
453 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
454 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
455 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
456 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
457 else {
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 725
diff changeset
458
610
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
459 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
460 + tmpItem.getName();
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
461 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
462
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
463 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
464 }
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
465 } else {
6484464d2059 Changed the mechanism for searching for specific parameter collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 493
diff changeset
466 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
467 }
818
8dc820099306 BUGFIX: Chartresults where stored in Cache using null-Value as Key.
Tim Englich <tim.englich@intevation.de>
parents: 815
diff changeset
468 setHash(uuid);
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
469 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
470
815
22c18083225e Removed compiler warnings while JavaDoc generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
471
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
472 public void out(
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
473 String outputMode,
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
474 Collection<InputData> inputData,
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
475 OutputStream outputStream,
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
476 String uuid,
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
477 CallMeta callMeta)
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
478 throws StateException { }
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
479
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
480
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
481 /**
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
482 * Retrieves a message from resource bundle specified by locale.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
483 *
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
484 * @param locale Locale to use.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
485 * @param key The key of the message.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
486 * @param value The default value.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
487 * @return The value.
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
488 */
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
489 protected String getMessage(Locale locale, String key, String value) {
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
490 return RessourceFactory.getInstance().getRessource(
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
491 locale,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
492 key,
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
493 value
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
494 );
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
495 }
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
496 }
796
a5526908f92f Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
497 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org