txQuery.setPropertyNames(getRequiredAttributes(query));
txQuery.setSortBy(getTransformedSortBy(query));
txQuery.setFilter(txFilter);
// can we support the required sorting?
QueryCapabilities caps = source.getQueryCapabilities();
if (query.getStartIndex() != null && !caps.isJoiningSupported()) {
txQuery.setStartIndex(null);
}
if (query.getSortBy() != null && !caps.supportsSorting(query.getSortBy())) {
txQuery.setSortBy(null);
}
// if the original query had sorting but we cannot pass it down we
// have to remove offset and limit too
if (query.getSortBy() != null && txQuery.getSortBy() == null) {
txQuery.setStartIndex(null);
txQuery.setMaxFeatures(Query.DEFAULT_MAX);
}
// if the wrapped store cannot apply offsets we have to remove them too
if (!caps.isOffsetSupported()) {
txQuery.setStartIndex(null);
}
return txQuery;
}