annotate gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java @ 83:5c8e54726a58

Added Support for Vertical Profiles Mesh gnv-artifacts/trunk@113 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Wed, 23 Sep 2009 11:57:08 +0000
parents 5eb62df21f9a
children 1b12021905b9
rev   line source
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2 *
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
3 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
4 package de.intevation.gnv.artifacts.fis;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5
73
504570de21fd Refactoring Work depending on Infrastructurchanges in the Artifact-Module
Tim Englich <tim.englich@intevation.de>
parents: 71
diff changeset
6 import java.io.IOException;
504570de21fd Refactoring Work depending on Infrastructurchanges in the Artifact-Module
Tim Englich <tim.englich@intevation.de>
parents: 71
diff changeset
7 import java.io.OutputStream;
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8 import java.util.ArrayList;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 import java.util.Collection;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10 import java.util.HashMap;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11 import java.util.Iterator;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12 import java.util.Map;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 import org.apache.log4j.Logger;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 import org.w3c.dom.Document;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 import org.w3c.dom.Element;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17 import org.w3c.dom.Node;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 import org.w3c.dom.NodeList;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 import de.intevation.artifactdatabase.Config;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 import de.intevation.artifactdatabase.DefaultArtifact;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22 import de.intevation.artifactdatabase.XMLUtils;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23 import de.intevation.artifacts.Artifact;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 import de.intevation.artifacts.ArtifactFactory;
73
504570de21fd Refactoring Work depending on Infrastructurchanges in the Artifact-Module
Tim Englich <tim.englich@intevation.de>
parents: 71
diff changeset
25 import de.intevation.artifacts.CallContext;
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26 import de.intevation.gnv.artifacts.GNVArtifactBase;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 import de.intevation.gnv.artifacts.context.GNVArtifactContext;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 import de.intevation.gnv.artifacts.fis.product.DefaultProduct;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 import de.intevation.gnv.artifacts.fis.product.Product;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 import de.intevation.gnv.transition.DefaultInputData;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 import de.intevation.gnv.transition.InputData;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 import de.intevation.gnv.transition.InputValue;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 import de.intevation.gnv.transition.OutputMode;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 import de.intevation.gnv.transition.OutputTransition;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 import de.intevation.gnv.utils.ArtifactFactoryUtilities;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36 import de.intevation.gnv.utils.ArtifactXMLUtilities;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 * @author Tim Englich <tim.englich@intevation.de>
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 *
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 public class FISArtifact extends DefaultArtifact {
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 * the logger, used to log exceptions and additonaly information
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
46 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 private static Logger log = Logger.getLogger(GNVArtifactBase.class);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 * The UID of this Class
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 private static final long serialVersionUID = 2874044542701727083L;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 * The Identifier for the Replacement of the Artifactname
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 public static final String XPATH_IDENTIFIER_REPLACE = "IDENTIFIER";
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
58 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 * The XPATH to the XML-Fragment that should be used for the Configuration
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61 public static final String XPATH_ARTIFACT_CONFIGURATION= "/artifact-database/artifacts/artifact[@name='"+XPATH_IDENTIFIER_REPLACE+"']";
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
64 * The Name of the Artifact
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
65 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
66 private String name = null;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68 private Map<String, Product> products = null;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
69
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
70 private Artifact productArtifact = null;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
72 private Product current = null;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
73
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
74 private ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
75
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
76
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
77 /**
73
504570de21fd Refactoring Work depending on Infrastructurchanges in the Artifact-Module
Tim Englich <tim.englich@intevation.de>
parents: 71
diff changeset
78 * @see de.intevation.artifactdatabase.DefaultArtifact#advance(org.w3c.dom.Document, de.intevation.artifacts.CallContext)
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
79 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
80 @Override
73
504570de21fd Refactoring Work depending on Infrastructurchanges in the Artifact-Module
Tim Englich <tim.englich@intevation.de>
parents: 71
diff changeset
81 public Document advance(Document target, CallContext context) {
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
82 if (this.productArtifact == null){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
83 if (this.current != null){
79
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
84 try {
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
85 String uuid = Config.getStringXPath(target, "action/uuid/@value"); // TODO: m�ssen wir f�r das subartifact eine ver�nderte uuid f�hren?
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
86 String hash = Config.getStringXPath(target, "action/hash/@value");
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
87 this.productArtifact = this.current.getArtifactFactory().createArtifact(uuid, context);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
88 Document feedDocument = xmlUtilities.reInitDocument(this.createFeedProductArtifactDocument(uuid, hash));
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
89 log.debug("Feed ==> "+this.xmlUtilities.writeDocument2String(feedDocument));
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
90 Document descibeDocument = xmlUtilities.reInitDocument(this.productArtifact.describe(context));
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
91 log.debug("Descibe ==> "+this.xmlUtilities.writeDocument2String(descibeDocument));
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
92 this.productArtifact.feed(feedDocument, context);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
93 String targetName = Config.getStringXPath(descibeDocument, "result/reachable-states/state/@name");
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
94 Document advanceDocument = xmlUtilities.reInitDocument(this.createAdvanceProductArtifactDocument(uuid, hash, targetName));
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
95 log.debug("Advance ==> "+this.xmlUtilities.writeDocument2String(advanceDocument));
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
96 return this.productArtifact.advance(advanceDocument, context);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
97 } catch (RuntimeException e) {
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
98 log.error(e,e);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
99 }
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
100 }else{
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
101 log.warn("Artifact is not configured properly. Call feed first.");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
102 // TODO Fehlerdokument erzeugen.
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
103 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
104 return null;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
105 }else{
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
106 return this.productArtifact.advance(target, context);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
107 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
108 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
109 private Document createAdvanceProductArtifactDocument(String uuid, String hash, String targetName){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
110 Document document = XMLUtils.newDocument();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
111 Element rootNode = xmlUtilities.createArtifactElement(document, "action");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
112
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
113 Element typeNode = xmlUtilities.createArtifactElement(document, "type");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
114 typeNode.setAttribute("name", "advanve");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
115 rootNode.appendChild(typeNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
116
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
117 Element uuidNode = xmlUtilities.createArtifactElement(document, "uuid");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
118 uuidNode.setAttribute("value", uuid);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
119 rootNode.appendChild(uuidNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
120
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
121 Element hashNode = xmlUtilities.createArtifactElement(document, "hash");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
122 hashNode.setAttribute("value", hash);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
123 rootNode.appendChild(hashNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
124 Element targetNode = xmlUtilities.createArtifactElement(document, "target");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
125 targetNode.setAttribute("name", targetName);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
126 rootNode.appendChild(targetNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
127
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
128 document.appendChild(rootNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
129 return document;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
130 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
131
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
132 private Document createFeedProductArtifactDocument(String uuid, String hash){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
133 Document document = XMLUtils.newDocument();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
134 Element rootNode = xmlUtilities.createArtifactElement(document, "action");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
135
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
136 Element typeNode = xmlUtilities.createArtifactElement(document, "type");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
137 typeNode.setAttribute("name", "feed");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
138 rootNode.appendChild(typeNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
139
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
140 Element uuidNode = xmlUtilities.createArtifactElement(document, "uuid");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
141 uuidNode.setAttribute("value", uuid);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
142 rootNode.appendChild(uuidNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
143
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
144 Element hashNode = xmlUtilities.createArtifactElement(document, "hash");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
145 hashNode.setAttribute("value", hash);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
146 rootNode.appendChild(hashNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
147
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
148 Element dataNode = xmlUtilities.createArtifactElement(document, "data");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
149 rootNode.appendChild(dataNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
150
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
151
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
152 Collection<InputData> parameter = this.current.getParameter();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
153 if (parameter != null){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
154 Iterator<InputData> parameterIt = parameter.iterator();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
155 while(parameterIt.hasNext()){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
156 InputData inputData = parameterIt.next();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
157 Element inputNode = xmlUtilities.createArtifactElement(document, "input");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
158 inputNode.setAttribute("name", inputData.getName());
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
159 inputNode.setAttribute("value", inputData.getValue());
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
160 dataNode.appendChild(inputNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
161 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
162 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
163 document.appendChild(rootNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
164 return document;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
165
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
166 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
167
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
168 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
169 * @see de.intevation.artifactdatabase.DefaultArtifact#describe(java.lang.Object)
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
170 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
171 @Override
73
504570de21fd Refactoring Work depending on Infrastructurchanges in the Artifact-Module
Tim Englich <tim.englich@intevation.de>
parents: 71
diff changeset
172 public Document describe(CallContext context) {
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
173 if (this.productArtifact == null){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
174 return this.createDescibeOutput();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
175 }else{
79
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
176 Document document = this.productArtifact.describe(context);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
177 document = new ArtifactXMLUtilities().reInitDocument(document);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
178 Node staticNode = Config.getNodeXPath(document, "/result/ui/static");
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
179 if (staticNode != null){
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
180 Node staticUI = this.createSelectBox(document);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
181 staticNode.insertBefore(staticUI, staticNode.getFirstChild());
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
182 }
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
183 return document;
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
184 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
185 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
186
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
187 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
188 * @see de.intevation.artifactdatabase.DefaultArtifact#feed(org.w3c.dom.Document, java.lang.Object)
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
189 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
190 @Override
73
504570de21fd Refactoring Work depending on Infrastructurchanges in the Artifact-Module
Tim Englich <tim.englich@intevation.de>
parents: 71
diff changeset
191 public Document feed(Document target, CallContext context) {
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
192 if (this.productArtifact == null){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
193 String productName = Config.getStringXPath(target, "action/data/input[@name='product']/@value");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
194 if (this.products.containsKey(productName)) {
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
195 this.current = this.products.get(productName);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
196 }else{
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
197 log.error("Product does not exists for "+productName);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
198 // TODO: Fehlerdokument erzeugen.
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
199 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
200 return null;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
201 }else{
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
202 return this.productArtifact.feed(target, context);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
203 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
204 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
205
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
206 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
207 * @see de.intevation.artifactdatabase.DefaultArtifact#out(org.w3c.dom.Document, java.lang.Object)
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
208 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
209 @Override
73
504570de21fd Refactoring Work depending on Infrastructurchanges in the Artifact-Module
Tim Englich <tim.englich@intevation.de>
parents: 71
diff changeset
210 public void out(Document format, OutputStream outputStream, CallContext context) throws IOException {
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
211 if (this.productArtifact != null){
73
504570de21fd Refactoring Work depending on Infrastructurchanges in the Artifact-Module
Tim Englich <tim.englich@intevation.de>
parents: 71
diff changeset
212 this.productArtifact.out(format,outputStream, context);
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
213 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
214 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
215
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
216 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
217 * Constructor
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
218 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
219 public FISArtifact() {
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
220 super();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
221 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
222
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
223 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
224 * @see de.intevation.artifactdatabase.DefaultArtifact#setup(java.lang.String, de.intevation.artifacts.ArtifactFactory, java.lang.Object)
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
225 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
226 @Override
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
227 public void setup(String identifier, ArtifactFactory factory, Object context) {
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
228 log.debug("FISArtifact.setup");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
229 this.name = factory.getName();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
230 super.setup(identifier,factory, context);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
231 if (context instanceof GNVArtifactContext){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
232 GNVArtifactContext gnvContext = (GNVArtifactContext)context;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
233 Document doc = gnvContext.getConfig();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
234 Node artifactNode = this.getConfigurationFragment(doc);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
235
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
236 NodeList products = Config.getNodeSetXPath(artifactNode,"products/product");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
237 if (products != null){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
238 this.products = new HashMap<String, Product>(products.getLength());
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
239 for (int i = 0; i < products.getLength(); i++){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
240 Node productNode = products.item(i);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
241 String productName = Config.getStringXPath(productNode, "@name");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
242 NodeList parameterNodes = Config.getNodeSetXPath(productNode, "parameters/parameter");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
243 Collection<InputData> parameter = null;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
244 if (parameterNodes != null){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
245 parameter = new ArrayList<InputData>(parameterNodes.getLength());
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
246 for (int j = 0; j < parameterNodes.getLength(); j++){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
247 Node parameterNode = parameterNodes.item(j);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
248 String name = Config.getStringXPath(parameterNode, "@name");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
249 String value = Config.getStringXPath(parameterNode, "@value");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
250 parameter.add(new DefaultInputData(name, value));
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
251 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
252 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
253 Node artifactFactoryNode = Config.getNodeXPath(productNode, "artifact-factory");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
254 ArtifactFactory artifactFactory =new ArtifactFactoryUtilities().createArtitfactFactor(doc, artifactFactoryNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
255 this.products.put(productName, new DefaultProduct(productName, parameter,artifactFactory));
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
256 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
257 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
258
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
259
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
260 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
261 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
262
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
263 protected Node getConfigurationFragment(Document document){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
264 log.debug("GNVArtifactBase.getConfigurationFragment");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
265 String xpathQuery = XPATH_ARTIFACT_CONFIGURATION.replaceAll(XPATH_IDENTIFIER_REPLACE, this.name);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
266 log.debug(xpathQuery);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
267 return Config.getNodeXPath(document,xpathQuery);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
268 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
269
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
270 protected Document createDescibeOutput(){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
271 log.debug("GNVArtifactBase.createDescibeOutput");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
272 Document document = XMLUtils.newDocument();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
273 Element rootNode = this.createRootNode(document);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
274 this.createHeader(rootNode, document, "describe");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
275 this.createOutputs(rootNode, document);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
276 this.createCurrentState(rootNode, document);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
277 this.createReachableStates(rootNode, document);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
278 this.createModel(rootNode, document);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
279 this.createUserInterface(rootNode, document);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
280
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
281 return document;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
282 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
283
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
284 protected Element createRootNode(Document document){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
285 Element rootNode = xmlUtilities.createArtifactElement(document,"result");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
286 document.appendChild(rootNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
287 return rootNode;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
288 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
289
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
290 protected void createHeader(Element parent, Document document, String documentType){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
291 Element typeNode = xmlUtilities.createArtifactElement(document,"type");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
292 typeNode.setAttribute("name", documentType);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
293 parent.appendChild(typeNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
294
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
295 Element uuidNode = xmlUtilities.createArtifactElement(document,"uuid");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
296 uuidNode.setAttribute("value", super.identifier);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
297 parent.appendChild(uuidNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
298
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
299 Element hashNode = xmlUtilities.createArtifactElement(document,"hash");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
300 hashNode.setAttribute("value", this.hash());
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
301 parent.appendChild(hashNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
302
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
303
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
304 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
305 protected void createReachableStates(Element parent,Document document){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
306 Element stateNode = xmlUtilities.createArtifactElement(document,"reachable-states");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
307 if (this.products != null){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
308 Iterator<Product> products = this.products.values().iterator();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
309 while(products.hasNext()){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
310 Product product = products.next();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
311 Element currentNode = xmlUtilities.createArtifactElement(document,"state");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
312 currentNode.setAttribute("name", product.getName());
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
313 currentNode.setAttribute("description", product.getName());
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
314 stateNode.appendChild(currentNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
315 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
316 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
317 parent.appendChild(stateNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
318 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
319
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
320 protected void createCurrentState(Element parent, Document document){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
321 Element stateNode = xmlUtilities.createArtifactElement(document,"state");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
322 stateNode.setAttribute("name", "choose-product");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
323 stateNode.setAttribute("description", "Initialer Stand Auswahl des products");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
324 parent.appendChild(stateNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
325 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
326
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
327
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
328 protected void createModel(Element parent, Document document){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
329 Element modelNode = xmlUtilities.createArtifactElement(document,"model");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
330
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
331 Element inputNode = xmlUtilities.createArtifactElement(document,"input");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
332 inputNode.setAttribute("name", "product");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
333 inputNode.setAttribute("type", "String");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
334 modelNode.appendChild(inputNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
335
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
336 parent.appendChild(modelNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
337 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
338
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
339 protected void createUserInterface(Element parent, Document document){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
340 Element uiNode = xmlUtilities.createArtifactElement(document,"ui");
76
2473440671ce Integrate UI-Representation for Describe into the FISArtifact.
Tim Englich <tim.englich@intevation.de>
parents: 73
diff changeset
341 ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities();
79
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
342 Node dynamic = xmlUtilities.createArtifactElement(document, "dynamic");
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
343 uiNode.appendChild(dynamic);
76
2473440671ce Integrate UI-Representation for Describe into the FISArtifact.
Tim Englich <tim.englich@intevation.de>
parents: 73
diff changeset
344 if (this.products != null && !this.products.isEmpty()){
79
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
345 Element selectNode = createSelectBox(document);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
346
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
347 dynamic.appendChild(selectNode);
76
2473440671ce Integrate UI-Representation for Describe into the FISArtifact.
Tim Englich <tim.englich@intevation.de>
parents: 73
diff changeset
348 }
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
349
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
350 parent.appendChild(uiNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
351 }
79
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
352 /**
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
353 * @param document
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
354 * @param xmlUtilities
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
355 * @return
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
356 */
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
357 private Element createSelectBox(Document document) {
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
358 ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities();
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
359 String selectboxName = "product";
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
360 Iterator<Product> it = this.products.values().iterator();
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
361 Element selectNode = xmlUtilities.createXFormElement(document,"select1");
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
362 selectNode.setAttribute("ref", selectboxName);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
363
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
364
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
365 Element lableNode = xmlUtilities.createXFormElement(document, "label");
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
366 lableNode.setTextContent(selectboxName);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
367 selectNode.appendChild(lableNode);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
368 Element choiceNode = xmlUtilities.createXFormElement(document, "choices");
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
369 selectNode.appendChild(choiceNode);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
370 while (it.hasNext()){
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
371 Product p = it.next();
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
372 Element itemNode = xmlUtilities.createXFormElement(document, "item");
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
373
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 79
diff changeset
374 if (this.current != null && this.current.getName().equals(p.getName())){
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 79
diff changeset
375 itemNode.setAttribute("selected", "true");
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 79
diff changeset
376 }
79
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
377
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
378 Element choiceLableNode = xmlUtilities.createXFormElement(document, "label");
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
379 choiceLableNode.setTextContent(p.getName());
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
380 itemNode.appendChild(choiceLableNode);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
381
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
382 Element choicValueNode = xmlUtilities.createXFormElement(document, "value");
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
383 choicValueNode.setTextContent(p.getName());
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
384 itemNode.appendChild(choicValueNode);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
385
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
386 choiceNode.appendChild(itemNode);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
387
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
388 }
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
389 return selectNode;
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
390 }
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
391
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
392 protected void createOutputs(Element parent, Document document){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
393 log.debug("GNVArtifactBase.createOutputs");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
394 Element outputsNode = xmlUtilities.createArtifactElement(document,"outputs");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
395 parent.appendChild(outputsNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
396 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
397
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
398 }

http://dive4elements.wald.intevation.org