Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java @ 3814:8083f6384023
merged flys-artifacts/pre2.6-2012-01-04
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:56 +0200 |
parents | e384d78ff78b |
children | 907322e269e3 |
comparison
equal
deleted
inserted
replaced
1491:2a00f4849738 | 3814:8083f6384023 |
---|---|
1 package de.intevation.flys.artifacts.states; | |
2 | |
3 import java.util.List; | |
4 | |
5 import org.apache.log4j.Logger; | |
6 | |
7 import de.intevation.artifacts.CallContext; | |
8 | |
9 import de.intevation.artifactdatabase.state.Facet; | |
10 | |
11 import de.intevation.flys.artifacts.FLYSArtifact; | |
12 import de.intevation.flys.artifacts.WINFOArtifact; | |
13 import de.intevation.flys.artifacts.model.DataFacet; | |
14 import de.intevation.flys.artifacts.model.CrossSectionWaterLineFacet; | |
15 import de.intevation.flys.artifacts.model.CalculationResult; | |
16 import de.intevation.flys.artifacts.model.FacetTypes; | |
17 import de.intevation.flys.artifacts.model.ReportFacet; | |
18 import de.intevation.flys.artifacts.model.WaterlevelFacet; | |
19 import de.intevation.flys.artifacts.model.WQKms; | |
20 import de.intevation.flys.utils.FLYSUtils; | |
21 | |
22 | |
23 public class WaterlevelState | |
24 extends DefaultState | |
25 implements FacetTypes | |
26 { | |
27 /** The logger that is used in this state. */ | |
28 private static Logger logger = Logger.getLogger(WaterlevelState.class); | |
29 | |
30 | |
31 /** | |
32 * From this state can only be continued trivially. | |
33 */ | |
34 @Override | |
35 protected String getUIProvider() { | |
36 return "continue"; | |
37 } | |
38 | |
39 | |
40 protected Object compute( | |
41 WINFOArtifact winfo, | |
42 CallContext cc, | |
43 String hash, | |
44 List<Facet> facets, | |
45 Object old | |
46 ) { | |
47 String id = getID(); | |
48 | |
49 CalculationResult res = old instanceof CalculationResult | |
50 ? (CalculationResult)old | |
51 : winfo.getWaterlevelData(); | |
52 | |
53 if (facets == null) { | |
54 return res; | |
55 } | |
56 | |
57 WQKms [] wqkms = (WQKms [])res.getData(); | |
58 | |
59 for (int i = 0; i < wqkms.length; i++) { | |
60 String name = wqkms[i].getName(); | |
61 | |
62 String nameW = FLYSUtils.createWspWTitle(winfo, cc, name); | |
63 String nameQ = FLYSUtils.createWspQTitle(winfo, cc, name); | |
64 | |
65 logger.debug("Create facet: " + nameW); | |
66 logger.debug("Create facet: " + nameQ); | |
67 | |
68 Facet w = new WaterlevelFacet( | |
69 i, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, id, hash); | |
70 Facet q = new WaterlevelFacet( | |
71 i, LONGITUDINAL_Q, nameQ, ComputeType.ADVANCE, id, hash); | |
72 | |
73 facets.add(new CrossSectionWaterLineFacet(i, nameQ)); | |
74 | |
75 facets.add(w); | |
76 facets.add(q); | |
77 } | |
78 | |
79 if (wqkms.length > 0) { | |
80 Facet wst = new DataFacet( | |
81 WST, "WST data", ComputeType.ADVANCE, hash, id); | |
82 Facet csv = new DataFacet( | |
83 CSV, "CSV data", ComputeType.ADVANCE, hash, id); | |
84 | |
85 facets.add(wst); | |
86 facets.add(csv); | |
87 } | |
88 | |
89 if (res.getReport().hasProblems()) { | |
90 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id)); | |
91 } | |
92 | |
93 return res; | |
94 } | |
95 | |
96 | |
97 /** | |
98 * @param context Ignored. | |
99 */ | |
100 @Override | |
101 public Object computeFeed( | |
102 FLYSArtifact artifact, | |
103 String hash, | |
104 CallContext context, | |
105 List<Facet> facets, | |
106 Object old | |
107 ) { | |
108 return compute((WINFOArtifact) artifact, context, hash, facets, old); | |
109 } | |
110 | |
111 | |
112 /** | |
113 * @param context Ignored. | |
114 */ | |
115 @Override | |
116 public Object computeAdvance( | |
117 FLYSArtifact artifact, | |
118 String hash, | |
119 CallContext context, | |
120 List<Facet> facets, | |
121 Object old | |
122 ) { | |
123 return compute((WINFOArtifact) artifact, context, hash, facets, old); | |
124 } | |
125 } | |
126 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |