# HG changeset patch # User Felix Wolfsteller # Date 1319792451 0 # Node ID a8aa343799a210d21b89d02265cc1edbd4f6ea99 # Parent 7d1bd710a4b3201808daf0257c24e91aceba8be6 Extracet getFlysContext from FLYSArtifact to FLYSUtils. flys-artifacts/trunk@3099 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 7d1bd710a4b3 -r a8aa343799a2 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Oct 28 08:52:46 2011 +0000 +++ b/flys-artifacts/ChangeLog Fri Oct 28 09:00:51 2011 +0000 @@ -3,6 +3,20 @@ * src/main/java/de/intevation/flys/exports/MapGenerator.java: Bugfix: Catch IOException - flys-artifacts compiles again. +2011-10-28 Felix Wolfsteller + + Extracted getFlysContext from FLYSArtifacts into FLYSUtils. + + * src/main/java/de/intevation/flys/utils/FLYSUtils.java + (getFlysContext): Added, extracted from FLYSArtifact. + + * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: + (getFlysContext): Moved to FLYSUtils, updated callers. + + * src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java, + src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java: + Update callers to getFlysContext. + 2011-10-28 Ingo Weinzierl * doc/conf/artifacts/winfo.xml: Defined "floodmap.barriers" as valid facet diff -r 7d1bd710a4b3 -r a8aa343799a2 flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java Fri Oct 28 08:52:46 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java Fri Oct 28 09:00:51 2011 +0000 @@ -95,7 +95,7 @@ dumpArtifact(); } - FLYSContext flysContext = getFlysContext(context); + FLYSContext flysContext = FLYSUtils.getFlysContext(context); StateEngine stateEngine = (StateEngine) flysContext.get( FLYSContext.STATE_ENGINE_KEY); @@ -159,7 +159,7 @@ ArtifactNamespaceContext.NAMESPACE_URI, ArtifactNamespaceContext.NAMESPACE_PREFIX); - FLYSContext flysContext = getFlysContext(context); + FLYSContext flysContext = FLYSUtils.getFlysContext(context); StateEngine engine = (StateEngine) flysContext.get( FLYSContext.STATE_ENGINE_KEY); diff -r 7d1bd710a4b3 -r a8aa343799a2 flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Fri Oct 28 08:52:46 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Fri Oct 28 09:00:51 2011 +0000 @@ -30,9 +30,10 @@ import de.intevation.flys.artifacts.context.FLYSContext; +import de.intevation.flys.artifacts.states.DefaultState; import de.intevation.flys.artifacts.states.DefaultState.ComputeType; -import de.intevation.flys.artifacts.states.DefaultState; +import de.intevation.flys.utils.FLYSUtils; import java.util.ArrayList; import java.util.Collection; @@ -126,19 +127,6 @@ return name; } - /** - * Returns the FLYSContext from context object. - * - * @param context The CallContext or the FLYSContext. - * - * @return the FLYSContext. - */ - protected static FLYSContext getFlysContext(Object context) { - return context instanceof FLYSContext - ? (FLYSContext) context - : (FLYSContext) ((CallContext) context).globalContext(); - } - /** * Initialize the artifact and insert new data if data contains @@ -161,7 +149,7 @@ super.setup(identifier, factory, context, callMeta, data); - FLYSContext flysContext = getFlysContext(context); + FLYSContext flysContext = FLYSUtils.getFlysContext(context); List states = getStates(context); @@ -465,7 +453,7 @@ * @return list of states. */ protected List getStates(Object context) { - FLYSContext flysContext = getFlysContext(context); + FLYSContext flysContext = FLYSUtils.getFlysContext(context); StateEngine engine = (StateEngine) flysContext.get( FLYSContext.STATE_ENGINE_KEY); return engine.getStates(getName()); @@ -479,7 +467,7 @@ * @return state with given ID. */ protected State getState(Object context, String stateID) { - FLYSContext flysContext = getFlysContext(context); + FLYSContext flysContext = FLYSUtils.getFlysContext(context); StateEngine engine = (StateEngine) flysContext.get( FLYSContext.STATE_ENGINE_KEY); return engine.getState(stateID); @@ -635,7 +623,7 @@ protected boolean isStateReachable(String stateId, Object context) { logger.debug("Determine if the state '" + stateId + "' is reachable."); - FLYSContext flysContext = getFlysContext(context); + FLYSContext flysContext = FLYSUtils.getFlysContext(context); State currentState = getCurrentState(context); StateEngine sEngine = (StateEngine) flysContext.get( diff -r 7d1bd710a4b3 -r a8aa343799a2 flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Fri Oct 28 08:52:46 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Fri Oct 28 09:00:51 2011 +0000 @@ -113,7 +113,7 @@ dumpArtifact(); } - FLYSContext flysContext = getFlysContext(context); + FLYSContext flysContext = FLYSUtils.getFlysContext(context); StateEngine stateEngine = (StateEngine) flysContext.get( FLYSContext.STATE_ENGINE_KEY); @@ -242,7 +242,7 @@ ArtifactNamespaceContext.NAMESPACE_URI, ArtifactNamespaceContext.NAMESPACE_PREFIX); - FLYSContext flysContext = getFlysContext(context); + FLYSContext flysContext = FLYSUtils.getFlysContext(context); StateEngine engine = (StateEngine) flysContext.get( FLYSContext.STATE_ENGINE_KEY); @@ -318,7 +318,7 @@ { List stateIds = getPreviousStateIds(); - FLYSContext flysContext = getFlysContext(context); + FLYSContext flysContext = FLYSUtils.getFlysContext(context); StateEngine engine = (StateEngine) flysContext.get( FLYSContext.STATE_ENGINE_KEY); diff -r 7d1bd710a4b3 -r a8aa343799a2 flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java --- a/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java Fri Oct 28 08:52:46 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java Fri Oct 28 09:00:51 2011 +0000 @@ -19,6 +19,7 @@ import de.intevation.artifacts.common.utils.Config; import de.intevation.artifacts.common.utils.XMLUtils; +import de.intevation.flys.artifacts.context.FLYSContext; import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.WINFOArtifact; import de.intevation.flys.artifacts.model.RiverFactory; @@ -84,6 +85,20 @@ /** + * Returns the FLYSContext from context object. + * + * @param context The CallContext or the FLYSContext. + * + * @return the FLYSContext. + */ + public static FLYSContext getFlysContext(Object context) { + return context instanceof FLYSContext + ? (FLYSContext) context + : (FLYSContext) ((CallContext) context).globalContext(); + } + + + /** * Convinience function to retrieve an XPath as string with replaced config * directory. *