Mercurial > dive4elements > gnv-client
changeset 728:f6630d0203da
Put all Attributes of the Databasetables into the Shapefile which will be produced for the Product Layer
gnv-artifacts/trunk@764 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Fri, 12 Mar 2010 11:36:38 +0000 |
parents | 22dc921cd8b1 |
children | d23ad22bcfe7 |
files | gnv-artifacts/ChangeLog gnv-artifacts/doc/conf/products/layer/conf.xml gnv-artifacts/doc/conf/queries.properties gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java |
diffstat | 4 files changed, 65 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog Fri Mar 12 11:28:36 2010 +0000 +++ b/gnv-artifacts/ChangeLog Fri Mar 12 11:36:38 2010 +0000 @@ -1,3 +1,18 @@ +2010-03-12 Tim Englich <tim.englich@intevation.de> + + * src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java (fetchColumns): + Integrated an Method for fetching all required Columns for an given Layer + and put them into the Query witch will load the Layerdata from the + Database. + + * doc/conf/products/layer/conf.xml: + Added an Configuration-Element to determine the Query which should be used + to Query the Columns of a choosen Layer. + + * doc/conf/queries.properties: + Manipulated the Queries for fetching the Layerdata in that way that it is + possible to put the requested-Columns into it using the ?-Syntax. + 2010-03-12 Tim Englich <tim.englich@intevation.de> * src/main/java/de/intevation/gnv/utils/ShapeFileWriter.java (writeDataToFile):
--- a/gnv-artifacts/doc/conf/products/layer/conf.xml Fri Mar 12 11:28:36 2010 +0000 +++ b/gnv-artifacts/doc/conf/products/layer/conf.xml Fri Mar 12 11:36:38 2010 +0000 @@ -91,6 +91,7 @@ <queryID>layer_request_data</queryID> <queryID-layerdata>layer_data_with_geom</queryID-layerdata> <queryID-geometry>geometry_for_subareafilter</queryID-geometry> + <queryID-columns>layer_colums</queryID-columns> <inputvalue-geometry>subareaid</inputvalue-geometry> <inputvalues> <inputvalue name="sourceid" type="String" multiselect="false" usedinquery="0"/>
--- a/gnv-artifacts/doc/conf/queries.properties Fri Mar 12 11:28:36 2010 +0000 +++ b/gnv-artifacts/doc/conf/queries.properties Fri Mar 12 11:36:38 2010 +0000 @@ -1233,11 +1233,11 @@ FROM MEDIAN.LAYER_HAS_SUBTYPES \ WHERE ROW_ID = ? -layer_data = SELECT ST_ASTEXT(SHAPE) \ +layer_data = SELECT ST_ASTEXT(SHAPE), ? \ FROM ? \ WHERE ? -layer_data_with_geom = SELECT ST_ASTEXT(SHAPE) \ +layer_data_with_geom = SELECT ST_ASTEXT(SHAPE), ? \ FROM ? \ WHERE ? AND \ INTERSECTS(SHAPE,"?") @@ -1246,3 +1246,9 @@ FROM MEDIAN.FEATUREAREA \ WHERE (FEATURETYPE = 7 OR FEATURETYPE = 8) AND \ FEATURECODE = ? + +layer_colums= SELECT COLUMN_NAME \ + FROM SDE.COLUMN_REGISTRY \ + WHERE COLUMN_NAME NOT LIKE 'SHAPE' AND \ + OWNER = '?' AND \ + TABLE_NAME = '?'
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java Fri Mar 12 11:28:36 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java Fri Mar 12 11:36:38 2010 +0000 @@ -7,9 +7,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Collection; -import java.util.HashMap; import java.util.Iterator; -import java.util.Map; import org.apache.log4j.Logger; import org.w3c.dom.Document; @@ -29,7 +27,6 @@ import de.intevation.gnv.geobackend.base.query.QueryExecutor; import de.intevation.gnv.geobackend.base.query.QueryExecutorFactory; import de.intevation.gnv.geobackend.base.query.exception.QueryException; -import de.intevation.gnv.raster.PaletteManager; import de.intevation.gnv.state.InputData; import de.intevation.gnv.state.OutputStateBase; import de.intevation.gnv.state.exception.StateException; @@ -69,6 +66,8 @@ */ private String geometryQueryID = null; + private String columnQueryID = null; + /** * The ID for the Value which will hold the Geometrie-Value */ @@ -152,6 +151,8 @@ Result resultValue = it.next(); String table = resultValue.getString(0); String where = resultValue.getString(1); + String columns = this.fetchColumns(table); + templateID = resultValue.getString(2); if (this.geometryID != null){ InputData geometryInputData = @@ -171,16 +172,17 @@ log.error(e,e); // TODO: what should happen?? } - queryValues = new String[]{table, + queryValues = new String[]{columns, + table, where, geometryWKT}; }else{ // TODO: Look into the presetting for an WKT - queryValues = new String[]{table,where}; + queryValues = new String[]{columns,table,where}; } }else{ // TODO: Look into the presetting for an WKT - queryValues = new String[]{table,where}; + queryValues = new String[]{columns,table,where}; } } @@ -221,6 +223,36 @@ return data; } + private String fetchColumns(String tableName){ + String returnValue = null; + try { + String[] filter = tableName.toUpperCase().split("\\."); + QueryExecutor queryExecutor = QueryExecutorFactory.getInstance() + .getQueryExecutor(); + + Collection<Result> columnData = queryExecutor. + executeQuery(this.columnQueryID, + filter); + if (columnData != null && !columnData.isEmpty()){ + StringBuffer sb = new StringBuffer(); + synchronized (sb) { + Iterator<Result> it = columnData.iterator(); + while(it.hasNext()){ + Result current = it.next(); + sb.append(current.getString(0)); + if (it.hasNext()){ + sb.append(" , "); + } + } + } + returnValue = sb.toString(); + } + + } catch (QueryException e) { + log.error(e,e); + } + return returnValue; + } @Override public void setup(Node configuration) { log.debug("LayerOutputState.setup"); @@ -231,6 +263,9 @@ "inputvalue-geometry"); this.geometryQueryID = Config.getStringXPath(configuration, "queryID-geometry"); + + this.columnQueryID = "layer_colums"; //Config.getStringXPath(configuration, + // "queryID-columns"); } protected String writeToShapeFile( @@ -423,19 +458,4 @@ } return returnValue; } - - private static Map<Integer, PaletteManager> getPalettes( - CallContext callContext - ) { - //TODO: customize for product Layer - GNVArtifactContext context = - (GNVArtifactContext)callContext.globalContext(); - Map<Integer, PaletteManager> palettes = - (Map<Integer, PaletteManager>)context.get( - GNVArtifactContext.PALETTES_KEY); - return palettes != null - ? palettes - : new HashMap<Integer, PaletteManager>(); - } - }