comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java @ 376:d8f3ef441bf2

merged gnv-artifacts/0.3
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:13:47 +0200
parents a887074460b6
children 88cd37c3b5e4
comparison
equal deleted inserted replaced
293:6b0ef2324d02 376:d8f3ef441bf2
1 /**
2 *
3 */
4 package de.intevation.gnv.state;
5
6 import java.util.ArrayList;
7 import java.util.Collection;
8 import java.util.Date;
9 import java.util.GregorianCalendar;
10 import java.util.HashMap;
11 import java.util.HashSet;
12 import java.util.Iterator;
13 import java.util.List;
14 import java.util.Map;
15 import java.util.Set;
16
17 import org.apache.log4j.Logger;
18 import org.w3c.dom.Document;
19 import org.w3c.dom.Element;
20 import org.w3c.dom.Node;
21 import org.w3c.dom.NodeList;
22
23 import de.intevation.artifactdatabase.Config;
24 import de.intevation.artifacts.CallMeta;
25 import de.intevation.gnv.artifacts.GNVArtifactBase;
26 import de.intevation.gnv.artifacts.cache.CacheFactory;
27 import de.intevation.gnv.artifacts.ressource.RessourceFactory;
28 import de.intevation.gnv.geobackend.base.Result;
29 import de.intevation.gnv.geobackend.base.query.QueryExecutor;
30 import de.intevation.gnv.geobackend.base.query.QueryExecutorFactory;
31 import de.intevation.gnv.geobackend.base.query.exception.QueryException;
32 import de.intevation.gnv.geobackend.util.DateUtils;
33 import de.intevation.gnv.state.describedata.DefaultKeyValueDescribeData;
34 import de.intevation.gnv.state.describedata.KeyValueDescibeData;
35 import de.intevation.gnv.state.describedata.MinMaxDescribeData;
36 import de.intevation.gnv.state.describedata.NamedArrayList;
37 import de.intevation.gnv.state.describedata.NamedCollection;
38 import de.intevation.gnv.state.describedata.SingleValueDescribeData;
39 import de.intevation.gnv.state.exception.StateException;
40 import de.intevation.gnv.utils.ArtifactXMLUtilities;
41 import de.intevation.gnv.utils.InputValidator;
42
43 /**
44 * @author Tim Englich <tim.englich@intevation.de>
45 *
46 */
47 public abstract class StateBase implements State {
48
49 /**
50 * The UID of this Class
51 */
52 private static final long serialVersionUID = 2411169179001645426L;
53
54 /**
55 * the logger, used to log exceptions and additonaly information
56 */
57 private static Logger log = Logger.getLogger(GNVArtifactBase.class);
58
59 private final static String MINVALUEFIELDNAME = "minvalue";
60 private final static String MAXVALUEFIELDNAME = "maxvalue";
61
62 private final static String NODATASELECTIONKEY = "n/n";
63
64 private final static String DESCRIBEDATAKEY = "_DESCRIBEDATA";
65
66 private String id = null;
67
68 private String description = null;
69
70 protected String dataName = null;
71
72 protected boolean dataMultiSelect = false;
73
74 protected boolean dataNoSelect = false;
75
76 protected String queryID = null;
77
78 protected Collection<String> inputValueNames = null;
79
80 private Map<String, InputValue> inputValues = null;
81
82 private State parent = null;
83
84 protected Map<String, InputData> inputData = null;
85
86
87 /**
88 * Constructor
89 */
90 public StateBase() {
91 super();
92 }
93
94 /**
95 * @see de.intevation.gnv.state.State#getID()
96 */
97 public String getID() {
98 return this.id;
99 }
100
101 /**
102 * @see de.intevation.gnv.state.State#getDescription()
103 */
104 public String getDescription() {
105 return this.description;
106 }
107
108
109
110 /**
111 * @see de.intevation.gnv.state.State#getRequiredInputValues()
112 */
113 public Collection<InputValue> getRequiredInputValues() {
114 return this.inputValues.values();
115 }
116
117 /**
118 * @see de.intevation.gnv.state.State#setup(org.w3c.dom.Node)
119 */
120 public void setup(Node configuration) {
121 log.debug("StateBase.setup");
122 this.id = ((Element)configuration).getAttribute("id");
123 this.description = ((Element)configuration).getAttribute("description");
124
125 log.info("State-ID = " + this.id);
126
127 NodeList inputValuesNodes = Config.getNodeSetXPath(configuration,
128 "inputvalues/inputvalue");
129 this.inputValues = new HashMap<String, InputValue>(inputValuesNodes
130 .getLength());
131 this.inputValueNames = new ArrayList<String>(inputValuesNodes
132 .getLength());
133 for (int i = 0; i < inputValuesNodes.getLength(); i++) {
134 Element inputValueNode = (Element)inputValuesNodes.item(i);
135 String usedinQueryValue = inputValueNode.getAttribute("usedinquery");
136 int usedinQuery = 1;
137 if (usedinQueryValue != null) {
138 try {
139 usedinQuery = Integer.parseInt(usedinQueryValue);
140 } catch (NumberFormatException e) {
141 log
142 .warn("Used in Query Value cannot be transformed into a Number");
143 }
144 }
145 InputValue inputValue = new DefaultInputValue(inputValueNode.getAttribute("name"),
146 inputValueNode.getAttribute("type"),
147 Boolean.parseBoolean(inputValueNode.
148 getAttribute("multiselect")), usedinQuery);
149 log.debug(inputValue.toString());
150 this.inputValues.put(inputValue.getName(), inputValue);
151 this.inputValueNames.add(inputValue.getName());
152 }
153
154 this.queryID = Config.getStringXPath(configuration, "queryID");
155 log.info("QueryID ==> " + this.queryID);
156
157 this.dataName = Config.getStringXPath(configuration, "dataname");
158
159 String dataMultiSelectValue = Config.getStringXPath(configuration,
160 "data-multiselect");
161 if (dataMultiSelectValue != null) {
162 this.dataMultiSelect = Boolean.parseBoolean(dataMultiSelectValue);
163 }
164
165 String dataNoSelectValue =Config.getStringXPath(configuration,
166 "data-noselect");
167 if (dataNoSelectValue != null) {
168 this. dataNoSelect = Boolean.parseBoolean(dataNoSelectValue);
169 }
170
171 }
172
173 /**
174 * @see de.intevation.gnv.state.State#getParent()
175 */
176 public State getParent() {
177 return this.parent;
178 }
179
180 /**
181 * @see de.intevation.gnv.state.State#setParent(de.intevation.gnv.state.State)
182 */
183 public void setParent(State state) {
184 this.parent = state;
185 }
186
187 /**
188 * @see de.intevation.gnv.state.State#putInputData(java.util.Collection)
189 */
190 public void putInputData(Collection<InputData> inputData, String uuid)
191 throws StateException {
192 log.debug("StateBase.putInputData");
193 if (inputData != null) {
194 Iterator<InputData> it = inputData.iterator();
195 InputValidator iv = new InputValidator();
196 while (it.hasNext()) {
197 InputData tmpItem = it.next();
198 InputValue inputValue = this.inputValues.get(tmpItem.getName());
199 if (inputValue != null) {
200 if (this.inputData == null) {
201 this.inputData = new HashMap<String, InputData>(
202 inputData.size());
203 }
204
205 boolean valid = iv.isInputValid(tmpItem.getValue(),
206 inputValue.getType());
207 if (valid) {
208 if (tmpItem.getName().equals(MINVALUEFIELDNAME)){
209 String minValue = tmpItem.getValue();
210 String maxValue = this.getInputValue4ID(inputData, MAXVALUEFIELDNAME);
211 valid = iv.isInputValid(maxValue,inputValue.getType());
212 if (!valid){
213 String errMsg = "Wrong input for " + tmpItem.getValue()
214 + " is not an " + inputValue.getType()
215 + " Value.";
216 log.warn(errMsg);
217 throw new StateException(errMsg);
218 }
219
220 valid = iv.isInputValid(minValue,
221 maxValue,
222 inputValue.getType());
223 if (!valid){
224 String errMsg = "MaxValue-Input is less than MinValue-Input ";
225 log.warn(errMsg);
226 throw new StateException(errMsg);
227 }
228 }else if (tmpItem.getName().equals(MAXVALUEFIELDNAME)){
229 String minValue = this.getInputValue4ID(inputData, MINVALUEFIELDNAME);
230 String maxValue = tmpItem.getValue();
231 valid = iv.isInputValid(minValue,inputValue.getType());
232 if (!valid){
233 String errMsg = "Wrong input for " + tmpItem.getValue()
234 + " is not an " + inputValue.getType()
235 + " Value.";
236 log.warn(errMsg);
237 throw new StateException(errMsg);
238 }
239
240 valid = iv.isInputValid(minValue,
241 maxValue,
242 inputValue.getType());
243 if (!valid){
244 String errMsg = "MaxValue-Input is less than MinValue-Input ";
245 log.warn(errMsg);
246 throw new StateException(errMsg);
247 }
248 }
249 this.setSelection(tmpItem, uuid);
250 this.inputData.put(tmpItem.getName(), tmpItem);
251 } else {
252 String errMsg = "Wrong input for " + tmpItem.getValue()
253 + " is not an " + inputValue.getType()
254 + " Value.";
255 log.warn(errMsg);
256 throw new StateException(errMsg);
257 }
258
259 } else {
260 String errMsg = "No Inputvalue given for Inputdata "
261 + tmpItem.getName();
262 log.warn(errMsg + "Value will be ignored");
263
264 }
265 }
266 } else {
267 log.warn("No Inputdata given");
268 }
269 }
270
271 private String getInputValue4ID(Collection<InputData> inputData, String inputName){
272 Iterator<InputData> it = inputData.iterator();
273 while (it.hasNext()) {
274 InputData tmpItem = it.next();
275 if (tmpItem.getName().equals(inputName)){
276 return tmpItem.getValue();
277 }
278 }
279 return null;
280 }
281
282 private void setSelection(InputData inputData, String uuid) {
283 log.debug("StateBase.setSelection");
284
285 Object o = this.getDescribeData(inputData.getName(),uuid);
286 if (o != null) {
287 if (o instanceof Collection<?>) {
288 Collection<KeyValueDescibeData> values = (Collection<KeyValueDescibeData>) o;
289
290 String value = inputData.getValue();
291 String[] selectedValues = value.split(",");
292 Set<String> selectedItems = new HashSet<String>(
293 selectedValues.length);
294 for (int i = 0; i < selectedValues.length; i++) {
295 selectedItems.add(selectedValues[i].trim());
296 }
297 // Selektion umsetzen
298 Iterator<KeyValueDescibeData> it = values.iterator();
299 while (it.hasNext()) {
300 KeyValueDescibeData data = it.next();
301 String key = "" + data.getKey();
302 boolean selected = selectedItems.contains(key);
303 data.setSelected(selected);
304 }
305 } else if (o instanceof MinMaxDescribeData) {
306 MinMaxDescribeData data = (MinMaxDescribeData) o;
307 if (inputData.getName().equals(MINVALUEFIELDNAME)) {
308 data.setMinValue(inputData.getValue());
309 }
310 if (inputData.getName().equals(MAXVALUEFIELDNAME)) {
311 data.setMaxValue(inputData.getValue());
312 }
313 } else if (o instanceof SingleValueDescribeData) {
314 ((SingleValueDescribeData)o).setValue(inputData.getValue());
315 }
316 }
317 }
318
319 private Object getDescribeData(String name, String uuid) {
320 log.debug("StateBase.getDescribeData");
321 Collection<Object> descibeData = this.getDescibeData(uuid);
322 if (descibeData != null) {
323 Iterator<Object> it = descibeData.iterator();
324 while (it.hasNext()) {
325 Object o = it.next();
326 if (o instanceof NamedCollection<?>) {
327 if (name.equals(((NamedCollection<?>) o).getName())) {
328 return o;
329 }
330 } else if (o instanceof MinMaxDescribeData) {
331 if (name.equals(((MinMaxDescribeData) o).getMinName())) {
332 return o;
333 }
334 if (name.equals(((MinMaxDescribeData) o).getMaxName())) {
335 return o;
336 }
337 }else if (o instanceof SingleValueDescribeData) {
338 if (name.equals(((SingleValueDescribeData)o).getName())){
339 return o;
340 }
341 }
342 }
343 }
344 return null;
345
346 }
347
348 /**
349 * @see de.intevation.gnv.state.State#advance(java.lang.String,
350 * de.intevation.artifacts.CallMeta)
351 */
352 public void advance(String uuid, CallMeta callMeta)
353 throws StateException {
354 }
355
356 public void initialize(String uuid, CallMeta callMeta)
357 throws StateException {
358 log.debug("StateBase.initialize");
359 try {
360 String[] filterValues = this
361 .generateFilterValuesFromInputData();
362 Collection<Result> result = null;
363 try {
364 if (this.queryID != null) {
365 QueryExecutor queryExecutor = QueryExecutorFactory
366 .getInstance().getQueryExecutor();
367 result = queryExecutor.executeQuery(this.queryID,
368 filterValues);
369 }
370 this.purifyResult(result, uuid);
371 } catch (RuntimeException e) {
372 log.error(e, e);
373 }
374 } catch (QueryException e) {
375 log.error(e, e);
376 throw new StateException(e);
377 }
378 }
379
380 /**
381 * @return
382 */
383 protected String[] generateFilterValuesFromInputData() {
384 List<String> list = new ArrayList<String>();
385 Iterator<String> it = this.inputValueNames.iterator();
386 while (it.hasNext()) {
387 String value = it.next();
388 InputData data = this.inputData.get(value);
389 if (data != null
390 && this.inputValues.containsKey(data.getName())) {
391 int size = this.inputValues.get(data.getName())
392 .usedInQueries();
393 String type = this.inputValues.get(data.getName())
394 .getType();
395 String requestValue = data.getValue();
396 if (type.equalsIgnoreCase("string")) {
397 requestValue = this
398 .prepareInputData4DBQuery(requestValue);
399 } else if (type.equalsIgnoreCase("date")) {
400 requestValue = this
401 .prepareInputData4DateDBQuery(requestValue);
402 } else if (type.equalsIgnoreCase("coordinate")){
403 requestValue = this
404 .prepareInputData4RegionDBQuery(requestValue);
405 }
406 for (int j = 0; j < size; j++) {
407 list.add(requestValue);
408 }
409 }
410 }
411 String[] filterValues = list.toArray(new String[0]);
412 return filterValues;
413 }
414
415 protected String prepareInputData4RegionDBQuery(String value){
416 return value;
417 }
418
419 private String prepareInputData4DateDBQuery(String value) {
420 log.debug("StateBase.prepareInputData4DateDBQuery");
421 if (value != null) {
422 String[] values = value.split(",");
423 String newValue = "";
424 for (int i = 0; i < values.length; i++) {
425 if (newValue.length() > 0) {
426 newValue = newValue + " , ";
427 }
428 // TODO JUST HACK FIND A BETTER RESOLUTION
429 newValue = newValue + "to_date('" + values[i].trim()
430 + "', 'YYYY.MM.DD HH24:MI:SS')";
431 }
432 return newValue;
433 }
434
435 return value;
436 }
437
438 private String prepareInputData4DBQuery(String value) {
439 log.debug("StateBase.prepareInputData4DBQuery");
440 if (value != null) {
441 String[] values = value.split(",");
442 String newValue = "";
443 for (int i = 0; i < values.length; i++) {
444 if (newValue.length() > 0) {
445 newValue = newValue + " , ";
446 }
447 newValue = newValue + "'" + values[i].trim() + "'";
448 }
449 return newValue;
450 }
451
452 return value;
453
454 }
455
456 /**
457 * @param result
458 */
459 protected void purifyResult(Collection<Result> result, String uuid) {
460 log.debug("StateBase.purifyResult");
461 Collection<Object> describeData = this.getDescibeData(uuid);
462 if (describeData == null) {
463 describeData = new ArrayList<Object>();
464 }
465 NamedCollection<KeyValueDescibeData> keyValueDescibeData = extractKVP(result, "KEY", "VALUE");
466 describeData.add(keyValueDescibeData);
467 this.setDescibeData(uuid, describeData);
468 }
469
470 /**
471 * @param result
472 * @return
473 */
474 protected NamedCollection<KeyValueDescibeData> extractKVP(Collection<Result> result,
475 String keyid,
476 String valueid) {
477 Iterator<Result> rit = result.iterator();
478 int dataSize = (this.dataNoSelect ? result.size()+1 : result.size());
479
480 NamedCollection<KeyValueDescibeData> keyValueDescibeData = new NamedArrayList<KeyValueDescibeData>(
481 this.dataName, dataSize);
482 keyValueDescibeData.setMultiSelect(this.dataMultiSelect);
483
484 if (this.dataNoSelect){
485 keyValueDescibeData.add(new DefaultKeyValueDescribeData(NODATASELECTIONKEY,
486 "No Selection"));
487 }
488 boolean initialized = false;
489 int keyPos= 0;
490 int valuePos = 1;
491 String previousKey = null;
492 while (rit.hasNext()) {
493 Result resultValue = rit.next();
494 if (!initialized){
495 keyPos = resultValue.getResultDescriptor().getColumnIndex(keyid);
496 valuePos = resultValue.getResultDescriptor().getColumnIndex(valueid);
497 if (valuePos < 0){
498 valuePos = 1;
499 }
500 initialized = true;
501 }
502 String tmpKey = resultValue.getString(keyPos);
503 // TODO: HACK da die ARCSDE kein DISTINCT auf räumlichen Anfragen unterstützt.
504 if (previousKey == null || !tmpKey.equals(previousKey)){
505 previousKey = tmpKey;
506 keyValueDescibeData.add(new DefaultKeyValueDescribeData(tmpKey, resultValue.getString(valuePos)));
507 }
508 }
509 return keyValueDescibeData;
510 }
511
512 /**
513 * @see de.intevation.gnv.state.State#describe(org.w3c.dom.Document,
514 * org.w3c.dom.Node, de.intevation.artifacts.CallMeta,
515 * java.lang.String)
516 */
517 public void describe(Document document, Node rootNode, CallMeta callMeta,String uuid) {
518 log.debug("StateBase.describe");
519 Collection<Object> descibeData = this.getDescibeData(uuid);
520 if (descibeData != null) {
521 ArtifactXMLUtilities xmlutilities = new ArtifactXMLUtilities();
522 Iterator<Object> it = descibeData.iterator();
523 Node staticNode = xmlutilities.createArtifactElement(document,
524 "static");
525 Node dynamic = xmlutilities.createArtifactElement(document,
526 "dynamic");
527 rootNode.appendChild(staticNode);
528 rootNode.appendChild(dynamic);
529 while (it.hasNext()) {
530
531 Object o = it.next();
532 if (o instanceof Collection<?>) {
533 String name = null;
534 boolean multiselect = false;
535 if (o instanceof NamedCollection<?>) {
536 NamedCollection<?> nc = ((NamedCollection<?>) o);
537 name = nc.getName();
538 multiselect = nc.isMultiSelect();
539 } else {
540 Object[] names = this.inputValueNames.toArray();
541 name = names[names.length - 1].toString();
542 }
543
544 Element selectNode = xmlutilities.createXFormElement(
545 document, multiselect ? "select" : "select1");
546 selectNode.setAttribute("ref", name);
547
548 Element lableNode = xmlutilities.createXFormElement(
549 document, "label");
550 lableNode.setTextContent(RessourceFactory.getInstance()
551 .getRessource(callMeta.getLanguages(), name, name));
552 Element choiceNode = xmlutilities.createXFormElement(
553 document, "choices");
554
555 Collection<KeyValueDescibeData> values = (Collection<KeyValueDescibeData>) o;
556 Iterator<KeyValueDescibeData> resultIt = values.iterator();
557 while (resultIt.hasNext()) {
558 KeyValueDescibeData result = resultIt.next();
559 Element itemNode = xmlutilities.createXFormElement(
560 document, "item");
561
562 if (result.isSelected()) {
563 itemNode.setAttribute("selected", "true");
564 }
565
566 Element choiceLableNode = xmlutilities
567 .createXFormElement(document, "label");
568 choiceLableNode.setTextContent(result.getValue());
569 itemNode.appendChild(choiceLableNode);
570
571 Element choicValueNode = xmlutilities
572 .createXFormElement(document, "value");
573 choicValueNode.setTextContent("" + result.getKey());
574 itemNode.appendChild(choicValueNode);
575 choiceNode.appendChild(itemNode);
576 }
577 selectNode.appendChild(lableNode);
578 selectNode.appendChild(choiceNode);
579
580 if (!it.hasNext() && this.dataName != null) {
581 dynamic.appendChild(selectNode);
582 } else {
583 staticNode.appendChild(selectNode);
584 }
585
586 } else if (o instanceof MinMaxDescribeData) {
587 MinMaxDescribeData minMaxDescibeData = (MinMaxDescribeData) o;
588 Object min = minMaxDescibeData.getMinValue();
589 Object max = minMaxDescibeData.getMaxValue();
590 if (min instanceof GregorianCalendar) {
591 Date d = ((GregorianCalendar) min).getTime();
592 min = DateUtils.getPatternedDateAmer(d);
593 }
594
595 if (max instanceof GregorianCalendar) {
596 Date d = ((GregorianCalendar) max).getTime();
597 max = DateUtils.getPatternedDateAmer(d);
598 }
599
600 Element groupNode = xmlutilities.createXFormElement(
601 document, "group");
602 groupNode.setAttribute("ref", minMaxDescibeData.getName());
603 Element groupNodeLableNode = xmlutilities
604 .createXFormElement(document, "label");
605 groupNodeLableNode.setTextContent(RessourceFactory
606 .getInstance().getRessource(
607 callMeta.getLanguages(),
608 minMaxDescibeData.getName(),
609 minMaxDescibeData.getName()));
610 groupNode.appendChild(groupNodeLableNode);
611
612 Element inputMinNode = xmlutilities.createXFormElement(
613 document, "input");
614 inputMinNode.setAttribute("ref", MINVALUEFIELDNAME);
615 Element inputMinLableNode = xmlutilities
616 .createXFormElement(document, "label");
617 inputMinLableNode.setTextContent(RessourceFactory
618 .getInstance().getRessource(
619 callMeta.getLanguages(), MINVALUEFIELDNAME,
620 MINVALUEFIELDNAME));
621 inputMinNode.appendChild(inputMinLableNode);
622
623 Element inputMinValueNode = xmlutilities
624 .createXFormElement(document, "value");
625 inputMinValueNode.setTextContent(min.toString());
626 inputMinNode.appendChild(inputMinValueNode);
627
628 Element inputMaxNode = xmlutilities.createXFormElement(
629 document, "input");
630 inputMaxNode.setAttribute("ref", MAXVALUEFIELDNAME);
631 Element inputMaxLableNode = xmlutilities
632 .createXFormElement(document, "label");
633 inputMaxLableNode.setTextContent(RessourceFactory
634 .getInstance().getRessource(
635 callMeta.getLanguages(), MAXVALUEFIELDNAME,
636 MAXVALUEFIELDNAME));
637 inputMaxNode.appendChild(inputMaxLableNode);
638
639 Element inputMaxValueNode = xmlutilities
640 .createXFormElement(document, "value");
641 inputMaxValueNode.setTextContent(max.toString());
642 inputMaxNode.appendChild(inputMaxValueNode);
643
644 groupNode.appendChild(inputMinNode);
645 groupNode.appendChild(inputMaxNode);
646
647 if (!it.hasNext() && this.dataName != null) {
648 dynamic.appendChild(groupNode);
649 } else {
650 staticNode.appendChild(groupNode);
651 }
652 } else if (o instanceof SingleValueDescribeData) {
653
654 SingleValueDescribeData svdb = (SingleValueDescribeData) o;
655
656 Element groupNode = xmlutilities.createXFormElement(
657 document, "group");
658 groupNode.setAttribute("ref", svdb.getName());
659 Element groupNodeLableNode = xmlutilities
660 .createXFormElement(document, "label");
661 groupNodeLableNode.setTextContent(RessourceFactory
662 .getInstance().getRessource(
663 callMeta.getLanguages(),
664 svdb.getName(),
665 svdb.getName()));
666 groupNode.appendChild(groupNodeLableNode);
667
668 Element inputNode = xmlutilities.createXFormElement(
669 document, "input");
670 inputNode.setAttribute("ref", svdb.getName());
671
672 Element inputLableNode = xmlutilities.createXFormElement(
673 document, "label");
674 inputLableNode.setTextContent("");
675 inputNode.appendChild(inputLableNode);
676
677 Element inputValueNode = xmlutilities.createXFormElement(
678 document, "value");
679 inputValueNode.setTextContent(svdb.getValue());
680 inputNode.appendChild(inputValueNode);
681
682 groupNode.appendChild(inputNode);
683 if (!it.hasNext() && this.dataName != null) {
684 dynamic.appendChild(groupNode);
685 } else {
686 staticNode.appendChild(groupNode);
687 }
688 }
689
690 }
691 }
692 }
693
694 /**
695 * @see de.intevation.gnv.state.State#getDescibeData()
696 */
697 protected Collection<Object> getDescibeData(String uuid) {
698 if (CacheFactory.getInstance().isInitialized()) {
699 String key = uuid + DESCRIBEDATAKEY;
700 log.debug("Hash for Queryelements: " + key);
701 net.sf.ehcache.Element value = CacheFactory.getInstance().getCache().get(key);
702 if (value != null) {
703 return (Collection<Object>) (value.getObjectValue());
704 }
705 }
706 return null;
707 }
708
709 /**
710 * @see de.intevation.gnv.state.State#getDescibeData()
711 */
712 protected void setDescibeData(String uuid, Collection<Object> describeData) {
713
714 if (CacheFactory.getInstance().isInitialized()) {
715 String key = uuid + DESCRIBEDATAKEY;
716 log.debug("Hash for Queryelements: " + key);
717 CacheFactory.getInstance().getCache().put(new net.sf.ehcache.Element(key, describeData));
718 }
719 }
720
721 /**
722 * @see de.intevation.gnv.state.State#getInputData()
723 */
724 public Collection<InputData> getInputData() throws StateException {
725 return this.inputData != null ? this.inputData.values() : null;
726 }
727 }

http://dive4elements.wald.intevation.org