Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstState.java @ 9274:1c8eeaf6031f
bundu.wst workflow
author | gernotbelger |
---|---|
date | Thu, 19 Jul 2018 17:33:24 +0200 |
parents | 02739b8c010d |
children | 6ffcbb4f35d5 |
rev | line source |
---|---|
9274 | 1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by Intevation GmbH | |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
3 * |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
7 */ |
9274 | 8 |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
9 package org.dive4elements.river.artifacts.bundu.bezugswst; |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
10 |
9274 | 11 import java.text.DateFormat; |
12 import java.util.Collection; | |
13 import java.util.Date; | |
14 import java.util.List; | |
15 | |
16 import org.apache.log4j.Logger; | |
17 import org.dive4elements.artifactdatabase.state.Facet; | |
18 import org.dive4elements.artifacts.CallContext; | |
19 import org.dive4elements.artifacts.CallMeta; | |
20 import org.dive4elements.river.artifacts.D4EArtifact; | |
21 import org.dive4elements.river.artifacts.access.FixRealizingAccess; | |
22 import org.dive4elements.river.artifacts.model.CalculationResult; | |
23 import org.dive4elements.river.artifacts.model.CrossSectionWaterLineFacet; | |
24 import org.dive4elements.river.artifacts.model.DataFacet; | |
25 import org.dive4elements.river.artifacts.model.FacetTypes; | |
26 import org.dive4elements.river.artifacts.model.ReportFacet; | |
27 import org.dive4elements.river.artifacts.model.WQCKms; | |
28 import org.dive4elements.river.artifacts.model.WQKms; | |
29 import org.dive4elements.river.artifacts.model.fixings.FixOutlierFacet; | |
30 import org.dive4elements.river.artifacts.model.fixings.FixRealizingCalculation; | |
31 import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult; | |
32 import org.dive4elements.river.artifacts.model.fixings.FixReferenceEventsFacet; | |
33 import org.dive4elements.river.artifacts.model.fixings.FixWQCurveFacet; | |
34 import org.dive4elements.river.artifacts.model.fixings.FixWaterlevelFacet; | |
35 import org.dive4elements.river.artifacts.resources.Resources; | |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
36 import org.dive4elements.river.artifacts.states.DefaultState; |
9274 | 37 import org.dive4elements.river.utils.Formatter; |
38 import org.dive4elements.river.utils.UniqueDateFormatter; | |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
39 |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
40 /** |
9274 | 41 * State to compute the fixation realizing (vollmer) results. |
42 * | |
43 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
44 */ |
9274 | 45 public class BezugswstState extends DefaultState implements FacetTypes { |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
46 |
9274 | 47 /* |
48 * TODO: THIS CLASS IS A CLONE OF FixRealizingCompute | |
49 * + | |
50 * ++ | |
51 * +++ | |
52 * ++++ | |
53 * +++++ | |
54 * ++++++ | |
55 * +++++++ | |
56 * ++++++++ | |
57 * +++++++++ | |
58 * ++++++++++ | |
59 * +++++++++++ | |
60 * IT does not work here | |
61 */ | |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
62 |
9274 | 63 /** The log used in this class. */ |
64 private static Logger log = Logger.getLogger(BezugswstState.class); | |
65 | |
66 public static final String I18N_WQ_CURVE = "fix.vollmer.wq.curve"; | |
67 | |
68 public static final String I18N_WQ_OUTLIER = "fix.vollmer.wq.outliers"; | |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
69 |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
70 /** |
9274 | 71 * The default constructor that initializes an empty State object. |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
72 */ |
9274 | 73 public BezugswstState() { |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
74 } |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
75 |
9274 | 76 @Override |
77 public Object computeAdvance(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { | |
78 log.debug("BezugswstState.computeAdvance"); | |
79 | |
80 CalculationResult res; | |
81 | |
82 final FixRealizingAccess access = new FixRealizingAccess(artifact); | |
83 | |
84 if (old instanceof CalculationResult) { | |
85 res = (CalculationResult) old; | |
86 } else { | |
87 final FixRealizingCalculation calc = new FixRealizingCalculation(access); | |
88 res = calc.calculate(); | |
89 } | |
90 | |
91 if (facets == null) { | |
92 return res; | |
93 } | |
94 | |
95 if (res.getReport().hasProblems()) { | |
96 facets.add(new ReportFacet()); | |
97 } | |
98 | |
99 final String id = getID(); | |
100 final CallMeta meta = context.getMeta(); | |
101 | |
102 final FixRealizingResult fixRes = (FixRealizingResult) res.getData(); | |
103 final WQKms[] wqkms = fixRes != null ? fixRes.getWQKms() : new WQKms[0]; | |
104 | |
105 for (int i = 0; i < wqkms.length; i++) { | |
106 String nameW = null; | |
107 String nameQ = null; | |
108 | |
109 if (access.isQ()) { | |
110 nameQ = wqkms[i].getName(); | |
111 nameW = "W(" + nameQ + ")"; | |
112 } else { | |
113 nameW = wqkms[i].getName(); | |
114 nameQ = "Q(" + nameW + ")"; | |
115 } | |
116 | |
117 final Facet wq = new FixWaterlevelFacet(i, FIX_WQ_LS, nameW, ComputeType.ADVANCE, hash, id); | |
118 | |
119 final Facet w = new FixWaterlevelFacet(i, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, hash, id); | |
120 | |
121 final Facet q = new FixWaterlevelFacet(i, LONGITUDINAL_Q, nameQ, ComputeType.ADVANCE, hash, id); | |
122 final Facet csFacet = new CrossSectionWaterLineFacet(i, nameW); | |
123 | |
124 facets.add(wq); | |
125 facets.add(w); | |
126 facets.add(q); | |
127 facets.add(csFacet); | |
128 | |
129 // XXX: THIS CAN NOT HAPPEN! REMOVE IT! | |
130 if (wqkms[i] instanceof WQCKms) { | |
131 final String nameC = nameW.replace("benutzerdefiniert", "benutzerdefiniert [korrigiert]"); | |
132 | |
133 final Facet c = new FixWaterlevelFacet(i, DISCHARGE_LONGITUDINAL_C, nameC); | |
134 | |
135 facets.add(c); | |
136 } | |
137 } | |
138 | |
139 if (wqkms.length > 0) { | |
140 final DateFormat df = Formatter.getDateFormatter(context.getMeta(), "dd.MM.yyyy"); | |
141 final DateFormat lf = Formatter.getDateFormatter(context.getMeta(), "dd.MM.yyyy'T'HH:mm"); | |
142 | |
143 final Collection<Date> reds = fixRes.getReferenceEventsDates(); | |
144 final UniqueDateFormatter cf = new UniqueDateFormatter(df, lf, reds); | |
145 | |
146 int i = 0; | |
147 for (final Date d : reds) { | |
148 facets.add(new FixReferenceEventsFacet((1 << 9) | i, FIX_EVENTS, cf.format(d))); | |
149 i++; | |
150 } | |
151 | |
152 facets.add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id)); | |
153 | |
154 facets.add(new DataFacet(WST, "WST data", ComputeType.ADVANCE, hash, id)); | |
155 | |
156 facets.add(new DataFacet(PDF, "PDF data", ComputeType.ADVANCE, hash, id)); | |
157 } | |
158 | |
159 facets.add(new DataFacet(AT, "AT data", ComputeType.ADVANCE, hash, id)); | |
160 | |
161 facets.add(new FixWQCurveFacet(0, Resources.getMsg(meta, I18N_WQ_CURVE, I18N_WQ_CURVE) + " (" + access.getFunction() + ")")); | |
162 | |
163 if (access.getPreprocessing()) { | |
164 facets.add(new FixOutlierFacet(0, FIX_OUTLIER, Resources.getMsg(meta, I18N_WQ_OUTLIER, I18N_WQ_OUTLIER))); | |
165 } | |
166 | |
167 return res; | |
168 } | |
169 } |