Search in sources :

Example 1 with METADATA_KEY

use of org.folio.inventory.domain.instances.Instance.METADATA_KEY in project mod-inventory by folio-org.

the class ReplaceInstanceEventHandler method prepareTargetInstance.

private JsonObject prepareTargetInstance(DataImportEventPayload dataImportEventPayload, Instance instanceToUpdate) {
    JsonObject instanceAsJson = new JsonObject(dataImportEventPayload.getContext().get(INSTANCE.value()));
    if (instanceAsJson.getJsonObject(INSTANCE_PATH) != null) {
        instanceAsJson = instanceAsJson.getJsonObject(INSTANCE_PATH);
    }
    Set<String> precedingSucceedingIds = new HashSet<>();
    precedingSucceedingIds.addAll(instanceToUpdate.getPrecedingTitles().stream().filter(pr -> isNotEmpty(pr.id)).map(pr -> pr.id).collect(Collectors.toList()));
    precedingSucceedingIds.addAll(instanceToUpdate.getSucceedingTitles().stream().filter(pr -> isNotEmpty(pr.id)).map(pr -> pr.id).collect(Collectors.toList()));
    instanceAsJson.put("id", instanceToUpdate.getId());
    instanceAsJson.put(HRID_KEY, instanceToUpdate.getHrid());
    instanceAsJson.put(SOURCE_KEY, MARC_FORMAT);
    instanceAsJson.put(METADATA_KEY, instanceToUpdate.getMetadata());
    return instanceAsJson;
}
Also used : Json(io.vertx.core.json.Json) Context(org.folio.inventory.common.Context) MappingManager(org.folio.processing.mapping.MappingManager) HttpStatus(org.apache.http.HttpStatus) Failure(org.folio.inventory.common.domain.Failure) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) InstanceCollection(org.folio.inventory.domain.instances.InstanceCollection) ACTION_PROFILE(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper.ContentType.ACTION_PROFILE) InstanceUtil(org.folio.inventory.support.InstanceUtil) StringUtils.isNotEmpty(org.apache.commons.lang3.StringUtils.isNotEmpty) HashSet(java.util.HashSet) ProfileSnapshotWrapper(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper) ObjectMapperTool(org.folio.dbschema.ObjectMapperTool) JsonObject(io.vertx.core.json.JsonObject) ActionProfile(org.folio.ActionProfile) StringUtils.isEmpty(org.apache.commons.lang3.StringUtils.isEmpty) MappingParameters(org.folio.processing.mapping.defaultmapper.processor.parameters.MappingParameters) MARC_BIBLIOGRAPHIC(org.folio.ActionProfile.FolioRecord.MARC_BIBLIOGRAPHIC) MappingContext(org.folio.processing.mapping.mapper.MappingContext) HRID_KEY(org.folio.inventory.domain.instances.Instance.HRID_KEY) Promise(io.vertx.core.Promise) DataImportEventPayload(org.folio.DataImportEventPayload) DI_INVENTORY_INSTANCE_UPDATED(org.folio.DataImportEventTypes.DI_INVENTORY_INSTANCE_UPDATED) Set(java.util.Set) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Future(io.vertx.core.Future) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Storage(org.folio.inventory.storage.Storage) DI_INVENTORY_INSTANCE_UPDATED_READY_FOR_POST_PROCESSING(org.folio.DataImportEventTypes.DI_INVENTORY_INSTANCE_UPDATED_READY_FOR_POST_PROCESSING) UPDATE(org.folio.ActionProfile.Action.UPDATE) List(java.util.List) EventProcessingException(org.folio.processing.exceptions.EventProcessingException) METADATA_KEY(org.folio.inventory.domain.instances.Instance.METADATA_KEY) EventHandlingUtil(org.folio.inventory.dataimport.handlers.matching.util.EventHandlingUtil) INSTANCE(org.folio.ActionProfile.FolioRecord.INSTANCE) Instance(org.folio.inventory.domain.instances.Instance) SOURCE_KEY(org.folio.inventory.domain.instances.Instance.SOURCE_KEY) MappingMetadataCache(org.folio.inventory.dataimport.cache.MappingMetadataCache) JsonObject(io.vertx.core.json.JsonObject) HashSet(java.util.HashSet)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 Future (io.vertx.core.Future)1 Promise (io.vertx.core.Promise)1 Json (io.vertx.core.json.Json)1 JsonObject (io.vertx.core.json.JsonObject)1 String.format (java.lang.String.format)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Collectors (java.util.stream.Collectors)1 StringUtils.isEmpty (org.apache.commons.lang3.StringUtils.isEmpty)1 StringUtils.isNotEmpty (org.apache.commons.lang3.StringUtils.isNotEmpty)1 HttpStatus (org.apache.http.HttpStatus)1 ActionProfile (org.folio.ActionProfile)1 UPDATE (org.folio.ActionProfile.Action.UPDATE)1 INSTANCE (org.folio.ActionProfile.FolioRecord.INSTANCE)1 MARC_BIBLIOGRAPHIC (org.folio.ActionProfile.FolioRecord.MARC_BIBLIOGRAPHIC)1 DataImportEventPayload (org.folio.DataImportEventPayload)1