use of org.folio.rest.jaxrs.model.Title in project mod-kb-ebsco-java by folio-org.
the class EholdingsTitlesTest method shouldUpdateTagsWhenValidPostRequest.
@Test
public void shouldUpdateTagsWhenValidPostRequest() throws IOException, URISyntaxException {
List<String> tagList = Arrays.asList(STUB_TAG_VALUE, STUB_TAG_VALUE_2);
Title actual = postTitle(tagList).as(Title.class);
List<String> tagsFromDB = TagsTestUtil.getTags(vertx);
assertThat(actual.getData().getAttributes().getTags().getTagList(), containsInAnyOrder(tagList.toArray()));
assertThat(tagsFromDB, containsInAnyOrder(tagList.toArray()));
}
use of org.folio.rest.jaxrs.model.Title 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.rest.jaxrs.model.Title in project mod-kb-ebsco-java by folio-org.
the class ResourceResultConverter method includeTitle.
private void includeTitle(org.folio.holdingsiq.model.Title rmapiTitle, Resource resultResource) {
Title title = requireNonNull(titlesConverter.convert(new TitleResult(rmapiTitle, false)));
resultResource.getIncluded().add(title.getData());
resultResource.getData().getRelationships().withTitle(new HasOneRelationship().withData(new RelationshipData().withId(title.getData().getId()).withType(TITLES_TYPE)));
}
use of org.folio.rest.jaxrs.model.Title in project mod-kb-ebsco-java by folio-org.
the class TitleConverter method convert.
@Override
public Title convert(@NonNull TitleResult titleResult) {
org.folio.holdingsiq.model.Title rmapiTitle = titleResult.getTitle();
Title title = new Title().withData(new Data().withId(String.valueOf(rmapiTitle.getTitleId())).withType(TITLES_TYPE).withAttributes(new TitleAttributes().withName(rmapiTitle.getTitleName()).withPublisherName(rmapiTitle.getPublisherName()).withIsTitleCustom(rmapiTitle.getIsTitleCustom()).withPublicationType(ConverterConsts.publicationTypes.get(rmapiTitle.getPubType().toLowerCase())).withSubjects(subjectsConverter.convert(rmapiTitle.getSubjectsList())).withIdentifiers(identifiersConverter.convert(rmapiTitle.getIdentifiersList())).withContributors(contributorsConverter.convert(rmapiTitle.getContributorsList())).withAlternateTitles(alternateTitleConverter.convert(rmapiTitle.getAlternateTitleList())).withEdition(rmapiTitle.getEdition()).withDescription(rmapiTitle.getDescription()).withIsPeerReviewed(rmapiTitle.getIsPeerReviewed()).withTags(titleResult.getTags())).withRelationships(createEmptyResourcesRelationships())).withIncluded(null).withJsonapi(RestConstants.JSONAPI);
title.getData().getAttributes().setHasSelectedResources(matchesAny(rmapiTitle.getCustomerResourcesList(), CustomerResources::getIsSelected));
includeResourcesIfNeeded(title, titleResult);
return title;
}
use of org.folio.rest.jaxrs.model.Title in project mod-orders by folio-org.
the class OpenCompositeOrderPieceServiceTest method testShouldUpdateInventoryPositiveCaseIfLineIsPackageAndPieceContainsHoldingId.
@Test
void testShouldUpdateInventoryPositiveCaseIfLineIsPackageAndPieceContainsHoldingId() throws ExecutionException, InterruptedException {
// given
CompositePoLine line = getMockAsJson(COMPOSITE_LINES_PATH, LINE_ID).mapTo(CompositePoLine.class);
String holdingId = UUID.randomUUID().toString();
String itemId = UUID.randomUUID().toString();
line.getLocations().get(0).withLocationId(null).withHoldingId(holdingId);
line.setIsPackage(true);
Title title = getMockAsJson(TILES_PATH, "title").mapTo(Title.class);
Piece piece = createPieceWithHoldingId(line, title);
doReturn(completedFuture(title)).when(titlesService).getTitleById(piece.getTitleId(), requestContext);
doReturn(completedFuture(null)).when(titlesService).saveTitle(title, requestContext);
doReturn(completedFuture(title)).when(inventoryManager).openOrderHandlePackageLineInstance(title, false, requestContext);
doReturn(completedFuture(itemId)).when(inventoryManager).openOrderCreateItemRecord(line, holdingId, requestContext);
// When
openCompositeOrderPieceService.openOrderUpdateInventory(line, piece, false, requestContext).get();
// Then
assertEquals(holdingId, piece.getHoldingId());
assertEquals(title.getId(), piece.getTitleId());
}
Aggregations