changeset 3558:c3cd414982fe

Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities. flys-artifacts/trunk@5155 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 29 Jul 2012 11:39:39 +0000
parents f1f798b5f14a
children f9f266504f1d
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.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/collections/AttributeWriter.java
diffstat 5 files changed, 32 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Sun Jul 29 11:11:51 2012 +0000
+++ b/flys-artifacts/ChangeLog	Sun Jul 29 11:39:39 2012 +0000
@@ -1,3 +1,12 @@
+2012-07-29	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/collections/AttributeWriter.java,
+	  src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java:
+	  Refactored to use the new Chain-of-responsibility pattern in facet
+	  activation.
+
 2012-07-29	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/services/GaugeInfoService.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java	Sun Jul 29 11:11:51 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java	Sun Jul 29 11:39:39 2012 +0000
@@ -71,7 +71,7 @@
             CS_ARTIFACT_NAME,
             new FacetActivity() {
                 @Override
-                public boolean isInitialActive(
+                public Boolean isInitialActive(
                     Artifact artifact,
                     Facet    facet,
                     String   outputName
@@ -81,7 +81,7 @@
                         String data = flys.getDataAsString(DATA_IS_NEWEST);
                         return data != null && data.equals("1");
                     }
-                    return false;
+                    return null;
                 }
             });
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Sun Jul 29 11:11:51 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Sun Jul 29 11:39:39 2012 +0000
@@ -57,6 +57,23 @@
     protected transient State state = null;
 
 
+    static {
+        // TODO: Move to configuration.
+        FacetActivity.Registry.getInstance().register(
+            ARTIFACT_NAME,
+            new FacetActivity() {
+                @Override
+                public Boolean isInitialActive(
+                    Artifact artifact,
+                    Facet    facet,
+                    String   outputName
+                ) {
+                    return outputName.equals("computed_discharge_curve")
+                        || outputName.equals("duration_curve");
+                }
+            });
+    }
+
     /**
      * Trivial Constructor.
      */
@@ -316,22 +333,5 @@
         }
         return filteredList;
     }
-
-    static {
-        // TODO: Move to configuration.
-        FacetActivity.Registry.getInstance().register(
-            ARTIFACT_NAME,
-            new FacetActivity() {
-                @Override
-                public boolean isInitialActive(
-                    Artifact artifact,
-                    Facet    facet,
-                    String   outputName
-                ) {
-                    return outputName.equals("computed_discharge_curve")
-                        || outputName.equals("duration_curve");
-                }
-            });
-    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Sun Jul 29 11:11:51 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Sun Jul 29 11:39:39 2012 +0000
@@ -90,7 +90,7 @@
             ARTIFACT_NAME,
             new FacetActivity() {
                 @Override
-                public boolean isInitialActive(
+                public Boolean isInitialActive(
                     Artifact artifact,
                     Facet    facet,
                     String   outputName
@@ -99,7 +99,7 @@
                     if ((fname.equals(COMPUTED_DISCHARGE_MAINVALUES_Q)
                     ||   fname.equals(COMPUTED_DISCHARGE_MAINVALUES_W))
                     && outputName.equals("computed_discharge_curve")) {
-                        return false;
+                        return Boolean.FALSE;
                     }
                     return !StringUtils.contains(fname, INACTIVES);
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java	Sun Jul 29 11:11:51 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java	Sun Jul 29 11:39:39 2012 +0000
@@ -207,10 +207,8 @@
             FLYSArtifact flys =
                 (FLYSArtifact)db.getRawArtifact(newMF.getArtifact());
 
-            FacetActivity activity = registry.getActivity(flys.getName());
-
-            boolean isActive = activity.isInitialActive(
-                flys, newMF, outputName);
+            boolean isActive = registry.isInitialActive(
+                flys.getName(), flys, newMF, outputName);
 
             newMF.setActive(isActive ? 1 : 0);
         }

http://dive4elements.wald.intevation.org