Package org.opengis.filter.sort

Examples of org.opengis.filter.sort.SortBy


        if (textFilter != null) {
            filter = Predicates.and(filter, Predicates.fullTextSearch(textFilter));
        }
        Integer total = cat.count(LayerInfo.class, filter);

        SortBy sortBy = null;
        if (sort != null) {
            String[] sortArr = sort.split(":", 2);
            if (sortArr.length == 2) {
                if (sortArr[1].equals("asc")) {
                    sortBy = Predicates.asc(sortArr[0]);
View Full Code Here


            return null;
        }

        StringBuilder byClause = new StringBuilder("ORDER BY ");
        for (int i = 0; i < sortByAttributes.length; i++) {
            SortBy sortAtt = sortByAttributes[i];
            if (sortAtt == NATURAL_ORDER || sortAtt == REVERSE_ORDER) {
                if (fidReader instanceof SdeManagedFidReader
                        || fidReader instanceof UserManagedFidReader) {
                    byClause.append(fidReader.getFidColumn()).append(" ");
                    byClause.append(sortAtt == NATURAL_ORDER ? "ASC" : "DESC");
                } else {
                    throw new IllegalArgumentException(sortAtt
                            + " sorting is not supported for featureclasses"
                            + " with no primary key");
                }
            } else {
                final PropertyName propertyName = sortAtt.getPropertyName();
                final String attName = propertyName.getPropertyName();
                final AttributeDescriptor descriptor = fullSchema.getDescriptor(attName);
                if (descriptor == null) {
                    throw new IllegalArgumentException(attName
                            + " does not exist. Can't sort by it");
                }
                if (descriptor instanceof GeometryDescriptor) {
                    throw new IllegalArgumentException(attName
                            + " is a geometry attribute. Can't sort by it");
                }

                byClause.append(attName).append(" ");
                byClause.append(sortAtt.getSortOrder() == SortOrder.ASCENDING ? "ASC" : "DESC");
            }
            if (i < sortByAttributes.length - 1) {
                byClause.append(", ");
            }
        }
View Full Code Here

        return filterfactory.sort(name.getPropertyName(), order);
    }

    public Object getProperty(Object object, QName name)
        throws Exception {
        SortBy sortBy = (SortBy) object;

        if (OGC.PropertyName.equals(name)) {
            return sortBy.getPropertyName();
        }

        if ("SortOrder".equals(name.getLocalPart())) {
            return sortBy.getSortOrder();
        }

        return null;
    }
View Full Code Here

            // assertTrue(subCollection.size()==0);
            // assertFalse(subCollection.contains(array[0]));

            // SortBy2 sortBy = new SortByImpl(new
            // AttributeExpressionImpl("CAT_ID"),SortOrder.ASCENDING);
            SortBy sortBy = new SortBy() {
                public PropertyName getPropertyName() {
                    return new AttributeExpressionImpl("CAT_ID");
                }
                public SortOrder getSortOrder() {
                    return SortOrder.ASCENDING;
View Full Code Here

                if( filter.evaluate(feature ) ){
                    fids.add( feature.getIdentifier() );
                }
            }
            if( sort != null && !sort.isEmpty()){
                final SortBy initialOrder = (SortBy) sort.get( sort.size() -1 );
                final FeatureIdAccessor idAccessor = new FeatureIdAccessor(true);
                Collections.sort(fids, new Comparator<FeatureId>() {
                    public int compare( FeatureId key1, FeatureId key2 ) {
                        SimpleFeature feature1 = idAccessor.getFeature( key1.getID() );
                        SimpleFeature feature2 = idAccessor.getFeature( key2.getID() );
View Full Code Here

    }

    public void testGetFeaturesWithSort() throws Exception {
        init();
        FilterFactory ff = dataStore.getFilterFactory();
        SortBy sort = ff.sort("vendor_s", SortOrder.ASCENDING);
        Query query = new Query();
        query.setSortBy(new SortBy[] { sort });

        SimpleFeatureCollection features = featureSource.getFeatures(query);
        assertEquals(11, features.size());
View Full Code Here

    public boolean supportsSorting(final SortBy[] sortAttributes) {
        if(super.supportsSorting(sortAttributes))
            return true;
       
        for (int i = 0; i < sortAttributes.length; i++) {
            SortBy sortBy = sortAttributes[i];
            if (SortBy.NATURAL_ORDER == sortBy || SortBy.REVERSE_ORDER == sortBy) {
                // we do only if we have a non null primary key
                return !(source.getPrimaryKey() instanceof NullPrimaryKey);
            } else {
                PropertyName propertyName = sortBy.getPropertyName();
                SortOrder sortOrder = sortBy.getSortOrder();
                if (!supportsPropertySorting(propertyName, sortOrder)) {
                    return false;
                }
            }
        }
View Full Code Here

        }
    }

    public void testGetFeaturesWithSort() throws Exception {
        FilterFactory ff = dataStore.getFilterFactory();
        SortBy sort = ff.sort(aname("stringProperty"), SortOrder.ASCENDING);
        Query query = new Query();
        query.setSortBy(new SortBy[] { sort });

        SimpleFeatureCollection features = featureSource.getFeatures(query);
        assertEquals(3, features.size());
View Full Code Here

                new SortBy[] { SortBy.REVERSE_ORDER });
        checkSorted(sorted, DataUtilities.sortComparator(SortBy.REVERSE_ORDER));
    }

    public void testSortAttribute() throws Exception {
        SortBy sort = ff.sort("someAtt", SortOrder.ASCENDING);
        SortedSimpleFeatureCollection sorted = new SortedSimpleFeatureCollection(delegate,
                new SortBy[] { sort });
        checkSorted(sorted, DataUtilities.sortComparator(sort));
    }
View Full Code Here

      }
      assertTrue(error);

      //sort by
      String prop = schema.getAttributeDescriptors().get(1).getLocalName();
      SortBy sb =filterFactory.sort(prop, SortOrder.ASCENDING);
      query = new DefaultQuery(schema.getTypeName());
      query.setSortBy(new SortBy[]{sb});
      error = false;
      try{
        features = cacheDataset.getFeatures(query);
View Full Code Here

TOP

Related Classes of org.opengis.filter.sort.SortBy

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.