@Override public Object visit(PropertyName expression, Object extraData) { AttributeDescriptor result = expression.evaluate(schema, AttributeDescriptor.class); if (result == null) { throw new IllegalArgumentException( "Original feature type does not have a property named " + expression.getPropertyName()); } if (result instanceof GeometryDescriptor) { this.crs = ((GeometryDescriptor) result).getCoordinateReferenceSystem(); } return result.getType().getBinding(); }
public Object visit(PropertyName expression, Object extraData) { // NC - namespace support return getFactory(extraData) .property(expression.getPropertyName(), expression.getNamespaceContext()); }
/** * Helper method for executing a property name against a feature type. * * <p>This method will fall back on {@link PropertyName#getPropertyName()} if it does not * evaulate against the feature type. */ protected String getPropertyName(SimpleFeatureType featureType, PropertyName propertyName) { AttributeDescriptor att = (AttributeDescriptor) propertyName.evaluate(featureType); if (att != null) { return att.getLocalName(); } return propertyName.getPropertyName(); }
@Override public Object visit(PropertyName expression, Object extraData) { AttributeDescriptor ad = expression.evaluate(schema, AttributeDescriptor.class); if (ad == null) { throw new IllegalArgumentException( "Original feature type does not have a property named " + expression.getPropertyName()); } else if (ad instanceof GeometryDescriptor) { return ((GeometryDescriptor) ad).getCoordinateReferenceSystem(); } return null; }
static final boolean canSort(SimpleFeatureType schema, SortBy[] sortBy) { if (sortBy == SortBy.UNSORTED) { return true; } // check all attributes are serializable for (AttributeDescriptor ad : schema.getAttributeDescriptors()) { Class<?> binding = ad.getType().getBinding(); if (!Serializable.class.isAssignableFrom(binding)) { return false; } } // check all sorting attributes are comparable for (SortBy sb : sortBy) { if (sb != SortBy.NATURAL_ORDER && sb != SortBy.REVERSE_ORDER) { AttributeDescriptor ad = schema.getDescriptor(sb.getPropertyName().getPropertyName()); if (ad == null) { return false; } Class<?> binding = ad.getType().getBinding(); if (!Comparable.class.isAssignableFrom(binding) || Geometry.class.isAssignableFrom(binding)) { return false; } } } return true; }
filterFac.property(targetSteps.toString(), mapping.getNamespaces()); Object descr = targetProp.evaluate(targetDescriptor.getType()); if (descr instanceof PropertyDescriptor) { if (((PropertyDescriptor) descr).getMinOccurs() >= 1) { requestedProperty.getPropertyName())) { String defGeomPath = mapping.getDefaultGeometryXPath(); requestedProperty = filterFac.property(defGeomPath, mapping.getNamespaces()); if (requestedProperty.getNamespaceContext() == null) { requestedPropertySteps = XPath.steps( targetDescriptor, requestedProperty.getPropertyName(), mapping.getNamespaces()); } else { XPath.steps( targetDescriptor, requestedProperty.getPropertyName(), requestedProperty.getNamespaceContext()); ? matchProperty(requestedProperty.getPropertyName(), targetSteps) : matchProperty(requestedPropertySteps, targetSteps)) { addThis = true; Object object = propExpr.evaluate(mappedType); AttributeDescriptor mappedAttribute = (AttributeDescriptor) object;
private void testLogicFilter(Class<?> filterType) throws Exception { BinaryLogicOperator complexLogicFilter; PropertyIsGreaterThan resultFilter = ff.greater(ff.property("measurement/result"), ff.literal(Integer.valueOf(5))); ((PropertyName) unmappedResult.getExpression1()).getPropertyName()); assertEquals(Integer.valueOf(5), ((Literal) unmappedResult.getExpression2()).getValue()); ((PropertyName) unmappedDeterm.getExpression()).getPropertyName()); assertEquals( "determinand_description_1_1", ((Literal) unmappedDeterm.getLowerBoundary()).getValue()); assertEquals( "determinand_description_3_3", ((Literal) unmappedDeterm.getUpperBoundary()).getValue());
@Test public void testLogicFilterAnd() throws Exception { PropertyIsEqualTo equals = ff.equals(ff.property("measurement/result"), ff.literal(1.1)); PropertyIsGreaterThan greater = ff.greater(ff.property("measurement/determinand_description"), ff.literal("desc1")); And logicFilter = ff.and(equals, greater); Filter unrolled = (Filter) logicFilter.accept(visitor, null); assertNotNull(unrolled); assertTrue(unrolled instanceof And); assertNotSame(equals, unrolled); And sourceAnd = (And) unrolled; assertEquals(2, sourceAnd.getChildren().size()); Filter sourceEquals = (Filter) sourceAnd.getChildren().get(0); assertTrue(sourceEquals instanceof PropertyIsEqualTo); Expression left = ((PropertyIsEqualTo) sourceEquals).getExpression1(); Expression right = ((PropertyIsEqualTo) sourceEquals).getExpression2(); assertTrue(left instanceof PropertyName); assertTrue(right instanceof Literal); assertEquals("results_value", ((PropertyName) left).getPropertyName()); assertEquals(new Double(1.1), ((Literal) right).getValue()); Filter sourceGreater = (Filter) sourceAnd.getChildren().get(1); assertTrue(sourceGreater instanceof PropertyIsGreaterThan); left = ((PropertyIsGreaterThan) sourceGreater).getExpression1(); right = ((PropertyIsGreaterThan) sourceGreater).getExpression2(); assertTrue(left instanceof PropertyName); assertTrue(right instanceof Literal); assertEquals("determinand_description", ((PropertyName) left).getPropertyName()); assertEquals("desc1", ((Literal) right).getValue()); }
@Test public void testGeometryFilter() throws Exception { mapping = createSampleDerivedAttributeMappings(); visitor = new UnmappingFilterVisitor(mapping); targetDescriptor = mapping.getTargetFeature(); targetType = (FeatureType) targetDescriptor.getType(); Expression literalGeom = ff.literal(new GeometryFactory().createPoint(new Coordinate(1, 1))); Intersects gf = ff.intersects(ff.property("areaOfInfluence"), literalGeom, MatchAction.ALL); Filter unrolled = (Filter) gf.accept(visitor, null); assertTrue(unrolled instanceof Intersects); assertNotSame(gf, unrolled); assertEquals(MatchAction.ALL, ((Intersects) unrolled).getMatchAction()); Intersects newFilter = (Intersects) unrolled; Expression left = newFilter.getExpression1(); Expression right = newFilter.getExpression2(); assertSame(right, literalGeom); assertTrue(left instanceof Function); Function fe = (Function) left; assertEquals("buffer", fe.getName()); Expression arg0 = (Expression) fe.getParameters().get(0); assertTrue(arg0 instanceof PropertyName); assertEquals("location", ((PropertyName) arg0).getPropertyName()); }
AttributeDescriptor parentDescriptor = parent.getDescriptor(); if (parentDescriptor != null) { rootName = parentDescriptor.getName(); Step rootStep = (Step) steps.get(0); QName stepName = rootStep.getName(); geomType, rootName, parentDescriptor.getMinOccurs(), parentDescriptor.getMaxOccurs(), parentDescriptor.isNillable(), parentDescriptor.getDefaultValue()); if (_parentType.getName().equals(XSSchema.ANYTYPE_TYPE.getName()) && targetDescriptor != null) { Attribute child = (Attribute) name.evaluate(parent); if (child != null) { currStepDescriptor = child.getDescriptor(); if (actualDescriptor instanceof GeometryDescriptor) { if (Geometry.class.isAssignableFrom(targetNodeType.getBinding())) { if (!(targetNodeType instanceof GeometryType)) { targetNodeType =
public Object visit(PropertyName expression, Object extraData) { if ("".equals(expression.getPropertyName())) { return super.visit(expression, extraData); } AttributeDescriptor att = expression.evaluate(featureType, null); if (att != null) { return getFactory(extraData).property(att.getLocalName()); } return super.visit(expression, extraData); } }
public Object evaluate(Object feature) { String name = getExpression(0).evaluate(feature, String.class); if (name == null) { return null; } PropertyName pn = lastPropertyName; if (pn != null && pn.getPropertyName().equals(name)) { return pn.evaluate(feature); } else { pn = FF.property(name); Object result = pn.evaluate(feature); lastPropertyName = pn; return result; } } }
PropertyName targetProp = namespaceAwareFilterFactory.property(targetSteps.toString()); Object descr = targetProp.evaluate(targetDescriptor.getType()); if (descr instanceof PropertyDescriptor) { if (((PropertyDescriptor) descr).getMinOccurs() >= 1) { if (DEFAULT_GEOMETRY_LOCAL_NAME.equals(requestedProperty.getPropertyName())) { String defGeomPath = mapping.getDefaultGeometryXPath(); requestedProperty = namespaceAwareFilterFactory.property(defGeomPath); if (requestedProperty.getNamespaceContext() == null) { requestedPropertySteps = XPath.steps( targetDescriptor, requestedProperty.getPropertyName(), namespaces); } else { XPath.steps( targetDescriptor, requestedProperty.getPropertyName(), requestedProperty.getNamespaceContext()); requestedProperty.getPropertyName(), targetSteps) : AppSchemaDataAccess.matchProperty( requestedPropertySteps, targetSteps)) { targetSteps.size(), requestedPropertySteps.size()); pnList.add(
AttributeDescriptor attType = (AttributeDescriptor) property.evaluate(featureType); if (attType != null) { typeContext = attType.getType().getBinding(); property.accept(this, extraData); out.write(swapped ? inv : op); visitBegin(period, extraData); property.accept(this, extraData); out.write(swapped ? inv : op); visitEnd(period, extraData); } else { if (swapped) { temporal.accept(this, typeContext); } else { property.accept(this, extraData); property.accept(this, extraData); || filter instanceof BegunBy || filter instanceof EndedBy) { property.accept(this, extraData); out.write(" = "); property.accept(this, extraData); out.write(" BETWEEN "); visitEnd(period, extraData);
@Test public void testCompareFilter() throws Exception { PropertyIsEqualTo complexFilter = ff.equal(ff.property("measurement/result"), ff.literal(1.1), true, MatchAction.ALL); Filter unrolled = (Filter) complexFilter.accept(visitor, null); assertNotNull(unrolled); assertTrue(unrolled instanceof PropertyIsEqualTo); assertNotSame(complexFilter, unrolled); assertTrue(((PropertyIsEqualTo) unrolled).isMatchingCase()); assertEquals(MatchAction.ALL, ((PropertyIsEqualTo) unrolled).getMatchAction()); Expression left = ((PropertyIsEqualTo) unrolled).getExpression1(); Expression right = ((PropertyIsEqualTo) unrolled).getExpression2(); assertTrue(left instanceof PropertyName); assertTrue(right instanceof Literal); PropertyName attExp = (PropertyName) left; String expectedAtt = "results_value"; assertEquals(expectedAtt, attExp.getPropertyName()); assertEquals(new Double(1.1), ((Literal) right).getValue()); }
@Override public Object visit(PropertyName expression, Object extraData) { AttributeDescriptor ad = expression.evaluate(featureType, AttributeDescriptor.class); if (ad != null) { return ad.getType().getBinding(); } else { return Object.class; } } }
@Test public void testFunction() throws Exception { Function fe = ff.function( "strIndexOf", ff.property("/measurement/determinand_description"), ff.literal("determinand_description_1")); List unrolledExpressions = (List) fe.accept(visitor, null); Expression unmapped = (Expression) unrolledExpressions.get(0); assertTrue(unmapped instanceof Function); List params = ((Function) unmapped).getParameters(); assertEquals(2, params.size()); assertTrue(params.get(0) instanceof PropertyName); assertEquals("determinand_description", ((PropertyName) params.get(0)).getPropertyName()); }
if (geometry instanceof PropertyName) { PropertyName propertyName = (PropertyName) geometry; ls.setGeometryPropertyName(propertyName.getPropertyName()); } else { ls.setGeometry(geometry); .put(param.getName(), param.getExpression().evaluate(null, String.class));
attribute = ((PropertyName) expr).getPropertyName(); return false; // optimization restricted to column evaulation Class binding = descriptor.getType().getBinding(); if (Geometry.class.isAssignableFrom(binding) || !(Comparable.class.isAssignableFrom(binding))) {
@Override public int compare(Object o1, Object o2) { Object v1 = OwsUtils.get(o1, sortOrder.getPropertyName().getPropertyName()); Object v2 = OwsUtils.get(o2, sortOrder.getPropertyName().getPropertyName()); if (v1 == null) { if (v2 == null) { return 0; } else { return -1; } } else if (v2 == null) { return 1; } Comparable c1 = (Comparable) v1; Comparable c2 = (Comparable) v2; return c1.compareTo(c2); } };