# HG changeset patch # User Raimund Renkert # Date 1370935214 -7200 # Node ID ea622501087128cf2aa4c25b6ecc2da54f9c9913 # Parent 83a04004969f242a9b811bfdb706d8134fabf8ee Set facet activity, have the correct facet order and added new facet to bed quality. diff -r 83a04004969f -r ea6225010871 artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java Tue Jun 11 09:18:30 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java Tue Jun 11 09:20:14 2013 +0200 @@ -15,6 +15,8 @@ import org.apache.log4j.Logger; import org.dive4elements.artifactdatabase.state.Facet; +import org.dive4elements.artifactdatabase.state.FacetActivity; +import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallContext; import org.dive4elements.artifacts.CallMeta; import org.dive4elements.river.artifacts.D4EArtifact; @@ -32,6 +34,7 @@ import org.dive4elements.river.artifacts.model.minfo.BedQualityCalculation; import org.dive4elements.river.artifacts.model.minfo.BedQualityDiameterResult; import org.dive4elements.river.artifacts.model.minfo.BedQualityResult; +import org.dive4elements.river.artifacts.model.minfo.BedloadDiameterDataFacet; import org.dive4elements.river.artifacts.model.minfo.BedloadDiameterFacet; import org.dive4elements.river.artifacts.model.minfo.BedloadDiameterResult; import org.dive4elements.river.artifacts.resources.Resources; @@ -59,6 +62,32 @@ public static final String I18N_FACET_BEDLOAD_DIAMETER_DATA = "facet.bedquality.bedload.diameter.data"; public static final String I18N_FACET_BEDLOAD_DIAMETER = "facet.bedquality.bedload.diameter"; + static { + // Active/deactivate facets. + FacetActivity.Registry.getInstance().register( + "minfo", + new FacetActivity() { + @Override + public Boolean isInitialActive( + Artifact artifact, + Facet facet, + String output + ) { + String name = facet.getName(); + if (name.equals(BED_QUALITY_SEDIMENT_DENSITY_TOPLAYER) || + name.equals(BED_QUALITY_SEDIMENT_DENSITY_SUBLAYER) || + name.equals(BED_DIAMETER_DATA_TOP) || + name.equals(BED_DIAMETER_DATA_SUB) || + name.equals(BEDLOAD_DIAMETER_DATA)){ + return Boolean.FALSE; + } + else { + return null; + } + } + }); + } + @Override public Object computeAdvance(D4EArtifact artifact, String hash, CallContext context, List facets, Object old) { @@ -97,12 +126,18 @@ String stateId, String hash) { List diameters = access.getBedDiameter(); + List loadDiameters = access.getBedloadDiameter(); List ranges = access.getDateRanges(); for (int i = 0; i < ranges.size(); i++) { DateRange range = ranges.get(i); for (String diameter: diameters) { - int ndxTop = generateIndex(diameter, true); - int ndxSub = generateIndex(diameter, false); + int ndxTop = generateIndex(diameter); + int ndxSub = generateIndex(diameter); + ndxTop += 1; + ndxTop = ndxTop << 3; + ndxSub = ndxSub << 3; + ndxTop += i; + ndxSub += i; String toplayer = Resources.getMsg( context.getMeta(), I18N_TOPLAYER, I18N_TOPLAYER); @@ -136,10 +171,27 @@ stateId, hash)); } + for (String loadDiameter: loadDiameters) { + int ndx = generateIndex(loadDiameter); + ndx = ndx << 3; + ndx += i; + newFacets.add(new BedloadDiameterDataFacet( + ndx, + BEDLOAD_DIAMETER_DATA, + Resources.getMsg( + context.getMeta(), + I18N_FACET_BEDLOAD_DIAMETER_DATA, + I18N_FACET_BEDLOAD_DIAMETER_DATA, + new Object[] { loadDiameter.toUpperCase(), + range.getFrom(), range.getTo()}), + ComputeType.ADVANCE, + stateId, + hash)); + } } } - private int generateIndex(String diameter, boolean b) { + private int generateIndex(String diameter) { int d = 0; if(diameter.equals("d10")) { d = 1; @@ -189,12 +241,7 @@ else if (diameter.equals("dm")) { d = 16; } - int ndx = d; - ndx = ndx << 1; - if (b) { - ndx += 1; - } - ndx = ndx << 3; + int ndx = d << 1; return ndx; } @@ -238,39 +285,41 @@ hash)); } - BedParametersResult[] bedParameters = result.getParameters(); - for (int j = 0; j < bedParameters.length; j++) { - newFacets.add(new BedPorosityFacet((idx << 8) + j, - BED_QUALITY_POROSITY_TOPLAYER, - createPorosityTopLayerDescription( - meta, - bedParameters[j], - range), - ComputeType.ADVANCE, stateId, hash)); + if (bedDiameter.length > 0) { + BedParametersResult[] bedParameters = result.getParameters(); + for (int j = 0; j < bedParameters.length; j++) { + newFacets.add(new BedPorosityFacet((idx << 8) + j, + BED_QUALITY_POROSITY_TOPLAYER, + createPorosityTopLayerDescription( + meta, + bedParameters[j], + range), + ComputeType.ADVANCE, stateId, hash)); - newFacets.add(new BedPorosityFacet((idx << 8) + j, - BED_QUALITY_POROSITY_SUBLAYER, - createPorositySubLayerDescription( - meta, - bedParameters[j], - range), - ComputeType.ADVANCE, stateId, hash)); + newFacets.add(new BedPorosityFacet((idx << 8) + j, + BED_QUALITY_POROSITY_SUBLAYER, + createPorositySubLayerDescription( + meta, + bedParameters[j], + range), + ComputeType.ADVANCE, stateId, hash)); - newFacets.add(new BedDensityFacet((idx << 8) + j, - BED_QUALITY_SEDIMENT_DENSITY_TOPLAYER, - createDensityTopLayerDescription( - meta, - bedParameters[j], - range), - ComputeType.ADVANCE, stateId, hash)); + newFacets.add(new BedDensityFacet((idx << 8) + j, + BED_QUALITY_SEDIMENT_DENSITY_TOPLAYER, + createDensityTopLayerDescription( + meta, + bedParameters[j], + range), + ComputeType.ADVANCE, stateId, hash)); - newFacets.add(new BedDensityFacet((idx << 8) + j, - BED_QUALITY_SEDIMENT_DENSITY_SUBLAYER, - createDensitySubLayerDescription( - meta, - bedParameters[j], - range), - ComputeType.ADVANCE, stateId, hash)); + newFacets.add(new BedDensityFacet((idx << 8) + j, + BED_QUALITY_SEDIMENT_DENSITY_SUBLAYER, + createDensitySubLayerDescription( + meta, + bedParameters[j], + range), + ComputeType.ADVANCE, stateId, hash)); + } } } } diff -r 83a04004969f -r ea6225010871 artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedQualityGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedQualityGenerator.java Tue Jun 11 09:18:30 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedQualityGenerator.java Tue Jun 11 09:20:14 2013 +0200 @@ -195,7 +195,8 @@ artifactAndFacet, attr, visible); } else if (name.equals(BED_DIAMETER_DATA_TOP) || - name.equals(BED_DIAMETER_DATA_SUB)) { + name.equals(BED_DIAMETER_DATA_SUB) || + name.equals(BEDLOAD_DIAMETER_DATA)) { doBedDiameterDataOut( (BedDiameterData) artifactAndFacet.getData(context), artifactAndFacet, attr, visible);