Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"provides": [
{
"id": "inventory",
"version": "14.2",
"version": "14.3",
"handlers": [
{
"methods": ["GET"],
Expand Down
4 changes: 4 additions & 0 deletions ramls/instance.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"type": "string",
"description" : "An unique instance identifier matching a client-side bibliographic record identification. Could be an actual local identifier or a key generated from metadata in the local bibliographic record. Enables the client to determine if a client side bibliographic record already exists as an Instance in Inventory"
},
"sourceUri": {
"type": "string",
"description": "A remote URI uniquely identifying the source of the instance"
},
"source": {
"type": "string",
"description": "The metadata source and its format of the underlying record to the instance record. (e.g. FOLIO if it's a record created in Inventory; MARC if it's a MARC record created in MARCcat or EPKB if it's a record coming from eHoldings)"
Expand Down
22 changes: 18 additions & 4 deletions src/main/java/org/folio/inventory/domain/instances/Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class Instance {
public static final String VERSION_KEY = "_version";
public static final String HRID_KEY = "hrid";
public static final String MATCH_KEY_KEY = "matchKey";
public static final String SOURCE_URI_KEY = "sourceUri";
public static final String SOURCE_KEY = "source";
public static final String PARENT_INSTANCES_KEY = "parentInstances";
public static final String CHILD_INSTANCES_KEY = "childInstances";
Expand Down Expand Up @@ -83,6 +84,7 @@ public class Instance {
private String version;
private final String hrid;
private String matchKey;
private String sourceUri;
private final String source;
private List<InstanceRelationshipToParent> parentInstances = new ArrayList<>();
private List<InstanceRelationshipToChild> childInstances = new ArrayList<>();
Expand Down Expand Up @@ -123,8 +125,6 @@ public class Instance {
private List<String> natureOfContentTermIds = new ArrayList<>();
private Dates dates;

protected static final String INVENTORY_PATH = "/inventory";
protected static final String INSTANCES_PATH = INVENTORY_PATH + "/instances";
protected static final Logger log = LogManager.getLogger(MethodHandles.lookup().lookupClass());

public Instance(
Expand Down Expand Up @@ -155,12 +155,13 @@ public static Instance fromJson(JsonObject instanceJson) {
return new Instance(
instanceJson.getString(ID),
instanceJson.getString(VERSION_KEY),
instanceJson.getString("hrid"),
instanceJson.getString(HRID_KEY),
instanceJson.getString(SOURCE_KEY),
instanceJson.getString(TITLE_KEY),
instanceJson.getString(INSTANCE_TYPE_ID_KEY))
.setIndexTitle(instanceJson.getString(INDEX_TITLE_KEY))
.setMatchKey(instanceJson.getString(MATCH_KEY_KEY))
.setSourceUri(instanceJson.getString(SOURCE_URI_KEY))
.setParentInstances(instanceJson.getJsonArray(PARENT_INSTANCES_KEY))
.setChildInstances(instanceJson.getJsonArray(CHILD_INSTANCES_KEY))
.setPrecedingTitles(instanceJson.getJsonArray(PRECEDING_TITLES_KEY))
Expand Down Expand Up @@ -212,6 +213,7 @@ public JsonObject getJsonForStorage() {
json.put(HRID_KEY, hrid);
if (source != null) json.put(SOURCE_KEY, source);
json.put(MATCH_KEY_KEY, matchKey);
json.put(SOURCE_URI_KEY, sourceUri);
json.put(TITLE_KEY, title);
json.put(INDEX_TITLE_KEY, indexTitle);
json.put(ALTERNATIVE_TITLES_KEY, alternativeTitles);
Expand Down Expand Up @@ -259,11 +261,12 @@ public JsonObject getJsonForResponse(WebContext context) {

json.put(ID, getId());
putIfNotNull(json, VERSION_KEY, version);
json.put("hrid", getHrid());
json.put(HRID_KEY, getHrid());
json.put(SOURCE_KEY, getSource());
json.put(TITLE_KEY, getTitle());
json.put(ADMININSTRATIVE_NOTES_KEY, getAdministrativeNotes());
putIfNotNull(json, MATCH_KEY_KEY, getMatchKey());
putIfNotNull(json, SOURCE_URI_KEY, getSourceUri());
putIfNotNull(json, INDEX_TITLE_KEY, getIndexTitle());
putIfNotNull(json, PARENT_INSTANCES_KEY, parentInstances);
putIfNotNull(json, CHILD_INSTANCES_KEY, childInstances);
Expand Down Expand Up @@ -319,6 +322,11 @@ public Instance setMatchKey(String matchKey) {
return this;
}

public Instance setSourceUri(String sourceUri) {
this.sourceUri = sourceUri;
return this;
}

public Instance setIndexTitle(String indexTitle) {
this.indexTitle = indexTitle;
return this;
Expand Down Expand Up @@ -585,6 +593,10 @@ public String getMatchKey() {
return matchKey;
}

public String getSourceUri() {
return sourceUri;
}

public String getSource() {
return source;
}
Expand Down Expand Up @@ -741,6 +753,7 @@ public List<String> getNatureOfContentTermIds() {
public Instance copyWithNewId(String newId) {
return new Instance(newId, null, null, this.source, this.title, this.instanceTypeId)
.setIndexTitle(indexTitle)
.setSourceUri(sourceUri)
.setAlternativeTitles(alternativeTitles)
.setEditions(editions)
.setSeries(series)
Expand Down Expand Up @@ -775,6 +788,7 @@ public Instance copyWithNewId(String newId) {
public Instance copyInstance() {
return new Instance(this.id, this.version, this.hrid, this.source, this.title, this.instanceTypeId)
.setIndexTitle(indexTitle)
.setSourceUri(sourceUri)
.setAlternativeTitles(alternativeTitles)
.setEditions(editions)
.setSeries(series)
Expand Down