/** * Ensures that the operation being executed is a GetFeature operation. * * <p>Subclasses may implement */ public boolean canHandle(Operation operation) { // GetFeature operation? if ("GetFeature".equalsIgnoreCase(operation.getId()) || "GetFeatureWithLock".equalsIgnoreCase(operation.getId())) { // also check that the resultType is "results" GetFeatureRequest req = GetFeatureRequest.adapt(operation.getParameters()[0]); if (req.isResultTypeResults()) { // call subclass hook return canHandleInternal(operation); } } return false; }
public ValueCollectionType run(GetPropertyValueType request) throws WFSException { // check the request resolve if (request.isSetResolve() && !ResolveValueType.NONE.equals(request.getResolve())) { throw new WFSException(request, "Only resolve = none is supported", "InvalidParameterValue") .locator("resolve"); } if (request.getValueReference() == null) { throw new WFSException(request, "No valueReference specified", "MissingParameterValue") .locator("valueReference"); } // do a getFeature request GetFeatureType getFeature = Wfs20Factory.eINSTANCE.createGetFeatureType(); getFeature.getAbstractQueryExpression().add(request.getAbstractQueryExpression()); FeatureCollectionType fc = (FeatureCollectionType) delegate.run(GetFeatureRequest.adapt(getFeature)).getAdaptee(); QueryType query = (QueryType) request.getAbstractQueryExpression(); QName typeName = (QName) query.getTypeNames().iterator().next(); FeatureTypeInfo featureType = catalog.getFeatureTypeByName(typeName.getNamespaceURI(), typeName.getLocalPart()); try { // look for the attribute type AttributeTypeInfo attribute = null; for (AttributeTypeInfo at : featureType.attributes()) { if (at.getName().equals(request.getValueReference())) { attribute = at; break; } } if (attribute == null) { throw new WFSException(request, "No such attribute: " + request.getValueReference()); } AttributeDescriptor descriptor = attribute.getAttribute(); if (descriptor == null) { PropertyDescriptor pd = featureType.getFeatureType().getDescriptor(attribute.getName()); if (pd instanceof AttributeDescriptor) { descriptor = (AttributeDescriptor) pd; } } if (descriptor == null) { throw new WFSException(request, "Unable to obtain descriptor for " + attribute.getName()); } // create value collection type from feature collection ValueCollectionType vc = Wfs20Factory.eINSTANCE.createValueCollectionType(); vc.setTimeStamp(fc.getTimeStamp()); vc.setNumberMatched(fc.getNumberMatched()); vc.setNumberReturned(fc.getNumberReturned()); vc.getMember().add(new PropertyValueCollection(fc.getMember().iterator().next(), descriptor)); // TODO: next/previous but point back at GetPropertyValue // vc.setNext(fc.getNext()); // vc.setPrevious(fc.getPrevious()); return vc; } catch (IOException e) { throw new WFSException(request, e); } }