Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationState.java @ 9176:1614cb14308f
Work on calculations for S-Info flood duration workflow
author | mschaefer |
---|---|
date | Mon, 25 Jun 2018 19:21:11 +0200 |
parents | 23945061daec |
children | a4121ec450d6 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationState.java Mon Jun 25 17:58:11 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationState.java Mon Jun 25 19:21:11 2018 +0200 @@ -14,19 +14,23 @@ import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.ChartArtifact; import org.dive4elements.river.artifacts.D4EArtifact; -import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; +import org.dive4elements.river.artifacts.model.Calculation; import org.dive4elements.river.artifacts.model.CalculationResult; import org.dive4elements.river.artifacts.model.DataFacet; import org.dive4elements.river.artifacts.model.EmptyFacet; import org.dive4elements.river.artifacts.model.FacetTypes; +import org.dive4elements.river.artifacts.model.ReportFacet; import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; +import org.dive4elements.river.artifacts.sinfo.common.FloodDurationProcessor; import org.dive4elements.river.artifacts.states.DefaultState; -/** State in which a waterlevel has been calculated. */ +/** + * Last state of the S-Info flood duration workflow that calculates and outputs the result + */ public class FloodDurationState extends DefaultState { /// ** The log that is used in this state. */ - // private static Logger log = Logger.getLogger(FlowDepthState.class); + // private static Logger log = Logger.getLogger(FloodDurationState.class); private static final long serialVersionUID = 1L; @@ -44,7 +48,6 @@ facets.add(new EmptyFacet()); return null; } - return compute((SINFOArtifact) artifact, context, hash, facets, old); } @@ -71,32 +74,21 @@ return res; final FloodDurationCalculationResults results = (FloodDurationCalculationResults) res.getData(); - - /* add themes for chart, for each result */ - final List<AbstractCalculationExportableResult<FloodDurationCalculationResults>> resultList = results.getResults(); - for (int index = 0; index < resultList.size(); index++) { + final FloodDurationCalculationResult result = results.getResult(); + if (result != null) { + // add themes for chart + final int index = 0; - final AbstractCalculationExportableResult<FloodDurationCalculationResults> result = resultList.get(0); + facets.add(FloodDurationProcessor.createFloodDurationFacet(context, hash, this.id, result, index)); + facets.add(FloodDurationProcessor.createMainValueDurationFacet(context, hash, this.id, result, index)); - /* filtered (zoom dependent mean) flow depth TODO: */ - // facets.add(FloodDurationProcessor.createFlowDepthFilteredFacet(context, hash, this.id, result, index)); - // facets.add(FloodDurationProcessor.createFlowDepthRawFacet(context, hash, this.id, result, index)); - + facets.add(new DataFacet(FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, this.id)); + facets.add(new DataFacet(FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, this.id)); } - if (!resultList.isEmpty()) { - final Facet csv = new DataFacet(FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, this.id); - final Facet pdf = new DataFacet(FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, this.id); - - facets.add(csv); - facets.add(pdf); - } - - // final Calculation report = res.getReport(); - // - // if (report.hasProblems()) { - // facets.add(new ReportFacet(ComputeType.ADVANCE, hash, this.id)); - // } + final Calculation report = res.getReport(); + if (report.hasProblems()) + facets.add(new ReportFacet(ComputeType.ADVANCE, hash, this.id)); return res; }