changeset 1777:a8aa343799a2

Extracet getFlysContext from FLYSArtifact to FLYSUtils. flys-artifacts/trunk@3099 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 28 Oct 2011 09:00:51 +0000
parents 7d1bd710a4b3
children 5a1d59926a72
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java
diffstat 5 files changed, 40 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- 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	<felix.wolfsteller@intevation.de>
+
+	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 <ingo@intevation.de>
 
 	* doc/conf/artifacts/winfo.xml: Defined "floodmap.barriers" as valid facet
--- 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);
 
--- 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 <code>data</code> contains
@@ -161,7 +149,7 @@
 
         super.setup(identifier, factory, context, callMeta, data);
 
-        FLYSContext flysContext = getFlysContext(context);
+        FLYSContext flysContext = FLYSUtils.getFlysContext(context);
 
         List<State> states = getStates(context);
 
@@ -465,7 +453,7 @@
      * @return list of states.
      */
     protected List<State> 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(
--- 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<String> stateIds = getPreviousStateIds();
 
-        FLYSContext flysContext = getFlysContext(context);
+        FLYSContext flysContext = FLYSUtils.getFlysContext(context);
         StateEngine engine      = (StateEngine) flysContext.get(
             FLYSContext.STATE_ENGINE_KEY);
 
--- 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.
      *

http://dive4elements.wald.intevation.org