# HG changeset patch # User Felix Wolfsteller # Date 1322648318 0 # Node ID a584a26d5fdeb5581ff454cb0351357b616a2ea4 # Parent f2c14e09a8f12295da75a9955c75d042cad9ff26 Introduce pre-rendering inter-facet communication phase ('blackboard pass'). flys-artifacts/trunk@3336 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r f2c14e09a8f1 -r a584a26d5fde flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Wed Nov 30 10:13:16 2011 +0000 +++ b/flys-artifacts/ChangeLog Wed Nov 30 10:18:38 2011 +0000 @@ -1,3 +1,14 @@ +2011-11-30 Felix Wolfsteller + + Introduce pre-rendering inter-facet communication phase ('blackboard + pass'). + + * src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java + (doBlackboardPass): New. Before actually calling doOut, bundle + ArtifactAndFacets and let them register + themselfes as DataProvider in CallContext if they + want ("announce on blackboard"). + 2011-11-30 Felix Wolfsteller * src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java diff -r f2c14e09a8f1 -r a584a26d5fde flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java --- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java Wed Nov 30 10:13:16 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java Wed Nov 30 10:18:38 2011 +0000 @@ -30,6 +30,9 @@ import de.intevation.artifactdatabase.Backend; import de.intevation.artifactdatabase.Backend.PersistentArtifact; import de.intevation.artifactdatabase.DefaultArtifactCollection; +import de.intevation.artifactdatabase.state.ArtifactAndFacet; +import de.intevation.artifactdatabase.state.Blackboard; +import de.intevation.artifactdatabase.state.Facet; import de.intevation.artifactdatabase.state.StateEngine; import de.intevation.flys.artifacts.context.FLYSContext; @@ -46,7 +49,6 @@ * @author Ingo Weinzierl */ public class FLYSArtifactCollection extends DefaultArtifactCollection { - /** The logger used in this class. */ private static Logger log = Logger.getLogger(FLYSArtifactCollection.class); @@ -269,6 +271,9 @@ int size = themeList.size(); log.debug("Output will contain " + size + " elements."); + List dataProviders = + doBlackboardPass(themeList, context); + try { for (int i = 0; i < size; i++) { ManagedFacet theme = themeList.get(i); @@ -279,24 +284,20 @@ } String art = theme.getArtifact(); + String facetName = theme.getName(); if (log.isDebugEnabled()) { log.debug("Do output for..."); log.debug("... artifact: " + art); - log.debug("... facet: " + theme.getName()); + log.debug("... facet: " + facetName); } - String facetName = theme.getName(); - if (outName.equals("export") && !facetName.equals(facet)) { continue; } - Artifact artifact = getArtifact(art, context); - generator.doOut( - artifact, - theme, + dataProviders.get(i), getFacetThemeFromAttribute( art, outName, @@ -316,6 +317,44 @@ /** + * Show blackboard (context) to each facet and create a list of + * ArtifactAndFacets on the fly (with the same ordering as the passed + * ThemeList). + * @param themeList ThemeList to create a ArtifactAndFacetList along. + * @param contect The "Blackboard". + */ + protected List doBlackboardPass( + ThemeList themeList, CallContext context + ) { + ArrayList dataProviders = + new ArrayList(); + int size = themeList.size(); + + try { + // Collect all ArtifactAndFacets for blackboard pass. + for (int i = 0; i < size; i++) { + ManagedFacet theme = themeList.get(i); + String uuid = theme.getArtifact(); + Artifact artifact = getArtifact(uuid, context); + FLYSArtifact flys = (FLYSArtifact) artifact; + ArtifactAndFacet artifactAndFacet = new ArtifactAndFacet(artifact, + flys.getNativeFacet(theme)); + + // Show blackboard to facet. + artifactAndFacet.register(context); + + // Add to themes. + dataProviders.add(i, artifactAndFacet); + } + } + catch (ArtifactDatabaseException ade) { + log.error("ArtifactDatabaseException!", ade); + } + + return dataProviders; + } + + /** * @return masterartifact or null if exception/not found. */ protected FLYSArtifact getMasterArtifact(CallContext context)