Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java @ 1190:f514894ec2fd
merged flys-artifacts/2.5
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:17 +0200 |
parents | fbe18ad4caff |
children | 71d5abde92f2 |
comparison
equal
deleted
inserted
replaced
917:b48c36076e17 | 1190:f514894ec2fd |
---|---|
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.FacetTypes; | |
14 import de.intevation.flys.artifacts.model.ReportFacet; | |
15 import de.intevation.flys.artifacts.model.WaterlevelFacet; | |
16 import de.intevation.flys.artifacts.model.WQKms; | |
17 | |
18 import de.intevation.flys.artifacts.model.DataFacet; | |
19 import de.intevation.flys.artifacts.model.CrossSectionFacet; | |
20 import de.intevation.flys.artifacts.model.CrossSectionWaterLineFacet; | |
21 import de.intevation.flys.artifacts.model.CalculationResult; | |
22 | |
23 | |
24 public class WaterlevelState | |
25 extends DefaultState | |
26 implements FacetTypes | |
27 { | |
28 /** The logger that is used in this state. */ | |
29 private static Logger logger = Logger.getLogger(WaterlevelState.class); | |
30 | |
31 | |
32 @Override | |
33 protected String getUIProvider() { | |
34 return "continue"; | |
35 } | |
36 | |
37 | |
38 protected Object compute( | |
39 WINFOArtifact winfo, | |
40 String hash, | |
41 List<Facet> facets, | |
42 Object old | |
43 ) { | |
44 String id = getID(); | |
45 | |
46 CalculationResult res = old instanceof CalculationResult | |
47 ? (CalculationResult)old | |
48 : winfo.getWaterlevelData(); | |
49 | |
50 if (facets == null) { | |
51 return res; | |
52 } | |
53 | |
54 WQKms [] wqkms = (WQKms [])res.getData(); | |
55 | |
56 for (int i = 0; i < wqkms.length; i++) { | |
57 String nameW = null; | |
58 String nameQ = null; | |
59 | |
60 if (winfo.isQ()) { | |
61 nameQ = wqkms[i].getName(); | |
62 nameW = "W(" + nameQ + ")"; | |
63 } | |
64 else { | |
65 nameW = wqkms[i].getName(); | |
66 nameQ = "Q(" + nameQ + ")"; | |
67 } | |
68 | |
69 logger.debug("Create facet: " + nameW); | |
70 logger.debug("Create facet: " + nameQ); | |
71 | |
72 Facet w = new WaterlevelFacet( | |
73 i, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, id, hash); | |
74 Facet q = new WaterlevelFacet( | |
75 i, LONGITUDINAL_Q, nameQ, ComputeType.ADVANCE, id, hash); | |
76 | |
77 facets.add(w); | |
78 facets.add(q); | |
79 } | |
80 | |
81 if (wqkms.length > 0) { | |
82 Facet wst = new DataFacet( | |
83 WST, "WST data", ComputeType.ADVANCE, hash, id); | |
84 Facet csv = new DataFacet( | |
85 CSV, "CSV data", ComputeType.ADVANCE, hash, id); | |
86 | |
87 facets.add(wst); | |
88 facets.add(csv); | |
89 } | |
90 | |
91 if (res.getReport().hasProblems()) { | |
92 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id)); | |
93 } | |
94 | |
95 // Also register the CrossSectionFacet (added to respective out). | |
96 facets.add(new CrossSectionFacet(winfo.getCrossSectionName())); | |
97 // Assume to be in wq_single mode. | |
98 facets.add(new CrossSectionWaterLineFacet("Q=" + winfo.getDataAsString("wq_single"))); | |
99 return res; | |
100 } | |
101 | |
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 */ | |
122 @Override | |
123 public Object computeAdvance( | |
124 FLYSArtifact artifact, | |
125 String hash, | |
126 CallContext context, | |
127 List<Facet> facets, | |
128 Object old | |
129 ) { | |
130 return compute((WINFOArtifact) artifact, hash, facets, old); | |
131 } | |
132 } | |
133 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |