# HG changeset patch # User Felix Wolfsteller # Date 1320233224 0 # Node ID 193a916d1ab54dcaa30e7752aa6581559f0af5da # Parent f6a190f6aaff2bebb4959f316fd280f4e4e3806b Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions. flys-artifacts/trunk@3139 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r f6a190f6aaff -r 193a916d1ab5 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Wed Nov 02 11:21:57 2011 +0000 +++ b/flys-artifacts/ChangeLog Wed Nov 02 11:27:04 2011 +0000 @@ -1,3 +1,14 @@ +2011-11-02 Felix Wolfsteller + + 1) Pass outputs name to artifacts getInitialFacetActivity(). + 2) Do not allow "gaps" in positions of facets in outputs in attributes + of collection (prevent e.g. positions 1,3,5; will become 1,2,3 + instead). + + * src/main/java/de/intevation/flys/collections/AttributeWriter.java: + Pass outputname to artifacts getInitialFacetActivity(), prevent + gaps in facets positions in outputs (1,3,10 become 1,2,3). + 2011-11-02 Felix Wolfsteller 1) Give Artifacts information about the out when they have to decide diff -r f6a190f6aaff -r 193a916d1ab5 flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java --- a/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java Wed Nov 02 11:21:57 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java Wed Nov 02 11:27:04 2011 +0000 @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.HashMap; import java.util.Map; import org.apache.log4j.Logger; @@ -162,7 +163,6 @@ List compatibleFacets) throws ArtifactDatabaseException { - if (compatibleFacets == null) { logger.warn("No compatible facets, not generating out."); return; @@ -198,6 +198,7 @@ for (ManagedFacet newMF: genuinelyNewFacets) { FLYSArtifact flys = (FLYSArtifact) db.getRawArtifact(newMF.getArtifact()); newMF.setActive(flys.getInitialFacetActivity( + output.getAttribute("name"), newMF.getName(), newMF.getIndex())); } @@ -221,6 +222,30 @@ currentFacets.add(newMF); } + // Fill/correct "gaps" (e.g. position 1,2,5 are taken, after gap filling + // expect positions 1,2,3 [5->3]) + // Preparations to be able to detect gaps. + Map mfmap = new HashMap(); + int max = 0; + for (ManagedFacet mf: currentFacets) { + int pos = mf.getPosition(); + mfmap.put(Integer.valueOf(pos), mf); + if (pos > max) max = pos; + } + + // Finally do gap correction. + if (max != currentFacets.size()) { + int gap = 0; + for (int i = 1; i <= max; i++) { + ManagedFacet mf = mfmap.get(Integer.valueOf(i)); + if (mf == null) { + gap++; + continue; + } + mf.setPosition(mf.getPosition() - gap); + } + } + // Now add all facets. for (ManagedFacet oldMF: currentFacets) { Node node = oldMF.toXML(doc);