diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java @ 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 c62ff9e72cea
children 376c81aa7d55
line wrap: on
line diff
--- 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(

http://dive4elements.wald.intevation.org