use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor in project ddf by codice.
the class WfsFilterDelegate method buildBeforeFilterType.
private FilterType buildBeforeFilterType(String propertyName, String date) {
TemporalOperand timeInstantTemporalOperand = new TemporalOperand();
timeInstantTemporalOperand.setName(new QName(Wfs20Constants.GML_3_2_NAMESPACE, Wfs20Constants.TIME_INSTANT));
if (!isTemporalOperandSupported(timeInstantTemporalOperand)) {
throw new UnsupportedOperationException("Temporal Operand [" + timeInstantTemporalOperand.getName() + "] is not supported.");
}
if (!isValidInputParameters(propertyName, date)) {
throw new IllegalArgumentException(MISSING_PARAMETERS_MSG);
}
if (!isPropertyTemporalType(propertyName)) {
throw new IllegalArgumentException("Property [" + propertyName + "] is not of type " + timeInstantTemporalOperand.getName() + ".");
}
FilterType filter = filterObjectFactory.createFilterType();
if (featureMetacardType.getProperties().contains(propertyName)) {
FeatureAttributeDescriptor featureAttributeDescriptor = (FeatureAttributeDescriptor) featureMetacardType.getAttributeDescriptor(propertyName);
if (featureAttributeDescriptor.isIndexed()) {
filter.setTemporalOps(createBefore(featureAttributeDescriptor.getPropertyName(), featureMetacardType.getName(), date));
} else {
throw new IllegalArgumentException(String.format(PROPERTY_NOT_QUERYABLE, propertyName));
}
} else {
return null;
}
return filter;
}
use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor in project ddf by codice.
the class WfsFilterDelegate method buildDuringFilterType.
private FilterType buildDuringFilterType(String propertyName, String startDate, String endDate) {
if (!isTemporalOpSupported(TEMPORAL_OPERATORS.During)) {
throw new UnsupportedOperationException("Temporal Operator [" + TEMPORAL_OPERATORS.During + "] is not supported.");
}
TemporalOperand timePeriodTemporalOperand = new TemporalOperand();
timePeriodTemporalOperand.setName(new QName(Wfs20Constants.GML_3_2_NAMESPACE, Wfs20Constants.TIME_PERIOD));
if (!isTemporalOperandSupported(timePeriodTemporalOperand)) {
throw new UnsupportedOperationException("Temporal Operand [" + timePeriodTemporalOperand.getName() + "] is not supported.");
}
if (!isValidInputParameters(propertyName, startDate, endDate)) {
throw new IllegalArgumentException(MISSING_PARAMETERS_MSG);
}
if (!isPropertyTemporalType(propertyName)) {
throw new IllegalArgumentException("Property [" + propertyName + "] is not of type " + timePeriodTemporalOperand.getName() + ".");
}
FilterType filter = filterObjectFactory.createFilterType();
if (featureMetacardType.getProperties().contains(propertyName)) {
FeatureAttributeDescriptor featureAttributeDescriptor = (FeatureAttributeDescriptor) featureMetacardType.getAttributeDescriptor(propertyName);
if (featureAttributeDescriptor.isIndexed()) {
filter.setTemporalOps(createDuring(featureAttributeDescriptor.getPropertyName(), featureMetacardType.getName(), startDate, endDate));
} else {
throw new IllegalArgumentException(String.format(PROPERTY_NOT_QUERYABLE, propertyName));
}
} else {
return null;
}
return filter;
}
use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor in project ddf by codice.
the class TestWfsFilterDelegate method mockFeatureMetacardCreateDelegate.
private WfsFilterDelegate mockFeatureMetacardCreateDelegate(String mockProperty, String mockType) {
List<String> mockProperties = new ArrayList<>(1);
mockProperties.add(mockProperty);
when(mockFeatureMetacardType.getProperties()).thenReturn(mockProperties);
when(mockFeatureMetacardType.getGmlProperties()).thenReturn(mockProperties);
when(mockFeatureMetacardType.getTextualProperties()).thenReturn(mockProperties);
when(mockFeatureMetacardType.getTemporalProperties()).thenReturn(mockProperties);
when(mockFeatureMetacardType.getName()).thenReturn(mockType);
FeatureAttributeDescriptor mockFeatureAttributeDescriptor = mock(FeatureAttributeDescriptor.class);
when(mockFeatureAttributeDescriptor.isIndexed()).thenReturn(true);
when(mockFeatureAttributeDescriptor.getPropertyName()).thenReturn(mockProperty);
when(mockFeatureMetacardType.getAttributeDescriptor(mockProperty)).thenReturn(mockFeatureAttributeDescriptor);
return new WfsFilterDelegate(mockFeatureMetacardType, MockWfsServer.getFilterCapabilities(), GeospatialUtil.EPSG_4326_URN, null, GeospatialUtil.LAT_LON_ORDER);
}
use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor in project ddf by codice.
the class TestWfsFilterDelegate method testIntersectsWithEnvelope.
@Test
public void testIntersectsWithEnvelope() throws SAXException, IOException, JAXBException {
List<String> gmlProps = new ArrayList<>();
gmlProps.add(MOCK_GEOM);
when(mockFeatureMetacardType.getGmlProperties()).thenReturn(gmlProps);
when(mockFeatureMetacardType.getAttributeDescriptor(MOCK_GEOM)).thenReturn(new FeatureAttributeDescriptor(MOCK_GEOM, MOCK_GEOM, true, false, false, false, BasicTypes.STRING_TYPE));
SpatialOperatorType operator = new SpatialOperatorType();
operator.setName(SPATIAL_OPERATORS.Intersects.toString());
FilterCapabilities capabilities = MockWfsServer.getFilterCapabilities();
capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().clear();
capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().add(operator);
capabilities.getSpatialCapabilities().getGeometryOperands().getGeometryOperand().clear();
GeometryOperand geoOperand = new GeometryOperand();
geoOperand.setName(Wfs20Constants.ENVELOPE);
capabilities.getSpatialCapabilities().getGeometryOperands().getGeometryOperand().add(geoOperand);
WfsFilterDelegate delegate = new WfsFilterDelegate(mockFeatureMetacardType, capabilities, GeospatialUtil.EPSG_4326_URN, null, GeospatialUtil.LAT_LON_ORDER);
FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
assertTrue(filter.getSpatialOps().getValue() instanceof BinarySpatialOpType);
assertFalse(filter.isSetLogicOps());
assertXMLEqual(MockWfsServer.getIntersectsWithEnvelopeXmlFilter(), getXmlFromMarshaller(filter));
}
use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor in project ddf by codice.
the class TestWfsFilterDelegate method testSingleGmlPropertyBlacklisted.
@Test(expected = IllegalArgumentException.class)
public void testSingleGmlPropertyBlacklisted() {
WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.Contains.toString());
when(mockFeatureMetacardType.getAttributeDescriptor(MOCK_GEOM)).thenReturn(new FeatureAttributeDescriptor(MOCK_GEOM, MOCK_GEOM, false, false, false, false, BasicTypes.STRING_TYPE));
delegate.contains(MOCK_GEOM, POLYGON);
}
Aggregations