use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor in project ddf by codice.
the class TestWfsFilterDelegate method testSequentialPropertyIsNotOfTemporalType.
private void testSequentialPropertyIsNotOfTemporalType(String methName, Object... inputParams) throws Throwable {
String mockMetacardAttribute = "myMetacardAttribute";
String mockFeatureType = "myFeatureType";
String mockFeatureProperty = "myFeatureProperty";
List<String> mockProperties = new ArrayList<>(1);
mockProperties.add(mockFeatureProperty);
when(mockFeatureMetacardType.getProperties()).thenReturn(mockProperties);
when(mockFeatureMetacardType.getName()).thenReturn(mockFeatureType);
List<String> mockTemporalProperties = Collections.emptyList();
when(mockFeatureMetacardType.getTemporalProperties()).thenReturn(mockTemporalProperties);
FeatureAttributeDescriptor mockFeatureAttributeDescriptor = mock(FeatureAttributeDescriptor.class);
when(mockFeatureAttributeDescriptor.isIndexed()).thenReturn(true);
when(mockFeatureAttributeDescriptor.getPropertyName()).thenReturn(mockFeatureProperty);
when(mockFeatureMetacardType.getAttributeDescriptor(mockFeatureProperty)).thenReturn(mockFeatureAttributeDescriptor);
MetacardMapper mockMapper = mock(MetacardMapper.class);
when(mockMapper.getFeatureProperty(mockMetacardAttribute)).thenReturn(mockFeatureProperty);
WfsFilterDelegate delegate = new WfsFilterDelegate(mockFeatureMetacardType, MockWfsServer.getFilterCapabilities(), GeospatialUtil.EPSG_4326_URN, mockMapper, GeospatialUtil.LAT_LON_ORDER);
try {
// Inject the mockMetacardAttribute at the head of the array
Object[] methParams = ObjectArrays.concat(mockMetacardAttribute, inputParams);
// Generate the array of class types for the reflection call
Class<?>[] classTypes = FluentIterable.from(Arrays.asList(methParams)).transform(new Function<Object, Class>() {
@Override
public Class<?> apply(Object o) {
// Autoboxing is a small problem with reflection when trying to be too clever
return (o instanceof Long) ? long.class : o.getClass();
}
}).toArray(Class.class);
Method method = WfsFilterDelegate.class.getMethod(methName, classTypes);
method.invoke(delegate, methParams);
} catch (InvocationTargetException e) {
throw e.getCause();
}
}
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;
}
Aggregations