use of ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType in project ddf by codice.
the class WfsSource method initProviders.
private List<? extends Object> initProviders() {
// We need to tell the JAXBElementProvider to marshal the GetFeatureType
// class as an element because it is missing the @XmlRootElement Annotation
JAXBElementProvider<GetFeatureType> provider = new JAXBElementProvider<GetFeatureType>();
Map<String, String> jaxbClassMap = new HashMap<String, String>();
// Ensure a namespace is used when the GetFeature request is generated
String expandedName = new QName(Wfs10Constants.WFS_NAMESPACE, Wfs10Constants.GET_FEATURE).toString();
jaxbClassMap.put(GetFeatureType.class.getName(), expandedName);
provider.setJaxbElementClassMap(jaxbClassMap);
provider.setMarshallAsJaxbElement(true);
featureCollectionReader = new FeatureCollectionMessageBodyReaderWfs10();
return Arrays.asList(provider, new WfsResponseExceptionMapper(), new XmlSchemaMessageBodyReaderWfs10(), featureCollectionReader);
}
use of ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType in project ddf by codice.
the class WfsSource method logMessage.
private void logMessage(GetFeatureType getFeature) {
if (LOGGER.isDebugEnabled()) {
try {
StringWriter writer = new StringWriter();
JAXBContext contextObj = JAXBContext.newInstance(GetFeatureType.class);
Marshaller marshallerObj = contextObj.createMarshaller();
marshallerObj.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshallerObj.marshal(new ObjectFactory().createGetFeature(getFeature), writer);
LOGGER.debug("WfsSource {}: {}", getId(), writer.toString());
} catch (JAXBException e) {
LOGGER.debug("An error occurred debugging the GetFeature request", e);
}
}
}
use of ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType in project ddf by codice.
the class TestWfsSource method testTwoIntersectQuery.
@Test
public void testTwoIntersectQuery() throws UnsupportedQueryException, WfsException, SecurityServiceException {
setUp(TWO_GML_PROPERTY_SCHEMA, Arrays.asList(new Intersect(), new BBOX()), SRS_NAME, ONE_FEATURE, null);
Filter intersectFilter = builder.attribute(Metacard.ANY_GEO).is().intersecting().wkt(POLYGON_WKT);
QueryImpl intersectQuery = new QueryImpl(intersectFilter);
intersectQuery.setPageSize(MAX_FEATURES);
ArgumentCaptor<GetFeatureType> captor = ArgumentCaptor.forClass(GetFeatureType.class);
source.query(new QueryRequestImpl(intersectQuery));
verify(mockWfs).getFeature(captor.capture());
GetFeatureType getFeatureType = captor.getValue();
assertMaxFeatures(getFeatureType, intersectQuery);
assertTrue(getFeatureType.getQuery().size() == ONE_FEATURE);
QueryType query = getFeatureType.getQuery().get(0);
assertTrue(query.getTypeName().equals(sampleFeatures.get(0)));
// The Text Properties should be ORed
assertNotNull(query.getFilter());
assertTrue(query.getFilter().isSetLogicOps());
assertTrue(query.getFilter().getLogicOps().getValue() instanceof LogicOpsType);
}
use of ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType in project ddf by codice.
the class TestWfsSource method testBboxQuery.
@Test
public void testBboxQuery() throws UnsupportedQueryException, WfsException, SecurityServiceException {
List<Object> bbox = new ArrayList<Object>();
bbox.add(new BBOX());
setUp(ONE_GML_PROPERTY_SCHEMA, bbox, SRS_NAME, ONE_FEATURE, null);
Filter intersectFilter = builder.attribute(Metacard.ANY_GEO).is().intersecting().wkt(POLYGON_WKT);
QueryImpl intersectQuery = new QueryImpl(intersectFilter);
intersectQuery.setPageSize(MAX_FEATURES);
ArgumentCaptor<GetFeatureType> captor = ArgumentCaptor.forClass(GetFeatureType.class);
source.query(new QueryRequestImpl(intersectQuery));
verify(mockWfs).getFeature(captor.capture());
GetFeatureType getFeatureType = captor.getValue();
assertMaxFeatures(getFeatureType, intersectQuery);
assertTrue(getFeatureType.getQuery().size() == ONE_FEATURE);
QueryType query = getFeatureType.getQuery().get(0);
assertTrue(query.getTypeName().equals(sampleFeatures.get(0)));
assertTrue(query.getFilter().isSetSpatialOps());
assertTrue(query.getFilter().getSpatialOps().getValue() instanceof SpatialOpsType);
}
use of ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType in project ddf by codice.
the class TestWfsSource method testQueryTwoFeaturesOneInvalid.
@Test
public void testQueryTwoFeaturesOneInvalid() throws UnsupportedQueryException, WfsException, SecurityServiceException {
setUp(TWO_TEXT_PROPERTY_SCHEMA, null, null, TWO_FEATURES, null);
Filter orderPersonFilter = builder.attribute(EXT_PREFIX + sampleFeatures.get(0) + "." + ORDER_PERSON).is().like().text(LITERAL);
Filter mctFeature1Fitler = builder.attribute(Metacard.CONTENT_TYPE).is().like().text(sampleFeatures.get(0).getLocalPart());
Filter feature1Filter = builder.allOf(Arrays.asList(orderPersonFilter, mctFeature1Fitler));
Filter orderDogFilter = builder.attribute("FAKE").is().like().text(LITERAL);
Filter mctFeature2Fitler = builder.attribute(Metacard.CONTENT_TYPE).is().like().text(sampleFeatures.get(1).getLocalPart());
Filter feature2Filter = builder.allOf(Arrays.asList(orderDogFilter, mctFeature2Fitler));
Filter totalFilter = builder.anyOf(Arrays.asList(feature1Filter, feature2Filter));
QueryImpl inQuery = new QueryImpl(totalFilter);
inQuery.setPageSize(MAX_FEATURES);
ArgumentCaptor<GetFeatureType> captor = ArgumentCaptor.forClass(GetFeatureType.class);
source.query(new QueryRequestImpl(inQuery));
verify(mockWfs).getFeature(captor.capture());
GetFeatureType getFeatureType = captor.getValue();
assertMaxFeatures(getFeatureType, inQuery);
assertEquals(ONE_FEATURE.intValue(), getFeatureType.getQuery().size());
QueryType query = getFeatureType.getQuery().get(0);
assertTrue(query.getTypeName().equals(sampleFeatures.get(0)));
// The Text Properties should be ORed
assertTrue(query.getFilter().isSetComparisonOps());
assertTrue(query.getFilter().getComparisonOps().getValue() instanceof PropertyIsLikeType);
PropertyIsLikeType pilt = (PropertyIsLikeType) query.getFilter().getComparisonOps().getValue();
assertEquals(ORDER_PERSON, pilt.getPropertyName().getContent());
}
Aggregations