Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineState.java @ 9426:b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
author | gernotbelger |
---|---|
date | Fri, 17 Aug 2018 15:31:16 +0200 |
parents | 6f7e92c16050 |
children | bd5f5d2220fa |
rev | line source |
---|---|
8996 | 1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
8996
diff
changeset
|
2 * Software engineering by |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
8996
diff
changeset
|
3 * Björnsen Beratende Ingenieure GmbH |
8996 | 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.uinfo.salix; | |
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; | |
18 import org.dive4elements.river.artifacts.model.Calculation; | |
19 import org.dive4elements.river.artifacts.model.CalculationResult; | |
9426
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
20 import org.dive4elements.river.artifacts.model.CrossSectionWaterLineFacet; |
8996 | 21 import org.dive4elements.river.artifacts.model.DataFacet; |
22 import org.dive4elements.river.artifacts.model.EmptyFacet; | |
23 import org.dive4elements.river.artifacts.model.FacetTypes; | |
24 import org.dive4elements.river.artifacts.model.ReportFacet; | |
9316
72b3270e1568
U-Info salix line with regional and supraregional scenario calculation and chart display
mschaefer
parents:
9295
diff
changeset
|
25 import org.dive4elements.river.artifacts.resources.Resources; |
8996 | 26 import org.dive4elements.river.artifacts.states.DefaultState; |
27 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; | |
28 | |
29 /** | |
30 * @author Domenico Nardi Tironi | |
31 */ | |
32 public class SalixLineState extends DefaultState { | |
33 | |
34 private static final long serialVersionUID = 1L; | |
35 | |
36 /** | |
37 * From this state can only be continued trivially. | |
38 */ | |
39 @Override | |
40 protected String getUIProvider() { | |
41 return "continue"; | |
42 } | |
43 | |
44 @Override | |
45 public Object computeFeed(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { | |
46 // FIXME: why is this necessary? | |
47 if (artifact instanceof ChartArtifact) { | |
48 facets.add(new EmptyFacet()); | |
49 return null; | |
50 } | |
51 | |
9426
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
52 return compute((UINFOArtifact) artifact, context, ComputeType.FEED, hash, facets, old); |
8996 | 53 } |
54 | |
55 @Override | |
56 public Object computeAdvance(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { | |
57 if (artifact instanceof ChartArtifact) { | |
58 facets.add(new EmptyFacet()); | |
59 return null; | |
60 } | |
9426
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
61 return compute((UINFOArtifact) artifact, context, ComputeType.ADVANCE, hash, facets, old); |
8996 | 62 } |
63 | |
64 /** | |
65 * Compute result or returned object from cache, create facets. | |
66 * | |
67 * @param old | |
68 * Object that was cached. | |
69 */ | |
9426
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
70 private Object compute(final UINFOArtifact uinfo, final CallContext context, final ComputeType type, final String hash, final List<Facet> facets, |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
71 final Object old) { |
8996 | 72 |
9316
72b3270e1568
U-Info salix line with regional and supraregional scenario calculation and chart display
mschaefer
parents:
9295
diff
changeset
|
73 final CalculationResult res = doCompute(uinfo, context, old); |
8996 | 74 |
75 if (facets == null) | |
76 return res; | |
77 | |
78 final SalixLineCalculationResults results = (SalixLineCalculationResults) res.getData(); | |
79 | |
9361
2aec052d4088
Refactoring on SalixLineCalculationResult etc., calculation using MQ etc., scenario (regional+supra) csv columns and meta data added
mschaefer
parents:
9347
diff
changeset
|
80 final List<SalixLineCalculationResult> resultList = results.getResults(); |
8996 | 81 |
9426
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
82 final String stateId = getID(); |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
83 |
9347 | 84 int facetIndex = 0; |
85 | |
8996 | 86 if (!resultList.isEmpty()) { |
9426
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
87 facets.add(SalixLineProcessor.createSalixLineFilteredFacet(context, hash, stateId, facetIndex++, 0)); |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
88 facets.add(SalixLineProcessor.createSalixLineRawFacet(context, hash, stateId, facetIndex++, 0)); |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
89 facets.add(SalixLineProcessor.createSalixMnwMwFilteredFacet(context, hash, stateId, facetIndex++, 0)); |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
90 facets.add(SalixLineProcessor.createSalixMnwMwRawFacet(context, hash, stateId, facetIndex++, 0)); |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
91 facets.add(SalixLineProcessor.createSalixRankFacet(context, hash, stateId, facetIndex++, 0)); |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
92 |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
93 facets.add(new CrossSectionWaterLineFacet(facetIndex++, "Salix Linie (!I10N!)", type, hash, stateId, SalixLineCrossSectionIndexData.salixLine())); |
9347 | 94 |
9361
2aec052d4088
Refactoring on SalixLineCalculationResult etc., calculation using MQ etc., scenario (regional+supra) csv columns and meta data added
mschaefer
parents:
9347
diff
changeset
|
95 final SalixLineCalculationResult result = resultList.get(0); |
9347 | 96 |
9361
2aec052d4088
Refactoring on SalixLineCalculationResult etc., calculation using MQ etc., scenario (regional+supra) csv columns and meta data added
mschaefer
parents:
9347
diff
changeset
|
97 for (int i = 0; i <= result.getScenarioCount() - 1; i++) { |
2aec052d4088
Refactoring on SalixLineCalculationResult etc., calculation using MQ etc., scenario (regional+supra) csv columns and meta data added
mschaefer
parents:
9347
diff
changeset
|
98 final String sublabel = Resources.getMsg(context.getMeta(), "uinfo_salix_scenario_deltaw", "uinfo_salix_scenario_deltaw", |
2aec052d4088
Refactoring on SalixLineCalculationResult etc., calculation using MQ etc., scenario (regional+supra) csv columns and meta data added
mschaefer
parents:
9347
diff
changeset
|
99 result.getScenarioLabel(i)); |
2aec052d4088
Refactoring on SalixLineCalculationResult etc., calculation using MQ etc., scenario (regional+supra) csv columns and meta data added
mschaefer
parents:
9347
diff
changeset
|
100 // REMARK: using data index as facetIndex, as we know there is only one result of this type. Else we should just |
2aec052d4088
Refactoring on SalixLineCalculationResult etc., calculation using MQ etc., scenario (regional+supra) csv columns and meta data added
mschaefer
parents:
9347
diff
changeset
|
101 // increment |
9426
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
102 facets.add(SalixLineProcessor.createSalixScenarioFilteredFacet(context, hash, stateId, i, 0, facetIndex++, sublabel)); |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
103 facets.add(SalixLineProcessor.createSalixScenarioRawFacet(context, hash, stateId, i, 0, facetIndex++, sublabel)); |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
104 |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
105 facets.add(new CrossSectionWaterLineFacet(facetIndex++, "Salix Linie Scenario (!I10N! )" + i, type, hash, stateId, |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
106 SalixLineCrossSectionIndexData.scenario(i))); |
9316
72b3270e1568
U-Info salix line with regional and supraregional scenario calculation and chart display
mschaefer
parents:
9295
diff
changeset
|
107 } |
9295
385b52ccde23
Work on U-Info salix line calculation and chart (no scenario case)
mschaefer
parents:
9243
diff
changeset
|
108 |
9426
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
109 // FIXME: add cross section wst lines (MW, MMHW, ...) |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
110 |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
111 final Facet csv = new DataFacet(FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, stateId); |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
112 final Facet pdf = new DataFacet(FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, stateId); |
8996 | 113 |
114 facets.add(csv); | |
115 facets.add(pdf); | |
116 } | |
117 | |
118 final Calculation report = res.getReport(); | |
119 | |
120 if (report.hasProblems()) | |
9426
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
121 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, stateId)); |
8996 | 122 |
123 return res; | |
124 } | |
125 | |
9295
385b52ccde23
Work on U-Info salix line calculation and chart (no scenario case)
mschaefer
parents:
9243
diff
changeset
|
126 private CalculationResult doCompute(final UINFOArtifact uinfo, final CallContext context, final Object old) { |
8996 | 127 if (old instanceof CalculationResult) |
128 return (CalculationResult) old; | |
129 | |
9295
385b52ccde23
Work on U-Info salix line calculation and chart (no scenario case)
mschaefer
parents:
9243
diff
changeset
|
130 return new SalixLineCalculation(context).calculate(uinfo); |
8996 | 131 } |
132 } |