Skip to content

Commit

Permalink
Adapt feature versioning to GetFeatureCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
aaime committed Nov 2, 2017
1 parent c8f35fa commit 4734dbe
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -45,28 +45,29 @@ final class TimeVersioningCallback implements GetFeatureCallback, TransactionCal
} }


@Override @Override
public GetFeatureContext beforeQuerying(GetFeatureContext context) { public void beforeQuerying(GetFeatureContext context) {
String version = context.getRequest().getVersion(); String version = context.getRequest().getVersion();
if (version == null || !version.startsWith("2.0")) { if (version == null || !version.startsWith("2.0")) {
return context; return;
} }
FeatureTypeInfo featureTypeInfo = context.getFeatureTypeInfo(); FeatureTypeInfo featureTypeInfo = context.getFeatureTypeInfo();
if (!TimeVersioning.isEnabled(featureTypeInfo)) { if (!TimeVersioning.isEnabled(featureTypeInfo)) {
// time versioning is not enabled for this feature type or is not a WFS 2.0 request // time versioning is not enabled for this feature type or is not a WFS 2.0 request
return context; return;
} }
Filter adapted = VersioningFilterAdapter.adapt(featureTypeInfo, context.getQuery().getFilter()); Query query = new Query(context.getQuery());
context.getQuery().setFilter(adapted); Filter adapted = VersioningFilterAdapter.adapt(featureTypeInfo, query.getFilter());
query.setFilter(adapted);
SortBy sort = FILTER_FACTORY.sort(TimeVersioning.getTimePropertyName(featureTypeInfo), SortOrder.DESCENDING); SortBy sort = FILTER_FACTORY.sort(TimeVersioning.getTimePropertyName(featureTypeInfo), SortOrder.DESCENDING);
SortBy[] sorts = context.getQuery().getSortBy(); SortBy[] sorts = query.getSortBy();
if (sorts == null) { if (sorts == null) {
sorts = new SortBy[]{sort}; sorts = new SortBy[]{sort};
} else { } else {
sorts = Arrays.copyOf(sorts, sorts.length + 1); sorts = Arrays.copyOf(sorts, sorts.length + 1);
sorts[sorts.length - 1] = sort; sorts[sorts.length - 1] = sort;
} }
context.getQuery().setSortBy(sorts); query.setSortBy(sorts);
return context; context.setQuery(query);
} }


@Override @Override
Expand Down

0 comments on commit 4734dbe

Please sign in to comment.