Mercurial > dive4elements > gnv-client
changeset 488:d265f5dc2979
Appended the selected fis to the describe document.
gnv-artifacts/trunk@564 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 18 Jan 2010 13:43:50 +0000 (2010-01-18) |
parents | 9da25f0c5962 |
children | 3784cf498ab7 |
files | gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVDefaultArtifact.java gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/SelectProductArtifact.java gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java gnv-artifacts/src/main/resources/lang/artifactMessages.properties gnv-artifacts/src/main/resources/lang/artifactMessages_de.properties gnv-artifacts/src/main/resources/lang/artifactMessages_de_DE.properties gnv-artifacts/src/main/resources/lang/artifactMessages_en.properties |
diffstat | 9 files changed, 165 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog Mon Jan 18 11:40:41 2010 +0000 +++ b/gnv-artifacts/ChangeLog Mon Jan 18 13:43:50 2010 +0000 @@ -1,3 +1,24 @@ +2010-01-18 Ingo Weinzierl <ingo.weinzierl@intevation.de> + + * src/main/java/de/intevation/gnv/artifacts/GNVDefaultArtifact.java: + Implements a single method to append the selected fis to ui's static part. + + * src/main/java/de/intevation/gnv/artifacts/fis/SelectProductArtifact.java, + src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java: Inherit + from GNVDefaultArtifact to append the selected fis to static part of the + describe document. + + * src/main/java/de/intevation/gnv/state/StateBase.java: Do not create static + and dynamic nodes of the user interface any longer - fetch these nodes via + xpath expression. The creation of these nodes takes place in the artifact + itself. + + * src/main/resources/lang/artifactMessages.properties, + src/main/resources/lang/artifactMessages_de_DE.properties, + src/main/resources/lang/artifactMessages_en.properties, + src/main/resources/lang/artifactMessages_de.propertie: Added label for + fis. + 2010-01-18 Sascha L. Teichmann <sascha.teichmann@intevation.de> * ChangeLog: Fixed indention.
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Mon Jan 18 11:40:41 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Mon Jan 18 13:43:50 2010 +0000 @@ -4,7 +4,6 @@ package de.intevation.gnv.artifacts; import de.intevation.artifactdatabase.Config; -import de.intevation.artifactdatabase.DefaultArtifact; import de.intevation.artifactdatabase.ProxyArtifact; import de.intevation.artifactdatabase.XMLUtils; @@ -65,7 +64,7 @@ * @author Ingo Weinzierl (ingo.weinzierl@intevation.de) * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) */ -public abstract class GNVArtifactBase extends DefaultArtifact { +public abstract class GNVArtifactBase extends GNVDefaultArtifact { /** * the logger, used to log exceptions and additonaly information */ @@ -364,7 +363,6 @@ log.debug("GNVArtifactBase.getConfigurationFragment"); String xpathQuery = XPATH_ARTIFACT_CONFIGURATION.replaceAll( XPATH_IDENTIFIER_REPLACE, this.name); - log.debug(xpathQuery); Element configurationNode = (Element)Config.getNodeXPath(document, xpathQuery); @@ -424,7 +422,7 @@ log.debug("GNVArtifactBase.describe"); Document document = createDescibeOutput( - context.getMeta(), + context, identifier, getIncludeUIFromDocument(data) ); @@ -449,13 +447,6 @@ ArtifactNamespaceContext.NAMESPACE_PREFIX ); - if (staticNode != null) { - Element staticUI = createSelectBox( - artCreator, creator, document, context - ); - staticNode.insertBefore(staticUI, staticNode.getFirstChild()); - } - return document; } @@ -508,12 +499,16 @@ } } - - protected Document createDescibeOutput(CallMeta callMeta, String uuid, boolean incudeUI) { + + protected Document createDescibeOutput( + CallContext context, + String uuid, + boolean incudeUI + ) { log.debug("GNVArtifactBase.createDescibeOutput"); Document document = XMLUtils.newDocument(); - + XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( document, ArtifactNamespaceContext.NAMESPACE_URI, @@ -526,7 +521,7 @@ this.createReachableStates(creator, rootNode, document); this.createModel(creator, rootNode, document); if (incudeUI){ - this.createUserInterface(creator, rootNode, document, callMeta, uuid); + this.createUserInterface(creator, rootNode, document, context, uuid); } return document; @@ -616,6 +611,7 @@ return selectNode; } + protected void createReachableStates( XMLUtils.ElementCreator creator, Element parent, @@ -705,18 +701,37 @@ XMLUtils.ElementCreator creator, Element parent, Document document, - CallMeta callMeta, - String uuid + CallContext context, + String uuid ) { - Element uiNode = creator.create("ui"); + XMLUtils.ElementCreator xCreator = new XMLUtils.ElementCreator( + document, + XMLUtils.XFORM_URL, + XMLUtils.XFORM_PREFIX + ); + + Element uiNode = creator.create("ui"); + Element staticNode = creator.create("static"); + Element dynamic = creator.create("dynamic"); + + uiNode.appendChild(staticNode); + uiNode.appendChild(dynamic); + + parent.appendChild(uiNode); + + // append fis to dynamic part + appendFis(document, staticNode, context, product.getArtifactFactory()); if (this.current != null) { + Element staticUI = createSelectBox( + creator, xCreator, document, context + ); + staticNode.appendChild(staticUI); + this.current.describe( - document, uiNode, callMeta, uuid + document, uiNode, context.getMeta(), uuid ); } - - parent.appendChild(uiNode); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVDefaultArtifact.java Mon Jan 18 13:43:50 2010 +0000 @@ -0,0 +1,76 @@ +package de.intevation.gnv.artifacts; + +import de.intevation.artifactdatabase.DefaultArtifact; +import de.intevation.artifactdatabase.XMLUtils; + +import de.intevation.artifacts.CallContext; +import de.intevation.artifacts.CallMeta; + +import de.intevation.gnv.artifacts.ressource.RessourceFactory; + +import org.apache.log4j.Logger; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +/** + * @author Ingo Weinzierl <ingo.weinzierl@intevation.de> + */ +public class GNVDefaultArtifact extends DefaultArtifact { + + private static Logger logger = Logger.getLogger(GNVDefaultArtifact.class); + + + public GNVDefaultArtifact() { + super(); + } + + + protected void appendFis( + Document document, + Element staticNode, + CallContext context, + String fisName + ) { + RessourceFactory resource = RessourceFactory.getInstance(); + CallMeta callMeta = (CallMeta) context.getMeta(); + + XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( + document, + XMLUtils.XFORM_URL, + XMLUtils.XFORM_PREFIX + ); + + Element selectNode = creator.create("select1"); + creator.addAttr(selectNode, "ref", "fis"); + + Element labelNode = creator.create("label"); + labelNode.setTextContent( + resource.getRessource(callMeta.getLanguages(), "fis", "fis") + ); + + Element choicesNode = creator.create("choices"); + + Element itemNode = creator.create("item"); + creator.addAttr(itemNode, "selected", "true"); + + Element choiceLabel = creator.create("label"); + choiceLabel.setTextContent(resource.getRessource( + callMeta.getLanguages(), + fisName, + fisName + )); + + Element choiceValue = creator.create("value"); + choiceValue.setTextContent(fisName); + + itemNode.appendChild(choiceLabel); + itemNode.appendChild(choiceValue); + choicesNode.appendChild(itemNode); + + selectNode.appendChild(labelNode); + selectNode.appendChild(choicesNode); + + staticNode.appendChild(selectNode); + } +}
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/SelectProductArtifact.java Mon Jan 18 11:40:41 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/SelectProductArtifact.java Mon Jan 18 13:43:50 2010 +0000 @@ -1,6 +1,5 @@ package de.intevation.gnv.artifacts.fis; -import de.intevation.artifactdatabase.DefaultArtifact; import de.intevation.artifactdatabase.ProxyArtifact; import de.intevation.artifactdatabase.XMLUtils; @@ -11,6 +10,7 @@ import de.intevation.artifacts.CallMeta; import de.intevation.gnv.artifacts.GNVArtifactBase; +import de.intevation.gnv.artifacts.GNVDefaultArtifact; import de.intevation.gnv.artifacts.GNVProductArtifactFactory; import de.intevation.gnv.artifacts.fis.product.Product; @@ -32,10 +32,11 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; + /** * @author Ingo Weinzierl <ingo.weinzierl@intevation.de> */ -public class SelectProductArtifact extends DefaultArtifact { +public class SelectProductArtifact extends GNVDefaultArtifact { public static final String XPATH_UUID = "art:action/art:uuid/@value"; @@ -232,13 +233,18 @@ rootNode.appendChild(model); // create ui - Element ui = creator.create("ui"); - Element dynamic = creator.create("dynamic"); + Element ui = creator.create("ui"); + Element staticNode = creator.create("static"); + Element dynamic = creator.create("dynamic"); + + appendFis(document, staticNode, context, this.name); appendSelectProducts(document, dynamic, context.getMeta()); + ui.appendChild(staticNode); ui.appendChild(dynamic); rootNode.appendChild(ui); document.appendChild(rootNode); + return document; }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Mon Jan 18 11:40:41 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Mon Jan 18 13:43:50 2010 +0000 @@ -46,6 +46,8 @@ import java.util.Map; import java.util.Set; +import javax.xml.xpath.XPathConstants; + import org.apache.log4j.Logger; import org.w3c.dom.Document; @@ -77,6 +79,9 @@ public final static String DESCRIBEDATAKEY = "_DESCRIBEDATA"; + public final static String XPATH_STATIC_UI = "art:static"; + public final static String XPATH_DYNAMIC_UI = "art:dynamic"; + private String id = null; private String description = null; @@ -553,11 +558,20 @@ ArtifactNamespaceContext.NAMESPACE_URI, ArtifactNamespaceContext.NAMESPACE_PREFIX ); - Node staticNode = creator.create("static"); - Node dynamic = creator.create("dynamic"); - rootNode.appendChild(staticNode); - rootNode.appendChild(dynamic); + Node staticNode = (Node) XMLUtils.xpath( + rootNode, + XPATH_STATIC_UI, + XPathConstants.NODE, + ArtifactNamespaceContext.INSTANCE + ); + + Node dynamic = (Node) XMLUtils.xpath( + rootNode, + XPATH_DYNAMIC_UI, + XPathConstants.NODE, + ArtifactNamespaceContext.INSTANCE + ); XMLUtils.ElementCreator xCreator = new XMLUtils.ElementCreator( document,
--- a/gnv-artifacts/src/main/resources/lang/artifactMessages.properties Mon Jan 18 11:40:41 2010 +0000 +++ b/gnv-artifacts/src/main/resources/lang/artifactMessages.properties Mon Jan 18 13:43:50 2010 +0000 @@ -16,6 +16,7 @@ fis_icestations = Ice Station Report meshid= Mesh +fis = Data set product= Product timeSeries= Timeseries verticalProfile = Verticalprofile
--- a/gnv-artifacts/src/main/resources/lang/artifactMessages_de.properties Mon Jan 18 11:40:41 2010 +0000 +++ b/gnv-artifacts/src/main/resources/lang/artifactMessages_de.properties Mon Jan 18 13:43:50 2010 +0000 @@ -15,6 +15,7 @@ fis_currentmeter = Strommesser fis_icestations = Eismeldungen +fis = Fachinformationssystem product= Produkt timeSeries= Zeitserie verticalProfile = Vertikalprofil
--- a/gnv-artifacts/src/main/resources/lang/artifactMessages_de_DE.properties Mon Jan 18 11:40:41 2010 +0000 +++ b/gnv-artifacts/src/main/resources/lang/artifactMessages_de_DE.properties Mon Jan 18 13:43:50 2010 +0000 @@ -15,6 +15,7 @@ fis_currentmeter = Strommesser fis_icestations = Eismeldungen +fis= Fachinformationssystem product= Produkt timeSeries= Zeitserie verticalProfile = Vertikalprofil
--- a/gnv-artifacts/src/main/resources/lang/artifactMessages_en.properties Mon Jan 18 11:40:41 2010 +0000 +++ b/gnv-artifacts/src/main/resources/lang/artifactMessages_en.properties Mon Jan 18 13:43:50 2010 +0000 @@ -16,6 +16,7 @@ fis_icestations = Ice Station Report meshid= Mesh +fis = Data set product= Product timeSeries= Timeseries verticalProfile = Verticalprofile