fix GSCoverageEncoder. fix integration some test. TODO run integration tests.
This commit is contained in:
parent
1c60c1d94a
commit
0f833b2664
@ -43,8 +43,9 @@ import org.jdom.Namespace;
|
|||||||
* Parse a resource (FeatureType or Coverage) returned as XML REST objects.
|
* Parse a resource (FeatureType or Coverage) returned as XML REST objects.
|
||||||
*
|
*
|
||||||
* @author etj
|
* @author etj
|
||||||
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com |
|
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com | emmanuel.blondel@fao.org
|
||||||
* emmanuel.blondel@fao.org
|
* @author Henry Rotzoll
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class RESTResource {
|
public class RESTResource {
|
||||||
protected final Element rootElem;
|
protected final Element rootElem;
|
||||||
@ -74,15 +75,15 @@ public class RESTResource {
|
|||||||
return rootElem.getChildText("abstract");
|
return rootElem.getChildText("abstract");
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getKeywords(){
|
public List<String> getKeywords() {
|
||||||
List<String> kwdsList = null;
|
List<String> kwdsList = null;
|
||||||
|
|
||||||
final Element keywordsRoot = rootElem.getChild("keywords");
|
final Element keywordsRoot = rootElem.getChild("keywords");
|
||||||
if(keywordsRoot != null){
|
if (keywordsRoot != null) {
|
||||||
final List<Element> keywords = keywordsRoot.getChildren();
|
final List<Element> keywords = keywordsRoot.getChildren();
|
||||||
if(keywords != null){
|
if (keywords != null) {
|
||||||
kwdsList = new ArrayList<String>(keywords.size());
|
kwdsList = new ArrayList<String>(keywords.size());
|
||||||
for(Element keyword : keywords){
|
for (Element keyword : keywords) {
|
||||||
kwdsList.add(keyword.getValue());
|
kwdsList.add(keyword.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,7 +91,6 @@ public class RESTResource {
|
|||||||
return kwdsList;
|
return kwdsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getNameSpace() {
|
public String getNameSpace() {
|
||||||
return rootElem.getChild("namespace").getChildText("name");
|
return rootElem.getChild("namespace").getChildText("name");
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ public class RESTResource {
|
|||||||
/**
|
/**
|
||||||
* Decodes the list of MetadataLinkInfo from the GeoServer Resource
|
* Decodes the list of MetadataLinkInfo from the GeoServer Resource
|
||||||
*
|
*
|
||||||
* @author Emmanuel Blondel
|
* @since gs-2.4.x
|
||||||
*
|
*
|
||||||
* @return the list of GSMetadataLinkEncoder
|
* @return the list of GSMetadataLinkEncoder
|
||||||
*/
|
*/
|
||||||
@ -165,16 +165,18 @@ public class RESTResource {
|
|||||||
List<GSMetadataLinkInfoEncoder> metaLinksList = null;
|
List<GSMetadataLinkInfoEncoder> metaLinksList = null;
|
||||||
|
|
||||||
final Element metaLinksRoot = rootElem.getChild("metadataLinks");
|
final Element metaLinksRoot = rootElem.getChild("metadataLinks");
|
||||||
if(metaLinksRoot!=null){
|
if (metaLinksRoot != null) {
|
||||||
final List<Element> metaLinks = metaLinksRoot.getChildren();
|
final List<Element> metaLinks = metaLinksRoot.getChildren();
|
||||||
if (metaLinks != null) {
|
if (metaLinks != null) {
|
||||||
metaLinksList = new ArrayList<GSMetadataLinkInfoEncoder>(
|
metaLinksList = new ArrayList<GSMetadataLinkInfoEncoder>(metaLinks.size());
|
||||||
metaLinks.size());
|
|
||||||
for (Element metaLink : metaLinks) {
|
for (Element metaLink : metaLinks) {
|
||||||
final GSMetadataLinkInfoEncoder metaLinkEnc = new GSMetadataLinkInfoEncoder();
|
final GSMetadataLinkInfoEncoder metaLinkEnc = new GSMetadataLinkInfoEncoder();
|
||||||
metaLinkEnc.setType(metaLink.getChildText(ResourceMetadataLinkInfo.type.name()));
|
metaLinkEnc
|
||||||
metaLinkEnc.setMetadataType(metaLink.getChildText(ResourceMetadataLinkInfo.metadataType.name()));
|
.setType(metaLink.getChildText(ResourceMetadataLinkInfo.type.name()));
|
||||||
metaLinkEnc.setContent(metaLink.getChildText(ResourceMetadataLinkInfo.content.name()));
|
metaLinkEnc.setMetadataType(metaLink
|
||||||
|
.getChildText(ResourceMetadataLinkInfo.metadataType.name()));
|
||||||
|
metaLinkEnc.setContent(metaLink.getChildText(ResourceMetadataLinkInfo.content
|
||||||
|
.name()));
|
||||||
metaLinksList.add(metaLinkEnc);
|
metaLinksList.add(metaLinkEnc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,41 +188,37 @@ public class RESTResource {
|
|||||||
/**
|
/**
|
||||||
* Decodes the list of GSCoverageDimensionEncoder from the GeoServer Resource
|
* Decodes the list of GSCoverageDimensionEncoder from the GeoServer Resource
|
||||||
*
|
*
|
||||||
* @author Henry Rotzoll
|
* @since gs-2.4.x
|
||||||
*
|
*
|
||||||
* @return the list of GSCoverageDimensionEncoder
|
* @return the list of GSCoverageDimensionEncoder
|
||||||
*/
|
*/
|
||||||
public List<GSCoverageDimensionEncoder> getEncodedDimensionsInfoList()
|
public List<GSCoverageDimensionEncoder> getEncodedDimensionsInfoList() {
|
||||||
{
|
|
||||||
List<GSCoverageDimensionEncoder> dimensionList = null;
|
List<GSCoverageDimensionEncoder> dimensionList = null;
|
||||||
final Element dimensionsRoot = rootElem.getChild("dimensions");
|
final Element dimensionsRoot = rootElem.getChild("dimensions");
|
||||||
|
|
||||||
if(dimensionsRoot!=null)
|
if (dimensionsRoot != null) {
|
||||||
{
|
|
||||||
final List<Element> dimensions = dimensionsRoot.getChildren();
|
final List<Element> dimensions = dimensionsRoot.getChildren();
|
||||||
if (dimensions != null)
|
if (dimensions != null) {
|
||||||
{
|
|
||||||
dimensionList = new ArrayList<GSCoverageDimensionEncoder>(dimensions.size());
|
dimensionList = new ArrayList<GSCoverageDimensionEncoder>(dimensions.size());
|
||||||
for (Element coverageDimension : dimensions)
|
for (Element coverageDimension : dimensions) {
|
||||||
{
|
|
||||||
final String name = coverageDimension.getChildText("name");
|
final String name = coverageDimension.getChildText("name");
|
||||||
final String description = coverageDimension.getChildText("description");
|
final String description = coverageDimension.getChildText("description");
|
||||||
String rangeMin = null;
|
String rangeMin = null;
|
||||||
String rangeMax = null;
|
String rangeMax = null;
|
||||||
final Element rangeElement = coverageDimension.getChild("range");
|
final Element rangeElement = coverageDimension.getChild("range");
|
||||||
if(rangeElement != null)
|
if (rangeElement != null) {
|
||||||
{
|
|
||||||
rangeMin = rangeElement.getChildText("min");
|
rangeMin = rangeElement.getChildText("min");
|
||||||
rangeMax = rangeElement.getChildText("max");
|
rangeMax = rangeElement.getChildText("max");
|
||||||
}
|
}
|
||||||
final String unit = coverageDimension.getChildText("unit");
|
final String unit = coverageDimension.getChildText("unit");
|
||||||
String dimensionTypeName = null;
|
String dimensionTypeName = null;
|
||||||
final Element dimensionTypeElement = coverageDimension.getChild("dimensionType");
|
final Element dimensionTypeElement = coverageDimension
|
||||||
if(dimensionTypeElement != null)
|
.getChild("dimensionType");
|
||||||
{
|
if (dimensionTypeElement != null) {
|
||||||
dimensionTypeName = dimensionTypeElement.getChildText("name");
|
dimensionTypeName = dimensionTypeElement.getChildText("name");
|
||||||
}
|
}
|
||||||
final GSCoverageDimensionEncoder coverageDimensionEncoder = new GSCoverageDimensionEncoder(name, description, rangeMin, rangeMax, unit, dimensionTypeName);
|
final GSCoverageDimensionEncoder coverageDimensionEncoder = new GSCoverageDimensionEncoder(
|
||||||
|
name, description, rangeMin, rangeMax, unit, dimensionTypeName);
|
||||||
dimensionList.add(coverageDimensionEncoder);
|
dimensionList.add(coverageDimensionEncoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,6 @@
|
|||||||
package it.geosolutions.geoserver.rest.encoder;
|
package it.geosolutions.geoserver.rest.encoder;
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.coverage.GSCoverageEncoder;
|
import it.geosolutions.geoserver.rest.encoder.coverage.GSCoverageEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.dimensions.GSCoverageDimensionEncoder;
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder;
|
import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSFeatureDimensionInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSFeatureDimensionInfoEncoder;
|
||||||
@ -48,32 +47,34 @@ import org.jdom.filter.Filter;
|
|||||||
*
|
*
|
||||||
* @author ETj (etj at geo-solutions.it)
|
* @author ETj (etj at geo-solutions.it)
|
||||||
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||||
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com |
|
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com | emmanuel.blondel@fao.org
|
||||||
* emmanuel.blondel@fao.org
|
* @author Henry Rotzoll
|
||||||
*/
|
*/
|
||||||
public abstract class GSResourceEncoder
|
public abstract class GSResourceEncoder extends PropertyXMLEncoder {
|
||||||
extends PropertyXMLEncoder {
|
|
||||||
public final static String NAME = "name";
|
public final static String NAME = "name";
|
||||||
|
|
||||||
public final static String NATIVENAME = "nativeName";
|
public final static String NATIVENAME = "nativeName";
|
||||||
public final static String METADATA="metadata";
|
|
||||||
public final static String KEYWORDS="keywords";
|
public final static String METADATA = "metadata";
|
||||||
public final static String METADATALINKS="metadataLinks";
|
|
||||||
public final static String DIMENSIONS="dimensions";
|
public final static String KEYWORDS = "keywords";
|
||||||
|
|
||||||
|
public final static String METADATALINKS = "metadataLinks";
|
||||||
|
|
||||||
final private GSMetadataEncoder metadata = new GSMetadataEncoder();
|
final private GSMetadataEncoder metadata = new GSMetadataEncoder();
|
||||||
final private Element keywordsListEncoder = new Element(KEYWORDS);
|
|
||||||
final private Element metadataLinksListEncoder = new Element(METADATALINKS);
|
|
||||||
final private Element dimensionsEncoder = new Element(DIMENSIONS);
|
|
||||||
|
|
||||||
private class GSMetadataEncoder extends NestedElementEncoder{
|
final private Element keywordsListEncoder = new Element(KEYWORDS);
|
||||||
|
|
||||||
|
final private Element metadataLinksListEncoder = new Element(METADATALINKS);
|
||||||
|
|
||||||
|
private class GSMetadataEncoder extends NestedElementEncoder {
|
||||||
public GSMetadataEncoder() {
|
public GSMetadataEncoder() {
|
||||||
super(METADATA);
|
super(METADATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param rootName
|
* @param rootName Actually 'feature' or 'coverage'
|
||||||
* Actually 'feature' or 'coverage'
|
|
||||||
* @see GSFeatureTypeEncoder
|
* @see GSFeatureTypeEncoder
|
||||||
* @see GSCoverageEncoder
|
* @see GSCoverageEncoder
|
||||||
*/
|
*/
|
||||||
@ -91,7 +92,6 @@ public abstract class GSResourceEncoder
|
|||||||
set("enabled", (enabled) ? "true" : "false");
|
set("enabled", (enabled) ? "true" : "false");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param key
|
* @param key
|
||||||
* @param dimensionInfo
|
* @param dimensionInfo
|
||||||
@ -124,10 +124,11 @@ public abstract class GSResourceEncoder
|
|||||||
* @param dimensionInfo {@link GSDimensionInfoEncoder} with additional information about the dimension
|
* @param dimensionInfo {@link GSDimensionInfoEncoder} with additional information about the dimension
|
||||||
* @param custom is the dimension custom or not?
|
* @param custom is the dimension custom or not?
|
||||||
*/
|
*/
|
||||||
protected void addMetadataDimension(String key, GSDimensionInfoEncoder dimensionInfo, boolean custom) {
|
protected void addMetadataDimension(String key, GSDimensionInfoEncoder dimensionInfo,
|
||||||
if(custom){
|
boolean custom) {
|
||||||
metadata.set("custom_dimension_"+key.toUpperCase(), dimensionInfo.getRoot());
|
if (custom) {
|
||||||
}else{
|
metadata.set("custom_dimension_" + key.toUpperCase(), dimensionInfo.getRoot());
|
||||||
|
} else {
|
||||||
metadata.add(key, dimensionInfo.getRoot());
|
metadata.add(key, dimensionInfo.getRoot());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,23 +148,23 @@ public abstract class GSResourceEncoder
|
|||||||
* @param dimensionInfo {@link GSDimensionInfoEncoder} with additional information about the dimension
|
* @param dimensionInfo {@link GSDimensionInfoEncoder} with additional information about the dimension
|
||||||
* @param custom is the dimension custom or not?
|
* @param custom is the dimension custom or not?
|
||||||
*/
|
*/
|
||||||
public void setMetadataDimension(String key, GSDimensionInfoEncoder dimensionInfo, boolean custom) {
|
public void setMetadataDimension(String key, GSDimensionInfoEncoder dimensionInfo,
|
||||||
if(custom){
|
boolean custom) {
|
||||||
metadata.set("custom_dimension_"+key.toUpperCase(), dimensionInfo.getRoot());
|
if (custom) {
|
||||||
}else{
|
metadata.set("custom_dimension_" + key.toUpperCase(), dimensionInfo.getRoot());
|
||||||
|
} else {
|
||||||
metadata.set(key, dimensionInfo.getRoot());
|
metadata.set(key, dimensionInfo.getRoot());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param key
|
* @param key the name of the metadata to add (f.e.: elevation, time)
|
||||||
* the name of the metadata to add (f.e.: elevation, time)
|
|
||||||
* @return true if something is removed, false otherwise
|
* @return true if something is removed, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean delMetadata(String key) {
|
public boolean delMetadata(String key) {
|
||||||
return metadata.remove(key);
|
return metadata.remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addKeyword(String keyword) {
|
public void addKeyword(String keyword) {
|
||||||
final Element el = new Element("string");
|
final Element el = new Element("string");
|
||||||
el.setText(keyword);
|
el.setText(keyword);
|
||||||
@ -196,7 +197,6 @@ public abstract class GSResourceEncoder
|
|||||||
*
|
*
|
||||||
* @param MetadataLink
|
* @param MetadataLink
|
||||||
*
|
*
|
||||||
* @author Emmanuel Blondel
|
|
||||||
*/
|
*/
|
||||||
public void addMetadataLinkInfo(GSMetadataLinkInfoEncoder metadataLinkInfo) {
|
public void addMetadataLinkInfo(GSMetadataLinkInfoEncoder metadataLinkInfo) {
|
||||||
metadataLinksListEncoder.addContent(metadataLinkInfo.getRoot());
|
metadataLinksListEncoder.addContent(metadataLinkInfo.getRoot());
|
||||||
@ -205,82 +205,28 @@ public abstract class GSResourceEncoder
|
|||||||
/**
|
/**
|
||||||
* Adds quickly a MetadataLinkInfo to the GeoServer Resource
|
* Adds quickly a MetadataLinkInfo to the GeoServer Resource
|
||||||
*
|
*
|
||||||
* @author Emmanuel Blondel
|
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type
|
||||||
* @param metadataType
|
* @param metadataType
|
||||||
* @param content
|
* @param content
|
||||||
*/
|
*/
|
||||||
public void addMetadataLinkInfo(String type, String metadataType,
|
public void addMetadataLinkInfo(String type, String metadataType, String content) {
|
||||||
String content) {
|
final GSMetadataLinkInfoEncoder mde = new GSMetadataLinkInfoEncoder(type, metadataType,
|
||||||
final GSMetadataLinkInfoEncoder mde = new GSMetadataLinkInfoEncoder(
|
content);
|
||||||
type, metadataType, content);
|
|
||||||
metadataLinksListEncoder.addContent(mde.getRoot());
|
metadataLinksListEncoder.addContent(mde.getRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a metadataLinkInfo from the list using the metadataURL
|
* Deletes a metadataLinkInfo from the list using the metadataURL (MetadataLinkInfo content)
|
||||||
* (MetadataLinkInfo content)
|
|
||||||
*
|
|
||||||
* @author Emmanuel Blondel
|
|
||||||
*
|
*
|
||||||
* @param metadataURL
|
* @param metadataURL
|
||||||
* @return true if something is removed, false otherwise
|
* @return true if something is removed, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean delMetadataLinkInfo(final String metadataURL) {
|
public boolean delMetadataLinkInfo(final String metadataURL) {
|
||||||
return (metadataLinksListEncoder
|
return (metadataLinksListEncoder.removeContent(GSMetadataLinkInfoEncoder
|
||||||
.removeContent(GSMetadataLinkInfoEncoder
|
.getFilterByContent(metadataURL))).size() == 0 ? false : true;
|
||||||
.getFilterByContent(metadataURL))).size() == 0 ? false
|
|
||||||
: true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a CoverageDimensionInfo to the GeoServer Resource
|
|
||||||
*
|
|
||||||
* @param coverageDimensionInfo
|
|
||||||
*
|
|
||||||
* @author Henry Rotzoll
|
|
||||||
*/
|
|
||||||
public void addCoverageDimensionInfo (GSCoverageDimensionEncoder coverageDimensionInfo) {
|
|
||||||
if(ElementUtils.contains(getRoot(), DIMENSIONS) == null)addContent(dimensionsEncoder);
|
|
||||||
dimensionsEncoder.addContent(coverageDimensionInfo.getRoot());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds quickly a CoverageDimensionInfo to the GeoServer Resource
|
|
||||||
*
|
|
||||||
* @author Henry Rotzoll
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* @param description
|
|
||||||
* @param rangeMin
|
|
||||||
* @param rangeMax
|
|
||||||
* @param unit
|
|
||||||
* @param dimensionType
|
|
||||||
*/
|
|
||||||
public void addCoverageDimensionInfo(String name, String description, String rangeMin, String rangeMax, String unit, String dimensionType) {
|
|
||||||
final GSCoverageDimensionEncoder coverageDimensionEncoder = new GSCoverageDimensionEncoder(
|
|
||||||
name, description, rangeMin, rangeMax, unit, dimensionType);
|
|
||||||
addCoverageDimensionInfo(coverageDimensionEncoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes a CoverageDimensionInfo from the list using the CoverageDimension Name
|
|
||||||
* (CoverageDimensionInfo content)
|
|
||||||
*
|
|
||||||
* @author Henry Rotzoll
|
|
||||||
*
|
|
||||||
* @param coverageDimensionName
|
|
||||||
* @return true if something is removed, false otherwise
|
|
||||||
*/
|
|
||||||
public boolean delCoverageDimensionInfo(final String coverageDimensionName) {
|
|
||||||
return (dimensionsEncoder
|
|
||||||
.removeContent(GSCoverageDimensionEncoder
|
|
||||||
.getFilterByContent(coverageDimensionName))).size() == 0 ? false
|
|
||||||
: true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reprojection policy for a published layer. One of:
|
* Reprojection policy for a published layer. One of:
|
||||||
* <ul>
|
* <ul>
|
||||||
@ -341,7 +287,6 @@ public abstract class GSResourceEncoder
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the 'nativename' node with a text value from 'name'
|
* Add the 'nativename' node with a text value from 'name'
|
||||||
*
|
*
|
||||||
@ -351,19 +296,16 @@ public abstract class GSResourceEncoder
|
|||||||
add(NATIVENAME, nativename);
|
add(NATIVENAME, nativename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set or modify the 'nativename' node with a text value from 'name'
|
* Set or modify the 'nativename' node with a text value from 'name'
|
||||||
*
|
*
|
||||||
* @note if not specified, the nativeName will be set with the value of the
|
* @note if not specified, the nativeName will be set with the value of the 'name' node.
|
||||||
* 'name' node.
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setNativeName(final String nativename) {
|
public void setNativeName(final String nativename) {
|
||||||
set(NATIVENAME, nativename);
|
set(NATIVENAME, nativename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the nativeName
|
* Get the nativeName
|
||||||
*
|
*
|
||||||
@ -377,7 +319,6 @@ public abstract class GSResourceEncoder
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private final static String DESCRIPTION = "description";
|
private final static String DESCRIPTION = "description";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -396,6 +337,7 @@ public abstract class GSResourceEncoder
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final static String ABSTRACT = "abstract";
|
private final static String ABSTRACT = "abstract";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the 'abstract' node with a text value from 'abstract'
|
* Add the 'abstract' node with a text value from 'abstract'
|
||||||
*
|
*
|
||||||
@ -403,6 +345,7 @@ public abstract class GSResourceEncoder
|
|||||||
protected void addAbstract(final String _abstract) {
|
protected void addAbstract(final String _abstract) {
|
||||||
add(ABSTRACT, _abstract);
|
add(ABSTRACT, _abstract);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set or modify the 'abstract' node with a text value from 'abstract'
|
* Set or modify the 'abstract' node with a text value from 'abstract'
|
||||||
*/
|
*/
|
||||||
@ -460,9 +403,13 @@ public abstract class GSResourceEncoder
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final static String LATLONBBMINX = "latLonBoundingBox/minx";
|
private final static String LATLONBBMINX = "latLonBoundingBox/minx";
|
||||||
|
|
||||||
private final static String LATLONBBMAXX = "latLonBoundingBox/maxx";
|
private final static String LATLONBBMAXX = "latLonBoundingBox/maxx";
|
||||||
|
|
||||||
private final static String LATLONBBMINY = "latLonBoundingBox/miny";
|
private final static String LATLONBBMINY = "latLonBoundingBox/miny";
|
||||||
|
|
||||||
private final static String LATLONBBMAXY = "latLonBoundingBox/maxy";
|
private final static String LATLONBBMAXY = "latLonBoundingBox/maxy";
|
||||||
|
|
||||||
private final static String LATLONBBCRS = "latLonBoundingBox/crs";
|
private final static String LATLONBBCRS = "latLonBoundingBox/crs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -473,8 +420,8 @@ public abstract class GSResourceEncoder
|
|||||||
* @param miny
|
* @param miny
|
||||||
* @param crs
|
* @param crs
|
||||||
*/
|
*/
|
||||||
protected void addLatLonBoundingBox(double minx, double miny, double maxx,
|
protected void addLatLonBoundingBox(double minx, double miny, double maxx, double maxy,
|
||||||
double maxy, final String crs) {
|
final String crs) {
|
||||||
add(LATLONBBMINX, String.valueOf(minx));
|
add(LATLONBBMINX, String.valueOf(minx));
|
||||||
add(LATLONBBMINY, String.valueOf(miny));
|
add(LATLONBBMINY, String.valueOf(miny));
|
||||||
add(LATLONBBMAXY, String.valueOf(maxy));
|
add(LATLONBBMAXY, String.valueOf(maxy));
|
||||||
@ -482,8 +429,8 @@ public abstract class GSResourceEncoder
|
|||||||
add(LATLONBBCRS, crs);
|
add(LATLONBBCRS, crs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLatLonBoundingBox(double minx, double miny, double maxx,
|
public void setLatLonBoundingBox(double minx, double miny, double maxx, double maxy,
|
||||||
double maxy, final String crs) {
|
final String crs) {
|
||||||
set(LATLONBBMINX, String.valueOf(minx));
|
set(LATLONBBMINX, String.valueOf(minx));
|
||||||
set(LATLONBBMAXY, String.valueOf(maxy));
|
set(LATLONBBMAXY, String.valueOf(maxy));
|
||||||
set(LATLONBBMAXX, String.valueOf(maxx));
|
set(LATLONBBMAXX, String.valueOf(maxx));
|
||||||
@ -492,9 +439,13 @@ public abstract class GSResourceEncoder
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final static String NATIVEBBMINX = "nativeBoundingBox/minx";
|
private final static String NATIVEBBMINX = "nativeBoundingBox/minx";
|
||||||
|
|
||||||
private final static String NATIVEBBMAXX = "nativeBoundingBox/maxx";
|
private final static String NATIVEBBMAXX = "nativeBoundingBox/maxx";
|
||||||
|
|
||||||
private final static String NATIVEBBMINY = "nativeBoundingBox/miny";
|
private final static String NATIVEBBMINY = "nativeBoundingBox/miny";
|
||||||
|
|
||||||
private final static String NATIVEBBMAXY = "nativeBoundingBox/maxy";
|
private final static String NATIVEBBMAXY = "nativeBoundingBox/maxy";
|
||||||
|
|
||||||
private final static String NATIVEBBCRS = "nativeBoundingBox/crs";
|
private final static String NATIVEBBCRS = "nativeBoundingBox/crs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -504,8 +455,8 @@ public abstract class GSResourceEncoder
|
|||||||
* @param miny
|
* @param miny
|
||||||
* @param crs
|
* @param crs
|
||||||
*/
|
*/
|
||||||
protected void addNativeBoundingBox(double minx, double miny, double maxx,
|
protected void addNativeBoundingBox(double minx, double miny, double maxx, double maxy,
|
||||||
double maxy, final String crs) {
|
final String crs) {
|
||||||
add(NATIVEBBMINX, String.valueOf(minx));
|
add(NATIVEBBMINX, String.valueOf(minx));
|
||||||
add(NATIVEBBMAXY, String.valueOf(maxy));
|
add(NATIVEBBMAXY, String.valueOf(maxy));
|
||||||
add(NATIVEBBMAXX, String.valueOf(maxx));
|
add(NATIVEBBMAXX, String.valueOf(maxx));
|
||||||
@ -513,8 +464,8 @@ public abstract class GSResourceEncoder
|
|||||||
add(NATIVEBBCRS, crs);
|
add(NATIVEBBCRS, crs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNativeBoundingBox(double minx, double miny, double maxx,
|
public void setNativeBoundingBox(double minx, double miny, double maxx, double maxy,
|
||||||
double maxy, final String crs) {
|
final String crs) {
|
||||||
set(NATIVEBBMINX, String.valueOf(minx));
|
set(NATIVEBBMINX, String.valueOf(minx));
|
||||||
set(NATIVEBBMAXY, String.valueOf(maxy));
|
set(NATIVEBBMAXY, String.valueOf(maxy));
|
||||||
set(NATIVEBBMAXX, String.valueOf(maxx));
|
set(NATIVEBBMAXX, String.valueOf(maxx));
|
||||||
|
|||||||
@ -25,9 +25,12 @@
|
|||||||
|
|
||||||
package it.geosolutions.geoserver.rest.encoder.coverage;
|
package it.geosolutions.geoserver.rest.encoder.coverage;
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
import org.jdom.Element;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.dimensions.GSCoverageDimensionEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.utils.ElementUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an XML
|
* Creates an XML
|
||||||
@ -38,8 +41,13 @@ import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
|||||||
*/
|
*/
|
||||||
public class GSCoverageEncoder extends GSResourceEncoder {
|
public class GSCoverageEncoder extends GSResourceEncoder {
|
||||||
|
|
||||||
|
public final static String DIMENSIONS = "dimensions";
|
||||||
|
|
||||||
|
final private Element dimensionsEncoder = new Element(DIMENSIONS);
|
||||||
|
|
||||||
public GSCoverageEncoder() {
|
public GSCoverageEncoder() {
|
||||||
super("coverage");
|
super("coverage");
|
||||||
|
addContent(dimensionsEncoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,4 +67,44 @@ public class GSCoverageEncoder extends GSResourceEncoder {
|
|||||||
public void setMetadata(String key, GSDimensionInfoEncoder dimensionInfo) {
|
public void setMetadata(String key, GSDimensionInfoEncoder dimensionInfo) {
|
||||||
super.setMetadata(key, dimensionInfo);
|
super.setMetadata(key, dimensionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a CoverageDimensionInfo to the GeoServer Resource
|
||||||
|
*
|
||||||
|
* @param coverageDimensionInfo
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void addCoverageDimensionInfo(GSCoverageDimensionEncoder coverageDimensionInfo) {
|
||||||
|
if (ElementUtils.contains(getRoot(), DIMENSIONS) == null)
|
||||||
|
addContent(dimensionsEncoder);
|
||||||
|
dimensionsEncoder.addContent(coverageDimensionInfo.getRoot());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds quickly a CoverageDimensionInfo to the GeoServer Resource
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @param description
|
||||||
|
* @param rangeMin
|
||||||
|
* @param rangeMax
|
||||||
|
* @param unit
|
||||||
|
* @param dimensionType
|
||||||
|
*/
|
||||||
|
public void addCoverageDimensionInfo(String name, String description, String rangeMin,
|
||||||
|
String rangeMax, String unit, String dimensionType) {
|
||||||
|
final GSCoverageDimensionEncoder coverageDimensionEncoder = new GSCoverageDimensionEncoder(
|
||||||
|
name, description, rangeMin, rangeMax, unit, dimensionType);
|
||||||
|
addCoverageDimensionInfo(coverageDimensionEncoder);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a CoverageDimensionInfo from the list using the CoverageDimension Name (CoverageDimensionInfo content)
|
||||||
|
*
|
||||||
|
* @param coverageDimensionName
|
||||||
|
* @return true if something is removed, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean delCoverageDimensionInfo(final String coverageDimensionName) {
|
||||||
|
return (dimensionsEncoder.removeContent(GSCoverageDimensionEncoder
|
||||||
|
.getFilterByContent(coverageDimensionName))).size() == 0 ? false : true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,18 +31,22 @@ import org.jdom.Element;
|
|||||||
import org.jdom.filter.Filter;
|
import org.jdom.filter.Filter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GSCoverageDimension - encodes a CoverageDimension for a given GeoServer Resource
|
* GSCoverageDimension - encodes a CoverageDimension for a given GeoServer Resource (feature type /coverage), as follows:
|
||||||
* (feature type /coverage), as follows:
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* final GSCoverageDimensionEncoder gsCoverageDimensionEncoder = new GSCoverageDimensionEncoder("GRAY_INDEX", "GridSampleDimension[-2.147483648E9,-2.147483648E9]", String.valueOf(Integer.MIN_VALUE), String.valueOf(Integer.MAX_VALUE), "dobson units³", "REAL_32BITS");
|
* final GSCoverageDimensionEncoder gsCoverageDimensionEncoder =
|
||||||
|
* new GSCoverageDimensionEncoder("GRAY_INDEX", "GridSampleDimension[-2.147483648E9,-2.147483648E9]",
|
||||||
|
* String.valueOf(Integer.MIN_VALUE), String.valueOf(Integer.MAX_VALUE), "dobson units³", "REAL_32BITS");
|
||||||
* coverageEncoder.addCoverageDimensionInfo(gsCoverageDimensionEncoder);
|
* coverageEncoder.addCoverageDimensionInfo(gsCoverageDimensionEncoder);
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* For this example, the XML output is:
|
* For this example, the XML output is:
|
||||||
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
*<coverageDimension>
|
* <coverageDimension>
|
||||||
* <name>GRAY_INDEX</name>
|
* <name>GRAY_INDEX</name>
|
||||||
* <description>GridSampleDimension[-2.147483648E9,2.147483648E9]</description>
|
* <description>GridSampleDimension[-2.147483648E9,2.147483648E9]</description>
|
||||||
* <range>
|
* <range>
|
||||||
@ -53,7 +57,7 @@ import org.jdom.filter.Filter;
|
|||||||
* <dimensionType>
|
* <dimensionType>
|
||||||
* <name>REAL_32BITS</name>
|
* <name>REAL_32BITS</name>
|
||||||
* </dimensionType>
|
* </dimensionType>
|
||||||
*</coverageDimension>
|
* </coverageDimension>
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
@ -62,7 +66,8 @@ import org.jdom.filter.Filter;
|
|||||||
*/
|
*/
|
||||||
public class GSCoverageDimensionEncoder extends XmlElement {
|
public class GSCoverageDimensionEncoder extends XmlElement {
|
||||||
|
|
||||||
/** A class to filter the GSCoverageDimension by content
|
/**
|
||||||
|
* A class to filter the GSCoverageDimension by content
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -77,8 +82,7 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public boolean matches(Object obj) {
|
public boolean matches(Object obj) {
|
||||||
Element el = ((Element) obj)
|
Element el = ((Element) obj).getChild("name");
|
||||||
.getChild("name");
|
|
||||||
if (el != null && el.getTextTrim().equals(key)) {
|
if (el != null && el.getTextTrim().equals(key)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -114,7 +118,8 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
* @param unit
|
* @param unit
|
||||||
* @param dimensionTypeName
|
* @param dimensionTypeName
|
||||||
*/
|
*/
|
||||||
public GSCoverageDimensionEncoder(String name, String description, String rangeMin, String rangeMax, String unit, String dimensionTypeName) {
|
public GSCoverageDimensionEncoder(String name, String description, String rangeMin,
|
||||||
|
String rangeMax, String unit, String dimensionTypeName) {
|
||||||
super("coverageDimension");
|
super("coverageDimension");
|
||||||
this.setup(name, description, rangeMin, rangeMax, unit, dimensionTypeName);
|
this.setup(name, description, rangeMin, rangeMax, unit, dimensionTypeName);
|
||||||
}
|
}
|
||||||
@ -129,25 +134,24 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
* @param unit
|
* @param unit
|
||||||
* @param dimensionTypeName
|
* @param dimensionTypeName
|
||||||
*/
|
*/
|
||||||
protected void setup(String name, String description, String rangeMin, String rangeMax, String unit, String dimensionTypeName)
|
protected void setup(String name, String description, String rangeMin, String rangeMax,
|
||||||
{
|
String unit, String dimensionTypeName) {
|
||||||
//name
|
// name
|
||||||
setName(name);
|
setName(name);
|
||||||
|
|
||||||
//description
|
// description
|
||||||
setDescription(description);
|
setDescription(description);
|
||||||
|
|
||||||
//range
|
// range
|
||||||
setRange(rangeMin, rangeMax);
|
setRange(rangeMin, rangeMax);
|
||||||
|
|
||||||
//unit
|
// unit
|
||||||
setUnit(unit);
|
setUnit(unit);
|
||||||
|
|
||||||
//dimension Type
|
// dimension Type
|
||||||
setDimensionType(dimensionTypeName);
|
setDimensionType(dimensionTypeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value of the GSCoverageDimensionEncoder member
|
* Get the value of the GSCoverageDimensionEncoder member
|
||||||
*
|
*
|
||||||
@ -169,9 +173,9 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
* @return true if the GSCoverageDimensionEncoder member is removed
|
* @return true if the GSCoverageDimensionEncoder member is removed
|
||||||
*/
|
*/
|
||||||
protected boolean delMemberIfExists(String memberName) {
|
protected boolean delMemberIfExists(String memberName) {
|
||||||
if(ElementUtils.contains(getRoot(), memberName) != null)
|
if (ElementUtils.contains(getRoot(), memberName) != null) {
|
||||||
{
|
return ElementUtils.remove(this.getRoot(),
|
||||||
return ElementUtils.remove(this.getRoot(), this.getRoot().getChild(memberName.toString()));
|
this.getRoot().getChild(memberName.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -184,9 +188,9 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
* @param memberValue
|
* @param memberValue
|
||||||
*/
|
*/
|
||||||
protected void setMember(String memberName, String memberValue) {
|
protected void setMember(String memberName, String memberValue) {
|
||||||
if(memberName != null && !memberName.isEmpty() && memberValue != null && !memberValue.isEmpty())
|
if (memberName != null && !memberName.isEmpty() && memberValue != null
|
||||||
{
|
&& !memberValue.isEmpty()) {
|
||||||
delMemberIfExists(memberName); //delete the element if it already exists
|
delMemberIfExists(memberName); // delete the element if it already exists
|
||||||
addMember(memberName.toString(), memberValue);
|
addMember(memberName.toString(), memberValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,8 +202,8 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
* @param memberValue
|
* @param memberValue
|
||||||
*/
|
*/
|
||||||
protected void addMember(String memberName, String memberValue) {
|
protected void addMember(String memberName, String memberValue) {
|
||||||
if(memberName != null && !memberName.isEmpty() && memberValue != null && ! memberValue.isEmpty())
|
if (memberName != null && !memberName.isEmpty() && memberValue != null
|
||||||
{
|
&& !memberValue.isEmpty()) {
|
||||||
set(memberName.toString(), memberValue);
|
set(memberName.toString(), memberValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,7 +213,7 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
public void setName(String name){
|
public void setName(String name) {
|
||||||
setMember("name", name);
|
setMember("name", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,7 +223,7 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
* @param name
|
* @param name
|
||||||
* @return true if removed
|
* @return true if removed
|
||||||
*/
|
*/
|
||||||
public boolean delName(){
|
public boolean delName() {
|
||||||
return this.delMemberIfExists("name");
|
return this.delMemberIfExists("name");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +232,7 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
*
|
*
|
||||||
* @return description
|
* @return description
|
||||||
*/
|
*/
|
||||||
public String getName(){
|
public String getName() {
|
||||||
return this.getMember("name");
|
return this.getMember("name");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +241,7 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
*
|
*
|
||||||
* @param description
|
* @param description
|
||||||
*/
|
*/
|
||||||
public void setDescription(String description){
|
public void setDescription(String description) {
|
||||||
setMember("description", description);
|
setMember("description", description);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,7 +251,7 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
* @param description
|
* @param description
|
||||||
* @return true if removed
|
* @return true if removed
|
||||||
*/
|
*/
|
||||||
public boolean delDescription(){
|
public boolean delDescription() {
|
||||||
return this.delMemberIfExists("description");
|
return this.delMemberIfExists("description");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +260,7 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
*
|
*
|
||||||
* @return description
|
* @return description
|
||||||
*/
|
*/
|
||||||
public String getDescription(){
|
public String getDescription() {
|
||||||
return this.getMember("description");
|
return this.getMember("description");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,9 +269,8 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
*
|
*
|
||||||
* @param range
|
* @param range
|
||||||
*/
|
*/
|
||||||
public void setRange(String rangeMin, String rangeMax){
|
public void setRange(String rangeMin, String rangeMax) {
|
||||||
if(rangeMin != null && !rangeMin.isEmpty() && rangeMax != null && !rangeMax.isEmpty())
|
if (rangeMin != null && !rangeMin.isEmpty() && rangeMax != null && !rangeMax.isEmpty()) {
|
||||||
{
|
|
||||||
remove("range");
|
remove("range");
|
||||||
|
|
||||||
final Element rangeElement = new Element("range");
|
final Element rangeElement = new Element("range");
|
||||||
@ -287,7 +290,7 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
* @param range
|
* @param range
|
||||||
* @return true if removed
|
* @return true if removed
|
||||||
*/
|
*/
|
||||||
public boolean delRange(){
|
public boolean delRange() {
|
||||||
return this.delMemberIfExists("range");
|
return this.delMemberIfExists("range");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,10 +299,9 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
*
|
*
|
||||||
* @return range min
|
* @return range min
|
||||||
*/
|
*/
|
||||||
public String getRangeMin(){
|
public String getRangeMin() {
|
||||||
final Element range = this.getRoot().getChild("range");
|
final Element range = this.getRoot().getChild("range");
|
||||||
if(range != null)
|
if (range != null) {
|
||||||
{
|
|
||||||
return range.getChildText("min");
|
return range.getChildText("min");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,10 +313,9 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
*
|
*
|
||||||
* @return range max
|
* @return range max
|
||||||
*/
|
*/
|
||||||
public String getRangeMax(){
|
public String getRangeMax() {
|
||||||
final Element range = this.getRoot().getChild("range");
|
final Element range = this.getRoot().getChild("range");
|
||||||
if(range != null)
|
if (range != null) {
|
||||||
{
|
|
||||||
return range.getChildText("max");
|
return range.getChildText("max");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,7 +327,7 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
*
|
*
|
||||||
* @param unit
|
* @param unit
|
||||||
*/
|
*/
|
||||||
public void setUnit(String unit){
|
public void setUnit(String unit) {
|
||||||
setMember("unit", unit);
|
setMember("unit", unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +337,7 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
* @param type
|
* @param type
|
||||||
* @return true if removed
|
* @return true if removed
|
||||||
*/
|
*/
|
||||||
public boolean delUnit(){
|
public boolean delUnit() {
|
||||||
return this.delMemberIfExists("unit");
|
return this.delMemberIfExists("unit");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +346,7 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
*
|
*
|
||||||
* @return unit
|
* @return unit
|
||||||
*/
|
*/
|
||||||
public String getUnit(){
|
public String getUnit() {
|
||||||
return this.getMember("unit");
|
return this.getMember("unit");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,9 +355,8 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
*
|
*
|
||||||
* @param dimensionType
|
* @param dimensionType
|
||||||
*/
|
*/
|
||||||
public void setDimensionType(String dimensionTypeName){
|
public void setDimensionType(String dimensionTypeName) {
|
||||||
if(dimensionTypeName != null && !dimensionTypeName.isEmpty())
|
if (dimensionTypeName != null && !dimensionTypeName.isEmpty()) {
|
||||||
{
|
|
||||||
remove("dimensionType");
|
remove("dimensionType");
|
||||||
|
|
||||||
final Element dimensionTypeElement = new Element("dimensionType");
|
final Element dimensionTypeElement = new Element("dimensionType");
|
||||||
@ -373,7 +373,7 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
* @param dimensionType
|
* @param dimensionType
|
||||||
* @return true if removed
|
* @return true if removed
|
||||||
*/
|
*/
|
||||||
public boolean delDimensionType(){
|
public boolean delDimensionType() {
|
||||||
return this.delMemberIfExists("dimensionType");
|
return this.delMemberIfExists("dimensionType");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,10 +382,9 @@ public class GSCoverageDimensionEncoder extends XmlElement {
|
|||||||
*
|
*
|
||||||
* @return dimensionType name
|
* @return dimensionType name
|
||||||
*/
|
*/
|
||||||
public String getDimensionTypeName(){
|
public String getDimensionTypeName() {
|
||||||
final Element dimensionType = this.getRoot().getChild("dimensionType");
|
final Element dimensionType = this.getRoot().getChild("dimensionType");
|
||||||
if(dimensionType != null)
|
if (dimensionType != null) {
|
||||||
{
|
|
||||||
return dimensionType.getChildText("name");
|
return dimensionType.getChildText("name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,38 +23,37 @@ import org.springframework.core.io.ClassPathResource;
|
|||||||
*/
|
*/
|
||||||
public class ResourceDecoderTest {
|
public class ResourceDecoderTest {
|
||||||
|
|
||||||
|
|
||||||
RESTCoverage coverage;
|
RESTCoverage coverage;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws IOException{
|
public void setup() throws IOException {
|
||||||
File coverageFile = new ClassPathResource("testdata/coverageExample.xml").getFile();
|
File coverageFile = new ClassPathResource("testdata/coverageExample.xml").getFile();
|
||||||
String coverageString = FileUtils.readFileToString(coverageFile);
|
String coverageString = FileUtils.readFileToString(coverageFile);
|
||||||
coverage = RESTCoverage.build(coverageString);
|
coverage = RESTCoverage.build(coverageString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testName(){
|
public void testName() {
|
||||||
Assert.assertEquals(coverage.getName(),"granuleTestMosaic");
|
Assert.assertEquals(coverage.getName(), "granuleTestMosaic");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNativeName(){
|
public void testNativeName() {
|
||||||
Assert.assertEquals(coverage.getNativeName(), "granuleTestMosaic");
|
Assert.assertEquals(coverage.getNativeName(), "granuleTestMosaic");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTitle(){
|
public void testTitle() {
|
||||||
Assert.assertEquals(coverage.getNativeName(), "granuleTestMosaic");
|
Assert.assertEquals(coverage.getNativeName(), "granuleTestMosaic");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAbstract(){
|
public void testAbstract() {
|
||||||
Assert.assertEquals(coverage.getAbstract(), "this is an abstract");
|
Assert.assertEquals(coverage.getAbstract(), "this is an abstract");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testKeywords(){
|
public void testKeywords() {
|
||||||
List<String> keywords = coverage.getKeywords();
|
List<String> keywords = coverage.getKeywords();
|
||||||
Assert.assertEquals(keywords.get(0), "keyword1");
|
Assert.assertEquals(keywords.get(0), "keyword1");
|
||||||
Assert.assertEquals(keywords.get(1), "keyword2");
|
Assert.assertEquals(keywords.get(1), "keyword2");
|
||||||
@ -62,41 +61,41 @@ public class ResourceDecoderTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNameSpace(){
|
public void testNameSpace() {
|
||||||
Assert.assertEquals(coverage.getNameSpace(),"topp");
|
Assert.assertEquals(coverage.getNameSpace(), "topp");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStoreName(){
|
public void testStoreName() {
|
||||||
Assert.assertEquals(coverage.getStoreName(), "granuleTestMosaic");
|
Assert.assertEquals(coverage.getStoreName(), "granuleTestMosaic");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStoreType(){
|
public void testStoreType() {
|
||||||
Assert.assertEquals(coverage.getStoreType(), "coverageStore");
|
Assert.assertEquals(coverage.getStoreType(), "coverageStore");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStoreUrl(){
|
public void testStoreUrl() {
|
||||||
Assert.assertEquals(coverage.getStoreUrl(), "http://localhost:8080/geoserver/rest/workspaces/topp/coveragestores/granuleTestMosaic.xml");
|
Assert.assertEquals(coverage.getStoreUrl(),
|
||||||
|
"http://localhost:8080/geoserver/rest/workspaces/topp/coveragestores/granuleTestMosaic.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCRS(){
|
public void testCRS() {
|
||||||
Assert.assertEquals(coverage.getCRS(), "EPSG:4326");
|
Assert.assertEquals(coverage.getCRS(), "EPSG:4326");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBoundingBox(){
|
public void testBoundingBox() {
|
||||||
Assert.assertEquals(coverage.getMinX(), -180.0, 0);
|
Assert.assertEquals(coverage.getMinX(), -180.0, 0);
|
||||||
Assert.assertEquals(coverage.getMaxX(), 180.0, 0);
|
Assert.assertEquals(coverage.getMaxX(), 180.0, 0);
|
||||||
Assert.assertEquals(coverage.getMinY(), -90, 0);
|
Assert.assertEquals(coverage.getMinY(), -90, 0);
|
||||||
Assert.assertEquals(coverage.getMaxY(), 90, 0);
|
Assert.assertEquals(coverage.getMaxY(), 90, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMetadataLinkInfo() throws IOException{
|
public void testMetadataLinkInfo() throws IOException {
|
||||||
|
|
||||||
List<GSMetadataLinkInfoEncoder> list = coverage.getEncodedMetadataLinkInfoList();
|
List<GSMetadataLinkInfoEncoder> list = coverage.getEncodedMetadataLinkInfoList();
|
||||||
|
|
||||||
@ -106,25 +105,25 @@ public class ResourceDecoderTest {
|
|||||||
Assert.assertEquals("http://www.organization.org/metadata1", metadataLinkInfo1.getContent());
|
Assert.assertEquals("http://www.organization.org/metadata1", metadataLinkInfo1.getContent());
|
||||||
|
|
||||||
GSMetadataLinkInfoEncoder metadataLinkInfo2 = list.get(1);
|
GSMetadataLinkInfoEncoder metadataLinkInfo2 = list.get(1);
|
||||||
Assert.assertEquals("text/html",metadataLinkInfo2.getType());
|
Assert.assertEquals("text/html", metadataLinkInfo2.getType());
|
||||||
Assert.assertEquals("ISO19115:2003",metadataLinkInfo2.getMetadataType());
|
Assert.assertEquals("ISO19115:2003", metadataLinkInfo2.getMetadataType());
|
||||||
Assert.assertEquals("http://www.organization.org/metadata2",metadataLinkInfo2.getContent());
|
Assert.assertEquals("http://www.organization.org/metadata2", metadataLinkInfo2.getContent());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCoverageDimension() throws IOException{
|
public void testCoverageDimension() throws IOException {
|
||||||
|
|
||||||
List<GSCoverageDimensionEncoder> list = coverage.getEncodedDimensionsInfoList();
|
List<GSCoverageDimensionEncoder> list = coverage.getEncodedDimensionsInfoList();
|
||||||
|
|
||||||
GSCoverageDimensionEncoder coverageDimension1 = list.get(0);
|
GSCoverageDimensionEncoder coverageDimension1 = list.get(0);
|
||||||
Assert.assertEquals("GRAY_INDEX", coverageDimension1.getName());
|
Assert.assertEquals("GRAY_INDEX", coverageDimension1.getName());
|
||||||
Assert.assertEquals("GridSampleDimension[-Infinity,Infinity]", coverageDimension1.getDescription());
|
Assert.assertEquals("GridSampleDimension[-Infinity,Infinity]",
|
||||||
|
coverageDimension1.getDescription());
|
||||||
Assert.assertEquals("-inf", coverageDimension1.getRangeMin());
|
Assert.assertEquals("-inf", coverageDimension1.getRangeMin());
|
||||||
Assert.assertEquals("inf", coverageDimension1.getRangeMax());
|
Assert.assertEquals("inf", coverageDimension1.getRangeMax());
|
||||||
Assert.assertEquals("dobson units³", coverageDimension1.getUnit());
|
Assert.assertEquals("dobson units³", coverageDimension1.getUnit());
|
||||||
Assert.assertEquals("REAL_32BITS", coverageDimension1.getDimensionTypeName());
|
Assert.assertEquals("REAL_32BITS", coverageDimension1.getDimensionTypeName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ package it.geosolutions.geoserver.rest.encoder.coverage;
|
|||||||
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.dimensions.GSCoverageDimensionEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
||||||
import it.geosolutions.geoserver.rest.encoder.utils.ElementUtils;
|
import it.geosolutions.geoserver.rest.encoder.utils.ElementUtils;
|
||||||
@ -105,6 +106,8 @@ public class GSCoverageEncoderTest extends TestCase {
|
|||||||
encoder.addKeyword("...");
|
encoder.addKeyword("...");
|
||||||
encoder.addKeyword("KEYWORD_N");
|
encoder.addKeyword("KEYWORD_N");
|
||||||
|
|
||||||
|
|
||||||
|
// Old style dimensions (into metadata)
|
||||||
final GSDimensionInfoEncoder timeDimension=new GSDimensionInfoEncoder(true);
|
final GSDimensionInfoEncoder timeDimension=new GSDimensionInfoEncoder(true);
|
||||||
timeDimension.setPresentation(Presentation.CONTINUOUS_INTERVAL);
|
timeDimension.setPresentation(Presentation.CONTINUOUS_INTERVAL);
|
||||||
encoder.setMetadata("time", timeDimension);
|
encoder.setMetadata("time", timeDimension);
|
||||||
@ -120,6 +123,12 @@ public class GSCoverageEncoderTest extends TestCase {
|
|||||||
elevationDimension.setPresentation(Presentation.LIST);
|
elevationDimension.setPresentation(Presentation.LIST);
|
||||||
encoder.setMetadata("elevation", elevationDimension);
|
encoder.setMetadata("elevation", elevationDimension);
|
||||||
|
|
||||||
|
// New style dimensions (since gs-2.4.x)
|
||||||
|
GSCoverageDimensionEncoder gsCoverageDimensionEncoder = new GSCoverageDimensionEncoder(
|
||||||
|
"GRAY_INDEX", "GridSampleDimension[-Infinity,Infinity]", "-inf", "inf",
|
||||||
|
"dobson units³", "REAL_32BITS");
|
||||||
|
encoder.addCoverageDimensionInfo(gsCoverageDimensionEncoder);
|
||||||
|
|
||||||
if (LOGGER.isInfoEnabled())
|
if (LOGGER.isInfoEnabled())
|
||||||
LOGGER.info(encoder.toString());
|
LOGGER.info(encoder.toString());
|
||||||
|
|
||||||
|
|||||||
@ -19,20 +19,28 @@
|
|||||||
*/
|
*/
|
||||||
package it.geosolutions.geoserver.rest.encoder.dimensions;
|
package it.geosolutions.geoserver.rest.encoder.dimensions;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Henry Rotzoll (henry.rotzoll@dlr.de)
|
* @author Henry Rotzoll (henry.rotzoll@dlr.de)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class GSCoverageDimensionEncoderTest {
|
public class GSCoverageDimensionEncoderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void coverageDimensionTest(){
|
public void coverageDimensionTest() {
|
||||||
GSCoverageDimensionEncoder encoder = new GSCoverageDimensionEncoder("GRAY_INDEX", "GridSampleDimension[-Infinity,Infinity]", "-inf", "inf", "dobson units³", "REAL_32BITS");
|
GSCoverageDimensionEncoder encoder = new GSCoverageDimensionEncoder("GRAY_INDEX",
|
||||||
|
"GridSampleDimension[-Infinity,Infinity]", "-inf", "inf", "dobson units³",
|
||||||
|
"REAL_32BITS");
|
||||||
|
|
||||||
Assert.assertEquals("GRAY_INDEX", encoder.getName());
|
Assert.assertEquals("GRAY_INDEX", encoder.getName());
|
||||||
Assert.assertEquals("GridSampleDimension[-Infinity,Infinity]", encoder.getDescription());
|
Assert.assertEquals("GridSampleDimension[-Infinity,Infinity]", encoder.getDescription());
|
||||||
@ -47,7 +55,7 @@ public class GSCoverageDimensionEncoderTest {
|
|||||||
Assert.assertTrue(encoder.delUnit());
|
Assert.assertTrue(encoder.delUnit());
|
||||||
Assert.assertTrue(encoder.delDimensionType());
|
Assert.assertTrue(encoder.delDimensionType());
|
||||||
|
|
||||||
Assert.assertNull( encoder.getName());
|
Assert.assertNull(encoder.getName());
|
||||||
Assert.assertNull(encoder.getDescription());
|
Assert.assertNull(encoder.getDescription());
|
||||||
Assert.assertNull(encoder.getRangeMin());
|
Assert.assertNull(encoder.getRangeMin());
|
||||||
Assert.assertNull(encoder.getRangeMax());
|
Assert.assertNull(encoder.getRangeMax());
|
||||||
@ -67,4 +75,5 @@ public class GSCoverageDimensionEncoderTest {
|
|||||||
Assert.assertEquals("dobson units³", encoder.getUnit());
|
Assert.assertEquals("dobson units³", encoder.getUnit());
|
||||||
Assert.assertEquals("REAL_32BITS", encoder.getDimensionTypeName());
|
Assert.assertEquals("REAL_32BITS", encoder.getDimensionTypeName());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -53,15 +53,12 @@ import org.springframework.core.io.ClassPathResource;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Note on adding multiple available styles to the GSLayerEncoder: - to run the
|
* Note on adding multiple available styles to the GSLayerEncoder: - to run the testIntegration(), 2 clones of the "point" style, named "point2" and
|
||||||
* testIntegration(), 2 clones of the "point" style, named "point2" and "point3"
|
* "point3" have to be created.
|
||||||
* have to be created.
|
|
||||||
*
|
*
|
||||||
* @author ETj (etj at geo-solutions.it)
|
* @author ETj (etj at geo-solutions.it)
|
||||||
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
|
||||||
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com |
|
* @author Emmanuel Blondel - emmanuel.blondel1@gmail.com | emmanuel.blondel@fao.org
|
||||||
* emmanuel.blondel@fao.org
|
|
||||||
* @author Henry Rotzoll (henry.rotzoll@dlr.de)
|
|
||||||
*/
|
*/
|
||||||
public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
||||||
protected final static Logger LOGGER = LoggerFactory.getLogger(GSFeatureEncoderTest.class);
|
protected final static Logger LOGGER = LoggerFactory.getLogger(GSFeatureEncoderTest.class);
|
||||||
@ -87,15 +84,11 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
fte.setDescription("desc");
|
fte.setDescription("desc");
|
||||||
fte.setEnabled(true);
|
fte.setEnabled(true);
|
||||||
|
|
||||||
//metadataLink
|
// metadataLink
|
||||||
GSMetadataLinkInfoEncoder metadatalink = new GSMetadataLinkInfoEncoder(
|
GSMetadataLinkInfoEncoder metadatalink = new GSMetadataLinkInfoEncoder("text/xml",
|
||||||
"text/xml", "ISO19115:2003",
|
"ISO19115:2003", "http://www.organization.org/metadata1");
|
||||||
"http://www.organization.org/metadata1");
|
|
||||||
fte.addMetadataLinkInfo(metadatalink);
|
fte.addMetadataLinkInfo(metadatalink);
|
||||||
|
|
||||||
GSCoverageDimensionEncoder gsCoverageDimensionEncoder = new GSCoverageDimensionEncoder("GRAY_INDEX", "GridSampleDimension[-Infinity,Infinity]", "-inf", "inf", "dobson units³", "REAL_32BITS");
|
|
||||||
fte.addCoverageDimensionInfo(gsCoverageDimensionEncoder);
|
|
||||||
|
|
||||||
GSLayerEncoder layerEncoder = null;
|
GSLayerEncoder layerEncoder = null;
|
||||||
if (!GSVersionDecoder.VERSION.getVersion(VERSION).equals(
|
if (!GSVersionDecoder.VERSION.getVersion(VERSION).equals(
|
||||||
GSVersionDecoder.VERSION.UNRECOGNIZED)) {
|
GSVersionDecoder.VERSION.UNRECOGNIZED)) {
|
||||||
@ -113,31 +106,29 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
layerEncoder.addStyle("point3");
|
layerEncoder.addStyle("point3");
|
||||||
|
|
||||||
// authorityURL
|
// authorityURL
|
||||||
GSAuthorityURLInfoEncoder authorityURL = new GSAuthorityURLInfoEncoder(
|
GSAuthorityURLInfoEncoder authorityURL = new GSAuthorityURLInfoEncoder("authority1",
|
||||||
"authority1", "http://www.authority1.org");
|
"http://www.authority1.org");
|
||||||
layerEncoder.addAuthorityURL(authorityURL);
|
layerEncoder.addAuthorityURL(authorityURL);
|
||||||
|
|
||||||
// identifier
|
// identifier
|
||||||
GSIdentifierInfoEncoder identifier1 = new GSIdentifierInfoEncoder(
|
GSIdentifierInfoEncoder identifier1 = new GSIdentifierInfoEncoder("authority1",
|
||||||
"authority1", "identifier1");
|
"identifier1");
|
||||||
GSIdentifierInfoEncoder identifier2 = new GSIdentifierInfoEncoder(
|
GSIdentifierInfoEncoder identifier2 = new GSIdentifierInfoEncoder("authority1",
|
||||||
"authority1", "another_identifier");
|
"another_identifier");
|
||||||
layerEncoder.addIdentifier(identifier1);
|
layerEncoder.addIdentifier(identifier1);
|
||||||
layerEncoder.addIdentifier(identifier2);
|
layerEncoder.addIdentifier(identifier2);
|
||||||
|
|
||||||
publisher.createWorkspace(DEFAULT_WS);
|
publisher.createWorkspace(DEFAULT_WS);
|
||||||
|
|
||||||
File zipFile = new ClassPathResource("testdata/resttestshp.zip")
|
File zipFile = new ClassPathResource("testdata/resttestshp.zip").getFile();
|
||||||
.getFile();
|
|
||||||
|
|
||||||
// test insert
|
// test insert
|
||||||
boolean published = publisher.publishShp(DEFAULT_WS, storeName,
|
boolean published = publisher.publishShp(DEFAULT_WS, storeName, layerName, zipFile);
|
||||||
layerName, zipFile);
|
|
||||||
assertTrue("publish() failed", published);
|
assertTrue("publish() failed", published);
|
||||||
assertTrue(existsLayer(layerName));
|
assertTrue(existsLayer(layerName));
|
||||||
|
|
||||||
publisher.publishStyle(new File(new ClassPathResource("testdata")
|
publisher.publishStyle(new File(new ClassPathResource("testdata").getFile(),
|
||||||
.getFile(), "default_point.sld"));
|
"default_point.sld"));
|
||||||
|
|
||||||
// optionally select the attributes to publish
|
// optionally select the attributes to publish
|
||||||
RESTLayer layer = reader.getLayer(layerName);
|
RESTLayer layer = reader.getLayer(layerName);
|
||||||
@ -148,28 +139,10 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
fte.setAttribute(enc);
|
fte.setAttribute(enc);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTrue(publisher.publishDBLayer(DEFAULT_WS, storeName, fte,
|
assertTrue(publisher.publishDBLayer(DEFAULT_WS, storeName, fte, layerEncoder));
|
||||||
layerEncoder));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCoverageDimension() throws IOException {
|
|
||||||
GSFeatureTypeEncoder fte = new GSFeatureTypeEncoder();
|
|
||||||
fte.setNativeName("testlayer");
|
|
||||||
fte.setName("testlayer" + "_NEW");
|
|
||||||
fte.setTitle("title");
|
|
||||||
fte.setNativeCRS("EPSG:4326");
|
|
||||||
fte.setDescription("desc");
|
|
||||||
fte.setEnabled(true);
|
|
||||||
|
|
||||||
assertFalse(fte.toString().contains("<dimensions><coverageDimension><name>GRAY_INDEX</name><description>GridSampleDimension[-Infinity,Infinity]</description><range><min>-inf</min><max>inf</max></range><unit>dobson units³</unit><dimensionType><name>REAL_32BITS</name></dimensionType></coverageDimension></dimensions>"));
|
|
||||||
|
|
||||||
GSCoverageDimensionEncoder gsCoverageDimensionEncoder = new GSCoverageDimensionEncoder("GRAY_INDEX", "GridSampleDimension[-Infinity,Infinity]", "-inf", "inf", "dobson units³", "REAL_32BITS");
|
|
||||||
fte.addCoverageDimensionInfo(gsCoverageDimensionEncoder);
|
|
||||||
LOGGER.debug("fte.toString() :" + fte.toString());
|
|
||||||
assertTrue(fte.toString().contains("<dimensions><coverageDimension><name>GRAY_INDEX</name><description>GridSampleDimension[-Infinity,Infinity]</description><range><min>-inf</min><max>inf</max></range><unit>dobson units³</unit><dimensionType><name>REAL_32BITS</name></dimensionType></coverageDimension></dimensions>"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -244,7 +217,7 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
if (LOGGER.isInfoEnabled())
|
if (LOGGER.isInfoEnabled())
|
||||||
LOGGER.info(encoder.toString());
|
LOGGER.info(encoder.toString());
|
||||||
|
|
||||||
assertEquals(encoder.getName(),"Layername");
|
assertEquals(encoder.getName(), "Layername");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -258,14 +231,16 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
assertTrue(encoder.delKeyword("KEYWORD_2"));
|
assertTrue(encoder.delKeyword("KEYWORD_2"));
|
||||||
assertFalse(encoder.delKeyword("KEYWORD_M"));
|
assertFalse(encoder.delKeyword("KEYWORD_M"));
|
||||||
|
|
||||||
//metadataLinkInfo
|
// metadataLinkInfo
|
||||||
encoder.addMetadataLinkInfo("text/xml", "ISO19115:2003","http://www.organization.org/metadata1");
|
encoder.addMetadataLinkInfo("text/xml", "ISO19115:2003",
|
||||||
encoder.addMetadataLinkInfo("text/html", "ISO19115:2003","http://www.organization.org/metadata2");
|
"http://www.organization.org/metadata1");
|
||||||
|
encoder.addMetadataLinkInfo("text/html", "ISO19115:2003",
|
||||||
|
"http://www.organization.org/metadata2");
|
||||||
|
|
||||||
assertTrue(encoder.delMetadataLinkInfo("http://www.organization.org/metadata2"));
|
assertTrue(encoder.delMetadataLinkInfo("http://www.organization.org/metadata2"));
|
||||||
assertFalse(encoder.delMetadataLinkInfo("http://www.organization.org/metadata3"));
|
assertFalse(encoder.delMetadataLinkInfo("http://www.organization.org/metadata3"));
|
||||||
|
|
||||||
//dimensions
|
// dimensions
|
||||||
final GSFeatureDimensionInfoEncoder elevationDimension = new GSFeatureDimensionInfoEncoder(
|
final GSFeatureDimensionInfoEncoder elevationDimension = new GSFeatureDimensionInfoEncoder(
|
||||||
"elevation_field");
|
"elevation_field");
|
||||||
|
|
||||||
@ -275,8 +250,7 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
final String metadata = "elevation";
|
final String metadata = "elevation";
|
||||||
encoder.setMetadataDimension(metadata, elevationDimension);
|
encoder.setMetadataDimension(metadata, elevationDimension);
|
||||||
|
|
||||||
elevationDimension.setPresentation(Presentation.DISCRETE_INTERVAL,
|
elevationDimension.setPresentation(Presentation.DISCRETE_INTERVAL, BigDecimal.valueOf(10));
|
||||||
BigDecimal.valueOf(10));
|
|
||||||
|
|
||||||
if (LOGGER.isInfoEnabled())
|
if (LOGGER.isInfoEnabled())
|
||||||
LOGGER.info(encoder.toString());
|
LOGGER.info(encoder.toString());
|
||||||
@ -297,24 +271,21 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
/**
|
/**
|
||||||
* Test method for virtual table encoding / SQL view layer integration
|
* Test method for virtual table encoding / SQL view layer integration
|
||||||
*
|
*
|
||||||
* Settings information for integration tests
|
* Settings information for integration tests - test is based on the data used in
|
||||||
* - test is based on the data used in http://docs.geoserver.org/latest/en/user/data/database/sqlview.html#parameterizing-sql-views
|
* http://docs.geoserver.org/latest/en/user/data/database/sqlview.html#parameterizing-sql-views (states shapefile - available in
|
||||||
* (states shapefile - available in testdata/states.zip)
|
* testdata/states.zip) - create a postgis db - import the states shapefile (using shp2pgsql or Postgis shapefile uploader) - In Geoserver, create
|
||||||
* - create a postgis db
|
* a postgis datastore for this DB, with the name "statesdb"
|
||||||
* - import the states shapefile (using shp2pgsql or Postgis shapefile uploader)
|
|
||||||
* - In Geoserver, create a postgis datastore for this DB, with the name "statesdb"
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSQLViewIntegration(){
|
public void testSQLViewIntegration() {
|
||||||
|
|
||||||
if (!enabled())
|
if (!enabled())
|
||||||
return;
|
return;
|
||||||
deleteAll();
|
deleteAll();
|
||||||
GeoServerRESTPublisher publisher = new GeoServerRESTPublisher(RESTURL, RESTUSER, RESTPW);
|
GeoServerRESTPublisher publisher = new GeoServerRESTPublisher(RESTURL, RESTUSER, RESTPW);
|
||||||
|
|
||||||
|
String storeName = "statesdb"; // name of the datastore setup for tests
|
||||||
String storeName = "statesdb"; //name of the datastore setup for tests
|
|
||||||
String layerName = "my_sqlviewlayer";
|
String layerName = "my_sqlviewlayer";
|
||||||
String nativeName = "popstates";
|
String nativeName = "popstates";
|
||||||
|
|
||||||
@ -329,8 +300,8 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
fte.setDescription("desc");
|
fte.setDescription("desc");
|
||||||
fte.setEnabled(true);
|
fte.setEnabled(true);
|
||||||
|
|
||||||
//virtual table
|
// virtual table
|
||||||
//-------------
|
// -------------
|
||||||
// Set-up the vtGeom
|
// Set-up the vtGeom
|
||||||
final VTGeometryEncoder vtGeom = new VTGeometryEncoder("the_geom", "Point", "4326");
|
final VTGeometryEncoder vtGeom = new VTGeometryEncoder("the_geom", "Point", "4326");
|
||||||
|
|
||||||
@ -341,16 +312,16 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
// sql
|
// sql
|
||||||
String sql = "select gid, state_name, the_geom from pgstates where persons between %low% and %high% and state_abbr = '%state%'";
|
String sql = "select gid, state_name, the_geom from pgstates where persons between %low% and %high% and state_abbr = '%state%'";
|
||||||
|
|
||||||
//set-up the virtual table
|
// set-up the virtual table
|
||||||
final GSVirtualTableEncoder vte = new GSVirtualTableEncoder();
|
final GSVirtualTableEncoder vte = new GSVirtualTableEncoder();
|
||||||
vte.setName(nativeName);
|
vte.setName(nativeName);
|
||||||
vte.setSql(sql);
|
vte.setSql(sql);
|
||||||
vte.addVirtualTableGeometry(vtGeom);
|
vte.addVirtualTableGeometry(vtGeom);
|
||||||
vte.addVirtualTableParameter(vtParam1);
|
vte.addVirtualTableParameter(vtParam1);
|
||||||
vte.addVirtualTableParameter(vtParam2);
|
vte.addVirtualTableParameter(vtParam2);
|
||||||
fte.setMetadataVirtualTable(vte); //Set the virtual table
|
fte.setMetadataVirtualTable(vte); // Set the virtual table
|
||||||
|
|
||||||
//modif the vte
|
// modif the vte
|
||||||
vte.delVirtualTableGeometry("the_geom");
|
vte.delVirtualTableGeometry("the_geom");
|
||||||
vte.addVirtualTableGeometry("the_geom", "MultiPolygon", "4326");
|
vte.addVirtualTableGeometry("the_geom", "MultiPolygon", "4326");
|
||||||
|
|
||||||
@ -358,15 +329,15 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
vte.addVirtualTableParameter(vtParam3);
|
vte.addVirtualTableParameter(vtParam3);
|
||||||
vte.addKeyColumn("gid");
|
vte.addKeyColumn("gid");
|
||||||
|
|
||||||
//Layer encoder
|
// Layer encoder
|
||||||
//-------------
|
// -------------
|
||||||
GSLayerEncoder layerEncoder = new GSLayerEncoder();
|
GSLayerEncoder layerEncoder = new GSLayerEncoder();
|
||||||
layerEncoder.setEnabled(true);
|
layerEncoder.setEnabled(true);
|
||||||
layerEncoder.setQueryable(true);
|
layerEncoder.setQueryable(true);
|
||||||
layerEncoder.setDefaultStyle("polygon");
|
layerEncoder.setDefaultStyle("polygon");
|
||||||
|
|
||||||
// test insert
|
// test insert
|
||||||
//------------
|
// ------------
|
||||||
publisher.createWorkspace(DEFAULT_WS);
|
publisher.createWorkspace(DEFAULT_WS);
|
||||||
boolean published = publisher.publishDBLayer(DEFAULT_WS, storeName, fte, layerEncoder);
|
boolean published = publisher.publishDBLayer(DEFAULT_WS, storeName, fte, layerEncoder);
|
||||||
assertTrue("Publication unsuccessful", published);
|
assertTrue("Publication unsuccessful", published);
|
||||||
|
|||||||
@ -29,9 +29,11 @@ package it.geosolutions.geoserver.rest.publisher;
|
|||||||
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.ParameterConfigure;
|
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.ParameterConfigure;
|
||||||
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTCoverageStore;
|
import it.geosolutions.geoserver.rest.decoder.RESTCoverageStore;
|
||||||
|
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
||||||
import it.geosolutions.geoserver.rest.encoder.coverage.GSImageMosaicEncoder;
|
import it.geosolutions.geoserver.rest.encoder.coverage.GSImageMosaicEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.dimensions.GSCoverageDimensionEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
||||||
|
|
||||||
@ -42,6 +44,7 @@ import java.io.IOException;
|
|||||||
import org.apache.commons.httpclient.NameValuePair;
|
import org.apache.commons.httpclient.NameValuePair;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
@ -105,6 +108,16 @@ public class GeoserverRESTImageMosaicTest extends GeoserverRESTTest {
|
|||||||
coverageEncoder.setSRS("EPSG:4326");
|
coverageEncoder.setSRS("EPSG:4326");
|
||||||
coverageEncoder.setSUGGESTED_TILE_SIZE("256,256");
|
coverageEncoder.setSUGGESTED_TILE_SIZE("256,256");
|
||||||
coverageEncoder.setUSE_JAI_IMAGEREAD(true);
|
coverageEncoder.setUSE_JAI_IMAGEREAD(true);
|
||||||
|
|
||||||
|
GSVersionDecoder v=reader.getGeoserverVersion();
|
||||||
|
if (v.getVersion().equals(GSVersionDecoder.VERSION.getVersion(GSVersionDecoder.VERSION.v24.toString()))){
|
||||||
|
// New style dimensions (since gs-2.4.x)
|
||||||
|
GSCoverageDimensionEncoder gsCoverageDimensionEncoder = new GSCoverageDimensionEncoder(
|
||||||
|
"GRAY_INDEX", "GridSampleDimension[-Infinity,Infinity]", "-inf", "inf",
|
||||||
|
"dobson units³", "REAL_32BITS");
|
||||||
|
coverageEncoder.addCoverageDimensionInfo(gsCoverageDimensionEncoder);
|
||||||
|
} else {
|
||||||
|
// Old stile setting code
|
||||||
// activate time
|
// activate time
|
||||||
final GSDimensionInfoEncoder time=new GSDimensionInfoEncoder(true);
|
final GSDimensionInfoEncoder time=new GSDimensionInfoEncoder(true);
|
||||||
time.setPresentation(Presentation.LIST);
|
time.setPresentation(Presentation.LIST);
|
||||||
@ -112,6 +125,9 @@ public class GeoserverRESTImageMosaicTest extends GeoserverRESTTest {
|
|||||||
coverageEncoder.setMetadata("time", time);
|
coverageEncoder.setMetadata("time", time);
|
||||||
// not active elevation
|
// not active elevation
|
||||||
coverageEncoder.setMetadata("elevation", new GSDimensionInfoEncoder());
|
coverageEncoder.setMetadata("elevation", new GSDimensionInfoEncoder());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
assertTrue(publisher.createWorkspace(wsName));
|
assertTrue(publisher.createWorkspace(wsName));
|
||||||
|
|
||||||
|
|||||||
10
src/test/resources/testdata/coverageExample.xml
vendored
10
src/test/resources/testdata/coverageExample.xml
vendored
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
<coverage>
|
<coverage>
|
||||||
<name>granuleTestMosaic</name>
|
<name>granuleTestMosaic</name>
|
||||||
<nativeName>granuleTestMosaic</nativeName>
|
<nativeName>granuleTestMosaic</nativeName>
|
||||||
@ -27,15 +26,18 @@
|
|||||||
</metadataLink>
|
</metadataLink>
|
||||||
</metadataLinks>
|
</metadataLinks>
|
||||||
<nativeCRS>GEOGCS["WGS 84", 
|
<nativeCRS>GEOGCS["WGS 84", 
|
||||||
DATUM["World Geodetic System 1984", 
|
DATUM["World Geodetic
|
||||||
SPHEROID["WGS 84", 6378137.0, 298.257223563,
|
System 1984", 
|
||||||
|
SPHEROID["WGS 84", 6378137.0,
|
||||||
|
298.257223563,
|
||||||
AUTHORITY["EPSG","7030"]], 
|
AUTHORITY["EPSG","7030"]], 
|
||||||
AUTHORITY["EPSG","6326"]], 
|
AUTHORITY["EPSG","6326"]], 
|
||||||
PRIMEM["Greenwich", 0.0,
|
PRIMEM["Greenwich", 0.0,
|
||||||
AUTHORITY["EPSG","8901"]], 
|
AUTHORITY["EPSG","8901"]], 
|
||||||
UNIT["degree", 0.017453292519943295], 
|
UNIT["degree", 0.017453292519943295], 
|
||||||
AXIS["Geodetic longitude", EAST], 
|
AXIS["Geodetic longitude", EAST], 
|
||||||
AXIS["Geodetic latitude", NORTH], 
|
AXIS["Geodetic
|
||||||
|
latitude", NORTH], 
|
||||||
AUTHORITY["EPSG","4326"]]</nativeCRS>
|
AUTHORITY["EPSG","4326"]]</nativeCRS>
|
||||||
<srs>EPSG:4326</srs>
|
<srs>EPSG:4326</srs>
|
||||||
<nativeBoundingBox>
|
<nativeBoundingBox>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user