Search in sources :

Example 66 with SortByImpl

use of ddf.catalog.filter.impl.SortByImpl in project ddf by codice.

the class OpenSearchParserImplTest method populateSearchOptionsWithNullPrincipalSubject.

@Test
public void populateSearchOptionsWithNullPrincipalSubject() {
    SortBy sortBy = new SortByImpl(Result.TEMPORAL, SortOrder.DESCENDING);
    Filter filter = mock(Filter.class);
    Query query = new QueryImpl(filter, 0, 2000, sortBy, true, 30000);
    QueryRequest queryRequest = new QueryRequestImpl(query);
    String principalName = "principalName";
    Subject subject = getMockSubject(principalName);
    when(subject.getPrincipals()).thenReturn(null);
    openSearchParser.populateSearchOptions(webClient, queryRequest, subject, Arrays.asList("q,src,mr,start,count,mt,dn,lat,lon,radius,bbox,polygon,dtstart,dtend,dateName,filter,sort".split(",")));
    assertQueryParameterPopulated(OpenSearchConstants.COUNT);
    assertQueryParameterPopulated(OpenSearchConstants.MAX_RESULTS, MAX_RESULTS);
    assertQueryParameterPopulated(OpenSearchConstants.MAX_TIMEOUT, TIMEOUT);
    assertQueryParameterNotPopulated(OpenSearchParserImpl.USER_DN);
    assertQueryParameterPopulated(OpenSearchConstants.SORT, DESCENDING_TEMPORAL_SORT);
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) Query(ddf.catalog.operation.Query) QueryRequest(ddf.catalog.operation.QueryRequest) SortByImpl(ddf.catalog.filter.impl.SortByImpl) TemporalFilter(ddf.catalog.impl.filter.TemporalFilter) Filter(org.opengis.filter.Filter) SortBy(org.opengis.filter.sort.SortBy) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) Subject(ddf.security.Subject) Test(org.junit.Test)

Example 67 with SortByImpl

use of ddf.catalog.filter.impl.SortByImpl in project ddf by codice.

the class CswQueryFactory method normalizeSortBy.

private SortBy normalizeSortBy(SortBy cswSortBy) {
    if (cswSortBy == null || cswSortBy.getPropertyName() == null) {
        return null;
    }
    String propertyName = cswSortBy.getPropertyName().getPropertyName();
    if (propertyName == null) {
        LOGGER.debug("Property in SortBy Field is null");
        return null;
    }
    NamespaceSupport namespaceContext = cswSortBy.getPropertyName().getNamespaceContext();
    if (!attributeRegistry.lookup(propertyName).isPresent() && !cswRecordMap.hasProperty(propertyName, namespaceContext)) {
        LOGGER.debug("Property {} is not a valid SortBy Field", propertyName);
        return null;
    }
    String name = cswRecordMap.getProperty(propertyName, namespaceContext);
    PropertyName propName = new AttributeExpressionImpl(new NameImpl(name));
    return new SortByImpl(propName, cswSortBy.getSortOrder());
}
Also used : PropertyName(org.opengis.filter.expression.PropertyName) NameImpl(org.geotools.feature.NameImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) SortByImpl(ddf.catalog.filter.impl.SortByImpl) NamespaceSupport(org.xml.sax.helpers.NamespaceSupport)

Example 68 with SortByImpl

use of ddf.catalog.filter.impl.SortByImpl in project ddf by codice.

the class CswQueryFactory method buildSort.

private SortBy[] buildSort(SortByType sort) throws CswException {
    if (sort == null || sort.getSortProperty() == null) {
        return null;
    }
    SortBy[] sortByArr = parseSortBy(sort);
    if (sortByArr == null || sortByArr.length == 0) {
        return null;
    }
    List<SortBy> sortBys = new ArrayList<>(sortByArr.length);
    for (SortBy cswSortBy : sortByArr) {
        if (cswSortBy.getPropertyName() == null) {
            LOGGER.debug("No property name in primary sort criteria");
            return null;
        }
        String name = cswSortBy.getPropertyName().getPropertyName();
        PropertyName propName = new AttributeExpressionImpl(new NameImpl(name));
        SortBy sortBy = new SortByImpl(propName, cswSortBy.getSortOrder());
        sortBys.add(sortBy);
    }
    if (sortBys.isEmpty()) {
        return null;
    }
    return sortBys.toArray(new SortBy[0]);
}
Also used : PropertyName(org.opengis.filter.expression.PropertyName) NameImpl(org.geotools.feature.NameImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) SortByImpl(ddf.catalog.filter.impl.SortByImpl) SortBy(org.opengis.filter.sort.SortBy) ArrayList(java.util.ArrayList)

Aggregations

SortByImpl (ddf.catalog.filter.impl.SortByImpl)68 QueryImpl (ddf.catalog.operation.impl.QueryImpl)65 Test (org.junit.Test)56 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)47 SortBy (org.opengis.filter.sort.SortBy)45 SourceResponse (ddf.catalog.operation.SourceResponse)28 QueryRequest (ddf.catalog.operation.QueryRequest)23 Matchers.containsString (org.hamcrest.Matchers.containsString)21 Filter (org.opengis.filter.Filter)13 ArrayList (java.util.ArrayList)12 GetFeatureType (net.opengis.wfs.v_2_0_0.GetFeatureType)12 QueryType (net.opengis.wfs.v_2_0_0.QueryType)12 Query (ddf.catalog.operation.Query)9 TemporalFilter (ddf.catalog.impl.filter.TemporalFilter)8 InputStream (java.io.InputStream)8 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)8 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)8 CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)8 MetacardMapper (org.codice.ddf.spatial.ogc.wfs.catalog.mapper.MetacardMapper)8 ByteArrayInputStream (java.io.ByteArrayInputStream)7