use of org.folio.dao.util.SortField in project mod-source-record-manager by folio-org.
the class MetadataProviderImpl method mapSortQueryToSortFields.
private List<SortField> mapSortQueryToSortFields(List<String> sortQuery) {
ArrayList<SortField> fields = new ArrayList<>();
for (String sortFieldQuery : sortQuery) {
String sortField = StringUtils.substringBefore(sortFieldQuery, ",");
String sortOrder = StringUtils.substringAfter(sortFieldQuery, ",");
if (!JOB_EXECUTION_SORTABLE_FIELDS.contains(sortField) || !SORT_ORDER_VALUES.contains(sortOrder)) {
throw new BadRequestException(format(INVALID_SORT_PARAMS_MSG, sortFieldQuery, JOB_EXECUTION_SORTABLE_FIELDS));
}
fields.add(new SortField(sortField, sortOrder));
}
return fields;
}
use of org.folio.dao.util.SortField in project mod-source-record-manager by folio-org.
the class MetadataProviderImpl method getMetadataProviderJobExecutions.
@Override
public void getMetadataProviderJobExecutions(List<String> statusAny, List<String> profileIdNotAny, String statusNot, List<String> uiStatusAny, String hrId, String fileName, List<String> profileIdAny, String userId, Date completedAfter, Date completedBefore, List<String> sortBy, int offset, int limit, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
vertxContext.runOnContext(v -> {
try {
List<SortField> sortFields = mapSortQueryToSortFields(sortBy);
JobExecutionFilter filter = buildJobExecutionFilter(statusAny, profileIdNotAny, statusNot, uiStatusAny, hrId, fileName, profileIdAny, userId, completedAfter, completedBefore);
jobExecutionsCache.get(tenantId, filter, sortFields, offset, limit).map(GetMetadataProviderJobExecutionsResponse::respond200WithApplicationJson).map(Response.class::cast).otherwise(ExceptionHelper::mapExceptionToResponse).onComplete(asyncResultHandler);
} catch (Exception e) {
asyncResultHandler.handle(Future.succeededFuture(ExceptionHelper.mapExceptionToResponse(e)));
}
});
}
Aggregations