Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java @ 1725:d9afb16d1fd4
Store parameterization in data, not in fields.
flys-artifacts/trunk@3007 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 18 Oct 2011 13:28:39 +0000 |
parents | 690037105542 |
children | e3b9164a85fe |
comparison
equal
deleted
inserted
replaced
1724:0349dd524f9c | 1725:d9afb16d1fd4 |
---|---|
4 import java.util.List; | 4 import java.util.List; |
5 | 5 |
6 import org.apache.log4j.Logger; | 6 import org.apache.log4j.Logger; |
7 | 7 |
8 import org.w3c.dom.Document; | 8 import org.w3c.dom.Document; |
9 | |
10 import de.intevation.artifactdatabase.data.DefaultStateData; | |
9 | 11 |
10 import de.intevation.artifactdatabase.state.Facet; | 12 import de.intevation.artifactdatabase.state.Facet; |
11 import de.intevation.artifactdatabase.state.DefaultOutput; | 13 import de.intevation.artifactdatabase.state.DefaultOutput; |
12 import de.intevation.artifactdatabase.state.State; | 14 import de.intevation.artifactdatabase.state.State; |
13 | 15 |
48 "/art:action/art:ids/@value"; | 50 "/art:action/art:ids/@value"; |
49 | 51 |
50 /** One and only state to be in. */ | 52 /** One and only state to be in. */ |
51 protected transient State state = null; | 53 protected transient State state = null; |
52 | 54 |
53 protected int col_pos; | |
54 | |
55 protected int wst_id; | |
56 | |
57 | 55 |
58 /** | 56 /** |
59 * Trivial Constructor. | 57 * Trivial Constructor. |
60 */ | 58 */ |
61 public StaticWKmsArtifact() { | 59 public StaticWKmsArtifact() { |
77 logger.debug("StaticWKmsArtifact.setup"); | 75 logger.debug("StaticWKmsArtifact.setup"); |
78 | 76 |
79 state = new StaticState( | 77 state = new StaticState( |
80 "state.additional_wkms.static", | 78 "state.additional_wkms.static", |
81 "state.additional_wkms.static"); | 79 "state.additional_wkms.static"); |
80 | |
82 List<Facet> fs = new ArrayList<Facet>(); | 81 List<Facet> fs = new ArrayList<Facet>(); |
83 logger.debug(XMLUtils.toString(data)); | 82 logger.debug(XMLUtils.toString(data)); |
84 String code = XMLUtils.xpathString( | 83 String code = XMLUtils.xpathString( |
85 data, XPATH_DATA, ArtifactNamespaceContext.INSTANCE); | 84 data, XPATH_DATA, ArtifactNamespaceContext.INSTANCE); |
86 | 85 |
87 logger.debug("makes: " + code); | 86 logger.debug("makes: " + code); |
88 | 87 |
88 // TODO Go for JSON, one day. | |
89 //ex.: flood_protection-wstv-114-12 | 89 //ex.: flood_protection-wstv-114-12 |
90 if (code != null) { | 90 if (code != null) { |
91 String [] parts = code.split("-"); | 91 String [] parts = code.split("-"); |
92 int col = Integer.valueOf(parts[2]); | 92 |
93 int wst = Integer.valueOf(parts[3]); | 93 if (parts.length >= 4) { |
94 // These shall be put in data (addData) | 94 try { |
95 this.col_pos = col; | 95 Integer.valueOf(parts[2]); |
96 this.wst_id = wst; | 96 Integer.valueOf(parts[3]); |
97 // addDataAsString? | 97 addStringData("col_pos", parts[2]); |
98 addStringData("wst_id", parts[3]); | |
99 } | |
100 catch (Exception e) {} | |
101 } | |
98 } | 102 } |
99 | 103 |
100 // Will get col_id and wst_id | |
101 | |
102 Facet facet = new WKmsFacet(Resources.getMsg(callMeta, | 104 Facet facet = new WKmsFacet(Resources.getMsg(callMeta, |
103 "facet.discharge_curves.mainvalues.w", | 105 "facet.discharge_curves.mainvalues.w", |
104 "facet.discharge_curves.mainvalues.w")); | 106 "facet.discharge_curves.mainvalues.w")); |
105 fs.add(facet); | 107 fs.add(facet); |
106 facets.put(state.getID(), fs); | 108 facets.put(state.getID(), fs); |
110 } | 112 } |
111 | 113 |
112 | 114 |
113 /** | 115 /** |
114 * Initialize the static state with output. | 116 * Initialize the static state with output. |
117 * @return static state | |
115 */ | 118 */ |
116 protected State spawnState() { | 119 protected State spawnState() { |
117 state = new StaticState( | 120 state = new StaticState( |
118 "state.additional_wkms.static", | 121 "state.additional_wkms.static", |
119 "state.additional_wkms.static"); | 122 "state.additional_wkms.static"); |
199 logger.debug("StaticWKmsArtifact.getWKms"); | 202 logger.debug("StaticWKmsArtifact.getWKms"); |
200 | 203 |
201 // TODO KIND is not needed. | 204 // TODO KIND is not needed. |
202 return WKmsFactory.getWKms( | 205 return WKmsFactory.getWKms( |
203 WKmsFactory.KIND_PROTECTION, | 206 WKmsFactory.KIND_PROTECTION, |
204 this.col_pos, | 207 Integer.valueOf(getDataAsString("col_pos")), |
205 this.wst_id); | 208 Integer.valueOf(getDataAsString("wst_id"))); |
206 } | 209 } |
207 } | 210 } |
208 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : | 211 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |