comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixRealizingCompute.java @ 9082:42c15e2f95fb

2.3.4.1.4 Wasserstand falsche Einheit FixAnalysis PDF start
author gernotbelger
date Fri, 25 May 2018 10:44:24 +0200
parents e4f9e2316e92
children 0c621beceb2f
comparison
equal deleted inserted replaced
9081:a0feac6ea1ba 9082:42c15e2f95fb
12 import java.util.Collection; 12 import java.util.Collection;
13 import java.util.Date; 13 import java.util.Date;
14 import java.util.List; 14 import java.util.List;
15 15
16 import org.apache.log4j.Logger; 16 import org.apache.log4j.Logger;
17
18 import org.dive4elements.artifactdatabase.state.Facet; 17 import org.dive4elements.artifactdatabase.state.Facet;
19 import org.dive4elements.artifacts.CallContext; 18 import org.dive4elements.artifacts.CallContext;
20 import org.dive4elements.artifacts.CallMeta; 19 import org.dive4elements.artifacts.CallMeta;
21 import org.dive4elements.river.artifacts.D4EArtifact; 20 import org.dive4elements.river.artifacts.D4EArtifact;
22 import org.dive4elements.river.artifacts.access.FixRealizingAccess; 21 import org.dive4elements.river.artifacts.access.FixRealizingAccess;
56 * The default constructor that initializes an empty State object. 55 * The default constructor that initializes an empty State object.
57 */ 56 */
58 public FixRealizingCompute() { 57 public FixRealizingCompute() {
59 } 58 }
60 59
61
62 @Override 60 @Override
63 public Object computeAdvance( 61 public Object computeAdvance(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) {
64 D4EArtifact artifact,
65 String hash,
66 CallContext context,
67 List<Facet> facets,
68 Object old
69 ) {
70 log.debug("FixRealizingCompute.computeAdvance"); 62 log.debug("FixRealizingCompute.computeAdvance");
71 63
72 CalculationResult res; 64 CalculationResult res;
73 65
74 FixRealizingAccess access = new FixRealizingAccess(artifact); 66 final FixRealizingAccess access = new FixRealizingAccess(artifact);
75 67
76 if (old instanceof CalculationResult) { 68 if (old instanceof CalculationResult) {
77 res = (CalculationResult) old; 69 res = (CalculationResult) old;
78 } 70 } else {
79 else { 71 final FixRealizingCalculation calc = new FixRealizingCalculation(access);
80 FixRealizingCalculation calc = new FixRealizingCalculation(access);
81 res = calc.calculate(); 72 res = calc.calculate();
82 } 73 }
83 74
84 if (facets == null) { 75 if (facets == null) {
85 return res; 76 return res;
87 78
88 if (res.getReport().hasProblems()) { 79 if (res.getReport().hasProblems()) {
89 facets.add(new ReportFacet()); 80 facets.add(new ReportFacet());
90 } 81 }
91 82
92 String id = getID(); 83 final String id = getID();
93 CallMeta meta = context.getMeta(); 84 final CallMeta meta = context.getMeta();
94 85
95 FixRealizingResult fixRes = (FixRealizingResult) res.getData(); 86 final FixRealizingResult fixRes = (FixRealizingResult) res.getData();
96 WQKms [] wqkms = fixRes != null ? fixRes.getWQKms() : new WQKms[0]; 87 final WQKms[] wqkms = fixRes != null ? fixRes.getWQKms() : new WQKms[0];
97 88
98 for (int i = 0; i < wqkms.length; i++) { 89 for (int i = 0; i < wqkms.length; i++) {
99 String nameW = null; 90 String nameW = null;
100 String nameQ = null; 91 String nameQ = null;
101 92
102 if (access.isQ()) { 93 if (access.isQ()) {
103 nameQ = wqkms[i].getName(); 94 nameQ = wqkms[i].getName();
104 nameW = "W(" + nameQ + ")"; 95 nameW = "W(" + nameQ + ")";
105 } 96 } else {
106 else {
107 nameW = wqkms[i].getName(); 97 nameW = wqkms[i].getName();
108 nameQ = "Q(" + nameW + ")"; 98 nameQ = "Q(" + nameW + ")";
109 } 99 }
110 100
111 Facet wq = new FixWaterlevelFacet( 101 final Facet wq = new FixWaterlevelFacet(i, FIX_WQ_LS, nameW, ComputeType.ADVANCE, hash, id);
112 i, FIX_WQ_LS, nameW, ComputeType.ADVANCE, hash, id);
113 102
114 Facet w = new FixWaterlevelFacet( 103 final Facet w = new FixWaterlevelFacet(i, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, hash, id);
115 i, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, hash, id);
116 104
117 Facet q = new FixWaterlevelFacet( 105 final Facet q = new FixWaterlevelFacet(i, LONGITUDINAL_Q, nameQ, ComputeType.ADVANCE, hash, id);
118 i, LONGITUDINAL_Q, nameQ, ComputeType.ADVANCE, hash, id); 106 final Facet csFacet = new CrossSectionWaterLineFacet(i, nameW);
119 Facet csFacet = new CrossSectionWaterLineFacet(i, nameW);
120 107
121 facets.add(wq); 108 facets.add(wq);
122 facets.add(w); 109 facets.add(w);
123 facets.add(q); 110 facets.add(q);
124 facets.add(csFacet); 111 facets.add(csFacet);
125 112
126 // XXX: THIS CAN NOT HAPPEN! REMOVE IT! 113 // XXX: THIS CAN NOT HAPPEN! REMOVE IT!
127 if (wqkms[i] instanceof WQCKms) { 114 if (wqkms[i] instanceof WQCKms) {
128 String nameC = nameW.replace( 115 final String nameC = nameW.replace("benutzerdefiniert", "benutzerdefiniert [korrigiert]");
129 "benutzerdefiniert",
130 "benutzerdefiniert [korrigiert]");
131 116
132 Facet c = new FixWaterlevelFacet( 117 final Facet c = new FixWaterlevelFacet(i, DISCHARGE_LONGITUDINAL_C, nameC);
133 i, DISCHARGE_LONGITUDINAL_C, nameC);
134 118
135 facets.add(c); 119 facets.add(c);
136 } 120 }
137 } 121 }
138 122
139 if (wqkms.length > 0) { 123 if (wqkms.length > 0) {
140 DateFormat df = Formatter.getDateFormatter(context.getMeta(), 124 final DateFormat df = Formatter.getDateFormatter(context.getMeta(), "dd.MM.yyyy");
141 "dd.MM.yyyy"); 125 final DateFormat lf = Formatter.getDateFormatter(context.getMeta(), "dd.MM.yyyy'T'HH:mm");
142 DateFormat lf = Formatter.getDateFormatter(context.getMeta(),
143 "dd.MM.yyyy'T'HH:mm");
144 126
145 Collection<Date> reds = fixRes.getReferenceEventsDates(); 127 final Collection<Date> reds = fixRes.getReferenceEventsDates();
146 UniqueDateFormatter cf = new UniqueDateFormatter(df, lf, reds); 128 final UniqueDateFormatter cf = new UniqueDateFormatter(df, lf, reds);
147 129
148 int i = 0; 130 int i = 0;
149 for (Date d: reds) { 131 for (final Date d : reds) {
150 facets.add(new FixReferenceEventsFacet( 132 facets.add(new FixReferenceEventsFacet((1 << 9) | i, FIX_EVENTS, cf.format(d)));
151 (1 << 9) | i,
152 FIX_EVENTS,
153 cf.format(d)));
154 i++; 133 i++;
155 } 134 }
156 135
157 facets.add( 136 facets.add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id));
158 new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id));
159 137
160 facets.add( 138 facets.add(new DataFacet(WST, "WST data", ComputeType.ADVANCE, hash, id));
161 new DataFacet(WST, "WST data", ComputeType.ADVANCE, hash, id));
162 139
163 facets.add( 140 facets.add(new DataFacet(PDF, "PDF data", ComputeType.ADVANCE, hash, id));
164 new DataFacet(PDF, "PDF data", ComputeType.ADVANCE, hash, id));
165 } 141 }
166 142
167 facets.add( 143 facets.add(new DataFacet(AT, "AT data", ComputeType.ADVANCE, hash, id));
168 new DataFacet(AT, "AT data", ComputeType.ADVANCE, hash, id));
169 144
170 facets.add(new FixWQCurveFacet( 145 facets.add(new FixWQCurveFacet(0, Resources.getMsg(meta, I18N_WQ_CURVE, I18N_WQ_CURVE) + " (" + access.getFunction() + ")"));
171 0,
172 Resources.getMsg(meta, I18N_WQ_CURVE, I18N_WQ_CURVE) + " ("
173 + access.getFunction() + ")"));
174 146
175 if (access.getPreprocessing()) { 147 if (access.getPreprocessing()) {
176 facets.add(new FixOutlierFacet( 148 facets.add(new FixOutlierFacet(0, FIX_OUTLIER, Resources.getMsg(meta, I18N_WQ_OUTLIER, I18N_WQ_OUTLIER)));
177 0,
178 FIX_OUTLIER,
179 Resources.getMsg(meta, I18N_WQ_OUTLIER, I18N_WQ_OUTLIER)));
180 } 149 }
181 150
182 return res; 151 return res;
183 } 152 }
184 } 153 }
185 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org