comparison gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionBase.java @ 77:0e38f512f7e4

Some improvements an bugfixes done gnv-artifacts/trunk@92 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Wed, 16 Sep 2009 07:49:46 +0000
parents 2473440671ce
children 969faa37a11b
comparison
equal deleted inserted replaced
76:2473440671ce 77:0e38f512f7e4
33 /** 33 /**
34 * @author Tim Englich <tim.englich@intevation.de> 34 * @author Tim Englich <tim.englich@intevation.de>
35 * 35 *
36 */ 36 */
37 public abstract class TransitionBase implements Transition { 37 public abstract class TransitionBase implements Transition {
38
39 /**
40 * The UID of this Class
41 */
42 private static final long serialVersionUID = 2411169179001645426L;
43
38 /** 44 /**
39 * the logger, used to log exceptions and additonaly information 45 * the logger, used to log exceptions and additonaly information
40 */ 46 */
41 private static Logger log = Logger.getLogger(GNVArtifactBase.class); 47 private static Logger log = Logger.getLogger(GNVArtifactBase.class);
42 48
236 242
237 if(this.descibeData != null){ 243 if(this.descibeData != null){
238 ArtifactXMLUtilities xmlutilities = new ArtifactXMLUtilities(); 244 ArtifactXMLUtilities xmlutilities = new ArtifactXMLUtilities();
239 Iterator<Object> it = this.descibeData.iterator(); 245 Iterator<Object> it = this.descibeData.iterator();
240 while (it.hasNext()){ 246 while (it.hasNext()){
247
241 Object o = it.next(); 248 Object o = it.next();
242 if (o instanceof Collection<?>){ 249 if (!it.hasNext()){
243 Element selectNode = xmlutilities.createXFormElement(document,"select"); 250 if (o instanceof Collection<?>){
244 // TODO: HACK: 251 Element selectNode = xmlutilities.createXFormElement(document,"select");
245 // BESSERE LÖSUNG FINDEN 252 // TODO: HACK:
246 Object[] names = this.inputValueNames.toArray(); 253 // BESSERE LÖSUNG FINDEN
247 String name = names[names.length-1].toString(); 254 Object[] names = this.inputValueNames.toArray();
248 255 String name = names[names.length-1].toString();
249 selectNode.setAttribute("ref", name); 256
250 257 selectNode.setAttribute("ref", name);
251 Element lableNode = xmlutilities.createXFormElement(document, "label"); 258
252 lableNode.setTextContent(name); 259 Element lableNode = xmlutilities.createXFormElement(document, "label");
253 Element choiceNode = xmlutilities.createXFormElement(document, "choices"); 260 lableNode.setTextContent(name);
254 261 Element choiceNode = xmlutilities.createXFormElement(document, "choices");
255 Collection<KeyValueDescibeData> values = (Collection)o; 262
256 Iterator<KeyValueDescibeData> resultIt = values.iterator(); 263 Collection<KeyValueDescibeData> values = (Collection)o;
257 while (resultIt.hasNext()){ 264 Iterator<KeyValueDescibeData> resultIt = values.iterator();
258 KeyValueDescibeData result = resultIt.next(); 265 while (resultIt.hasNext()){
259 Element itemNode = xmlutilities.createXFormElement(document, "item"); 266 KeyValueDescibeData result = resultIt.next();
260 267 Element itemNode = xmlutilities.createXFormElement(document, "item");
261 268
262 Element choiceLableNode = xmlutilities.createXFormElement(document, "label"); 269
263 choiceLableNode.setTextContent(result.getValue()); 270 Element choiceLableNode = xmlutilities.createXFormElement(document, "label");
264 itemNode.appendChild(choiceLableNode); 271 choiceLableNode.setTextContent(result.getValue());
265 272 itemNode.appendChild(choiceLableNode);
266 Element choicValueNode = xmlutilities.createXFormElement(document, "value"); 273
267 choicValueNode.setTextContent(""+result.getKey()); 274 Element choicValueNode = xmlutilities.createXFormElement(document, "value");
268 itemNode.appendChild(choicValueNode); 275 choicValueNode.setTextContent(""+result.getKey());
269 276 itemNode.appendChild(choicValueNode);
270 choiceNode.appendChild(itemNode); 277
278 choiceNode.appendChild(itemNode);
279 }
280 selectNode.appendChild(lableNode);
281 selectNode.appendChild(choiceNode);
282 rootNode.appendChild(selectNode);
283 }else if (o instanceof MinMaxDescribeData){
284 MinMaxDescribeData descibeData = (MinMaxDescribeData)o;
285 Object min = descibeData.getMinValue();
286 Object max = descibeData.getMaxValue();
287 if (min instanceof GregorianCalendar){
288 Date d = ((GregorianCalendar)min).getTime();
289 min = DateUtils.getPatternedDateAmer(d);
290 }
291
292 if (max instanceof GregorianCalendar){
293 Date d = ((GregorianCalendar)max).getTime();
294 max = DateUtils.getPatternedDateAmer(d);
295 }
296
297 Element inputMinNode = xmlutilities.createXFormElement(document, "input");
298 inputMinNode.setAttribute("ref", "minvalue");
299 Element inputMinLableNode = xmlutilities.createXFormElement(document, "label");
300 inputMinLableNode.setTextContent("minvalue");
301 inputMinNode.appendChild(inputMinLableNode);
302
303 Element inputMinValueNode = xmlutilities.createXFormElement(document, "value");
304 inputMinValueNode.setTextContent(min.toString());
305 inputMinNode.appendChild(inputMinValueNode);
306
307 Element inputMaxNode = xmlutilities.createXFormElement(document, "input");
308 inputMaxNode.setAttribute("ref", "maxvalue");
309 Element inputMaxLableNode = xmlutilities.createXFormElement(document, "label");
310 inputMaxLableNode.setTextContent("maxvalue");
311 inputMaxNode.appendChild(inputMaxLableNode);
312
313 Element inputMaxValueNode = xmlutilities.createXFormElement(document, "value");
314 inputMaxValueNode.setTextContent(max.toString());
315 inputMaxNode.appendChild(inputMaxValueNode);
316
317 rootNode.appendChild(inputMinNode);
318 rootNode.appendChild(inputMaxNode);
319
271 } 320 }
272 selectNode.appendChild(lableNode); 321
273 selectNode.appendChild(choiceNode);
274 rootNode.appendChild(selectNode);
275 }else if (o instanceof MinMaxDescribeData){
276 MinMaxDescribeData descibeData = (MinMaxDescribeData)o;
277 Object min = descibeData.getMinValue();
278 Object max = descibeData.getMaxValue();
279 if (min instanceof GregorianCalendar){
280 Date d = ((GregorianCalendar)min).getTime();
281 min = DateUtils.getPatternedDateAmer(d);
282 }
283
284 if (max instanceof GregorianCalendar){
285 Date d = ((GregorianCalendar)max).getTime();
286 max = DateUtils.getPatternedDateAmer(d);
287 }
288
289 Element inputMinNode = xmlutilities.createXFormElement(document, "input");
290 inputMinNode.setAttribute("ref", "minvalue");
291 Element inputMinLableNode = xmlutilities.createXFormElement(document, "label");
292 inputMinLableNode.setTextContent("minvalue");
293 inputMinNode.appendChild(inputMinLableNode);
294
295 Element inputMinValueNode = xmlutilities.createXFormElement(document, "value");
296 inputMinValueNode.setTextContent(min.toString());
297 inputMinNode.appendChild(inputMinValueNode);
298
299 Element inputMaxNode = xmlutilities.createXFormElement(document, "input");
300 inputMaxNode.setAttribute("ref", "maxvalue");
301 Element inputMaxLableNode = xmlutilities.createXFormElement(document, "label");
302 inputMaxLableNode.setTextContent("maxvalue");
303 inputMaxNode.appendChild(inputMaxLableNode);
304
305 Element inputMaxValueNode = xmlutilities.createXFormElement(document, "value");
306 inputMaxValueNode.setTextContent(max.toString());
307 inputMaxNode.appendChild(inputMaxValueNode);
308
309 rootNode.appendChild(inputMinNode);
310 rootNode.appendChild(inputMaxNode);
311
312 } 322 }
313
314 } 323 }
315 } 324 }
316 325
317 } 326 }
318 327

http://dive4elements.wald.intevation.org