Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java @ 723:199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
gnv-artifacts/trunk@753 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 09 Mar 2010 11:42:57 +0000 |
parents | 6eccb68a8b99 |
children | 9ba6bb85d6dd |
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 |
649
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
83 public static final String SHAPEFILE_NAME = "data.shp"; |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
84 |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
85 /** |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
86 * Constructor |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
87 */ |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
88 public LayerOutputState() { |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
89 super(); |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
90 } |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
91 |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
92 /** |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
93 * @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
|
94 * 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
|
95 * java.lang.String, de.intevation.artifacts.CallContext) |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
96 */ |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
97 public void out(Document format, Collection<InputData> inputData, |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
98 OutputStream outputStream, String uuid, |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
99 CallContext callContext) throws StateException { |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
100 |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
101 log.debug("LayerOutputState.out"); |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
102 String outputMode = XMLUtils.xpathString( |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
103 format, XPATH_OUTPUT_MODE, ArtifactNamespaceContext.INSTANCE); |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
104 if (outputMode.equalsIgnoreCase("wms")) { |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
105 Collection<Result> data = this.fetchData(); |
723
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
106 if (data != null && !data.isEmpty()){ |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
107 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
|
108 outputStream); |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
109 }else{ |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
110 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
|
111 } |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
112 }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
|
113 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
|
114 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
|
115 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
|
116 }else{ |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
117 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
|
118 } |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
119 |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
120 } |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
121 } |
723
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
122 |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
123 /** |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
124 * @param outputStream |
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 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
|
127 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
|
128 new ArtifactXMLUtilities(). |
199982e8866e
Integrated ExceptionHandling if no Data was found for the given Layer.
Tim Englich <tim.englich@intevation.de>
parents:
655
diff
changeset
|
129 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
|
130 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
|
131 } |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
132 |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
133 |
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
|
134 /** |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
135 * 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
|
136 * @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
|
137 */ |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
138 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
|
139 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
|
140 // 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
|
141 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
|
142 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
|
143 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
|
144 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
|
145 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
|
146 .getQueryExecutor(); |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
147 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
|
148 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
|
149 if (it.hasNext()){ |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
150 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
|
151 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
|
152 String where = resultValue.getString(1); |
4fc97074eb90
Added 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 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
|
154 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
|
155 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
|
156 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
|
157 |
4fc97074eb90
Added 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 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
|
159 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
|
160 .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
|
161 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
|
162 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
|
163 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
|
164 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
|
165 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
|
166 } |
4fc97074eb90
Added 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 } 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
|
168 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
|
169 // 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
|
170 } |
4fc97074eb90
Added 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 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
|
172 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
|
173 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
|
174 }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
|
175 // 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
|
176 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
|
177 } |
4fc97074eb90
Added 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 }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
|
179 // 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
|
180 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
|
181 |
4fc97074eb90
Added 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 } |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
183 } |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
184 |
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 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
|
186 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
|
187 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
|
188 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
|
189 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
|
190 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
|
191 |
4fc97074eb90
Added 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 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
|
193 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
|
194 // 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
|
195 // 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
|
196 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
|
197 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
|
198 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
|
199 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
|
200 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
|
201 } 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
|
202 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
|
203 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
|
204 } |
4fc97074eb90
Added 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 |
4fc97074eb90
Added 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 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
|
207 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
|
208 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
|
209 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
210 } |
4fc97074eb90
Added 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 } |
4fc97074eb90
Added 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 } 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
|
213 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
|
214 } 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
|
215 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
|
216 } |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
217 } |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
218 return data; |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
219 } |
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 @Override |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
222 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
|
223 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
|
224 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
|
225 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
|
226 "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
|
227 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
|
228 "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
|
229 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
|
230 "queryID-geometry"); |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
231 } |
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
|
232 |
4fc97074eb90
Added 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 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
|
234 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
|
235 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
|
236 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
|
237 ) { |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
238 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
|
239 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
240 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
|
241 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
|
242 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
|
243 |
4fc97074eb90
Added 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 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
|
245 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
|
246 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
|
247 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
|
248 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
|
249 ++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
|
250 } |
4fc97074eb90
Added 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 |
4fc97074eb90
Added 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 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
|
253 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
|
254 + 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
|
255 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
|
256 } |
4fc97074eb90
Added 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 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
|
258 } |
4fc97074eb90
Added 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 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
|
261 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
|
262 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
|
263 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
|
264 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
265 |
4fc97074eb90
Added 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 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
|
267 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
|
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 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
|
270 |
4fc97074eb90
Added 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 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
|
272 } |
4fc97074eb90
Added 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 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
|
274 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
|
275 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
|
276 } |
4fc97074eb90
Added 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 } |
4fc97074eb90
Added 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 } |
4fc97074eb90
Added 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 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
|
281 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
|
282 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
|
283 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
|
284 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
|
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 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
|
287 { |
4fc97074eb90
Added 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 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
|
289 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
|
290 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
|
291 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
|
292 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
|
293 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
|
294 } |
4fc97074eb90
Added 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 } |
4fc97074eb90
Added 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 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
|
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 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
|
299 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
|
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 } |
4fc97074eb90
Added 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 } |
4fc97074eb90
Added 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 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
|
304 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
|
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 } |
4fc97074eb90
Added 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 |
4fc97074eb90
Added 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 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
|
309 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
|
310 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
|
311 } |
4fc97074eb90
Added 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 } |
4fc97074eb90
Added 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 |
4fc97074eb90
Added 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 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
|
315 // 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
|
316 // 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
|
317 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
|
318 (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
|
319 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
|
320 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
|
321 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
|
322 ? 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
|
323 : 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
|
324 } |
4fc97074eb90
Added 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 |
4fc97074eb90
Added 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 /** |
4fc97074eb90
Added 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 * @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
|
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 @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
|
330 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
|
331 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
|
332 |
4fc97074eb90
Added 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 // 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
|
334 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
|
335 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
|
336 // 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
|
337 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
|
338 |
4fc97074eb90
Added 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 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
|
340 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
|
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 |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
343 File 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
|
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 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
|
346 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
|
347 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
|
348 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
|
349 } |
4fc97074eb90
Added 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 |
4fc97074eb90
Added 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 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
|
352 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
|
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 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
|
355 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
356 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
357 |
4fc97074eb90
Added 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 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
|
359 } // 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
|
360 }.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
|
361 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
362 |
4fc97074eb90
Added 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 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
|
364 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
|
365 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
|
366 shapeFilePath = null; |
655
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
367 geometryType = null; |
649
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
368 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
|
369 } |
4fc97074eb90
Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
616
diff
changeset
|
370 } |
655
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
371 protected Document getWMS(String uuid, |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
372 CallContext callContext, |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
373 Collection<Result> data) |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
374 throws StateException |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
375 { |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
376 // TODO: Do the real WMS publishing here! |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
377 Document document = XMLUtils.newDocument(); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
378 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
379 Element pathElement = document.createElement("path"); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
380 document.appendChild(pathElement); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
381 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
382 String path = getShapeFilePath(); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
383 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
384 if (path != null && new File(path).isDirectory()) { |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
385 pathElement.setTextContent(path); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
386 } |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
387 else { |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
388 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
389 if (data != null && |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
390 (path = writeToShapeFile(uuid, data, callContext)) != null) { |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
391 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
392 String paramType = LAYER_MODEL+"_"+this.geometryType.toLowerCase(); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
393 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
394 Document meta = MetaWriter.writeLayerMeta(callContext, uuid, |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
395 path, paramType, |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
396 this.determineGeometryType()); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
397 if (meta != null) { |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
398 MapfileGenerator.getInstance().update(); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
399 return meta; |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
400 } |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
401 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
402 pathElement.setTextContent(path); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
403 } |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
404 } |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
405 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
406 return document; |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
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 |
655
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
409 private String determineGeometryType(){ |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
410 |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
411 String returnValue = this.geometryType.toLowerCase(); |
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 if (returnValue.equalsIgnoreCase("linestring")){ |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
414 returnValue = "Line"; |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
415 } |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
416 return returnValue; |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
417 } |
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 private static Map<Integer, PaletteManager> getPalettes( |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
420 CallContext callContext |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
421 ) { |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
422 //TODO: customize for product Layer |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
423 GNVArtifactContext context = |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
424 (GNVArtifactContext)callContext.globalContext(); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
425 Map<Integer, PaletteManager> palettes = |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
426 (Map<Integer, PaletteManager>)context.get( |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
427 GNVArtifactContext.PALETTES_KEY); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
428 return palettes != null |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
429 ? palettes |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
430 : new HashMap<Integer, PaletteManager>(); |
6eccb68a8b99
Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents:
649
diff
changeset
|
431 } |
616
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
432 |
93978859fa9e
Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
433 } |