use of org.folio.holdingsiq.model.ResourcePut in project mod-kb-ebsco-java by folio-org.
the class EholdingsTitlesImpl method putEholdingsTitlesByTitleId.
@Override
@HandleValidationErrors
public void putEholdingsTitlesByTitleId(String titleId, String contentType, TitlePutRequest entity, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
titleCommonRequestAttributesValidator.validate(entity.getData().getAttributes());
Long parsedTitleId = parseTitleId(titleId);
templateFactory.createTemplate(okapiHeaders, asyncResultHandler).requestAction(context -> context.getTitlesService().retrieveTitle(parsedTitleId).thenCompose(title -> {
if (BooleanUtils.isNotTrue(title.getIsTitleCustom())) {
return completedFuture(null);
}
CustomerResources resource = title.getCustomerResourcesList().get(0);
ResourcePut resourcePutRequest = titlePutRequestConverter.convertToRMAPICustomResourcePutRequest(entity, resource);
String resourceId = resource.getVendorId() + "-" + resource.getPackageId() + "-" + resource.getTitleId();
return context.getResourcesService().updateResource(parseResourceId(resourceId), resourcePutRequest);
}).thenCompose(o -> context.getTitlesService().retrieveTitle(parsedTitleId)).thenCompose(title -> updateTags(toTitleResult(title, false), context, entity.getData().getAttributes().getTags()))).executeWithResult(Title.class);
}
use of org.folio.holdingsiq.model.ResourcePut in project mod-kb-ebsco-java by folio-org.
the class ResourceRequestConverter method convertToRMAPICustomResourcePutRequest.
public ResourcePut convertToRMAPICustomResourcePutRequest(ResourcePutRequest entity, Title oldTitle) {
ResourcePutDataAttributes attributes = entity.getData().getAttributes();
// Map common attributes for custom/managed resources to RM API fields
ResourcePut.ResourcePutBuilder builder = convertCommonAttributesToResourcePutRequest(attributes, oldTitle);
// Map attributes specific to custom resources to RM API fields
builder.titleName(oldTitle.getTitleName());
builder.publisherName(oldTitle.getPublisherName());
builder.edition(oldTitle.getEdition());
builder.description(oldTitle.getDescription());
builder.identifiersList(oldTitle.getIdentifiersList());
builder.contributorsList(oldTitle.getContributorsList());
return builder.build();
}
use of org.folio.holdingsiq.model.ResourcePut in project mod-kb-ebsco-java by folio-org.
the class TitlePutRequestConverter method convertToRMAPICustomResourcePutRequest.
public ResourcePut convertToRMAPICustomResourcePutRequest(TitlePutRequest entity, CustomerResources oldResource) {
TitleCommonRequestAttributes attributes = entity.getData().getAttributes();
ResourcePut.ResourcePutBuilder builder = ResourcePut.builder();
Proxy proxy = null;
if (oldResource.getProxy() != null && oldResource.getProxy().getId() != null) {
proxy = Proxy.builder().inherited(false).id(oldResource.getProxy().getId()).build();
}
builder.proxy(proxy);
builder.isHidden(oldResource.getVisibilityData().getIsHidden());
builder.coverageStatement(oldResource.getCoverageStatement());
builder.customEmbargoPeriod(oldResource.getCustomEmbargoPeriod());
builder.customCoverageList(oldResource.getCustomCoverageList());
builder.url(oldResource.getUrl());
builder.isSelected(true);
if (attributes.getPublicationType() != null) {
builder.pubType(ConverterConsts.publicationTypes.inverseBidiMap().get(attributes.getPublicationType()));
}
builder.isPeerReviewed(attributes.getIsPeerReviewed());
builder.titleName(attributes.getName());
builder.publisherName(attributes.getPublisherName());
builder.edition(attributes.getEdition());
builder.description(attributes.getDescription());
builder.identifiersList(toIdentifiersConverter.convert(attributes.getIdentifiers()));
builder.contributorsList(toContributorsConverter.convert(attributes.getContributors()));
builder.userDefinedFields(UserDefinedFields.builder().userDefinedField1(oldResource.getUserDefinedFields().getUserDefinedField1()).userDefinedField2(oldResource.getUserDefinedFields().getUserDefinedField2()).userDefinedField3(oldResource.getUserDefinedFields().getUserDefinedField3()).userDefinedField4(oldResource.getUserDefinedFields().getUserDefinedField4()).userDefinedField5(oldResource.getUserDefinedFields().getUserDefinedField5()).build());
return builder.build();
}
use of org.folio.holdingsiq.model.ResourcePut in project mod-kb-ebsco-java by folio-org.
the class TitlePutRequestConverterTest method shouldCreateRequestToUpdatePublisherNameForCustomResource.
@Test
public void shouldCreateRequestToUpdatePublisherNameForCustomResource() {
TitlePutRequest request = createEmptyTitlePutRequest();
request.getData().getAttributes().setPublisherName("test pub name");
ResourcePut resourcePut = converter.convertToRMAPICustomResourcePutRequest(request, ResourcesTestData.createResourceData().getTitle().getCustomerResourcesList().get(0));
assertEquals("test pub name", resourcePut.getPublisherName());
}
use of org.folio.holdingsiq.model.ResourcePut in project mod-kb-ebsco-java by folio-org.
the class TitlePutRequestConverterTest method shouldCreateRequestToUpdateResourceNameForCustomResource.
@Test
public void shouldCreateRequestToUpdateResourceNameForCustomResource() {
TitlePutRequest request = createEmptyTitlePutRequest();
request.getData().getAttributes().setName("test name");
ResourcePut resourcePut = converter.convertToRMAPICustomResourcePutRequest(request, ResourcesTestData.createResourceData().getTitle().getCustomerResourcesList().get(0));
assertEquals("test name", resourcePut.getTitleName());
}
Aggregations