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,23 +75,22 @@ 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return kwdsList;
|
return kwdsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getNameSpace() {
|
public String getNameSpace() {
|
||||||
return rootElem.getChild("namespace").getChildText("name");
|
return rootElem.getChild("namespace").getChildText("name");
|
||||||
}
|
}
|
||||||
@ -154,79 +154,77 @@ public class RESTResource {
|
|||||||
throw new UnsupportedOperationException("This method is specific for RESTFeatureType");
|
throw new UnsupportedOperationException("This method is specific for RESTFeatureType");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
*/
|
*/
|
||||||
public List<GSMetadataLinkInfoEncoder> getEncodedMetadataLinkInfoList() {
|
public List<GSMetadataLinkInfoEncoder> getEncodedMetadataLinkInfoList() {
|
||||||
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
|
||||||
metaLinkEnc.setType(metaLink.getChildText(ResourceMetadataLinkInfo.type.name()));
|
.setType(metaLink.getChildText(ResourceMetadataLinkInfo.type.name()));
|
||||||
metaLinkEnc.setMetadataType(metaLink.getChildText(ResourceMetadataLinkInfo.metadataType.name()));
|
metaLinkEnc.setMetadataType(metaLink
|
||||||
metaLinkEnc.setContent(metaLink.getChildText(ResourceMetadataLinkInfo.content.name()));
|
.getChildText(ResourceMetadataLinkInfo.metadataType.name()));
|
||||||
metaLinksList.add(metaLinkEnc);
|
metaLinkEnc.setContent(metaLink.getChildText(ResourceMetadataLinkInfo.content
|
||||||
}
|
.name()));
|
||||||
|
metaLinksList.add(metaLinkEnc);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return metaLinksList;
|
return metaLinksList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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());
|
||||||
{
|
for (Element coverageDimension : dimensions) {
|
||||||
dimensionList = new ArrayList<GSCoverageDimensionEncoder>(dimensions.size());
|
final String name = coverageDimension.getChildText("name");
|
||||||
for (Element coverageDimension : dimensions)
|
final String description = coverageDimension.getChildText("description");
|
||||||
{
|
String rangeMin = null;
|
||||||
final String name = coverageDimension.getChildText("name");
|
String rangeMax = null;
|
||||||
final String description = coverageDimension.getChildText("description");
|
final Element rangeElement = coverageDimension.getChild("range");
|
||||||
String rangeMin = null;
|
if (rangeElement != null) {
|
||||||
String rangeMax = null;
|
rangeMin = rangeElement.getChildText("min");
|
||||||
final Element rangeElement = coverageDimension.getChild("range");
|
rangeMax = rangeElement.getChildText("max");
|
||||||
if(rangeElement != null)
|
}
|
||||||
{
|
final String unit = coverageDimension.getChildText("unit");
|
||||||
rangeMin = rangeElement.getChildText("min");
|
String dimensionTypeName = null;
|
||||||
rangeMax = rangeElement.getChildText("max");
|
final Element dimensionTypeElement = coverageDimension
|
||||||
}
|
.getChild("dimensionType");
|
||||||
final String unit = coverageDimension.getChildText("unit");
|
if (dimensionTypeElement != null) {
|
||||||
String dimensionTypeName = null;
|
dimensionTypeName = dimensionTypeElement.getChildText("name");
|
||||||
final Element dimensionTypeElement = coverageDimension.getChild("dimensionType");
|
}
|
||||||
if(dimensionTypeElement != null)
|
final GSCoverageDimensionEncoder coverageDimensionEncoder = new GSCoverageDimensionEncoder(
|
||||||
{
|
name, description, rangeMin, rangeMax, unit, dimensionTypeName);
|
||||||
dimensionTypeName = dimensionTypeElement.getChildText("name");
|
dimensionList.add(coverageDimensionEncoder);
|
||||||
}
|
}
|
||||||
final GSCoverageDimensionEncoder coverageDimensionEncoder = new GSCoverageDimensionEncoder(name, description, rangeMin, rangeMax, unit, dimensionTypeName);
|
|
||||||
dimensionList.add(coverageDimensionEncoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dimensionList;
|
return dimensionList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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,57 +47,58 @@ 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 METADATA="metadata";
|
|
||||||
public final static String KEYWORDS="keywords";
|
|
||||||
public final static String METADATALINKS="metadataLinks";
|
|
||||||
public final static String DIMENSIONS="dimensions";
|
|
||||||
|
|
||||||
final private GSMetadataEncoder metadata = new GSMetadataEncoder();
|
public final static String NATIVENAME = "nativeName";
|
||||||
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{
|
public final static String METADATA = "metadata";
|
||||||
public GSMetadataEncoder() {
|
|
||||||
super(METADATA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public final static String KEYWORDS = "keywords";
|
||||||
* @param rootName
|
|
||||||
* Actually 'feature' or 'coverage'
|
|
||||||
* @see GSFeatureTypeEncoder
|
|
||||||
* @see GSCoverageEncoder
|
|
||||||
*/
|
|
||||||
protected GSResourceEncoder(final String rootName) {
|
|
||||||
super(rootName);
|
|
||||||
add("enabled", "true");
|
|
||||||
|
|
||||||
// Link members to the parent
|
public final static String METADATALINKS = "metadataLinks";
|
||||||
addContent(metadata.getRoot());
|
|
||||||
addContent(keywordsListEncoder);
|
|
||||||
addContent(metadataLinksListEncoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnabled(boolean enabled) {
|
final private GSMetadataEncoder metadata = new GSMetadataEncoder();
|
||||||
set("enabled", (enabled) ? "true" : "false");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
final private Element keywordsListEncoder = new Element(KEYWORDS);
|
||||||
|
|
||||||
/**
|
final private Element metadataLinksListEncoder = new Element(METADATALINKS);
|
||||||
* @param key
|
|
||||||
* @param dimensionInfo
|
private class GSMetadataEncoder extends NestedElementEncoder {
|
||||||
*/
|
public GSMetadataEncoder() {
|
||||||
protected void addMetadata(String key, XmlElement dimensionInfo) {
|
super(METADATA);
|
||||||
metadata.add(key, dimensionInfo.getRoot());
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param rootName Actually 'feature' or 'coverage'
|
||||||
|
* @see GSFeatureTypeEncoder
|
||||||
|
* @see GSCoverageEncoder
|
||||||
|
*/
|
||||||
|
protected GSResourceEncoder(final String rootName) {
|
||||||
|
super(rootName);
|
||||||
|
add("enabled", "true");
|
||||||
|
|
||||||
|
// Link members to the parent
|
||||||
|
addContent(metadata.getRoot());
|
||||||
|
addContent(keywordsListEncoder);
|
||||||
|
addContent(metadataLinksListEncoder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
set("enabled", (enabled) ? "true" : "false");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param key
|
||||||
|
* @param dimensionInfo
|
||||||
|
*/
|
||||||
|
protected void addMetadata(String key, XmlElement dimensionInfo) {
|
||||||
|
metadata.add(key, dimensionInfo.getRoot());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #setMetadataDimension(String, GSDimensionInfoEncoder)} this method will be set as protected for internal use only
|
* @deprecated Use {@link #setMetadataDimension(String, GSDimensionInfoEncoder)} this method will be set as protected for internal use only
|
||||||
@ -124,20 +124,21 @@ 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMetadataDimension(String key, GSDimensionInfoEncoder dimensionInfo) {
|
public void setMetadataDimension(String key, GSDimensionInfoEncoder dimensionInfo) {
|
||||||
setMetadataDimension(key, dimensionInfo, false);
|
setMetadataDimension(key, dimensionInfo, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMetadataString(String key, String value) {
|
public void setMetadataString(String key, String value) {
|
||||||
metadata.set(key, value);
|
metadata.set(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -147,139 +148,84 @@ 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
|
|
||||||
* the name of the metadata to add (f.e.: elevation, time)
|
|
||||||
* @return true if something is removed, false otherwise
|
|
||||||
*/
|
|
||||||
public boolean delMetadata(String key) {
|
|
||||||
return metadata.remove(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param key the name of the metadata to add (f.e.: elevation, time)
|
||||||
|
* @return true if something is removed, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean delMetadata(String 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);
|
||||||
keywordsListEncoder.addContent(el);
|
keywordsListEncoder.addContent(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete a keyword from the list
|
* delete a keyword from the list
|
||||||
*
|
*
|
||||||
* @param keyword
|
* @param keyword
|
||||||
* @return true if something is removed, false otherwise
|
* @return true if something is removed, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean delKeyword(final String keyword) {
|
public boolean delKeyword(final String keyword) {
|
||||||
final Element el = new Element("string");
|
final Element el = new Element("string");
|
||||||
el.setText(keyword);
|
el.setText(keyword);
|
||||||
return (keywordsListEncoder.removeContent(new Filter() {
|
return (keywordsListEncoder.removeContent(new Filter() {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public boolean matches(Object obj) {
|
public boolean matches(Object obj) {
|
||||||
if (((Element) obj).getText().equals(keyword)) {
|
if (((Element) obj).getText().equals(keyword)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
})).size() == 0 ? false : true;
|
})).size() == 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a MetadataLinkInfo to the GeoServer Resource
|
* Adds a MetadataLinkInfo to the GeoServer Resource
|
||||||
*
|
*
|
||||||
* @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());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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, String content) {
|
||||||
public void addMetadataLinkInfo(String type, String metadataType,
|
final GSMetadataLinkInfoEncoder mde = new GSMetadataLinkInfoEncoder(type, metadataType,
|
||||||
String content) {
|
content);
|
||||||
final GSMetadataLinkInfoEncoder mde = new GSMetadataLinkInfoEncoder(
|
metadataLinksListEncoder.addContent(mde.getRoot());
|
||||||
type, metadataType, content);
|
}
|
||||||
metadataLinksListEncoder.addContent(mde.getRoot());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes a metadataLinkInfo from the list using the metadataURL
|
|
||||||
* (MetadataLinkInfo content)
|
|
||||||
*
|
|
||||||
* @author Emmanuel Blondel
|
|
||||||
*
|
|
||||||
* @param metadataURL
|
|
||||||
* @return true if something is removed, false otherwise
|
|
||||||
*/
|
|
||||||
public boolean delMetadataLinkInfo(final String metadataURL) {
|
|
||||||
return (metadataLinksListEncoder
|
|
||||||
.removeContent(GSMetadataLinkInfoEncoder
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a metadataLinkInfo from the list using the metadataURL (MetadataLinkInfo content)
|
||||||
|
*
|
||||||
|
* @param metadataURL
|
||||||
|
* @return true if something is removed, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean delMetadataLinkInfo(final String metadataURL) {
|
||||||
|
return (metadataLinksListEncoder.removeContent(GSMetadataLinkInfoEncoder
|
||||||
|
.getFilterByContent(metadataURL))).size() == 0 ? false : true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reprojection policy for a published layer. One of:
|
* Reprojection policy for a published layer. One of:
|
||||||
@ -289,94 +235,89 @@ public abstract class GSResourceEncoder
|
|||||||
* <li>{@link #NONE} No reprojection (use native CRS)
|
* <li>{@link #NONE} No reprojection (use native CRS)
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public enum ProjectionPolicy {
|
public enum ProjectionPolicy {
|
||||||
/** Reproject from native to declared CRS */
|
/** Reproject from native to declared CRS */
|
||||||
REPROJECT_TO_DECLARED,
|
REPROJECT_TO_DECLARED,
|
||||||
/** Use the declared CRS (ignore native) */
|
/** Use the declared CRS (ignore native) */
|
||||||
FORCE_DECLARED,
|
FORCE_DECLARED,
|
||||||
/** Keep native */
|
/** Keep native */
|
||||||
NONE
|
NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static String PROJECTIONPOLICY = "projectionPolicy";
|
private final static String PROJECTIONPOLICY = "projectionPolicy";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NONE, REPROJECT_TO_DECLARED, FORCE_DECLARED
|
* NONE, REPROJECT_TO_DECLARED, FORCE_DECLARED
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected void addProjectionPolicy(ProjectionPolicy policy) {
|
protected void addProjectionPolicy(ProjectionPolicy policy) {
|
||||||
add(PROJECTIONPOLICY, policy.toString());
|
add(PROJECTIONPOLICY, policy.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NONE, REPROJECT_TO_DECLARED, FORCE_DECLARED
|
* NONE, REPROJECT_TO_DECLARED, FORCE_DECLARED
|
||||||
*/
|
*/
|
||||||
public void setProjectionPolicy(ProjectionPolicy policy) {
|
public void setProjectionPolicy(ProjectionPolicy policy) {
|
||||||
set(PROJECTIONPOLICY, policy.toString());
|
set(PROJECTIONPOLICY, policy.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the 'name' node with a text value from 'name'
|
* Add the 'name' node with a text value from 'name'
|
||||||
*
|
*
|
||||||
* @note REQUIRED to configure a resource
|
* @note REQUIRED to configure a resource
|
||||||
*/
|
*/
|
||||||
protected void addName(final String name) {
|
protected void addName(final String name) {
|
||||||
add(NAME, name);
|
add(NAME, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set or modify the 'name' node with a text value from 'name'
|
* Set or modify the 'name' node with a text value from 'name'
|
||||||
*
|
*
|
||||||
* @note REQUIRED to configure a resource
|
* @note REQUIRED to configure a resource
|
||||||
*/
|
*/
|
||||||
public void setName(final String name) {
|
public void setName(final String name) {
|
||||||
set(NAME, name);
|
set(NAME, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
final Element nameNode = ElementUtils.contains(getRoot(), NAME, 1);
|
final Element nameNode = ElementUtils.contains(getRoot(), NAME, 1);
|
||||||
if (nameNode != null)
|
if (nameNode != null)
|
||||||
return nameNode.getText();
|
return nameNode.getText();
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the 'nativename' node with a text value from 'name'
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected void addNativeName(final String nativename) {
|
||||||
|
add(NATIVENAME, nativename);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add 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 'name' node.
|
||||||
*/
|
*
|
||||||
protected void addNativeName(final String nativename) {
|
*/
|
||||||
add(NATIVENAME, nativename);
|
public void setNativeName(final String nativename) {
|
||||||
}
|
set(NATIVENAME, nativename);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
* 'name' node.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void setNativeName(final String nativename) {
|
|
||||||
set(NATIVENAME, nativename);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the nativeName
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String getNativeName() {
|
|
||||||
final Element nameNode = ElementUtils.contains(getRoot(), NATIVENAME, 1);
|
|
||||||
if (nameNode != null)
|
|
||||||
return nameNode.getText();
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the nativeName
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getNativeName() {
|
||||||
|
final Element nameNode = ElementUtils.contains(getRoot(), NATIVENAME, 1);
|
||||||
|
if (nameNode != null)
|
||||||
|
return nameNode.getText();
|
||||||
|
else
|
||||||
|
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'
|
||||||
*/
|
*/
|
||||||
@ -410,116 +353,124 @@ public abstract class GSResourceEncoder
|
|||||||
set(ABSTRACT, _abstract);
|
set(ABSTRACT, _abstract);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static String TITLE = "title";
|
private final static String TITLE = "title";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the 'title' node with a text value from 'title'
|
* Add the 'title' node with a text value from 'title'
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected void addTitle(final String title) {
|
protected void addTitle(final String title) {
|
||||||
add(TITLE, title);
|
add(TITLE, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set or modify the 'title' node with a text value from 'title'
|
* Set or modify the 'title' node with a text value from 'title'
|
||||||
*/
|
*/
|
||||||
public void setTitle(final String title) {
|
public void setTitle(final String title) {
|
||||||
set(TITLE, title);
|
set(TITLE, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static String SRS = "srs";
|
private final static String SRS = "srs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the 'SRS' node with a text value from 'srs'
|
* Add the 'SRS' node with a text value from 'srs'
|
||||||
*/
|
*/
|
||||||
protected void addSRS(final String srs) {
|
protected void addSRS(final String srs) {
|
||||||
add(SRS, srs);
|
add(SRS, srs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set or modify the 'SRS' node with a text value from 'srs'
|
* Set or modify the 'SRS' node with a text value from 'srs'
|
||||||
*/
|
*/
|
||||||
public void setSRS(final String srs) {
|
public void setSRS(final String srs) {
|
||||||
set(SRS, srs);
|
set(SRS, srs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static String NATIVECRS = "nativeCRS";
|
private final static String NATIVECRS = "nativeCRS";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the 'nativeCRS' node with a text value from 'nativeCRS'
|
* Add the 'nativeCRS' node with a text value from 'nativeCRS'
|
||||||
*/
|
*/
|
||||||
protected void addNativeCRS(final String nativeCRS) {
|
protected void addNativeCRS(final String nativeCRS) {
|
||||||
add(NATIVECRS, nativeCRS);
|
add(NATIVECRS, nativeCRS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set or modify the 'nativeCRS' node with a text value from 'nativeCRS'
|
* Set or modify the 'nativeCRS' node with a text value from 'nativeCRS'
|
||||||
*/
|
*/
|
||||||
public void setNativeCRS(final String nativeCRS) {
|
public void setNativeCRS(final String nativeCRS) {
|
||||||
set(NATIVECRS, nativeCRS);
|
set(NATIVECRS, nativeCRS);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 LATLONBBMINY = "latLonBoundingBox/miny";
|
|
||||||
private final static String LATLONBBMAXY = "latLonBoundingBox/maxy";
|
|
||||||
private final static String LATLONBBCRS = "latLonBoundingBox/crs";
|
|
||||||
|
|
||||||
/**
|
private final static String LATLONBBMAXX = "latLonBoundingBox/maxx";
|
||||||
*
|
|
||||||
* @param minx
|
|
||||||
* @param maxy
|
|
||||||
* @param maxx
|
|
||||||
* @param miny
|
|
||||||
* @param crs
|
|
||||||
*/
|
|
||||||
protected void addLatLonBoundingBox(double minx, double miny, double maxx,
|
|
||||||
double maxy, final String crs) {
|
|
||||||
add(LATLONBBMINX, String.valueOf(minx));
|
|
||||||
add(LATLONBBMINY, String.valueOf(miny));
|
|
||||||
add(LATLONBBMAXY, String.valueOf(maxy));
|
|
||||||
add(LATLONBBMAXX, String.valueOf(maxx));
|
|
||||||
add(LATLONBBCRS, crs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLatLonBoundingBox(double minx, double miny, double maxx,
|
private final static String LATLONBBMINY = "latLonBoundingBox/miny";
|
||||||
double maxy, final String crs) {
|
|
||||||
set(LATLONBBMINX, String.valueOf(minx));
|
|
||||||
set(LATLONBBMAXY, String.valueOf(maxy));
|
|
||||||
set(LATLONBBMAXX, String.valueOf(maxx));
|
|
||||||
set(LATLONBBMINY, String.valueOf(miny));
|
|
||||||
set(LATLONBBCRS, crs);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static String NATIVEBBMINX = "nativeBoundingBox/minx";
|
private final static String LATLONBBMAXY = "latLonBoundingBox/maxy";
|
||||||
private final static String NATIVEBBMAXX = "nativeBoundingBox/maxx";
|
|
||||||
private final static String NATIVEBBMINY = "nativeBoundingBox/miny";
|
|
||||||
private final static String NATIVEBBMAXY = "nativeBoundingBox/maxy";
|
|
||||||
private final static String NATIVEBBCRS = "nativeBoundingBox/crs";
|
|
||||||
|
|
||||||
/**
|
private final static String LATLONBBCRS = "latLonBoundingBox/crs";
|
||||||
* @param minx
|
|
||||||
* @param maxy
|
|
||||||
* @param maxx
|
|
||||||
* @param miny
|
|
||||||
* @param crs
|
|
||||||
*/
|
|
||||||
protected void addNativeBoundingBox(double minx, double miny, double maxx,
|
|
||||||
double maxy, final String crs) {
|
|
||||||
add(NATIVEBBMINX, String.valueOf(minx));
|
|
||||||
add(NATIVEBBMAXY, String.valueOf(maxy));
|
|
||||||
add(NATIVEBBMAXX, String.valueOf(maxx));
|
|
||||||
add(NATIVEBBMINY, String.valueOf(miny));
|
|
||||||
add(NATIVEBBCRS, crs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNativeBoundingBox(double minx, double miny, double maxx,
|
/**
|
||||||
double maxy, final String crs) {
|
*
|
||||||
set(NATIVEBBMINX, String.valueOf(minx));
|
* @param minx
|
||||||
set(NATIVEBBMAXY, String.valueOf(maxy));
|
* @param maxy
|
||||||
set(NATIVEBBMAXX, String.valueOf(maxx));
|
* @param maxx
|
||||||
set(NATIVEBBMINY, String.valueOf(miny));
|
* @param miny
|
||||||
set(NATIVEBBCRS, crs);
|
* @param crs
|
||||||
}
|
*/
|
||||||
|
protected void addLatLonBoundingBox(double minx, double miny, double maxx, double maxy,
|
||||||
|
final String crs) {
|
||||||
|
add(LATLONBBMINX, String.valueOf(minx));
|
||||||
|
add(LATLONBBMINY, String.valueOf(miny));
|
||||||
|
add(LATLONBBMAXY, String.valueOf(maxy));
|
||||||
|
add(LATLONBBMAXX, String.valueOf(maxx));
|
||||||
|
add(LATLONBBCRS, crs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLatLonBoundingBox(double minx, double miny, double maxx, double maxy,
|
||||||
|
final String crs) {
|
||||||
|
set(LATLONBBMINX, String.valueOf(minx));
|
||||||
|
set(LATLONBBMAXY, String.valueOf(maxy));
|
||||||
|
set(LATLONBBMAXX, String.valueOf(maxx));
|
||||||
|
set(LATLONBBMINY, String.valueOf(miny));
|
||||||
|
set(LATLONBBCRS, crs);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static String NATIVEBBMINX = "nativeBoundingBox/minx";
|
||||||
|
|
||||||
|
private final static String NATIVEBBMAXX = "nativeBoundingBox/maxx";
|
||||||
|
|
||||||
|
private final static String NATIVEBBMINY = "nativeBoundingBox/miny";
|
||||||
|
|
||||||
|
private final static String NATIVEBBMAXY = "nativeBoundingBox/maxy";
|
||||||
|
|
||||||
|
private final static String NATIVEBBCRS = "nativeBoundingBox/crs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param minx
|
||||||
|
* @param maxy
|
||||||
|
* @param maxx
|
||||||
|
* @param miny
|
||||||
|
* @param crs
|
||||||
|
*/
|
||||||
|
protected void addNativeBoundingBox(double minx, double miny, double maxx, double maxy,
|
||||||
|
final String crs) {
|
||||||
|
add(NATIVEBBMINX, String.valueOf(minx));
|
||||||
|
add(NATIVEBBMAXY, String.valueOf(maxy));
|
||||||
|
add(NATIVEBBMAXX, String.valueOf(maxx));
|
||||||
|
add(NATIVEBBMINY, String.valueOf(miny));
|
||||||
|
add(NATIVEBBCRS, crs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNativeBoundingBox(double minx, double miny, double maxx, double maxy,
|
||||||
|
final String crs) {
|
||||||
|
set(NATIVEBBMINX, String.valueOf(minx));
|
||||||
|
set(NATIVEBBMAXY, String.valueOf(maxy));
|
||||||
|
set(NATIVEBBMAXX, String.valueOf(maxx));
|
||||||
|
set(NATIVEBBMINY, String.valueOf(miny));
|
||||||
|
set(NATIVEBBCRS, crs);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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,25 +41,70 @@ import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
|||||||
*/
|
*/
|
||||||
public class GSCoverageEncoder extends GSResourceEncoder {
|
public class GSCoverageEncoder extends GSResourceEncoder {
|
||||||
|
|
||||||
public GSCoverageEncoder() {
|
public final static String DIMENSIONS = "dimensions";
|
||||||
|
|
||||||
|
final private Element dimensionsEncoder = new Element(DIMENSIONS);
|
||||||
|
|
||||||
|
public GSCoverageEncoder() {
|
||||||
super("coverage");
|
super("coverage");
|
||||||
}
|
addContent(dimensionsEncoder);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param key
|
* @param key
|
||||||
* @param dimensionInfo
|
* @param dimensionInfo
|
||||||
* @deprecated Use {@link GSResourceEncoder#addMetadataDimension(String, GSDimensionInfoEncoder)} this method will be removed soon
|
* @deprecated Use {@link GSResourceEncoder#addMetadataDimension(String, GSDimensionInfoEncoder)} this method will be removed soon
|
||||||
*/
|
*/
|
||||||
protected void addMetadata(String key, GSDimensionInfoEncoder dimensionInfo) {
|
protected void addMetadata(String key, GSDimensionInfoEncoder dimensionInfo) {
|
||||||
super.addMetadata(key, dimensionInfo);
|
super.addMetadata(key, dimensionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link GSResourceEncoder#setMetadataDimension(String, GSDimensionInfoEncoder)} this method will be removed soon
|
* @deprecated Use {@link GSResourceEncoder#setMetadataDimension(String, GSDimensionInfoEncoder)} this method will be removed soon
|
||||||
* @param key
|
* @param key
|
||||||
* @param dimensionInfo
|
* @param dimensionInfo
|
||||||
*/
|
*/
|
||||||
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,30 +31,34 @@ 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>
|
||||||
* <min>-2.147483648E9</min>
|
* <min>-2.147483648E9</min>
|
||||||
* <max>2.147483647E9</max>
|
* <max>2.147483647E9</max>
|
||||||
* </range>
|
* </range>
|
||||||
* <unit>dobson units³</unit>
|
* <unit>dobson units³</unit>
|
||||||
* <dimensionType>
|
* <dimensionType>
|
||||||
* <name>REAL_32BITS</name>
|
* <name>REAL_32BITS</name>
|
||||||
* </dimensionType>
|
* </dimensionType>
|
||||||
*</coverageDimension>
|
* </coverageDimension>
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author Henry Rotzoll (henry.rotzoll@dlr.de)
|
* @author Henry Rotzoll (henry.rotzoll@dlr.de)
|
||||||
@ -62,333 +66,328 @@ 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
|
||||||
*
|
*
|
||||||
*/
|
*
|
||||||
private static class filterByContent implements Filter {
|
*/
|
||||||
|
private static class filterByContent implements Filter {
|
||||||
|
|
||||||
final private String key;
|
final private String key;
|
||||||
|
|
||||||
public filterByContent(String content) {
|
public filterByContent(String content) {
|
||||||
this.key = content;
|
this.key = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
}
|
||||||
}
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a Filter using the GSCoverageDimensionEncoder content (GSCoverageDimensionEncoder name)
|
* Get a Filter using the GSCoverageDimensionEncoder content (GSCoverageDimensionEncoder name)
|
||||||
*
|
*
|
||||||
* @param content
|
* @param content
|
||||||
* @return the filter
|
* @return the filter
|
||||||
*/
|
*/
|
||||||
public static Filter getFilterByContent(String content) {
|
public static Filter getFilterByContent(String content) {
|
||||||
return new filterByContent(content);
|
return new filterByContent(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new GSCoverageDimensionEncoder
|
* Constructs a new GSCoverageDimensionEncoder
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public GSCoverageDimensionEncoder() {
|
public GSCoverageDimensionEncoder() {
|
||||||
super("coverageDimension");
|
super("coverageDimension");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs quickly a GSCoverageDimensionEncoder info
|
* Constructs quickly a GSCoverageDimensionEncoder info
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @param description
|
* @param description
|
||||||
* @param rangeMin
|
* @param rangeMin
|
||||||
* @param rangeMax
|
* @param rangeMax
|
||||||
* @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,
|
||||||
super("coverageDimension");
|
String rangeMax, String unit, String dimensionTypeName) {
|
||||||
this.setup(name, description, rangeMin, rangeMax, unit, dimensionTypeName);
|
super("coverageDimension");
|
||||||
}
|
this.setup(name, description, rangeMin, rangeMax, unit, dimensionTypeName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set-up quickly a GSCoverageDimensionEncoder info
|
* Set-up quickly a GSCoverageDimensionEncoder info
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @param description
|
* @param description
|
||||||
* @param rangeMin
|
* @param rangeMin
|
||||||
* @param rangeMax
|
* @param rangeMax
|
||||||
* @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
|
||||||
|
*
|
||||||
|
* @param memberName
|
||||||
|
* @return the value of the GSCoverageDimensionEncoder member
|
||||||
|
*/
|
||||||
|
protected String getMember(String memberName) {
|
||||||
|
Element el = this.getRoot().getChild(memberName.toString());
|
||||||
|
if (el != null)
|
||||||
|
return el.getTextTrim();
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value of the GSCoverageDimensionEncoder member
|
* Deletes a GSCoverageDimensionEncoder member
|
||||||
*
|
*
|
||||||
* @param memberName
|
* @param memberName
|
||||||
* @return the value of the GSCoverageDimensionEncoder member
|
* @return true if the GSCoverageDimensionEncoder member is removed
|
||||||
*/
|
*/
|
||||||
protected String getMember(String memberName) {
|
protected boolean delMemberIfExists(String memberName) {
|
||||||
Element el = this.getRoot().getChild(memberName.toString());
|
if (ElementUtils.contains(getRoot(), memberName) != null) {
|
||||||
if (el != null)
|
return ElementUtils.remove(this.getRoot(),
|
||||||
return el.getTextTrim();
|
this.getRoot().getChild(memberName.toString()));
|
||||||
else
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
return false;
|
||||||
* Deletes a GSCoverageDimensionEncoder member
|
}
|
||||||
*
|
|
||||||
* @param memberName
|
|
||||||
* @return true if the GSCoverageDimensionEncoder member is removed
|
|
||||||
*/
|
|
||||||
protected boolean delMemberIfExists(String memberName) {
|
|
||||||
if(ElementUtils.contains(getRoot(), memberName) != null)
|
|
||||||
{
|
|
||||||
return ElementUtils.remove(this.getRoot(), this.getRoot().getChild(memberName.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
/**
|
||||||
}
|
* Set a GSCoverageDimensionEncoder member
|
||||||
|
*
|
||||||
|
* @param memberName
|
||||||
|
* @param memberValue
|
||||||
|
*/
|
||||||
|
protected void setMember(String memberName, String memberValue) {
|
||||||
|
if (memberName != null && !memberName.isEmpty() && memberValue != null
|
||||||
|
&& !memberValue.isEmpty()) {
|
||||||
|
delMemberIfExists(memberName); // delete the element if it already exists
|
||||||
|
addMember(memberName.toString(), memberValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a GSCoverageDimensionEncoder member
|
* adds a GSCoverageDimensionEncoder member
|
||||||
*
|
*
|
||||||
* @param memberName
|
* @param memberName
|
||||||
* @param memberValue
|
* @param memberValue
|
||||||
*/
|
*/
|
||||||
protected void setMember(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()) {
|
||||||
delMemberIfExists(memberName); //delete the element if it already exists
|
set(memberName.toString(), memberValue);
|
||||||
addMember(memberName.toString(), memberValue);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adds a GSCoverageDimensionEncoder member
|
* Set the name
|
||||||
*
|
*
|
||||||
* @param memberName
|
* @param name
|
||||||
* @param memberValue
|
*/
|
||||||
*/
|
public void setName(String name) {
|
||||||
protected void addMember(String memberName, String memberValue) {
|
setMember("name", name);
|
||||||
if(memberName != null && !memberName.isEmpty() && memberValue != null && ! memberValue.isEmpty())
|
}
|
||||||
{
|
|
||||||
set(memberName.toString(), memberValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the name
|
* Deletes the name
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
* @return true if removed
|
||||||
public void setName(String name){
|
*/
|
||||||
setMember("name", name);
|
public boolean delName() {
|
||||||
}
|
return this.delMemberIfExists("name");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the name
|
* Get the description
|
||||||
*
|
*
|
||||||
* @param name
|
* @return description
|
||||||
* @return true if removed
|
*/
|
||||||
*/
|
public String getName() {
|
||||||
public boolean delName(){
|
return this.getMember("name");
|
||||||
return this.delMemberIfExists("name");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the description
|
* Set the description
|
||||||
*
|
*
|
||||||
* @return description
|
* @param description
|
||||||
*/
|
*/
|
||||||
public String getName(){
|
public void setDescription(String description) {
|
||||||
return this.getMember("name");
|
setMember("description", description);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the description
|
* Deletes the description
|
||||||
*
|
*
|
||||||
* @param description
|
* @param description
|
||||||
*/
|
* @return true if removed
|
||||||
public void setDescription(String description){
|
*/
|
||||||
setMember("description", description);
|
public boolean delDescription() {
|
||||||
}
|
return this.delMemberIfExists("description");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the description
|
* Get the description
|
||||||
*
|
*
|
||||||
* @param description
|
* @return description
|
||||||
* @return true if removed
|
*/
|
||||||
*/
|
public String getDescription() {
|
||||||
public boolean delDescription(){
|
return this.getMember("description");
|
||||||
return this.delMemberIfExists("description");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the description
|
* Set the range
|
||||||
*
|
*
|
||||||
* @return description
|
* @param range
|
||||||
*/
|
*/
|
||||||
public String getDescription(){
|
public void setRange(String rangeMin, String rangeMax) {
|
||||||
return this.getMember("description");
|
if (rangeMin != null && !rangeMin.isEmpty() && rangeMax != null && !rangeMax.isEmpty()) {
|
||||||
}
|
remove("range");
|
||||||
|
|
||||||
/**
|
final Element rangeElement = new Element("range");
|
||||||
* Set the range
|
final Element rangeMinElement = new Element("min");
|
||||||
*
|
rangeMinElement.setText(rangeMin);
|
||||||
* @param range
|
final Element rangeMaxElement = new Element("max");
|
||||||
*/
|
rangeMaxElement.setText(rangeMax);
|
||||||
public void setRange(String rangeMin, String rangeMax){
|
rangeElement.addContent(rangeMinElement);
|
||||||
if(rangeMin != null && !rangeMin.isEmpty() && rangeMax != null && !rangeMax.isEmpty())
|
rangeElement.addContent(rangeMaxElement);
|
||||||
{
|
addContent(rangeElement);
|
||||||
remove("range");
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final Element rangeElement = new Element("range");
|
/**
|
||||||
final Element rangeMinElement = new Element("min");
|
* Deletes the range
|
||||||
rangeMinElement.setText(rangeMin);
|
*
|
||||||
final Element rangeMaxElement = new Element("max");
|
* @param range
|
||||||
rangeMaxElement.setText(rangeMax);
|
* @return true if removed
|
||||||
rangeElement.addContent(rangeMinElement);
|
*/
|
||||||
rangeElement.addContent(rangeMaxElement);
|
public boolean delRange() {
|
||||||
addContent(rangeElement);
|
return this.delMemberIfExists("range");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the range
|
* Get the range min
|
||||||
*
|
*
|
||||||
* @param range
|
* @return range min
|
||||||
* @return true if removed
|
*/
|
||||||
*/
|
public String getRangeMin() {
|
||||||
public boolean delRange(){
|
final Element range = this.getRoot().getChild("range");
|
||||||
return this.delMemberIfExists("range");
|
if (range != null) {
|
||||||
}
|
return range.getChildText("min");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
return null;
|
||||||
* Get the range min
|
}
|
||||||
*
|
|
||||||
* @return range min
|
|
||||||
*/
|
|
||||||
public String getRangeMin(){
|
|
||||||
final Element range = this.getRoot().getChild("range");
|
|
||||||
if(range != null)
|
|
||||||
{
|
|
||||||
return range.getChildText("min");
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
/**
|
||||||
}
|
* Get the range max
|
||||||
|
*
|
||||||
|
* @return range max
|
||||||
|
*/
|
||||||
|
public String getRangeMax() {
|
||||||
|
final Element range = this.getRoot().getChild("range");
|
||||||
|
if (range != null) {
|
||||||
|
return range.getChildText("max");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
return null;
|
||||||
* Get the range max
|
}
|
||||||
*
|
|
||||||
* @return range max
|
|
||||||
*/
|
|
||||||
public String getRangeMax(){
|
|
||||||
final Element range = this.getRoot().getChild("range");
|
|
||||||
if(range != null)
|
|
||||||
{
|
|
||||||
return range.getChildText("max");
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
/**
|
||||||
}
|
* Set the unit
|
||||||
|
*
|
||||||
|
* @param unit
|
||||||
|
*/
|
||||||
|
public void setUnit(String unit) {
|
||||||
|
setMember("unit", unit);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the unit
|
* Deletes the type
|
||||||
*
|
*
|
||||||
* @param unit
|
* @param type
|
||||||
*/
|
* @return true if removed
|
||||||
public void setUnit(String unit){
|
*/
|
||||||
setMember("unit", unit);
|
public boolean delUnit() {
|
||||||
}
|
return this.delMemberIfExists("unit");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the type
|
* Get the unit
|
||||||
*
|
*
|
||||||
* @param type
|
* @return unit
|
||||||
* @return true if removed
|
*/
|
||||||
*/
|
public String getUnit() {
|
||||||
public boolean delUnit(){
|
return this.getMember("unit");
|
||||||
return this.delMemberIfExists("unit");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the unit
|
* Set the dimensionType
|
||||||
*
|
*
|
||||||
* @return unit
|
* @param dimensionType
|
||||||
*/
|
*/
|
||||||
public String getUnit(){
|
public void setDimensionType(String dimensionTypeName) {
|
||||||
return this.getMember("unit");
|
if (dimensionTypeName != null && !dimensionTypeName.isEmpty()) {
|
||||||
}
|
remove("dimensionType");
|
||||||
|
|
||||||
/**
|
final Element dimensionTypeElement = new Element("dimensionType");
|
||||||
* Set the dimensionType
|
final Element dimensionNameElement = new Element("name");
|
||||||
*
|
dimensionNameElement.setText(dimensionTypeName);
|
||||||
* @param dimensionType
|
dimensionTypeElement.addContent(dimensionNameElement);
|
||||||
*/
|
addContent(dimensionTypeElement);
|
||||||
public void setDimensionType(String dimensionTypeName){
|
}
|
||||||
if(dimensionTypeName != null && !dimensionTypeName.isEmpty())
|
}
|
||||||
{
|
|
||||||
remove("dimensionType");
|
|
||||||
|
|
||||||
final Element dimensionTypeElement = new Element("dimensionType");
|
/**
|
||||||
final Element dimensionNameElement = new Element("name");
|
* Deletes the dimensionType
|
||||||
dimensionNameElement.setText(dimensionTypeName);
|
*
|
||||||
dimensionTypeElement.addContent(dimensionNameElement);
|
* @param dimensionType
|
||||||
addContent(dimensionTypeElement);
|
* @return true if removed
|
||||||
}
|
*/
|
||||||
}
|
public boolean delDimensionType() {
|
||||||
|
return this.delMemberIfExists("dimensionType");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the dimensionType
|
* Get the dimensionType name
|
||||||
*
|
*
|
||||||
* @param dimensionType
|
* @return dimensionType name
|
||||||
* @return true if removed
|
*/
|
||||||
*/
|
public String getDimensionTypeName() {
|
||||||
public boolean delDimensionType(){
|
final Element dimensionType = this.getRoot().getChild("dimensionType");
|
||||||
return this.delMemberIfExists("dimensionType");
|
if (dimensionType != null) {
|
||||||
}
|
return dimensionType.getChildText("name");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
return null;
|
||||||
* Get the dimensionType name
|
}
|
||||||
*
|
|
||||||
* @return dimensionType name
|
|
||||||
*/
|
|
||||||
public String getDimensionTypeName(){
|
|
||||||
final Element dimensionType = this.getRoot().getChild("dimensionType");
|
|
||||||
if(dimensionType != null)
|
|
||||||
{
|
|
||||||
return dimensionType.getChildText("name");
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -23,80 +23,79 @@ 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");
|
||||||
Assert.assertEquals(keywords.get(2), "keyword3");
|
Assert.assertEquals(keywords.get(2), "keyword3");
|
||||||
}
|
}
|
||||||
|
|
||||||
@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,52 +19,61 @@
|
|||||||
*/
|
*/
|
||||||
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());
|
||||||
Assert.assertEquals("-inf", encoder.getRangeMin());
|
Assert.assertEquals("-inf", encoder.getRangeMin());
|
||||||
Assert.assertEquals("inf", encoder.getRangeMax());
|
Assert.assertEquals("inf", encoder.getRangeMax());
|
||||||
Assert.assertEquals("dobson units³", encoder.getUnit());
|
Assert.assertEquals("dobson units³", encoder.getUnit());
|
||||||
Assert.assertEquals("REAL_32BITS", encoder.getDimensionTypeName());
|
Assert.assertEquals("REAL_32BITS", encoder.getDimensionTypeName());
|
||||||
|
|
||||||
Assert.assertTrue(encoder.delName());
|
Assert.assertTrue(encoder.delName());
|
||||||
Assert.assertTrue(encoder.delDescription());
|
Assert.assertTrue(encoder.delDescription());
|
||||||
Assert.assertTrue(encoder.delRange());
|
Assert.assertTrue(encoder.delRange());
|
||||||
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());
|
||||||
Assert.assertNull(encoder.getUnit());
|
Assert.assertNull(encoder.getUnit());
|
||||||
Assert.assertNull(encoder.getDimensionTypeName());
|
Assert.assertNull(encoder.getDimensionTypeName());
|
||||||
|
|
||||||
encoder.setName("GRAY_INDEX");
|
encoder.setName("GRAY_INDEX");
|
||||||
encoder.setDescription("GridSampleDimension[-Infinity,Infinity]");
|
encoder.setDescription("GridSampleDimension[-Infinity,Infinity]");
|
||||||
encoder.setRange("-inf", "inf");
|
encoder.setRange("-inf", "inf");
|
||||||
encoder.setUnit("dobson units³");
|
encoder.setUnit("dobson units³");
|
||||||
encoder.setDimensionType("REAL_32BITS");
|
encoder.setDimensionType("REAL_32BITS");
|
||||||
|
|
||||||
|
Assert.assertEquals("GRAY_INDEX", encoder.getName());
|
||||||
|
Assert.assertEquals("GridSampleDimension[-Infinity,Infinity]", encoder.getDescription());
|
||||||
|
Assert.assertEquals("-inf", encoder.getRangeMin());
|
||||||
|
Assert.assertEquals("inf", encoder.getRangeMax());
|
||||||
|
Assert.assertEquals("dobson units³", encoder.getUnit());
|
||||||
|
Assert.assertEquals("REAL_32BITS", encoder.getDimensionTypeName());
|
||||||
|
}
|
||||||
|
|
||||||
Assert.assertEquals("GRAY_INDEX", encoder.getName());
|
|
||||||
Assert.assertEquals("GridSampleDimension[-Infinity,Infinity]", encoder.getDescription());
|
|
||||||
Assert.assertEquals("-inf", encoder.getRangeMin());
|
|
||||||
Assert.assertEquals("inf", encoder.getRangeMax());
|
|
||||||
Assert.assertEquals("dobson units³", encoder.getUnit());
|
|
||||||
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,89 +84,65 @@ 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");
|
GSLayerEncoder layerEncoder = null;
|
||||||
fte.addCoverageDimensionInfo(gsCoverageDimensionEncoder);
|
if (!GSVersionDecoder.VERSION.getVersion(VERSION).equals(
|
||||||
|
GSVersionDecoder.VERSION.UNRECOGNIZED)) {
|
||||||
|
layerEncoder = new GSLayerEncoder();
|
||||||
|
} else if (GSVersionDecoder.VERSION.getVersion(VERSION).equals(
|
||||||
|
GSVersionDecoder.VERSION.UNRECOGNIZED)) {
|
||||||
|
layerEncoder = new GSLayerEncoder21();
|
||||||
|
}
|
||||||
|
layerEncoder.setEnabled(true);
|
||||||
|
layerEncoder.setQueryable(true);
|
||||||
|
layerEncoder.setAdvertised(true);
|
||||||
|
|
||||||
GSLayerEncoder layerEncoder = null;
|
layerEncoder.setDefaultStyle("point");
|
||||||
if (!GSVersionDecoder.VERSION.getVersion(VERSION).equals(
|
layerEncoder.addStyle("point2");
|
||||||
GSVersionDecoder.VERSION.UNRECOGNIZED)) {
|
layerEncoder.addStyle("point3");
|
||||||
layerEncoder = new GSLayerEncoder();
|
|
||||||
} else if (GSVersionDecoder.VERSION.getVersion(VERSION).equals(
|
|
||||||
GSVersionDecoder.VERSION.UNRECOGNIZED)) {
|
|
||||||
layerEncoder = new GSLayerEncoder21();
|
|
||||||
}
|
|
||||||
layerEncoder.setEnabled(true);
|
|
||||||
layerEncoder.setQueryable(true);
|
|
||||||
layerEncoder.setAdvertised(true);
|
|
||||||
|
|
||||||
layerEncoder.setDefaultStyle("point");
|
// authorityURL
|
||||||
layerEncoder.addStyle("point2");
|
GSAuthorityURLInfoEncoder authorityURL = new GSAuthorityURLInfoEncoder("authority1",
|
||||||
layerEncoder.addStyle("point3");
|
"http://www.authority1.org");
|
||||||
|
layerEncoder.addAuthorityURL(authorityURL);
|
||||||
|
|
||||||
// authorityURL
|
// identifier
|
||||||
GSAuthorityURLInfoEncoder authorityURL = new GSAuthorityURLInfoEncoder(
|
GSIdentifierInfoEncoder identifier1 = new GSIdentifierInfoEncoder("authority1",
|
||||||
"authority1", "http://www.authority1.org");
|
"identifier1");
|
||||||
layerEncoder.addAuthorityURL(authorityURL);
|
GSIdentifierInfoEncoder identifier2 = new GSIdentifierInfoEncoder("authority1",
|
||||||
|
"another_identifier");
|
||||||
|
layerEncoder.addIdentifier(identifier1);
|
||||||
|
layerEncoder.addIdentifier(identifier2);
|
||||||
|
|
||||||
// identifier
|
publisher.createWorkspace(DEFAULT_WS);
|
||||||
GSIdentifierInfoEncoder identifier1 = new GSIdentifierInfoEncoder(
|
|
||||||
"authority1", "identifier1");
|
|
||||||
GSIdentifierInfoEncoder identifier2 = new GSIdentifierInfoEncoder(
|
|
||||||
"authority1", "another_identifier");
|
|
||||||
layerEncoder.addIdentifier(identifier1);
|
|
||||||
layerEncoder.addIdentifier(identifier2);
|
|
||||||
|
|
||||||
publisher.createWorkspace(DEFAULT_WS);
|
File zipFile = new ClassPathResource("testdata/resttestshp.zip").getFile();
|
||||||
|
|
||||||
File zipFile = new ClassPathResource("testdata/resttestshp.zip")
|
// test insert
|
||||||
.getFile();
|
boolean published = publisher.publishShp(DEFAULT_WS, storeName, layerName, zipFile);
|
||||||
|
assertTrue("publish() failed", published);
|
||||||
|
assertTrue(existsLayer(layerName));
|
||||||
|
|
||||||
// test insert
|
publisher.publishStyle(new File(new ClassPathResource("testdata").getFile(),
|
||||||
boolean published = publisher.publishShp(DEFAULT_WS, storeName,
|
"default_point.sld"));
|
||||||
layerName, zipFile);
|
|
||||||
assertTrue("publish() failed", published);
|
|
||||||
assertTrue(existsLayer(layerName));
|
|
||||||
|
|
||||||
publisher.publishStyle(new File(new ClassPathResource("testdata")
|
// optionally select the attributes to publish
|
||||||
.getFile(), "default_point.sld"));
|
RESTLayer layer = reader.getLayer(layerName);
|
||||||
|
RESTResource resource = reader.getResource(layer);
|
||||||
|
List<GSAttributeEncoder> attrs = resource.getEncodedAttributeList();
|
||||||
|
assertNotNull(attrs);
|
||||||
|
for (GSAttributeEncoder enc : attrs) {
|
||||||
|
fte.setAttribute(enc);
|
||||||
|
}
|
||||||
|
|
||||||
// optionally select the attributes to publish
|
assertTrue(publisher.publishDBLayer(DEFAULT_WS, storeName, fte, layerEncoder));
|
||||||
RESTLayer layer = reader.getLayer(layerName);
|
|
||||||
RESTResource resource = reader.getResource(layer);
|
|
||||||
List<GSAttributeEncoder> attrs = resource.getEncodedAttributeList();
|
|
||||||
assertNotNull(attrs);
|
|
||||||
for (GSAttributeEncoder enc : attrs) {
|
|
||||||
fte.setAttribute(enc);
|
|
||||||
}
|
|
||||||
|
|
||||||
assertTrue(publisher.publishDBLayer(DEFAULT_WS, storeName, fte,
|
|
||||||
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,13 +108,26 @@ 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);
|
||||||
// activate time
|
|
||||||
final GSDimensionInfoEncoder time=new GSDimensionInfoEncoder(true);
|
GSVersionDecoder v=reader.getGeoserverVersion();
|
||||||
time.setPresentation(Presentation.LIST);
|
if (v.getVersion().equals(GSVersionDecoder.VERSION.getVersion(GSVersionDecoder.VERSION.v24.toString()))){
|
||||||
// set time metadata
|
// New style dimensions (since gs-2.4.x)
|
||||||
coverageEncoder.setMetadata("time", time);
|
GSCoverageDimensionEncoder gsCoverageDimensionEncoder = new GSCoverageDimensionEncoder(
|
||||||
// not active elevation
|
"GRAY_INDEX", "GridSampleDimension[-Infinity,Infinity]", "-inf", "inf",
|
||||||
coverageEncoder.setMetadata("elevation", new GSDimensionInfoEncoder());
|
"dobson units³", "REAL_32BITS");
|
||||||
|
coverageEncoder.addCoverageDimensionInfo(gsCoverageDimensionEncoder);
|
||||||
|
} else {
|
||||||
|
// Old stile setting code
|
||||||
|
// activate time
|
||||||
|
final GSDimensionInfoEncoder time=new GSDimensionInfoEncoder(true);
|
||||||
|
time.setPresentation(Presentation.LIST);
|
||||||
|
// set time metadata
|
||||||
|
coverageEncoder.setMetadata("time", time);
|
||||||
|
// not active elevation
|
||||||
|
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