use of org.codice.ddf.spatial.ogc.csw.catalog.endpoint.mappings.CswRecordMapperFilterVisitor in project ddf by codice.
the class CswQueryFactory method buildFilter.
private CswRecordMapperFilterVisitor buildFilter(QueryConstraintType constraint) throws CswException {
CswRecordMapperFilterVisitor visitor = new CswRecordMapperFilterVisitor(metacardType, metacardTypes);
Filter filter = null;
if (constraint != null) {
if (constraint.isSetCqlText()) {
try {
filter = CQL.toFilter(constraint.getCqlText());
} catch (CQLException e) {
throw new CswException("Unable to parse CQL Constraint: " + e.getMessage(), e);
}
} else if (constraint.isSetFilter()) {
FilterType constraintFilter = constraint.getFilter();
filter = parseFilter(constraintFilter);
}
} else {
// not supported by catalog:
//filter = Filter.INCLUDE;
filter = builder.attribute(Core.ID).is().like().text(FilterDelegate.WILDCARD_CHAR);
}
if (filter == null) {
throw new CswException("Invalid Filter Expression", CswConstants.NO_APPLICABLE_CODE, null);
}
filter = transformCustomFunctionToFilter(filter);
try {
visitor.setVisitedFilter((Filter) filter.accept(visitor, new FilterFactoryImpl()));
} catch (UnsupportedOperationException ose) {
throw new CswException(ose.getMessage(), CswConstants.INVALID_PARAMETER_VALUE, null);
}
return visitor;
}
Aggregations