changeset 1050:eccf966fb677

State engine: Removed CallContext from state validation. flys-artifacts/trunk@2512 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 19 Aug 2011 14:10:18 +0000
parents 433559e25b50
children 9a77a9adbb36
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/MainValuesArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DGMSelect.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodplainChoice.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationSelect.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ProfileDistanceSelect.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RangeState.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java
diffstat 19 files changed, 59 insertions(+), 91 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/ChangeLog	Fri Aug 19 14:10:18 2011 +0000
@@ -1,3 +1,33 @@
+2011-08-19  Sascha L. Teichmann <sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/states/DefaultState.java:
+	  Removed CallContext from state validation. It is not needed and hindered
+	  the extraction of all out of an artifact if you don't have a
+	  call context (like initial scan of datacage database).
+
+	* src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java:
+	  Extract all outs now.
+
+	* src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java,
+	  src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/states/FloodplainChoice.java,
+	  src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java,
+	  src/main/java/de/intevation/flys/artifacts/states/DGMSelect.java,
+	  src/main/java/de/intevation/flys/artifacts/states/LocationSelect.java,
+	  src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java,
+	  src/main/java/de/intevation/flys/artifacts/states/ProfileDistanceSelect.java,
+	  src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java,
+	  src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java,
+	  src/main/java/de/intevation/flys/artifacts/states/DefaultState.java,
+	  src/main/java/de/intevation/flys/artifacts/states/WQSelect.java,
+	  src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java,
+	  src/main/java/de/intevation/flys/artifacts/states/RangeState.java,
+	  src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java,
+	  src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java:
+	  Adjusted calls.
+
 2011-08-19  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	* src/main/resources/messages.properties,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java	Fri Aug 19 14:10:18 2011 +0000
@@ -194,7 +194,7 @@
 
         try {
             DefaultState cur = (DefaultState) getCurrentState(context);
-            if (cur.validate(this, context)) {
+            if (cur.validate(this)) {
                 List<Output> list = cur.getOutputs();
                 if (list != null && list.size() > 0) {
                     logger.debug(
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Fri Aug 19 14:10:18 2011 +0000
@@ -471,7 +471,7 @@
         }
 
         DefaultState current = (DefaultState) getCurrentState(context);
-        current.validate(this, context);
+        current.validate(this);
     }
 
 
@@ -1121,7 +1121,7 @@
     }
 
 
-    public List<Output> getOutputs(CallContext context) {
+    public List<Output> getOutputs(Object context) {
         List<String> stateIds  = getPreviousStateIds();
         List<Output> generated = new ArrayList<Output>();
 
@@ -1140,11 +1140,11 @@
     }
 
 
-    public List<Output> getCurrentOutputs(CallContext context) {
+    public List<Output> getCurrentOutputs(Object context) {
         DefaultState cur = (DefaultState) getCurrentState(context);
 
         try {
-            if (cur.validate(this, context)) {
+            if (cur.validate(this)) {
                 return getOutputForState(cur);
             }
         }
@@ -1153,10 +1153,6 @@
         return new ArrayList<Output>();
     }
 
-    public List<Output> getCurrentOutputs(Object context) {
-        return getOutputForState((DefaultState)getCurrentState(context));
-    }
-
     protected List<Output> getOutputForState(DefaultState state) {
         List<Output> list = state.getOutputs();
         if (list == null || list.size() == 0) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Fri Aug 19 14:10:18 2011 +0000
@@ -153,7 +153,7 @@
 
         try {
             DefaultState cur = (DefaultState) getCurrentState(context);
-            if (cur.validate(this, context)) {
+            if (cur.validate(this)) {
                 List<Output> list = cur.getOutputs();
                 if (list != null && list.size() > 0) {
                     logger.debug(
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Fri Aug 19 14:10:18 2011 +0000
@@ -199,7 +199,7 @@
 
         try {
             DefaultState cur = (DefaultState) getCurrentState(context);
-            if (cur.validate(this, context)) {
+            if (cur.validate(this)) {
                 List<Output> list = cur.getOutputs();
                 if (list != null && list.size() > 0) {
                     logger.debug(
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Datacage.java	Fri Aug 19 14:10:18 2011 +0000
@@ -929,7 +929,7 @@
         final FLYSArtifact artifact,
         GlobalContext      context
     ) {
-        final List<Output> outs = artifact.getCurrentOutputs(context);
+        final List<Output> outs = artifact.getOutputs(context);
 
         if (outs.isEmpty()) {
             return;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java	Fri Aug 19 14:10:18 2011 +0000
@@ -113,7 +113,7 @@
 
 
     @Override
-    public boolean validate(Artifact artifact, CallContext context)
+    public boolean validate(Artifact artifact)
     throws IllegalArgumentException
     {
         logger.debug("CalculationSelect.validate");
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DGMSelect.java	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DGMSelect.java	Fri Aug 19 14:10:18 2011 +0000
@@ -13,14 +13,5 @@
     protected String getUIProvider() {
         return "datacage_panel";
     }
-
-
-    @Override
-    public boolean validate(Artifact artifact, CallContext context)
-    throws IllegalArgumentException
-    {
-        // TODO We have to check the user data if there is a real input!
-        return true;
-    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java	Fri Aug 19 14:10:18 2011 +0000
@@ -249,11 +249,10 @@
      * was correct, otherwise an exception is thrown.
      *
      * @param artifact A reference to the owner artifact.
-     * @param context The CallContext object.
      *
      * @return true, if everything was fine.
      */
-    public boolean validate(Artifact artifact, CallContext context)
+    public boolean validate(Artifact artifact)
     throws IllegalArgumentException
     {
         return true;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodplainChoice.java	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodplainChoice.java	Fri Aug 19 14:10:18 2011 +0000
@@ -59,14 +59,5 @@
 
         return item;
     }
-
-
-    @Override
-    public boolean validate(Artifact artifact, CallContext context)
-    throws IllegalArgumentException
-    {
-        // TODO We have to check the user data if there is a real input!
-        return true;
-    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java	Fri Aug 19 14:10:18 2011 +0000
@@ -44,7 +44,7 @@
 
 
     @Override
-    public boolean validate(Artifact artifact, CallContext context)
+    public boolean validate(Artifact artifact)
     throws IllegalArgumentException
     {
         logger.debug("LocationDistanceSelect.validate");
@@ -52,15 +52,15 @@
         FLYSArtifact flys = (FLYSArtifact) artifact;
 
         if (flys.isRange()) {
-            return super.validate(flys, context);
+            return super.validate(flys);
         }
         else {
-            return validateLocations(flys, context);
+            return validateLocations(flys);
         }
     }
 
 
-    protected boolean validateLocations(FLYSArtifact flys, CallContext context)
+    protected boolean validateLocations(FLYSArtifact flys)
     throws    IllegalArgumentException
     {
         StateData dValues = getData(flys, LOCATIONS);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationSelect.java	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationSelect.java	Fri Aug 19 14:10:18 2011 +0000
@@ -80,7 +80,7 @@
 
 
     @Override
-    public boolean validate(Artifact artifact, CallContext context)
+    public boolean validate(Artifact artifact)
     throws IllegalArgumentException
     {
         logger.debug("LocationSelect.validate");
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ProfileDistanceSelect.java	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ProfileDistanceSelect.java	Fri Aug 19 14:10:18 2011 +0000
@@ -13,14 +13,5 @@
     protected String getUIProvider() {
         return "auto_integer";
     }
-
-
-    @Override
-    public boolean validate(Artifact artifact, CallContext context)
-    throws IllegalArgumentException
-    {
-        // TODO We have to check the user data if there is a real input!
-        return true;
-    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RangeState.java	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RangeState.java	Fri Aug 19 14:10:18 2011 +0000
@@ -63,7 +63,7 @@
 
 
     @Override
-    public boolean validate(Artifact artifact, CallContext context)
+    public boolean validate(Artifact artifact)
     throws IllegalArgumentException
     {
         FLYSArtifact flys = (FLYSArtifact) artifact;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java	Fri Aug 19 14:10:18 2011 +0000
@@ -132,7 +132,7 @@
 
 
     @Override
-    public boolean validate(Artifact artifact, CallContext context)
+    public boolean validate(Artifact artifact)
     throws IllegalArgumentException
     {
         logger.debug("RiverSelect.validate");
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java	Fri Aug 19 14:10:18 2011 +0000
@@ -74,15 +74,5 @@
 
         return item;
     }
-
-
-    @Override
-    public boolean validate(Artifact artifact, CallContext context)
-    throws IllegalArgumentException
-    {
-        // TODO
-
-        return true;
-    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java	Fri Aug 19 14:10:18 2011 +0000
@@ -271,7 +271,7 @@
 
 
     @Override
-    public boolean validate(Artifact artifact, CallContext context)
+    public boolean validate(Artifact artifact)
     throws IllegalArgumentException
     {
         logger.debug("WQAdapted.validate");
@@ -282,10 +282,10 @@
         String mode = data != null ? (String) data.getValue() : null;
 
         if (mode != null && mode.equals("W")) {
-            return validateW(artifact, context);
+            return validateW(artifact);
         }
         else if (mode != null && mode.equals("Q")) {
-            return validateQ(artifact, context);
+            return validateQ(artifact);
         }
         else {
             throw new IllegalArgumentException("error_feed_no_wq_mode_selected");
@@ -293,7 +293,7 @@
     }
 
 
-    protected boolean validateW(Artifact artifact, CallContext context)
+    protected boolean validateW(Artifact artifact)
     throws IllegalArgumentException
     {
         logger.debug("WQAdapted.validateW");
@@ -323,7 +323,7 @@
     }
 
 
-    protected boolean validateQ(Artifact artifact, CallContext context)
+    protected boolean validateQ(Artifact artifact)
     throws IllegalArgumentException
     {
         logger.debug("WQAdapted.validateQ");
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java	Fri Aug 19 14:10:18 2011 +0000
@@ -200,7 +200,7 @@
 
 
     @Override
-    public boolean validate(Artifact artifact, CallContext context)
+    public boolean validate(Artifact artifact)
     throws IllegalArgumentException
     {
         logger.debug("WQSelect.validate");
@@ -211,10 +211,10 @@
         String selectionMode = data != null ? (String) data.getValue() : null;
 
         if (selectionMode == null || selectionMode.equals("single")) {
-            return validateSingle(artifact, context);
+            return validateSingle(artifact);
         }
         else {
-            return validateRange(artifact, context);
+            return validateRange(artifact);
         }
     }
 
@@ -241,7 +241,7 @@
     }
 
 
-    protected boolean validateSingle(Artifact artifact, CallContext context)
+    protected boolean validateSingle(Artifact artifact)
     throws    IllegalArgumentException
     {
         logger.debug("WQSelect.validateSingle");
@@ -293,7 +293,7 @@
     }
 
 
-    protected boolean validateRange(Artifact artifact, CallContext context)
+    protected boolean validateRange(Artifact artifact)
     throws    IllegalArgumentException
     {
         logger.debug("WQSelect.validateRange");
@@ -325,10 +325,10 @@
             double step = Double.parseDouble(stepStr);
 
             if (mode != null && mode.trim().toLowerCase().equals("w")) {
-                return validateW(artifact, context, from, to, step);
+                return validateW(artifact, from, to, step);
             }
             else if (mode != null && mode.trim().toLowerCase().equals("q")) {
-                return validateQ(artifact, context, from, to, step);
+                return validateQ(artifact, from, to, step);
             }
             else {
                 throw new IllegalArgumentException(
@@ -345,7 +345,6 @@
      * Validates the inserted W values.
      *
      * @param artifact The owner artifact.
-     * @param context The CallContext
      * @param from The lower value of the W range.
      * @param to The upper value of the W range.
      * @param step The step width.
@@ -354,7 +353,6 @@
      */
     protected boolean validateW(
         Artifact    artifact,
-        CallContext context,
         double from,
         double to,
         double step)
@@ -372,7 +370,6 @@
      * Validates the inserted Q values.
      *
      * @param artifact The owner artifact.
-     * @param context The CallContext
      * @param from The lower value of the Q range.
      * @param to The upper value of the Q range.
      * @param step The step width.
@@ -381,7 +378,6 @@
      */
     protected boolean validateQ(
         Artifact    artifact,
-        CallContext context,
         double from,
         double to,
         double step)
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java	Fri Aug 19 11:46:40 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java	Fri Aug 19 14:10:18 2011 +0000
@@ -34,22 +34,6 @@
     }
 
 
-    /**
-     * This method returns always true, because there is no data to validate.
-     *
-     * @param artifact The Artifact.
-     * @param context The CallContext.
-     *
-     * @return always true.
-     */
-    @Override
-    public boolean validate(Artifact artifact, CallContext context)
-    throws IllegalArgumentException
-    {
-        return true;
-    }
-
-
     @Override
     public Object computeAdvance(
         FLYSArtifact artifact,

http://dive4elements.wald.intevation.org