VirtualTable support - add encoders
This commit is contained in:
parent
3ee4e30040
commit
755cf4479e
@ -27,6 +27,7 @@ package it.geosolutions.geoserver.rest.encoder.feature;
|
|||||||
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSFeatureDimensionInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSFeatureDimensionInfoEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSVirtualTableEncoder;
|
||||||
|
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
|
||||||
@ -51,15 +52,67 @@ public class GSFeatureTypeEncoder extends GSResourceEncoder {
|
|||||||
/**
|
/**
|
||||||
* @param key
|
* @param key
|
||||||
* @param dimensionInfo
|
* @param dimensionInfo
|
||||||
|
*
|
||||||
|
* @deprecated Replaced by
|
||||||
|
* {@link #addMetadataDimension(String, GSFeatureDimensionInfoEncoder)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
protected void addMetadata(String key, GSFeatureDimensionInfoEncoder dimensionInfo) {
|
protected void addMetadata(String key, GSFeatureDimensionInfoEncoder dimensionInfo) {
|
||||||
super.addMetadata(key, dimensionInfo);
|
super.addMetadata(key, dimensionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* @param dimensionInfo
|
||||||
|
*/
|
||||||
|
protected void addMetadataDimension(String key, GSFeatureDimensionInfoEncoder dimensionInfo) {
|
||||||
|
super.addMetadata(key, dimensionInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* @param dimensionInfo
|
||||||
|
*
|
||||||
|
* @deprecated Replaced by
|
||||||
|
* {@link #setMetadataDimension(String, GSFeatureDimensionInfoEncoder)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setMetadata(String key, GSFeatureDimensionInfoEncoder dimensionInfo) {
|
public void setMetadata(String key, GSFeatureDimensionInfoEncoder dimensionInfo) {
|
||||||
super.setMetadata(key, dimensionInfo);
|
super.setMetadata(key, dimensionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* @param dimensionInfo
|
||||||
|
*/
|
||||||
|
public void setMetadataDimension(String key, GSFeatureDimensionInfoEncoder dimensionInfo) {
|
||||||
|
super.setMetadata(key, dimensionInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a VirtualTable (SQL View feature type)
|
||||||
|
*
|
||||||
|
* @param virtualtable
|
||||||
|
*/
|
||||||
|
protected void addMetadataVirtualTable(
|
||||||
|
final GSVirtualTableEncoder virtualtable) {
|
||||||
|
super.addMetadata("JDBC_VIRTUAL_TABLE", virtualtable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a VirtualTable (SQL View feature type)
|
||||||
|
*
|
||||||
|
* @param virtualtable
|
||||||
|
*/
|
||||||
|
public void setMetadataVirtualTable(final GSVirtualTableEncoder virtualtable) {
|
||||||
|
super.setMetadata("JDBC_VIRTUAL_TABLE", virtualtable);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete a keyword from the list
|
* delete a keyword from the list
|
||||||
*
|
*
|
||||||
|
|||||||
@ -0,0 +1,199 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package it.geosolutions.geoserver.rest.encoder.metadata;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.utils.PropertyXMLEncoder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GSVirtualTableEncoder - Encodes a metadata VirtualTable for a GeoServer
|
||||||
|
* featureType, as follows:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* {
|
||||||
|
* @code
|
||||||
|
* // Set-up the vtGeom
|
||||||
|
* final GSVirtualTableGeomEncoder vtGeom = new GSVirtualTableGeomEncoder();
|
||||||
|
* vtGeom.setup("the_geom", "MultiPolygon", "4326");
|
||||||
|
*
|
||||||
|
* // Set-up 2 virtual table parameters
|
||||||
|
* final GSVirtualTableParamEncoder vtParam1 = new GSVirtualTableParamEncoder();
|
||||||
|
* vtParam1.setup("fieldname1", "default_value1", "^[\\w\\d\\s]+$");
|
||||||
|
* final GSVirtualTableParamEncoder vtParam2 = new GSVirtualTableParamEncoder();
|
||||||
|
* vtParam2.setup("fieldname2", "default_value2", "^[\\w\\d\\s]+$");
|
||||||
|
*
|
||||||
|
* // sql
|
||||||
|
* String sql = "select the_geom, id, field1, field2 from mytable where field1 = '%fieldname1%' and field2 = '%fieldname2%'";
|
||||||
|
*
|
||||||
|
* // Set-up the virtual table
|
||||||
|
* final GSVirtualTableEncoder vte = new GSVirtualTableEncoder();
|
||||||
|
* vte.setup("mysqlview", sql, Arrays.asList("id"), Arrays.asList(vtGeom),
|
||||||
|
* Arrays.asList(vtParam1, vtParam2));
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* For this example, the XML output is:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* {@code
|
||||||
|
* <virtualTable>
|
||||||
|
* <name>mysqlview</name>
|
||||||
|
* <sql>select the_geom, id, field1, field2 from mytable where field1 = '%fieldname1%' and field2 = '%fieldname2%'</sql>
|
||||||
|
* <keyColumn>id</keyColumn>
|
||||||
|
* <geometry>
|
||||||
|
* <name>the_geom</name>
|
||||||
|
* <type>MultiPolygon</type>
|
||||||
|
* <srid>4326</srid>
|
||||||
|
* </geometry>
|
||||||
|
* <parameter>
|
||||||
|
* <name>fieldname1</name>
|
||||||
|
* <defaultValue>default_value1</defaultValue>
|
||||||
|
* <regexpValidator>^[\w\d\s]+$</regexpValidator>
|
||||||
|
* </parameter>
|
||||||
|
* <parameter>
|
||||||
|
* <name>fieldname2</name>
|
||||||
|
* <defaultValue>default_value2</defaultValue>
|
||||||
|
* <regexpValidator>^[\w\d\s]+$</regexpValidator>
|
||||||
|
* </parameter>
|
||||||
|
* </virtualTable>
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com |
|
||||||
|
* emmanuel.blondel@fao.org
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GSVirtualTableEncoder extends PropertyXMLEncoder {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String sql;
|
||||||
|
private List<String> keyColumns;
|
||||||
|
private List<GSVirtualTableGeomEncoder> geomEncList;
|
||||||
|
private List<GSVirtualTableParamEncoder> paramEncList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a GSVirtualTableEncoder
|
||||||
|
*/
|
||||||
|
public GSVirtualTableEncoder() {
|
||||||
|
super("virtualTable");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set-up quickly a GSVirtualTableEncoder. This unique entry point to set-up
|
||||||
|
* is aimed to ensure that the order of metadata elements is well
|
||||||
|
* maintained, and avoid errors at publication time in Geoserver.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* (must be the same as the featureType name)
|
||||||
|
* @param sql
|
||||||
|
* @param keyColumns
|
||||||
|
* @param geomEncList
|
||||||
|
* @param paramEncList
|
||||||
|
*/
|
||||||
|
public void setup(String name, String sql, List<String> keyColumns,
|
||||||
|
List<GSVirtualTableGeomEncoder> geomEncList,
|
||||||
|
List<GSVirtualTableParamEncoder> paramEncList) {
|
||||||
|
|
||||||
|
this.getRoot().removeContent();
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
this.sql = sql;
|
||||||
|
set("name", this.name);
|
||||||
|
set("sql", this.sql);
|
||||||
|
|
||||||
|
if (keyColumns != null) {
|
||||||
|
this.keyColumns = new ArrayList<String>();
|
||||||
|
this.keyColumns.addAll(keyColumns);
|
||||||
|
for (String pk : this.keyColumns) {
|
||||||
|
add("keyColumn", pk);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (geomEncList != null) {
|
||||||
|
this.geomEncList = new ArrayList<GSVirtualTableGeomEncoder>();
|
||||||
|
this.geomEncList.addAll(geomEncList);
|
||||||
|
for (GSVirtualTableGeomEncoder geomEnc : this.geomEncList) {
|
||||||
|
addContent(geomEnc.getRoot());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paramEncList != null) {
|
||||||
|
this.paramEncList = new ArrayList<GSVirtualTableParamEncoder>();
|
||||||
|
this.paramEncList.addAll(paramEncList);
|
||||||
|
for (GSVirtualTableParamEncoder paramEnc : this.paramEncList) {
|
||||||
|
addContent(paramEnc.getRoot());
|
||||||
|
}
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get Name
|
||||||
|
*
|
||||||
|
* @return the name of the virtual table
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get SQL query
|
||||||
|
*
|
||||||
|
* @return the sql query of the virtual table
|
||||||
|
*/
|
||||||
|
public String getSql() {
|
||||||
|
return this.sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the list of GSVirtualTableGeomEncoder
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<GSVirtualTableGeomEncoder> getVirtualTableGeomEncoderList() {
|
||||||
|
return this.geomEncList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the list of VirtualTableParamEncoder
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<GSVirtualTableParamEncoder> getVirtualTableParamEncoderList() {
|
||||||
|
return this.paramEncList;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO (eventually) utils method to check consistency between SQL view
|
||||||
|
// params provided by the sql string
|
||||||
|
// and the virtual table parameters set up in parallel
|
||||||
|
public boolean checkVirtualTableParams() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package it.geosolutions.geoserver.rest.encoder.metadata;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.utils.ElementUtils;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.utils.PropertyXMLEncoder;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.jdom.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GSVirtualTableGeomEncoder - Encodes a metadata VirtualTable geometry for a
|
||||||
|
* GeoServer featureType, as follows:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* {
|
||||||
|
* @code
|
||||||
|
* final GSVirtualTableGeomEncoder vtGeom = new GSVirtualTableGeomEncoder();
|
||||||
|
* vtGeom.setup("the_geom", "MultiPolygon", "4326");
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* For this example, the XML output is:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* {@code
|
||||||
|
* <geometry>
|
||||||
|
* <name>the_geom</name>
|
||||||
|
* <type>MultiPolygon</type>
|
||||||
|
* <srid>4326</srid>
|
||||||
|
* </geometry>
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com |
|
||||||
|
* emmanuel.blondel@fao.org
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GSVirtualTableGeomEncoder extends PropertyXMLEncoder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a GSVirtualTableGeomEncoder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public GSVirtualTableGeomEncoder() {
|
||||||
|
super("geometry");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set-up quickly a GSVirtualTableGeomEncoder
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @param geometryType
|
||||||
|
* @param srid
|
||||||
|
*/
|
||||||
|
public void setup(String name, String geometryType, String srid) {
|
||||||
|
set(VirtualTableGeometry.name.name(), name);
|
||||||
|
set(VirtualTableGeometry.type.name(), geometryType);
|
||||||
|
set(VirtualTableGeometry.srid.name(), srid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set-up a GSVirtualTableGeomEncoder
|
||||||
|
*
|
||||||
|
* @param vtGeometryMembers
|
||||||
|
*/
|
||||||
|
public void setup(Map<VirtualTableGeometry, String> vtGeometryMembers) {
|
||||||
|
for (Entry<VirtualTableGeometry, String> vtGeomMember : vtGeometryMembers
|
||||||
|
.entrySet()) {
|
||||||
|
set(vtGeomMember.getKey().toString(), vtGeomMember.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a VirtualTable Geometry member
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
public void setVirtualTableGeometryMember(VirtualTableGeometry type,
|
||||||
|
String value) {
|
||||||
|
set(type.toString(), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a VirtualTableGeometry member
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean delVirtualTableGeometryMember(VirtualTableGeometry type) {
|
||||||
|
return ElementUtils.remove(this.getRoot(), get(type.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the VirtualTableGeometry member value
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getVirtualTableGeometryMember(VirtualTableGeometry type) {
|
||||||
|
Element el = get(type.toString());
|
||||||
|
if (el != null)
|
||||||
|
return el.getTextTrim();
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,131 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package it.geosolutions.geoserver.rest.encoder.metadata;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.utils.ElementUtils;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.utils.PropertyXMLEncoder;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.jdom.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GSVirtualTableParamEncoder - Encodes a metadata VirtualTable parameter for a
|
||||||
|
* GeoServer featureType, as follows:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* {
|
||||||
|
* @code
|
||||||
|
* final GSVirtualTableParamEncoder vtParam = new GSVirtualTableParamEncoder();
|
||||||
|
* vtParam.setup("fieldname", "default_value", "^[\\w\\d\\s]+$");
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* For this example, the XML output is:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* {@code
|
||||||
|
* <parameter>
|
||||||
|
* <name>fieldname</name>
|
||||||
|
* <defaultValue>default_value</defaultValue>
|
||||||
|
* <regexpValidator>^[\w\d\s]+$</regexpValidator>
|
||||||
|
* </parameter>
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com |
|
||||||
|
* emmanuel.blondel@fao.org
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GSVirtualTableParamEncoder extends PropertyXMLEncoder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a GSVirtualTableParamEncoder
|
||||||
|
*/
|
||||||
|
public GSVirtualTableParamEncoder() {
|
||||||
|
super("parameter");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set-up quickly a VirtualTable parameter
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @param defaultValue
|
||||||
|
* @param regexpValidator
|
||||||
|
*/
|
||||||
|
public void setup(String name, String defaultValue, String regexpValidator) {
|
||||||
|
set(VirtualTableParameter.name.name(), name);
|
||||||
|
set(VirtualTableParameter.defaultValue.name(), defaultValue);
|
||||||
|
set(VirtualTableParameter.regexpValidator.name(), regexpValidator);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set-up a VirtualTable parameter
|
||||||
|
*
|
||||||
|
* @param vtParamMembers
|
||||||
|
*/
|
||||||
|
public void setup(Map<VirtualTableParameter, String> vtParamMembers) {
|
||||||
|
for (Entry<VirtualTableParameter, String> vtParamMember : vtParamMembers
|
||||||
|
.entrySet()) {
|
||||||
|
set(vtParamMember.getKey().toString(), vtParamMember.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a VirtualTableParameter member
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
public void setVirtualTableParamMember(VirtualTableParameter type,
|
||||||
|
String value) {
|
||||||
|
set(type.toString(), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a VirtualTableParameter member
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean delVirtualTableParamMember(VirtualTableParameter type) {
|
||||||
|
return ElementUtils.remove(this.getRoot(), get(type.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a VirtualTableParameter member
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getVirtualTableParamMember(VirtualTableParameter type) {
|
||||||
|
Element el = get(type.toString());
|
||||||
|
if (el != null)
|
||||||
|
return el.getTextTrim();
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package it.geosolutions.geoserver.rest.encoder.metadata;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumeration of Virtual Table geometry members
|
||||||
|
*
|
||||||
|
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com |
|
||||||
|
* emmanuel.blondel@fao.org
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum VirtualTableGeometry {
|
||||||
|
name, type, srid
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
|
||||||
|
* http://www.geo-solutions.it
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package it.geosolutions.geoserver.rest.encoder.metadata;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumeration of SQL View featureType virtual table parameter members
|
||||||
|
*
|
||||||
|
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com |
|
||||||
|
* emmanuel.blondel@fao.org
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum VirtualTableParameter {
|
||||||
|
name, defaultValue, regexpValidator
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user