comparison gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java @ 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
parents 20dde2b6f1b5
children cef17cc90fd0
comparison
equal deleted inserted replaced
487:9da25f0c5962 488:d265f5dc2979
2 * 2 *
3 */ 3 */
4 package de.intevation.gnv.artifacts; 4 package de.intevation.gnv.artifacts;
5 5
6 import de.intevation.artifactdatabase.Config; 6 import de.intevation.artifactdatabase.Config;
7 import de.intevation.artifactdatabase.DefaultArtifact;
8 import de.intevation.artifactdatabase.ProxyArtifact; 7 import de.intevation.artifactdatabase.ProxyArtifact;
9 import de.intevation.artifactdatabase.XMLUtils; 8 import de.intevation.artifactdatabase.XMLUtils;
10 9
11 import de.intevation.artifacts.Artifact; 10 import de.intevation.artifacts.Artifact;
12 import de.intevation.artifacts.ArtifactDatabase; 11 import de.intevation.artifacts.ArtifactDatabase;
63 /** 62 /**
64 * @author Tim Englich (tim.englich@intevation.de) 63 * @author Tim Englich (tim.englich@intevation.de)
65 * @author Ingo Weinzierl (ingo.weinzierl@intevation.de) 64 * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
66 * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) 65 * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
67 */ 66 */
68 public abstract class GNVArtifactBase extends DefaultArtifact { 67 public abstract class GNVArtifactBase extends GNVDefaultArtifact {
69 /** 68 /**
70 * the logger, used to log exceptions and additonaly information 69 * the logger, used to log exceptions and additonaly information
71 */ 70 */
72 private static Logger log = Logger.getLogger(GNVArtifactBase.class); 71 private static Logger log = Logger.getLogger(GNVArtifactBase.class);
73 /** 72 /**
362 361
363 protected Node getConfigurationFragment(Document document) { 362 protected Node getConfigurationFragment(Document document) {
364 log.debug("GNVArtifactBase.getConfigurationFragment"); 363 log.debug("GNVArtifactBase.getConfigurationFragment");
365 String xpathQuery = XPATH_ARTIFACT_CONFIGURATION.replaceAll( 364 String xpathQuery = XPATH_ARTIFACT_CONFIGURATION.replaceAll(
366 XPATH_IDENTIFIER_REPLACE, this.name); 365 XPATH_IDENTIFIER_REPLACE, this.name);
367 log.debug(xpathQuery);
368 366
369 Element configurationNode = (Element)Config.getNodeXPath(document, xpathQuery); 367 Element configurationNode = (Element)Config.getNodeXPath(document, xpathQuery);
370 368
371 String link = configurationNode.getAttribute("xlink:href"); 369 String link = configurationNode.getAttribute("xlink:href");
372 if (link != null ){ 370 if (link != null ){
422 @Override 420 @Override
423 public Document describe(Document data, CallContext context) { 421 public Document describe(Document data, CallContext context) {
424 log.debug("GNVArtifactBase.describe"); 422 log.debug("GNVArtifactBase.describe");
425 423
426 Document document = createDescibeOutput( 424 Document document = createDescibeOutput(
427 context.getMeta(), 425 context,
428 identifier, 426 identifier,
429 getIncludeUIFromDocument(data) 427 getIncludeUIFromDocument(data)
430 ); 428 );
431 429
432 // insert node for rendering product field 430 // insert node for rendering product field
446 XMLUtils.ElementCreator artCreator = new XMLUtils.ElementCreator( 444 XMLUtils.ElementCreator artCreator = new XMLUtils.ElementCreator(
447 document, 445 document,
448 ArtifactNamespaceContext.NAMESPACE_URI, 446 ArtifactNamespaceContext.NAMESPACE_URI,
449 ArtifactNamespaceContext.NAMESPACE_PREFIX 447 ArtifactNamespaceContext.NAMESPACE_PREFIX
450 ); 448 );
451
452 if (staticNode != null) {
453 Element staticUI = createSelectBox(
454 artCreator, creator, document, context
455 );
456 staticNode.insertBefore(staticUI, staticNode.getFirstChild());
457 }
458 449
459 return document; 450 return document;
460 } 451 }
461 452
462 /** 453 /**
506 } 497 }
507 } 498 }
508 499
509 } 500 }
510 } 501 }
511 502
512 503
513 protected Document createDescibeOutput(CallMeta callMeta, String uuid, boolean incudeUI) { 504 protected Document createDescibeOutput(
505 CallContext context,
506 String uuid,
507 boolean incudeUI
508 ) {
514 log.debug("GNVArtifactBase.createDescibeOutput"); 509 log.debug("GNVArtifactBase.createDescibeOutput");
515 Document document = XMLUtils.newDocument(); 510 Document document = XMLUtils.newDocument();
516 511
517 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( 512 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(
518 document, 513 document,
519 ArtifactNamespaceContext.NAMESPACE_URI, 514 ArtifactNamespaceContext.NAMESPACE_URI,
520 ArtifactNamespaceContext.NAMESPACE_PREFIX 515 ArtifactNamespaceContext.NAMESPACE_PREFIX
521 ); 516 );
524 this.createOutputs(creator, rootNode, document); 519 this.createOutputs(creator, rootNode, document);
525 this.createCurrentState(creator, rootNode, document); 520 this.createCurrentState(creator, rootNode, document);
526 this.createReachableStates(creator, rootNode, document); 521 this.createReachableStates(creator, rootNode, document);
527 this.createModel(creator, rootNode, document); 522 this.createModel(creator, rootNode, document);
528 if (incudeUI){ 523 if (incudeUI){
529 this.createUserInterface(creator, rootNode, document, callMeta, uuid); 524 this.createUserInterface(creator, rootNode, document, context, uuid);
530 } 525 }
531 526
532 return document; 527 return document;
533 } 528 }
534 529
613 selectNode.appendChild(labelNode); 608 selectNode.appendChild(labelNode);
614 selectNode.appendChild(choicesNode); 609 selectNode.appendChild(choicesNode);
615 610
616 return selectNode; 611 return selectNode;
617 } 612 }
613
618 614
619 protected void createReachableStates( 615 protected void createReachableStates(
620 XMLUtils.ElementCreator creator, 616 XMLUtils.ElementCreator creator,
621 Element parent, 617 Element parent,
622 Document document 618 Document document
703 699
704 protected void createUserInterface( 700 protected void createUserInterface(
705 XMLUtils.ElementCreator creator, 701 XMLUtils.ElementCreator creator,
706 Element parent, 702 Element parent,
707 Document document, 703 Document document,
708 CallMeta callMeta, 704 CallContext context,
709 String uuid 705 String uuid
710 ) { 706 ) {
711 Element uiNode = creator.create("ui"); 707 XMLUtils.ElementCreator xCreator = new XMLUtils.ElementCreator(
708 document,
709 XMLUtils.XFORM_URL,
710 XMLUtils.XFORM_PREFIX
711 );
712
713 Element uiNode = creator.create("ui");
714 Element staticNode = creator.create("static");
715 Element dynamic = creator.create("dynamic");
716
717 uiNode.appendChild(staticNode);
718 uiNode.appendChild(dynamic);
719
720 parent.appendChild(uiNode);
721
722 // append fis to dynamic part
723 appendFis(document, staticNode, context, product.getArtifactFactory());
712 724
713 if (this.current != null) { 725 if (this.current != null) {
726 Element staticUI = createSelectBox(
727 creator, xCreator, document, context
728 );
729 staticNode.appendChild(staticUI);
730
714 this.current.describe( 731 this.current.describe(
715 document, uiNode, callMeta, uuid 732 document, uiNode, context.getMeta(), uuid
716 ); 733 );
717 } 734 }
718
719 parent.appendChild(uiNode);
720 } 735 }
721 736
722 737
723 protected void createOutputs( 738 protected void createOutputs(
724 XMLUtils.ElementCreator creator, 739 XMLUtils.ElementCreator creator,

http://dive4elements.wald.intevation.org