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);
}
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();
}
Aggregations