diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java @ 944:c256061287d7

Simplified the code to read all provided Outputs of an Artifact. flys-artifacts/trunk@2357 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 18 Jul 2011 17:09:00 +0000
parents 796c54058dc4
children 7399401f728c
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Mon Jul 18 15:07:47 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Mon Jul 18 17:09:00 2011 +0000
@@ -1111,6 +1111,48 @@
     }
 
 
+    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<Output> generated = new ArrayList<Output>();
+
+        FLYSContext flysContext = getFlysContext(context);
+        StateEngine engine      = (StateEngine) flysContext.get(
+            FLYSContext.STATE_ENGINE_KEY);
+
+        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);
+        }
+
+
+        return generated;
+    }
+
+
     protected List<Output> generateOutputs(List<Output> list, List<Facet> fs) {
         List<Output> generated = new ArrayList<Output>();
 

http://dive4elements.wald.intevation.org