use of org.geotools.filter.AttributeExpressionImpl in project ddf by codice.
the class PropertyMapperVisitorTest method testPropertyMapperVisit.
@Test
public void testPropertyMapperVisit() {
Map<String, String> map = new HashMap<>();
map.put("prop", "newProp");
PropertyMapperVisitor mapper = new PropertyMapperVisitor(map);
PropertyName propertyName = new PropertyNameImpl("prop");
AttributeExpressionImpl exp = (AttributeExpressionImpl) mapper.visit(propertyName, new FilterFactoryImpl());
assertThat(exp.getPropertyName(), equalTo("newProp"));
}
use of org.geotools.filter.AttributeExpressionImpl in project ddf by codice.
the class PropertyMapperVisitorTest method testPropertyMapperVisitNullProperty.
@Test
public void testPropertyMapperVisitNullProperty() {
Map<String, String> map = new HashMap<>();
PropertyMapperVisitor mapper = new PropertyMapperVisitor(map);
AttributeExpressionImpl exp = (AttributeExpressionImpl) mapper.visit((PropertyName) null, new FilterFactoryImpl());
assertThat(exp, nullValue());
}
use of org.geotools.filter.AttributeExpressionImpl in project ddf by codice.
the class CswRecordMapperFilterVisitorTest method testVisitWithBoundingBoxProperty.
@Test
public void testVisitWithBoundingBoxProperty() {
AttributeExpressionImpl propName = new AttributeExpressionImpl(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, CswConstants.OWS_BOUNDING_BOX, CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
CswRecordMapperFilterVisitor visitor = new CswRecordMapperFilterVisitor(DEFAULT_CSW_RECORD_MAP, attributeRegistry);
PropertyName propertyName = (PropertyName) visitor.visit(propName, null);
assertThat(propertyName.getPropertyName(), is(Metacard.ANY_GEO));
}
use of org.geotools.filter.AttributeExpressionImpl in project ddf by codice.
the class CatalogFeatureQueryableTest method testQuery.
@Test
public void testQuery() throws UnsupportedQueryException, SourceUnavailableException, FederationException, FeatureQueryException {
final ArgumentCaptor<QueryRequest> requestArgument = ArgumentCaptor.forClass(QueryRequest.class);
QueryResponse queryResponse = getMockQueryResponse();
when(catalogFramework.query(any())).thenReturn(queryResponse);
List<SimpleFeature> results = catalogFeatureQueryable.query(COUNTRY_CODE, "PCL1", 1);
verify(catalogFramework, atLeastOnce()).query(requestArgument.capture());
SimpleFeature result = results.get(0);
Geometry geometry = (Geometry) result.getDefaultGeometry();
assertThat(geometry.getNumPoints(), is(WKT_NUM_POINTS));
assertThat(geometry.getGeometryType(), is(WKT_TYPE));
QueryImpl query = (QueryImpl) requestArgument.getValue().getQuery();
Filter filter = query.getFilter();
And and = (And) filter;
List<Filter> filters = and.getChildren();
assertThat(filters, hasSize(3));
List<String> attributes = new ArrayList<>();
List<String> values = new ArrayList<>();
for (Filter compFilter : filters) {
String attribute;
String value;
if (compFilter instanceof IsEqualsToImpl) {
IsEqualsToImpl equals = (IsEqualsToImpl) compFilter;
AttributeExpressionImpl attributeExpression = (AttributeExpressionImpl) equals.getExpression1();
attribute = attributeExpression.getPropertyName();
LiteralExpressionImpl literalExpression = (LiteralExpressionImpl) equals.getExpression2();
value = (String) literalExpression.getValue();
} else {
LikeFilterImpl likeFilter = (LikeFilterImpl) compFilter;
AttributeExpressionImpl literalExpression = (AttributeExpressionImpl) likeFilter.getExpression();
attribute = literalExpression.getPropertyName();
value = likeFilter.getLiteral();
}
attributes.add(attribute);
values.add(value);
}
assertThat(attributes, hasSize(3));
assertThat(attributes, hasItems(Location.COUNTRY_CODE, Core.METACARD_TAGS, Core.METACARD_TAGS));
assertThat(values, hasSize(3));
assertThat(values, hasItems(COUNTRY_CODE, GAZETTEER_METACARD_TAG, GeoCodingConstants.COUNTRY_TAG));
}
use of org.geotools.filter.AttributeExpressionImpl in project hale by halestudio.
the class CqlToMappingConditionTranslator method getRightContents.
private LeafNode getRightContents(Expression expression) {
LeafNode node = new LeafNode();
if (LiteralExpressionImpl.class.isAssignableFrom(expression.getClass())) {
LiteralExpressionImpl literal = (LiteralExpressionImpl) expression;
if (literal.getValue() instanceof com.vividsolutions.jts.geom.Geometry) {
throw new IllegalArgumentException(// $NON-NLS-1$
"Geometric literals are " + // $NON-NLS-1$
"not supported! Found " + literal.getValue().getClass().getCanonicalName());
}
node.setLiteralValue(LiteralValue.getNew(literal.getValue()));
} else if (AttributeExpressionImpl.class.isAssignableFrom(expression.getClass())) {
AttributeExpressionImpl attribute = (AttributeExpressionImpl) expression;
node.setPropertyName(attribute.getPropertyName());
} else {
throw new IllegalArgumentException(// $NON-NLS-1$
"Unsupported expression type: " + expression.getClass().getCanonicalName());
}
return node;
}
Aggregations