changeset 965:79251b1d47da

Modified the CollectionMonitor to recommend artifacts for the current state's outputs only. flys-artifacts/trunk@2385 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 21 Jul 2011 14:00:09 +0000
parents ff6ce301c472
children a63d79107289
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/CollectionMonitor.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java
diffstat 3 files changed, 48 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Jul 21 10:45:52 2011 +0000
+++ b/flys-artifacts/ChangeLog	Thu Jul 21 14:00:09 2011 +0000
@@ -1,3 +1,13 @@
+2011-07-21  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: Refactored
+	  the method that retrieves the Outputs for the Artifact. Now, we are able
+	  to query the Outputs for the current state, and all outputs separately.
+
+	* src/main/java/de/intevation/flys/artifacts/CollectionMonitor.java: The
+	  recommendations provided by this monitor will take the Outputs of the
+	  current state only into account.
+
 2011-07-21  Ingo Weinzierl <ingo@intevation.de>
 
 	* doc/conf/meta-data-template.xml: Added conditions for each output type.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/CollectionMonitor.java	Thu Jul 21 10:45:52 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/CollectionMonitor.java	Thu Jul 21 14:00:09 2011 +0000
@@ -69,7 +69,7 @@
         FLYSArtifact flys,
         CallContext  context)
     {
-        List<Output> outs = flys.getOutputs(context);
+        List<Output> outs = flys.getCurrentOutputs(context);
         String[]    names = new String[outs.size()];
 
         for (int i = 0, num = outs != null ? outs.size() : 0; i < num; i++) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Thu Jul 21 10:45:52 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Thu Jul 21 14:00:09 2011 +0000
@@ -1122,16 +1122,7 @@
 
 
     public List<Output> getOutputs(CallContext context) {
-        List<String> stateIds = getPreviousStateIds();
-
-        DefaultState cur = (DefaultState) getCurrentState(context);
-        try {
-            if (cur.validate(this, context)) {
-                stateIds.add(cur.getID());
-            }
-        }
-        catch (IllegalArgumentException iae) { }
-
+        List<String> stateIds  = getPreviousStateIds();
         List<Output> generated = new ArrayList<Output>();
 
         FLYSContext flysContext = getFlysContext(context);
@@ -1140,29 +1131,49 @@
 
         for (String stateId: stateIds) {
             DefaultState state = (DefaultState) engine.getState(stateId);
-
-            List<Output> list = state.getOutputs();
-            if (list == null || list.size() == 0) {
-                logger.debug("-> No output modes for this state.");
-                continue;
-            }
-
-            List<Facet>  fs = facets.get(stateId);
-            if (fs == null || fs.size() == 0) {
-                logger.debug("No facets found.");
-                continue;
-            }
-
-            List<Output> o = generateOutputs(list, fs);
-
-            generated.addAll(o);
+            generated.addAll(getOutputForState(context, state));
         }
 
+        generated.addAll(getCurrentOutputs(context));
 
         return generated;
     }
 
 
+    public List<Output> getCurrentOutputs(CallContext context) {
+        DefaultState cur = (DefaultState) getCurrentState(context);
+
+        try {
+            if (cur.validate(this, context)) {
+                return getOutputForState(context, cur);
+            }
+        }
+        catch (IllegalArgumentException iae) { }
+
+        return new ArrayList<Output>();
+    }
+
+
+    protected List<Output> getOutputForState(
+        CallContext  context,
+        DefaultState state)
+    {
+        List<Output> list = state.getOutputs();
+        if (list == null || list.size() == 0) {
+            logger.debug("-> No output modes for this state.");
+            return new ArrayList<Output>();
+        }
+
+        List<Facet>  fs = facets.get(state.getID());
+        if (fs == null || fs.size() == 0) {
+            logger.debug("No facets found.");
+            return new ArrayList<Output>();
+        }
+
+        return generateOutputs(list, fs);
+    }
+
+
     protected List<Output> generateOutputs(List<Output> list, List<Facet> fs) {
         List<Output> generated = new ArrayList<Output>();
 

http://dive4elements.wald.intevation.org