Mercurial > dive4elements > gnv-client
annotate gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java @ 678:2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
gnv/trunk@813 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 22 Mar 2010 10:15:33 +0000 |
parents | 707e142e7d44 |
children | 4eccd03394ac |
rev | line source |
---|---|
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.gnv.artifactdatabase.client; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
2 |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
3 import java.io.IOException; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
4 import java.io.InputStream; |
678
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
5 import java.io.InputStreamReader; |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
6 import java.io.OutputStream; |
678
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
7 import java.io.OutputStreamWriter; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
8 import java.util.ArrayList; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
9 import java.util.Collection; |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
10 import java.util.HashMap; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
11 import java.util.Iterator; |
40
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
12 import java.util.List; |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
13 import java.util.Locale; |
558
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
14 import java.util.Map; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
15 |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
16 import org.apache.log4j.Logger; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
17 import org.restlet.Client; |
558
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
18 import org.restlet.data.ClientInfo; |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
19 import org.restlet.data.Language; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
20 import org.restlet.data.Method; |
558
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
21 import org.restlet.data.Preference; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
22 import org.restlet.data.Protocol; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
23 import org.restlet.data.Request; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
24 import org.restlet.data.Response; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
25 import org.restlet.representation.Representation; |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
26 import org.restlet.representation.StringRepresentation; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
27 import org.w3c.dom.Document; |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
28 import org.w3c.dom.Element; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
29 import org.w3c.dom.Node; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
30 import org.w3c.dom.NodeList; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
31 |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
32 import de.intevation.gnv.artifactdatabase.client.exception.ArtifactDatabaseClientException; |
665
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
33 import de.intevation.gnv.artifactdatabase.client.exception.ArtifactDatabaseInputException; |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
34 import de.intevation.gnv.artifactdatabase.objects.Artifact; |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
35 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
36 import de.intevation.gnv.artifactdatabase.objects.ArtifactFactory; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
37 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject; |
164
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
38 import de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticsSet; |
32
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
39 import de.intevation.gnv.artifactdatabase.objects.DefaultArtifactStatisticValue; |
164
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
40 import de.intevation.gnv.artifactdatabase.objects.DefaultArtifactStatisticsSet; |
573
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
41 import de.intevation.gnv.artifactdatabase.objects.DefaultExportMode; |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
42 import de.intevation.gnv.artifactdatabase.objects.DefaultOutputMode; |
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
43 import de.intevation.gnv.artifactdatabase.objects.DefaultOutputParameter; |
573
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
44 import de.intevation.gnv.artifactdatabase.objects.ExportMode; |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
45 import de.intevation.gnv.artifactdatabase.objects.InputParameter; |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
46 import de.intevation.gnv.artifactdatabase.objects.OutputMode; |
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
47 import de.intevation.gnv.artifactdatabase.objects.OutputParameter; |
558
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
48 import de.intevation.gnv.artifactdatabase.objects.ParametrizedArtifactFactory; |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
49 import de.intevation.gnv.artifactdatabase.objects.ParametrizedArtifactObject; |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
50 import de.intevation.gnv.artifactdatabase.objects.map.Layer; |
402
b88e881e8e94
Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
394
diff
changeset
|
51 import de.intevation.gnv.artifactdatabase.objects.map.MapService; |
23
b11f941f7eb2
Made ArtifactDatabase URL configurable
Tim Englich <tim.englich@intevation.de>
parents:
19
diff
changeset
|
52 import de.intevation.gnv.propertiesreader.PropertiesReader; |
b11f941f7eb2
Made ArtifactDatabase URL configurable
Tim Englich <tim.englich@intevation.de>
parents:
19
diff
changeset
|
53 import de.intevation.gnv.propertiesreader.PropertiesReaderFactory; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
54 import de.intevation.gnv.util.XMLUtils; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
55 |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
56 /** |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
57 * @author Tim Englich (tim.englich@intevation.de) |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
58 * @author Ingo Weinzierl (ingo.weinzierl@intevation.de) |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
59 */ |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
60 public class DefaultArtifactDatabaseClient implements ArtifactDatabaseClient { |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
61 /** |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
62 * The URI of the namespace of the artifacts. |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
63 */ |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
64 public final static String NAMESPACE_URI = "http://www.intevation.de/2009/artifacts"; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
65 |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
66 /** |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
67 * The XML prefix for the artifacts namespace. |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
68 */ |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
69 public final static String NAMESPACE_PREFIX = "art"; |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
70 |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
71 /** |
665
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
72 * Xpath expression to get general exception messages related to server |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
73 * errors. |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
74 */ |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
75 public static final String EXCEPTION_GENERAL = |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
76 "/art:exceptionreport/art:exception/text()"; |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
77 |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
78 /** |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
79 * Xpath expression to get exception messages related to invalid user input. |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
80 */ |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
81 public static final String EXCEPTION_USER_INPUT = |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
82 "/art:exceptionreport/art:exception/art:input/text()"; |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
83 |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
84 /** |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
85 * the logger, used to log exceptions and additonaly information |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
86 */ |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
87 private static Logger log = Logger |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
88 .getLogger(DefaultArtifactDatabaseClient.class); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
89 |
25 | 90 /** |
91 * The Databases which could be used | |
92 */ | |
93 private static Collection<String> artifactDatabases = null; | |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
94 |
25 | 95 /** |
96 * Is the Class initialized? | |
97 */ | |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
98 private static boolean initialized = false; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
99 |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
100 /** |
40
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
101 * Request locale |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
102 */ |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
103 private Locale locale; |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
104 |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
105 |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
106 /** |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
107 * Constructor |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
108 */ |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
109 public DefaultArtifactDatabaseClient() { |
40
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
110 |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
111 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
112 |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
113 /** |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
114 * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#getArtifactFactories() |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
115 */ |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
116 public Collection<ArtifactObject> getArtifactFactories() |
665
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
117 throws ArtifactDatabaseClientException, ArtifactDatabaseInputException { |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
118 Collection<ArtifactObject> resultValues = null; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
119 if (!initialized) { |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
120 this.initialize(); |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
121 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
122 try { |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
123 log.debug("DefaultArtifactDatabaseClient.getArtifactFactories"); |
25 | 124 Iterator<String> it = artifactDatabases.iterator(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
125 while (it.hasNext()) { |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
126 String server = it.next(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
127 String url = server + "/factories"; |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
128 Document document = this.doGetRequest(url); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
129 if (resultValues == null) { |
565
8355d7cacd09
Modified the Create-Artifact-Request-Body that a Geometry will be put into
Tim Englich <tim.englich@intevation.de>
parents:
561
diff
changeset
|
130 resultValues = this.getArtifactFactories(document, server,null); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
131 } else { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
132 resultValues.addAll(this.getArtifactFactories(document, |
565
8355d7cacd09
Modified the Create-Artifact-Request-Body that a Geometry will be put into
Tim Englich <tim.englich@intevation.de>
parents:
561
diff
changeset
|
133 server,null)); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
134 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
135 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
136 } catch (IOException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
137 log.error(e, e); |
47
f35b7d7a04d6
Read the Status-Code from the Response and throw an Exception which Message will be visualized in the GUI. gnv/issue18
Tim Englich <tim.englich@intevation.de>
parents:
40
diff
changeset
|
138 throw new ArtifactDatabaseClientException(e); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
139 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
140 return resultValues; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
141 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
142 |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
143 private Collection<ArtifactObject> getArtifactFactories(Document document, |
565
8355d7cacd09
Modified the Create-Artifact-Request-Body that a Geometry will be put into
Tim Englich <tim.englich@intevation.de>
parents:
561
diff
changeset
|
144 String server, |
8355d7cacd09
Modified the Create-Artifact-Request-Body that a Geometry will be put into
Tim Englich <tim.englich@intevation.de>
parents:
561
diff
changeset
|
145 String geometry) { |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
146 XMLUtils xmlUtils = new XMLUtils(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
147 NodeList artifactFactories = xmlUtils.getNodeSetXPath(document, |
389
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
281
diff
changeset
|
148 "/art:result/art:factories/art:factory"); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
149 Collection<ArtifactObject> resultValues = new ArrayList<ArtifactObject>( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
150 artifactFactories.getLength()); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
151 if (artifactFactories != null) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
152 for (int i = 0; i < artifactFactories.getLength(); i++) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
153 Node artifactFactoryNode = artifactFactories.item(i); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
154 String name = xmlUtils.getStringXPath(artifactFactoryNode, |
389
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
281
diff
changeset
|
155 "@art:name"); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
156 String description = xmlUtils.getStringXPath( |
389
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
281
diff
changeset
|
157 artifactFactoryNode, "@art:description"); |
558
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
158 |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
159 NodeList parameterNodeList = xmlUtils.getNodeSetXPath( |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
160 artifactFactoryNode, |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
161 "art:parameter"); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
162 |
565
8355d7cacd09
Modified the Create-Artifact-Request-Body that a Geometry will be put into
Tim Englich <tim.englich@intevation.de>
parents:
561
diff
changeset
|
163 if ((parameterNodeList != null && |
8355d7cacd09
Modified the Create-Artifact-Request-Body that a Geometry will be put into
Tim Englich <tim.englich@intevation.de>
parents:
561
diff
changeset
|
164 parameterNodeList.getLength() > 0) || |
8355d7cacd09
Modified the Create-Artifact-Request-Body that a Geometry will be put into
Tim Englich <tim.englich@intevation.de>
parents:
561
diff
changeset
|
165 geometry != null){ |
558
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
166 Collection<String> parameters = |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
167 new ArrayList<String>(parameterNodeList.getLength()); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
168 for (int j = 0; j < parameterNodeList.getLength(); j++){ |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
169 Element parameterNode = (Element)parameterNodeList.item(j); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
170 parameters.add(parameterNode.getAttribute("id")); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
171 } |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
172 ParametrizedArtifactObject pao = |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
173 new ParametrizedArtifactFactory(name, |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
174 description, |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
175 server); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
176 pao.addParameters("parameter", parameters); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
177 resultValues.add(pao); |
565
8355d7cacd09
Modified the Create-Artifact-Request-Body that a Geometry will be put into
Tim Englich <tim.englich@intevation.de>
parents:
561
diff
changeset
|
178 if (geometry != null){ |
8355d7cacd09
Modified the Create-Artifact-Request-Body that a Geometry will be put into
Tim Englich <tim.englich@intevation.de>
parents:
561
diff
changeset
|
179 Collection<String> geometryList = new ArrayList<String>(1); |
8355d7cacd09
Modified the Create-Artifact-Request-Body that a Geometry will be put into
Tim Englich <tim.englich@intevation.de>
parents:
561
diff
changeset
|
180 geometryList.add(geometry); |
8355d7cacd09
Modified the Create-Artifact-Request-Body that a Geometry will be put into
Tim Englich <tim.englich@intevation.de>
parents:
561
diff
changeset
|
181 pao.addParameters("geometry",geometryList); |
8355d7cacd09
Modified the Create-Artifact-Request-Body that a Geometry will be put into
Tim Englich <tim.englich@intevation.de>
parents:
561
diff
changeset
|
182 } |
558
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
183 }else{ |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
184 ArtifactObject artifactFactory = new ArtifactFactory(name, |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
185 description, |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
186 server); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
187 resultValues.add(artifactFactory); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
188 } |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
189 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
190 } |
389
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
281
diff
changeset
|
191 log.debug("Artifact Factories: " + resultValues.size()); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
192 return resultValues; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
193 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
194 |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
195 /** |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
196 * @throws IOException |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
197 */ |
665
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
198 private Document doGetRequest(String requestUrl) |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
199 throws IOException, ArtifactDatabaseClientException, ArtifactDatabaseInputException { |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
200 return this.doGetRequest(requestUrl, null); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
201 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
202 |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
203 /** |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
204 * @throws IOException |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
205 */ |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
206 private Document doGetRequest(String requestUrl, Document requestBody) |
665
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
207 throws IOException, ArtifactDatabaseClientException, ArtifactDatabaseInputException { |
25 | 208 XMLUtils xmlUtils = new XMLUtils(); |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
209 Representation output = doGetRequestInternal(requestUrl, requestBody); |
25 | 210 Document document = xmlUtils.readDocument(output.getStream()); |
211 this.check4ExceptionReport(document); | |
212 return document; | |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
213 } |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
214 |
40
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
215 protected Request initialize(Request request) { |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
216 return initialize(request, locale); |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
217 } |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
218 |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
219 protected Request initialize(Request request, Locale locale) { |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
220 if (locale != null) { |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
221 ClientInfo clientInfo = request.getClientInfo(); |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
222 String lang = locale.getLanguage(); |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
223 Language language = new Language(lang); |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
224 List<Preference<Language>> acceptedLanguages = |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
225 new ArrayList<Preference<Language>>(2); |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
226 acceptedLanguages.add(new Preference(language, 1.0f)); |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
227 acceptedLanguages.add(new Preference(Language.ALL, 0.5f)); |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
228 clientInfo.setAcceptedLanguages(acceptedLanguages); |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
229 } |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
230 return request; |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
231 } |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
232 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
233 /** |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
234 * @param requestUrl |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
235 * @param requestBody |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
236 * @return |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
237 */ |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
238 private Representation doGetRequestInternal(String requestUrl, |
47
f35b7d7a04d6
Read the Status-Code from the Response and throw an Exception which Message will be visualized in the GUI. gnv/issue18
Tim Englich <tim.englich@intevation.de>
parents:
40
diff
changeset
|
239 Document requestBody) throws IOException { |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
240 Client client = new Client(Protocol.HTTP); |
40
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
241 Request request = initialize(new Request(Method.GET, requestUrl)); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
242 if (requestBody != null) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
243 String documentBody = new XMLUtils() |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
244 .writeDocument2String(requestBody); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
245 Representation representation = new StringRepresentation( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
246 documentBody); |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
247 request.setEntity(representation); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
248 } |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
249 Response response = client.handle(request); |
47
f35b7d7a04d6
Read the Status-Code from the Response and throw an Exception which Message will be visualized in the GUI. gnv/issue18
Tim Englich <tim.englich@intevation.de>
parents:
40
diff
changeset
|
250 if (response.getStatus().getCode() != 200){ |
f35b7d7a04d6
Read the Status-Code from the Response and throw an Exception which Message will be visualized in the GUI. gnv/issue18
Tim Englich <tim.englich@intevation.de>
parents:
40
diff
changeset
|
251 throw new IOException(response.getStatus().getDescription()); |
f35b7d7a04d6
Read the Status-Code from the Response and throw an Exception which Message will be visualized in the GUI. gnv/issue18
Tim Englich <tim.englich@intevation.de>
parents:
40
diff
changeset
|
252 } |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
253 Representation output = response.getEntity(); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
254 return output; |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
255 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
256 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
257 /** |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
258 * @throws IOException |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
259 */ |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
260 private InputStream doPostRequest(String requestUrl, Document requestBody) |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
261 throws IOException { |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
262 Client client = new Client(Protocol.HTTP); |
40
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
263 Request request = initialize(new Request(Method.POST, requestUrl)); |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
264 String documentBody = new XMLUtils().writeDocument2String(requestBody); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
265 Representation representation = new StringRepresentation(documentBody); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
266 request.setEntity(representation); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
267 Response response = client.handle(request); |
47
f35b7d7a04d6
Read the Status-Code from the Response and throw an Exception which Message will be visualized in the GUI. gnv/issue18
Tim Englich <tim.englich@intevation.de>
parents:
40
diff
changeset
|
268 if (response.getStatus().getCode() != 200){ |
f35b7d7a04d6
Read the Status-Code from the Response and throw an Exception which Message will be visualized in the GUI. gnv/issue18
Tim Englich <tim.englich@intevation.de>
parents:
40
diff
changeset
|
269 throw new IOException(response.getStatus().getDescription()); |
f35b7d7a04d6
Read the Status-Code from the Response and throw an Exception which Message will be visualized in the GUI. gnv/issue18
Tim Englich <tim.englich@intevation.de>
parents:
40
diff
changeset
|
270 } |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
271 Representation output = response.getEntity(); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
272 return output.getStream(); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
273 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
274 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
275 private synchronized void initialize() { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
276 if (!initialized) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
277 PropertiesReader pr = PropertiesReaderFactory.getInstance() |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
278 .getPropertiesReader(); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
279 int count = Integer.parseInt(pr.getPropertieValue( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
280 ARTIFACTDATABASE_COUNT_ID, "0")); |
25 | 281 artifactDatabases = new ArrayList<String>(count); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
282 for (int i = 0; i < count; i++) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
283 artifactDatabases.add(pr.getPropertieValue( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
284 ARTIFACTDATABASE_URL_ID + "." + (i + 1), "N/N")); |
23
b11f941f7eb2
Made ArtifactDatabase URL configurable
Tim Englich <tim.englich@intevation.de>
parents:
19
diff
changeset
|
285 } |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
286 initialized = true; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
287 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
288 |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
289 } |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
290 |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
291 /** |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
292 * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#createNewArtifact(de.intevation.gnv.artifactdatabase.objects.ArtifactObject) |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
293 */ |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
294 public ArtifactObject createNewArtifact(ArtifactObject artifactFactory) |
665
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
295 throws ArtifactDatabaseClientException, ArtifactDatabaseInputException { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
296 |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
297 try { |
558
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
298 Document request = this.createCreateRequestBody(artifactFactory); |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
299 Document result = doPostRequest(artifactFactory, request, "create"); |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
300 return this.getArtifact(result); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
301 } catch (IOException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
302 log.error(e, e); |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
303 throw new ArtifactDatabaseClientException(e); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
304 } |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
305 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
306 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
307 private ArtifactObject getArtifact(Document document) { |
35 | 308 XMLUtils xmlUtils = new XMLUtils(); |
389
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
281
diff
changeset
|
309 String uuid = xmlUtils.getStringXPath(document, "/art:result/art:uuid/@value"); |
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
281
diff
changeset
|
310 String hash = xmlUtils.getStringXPath(document, "/art:result/art:hash/@value"); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
311 log.info("NEW Artifact: " + uuid + " / " + hash); |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
312 return new Artifact(uuid, hash); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
313 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
314 |
558
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
315 private Document createCreateRequestBody(ArtifactObject artifactFactory) { |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
316 Document document = new XMLUtils().newDocument(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
317 Node rootNode = this.createRootNode(document); |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
318 Element typeNode = this.createArtifactElement(document, "type"); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
319 typeNode.setAttribute("name", "create"); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
320 rootNode.appendChild(typeNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
321 |
558
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
322 Element factoryNode = this.createArtifactElement(document, "factory"); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
323 factoryNode.setAttribute("name", artifactFactory.getId()); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
324 rootNode.appendChild(factoryNode); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
325 |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
326 if (artifactFactory instanceof ParametrizedArtifactObject){ |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
327 Map<String, Collection<String>> parameterMap = |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
328 ((ParametrizedArtifactObject)artifactFactory).getParameters(); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
329 if (parameterMap != null && !parameterMap.isEmpty() ){ |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
330 Iterator<String> keyIt = parameterMap.keySet().iterator(); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
331 while (keyIt.hasNext()){ |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
332 String key = keyIt.next(); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
333 Iterator<String> valueIt = parameterMap.get(key).iterator(); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
334 while (valueIt.hasNext()){ |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
335 String value = valueIt.next(); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
336 Element parameterNode = |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
337 this.createArtifactElement(document, "parameter"); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
338 parameterNode.setAttribute("name", key); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
339 parameterNode.setAttribute("value", value); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
340 factoryNode.appendChild(parameterNode); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
341 } |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
342 } |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
343 } |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
344 } |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
345 return document; |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
346 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
347 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
348 private Element createRootNode(Document document) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
349 Element rootNode = this.createArtifactElement(document, "action"); |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
350 document.appendChild(rootNode); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
351 return rootNode; |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
352 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
353 |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
354 /** |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
355 * @param document |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
356 * @return |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
357 */ |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
358 private Element createArtifactElement(Document document, String name) { |
391
ee8003fffc71
Use XMLUtils.ElementCreator to create new nodes in xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
389
diff
changeset
|
359 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( |
ee8003fffc71
Use XMLUtils.ElementCreator to create new nodes in xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
389
diff
changeset
|
360 document, |
ee8003fffc71
Use XMLUtils.ElementCreator to create new nodes in xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
389
diff
changeset
|
361 NAMESPACE_URI, |
ee8003fffc71
Use XMLUtils.ElementCreator to create new nodes in xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
389
diff
changeset
|
362 NAMESPACE_PREFIX |
ee8003fffc71
Use XMLUtils.ElementCreator to create new nodes in xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
389
diff
changeset
|
363 ); |
ee8003fffc71
Use XMLUtils.ElementCreator to create new nodes in xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
389
diff
changeset
|
364 |
ee8003fffc71
Use XMLUtils.ElementCreator to create new nodes in xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
389
diff
changeset
|
365 return creator.create(name); |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
366 } |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
367 |
25 | 368 /** |
369 * @param artifactFactory | |
370 * @param xmlUtils | |
371 * @param request | |
372 * @throws IOException | |
373 */ | |
374 private Document doPostRequest(ArtifactObject artifactFactory, | |
665
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
375 Document request, String suburl) |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
376 throws IOException, ArtifactDatabaseClientException, ArtifactDatabaseInputException { |
25 | 377 XMLUtils xmlUtils = new XMLUtils(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
378 String url = ((ArtifactFactory) artifactFactory).getDataBaseUrl(); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
379 InputStream is = this.doPostRequest(url + "/" + suburl, request); |
25 | 380 Document result = xmlUtils.readDocument(is); |
381 this.check4ExceptionReport(result); | |
382 return result; | |
383 } | |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
384 |
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
385 /** |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
386 * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#getCurrentStepDescription(de.intevation.gnv.artifactdatabase.objects.ArtifactFactory, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
387 * de.intevation.gnv.artifactdatabase.objects.ArtifactObject) |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
388 */ |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
389 public ArtifactDescription getCurrentStepDescription( |
665
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
390 ArtifactObject artifactFactory, |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
391 ArtifactObject currentArtifact, |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
392 boolean includeUI) |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
393 throws ArtifactDatabaseClientException, ArtifactDatabaseInputException { |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
394 try { |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
395 String url = this.getArtifactUrl(artifactFactory, currentArtifact); |
673
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
396 log.debug("DESCRIBE URL: " + url); |
157
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
397 Document request = this.createDescribeRequestBody(currentArtifact, |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
398 includeUI); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
399 InputStream describeResult = this.doPostRequest(url, request); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
400 |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
401 return this.readDescription(new XMLUtils().readDocument(describeResult), |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
402 currentArtifact); |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
403 } catch (IOException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
404 log.error(e, e); |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
405 throw new ArtifactDatabaseClientException(e); |
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
406 } |
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
407 } |
157
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
408 |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
409 |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
410 private Document createDescribeRequestBody(ArtifactObject currentArtifact, |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
411 boolean includeUI){ |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
412 |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
413 Document document = new XMLUtils().newDocument(); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
414 Node rootNode = this.createRootNode(document); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
415 |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
416 Element typeNode = this.createArtifactElement(document, "type"); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
417 typeNode.setAttribute("name", "describe"); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
418 rootNode.appendChild(typeNode); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
419 |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
420 Element uuidNode = this.createArtifactElement(document, "uuid"); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
421 uuidNode.setAttribute("value", currentArtifact.getId()); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
422 rootNode.appendChild(uuidNode); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
423 |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
424 Element hashNode = this.createArtifactElement(document, "hash"); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
425 hashNode.setAttribute("value", currentArtifact.getHash()); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
426 rootNode.appendChild(hashNode); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
427 Element includeUINode = this.createArtifactElement(document, "include-ui"); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
428 includeUINode.appendChild(document.createTextNode(""+includeUI)); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
429 rootNode.appendChild(includeUINode); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
430 return document; |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
431 } |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
432 |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
433 /** |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
434 * @param artifactFactory |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
435 * @param currentArtifact |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
436 * @return |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
437 */ |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
438 private String getArtifactUrl(ArtifactObject artifactFactory, |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
439 ArtifactObject currentArtifact) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
440 String url = ((ArtifactFactory) artifactFactory).getDataBaseUrl() |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
441 + "/artifact/" + currentArtifact.getId(); |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
442 return url; |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
443 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
444 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
445 private ArtifactDescription readDescription(Document document, |
665
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
446 ArtifactObject artifact) |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
447 throws ArtifactDatabaseClientException, ArtifactDatabaseInputException { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
448 // Check if there was an Error or Exception reported from the |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
449 // ArtifactDatabase |
25 | 450 this.check4ExceptionReport(document); |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
451 XMLUtils xmlUtils = new XMLUtils(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
452 if (artifact instanceof ArtifactDescription) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
453 ArtifactDescription ad = (ArtifactDescription) artifact; |
389
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
281
diff
changeset
|
454 Node uiNode = xmlUtils.getNodeXPath(document, "/art:result/art:ui"); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
455 Node outputNode = xmlUtils |
389
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
281
diff
changeset
|
456 .getNodeXPath(document, "/art:result/art:outputs"); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
457 |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
458 Map<String, OutputMode> outputModes = null; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
459 if (outputNode != null) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
460 NodeList outputModesNodes = xmlUtils.getNodeSetXPath( |
389
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
281
diff
changeset
|
461 outputNode, "art:output"); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
462 if (outputModesNodes != null) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
463 outputModes = new HashMap<String, OutputMode>( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
464 outputModesNodes.getLength()); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
465 for (int i = 0; i < outputModesNodes.getLength(); i++) { |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
466 Node outputModeNode = outputModesNodes.item(i); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
467 String name = xmlUtils.getStringXPath(outputModeNode, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
468 "@name"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
469 String mimeType = xmlUtils.getStringXPath( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
470 outputModeNode, "@mime-type"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
471 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
472 NodeList parameterNodes = xmlUtils.getNodeSetXPath( |
389
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
281
diff
changeset
|
473 outputModeNode, "art:parameter/art:parameter"); |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
474 Collection<OutputParameter> parameter = null; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
475 if (parameterNodes != null) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
476 parameter = new ArrayList<OutputParameter>( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
477 parameterNodes.getLength()); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
478 for (int j = 0; j < parameterNodes.getLength(); j++) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
479 Node outputParameterNode = parameterNodes |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
480 .item(j); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
481 parameter.add(new DefaultOutputParameter( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
482 xmlUtils.getStringXPath( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
483 outputParameterNode, "@name"), |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
484 xmlUtils.getStringXPath( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
485 outputParameterNode, "@value"), |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
486 xmlUtils.getStringXPath( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
487 outputParameterNode, "@name"), |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
488 xmlUtils.getStringXPath( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
489 outputParameterNode, "@type"))); |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
490 } |
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
491 } |
573
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
492 |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
493 NodeList exportNodes = xmlUtils.getNodeSetXPath( |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
494 outputModeNode, "art:exports/art:export"); |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
495 Map exports = null; |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
496 |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
497 if (exportNodes != null) { |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
498 int size = exportNodes.getLength(); |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
499 exports = new HashMap<String, ExportMode>(size); |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
500 |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
501 for (int k = 0; k < size; k++) { |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
502 Node export = exportNodes.item(k); |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
503 String expName = xmlUtils.getStringXPath( |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
504 export, "@name"); |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
505 exports.put(expName, new DefaultExportMode( |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
506 expName, |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
507 xmlUtils.getStringXPath(export, "@description"), |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
508 xmlUtils.getStringXPath(export, "@mime-type"))); |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
509 } |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
510 } |
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
511 |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
512 outputModes.put(name, new DefaultOutputMode(name, |
573
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
513 mimeType, parameter, exports)); |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
514 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
515 |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
516 } |
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
517 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
518 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
519 String currentState = xmlUtils.getStringXPath(document, |
389
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
281
diff
changeset
|
520 "/art:result/art:state/@name"); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
521 NodeList statesList = xmlUtils.getNodeSetXPath(document, |
389
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
281
diff
changeset
|
522 "/art:result/art:reachable-states/art:state/@name"); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
523 Collection<String> reachableStates = new ArrayList<String>( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
524 statesList.getLength()); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
525 for (int i = 0; i < statesList.getLength(); i++) { |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
526 reachableStates.add(statesList.item(i).getNodeValue()); |
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
527 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
528 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
529 NodeList inputNodes = xmlUtils.getNodeSetXPath(document, |
389
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
281
diff
changeset
|
530 "/art:result/art:model/art:input"); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
531 if (inputNodes != null) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
532 Collection<String> inputParameter = new ArrayList<String>( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
533 inputNodes.getLength()); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
534 for (int i = 0; i < inputNodes.getLength(); i++) { |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
535 Node inputNode = inputNodes.item(i); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
536 String name = xmlUtils.getStringXPath(inputNode, "@name"); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
537 inputParameter.add(name); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
538 } |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
539 ad.setInputParameter(inputParameter); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
540 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
541 |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
542 ad.setOutputModes(outputModes); |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
543 ad.setCurrentOut(outputNode); |
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
544 ad.setCurrentUI(uiNode); |
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
545 ad.setCurrentState(currentState); |
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
546 ad.setReachableStates(reachableStates); |
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
547 return ad; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
548 } else { |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
549 log.error("Artifact must be Instance of ArtifactDescription"); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
550 throw new ArtifactDatabaseClientException( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
551 "Artifact must be Instance of ArtifactDescription"); |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
552 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
553 |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
554 } |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
555 |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
556 /** |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
557 * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#doNextStep(de.intevation.gnv.artifactdatabase.objects.ArtifactObject, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
558 * de.intevation.gnv.artifactdatabase.objects.ArtifactObject, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
559 * java.lang.String, java.util.Collection) |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
560 */ |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
561 public ArtifactDescription doNextStep( |
665
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
562 ArtifactObject artifactFactory, |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
563 ArtifactObject currentArtifact, |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
564 String target, |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
565 Collection<InputParameter> inputParameter) |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
566 throws ArtifactDatabaseClientException, ArtifactDatabaseInputException { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
567 |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
568 try { |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
569 // 1 Feed |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
570 this.doFeed(artifactFactory, currentArtifact, inputParameter); |
157
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
571 |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
572 // 2. Noch einmal Describe um das jetzt zu erreichende Ziel zu ermitteln |
394
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
573 ArtifactDescription ad = getCurrentStepDescription( |
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
574 artifactFactory, |
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
575 new Artifact(currentArtifact.getId(), |
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
576 currentArtifact.getHash()), |
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
577 false |
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
578 ); |
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
579 |
157
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
580 target = ad.getReachableStates().iterator().next(); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
581 |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
582 // 3 Advance |
394
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
583 doAdvance(artifactFactory, currentArtifact, target); |
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
584 |
25 | 585 // 3 Describe |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
586 return this.getCurrentStepDescription(artifactFactory, |
157
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
587 currentArtifact,true); |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
588 } catch (IOException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
589 log.error(e, e); |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
590 throw new ArtifactDatabaseClientException(e); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
591 } |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
592 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
593 |
394
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
594 |
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
595 public void doAdvance( |
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
596 ArtifactObject factory, |
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
597 ArtifactObject artifact, |
665
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
598 String target) |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
599 throws IOException, ArtifactDatabaseClientException, ArtifactDatabaseInputException { |
394
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
600 String url = getArtifactUrl(factory, artifact); |
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
601 Document advanceDocument = createAdvanceRequestBody(artifact, target); |
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
602 InputStream advanceResult = doPostRequest(url, advanceDocument); |
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
603 check4ExceptionReport(new XMLUtils().readDocument(advanceResult)); |
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
604 } |
14eecfde4607
Render links to step back to previous states into gui. Added controller to advance back to these states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
605 |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
606 private Document createFeedRequestBody( |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
607 ArtifactObject currentArtifact, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
608 Collection<InputParameter> inputParameter) { |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
609 Document document = new XMLUtils().newDocument(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
610 Node rootNode = this.createRootNode(document); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
611 |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
612 Element typeNode = this.createArtifactElement(document, "type"); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
613 typeNode.setAttribute("name", "feed"); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
614 rootNode.appendChild(typeNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
615 |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
616 Element uuidNode = this.createArtifactElement(document, "uuid"); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
617 uuidNode.setAttribute("value", currentArtifact.getId()); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
618 rootNode.appendChild(uuidNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
619 |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
620 Element hashNode = this.createArtifactElement(document, "hash"); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
621 hashNode.setAttribute("value", currentArtifact.getHash()); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
622 rootNode.appendChild(hashNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
623 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
624 Node dataNode = this.createParameterNodes(inputParameter, document, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
625 "data"); |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
626 rootNode.appendChild(dataNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
627 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
628 return document; |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
629 } |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
630 |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
631 /** |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
632 * @param inputParameter |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
633 * @param document |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
634 * @param rootNode |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
635 */ |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
636 private Node createParameterNodes( |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
637 Collection<InputParameter> inputParameter, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
638 Document document, String nodeName) { |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
639 Element dataNode = this.createArtifactElement(document, nodeName); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
640 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
641 if (inputParameter != null) { |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
642 Iterator<InputParameter> it = inputParameter.iterator(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
643 while (it.hasNext()) { |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
644 InputParameter ip = it.next(); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
645 String name = ip.getName(); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
646 String[] values = ip.getValues(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
647 if (values != null) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
648 for (int i = 0; i < values.length; i++) { |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
649 String value = values[i]; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
650 Element inputNode = this.createArtifactElement( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
651 document, "input"); |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
652 inputNode.setAttribute("name", name); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
653 inputNode.setAttribute("value", value); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
654 dataNode.appendChild(inputNode); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
655 } |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
656 } |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
657 } |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
658 } |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
659 return dataNode; |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
660 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
661 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
662 private Document createAdvanceRequestBody(ArtifactObject currentArtifact, |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
663 String target) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
664 Document document = new XMLUtils().newDocument(); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
665 Node rootNode = this.createRootNode(document); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
666 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
667 Element typeNode = this.createArtifactElement(document, "type"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
668 typeNode.setAttribute("name", "advance"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
669 rootNode.appendChild(typeNode); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
670 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
671 Element uuidNode = this.createArtifactElement(document, "uuid"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
672 uuidNode.setAttribute("value", currentArtifact.getId()); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
673 rootNode.appendChild(uuidNode); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
674 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
675 Element hashNode = this.createArtifactElement(document, "hash"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
676 hashNode.setAttribute("value", currentArtifact.getHash()); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
677 rootNode.appendChild(hashNode); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
678 Element targetNode = this.createArtifactElement(document, "target"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
679 targetNode.setAttribute("name", target); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
680 rootNode.appendChild(targetNode); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
681 return document; |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
682 } |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
683 |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
684 /** |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
685 * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#doOutput(de.intevation.gnv.artifactdatabase.objects.ArtifactObject, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
686 * de.intevation.gnv.artifactdatabase.objects.ArtifactObject, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
687 * java.io.OutputStream, java.lang.String, java.lang.String, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
688 * java.util.Collection) |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
689 */ |
583
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
690 public void doOutput( |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
691 ArtifactObject artifactFactory, |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
692 ArtifactObject currentArtifact, |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
693 OutputStream stream, |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
694 String targetName, |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
695 String exportMode, |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
696 String mimeType, |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
697 Collection<InputParameter> inputParameter) |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
698 throws ArtifactDatabaseClientException |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
699 { |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
700 try { |
583
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
701 Document requestBody = this.createOutRequestBody( |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
702 currentArtifact, |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
703 targetName, |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
704 exportMode, |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
705 mimeType, |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
706 inputParameter); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
707 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
708 String requestUrl = this.getArtifactUrl(artifactFactory, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
709 currentArtifact) |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
710 + "/" + targetName; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
711 InputStream is = this.doPostRequest(requestUrl, requestBody); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
712 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
713 byte[] b = new byte[4096]; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
714 int i = -1; |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
715 while ((i = is.read(b)) > 0) { |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
716 stream.write(b, 0, i); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
717 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
718 } catch (IOException e) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
719 log.error(e, e); |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
720 throw new ArtifactDatabaseClientException(e); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
721 } |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
722 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
723 |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
724 |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
725 public void doExport( |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
726 ArtifactObject artifactFactory, |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
727 ArtifactObject currentArtifact, |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
728 OutputStream out) |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
729 throws ArtifactDatabaseClientException |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
730 { |
678
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
731 InputStreamReader reader = null; |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
732 OutputStreamWriter writer = null; |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
733 |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
734 try { |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
735 String url = ((ArtifactFactory) artifactFactory).getDataBaseUrl(); |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
736 url += "/export/" + currentArtifact.getId(); |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
737 |
678
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
738 Representation response = doGetRequestInternal(url, null); |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
739 InputStream in = response.getStream(); |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
740 |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
741 reader = new InputStreamReader(in); |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
742 writer = new OutputStreamWriter(out); |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
743 |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
744 while (reader.ready()) { |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
745 writer.write(reader.read()); |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
746 } |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
747 |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
748 } |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
749 catch (Exception e) { |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
750 log.error(e, e); |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
751 throw new ArtifactDatabaseClientException(e); |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
752 } |
678
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
753 finally { |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
754 try { |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
755 reader.close(); |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
756 } catch (IOException ioe) {} |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
757 |
678
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
758 try { |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
759 writer.flush(); |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
760 } catch (IOException ioe) {} |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
761 |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
762 try { |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
763 writer.close(); |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
764 } catch (IOException ioe) {} |
2943f69e006f
Removed xml parsing from InputStream while exporting an artifact. Just copy the input stream to the output stream.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
676
diff
changeset
|
765 } |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
766 } |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
767 |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
668
diff
changeset
|
768 |
673
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
769 public Document doImport( |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
770 ArtifactFactory factory, |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
771 Document document) |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
772 throws ArtifactDatabaseClientException, IOException |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
773 { |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
774 String url = factory.getDataBaseUrl() + "/import"; |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
775 InputStream response = doPostRequest(url, document); |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
776 |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
777 return XMLUtils.readDocument(response); |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
778 } |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
779 |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
780 |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
781 private Document createOutRequestBody( |
583
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
782 ArtifactObject currentArtifact, |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
783 String target, |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
784 String exportMode, |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
785 String mimeType, |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
786 Collection<InputParameter> inputParameter) |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
787 { |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
788 Document document = new XMLUtils().newDocument(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
789 Node rootNode = this.createRootNode(document); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
790 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
791 Element typeNode = this.createArtifactElement(document, "type"); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
792 typeNode.setAttribute("name", "out"); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
793 rootNode.appendChild(typeNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
794 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
795 Element uuidNode = this.createArtifactElement(document, "uuid"); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
796 uuidNode.setAttribute("value", currentArtifact.getId()); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
797 rootNode.appendChild(uuidNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
798 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
799 Element hashNode = this.createArtifactElement(document, "hash"); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
800 hashNode.setAttribute("value", currentArtifact.getHash()); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
801 rootNode.appendChild(hashNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
802 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
803 Element outNode = this.createArtifactElement(document, "out"); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
804 outNode.setAttribute("name", target); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
805 rootNode.appendChild(outNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
806 |
583
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
807 Element exportNode = this.createArtifactElement(document, "export"); |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
808 exportNode.setAttribute("name", exportMode); |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
809 outNode.appendChild(exportNode); |
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
810 |
281
4ec95d586f31
Removed mistake in xml structure of the artifact protocol.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
165
diff
changeset
|
811 Element mimeTypeNode = this.createArtifactElement(document, "mime-type"); |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
812 mimeTypeNode.setAttribute("value", mimeType); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
813 outNode.appendChild(mimeTypeNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
814 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
815 Node parameterNode = this.createParameterNodes(inputParameter, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
816 document, "params"); |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
817 outNode.appendChild(parameterNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
818 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
819 return document; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
820 } |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
821 |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
822 /** |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
823 * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#doFeed(de.intevation.gnv.artifactdatabase.objects.ArtifactObject, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
824 * de.intevation.gnv.artifactdatabase.objects.ArtifactObject, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
825 * java.util.Collection) |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
826 */ |
665
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
827 public void doFeed( |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
828 ArtifactObject artifactFactory, |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
829 ArtifactObject currentArtifact, |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
830 Collection<InputParameter> inputParameter) |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
831 throws ArtifactDatabaseClientException, ArtifactDatabaseInputException { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
832 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
833 try { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
834 Document feedDocument = this.createFeedRequestBody(currentArtifact, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
835 inputParameter); |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
836 String url = this.getArtifactUrl(artifactFactory, currentArtifact); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
837 InputStream feedResult = this.doPostRequest(url, feedDocument); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
838 Document feedResultDocument = new XMLUtils() |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
839 .readDocument(feedResult); |
25 | 840 this.check4ExceptionReport(feedResultDocument); |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
841 } catch (IOException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
842 log.error(e, e); |
25 | 843 throw new ArtifactDatabaseClientException(e); |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
844 } |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
845 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
846 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
847 private void check4ExceptionReport(Document document) |
665
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
848 throws ArtifactDatabaseClientException, ArtifactDatabaseInputException { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
849 String message = new XMLUtils().getStringXPath(document, |
665
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
850 EXCEPTION_GENERAL); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
851 if (message != null) { |
25 | 852 throw new ArtifactDatabaseClientException(message); |
853 } | |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
854 |
665
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
855 String input = XMLUtils.getStringXPath(document, EXCEPTION_USER_INPUT); |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
856 if (input != null) { |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
857 throw new ArtifactDatabaseInputException(input); |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
858 } |
25 | 859 } |
32
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
860 |
668
ccd47d9887ec
Added an options panel for wms customization (issue198).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
665
diff
changeset
|
861 public Document publishWMS( |
ccd47d9887ec
Added an options panel for wms customization (issue198).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
665
diff
changeset
|
862 ArtifactObject factory, |
ccd47d9887ec
Added an options panel for wms customization (issue198).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
665
diff
changeset
|
863 ArtifactObject artifact, |
ccd47d9887ec
Added an options panel for wms customization (issue198).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
665
diff
changeset
|
864 Collection<InputParameter> inputParameter |
676
707e142e7d44
Improved ExceptionHandling during WMS-Publishing.
Tim Englich <tim.englich@intevation.de>
parents:
673
diff
changeset
|
865 ) throws ArtifactDatabaseClientException, ArtifactDatabaseInputException{ |
570
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
565
diff
changeset
|
866 log.debug("Start wms publishing..."); |
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
565
diff
changeset
|
867 |
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
565
diff
changeset
|
868 String target = "wms"; |
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
565
diff
changeset
|
869 String requestURL = getArtifactUrl(factory, artifact) + "/" + target; |
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
565
diff
changeset
|
870 Document request = createOutRequestBody( |
668
ccd47d9887ec
Added an options panel for wms customization (issue198).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
665
diff
changeset
|
871 artifact, target, "", "text/xml", inputParameter); |
570
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
565
diff
changeset
|
872 try { |
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
565
diff
changeset
|
873 InputStream input = doPostRequest(requestURL, request); |
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
565
diff
changeset
|
874 Document result = XMLUtils.readDocument(input); |
676
707e142e7d44
Improved ExceptionHandling during WMS-Publishing.
Tim Englich <tim.englich@intevation.de>
parents:
673
diff
changeset
|
875 this.check4ExceptionReport(result); |
585
2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
583
diff
changeset
|
876 return result; |
570
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
565
diff
changeset
|
877 } |
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
565
diff
changeset
|
878 catch (IOException ioe) { |
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
565
diff
changeset
|
879 log.error(ioe, ioe); |
676
707e142e7d44
Improved ExceptionHandling during WMS-Publishing.
Tim Englich <tim.englich@intevation.de>
parents:
673
diff
changeset
|
880 throw new ArtifactDatabaseClientException(ioe); |
570
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
565
diff
changeset
|
881 } |
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
565
diff
changeset
|
882 } |
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
565
diff
changeset
|
883 |
164
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
884 public Collection<ArtifactStatisticsSet> calculateStatistics( |
570
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
565
diff
changeset
|
885 ArtifactObject artifactFactory, |
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
565
diff
changeset
|
886 ArtifactObject currentArtifact) |
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
565
diff
changeset
|
887 throws ArtifactDatabaseClientException |
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
565
diff
changeset
|
888 { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
889 log.debug("DefaultArtifactDatabaseClient.calculateStatistics"); |
164
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
890 Collection<ArtifactStatisticsSet> resultValues = null; |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
891 |
32
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
892 try { |
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
893 String targetName = "statistics"; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
894 String requestUrl = this.getArtifactUrl(artifactFactory, |
164
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
895 currentArtifact) + "/" + targetName; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
896 Document requestBody = this.createOutRequestBody(currentArtifact, |
583
2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
897 targetName, "", "text/xml", null); |
32
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
898 XMLUtils xmlUtils = new XMLUtils(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
899 InputStream is = this.doPostRequest(requestUrl, requestBody); |
32
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
900 Document resultDocument = xmlUtils.readDocument(is); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
901 if (resultDocument != null) { |
164
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
902 |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
903 NodeList statisticSetNodes = xmlUtils.getNodeSetXPath(resultDocument, |
389
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
281
diff
changeset
|
904 "/art:statistics/art:statistic"); |
164
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
905 resultValues = new ArrayList<ArtifactStatisticsSet> |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
906 (statisticSetNodes.getLength()); |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
907 for (int i = 0; i < statisticSetNodes.getLength(); i++) { |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
908 Element statisticSetNode = (Element)statisticSetNodes.item(i); |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
909 String name = statisticSetNode.getAttribute("name"); |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
910 ArtifactStatisticsSet set = |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
911 new DefaultArtifactStatisticsSet(name); |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
912 NodeList resultNodes = xmlUtils.getNodeSetXPath(statisticSetNode, |
389
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
281
diff
changeset
|
913 "art:statistic-value"); |
164
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
914 if (resultNodes != null) { |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
915 for (int j = 0; j < resultNodes.getLength(); j++) { |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
916 Element statisticNode = (Element)resultNodes.item(j); |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
917 String statisticName = statisticNode. |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
918 getAttribute("name"); |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
919 String statisticValue = statisticNode. |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
920 getAttribute("value"); |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
921 set.addStatisticValues( |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
922 new DefaultArtifactStatisticValue |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
923 (statisticName,statisticValue)); |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
924 } |
32
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
925 } |
164
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
926 resultValues.add(set); |
32
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
927 } |
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
928 } |
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
929 } catch (IOException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
930 log.error(e, e); |
35 | 931 throw new ArtifactDatabaseClientException(e); |
32
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
932 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
933 |
164
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
934 return resultValues; |
32
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
935 } |
40
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
936 |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
937 public void setLocale(Locale locale) { |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
938 this.locale = locale; |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
939 } |
402
b88e881e8e94
Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
394
diff
changeset
|
940 |
b88e881e8e94
Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
394
diff
changeset
|
941 /** |
b88e881e8e94
Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
394
diff
changeset
|
942 * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#getArtifactFactoryMetaInformation(java.util.Collection, java.lang.String, java.lang.String) |
b88e881e8e94
Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
394
diff
changeset
|
943 */ |
558
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
944 public Collection<ArtifactObject> getArtifactFactoryMetaInformation( |
665
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
945 Collection<MapService> mapServices, |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
946 String geometry, |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
947 String srs) |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
948 throws ArtifactDatabaseClientException, ArtifactDatabaseInputException { |
558
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
949 log.debug("DefaultArtifactDatabaseClient.getArtifactFactories"); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
950 Collection<ArtifactObject> resultValues = null; |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
951 try { |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
952 this.initialize(); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
953 Iterator<String> it = artifactDatabases.iterator(); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
954 Document requestBody = this.createMetaDataRequestBody(mapServices, |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
955 geometry, |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
956 srs); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
957 while (it.hasNext()) { |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
958 String server = it.next(); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
959 String url = server + "/service/metadata/"; |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
960 log.debug(url); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
961 |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
962 InputStream resultStream = this.doPostRequest(url, requestBody); |
565
8355d7cacd09
Modified the Create-Artifact-Request-Body that a Geometry will be put into
Tim Englich <tim.englich@intevation.de>
parents:
561
diff
changeset
|
963 resultValues = this.parseMetaDataResult(resultStream, server,geometry); |
558
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
964 } |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
965 } catch (IOException e) { |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
966 log.error(e,e); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
967 } |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
968 return resultValues; |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
969 } |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
970 |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
971 private Collection<ArtifactObject> parseMetaDataResult( |
665
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
972 InputStream inputStream, |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
973 String server, |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
974 String geometry) |
27f25b9ae9af
Improved exception handling. Display error messages after invalid user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
590
diff
changeset
|
975 throws ArtifactDatabaseClientException, ArtifactDatabaseInputException { |
558
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
976 XMLUtils xmlUtils = new XMLUtils(); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
977 Document document = xmlUtils.readDocument(inputStream); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
978 this.check4ExceptionReport(document); |
565
8355d7cacd09
Modified the Create-Artifact-Request-Body that a Geometry will be put into
Tim Englich <tim.englich@intevation.de>
parents:
561
diff
changeset
|
979 return this.getArtifactFactories(document, server,geometry); |
558
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
980 } |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
981 |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
982 private Document createMetaDataRequestBody(Collection<MapService> mapServices, |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
983 String geometry, |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
984 String srs){ |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
985 log.debug("DefaultArtifactDatabaseClient.createMetaDataRequestBody"); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
986 Document document = new XMLUtils().newDocument(); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
987 Node rootNode = this.createArtifactElement(document, "GetMetaData"); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
988 document.appendChild(rootNode); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
989 |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
990 Element locationNode = this.createArtifactElement(document, "location"); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
991 locationNode.setAttribute("srs", srs); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
992 locationNode.appendChild(document.createTextNode(geometry)); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
993 rootNode.appendChild(locationNode); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
994 |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
995 Element mapServicesNode = this.createArtifactElement(document, |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
996 "mapservices"); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
997 Iterator<MapService> it = mapServices.iterator(); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
998 while (it.hasNext()){ |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
999 MapService mapService = it.next(); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
1000 Element mapServiceNode = this.createArtifactElement(document, |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
1001 "mapservice"); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
1002 mapServiceNode.setAttribute("id", mapService.getID()); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
1003 mapServiceNode.setAttribute("type", mapService.getType()); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
1004 mapServiceNode.setAttribute("url", mapService.getURL()); |
561
3f39756e0c8a
Fixed a NPE. Now it is possible to put an Mapservice without an Layer into
Tim Englich <tim.englich@intevation.de>
parents:
558
diff
changeset
|
1005 if (mapService.getLayer() != null){ |
3f39756e0c8a
Fixed a NPE. Now it is possible to put an Mapservice without an Layer into
Tim Englich <tim.englich@intevation.de>
parents:
558
diff
changeset
|
1006 Iterator<Layer> layer = mapService.getLayer().iterator(); |
3f39756e0c8a
Fixed a NPE. Now it is possible to put an Mapservice without an Layer into
Tim Englich <tim.englich@intevation.de>
parents:
558
diff
changeset
|
1007 while (layer.hasNext()){ |
3f39756e0c8a
Fixed a NPE. Now it is possible to put an Mapservice without an Layer into
Tim Englich <tim.englich@intevation.de>
parents:
558
diff
changeset
|
1008 Layer tmpLayer = layer.next(); |
3f39756e0c8a
Fixed a NPE. Now it is possible to put an Mapservice without an Layer into
Tim Englich <tim.englich@intevation.de>
parents:
558
diff
changeset
|
1009 Element layerNode = this.createArtifactElement(document, |
3f39756e0c8a
Fixed a NPE. Now it is possible to put an Mapservice without an Layer into
Tim Englich <tim.englich@intevation.de>
parents:
558
diff
changeset
|
1010 "layer"); |
3f39756e0c8a
Fixed a NPE. Now it is possible to put an Mapservice without an Layer into
Tim Englich <tim.englich@intevation.de>
parents:
558
diff
changeset
|
1011 layerNode.setAttribute("id", tmpLayer.getID()); |
3f39756e0c8a
Fixed a NPE. Now it is possible to put an Mapservice without an Layer into
Tim Englich <tim.englich@intevation.de>
parents:
558
diff
changeset
|
1012 layerNode.setAttribute("name", tmpLayer.getName()); |
3f39756e0c8a
Fixed a NPE. Now it is possible to put an Mapservice without an Layer into
Tim Englich <tim.englich@intevation.de>
parents:
558
diff
changeset
|
1013 layerNode.setAttribute("isgrouplayer", |
3f39756e0c8a
Fixed a NPE. Now it is possible to put an Mapservice without an Layer into
Tim Englich <tim.englich@intevation.de>
parents:
558
diff
changeset
|
1014 ""+tmpLayer.isGroupLayer()); |
3f39756e0c8a
Fixed a NPE. Now it is possible to put an Mapservice without an Layer into
Tim Englich <tim.englich@intevation.de>
parents:
558
diff
changeset
|
1015 layerNode.setAttribute("parentid", tmpLayer.parentID()); |
3f39756e0c8a
Fixed a NPE. Now it is possible to put an Mapservice without an Layer into
Tim Englich <tim.englich@intevation.de>
parents:
558
diff
changeset
|
1016 mapServiceNode.appendChild(layerNode); |
3f39756e0c8a
Fixed a NPE. Now it is possible to put an Mapservice without an Layer into
Tim Englich <tim.englich@intevation.de>
parents:
558
diff
changeset
|
1017 } |
558
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
1018 } |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
1019 mapServicesNode.appendChild(mapServiceNode); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
1020 } |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
1021 rootNode.appendChild(mapServicesNode); |
8032da9e8b70
Added further business logic for the MapViewer-Interface
Tim Englich <tim.englich@intevation.de>
parents:
402
diff
changeset
|
1022 return document; |
402
b88e881e8e94
Added the first Implementation (not complete and not ready to use) for the Interface from the MapViewer to the GNV
Tim Englich <tim.englich@intevation.de>
parents:
394
diff
changeset
|
1023 } |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
1024 } |