Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java @ 79:e33c61735a4e
Implementation of the Static UI done
gnv-artifacts/trunk@101 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Thu, 17 Sep 2009 13:38:12 +0000 |
parents | 969faa37a11b |
children | 5eb62df21f9a |
comparison
equal
deleted
inserted
replaced
78:969faa37a11b | 79:e33c61735a4e |
---|---|
79 */ | 79 */ |
80 @Override | 80 @Override |
81 public Document advance(Document target, CallContext context) { | 81 public Document advance(Document target, CallContext context) { |
82 if (this.productArtifact == null){ | 82 if (this.productArtifact == null){ |
83 if (this.current != null){ | 83 if (this.current != null){ |
84 String uuid = Config.getStringXPath(target, "action/uuid/@value"); // TODO: müssen wir für das subartifact eine veränderte uuid führen? | 84 try { |
85 String hash = Config.getStringXPath(target, "action/hash/@value"); | 85 String uuid = Config.getStringXPath(target, "action/uuid/@value"); // TODO: müssen wir für das subartifact eine veränderte uuid führen? |
86 this.productArtifact = this.current.getArtifactFactory().createArtifact(uuid, context); | 86 String hash = Config.getStringXPath(target, "action/hash/@value"); |
87 Document feedDocument = xmlUtilities.reInitDocument(this.createFeedProductArtifactDocument(uuid, hash)); | 87 this.productArtifact = this.current.getArtifactFactory().createArtifact(uuid, context); |
88 log.debug("Feed ==> "+this.xmlUtilities.writeDocument2String(feedDocument)); | 88 Document feedDocument = xmlUtilities.reInitDocument(this.createFeedProductArtifactDocument(uuid, hash)); |
89 Document descibeDocument = xmlUtilities.reInitDocument(this.productArtifact.describe(context)); | 89 log.debug("Feed ==> "+this.xmlUtilities.writeDocument2String(feedDocument)); |
90 log.debug("Descibe ==> "+this.xmlUtilities.writeDocument2String(descibeDocument)); | 90 Document descibeDocument = xmlUtilities.reInitDocument(this.productArtifact.describe(context)); |
91 this.productArtifact.feed(feedDocument, context); | 91 log.debug("Descibe ==> "+this.xmlUtilities.writeDocument2String(descibeDocument)); |
92 String targetName = Config.getStringXPath(descibeDocument, "result/reachable-states/state/@name"); | 92 this.productArtifact.feed(feedDocument, context); |
93 Document advanceDocument = xmlUtilities.reInitDocument(this.createAdvanceProductArtifactDocument(uuid, hash, targetName)); | 93 String targetName = Config.getStringXPath(descibeDocument, "result/reachable-states/state/@name"); |
94 log.debug("Advance ==> "+this.xmlUtilities.writeDocument2String(advanceDocument)); | 94 Document advanceDocument = xmlUtilities.reInitDocument(this.createAdvanceProductArtifactDocument(uuid, hash, targetName)); |
95 return this.productArtifact.advance(advanceDocument, context); | 95 log.debug("Advance ==> "+this.xmlUtilities.writeDocument2String(advanceDocument)); |
96 return this.productArtifact.advance(advanceDocument, context); | |
97 } catch (RuntimeException e) { | |
98 log.error(e,e); | |
99 } | |
96 }else{ | 100 }else{ |
97 log.warn("Artifact is not configured properly. Call feed first."); | 101 log.warn("Artifact is not configured properly. Call feed first."); |
98 // TODO Fehlerdokument erzeugen. | 102 // TODO Fehlerdokument erzeugen. |
99 } | 103 } |
100 return null; | 104 return null; |
167 @Override | 171 @Override |
168 public Document describe(CallContext context) { | 172 public Document describe(CallContext context) { |
169 if (this.productArtifact == null){ | 173 if (this.productArtifact == null){ |
170 return this.createDescibeOutput(); | 174 return this.createDescibeOutput(); |
171 }else{ | 175 }else{ |
172 return this.productArtifact.describe(context); | 176 Document document = this.productArtifact.describe(context); |
177 document = new ArtifactXMLUtilities().reInitDocument(document); | |
178 Node staticNode = Config.getNodeXPath(document, "/result/ui/static"); | |
179 if (staticNode != null){ | |
180 Node staticUI = this.createSelectBox(document); | |
181 staticNode.insertBefore(staticUI, staticNode.getFirstChild()); | |
182 } | |
183 return document; | |
173 } | 184 } |
174 } | 185 } |
175 | 186 |
176 /** | 187 /** |
177 * @see de.intevation.artifactdatabase.DefaultArtifact#feed(org.w3c.dom.Document, java.lang.Object) | 188 * @see de.intevation.artifactdatabase.DefaultArtifact#feed(org.w3c.dom.Document, java.lang.Object) |
326 } | 337 } |
327 | 338 |
328 protected void createUserInterface(Element parent, Document document){ | 339 protected void createUserInterface(Element parent, Document document){ |
329 Element uiNode = xmlUtilities.createArtifactElement(document,"ui"); | 340 Element uiNode = xmlUtilities.createArtifactElement(document,"ui"); |
330 ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities(); | 341 ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities(); |
342 Node dynamic = xmlUtilities.createArtifactElement(document, "dynamic"); | |
343 uiNode.appendChild(dynamic); | |
331 if (this.products != null && !this.products.isEmpty()){ | 344 if (this.products != null && !this.products.isEmpty()){ |
332 String selectboxName = "product"; | 345 Element selectNode = createSelectBox(document); |
333 Iterator<Product> it = this.products.values().iterator(); | 346 |
334 Element selectNode = xmlUtilities.createXFormElement(document,"select1"); | 347 dynamic.appendChild(selectNode); |
335 selectNode.setAttribute("ref", selectboxName); | |
336 uiNode.appendChild(selectNode); | |
337 | |
338 Element lableNode = xmlUtilities.createXFormElement(document, "label"); | |
339 lableNode.setTextContent(selectboxName); | |
340 selectNode.appendChild(lableNode); | |
341 Element choiceNode = xmlUtilities.createXFormElement(document, "choices"); | |
342 selectNode.appendChild(choiceNode); | |
343 while (it.hasNext()){ | |
344 Product p = it.next(); | |
345 Element itemNode = xmlUtilities.createXFormElement(document, "item"); | |
346 | |
347 | |
348 Element choiceLableNode = xmlUtilities.createXFormElement(document, "label"); | |
349 choiceLableNode.setTextContent(p.getName()); | |
350 itemNode.appendChild(choiceLableNode); | |
351 | |
352 Element choicValueNode = xmlUtilities.createXFormElement(document, "value"); | |
353 choicValueNode.setTextContent(p.getName()); | |
354 itemNode.appendChild(choicValueNode); | |
355 | |
356 choiceNode.appendChild(itemNode); | |
357 | |
358 } | |
359 } | 348 } |
360 | 349 |
361 parent.appendChild(uiNode); | 350 parent.appendChild(uiNode); |
351 } | |
352 /** | |
353 * @param document | |
354 * @param xmlUtilities | |
355 * @return | |
356 */ | |
357 private Element createSelectBox(Document document) { | |
358 ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities(); | |
359 String selectboxName = "product"; | |
360 Iterator<Product> it = this.products.values().iterator(); | |
361 Element selectNode = xmlUtilities.createXFormElement(document,"select1"); | |
362 selectNode.setAttribute("ref", selectboxName); | |
363 | |
364 | |
365 Element lableNode = xmlUtilities.createXFormElement(document, "label"); | |
366 lableNode.setTextContent(selectboxName); | |
367 selectNode.appendChild(lableNode); | |
368 Element choiceNode = xmlUtilities.createXFormElement(document, "choices"); | |
369 selectNode.appendChild(choiceNode); | |
370 while (it.hasNext()){ | |
371 Product p = it.next(); | |
372 Element itemNode = xmlUtilities.createXFormElement(document, "item"); | |
373 | |
374 | |
375 Element choiceLableNode = xmlUtilities.createXFormElement(document, "label"); | |
376 choiceLableNode.setTextContent(p.getName()); | |
377 itemNode.appendChild(choiceLableNode); | |
378 | |
379 Element choicValueNode = xmlUtilities.createXFormElement(document, "value"); | |
380 choicValueNode.setTextContent(p.getName()); | |
381 itemNode.appendChild(choicValueNode); | |
382 | |
383 choiceNode.appendChild(itemNode); | |
384 | |
385 } | |
386 return selectNode; | |
362 } | 387 } |
363 | 388 |
364 protected void createOutputs(Element parent, Document document){ | 389 protected void createOutputs(Element parent, Document document){ |
365 log.debug("GNVArtifactBase.createOutputs"); | 390 log.debug("GNVArtifactBase.createOutputs"); |
366 Element outputsNode = xmlUtilities.createArtifactElement(document,"outputs"); | 391 Element outputsNode = xmlUtilities.createArtifactElement(document,"outputs"); |