Package org.geotools.filter

Examples of org.geotools.filter.FilterAttributeExtractor


                    FeatureSource<SimpleFeatureType, SimpleFeature> source = layer.getResource(FeatureSource.class, ProgressManager.instance().get());
                    SimpleFeatureType schema=source.getSchema();              
                    //FilterFactory fac=CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
                    //final List<String> queryAtts = obtainQueryAttributesForFeatureTable(schema);
                   
                    Set<String> required = (Set<String>) filter.accept( new FilterAttributeExtractor(), null );
                    String[] names = required.toArray( new String[ required.size()]);
                    final DefaultQuery query=new DefaultQuery(schema.getName().getLocalPart(), filter, names );
                   
                    FeatureCollection<SimpleFeatureType, SimpleFeature> features;
                    features = source.getFeatures( query ); // we just want the FeatureID no attributes needed
View Full Code Here


        final ILayer layer = (ILayer) target;
        @SuppressWarnings("unchecked")
    FeatureSource<SimpleFeatureType, SimpleFeature> source = layer
                .getResource(FeatureSource.class, new NullProgressMonitor());
       
        FilterAttributeExtractor extractor = new FilterAttributeExtractor(source.getSchema());
        layer.getFilter().accept(extractor, null);
        String[] atts = extractor.getAttributeNames();
        Query query = new Query(source.getSchema().getTypeName(),Filter.INCLUDE,atts);
        FeatureCollection<SimpleFeatureType, SimpleFeature> allCollection = source.getFeatures(query);

        FeatureIterator<SimpleFeature> allFeatures = allCollection.features();
View Full Code Here

                    }
            } else {
                DefaultQuery defaultQuery = new DefaultQuery(source.getSchema().getName().getLocalPart(),
                        filter, new String[0]);
                // TODO: Remove this workaround in 2.6.1 (note this has no performance impact)
                Set<String> required = (Set) filter.accept( new FilterAttributeExtractor(), null );               
                defaultQuery.setPropertyNames( required.toArray(new String[0]) );
               
                // get features that are just fids no attributes
                FeatureCollection<SimpleFeatureType, SimpleFeature>  features = source.getFeatures(defaultQuery);
                long start=System.currentTimeMillis();
View Full Code Here

            // Ok, say we don't support the full filter natively and it references
            // some properties, then they have to be retrieved in order to evaluate
            // the filter at runtime
            if (unsupportedFilter != null) {
                final FilterAttributeExtractor attExtractor;
                attExtractor = new FilterAttributeExtractor(fullSchema);
                unsupportedFilter.accept(attExtractor, null);
                final String[] filterAtts = attExtractor.getAttributeNames();
                for (String attName : filterAtts) {
                    if (!columnNames.contains(attName)) {
                        columnNames.add(attName);
                    }
                }
View Full Code Here

        join.setDenormalised(fMapping.isDenormalised());
        join.setSortBy(instance.baseTableQuery.getSortBy()); // incorporate order
        // pass on paging from the parent table to the same query within this join
        join.setMaxFeatures(instance.baseTableQuery.getMaxFeatures());
        join.setStartIndex(instance.baseTableQuery.getStartIndex());
        FilterAttributeExtractor extractor = new FilterAttributeExtractor();
        instance.mapping.getFeatureIdExpression().accept(extractor, null);
        for (String pn : extractor.getAttributeNameSet()) {
            join.addId(pn);
        }  
        joins.add(0, join);
        query.setQueryJoins(joins);
       
View Full Code Here

                querySchema = targetSchema;
                // if we have a post filter we have to include in the queried features also the
                // attribute needed to evaluate the post-filter
                if (postFilter != null) {
                    Set<String> queriedAttributes = new HashSet<String>(Arrays.asList(properties));
                    FilterAttributeExtractor extraAttributeExtractor = new FilterAttributeExtractor();
                    postFilter.accept(extraAttributeExtractor, null);
                    Set<String> extraAttributeSet = new HashSet<String>(
                            extraAttributeExtractor.getAttributeNameSet());
                    extraAttributeSet.removeAll(queriedAttributes);
                    if (extraAttributeSet.size() > 0) {
                        String[] queryProperties = new String[properties.length
                                + extraAttributeSet.size()];
                        System.arraycopy(properties, 0, queryProperties, 0, properties.length);
View Full Code Here

            if (!(query instanceof JoiningQuery)) {
                boolean hasIdColumn = !Expression.NIL.equals(mapping.getFeatureIdExpression())
                        && !(mapping.getFeatureIdExpression() instanceof Literal);
                query = new JoiningQuery(query);
                if (hasIdColumn) {
                    FilterAttributeExtractor extractor = new FilterAttributeExtractor();
                    mapping.getFeatureIdExpression().accept(extractor, null);
                    for (String pn : extractor.getAttributeNameSet()) {
                        ((JoiningQuery) query).addId(pn);
                    }
                }
            }
        }
View Full Code Here

        } else {
            LinkedHashSet<String> attributes = new LinkedHashSet<String>();
            attributes.addAll(Arrays.asList(q.getPropertyNames()));
            Filter filter = q.getFilter();
            if(filter != null && !Filter.INCLUDE.equals(filter)) {
                FilterAttributeExtractor fat = new FilterAttributeExtractor();
                filter.accept(fat, null);
                attributes.addAll(fat.getAttributeNameSet());
            }
           
            return SimpleFeatureTypeBuilder.retype(getSchema(), new ArrayList<String>(attributes));
        }
    }
View Full Code Here

            List<SortBy> sort = new ArrayList<SortBy>();
            if (query.getSortBy() != null) {
                for (SortBy sortBy : query.getSortBy()) {
                    for (Expression expr : unrollProperty(sortBy.getPropertyName(), mapping)) {
                        if (expr != null) {
                            FilterAttributeExtractor extractor = new FilterAttributeExtractor();
                            expr.accept(extractor, null);
       
                            for (String att : extractor.getAttributeNameSet()) {
                                sort.add(new SortByImpl(filterFac.property(att), sortBy.getSortOrder()));
                            }
                        }
                    } 
                }
            }

            if (query instanceof JoiningQuery) {
                FilterAttributeExtractor extractor = new FilterAttributeExtractor();
                mapping.getFeatureIdExpression().accept(extractor, null);
               
                if (!Expression.NIL.equals(mapping.getFeatureIdExpression())
                        && !(mapping.getFeatureIdExpression() instanceof Literal)
                        && extractor.getAttributeNameSet().isEmpty()) {
                    // GEOS-5618: getID() and functions in idExpression aren't supported with joining
                    String ns = mapping.namespaces.getPrefix(mapping.getTargetFeature().getName()
                            .getNamespaceURI());
                    String separator = mapping.getTargetFeature().getName().getSeparator();
                    String typeName = mapping.getTargetFeature().getLocalName();
                    throw new UnsupportedOperationException(
                            String.format(
                                    "idExpression '%s' for targetElement '%s%s%s' cannot be translated into SQL, "
                                            + "therefore is not supported with joining!"
                                            + "\nPlease make sure idExpression is mapped into existing database fields, "
                                            + "and only use functions that are supported by your database."
                                            + "\nIf this cannot be helped, you can turn off joining in app-schema.properties file.",
                                    mapping.getFeatureIdExpression(), ns, separator, typeName));
                }
               
                JoiningQuery jQuery = new JoiningQuery(newQuery);
                jQuery.setDenormalised(((JoiningQuery) query).isDenormalised());
                jQuery.setQueryJoins(((JoiningQuery) query).getQueryJoins());
                jQuery.setSubset(((JoiningQuery) query).isSubset());

                for (String att : extractor.getAttributeNameSet()) {
                    sort.add(new SortByImpl(filterFac.property(att), SortOrder.ASCENDING));
                    jQuery.addId(att);
                }

               
View Full Code Here

                    final Expression idExpression = entry.getIdentifierExpression();
                    // NC - include client properties
                    final Collection<Expression> clientProperties = entry.getClientProperties()
                            .values();

                    FilterAttributeExtractor extractor = new FilterAttributeExtractor();
                    sourceExpression.accept(extractor, null);
                    idExpression.accept(extractor, null);

                    // RA - include function parameters in linkField
                    if (entry instanceof NestedAttributeMapping) {
                        final Expression linkFieldExpression = ((NestedAttributeMapping) entry).nestedFeatureType;
                        linkFieldExpression.accept(extractor, null);
                    }

                    Iterator<Expression> it = clientProperties.iterator();
                    while (it.hasNext()) {
                        it.next().accept(extractor, null);
                    }
                    Set<String> exprAtts = extractor.getAttributeNameSet();

                    for (String mappedAtt : exprAtts) {
                        if (!mappedAtt.equals("Expression.NIL")) { // NC - ignore Nil Expression
                            if (mappedType == null) {
                                // web service backend.. no underlying simple feature
View Full Code Here

TOP

Related Classes of org.geotools.filter.FilterAttributeExtractor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.