use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor in project ddf by codice.
the class WfsFilterDelegate method buildAfterFilterType.
private FilterType buildAfterFilterType(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(createAfter(featureAttributeDescriptor.getPropertyName(), featureMetacardType.getName(), date));
} else {
throw new IllegalArgumentException(String.format(PROPERTY_NOT_QUERYABLE, propertyName));
}
} else {
return null;
}
if (!isTemporalOpSupported(TEMPORAL_OPERATORS.After)) {
if (isTemporalOpSupported(TEMPORAL_OPERATORS.During)) {
return buildDuringFilterType(propertyName, date, convertDateToIso8601Format(new Date()));
}
}
return filter;
}
use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor in project ddf by codice.
the class WfsFilterDelegate method buildGeospatialFilterType.
private FilterType buildGeospatialFilterType(String spatialOpType, String propertyName, String wkt, Double distance) {
FilterType returnFilter = new FilterType();
if (Metacard.ANY_GEO.equals(propertyName)) {
if (CollectionUtils.isEmpty(featureMetacardType.getGmlProperties())) {
LOGGER.debug("Feature Type does not have GEO properties to query");
return null;
}
if (featureMetacardType.getGmlProperties().size() == 1) {
FeatureAttributeDescriptor attrDesc = (FeatureAttributeDescriptor) featureMetacardType.getAttributeDescriptor(featureMetacardType.getGmlProperties().get(0));
if (attrDesc != null && attrDesc.isIndexed()) {
returnFilter.setSpatialOps(createSpatialOpType(spatialOpType, attrDesc.getPropertyName(), wkt, distance));
} else {
LOGGER.debug("All GEO properties have been blacklisted. Removing from query");
return null;
}
} else {
List<FilterType> filtersToBeOred = new ArrayList<FilterType>();
for (String property : featureMetacardType.getGmlProperties()) {
FeatureAttributeDescriptor attrDesc = (FeatureAttributeDescriptor) featureMetacardType.getAttributeDescriptor(property);
if (attrDesc != null && attrDesc.isIndexed()) {
FilterType filter = new FilterType();
filter.setSpatialOps(createSpatialOpType(spatialOpType, attrDesc.getPropertyName(), wkt, distance));
filtersToBeOred.add(filter);
} else {
LOGGER.debug(String.format(PROPERTY_NOT_QUERYABLE, property));
}
}
if (!filtersToBeOred.isEmpty()) {
returnFilter = or(filtersToBeOred);
} else {
LOGGER.debug("All GEO properties have been blacklisted. Removing from query.");
returnFilter = null;
}
}
} else if (featureMetacardType.getGmlProperties().contains(propertyName)) {
FeatureAttributeDescriptor attrDesc = (FeatureAttributeDescriptor) featureMetacardType.getAttributeDescriptor(propertyName);
if (attrDesc != null && attrDesc.isIndexed()) {
FilterType filter = new FilterType();
filter.setSpatialOps(createSpatialOpType(spatialOpType, attrDesc.getPropertyName(), wkt, distance));
return filter;
} else {
// blacklisted property encountered
throw new IllegalArgumentException(String.format(PROPERTY_NOT_QUERYABLE, propertyName));
}
} else {
return null;
}
return returnFilter;
}
use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor in project ddf by codice.
the class WfsFilterDelegate method buildPropertyIsFilterType.
private FilterType buildPropertyIsFilterType(String propertyName, Object literal, PROPERTY_IS_OPS propertyIsType) {
if (!isValidInputParameters(propertyName, literal)) {
throw new IllegalArgumentException(MISSING_PARAMETERS_MSG);
}
FilterType returnFilter = new FilterType();
if (Metacard.CONTENT_TYPE.equals(propertyName)) {
return returnFilter;
}
// series of OR's
if ((Metacard.ANY_TEXT.equalsIgnoreCase(propertyName))) {
if (CollectionUtils.isEmpty(featureMetacardType.getTextualProperties())) {
LOGGER.debug("Feature Type does not have Textual Properties to query.");
return null;
}
if (featureMetacardType.getTextualProperties().size() == 1) {
FeatureAttributeDescriptor attrDescriptor = (FeatureAttributeDescriptor) featureMetacardType.getAttributeDescriptor(featureMetacardType.getTextualProperties().get(0));
if (attrDescriptor.isIndexed()) {
returnFilter.setComparisonOps(createPropertyIsFilter(attrDescriptor.getPropertyName(), literal, propertyIsType));
} else {
LOGGER.debug("All textual properties have been blacklisted. Removing from query.");
return null;
}
} else {
List<FilterType> binaryCompOpsToBeOred = new ArrayList<FilterType>();
for (String property : featureMetacardType.getTextualProperties()) {
// only build filters for queryable properties
FeatureAttributeDescriptor attrDesc = (FeatureAttributeDescriptor) featureMetacardType.getAttributeDescriptor(property);
if (attrDesc.isIndexed()) {
FilterType filter = new FilterType();
filter.setComparisonOps(createPropertyIsFilter(attrDesc.getPropertyName(), literal, propertyIsType));
binaryCompOpsToBeOred.add(filter);
} else {
LOGGER.debug(String.format(PROPERTY_NOT_QUERYABLE, property));
}
}
if (!binaryCompOpsToBeOred.isEmpty()) {
returnFilter = or(binaryCompOpsToBeOred);
} else {
LOGGER.debug("All textual properties have been blacklisted. Removing from query.");
return null;
}
}
// filter is for a specific property; check to see if it is valid
} else if (featureMetacardType.getProperties().contains(propertyName)) {
FeatureAttributeDescriptor attrDesc = (FeatureAttributeDescriptor) featureMetacardType.getAttributeDescriptor(propertyName);
if (attrDesc.isIndexed()) {
returnFilter.setComparisonOps(createPropertyIsFilter(attrDesc.getPropertyName(), literal, propertyIsType));
} else {
// blacklisted property encountered
throw new IllegalArgumentException(String.format(PROPERTY_NOT_QUERYABLE, propertyName));
}
} else if (Metacard.ID.equals(propertyName)) {
LOGGER.debug("feature id query for : {}", literal);
String[] idTokens = literal.toString().split("\\.");
if (idTokens.length > 1) {
if (idTokens[0].equals(featureMetacardType.getName())) {
LOGGER.debug("feature type matches metacard type; creating featureID filter");
returnFilter.getId().add(createFeatureIdFilter(literal.toString()));
} else {
LOGGER.debug("feature type does not match metacard type; invalidating filter");
return null;
}
} else {
returnFilter.getId().add(createFeatureIdFilter(literal.toString()));
}
} else {
return null;
}
return returnFilter;
}
use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor in project ddf by codice.
the class TestWfsFilterDelegate method testIntersectsLonLat.
@Test
public void testIntersectsLonLat() 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);
WfsFilterDelegate delegate = new WfsFilterDelegate(mockFeatureMetacardType, capabilities, GeospatialUtil.EPSG_4326_URN, null, GeospatialUtil.LON_LAT_ORDER);
FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
assertTrue(filter.getSpatialOps().getValue() instanceof BinarySpatialOpType);
assertFalse(filter.isSetLogicOps());
assertXMLEqual(MockWfsServer.getIntersectsLonLatXmlFilter(), getXmlFromMarshaller(filter));
}
use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor in project ddf by codice.
the class TestWfsFilterDelegate method testIntersectsWithEnvelopeLonLat.
@Test
public void testIntersectsWithEnvelopeLonLat() 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.LON_LAT_ORDER);
FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
assertTrue(filter.getSpatialOps().getValue() instanceof BinarySpatialOpType);
assertFalse(filter.isSetLogicOps());
assertXMLEqual(MockWfsServer.getIntersectsWithEnvelopeLonLatXmlFilter(), getXmlFromMarshaller(filter));
}
Aggregations