# HG changeset patch # User Sascha L. Teichmann # Date 1343559846 0 # Node ID afc7bfb4800b7bd7e4f44379055cd62f31a20d36 # Parent b1912514e0f57a57acac40064abe5b4f3e305a83 Use the new infrastructure to figure out if a facet should be initially active or not. flys-artifacts/trunk@5152 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r b1912514e0f5 -r afc7bfb4800b flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Sat Jul 28 21:48:15 2012 +0000 +++ b/flys-artifacts/ChangeLog Sun Jul 29 11:04:06 2012 +0000 @@ -1,3 +1,26 @@ +2012-07-29 Sascha L. Teichmann + + Use the new infrastructure to figure out if a facet should + be initially active or not. + + * src/main/java/de/intevation/flys/collections/AttributeWriter.java: + Uses the FacetActivity.Registry to look up the initial acitiviy. + + * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: + Do not use sub classing any more. + + * src/main/java/de/intevation/flys/artifacts/WaterlevelArtifact.java, + src/main/java/de/intevation/flys/artifacts/ManualPointsArtifact.java, + src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java, + src/main/java/de/intevation/flys/artifacts/WQKmsInterpolArtifact.java, + src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java, + src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java, + src/main/java/de/intevation/flys/artifacts/StaticWQKmsArtifact.java, + src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java, + src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java, + src/main/java/de/intevation/flys/artifacts/HYKArtifact.java: + Register to FacetActivity.Registry now. TODO: Make it configurable. + 2012-07-28 Sascha L. Teichmann * src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java, diff -r b1912514e0f5 -r afc7bfb4800b flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java Sat Jul 28 21:48:15 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java Sun Jul 29 11:04:06 2012 +0000 @@ -24,6 +24,7 @@ import de.intevation.flys.artifacts.states.StaticState; import de.intevation.artifactdatabase.state.Facet; +import de.intevation.artifactdatabase.state.FacetActivity; import de.intevation.artifactdatabase.state.State; import de.intevation.flys.utils.FLYSUtils; @@ -64,6 +65,26 @@ private static final Logger logger = Logger.getLogger(CrossSectionArtifact.class); + static { + // TODO: Move to configuration. + FacetActivity.Registry.getInstance().register( + CS_ARTIFACT_NAME, + new FacetActivity() { + @Override + public boolean isInitialActive( + Artifact artifact, + Facet facet, + String outputName + ) { + if (artifact instanceof FLYSArtifact) { + FLYSArtifact flys = (FLYSArtifact)artifact; + String data = flys.getDataAsString(DATA_IS_NEWEST); + return data != null && data.equals("1"); + } + return false; + } + }); + } /** Return given name. */ @Override @@ -320,22 +341,5 @@ return FastCrossSectionLineFactory .getCrossSectionLine(crossSection, km); } - - - /** - * Determines Facets initial disposition regarding activity (think of - * selection in Client ThemeList GUI). This will be checked one time - * when the facet enters a collections describe document. - * - * @param outputName Ignored. - * @param facetName Ignored. - * @param index Ignored. - * @return 0 if not active - */ - @Override - public int getInitialFacetActivity(String outputName, String facetName, int index) { - return (getDataAsString(DATA_IS_NEWEST) != null - && getDataAsString(DATA_IS_NEWEST).equals("1")) ? 1 : 0; - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r b1912514e0f5 -r afc7bfb4800b flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Sat Jul 28 21:48:15 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Sun Jul 29 11:04:06 2012 +0000 @@ -1502,27 +1502,5 @@ destroyStates(toDestroy, context); } - - - /** - * Determines Facets initial disposition regarding activity (think of - * selection in Client ThemeList GUI). This will be checked one time - * when the facet enters a collections describe document. - * - * @param facetName name of the facet. - * @param outputName name of the output. - * @param index index of the facet. - * - * @return 1 if wished to be initally active, 0 if not. FLYSArtifact - * defaults to "1". - */ - public int getInitialFacetActivity( - String outputName, - String facetName, - int index - ) - { - return 1; - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r b1912514e0f5 -r afc7bfb4800b flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java Sat Jul 28 21:48:15 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java Sun Jul 29 11:04:06 2012 +0000 @@ -182,24 +182,5 @@ res.toArray(new WQKms[res.size()]), new Calculation()); } - - - /** - * Determines Facets initial disposition regarding activity (think of - * selection in Client ThemeList GUI). This will be checked one time - * when the facet enters a collections describe document. - * - * @param facetName name of the facet. - * @param index index of the facet. - * @return 1 - all Facets enter activated. - */ - @Override - public int getInitialFacetActivity( - String outputName, - String facetName, - int index) - { - return 1; - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r b1912514e0f5 -r afc7bfb4800b flys-artifacts/src/main/java/de/intevation/flys/artifacts/HYKArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/HYKArtifact.java Sat Jul 28 21:48:15 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/HYKArtifact.java Sun Jul 29 11:04:06 2012 +0000 @@ -15,6 +15,7 @@ import de.intevation.flys.artifacts.states.DefaultState; import de.intevation.artifactdatabase.state.Facet; +import de.intevation.artifactdatabase.state.FacetActivity; /** @@ -35,6 +36,11 @@ private static final Logger logger = Logger.getLogger(HYKArtifact.class); + static { + // TODO: Move to configuration. + FacetActivity.Registry.getInstance() + .register(HYK_ARTIFACT_NAME, FacetActivity.INACTIVE); + } /** Return given name. */ @Override @@ -115,25 +121,5 @@ + state.getID() + ")."); } } - - - /** - * Determines Facets initial disposition regarding activity (think of - * selection in Client ThemeList GUI). This will be checked one time - * when the facet enters a collections describe document. - * - * @param facetName name of the facet. - * @param index index of the facet. - * - * @return Always 0. Hyk Data will enter plots inactive. - */ - @Override - public int getInitialFacetActivity( - String outputName, - String facetName, - int index) - { - return 0; - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r b1912514e0f5 -r afc7bfb4800b flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java Sat Jul 28 21:48:15 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java Sun Jul 29 11:04:06 2012 +0000 @@ -9,6 +9,7 @@ import de.intevation.artifactdatabase.data.DefaultStateData; import de.intevation.artifactdatabase.state.Facet; +import de.intevation.artifactdatabase.state.FacetActivity; import de.intevation.artifactdatabase.state.DefaultOutput; import de.intevation.artifactdatabase.state.State; @@ -316,34 +317,21 @@ return filteredList; } - - /** - * Determines Facets initial disposition regarding activity (think of - * selection in Client ThemeList GUI). This will be checked one time - * when the facet enters a collections describe document. - * - * @param facetName name of the facet. - * @param index index of the facet. - * @return 0 if not active - */ - @Override - public int getInitialFacetActivity( - String outputName, - String facetName, - int index) - { - logger.debug("MainValuesArtifact.active?: " - + outputName - + "/" - + facetName); - - if (outputName.equals("computed_discharge_curve") - || outputName.equals("duration_curve")) { - return 0; - } - else { - return 1; - } + static { + // TODO: Move to configuration. + FacetActivity.Registry.getInstance().register( + ARTIFACT_NAME, + new FacetActivity() { + @Override + public boolean isInitialActive( + Artifact artifact, + Facet facet, + String outputName + ) { + return outputName.equals("computed_discharge_curve") + || outputName.equals("duration_curve"); + } + }); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r b1912514e0f5 -r afc7bfb4800b flys-artifacts/src/main/java/de/intevation/flys/artifacts/ManualPointsArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/ManualPointsArtifact.java Sat Jul 28 21:48:15 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/ManualPointsArtifact.java Sun Jul 29 11:04:06 2012 +0000 @@ -146,23 +146,5 @@ List points = csl.getPoints(); return Lines.createWaterLines(points, getLine(index)); } - - /** - * Determines Facets initial disposition regarding activity (think of - * selection in Client ThemeList GUI). This will be checked one time - * when the facet enters a collections describe document. - * - * @param facetName name of the facet. - * @param index index of the facet. - * @return 0 if not active - */ - @Override - public int getInitialFacetActivity( - String outputName, - String facetName, - int index) - { - return 1; - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r b1912514e0f5 -r afc7bfb4800b flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java Sat Jul 28 21:48:15 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java Sun Jul 29 11:04:06 2012 +0000 @@ -1,21 +1,18 @@ package de.intevation.flys.artifacts; -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; - -import org.w3c.dom.Document; - -import java.awt.geom.Point2D; - +import de.intevation.artifactdatabase.state.DefaultOutput; import de.intevation.artifactdatabase.state.Facet; -import de.intevation.artifactdatabase.state.DefaultOutput; +import de.intevation.artifactdatabase.state.FacetActivity; import de.intevation.artifactdatabase.state.State; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.ArtifactFactory; import de.intevation.artifacts.CallMeta; + +import de.intevation.artifacts.common.utils.XMLUtils; + +import de.intevation.flys.artifacts.geom.Lines; + import de.intevation.flys.artifacts.math.Distance; import de.intevation.flys.artifacts.math.Linear; @@ -26,15 +23,20 @@ import de.intevation.flys.artifacts.model.WKmsFacet; import de.intevation.flys.artifacts.model.WKmsFactory; -import de.intevation.flys.artifacts.states.StaticState; import de.intevation.flys.artifacts.resources.Resources; -import de.intevation.artifacts.common.utils.XMLUtils; - -import de.intevation.flys.artifacts.geom.Lines; +import de.intevation.flys.artifacts.states.StaticState; import de.intevation.flys.model.FastCrossSectionLine; +import java.awt.geom.Point2D; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; + +import org.w3c.dom.Document; /** * Artifact to access additional "waterlevel"-type of data, like the height @@ -51,6 +53,14 @@ private static Logger logger = Logger.getLogger(StaticWKmsArtifact.class); + private static final String NAME = "staticwkms"; + + static { + // TODO: Move to configuration. + FacetActivity.Registry.getInstance() + .register(NAME, FacetActivity.INACTIVE); + } + public static final String STATIC_STATE_NAME = "state.additional_wkms.static"; @@ -70,6 +80,10 @@ logger.debug("StaticWKmsArtifact.StaticWKmsArtifact"); } + @Override + public String getName() { + return NAME; + } /** * Gets called from factory, to set things up. @@ -86,8 +100,11 @@ state = new StaticState(STATIC_STATE_NAME); + if (logger.isDebugEnabled()) { + logger.debug(XMLUtils.toString(data)); + } + List fs = new ArrayList(); - logger.debug(XMLUtils.toString(data)); String code = getDatacageIDValue(data); // TODO Go for JSON, one day. @@ -363,25 +380,5 @@ return Lines.createWaterLines(points, wAtKm); } - - - /** - * Determines Facets initial disposition regarding activity (think of - * selection in Client ThemeList GUI). This will be checked one time - * when the facet enters a collections describe document. - * - * @param facetName name of the facet. - * @param index index of the facet. - * - * @return Always 0. Static Data will enter plots inactive. - */ - @Override - public int getInitialFacetActivity( - String outputName, - String facetName, - int index) - { - return 0; - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r b1912514e0f5 -r afc7bfb4800b flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWQKmsArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWQKmsArtifact.java Sat Jul 28 21:48:15 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWQKmsArtifact.java Sun Jul 29 11:04:06 2012 +0000 @@ -8,6 +8,7 @@ import org.w3c.dom.Document; import de.intevation.artifactdatabase.state.Facet; +import de.intevation.artifactdatabase.state.FacetActivity; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.ArtifactFactory; @@ -41,6 +42,13 @@ public static final String STATIC_STATE_NAME = "state.additional_wqkms.static"; + private static final String NAME = "staticwqkms"; + + static { + // TODO: Move to configuration. + FacetActivity.Registry.getInstance() + .register(NAME, FacetActivity.INACTIVE); + } /** * Trivial Constructor. @@ -136,30 +144,10 @@ return res; } - - /** - * Determines Facets initial disposition regarding activity (think of - * selection in Client ThemeList GUI). This will be checked one time - * when the facet enters a collections describe document. - * - * @param facetName name of the facet. - * @param index index of the facet. - * - * @return Always 0. Static Data will enter plots inactive. - */ + /** Return specific name. */ @Override - public int getInitialFacetActivity( - String outputName, - String facetName, - int index) - { - return 0; - } - - - /** Return specific name. */ public String getName() { - return "staticwqkms"; + return NAME; } // TODO implement deepCopy. diff -r b1912514e0f5 -r afc7bfb4800b flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Sat Jul 28 21:48:15 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Sun Jul 29 11:04:06 2012 +0000 @@ -2,6 +2,10 @@ import de.intevation.artifactdatabase.data.StateData; +import de.intevation.artifactdatabase.state.Facet; +import de.intevation.artifactdatabase.state.FacetActivity; + +import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; import de.intevation.artifacts.common.utils.StringUtils; @@ -75,6 +79,33 @@ /** The default step width between the start end end kilometer. */ public static final double DEFAULT_KM_STEPS = 0.1; + private static final String [] INACTIVES = new String[] { + LONGITUDINAL_Q, + DURATION_Q + }; + + static { + // TODO: Move to configuration. + FacetActivity.Registry.getInstance().register( + ARTIFACT_NAME, + new FacetActivity() { + @Override + public boolean isInitialActive( + Artifact artifact, + Facet facet, + String outputName + ) { + String fname = facet.getName(); + if ((fname.equals(COMPUTED_DISCHARGE_MAINVALUES_Q) + || fname.equals(COMPUTED_DISCHARGE_MAINVALUES_W)) + && outputName.equals("computed_discharge_curve")) { + return false; + } + return !StringUtils.contains(fname, INACTIVES); + + } + }); + } /** * The default constructor. @@ -1144,40 +1175,6 @@ return values.toNativeArray(); } - - /** - * Determines Facets initial disposition regarding activity (think of - * selection in Client ThemeList GUI). This will be checked one time - * when the facet enters a collections describe document. - * - * @param facetName name of the facet. - * @param index index of the facet. - * @return 0 if not active - */ - @Override - public int getInitialFacetActivity(String outputName, String facetName, int index) { - - logger.debug("WINFOArtifact.active?: " - + outputName - + "/" - + facetName); - - if (facetName.equals(COMPUTED_DISCHARGE_MAINVALUES_Q) || - facetName.equals(COMPUTED_DISCHARGE_MAINVALUES_W) - && outputName.equals("computed_discharge_curve")) - { - return 0; - } - - return StringUtils.contains(facetName, INACTIVES) ? 0 : 1; - } - - private static final String [] INACTIVES = new String[] { - LONGITUDINAL_Q, - DURATION_Q - }; - - /** * Returns the WstValueTable of current river. */ diff -r b1912514e0f5 -r afc7bfb4800b flys-artifacts/src/main/java/de/intevation/flys/artifacts/WQKmsInterpolArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WQKmsInterpolArtifact.java Sat Jul 28 21:48:15 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WQKmsInterpolArtifact.java Sun Jul 29 11:04:06 2012 +0000 @@ -8,6 +8,7 @@ import org.w3c.dom.Document; import de.intevation.artifactdatabase.state.Facet; +import de.intevation.artifactdatabase.state.FacetActivity; import de.intevation.artifactdatabase.state.DefaultOutput; import de.intevation.artifactdatabase.state.State; @@ -45,6 +46,14 @@ public static final String STATIC_STATE_NAME = "state.additional_wqkms.interpol.static"; + private static final String NAME = "staticwqkmsinterpol"; + + static { + // TODO: Move to configuration. + FacetActivity.Registry.getInstance() + .register(NAME, FacetActivity.INACTIVE); + } + /** One and only state to be in. */ protected transient State state = null; @@ -57,6 +66,12 @@ } + @Override + public String getName() { + return NAME; + } + + /** * Gets called from factory, to set things up. */ @@ -263,25 +278,5 @@ Integer.parseInt(getDataAsString("col_pos")), Integer.parseInt(getDataAsString("wst_id"))); } - - - /** - * Determines Facets initial disposition regarding activity (think of - * selection in Client ThemeList GUI). This will be checked one time - * when the facet enters a collections describe document. - * - * @param facetName name of the facet. - * @param index index of the facet. - * - * @return Always 0. Static Data will enter plots inactive. - */ - @Override - public int getInitialFacetActivity( - String outputName, - String facetName, - int index) - { - return 0; - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r b1912514e0f5 -r afc7bfb4800b flys-artifacts/src/main/java/de/intevation/flys/artifacts/WaterlevelArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WaterlevelArtifact.java Sat Jul 28 21:48:15 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WaterlevelArtifact.java Sun Jul 29 11:04:06 2012 +0000 @@ -2,6 +2,7 @@ import de.intevation.artifactdatabase.state.DefaultFacet; import de.intevation.artifactdatabase.state.Facet; +import de.intevation.artifactdatabase.state.FacetActivity; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.ArtifactFactory; @@ -32,6 +33,11 @@ /** The name of the artifact. */ public static final String ARTIFACT_NAME = "waterlevel"; + static { + // TODO: Move to configuration. + FacetActivity.Registry.getInstance() + .register(ARTIFACT_NAME, FacetActivity.INACTIVE); + } /** * The default constructor. @@ -107,26 +113,5 @@ public String getName() { return ARTIFACT_NAME; } - - - /** - * Determines Facets initial disposition regarding activity (think of - * selection in Client ThemeList GUI). - * WaterlevelArtifact Facets should come to live "inactive" (always - * return 0). - * - * @param facetName name of the facet. - * @param index index of the facet. - * - * @return Always 0 to have Facets initial predisposition to "inactive". - */ - @Override - public int getInitialFacetActivity( - String outputName, - String facetName, - int index) - { - return 0; - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r b1912514e0f5 -r afc7bfb4800b flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java --- a/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java Sat Jul 28 21:48:15 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java Sun Jul 29 11:04:06 2012 +0000 @@ -11,6 +11,7 @@ import de.intevation.artifacts.ArtifactDatabaseException; import de.intevation.artifactdatabase.state.Facet; +import de.intevation.artifactdatabase.state.FacetActivity; import de.intevation.artifactdatabase.state.Output; import de.intevation.flys.artifacts.FLYSArtifact; @@ -90,11 +91,13 @@ * @return document with merged outputs as described. */ protected CollectionAttribute write() { + + boolean debug = logger.isDebugEnabled(); + for (Map.Entry entry: newAttr.entrySet()) { String outName = entry.getKey(); Output a = entry.getValue(); - Output exists = attribute.getOutput(outName); if (exists == null) { attribute.addOutput(outName, a); @@ -102,7 +105,7 @@ attribute.clearFacets(outName); - if (logger.isDebugEnabled()) { + if (debug) { logger.debug("Merge Output: " + outName); logger.debug(" old Facets: " + oldFacets.size()); logger.debug(" new Facets: " + newFacets.size()); @@ -153,10 +156,10 @@ * @return true if any facets are written to the out. */ protected boolean writeFacets( - String outputName, - List newFacets, - List oldFacets, - List compatibleFacets) + String outputName, + List newFacets, + List oldFacets, + List compatibleFacets) throws ArtifactDatabaseException { if (compatibleFacets == null) { @@ -171,10 +174,14 @@ List currentFacets = new ArrayList(); List genuinelyNewFacets = new ArrayList(); + boolean debug = logger.isDebugEnabled(); + for (int i = 0; i < num; i++) { ManagedFacet facet = (ManagedFacet) newFacets.get(i); - logger.debug("Try to add Facet: " + facet.getName()); + if (debug) { + logger.debug("Try to add Facet: " + facet.getName()); + } if (!compatibleFacets.contains(facet.getName())) { //logger.debug("Have incompatible facet, skip: " + facet.getName()); @@ -192,14 +199,20 @@ } } - // With each genuinely new Facet, ask Artifact whether it comes to live + FacetActivity.Registry registry = FacetActivity.Registry.getInstance(); + + // With each genuinely new Facet, figure out whether it comes to live // in/activate. for (ManagedFacet newMF: genuinelyNewFacets) { - FLYSArtifact flys = (FLYSArtifact) db.getRawArtifact(newMF.getArtifact()); - newMF.setActive(flys.getInitialFacetActivity( - outputName, - newMF.getName(), - newMF.getIndex())); + FLYSArtifact flys = + (FLYSArtifact)db.getRawArtifact(newMF.getArtifact()); + + FacetActivity activity = registry.getActivity(flys.getName()); + + boolean isActive = activity.isInitialActive( + flys, newMF, outputName); + + newMF.setActive(isActive ? 1 : 0); } // For each genuinely new Facet check positional conflicts. @@ -211,8 +224,12 @@ for (ManagedFacet oldMF: currentFacets) { if (newMF.getPosition() == oldMF.getPosition()) { conflicts = true; - logger.debug("Positional conflict while merging " + - "facets, pushing newest facet 1 up (" + newMF.getPosition() + ")"); + if (debug) { + logger.debug( + "Positional conflict while merging " + + "facets, pushing newest facet 1 up (" + + newMF.getPosition() + ")"); + } newMF.setPosition(newMF.getPosition() + 1); break; } @@ -224,7 +241,8 @@ // 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(); + Map mfmap = + new HashMap(); int max = 0; for (ManagedFacet mf: currentFacets) { int pos = mf.getPosition(); @@ -250,7 +268,7 @@ attribute.addFacet(outputName, oldMF); } - return currentFacets.size() > 0; + return !currentFacets.isEmpty(); }