annotate gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java @ 655:6eccb68a8b99

Added WMS-Publishing to Product Layer gnv-artifacts/trunk@747 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Mon, 08 Mar 2010 14:04:28 +0000
parents 4fc97074eb90
children 199982e8866e
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;
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
36 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
37 import de.intevation.gnv.utils.MapfileGenerator;
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
38 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
39 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
40
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 /**
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 * @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
43 *
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 */
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 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
46
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 /**
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 * the 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
49 */
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 private static 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
51
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 * 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
54 */
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 private static final long serialVersionUID = 9180957321704424049L;
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
56
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
57 // TODO: Replace
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
58 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
59
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 * 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
62 */
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 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
64
4fc97074eb90 Added 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 * 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
67 * 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
68 */
4fc97074eb90 Added 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 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
70
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
71 /**
4fc97074eb90 Added 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 * 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
73 */
4fc97074eb90 Added 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 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
75
4fc97074eb90 Added 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 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
77
4fc97074eb90 Added 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 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
79
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
80 private String geometryType = null;
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
81
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
82 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
83
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
84 /**
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
85 * Constructor
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
86 */
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
87 public LayerOutputState() {
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
88 super();
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
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 * @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
93 * 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
94 * 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
95 */
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
96 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
97 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
98 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
99
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
100 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
101 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
102 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
103 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
104 Collection<Result> data = this.fetchData();
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
105 XMLUtils.toStream(this.getWMS(uuid, callContext, data),outputStream);
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
106 }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
107 Collection<Result> data = this.fetchData();
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
108 this.writeZip(uuid, callContext, outputStream, data);
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
109 }
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
110 }
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
111
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
112
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
113 /**
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
114 * 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
115 * @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
116 */
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
117 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
118 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
119 // 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
120 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
121 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
122 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
123 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
124 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
125 .getQueryExecutor();
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
126 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
127 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
128 if (it.hasNext()){
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
129 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
130 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
131 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
132 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
133 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
134 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
135 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
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 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
138 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
139 .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
140 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
141 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
142 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
143 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
144 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
145 }
4fc97074eb90 Added 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 } 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
147 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
148 // 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
149 }
4fc97074eb90 Added 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 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
151 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
152 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
153 }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
154 // 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
155 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
156 }
4fc97074eb90 Added 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 }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
158 // 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
159 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
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 }
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
162 }
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
163
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
164 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
165 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
166 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
167 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
168 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
169 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
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 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
172 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
173 // 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
174 // 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
175 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
176 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
177 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
178 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
179 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
180 } 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
181 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
182 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
183 }
4fc97074eb90 Added 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 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
186 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
187 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
188 }
4fc97074eb90 Added 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 }
4fc97074eb90 Added 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 }
4fc97074eb90 Added 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 } 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
192 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
193 } 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
194 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
195 }
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
196 }
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
197 return data;
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
198 }
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
199
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
200 @Override
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
201 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
202 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
203 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
204 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
205 "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
206 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
207 "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
208 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
209 "queryID-geometry");
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
210 }
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
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 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
213 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
214 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
215 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
216 ) {
4fc97074eb90 Added 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 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
218
4fc97074eb90 Added 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 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
220 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
221 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
222
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
223 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
224 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
225 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
226 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
227 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
228 ++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
229 }
4fc97074eb90 Added 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
4fc97074eb90 Added 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 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
232 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
233 + 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
234 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
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 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
237 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
238
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
239 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
240 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
241 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
242 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
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
4fc97074eb90 Added 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 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
246 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
247
4fc97074eb90 Added 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 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
249
4fc97074eb90 Added 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 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
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 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
253 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
254 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
255 }
4fc97074eb90 Added 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 }
4fc97074eb90 Added 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 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
260 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
261 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
262 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
263 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
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 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
266 {
4fc97074eb90 Added 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 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
268 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
269 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
270 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
271 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
272 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
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 }
4fc97074eb90 Added 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 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
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 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
278 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
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 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
283 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
284 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
285 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
286
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
287 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
288 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
289 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
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 }
4fc97074eb90 Added 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
4fc97074eb90 Added 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 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
294 // 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
295 // 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
296 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
297 (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
298 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
299 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
300 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
301 ? 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
302 : 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
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 * @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
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 @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
309 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
310 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
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 // 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
313 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
314 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
315 // 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
316 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
317
4fc97074eb90 Added 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 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
319 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
320 }
4fc97074eb90 Added 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
4fc97074eb90 Added 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 = 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
323
4fc97074eb90 Added 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 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
325 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
326 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
327 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
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 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
331 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
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 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
334 }
4fc97074eb90 Added 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
4fc97074eb90 Added 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 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
338 } // 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 }.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
340 }
4fc97074eb90 Added 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 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
343 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
344 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
345 shapeFilePath = null;
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
346 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
347 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
348 }
4fc97074eb90 Added Support for writing Shapefiles and Export them as an Zipfile for the Product Layer.
Tim Englich <tim.englich@intevation.de>
parents: 616
diff changeset
349 }
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
350 protected Document getWMS(String uuid,
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
351 CallContext callContext,
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
352 Collection<Result> data)
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
353 throws StateException
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
354 {
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
355 // TODO: Do the real WMS publishing here!
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
356 Document document = XMLUtils.newDocument();
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
357
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
358 Element pathElement = document.createElement("path");
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
359 document.appendChild(pathElement);
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
360
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
361 String path = getShapeFilePath();
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
362
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
363 if (path != null && new File(path).isDirectory()) {
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
364 pathElement.setTextContent(path);
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
365 }
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
366 else {
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
367
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
368 if (data != null &&
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
369 (path = writeToShapeFile(uuid, data, callContext)) != null) {
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
370
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
371 String paramType = LAYER_MODEL+"_"+this.geometryType.toLowerCase();
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
372
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
373 Document meta = MetaWriter.writeLayerMeta(callContext, uuid,
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
374 path, paramType,
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
375 this.determineGeometryType());
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
376 if (meta != null) {
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
377 MapfileGenerator.getInstance().update();
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
378 return meta;
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
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
381 pathElement.setTextContent(path);
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 }
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
384
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
385 return document;
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
386 }
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
387
655
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
388 private String determineGeometryType(){
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
389
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
390 String returnValue = this.geometryType.toLowerCase();
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 if (returnValue.equalsIgnoreCase("linestring")){
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
393 returnValue = "Line";
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
394 }
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
395 return returnValue;
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
396 }
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
397
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
398 private static Map<Integer, PaletteManager> getPalettes(
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
399 CallContext callContext
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 //TODO: customize for product Layer
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
402 GNVArtifactContext context =
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
403 (GNVArtifactContext)callContext.globalContext();
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
404 Map<Integer, PaletteManager> palettes =
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
405 (Map<Integer, PaletteManager>)context.get(
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
406 GNVArtifactContext.PALETTES_KEY);
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
407 return palettes != null
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
408 ? palettes
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
409 : new HashMap<Integer, PaletteManager>();
6eccb68a8b99 Added WMS-Publishing to Product Layer
Tim Englich <tim.englich@intevation.de>
parents: 649
diff changeset
410 }
616
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
411
93978859fa9e Added the Configuration and the Classes for the new Product Layer.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
412 }

http://dive4elements.wald.intevation.org