annotate gnv/src/main/java/de/intevation/gnv/action/mapviewer/parser/XMLExternalCallParser.java @ 1022:28a0628b11b0

Added license file and license header. gnv/trunk@1258 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 02 Nov 2010 17:15:08 +0000
parents 4b64b4d1f0cf
children
rev   line source
1022
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 953
diff changeset
1 /*
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 953
diff changeset
2 * Copyright (c) 2010 by Intevation GmbH
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 953
diff changeset
3 *
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 953
diff changeset
4 * This program is free software under the LGPL (>=v2.1)
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 953
diff changeset
5 * Read the file LGPL.txt coming with the software for details
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 953
diff changeset
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 953
diff changeset
7 */
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 953
diff changeset
8
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:
diff changeset
9 package de.intevation.gnv.action.mapviewer.parser;
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:
diff changeset
10
953
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
11 import java.io.InputStream;
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
12 import java.util.ArrayList;
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
13 import java.util.Collection;
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
14
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
15 import org.apache.log4j.Logger;
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
16 import org.w3c.dom.Document;
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
17 import org.w3c.dom.Element;
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
18 import org.w3c.dom.NodeList;
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
19
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:
diff changeset
20 import de.intevation.gnv.artifactdatabase.objects.map.DefaultLayer;
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:
diff changeset
21 import de.intevation.gnv.artifactdatabase.objects.map.DefaultMapService;
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:
diff changeset
22 import de.intevation.gnv.artifactdatabase.objects.map.Layer;
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:
diff changeset
23 import de.intevation.gnv.artifactdatabase.objects.map.MapService;
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:
diff changeset
24 import de.intevation.gnv.util.XMLUtils;
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:
diff changeset
25
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:
diff changeset
26 /**
953
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
27 * This class provides an XMl-Parser which try's to create an DOM from
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
28 * an given Inputstream. Is this is possible it try to read the required
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
29 * informations e.g. Mapservices, Layer, SRID and Geometry from the
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
30 * document.
684
57fa8019fbdc Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 683
diff changeset
31 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
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:
diff changeset
32 */
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:
diff changeset
33 public class XMLExternalCallParser implements ExternalCallParser {
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
34
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:
diff changeset
35 /**
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:
diff changeset
36 * the logger, used to log exceptions and additonaly information
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:
diff changeset
37 */
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:
diff changeset
38 private static Logger log = Logger.getLogger(XMLExternalCallParser.class);
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
39
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:
diff changeset
40 private static String XPATH_GEOMETRY = "/gnviewer/location/data";
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:
diff changeset
41 private static String XPATH_SRS = "/gnviewer/location/srs";
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:
diff changeset
42 private static String XPATH_MAPSERVICES_NODESET = "/gnviewer/mapservices/mapservice";
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:
diff changeset
43 private static String XPATH_LAYER = "layer";
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:
diff changeset
44 private static String ATTRIBUTE_ID = "id";
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:
diff changeset
45 private static String ATTRIBUTE_NAME = "name";
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:
diff changeset
46 private static String ATTRIBUTE_TYPE = "type";
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:
diff changeset
47 private static String ATTRIBUTE_URL = "url";
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
48
953
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
49 /**
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
50 * The geometry which was parsed from the document.
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
51 */
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:
diff changeset
52 private String geometry = null;
953
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
53
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
54 /**
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
55 * The srid which was parsed from the document.
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
56 */
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:
diff changeset
57 private String srs = null;
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
58
953
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
59 /**
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
60 * The mapservices that were parsed from the document.
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
61 */
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:
diff changeset
62 private Collection<MapService> mapServices = null;
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
63
953
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
64 /**
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
65 * The inputstream where the data should be read from.
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
66 */
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:
diff changeset
67 private InputStream inputStream = null;
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:
diff changeset
68
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:
diff changeset
69 /**
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:
diff changeset
70 * Constructor
953
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
71 * @param inputStream The stream where the data should be read from
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:
diff changeset
72 */
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:
diff changeset
73 public XMLExternalCallParser(InputStream inputStream) {
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:
diff changeset
74 this.inputStream = inputStream;
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:
diff changeset
75 }
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:
diff changeset
76
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:
diff changeset
77 public String getGeometry() {
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:
diff changeset
78 return this.geometry;
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:
diff changeset
79 }
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:
diff changeset
80
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:
diff changeset
81 public Collection<MapService> getMapServices() {
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:
diff changeset
82 return this.mapServices;
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:
diff changeset
83 }
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:
diff changeset
84
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:
diff changeset
85 public void parse() throws ExternalCallParserException {
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:
diff changeset
86 if (inputStream != null){
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:
diff changeset
87 XMLUtils xmlUtils = new XMLUtils();
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:
diff changeset
88 Document document = xmlUtils.readDocument(this.inputStream);
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:
diff changeset
89 if (document != null){
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
90
953
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
91 this.geometry = xmlUtils.getStringXPath(document,
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
92 XPATH_GEOMETRY);
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:
diff changeset
93 this.srs = xmlUtils.getStringXPath(document, XPATH_SRS);
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
94 NodeList mapservicesNodes =
953
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
95 xmlUtils.getNodeSetXPath(document,
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
96 XPATH_MAPSERVICES_NODESET);
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:
diff changeset
97 if (mapservicesNodes != null){
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:
diff changeset
98 this.mapServices = new ArrayList<MapService>(mapservicesNodes.getLength());
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:
diff changeset
99 for (int i = 0; i < mapservicesNodes.getLength(); i++){
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:
diff changeset
100 Element mapserviceNode = (Element)mapservicesNodes.item(i);
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:
diff changeset
101 String mapserviceID = mapserviceNode.getAttribute(ATTRIBUTE_ID);
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:
diff changeset
102 String mapserviceType = mapserviceNode.getAttribute(ATTRIBUTE_TYPE);
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:
diff changeset
103 String mapserviceUrl = mapserviceNode.getAttribute(ATTRIBUTE_URL);
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:
diff changeset
104 NodeList layerNodes = xmlUtils.getNodeSetXPath(mapserviceNode, XPATH_LAYER);
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:
diff changeset
105 Collection<Layer> layer = null;
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:
diff changeset
106 if (layerNodes != null && layerNodes.getLength() > 0){
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:
diff changeset
107 layer = new ArrayList<Layer>(layerNodes.getLength());
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:
diff changeset
108 layer = this.extractLayer(layer, null, layerNodes);
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:
diff changeset
109 }else{
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:
diff changeset
110 log.debug("No Layer given for this Mapservice");
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:
diff changeset
111 }
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
112 MapService mapService =
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:
diff changeset
113 new DefaultMapService(mapserviceID, layer,
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:
diff changeset
114 mapserviceType, mapserviceUrl);
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:
diff changeset
115 this.mapServices.add(mapService);
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:
diff changeset
116 }
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
117
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:
diff changeset
118 }else{
953
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
119 String errMsg = "XML-Document does not contain any " +
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
120 "Mapservices which are required.";
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:
diff changeset
121 log.error(errMsg);
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:
diff changeset
122 throw new ExternalCallParserException(errMsg);
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:
diff changeset
123 }
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
124
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:
diff changeset
125 }else{
953
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
126 String errMsg = "XML-Document could not " +
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
127 "be read from InputStream.";
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:
diff changeset
128 log.error(errMsg);
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:
diff changeset
129 throw new ExternalCallParserException(errMsg);
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:
diff changeset
130 }
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:
diff changeset
131 }else{
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:
diff changeset
132 String errMsg = "No InputStream given for parsing the Call.";
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:
diff changeset
133 log.error(errMsg);
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:
diff changeset
134 throw new ExternalCallParserException(errMsg);
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:
diff changeset
135 }
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:
diff changeset
136 }
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
137
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:
diff changeset
138 /**
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:
diff changeset
139 * This Method extracts all Layers and put them into the Collection.
953
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
140 * @param layer the collection where the layer should be add to.
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
141 * @param groupId the id of the group of the layers
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
142 * @param layerNodes the Nodes which should contain the intormations
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
143 * about layers
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
144 * @return the 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:
diff changeset
145 */
953
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
146 private Collection<Layer> extractLayer(Collection<Layer> layer,
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
147 String groupId,
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
148 NodeList layerNodes){
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:
diff changeset
149 for (int i = 0; i < layerNodes.getLength(); i++){
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:
diff changeset
150 Element layerNode = (Element)layerNodes.item(i);
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:
diff changeset
151 String id = layerNode.getAttribute(ATTRIBUTE_ID);
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:
diff changeset
152 String name = layerNode.getAttribute(ATTRIBUTE_NAME);
953
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
153 NodeList localLayerNodes = XMLUtils.getNodeSetXPath(layerNode,
4b64b4d1f0cf Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 684
diff changeset
154 XPATH_LAYER);
681
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
155 Layer tmpLayer = new DefaultLayer(id, name,
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
156 (localLayerNodes != null &&
15ac78a91d1b Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
157 localLayerNodes.getLength() > 0),
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:
diff changeset
158 groupId);
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:
diff changeset
159 layer.add(tmpLayer);
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:
diff changeset
160 if (localLayerNodes != null && localLayerNodes.getLength() > 0){
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:
diff changeset
161 layer = this.extractLayer(layer, id, localLayerNodes);
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:
diff changeset
162 }
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:
diff changeset
163 }
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:
diff changeset
164 return layer;
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:
diff changeset
165 }
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:
diff changeset
166
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:
diff changeset
167 public String getSRS() {
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:
diff changeset
168 return this.srs;
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:
diff changeset
169 }
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:
diff changeset
170
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:
diff changeset
171 }

http://dive4elements.wald.intevation.org