Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/utils/ArtifactXMLUtilities.java @ 852:b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
gnv-artifacts/trunk@968 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 22 Apr 2010 08:54:36 +0000 |
parents | 05bf8534a35a |
children | f953c9a559d8 |
rev | line source |
---|---|
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.gnv.utils; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
2 |
79
e33c61735a4e
Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents:
76
diff
changeset
|
3 import java.io.ByteArrayInputStream; |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
4 import java.io.IOException; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
5 import java.io.InputStream; |
75
9345835e2bc1
Make the Interfaces Serializable to make them usable in the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
71
diff
changeset
|
6 import java.io.Serializable; |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
7 import java.io.StringWriter; |
79
e33c61735a4e
Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents:
76
diff
changeset
|
8 import java.io.UnsupportedEncodingException; |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
9 |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
10 import javax.xml.parsers.DocumentBuilder; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
11 import javax.xml.parsers.DocumentBuilderFactory; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
12 import javax.xml.parsers.ParserConfigurationException; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
13 import javax.xml.transform.Transformer; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
14 import javax.xml.transform.TransformerConfigurationException; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
15 import javax.xml.transform.TransformerException; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
16 import javax.xml.transform.TransformerFactory; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
17 import javax.xml.transform.TransformerFactoryConfigurationError; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
18 import javax.xml.transform.dom.DOMSource; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
19 import javax.xml.transform.stream.StreamResult; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
20 |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
21 import org.apache.log4j.Logger; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
22 import org.w3c.dom.Document; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
23 import org.w3c.dom.Element; |
217
3dcd2b0b456e
Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
24 import org.w3c.dom.Node; |
823
499cfbbb61bc
Removed obsolet SuppressWarnings-Annotations.
Tim Englich <tim.englich@intevation.de>
parents:
807
diff
changeset
|
25 import org.xml.sax.SAXException; |
779
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
26 |
823
499cfbbb61bc
Removed obsolet SuppressWarnings-Annotations.
Tim Englich <tim.englich@intevation.de>
parents:
807
diff
changeset
|
27 import de.intevation.artifacts.ArtifactNamespaceContext; |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
28 |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
29 /** |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
30 * This class provides some methods for creating and working with xml documents. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
31 * |
780
c4156275c1e1
Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
779
diff
changeset
|
32 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
725
diff
changeset
|
33 * |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
34 */ |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
35 public class ArtifactXMLUtilities implements Serializable { |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
36 /** |
79
e33c61735a4e
Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents:
76
diff
changeset
|
37 * |
e33c61735a4e
Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents:
76
diff
changeset
|
38 */ |
e33c61735a4e
Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents:
76
diff
changeset
|
39 private static final long serialVersionUID = -6236340358303411758L; |
e33c61735a4e
Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents:
76
diff
changeset
|
40 |
e33c61735a4e
Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents:
76
diff
changeset
|
41 /** |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
42 * the logger, used to log exceptions and additonaly information |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
43 */ |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
44 private static Logger log = Logger |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
217
diff
changeset
|
45 .getLogger(ArtifactXMLUtilities.class); |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
46 |
76
2473440671ce
Integrate UI-Representation for Describe into the FISArtifact.
Tim Englich <tim.englich@intevation.de>
parents:
75
diff
changeset
|
47 public static final String XFORM_URL = "http://www.w3.org/2002/xforms"; |
2473440671ce
Integrate UI-Representation for Describe into the FISArtifact.
Tim Englich <tim.englich@intevation.de>
parents:
75
diff
changeset
|
48 public static final String XFORM_PREFIX = "xform"; |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
49 |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
50 /** |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
51 * Constructor.<br> |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
52 * <b>Note:</b> It should not be necessary to create an object of this |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
53 * class - which is a helper class. Call static methods instead. |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
54 */ |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
55 public ArtifactXMLUtilities() { |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
56 } |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
57 |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
58 /** |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
59 * Creates an <code>Element</code> and returns it. |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
806
diff
changeset
|
60 * |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
61 * @param document A document |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
62 * @param name Name of a node. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
63 * @return an Element. |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
64 */ |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
65 public static Element createArtifactElement(Document document, String name) { |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
66 Element node = document.createElementNS( |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
67 ArtifactNamespaceContext.NAMESPACE_URI, name); |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
68 node.setPrefix(ArtifactNamespaceContext.NAMESPACE_PREFIX); |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
69 return node; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
70 } |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
71 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
72 |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
73 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
74 * Turns an xml document into a string. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
75 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
76 * @param document An xml document. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
77 * @return String representation of <i>document</i>. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
78 */ |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
79 public static String writeDocument2String(Document document) { |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
80 try { |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
81 TransformerFactory transformerFactory = TransformerFactory |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
82 .newInstance(); |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
83 Transformer transformer = transformerFactory.newTransformer(); |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
84 DOMSource source = new DOMSource(document); |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
85 StringWriter sw = new StringWriter(); |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
86 StreamResult result = new StreamResult(sw); |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
87 transformer.transform(source, result); |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
88 return sw.getBuffer().toString(); |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
89 } catch (TransformerConfigurationException e) { |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
90 log.error(e, e); |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
91 } catch (TransformerFactoryConfigurationError e) { |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
92 log.error(e, e); |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
93 } catch (TransformerException e) { |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
94 log.error(e, e); |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
95 } |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
96 return null; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
97 } |
79
e33c61735a4e
Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents:
76
diff
changeset
|
98 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
99 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
100 * Read a document from input stream. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
101 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
102 * @param inputStream The input stream. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
103 * @return the document read from stream. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
104 */ |
358
2f7a28f211c7
Fetch ChartTheme from CallContext instead of creating it each time before creating a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
335
diff
changeset
|
105 public static Document readDocument(InputStream inputStream) { |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
106 Document returnValue = null; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
107 try { |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
108 DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
109 .newInstance(); |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
110 DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
111 returnValue = docBuilder.parse(inputStream); |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
112 } catch (ParserConfigurationException e) { |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
113 log.error(e, e); |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
114 } catch (SAXException e) { |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
115 log.error(e, e); |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
116 } catch (IOException e) { |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
117 log.error(e, e); |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
118 } |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
119 return returnValue; |
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
120 } |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
121 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
122 |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
123 public Document reInitDocument(Document document) { |
79
e33c61735a4e
Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents:
76
diff
changeset
|
124 try { |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
125 byte[] barray = ArtifactXMLUtilities.writeDocument2String(document).getBytes( |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
126 "UTF-8"); |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
127 InputStream inputStream = new ByteArrayInputStream(barray); |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
128 return ArtifactXMLUtilities.readDocument(inputStream); |
79
e33c61735a4e
Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents:
76
diff
changeset
|
129 } catch (UnsupportedEncodingException e) { |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
130 log.error(e, e); |
79
e33c61735a4e
Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents:
76
diff
changeset
|
131 } |
e33c61735a4e
Implementation of the Static UI done
Tim Englich <tim.englich@intevation.de>
parents:
76
diff
changeset
|
132 return document; |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
133 } |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
134 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
135 |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
136 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
137 * Creates an <code>Element</code> with {@link #XFORM_PREFIX} and <i>name |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
138 * </i>. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
139 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
140 * @param document A document. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
141 * @param name The node name. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
142 * @return the created element. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
143 */ |
456
b8080695ea62
Splitted code pathes of dynamic and static nodes. Static nodes contain the selected value only instead of transfering the whole stack of options again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
358
diff
changeset
|
144 public static Element createXFormElement(Document document, String name) { |
76
2473440671ce
Integrate UI-Representation for Describe into the FISArtifact.
Tim Englich <tim.englich@intevation.de>
parents:
75
diff
changeset
|
145 Element node = document.createElementNS(XFORM_URL, name); |
2473440671ce
Integrate UI-Representation for Describe into the FISArtifact.
Tim Englich <tim.englich@intevation.de>
parents:
75
diff
changeset
|
146 node.setPrefix(XFORM_PREFIX); |
2473440671ce
Integrate UI-Representation for Describe into the FISArtifact.
Tim Englich <tim.englich@intevation.de>
parents:
75
diff
changeset
|
147 return node; |
2473440671ce
Integrate UI-Representation for Describe into the FISArtifact.
Tim Englich <tim.englich@intevation.de>
parents:
75
diff
changeset
|
148 } |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
149 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
150 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
151 * Creates an exception node. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
152 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
153 * @param message The message in the node. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
154 * @param document A document. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
155 * @return the document containing the exception node. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
156 */ |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
157 public static Document createExceptionReport(String message, Document document) { |
88
1b12021905b9
Some CodeCleanup done.
Tim Englich <tim.englich@intevation.de>
parents:
79
diff
changeset
|
158 log.debug("ArtifactXMLUtilities.createExceptionReport"); |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
159 Element exceptionReportNode = createArtifactElement(document, |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
160 "exceptionreport"); |
88
1b12021905b9
Some CodeCleanup done.
Tim Englich <tim.englich@intevation.de>
parents:
79
diff
changeset
|
161 document.appendChild(exceptionReportNode); |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
162 Element exceptionNode = createArtifactElement(document, |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
163 "exception"); |
88
1b12021905b9
Some CodeCleanup done.
Tim Englich <tim.englich@intevation.de>
parents:
79
diff
changeset
|
164 exceptionNode.setTextContent(message); |
1b12021905b9
Some CodeCleanup done.
Tim Englich <tim.englich@intevation.de>
parents:
79
diff
changeset
|
165 exceptionReportNode.appendChild(exceptionNode); |
1b12021905b9
Some CodeCleanup done.
Tim Englich <tim.englich@intevation.de>
parents:
79
diff
changeset
|
166 return document; |
1b12021905b9
Some CodeCleanup done.
Tim Englich <tim.englich@intevation.de>
parents:
79
diff
changeset
|
167 } |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
89
diff
changeset
|
168 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
169 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
170 * Creates an input exception node. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
171 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
172 * @param msg The message in the node. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
173 * @param doc A document. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
174 * @return the document containing the exception node. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
175 */ |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
176 public static Document createInputExceptionReport(String msg, Document doc) { |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
177 Element exceptionReportNode = createArtifactElement( |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
178 doc,"exceptionreport"); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
179 Element exceptionNode = createArtifactElement( |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
180 doc,"exception"); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
181 Element inputNode = createArtifactElement( |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
182 doc, "input"); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
183 inputNode.setTextContent(msg); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
184 exceptionNode.appendChild(inputNode); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
185 exceptionReportNode.appendChild(exceptionNode); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
186 doc.appendChild(exceptionReportNode); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
187 return doc; |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
188 } |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
189 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
190 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
191 * Creates a success node. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
192 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
193 * @param message The message. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
194 * @param document A document. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
195 * @return the document containing the success node. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
196 */ |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
197 public static Document createSuccessReport(String message, Document document) { |
89
cde042a0a395
Successreporting added
Tim Englich <tim.englich@intevation.de>
parents:
88
diff
changeset
|
198 log.debug("ArtifactXMLUtilities.creatSuccessReport"); |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
199 Element reportNode = createArtifactElement(document, "result"); |
89
cde042a0a395
Successreporting added
Tim Englich <tim.englich@intevation.de>
parents:
88
diff
changeset
|
200 document.appendChild(reportNode); |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
456
diff
changeset
|
201 Element successNode = createArtifactElement(document, "success"); |
89
cde042a0a395
Successreporting added
Tim Englich <tim.englich@intevation.de>
parents:
88
diff
changeset
|
202 successNode.setTextContent(message); |
cde042a0a395
Successreporting added
Tim Englich <tim.englich@intevation.de>
parents:
88
diff
changeset
|
203 reportNode.appendChild(successNode); |
cde042a0a395
Successreporting added
Tim Englich <tim.englich@intevation.de>
parents:
88
diff
changeset
|
204 return document; |
cde042a0a395
Successreporting added
Tim Englich <tim.englich@intevation.de>
parents:
88
diff
changeset
|
205 } |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
725
diff
changeset
|
206 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
207 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
208 * Read <i>fileName</i> and return the first child node. |
807
a645bd23c1c8
Added more javadoc. Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
806
diff
changeset
|
209 * |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
210 * @param fileName An xml document. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
211 * @return the first child node in this document. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
212 */ |
217
3dcd2b0b456e
Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
213 public Node readConfiguration(String fileName){ |
3dcd2b0b456e
Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
214 try { |
3dcd2b0b456e
Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
215 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
725
diff
changeset
|
216 factory.setValidating(false); |
217
3dcd2b0b456e
Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
217 return factory.newDocumentBuilder().parse(fileName).getChildNodes().item(0); |
3dcd2b0b456e
Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
218 } catch (SAXException e) { |
3dcd2b0b456e
Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
219 log.error(e,e); |
3dcd2b0b456e
Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
220 return null; |
3dcd2b0b456e
Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
221 } catch (IOException e) { |
3dcd2b0b456e
Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
222 log.error(e,e); |
3dcd2b0b456e
Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
223 return null; |
3dcd2b0b456e
Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
224 } catch (ParserConfigurationException e) { |
3dcd2b0b456e
Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
225 log.error(e,e); |
3dcd2b0b456e
Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
226 return null; |
3dcd2b0b456e
Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
227 } |
3dcd2b0b456e
Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
228 } |
71
e4ecf3188bdf
Integrated FIS-Artifact
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
229 } |
836
05bf8534a35a
Using unix line endings only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
823
diff
changeset
|
230 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |