comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.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
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 16
17 import de.intevation.flys.artifacts.model.DataFacet; 17 import de.intevation.flys.artifacts.model.DataFacet;
18 import de.intevation.flys.artifacts.model.CalculationResult;
18 19
19 20
20 public class WaterlevelState 21 public class WaterlevelState
21 extends DefaultState 22 extends DefaultState
22 implements FacetTypes 23 implements FacetTypes
33 List<Facet> facets, 34 List<Facet> facets,
34 Object old 35 Object old
35 ) { 36 ) {
36 WINFOArtifact winfo = (WINFOArtifact)artifact; 37 WINFOArtifact winfo = (WINFOArtifact)artifact;
37 38
38 WQKms [] res; 39 CalculationResult res = old instanceof CalculationResult
39 40 ? (CalculationResult)old
40 if (old instanceof WQKms []) { 41 : winfo.getWaterlevelData();
41 res = (WQKms [])old;
42 }
43 else {
44 res = winfo.getWaterlevelData();
45 if (res == null) {
46 logger.debug("No results given.");
47 return null;
48 }
49 }
50 42
51 if (facets == null) { 43 if (facets == null) {
52 return res; 44 return res;
53 } 45 }
54 46
55 for (int i = 0; i < res.length; i++) { 47 WQKms [] wqkms = (WQKms [])res.getData();
48
49 for (int i = 0; i < wqkms.length; i++) {
56 String nameW = null; 50 String nameW = null;
57 String nameQ = null; 51 String nameQ = null;
58 52
59 if (winfo.isQ()) { 53 if (winfo.isQ()) {
60 nameQ = res[i].getName(); 54 nameQ = wqkms[i].getName();
61 nameW = "W(" + nameQ + ")"; 55 nameW = "W(" + nameQ + ")";
62 } 56 }
63 else { 57 else {
64 nameW = res[i].getName(); 58 nameW = wqkms[i].getName();
65 nameQ = "Q(" + nameQ + ")"; 59 nameQ = "Q(" + nameQ + ")";
66 } 60 }
67 61
68 logger.debug("Create facet: " + nameW); 62 logger.debug("Create facet: " + nameW);
69 logger.debug("Create facet: " + nameQ); 63 logger.debug("Create facet: " + nameQ);
73 67
74 facets.add(w); 68 facets.add(w);
75 facets.add(q); 69 facets.add(q);
76 } 70 }
77 71
78 if (res.length > 0) { 72 if (wqkms.length > 0) {
79 Facet wst = new DataFacet(WST, "WST data"); 73 Facet wst = new DataFacet(WST, "WST data");
80 Facet csv = new DataFacet(CSV, "CSV data"); 74 Facet csv = new DataFacet(CSV, "CSV data");
81 75
82 facets.add(wst); 76 facets.add(wst);
83 facets.add(csv); 77 facets.add(csv);

http://dive4elements.wald.intevation.org