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

Added the time interval into the subtitle of timeseries charts (issue152). gnv-artifacts/trunk@948 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 19 Apr 2010 14:19:19 +0000
parents 05bf8534a35a
children 164d102b0af5
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;
828
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
31 import de.intevation.gnv.utils.ExclusiveExec;
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
32 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
33 import de.intevation.gnv.utils.MapfileGenerator;
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
34 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
35 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
36
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 /**
822
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
38 * This <code>OutputState</code> is used for Layer-Products.
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
39 * @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
40 *
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 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
43
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 * 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
46 */
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 private static Logger log = Logger.getLogger(LayerOutputState.class);
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
48
616
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 * 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
51 */
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 private static final long serialVersionUID = 9180957321704424049L;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
53
822
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
54 /**
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
55 * The Basename of the Templates for the WMS-Exports
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
56 */
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
57 public static final String LAYER_MODEL = "layer";
835
2423cefe7d39 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 828
diff changeset
58
822
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
59 /**
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
60 * The Name of the Shapefile which will be generated.
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
61 */
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
62 public static final String SHAPEFILE_NAME = "data.shp";
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
64 /**
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
65 * 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
66 */
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
67 private String dataQueryID = null;
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
68
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
69 /**
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 * 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
71 * 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
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 geometryQueryID = null;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
74
822
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
75 /**
835
2423cefe7d39 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 828
diff changeset
76 * The ID of the Query for fetching the Columnnames of the Table which
822
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
77 * should put into the Shapefile.
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
78 */
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
79 private String columnQueryID = null;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
80
822
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
81 /**
835
2423cefe7d39 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 828
diff changeset
82 * The ID of the Query for fetching the Information which kind of Geometry
822
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
83 * should be put into the Shapefile.
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
84 */
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
85 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
86
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
87 /**
822
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
88 * The ID for the Value which will hold the Geometry-Value
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
89 */
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
90 private String geometryID = null;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
91
822
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
92 /**
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
93 * Flag for synchronized Access of the Shapefile.
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
94 */
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
95 private Boolean shapeFileLock = new Boolean(true);
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
96
822
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
97 /**
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
98 * The Path where the Shapefile is stored.
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
99 */
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
100 private String shapeFilePath;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
101
822
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
102 /**
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
103 * The ID of the Template which should be used to generate the Layerentry
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
104 * in the Mapfile.
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
105 */
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
106 private String templateID = null;
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
107
822
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
108 /**
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
109 * The Kind of Geometry which should be used to generate the Shapefile.
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
110 */
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
111 private String geometryType = null;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
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 /**
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
114 * Constructor
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
115 */
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
116 public LayerOutputState() {
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
117 super();
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
118 }
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
119
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
120 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
121 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
122 CallContext callContext) throws StateException {
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
123
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
124 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
125 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
126 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
127 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
128 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
129 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
130 XMLUtils.toStream(this.getWMS(uuid, callContext,
828
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
131 data, geometryType,
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
132 inputData),
723
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
133 outputStream);
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
134 }else{
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
135 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
136 }
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
137 }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
138 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
139 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
140 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
141 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
142 }else{
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
143 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
144 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
145
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
146 }
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
147 }
723
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
148
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
149 /**
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
150 * Writes an exception to an output stream.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
151 *
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
152 * @param outputStream The output stream used to write the exception to.
723
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
153 */
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
154 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
155 Document document = XMLUtils.newDocument();
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
156 ArtifactXMLUtilities.
723
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
157 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
158 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
159 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
160
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
161
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
162 /**
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
163 * Fetches the Data from the Databasebackend.
835
2423cefe7d39 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 828
diff changeset
164 *
822
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
165 * @return the resultdata.
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 */
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
167 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
168 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
169 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
170 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
171 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
172 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
173 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
174 .getQueryExecutor();
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
175 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
176 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
177 if (it.hasNext()){
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
178 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
179 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
180
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
181 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
182
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
183 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
184 String columns = this.fetchColumns(table);
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
185
724
9ba6bb85d6dd Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents: 723
diff changeset
186 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
187 if (this.geometryID != null){
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
188 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
189 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
190 if (geometryInputData != null){
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
191
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
192 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
193 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
194 .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
195 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
196 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
197 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
198 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
199 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
200 }
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
201 } 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
202 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
203 }
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
204 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
205 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
206 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
207 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
208 }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
209 //Look into the presetting for an WKT
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
210 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
211 this.preSettings.get("geometry") :
cae93c709548 Fixed NPE using the Presettings-Object without given Presettings.
Tim Englich <tim.englich@intevation.de>
parents: 729
diff changeset
212 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
213 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
214 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
215 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
216 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
217 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
218 }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
219 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
220 }
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
221 }
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
222 }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
223 //Look into the presetting for an WKT
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
224 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
225 this.preSettings.get("geometry") :
cae93c709548 Fixed NPE using the Presettings-Object without given Presettings.
Tim Englich <tim.englich@intevation.de>
parents: 729
diff changeset
226 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
227 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
228 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
229 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
230 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
231 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
232 }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
233 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
234 }
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 }
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
236 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
237
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
238 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
239 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
240 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
241 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
242 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
243 Geometry border = wktReader.read(geometryWKT);
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
244
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
245 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
246 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
247 // 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
248 // 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
249 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
250 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
251 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
252 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
253 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
254 } 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
255 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
256 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
257 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
258
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
259 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
260 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
261 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
262 }
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
263 }
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
264 }
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
265 } 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
266 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
267 } 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
268 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
269 }
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
270 }
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
271 return data;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
272 }
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
273
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
274
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
275 /**
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
276 * This method determines the geometry type on basis of a table name.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
277 *
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
278 * @param tableName Name of the table in the database.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
279 * @param queryExecutor The QueryExecutor.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
280 * @return the geometry type as string (e.g. MultiPolygon, Polygon, etc).
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
281 */
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
282 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
283 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
284 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
285 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
286 String[] filter = tables[0].split("\\.");
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
287
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
288 try {
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
289 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
290 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
291 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
292 {
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
293 int geometryCode = result.iterator().next().getInteger(0);
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
294 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
295 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
296 returnValue = "MultiPolygon";
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
297 }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
298 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
299 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
300 }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
301 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
302 }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
303 returnValue = "GeometryCollection";
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
304 }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
305 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
306 returnValue = "Polygon";
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
307 }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
308 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
309 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
310 }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
311 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
312 }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
313 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
314 }
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
315 }
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
316 } 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
317 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
318 }
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
319
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
320 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
321 }
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
322
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
323
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
324 /**
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
325 * Fetch the columns of a specific table.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
326 *
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
327 * @param tableName The name of the table.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
328 * @return the columns as string.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
329 */
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
330 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
331 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
332 try {
756
1614b27dcbfa Added Support of Layers which are Joined from two Tables.
Tim Englich <tim.englich@intevation.de>
parents: 742
diff changeset
333 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
334 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
335 // 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
336 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
337 .getQueryExecutor();
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
338
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
339 Collection<Result> columnData = queryExecutor.
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
340 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
341 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
342 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
343 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
344 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
345 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
346 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
347 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
348 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
349 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
350 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
351 }
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
352 }
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
353 }
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
354 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
355 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
356
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
357 } 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
358 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
359 }
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
360 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
361 }
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
362
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
363
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
364 @Override
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
365 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
366 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
367 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
368 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
369 "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
370 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
371 "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
372 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
373 "queryID-geometry");
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
374
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
375 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
376 // "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
377 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
378 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
379
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
380
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
381 /**
822
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
382 * Write the resultdata to shapefiles.
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
383 *
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
384 * @param uuid The UUID of the current artifact.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
385 * @param data The finalized data used for shapefile creation.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
386 * @param callContext The CallContext object.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
387 * @param geometryType The geometry type.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
388 * @return the shapefile path.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
389 */
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
390 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
391 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
392 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
393 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
394 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
395 ) {
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 File baseDir = shapefileDirectory(callContext);
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
397
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
398 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
399 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
400 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
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 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
403 synchronized (shapeFileLock) {
828
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
404 if (shapeDir.exists()) {
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
405 FileUtils.deleteContent(shapeDir);
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
406 }
828
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
407 else if (!shapeDir.mkdirs()) {
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
408 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
409 + 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
410 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
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 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
413 }
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
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 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
416 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
417 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
418 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
419 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
420
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
421 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
422 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
423
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 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
425
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 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
427 }
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 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
429 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
430 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
431 }
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 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
434
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
435
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
436 /**
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
437 * Create a zip archive with the shapefiles of the given shapefiles path and
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
438 * write it to <code>output</code>.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
439 *
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
440 * @param uuid The UUID of the current artifact.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
441 * @param callContext The CallContext object.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
442 * @param output The output stream.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
443 * @param data The data to be written to shapefile.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
444 * @param geometryType The geometry type.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
445 * @throws StateException if an error occured while zipfile creation.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
446 */
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
447 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
448 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
449 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
450 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
451 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
452 String geometryType
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
453 )
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
454 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
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 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
457 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
458 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
459 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
460 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
461 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
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 else {
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
465
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
466 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
467 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
468 }
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 }
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 }
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 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
472 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
473 }
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 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
475
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
476 /**
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
477 * Returns the shapefile path.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
478 *
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
479 * @return the shapefile path.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
480 */
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
481 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
482 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
483 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
484 }
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
485 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
486
835
2423cefe7d39 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 828
diff changeset
487
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
488 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
489 // 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
490 // 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
491 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
492 (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
493 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
494 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
495 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
496 ? 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
497 : 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
498 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
499
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
500
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
501 @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
502 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
503 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
504
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
505 // 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
506 new Thread() {
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
507 @Override
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
508 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
509 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
510
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
511 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
512 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
513 }
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
514
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
515 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
516
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
517 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
518 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
519 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
520 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
521 }
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
522
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
523 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
524 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
525 }
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
526 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
527 }
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
528 }
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
529
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
530 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
531 } // 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
532 }.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
533 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
534
822
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
535 /**
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
536 * Resets the Settings e.g shapeFilePath and templateID
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
537 * @return
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
538 */
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
539 private String resetShapeFilePath() {
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
540 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
541 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
542 shapeFilePath = null;
724
9ba6bb85d6dd Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents: 723
diff changeset
543 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
544 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
545 }
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
546 }
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
547
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
548
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
549 /**
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
550 * Write data to shapefiles and feed a map service with information about
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
551 * these shapefiles. The map service can be queried for displaying
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
552 * corresponding layers as WMS.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
553 *
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
554 * @param uuid The UUID of the current artifact.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
555 * @param callContext The CallContext object.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
556 * @param data A collection with some input data.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
557 * @param geometryType The geometry type.
828
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
558 * @param inputData the Parameters which are send by the out-Call.
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
559 * @return a document with some meta information (shapefile path, geometry
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
560 * type, time to live of the current artifact, etc).
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
561 * @throws StateException if an error occured while shapefile writing.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
562 */
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
563 protected Document getWMS(String uuid,
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
564 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
565 Collection<Result> data,
828
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
566 String geometryType,
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
567 Collection<InputData> inputData)
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
568 throws StateException
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
569 {
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
570 Document document = XMLUtils.newDocument();
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
571
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
572 Element pathElement = document.createElement("path");
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
573 document.appendChild(pathElement);
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
574
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
575 String path = getShapeFilePath();
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
576
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
577 if (path != null && new File(path).isDirectory()) {
828
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
578 String title = getLayerTitle(inputData);
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
579 if (title == null) {
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
580 title = uuid;
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
581 }
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
582
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
583 callContext.putContextValue(
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
584 MetaWriter.CONTEXT_LAYER_TITLE, title);
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
585
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
586 String paramType = findParameterTitle(geometryType);
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
587
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
588 if (log.isDebugEnabled()) {
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
589 log.debug("Layer title: " + title);
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
590 log.debug("Layer type: " + paramType);
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
591 }
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
592
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
593 Document meta = MetaWriter.writeHorizontalcrosssectionMeta(
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
594 callContext, uuid, path, paramType);
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
595 if (meta != null) {
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
596 MapfileGenerator.getInstance().update();
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
597 return meta;
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
598 }
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
599
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
600 pathElement.setTextContent(path);
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
601 }
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
602 else {
828
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
603 ExclusiveExec.UniqueKey key = ExclusiveExec.INSTANCE.acquire(uuid);
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
604 try{
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
605 if (data != null &&
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
606 (path = writeToShapeFile(uuid, data, callContext,geometryType)) != null) {
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
607 String paramType = findParameterTitle(geometryType);
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
608 String title = getLayerTitle(inputData);
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
609 if (title == null) {
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
610 title = uuid;
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
611 }
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
612 Document meta = MetaWriter.writeLayerMeta(callContext, uuid,
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
613 path, paramType,
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
614 this.determineGeometryType(geometryType));
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
615 if (meta != null) {
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
616 MapfileGenerator.getInstance().update();
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
617 return meta;
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
618 }
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
619 pathElement.setTextContent(path);
724
9ba6bb85d6dd Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents: 723
diff changeset
620 }
828
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
621 }finally{
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
622 ExclusiveExec.INSTANCE.release(key);
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
623 }
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
624 }
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
625
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
626 return document;
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
627 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
628
828
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
629 /**
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
630 * Returns the parameterType for the Layer.
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
631 * @param geometryType
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
632 * @return
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
633 */
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
634 private String findParameterTitle(String geometryType) {
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
635 String paramType = LAYER_MODEL+"_"+templateID;
835
2423cefe7d39 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 828
diff changeset
636
828
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
637 if (!MapfileGenerator.getInstance().templateExists(paramType)){
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
638 // If the template doesn't exist the Defaulttemplates will be used.
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
639 paramType = LAYER_MODEL+"_"+
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
640 this.determineDefaultTemplateName(geometryType);
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
641 }
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
642 return paramType;
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
643 }
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
644
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
645 /**
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
646 * Find the title for a wms layer specified by the user.
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
647 *
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
648 * @param inputData A collection with InputData objects.
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
649 * @return the title.
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
650 */
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
651 protected String getLayerTitle(Collection<InputData> inputData) {
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
652 for (InputData data: inputData) {
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
653 String name = data.getName();
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
654 if (name != null && name.equals("title")) {
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
655 return (String) data.getValue();
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
656 }
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
657 }
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
658 return null;
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
659 }
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
660
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
661
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
662 /**
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
663 * Turns the geometry type into a form used for the templating mechanism
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
664 * while mapfile generation.
835
2423cefe7d39 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 828
diff changeset
665 *
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
666 * @param geometryType The original geometry type.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
667 * @return a valid geometry type fpr the template mechanism.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
668 */
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
669 private String determineGeometryType(String geometryType){
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
670
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
671 String returnValue = geometryType.toLowerCase();
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
672
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
673 if (returnValue.equalsIgnoreCase("linestring")){
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
674 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
675 }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
676 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
677 }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
678 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
679 }
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
680 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
681 }
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
682
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
683
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
684 /**
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
685 * Determine the default template name if no special template is existing
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
686 * for this layer.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
687 *
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
688 * @param geometryType The geometry type.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
689 * @return a default geometry fitting to the original geometry type.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
690 */
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
691 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
692
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
693 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
694
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
695 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
696 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
697 }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
698 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
699 }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
700 returnValue = "point";
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
701 }
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
702 return returnValue;
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
703 }
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
704 }
836
05bf8534a35a Using unix line endings only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 835
diff changeset
705 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org