Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/FLYSArtifact.java @ 5866:9a6741ccf6d4
FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Sun, 28 Apr 2013 15:14:30 +0200 |
parents | 73da40528cf2 |
children |
comparison
equal
deleted
inserted
replaced
5865:73da40528cf2 | 5866:9a6741ccf6d4 |
---|---|
49 import org.dive4elements.artifacts.Message; | 49 import org.dive4elements.artifacts.Message; |
50 import org.dive4elements.artifacts.common.ArtifactNamespaceContext; | 50 import org.dive4elements.artifacts.common.ArtifactNamespaceContext; |
51 import org.dive4elements.artifacts.common.utils.XMLUtils; | 51 import org.dive4elements.artifacts.common.utils.XMLUtils; |
52 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; | 52 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; |
53 import org.dive4elements.river.artifacts.cache.CacheFactory; | 53 import org.dive4elements.river.artifacts.cache.CacheFactory; |
54 import org.dive4elements.river.artifacts.context.FLYSContext; | 54 import org.dive4elements.river.artifacts.context.RiverContext; |
55 import org.dive4elements.river.artifacts.model.CalculationMessage; | 55 import org.dive4elements.river.artifacts.model.CalculationMessage; |
56 import org.dive4elements.river.artifacts.states.DefaultState; | 56 import org.dive4elements.river.artifacts.states.DefaultState; |
57 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; | 57 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
58 import org.dive4elements.river.utils.RiverUtils; | 58 import org.dive4elements.river.utils.RiverUtils; |
59 | 59 |
137 CallContext context, | 137 CallContext context, |
138 String uuid) | 138 String uuid) |
139 { | 139 { |
140 List<String> stateIds = getPreviousStateIds(); | 140 List<String> stateIds = getPreviousStateIds(); |
141 | 141 |
142 FLYSContext flysContext = RiverUtils.getFlysContext(context); | 142 RiverContext flysContext = RiverUtils.getFlysContext(context); |
143 StateEngine engine = (StateEngine) flysContext.get( | 143 StateEngine engine = (StateEngine) flysContext.get( |
144 FLYSContext.STATE_ENGINE_KEY); | 144 RiverContext.STATE_ENGINE_KEY); |
145 | 145 |
146 boolean debug = log.isDebugEnabled(); | 146 boolean debug = log.isDebugEnabled(); |
147 | 147 |
148 for (String stateId: stateIds) { | 148 for (String stateId: stateIds) { |
149 if (debug) { | 149 if (debug) { |
189 log.debug("Setup this artifact with the uuid: " + identifier); | 189 log.debug("Setup this artifact with the uuid: " + identifier); |
190 } | 190 } |
191 | 191 |
192 super.setup(identifier, factory, context, callMeta, data); | 192 super.setup(identifier, factory, context, callMeta, data); |
193 | 193 |
194 FLYSContext flysContext = RiverUtils.getFlysContext(context); | 194 RiverContext flysContext = RiverUtils.getFlysContext(context); |
195 | 195 |
196 List<State> states = getStates(context); | 196 List<State> states = getStates(context); |
197 | 197 |
198 String name = getName(); | 198 String name = getName(); |
199 | 199 |
445 log.debug( | 445 log.debug( |
446 "Describe: the current state is: " + getCurrentStateId()); | 446 "Describe: the current state is: " + getCurrentStateId()); |
447 dumpArtifact(); | 447 dumpArtifact(); |
448 } | 448 } |
449 | 449 |
450 FLYSContext flysContext = RiverUtils.getFlysContext(context); | 450 RiverContext flysContext = RiverUtils.getFlysContext(context); |
451 | 451 |
452 StateEngine stateEngine = (StateEngine) flysContext.get( | 452 StateEngine stateEngine = (StateEngine) flysContext.get( |
453 FLYSContext.STATE_ENGINE_KEY); | 453 RiverContext.STATE_ENGINE_KEY); |
454 | 454 |
455 TransitionEngine transitionEngine = (TransitionEngine) flysContext.get( | 455 TransitionEngine transitionEngine = (TransitionEngine) flysContext.get( |
456 FLYSContext.TRANSITION_ENGINE_KEY); | 456 RiverContext.TRANSITION_ENGINE_KEY); |
457 | 457 |
458 List<State> reachable = transitionEngine.getReachableStates( | 458 List<State> reachable = transitionEngine.getReachableStates( |
459 this, getCurrentState(context), stateEngine); | 459 this, getCurrentState(context), stateEngine); |
460 | 460 |
461 Document description = XMLUtils.newDocument(); | 461 Document description = XMLUtils.newDocument(); |
702 * Get list of existant states for this Artifact. | 702 * Get list of existant states for this Artifact. |
703 * @param context Contex to get StateEngine from. | 703 * @param context Contex to get StateEngine from. |
704 * @return list of states. | 704 * @return list of states. |
705 */ | 705 */ |
706 protected List<State> getStates(Object context) { | 706 protected List<State> getStates(Object context) { |
707 FLYSContext flysContext = RiverUtils.getFlysContext(context); | 707 RiverContext flysContext = RiverUtils.getFlysContext(context); |
708 StateEngine engine = (StateEngine) flysContext.get( | 708 StateEngine engine = (StateEngine) flysContext.get( |
709 FLYSContext.STATE_ENGINE_KEY); | 709 RiverContext.STATE_ENGINE_KEY); |
710 return engine.getStates(getName()); | 710 return engine.getStates(getName()); |
711 } | 711 } |
712 | 712 |
713 | 713 |
714 /** | 714 /** |
716 * @param context Context to get StateEngine from. | 716 * @param context Context to get StateEngine from. |
717 * @param stateID ID of state to get. | 717 * @param stateID ID of state to get. |
718 * @return state with given ID. | 718 * @return state with given ID. |
719 */ | 719 */ |
720 protected State getState(Object context, String stateID) { | 720 protected State getState(Object context, String stateID) { |
721 FLYSContext flysContext = RiverUtils.getFlysContext(context); | 721 RiverContext flysContext = RiverUtils.getFlysContext(context); |
722 StateEngine engine = (StateEngine) flysContext.get( | 722 StateEngine engine = (StateEngine) flysContext.get( |
723 FLYSContext.STATE_ENGINE_KEY); | 723 RiverContext.STATE_ENGINE_KEY); |
724 return engine.getState(stateID); | 724 return engine.getState(stateID); |
725 } | 725 } |
726 | 726 |
727 | 727 |
728 /** | 728 /** |
977 | 977 |
978 String uri = ArtifactNamespaceContext.NAMESPACE_URI; | 978 String uri = ArtifactNamespaceContext.NAMESPACE_URI; |
979 | 979 |
980 DefaultState current = (DefaultState) getCurrentState(context); | 980 DefaultState current = (DefaultState) getCurrentState(context); |
981 | 981 |
982 FLYSContext flysContext = RiverUtils.getFlysContext(context); | 982 RiverContext flysContext = RiverUtils.getFlysContext(context); |
983 StateEngine engine = (StateEngine) flysContext.get( | 983 StateEngine engine = (StateEngine) flysContext.get( |
984 FLYSContext.STATE_ENGINE_KEY); | 984 RiverContext.STATE_ENGINE_KEY); |
985 | 985 |
986 for (int i = 0; i < count; i++) { | 986 for (int i = 0; i < count; i++) { |
987 Element node = (Element)nodes.item(i); | 987 Element node = (Element)nodes.item(i); |
988 | 988 |
989 String name = node.getAttributeNS(uri, "name"); | 989 String name = node.getAttributeNS(uri, "name"); |
1029 | 1029 |
1030 if (log.isDebugEnabled()) { | 1030 if (log.isDebugEnabled()) { |
1031 log.debug("Determine if the state '" + stateId + "' is reachable."); | 1031 log.debug("Determine if the state '" + stateId + "' is reachable."); |
1032 } | 1032 } |
1033 | 1033 |
1034 FLYSContext flysContext = RiverUtils.getFlysContext(context); | 1034 RiverContext flysContext = RiverUtils.getFlysContext(context); |
1035 | 1035 |
1036 State currentState = getCurrentState(context); | 1036 State currentState = getCurrentState(context); |
1037 StateEngine sEngine = (StateEngine) flysContext.get( | 1037 StateEngine sEngine = (StateEngine) flysContext.get( |
1038 FLYSContext.STATE_ENGINE_KEY); | 1038 RiverContext.STATE_ENGINE_KEY); |
1039 | 1039 |
1040 TransitionEngine tEngine = (TransitionEngine) flysContext.get( | 1040 TransitionEngine tEngine = (TransitionEngine) flysContext.get( |
1041 FLYSContext.TRANSITION_ENGINE_KEY); | 1041 RiverContext.TRANSITION_ENGINE_KEY); |
1042 | 1042 |
1043 return tEngine.isStateReachable(this, stateId, currentState, sEngine); | 1043 return tEngine.isStateReachable(this, stateId, currentState, sEngine); |
1044 } | 1044 } |
1045 | 1045 |
1046 | 1046 |
1532 | 1532 |
1533 /** | 1533 /** |
1534 * Calls endOfLife() for each state in the list <i>ids</i>. | 1534 * Calls endOfLife() for each state in the list <i>ids</i>. |
1535 * | 1535 * |
1536 * @param ids The State IDs that should be destroyed. | 1536 * @param ids The State IDs that should be destroyed. |
1537 * @param context The FLYSContext. | 1537 * @param context The RiverContext. |
1538 */ | 1538 */ |
1539 protected void destroyStates(List<String> ids, Object context) { | 1539 protected void destroyStates(List<String> ids, Object context) { |
1540 for (int i = 0, num = ids.size(); i < num; i++) { | 1540 for (int i = 0, num = ids.size(); i < num; i++) { |
1541 destroyState(ids.get(i), context); | 1541 destroyState(ids.get(i), context); |
1542 } | 1542 } |