Search in sources :

Example 1 with RecordType

use of org.folio.repository.RecordType 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);
}
Also used : RMAPITemplateFactory(org.folio.rest.util.template.RMAPITemplateFactory) Filter(org.folio.rest.model.filter.Filter) TagRepository(org.folio.repository.tag.TagRepository) PackageParametersValidator(org.folio.holdingsiq.service.validator.PackageParametersValidator) TitleCollectionResult(org.folio.rmapi.result.TitleCollectionResult) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) ExceptionMappers.error400NotFoundMapper(org.folio.rest.util.ExceptionMappers.error400NotFoundMapper) Autowired(org.springframework.beans.factory.annotation.Autowired) PackagePut(org.folio.holdingsiq.model.PackagePut) AccessTypeMappingsService(org.folio.service.accesstypes.AccessTypeMappingsService) Context(io.vertx.core.Context) PackageId(org.folio.holdingsiq.model.PackageId) AccessType(org.folio.rest.jaxrs.model.AccessType) JSONAPI(org.folio.rest.util.RestConstants.JSONAPI) AccessTypesService(org.folio.service.accesstypes.AccessTypesService) Collectors.toMap(java.util.stream.Collectors.toMap) HandleValidationErrors(org.folio.rest.aspect.HandleValidationErrors) EholdingsPackages(org.folio.rest.jaxrs.resource.EholdingsPackages) ListUtils.parseByComma(org.folio.common.ListUtils.parseByComma) PackagePutBodyValidator(org.folio.rest.validator.PackagePutBodyValidator) Map(java.util.Map) Package(org.folio.rest.jaxrs.model.Package) ResourceCollection(org.folio.rest.jaxrs.model.ResourceCollection) IdParser.packageIdToString(org.folio.rest.util.IdParser.packageIdToString) PackageTagsItem(org.folio.rest.jaxrs.model.PackageTagsItem) OkapiData(org.folio.holdingsiq.model.OkapiData) VertxCache(org.folio.cache.VertxCache) PackageBulkFetchCollection(org.folio.rest.jaxrs.model.PackageBulkFetchCollection) RowSetUtils.toUUID(org.folio.db.RowSetUtils.toUUID) UUID(java.util.UUID) Future(io.vertx.core.Future) NotFoundException(javax.ws.rs.NotFoundException) PackageCollection(org.folio.rest.jaxrs.model.PackageCollection) List(java.util.List) CompletionStage(java.util.concurrent.CompletionStage) Response(javax.ws.rs.core.Response) PackageResult(org.folio.rmapi.result.PackageResult) ErrorUtil(org.folio.rest.util.ErrorUtil) PackagePostRequest(org.folio.rest.jaxrs.model.PackagePostRequest) RMAPITemplateContext(org.folio.rest.util.template.RMAPITemplateContext) VendorIdCacheKey(org.folio.config.cache.VendorIdCacheKey) UserKbCredentialsService(org.folio.service.kbcredentials.UserKbCredentialsService) RecordKey(org.folio.repository.RecordKey) FilteredEntitiesLoader(org.folio.service.loader.FilteredEntitiesLoader) PackageTagsDataAttributes(org.folio.rest.jaxrs.model.PackageTagsDataAttributes) RecordType(org.folio.repository.RecordType) IdParser.parsePackageId(org.folio.rest.util.IdParser.parsePackageId) Tags(org.folio.rest.jaxrs.model.Tags) CompletableFuture(java.util.concurrent.CompletableFuture) BooleanUtils(org.apache.commons.lang3.BooleanUtils) CustomPackagePutBodyValidator(org.folio.rest.validator.CustomPackagePutBodyValidator) Function(java.util.function.Function) DbPackage(org.folio.repository.packages.DbPackage) PackageRequestConverter(org.folio.rest.converter.packages.PackageRequestConverter) InputValidationException(org.folio.rest.exception.InputValidationException) SpringContextUtil(org.folio.spring.SpringContextUtil) ArrayList(java.util.ArrayList) PackagePutRequest(org.folio.rest.jaxrs.model.PackagePutRequest) Qualifier(org.springframework.beans.factory.annotation.Qualifier) PackageTagsPutBodyValidator(org.folio.rest.validator.PackageTagsPutBodyValidator) PackagePostBulkFetchRequest(org.folio.rest.jaxrs.model.PackagePostBulkFetchRequest) RelatedEntitiesLoader(org.folio.service.loader.RelatedEntitiesLoader) AsyncResult(io.vertx.core.AsyncResult) SearchProperties(org.folio.properties.common.SearchProperties) RMAPITemplate(org.folio.rest.util.template.RMAPITemplate) Converter(org.springframework.core.convert.converter.Converter) ExceptionMappers.error422InputValidationMapper(org.folio.rest.util.ExceptionMappers.error422InputValidationMapper) Vertx(io.vertx.core.Vertx) ResourceNotFoundException(org.folio.holdingsiq.service.exception.ResourceNotFoundException) ErrorHandler(org.folio.rest.util.ErrorHandler) Titles(org.folio.holdingsiq.model.Titles) PackagesPostBodyValidator(org.folio.rest.validator.PackagesPostBodyValidator) DbTag(org.folio.repository.tag.DbTag) Validate(org.folio.rest.annotations.Validate) PackageTagsPutRequest(org.folio.rest.jaxrs.model.PackageTagsPutRequest) PackageRepository(org.folio.repository.packages.PackageRepository) CustomerResources(org.folio.holdingsiq.model.CustomerResources) ConverterConsts(org.folio.rest.converter.common.ConverterConsts) TAGS_TYPE(org.folio.rest.util.RestConstants.TAGS_TYPE) TitleResult(org.folio.rmapi.result.TitleResult) PackageTags(org.folio.rest.jaxrs.model.PackageTags) Handler(io.vertx.core.Handler) PackageByIdData(org.folio.holdingsiq.model.PackageByIdData) PackagePost(org.folio.holdingsiq.model.PackagePost) Filter(org.folio.rest.model.filter.Filter) PackageId(org.folio.holdingsiq.model.PackageId) IdParser.parsePackageId(org.folio.rest.util.IdParser.parsePackageId) ResourceNotFoundException(org.folio.holdingsiq.service.exception.ResourceNotFoundException) RMAPITemplate(org.folio.rest.util.template.RMAPITemplate) Validate(org.folio.rest.annotations.Validate) HandleValidationErrors(org.folio.rest.aspect.HandleValidationErrors)

Example 2 with RecordType

use of org.folio.repository.RecordType 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);
}
Also used : EholdingsProviders(org.folio.rest.jaxrs.resource.EholdingsProviders) RMAPITemplateFactory(org.folio.rest.util.template.RMAPITemplateFactory) Filter(org.folio.rest.model.filter.Filter) TagRepository(org.folio.repository.tag.TagRepository) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) Autowired(org.springframework.beans.factory.annotation.Autowired) ProviderPutRequest(org.folio.rest.jaxrs.model.ProviderPutRequest) Context(io.vertx.core.Context) JSONAPI(org.folio.rest.util.RestConstants.JSONAPI) IdParser.parseProviderId(org.folio.rest.util.IdParser.parseProviderId) ProviderPutDataAttributes(org.folio.rest.jaxrs.model.ProviderPutDataAttributes) HandleValidationErrors(org.folio.rest.aspect.HandleValidationErrors) Map(java.util.Map) OkapiData(org.folio.holdingsiq.model.OkapiData) DbProvider(org.folio.repository.providers.DbProvider) Collections.emptyList(java.util.Collections.emptyList) RowSetUtils.toUUID(org.folio.db.RowSetUtils.toUUID) UUID(java.util.UUID) Future(io.vertx.core.Future) ProviderCollection(org.folio.rest.jaxrs.model.ProviderCollection) Objects(java.util.Objects) PackageCollection(org.folio.rest.jaxrs.model.PackageCollection) ProviderTagsItem(org.folio.rest.jaxrs.model.ProviderTagsItem) List(java.util.List) Response(javax.ws.rs.core.Response) ErrorUtil(org.folio.rest.util.ErrorUtil) IdParser.getPackageIds(org.folio.rest.util.IdParser.getPackageIds) RMAPITemplateContext(org.folio.rest.util.template.RMAPITemplateContext) UserKbCredentialsService(org.folio.service.kbcredentials.UserKbCredentialsService) RecordKey(org.folio.repository.RecordKey) FilteredEntitiesLoader(org.folio.service.loader.FilteredEntitiesLoader) RecordType(org.folio.repository.RecordType) PackageCollectionResult(org.folio.rmapi.result.PackageCollectionResult) Tags(org.folio.rest.jaxrs.model.Tags) CompletableFuture(java.util.concurrent.CompletableFuture) Provider(org.folio.rest.jaxrs.model.Provider) VendorPut(org.folio.holdingsiq.model.VendorPut) InputValidationException(org.folio.rest.exception.InputValidationException) SpringContextUtil(org.folio.spring.SpringContextUtil) Value(org.springframework.beans.factory.annotation.Value) Qualifier(org.springframework.beans.factory.annotation.Qualifier) ProviderPutBodyValidator(org.folio.rest.validator.ProviderPutBodyValidator) RelatedEntitiesLoader(org.folio.service.loader.RelatedEntitiesLoader) AsyncResult(io.vertx.core.AsyncResult) RMAPITemplate(org.folio.rest.util.template.RMAPITemplate) VendorById(org.folio.holdingsiq.model.VendorById) Converter(org.springframework.core.convert.converter.Converter) ProviderTagsPutRequest(org.folio.rest.jaxrs.model.ProviderTagsPutRequest) ProviderTags(org.folio.rest.jaxrs.model.ProviderTags) ExceptionMappers.error422InputValidationMapper(org.folio.rest.util.ExceptionMappers.error422InputValidationMapper) Vertx(io.vertx.core.Vertx) ResourceNotFoundException(org.folio.holdingsiq.service.exception.ResourceNotFoundException) ErrorHandler(org.folio.rest.util.ErrorHandler) ProviderTagsPutBodyValidator(org.folio.rest.validator.ProviderTagsPutBodyValidator) VendorResult(org.folio.rmapi.result.VendorResult) Validate(org.folio.rest.annotations.Validate) ProviderTagsDataAttributes(org.folio.rest.jaxrs.model.ProviderTagsDataAttributes) PackageRepository(org.folio.repository.packages.PackageRepository) Packages(org.folio.holdingsiq.model.Packages) TAGS_TYPE(org.folio.rest.util.RestConstants.TAGS_TYPE) Handler(io.vertx.core.Handler) ProviderRepository(org.folio.repository.providers.ProviderRepository) Filter(org.folio.rest.model.filter.Filter) PackageCollectionResult(org.folio.rmapi.result.PackageCollectionResult) ResourceNotFoundException(org.folio.holdingsiq.service.exception.ResourceNotFoundException) RMAPITemplate(org.folio.rest.util.template.RMAPITemplate) Validate(org.folio.rest.annotations.Validate) HandleValidationErrors(org.folio.rest.aspect.HandleValidationErrors)

Example 3 with RecordType

use of org.folio.repository.RecordType 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);
}
Also used : RMAPITemplateFactory(org.folio.rest.util.template.RMAPITemplateFactory) Filter(org.folio.rest.model.filter.Filter) TagRepository(org.folio.repository.tag.TagRepository) TitleCollectionResult(org.folio.rmapi.result.TitleCollectionResult) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) Autowired(org.springframework.beans.factory.annotation.Autowired) Context(io.vertx.core.Context) PackageId(org.folio.holdingsiq.model.PackageId) HandleValidationErrors(org.folio.rest.aspect.HandleValidationErrors) Map(java.util.Map) TitlesPostBodyValidator(org.folio.rest.validator.TitlesPostBodyValidator) TitlePutRequest(org.folio.rest.jaxrs.model.TitlePutRequest) EholdingsTitles(org.folio.rest.jaxrs.resource.EholdingsTitles) IdParser.parseTitleId(org.folio.rest.util.IdParser.parseTitleId) RowSetUtils.toUUID(org.folio.db.RowSetUtils.toUUID) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) Response(javax.ws.rs.core.Response) ErrorUtil(org.folio.rest.util.ErrorUtil) TitlePostRequest(org.folio.rest.jaxrs.model.TitlePostRequest) RMAPITemplateContext(org.folio.rest.util.template.RMAPITemplateContext) ListUtils(org.folio.common.ListUtils) RecordKey(org.folio.repository.RecordKey) FilteredEntitiesLoader(org.folio.service.loader.FilteredEntitiesLoader) RecordType(org.folio.repository.RecordType) IdParser.parsePackageId(org.folio.rest.util.IdParser.parsePackageId) IdParser.parseResourceId(org.folio.rest.util.IdParser.parseResourceId) Tags(org.folio.rest.jaxrs.model.Tags) TitlesRepository(org.folio.repository.titles.TitlesRepository) CompletableFuture(java.util.concurrent.CompletableFuture) BooleanUtils(org.apache.commons.lang3.BooleanUtils) DbTitle(org.folio.repository.titles.DbTitle) SpringContextUtil(org.folio.spring.SpringContextUtil) TitlePost(org.folio.holdingsiq.model.TitlePost) Title(org.folio.rest.jaxrs.model.Title) RelatedEntitiesLoader(org.folio.service.loader.RelatedEntitiesLoader) AsyncResult(io.vertx.core.AsyncResult) SearchProperties(org.folio.properties.common.SearchProperties) Converter(org.springframework.core.convert.converter.Converter) TitleCommonRequestAttributesValidator(org.folio.rest.validator.TitleCommonRequestAttributesValidator) IdParser(org.folio.rest.util.IdParser) Vertx(io.vertx.core.Vertx) ResourceNotFoundException(org.folio.holdingsiq.service.exception.ResourceNotFoundException) Titles(org.folio.holdingsiq.model.Titles) Validate(org.folio.rest.annotations.Validate) CustomerResources(org.folio.holdingsiq.model.CustomerResources) TitlePutRequestConverter(org.folio.rest.converter.titles.TitlePutRequestConverter) TitleResult(org.folio.rmapi.result.TitleResult) TitleCollection(org.folio.rest.jaxrs.model.TitleCollection) ResourcePut(org.folio.holdingsiq.model.ResourcePut) Handler(io.vertx.core.Handler) Filter(org.folio.rest.model.filter.Filter) Validate(org.folio.rest.annotations.Validate) HandleValidationErrors(org.folio.rest.aspect.HandleValidationErrors)

Example 4 with RecordType

use of org.folio.repository.RecordType in project mod-kb-ebsco-java by folio-org.

the class FilteredEntitiesLoaderImpl method fetchAccessTypeMappings.

private CompletableFuture<Collection<AccessTypeMapping>> fetchAccessTypeMappings(AccessTypeFilter accessTypeFilter, RMAPITemplateContext context, AtomicInteger totalCount) {
    Map<String, String> okapiHeaders = context.getOkapiData().getHeaders();
    String credentialsId = context.getCredentialsId();
    RecordType recordType = accessTypeFilter.getRecordType();
    String recordIdPrefix = createRecordIdPrefix(accessTypeFilter);
    return accessTypesService.findByNames(accessTypeFilter.getAccessTypeNames(), credentialsId, okapiHeaders).thenApply(this::extractAccessTypeIds).thenCombine(accessTypeMappingsService.countByRecordPrefix(recordIdPrefix, recordType, credentialsId, okapiHeaders), (accessTypeIds, mappingCount) -> {
        accessTypeFilter.setAccessTypeIds(accessTypeIds);
        accessTypeFilter.setRecordIdPrefix(recordIdPrefix);
        accessTypeIds.forEach(id -> totalCount.getAndAdd(mappingCount.getOrDefault(id, 0)));
        return accessTypeFilter;
    }).thenCompose(filter -> accessTypeMappingsService.findByAccessTypeFilter(filter, okapiHeaders));
}
Also used : RecordType(org.folio.repository.RecordType) AccessTypeFilter(org.folio.rest.model.filter.AccessTypeFilter) PackageCollectionResult(org.folio.rmapi.result.PackageCollectionResult) IdParser.resourceIdsToStrings(org.folio.rest.util.IdParser.resourceIdsToStrings) TagRepository(org.folio.repository.tag.TagRepository) ResourceCollectionResult(org.folio.rmapi.result.ResourceCollectionResult) Autowired(org.springframework.beans.factory.annotation.Autowired) TitlesRepository(org.folio.repository.titles.TitlesRepository) CompletableFuture(java.util.concurrent.CompletableFuture) IdParser.dbResourcesToIdStrings(org.folio.rest.util.IdParser.dbResourcesToIdStrings) AccessTypeMappingsService(org.folio.service.accesstypes.AccessTypeMappingsService) StringUtils(org.apache.commons.lang3.StringUtils) PackageServiceImpl(org.folio.rmapi.PackageServiceImpl) PackageId(org.folio.holdingsiq.model.PackageId) DbPackage(org.folio.repository.packages.DbPackage) AccessType(org.folio.rest.jaxrs.model.AccessType) Vendors(org.folio.holdingsiq.model.Vendors) IdParser.getTitleIds(org.folio.rest.util.IdParser.getTitleIds) DbHoldingInfo(org.folio.repository.holdings.DbHoldingInfo) RowSetUtils(org.folio.db.RowSetUtils) AccessTypeCollection(org.folio.rest.jaxrs.model.AccessTypeCollection) AccessTypeMapping(org.folio.repository.accesstypes.AccessTypeMapping) AccessTypesService(org.folio.service.accesstypes.AccessTypesService) IdParser.getResourceIds(org.folio.rest.util.IdParser.getResourceIds) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) ResourceRepository(org.folio.repository.resources.ResourceRepository) ResourceId(org.folio.holdingsiq.model.ResourceId) Title(org.folio.holdingsiq.model.Title) ProvidersServiceImpl(org.folio.rmapi.ProvidersServiceImpl) TitlesServiceImpl(org.folio.rmapi.TitlesServiceImpl) IdParser(org.folio.rest.util.IdParser) Collections.emptyList(java.util.Collections.emptyList) Collection(java.util.Collection) DbResource(org.folio.repository.resources.DbResource) Titles(org.folio.holdingsiq.model.Titles) RowSetUtils.toUUID(org.folio.db.RowSetUtils.toUUID) UUID(java.util.UUID) HoldingsService(org.folio.service.holdings.HoldingsService) TagFilter(org.folio.rest.model.filter.TagFilter) Collectors(java.util.stream.Collectors) PackageRepository(org.folio.repository.packages.PackageRepository) List(java.util.List) Component(org.springframework.stereotype.Component) Packages(org.folio.holdingsiq.model.Packages) IdParser.getPackageIds(org.folio.rest.util.IdParser.getPackageIds) RMAPITemplateContext(org.folio.rest.util.template.RMAPITemplateContext) ProviderRepository(org.folio.repository.providers.ProviderRepository) RecordType(org.folio.repository.RecordType)

Example 5 with RecordType

use of org.folio.repository.RecordType 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);
}
Also used : RMAPITemplateFactory(org.folio.rest.util.template.RMAPITemplateFactory) Filter(org.folio.rest.model.filter.Filter) TagRepository(org.folio.repository.tag.TagRepository) PackageParametersValidator(org.folio.holdingsiq.service.validator.PackageParametersValidator) TitleCollectionResult(org.folio.rmapi.result.TitleCollectionResult) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) ExceptionMappers.error400NotFoundMapper(org.folio.rest.util.ExceptionMappers.error400NotFoundMapper) Autowired(org.springframework.beans.factory.annotation.Autowired) PackagePut(org.folio.holdingsiq.model.PackagePut) AccessTypeMappingsService(org.folio.service.accesstypes.AccessTypeMappingsService) Context(io.vertx.core.Context) PackageId(org.folio.holdingsiq.model.PackageId) AccessType(org.folio.rest.jaxrs.model.AccessType) JSONAPI(org.folio.rest.util.RestConstants.JSONAPI) AccessTypesService(org.folio.service.accesstypes.AccessTypesService) Collectors.toMap(java.util.stream.Collectors.toMap) HandleValidationErrors(org.folio.rest.aspect.HandleValidationErrors) EholdingsPackages(org.folio.rest.jaxrs.resource.EholdingsPackages) ListUtils.parseByComma(org.folio.common.ListUtils.parseByComma) PackagePutBodyValidator(org.folio.rest.validator.PackagePutBodyValidator) Map(java.util.Map) Package(org.folio.rest.jaxrs.model.Package) ResourceCollection(org.folio.rest.jaxrs.model.ResourceCollection) IdParser.packageIdToString(org.folio.rest.util.IdParser.packageIdToString) PackageTagsItem(org.folio.rest.jaxrs.model.PackageTagsItem) OkapiData(org.folio.holdingsiq.model.OkapiData) VertxCache(org.folio.cache.VertxCache) PackageBulkFetchCollection(org.folio.rest.jaxrs.model.PackageBulkFetchCollection) RowSetUtils.toUUID(org.folio.db.RowSetUtils.toUUID) UUID(java.util.UUID) Future(io.vertx.core.Future) NotFoundException(javax.ws.rs.NotFoundException) PackageCollection(org.folio.rest.jaxrs.model.PackageCollection) List(java.util.List) CompletionStage(java.util.concurrent.CompletionStage) Response(javax.ws.rs.core.Response) PackageResult(org.folio.rmapi.result.PackageResult) ErrorUtil(org.folio.rest.util.ErrorUtil) PackagePostRequest(org.folio.rest.jaxrs.model.PackagePostRequest) RMAPITemplateContext(org.folio.rest.util.template.RMAPITemplateContext) VendorIdCacheKey(org.folio.config.cache.VendorIdCacheKey) UserKbCredentialsService(org.folio.service.kbcredentials.UserKbCredentialsService) RecordKey(org.folio.repository.RecordKey) FilteredEntitiesLoader(org.folio.service.loader.FilteredEntitiesLoader) PackageTagsDataAttributes(org.folio.rest.jaxrs.model.PackageTagsDataAttributes) RecordType(org.folio.repository.RecordType) IdParser.parsePackageId(org.folio.rest.util.IdParser.parsePackageId) Tags(org.folio.rest.jaxrs.model.Tags) CompletableFuture(java.util.concurrent.CompletableFuture) BooleanUtils(org.apache.commons.lang3.BooleanUtils) CustomPackagePutBodyValidator(org.folio.rest.validator.CustomPackagePutBodyValidator) Function(java.util.function.Function) DbPackage(org.folio.repository.packages.DbPackage) PackageRequestConverter(org.folio.rest.converter.packages.PackageRequestConverter) InputValidationException(org.folio.rest.exception.InputValidationException) SpringContextUtil(org.folio.spring.SpringContextUtil) ArrayList(java.util.ArrayList) PackagePutRequest(org.folio.rest.jaxrs.model.PackagePutRequest) Qualifier(org.springframework.beans.factory.annotation.Qualifier) PackageTagsPutBodyValidator(org.folio.rest.validator.PackageTagsPutBodyValidator) PackagePostBulkFetchRequest(org.folio.rest.jaxrs.model.PackagePostBulkFetchRequest) RelatedEntitiesLoader(org.folio.service.loader.RelatedEntitiesLoader) AsyncResult(io.vertx.core.AsyncResult) SearchProperties(org.folio.properties.common.SearchProperties) RMAPITemplate(org.folio.rest.util.template.RMAPITemplate) Converter(org.springframework.core.convert.converter.Converter) ExceptionMappers.error422InputValidationMapper(org.folio.rest.util.ExceptionMappers.error422InputValidationMapper) Vertx(io.vertx.core.Vertx) ResourceNotFoundException(org.folio.holdingsiq.service.exception.ResourceNotFoundException) ErrorHandler(org.folio.rest.util.ErrorHandler) Titles(org.folio.holdingsiq.model.Titles) PackagesPostBodyValidator(org.folio.rest.validator.PackagesPostBodyValidator) DbTag(org.folio.repository.tag.DbTag) Validate(org.folio.rest.annotations.Validate) PackageTagsPutRequest(org.folio.rest.jaxrs.model.PackageTagsPutRequest) PackageRepository(org.folio.repository.packages.PackageRepository) CustomerResources(org.folio.holdingsiq.model.CustomerResources) ConverterConsts(org.folio.rest.converter.common.ConverterConsts) TAGS_TYPE(org.folio.rest.util.RestConstants.TAGS_TYPE) TitleResult(org.folio.rmapi.result.TitleResult) PackageTags(org.folio.rest.jaxrs.model.PackageTags) Handler(io.vertx.core.Handler) PackageByIdData(org.folio.holdingsiq.model.PackageByIdData) PackagePost(org.folio.holdingsiq.model.PackagePost) Filter(org.folio.rest.model.filter.Filter) RMAPITemplate(org.folio.rest.util.template.RMAPITemplate) Validate(org.folio.rest.annotations.Validate) HandleValidationErrors(org.folio.rest.aspect.HandleValidationErrors)

Aggregations

RecordType (org.folio.repository.RecordType)8 List (java.util.List)7 Map (java.util.Map)7 UUID (java.util.UUID)7 CompletableFuture (java.util.concurrent.CompletableFuture)7 Autowired (org.springframework.beans.factory.annotation.Autowired)7 AsyncResult (io.vertx.core.AsyncResult)6 Handler (io.vertx.core.Handler)6 Vertx (io.vertx.core.Vertx)6 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)6 RowSetUtils.toUUID (org.folio.db.RowSetUtils.toUUID)6 RecordKey (org.folio.repository.RecordKey)6 TagRepository (org.folio.repository.tag.TagRepository)6 Context (io.vertx.core.Context)5 Future (io.vertx.core.Future)5 Response (javax.ws.rs.core.Response)5 PackageId (org.folio.holdingsiq.model.PackageId)5 Titles (org.folio.holdingsiq.model.Titles)5 ResourceNotFoundException (org.folio.holdingsiq.service.exception.ResourceNotFoundException)5 PackageRepository (org.folio.repository.packages.PackageRepository)5