Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthState.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 | 5294114b1df4 |
children | a4121ec450d6 |
rev | line source |
---|---|
8854 | 1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 | |
9 package org.dive4elements.river.artifacts.sinfo.flowdepth; | |
10 | |
11 import java.util.List; | |
12 | |
13 import org.dive4elements.artifactdatabase.state.Facet; | |
14 import org.dive4elements.artifacts.CallContext; | |
15 import org.dive4elements.river.artifacts.ChartArtifact; | |
16 import org.dive4elements.river.artifacts.D4EArtifact; | |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9040
diff
changeset
|
17 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; |
8854 | 18 import org.dive4elements.river.artifacts.model.Calculation; |
19 import org.dive4elements.river.artifacts.model.CalculationResult; | |
20 import org.dive4elements.river.artifacts.model.DataFacet; | |
21 import org.dive4elements.river.artifacts.model.EmptyFacet; | |
22 import org.dive4elements.river.artifacts.model.FacetTypes; | |
23 import org.dive4elements.river.artifacts.model.ReportFacet; | |
24 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; | |
8940
82998242ba84
Preparing for additional outputs of SINFO-Tkh
gernotbelger
parents:
8916
diff
changeset
|
25 import org.dive4elements.river.artifacts.sinfo.common.FlowDepthProcessor; |
8916 | 26 import org.dive4elements.river.artifacts.sinfo.common.TkhProcessor; |
8854 | 27 import org.dive4elements.river.artifacts.states.DefaultState; |
28 | |
29 /** State in which a waterlevel has been calculated. */ | |
8884 | 30 public class FlowDepthState extends DefaultState { |
31 | |
8854 | 32 /// ** The log that is used in this state. */ |
33 // private static Logger log = Logger.getLogger(FlowDepthState.class); | |
34 | |
8877 | 35 private static final long serialVersionUID = 1L; |
36 | |
8854 | 37 /** |
38 * From this state can only be continued trivially. | |
39 */ | |
40 @Override | |
41 protected String getUIProvider() { | |
42 return "continue"; | |
43 } | |
44 | |
45 @Override | |
8884 | 46 public Object computeFeed(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { |
8879 | 47 if (artifact instanceof ChartArtifact) { |
48 facets.add(new EmptyFacet()); | |
49 return null; | |
50 } | |
51 | |
52 return compute((SINFOArtifact) artifact, context, hash, facets, old); | |
53 } | |
54 | |
55 @Override | |
8884 | 56 public Object computeAdvance(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { |
8854 | 57 if (artifact instanceof ChartArtifact) { |
58 facets.add(new EmptyFacet()); | |
59 return null; | |
60 } | |
61 return compute((SINFOArtifact) artifact, context, hash, facets, old); | |
62 } | |
63 | |
64 /** | |
65 * Compute result or returned object from cache, create facets. | |
8884 | 66 * |
67 * @param old | |
68 * Object that was cached. | |
8854 | 69 */ |
8884 | 70 private Object compute(final SINFOArtifact sinfo, final CallContext context, final String hash, final List<Facet> facets, final Object old) { |
8879 | 71 |
8914
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
72 final CalculationResult res = doCompute(sinfo, context, old); |
8854 | 73 |
8914
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
74 if (facets == null) |
8854 | 75 return res; |
76 | |
8884 | 77 final FlowDepthCalculationResults results = (FlowDepthCalculationResults) res.getData(); |
8854 | 78 |
79 /* add themes for chart, for each result */ | |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9040
diff
changeset
|
80 final List<AbstractCalculationExportableResult<FlowDepthCalculationResults>> resultList = results.getResults(); |
8854 | 81 for (int index = 0; index < resultList.size(); index++) { |
82 | |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9040
diff
changeset
|
83 final FlowDepthCalculationResult result = (FlowDepthCalculationResult) resultList.get(index); |
8879 | 84 |
85 /* filtered (zoom dependent mean) flow depth */ | |
8980
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8940
diff
changeset
|
86 facets.add(FlowDepthProcessor.createFlowDepthFilteredFacet(context, hash, this.id, result, index)); |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8940
diff
changeset
|
87 facets.add(FlowDepthProcessor.createFlowDepthRawFacet(context, hash, this.id, result, index)); |
8879 | 88 |
8884 | 89 if (results.isUseTkh()) { |
90 /* filtered (zoom dependent mean) flow depth including tkh */ | |
8980
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8940
diff
changeset
|
91 facets.add(FlowDepthProcessor.createFlowDepthTkhFilteredFacet(context, hash, this.id, result, index)); |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8940
diff
changeset
|
92 facets.add(FlowDepthProcessor.createFlowDepthTkhRawFacet(context, hash, this.id, result, index)); |
8884 | 93 |
8916 | 94 facets.add(TkhProcessor.createTkhFacet(context, hash, this.id, result, index)); |
8884 | 95 } |
8879 | 96 } |
8854 | 97 |
8884 | 98 if (!resultList.isEmpty()) { |
99 final Facet csv = new DataFacet(FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, this.id); | |
100 final Facet pdf = new DataFacet(FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, this.id); | |
8854 | 101 |
102 facets.add(csv); | |
103 facets.add(pdf); | |
104 } | |
105 | |
106 final Calculation report = res.getReport(); | |
107 | |
108 if (report.hasProblems()) { | |
8879 | 109 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, this.id)); |
8854 | 110 } |
111 | |
112 return res; | |
113 } | |
8914
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
114 |
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
115 private CalculationResult doCompute(final SINFOArtifact sinfo, final CallContext context, final Object old) { |
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
116 if (old instanceof CalculationResult) |
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
117 return (CalculationResult) old; |
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
118 |
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
119 return new FlowDepthCalculation(context).calculate(sinfo); |
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
120 } |
8854 | 121 } |