Search in sources :

Example 1 with TitlePost

use of org.folio.holdingsiq.model.TitlePost in project mod-kb-ebsco-java by folio-org.

the class EholdingsTitlesImpl method postEholdingsTitles.

@Override
@HandleValidationErrors
public void postEholdingsTitles(String contentType, TitlePostRequest entity, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
    titlesPostBodyValidator.validate(entity);
    TitlePost titlePost = titlePostRequestConverter.convert(entity);
    PackageId packageId = parsePackageId(entity.getIncluded().get(0).getAttributes().getPackageId());
    templateFactory.createTemplate(okapiHeaders, asyncResultHandler).requestAction(context -> context.getTitlesService().postTitle(titlePost, packageId).thenCompose(title -> completedFuture(toTitleResult(title, false))).thenCompose(titleResult -> updateTags(titleResult, context, entity.getData().getAttributes().getTags()))).executeWithResult(Title.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) PackageId(org.folio.holdingsiq.model.PackageId) IdParser.parsePackageId(org.folio.rest.util.IdParser.parsePackageId) TitlePost(org.folio.holdingsiq.model.TitlePost) HandleValidationErrors(org.folio.rest.aspect.HandleValidationErrors)

Example 2 with TitlePost

use of org.folio.holdingsiq.model.TitlePost in project mod-kb-ebsco-java by folio-org.

the class TitlePostRequestConverter method convert.

@Override
public TitlePost convert(@NonNull TitlePostRequest entity) {
    TitlePostDataAttributes attributes = entity.getData().getAttributes();
    Boolean isPeerReviewed = attributes.getIsPeerReviewed();
    TitlePost.TitlePostBuilder titlePost = TitlePost.builder().titleName(attributes.getName()).description(attributes.getDescription()).edition(attributes.getEdition()).isPeerReviewed(java.util.Objects.isNull(isPeerReviewed) ? Boolean.FALSE : isPeerReviewed).publisherName(attributes.getPublisherName()).pubType(ConverterConsts.publicationTypes.inverseBidiMap().get(attributes.getPublicationType())).userDefinedFields(UserDefinedFields.builder().userDefinedField1(attributes.getUserDefinedField1()).userDefinedField2(attributes.getUserDefinedField2()).userDefinedField3(attributes.getUserDefinedField3()).userDefinedField4(attributes.getUserDefinedField4()).userDefinedField5(attributes.getUserDefinedField5()).build());
    List<org.folio.rest.jaxrs.model.Identifier> identifiersList = attributes.getIdentifiers();
    if (!identifiersList.isEmpty()) {
        titlePost.identifiersList(toIdentifiersConverter.convert(identifiersList));
    }
    List<org.folio.rest.jaxrs.model.Contributors> contributorsList = attributes.getContributors();
    if (!contributorsList.isEmpty()) {
        titlePost.contributorsList(toContributorsConverter.convert(contributorsList));
    }
    return titlePost.build();
}
Also used : Identifier(org.folio.holdingsiq.model.Identifier) Contributors(org.folio.rest.jaxrs.model.Contributors) TitlePost(org.folio.holdingsiq.model.TitlePost) TitlePostDataAttributes(org.folio.rest.jaxrs.model.TitlePostDataAttributes)

Aggregations

TitlePost (org.folio.holdingsiq.model.TitlePost)2 AsyncResult (io.vertx.core.AsyncResult)1 Context (io.vertx.core.Context)1 Handler (io.vertx.core.Handler)1 Vertx (io.vertx.core.Vertx)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 UUID (java.util.UUID)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)1 Collectors (java.util.stream.Collectors)1 Response (javax.ws.rs.core.Response)1 BooleanUtils (org.apache.commons.lang3.BooleanUtils)1 ListUtils (org.folio.common.ListUtils)1 RowSetUtils.toUUID (org.folio.db.RowSetUtils.toUUID)1 CustomerResources (org.folio.holdingsiq.model.CustomerResources)1 Identifier (org.folio.holdingsiq.model.Identifier)1 PackageId (org.folio.holdingsiq.model.PackageId)1 ResourcePut (org.folio.holdingsiq.model.ResourcePut)1