annotate gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java @ 112:b8dbf39ca935

Fixed some text/xml MIME types in configuration. gnv-artifacts/trunk@161 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 30 Sep 2009 06:00:21 +0000
parents cde042a0a395
children 158e89c2263b
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) {
88
1b12021905b9 Some CodeCleanup done.
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
82
1b12021905b9 Some CodeCleanup done.
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
83 Document result = null;
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
84 if (this.productArtifact == null){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
85 if (this.current != null){
88
1b12021905b9 Some CodeCleanup done.
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
86
1b12021905b9 Some CodeCleanup done.
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
87 String uuid = Config.getStringXPath(target, "action/uuid/@value");
79
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
88 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
89 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
90 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
91 log.debug("Feed ==> "+this.xmlUtilities.writeDocument2String(feedDocument));
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
92 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
93 log.debug("Descibe ==> "+this.xmlUtilities.writeDocument2String(descibeDocument));
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
94 this.productArtifact.feed(feedDocument, context);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
95 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
96 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
97 log.debug("Advance ==> "+this.xmlUtilities.writeDocument2String(advanceDocument));
88
1b12021905b9 Some CodeCleanup done.
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
98 result = this.productArtifact.advance(advanceDocument, context);
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
99 }else{
88
1b12021905b9 Some CodeCleanup done.
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
100 String msg = "Artifact is not configured properly. Call feed first.";
1b12021905b9 Some CodeCleanup done.
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
101 log.error(msg);
1b12021905b9 Some CodeCleanup done.
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
102 result = new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument());
71
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 }else{
88
1b12021905b9 Some CodeCleanup done.
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
105 result = this.productArtifact.advance(target, context);
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
106 }
88
1b12021905b9 Some CodeCleanup done.
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
107 return result;
71
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) {
89
cde042a0a395 Successreporting added
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
192 log.debug("FISArtifact.feed");
cde042a0a395 Successreporting added
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
193 Document result = null;
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
194 if (this.productArtifact == null){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
195 String productName = Config.getStringXPath(target, "action/data/input[@name='product']/@value");
89
cde042a0a395 Successreporting added
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
196 log.debug("Looking for ProductArtifact "+productName);
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
197 if (this.products.containsKey(productName)) {
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
198 this.current = this.products.get(productName);
89
cde042a0a395 Successreporting added
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
199 result = new ArtifactXMLUtilities().createSuccessReport("Feed success New ProductArtifact created", XMLUtils.newDocument());
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
200 }else{
88
1b12021905b9 Some CodeCleanup done.
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
201 String msg = "Product does not exists for "+productName;
1b12021905b9 Some CodeCleanup done.
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
202 log.error(msg);
89
cde042a0a395 Successreporting added
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
203 result = new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument());
71
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 }else{
89
cde042a0a395 Successreporting added
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
206 log.debug("Feed a Productartifact");
cde042a0a395 Successreporting added
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
207 result = this.productArtifact.feed(target, context);
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
208 }
89
cde042a0a395 Successreporting added
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
209 return result;
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
210 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
211
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
212 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
213 * @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
214 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
215 @Override
73
504570de21fd Refactoring Work depending on Infrastructurchanges in the Artifact-Module
Tim Englich <tim.englich@intevation.de>
parents: 71
diff changeset
216 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
217 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
218 this.productArtifact.out(format,outputStream, context);
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
219 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
220 }
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 * Constructor
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
224 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
225 public FISArtifact() {
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
226 super();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
227 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
228
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
229 /**
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
230 * @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
231 */
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
232 @Override
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
233 public void setup(String identifier, ArtifactFactory factory, Object context) {
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
234 log.debug("FISArtifact.setup");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
235 this.name = factory.getName();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
236 super.setup(identifier,factory, context);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
237 if (context instanceof GNVArtifactContext){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
238 GNVArtifactContext gnvContext = (GNVArtifactContext)context;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
239 Document doc = gnvContext.getConfig();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
240 Node artifactNode = this.getConfigurationFragment(doc);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
241
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
242 NodeList products = Config.getNodeSetXPath(artifactNode,"products/product");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
243 if (products != null){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
244 this.products = new HashMap<String, Product>(products.getLength());
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
245 for (int i = 0; i < products.getLength(); i++){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
246 Node productNode = products.item(i);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
247 String productName = Config.getStringXPath(productNode, "@name");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
248 NodeList parameterNodes = Config.getNodeSetXPath(productNode, "parameters/parameter");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
249 Collection<InputData> parameter = null;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
250 if (parameterNodes != null){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
251 parameter = new ArrayList<InputData>(parameterNodes.getLength());
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
252 for (int j = 0; j < parameterNodes.getLength(); j++){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
253 Node parameterNode = parameterNodes.item(j);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
254 String name = Config.getStringXPath(parameterNode, "@name");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
255 String value = Config.getStringXPath(parameterNode, "@value");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
256 parameter.add(new DefaultInputData(name, value));
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 Node artifactFactoryNode = Config.getNodeXPath(productNode, "artifact-factory");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
260 ArtifactFactory artifactFactory =new ArtifactFactoryUtilities().createArtitfactFactor(doc, artifactFactoryNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
261 this.products.put(productName, new DefaultProduct(productName, parameter,artifactFactory));
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 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
264 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
265 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
266
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
267 protected Node getConfigurationFragment(Document document){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
268 log.debug("GNVArtifactBase.getConfigurationFragment");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
269 String xpathQuery = XPATH_ARTIFACT_CONFIGURATION.replaceAll(XPATH_IDENTIFIER_REPLACE, this.name);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
270 log.debug(xpathQuery);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
271 return Config.getNodeXPath(document,xpathQuery);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
272 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
273
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
274 protected Document createDescibeOutput(){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
275 log.debug("GNVArtifactBase.createDescibeOutput");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
276 Document document = XMLUtils.newDocument();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
277 Element rootNode = this.createRootNode(document);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
278 this.createHeader(rootNode, document, "describe");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
279 this.createOutputs(rootNode, document);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
280 this.createCurrentState(rootNode, document);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
281 this.createReachableStates(rootNode, document);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
282 this.createModel(rootNode, document);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
283 this.createUserInterface(rootNode, document);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
284
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
285 return document;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
286 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
287
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
288 protected Element createRootNode(Document document){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
289 Element rootNode = xmlUtilities.createArtifactElement(document,"result");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
290 document.appendChild(rootNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
291 return rootNode;
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
292 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
293
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
294 protected void createHeader(Element parent, Document document, String documentType){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
295 Element typeNode = xmlUtilities.createArtifactElement(document,"type");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
296 typeNode.setAttribute("name", documentType);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
297 parent.appendChild(typeNode);
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 uuidNode = xmlUtilities.createArtifactElement(document,"uuid");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
300 uuidNode.setAttribute("value", super.identifier);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
301 parent.appendChild(uuidNode);
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 Element hashNode = xmlUtilities.createArtifactElement(document,"hash");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
304 hashNode.setAttribute("value", this.hash());
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
305 parent.appendChild(hashNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
306
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
307
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
308 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
309 protected void createReachableStates(Element parent,Document document){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
310 Element stateNode = xmlUtilities.createArtifactElement(document,"reachable-states");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
311 if (this.products != null){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
312 Iterator<Product> products = this.products.values().iterator();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
313 while(products.hasNext()){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
314 Product product = products.next();
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
315 Element currentNode = xmlUtilities.createArtifactElement(document,"state");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
316 currentNode.setAttribute("name", product.getName());
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
317 currentNode.setAttribute("description", product.getName());
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
318 stateNode.appendChild(currentNode);
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 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
321 parent.appendChild(stateNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
322 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
323
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
324 protected void createCurrentState(Element parent, Document document){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
325 Element stateNode = xmlUtilities.createArtifactElement(document,"state");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
326 stateNode.setAttribute("name", "choose-product");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
327 stateNode.setAttribute("description", "Initialer Stand Auswahl des products");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
328 parent.appendChild(stateNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
329 }
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
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
332 protected void createModel(Element parent, Document document){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
333 Element modelNode = xmlUtilities.createArtifactElement(document,"model");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
334
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
335 Element inputNode = xmlUtilities.createArtifactElement(document,"input");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
336 inputNode.setAttribute("name", "product");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
337 inputNode.setAttribute("type", "String");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
338 modelNode.appendChild(inputNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
339
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
340 parent.appendChild(modelNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
341 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
342
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
343 protected void createUserInterface(Element parent, Document document){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
344 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
345 ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities();
79
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
346 Node dynamic = xmlUtilities.createArtifactElement(document, "dynamic");
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
347 uiNode.appendChild(dynamic);
76
2473440671ce Integrate UI-Representation for Describe into the FISArtifact.
Tim Englich <tim.englich@intevation.de>
parents: 73
diff changeset
348 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
349 Element selectNode = createSelectBox(document);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
350
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
351 dynamic.appendChild(selectNode);
76
2473440671ce Integrate UI-Representation for Describe into the FISArtifact.
Tim Englich <tim.englich@intevation.de>
parents: 73
diff changeset
352 }
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
353
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
354 parent.appendChild(uiNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
355 }
79
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 * @param document
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
358 * @param xmlUtilities
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
359 * @return
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
360 */
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
361 private Element createSelectBox(Document document) {
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
362 ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities();
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
363 String selectboxName = "product";
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
364 Iterator<Product> it = this.products.values().iterator();
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
365 Element selectNode = xmlUtilities.createXFormElement(document,"select1");
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
366 selectNode.setAttribute("ref", selectboxName);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
367
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
368
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
369 Element lableNode = xmlUtilities.createXFormElement(document, "label");
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
370 lableNode.setTextContent(selectboxName);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
371 selectNode.appendChild(lableNode);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
372 Element choiceNode = xmlUtilities.createXFormElement(document, "choices");
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
373 selectNode.appendChild(choiceNode);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
374 while (it.hasNext()){
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
375 Product p = it.next();
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
376 Element itemNode = xmlUtilities.createXFormElement(document, "item");
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
377
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 79
diff changeset
378 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
379 itemNode.setAttribute("selected", "true");
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 79
diff changeset
380 }
79
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 choiceLableNode = xmlUtilities.createXFormElement(document, "label");
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
383 choiceLableNode.setTextContent(p.getName());
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
384 itemNode.appendChild(choiceLableNode);
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 Element choicValueNode = xmlUtilities.createXFormElement(document, "value");
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
387 choicValueNode.setTextContent(p.getName());
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
388 itemNode.appendChild(choicValueNode);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
389
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
390 choiceNode.appendChild(itemNode);
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
391
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
392 }
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
393 return selectNode;
e33c61735a4e Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents: 78
diff changeset
394 }
71
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
395
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
396 protected void createOutputs(Element parent, Document document){
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
397 log.debug("GNVArtifactBase.createOutputs");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
398 Element outputsNode = xmlUtilities.createArtifactElement(document,"outputs");
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
399 parent.appendChild(outputsNode);
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
400 }
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
401
e4ecf3188bdf Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
402 }

http://dive4elements.wald.intevation.org