comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java @ 337:a887074460b6

Last Step of the Refactoring Work on the Transition Model. Splitted Businesslogic between States and Transitions. Splitted the ConfigurationElements of State and Transition in several XML-Fragments. gnv-artifacts/trunk@403 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 08 Dec 2009 13:38:21 +0000
parents e964a3d8f7bc
children 88cd37c3b5e4
comparison
equal deleted inserted replaced
336:1b9ca0f2d498 337:a887074460b6
44 * @author Tim Englich <tim.englich@intevation.de> 44 * @author Tim Englich <tim.englich@intevation.de>
45 * 45 *
46 */ 46 */
47 public abstract class StateBase implements State { 47 public abstract class StateBase implements State {
48 48
49
50
51 /** 49 /**
52 * The UID of this Class 50 * The UID of this Class
53 */ 51 */
54 private static final long serialVersionUID = 2411169179001645426L; 52 private static final long serialVersionUID = 2411169179001645426L;
55 53
75 73
76 protected boolean dataNoSelect = false; 74 protected boolean dataNoSelect = false;
77 75
78 protected String queryID = null; 76 protected String queryID = null;
79 77
80 private Collection<String> reachableStates = null;
81
82 protected Collection<String> inputValueNames = null; 78 protected Collection<String> inputValueNames = null;
83 79
84 private Map<String, InputValue> inputValues = null; 80 private Map<String, InputValue> inputValues = null;
85 81
86 private State parent = null; 82 private State parent = null;
107 */ 103 */
108 public String getDescription() { 104 public String getDescription() {
109 return this.description; 105 return this.description;
110 } 106 }
111 107
112 /** 108
113 * @see de.intevation.gnv.state.State#reachableStates()
114 */
115 public Collection<String> reachableStates() {
116
117 if (this.couldAlternativeStateUsed()){
118 Iterator<String> it = this.reachableStates.iterator();
119 String transValue = null;
120 while (it.hasNext()){
121 transValue = it.next();
122 }
123 Collection<String> returnValue = new ArrayList<String>(1);
124 returnValue.add(transValue);
125 return returnValue;
126 }else{
127 return this.reachableStates;
128 }
129
130 }
131
132 /**
133 * @return
134 */
135 private boolean couldAlternativeStateUsed() {
136 // TODO das muss hier noch etwas freier gestaltet werden.
137 String key = this.dataName;
138 boolean returnValue=this.inputData != null &&
139 this.inputData.containsKey(key) &&
140 this.inputData.get(key).getValue().
141 equals(NODATASELECTIONKEY);
142 return returnValue;
143 }
144 109
145 /** 110 /**
146 * @see de.intevation.gnv.state.State#getRequiredInputValues() 111 * @see de.intevation.gnv.state.State#getRequiredInputValues()
147 */ 112 */
148 public Collection<InputValue> getRequiredInputValues() { 113 public Collection<InputValue> getRequiredInputValues() {
156 log.debug("StateBase.setup"); 121 log.debug("StateBase.setup");
157 this.id = ((Element)configuration).getAttribute("id"); 122 this.id = ((Element)configuration).getAttribute("id");
158 this.description = ((Element)configuration).getAttribute("description"); 123 this.description = ((Element)configuration).getAttribute("description");
159 124
160 log.info("State-ID = " + this.id); 125 log.info("State-ID = " + this.id);
161 NodeList nodes = Config.getNodeSetXPath(configuration,
162 "reachablestates/state");
163 this.reachableStates = new ArrayList<String>(nodes.getLength());
164 for (int i = 0; i < nodes.getLength(); i++) {
165 String reachableState = nodes.item(i).getTextContent();
166 log.info("ReachableState ==> " + reachableState);
167 this.reachableStates.add(reachableState);
168
169 }
170 126
171 NodeList inputValuesNodes = Config.getNodeSetXPath(configuration, 127 NodeList inputValuesNodes = Config.getNodeSetXPath(configuration,
172 "inputvalues/inputvalue"); 128 "inputvalues/inputvalue");
173 this.inputValues = new HashMap<String, InputValue>(inputValuesNodes 129 this.inputValues = new HashMap<String, InputValue>(inputValuesNodes
174 .getLength()); 130 .getLength());
388 return null; 344 return null;
389 345
390 } 346 }
391 347
392 /** 348 /**
393 * @see de.intevation.gnv.state.State#isStateReachable(java.lang.String)
394 */
395 public boolean isStateReachable(String stateID) {
396 log.debug("StateBase.isStateReachable");
397 boolean returnValue = false;
398 Iterator<String> states = reachableStates.iterator();
399 while (states.hasNext()) {
400 if (states.next().equals(stateID)) {
401 log.debug("State " + stateID + " wird unterstützt.");
402 returnValue = true;
403 break;
404 }
405 }
406 return returnValue;
407 }
408
409 /**
410 * @see de.intevation.gnv.state.State#advance(java.lang.String, 349 * @see de.intevation.gnv.state.State#advance(java.lang.String,
411 * de.intevation.artifacts.CallMeta) 350 * de.intevation.artifacts.CallMeta)
412 */ 351 */
413 public void advance(String uuid, CallMeta callMeta) 352 public void advance(String uuid, CallMeta callMeta)
414 throws StateException { 353 throws StateException {

http://dive4elements.wald.intevation.org