use of org.folio.rest.util.template.RMAPITemplateContext in project mod-kb-ebsco-java by folio-org.
the class EholdingsResourcesImpl method deleteTags.
private CompletableFuture<Void> deleteTags(String resourceId, RMAPITemplateContext context) {
String tenant = context.getOkapiData().getTenant();
UUID credentialsId = RowSetUtils.toUUID(context.getCredentialsId());
return resourceRepository.delete(resourceId, credentialsId, tenant).thenCompose(o -> tagRepository.deleteRecordTags(tenant, resourceId, RecordType.RESOURCE)).thenCompose(aBoolean -> CompletableFuture.completedFuture(null));
}
use of org.folio.rest.util.template.RMAPITemplateContext in project mod-kb-ebsco-java by folio-org.
the class HoldingsServiceImpl method loadSingleHoldings.
@Override
public CompletableFuture<Void> loadSingleHoldings(RMAPITemplateContext context) {
final String tenantId = context.getOkapiData().getTenant();
final String credentialsId = context.getCredentialsId();
Future<Void> executeFuture = executeWithLock(START_LOADING_LOCK, () -> tryChangingStatusToInProgress(getStatusPopulatingStagingArea(), toUUID(credentialsId), tenantId).thenCompose(o -> resetRetries(snapshotRetryCount - 1, toUUID(credentialsId), tenantId)).thenAccept(o -> {
ConfigurationMessage configuration = new ConfigurationMessage(context.getConfiguration(), credentialsId, tenantId);
loadServiceFacade.createSnapshot(configuration);
}));
return mapVertxFuture(executeFuture);
}
use of org.folio.rest.util.template.RMAPITemplateContext in project mod-kb-ebsco-java by folio-org.
the class FilteredEntitiesLoaderImpl method fetchResourcesByTagFilter.
@Override
public CompletableFuture<ResourceCollectionResult> fetchResourcesByTagFilter(TagFilter tagFilter, RMAPITemplateContext context) {
String tenant = context.getOkapiData().getTenant();
UUID credentialsId = toUUID(context.getCredentialsId());
return tagRepository.countRecordsByTagFilter(tagFilter, tenant).thenCompose(resourcesCount -> resourceRepository.findByTagFilter(tagFilter, credentialsId, tenant).thenCompose(dbResources -> {
List<String> ids = dbResourcesToIdStrings(dbResources);
return holdingsService.getHoldingsByIds(ids, context.getCredentialsId(), tenant).thenCompose(dbHoldings -> context.getResourcesService().retrieveResources(getMissingResourceIds(dbHoldings, getTitleIds(dbResources))).thenApply(resources -> toResourceCollectionResult(resources, dbResources, dbHoldings, resourcesCount)));
}));
}
use of org.folio.rest.util.template.RMAPITemplateContext in project mod-kb-ebsco-java by folio-org.
the class FilteredEntitiesLoaderImpl method fetchProvidersByTagFilter.
@Override
public CompletableFuture<Vendors> fetchProvidersByTagFilter(TagFilter tagFilter, RMAPITemplateContext context) {
String tenant = context.getOkapiData().getTenant();
UUID credentialsId = toUUID(context.getCredentialsId());
ProvidersServiceImpl providersService = context.getProvidersService();
return tagRepository.countRecordsByTagFilter(tagFilter, tenant).thenCompose(providerCount -> providerRepository.findIdsByTagFilter(tagFilter, credentialsId, tenant).thenCompose(providersService::retrieveProviders).thenApply(providers -> providers.toBuilder().totalResults(providerCount).build()));
}
use of org.folio.rest.util.template.RMAPITemplateContext in project mod-kb-ebsco-java by folio-org.
the class FilteredEntitiesLoaderImpl method fetchAccessTypeMappings.
private CompletableFuture<Collection<AccessTypeMapping>> fetchAccessTypeMappings(AccessTypeFilter accessTypeFilter, RMAPITemplateContext context, AtomicInteger totalCount) {
Map<String, String> okapiHeaders = context.getOkapiData().getHeaders();
String credentialsId = context.getCredentialsId();
RecordType recordType = accessTypeFilter.getRecordType();
String recordIdPrefix = createRecordIdPrefix(accessTypeFilter);
return accessTypesService.findByNames(accessTypeFilter.getAccessTypeNames(), credentialsId, okapiHeaders).thenApply(this::extractAccessTypeIds).thenCombine(accessTypeMappingsService.countByRecordPrefix(recordIdPrefix, recordType, credentialsId, okapiHeaders), (accessTypeIds, mappingCount) -> {
accessTypeFilter.setAccessTypeIds(accessTypeIds);
accessTypeFilter.setRecordIdPrefix(recordIdPrefix);
accessTypeIds.forEach(id -> totalCount.getAndAdd(mappingCount.getOrDefault(id, 0)));
return accessTypeFilter;
}).thenCompose(filter -> accessTypeMappingsService.findByAccessTypeFilter(filter, okapiHeaders));
}
Aggregations