Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java @ 1180:1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
flys-artifacts/trunk@2770 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 16 Sep 2011 08:47:09 +0000 |
parents | 28154920e0b3 |
children | 17648043429f |
comparison
equal
deleted
inserted
replaced
1179:ebb48bef3529 | 1180:1aba1a75beb2 |
---|---|
81 Iterator<String> iter = theData.keySet().iterator(); | 81 Iterator<String> iter = theData.keySet().iterator(); |
82 FLYSArtifact flys = (FLYSArtifact) artifact; | 82 FLYSArtifact flys = (FLYSArtifact) artifact; |
83 | 83 |
84 while (iter.hasNext()) { | 84 while (iter.hasNext()) { |
85 String name = iter.next(); | 85 String name = iter.next(); |
86 appendStaticData(flys, meta, creator, ui, name); | 86 appendStaticData(flys, context, creator, ui, name); |
87 } | 87 } |
88 | 88 |
89 return ui; | 89 return ui; |
90 } | 90 } |
91 | 91 |
92 | 92 |
93 protected void appendStaticData( | 93 protected void appendStaticData( |
94 FLYSArtifact flys, | 94 FLYSArtifact flys, |
95 CallMeta meta, | 95 CallContext context, |
96 ElementCreator creator, | 96 ElementCreator cr, |
97 Element ui, | 97 Element ui, |
98 String name | 98 String name |
99 ) { | 99 ) { |
100 StateData data = getData(flys, name); | 100 StateData data = getData(flys, name); |
101 String value = (data != null) ? (String) data.getValue() : null; | 101 String value = (data != null) ? (String) data.getValue() : null; |
104 return; | 104 return; |
105 } | 105 } |
106 | 106 |
107 logger.debug("Append element '" + name + "' (" + value + ")"); | 107 logger.debug("Append element '" + name + "' (" + value + ")"); |
108 | 108 |
109 Element e = createStaticData(cr, context, name, value, data.getType()); | |
110 | |
111 ui.appendChild(e); | |
112 | |
113 } | |
114 | |
115 | |
116 /** | |
117 * Creates a <i>data</i> element used in the static part of the DESCRIBE | |
118 * document. | |
119 * | |
120 * @param creator The ElementCreator that is used to build new Elements. | |
121 * @param meta The CallMeta object used for i18n. | |
122 * @param name The name of the data item. | |
123 * @param value The value as string. | |
124 * | |
125 * @return an Element. | |
126 */ | |
127 protected Element createStaticData( | |
128 ElementCreator creator, | |
129 CallContext cc, | |
130 String name, | |
131 String value, | |
132 String type | |
133 ) { | |
134 CallMeta meta = cc.getMeta(); | |
135 | |
109 Element dataElement = creator.create("data"); | 136 Element dataElement = creator.create("data"); |
110 creator.addAttr(dataElement, "name", name, true); | 137 creator.addAttr(dataElement, "name", name, true); |
111 creator.addAttr(dataElement, "type", data.getType(), true); | 138 creator.addAttr(dataElement, "type", type, true); |
112 | 139 |
113 Element itemElement = creator.create("item"); | 140 Element itemElement = creator.create("item"); |
114 creator.addAttr(itemElement, "value", value, true); | 141 creator.addAttr(itemElement, "value", value, true); |
115 | 142 |
116 String attrValue = ""; | 143 String attrValue = ""; |
126 catch (NumberFormatException nfe) { | 153 catch (NumberFormatException nfe) { |
127 attrValue = Resources.getMsg(meta, value, value); | 154 attrValue = Resources.getMsg(meta, value, value); |
128 } | 155 } |
129 | 156 |
130 creator.addAttr(itemElement, "label", attrValue, true); | 157 creator.addAttr(itemElement, "label", attrValue, true); |
131 | |
132 dataElement.appendChild(itemElement); | 158 dataElement.appendChild(itemElement); |
133 ui.appendChild(dataElement); | 159 |
160 return dataElement; | |
134 } | 161 } |
135 | 162 |
136 | 163 |
137 public Element describe( | 164 public Element describe( |
138 Artifact artifact, | 165 Artifact artifact, |
258 return null; | 285 return null; |
259 } | 286 } |
260 | 287 |
261 | 288 |
262 /** | 289 /** |
290 * This method is used to create an <i>item</i> Element that contains two | |
291 * further elements <i>label</i> and <i>value</i>. The label and value | |
292 * elements both have text nodes. | |
293 * | |
294 * @param cr The ElementCreator used to build new Elements. | |
295 * @param obj This implementation awaits a String array with [0] = label and | |
296 * [1] = value. | |
297 * | |
298 * @return an Element. | |
299 */ | |
300 protected Element createItem(XMLUtils.ElementCreator cr, Object obj) { | |
301 Element item = ProtocolUtils.createArtNode(cr, "item", null, null); | |
302 Element label = ProtocolUtils.createArtNode(cr, "label", null, null); | |
303 Element value = ProtocolUtils.createArtNode(cr, "value", null, null); | |
304 | |
305 String[] arr = (String[]) obj; | |
306 | |
307 label.setTextContent(arr[0]); | |
308 value.setTextContent(arr[1]); | |
309 | |
310 item.appendChild(label); | |
311 item.appendChild(value); | |
312 | |
313 return item; | |
314 } | |
315 | |
316 | |
317 /** | |
263 * This method transform a given value into a StateData object. | 318 * This method transform a given value into a StateData object. |
264 * | 319 * |
265 * @param flys The FLYSArtifact. | 320 * @param flys The FLYSArtifact. |
266 * @param name The name of the data object. | 321 * @param name The name of the data object. |
267 * @param val The value of the data object. | 322 * @param val The value of the data object. |