Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DischargeLongitudinalSection.java @ 3318:dbe2f85bf160
merged flys-artifacts/2.8
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:35 +0200 |
parents | 555ed85af32e |
children | 65bfb6faa538 |
comparison
equal
deleted
inserted
replaced
2987:98c7a46ec5ae | 3318:dbe2f85bf160 |
---|---|
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.ChartArtifact; | |
14 | |
15 import de.intevation.flys.artifacts.model.CrossSectionWaterLineFacet; | |
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.EmptyFacet; | |
20 | |
21 import de.intevation.flys.artifacts.model.WQKms; | |
22 import de.intevation.flys.artifacts.model.WQCKms; | |
23 import de.intevation.flys.artifacts.model.CalculationResult; | |
24 | |
25 import de.intevation.flys.artifacts.model.DataFacet; | |
26 | |
27 public class DischargeLongitudinalSection | |
28 extends DefaultState | |
29 implements FacetTypes | |
30 { | |
31 private static Logger logger = | |
32 Logger.getLogger(DischargeLongitudinalSection.class); | |
33 | |
34 | |
35 @Override | |
36 public Object computeAdvance( | |
37 FLYSArtifact artifact, | |
38 String hash, | |
39 CallContext context, | |
40 List<Facet> facets, | |
41 Object old | |
42 ) { | |
43 if (artifact instanceof ChartArtifact) { | |
44 ChartArtifact chart = (ChartArtifact)artifact; | |
45 facets.add(new EmptyFacet()); | |
46 return null; | |
47 } | |
48 | |
49 WINFOArtifact winfo = (WINFOArtifact)artifact; | |
50 | |
51 CalculationResult res = old instanceof CalculationResult | |
52 ? (CalculationResult)old | |
53 : winfo.getDischargeLongitudinalSectionData(); | |
54 | |
55 if (facets == null) { | |
56 return res; | |
57 } | |
58 | |
59 WQKms [] wqkms = (WQKms [])res.getData(); | |
60 | |
61 for (int i = 0; i < wqkms.length; i++) { | |
62 String nameW = null; | |
63 String nameQ = null; | |
64 | |
65 if (winfo.isQ()) { | |
66 nameQ = wqkms[i].getName(); | |
67 nameW = "W(" + nameQ + ")"; | |
68 } | |
69 else { | |
70 nameW = wqkms[i].getName(); | |
71 nameQ = "Q(" + nameW + ")"; | |
72 } | |
73 | |
74 Facet w = new WaterlevelFacet( | |
75 i, DISCHARGE_LONGITUDINAL_W, nameW); | |
76 | |
77 Facet q = new WaterlevelFacet( | |
78 i, DISCHARGE_LONGITUDINAL_Q, nameQ); | |
79 | |
80 Facet s = new CrossSectionWaterLineFacet(i, nameW); | |
81 | |
82 facets.add(s); | |
83 facets.add(w); | |
84 facets.add(q); | |
85 | |
86 if (wqkms[i] instanceof WQCKms) { | |
87 // TODO DO i18n | |
88 | |
89 String nameC = nameW.replace( | |
90 "benutzerdefiniert", | |
91 "benutzerdefiniert [korrigiert]"); | |
92 | |
93 Facet c = new WaterlevelFacet( | |
94 i, DISCHARGE_LONGITUDINAL_C, nameC); | |
95 | |
96 // Here, avoid index clash with Facet "s" above and | |
97 // signal the WINFO later that we want to access Cs. | |
98 Facet r = new CrossSectionWaterLineFacet(i + 1, nameC); | |
99 | |
100 facets.add(c); | |
101 facets.add(r); | |
102 } | |
103 } | |
104 | |
105 if (wqkms.length > 0) { | |
106 facets.add(new DataFacet(CSV, "CSV data")); | |
107 facets.add(new DataFacet(WST, "WST data")); | |
108 } | |
109 | |
110 if (res.getReport().hasProblems()) { | |
111 facets.add(new ReportFacet()); | |
112 } | |
113 | |
114 return res; | |
115 } | |
116 } | |
117 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |