Mercurial > dive4elements > river
changeset 8148:eb48b244921d
The rest is silence.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 27 Aug 2014 19:52:51 +0200 |
parents | 8ad0b7bc3e73 |
children | 969963ee61ba |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/SedimentYieldArtifact.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadLSFacet.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadCalculate.java artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadM3AProcessor.java artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadProcessor.java artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadTAProcessor.java |
diffstat | 8 files changed, 6 insertions(+), 1015 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/SedimentYieldArtifact.java Wed Aug 27 16:47:38 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,310 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.artifacts; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; - -import org.apache.log4j.Logger; -import org.w3c.dom.Document; - -import org.dive4elements.artifactdatabase.state.DefaultOutput; -import org.dive4elements.artifactdatabase.state.Facet; -import org.dive4elements.artifactdatabase.state.FacetActivity; -import org.dive4elements.artifactdatabase.state.State; -import org.dive4elements.artifacts.Artifact; -import org.dive4elements.artifacts.ArtifactFactory; -import org.dive4elements.artifacts.CallMeta; -import org.dive4elements.artifacts.common.utils.XMLUtils; -import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; -import org.dive4elements.river.artifacts.model.Calculation; -import org.dive4elements.river.artifacts.model.CalculationResult; -import org.dive4elements.river.artifacts.model.minfo.SedimentLoadLSData; -import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFacet; -import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFactory; -import org.dive4elements.river.artifacts.model.minfo.SedimentLoadResult; -import org.dive4elements.river.artifacts.resources.Resources; -import org.dive4elements.river.artifacts.states.StaticState; - -import org.dive4elements.river.artifacts.model.FacetTypes; - - -/** Artifact to access sediment yield measurements. */ -// TODO Naming: would SedimentLoadArtifact be more precise? -public class SedimentYieldArtifact -extends StaticD4EArtifact -implements FacetTypes -{ - /** The logger for this class. */ - private static Logger logger = - Logger.getLogger(SedimentYieldArtifact.class); - - /** Artifact key name. */ - private static final String NAME = "sedimentyield"; - - /** Spawn only inactive facets. */ - static { - // TODO: Move to configuration. - FacetActivity.Registry.getInstance() - .register(NAME, FacetActivity.INACTIVE); - } - - /** Need to give the state an id. */ - public static final String STATIC_STATE_NAME = - "state.sedimentyield.static"; - - /** One and only state to be in. */ - protected transient State state = null; - - protected String DATA_NAME = "ID"; - - /** - * Trivial Constructor. - */ - public SedimentYieldArtifact() { - logger.debug("SedimentYieldArtifact.SedimentYieldArtifact"); - } - - - /** Get artifact key name. */ - @Override - public String getName() { - return NAME; - } - - - private Object getSedimentLoad() { - logger.debug("SedimentYieldArtifact.getSedimentLoad"); - String id = getDataAsString(DATA_NAME); - String river = getDataAsString("river"); - - // TODO use cache if possible - SedimentLoadLSData myLoad = SedimentLoadFactory.getSedimentLoadWithDataUncached(id, river); - return new CalculationResult( - new SedimentLoadResult[] { - new SedimentLoadResult(1983,2042,myLoad) - }, new Calculation()); - } - - - /** Create a new state with bogus output. */ - protected State spawnState() { - state = new StaticState(STATIC_STATE_NAME) { - - public Object staticCompute(List<Facet> facets) { - return getSedimentLoad(); - } - }; - List<Facet> fs = getFacets(STATIC_STATE_NAME); - DefaultOutput output = new DefaultOutput( - "general", - "general", - "image/png", - fs, - "chart"); - - state.getOutputs().add(output); - - return state; - } - - - /** - * Gets called from factory, to set things up. - */ - @Override - public void setup( - String identifier, - ArtifactFactory factory, - Object context, - CallMeta callMeta, - Document data, - List<Class> loadFacets) - { - logger.debug("SedimentYieldArtifact.setup"); - - // Refactor? this happens at another place, too - // Store id, yield yields. - state = new StaticState(STATIC_STATE_NAME) { - - public Object staticCompute(List<Facet> facets) { - return getSedimentLoad(); - } - }; - if (logger.isDebugEnabled()) { - logger.debug(XMLUtils.toString(data)); - } - - List<Facet> fs = new ArrayList<Facet>(); - String code = getDatacageIDValue(data); - - if (code != null) { - int id = Integer.valueOf(code); - String fraction = SedimentLoadFactory.getSedimentYieldFractionName(id); - String fractionName = Resources.getMsg(callMeta, fraction, "-"); - Date[] dates = SedimentLoadFactory.getSedimentYieldTimes(id); - Calendar date = Calendar.getInstance(); - date.setTime(dates[0]); - String name = fractionName + " - " + date.get(Calendar.YEAR); - if (dates[1] != null) { - date.setTime(dates[1]); - name += " - " + date.get(Calendar.YEAR); - } - - boolean unitIsTA = - SedimentLoadFactory.getSedimentYieldUnitName(id).startsWith("t"); - - name += " "; - name += (unitIsTA) - ? Resources.getMsg(callMeta, "state.minfo.sediment.load.t_per_a", "(t/a)") - : Resources.getMsg(callMeta, "state.minfo.sediment.load.m3_per_a", "(m^3/a)"); - - String facetType = ""; - if (fraction.equals("coarse")) { - if (unitIsTA) { - facetType = SEDIMENT_LOAD_TA_COARSE; - } - else { - facetType = SEDIMENT_LOAD_M3A_COARSE; - } - } - else if (fraction.equals("sand")) { - if (unitIsTA) { - facetType = SEDIMENT_LOAD_TA_SAND; - } - else { - facetType = SEDIMENT_LOAD_M3A_SAND; - } - } - else if (fraction.equals("fine_middle")) { - if (unitIsTA) { - facetType = SEDIMENT_LOAD_TA_FINEMIDDLE; - } - else { - facetType = SEDIMENT_LOAD_M3A_FINEMIDDLE; - } - } - else if (fraction.equals("susp_sand")) { - if (unitIsTA) { - facetType = SEDIMENT_LOAD_TA_SUSP_SAND; - } - else { - facetType = SEDIMENT_LOAD_M3A_SAND; - } - } - else if (fraction.equals("susp_sand_bed")) { - if (unitIsTA) { - facetType = SEDIMENT_LOAD_TA_SUSP_SAND_BED; - } - else { - facetType = SEDIMENT_LOAD_M3A_SUSP_SAND_BED; - } - } - else if (fraction.equals("suspended_sediment")) { - if (unitIsTA) { - facetType = SEDIMENT_LOAD_TA_SUSP_SEDIMENT; - } - else { - facetType = SEDIMENT_LOAD_M3A_SUSP_SEDIMENT; - } - } - else if (fraction.equals("total")) { - if (unitIsTA) { - facetType = SEDIMENT_LOAD_TA_TOTAL_LOAD; - } - else { - facetType = SEDIMENT_LOAD_M3A_TOTAL_LOAD; - } - } - else { - logger.error("Do not know fraction type " + fraction); - } - - Facet facet = new SedimentLoadFacet( - 0, - facetType, - name, - //???? - ComputeType.ADVANCE, state.getID(), "hash" - ); - fs.add(facet); - addFacets(state.getID(), fs); - addStringData(DATA_NAME, code); - } - - spawnState(); - super.setup(identifier, factory, context, callMeta, data, loadFacets); - } - - - /** - * Get a list containing the one and only State. - * @param context ignored. - * @return list with one and only state. - */ - @Override - protected List<State> getStates(Object context) { - ArrayList<State> states = new ArrayList<State>(); - states.add(getState()); - return states; - } - - - /** - * Get the "current" state (there is but one). - * @param cc ignored. - * @return the "current" (only possible) state. - */ - @Override - public State getCurrentState(Object cc) { - return getState(); - } - - - /** - * Get the only possible state. - * @return the state. - */ - protected State getState() { - return getState(null, null); - } - - - /** - * Get the state. - * @param context ignored. - * @param stateID ignored. - * @return the state. - */ - @Override - protected State getState(Object context, String stateID) { - return (state != null) - ? state - : spawnState(); - } - - - /** - * Called via setup. Overridden to avoid cloning all data. - * - * @param artifact The master-artifact. - */ - @Override - protected void initialize( - Artifact artifact, - Object context, - CallMeta meta) - { - logger.debug("SedimentYieldArtifact.initialize"); - importData((D4EArtifact) artifact, "river"); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java Wed Aug 27 16:47:38 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java Wed Aug 27 19:52:51 2014 +0200 @@ -111,52 +111,6 @@ return false; } - public static boolean SEDIMENT_LOAD_TOTAL_LOAD(String type) { - return type.equals(SEDIMENT_LOAD_TA_TOTAL_LOAD) || - type.equals(SEDIMENT_LOAD_M3A_TOTAL_LOAD); - } - public static boolean SEDIMENT_LOAD_TOTAL(String type) { - return type.equals(SEDIMENT_LOAD_TA_TOTAL) || - type.equals(SEDIMENT_LOAD_M3A_TOTAL); - } - public static boolean SEDIMENT_LOAD_SUSP_SEDIMENT(String type) { - return type.equals(SEDIMENT_LOAD_TA_SUSP_SEDIMENT) || - type.equals(SEDIMENT_LOAD_M3A_SUSP_SEDIMENT); - } - public static boolean SEDIMENT_LOAD_SUSP_SAND_BED(String type) { - return type.equals(SEDIMENT_LOAD_TA_SUSP_SAND_BED) || - type.equals(SEDIMENT_LOAD_M3A_SUSP_SAND_BED); - } - public static boolean SEDIMENT_LOAD_SUSP_SAND(String type) { - return type.equals(SEDIMENT_LOAD_TA_SUSP_SAND) || - type.equals(SEDIMENT_LOAD_M3A_SUSP_SAND); - } - public static boolean SEDIMENT_LOAD_FINEMIDDLE(String type) { - return type.equals(SEDIMENT_LOAD_TA_FINEMIDDLE) || - type.equals(SEDIMENT_LOAD_M3A_FINEMIDDLE); - } - public static boolean SEDIMENT_LOAD_COARSE(String type) { - return type.equals(SEDIMENT_LOAD_TA_COARSE) || - type.equals(SEDIMENT_LOAD_M3A_COARSE); - } - public static boolean SEDIMENT_LOAD_SAND(String type) { - return type.equals(SEDIMENT_LOAD_TA_SAND) || - type.equals(SEDIMENT_LOAD_M3A_SAND); - } - public static boolean SEDIMENT_LOAD_M3A(String type) { - return type.startsWith("sedimentload.m3a") && !type.contains("unknown"); - } - public static boolean SEDIMENT_LOAD_TA(String type) { - return type.startsWith("sedimentload.ta") && !type.contains("unknown"); - } - public static boolean SEDIMENT_LOAD(String type){ - return type.startsWith("sedimentload") && - !(type.contains(".m3a.") || type.contains(".ta.")); - } - public static boolean SEDIMENT_LOAD_UNKNOWN(String type) { - return type.equals("sedimentload.m3a.unknown") || - type.equals("sedimentload.ta.unknown"); - } }; /** Available diagram/chart-types. This enum is evaluated at certain @@ -350,26 +304,6 @@ String SEDIMENT_DENSITY = "sediment.density"; - String SEDIMENT_LOAD_TA_COARSE = "sedimentload.ta.coarse"; - String SEDIMENT_LOAD_TA_SAND = "sedimentload.ta.sand"; - String SEDIMENT_LOAD_TA_FINEMIDDLE = "sedimentload.ta.finemiddle"; - String SEDIMENT_LOAD_TA_SUSP_SAND = "sedimentload.ta.susp_sand"; - String SEDIMENT_LOAD_TA_SUSP_SAND_BED = "sedimentload.ta.susp_sand_bed"; - String SEDIMENT_LOAD_TA_SUSP_SEDIMENT = "sedimentload.ta.susp_sediment"; - String SEDIMENT_LOAD_TA_TOTAL = "sedimentload.ta.total"; - String SEDIMENT_LOAD_TA_TOTAL_LOAD = "sedimentload.ta.total_load"; - String SEDIMENT_LOAD_TA_UNKNOWN = "sedimentload.ta.unknown"; - - String SEDIMENT_LOAD_M3A_COARSE = "sedimentload.m3a.coarse"; - String SEDIMENT_LOAD_M3A_SAND = "sedimentload.m3a.sand"; - String SEDIMENT_LOAD_M3A_FINEMIDDLE = "sedimentload.m3a.finemiddle"; - String SEDIMENT_LOAD_M3A_SUSP_SAND = "sedimentload.m3a.susp_sand"; - String SEDIMENT_LOAD_M3A_SUSP_SAND_BED = "sedimentload.m3a.susp_sand_bed"; - String SEDIMENT_LOAD_M3A_SUSP_SEDIMENT = "sedimentload.m3a.susp_sediment"; - String SEDIMENT_LOAD_M3A_TOTAL = "sedimentload.m3a.total"; - String SEDIMENT_LOAD_M3A_TOTAL_LOAD = "sedimentload.m3a.total_load"; - String SEDIMENT_LOAD_M3A_UNKNOWN = "sedimentload.m3a.unknown"; - String SQ_OVERVIEW = "sq_overview"; String SQ_A_CURVE = "sq_a_curve";
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java Wed Aug 27 16:47:38 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java Wed Aug 27 19:52:51 2014 +0200 @@ -22,7 +22,6 @@ import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.artifacts.model.DataFacet; -import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; @@ -34,7 +33,7 @@ /** Facet to access various sediment loads. */ public class SedimentLoadFacet extends DataFacet -implements FacetTypes, StaticFacet +implements StaticFacet { private static Logger logger = Logger.getLogger(SedimentLoadFacet.class);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadLSFacet.java Wed Aug 27 16:47:38 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadLSFacet.java Wed Aug 27 19:52:51 2014 +0200 @@ -21,7 +21,6 @@ import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.artifacts.model.DataFacet; -import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; @@ -42,7 +41,7 @@ */ public class SedimentLoadLSFacet extends DataFacet -implements FacetTypes, StaticFacet +implements StaticFacet { private static Logger logger = Logger.getLogger(SedimentLoadLSFacet.class);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadCalculate.java Wed Aug 27 16:47:38 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,613 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.artifacts.states.minfo; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -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; -import org.dive4elements.river.artifacts.access.SedimentLoadAccess; -import org.dive4elements.river.artifacts.model.CalculationResult; -import org.dive4elements.river.artifacts.model.DataFacet; -import org.dive4elements.river.artifacts.model.FacetTypes; -import org.dive4elements.river.artifacts.model.ReportFacet; -import org.dive4elements.river.artifacts.model.minfo.SedimentLoadLSData; -import org.dive4elements.river.artifacts.model.minfo.SedimentLoadCalculation; -import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFacet; -import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFactory; -import org.dive4elements.river.artifacts.model.minfo.SedimentLoadResult; -import org.dive4elements.river.artifacts.model.minfo.SedimentLoadUnknownFacet; -import org.dive4elements.river.artifacts.resources.Resources; -import org.dive4elements.river.artifacts.states.DefaultState; -import org.dive4elements.river.utils.DateUtil; - -/** State in which Sediment Load(s) are calculated/retrieved. */ -public class SedimentLoadCalculate -extends DefaultState -implements FacetTypes -{ - - private static final long serialVersionUID = 1L; - - private static final Logger logger = Logger - .getLogger(SedimentLoadCalculate.class); - - public static final String I18N_FACET_SEDIMENTLOAD_COARSE = "facet.sedimentload.coarse"; - public static final String I18N_FACET_SEDIMENTLOAD_SAND = "facet.sedimentload.sand"; - public static final String I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE = "facet.sedimentload.fine_middle"; - public static final String I18N_FACET_SEDIMENTLOAD_SUSPSAND = "facet.sedimentload.susp_sand"; - public static final String I18N_FACET_SEDIMENTLOAD_SUSPSANDBED = "facet.sediemntload.susp_sand_bed"; - public static final String I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT = "facet.sedimentload.susp_sediment"; - public static final String I18N_FACET_SEDIMENTLOAD_TOTAL_LOAD = "facet.sedimentload.total_load"; - public static final String I18N_FACET_SEDIMENTLOAD_TOTAL = "facet.sedimentload.total"; - - 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(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_TA_UNKNOWN) - || name.equals(SEDIMENT_LOAD_M3A_UNKNOWN)) { - D4EArtifact d4e = (D4EArtifact)artifact; - SedimentLoadUnknownFacet f = - (SedimentLoadUnknownFacet) - d4e.getNativeFacet(facet, null); - SedimentLoadLSData load = - (SedimentLoadLSData)f.getData(artifact, null); - SedimentLoadAccess access = - new SedimentLoadAccess(d4e); - List<int[]> dates = new ArrayList<int[]>(); - if (access.getYearEpoch().equals("year")) { - dates.add(access.getPeriod()); - } - else { - int[][] epochs = access.getEpochs(); - for (int i = 0; i < epochs.length; i++) { - dates.add(epochs[i]); - } - } - for (int[] date: dates) { - try { - Date s = - DateUtil.getStartDateFromYear(date[0]); - Date e = - DateUtil.getEndDateFromYear(date[1]); - if (!(s.after(load.getEnd()) || - e.before(load.getStart()))) { - return Boolean.TRUE; - } - } - catch (IllegalArgumentException iae) { - return Boolean.FALSE; - } - } - return Boolean.FALSE; - } - else { - return null; - } - } - }); - } - - @Override - public Object computeAdvance(D4EArtifact artifact, String hash, - CallContext context, List<Facet> facets, Object old) { - logger.debug("SedimentLoadCalculate.computeAdvance"); - - List<Facet> newFacets = new ArrayList<Facet>(); - - SedimentLoadAccess access = new SedimentLoadAccess(artifact); - - CalculationResult res = old instanceof CalculationResult ? (CalculationResult) old - : new SedimentLoadCalculation().calculate(access); - - if (facets == null || res == null) { - return res; - } - - SedimentLoadResult[] results = (SedimentLoadResult[]) res.getData(); - - if (results == null || results.length == 0) { - logger.warn("Calculation computed no results!"); - return res; - } - - String type = access.getYearEpoch(); - if (type.equals("year")) { - generateYearFacets(context, newFacets, results, getID(), hash, access); - } - else if (type.equals("epoch")) { - generateEpochFacets(context, newFacets, results, getID(), hash, access); - } - else if (type.equals("off_epoch")) { - generateOffEpochFacets(context, newFacets, results, getID(), hash, access); - } - logger.debug("Created " + newFacets.size() + " new Facets."); - - String river = access.getRiverName(); - SedimentLoadLSData[] unknown = - 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)); - } - - for (int i = 0; i < unknown.length; i++) { - newFacets.add(new SedimentLoadUnknownFacet( - i, - (isUnitTA)? SEDIMENT_LOAD_TA_UNKNOWN:SEDIMENT_LOAD_M3A_UNKNOWN, - unknown[i].getDescription(), - ComputeType.ADVANCE, - getID(), - hash)); - } - - newFacets.add( - new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id)); - - facets.addAll(newFacets); - - return res; - } - - private String facetNameInfo(SedimentLoadResult result, String unit) { - return " - " + result.getStartYear() + " " + unit; - } - - - protected void generateYearFacets(CallContext context, - List<Facet> newFacets, - SedimentLoadResult[] results, - String stateId, - String hash, - SedimentLoadAccess access - ) { - logger.debug("SedimentLoadCalculate.generateFacets " + access.getUnit()); - - CallMeta meta = context.getMeta(); - boolean isUnitTA = access.getUnit().startsWith("t"); - String unit = (isUnitTA) - ? Resources.getMsg(context.getMeta(), "state.minfo.sediment.load.t_per_a", "(t/a)") - : Resources.getMsg(context.getMeta(), "state.minfo.sediment.load.m3_per_a", "(m^3/a)"); - -// newFacets.add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id)); - for (int idx = 0; idx < results.length; idx++) { - SedimentLoadResult res = results[idx]; - if (res.hasCoarseData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_COARSE - :SEDIMENT_LOAD_M3A_COARSE, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_COARSE, - I18N_FACET_SEDIMENTLOAD_COARSE) + - facetNameInfo(res, unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - if (res.hasSandData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_SAND - :SEDIMENT_LOAD_M3A_SAND, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_SAND, - I18N_FACET_SEDIMENTLOAD_SAND) + - facetNameInfo(res, unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - if (res.hasFineMiddleData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_FINEMIDDLE - :SEDIMENT_LOAD_M3A_FINEMIDDLE, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE, - I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE) + - facetNameInfo(res, unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - if (res.hasSuspSandData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_SUSP_SAND - :SEDIMENT_LOAD_M3A_SUSP_SAND, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_SUSPSAND, - I18N_FACET_SEDIMENTLOAD_SUSPSAND) + - facetNameInfo(res, unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - if (res.hasSuspSandBedData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_SUSP_SAND_BED - :SEDIMENT_LOAD_M3A_SUSP_SAND_BED, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_SUSPSANDBED, - I18N_FACET_SEDIMENTLOAD_SUSPSANDBED) + - facetNameInfo(res, unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - if (res.hasSuspSedimentData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_SUSP_SEDIMENT - :SEDIMENT_LOAD_M3A_SUSP_SEDIMENT, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT, - I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT) + - facetNameInfo(res, unit), - ComputeType.ADVANCE, - stateId, - hash)); - - } - if (res.hasTotalData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_TOTAL - :SEDIMENT_LOAD_M3A_TOTAL, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_TOTAL, - I18N_FACET_SEDIMENTLOAD_TOTAL) + - facetNameInfo(res, unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - } - } - - private String epochFacetNameInfo(SedimentLoadResult result, String unit) { - return " - " + result.getStartYear() + "-" + result.getEndYear() + " " + unit; - } - - protected void generateEpochFacets( - CallContext context, - List<Facet> newFacets, - SedimentLoadResult[] results, - String stateId, - String hash, - SedimentLoadAccess access - ) { - logger.debug("SedimentLoadCalculate.generateEpochFacets "); - - CallMeta meta = context.getMeta(); - boolean isUnitTA = access.getUnit().startsWith("t"); - String unit = (isUnitTA) - ? Resources.getMsg(context.getMeta(), "state.minfo.sediment.load.t_per_a", "(t/a)") - : Resources.getMsg(context.getMeta(), "state.minfo.sediment.load.m3_per_a", "(m^3/a)"); - -// newFacets.add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id)); - for (int idx = 0; idx < results.length; idx++) { - SedimentLoadResult res = results[idx]; - if (res.hasCoarseData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_COARSE - :SEDIMENT_LOAD_M3A_COARSE, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_COARSE, - I18N_FACET_SEDIMENTLOAD_COARSE) + - epochFacetNameInfo(res,unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - if (res.hasSandData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_SAND - :SEDIMENT_LOAD_M3A_SAND, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_SAND, - I18N_FACET_SEDIMENTLOAD_SAND) + - epochFacetNameInfo(res,unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - if (res.hasFineMiddleData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_FINEMIDDLE - :SEDIMENT_LOAD_M3A_FINEMIDDLE, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE, - I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE) + - epochFacetNameInfo(res,unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - if (res.hasSuspSandData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_SUSP_SAND - :SEDIMENT_LOAD_M3A_SUSP_SAND, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_SUSPSAND, - I18N_FACET_SEDIMENTLOAD_SUSPSAND) + - epochFacetNameInfo(res,unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - if (res.hasSuspSandBedData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_SUSP_SAND_BED - :SEDIMENT_LOAD_M3A_SUSP_SAND, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_SUSPSANDBED, - I18N_FACET_SEDIMENTLOAD_SUSPSANDBED) + - epochFacetNameInfo(res,unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - if (res.hasSuspSedimentData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_SUSP_SEDIMENT - :SEDIMENT_LOAD_M3A_SUSP_SEDIMENT, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT, - I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT) + - epochFacetNameInfo(res,unit), - ComputeType.ADVANCE, - stateId, - hash)); - - } - if (res.hasTotalLoadData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_TOTAL_LOAD - :SEDIMENT_LOAD_M3A_TOTAL_LOAD, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_TOTAL_LOAD, - I18N_FACET_SEDIMENTLOAD_TOTAL_LOAD) + - epochFacetNameInfo(res,unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - if (res.hasTotalData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_TOTAL - :SEDIMENT_LOAD_M3A_TOTAL, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_TOTAL, - I18N_FACET_SEDIMENTLOAD_TOTAL) + - epochFacetNameInfo(res,unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - } - } - - protected void generateOffEpochFacets( - CallContext context, - List<Facet> newFacets, - SedimentLoadResult[] results, - String stateId, - String hash, - SedimentLoadAccess access - ) { - logger.debug("SedimentLoadCalculate.generateOffEpochFacets"); - - CallMeta meta = context.getMeta(); - boolean isUnitTA = access.getUnit().startsWith("t"); - String unit = (isUnitTA) - ? Resources.getMsg(context.getMeta(), "state.minfo.sediment.load.t_per_a", "(t/a)") - : Resources.getMsg(context.getMeta(), "state.minfo.sediment.load.m3_per_a", "(m^3/a)"); - -// newFacets.add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id)); - for (int idx = 0; idx < results.length; idx++) { - SedimentLoadResult res = results[idx]; - if (res.hasCoarseData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_COARSE - :SEDIMENT_LOAD_M3A_COARSE, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_COARSE, - I18N_FACET_SEDIMENTLOAD_COARSE) + - epochFacetNameInfo(res,unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - if (res.hasSandData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_SAND - :SEDIMENT_LOAD_M3A_SAND, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_SAND, - I18N_FACET_SEDIMENTLOAD_SAND) + - epochFacetNameInfo(res,unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - if (res.hasFineMiddleData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_FINEMIDDLE - :SEDIMENT_LOAD_M3A_FINEMIDDLE, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE, - I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE) + - epochFacetNameInfo(res,unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - if (res.hasSuspSandData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_SUSP_SAND - :SEDIMENT_LOAD_M3A_SUSP_SAND, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_SUSPSAND, - I18N_FACET_SEDIMENTLOAD_SUSPSAND) + - epochFacetNameInfo(res,unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - if (res.hasSuspSandBedData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_SUSP_SAND_BED - :SEDIMENT_LOAD_M3A_SUSP_SAND_BED, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_SUSPSANDBED, - I18N_FACET_SEDIMENTLOAD_SUSPSANDBED) + - epochFacetNameInfo(res,unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - if (res.hasSuspSedimentData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_SUSP_SEDIMENT - :SEDIMENT_LOAD_M3A_SUSP_SEDIMENT, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT, - I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT) + - epochFacetNameInfo(res,unit), - ComputeType.ADVANCE, - stateId, - hash)); - - } - if (res.hasTotalLoadData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_TOTAL_LOAD - :SEDIMENT_LOAD_M3A_TOTAL_LOAD, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_TOTAL_LOAD, - I18N_FACET_SEDIMENTLOAD_TOTAL_LOAD) + - epochFacetNameInfo(res,unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - if (res.hasTotalData()) { - newFacets.add(new SedimentLoadFacet( - idx, - (isUnitTA) - ?SEDIMENT_LOAD_TA_TOTAL - :SEDIMENT_LOAD_M3A_TOTAL, - Resources.getMsg( - meta, - I18N_FACET_SEDIMENTLOAD_TOTAL, - I18N_FACET_SEDIMENTLOAD_TOTAL) + - epochFacetNameInfo(res,unit), - ComputeType.ADVANCE, - stateId, - hash)); - } - } - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadM3AProcessor.java Wed Aug 27 16:47:38 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadM3AProcessor.java Wed Aug 27 19:52:51 2014 +0200 @@ -9,7 +9,6 @@ import org.apache.log4j.Logger; -import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.exports.DiagramGenerator; public class SedimentLoadM3AProcessor extends SedimentLoadProcessor { @@ -23,8 +22,7 @@ @Override public boolean canHandle(String facettype) { - return FacetTypes.IS.SEDIMENT_LOAD_M3A(facettype) || - FacetTypes.SEDIMENT_LOAD_M3A_UNKNOWN.equals(facettype); + return facettype.startsWith("sedimentload.m3a"); } @Override
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadProcessor.java Wed Aug 27 16:47:38 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadProcessor.java Wed Aug 27 19:52:51 2014 +0200 @@ -15,7 +15,6 @@ import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifacts.CallContext; -import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.exports.StyledSeriesBuilder; import org.dive4elements.river.jfree.StyledXYSeries; @@ -46,21 +45,8 @@ double [][] points; logger.debug("Do out for: " + facetName); - if (FacetTypes.IS.SEDIMENT_LOAD_M3A(facetName) || - FacetTypes.IS.SEDIMENT_LOAD_TA(facetName) || - FacetTypes.IS.SEDIMENT_LOAD(facetName)) { + if (facetName.startsWith("sedimentload.")) { points = (double[][]) data; - } else if (FacetTypes.IS.SEDIMENT_LOAD_UNKNOWN(facetName)) { - SedimentLoadLSData load = (SedimentLoadLSData) data; - Set<Double> kms = load.getKms(); - points = new double[2][kms.size()]; - int counter = 0; - for (Double km: kms) { - SedimentLoadFraction fraction = load.getFraction(km); - points[0][counter] = km; - points[1][counter] = fraction.getUnknown(); - counter++; - } } else { logger.error("Unknown facet name: " + facetName); return;
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadTAProcessor.java Wed Aug 27 16:47:38 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadTAProcessor.java Wed Aug 27 19:52:51 2014 +0200 @@ -10,7 +10,6 @@ import org.apache.log4j.Logger; -import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.exports.DiagramGenerator; public class SedimentLoadTAProcessor extends SedimentLoadProcessor{ @@ -24,9 +23,8 @@ @Override public boolean canHandle(String facettype) { - return FacetTypes.IS.SEDIMENT_LOAD_TA(facettype) || - FacetTypes.IS.SEDIMENT_LOAD(facettype) || - FacetTypes.SEDIMENT_LOAD_TA_UNKNOWN.equals(facettype); + return facettype.startsWith("sedimentload") && + !facettype.startsWith("sedimentload.m3a"); } @Override