# HG changeset patch # User Felix Wolfsteller # Date 1383319780 -3600 # Node ID f2d97537f48a8d8c970376d006fcb24f97687399 # Parent aab63784a80f8a8e95eb4a481069d3d4f74c674c issue1658: Handle new Facet-Types for SedimentLoad. diff -r aab63784a80f -r f2d97537f48a artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadCalculate.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadCalculate.java Fri Nov 01 16:27:49 2013 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadCalculate.java Fri Nov 01 16:29:40 2013 +0100 @@ -54,6 +54,8 @@ public static final String I18N_FACET_SEDIMENTLOAD_TOTAL_LOAD = "facet.sedimentload.total_load"; public static final String I18N_FACET_SEDIMENTLOAD_TOTAL = "facet.sedimentload.total"; + private transient SedimentLoadAccess access; + static { // Active/deactivate facets. FacetActivity.Registry.getInstance().register( @@ -66,15 +68,22 @@ String output ) { String name = facet.getName(); - if (name.equals(SEDIMENT_LOAD_COARSE) || - name.equals(SEDIMENT_LOAD_FINEMIDDLE) || - name.equals(SEDIMENT_LOAD_SAND) || - name.equals(SEDIMENT_LOAD_SUSP_SAND) || - name.equals(SEDIMENT_LOAD_SUSP_SEDIMENT) || - name.equals(SEDIMENT_LOAD_SUSP_SAND_BED)){ + if (name.equals(SEDIMENT_LOAD_TA_COARSE) || + name.equals(SEDIMENT_LOAD_TA_FINEMIDDLE) || + name.equals(SEDIMENT_LOAD_TA_SAND) || + name.equals(SEDIMENT_LOAD_TA_SUSP_SAND) || + name.equals(SEDIMENT_LOAD_TA_SUSP_SEDIMENT) || + name.equals(SEDIMENT_LOAD_TA_SUSP_SAND_BED) || + name.equals(SEDIMENT_LOAD_M3A_COARSE) || + name.equals(SEDIMENT_LOAD_M3A_FINEMIDDLE) || + name.equals(SEDIMENT_LOAD_M3A_SAND) || + name.equals(SEDIMENT_LOAD_M3A_SUSP_SAND) || + name.equals(SEDIMENT_LOAD_M3A_SUSP_SEDIMENT) || + name.equals(SEDIMENT_LOAD_M3A_SUSP_SAND_BED)){ return Boolean.FALSE; } - else if (name.equals(SEDIMENT_LOAD_UNKNOWN)) { + else if (name.equals(SEDIMENT_LOAD_TA_UNKNOWN) + || name.equals(SEDIMENT_LOAD_M3A_UNKNOWN)) { D4EArtifact d4e = (D4EArtifact)artifact; SedimentLoadUnknownFacet f = (SedimentLoadUnknownFacet) @@ -124,7 +133,9 @@ List newFacets = new ArrayList(); - SedimentLoadAccess access = new SedimentLoadAccess(artifact); + if (access == null) { + access = new SedimentLoadAccess(artifact); + } CalculationResult res = old instanceof CalculationResult ? (CalculationResult) old : new SedimentLoadCalculation().calculate(access); @@ -157,6 +168,8 @@ SedimentLoadFactory.getSedimentLoadUnknown(river, access.getUnit().replace("_per_","/"), type); + boolean isUnitTA = access.getUnit().startsWith("t"); + if (res.getReport().hasProblems()) { newFacets.add(new ReportFacet(ComputeType.ADVANCE, hash, id)); } @@ -164,7 +177,7 @@ for (int i = 0; i < unknown.length; i++) { newFacets.add(new SedimentLoadUnknownFacet( i, - SEDIMENT_LOAD_UNKNOWN, + (isUnitTA)? SEDIMENT_LOAD_TA_UNKNOWN:SEDIMENT_LOAD_M3A_UNKNOWN, unknown[i].getDescription(), ComputeType.ADVANCE, getID(), @@ -184,6 +197,7 @@ logger.debug("SedimentLoadCalculate.generateFacets"); CallMeta meta = context.getMeta(); + boolean isUnitTA = access.getUnit().startsWith("t"); // newFacets.add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id)); for (int idx = 0; idx < results.length; idx++) { @@ -191,7 +205,9 @@ if (res.hasCoarseData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_COARSE, + (isUnitTA) + ?SEDIMENT_LOAD_TA_COARSE + :SEDIMENT_LOAD_M3A_COARSE, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_COARSE, @@ -204,7 +220,9 @@ if (res.hasSandData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_SAND, + (isUnitTA) + ?SEDIMENT_LOAD_TA_SAND + :SEDIMENT_LOAD_M3A_SAND, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_SAND, @@ -217,7 +235,9 @@ if (res.hasFineMiddleData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_FINEMIDDLE, + (isUnitTA) + ?SEDIMENT_LOAD_TA_FINEMIDDLE + :SEDIMENT_LOAD_M3A_FINEMIDDLE, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE, @@ -230,7 +250,9 @@ if (res.hasSuspSandData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_SUSP_SAND, + (isUnitTA) + ?SEDIMENT_LOAD_TA_SUSP_SAND + :SEDIMENT_LOAD_M3A_SUSP_SAND, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_SUSPSAND, @@ -243,7 +265,9 @@ if (res.hasSuspSandBedData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_SUSP_SAND_BED, + (isUnitTA) + ?SEDIMENT_LOAD_TA_SUSP_SAND_BED + :SEDIMENT_LOAD_M3A_SUSP_SAND_BED, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_SUSPSANDBED, @@ -256,7 +280,9 @@ if (res.hasSuspSedimentData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_SUSP_SEDIMENT, + (isUnitTA) + ?SEDIMENT_LOAD_TA_SUSP_SEDIMENT + :SEDIMENT_LOAD_M3A_SUSP_SEDIMENT, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT, @@ -270,7 +296,9 @@ if (res.hasTotalData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_TOTAL, + (isUnitTA) + ?SEDIMENT_LOAD_TA_TOTAL + :SEDIMENT_LOAD_M3A_TOTAL, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_TOTAL, @@ -293,6 +321,7 @@ logger.debug("SedimentLoadCalculate.generateEpochFacets"); CallMeta meta = context.getMeta(); + boolean isUnitTA = access.getUnit().startsWith("t"); // newFacets.add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id)); for (int idx = 0; idx < results.length; idx++) { @@ -300,7 +329,9 @@ if (res.hasCoarseData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_COARSE, + (isUnitTA) + ?SEDIMENT_LOAD_TA_COARSE + :SEDIMENT_LOAD_M3A_COARSE, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_COARSE, @@ -313,7 +344,9 @@ if (res.hasSandData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_SAND, + (isUnitTA) + ?SEDIMENT_LOAD_TA_SAND + :SEDIMENT_LOAD_M3A_SAND, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_SAND, @@ -326,7 +359,9 @@ if (res.hasFineMiddleData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_FINEMIDDLE, + (isUnitTA) + ?SEDIMENT_LOAD_TA_FINEMIDDLE + :SEDIMENT_LOAD_M3A_FINEMIDDLE, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE, @@ -339,7 +374,9 @@ if (res.hasSuspSandData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_SUSP_SAND, + (isUnitTA) + ?SEDIMENT_LOAD_TA_SUSP_SAND + :SEDIMENT_LOAD_M3A_SUSP_SAND, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_SUSPSAND, @@ -352,7 +389,9 @@ if (res.hasSuspSandBedData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_SUSP_SAND_BED, + (isUnitTA) + ?SEDIMENT_LOAD_TA_SUSP_SAND_BED + :SEDIMENT_LOAD_M3A_SUSP_SAND, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_SUSPSANDBED, @@ -365,7 +404,9 @@ if (res.hasSuspSedimentData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_SUSP_SEDIMENT, + (isUnitTA) + ?SEDIMENT_LOAD_TA_SUSP_SEDIMENT + :SEDIMENT_LOAD_M3A_SUSP_SEDIMENT, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT, @@ -379,7 +420,9 @@ if (res.hasTotalLoadData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_TOTAL_LOAD, + (isUnitTA) + ?SEDIMENT_LOAD_TA_TOTAL_LOAD + :SEDIMENT_LOAD_M3A_TOTAL_LOAD, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_TOTAL_LOAD, @@ -392,7 +435,9 @@ if (res.hasTotalData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_TOTAL, + (isUnitTA) + ?SEDIMENT_LOAD_TA_TOTAL + :SEDIMENT_LOAD_M3A_TOTAL, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_TOTAL, @@ -415,6 +460,7 @@ logger.debug("SedimentLoadCalculate.generateOffEpochFacets"); CallMeta meta = context.getMeta(); + boolean isUnitTA = access.getUnit().startsWith("t"); // newFacets.add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id)); for (int idx = 0; idx < results.length; idx++) { @@ -422,7 +468,9 @@ if (res.hasCoarseData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_COARSE, + (isUnitTA) + ?SEDIMENT_LOAD_TA_COARSE + :SEDIMENT_LOAD_M3A_COARSE, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_COARSE, @@ -435,7 +483,9 @@ if (res.hasSandData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_SAND, + (isUnitTA) + ?SEDIMENT_LOAD_TA_SAND + :SEDIMENT_LOAD_M3A_SAND, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_SAND, @@ -448,7 +498,9 @@ if (res.hasFineMiddleData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_FINEMIDDLE, + (isUnitTA) + ?SEDIMENT_LOAD_TA_FINEMIDDLE + :SEDIMENT_LOAD_M3A_FINEMIDDLE, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE, @@ -461,7 +513,9 @@ if (res.hasSuspSandData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_SUSP_SAND, + (isUnitTA) + ?SEDIMENT_LOAD_TA_SUSP_SAND + :SEDIMENT_LOAD_M3A_SUSP_SAND, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_SUSPSAND, @@ -474,7 +528,9 @@ if (res.hasSuspSandBedData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_SUSP_SAND_BED, + (isUnitTA) + ?SEDIMENT_LOAD_TA_SUSP_SAND_BED + :SEDIMENT_LOAD_M3A_SUSP_SAND_BED, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_SUSPSANDBED, @@ -487,7 +543,9 @@ if (res.hasSuspSedimentData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_SUSP_SEDIMENT, + (isUnitTA) + ?SEDIMENT_LOAD_TA_SUSP_SEDIMENT + :SEDIMENT_LOAD_M3A_SUSP_SEDIMENT, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT, @@ -501,7 +559,9 @@ if (res.hasTotalLoadData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_TOTAL_LOAD, + (isUnitTA) + ?SEDIMENT_LOAD_TA_TOTAL_LOAD + :SEDIMENT_LOAD_M3A_TOTAL_LOAD, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_TOTAL_LOAD, @@ -514,7 +574,9 @@ if (res.hasTotalData()) { newFacets.add(new SedimentLoadFacet( idx, - SEDIMENT_LOAD_TOTAL, + (isUnitTA) + ?SEDIMENT_LOAD_TA_TOTAL + :SEDIMENT_LOAD_M3A_TOTAL, Resources.getMsg( meta, I18N_FACET_SEDIMENTLOAD_TOTAL,