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