annotate gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java @ 803:feae2f9d6c6f

Removed trailing whitespace. gnv-artifacts/trunk@885 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 07 Apr 2010 07:52:27 +0000
parents feeaf5aec552
children 79c1db3ca7cc
rev   line source
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.state.layer;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
3 import java.io.File;
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
4 import java.io.IOException;
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
5 import java.io.OutputStream;
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
6 import java.util.Collection;
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
7 import java.util.Iterator;
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
8
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
9 import org.apache.log4j.Logger;
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
10 import org.w3c.dom.Document;
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
11 import org.w3c.dom.Element;
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
12 import org.w3c.dom.Node;
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
13
779
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
14 import com.vividsolutions.jts.geom.Geometry;
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
15 import com.vividsolutions.jts.io.ParseException;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
16 import com.vividsolutions.jts.io.WKTReader;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
17
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 import de.intevation.artifactdatabase.Config;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 import de.intevation.artifactdatabase.XMLUtils;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 import de.intevation.artifacts.ArtifactNamespaceContext;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 import de.intevation.artifacts.CallContext;
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
22 import de.intevation.gnv.artifacts.context.GNVArtifactContext;
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23 import de.intevation.gnv.geobackend.base.Result;
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
24 import de.intevation.gnv.geobackend.base.query.QueryExecutor;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
25 import de.intevation.gnv.geobackend.base.query.QueryExecutorFactory;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
26 import de.intevation.gnv.geobackend.base.query.exception.QueryException;
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 import de.intevation.gnv.state.InputData;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 import de.intevation.gnv.state.OutputStateBase;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 import de.intevation.gnv.state.exception.StateException;
723
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
30 import de.intevation.gnv.utils.ArtifactXMLUtilities;
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
31 import de.intevation.gnv.utils.FileUtils;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
32 import de.intevation.gnv.utils.MapfileGenerator;
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
33 import de.intevation.gnv.utils.MetaWriter;
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
34 import de.intevation.gnv.utils.ShapeFileWriter;
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36 /**
780
c4156275c1e1 Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 779
diff changeset
37 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 *
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 */
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 public class LayerOutputState extends OutputStateBase {
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 /**
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 * the logger, used to log exceptions and additonaly information
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 */
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 private static Logger log = Logger.getLogger(LayerOutputState.class);
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
46
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 /**
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 * The UID of this Class.
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 */
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 private static final long serialVersionUID = 9180957321704424049L;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
51
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
52 // TODO: Replace
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
53 public static final String LAYER_MODEL = "layer";
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 /**
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 * The ID for the Query fetching the Layer from the DB
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57 */
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
58 private String dataQueryID = null;
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
59
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
60 /**
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
61 * The ID for the Query fetching the Geometry from the DB
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
62 * which should be used to Clip the Layerdata
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
63 */
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
64 private String geometryQueryID = null;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
65
728
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
66 private String columnQueryID = null;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
67
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
68 private String geometryTypeQueryID = null;
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
69
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
70 /**
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
71 * The ID for the Value which will hold the Geometrie-Value
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
72 */
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
73 private String geometryID = null;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
74
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
75 private Boolean shapeFileLock = new Boolean(true);
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
76
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
77 private String shapeFilePath;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
78
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
79 private String templateID = null;
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
80
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
81 private String geometryType = null;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
82
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
83 public static final String SHAPEFILE_NAME = "data.shp";
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
84
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
85 /**
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
86 * Constructor
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
87 */
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
88 public LayerOutputState() {
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
89 super();
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
90 }
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
91
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
92 /**
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
93 * @see de.intevation.gnv.state.OutputState#out(org.w3c.dom.Document,
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
94 * java.util.Collection, java.io.OutputStream,
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
95 * java.lang.String, de.intevation.artifacts.CallContext)
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
96 */
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
97 public void out(Document format, Collection<InputData> inputData,
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
98 OutputStream outputStream, String uuid,
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
99 CallContext callContext) throws StateException {
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
100
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
101 log.debug("LayerOutputState.out");
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
102 String outputMode = XMLUtils.xpathString(
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
103 format, XPATH_OUTPUT_MODE, ArtifactNamespaceContext.INSTANCE);
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
104 if (outputMode.equalsIgnoreCase("wms")) {
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
105 Collection<Result> data = this.fetchData();
723
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
106 if (data != null && !data.isEmpty()){
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
107 XMLUtils.toStream(this.getWMS(uuid, callContext,
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
108 data, geometryType),
723
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
109 outputStream);
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
110 }else{
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
111 this.writeExceptionReport2Stream(outputStream);
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
112 }
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
113 }else if (outputMode.equalsIgnoreCase("zip")){
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
114 Collection<Result> data = this.fetchData();
723
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
115 if (data != null && !data.isEmpty()){
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
116 this.writeZip(uuid, callContext, outputStream,
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
117 data,geometryType);
723
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
118 }else{
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
119 this.writeExceptionReport2Stream(outputStream);
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
120 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
121
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
122 }
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
123 }
723
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
124
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
125 /**
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
126 * @param outputStream
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
127 */
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
128 private void writeExceptionReport2Stream(OutputStream outputStream) {
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
129 Document document = XMLUtils.newDocument();
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
130 new ArtifactXMLUtilities().
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
131 createExceptionReport("No Data to Export", document);
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
132 XMLUtils.toStream(document,outputStream);
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
133 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
134
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
135
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
136 /**
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
137 * Fetches the Data from the Databasebackend
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
138 * @return
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
139 */
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
140 protected Collection<Result> fetchData(){
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
141 log.debug("LayerOutputState.fetchData");
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
142 // TODO PUT ALL in CACHE
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
143 Collection<Result> result = this.getData(this.queryID);
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
144 Collection<Result> data = null;
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
145 String geometryWKT = null;
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
146 if (result != null){
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
147 QueryExecutor queryExecutor = QueryExecutorFactory.getInstance()
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
148 .getQueryExecutor();
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
149 Iterator<Result> it = result.iterator();
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
150 String[] queryValues = null;
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
151 if (it.hasNext()){
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
152 Result resultValue = it.next();
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
153 String table = resultValue.getString(0);
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
154
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
155 this.geometryType = this.getGeometryType(table, queryExecutor);
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
156
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
157 String where = resultValue.getString(1);
728
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
158 String columns = this.fetchColumns(table);
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
159
724
9ba6bb85d6dd Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents: 723
diff changeset
160 templateID = resultValue.getString(2);
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
161 if (this.geometryID != null){
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
162 InputData geometryInputData =
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
163 this.inputData.get(this.geometryID);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
164 if (geometryInputData != null){
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
165
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
166 try {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
167 Collection<Result> geometryData = queryExecutor
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
168 .executeQuery(this.geometryQueryID,
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
169 new String[]{geometryInputData.getValue()});
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
170 Iterator<Result> git = geometryData.iterator();
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
171 if (git.hasNext()){
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
172 Result geometryValue = git.next();
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
173 geometryWKT = geometryValue.getString(0);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
174 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
175 } catch (QueryException e) {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
176 log.error(e,e);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
177 // TODO: what should happen??
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
178 }
728
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
179 queryValues = new String[]{columns,
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
180 table,
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
181 where,
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
182 geometryWKT};
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
183 }else{
729
d23ad22bcfe7 Integrated lookup of the Geometry which was put to the Artifact during the Instantiation
Tim Englich <tim.englich@intevation.de>
parents: 728
diff changeset
184 //Look into the presetting for an WKT
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
185 InputData geometryWKTData = this.preSettings != null ?
742
cae93c709548 Fixed NPE using the Presettings-Object without given Presettings.
Tim Englich <tim.englich@intevation.de>
parents: 729
diff changeset
186 this.preSettings.get("geometry") :
cae93c709548 Fixed NPE using the Presettings-Object without given Presettings.
Tim Englich <tim.englich@intevation.de>
parents: 729
diff changeset
187 null ;
729
d23ad22bcfe7 Integrated lookup of the Geometry which was put to the Artifact during the Instantiation
Tim Englich <tim.englich@intevation.de>
parents: 728
diff changeset
188 if (geometryWKTData != null){
d23ad22bcfe7 Integrated lookup of the Geometry which was put to the Artifact during the Instantiation
Tim Englich <tim.englich@intevation.de>
parents: 728
diff changeset
189 queryValues = new String[]{columns,
d23ad22bcfe7 Integrated lookup of the Geometry which was put to the Artifact during the Instantiation
Tim Englich <tim.englich@intevation.de>
parents: 728
diff changeset
190 table,
d23ad22bcfe7 Integrated lookup of the Geometry which was put to the Artifact during the Instantiation
Tim Englich <tim.englich@intevation.de>
parents: 728
diff changeset
191 where,
d23ad22bcfe7 Integrated lookup of the Geometry which was put to the Artifact during the Instantiation
Tim Englich <tim.englich@intevation.de>
parents: 728
diff changeset
192 geometryWKTData.getValue()};
d23ad22bcfe7 Integrated lookup of the Geometry which was put to the Artifact during the Instantiation
Tim Englich <tim.englich@intevation.de>
parents: 728
diff changeset
193 }else{
d23ad22bcfe7 Integrated lookup of the Geometry which was put to the Artifact during the Instantiation
Tim Englich <tim.englich@intevation.de>
parents: 728
diff changeset
194 queryValues = new String[]{columns,table,where};
d23ad22bcfe7 Integrated lookup of the Geometry which was put to the Artifact during the Instantiation
Tim Englich <tim.englich@intevation.de>
parents: 728
diff changeset
195 }
d23ad22bcfe7 Integrated lookup of the Geometry which was put to the Artifact during the Instantiation
Tim Englich <tim.englich@intevation.de>
parents: 728
diff changeset
196 }
d23ad22bcfe7 Integrated lookup of the Geometry which was put to the Artifact during the Instantiation
Tim Englich <tim.englich@intevation.de>
parents: 728
diff changeset
197 }else{
d23ad22bcfe7 Integrated lookup of the Geometry which was put to the Artifact during the Instantiation
Tim Englich <tim.englich@intevation.de>
parents: 728
diff changeset
198 //Look into the presetting for an WKT
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
199 InputData geometryWKTData = this.preSettings != null ?
742
cae93c709548 Fixed NPE using the Presettings-Object without given Presettings.
Tim Englich <tim.englich@intevation.de>
parents: 729
diff changeset
200 this.preSettings.get("geometry") :
cae93c709548 Fixed NPE using the Presettings-Object without given Presettings.
Tim Englich <tim.englich@intevation.de>
parents: 729
diff changeset
201 null ;
729
d23ad22bcfe7 Integrated lookup of the Geometry which was put to the Artifact during the Instantiation
Tim Englich <tim.englich@intevation.de>
parents: 728
diff changeset
202 if (geometryWKTData != null){
d23ad22bcfe7 Integrated lookup of the Geometry which was put to the Artifact during the Instantiation
Tim Englich <tim.englich@intevation.de>
parents: 728
diff changeset
203 queryValues = new String[]{columns,
d23ad22bcfe7 Integrated lookup of the Geometry which was put to the Artifact during the Instantiation
Tim Englich <tim.englich@intevation.de>
parents: 728
diff changeset
204 table,
d23ad22bcfe7 Integrated lookup of the Geometry which was put to the Artifact during the Instantiation
Tim Englich <tim.englich@intevation.de>
parents: 728
diff changeset
205 where,
d23ad22bcfe7 Integrated lookup of the Geometry which was put to the Artifact during the Instantiation
Tim Englich <tim.englich@intevation.de>
parents: 728
diff changeset
206 geometryWKTData.getValue()};
d23ad22bcfe7 Integrated lookup of the Geometry which was put to the Artifact during the Instantiation
Tim Englich <tim.englich@intevation.de>
parents: 728
diff changeset
207 }else{
728
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
208 queryValues = new String[]{columns,table,where};
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
209 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
210 }
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
211 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
212
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
213 try {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
214 data = queryExecutor.executeQuery(dataQueryID,
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
215 queryValues);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
216 if (data != null && geometryWKT != null){
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
217 WKTReader wktReader = new WKTReader();
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
218 Geometry border = wktReader.read(geometryWKT);
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
219
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
220 Iterator<Result> dataIt = data.iterator();
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
221 while (dataIt.hasNext()){
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
222 // Trim the Geometries using the
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
223 // Geometry if on is available.
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
224 Result current = dataIt.next();
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
225 String currentWKT = current.getString(0);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
226 Geometry currentGeometry = null;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
227 try {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
228 currentGeometry = wktReader.read(currentWKT);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
229 } catch (Exception e) {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
230 log.error("Error parsing Geometry "+ currentWKT);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
231 log.error(e,e);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
232 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
233
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
234 if (currentGeometry != null){
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
235 Geometry newGeometry = currentGeometry.intersection(border);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
236 current.addColumnValue(0, newGeometry.toText());
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
237 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
238 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
239 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
240 } catch (QueryException e) {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
241 log.error(e,e);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
242 } catch (ParseException e){
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
243 log.error(e,e);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
244 }
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
245 }
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
246 return data;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
247 }
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
248
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
249 private String getGeometryType(String tableName,
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
250 QueryExecutor queryExecutor){
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
251 String returnValue = null;
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
252 String[] tables = tableName.toUpperCase().split(",");
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
253 String[] filter = tables[0].split("\\.");
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
254
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
255 try {
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
256 Collection<Result> result =
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
257 queryExecutor.executeQuery(this.geometryTypeQueryID, filter);
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
258 if (result != null && !result.isEmpty())
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
259 {
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
260 int geometryCode = result.iterator().next().getInteger(0);
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
261 if (geometryCode == 11 ||
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
262 geometryCode == 10){
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
263 returnValue = "MultiPolygon";
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
264 }else if (geometryCode == 9 ||
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
265 geometryCode == 8){
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
266 returnValue = "MultiLineString";
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
267 }else if (geometryCode == 7){
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
268 returnValue = "MultiPoint";
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
269 }else if (geometryCode == 6){
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
270 returnValue = "GeometryCollection";
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
271 }else if (geometryCode == 5 ||
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
272 geometryCode == 4){
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
273 returnValue = "Polygon";
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
274 }else if (geometryCode == 3 ||
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
275 geometryCode == 2){
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
276 returnValue = "LineString";
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
277 }else if (geometryCode == 1){
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
278 returnValue = "Point";
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
279 }else if (geometryCode == 0){
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
280 returnValue = "Geometry";
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
281 }
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
282 }
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
283 } catch (QueryException e) {
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
284 log.error(e,e);
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
285 }
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
286
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
287 return returnValue;
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
288 }
728
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
289 private String fetchColumns(String tableName){
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
290 String returnValue = null;
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
291 try {
756
1614b27dcbfa Added Support of Layers which are Joined from two Tables.
Tim Englich <tim.englich@intevation.de>
parents: 742
diff changeset
292 String[] tables = tableName.toUpperCase().split(",");
1614b27dcbfa Added Support of Layers which are Joined from two Tables.
Tim Englich <tim.englich@intevation.de>
parents: 742
diff changeset
293 String[] filter = tables[0].split("\\.");
1614b27dcbfa Added Support of Layers which are Joined from two Tables.
Tim Englich <tim.englich@intevation.de>
parents: 742
diff changeset
294 // Only use the first Table the second one will be ignored.
728
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
295 QueryExecutor queryExecutor = QueryExecutorFactory.getInstance()
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
296 .getQueryExecutor();
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
297
728
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
298 Collection<Result> columnData = queryExecutor.
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
299 executeQuery(this.columnQueryID,
728
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
300 filter);
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
301 if (columnData != null && !columnData.isEmpty()){
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
302 StringBuffer sb = new StringBuffer();
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
303 synchronized (sb) {
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
304 Iterator<Result> it = columnData.iterator();
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
305 while(it.hasNext()){
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
306 Result current = it.next();
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
307 sb.append(current.getString(0));
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
308 if (it.hasNext()){
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
309 sb.append(" , ");
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
310 }
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
311 }
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
312 }
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
313 returnValue = sb.toString();
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
314 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
315
728
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
316 } catch (QueryException e) {
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
317 log.error(e,e);
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
318 }
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
319 return returnValue;
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
320 }
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
321 @Override
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
322 public void setup(Node configuration) {
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
323 log.debug("LayerOutputState.setup");
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
324 super.setup(configuration);
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
325 this.dataQueryID = Config.getStringXPath(configuration,
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
326 "queryID-layerdata");
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
327 this.geometryID = Config.getStringXPath(configuration,
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
328 "inputvalue-geometry");
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
329 this.geometryQueryID = Config.getStringXPath(configuration,
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
330 "queryID-geometry");
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
331
728
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
332 this.columnQueryID = "layer_colums"; //Config.getStringXPath(configuration,
f6630d0203da Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 724
diff changeset
333 // "queryID-columns");
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
334 this.geometryTypeQueryID = "geometry_type";
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
335 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
336
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
337 protected String writeToShapeFile(
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
338 String uuid,
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
339 Collection<Result> data,
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
340 CallContext callContext,
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
341 String geometryType
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
342 ) {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
343 File baseDir = shapefileDirectory(callContext);
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
344
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
345 File shapeDir = new File(baseDir, uuid);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
346 boolean success = false;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
347 boolean createdDir = false;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
348
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
349 try {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
350 synchronized (shapeFileLock) {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
351 int count = 0;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
352 while (shapeDir.exists()) {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
353 shapeDir = new File(baseDir, uuid + "-" + count);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
354 ++count;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
355 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
356
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
357 if (!shapeDir.mkdirs()) {
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
358 log.error("cannot create directory '"
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
359 + shapeDir.getAbsolutePath() + "'");
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
360 return null;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
361 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
362 createdDir = true;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
363 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
364
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
365 File shapeFile = new File(shapeDir, SHAPEFILE_NAME);
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
366 if (!ShapeFileWriter.writeDataToFile(shapeFile, "data", data,geometryType)){
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
367 log.error("writing data into shapefile failed");
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
368 return null;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
369 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
370
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
371 shapeFilePath = shapeDir.getAbsolutePath();
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
372 success = true;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
373
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
374 callContext.afterCall(CallContext.STORE);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
375
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
376 return shapeFilePath;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
377 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
378 finally {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
379 if (!success && createdDir) {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
380 FileUtils.deleteRecursive(shapeDir);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
381 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
382 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
383 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
384
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
385 protected void writeZip(
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
386 String uuid,
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
387 CallContext callContext,
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
388 OutputStream output,
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
389 Collection<Result> data,
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
390 String geometryType
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
391 )
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
392 throws StateException
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
393 {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
394 try {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
395 String p = getShapeFilePath();
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
396 if (p != null) {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
397 File dir = new File(p);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
398 if (dir.isDirectory()) {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
399 FileUtils.createZipArchive(dir, output);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
400 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
401 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
402 else {
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
403
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
404 if ((p = writeToShapeFile(uuid, data, callContext,geometryType)) != null) {
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
405 FileUtils.createZipArchive(new File(p), output);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
406 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
407 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
408 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
409 catch (IOException ioe) {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
410 log.error(ioe.getLocalizedMessage(), ioe);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
411 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
412 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
413
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
414 public String getShapeFilePath() {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
415 synchronized (shapeFileLock) {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
416 return shapeFilePath;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
417 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
418 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
419
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
420 private static File shapefileDirectory(CallContext callContext) {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
421 // TODO: Refactoring nessessary it should be used only one Shapefilepath
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
422 // for alle Modes. Code was taken from HorizontalCrossSectionMeshOutputState
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
423 GNVArtifactContext context =
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
424 (GNVArtifactContext)callContext.globalContext();
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
425 File dir = (File)context.get(
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
426 GNVArtifactContext.HORIZONTAL_CROSS_SECTION_RESULT_SHAPEFILE_PATH_KEY);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
427 return dir != null
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
428 ? dir
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
429 : GNVArtifactContext.DEFAULT_HORIZONTAL_CROSS_SECTION_PROFILE_SHAPEFILE_PATH;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
430 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
431
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
432 /**
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
433 * @see de.intevation.gnv.state.StateBase#endOfLife(java.lang.Object)
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
434 */
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
435 @Override
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
436 public void endOfLife(Object globalContext) {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
437 super.endOfLife(globalContext);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
438
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
439 // do it in background
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
440 new Thread() {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
441 public void run() {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
442 // TODO: Do the un-publishing WMS stuff.
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
443 String path = resetShapeFilePath();
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
444
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
445 if (path == null) {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
446 return;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
447 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
448
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
449 File dir = new File(path);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
450
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
451 for (int i = 0; i < 10; ++i) {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
452 if (!dir.exists() || FileUtils.deleteRecursive(dir)) {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
453 MapfileGenerator.getInstance().update();
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
454 return;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
455 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
456
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
457 try {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
458 Thread.sleep(10000L);
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
459 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
460 catch (InterruptedException ie) {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
461 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
462 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
463
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
464 log.error("failed to remove directory '" + path + "'");
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
465 } // run
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
466 }.start();
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
467 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
468
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
469 public String resetShapeFilePath() {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
470 synchronized (shapeFileLock) {
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
471 String path = shapeFilePath;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
472 shapeFilePath = null;
724
9ba6bb85d6dd Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents: 723
diff changeset
473 templateID = null;
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
474 return path;
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
475 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
476 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
477 protected Document getWMS(String uuid,
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
478 CallContext callContext,
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
479 Collection<Result> data,
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
480 String geometryType)
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
481 throws StateException
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
482 {
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
483 // TODO: Do the real WMS publishing here!
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
484 Document document = XMLUtils.newDocument();
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
485
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
486 Element pathElement = document.createElement("path");
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
487 document.appendChild(pathElement);
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
488
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
489 String path = getShapeFilePath();
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
490
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
491 if (path != null && new File(path).isDirectory()) {
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
492 pathElement.setTextContent(path);
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
493 }
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
494 else {
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
495
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
496 if (data != null &&
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
497 (path = writeToShapeFile(uuid, data, callContext,geometryType)) != null) {
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
498
724
9ba6bb85d6dd Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents: 723
diff changeset
499 String paramType = LAYER_MODEL+"_"+templateID;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
500
724
9ba6bb85d6dd Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents: 723
diff changeset
501 if (!MapfileGenerator.getInstance().templateExists(paramType)){
9ba6bb85d6dd Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents: 723
diff changeset
502 // If the template doesn't exist the Defaulttemplates will be used.
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
503 paramType = LAYER_MODEL+"_"+
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
504 this.determineDefaultTemplateName(geometryType);
724
9ba6bb85d6dd Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents: 723
diff changeset
505 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
506 Document meta = MetaWriter.writeLayerMeta(callContext, uuid,
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
507 path, paramType,
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
508 this.determineGeometryType(geometryType));
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
509 if (meta != null) {
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
510 MapfileGenerator.getInstance().update();
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
511 return meta;
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
512 }
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
513
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
514 pathElement.setTextContent(path);
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
515 }
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
516 }
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
517
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
518 return document;
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
519 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
520
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
521 private String determineGeometryType(String geometryType){
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
522
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
523 String returnValue = geometryType.toLowerCase();
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
524
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
525 if (returnValue.equalsIgnoreCase("linestring")){
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
526 returnValue = "Line";
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
527 }else if (returnValue.equalsIgnoreCase("multilinestring")){
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
528 returnValue ="Line";
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
529 }else if (returnValue.equalsIgnoreCase("multipolygon")){
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
530 returnValue = "Polygon";
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
531 }
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
532 return returnValue;
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
533 }
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
534
799
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
535 private String determineDefaultTemplateName(String geometryType){
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
536
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
537 String returnValue = geometryType.toLowerCase();
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
538
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
539 if (returnValue.equalsIgnoreCase("multilinestring")){
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
540 returnValue ="linestring";
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
541 }else if (returnValue.equalsIgnoreCase("multipolygon")){
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
542 returnValue = "polygon";
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
543 }else if (returnValue.equalsIgnoreCase("multipoint")){
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
544 returnValue = "point";
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
545 }
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
546 return returnValue;
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
547 }
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
548 }

http://dive4elements.wald.intevation.org