/** * Returns true if the last visited expression is a constant, that is, does not depend on any * attribute and does not use any {@link VolatileFunction} * * @return */ public boolean isConstantExpression() { return !usingVolatileFunctions && !usingDynamicProperties && getAttributeNameSet().isEmpty(); }
private boolean isStatic(Expression exp) { FilterAttributeExtractor attributeExtractor = new FilterAttributeExtractor(); exp.accept(attributeExtractor, null); return attributeExtractor.getAttributeNameSet().isEmpty(); }
/** * Uses FilterAttributeExtractor to return the list of all mentioned attribute names. * * <p>You can use this method to quickly build up the set of any mentioned attribute names. * * @param filter * @return Set of propertyNames */ public Set<String> attributeNames(Filter filter) { if (filter == null) { return Collections.emptySet(); } FilterAttributeExtractor extractor = new FilterAttributeExtractor(); filter.accept(extractor, new HashSet<String>()); return extractor.getAttributeNameSet(); }
/** * Returns all the JSON paths associated with the provided property name as property names, in * practice this method finds the source expression associated with the attribute mapping * matching the provided property name and extracts its JSON path converting it to a property * name. Since the source expression may use multiple attributes, multiple JSON paths may be * found. */ private List<PropertyName> extractJsonPaths( FeatureTypeMapping featureTypeMapping, PropertyName propertyName) { // get the expression of the mapping attribute matching the provided property name Expression expression = findPropertyExpression(featureTypeMapping, propertyName); if (expression == null) { // no attribute matches the provided property, let's move on return Collections.emptyList(); } // extracts all the properties from the attribute mapping expression FilterAttributeExtractor propertiesExtractor = new FilterAttributeExtractor(); expression.accept(propertiesExtractor, null); // convert all properties \ attributes to a property name return propertiesExtractor .getAttributeNameSet() .stream() .map(attributeName -> filterFactory.property(attributeName)) .collect(Collectors.toList()); }
/** * Builds the list of original attributes required to run the specified query * * @param source * @param query * @return */ String[] getRequiredAttributes(Query query) { Set<String> attributes = new HashSet<String>(); FilterAttributeExtractor extractor = new FilterAttributeExtractor(); if (query.getPropertyNames() == Query.ALL_NAMES) { for (Expression ex : expressions.values()) { ex.accept(extractor, null); } } else { for (String name : query.getPropertyNames()) { Expression ex = expressions.get(name); ex.accept(extractor, null); } } attributes.addAll(extractor.getAttributeNameSet()); return attributes.toArray(new String[attributes.size()]); }
SimpleFeatureType getReadSchema(Query q) { if (q.getPropertyNames() == Query.ALL_NAMES) { return getSchema(); } // Step 1: start with requested property names LinkedHashSet<String> attributes = new LinkedHashSet<String>(); attributes.addAll(Arrays.asList(q.getPropertyNames())); Filter filter = q.getFilter(); if (filter != null && !Filter.INCLUDE.equals(filter)) { // Step 2: Add query attributes (if needed) // Step 3: Fill empty XPath with appropriate property names FilterAttributeExtractor fat = new AbsoluteAttributeExtractor(getSchema()); filter.accept(fat, null); attributes.addAll(fat.getAttributeNameSet()); } return SimpleFeatureTypeBuilder.retype(getSchema(), new ArrayList<String>(attributes)); }
FilterAttributeExtractor attributeExtractor = new FilterAttributeExtractor(); filter.accept(attributeExtractor, null); Set<String> attributes = attributeExtractor.getAttributeNameSet(); GeometryDescriptor geometryAttribute = null; for (String name : attributes) {
/** * Only used for Joining, to make sure that rows with different foreign id's aren't interpreted * as one feature and merged. */ public List<Object> getIdValues(Object source) { List<Object> ids = new ArrayList<Object>(); Expression idExpression = mapping.getFeatureIdExpression(); if (Expression.NIL.equals(idExpression) || idExpression instanceof Literal) { // GEOT-4554: if idExpression is not specified, should use PK if (source instanceof Feature) { for (Property p : ((Feature) source).getProperties()) { if (p.getName() .getLocalPart() .startsWith(JoiningJDBCFeatureSource.PRIMARY_KEY)) { ids.add(p.getValue()); } } } } else { FilterAttributeExtractor extractor = new FilterAttributeExtractor(); idExpression.accept(extractor, null); for (String att : extractor.getAttributeNameSet()) { ids.add(peekValue(source, namespaceAwareFilterFactory.property(att))); } } if (foreignIds != null) { ids.addAll(getForeignIdValues(source)); } return ids; }
private void assertAttributeName(org.opengis.filter.Filter filter, String[] names) { fae.clear(); filter.accept(fae, null); Set<String> attNames = fae.getAttributeNameSet(); assertNotNull(attNames); assertEquals(attNames.size(), names.length); for (int i = 0; i < names.length; i++) { assertTrue(attNames.contains(names[i])); } // make sure the property name set is aligned Set<PropertyName> propNames = fae.getPropertyNameSet(); assertNotNull(propNames); assertEquals(attNames.size(), propNames.size()); for (PropertyName pn : propNames) { assertTrue(attNames.contains(pn.getPropertyName())); } }
it.next().accept(extractor, null); Set<String> exprAtts = extractor.getAttributeNameSet();
/** * Returns true if the last visited expression is a constant, that is, does not * depend on any attribute and does not use any {@link VolatileFunction} * * @return */ public boolean isConstantExpression() { return !usingVolatileFunctions && !usingDynamicProperties && getAttributeNameSet().isEmpty(); }
expr.accept(extractor, null); for (String att : extractor.getAttributeNameSet()) { sort.add( new SortByImpl( && extractor.getAttributeNameSet().isEmpty()) { jQuery.setSubset(((JoiningQuery) query).isSubset()); for (String att : extractor.getAttributeNameSet()) { sort.add(new SortByImpl(filterFac.property(att), SortOrder.ASCENDING)); jQuery.addId(att);
FilterAttributeExtractor extractor = new FilterAttributeExtractor(); instance.mapping.getFeatureIdExpression().accept(extractor, null); for (String pn : extractor.getAttributeNameSet()) { join.addId(pn);
public void testPropertyNameSet() throws IllegalFilterException { Filter filter = fac.equals(fac.property("testString"), fac.literal("test string data")); Expression expression1 = fac.property("code"); Expression expression2 = fac.function("length", fac.property("identification")); FilterAttributeExtractor extract = new FilterAttributeExtractor(null); Set<String> names = new HashSet<String>(); // used to collect names from expression1, expression2, and filter expression1.accept(extract, names); expression2.accept(extract, names); filter.accept(extract, names); String array[] = extract.getAttributeNames(); Set<String> attributes = extract.getAttributeNameSet(); Set<PropertyName> properties = extract.getPropertyNameSet(); assertEquals(3, array.length); assertEquals(3, attributes.size()); assertEquals(3, properties.size()); } /**
/** * Uses FilterAttributeExtractor to return the list of all mentioned attribute names. * <p> * You can use this method to quickly build up the set of any mentioned attribute names. * * @param filter * @return Set of propertyNames */ public Set<String> attributeNames( Filter filter ){ if( filter == null ){ return Collections.emptySet(); } FilterAttributeExtractor extractor = new FilterAttributeExtractor(); filter.accept( extractor, new HashSet<String>() ); return extractor.getAttributeNameSet(); }
FilterAttributeExtractor extractor = new FilterAttributeExtractor(); mapping.getFeatureIdExpression().accept(extractor, null); for (String pn : extractor.getAttributeNameSet()) { ((JoiningQuery) query).addId(pn);
/** * Builds the list of original attributes required to run the specified query * * @param source * @param query * @return */ String[] getRequiredAttributes(Query query) { Set<String> attributes = new HashSet<String>(); FilterAttributeExtractor extractor = new FilterAttributeExtractor(); if (query.getPropertyNames() == Query.ALL_NAMES) { for (Expression ex : expressions.values()) { ex.accept(extractor, null); } } else { for (String name : query.getPropertyNames()) { Expression ex = expressions.get(name); ex.accept(extractor, null); } } attributes.addAll(extractor.getAttributeNameSet()); return attributes.toArray(new String[attributes.size()]); }
/** * Only used for Joining, to make sure that rows with different foreign id's * aren't interpreted as one feature and merged. */ public List<Object> getIdValues(Object source) { List<Object> ids = new ArrayList<Object>(); FilterAttributeExtractor extractor = new FilterAttributeExtractor(); mapping.getFeatureIdExpression().accept(extractor, null); for (String att : extractor.getAttributeNameSet()) { ids.add(peekValue(source, namespaceAwareFilterFactory.property( att))); } if (foreignIds != null) { ids.addAll(getForeignIdValues(source)); } return ids; }
private void validateCqlFilter(FeatureTypeInfo typeInfo, String cqlFilterString) throws Exception { Filter cqlFilter = null; if (cqlFilterString != null && !cqlFilterString.isEmpty()) { cqlFilter = ECQL.toFilter(cqlFilterString); FeatureType ft = typeInfo.getFeatureType(); if (ft instanceof SimpleFeatureType) { SimpleFeatureType sft = (SimpleFeatureType) ft; BeanToPropertyValueTransformer transformer = new BeanToPropertyValueTransformer("localName"); Collection<String> featureAttributesNames = CollectionUtils.collect(sft.getAttributeDescriptors(), transformer); FilterAttributeExtractor filterAttriubtes = new FilterAttributeExtractor(null); cqlFilter.accept(filterAttriubtes, null); Set<String> filterAttributesNames = filterAttriubtes.getAttributeNameSet(); for (String filterAttributeName : filterAttributesNames) { if (!featureAttributesNames.contains(filterAttributeName)) { throw new ResourceConfigurationException( ResourceConfigurationException.CQL_ATTRIBUTE_NAME_NOT_FOUND_$1, new Object[] {filterAttributeName}); } } } } }
protected void init( Transaction transaction, Query query, Integer level ) throws IOException { FilterEncodingPreProcessor visitor = new FilterEncodingPreProcessor(level); Filters.accept( query.getFilter(), visitor ); this.transaction=transaction; if( visitor.requiresPostProcessing() && query.getPropertyNames()!=Query.ALL_NAMES){ FilterAttributeExtractor attributeExtractor=new FilterAttributeExtractor(); query.getFilter().accept( attributeExtractor, null ); Set<String> properties = new HashSet<String>(attributeExtractor.getAttributeNameSet()); properties.addAll(Arrays.asList(query.getPropertyNames())); this.query = new Query(query); this.query.setPropertyNames((String[]) properties.toArray(new String[0])); } else { this.query=query; } this.filter=visitor.getFilter(); Query nonFidQuery=new Query(query); Id fidFilter = visitor.getFidFilter(); nonFidQuery.setFilter(fidFilter); if( fidFilter.getIDs().size()>0 ){ delegate = StrictWFSStrategy.super.createFeatureReader(transaction, nonFidQuery); }else{ delegate=nextReader(); } }