Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/exports/OutputHelper.java @ 6140:60b94dec104b
Add handling of bound artifacts.
When an artifact is bound to an out its facets will only be shown
in that Out. They will be removed in the blackboard pass and marked
as incompatible by the AttributeWriter
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 31 May 2013 15:29:30 +0200 |
parents | af13ceeba52a |
children | 42856353a222 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/OutputHelper.java Fri May 31 15:27:06 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/OutputHelper.java Fri May 31 15:29:30 2013 +0200 @@ -26,6 +26,7 @@ import org.dive4elements.artifactdatabase.Backend; import org.dive4elements.artifactdatabase.Backend.PersistentArtifact; import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; +import org.dive4elements.artifactdatabase.state.Facet; import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.ArtifactDatabase; import org.dive4elements.artifacts.ArtifactDatabaseException; @@ -75,16 +76,11 @@ ThemeList themeList = new ThemeList(attributes); - int size = themeList.size(); - if (debug) { - log.debug("Output will contain " + size + " elements."); - } - List<ArtifactAndFacet> dataProviders = - doBlackboardPass(themeList, context); + doBlackboardPass(themeList, context, outName); try { - for (int i = 0; i < size; i++) { + for (int i = 0; i < themeList.size(); i++) { ManagedFacet theme = themeList.get(i); if (theme == null) { @@ -322,27 +318,40 @@ * @param context The "Blackboard". */ protected List<ArtifactAndFacet> doBlackboardPass( - ThemeList themeList, CallContext context + ThemeList themeList, CallContext context, String outname ) { ArrayList<ArtifactAndFacet> dataProviders = new ArrayList<ArtifactAndFacet>(); - int size = themeList.size(); try { // Collect all ArtifactAndFacets for blackboard pass. - for (int i = 0; i < size; i++) { + for (int i = 0; i < themeList.size(); i++) { + log.debug("BLackboard pass for: " + outname); ManagedFacet theme = themeList.get(i); if (theme == null) { log.warn("A ManagedFacet in ThemeList is null."); + themeList.remove(i); + i--; continue; } + String uuid = theme.getArtifact(); Artifact artifact = getArtifact(uuid, context); D4EArtifact flys = (D4EArtifact) artifact; + Facet face = flys.getNativeFacet(theme, outname); + log.debug("Looking for Native Facet for theme: " + theme + " and out: " + + outname + " in artifact: " + uuid + + face == null ? " Found. " : " Not Found. "); + if (face == null) { + log.warn("Theme " + theme.getName() + " for " + outname + " has no facets!. Removing theme."); + themeList.remove(i); + i--; + continue; + } ArtifactAndFacet artifactAndFacet = new ArtifactAndFacet( artifact, - flys.getNativeFacet(theme)); + face); // XXX HELP ME PLEASE artifactAndFacet.setFacetDescription(theme.getDescription()); @@ -515,6 +524,10 @@ return themes.get(idx); } + public void remove(int idx) { + themes.remove(idx); + } + public int size() { return themes.size(); }