Commit 367967e9 authored by Niels Erik G. Nielsen's avatar Niels Erik G. Nielsen
Browse files

Add `instanceRelations`, if any, to `inventoryRecordSet`

parent e2875ae0
......@@ -91,6 +91,9 @@ import com.indexdata.masterkey.localindices.util.MarcXMLToJson;
}
inventoryRecordSet.put("instance", transformedRecord.getInstance());
inventoryRecordSet.put("holdingsRecords", transformedRecord.getHoldings());
if (transformedRecord.hasInstanceRelations()) {
inventoryRecordSet.put("instanceRelations", transformedRecord.getInstanceRelations());
}
JSONObject responseJson = upsertInventoryRecordSet(inventoryRecordSet);
logger.log(Level.TRACE, "Response was: " + responseJson.toJSONString());
UpsertMetrics metrics = new UpsertMetrics((JSONObject)responseJson.get("metrics"));
......
......@@ -192,7 +192,7 @@ import com.indexdata.masterkey.localindices.harvest.storage.RecordJSON;
}
instance.remove("holdingsRecords");
instance.remove("matchKey");
} catch (ParseException pe) {
} catch (ParseException pe) {
logger.error("InventoryRecordStorage could not parse transformed record to get Instance: " + pe.getMessage());
}
return instance;
......@@ -223,6 +223,25 @@ import com.indexdata.masterkey.localindices.harvest.storage.RecordJSON;
return holdings;
}
public boolean hasInstanceRelations() {
return transformed.containsKey("instanceRelations");
}
public JSONObject getInstanceRelations() {
logger.log(Level.TRACE, "Looking for instance relations in root of " + transformed.toJSONString());
JSONObject instanceRelations = new JSONObject();
try {
if (transformed.containsKey("instanceRelations")) {
JSONObject instanceRelationsFromRecord = (JSONObject) (transformed.get("instanceRelations"));
instanceRelations = (JSONObject) parser.parse(instanceRelationsFromRecord.toJSONString());
}
} catch (ParseException pe) {
logger.error("InventoryRecordStorage could not parse transformed record to get Instance relations: " + pe.getMessage());
}
return instanceRelations;
}
public boolean hasMatchKey () {
return !(getMatchKey().isEmpty());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment