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;
}
Aggregations