Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java @ 725:dde7f51dbe1e
Improved exception handling while feeding an artifact.
gnv-artifacts/trunk@757 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 10 Mar 2010 13:27:14 +0000 |
parents | 9ba6bb85d6dd |
children | f6630d0203da |
rev | line source |
---|---|
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
1 /** |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
2 * |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
3 */ |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
4 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
|
5 |
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
|
6 import java.io.File; |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
7 import java.io.IOException; |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
8 import java.io.OutputStream; |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
9 import java.util.Collection; |
655
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
10 import java.util.HashMap; |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
11 import java.util.Iterator; |
655
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
12 import java.util.Map; |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
13 |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
14 import org.apache.log4j.Logger; |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
15 import org.w3c.dom.Document; |
655
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
16 import org.w3c.dom.Element; |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
17 import org.w3c.dom.Node; |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
18 |
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
|
19 import com.vividsolutions.jts.geom.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
|
20 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
|
21 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
|
22 |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
23 import de.intevation.artifactdatabase.Config; |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
24 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
|
25 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
|
26 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
|
27 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
|
28 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
|
29 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
|
30 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
|
31 import de.intevation.gnv.geobackend.base.query.exception.QueryException; |
655
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
32 import de.intevation.gnv.raster.PaletteManager; |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
33 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
|
34 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
|
35 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
|
36 import de.intevation.gnv.utils.ArtifactXMLUtilities; |
649
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
37 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
|
38 import de.intevation.gnv.utils.MapfileGenerator; |
655
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
39 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
|
40 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
|
41 |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
42 /** |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
43 * @author Tim Englich <tim.englich@intevation.de> |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
44 * |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
45 */ |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
46 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
|
47 |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
48 /** |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
49 * 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
|
50 */ |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
51 private static Logger log = Logger.getLogger(LayerOutputState.class); |
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 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
|
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 final long serialVersionUID = 9180957321704424049L; |
655
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
57 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
58 // TODO: Replace |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
59 public static final String LAYER_MODEL = "layer"; |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
60 |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
61 /** |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
62 * 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
|
63 */ |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
64 private String dataQueryID = 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
|
65 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
66 /** |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
67 * 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
|
68 * 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
|
69 */ |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
70 private String geometryQueryID = 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
|
71 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
72 /** |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
73 * The ID for the Value which will hold the Geometrie-Value |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
74 */ |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
75 private String geometryID = 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
|
76 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
77 private Boolean shapeFileLock = new Boolean(true); |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
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 private String 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
|
80 |
655
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
81 private String geometryType = null; |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
82 |
724
9ba6bb85d6dd
Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents:
723
diff
changeset
|
83 private String templateID = null; |
9ba6bb85d6dd
Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents:
723
diff
changeset
|
84 |
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
|
85 public static final String SHAPEFILE_NAME = "data.shp"; |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
86 |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
87 /** |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
88 * Constructor |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
89 */ |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
90 public LayerOutputState() { |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
91 super(); |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
92 } |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
93 |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
94 /** |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
95 * @see de.intevation.gnv.state.OutputState#out(org.w3c.dom.Document, |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
96 * java.util.Collection, java.io.OutputStream, |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
97 * java.lang.String, de.intevation.artifacts.CallContext) |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
98 */ |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
99 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
|
100 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
|
101 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
|
102 |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
103 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
|
104 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
|
105 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
|
106 if (outputMode.equalsIgnoreCase("wms")) { |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
107 Collection<Result> data = this.fetchData(); |
723
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
108 if (data != null && !data.isEmpty()){ |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
109 XMLUtils.toStream(this.getWMS(uuid, callContext, data), |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
110 outputStream); |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
111 }else{ |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
112 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
|
113 } |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
114 }else if (outputMode.equalsIgnoreCase("zip")){ |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
115 Collection<Result> data = this.fetchData(); |
723
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
116 if (data != null && !data.isEmpty()){ |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
117 this.writeZip(uuid, callContext, outputStream, data); |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
118 }else{ |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
119 this.writeExceptionReport2Stream(outputStream); |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
120 } |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
121 |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
122 } |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
123 } |
723
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
124 |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
125 /** |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
126 * @param outputStream |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
127 */ |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
128 private void writeExceptionReport2Stream(OutputStream outputStream) { |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
129 Document document = XMLUtils.newDocument(); |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
130 new ArtifactXMLUtilities(). |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
131 createExceptionReport("No Data to Export", document); |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
132 XMLUtils.toStream(document,outputStream); |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
133 } |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
134 |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
135 |
649
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
136 /** |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
137 * Fetches the Data from the Databasebackend |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
138 * @return |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
139 */ |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
140 protected Collection<Result> fetchData(){ |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
141 log.debug("LayerOutputState.fetchData"); |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
142 // TODO PUT ALL in CACHE |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
143 Collection<Result> result = this.getData(this.queryID); |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
144 Collection<Result> data = null; |
649
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
145 String geometryWKT = null; |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
146 if (result != null){ |
649
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
147 QueryExecutor queryExecutor = QueryExecutorFactory.getInstance() |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
148 .getQueryExecutor(); |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
149 Iterator<Result> it = result.iterator(); |
649
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
150 String[] queryValues = null; |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
151 if (it.hasNext()){ |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
152 Result resultValue = it.next(); |
649
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
153 String table = resultValue.getString(0); |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
154 String where = resultValue.getString(1); |
724
9ba6bb85d6dd
Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents:
723
diff
changeset
|
155 templateID = resultValue.getString(2); |
649
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
156 if (this.geometryID != 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
|
157 InputData geometryInputData = |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
158 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
|
159 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
|
160 |
4fc97074eb90
Added 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 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
|
162 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
|
163 .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
|
164 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
|
165 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
|
166 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
|
167 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
|
168 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
|
169 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
170 } 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
|
171 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
|
172 // TODO: what should happen?? |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
173 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
174 queryValues = new String[]{table, |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
175 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
|
176 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
|
177 }else{ |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
178 // TODO: Look into the presetting for an WKT |
4fc97074eb90
Added 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 queryValues = new String[]{table,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
|
180 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
181 }else{ |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
182 // TODO: Look into the presetting for an WKT |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
183 queryValues = new String[]{table,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
|
184 |
4fc97074eb90
Added 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 } |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
186 } |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
187 |
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
|
188 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
|
189 data = queryExecutor.executeQuery(dataQueryID, |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
190 queryValues); |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
191 if (data != null && geometryWKT != null){ |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
192 WKTReader wktReader = new WKTReader(); |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
193 Geometry border = wktReader.read(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
|
194 |
4fc97074eb90
Added 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 Iterator<Result> dataIt = data.iterator(); |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
196 while (dataIt.hasNext()){ |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
197 // Trim the Geometries using the |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
198 // Geometry if on is available. |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
199 Result current = dataIt.next(); |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
200 String currentWKT = current.getString(0); |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
201 Geometry currentGeometry = null; |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
202 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
|
203 currentGeometry = wktReader.read(currentWKT); |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
204 } catch (Exception e) { |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
205 log.error("Error parsing Geometry "+ currentWKT); |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
206 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
|
207 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
208 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
209 if (currentGeometry != null){ |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
210 Geometry newGeometry = currentGeometry.intersection(border); |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
211 current.addColumnValue(0, newGeometry.toText()); |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
212 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
213 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
214 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
215 } 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
|
216 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
|
217 } catch (ParseException e){ |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
218 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
|
219 } |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
220 } |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
221 return data; |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
222 } |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
223 |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
224 @Override |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
225 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
|
226 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
|
227 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
|
228 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
|
229 "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
|
230 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
|
231 "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
|
232 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
|
233 "queryID-geometry"); |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
234 } |
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
|
235 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
236 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
|
237 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
|
238 Collection<Result> data, |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
239 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
|
240 ) { |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
241 File baseDir = shapefileDirectory(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
|
242 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
243 File shapeDir = new File(baseDir, uuid); |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
244 boolean success = false; |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
245 boolean createdDir = false; |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
246 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
247 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
|
248 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
|
249 int count = 0; |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
250 while (shapeDir.exists()) { |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
251 shapeDir = new File(baseDir, uuid + "-" + count); |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
252 ++count; |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
253 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
254 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
255 if (!shapeDir.mkdirs()) { |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
256 log.error("cannot create directory '" |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
257 + shapeDir.getAbsolutePath() + "'"); |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
258 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
|
259 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
260 createdDir = true; |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
261 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
262 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
263 File shapeFile = new File(shapeDir, SHAPEFILE_NAME); |
655
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
264 if ((geometryType = ShapeFileWriter.writeDataToFile(shapeFile, "data", data)) == null){ |
649
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
265 log.error("writing data into shapefile failed"); |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
266 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
|
267 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
268 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
269 shapeFilePath = shapeDir.getAbsolutePath(); |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
270 success = true; |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
271 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
272 callContext.afterCall(CallContext.STORE); |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
273 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
274 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
|
275 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
276 finally { |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
277 if (!success && createdDir) { |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
278 FileUtils.deleteRecursive(shapeDir); |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
279 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
280 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
281 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
282 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
283 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
|
284 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
|
285 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
|
286 OutputStream 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
|
287 Collection<Result> data |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
288 ) |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
289 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
|
290 { |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
291 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
|
292 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
|
293 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
|
294 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
|
295 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
|
296 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
|
297 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
298 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
299 else { |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
300 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
301 if ((p = writeToShapeFile(uuid, data, callContext)) != 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
|
302 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
|
303 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
304 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
305 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
306 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
|
307 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
|
308 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
309 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
310 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
311 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
|
312 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
|
313 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
|
314 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
315 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
316 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
317 private static File shapefileDirectory(CallContext callContext) { |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
318 // TODO: Refactoring nessessary it should be used only one Shapefilepath |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
319 // for alle Modes. Code was taken from HorizontalCrossSectionMeshOutputState |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
320 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
|
321 (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
|
322 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
|
323 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
|
324 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
|
325 ? 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
|
326 : 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
|
327 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
328 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
329 /** |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
330 * @see de.intevation.gnv.state.StateBase#endOfLife(java.lang.Object) |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
331 */ |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
332 @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
|
333 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
|
334 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
|
335 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
336 // 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
|
337 new Thread() { |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
338 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
|
339 // TODO: Do the un-publishing WMS stuff. |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
340 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
|
341 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
342 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
|
343 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
|
344 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
345 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
346 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
|
347 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
348 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
|
349 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
|
350 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
|
351 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
|
352 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
353 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
354 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
|
355 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
|
356 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
357 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
|
358 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
359 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
360 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
361 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
|
362 } // 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
|
363 }.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
|
364 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
365 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
366 public String resetShapeFilePath() { |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
367 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
|
368 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
|
369 shapeFilePath = null; |
655
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
370 geometryType = null; |
724
9ba6bb85d6dd
Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents:
723
diff
changeset
|
371 templateID = null; |
649
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
372 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
|
373 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
374 } |
655
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
375 protected Document getWMS(String uuid, |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
376 CallContext callContext, |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
377 Collection<Result> data) |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
378 throws StateException |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
379 { |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
380 // TODO: Do the real WMS publishing here! |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
381 Document document = XMLUtils.newDocument(); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
382 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
383 Element pathElement = document.createElement("path"); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
384 document.appendChild(pathElement); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
385 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
386 String path = getShapeFilePath(); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
387 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
388 if (path != null && new File(path).isDirectory()) { |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
389 pathElement.setTextContent(path); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
390 } |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
391 else { |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
392 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
393 if (data != null && |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
394 (path = writeToShapeFile(uuid, data, callContext)) != null) { |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
395 |
724
9ba6bb85d6dd
Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents:
723
diff
changeset
|
396 String paramType = LAYER_MODEL+"_"+templateID; |
9ba6bb85d6dd
Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents:
723
diff
changeset
|
397 |
9ba6bb85d6dd
Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents:
723
diff
changeset
|
398 if (!MapfileGenerator.getInstance().templateExists(paramType)){ |
9ba6bb85d6dd
Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents:
723
diff
changeset
|
399 // If the template doesn't exist the Defaulttemplates will be used. |
9ba6bb85d6dd
Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents:
723
diff
changeset
|
400 paramType = LAYER_MODEL+"_"+this.geometryType.toLowerCase(); |
9ba6bb85d6dd
Integrate lookup for MapFileTemplate for the different Layer.
Tim Englich <tim.englich@intevation.de>
parents:
723
diff
changeset
|
401 } |
655
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
402 Document meta = MetaWriter.writeLayerMeta(callContext, uuid, |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
403 path, paramType, |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
404 this.determineGeometryType()); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
405 if (meta != null) { |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
406 MapfileGenerator.getInstance().update(); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
407 return meta; |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
408 } |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
409 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
410 pathElement.setTextContent(path); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
411 } |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
412 } |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
413 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
414 return document; |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
415 } |
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
|
416 |
655
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
417 private String determineGeometryType(){ |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
418 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
419 String returnValue = this.geometryType.toLowerCase(); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
420 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
421 if (returnValue.equalsIgnoreCase("linestring")){ |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
422 returnValue = "Line"; |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
423 } |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
424 return returnValue; |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
425 } |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
426 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
427 private static Map<Integer, PaletteManager> getPalettes( |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
428 CallContext callContext |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
429 ) { |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
430 //TODO: customize for product Layer |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
431 GNVArtifactContext context = |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
432 (GNVArtifactContext)callContext.globalContext(); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
433 Map<Integer, PaletteManager> palettes = |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
434 (Map<Integer, PaletteManager>)context.get( |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
435 GNVArtifactContext.PALETTES_KEY); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
436 return palettes != null |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
437 ? palettes |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
438 : new HashMap<Integer, PaletteManager>(); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
439 } |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
440 |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
441 } |