Mercurial > dive4elements > river
changeset 8585:e9343e4c9ae0
Reduce duplicated functions to obtain layer descritpions for bedquality
This should make it easier to reuse those for interpolation facets.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 17 Mar 2015 16:37:17 +0100 (2015-03-17) |
parents | ce325339e9ba |
children | 19fde13e2db4 |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java |
diffstat | 1 files changed, 44 insertions(+), 72 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java Mon Mar 16 17:38:08 2015 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java Tue Mar 17 16:37:17 2015 +0100 @@ -54,16 +54,19 @@ public static final String I18N_TOPLAYER = "bedquality.toplayer"; public static final String I18N_SUBLAYER = "bedquality.sublayer"; + /* Calculated layers */ public static final String I18N_FACET_BED_POROSITY_TOPLAYER = "facet.bedquality.bed.porosity.toplayer"; public static final String I18N_FACET_BED_POROSITY_SUBLAYER = "facet.bedquality.bed.porosity.sublayer"; public static final String I18N_FACET_BED_DENSITY_TOPLAYER = "facet.bedquality.bed.density.toplayer"; public static final String I18N_FACET_BED_DENSITY_SUBLAYER = "facet.bedquality.bed.density.sublayer"; public static final String I18N_FACET_BED_DIAMETER_TOPLAYER = "facet.bedquality.bed.diameter.toplayer"; public static final String I18N_FACET_BED_DIAMETER_SUBLAYER = "facet.bedquality.bed.diameter.sublayer"; + public static final String I18N_FACET_BEDLOAD_DIAMETER = "facet.bedquality.bedload.diameter"; + + /* Data Layers */ + public static final String I18N_FACET_BEDLOAD_DIAMETER_DATA = "facet.bedquality.bedload.diameter.data"; public static final String I18N_FACET_BED_DIAMETER_DATA_TOPLAYER = "facet.bedquality.bed.diameter.data.toplayer"; public static final String I18N_FACET_BED_DIAMETER_DATA_SUBLAYER = "facet.bedquality.bed.diameter.data.sublayer"; - 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. @@ -267,18 +270,22 @@ for (int j = 0; j < bedDiameter.length; j++) { newFacets.add(new BedDiameterTopFacet((idx << 8) + j, BED_QUALITY_BED_DIAMETER_TOPLAYER, - createDiameterTopLayerDescription( + getLayerDescription( meta, bedDiameter[j], - range), + range, + I18N_FACET_BED_DIAMETER_TOPLAYER, + true), ComputeType.ADVANCE, stateId, hash)); newFacets.add(new BedDiameterSubFacet((idx << 8) +j, BED_QUALITY_BED_DIAMETER_SUBLAYER, - createDiameterSubLayerDescription( + getLayerDescription( meta, bedDiameter[j], - range), + range, + I18N_FACET_BED_DIAMETER_SUBLAYER, + false), ComputeType.ADVANCE, stateId, hash)); } BedloadDiameterResult[] bedloadDiameter = result.getBedloadResults(); @@ -298,101 +305,66 @@ for (int j = 0; j < bedParameters.length; j++) { newFacets.add(new BedPorosityTopFacet((idx << 8) + j, BED_QUALITY_POROSITY_TOPLAYER, - createPorosityTopLayerDescription( + getLayerDescription( meta, bedParameters[j], - range), + range, + I18N_FACET_BED_POROSITY_TOPLAYER, + true), ComputeType.ADVANCE, stateId, hash)); newFacets.add(new BedPorositySubFacet((idx << 8) + j, BED_QUALITY_POROSITY_SUBLAYER, - createPorositySubLayerDescription( + getLayerDescription( meta, bedParameters[j], - range), + range, + I18N_FACET_BED_POROSITY_SUBLAYER, + false), ComputeType.ADVANCE, stateId, hash)); newFacets.add(new BedDensityTopFacet((idx << 8) + j, BED_QUALITY_SEDIMENT_DENSITY_TOPLAYER, - createDensityTopLayerDescription( + getLayerDescription( meta, bedParameters[j], - range), + range, + I18N_FACET_BED_DENSITY_TOPLAYER, + true), ComputeType.ADVANCE, stateId, hash)); newFacets.add(new BedDensitySubFacet((idx << 8) + j, BED_QUALITY_SEDIMENT_DENSITY_SUBLAYER, - createDensitySubLayerDescription( + getLayerDescription( meta, bedParameters[j], - range), + range, + I18N_FACET_BED_DENSITY_SUBLAYER, + false), ComputeType.ADVANCE, stateId, hash)); } } } } - protected String createPorosityTopLayerDescription(CallMeta meta, - BedParametersResult result, DateRange range) { - Date from = range != null ? range.getFrom() : new Date(); - Date to = range != null ? range.getTo() : new Date(); - - String toplayer = Resources.getMsg(meta, I18N_TOPLAYER, I18N_TOPLAYER); - return Resources.getMsg(meta, I18N_FACET_BED_POROSITY_TOPLAYER, - I18N_FACET_BED_POROSITY_TOPLAYER, new Object[] { from, to, toplayer }); - } - - protected String createPorositySubLayerDescription(CallMeta meta, - BedParametersResult result, DateRange range) { - Date from = range != null ? range.getFrom() : new Date(); - Date to = range != null ? range.getTo() : new Date(); - - String sublayer = Resources.getMsg(meta, I18N_SUBLAYER, I18N_SUBLAYER); - return Resources.getMsg(meta, I18N_FACET_BED_POROSITY_SUBLAYER, - I18N_FACET_BED_POROSITY_SUBLAYER, new Object[] { from, to, sublayer }); - } - - protected String createDensityTopLayerDescription(CallMeta meta, - BedParametersResult result, DateRange range) { + protected String getLayerDescription(CallMeta meta, + Object result, DateRange range, String i18n, boolean topLayer) { Date from = range != null ? range.getFrom() : new Date(); Date to = range != null ? range.getTo() : new Date(); - String toplayer = Resources.getMsg(meta, I18N_TOPLAYER, I18N_TOPLAYER); - return Resources.getMsg(meta, I18N_FACET_BED_DENSITY_TOPLAYER, - I18N_FACET_BED_DENSITY_TOPLAYER, new Object[] { from, to, toplayer }); - } - - protected String createDensitySubLayerDescription(CallMeta meta, - BedParametersResult result, DateRange range) { - Date from = range != null ? range.getFrom() : new Date(); - Date to = range != null ? range.getTo() : new Date(); - - String sublayer = Resources.getMsg(meta, I18N_SUBLAYER, I18N_SUBLAYER); - return Resources.getMsg(meta, I18N_FACET_BED_DENSITY_SUBLAYER, - I18N_FACET_BED_DENSITY_SUBLAYER, new Object[] { from, to, sublayer }); - } - - protected String createDiameterTopLayerDescription(CallMeta meta, - BedDiameterResult result, DateRange range) { - Date from = range != null ? range.getFrom() : new Date(); - Date to = range != null ? range.getTo() : new Date(); - - String toplayer = Resources.getMsg(meta, I18N_TOPLAYER, I18N_TOPLAYER); - - return Resources.getMsg(meta, I18N_FACET_BED_DIAMETER_TOPLAYER, - I18N_FACET_BED_DIAMETER_TOPLAYER, new Object[] { result.getType(), - from, to, toplayer }); - } - - protected String createDiameterSubLayerDescription(CallMeta meta, - BedDiameterResult result, DateRange range) { - Date from = range != null ? range.getFrom() : new Date(); - Date to = range != null ? range.getTo() : new Date(); - - String sublayer = Resources.getMsg(meta, I18N_SUBLAYER, I18N_SUBLAYER); - return Resources.getMsg(meta, I18N_FACET_BED_DIAMETER_SUBLAYER, - I18N_FACET_BED_DIAMETER_SUBLAYER, new Object[] { result.getType(), - from, to, sublayer }); + String layer; + /* Maybe just a check if i18n ends with .sublayer? */ + if (topLayer) { + layer = Resources.getMsg(meta, I18N_TOPLAYER, I18N_TOPLAYER); + } else { + layer = Resources.getMsg(meta, I18N_SUBLAYER, I18N_SUBLAYER); + } + if (result instanceof BedDiameterResult) { + return Resources.getMsg(meta, i18n, i18n, new Object[] { ((BedDiameterResult)result).getType(), + from, to, layer }); + } else { + return Resources.getMsg(meta, i18n, i18n, new Object[] { from, to, layer }); + } } protected String createDiameterDescription(CallMeta meta,