Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DischargeLongitudinalSection.java @ 709:3b7e9ddf6bb1
New model to transport data and error reports of calculations.
flys-artifacts/trunk@2165 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 20 Jun 2011 12:32:32 +0000 |
parents | 853dceead0f4 |
children | 69c8541edcc7 |
comparison
equal
deleted
inserted
replaced
708:757ff56b43b3 | 709:3b7e9ddf6bb1 |
---|---|
12 import de.intevation.flys.artifacts.WINFOArtifact; | 12 import de.intevation.flys.artifacts.WINFOArtifact; |
13 import de.intevation.flys.artifacts.model.FacetTypes; | 13 import de.intevation.flys.artifacts.model.FacetTypes; |
14 import de.intevation.flys.artifacts.model.WaterlevelFacet; | 14 import de.intevation.flys.artifacts.model.WaterlevelFacet; |
15 import de.intevation.flys.artifacts.model.WQKms; | 15 import de.intevation.flys.artifacts.model.WQKms; |
16 import de.intevation.flys.artifacts.model.WQCKms; | 16 import de.intevation.flys.artifacts.model.WQCKms; |
17 import de.intevation.flys.artifacts.model.CalculationResult; | |
17 | 18 |
18 import de.intevation.flys.artifacts.model.DataFacet; | 19 import de.intevation.flys.artifacts.model.DataFacet; |
19 | 20 |
20 public class DischargeLongitudinalSection | 21 public class DischargeLongitudinalSection |
21 extends DefaultState | 22 extends DefaultState |
31 String hash, | 32 String hash, |
32 CallContext context, | 33 CallContext context, |
33 List<Facet> facets, | 34 List<Facet> facets, |
34 Object old | 35 Object old |
35 ) { | 36 ) { |
36 WQKms [] res; | 37 CalculationResult res; |
37 | 38 |
38 WINFOArtifact winfo = (WINFOArtifact)artifact; | 39 WINFOArtifact winfo = (WINFOArtifact)artifact; |
39 | 40 |
40 if (old instanceof WQCKms []) { | 41 if (old instanceof CalculationResult) { |
41 res = (WQCKms [])old; | 42 res = (CalculationResult)old; |
42 } | 43 } |
43 else { | 44 else { |
44 res = winfo.getDischargeLongitudinalSectionData(); | 45 res = winfo.getDischargeLongitudinalSectionData(); |
45 | |
46 if (res == null) { | |
47 logger.debug("No results given."); | |
48 return null; | |
49 } | |
50 } | 46 } |
51 | 47 |
52 if (facets == null) { | 48 if (facets == null) { |
53 return res; | 49 return res; |
54 } | 50 } |
55 | 51 |
56 for (int i = 0; i < res.length; i++) { | 52 WQKms [] wqkms = (WQKms [])res.getData(); |
53 | |
54 for (int i = 0; i < wqkms.length; i++) { | |
57 String nameW = null; | 55 String nameW = null; |
58 String nameQ = null; | 56 String nameQ = null; |
59 | 57 |
60 if (winfo.isQ()) { | 58 if (winfo.isQ()) { |
61 nameQ = res[i].getName(); | 59 nameQ = wqkms[i].getName(); |
62 nameW = "W(" + nameQ + ")"; | 60 nameW = "W(" + nameQ + ")"; |
63 } | 61 } |
64 else { | 62 else { |
65 nameW = res[i].getName(); | 63 nameW = wqkms[i].getName(); |
66 nameQ = "Q(" + nameQ + ")"; | 64 nameQ = "Q(" + nameQ + ")"; |
67 } | 65 } |
68 | 66 |
69 Facet w = new WaterlevelFacet( | 67 Facet w = new WaterlevelFacet( |
70 i, DISCHARGE_LONGITUDINAL_W, nameW); | 68 i, DISCHARGE_LONGITUDINAL_W, nameW); |
73 i, DISCHARGE_LONGITUDINAL_Q, nameQ); | 71 i, DISCHARGE_LONGITUDINAL_Q, nameQ); |
74 | 72 |
75 facets.add(w); | 73 facets.add(w); |
76 facets.add(q); | 74 facets.add(q); |
77 | 75 |
78 if (res[i] instanceof WQCKms) { | 76 if (wqkms[i] instanceof WQCKms) { |
79 // TODO DO i18n | 77 // TODO DO i18n |
80 | 78 |
81 String nameC = nameW.replace( | 79 String nameC = nameW.replace( |
82 "Benutzerdefiniert", | 80 "Benutzerdefiniert", |
83 "Benutzerdefiniert [korrigiert]"); | 81 "Benutzerdefiniert [korrigiert]"); |
87 | 85 |
88 facets.add(c); | 86 facets.add(c); |
89 } | 87 } |
90 } | 88 } |
91 | 89 |
92 if (res.length > 0) { | 90 if (wqkms.length > 0) { |
93 facets.add(new DataFacet(CSV, "CSV data")); | 91 facets.add(new DataFacet(CSV, "CSV data")); |
94 facets.add(new DataFacet(WST, "WST data")); | 92 facets.add(new DataFacet(WST, "WST data")); |
95 } | 93 } |
96 | 94 |
97 return res; | 95 return res; |