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

Added license file and license headers. gnv-artifacts/trunk@1260 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 02 Nov 2010 17:46:55 +0000
parents 19182eaccc8d
children dec4257ad570
rev   line source
1115
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1111
diff changeset
1 /*
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1111
diff changeset
2 * Copyright (c) 2010 by Intevation GmbH
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1111
diff changeset
3 *
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1111
diff changeset
4 * This program is free software under the LGPL (>=v2.1)
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1111
diff changeset
5 * Read the file LGPL.txt coming with the software for details
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1111
diff changeset
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1111
diff changeset
7 */
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1111
diff changeset
8
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 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
10
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
11 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
12 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
13 import java.io.OutputStream;
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
14 import java.util.ArrayList;
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
15 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
16 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
17
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
18 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
19 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
20 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
21
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
22 import com.vividsolutions.jts.geom.Envelope;
779
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
23 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
24 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
25 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
26
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.artifactdatabase.Config;
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.artifactdatabase.XMLUtils;
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.artifacts.ArtifactNamespaceContext;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 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
31 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
32 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
33 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
34 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
35 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
36 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
37 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
38 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
39 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
40 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
41 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
42 import de.intevation.gnv.utils.MapfileGenerator;
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
43 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
44 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
45
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
46 /**
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
47 * 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
48 * @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
49 *
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 */
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 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
52
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 /**
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 * 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
55 */
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 private static Logger log = Logger.getLogger(LayerOutputState.class);
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
57
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
58 /**
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 * 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
60 */
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61 private static final long serialVersionUID = 9180957321704424049L;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
62
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
63 /**
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
64 * 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
65 */
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
66 public static final String LAYER_MODEL = "layer";
835
2423cefe7d39 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 828
diff changeset
67
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
68 /**
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
69 * 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
70 */
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
71 public static final String SHAPEFILE_NAME = "data";
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
72
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
73 /**
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
74 * 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
75 */
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
76 private String dataQueryID = null;
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
77
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
78 /**
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
79 * 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
80 * 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
81 */
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
82 private String geometryQueryID = null;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
83
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
84 /**
835
2423cefe7d39 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 828
diff changeset
85 * 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
86 * 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
87 */
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
88 private String columnQueryID = null;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
89
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
90 /**
835
2423cefe7d39 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 828
diff changeset
91 * 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
92 * 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
93 */
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
94 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
95
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
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 * 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
98 */
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
99 private String geometryID = null;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
100
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
101 /**
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 * 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
103 */
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
104 private Boolean shapeFileLock = new Boolean(true);
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
105
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
106 /**
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
107 * 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
108 */
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
109 private String shapeFilePath;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
110
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
111 /**
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
112 * Constructor
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 public LayerOutputState() {
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
115 super();
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
116 }
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
117
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
118 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
119 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
120 CallContext callContext) throws StateException {
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
121 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
122 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
123 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
124 if (outputMode.equalsIgnoreCase("wms")) {
870
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 859
diff changeset
125
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 859
diff changeset
126 Collection<LayerMetaData> layerMetaData =
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
127 this.getRequestedLayerMetadata();
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
128 if (layerMetaData != null && !layerMetaData.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
129 XMLUtils.toStream(this.getWMS(uuid, callContext,
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
130 layerMetaData,inputData),
723
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
131 outputStream);
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
132 }else{
199982e8866e Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents: 655
diff changeset
133 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
134 }
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
135 }else if (outputMode.equalsIgnoreCase("zip")){
870
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 859
diff changeset
136 Collection<LayerMetaData> layerMetaData =
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
137 this.getRequestedLayerMetadata();
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
138
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
139 if (layerMetaData != null && !layerMetaData.isEmpty()){
870
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 859
diff changeset
140 this.writeZip(uuid, callContext,
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
141 outputStream, layerMetaData);
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
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
161 /**
870
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 859
diff changeset
162 * Returns the Metadata for the requested Layers for fetching the data
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
163 * of the Layer and generating the Layer and WMS.
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
164 * @return the Metadata for the requested Layers
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
165 */
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
166 private Collection<LayerMetaData> getRequestedLayerMetadata(){
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
167 log.debug("LayerOutputState.getRequestedLayerMetadata");
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
168 Collection<Result> result = this.getData(this.queryID);
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
169 Collection<LayerMetaData> returnValue = null;
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
170 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
171 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
172 .getQueryExecutor();
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
173 Iterator<Result> it = result.iterator();
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
174 returnValue = new ArrayList<LayerMetaData>(result.size());
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
175 while (it.hasNext()){
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
176 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
177 String table = resultValue.getString(0);
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
178 String geometryType = this.getGeometryType(table, queryExecutor);
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 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
180 String columns = this.fetchColumns(table);
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
181 String templateID = resultValue.getString(2);
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
182 String layername = resultValue.getString(3);
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
183 String[] queryValues = null;
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
184 String geometryWKT = 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
185 if (this.geometryID != null){
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
186 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
187 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
188 if (geometryInputData != 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
189 try {
870
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 859
diff changeset
190
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
191 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
192 .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
193 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
194 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
195 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
196 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
197 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
198 }
4fc97074eb90 Added 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 } 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
200 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
201 }
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
202 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
203 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
204 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
205 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
206 }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
207 //Look into the presetting for an WKT
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
208 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
209 this.preSettings.get("geometry") :
cae93c709548 Fixed NPE using the Presettings-Object without given Presettings.
Tim Englich <tim.englich@intevation.de>
parents: 729
diff changeset
210 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
211 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
212 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
213 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
214 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
215 geometryWKTData.getValue()};
1103
faae3fc7b792 Now geometries of the generated layers will also be clipped if a polygon served by the mv-gnv-interface should be used.
Tim Englich <tim.englich@intevation.de>
parents: 1070
diff changeset
216 geometryWKT = geometryWKTData.getValue();
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
217 }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
218 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
219 }
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 }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
222 //Look into the presetting for an WKT
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
223 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
224 this.preSettings.get("geometry") :
cae93c709548 Fixed NPE using the Presettings-Object without given Presettings.
Tim Englich <tim.englich@intevation.de>
parents: 729
diff changeset
225 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
226 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
227 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
228 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
229 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
230 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
231 }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
232 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
233 }
4fc97074eb90 Added 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 }
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
235 returnValue.add(new LayerMetaData(
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
236 table, geometryType, where, columns,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
237 templateID, queryValues, geometryWKT, layername));
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
238 }
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
239 }
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
240 return returnValue;
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
241 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
242
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
243 /**
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
244 * Fetches the Data from the Databasebackend.
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
245 *
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
246 * @return the resultdata.
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
247 */
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
248 protected Collection<Result> fetchData(LayerMetaData layerMetaData, Envelope mbr){
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
249 log.debug("LayerOutputState.fetchData");
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
250 Collection<Result> data = null;
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
251 QueryExecutor queryExecutor = QueryExecutorFactory.getInstance()
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
252 .getQueryExecutor();
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
253 try {
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
254 data = queryExecutor.executeQuery(dataQueryID,
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
255 layerMetaData.getQueryValues());
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
256 if (data != null){
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
257 WKTReader wktReader = new WKTReader();
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
258 Geometry border = null;
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
259 if (layerMetaData.getGeometryWKT() != null){
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
260 border = wktReader.read(layerMetaData.getGeometryWKT());
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
261 }
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
262 Iterator<Result> dataIt = data.iterator();
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
263 while (dataIt.hasNext()){
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
264 // Trim the Geometries using the
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
265 // Geometry if one is available.
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
266 Result current = dataIt.next();
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
267 String currentWKT = current.getString(0);
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
268 Geometry currentGeometry = null;
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
269 try {
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
270 currentGeometry = wktReader.read(currentWKT);
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
271 } catch (Exception e) {
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
272 log.error("Error parsing Geometry "+ currentWKT);
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
273 log.error(e,e);
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
274 }
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
275 if (currentGeometry != null){
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
276 if (border != null){
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
277 currentGeometry = currentGeometry.intersection(border);
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
278 current.addColumnValue(0, currentGeometry.toText());
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
279 }
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
280 if (mbr.isNull()){
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
281 mbr.init(currentGeometry.getEnvelopeInternal());
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
282 }else{
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
283 mbr.expandToInclude(currentGeometry.getEnvelopeInternal());
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
284 }
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
285 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
286 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
287 }
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
288 } catch (QueryException e) {
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
289 log.error(e,e);
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
290 } catch (ParseException e){
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
291 log.error(e,e);
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
292 }
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
293 return data;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
294 }
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
295
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
296
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
297 /**
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
298 * 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
299 *
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
300 * @param tableName Name of the table in the database.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
301 * @param queryExecutor The QueryExecutor.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
302 * @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
303 */
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
304 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
305 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
306 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
307 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
308 String[] filter = tables[0].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
309 try {
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
310 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
311 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
312 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
313 {
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 int geometryCode = result.iterator().next().getInteger(0);
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
315 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
316 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
317 returnValue = "MultiPolygon";
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
318 }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
319 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
320 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
321 }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
322 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
323 }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
324 returnValue = "GeometryCollection";
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
325 }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
326 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
327 returnValue = "Polygon";
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
328 }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
329 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
330 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
331 }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
332 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
333 }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
334 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
335 }
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
336 }
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
337 } 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
338 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
339 }
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
340 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
341 }
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
342
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
343
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
344 /**
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
345 * Fetch the columns of a specific table.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
346 *
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
347 * @param tableName The name of the table.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
348 * @return the columns as string.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
349 */
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
350 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
351 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
352 try {
756
1614b27dcbfa Added Support of Layers which are Joined from two Tables.
Tim Englich <tim.englich@intevation.de>
parents: 742
diff changeset
353 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
354 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
355 // 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
356 QueryExecutor queryExecutor = QueryExecutorFactory.getInstance()
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
357 .getQueryExecutor();
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
358 Collection<Result> columnData = queryExecutor.
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
359 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
360 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
361 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
362 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
363 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
364 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
365 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
366 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
367 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
368 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
369 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
370 }
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
371 }
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
372 }
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
373 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
374 }
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 } 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
376 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
377 }
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
378 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
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
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
382 @Override
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
383 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
384 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
385 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
386 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
387 "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
388 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
389 "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
390 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
391 "queryID-geometry");
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
392
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
393 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
394 // "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
395 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
396 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
397
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
398
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
399 /**
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
400 * Write the resultdata to shapefiles.
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
401 *
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
402 * @param uuid The UUID of the current artifact.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
403 * @param data The finalized data used for shapefile creation.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
404 * @param callContext The CallContext object.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
405 * @param geometryType The geometry type.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
406 * @return the shapefile path.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
407 */
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
408 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
409 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
410 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
411 CallContext callContext,
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
412 String geometryType,
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
413 int layerNumber
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
414 ) {
4fc97074eb90 Added 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 boolean success = false;
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
416 if (data != null && !data.isEmpty()){
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
417 File shapeDir = new File(shapeFilePath);
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
418 try {
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
419 File shapeFile = new File(shapeDir, createShapeFileName(layerNumber));
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
420 if (!ShapeFileWriter.writeDataToFile(shapeFile, "data", data,geometryType)){
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
421 log.error("writing data into shapefile failed");
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
422 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
423 }
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
424 success = true;
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
425 callContext.afterCall(CallContext.STORE);
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
426 return shapeFilePath;
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
427 }
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
428 finally {
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
429 if (!success) {
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
430 FileUtils.deleteRecursive(shapeDir);
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
431 }
649
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
432 }
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
433 }else{
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
434 return 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
435 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
436 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
437
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
438 /**
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
439 * Check if the ShapeDir exists and if it exists delete all Contents
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
440 * in it. If it not exists the Director will be created.
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
441 * @param baseDir the BaseDirectory for all ShapeDirs
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
442 * @param uuid the UUID which is used to create the Directory
870
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 859
diff changeset
443 * @return true if the directory exists or could be created.
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
444 * false if the directory could not be created.
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
445 */
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
446 private boolean createShapeDir(File baseDir, String uuid){
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
447 File shapeDir = new File(baseDir, uuid);
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
448 boolean createdDir = false;
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
449 synchronized (shapeFileLock) {
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
450 if (shapeDir.exists()) {
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
451 FileUtils.deleteContent(shapeDir); // TODO Place on getZip and getWMS
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
452 }
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
453 else if (!shapeDir.mkdirs()) {
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
454 log.error("cannot create directory '"
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
455 + shapeDir.getAbsolutePath() + "'");
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
456 return false;
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
457 }
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
458 createdDir = true;
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
459 }
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
460 shapeFilePath = shapeDir.getAbsolutePath();
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
461 return createdDir;
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
462 }
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
463
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
464 /**
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
465 * 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
466 * write it to <code>output</code>.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
467 *
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
468 * @param uuid The UUID of the current artifact.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
469 * @param callContext The CallContext object.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
470 * @param output The output stream.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
471 * @param data The data to be written to shapefile.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
472 * @param geometryType The geometry type.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
473 * @throws StateException if an error occured while zipfile creation.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
474 */
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
475 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
476 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
477 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
478 OutputStream output,
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
479 Collection<LayerMetaData> layerMetaData
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
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 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
482 {
4fc97074eb90 Added 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 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
484 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
485 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
486 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
487 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
488 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
489 }
4fc97074eb90 Added 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 }
4fc97074eb90 Added 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 else {
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
492 File baseDir = shapefileDirectory(callContext);
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
493 if (!this.createShapeDir(baseDir, uuid)){
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
494 return;
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
495 }
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
496 Iterator<LayerMetaData> it = layerMetaData.iterator();
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
497 int i = 1;
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
498 Envelope mbr = new Envelope();
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
499 while(it.hasNext()){
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
500 LayerMetaData lmd = it.next();
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
501 Collection<Result> data = this.fetchData(lmd, mbr);
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
502 p = writeToShapeFile(uuid, data, callContext,lmd.getGeometryType(),i++);
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
503 }
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
504 if (p != 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
505 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
506 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
507 }
4fc97074eb90 Added 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 }
4fc97074eb90 Added 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 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
510 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
511 }
4fc97074eb90 Added 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 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
513
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
514 /**
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
515 * Returns the shapefile path.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
516 *
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
517 * @return the shapefile path.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
518 */
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
519 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
520 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
521 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
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 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
524
1044
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
525
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
526 /**
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
527 * Set the shapefile path.
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
528 */
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
529 public void setShapeFilePath(String shapeFilePath) {
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
530 synchronized (shapeFileLock) {
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
531 this.shapeFilePath = shapeFilePath;
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
532 }
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
533 }
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
534
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
535 /**
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
536 * Returns the basic-directory where the Shapefiles should be placed in.
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
537 * @param callContext the Context of this Call
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
538 * @return the Directory where the Shapefiles could be placed in.
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
539 * (Please create an own directory in this dir and not put the
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
540 * Files directly in it)
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
541 */
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
542 private static File shapefileDirectory(CallContext callContext) {
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
543 // Code was taken from HorizontalCrossSectionMeshOutputState
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 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
545 (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
546 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
547 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
548 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
549 ? 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
550 : 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
551 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
552
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
553
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
554 @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
555 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
556 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
557 // 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
558 new Thread() {
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
559 @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
560 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
561 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
562 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
563 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
564 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
565 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
566 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
567 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
568 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
569 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
570 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
571 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
572 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
573 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
574 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
575 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
576 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
577
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
578 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
579 } // 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
580 }.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
581 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
582
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
583 /**
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
584 * 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
585 * @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
586 */
ac1b9f00603f Added more Javadoc. Removed obsolet TODO-Flags. Added missing Files to Revision 907
Tim Englich <tim.englich@intevation.de>
parents: 813
diff changeset
587 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
588 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
589 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
590 shapeFilePath = 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
591 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
592 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
593 }
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
594
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
595
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
596 /**
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
597 * 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
598 * 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
599 * corresponding layers as WMS.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
600 *
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
601 * @param uuid The UUID of the current artifact.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
602 * @param callContext The CallContext object.
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
603 * @param layerMetaData The Metadata which is required to create the
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
604 * different Layers.
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
605 * @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
606 * @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
607 * type, time to live of the current artifact, etc).
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
608 * @throws StateException if an error occured while shapefile writing.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
609 */
1044
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
610 protected Document getWMS(
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
611 String uuid,
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
612 CallContext callContext,
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
613 Collection<LayerMetaData> layerMetaData,
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
614 Collection<InputData> inputData)
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
615 throws StateException
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
616 {
1044
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
617 Document document = XMLUtils.newDocument();
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
618
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
619 File baseDir = shapefileDirectory(callContext);
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
620 File shapeDir = new File(baseDir, uuid);
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
621
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
622 boolean success = false;
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
623 boolean createdDir = false;
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
624
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
625 try {
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
626 // create shapefile directory or delete content if it already exists
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
627 synchronized (shapeFileLock) {
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
628 if (shapeDir.exists()) {
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
629 FileUtils.deleteContent(shapeDir);
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
630 }
1044
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
631 else if (!shapeDir.mkdirs()) {
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
632 log.error("cannot create directory '"
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
633 + shapeDir.getAbsolutePath() + "'");
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
634 return null;
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
635 }
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
636 setShapeFilePath(shapeDir.getAbsolutePath());
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
637 createdDir = true;
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
638 }
1044
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
639
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
640 // process data
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
641 Iterator<LayerMetaData> it = layerMetaData.iterator();
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
642
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
643 // create meta file
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
644 Document meta = MetaWriter.initMeta();
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
645 MetaWriter.insertAbstractMeta(callContext, meta);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
646
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
647 String path = getShapeFilePath();
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
648 String prefix = getLayerPrefix(inputData);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
649
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
650 if (prefix == null) {
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
651 prefix = uuid;
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
652 }
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
653
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
654 int layerNumber = 0;
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
655 Envelope mbr = new Envelope();
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
656 while (it.hasNext()){
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
657 LayerMetaData lmd = it.next();
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
658 layerNumber ++;
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
659
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
660 String geometryType = lmd.getGeometryType();
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
661 String templateId = lmd.getTemplateID();
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
662
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
663 ExclusiveExec.UniqueKey key = ExclusiveExec.INSTANCE.acquire(uuid);
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
664 try{
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
665 Collection<Result> results = this.fetchData(lmd,mbr);
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
666 if (results != null && writeToShapeFile(uuid, results,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
667 callContext,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
668 geometryType,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
669 layerNumber) != null) {
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
670 String name = getLayerName(uuid, layerNumber);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
671 String base = lmd.getLayertitle();
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
672 String title = getLayerTitle(prefix, base);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
673 String data = getLayerData(
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
674 uuid, createShapeFileName(layerNumber));
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
675 String type = determineGeometryType(geometryType);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
676 String status = "OFF";
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
677 String model = findParameterTitle(
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
678 geometryType, templateId);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
679
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
680 MetaWriter.insertLayer(
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
681 callContext, meta, name, title,
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
682 data, model, type, status);
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
683 }
1044
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
684
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
685 success = true;
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
686
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
687 if (meta != null && !it.hasNext()) {
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
688 MetaWriter.insertMbr(mbr, "EPSG:4326",meta);
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
689 MetaWriter.writeMetaFile(path, meta);
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
690 MapfileGenerator.getInstance().update();
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
691 return meta;
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
692 }
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
693 }finally{
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
694 ExclusiveExec.INSTANCE.release(key);
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
695 }
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
696 }
1070
7096a2e13676 Added functionality to publish the the mbr of the generated layer to
Tim Englich <tim.englich@intevation.de>
parents: 1057
diff changeset
697
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
698 return document;
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
699 }
1044
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
700 finally {
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
701 if (!success && createdDir) {
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
702 FileUtils.deleteRecursive(shapeDir);
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
703 }
461d4489705c Improved directoy handling for incoming wms requests on product 'Layer' (issue269).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
704 }
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
705 }
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
706
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
707 /**
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
708 * Creates the name of the Shapefile
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
709 * @param layerNumber the Number of the Layer
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
710 * @return the create name of the Shapefile.
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
711 */
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
712 private String createShapeFileName(int layerNumber) {
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
713 return SHAPEFILE_NAME+"_"+layerNumber+".shp";
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
714 }
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
715
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 756
diff changeset
716
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
717 protected String getLayerName(String uuid, int idx) {
1111
19182eaccc8d Added a prefix for WMS layers to prevent the mapserver from generating invalid xml that would end in a bug (issue314, issue315).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1103
diff changeset
718 return "GNV_" + uuid + "_" + idx;
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
719 }
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
720
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
721
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
722 protected String getLayerTitle(String prefix, String base) {
1111
19182eaccc8d Added a prefix for WMS layers to prevent the mapserver from generating invalid xml that would end in a bug (issue314, issue315).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1103
diff changeset
723 return "GNV_" + prefix + "_" + base;
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
724 }
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
725
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
726
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
727 protected String getLayerData(String shapeDir, String filename) {
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
728 File path = new File(shapeDir, filename);
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
729
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
730 return path.toString();
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
731 }
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
732
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
733
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
734 /**
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
735 * 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
736 * @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
737 * @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
738 */
859
3fbabd4803d7 ISSUE252 Make it possible to export more than one Layer
Tim Englich <tim.englich@intevation.de>
parents: 853
diff changeset
739 private String findParameterTitle(String geometryType, String templateID) {
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
740 String paramType = LAYER_MODEL+"_"+templateID;
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
741 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
742 // 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
743 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
744 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
745 }
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
746 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
747 }
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
748
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
749 /**
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
750 * 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
751 *
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
752 * @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
753 * @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
754 */
1057
04967dc9c83f The title of a layer can be changed by the user. Product 'Layer' and 'Horizontalschnitt' now use the same code path to write the meta information file. (issue198)
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1044
diff changeset
755 protected String getLayerPrefix(Collection<InputData> inputData) {
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
756 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
757 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
758 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
759 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
760 }
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
761 }
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
762 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
763 }
28028979c813 Integrated the possibility to change the Title of an Layer in Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 822
diff changeset
764
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
765
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
766 /**
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
767 * 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
768 * while mapfile generation.
835
2423cefe7d39 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 828
diff changeset
769 *
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
770 * @param geometryType The original geometry type.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
771 * @return a valid geometry type fpr the template mechanism.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
772 */
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
773 private String determineGeometryType(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
774 String returnValue = geometryType.toLowerCase();
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
775 if (returnValue.equalsIgnoreCase("linestring")){
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
776 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
777 }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
778 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
779 }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
780 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
781 }
feeaf5aec552 ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
Tim Englich <tim.englich@intevation.de>
parents: 780
diff changeset
782 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
783 }
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 799
diff changeset
784
813
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
785
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
786 /**
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
787 * 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
788 * for this layer.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
789 *
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
790 * @param geometryType The geometry type.
79c1db3ca7cc Added some more javadocs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 803
diff changeset
791 * @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
792 */
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
793 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
794 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
795 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
796 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
797 }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
798 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
799 }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
800 returnValue = "point";
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
801 }
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
802 return returnValue;
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
803 }
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
804 }
836
05bf8534a35a Using unix line endings only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 835
diff changeset
805 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org