use of org.folio.rest.model.filter.Filter in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesImpl method getEholdingsPackagesResourcesByPackageId.
@Override
@Validate
@HandleValidationErrors
public void getEholdingsPackagesResourcesByPackageId(String packageId, List<String> filterTags, List<String> filterAccessType, String filterSelected, String filterType, String filterName, String filterIsxn, String filterSubject, String filterPublisher, String sort, int page, int count, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
Filter filter = Filter.builder().recordType(RecordType.RESOURCE).filterTags(filterTags).packageId(packageId).filterAccessType(filterAccessType).filterSelected(filterSelected).filterType(filterType).filterName(filterName).filterIsxn(filterIsxn).filterSubject(filterSubject).filterPublisher(filterPublisher).sort(sort).page(page).count(count).build();
RMAPITemplate template = templateFactory.createTemplate(okapiHeaders, asyncResultHandler);
if (filter.isTagsFilter()) {
template.requestAction(context -> filteredEntitiesLoader.fetchResourcesByTagFilter(filter.createTagFilter(), context));
} else if (filter.isAccessTypeFilter()) {
template.requestAction(context -> filteredEntitiesLoader.fetchResourcesByAccessTypeFilter(filter.createAccessTypeFilter(), context));
} else {
template.requestAction(context -> {
PackageId pkgId = filter.getPackageId();
long providerIdPart = pkgId.getProviderIdPart();
long packageIdPart = pkgId.getPackageIdPart();
return context.getTitlesService().retrieveTitles(providerIdPart, packageIdPart, filter.createFilterQuery(), searchProperties.getTitlesSearchType(), filter.getSort(), page, count).thenApply(titles -> titleCollectionConverter.convert(titles)).thenCompose(loadResourceTags(context));
});
}
template.addErrorMapper(ResourceNotFoundException.class, exception -> GetEholdingsPackagesResourcesByPackageIdResponse.respond404WithApplicationVndApiJson(ErrorUtil.createError(PACKAGE_NOT_FOUND_MESSAGE))).executeWithResult(ResourceCollection.class);
}
use of org.folio.rest.model.filter.Filter in project mod-kb-ebsco-java by folio-org.
the class EholdingsProvidersImpl method getEholdingsProvidersPackagesByProviderId.
@Override
@Validate
@HandleValidationErrors
public void getEholdingsProvidersPackagesByProviderId(String providerId, String q, List<String> filterTags, List<String> filterAccessType, String filterSelected, String filterType, String sort, int page, int count, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
RMAPITemplate template = templateFactory.createTemplate(okapiHeaders, asyncResultHandler);
Filter filter = Filter.builder().recordType(RecordType.PACKAGE).query(q).filterTags(filterTags).providerId(providerId).filterAccessType(filterAccessType).filterSelected(filterSelected).filterType(filterType).sort(sort).page(page).count(count).build();
if (filter.isTagsFilter()) {
template.requestAction(context -> filteredEntitiesLoader.fetchPackagesByTagFilter(filter.createTagFilter(), context));
} else if (filter.isAccessTypeFilter()) {
template.requestAction(context -> filteredEntitiesLoader.fetchPackagesByAccessTypeFilter(filter.createAccessTypeFilter(), context).thenApply(packages -> new PackageCollectionResult(packages, emptyList())));
} else {
template.requestAction(context -> context.getPackagesService().retrievePackages(filter.getFilterSelected(), filterType, packagesSearchType, filter.getProviderId(), q, page, count, filter.getSort()).thenCompose(packages -> loadTags(packages, context)));
}
template.addErrorMapper(ResourceNotFoundException.class, exception -> GetEholdingsProvidersPackagesByProviderIdResponse.respond404WithApplicationVndApiJson(ErrorUtil.createError(GET_PROVIDER_NOT_FOUND_MESSAGE))).executeWithResult(PackageCollection.class);
}
use of org.folio.rest.model.filter.Filter in project mod-kb-ebsco-java by folio-org.
the class EholdingsTitlesImpl method getEholdingsTitles.
@Override
@Validate
@HandleValidationErrors
public void getEholdingsTitles(List<String> filterTags, List<String> filterAccessType, String filterSelected, String filterType, String filterName, String filterIsxn, String filterSubject, String filterPublisher, String include, String sort, int page, int count, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
Filter filter = Filter.builder().recordType(RecordType.TITLE).filterTags(filterTags).filterAccessType(filterAccessType).filterSelected(filterSelected).filterType(filterType).filterName(filterName).filterIsxn(filterIsxn).filterSubject(filterSubject).filterPublisher(filterPublisher).sort(sort).page(page).count(count).build();
templateFactory.createTemplate(okapiHeaders, asyncResultHandler).requestAction(context -> fetchTitlesByFilter(filter, context).thenApply(titles -> toTitleCollectionResult(titles, shouldIncludeResources(include)))).executeWithResult(TitleCollection.class);
}
use of org.folio.rest.model.filter.Filter in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesImpl method getEholdingsPackages.
@Override
@Validate
@HandleValidationErrors
public void getEholdingsPackages(String filterCustom, String q, String filterSelected, String filterType, List<String> filterTags, List<String> filterAccessType, String sort, int page, int count, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
Filter filter = Filter.builder().recordType(RecordType.PACKAGE).query(q).filterTags(filterTags).filterCustom(filterCustom).filterAccessType(filterAccessType).filterSelected(filterSelected).filterType(filterType).sort(sort).page(page).count(count).build();
RMAPITemplate template = templateFactory.createTemplate(okapiHeaders, asyncResultHandler);
if (filter.isTagsFilter()) {
template.requestAction(context -> filteredEntitiesLoader.fetchPackagesByTagFilter(filter.createTagFilter(), context));
} else if (filter.isAccessTypeFilter()) {
template.requestAction(context -> filteredEntitiesLoader.fetchPackagesByAccessTypeFilter(filter.createAccessTypeFilter(), context));
} else {
template.requestAction(context -> {
if (Boolean.TRUE.equals(filter.getFilterCustom())) {
return getCustomProviderId(context).thenCompose(providerId -> context.getPackagesService().retrievePackages(filter.getFilterSelected(), filterType, searchProperties.getPackagesSearchType(), providerId, q, page, count, filter.getSort()));
} else {
return context.getPackagesService().retrievePackages(filter.getFilterSelected(), filterType, searchProperties.getPackagesSearchType(), null, q, page, count, filter.getSort());
}
});
}
template.executeWithResult(PackageCollection.class);
}
use of org.folio.rest.model.filter.Filter in project mod-kb-ebsco-java by folio-org.
the class EholdingsProvidersImpl method getEholdingsProviders.
@Override
@Validate
@HandleValidationErrors
public void getEholdingsProviders(String q, List<String> filterTags, String sort, int page, int count, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
RMAPITemplate template = templateFactory.createTemplate(okapiHeaders, asyncResultHandler);
Filter filter = Filter.builder().recordType(RecordType.PROVIDER).query(q).filterTags(filterTags).sort(sort).page(page).count(count).build();
if (filter.isTagsFilter()) {
template.requestAction(context -> filteredEntitiesLoader.fetchProvidersByTagFilter(filter.createTagFilter(), context));
} else {
template.requestAction(context -> context.getProvidersService().retrieveProviders(q, page, count, filter.getSort()));
}
template.executeWithResult(ProviderCollection.class);
}
Aggregations