Skip to content

Commit 3c9a2d5

Browse files
committed
MODINVSTOR-1342: Add "deleted" field to Instance schema
1 parent 35d60dd commit 3c9a2d5

File tree

6 files changed

+24
-0
lines changed

6 files changed

+24
-0
lines changed

ramls/instance.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,10 @@
427427
"type": "boolean",
428428
"description": "Records the fact that the record should not be displayed in a discovery system"
429429
},
430+
"deleted": {
431+
"type": "boolean",
432+
"description": "Indicates whether the record was marked for deletion"
433+
},
430434
"statisticalCodeIds": {
431435
"type": "array",
432436
"description": "List of statistical code IDs",

src/main/java/org/folio/inventory/consortium/handlers/MarcInstanceSharingHandlerImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ private Future<Instance> updateSuppressFromDiscoveryFlagIfNeeded(Instance target
121121
private Instance populateTargetInstanceWithNonMarcControlledFields(Instance targetInstance, Instance sourceInstance) {
122122
targetInstance.setStaffSuppress(sourceInstance.getStaffSuppress());
123123
targetInstance.setDiscoverySuppress(sourceInstance.getDiscoverySuppress());
124+
targetInstance.setDeleted(sourceInstance.getDeleted());
124125
targetInstance.setCatalogedDate(sourceInstance.getCatalogedDate());
125126
targetInstance.setStatusId(sourceInstance.getStatusId());
126127
targetInstance.setStatisticalCodeIds(sourceInstance.getStatisticalCodeIds());

src/main/java/org/folio/inventory/domain/instances/Instance.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public class Instance {
6363
public static final String PREVIOUSLY_HELD_KEY = "previouslyHeld";
6464
public static final String STAFF_SUPPRESS_KEY = "staffSuppress";
6565
public static final String DISCOVERY_SUPPRESS_KEY = "discoverySuppress";
66+
public static final String DELETED_KEY = "deleted";
6667
public static final String STATISTICAL_CODE_IDS_KEY = "statisticalCodeIds";
6768
public static final String ADMININSTRATIVE_NOTES_KEY = "administrativeNotes";
6869
public static final String SOURCE_RECORD_FORMAT_KEY = "sourceRecordFormat";
@@ -109,6 +110,7 @@ public class Instance {
109110
private Boolean previouslyHeld;
110111
private Boolean staffSuppress;
111112
private Boolean discoverySuppress;
113+
private Boolean deleted;
112114
private List<String> statisticalCodeIds = new ArrayList<>();
113115
private String sourceRecordFormat;
114116
private String statusId;
@@ -182,6 +184,7 @@ public static Instance fromJson(JsonObject instanceJson) {
182184
.setPreviouslyHeld(instanceJson.getBoolean(PREVIOUSLY_HELD_KEY, false))
183185
.setStaffSuppress(instanceJson.getBoolean(STAFF_SUPPRESS_KEY, false))
184186
.setDiscoverySuppress(instanceJson.getBoolean(DISCOVERY_SUPPRESS_KEY, false))
187+
.setDeleted(instanceJson.getBoolean(DELETED_KEY, false))
185188
.setStatisticalCodeIds(toListOfStrings(instanceJson.getJsonArray(STATISTICAL_CODE_IDS_KEY)))
186189
.setSourceRecordFormat(instanceJson.getString(SOURCE_RECORD_FORMAT_KEY))
187190
.setStatusId(instanceJson.getString(STATUS_ID_KEY))
@@ -230,6 +233,7 @@ public JsonObject getJsonForStorage() {
230233
json.put(PREVIOUSLY_HELD_KEY, previouslyHeld);
231234
json.put(STAFF_SUPPRESS_KEY, staffSuppress);
232235
json.put(DISCOVERY_SUPPRESS_KEY, discoverySuppress);
236+
json.put(DELETED_KEY, deleted);
233237
json.put(STATISTICAL_CODE_IDS_KEY, statisticalCodeIds);
234238
if (sourceRecordFormat != null) json.put(SOURCE_RECORD_FORMAT_KEY, sourceRecordFormat);
235239
json.put(STATUS_ID_KEY, statusId);
@@ -282,6 +286,7 @@ public JsonObject getJsonForResponse(WebContext context) {
282286
putIfNotNull(json, PREVIOUSLY_HELD_KEY, getPreviouslyHeld());
283287
putIfNotNull(json, STAFF_SUPPRESS_KEY, getStaffSuppress());
284288
putIfNotNull(json, DISCOVERY_SUPPRESS_KEY, getDiscoverySuppress());
289+
putIfNotNull(json, DELETED_KEY, getDeleted());
285290
putIfNotNull(json, STATISTICAL_CODE_IDS_KEY, getStatisticalCodeIds());
286291
putIfNotNull(json, SOURCE_RECORD_FORMAT_KEY, getSourceRecordFormat());
287292
putIfNotNull(json, STATUS_ID_KEY, getStatusId());
@@ -516,6 +521,11 @@ public Instance setDiscoverySuppress(Boolean discoverySuppress) {
516521
return this;
517522
}
518523

524+
public Instance setDeleted(Boolean deleted) {
525+
this.deleted = deleted;
526+
return this;
527+
}
528+
519529
public Instance setStatisticalCodeIds(List<String> statisticalCodeIds) {
520530
this.statisticalCodeIds = statisticalCodeIds;
521531
return this;
@@ -693,6 +703,10 @@ public Boolean getDiscoverySuppress() {
693703
return discoverySuppress;
694704
}
695705

706+
public Boolean getDeleted() {
707+
return deleted;
708+
}
709+
696710
public List<String> getStatisticalCodeIds() {
697711
return statisticalCodeIds;
698712
}

src/main/java/org/folio/inventory/support/InstanceUtil.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public static Instance mergeFieldsWhichAreNotControlled(Instance existing, org.f
5252
.withVersion(asIntegerOrNull(existing.getVersion()))
5353
.withDiscoverySuppress(existing.getDiscoverySuppress())
5454
.withStaffSuppress(existing.getStaffSuppress())
55+
.withDeleted(existing.getDeleted())
5556
.withPreviouslyHeld(existing.getPreviouslyHeld())
5657
.withCatalogedDate(existing.getCatalogedDate())
5758
.withStatusId(existing.getStatusId())

src/test/java/org/folio/inventory/consortium/handlers/MarcInstanceSharingHandlerImplTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ public void shouldPopulateTargetInstanceWithNonMarcControlledFields(TestContext
611611
Instance localSourceInstance = new Instance(instanceId, "1", "001", "MARC", "testTitle", UUID.randomUUID().toString())
612612
.setDiscoverySuppress(Boolean.TRUE)
613613
.setStaffSuppress(Boolean.TRUE)
614+
.setDeleted(Boolean.TRUE)
614615
.setCatalogedDate("1970-01-01")
615616
.setStatusId(UUID.randomUUID().toString())
616617
.setStatisticalCodeIds(List.of(UUID.randomUUID().toString()))
@@ -654,6 +655,7 @@ public void shouldPopulateTargetInstanceWithNonMarcControlledFields(TestContext
654655
testContext.assertEquals(targetInstanceHrid, targetInstanceWithNonMarcData.getHrid());
655656
testContext.assertEquals(localSourceInstance.getDiscoverySuppress(), targetInstanceWithNonMarcData.getDiscoverySuppress());
656657
testContext.assertEquals(localSourceInstance.getStaffSuppress(), targetInstanceWithNonMarcData.getStaffSuppress());
658+
testContext.assertEquals(localSourceInstance.getDeleted(), targetInstanceWithNonMarcData.getDeleted());
657659
testContext.assertEquals(localSourceInstance.getCatalogedDate(), targetInstanceWithNonMarcData.getCatalogedDate());
658660
testContext.assertEquals(localSourceInstance.getStatusId(), targetInstanceWithNonMarcData.getStatusId());
659661
testContext.assertEquals(localSourceInstance.getStatisticalCodeIds(), targetInstanceWithNonMarcData.getStatisticalCodeIds());

src/test/java/org/folio/inventory/dataimport/handlers/actions/util/InstanceUtilTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public void shouldMergeInstances() {
6565
existing.setStatisticalCodeIds(statisticalCodeIds);
6666
existing.setDiscoverySuppress(true);
6767
existing.setStaffSuppress(true);
68+
existing.setDeleted(true);
6869
existing.setPreviouslyHeld(true);
6970
existing.setCatalogedDate("");
7071
existing.setStatusId("30773a27-b485-4dab-aeb6-b8c04fa3cb26");
@@ -85,6 +86,7 @@ public void shouldMergeInstances() {
8586
assertEquals(statisticalCodeIds, instance.getStatisticalCodeIds());
8687
assertTrue(instance.getDiscoverySuppress());
8788
assertTrue(instance.getStaffSuppress());
89+
assertTrue(instance.getDeleted());
8890
assertTrue(instance.getPreviouslyHeld());
8991
assertEquals("", instance.getCatalogedDate());
9092
assertEquals("30773a27-b485-4dab-aeb6-b8c04fa3cb26", instance.getStatusId());

0 commit comments

Comments
 (0)