/* (c) 2014 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
package org.geoserver.wfs.xml.v1_0_0;
import java.math.BigInteger;
import javax.xml.namespace.QName;
import net.opengis.wfs.GetFeatureType;
import net.opengis.wfs.QueryType;
import net.opengis.wfs.WfsFactory;
import org.geoserver.wfs.xml.SqlViewParamsExtractor;
import org.geotools.util.Converters;
import org.geotools.xml.AbstractComplexBinding;
import org.geotools.xml.ElementInstance;
import org.geotools.xml.Node;
/**
* Binding object for the type http://www.opengis.net/wfs:GetFeatureType.
*
* <p>
* <pre>
* <code>
* <xsd:complexType name="GetFeatureType"> <xsd:annotation>
* <xsd:documentation> A GetFeature element
* contains one or more Query elements that
* describe a query operation on one feature type. In
* response to a GetFeature request, a Web Feature Service
* must be able to generate a GML2 response that validates
* using a schema generated by the DescribeFeatureType request.
* A Web Feature Service may support other possibly non-XML
* (and even binary) output formats as long as those formats
* are advertised in the capabilities document.
* </xsd:documentation> </xsd:annotation>
* <xsd:sequence> <xsd:element maxOccurs="unbounded"
* ref="wfs:Query"/> </xsd:sequence> <xsd:attribute
* fixed="1.0.0" name="version" type="xsd:string" use="required"/>
* <xsd:attribute fixed="WFS" name="service" type="xsd:string"
* use="required"/> <xsd:attribute name="handle"
* type="xsd:string" use="optional"/> <xsd:attribute
* default="GML2" name="outputFormat" type="xsd:string"
* use="optional"> <xsd:annotation>
* <xsd:documentation> The outputFormat
* attribute is used to specify the output
* format that the Web Feature Service should generate in
* response to a GetFeature or GetFeatureWithLock element.
* The default value of GML2 indicates that the output is
* an XML document that conforms to the
* Geography Markup Language (GML)
* Implementation Specification V2.0. Other
* values may be used to specify other formats as long
* as those values are advertised in the capabilities
* document. For example, the value WKB may
* be used to indicate that a Well Known
* Binary format be used to encode the output.
* </xsd:documentation> </xsd:annotation>
* </xsd:attribute> <xsd:attribute name="maxFeatures"
* type="xsd:positiveInteger" use="optional">
* <xsd:annotation> <xsd:documentation>
* The maxFeatures attribute is used to specify the maximum
* number of features that a GetFeature operation should
* generate (regardless of the actual number of query
* hits). </xsd:documentation>
* </xsd:annotation> </xsd:attribute> </xsd:complexType>
*
* </code>
* </pre>
* @generated
*/
public class GetFeatureTypeBinding extends AbstractComplexBinding {
WfsFactory wfsfactory;
public GetFeatureTypeBinding(WfsFactory wfsfactory) {
this.wfsfactory = wfsfactory;
}
/**
* @generated
*/
public QName getTarget() {
return WFS.GETFEATURETYPE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated modifiable
*/
public Class getType() {
return GetFeatureType.class;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated modifiable
*/
public Object parse(ElementInstance instance, Node node, Object value)
throws Exception {
GetFeatureType getFeature = wfsfactory.createGetFeatureType();
WFSBindingUtils.service(getFeature, node);
WFSBindingUtils.version(getFeature, node);
WFSBindingUtils.outputFormat(getFeature, node, "GML2");
if (node.getAttributeValue("handle") != null) {
getFeature.setHandle((String) node.getAttributeValue("handle"));
}
//get the max features
Number number = (Number) node.getAttributeValue("maxFeatures");
if (number != null) {
getFeature.setMaxFeatures(WFSBindingUtils.asBigInteger(number));
}
//startIndex (wfs 2.0)
if (node.hasAttribute("startIndex")) {
//convert manually since this is not standard schema for wfs 1.1
BigInteger startIndex =
Converters.convert(node.getAttributeValue("startIndex"), BigInteger.class);
getFeature.setStartIndex(startIndex);
}
//queries
getFeature.getQuery().addAll(node.getChildValues(QueryType.class));
// viewParams
SqlViewParamsExtractor.viewParams(getFeature, node);
return getFeature;
}
}