Mercurial > dive4elements > gnv-client
diff 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 |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java Wed Sep 16 12:38:24 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java Thu Sep 17 13:38:12 2009 +0000 @@ -81,18 +81,22 @@ public Document advance(Document target, CallContext context) { if (this.productArtifact == null){ if (this.current != null){ - String uuid = Config.getStringXPath(target, "action/uuid/@value"); // TODO: müssen wir für das subartifact eine veränderte uuid führen? - String hash = Config.getStringXPath(target, "action/hash/@value"); - this.productArtifact = this.current.getArtifactFactory().createArtifact(uuid, context); - Document feedDocument = xmlUtilities.reInitDocument(this.createFeedProductArtifactDocument(uuid, hash)); - log.debug("Feed ==> "+this.xmlUtilities.writeDocument2String(feedDocument)); - Document descibeDocument = xmlUtilities.reInitDocument(this.productArtifact.describe(context)); - log.debug("Descibe ==> "+this.xmlUtilities.writeDocument2String(descibeDocument)); - this.productArtifact.feed(feedDocument, context); - String targetName = Config.getStringXPath(descibeDocument, "result/reachable-states/state/@name"); - Document advanceDocument = xmlUtilities.reInitDocument(this.createAdvanceProductArtifactDocument(uuid, hash, targetName)); - log.debug("Advance ==> "+this.xmlUtilities.writeDocument2String(advanceDocument)); - return this.productArtifact.advance(advanceDocument, context); + try { + String uuid = Config.getStringXPath(target, "action/uuid/@value"); // TODO: müssen wir für das subartifact eine veränderte uuid führen? + String hash = Config.getStringXPath(target, "action/hash/@value"); + this.productArtifact = this.current.getArtifactFactory().createArtifact(uuid, context); + Document feedDocument = xmlUtilities.reInitDocument(this.createFeedProductArtifactDocument(uuid, hash)); + log.debug("Feed ==> "+this.xmlUtilities.writeDocument2String(feedDocument)); + Document descibeDocument = xmlUtilities.reInitDocument(this.productArtifact.describe(context)); + log.debug("Descibe ==> "+this.xmlUtilities.writeDocument2String(descibeDocument)); + this.productArtifact.feed(feedDocument, context); + String targetName = Config.getStringXPath(descibeDocument, "result/reachable-states/state/@name"); + Document advanceDocument = xmlUtilities.reInitDocument(this.createAdvanceProductArtifactDocument(uuid, hash, targetName)); + log.debug("Advance ==> "+this.xmlUtilities.writeDocument2String(advanceDocument)); + return this.productArtifact.advance(advanceDocument, context); + } catch (RuntimeException e) { + log.error(e,e); + } }else{ log.warn("Artifact is not configured properly. Call feed first."); // TODO Fehlerdokument erzeugen. @@ -169,7 +173,14 @@ if (this.productArtifact == null){ return this.createDescibeOutput(); }else{ - return this.productArtifact.describe(context); + Document document = this.productArtifact.describe(context); + document = new ArtifactXMLUtilities().reInitDocument(document); + Node staticNode = Config.getNodeXPath(document, "/result/ui/static"); + if (staticNode != null){ + Node staticUI = this.createSelectBox(document); + staticNode.insertBefore(staticUI, staticNode.getFirstChild()); + } + return document; } } @@ -328,38 +339,52 @@ protected void createUserInterface(Element parent, Document document){ Element uiNode = xmlUtilities.createArtifactElement(document,"ui"); ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities(); + Node dynamic = xmlUtilities.createArtifactElement(document, "dynamic"); + uiNode.appendChild(dynamic); if (this.products != null && !this.products.isEmpty()){ - String selectboxName = "product"; - Iterator<Product> it = this.products.values().iterator(); - Element selectNode = xmlUtilities.createXFormElement(document,"select1"); - selectNode.setAttribute("ref", selectboxName); - uiNode.appendChild(selectNode); - - Element lableNode = xmlUtilities.createXFormElement(document, "label"); - lableNode.setTextContent(selectboxName); - selectNode.appendChild(lableNode); - Element choiceNode = xmlUtilities.createXFormElement(document, "choices"); - selectNode.appendChild(choiceNode); - while (it.hasNext()){ - Product p = it.next(); - Element itemNode = xmlUtilities.createXFormElement(document, "item"); - - - Element choiceLableNode = xmlUtilities.createXFormElement(document, "label"); - choiceLableNode.setTextContent(p.getName()); - itemNode.appendChild(choiceLableNode); - - Element choicValueNode = xmlUtilities.createXFormElement(document, "value"); - choicValueNode.setTextContent(p.getName()); - itemNode.appendChild(choicValueNode); - - choiceNode.appendChild(itemNode); - - } + Element selectNode = createSelectBox(document); + + dynamic.appendChild(selectNode); } parent.appendChild(uiNode); } + /** + * @param document + * @param xmlUtilities + * @return + */ + private Element createSelectBox(Document document) { + ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities(); + String selectboxName = "product"; + Iterator<Product> it = this.products.values().iterator(); + Element selectNode = xmlUtilities.createXFormElement(document,"select1"); + selectNode.setAttribute("ref", selectboxName); + + + Element lableNode = xmlUtilities.createXFormElement(document, "label"); + lableNode.setTextContent(selectboxName); + selectNode.appendChild(lableNode); + Element choiceNode = xmlUtilities.createXFormElement(document, "choices"); + selectNode.appendChild(choiceNode); + while (it.hasNext()){ + Product p = it.next(); + Element itemNode = xmlUtilities.createXFormElement(document, "item"); + + + Element choiceLableNode = xmlUtilities.createXFormElement(document, "label"); + choiceLableNode.setTextContent(p.getName()); + itemNode.appendChild(choiceLableNode); + + Element choicValueNode = xmlUtilities.createXFormElement(document, "value"); + choicValueNode.setTextContent(p.getName()); + itemNode.appendChild(choicValueNode); + + choiceNode.appendChild(itemNode); + + } + return selectNode; + } protected void createOutputs(Element parent, Document document){ log.debug("GNVArtifactBase.createOutputs");