Mercurial > dive4elements > gnv-client
comparison 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 |
comparison
equal
deleted
inserted
replaced
477:40a058047854 | 478:0e0c64c821dc |
---|---|
20 import org.w3c.dom.Document; | 20 import org.w3c.dom.Document; |
21 import org.w3c.dom.Element; | 21 import org.w3c.dom.Element; |
22 import org.w3c.dom.Node; | 22 import org.w3c.dom.Node; |
23 import org.w3c.dom.NodeList; | 23 import org.w3c.dom.NodeList; |
24 | 24 |
25 import de.intevation.artifacts.Artifact; | |
26 import de.intevation.artifacts.ArtifactDatabase; | |
27 import de.intevation.artifactdatabase.ArtifactDatabaseImpl; | |
25 import de.intevation.artifactdatabase.Config; | 28 import de.intevation.artifactdatabase.Config; |
26 import de.intevation.artifactdatabase.DefaultArtifact; | 29 import de.intevation.artifactdatabase.DefaultArtifact; |
27 import de.intevation.artifactdatabase.ProxyArtifact; | 30 import de.intevation.artifactdatabase.ProxyArtifact; |
28 import de.intevation.artifactdatabase.XMLUtils; | 31 import de.intevation.artifactdatabase.XMLUtils; |
29 import de.intevation.artifacts.ArtifactFactory; | 32 import de.intevation.artifacts.ArtifactFactory; |
85 | 88 |
86 public static final String XPATH_OUTPUT_NAME = "/art:action/art:out/@name"; | 89 public static final String XPATH_OUTPUT_NAME = "/art:action/art:out/@name"; |
87 | 90 |
88 public static final String XPATH_OUTPUT_PARAMS = "/art:action/art:out/art:params/art:input"; | 91 public static final String XPATH_OUTPUT_PARAMS = "/art:action/art:out/art:params/art:input"; |
89 | 92 |
90 public static final String INITIAL_STATE = "start"; | 93 public static final String INITIAL_STATE = "product"; |
91 | 94 |
92 /** | 95 /** |
93 * The current State | 96 * The current State |
94 */ | 97 */ |
95 protected State current = null; | 98 protected State current = null; |
175 // reset input data | 178 // reset input data |
176 resetFutureStates(current, targetState); | 179 resetFutureStates(current, targetState); |
177 | 180 |
178 // remove data from future states from cache | 181 // remove data from future states from cache |
179 resetDescribeData(current, identifier, targetState); | 182 resetDescribeData(current, identifier, targetState); |
180 | 183 |
181 current = next; | 184 current = next; |
182 | 185 |
183 result = createReport( | 186 result = createReport( |
184 result, "result", "success", "Advance success" | 187 result, "result", "success", "Advance success" |
185 ); | 188 ); |
186 } | 189 } |
187 | 190 |
188 // goto initial step | 191 // goto initial step |
189 else if(targetState.equals(INITIAL_STATE)) { | 192 else if(targetState.equals(INITIAL_STATE)) { |
190 SelectProductArtifact select = new SelectProductArtifact(); | 193 |
191 select.setup(identifier, new GNVArtifactFactory(), context); | 194 String fis = product.getArtifactFactory(); |
195 ArtifactDatabase db = context.getDatabase(); | |
196 GNVProductArtifactFactory fac = (GNVProductArtifactFactory) | |
197 db.getInternalArtifactFactory(fis); | |
198 | |
199 Artifact select = fac.createArtifact(identifier, context); | |
192 context.putContextValue(ProxyArtifact.REPLACE_PROXY, select); | 200 context.putContextValue(ProxyArtifact.REPLACE_PROXY, select); |
201 | |
202 resetDescribeData(current, identifier, INITIAL_STATE); | |
193 | 203 |
194 result = createReport( | 204 result = createReport( |
195 result, "result", "success", "Advance success" | 205 result, "result", "success", "Advance success" |
196 ); | 206 ); |
197 } | 207 } |
271 | 281 |
272 List data = (List) value.getObjectValue(); | 282 List data = (List) value.getObjectValue(); |
273 while(!target.equals(state.getID())) { | 283 while(!target.equals(state.getID())) { |
274 data.remove(data.size()-1); | 284 data.remove(data.size()-1); |
275 state = state.getParent(); | 285 state = state.getParent(); |
286 | |
287 if (state == null) | |
288 break; | |
276 } | 289 } |
277 | 290 |
278 cache.put(new net.sf.ehcache.Element(key, data)); | 291 cache.put(new net.sf.ehcache.Element(key, data)); |
279 } | 292 } |
280 } | 293 } |
411 document, | 424 document, |
412 XMLUtils.XFORM_URL, | 425 XMLUtils.XFORM_URL, |
413 XMLUtils.XFORM_PREFIX | 426 XMLUtils.XFORM_PREFIX |
414 ); | 427 ); |
415 | 428 |
429 XMLUtils.ElementCreator artCreator = new XMLUtils.ElementCreator( | |
430 document, | |
431 ArtifactNamespaceContext.NAMESPACE_URI, | |
432 ArtifactNamespaceContext.NAMESPACE_PREFIX | |
433 ); | |
434 | |
416 if (staticNode != null) { | 435 if (staticNode != null) { |
417 Element staticUI = createSelectBox(creator, document, context); | 436 Element staticUI = createSelectBox( |
437 artCreator, creator, document, context | |
438 ); | |
418 staticNode.insertBefore(staticUI, staticNode.getFirstChild()); | 439 staticNode.insertBefore(staticUI, staticNode.getFirstChild()); |
419 } | 440 } |
420 | 441 |
421 return document; | 442 return document; |
422 } | 443 } |
500 | 521 |
501 boolean includeUI = false; | 522 boolean includeUI = false; |
502 if (value != null){ | 523 if (value != null){ |
503 includeUI = Boolean.parseBoolean(value); | 524 includeUI = Boolean.parseBoolean(value); |
504 } | 525 } |
505 log.debug("INCLUDE UI? " + includeUI); | |
506 return includeUI; | 526 return includeUI; |
507 } | 527 } |
508 | 528 |
509 protected Element createRootNode( | 529 protected Element createRootNode( |
510 XMLUtils.ElementCreator creator, | 530 XMLUtils.ElementCreator creator, |
518 protected void createHeader( | 538 protected void createHeader( |
519 XMLUtils.ElementCreator creator, | 539 XMLUtils.ElementCreator creator, |
520 Element parent, | 540 Element parent, |
521 Document document, | 541 Document document, |
522 String documentType | 542 String documentType |
523 ) { | 543 ) { |
524 Element typeNode = creator.create("type"); | 544 Element typeNode = creator.create("type"); |
525 creator.addAttr(typeNode, "name", documentType); | 545 creator.addAttr(typeNode, "name", documentType); |
526 parent.appendChild(typeNode); | 546 parent.appendChild(typeNode); |
527 | 547 |
528 Element uuidNode = creator.create("uuid"); | 548 Element uuidNode = creator.create("uuid"); |
533 creator.addAttr(hashNode, "value", this.hash()); | 553 creator.addAttr(hashNode, "value", this.hash()); |
534 parent.appendChild(hashNode); | 554 parent.appendChild(hashNode); |
535 } | 555 } |
536 | 556 |
537 protected Element createSelectBox( | 557 protected Element createSelectBox( |
558 XMLUtils.ElementCreator artCreator, | |
538 XMLUtils.ElementCreator creator, | 559 XMLUtils.ElementCreator creator, |
539 Document document, | 560 Document document, |
540 CallContext context | 561 CallContext context |
541 ) { | 562 ) { |
542 RessourceFactory resource = RessourceFactory.getInstance(); | 563 RessourceFactory resource = RessourceFactory.getInstance(); |
543 CallMeta callMeta = (CallMeta) context.getMeta(); | 564 CallMeta callMeta = (CallMeta) context.getMeta(); |
544 String productName = product.getName(); | 565 String productName = product.getName(); |
545 | 566 |
546 Element selectNode = creator.create("select1"); | 567 Element selectNode = creator.create("select1"); |
547 creator.addAttr(selectNode, "ref", "product"); | 568 creator.addAttr(selectNode, "ref", "product"); |
569 artCreator.addAttr(selectNode, "state", INITIAL_STATE, true); | |
570 | |
548 | 571 |
549 Element labelNode = creator.create("label"); | 572 Element labelNode = creator.create("label"); |
550 labelNode.setTextContent( | 573 labelNode.setTextContent( |
551 resource.getRessource(callMeta.getLanguages(), "product", "product") | 574 resource.getRessource(callMeta.getLanguages(), "product", "product") |
552 ); | 575 ); |
669 String uuid | 692 String uuid |
670 ) { | 693 ) { |
671 Element uiNode = creator.create("ui"); | 694 Element uiNode = creator.create("ui"); |
672 | 695 |
673 if (this.current != null) { | 696 if (this.current != null) { |
674 this.current.describe(document, uiNode, callMeta, uuid); | 697 this.current.describe( |
698 document, uiNode, callMeta, uuid | |
699 ); | |
675 } | 700 } |
676 | 701 |
677 parent.appendChild(uiNode); | 702 parent.appendChild(uiNode); |
678 } | 703 } |
704 | |
679 | 705 |
680 protected void createOutputs( | 706 protected void createOutputs( |
681 XMLUtils.ElementCreator creator, | 707 XMLUtils.ElementCreator creator, |
682 Element parent, | 708 Element parent, |
683 Document document | 709 Document document |