use of org.folio.rmapi.result.TitleResult 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.rmapi.result.TitleResult in project mod-kb-ebsco-java by folio-org.
the class EholdingsTitlesImpl method updateTags.
private CompletableFuture<TitleResult> updateTags(TitleResult result, RMAPITemplateContext context, Tags tags) {
if (Objects.isNull(tags)) {
return completedFuture(result);
} else {
String tenant = context.getOkapiData().getTenant();
UUID credentialsId = toUUID(context.getCredentialsId());
return updateStoredTitles(createDbTitle(result, credentialsId), tags, tenant).thenCompose(o -> tagRepository.updateRecordTags(tenant, String.valueOf(result.getTitle().getTitleId()), RecordType.TITLE, tags.getTagList())).thenApply(updated -> {
result.setTags(new Tags().withTagList(tags.getTagList()));
return result;
});
}
}
use of org.folio.rmapi.result.TitleResult 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.rmapi.result.TitleResult in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesImpl method populateResourceTags.
private void populateResourceTags(Map<String, TitleResult> resourceIdToTitle, Map<String, List<DbTag>> tagMap) {
tagMap.forEach((id, tags) -> {
TitleResult titleResult = resourceIdToTitle.get(id);
titleResult.setResourceTagList(tags);
});
}
use of org.folio.rmapi.result.TitleResult in project mod-kb-ebsco-java by folio-org.
the class TitleConverter method includeTagsIfNeeded.
private void includeTagsIfNeeded(Title title, TitleResult titleResult) {
if (nonNull(titleResult.getResourceTagList())) {
for (ResourceCollectionItem resourceCollectionItem : title.getIncluded()) {
List<DbTag> tags = titleResult.getResourceTagList().stream().filter(tag -> resourceCollectionItem.getId().equals(tag.getRecordId())).collect(Collectors.toList());
resourceCollectionItem.getAttributes().withTags(tagsConverter.convert(tags));
}
}
}
Aggregations