Merge pull request #99 from geosolutions-it/1.5.x-RESTFeatureTypes-attributes
fix inheritance for RESTFeatureTyle getAttribute methods
This commit is contained in:
commit
71b46e2745
@ -27,8 +27,14 @@ package it.geosolutions.geoserver.rest.decoder;
|
||||
|
||||
import it.geosolutions.geoserver.rest.decoder.utils.JDOMBuilder;
|
||||
import it.geosolutions.geoserver.rest.decoder.utils.JDOMListIterator;
|
||||
import it.geosolutions.geoserver.rest.encoder.feature.FeatureTypeAttribute;
|
||||
import it.geosolutions.geoserver.rest.encoder.feature.GSAttributeEncoder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.jdom.Element;
|
||||
|
||||
/**
|
||||
@ -244,4 +250,50 @@ public class RESTFeatureType extends RESTResource {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public List<Map<FeatureTypeAttribute, String>> getAttributeList() {
|
||||
List<Map<FeatureTypeAttribute, String>> attrsList = null;
|
||||
|
||||
final Element attrsRoot = rootElem.getChild("attributes");
|
||||
if(attrsRoot!=null){
|
||||
final List<Element> attrs = attrsRoot.getChildren();
|
||||
if (attrs != null) {
|
||||
attrsList = new ArrayList<Map<FeatureTypeAttribute, String>>(attrs.size());
|
||||
for (Element attr : attrs) {
|
||||
Map<FeatureTypeAttribute, String> attrsMap = new HashMap<FeatureTypeAttribute, String>();
|
||||
attrsList.add(attrsMap);
|
||||
for (FeatureTypeAttribute at : FeatureTypeAttribute.values()) {
|
||||
String key = at.toString();
|
||||
attrsMap.put(at, attr.getChildText(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return attrsList;
|
||||
}
|
||||
|
||||
public List<GSAttributeEncoder> getEncodedAttributeList() {
|
||||
List<GSAttributeEncoder> attrsList = null;
|
||||
|
||||
final Element attrsRoot = rootElem.getChild("attributes");
|
||||
if(attrsRoot!=null){
|
||||
final List<Element> attrs = attrsRoot.getChildren();
|
||||
if (attrs != null) {
|
||||
attrsList = new ArrayList<GSAttributeEncoder>(attrs.size());
|
||||
for (Element attr : attrs) {
|
||||
final GSAttributeEncoder attrEnc = new GSAttributeEncoder();
|
||||
for (FeatureTypeAttribute at : FeatureTypeAttribute.values()) {
|
||||
String key = at.toString();
|
||||
attrEnc.setAttribute(at, attr.getChildText(key));
|
||||
}
|
||||
attrsList.add(attrEnc);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return attrsList;
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,43 +133,22 @@ public class RESTResource {
|
||||
return getLatLonEdge("maxy");
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link RESTFeatureType#getAttributeList()}
|
||||
* @return
|
||||
* @throws UnsupportedOperationException
|
||||
*/
|
||||
public List<Map<FeatureTypeAttribute, String>> getAttributeList() {
|
||||
List<Map<FeatureTypeAttribute, String>> attrsList = null;
|
||||
|
||||
final Element attrsRoot = rootElem.getChild("attributes");
|
||||
final List<Element> attrs = attrsRoot.getChildren();
|
||||
if (attrs != null) {
|
||||
attrsList = new ArrayList<Map<FeatureTypeAttribute, String>>(attrs.size());
|
||||
for (Element attr : attrs) {
|
||||
Map<FeatureTypeAttribute, String> attrsMap = new HashMap<FeatureTypeAttribute, String>();
|
||||
attrsList.add(attrsMap);
|
||||
for (FeatureTypeAttribute at : FeatureTypeAttribute.values()) {
|
||||
String key = at.toString();
|
||||
attrsMap.put(at, attr.getChildText(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
return attrsList;
|
||||
throw new UnsupportedOperationException("This method is specific for RESTFeatureType");
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link RESTFeatureType#getEncodedAttributeList()}
|
||||
* @return
|
||||
* @throws UnsupportedOperationException
|
||||
*/
|
||||
public List<GSAttributeEncoder> getEncodedAttributeList() {
|
||||
List<GSAttributeEncoder> attrsList = null;
|
||||
|
||||
final Element attrsRoot = rootElem.getChild("attributes");
|
||||
final List<Element> attrs = attrsRoot.getChildren();
|
||||
if (attrs != null) {
|
||||
attrsList = new ArrayList<GSAttributeEncoder>(attrs.size());
|
||||
for (Element attr : attrs) {
|
||||
final GSAttributeEncoder attrEnc = new GSAttributeEncoder();
|
||||
for (FeatureTypeAttribute at : FeatureTypeAttribute.values()) {
|
||||
String key = at.toString();
|
||||
attrEnc.setAttribute(at, attr.getChildText(key));
|
||||
}
|
||||
attrsList.add(attrEnc);
|
||||
}
|
||||
|
||||
}
|
||||
return attrsList;
|
||||
throw new UnsupportedOperationException("This method is specific for RESTFeatureType");
|
||||
}
|
||||
|
||||
|
||||
@ -198,43 +177,4 @@ public class RESTResource {
|
||||
return metaLinksList;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return the list of available attribute names
|
||||
// */
|
||||
// public List<String> getAttributeNames() {
|
||||
// return getAttributes("name");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return a list of object which are String representation of Classes
|
||||
// */
|
||||
// public List<String> getAttributeBinding() {
|
||||
// return getAttributes("binding");
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * <attribute><br>
|
||||
// * <name>NATION</name><br>
|
||||
// * <minOccurs>0</minOccurs><br>
|
||||
// * <maxOccurs>1</maxOccurs><br>
|
||||
// * <nillable>true</nillable><br>
|
||||
// * <binding>java.lang.Integer</binding><br>
|
||||
// * <length>3</length><br>
|
||||
// * </attribute><br>
|
||||
// *
|
||||
// * @param name
|
||||
// * @return
|
||||
// */
|
||||
// private List<String> getAttributes(String name) {
|
||||
// final Element attrsRoot = rootElem.getChild("attributes");
|
||||
// final List<Element> attrs = attrsRoot.getChildren();
|
||||
// List<String> attrNames = null;
|
||||
// if (attrs != null) {
|
||||
// attrNames = new ArrayList<String>(attrs.size());
|
||||
// for (Element attr : attrs) {
|
||||
// attrNames.add(attr.getChildText(name));
|
||||
// }
|
||||
// }
|
||||
// return attrNames;
|
||||
// }
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user