Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentState.java @ 9150:23945061daec
gigantic refactoring: exporter, result, results
to support multiple jaspers -> collisions
author | gernotbelger |
---|---|
date | Thu, 14 Jun 2018 16:56:31 +0200 |
parents | 3828c7d820ef |
children | 740d65e4aa14 |
rev | line source |
---|---|
8951 | 1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.artifacts.sinfo.flowdepthdev; | |
11 | |
12 import java.util.List; | |
13 | |
14 import org.dive4elements.artifactdatabase.state.Facet; | |
15 import org.dive4elements.artifacts.CallContext; | |
16 import org.dive4elements.river.artifacts.ChartArtifact; | |
17 import org.dive4elements.river.artifacts.D4EArtifact; | |
8953
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8951
diff
changeset
|
18 import org.dive4elements.river.artifacts.model.Calculation; |
8951 | 19 import org.dive4elements.river.artifacts.model.CalculationResult; |
8953
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8951
diff
changeset
|
20 import org.dive4elements.river.artifacts.model.DataFacet; |
8951 | 21 import org.dive4elements.river.artifacts.model.EmptyFacet; |
8953
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8951
diff
changeset
|
22 import org.dive4elements.river.artifacts.model.FacetTypes; |
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8951
diff
changeset
|
23 import org.dive4elements.river.artifacts.model.ReportFacet; |
8951 | 24 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; |
8956 | 25 import org.dive4elements.river.artifacts.sinfo.common.FlowDepthDevelopmentPerYearProcessor; |
26 import org.dive4elements.river.artifacts.sinfo.common.FlowDepthDevelopmentProcessor; | |
27 import org.dive4elements.river.artifacts.sinfo.common.FlowDepthProcessor; | |
8951 | 28 import org.dive4elements.river.artifacts.states.DefaultState; |
29 | |
30 /** | |
31 * @author Gernot Belger | |
32 */ | |
33 public class FlowDepthDevelopmentState extends DefaultState { | |
34 | |
35 private static final long serialVersionUID = 1L; | |
36 | |
37 /** | |
38 * From this state can only be continued trivially. | |
39 */ | |
40 @Override | |
41 protected String getUIProvider() { | |
42 return "continue"; | |
43 } | |
44 | |
45 @Override | |
46 public Object computeFeed(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { | |
47 // FIXME: why is this necessary? | |
48 if (artifact instanceof ChartArtifact) { | |
49 facets.add(new EmptyFacet()); | |
50 return null; | |
51 } | |
52 | |
53 return compute((SINFOArtifact) artifact, context, hash, facets, old); | |
54 } | |
55 | |
56 @Override | |
57 public Object computeAdvance(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { | |
58 if (artifact instanceof ChartArtifact) { | |
59 facets.add(new EmptyFacet()); | |
60 return null; | |
61 } | |
62 return compute((SINFOArtifact) artifact, context, hash, facets, old); | |
63 } | |
64 | |
65 /** | |
66 * Compute result or returned object from cache, create facets. | |
67 * | |
68 * @param old | |
69 * Object that was cached. | |
70 */ | |
71 private Object compute(final SINFOArtifact sinfo, final CallContext context, final String hash, final List<Facet> facets, final Object old) { | |
72 | |
73 final CalculationResult res = doCompute(sinfo, context, old); | |
74 | |
75 if (facets == null) | |
76 return res; | |
77 | |
8953
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8951
diff
changeset
|
78 final FlowDepthDevelopmentCalculationResults results = (FlowDepthDevelopmentCalculationResults) res.getData(); |
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8951
diff
changeset
|
79 final FlowDepthDevelopmentCalculationResult result = results.getResult(); |
8980
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
80 if (result != null) { |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9083
diff
changeset
|
81 // final FlowDepthDevelopmentCalculationResult result = (FlowDepthDevelopmentCalculationResult) resultList.get(0); |
8980
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
82 /* add themes for chart, for each result */ |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
83 final int index = 0; |
8956 | 84 |
8980
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
85 // /* filtered (zoom dependent mean) flow depth development */ |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
86 facets.add(FlowDepthDevelopmentProcessor.createFlowDepthDevelopmentFilteredFacet(context, hash, this.id, result, index)); |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
87 facets.add(FlowDepthDevelopmentProcessor.createFlowDepthDevelopmentRawFacet(context, hash, this.id, result, index)); |
8956 | 88 |
9083 | 89 facets.add(FlowDepthDevelopmentPerYearProcessor.createFlowDepthDevelopmentFilteredFacet(context, hash, this.id, result, index)); |
90 facets.add(FlowDepthDevelopmentPerYearProcessor.createFlowDepthDevelopmentRawFacet(context, hash, this.id, result, index)); | |
91 | |
8980
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
92 facets.add(FlowDepthDevelopmentProcessor.createWaterlevelDifferenceFacet(context, hash, this.id, result, index)); |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
93 facets.add(FlowDepthDevelopmentProcessor.createBedHeightDifferenceFacet(context, hash, this.id, result, index)); |
8956 | 94 |
8980
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
95 facets.add(FlowDepthProcessor.createFlowDepthCurrentFilteredFacet(context, hash, this.id, result, index)); |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
96 facets.add(FlowDepthProcessor.createFlowDepthCurrentRawFacet(context, hash, this.id, result, index)); |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
97 facets.add(FlowDepthProcessor.createFlowDepthHistoricalFilteredFacet(context, hash, this.id, result, index)); |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
98 facets.add(FlowDepthProcessor.createFlowDepthHistoricalRawFacet(context, hash, this.id, result, index)); |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
99 |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
100 facets.add(new DataFacet(FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, this.id)); |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
101 facets.add(new DataFacet(FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, this.id)); |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8956
diff
changeset
|
102 } |
8953
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8951
diff
changeset
|
103 |
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8951
diff
changeset
|
104 final Calculation report = res.getReport(); |
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8951
diff
changeset
|
105 if (report.hasProblems()) |
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8951
diff
changeset
|
106 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, this.id)); |
8951 | 107 |
108 return res; | |
109 } | |
110 | |
111 private CalculationResult doCompute(final SINFOArtifact sinfo, final CallContext context, final Object old) { | |
112 if (old instanceof CalculationResult) | |
113 return (CalculationResult) old; | |
114 | |
115 return new FlowDepthDevelopmentCalculation(context).calculate(sinfo); | |
116 } | |
117 } |