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);
}
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());
}
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]);
}
Aggregations