comparison 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
comparison
equal deleted inserted replaced
6139:7c2a30198592 6140:60b94dec104b
24 import org.w3c.dom.NodeList; 24 import org.w3c.dom.NodeList;
25 25
26 import org.dive4elements.artifactdatabase.Backend; 26 import org.dive4elements.artifactdatabase.Backend;
27 import org.dive4elements.artifactdatabase.Backend.PersistentArtifact; 27 import org.dive4elements.artifactdatabase.Backend.PersistentArtifact;
28 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; 28 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
29 import org.dive4elements.artifactdatabase.state.Facet;
29 import org.dive4elements.artifacts.Artifact; 30 import org.dive4elements.artifacts.Artifact;
30 import org.dive4elements.artifacts.ArtifactDatabase; 31 import org.dive4elements.artifacts.ArtifactDatabase;
31 import org.dive4elements.artifacts.ArtifactDatabaseException; 32 import org.dive4elements.artifacts.ArtifactDatabaseException;
32 import org.dive4elements.artifacts.CallContext; 33 import org.dive4elements.artifacts.CallContext;
33 import org.dive4elements.artifacts.CallMeta; 34 import org.dive4elements.artifacts.CallMeta;
73 log.debug("D4EArtifactCollection.doOut: " + outName); 74 log.debug("D4EArtifactCollection.doOut: " + outName);
74 } 75 }
75 76
76 ThemeList themeList = new ThemeList(attributes); 77 ThemeList themeList = new ThemeList(attributes);
77 78
78 int size = themeList.size();
79 if (debug) {
80 log.debug("Output will contain " + size + " elements.");
81 }
82
83 List<ArtifactAndFacet> dataProviders = 79 List<ArtifactAndFacet> dataProviders =
84 doBlackboardPass(themeList, context); 80 doBlackboardPass(themeList, context, outName);
85 81
86 try { 82 try {
87 for (int i = 0; i < size; i++) { 83 for (int i = 0; i < themeList.size(); i++) {
88 ManagedFacet theme = themeList.get(i); 84 ManagedFacet theme = themeList.get(i);
89 85
90 if (theme == null) { 86 if (theme == null) {
91 log.debug("Theme is empty - no output is generated."); 87 log.debug("Theme is empty - no output is generated.");
92 continue; 88 continue;
320 * ThemeList). 316 * ThemeList).
321 * @param themeList ThemeList to create a ArtifactAndFacetList along. 317 * @param themeList ThemeList to create a ArtifactAndFacetList along.
322 * @param context The "Blackboard". 318 * @param context The "Blackboard".
323 */ 319 */
324 protected List<ArtifactAndFacet> doBlackboardPass( 320 protected List<ArtifactAndFacet> doBlackboardPass(
325 ThemeList themeList, CallContext context 321 ThemeList themeList, CallContext context, String outname
326 ) { 322 ) {
327 ArrayList<ArtifactAndFacet> dataProviders = 323 ArrayList<ArtifactAndFacet> dataProviders =
328 new ArrayList<ArtifactAndFacet>(); 324 new ArrayList<ArtifactAndFacet>();
329 int size = themeList.size();
330 325
331 try { 326 try {
332 // Collect all ArtifactAndFacets for blackboard pass. 327 // Collect all ArtifactAndFacets for blackboard pass.
333 for (int i = 0; i < size; i++) { 328 for (int i = 0; i < themeList.size(); i++) {
329 log.debug("BLackboard pass for: " + outname);
334 ManagedFacet theme = themeList.get(i); 330 ManagedFacet theme = themeList.get(i);
335 if (theme == null) { 331 if (theme == null) {
336 log.warn("A ManagedFacet in ThemeList is null."); 332 log.warn("A ManagedFacet in ThemeList is null.");
333 themeList.remove(i);
334 i--;
337 continue; 335 continue;
338 } 336 }
337
339 String uuid = theme.getArtifact(); 338 String uuid = theme.getArtifact();
340 Artifact artifact = getArtifact(uuid, context); 339 Artifact artifact = getArtifact(uuid, context);
341 D4EArtifact flys = (D4EArtifact) artifact; 340 D4EArtifact flys = (D4EArtifact) artifact;
341 Facet face = flys.getNativeFacet(theme, outname);
342 log.debug("Looking for Native Facet for theme: " + theme + " and out: " +
343 outname + " in artifact: " + uuid +
344 face == null ? " Found. " : " Not Found. ");
345 if (face == null) {
346 log.warn("Theme " + theme.getName() + " for " + outname + " has no facets!. Removing theme.");
347 themeList.remove(i);
348 i--;
349 continue;
350 }
342 351
343 ArtifactAndFacet artifactAndFacet = new ArtifactAndFacet( 352 ArtifactAndFacet artifactAndFacet = new ArtifactAndFacet(
344 artifact, 353 artifact,
345 flys.getNativeFacet(theme)); 354 face);
346 355
347 // XXX HELP ME PLEASE 356 // XXX HELP ME PLEASE
348 artifactAndFacet.setFacetDescription(theme.getDescription()); 357 artifactAndFacet.setFacetDescription(theme.getDescription());
349 358
350 // Show blackboard to facet. 359 // Show blackboard to facet.
513 522
514 public ManagedFacet get(int idx) { 523 public ManagedFacet get(int idx) {
515 return themes.get(idx); 524 return themes.get(idx);
516 } 525 }
517 526
527 public void remove(int idx) {
528 themes.remove(idx);
529 }
530
518 public int size() { 531 public int size() {
519 return themes.size(); 532 return themes.size();
520 } 533 }
521 } 534 }
522 } 535 }

http://dive4elements.wald.intevation.org