use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor in project ddf by codice.
the class TestWfsFilterDelegate method intersectsMultiple.
private void intersectsMultiple(boolean indexed) {
List<String> gmlProps = new ArrayList<>();
gmlProps.add(MOCK_GEOM);
gmlProps.add(MOCK_GEOM2);
when(mockFeatureMetacardType.getGmlProperties()).thenReturn(gmlProps);
for (String gmlProp : gmlProps) {
when(mockFeatureMetacardType.getAttributeDescriptor(gmlProp)).thenReturn(new FeatureAttributeDescriptor(gmlProp, gmlProp, indexed, 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.LAT_LON_ORDER);
FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
if (indexed) {
assertNotNull(filter);
assertTrue(filter.isSetLogicOps());
assertNotNull(filter.getLogicOps());
} else {
assertNull(filter);
}
}
use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor in project ddf by codice.
the class TestWfsFilterDelegate method setupFilterDelegate.
private WfsFilterDelegate setupFilterDelegate(String spatialOpType) {
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(spatialOpType);
FilterCapabilities capabilities = MockWfsServer.getFilterCapabilities();
capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().clear();
capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().add(operator);
return new WfsFilterDelegate(mockFeatureMetacardType, capabilities, 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 makeDelegateForLogicalSupportTests.
private WfsFilterDelegate makeDelegateForLogicalSupportTests() {
String mockProperty = "myPropertyName";
String mockType = "myType";
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);
FilterCapabilities filterCap = MockWfsServer.getFilterCapabilities();
//Create new ScalarCapabiltiesType without Logical Operator support
ScalarCapabilitiesType scalar = new ScalarCapabilitiesType();
scalar.setComparisonOperators(new ComparisonOperatorsType());
for (COMPARISON_OPERATORS compOp : COMPARISON_OPERATORS.values()) {
ComparisonOperatorType operator = new ComparisonOperatorType();
operator.setName(compOp.toString());
scalar.getComparisonOperators().getComparisonOperator().add(operator);
}
filterCap.setScalarCapabilities(scalar);
return new WfsFilterDelegate(mockFeatureMetacardType, filterCap, 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 setupMockMetacardType.
private void setupMockMetacardType() {
mockMetacardAttribute = "modified";
mockFeatureType = "myFeatureType";
mockFeatureProperty = "localpart.EXACT_COLLECT_DATE";
List<String> mockProperties = new ArrayList<>(1);
mockProperties.add(mockFeatureProperty);
QName localName = new QName("EXACT_COLLECT_DATE", "localpart");
when(mockFeatureMetacardType.getFeatureType()).thenReturn(localName);
when(mockFeatureMetacardType.getProperties()).thenReturn(mockProperties);
when(mockFeatureMetacardType.getName()).thenReturn(mockFeatureType);
when(mockFeatureMetacardType.getTemporalProperties()).thenReturn(mockProperties);
FeatureAttributeDescriptor mockFeatureAttributeDescriptor = mock(FeatureAttributeDescriptor.class);
when(mockFeatureAttributeDescriptor.isIndexed()).thenReturn(true);
when(mockFeatureAttributeDescriptor.getPropertyName()).thenReturn("EXACT_COLLECT_DATE");
when(mockFeatureMetacardType.getAttributeDescriptor(mockFeatureProperty)).thenReturn(mockFeatureAttributeDescriptor);
mockMapper = mock(MetacardMapper.class);
when(mockMapper.getFeatureProperty(mockMetacardAttribute)).thenReturn(mockFeatureProperty);
}
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 this is a Content Type filter verify its for this Filter delegate.
if (Metacard.CONTENT_TYPE.equals(propertyName)) {
if (featureMetacardType.getName().equals(literal)) {
return returnFilter;
}
return null;
}
// 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.getFeatureId().add(createFeatureIdFilter(literal.toString()));
} else {
LOGGER.debug("feature type does not match metacard type; invalidating filter");
return null;
}
} else {
returnFilter.getFeatureId().add(createFeatureIdFilter(literal.toString()));
}
} else {
return null;
}
return returnFilter;
}
Aggregations