comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java @ 1140:96d7842e80ee

Cosmetics, refactored, resolved todo. flys-artifacts/trunk@2661 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 07 Sep 2011 09:26:34 +0000
parents d90f5bfa3ddf
children bcba246d9c03
comparison
equal deleted inserted replaced
1139:6d9b08b958e2 1140:96d7842e80ee
34 protected String getUIProvider() { 34 protected String getUIProvider() {
35 return "continue"; 35 return "continue";
36 } 36 }
37 37
38 38
39 // TODO This is a duplicate of computeAdvance. Resolve. 39 protected Object compute(
40 public Object computeFeed( 40 WINFOArtifact winfo,
41 FLYSArtifact artifact, 41 String hash,
42 String hash, 42 List<Facet> facets,
43 CallContext context, 43 Object old
44 List<Facet> facets,
45 Object old
46 ) { 44 ) {
47 WINFOArtifact winfo = (WINFOArtifact)artifact;
48
49 String id = getID(); 45 String id = getID();
50 46
51 CalculationResult res = old instanceof CalculationResult 47 CalculationResult res = old instanceof CalculationResult
52 ? (CalculationResult)old 48 ? (CalculationResult)old
53 : winfo.getWaterlevelData(); 49 : winfo.getWaterlevelData();
102 facets.add(new CrossSectionWaterLineFacet("facet.cross_section_water_line")); 98 facets.add(new CrossSectionWaterLineFacet("facet.cross_section_water_line"));
103 return res; 99 return res;
104 } 100 }
105 101
106 102
103 /**
104 * @param context Ignored.
105 */
106 @Override
107 public Object computeFeed(
108 FLYSArtifact artifact,
109 String hash,
110 CallContext context,
111 List<Facet> facets,
112 Object old
113 ) {
114 return compute((WINFOArtifact) artifact, hash, facets, old);
115
116 }
117
118
119 /**
120 * @param context Ignored.
121 */
107 @Override 122 @Override
108 public Object computeAdvance( 123 public Object computeAdvance(
109 FLYSArtifact artifact, 124 FLYSArtifact artifact,
110 String hash, 125 String hash,
111 CallContext context, 126 CallContext context,
112 List<Facet> facets, 127 List<Facet> facets,
113 Object old 128 Object old
114 ) { 129 ) {
115 WINFOArtifact winfo = (WINFOArtifact)artifact; 130 return compute((WINFOArtifact) artifact, hash, facets, old);
116
117 String id = getID();
118
119 CalculationResult res = old instanceof CalculationResult
120 ? (CalculationResult)old
121 : winfo.getWaterlevelData();
122
123 if (facets == null) {
124 return res;
125 }
126
127 WQKms [] wqkms = (WQKms [])res.getData();
128
129 for (int i = 0; i < wqkms.length; i++) {
130 String nameW = null;
131 String nameQ = null;
132
133 if (winfo.isQ()) {
134 nameQ = wqkms[i].getName();
135 nameW = "W(" + nameQ + ")";
136 }
137 else {
138 nameW = wqkms[i].getName();
139 nameQ = "Q(" + nameQ + ")";
140 }
141
142 logger.debug("Create facet: " + nameW);
143 logger.debug("Create facet: " + nameQ);
144
145 Facet w = new WaterlevelFacet(
146 i, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, id, hash);
147 Facet q = new WaterlevelFacet(
148 i, LONGITUDINAL_Q, nameQ, ComputeType.ADVANCE, id, hash);
149
150 facets.add(w);
151 facets.add(q);
152 }
153
154 if (wqkms.length > 0) {
155 Facet wst = new DataFacet(
156 WST, "WST data", ComputeType.ADVANCE, hash, id);
157 Facet csv = new DataFacet(
158 CSV, "CSV data", ComputeType.ADVANCE, hash, id);
159
160 facets.add(wst);
161 facets.add(csv);
162 }
163
164 if (res.getReport().hasProblems()) {
165 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id));
166 }
167
168 // Also register the CrossSectionFacet (added to respective out).
169 facets.add(new CrossSectionFacet("facet.cross_section"));
170 facets.add(new CrossSectionWaterLineFacet("facet.cross_section_water_line"));
171 return res;
172 } 131 }
173 } 132 }
174 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : 133 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org