Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java @ 478:0e0c64c821dc
Added support to step back to the point for choosing a product.
gnv-artifacts/trunk@547 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 15 Jan 2010 18:21:49 +0000 |
parents | c0504976e606 |
children | d47b478e662b |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Fri Jan 15 10:13:18 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Fri Jan 15 18:21:49 2010 +0000 @@ -22,6 +22,9 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import de.intevation.artifacts.Artifact; +import de.intevation.artifacts.ArtifactDatabase; +import de.intevation.artifactdatabase.ArtifactDatabaseImpl; import de.intevation.artifactdatabase.Config; import de.intevation.artifactdatabase.DefaultArtifact; import de.intevation.artifactdatabase.ProxyArtifact; @@ -87,7 +90,7 @@ public static final String XPATH_OUTPUT_PARAMS = "/art:action/art:out/art:params/art:input"; - public static final String INITIAL_STATE = "start"; + public static final String INITIAL_STATE = "product"; /** * The current State @@ -177,7 +180,7 @@ // remove data from future states from cache resetDescribeData(current, identifier, targetState); - + current = next; result = createReport( @@ -187,10 +190,17 @@ // goto initial step else if(targetState.equals(INITIAL_STATE)) { - SelectProductArtifact select = new SelectProductArtifact(); - select.setup(identifier, new GNVArtifactFactory(), context); + + String fis = product.getArtifactFactory(); + ArtifactDatabase db = context.getDatabase(); + GNVProductArtifactFactory fac = (GNVProductArtifactFactory) + db.getInternalArtifactFactory(fis); + + Artifact select = fac.createArtifact(identifier, context); context.putContextValue(ProxyArtifact.REPLACE_PROXY, select); + resetDescribeData(current, identifier, INITIAL_STATE); + result = createReport( result, "result", "success", "Advance success" ); @@ -273,6 +283,9 @@ while(!target.equals(state.getID())) { data.remove(data.size()-1); state = state.getParent(); + + if (state == null) + break; } cache.put(new net.sf.ehcache.Element(key, data)); @@ -413,8 +426,16 @@ XMLUtils.XFORM_PREFIX ); + XMLUtils.ElementCreator artCreator = new XMLUtils.ElementCreator( + document, + ArtifactNamespaceContext.NAMESPACE_URI, + ArtifactNamespaceContext.NAMESPACE_PREFIX + ); + if (staticNode != null) { - Element staticUI = createSelectBox(creator, document, context); + Element staticUI = createSelectBox( + artCreator, creator, document, context + ); staticNode.insertBefore(staticUI, staticNode.getFirstChild()); } @@ -502,7 +523,6 @@ if (value != null){ includeUI = Boolean.parseBoolean(value); } - log.debug("INCLUDE UI? " + includeUI); return includeUI; } @@ -520,7 +540,7 @@ Element parent, Document document, String documentType - ) { + ) { Element typeNode = creator.create("type"); creator.addAttr(typeNode, "name", documentType); parent.appendChild(typeNode); @@ -535,16 +555,19 @@ } protected Element createSelectBox( + XMLUtils.ElementCreator artCreator, XMLUtils.ElementCreator creator, Document document, CallContext context ) { RessourceFactory resource = RessourceFactory.getInstance(); CallMeta callMeta = (CallMeta) context.getMeta(); - String productName = product.getName(); + String productName = product.getName(); Element selectNode = creator.create("select1"); creator.addAttr(selectNode, "ref", "product"); + artCreator.addAttr(selectNode, "state", INITIAL_STATE, true); + Element labelNode = creator.create("label"); labelNode.setTextContent( @@ -671,12 +694,15 @@ Element uiNode = creator.create("ui"); if (this.current != null) { - this.current.describe(document, uiNode, callMeta, uuid); + this.current.describe( + document, uiNode, callMeta, uuid + ); } parent.appendChild(uiNode); } + protected void createOutputs( XMLUtils.ElementCreator creator, Element parent,