Mercurial > dive4elements > river
changeset 7186:644b2f461272
issue1435: SedimentYieldArtifact: Add functionality.
Now the overriden state can actually access the load.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 27 Sep 2013 14:37:28 +0200 |
parents | 963b8bd54a63 |
children | 439d8a5b4cfa |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/SedimentYieldArtifact.java |
diffstat | 1 files changed, 33 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/SedimentYieldArtifact.java Fri Sep 27 14:36:05 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/SedimentYieldArtifact.java Fri Sep 27 14:37:28 2013 +0200 @@ -23,9 +23,12 @@ 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.SedimentLoad; 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.states.StaticState; import org.dive4elements.river.artifacts.model.FacetTypes; @@ -76,9 +79,27 @@ } + private Object getSedimentLoad() { + logger.debug("SedimentYieldArtifact.getSedimentLoad"); + String id = getDataAsString(DATA_NAME); + String river = getDataAsString("river"); + + SedimentLoad 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); + 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", @@ -106,9 +127,14 @@ { logger.debug("SedimentYieldArtifact.setup"); + // Refactor? this happens at another place, too // Store id, yield yields. - state = new StaticState(STATIC_STATE_NAME); + state = new StaticState(STATIC_STATE_NAME) { + public Object staticCompute(List<Facet> facets) { + return getSedimentLoad(); + } + }; if (logger.isDebugEnabled()) { logger.debug(XMLUtils.toString(data)); } @@ -119,16 +145,12 @@ // TODO need river, too. // if (code != null) { - // parse code, interact with factory, add real facets. - // store relevant parts of code as data. - // TODO no fakes - String fakeRiver = "Elbe"; - SedimentLoad myLoad = SedimentLoadFactory.getSedimentLoadWithDataUncached(code, fakeRiver); - String name = myLoad.getDescription(); + String name = SedimentLoadFactory.getSedimentYieldDescription(Integer.valueOf(code)); Facet facet = new SedimentLoadFacet( - 0, name, + 0, SEDIMENT_LOAD_COARSE, + name, //???? ComputeType.ADVANCE, state.getID(), "hash" ); @@ -200,8 +222,8 @@ Object context, CallMeta meta) { - logger.debug("initialize"); - // TODO Copy river data! + logger.debug("SedimentYieldArtifact.initialize"); + importData((D4EArtifact) artifact, "river"); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :