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 Diff line number Diff line change
Expand Up @@ -45,28 +45,29 @@ final class TimeVersioningCallback implements GetFeatureCallback, TransactionCal
}

@Override
public GetFeatureContext beforeQuerying(GetFeatureContext context) {
public void beforeQuerying(GetFeatureContext context) {
String version = context.getRequest().getVersion();
if (version == null || !version.startsWith("2.0")) {
return context;
return;
}
FeatureTypeInfo featureTypeInfo = context.getFeatureTypeInfo();
if (!TimeVersioning.isEnabled(featureTypeInfo)) {
// 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());
context.getQuery().setFilter(adapted);
Query query = new Query(context.getQuery());
Filter adapted = VersioningFilterAdapter.adapt(featureTypeInfo, query.getFilter());
query.setFilter(adapted);
SortBy sort = FILTER_FACTORY.sort(TimeVersioning.getTimePropertyName(featureTypeInfo), SortOrder.DESCENDING);
SortBy[] sorts = context.getQuery().getSortBy();
SortBy[] sorts = query.getSortBy();
if (sorts == null) {
sorts = new SortBy[]{sort};
} else {
sorts = Arrays.copyOf(sorts, sorts.length + 1);
sorts[sorts.length - 1] = sort;
}
context.getQuery().setSortBy(sorts);
return context;
query.setSortBy(sorts);
context.setQuery(query);
}

@Override
Expand Down

0 comments on commit 4734dbe

Please sign in to comment.