comparison gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionBase.java @ 57:f01592cd6419

Funktionalität Feed initial bereitgestellt. gnv-artifacts/trunk@39 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 08 Sep 2009 12:22:00 +0000
parents 737d8bf63701
children f31343d80d53
comparison
equal deleted inserted replaced
56:737d8bf63701 57:f01592cd6419
3 */ 3 */
4 package de.intevation.gnv.transition; 4 package de.intevation.gnv.transition;
5 5
6 import java.util.ArrayList; 6 import java.util.ArrayList;
7 import java.util.Collection; 7 import java.util.Collection;
8 import java.util.HashMap;
9 import java.util.Iterator;
10 import java.util.Map;
8 11
9 import org.apache.log4j.Logger; 12 import org.apache.log4j.Logger;
10 import org.w3c.dom.Document; 13 import org.w3c.dom.Document;
11 import org.w3c.dom.Node; 14 import org.w3c.dom.Node;
12 import org.w3c.dom.NodeList; 15 import org.w3c.dom.NodeList;
13 16
14 import de.intevation.artifactdatabase.Config; 17 import de.intevation.artifactdatabase.Config;
15 import de.intevation.gnv.artifacts.GNVArtifactBase; 18 import de.intevation.gnv.artifacts.GNVArtifactBase;
19 import de.intevation.gnv.transition.exception.TransitionException;
16 20
17 /** 21 /**
18 * @author Tim Englich <tim.englich@intevation.de> 22 * @author Tim Englich <tim.englich@intevation.de>
19 * 23 *
20 */ 24 */
32 36
33 protected String queryID = null; 37 protected String queryID = null;
34 38
35 private Collection<String> reachableTransitions = null; 39 private Collection<String> reachableTransitions = null;
36 40
37 private Collection<InputValue> inputValues = null; 41 private Collection<String> inputValueNames = null;
42
43 private Map<String,InputValue> inputValues = null;
38 44
39 private Transition parent = null; 45 private Transition parent = null;
46
47 private Collection<InputData> inputData = null;
40 /** 48 /**
41 * Constructor 49 * Constructor
42 */ 50 */
43 public TransitionBase() { 51 public TransitionBase() {
44 super(); 52 super();
67 75
68 /** 76 /**
69 * @see de.intevation.gnv.transition.Transition#getRequiredInputValues() 77 * @see de.intevation.gnv.transition.Transition#getRequiredInputValues()
70 */ 78 */
71 public Collection<InputValue> getRequiredInputValues() { 79 public Collection<InputValue> getRequiredInputValues() {
72 return this.inputValues; 80 return this.inputValues.values();
73 } 81 }
74 82
75 /** 83 /**
76 * @see de.intevation.gnv.transition.Transition#setup(org.w3c.dom.Node) 84 * @see de.intevation.gnv.transition.Transition#setup(org.w3c.dom.Node)
77 */ 85 */
89 this.reachableTransitions.add(reachableTransition); 97 this.reachableTransitions.add(reachableTransition);
90 98
91 } 99 }
92 100
93 NodeList inputValuesNodes = Config.getNodeSetXPath(configuration,"inputvalues/inputvalue"); 101 NodeList inputValuesNodes = Config.getNodeSetXPath(configuration,"inputvalues/inputvalue");
94 this.inputValues = new ArrayList<InputValue>(inputValuesNodes.getLength()); 102 this.inputValues = new HashMap<String,InputValue>(inputValuesNodes.getLength());
103 this.inputValueNames = new ArrayList<String>(inputValuesNodes.getLength());
95 for (int i = 0 ; i < inputValuesNodes.getLength(); i++){ 104 for (int i = 0 ; i < inputValuesNodes.getLength(); i++){
96 Node inputValueNode = inputValuesNodes.item(i); 105 Node inputValueNode = inputValuesNodes.item(i);
97 InputValue inputValue = new DefaultInputValue(Config.getStringXPath(inputValueNode,"@name"), Config.getStringXPath(inputValueNode,"@type")); 106 InputValue inputValue = new DefaultInputValue(Config.getStringXPath(inputValueNode,"@name"), Config.getStringXPath(inputValueNode,"@type"));
98 log.debug(inputValue.toString()); 107 log.debug(inputValue.toString());
99 this.inputValues.add(inputValue); 108 this.inputValues.put(inputValue.getName(),inputValue);
109 this.inputValueNames.add(inputValue.getName());
100 } 110 }
101 111
102 this.queryID = Config.getStringXPath(configuration,"queryID"); 112 this.queryID = Config.getStringXPath(configuration,"queryID");
103 log.info("QueryID ==>"+ this.queryID); 113 log.info("QueryID ==> "+ this.queryID);
104 114
105 } 115 }
106 116
107 /** 117 /**
108 * @see de.intevation.gnv.transition.Transition#getParent() 118 * @see de.intevation.gnv.transition.Transition#getParent()
115 * @see de.intevation.gnv.transition.Transition#setParent(de.intevation.gnv.transition.Transition) 125 * @see de.intevation.gnv.transition.Transition#setParent(de.intevation.gnv.transition.Transition)
116 */ 126 */
117 public void setParent(Transition transition) { 127 public void setParent(Transition transition) {
118 this.parent = transition; 128 this.parent = transition;
119 } 129 }
130
131 /**
132 * @see de.intevation.gnv.transition.Transition#putInputData(java.util.Collection)
133 */
134 public void putInputData(Collection<InputData> inputData) throws TransitionException {
135 log.debug("TransitionBase.putInputData");
136 if (inputData != null){
137 Iterator<InputData> it = inputData.iterator();
138 while(it.hasNext()){
139 InputData tmpItem = it.next();
140 InputValue inputValue = this.inputValues.get(tmpItem.getName());
141 if (inputValue != null){
142 if (this.inputData == null){
143 this.inputData = new ArrayList<InputData>(inputData.size());
144 // TODO validate Value;
145 this.inputData.add(tmpItem);
146 }
147
148 }else{
149 String errMsg = "No Inputvalue given for Inputdata "+ tmpItem.getName();
150 log.warn(errMsg+ "Value will be ignored");
151 throw new TransitionException(errMsg);
152
153 }
154 }
155 }else{
156 log.warn("No Inputdata given");
157 }
158
159 }
160
120 } 161 }

http://dive4elements.wald.intevation.org