Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java @ 624:929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
flys-artifacts/trunk@1982 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 23 May 2011 15:11:55 +0000 |
parents | aa64fe4df8ab |
children | 833290f16f09 |
comparison
equal
deleted
inserted
replaced
623:aa64fe4df8ab | 624:929137ee8154 |
---|---|
368 | 368 |
369 addData(name, new DefaultStateData(name, null, null, value)); | 369 addData(name, new DefaultStateData(name, null, null, value)); |
370 } | 370 } |
371 } | 371 } |
372 | 372 |
373 State current = getCurrentState(context); | 373 DefaultState current = (DefaultState) getCurrentState(context); |
374 DefaultState toValidate = (DefaultState) fillState(current); | 374 current.validate(this, context); |
375 | |
376 toValidate.validate(this, context); | |
377 } | |
378 | |
379 | |
380 /** | |
381 * This method fills a state object with the data that have been inserted to | |
382 * this artifact. This is necessary to use the isStateReachable() method, | |
383 * because the Transitions need to know about the inserted data. | |
384 * | |
385 * @param state The state that needs to be filled with data. | |
386 * | |
387 * @return the filled state. | |
388 */ | |
389 protected State fillState(State state) { | |
390 Map<String, StateData> stateData = state.getData(); | |
391 | |
392 if (stateData == null) { | |
393 return state; | |
394 } | |
395 | |
396 Set<String> keys = stateData.keySet(); | |
397 | |
398 for (String key: keys) { | |
399 StateData tmp = getData(key); | |
400 | |
401 if (tmp != null) { | |
402 StateData data = stateData.get(key); | |
403 data.setValue(tmp.getValue()); | |
404 } | |
405 } | |
406 | |
407 return state; | |
408 } | 375 } |
409 | 376 |
410 | 377 |
411 /** | 378 /** |
412 * Determines if the state with the identifier <i>stateId</i> is reachable | 379 * Determines if the state with the identifier <i>stateId</i> is reachable |
422 protected boolean isStateReachable(String stateId, Object context) { | 389 protected boolean isStateReachable(String stateId, Object context) { |
423 logger.debug("Determine if the state '" + stateId + "' is reachable."); | 390 logger.debug("Determine if the state '" + stateId + "' is reachable."); |
424 | 391 |
425 FLYSContext flysContext = getFlysContext(context); | 392 FLYSContext flysContext = getFlysContext(context); |
426 | 393 |
427 State currentState = fillState(getCurrentState(context)); | 394 State currentState = getCurrentState(context); |
428 StateEngine sEngine = (StateEngine) flysContext.get( | 395 StateEngine sEngine = (StateEngine) flysContext.get( |
429 FLYSContext.STATE_ENGINE_KEY); | 396 FLYSContext.STATE_ENGINE_KEY); |
430 | 397 |
431 TransitionEngine tEngine = (TransitionEngine) flysContext.get( | 398 TransitionEngine tEngine = (TransitionEngine) flysContext.get( |
432 FLYSContext.TRANSITION_ENGINE_KEY); | 399 FLYSContext.TRANSITION_ENGINE_KEY); |