Skip to content

Commit

Permalink
MODINVSTOR-1342: Add "deleted" field to Instance schema
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiBordak committed Feb 6, 2025
1 parent 35d60dd commit 3c9a2d5
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ramls/instance.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@
"type": "boolean",
"description": "Records the fact that the record should not be displayed in a discovery system"
},
"deleted": {
"type": "boolean",
"description": "Indicates whether the record was marked for deletion"
},
"statisticalCodeIds": {
"type": "array",
"description": "List of statistical code IDs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ private Future<Instance> updateSuppressFromDiscoveryFlagIfNeeded(Instance target
private Instance populateTargetInstanceWithNonMarcControlledFields(Instance targetInstance, Instance sourceInstance) {
targetInstance.setStaffSuppress(sourceInstance.getStaffSuppress());
targetInstance.setDiscoverySuppress(sourceInstance.getDiscoverySuppress());
targetInstance.setDeleted(sourceInstance.getDeleted());
targetInstance.setCatalogedDate(sourceInstance.getCatalogedDate());
targetInstance.setStatusId(sourceInstance.getStatusId());
targetInstance.setStatisticalCodeIds(sourceInstance.getStatisticalCodeIds());
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/org/folio/inventory/domain/instances/Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class Instance {
public static final String PREVIOUSLY_HELD_KEY = "previouslyHeld";
public static final String STAFF_SUPPRESS_KEY = "staffSuppress";
public static final String DISCOVERY_SUPPRESS_KEY = "discoverySuppress";
public static final String DELETED_KEY = "deleted";
public static final String STATISTICAL_CODE_IDS_KEY = "statisticalCodeIds";
public static final String ADMININSTRATIVE_NOTES_KEY = "administrativeNotes";
public static final String SOURCE_RECORD_FORMAT_KEY = "sourceRecordFormat";
Expand Down Expand Up @@ -109,6 +110,7 @@ public class Instance {
private Boolean previouslyHeld;
private Boolean staffSuppress;
private Boolean discoverySuppress;
private Boolean deleted;
private List<String> statisticalCodeIds = new ArrayList<>();
private String sourceRecordFormat;
private String statusId;
Expand Down Expand Up @@ -182,6 +184,7 @@ public static Instance fromJson(JsonObject instanceJson) {
.setPreviouslyHeld(instanceJson.getBoolean(PREVIOUSLY_HELD_KEY, false))
.setStaffSuppress(instanceJson.getBoolean(STAFF_SUPPRESS_KEY, false))
.setDiscoverySuppress(instanceJson.getBoolean(DISCOVERY_SUPPRESS_KEY, false))
.setDeleted(instanceJson.getBoolean(DELETED_KEY, false))
.setStatisticalCodeIds(toListOfStrings(instanceJson.getJsonArray(STATISTICAL_CODE_IDS_KEY)))
.setSourceRecordFormat(instanceJson.getString(SOURCE_RECORD_FORMAT_KEY))
.setStatusId(instanceJson.getString(STATUS_ID_KEY))
Expand Down Expand Up @@ -230,6 +233,7 @@ public JsonObject getJsonForStorage() {
json.put(PREVIOUSLY_HELD_KEY, previouslyHeld);
json.put(STAFF_SUPPRESS_KEY, staffSuppress);
json.put(DISCOVERY_SUPPRESS_KEY, discoverySuppress);
json.put(DELETED_KEY, deleted);
json.put(STATISTICAL_CODE_IDS_KEY, statisticalCodeIds);
if (sourceRecordFormat != null) json.put(SOURCE_RECORD_FORMAT_KEY, sourceRecordFormat);
json.put(STATUS_ID_KEY, statusId);
Expand Down Expand Up @@ -282,6 +286,7 @@ public JsonObject getJsonForResponse(WebContext context) {
putIfNotNull(json, PREVIOUSLY_HELD_KEY, getPreviouslyHeld());
putIfNotNull(json, STAFF_SUPPRESS_KEY, getStaffSuppress());
putIfNotNull(json, DISCOVERY_SUPPRESS_KEY, getDiscoverySuppress());
putIfNotNull(json, DELETED_KEY, getDeleted());
putIfNotNull(json, STATISTICAL_CODE_IDS_KEY, getStatisticalCodeIds());
putIfNotNull(json, SOURCE_RECORD_FORMAT_KEY, getSourceRecordFormat());
putIfNotNull(json, STATUS_ID_KEY, getStatusId());
Expand Down Expand Up @@ -516,6 +521,11 @@ public Instance setDiscoverySuppress(Boolean discoverySuppress) {
return this;
}

public Instance setDeleted(Boolean deleted) {
this.deleted = deleted;
return this;
}

public Instance setStatisticalCodeIds(List<String> statisticalCodeIds) {
this.statisticalCodeIds = statisticalCodeIds;
return this;
Expand Down Expand Up @@ -693,6 +703,10 @@ public Boolean getDiscoverySuppress() {
return discoverySuppress;
}

public Boolean getDeleted() {
return deleted;
}

public List<String> getStatisticalCodeIds() {
return statisticalCodeIds;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public static Instance mergeFieldsWhichAreNotControlled(Instance existing, org.f
.withVersion(asIntegerOrNull(existing.getVersion()))
.withDiscoverySuppress(existing.getDiscoverySuppress())
.withStaffSuppress(existing.getStaffSuppress())
.withDeleted(existing.getDeleted())
.withPreviouslyHeld(existing.getPreviouslyHeld())
.withCatalogedDate(existing.getCatalogedDate())
.withStatusId(existing.getStatusId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ public void shouldPopulateTargetInstanceWithNonMarcControlledFields(TestContext
Instance localSourceInstance = new Instance(instanceId, "1", "001", "MARC", "testTitle", UUID.randomUUID().toString())
.setDiscoverySuppress(Boolean.TRUE)
.setStaffSuppress(Boolean.TRUE)
.setDeleted(Boolean.TRUE)
.setCatalogedDate("1970-01-01")
.setStatusId(UUID.randomUUID().toString())
.setStatisticalCodeIds(List.of(UUID.randomUUID().toString()))
Expand Down Expand Up @@ -654,6 +655,7 @@ public void shouldPopulateTargetInstanceWithNonMarcControlledFields(TestContext
testContext.assertEquals(targetInstanceHrid, targetInstanceWithNonMarcData.getHrid());
testContext.assertEquals(localSourceInstance.getDiscoverySuppress(), targetInstanceWithNonMarcData.getDiscoverySuppress());
testContext.assertEquals(localSourceInstance.getStaffSuppress(), targetInstanceWithNonMarcData.getStaffSuppress());
testContext.assertEquals(localSourceInstance.getDeleted(), targetInstanceWithNonMarcData.getDeleted());
testContext.assertEquals(localSourceInstance.getCatalogedDate(), targetInstanceWithNonMarcData.getCatalogedDate());
testContext.assertEquals(localSourceInstance.getStatusId(), targetInstanceWithNonMarcData.getStatusId());
testContext.assertEquals(localSourceInstance.getStatisticalCodeIds(), targetInstanceWithNonMarcData.getStatisticalCodeIds());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public void shouldMergeInstances() {
existing.setStatisticalCodeIds(statisticalCodeIds);
existing.setDiscoverySuppress(true);
existing.setStaffSuppress(true);
existing.setDeleted(true);
existing.setPreviouslyHeld(true);
existing.setCatalogedDate("");
existing.setStatusId("30773a27-b485-4dab-aeb6-b8c04fa3cb26");
Expand All @@ -85,6 +86,7 @@ public void shouldMergeInstances() {
assertEquals(statisticalCodeIds, instance.getStatisticalCodeIds());
assertTrue(instance.getDiscoverySuppress());
assertTrue(instance.getStaffSuppress());
assertTrue(instance.getDeleted());
assertTrue(instance.getPreviouslyHeld());
assertEquals("", instance.getCatalogedDate());
assertEquals("30773a27-b485-4dab-aeb6-b8c04fa3cb26", instance.getStatusId());
Expand Down

0 comments on commit 3c9a2d5

Please sign in to comment.