Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MODINVSTOR-1161 SourceId is allowed to be deleted for Holdings record #1024

Merged
merged 14 commits into from
Jun 18, 2024
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
5 changes: 4 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## v27.2.0 In progress

### Breaking changes
* Description ([ISSUE\_NUMBER](https://folio-org.atlassian.net/browse/ISSUE_NUMBER))
* Required sourceId field in holdings record ([MODINVSTOR-1161](https://folio-org.atlassian.net/browse/MODINVSTOR-1161))

### New APIs versions
* Provides `instance-storage 10.1`
Expand All @@ -26,6 +26,9 @@
### Dependencies
* Bump `LIB_NAME` from `OLD_VERSION` to `NEW_VERSION`
* Bump `domain-models-runtime` from `35.2.0` to `35.2.2`
* Bump `holdings-storage` from `6.0` to `7.0`
* Bump `holdings-storage-batch-sync` from `1.1` to `2.0`
* Bump `holdings-storage-batch-sync-unsafe` from `1.0` to `2.0`
* Add `LIB_NAME` `2.7.4`
* Remove `LIB_NAME`

Expand Down
6 changes: 3 additions & 3 deletions descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
},
{
"id": "holdings-storage",
"version": "6.1",
"version": "7.0",
"handlers": [
{
"methods": ["GET"],
Expand Down Expand Up @@ -116,7 +116,7 @@
},
{
"id": "holdings-storage-batch-sync",
"version": "1.1",
"version": "2.0",
"handlers": [
{
"methods": ["POST"],
Expand All @@ -131,7 +131,7 @@
},
{
"id": "holdings-storage-batch-sync-unsafe",
"version": "1.0",
"version": "2.0",
"handlers": [
{
"methods": ["POST"],
Expand Down
1 change: 1 addition & 0 deletions ramls/examples/holdings-storage/holdingsRecord_get.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"id": "65cb2bf0-d4c2-4886-8ad0-b76f1ba75d61",
"instanceId": "cd28da0f-a3e4-465c-82f1-acade4e8e170",
"sourceId": "8081d707-610f-4b50-a28b-c36a6d25191b",
"permanentLocationId": "d9cd0bed-1b49-4b5e-a7bd-064b8d177231",
"holdingsStatements": [
{
Expand Down
2 changes: 2 additions & 0 deletions ramls/examples/holdings-storage/holdingsRecords_get.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{
"id": "65cb2bf0-d4c2-4886-8ad0-b76f1ba75d61",
"instanceId": "cd28da0f-a3e4-465c-82f1-acade4e8e170",
"sourceId": "8081d707-610f-4b50-a28b-c36a6d25191b",
"permanentLocationId": "d9cd0bed-1b49-4b5e-a7bd-064b8d177231",
"holdingsStatements": [
{
Expand All @@ -23,6 +24,7 @@
{
"id": "807084d2-1b6c-4448-a566-d3d9ebfd1c08",
"instanceId": "601a8dc4-dee7-48eb-b03f-d02fdf0debd0",
"sourceId": "a779e45e-0e5e-4303-9c93-09dbbd215134",
"permanentLocationId": "d9cd0bed-1b49-4b5e-a7bd-064b8d177231",
"holdingsStatements": [
{
Expand Down
2 changes: 2 additions & 0 deletions ramls/examples/holdings-storage/holdingsRecords_post.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{
"id": "65cb2bf0-d4c2-4886-8ad0-b76f1ba75d61",
"instanceId": "cd28da0f-a3e4-465c-82f1-acade4e8e170",
"sourceId": "8081d707-610f-4b50-a28b-c36a6d25191b",
"permanentLocationId": "d9cd0bed-1b49-4b5e-a7bd-064b8d177231",
"holdingsStatements": [
{
Expand All @@ -23,6 +24,7 @@
{
"id": "807084d2-1b6c-4448-a566-d3d9ebfd1c08",
"instanceId": "601a8dc4-dee7-48eb-b03f-d02fdf0debd0",
"sourceId": "65cb2bf0-3333-4886-8ad0-b76f1ba75d23",
"permanentLocationId": "d9cd0bed-1b49-4b5e-a7bd-064b8d177231",
"holdingsStatements": [
{
Expand Down
1 change: 1 addition & 0 deletions ramls/holdings-storage/holdingsRecord.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
}
},
"required": [
"sourceId",
"instanceId",
"permanentLocationId"
]
Expand Down
1 change: 1 addition & 0 deletions ramls/holdings-storage/holdingsRecordView.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
},
"additionalProperties": false,
"required": [
"sourceId",
"instanceId",
"permanentLocationId"
]
Expand Down
4 changes: 4 additions & 0 deletions sample-data/holdings-sources/folio.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"id": "7fbd5d84-abcd-1978-8899-6cb173998bbd",
"name": "TEST"
}
1 change: 1 addition & 0 deletions sample-data/holdingsrecords/aba-holdingsrecord3.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"hrid" : "hold000000000001",
"formerIds" : [ ],
"instanceId" : "69640328-788e-43fc-9c3c-af39e243f3b7",
"sourceId": "7fbd5d84-abcd-1978-8899-6cb173998bbd",
"permanentLocationId" : "53cf956f-c1df-410b-8bea-27f712cca7c0",
"electronicAccess" : [ {
"uri" : "https://search.proquest.com/publication/1396348",
Expand Down
1 change: 1 addition & 0 deletions sample-data/holdingsrecords/aba-holdingsrecord4.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"hrid" : "hold000000000002",
"formerIds" : [ "ABW4508", "442882" ],
"instanceId" : "69640328-788e-43fc-9c3c-af39e243f3b7",
"sourceId": "7fbd5d84-abcd-1978-8899-6cb173998bbd",
"permanentLocationId" : "fcd64ce1-6995-48f0-840e-89ffa2288371",
"electronicAccess" : [ {
"uri" : "http://www.ebscohost.com",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"id" : "133a7916-f05e-4df4-8f7f-09eb2a7076d1",
"hrid" : "hold000000000003",
"instanceId" : "30fcc8e7-a019-43f4-b642-2edc389f4501",
"sourceId": "7fbd5d84-abcd-1978-8899-6cb173998bbd",
"permanentLocationId" : "fcd64ce1-6995-48f0-840e-89ffa2288371",
"callNumber" : "R11.A38",
"holdingsStatements" : [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"id": "65cb2bf0-d4c2-4886-8ad0-b76f1ba75d61",
"hrid" : "hold000000000004",
"instanceId": "7fbd5d84-62d1-44c6-9c45-6cb173998bbd",
"sourceId": "7fbd5d84-abcd-1978-8899-6cb173998bbd",
"callNumber": "PR6056.I4588 B749 2016",
"permanentLocationId": "fcd64ce1-6995-48f0-840e-89ffa2288371"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"id": "fb7b70f1-b898-4924-a991-0e4b6312bb5f",
"hrid" : "hold000000000005",
"instanceId": "7fbd5d84-62d1-44c6-9c45-6cb173998bbd",
"sourceId": "7fbd5d84-abcd-1978-8899-6cb173998bbd",
"callNumber": "PR6056.I4588 B749 2016",
"permanentLocationId": "53cf956f-c1df-410b-8bea-27f712cca7c0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"id": "65032151-39a5-4cef-8810-5350eb316300",
"hrid" : "hold000000000006",
"instanceId": "f31a36de-fcf8-44f9-87ef-a55d06ad21ae",
"sourceId": "7fbd5d84-abcd-1978-8899-6cb173998bbd",
"callNumber": "MCN FICTION",
"permanentLocationId": "b241764c-1466-4e1d-a028-1a3684a5da87",
"holdingsStatements": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"id": "67cd0046-e4f1-4e4f-9024-adf0b0039d09",
"hrid" : "hold000000000007",
"instanceId": "a89eccf0-57a6-495e-898d-32b9b2210f2f",
"sourceId": "7fbd5d84-abcd-1978-8899-6cb173998bbd",
"callNumber": "D15.H63 A3 2002",
"permanentLocationId": "f34d27c6-a8eb-461b-acd6-5dea81771e70",
"holdingsStatements": [
Expand Down
1 change: 1 addition & 0 deletions sample-data/holdingsrecords/nod-holdingsrecord.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"id": "68872d8a-bf16-420b-829f-206da38f6c10",
"hrid" : "hold000000000008",
"instanceId": "6506b79b-7702-48b2-9774-a1c538fdd34e",
"sourceId": "7fbd5d84-abcd-1978-8899-6cb173998bbd",
"callNumber": "some-callnumber",
"permanentLocationId": "fcd64ce1-6995-48f0-840e-89ffa2288371",
"holdingsStatements": [
Expand Down
1 change: 1 addition & 0 deletions sample-data/holdingsrecords/semantic-web-primer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"holdingsTypeId" : "03c9c400-b9e3-4a07-ac0e-05ab470233ed",
"formerIds" : [ ],
"instanceId" : "5bf370e0-8cca-4d9c-82e4-5170ab2a0a39",
"sourceId": "7fbd5d84-abcd-1978-8899-6cb173998bbd",
"permanentLocationId" : "fcd64ce1-6995-48f0-840e-89ffa2288371",
"electronicAccess" : [ ],
"callNumberTypeId" : "512173a7-bd09-490e-b773-17d83f2b63fe",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"id": "e6d7e91a-4dbc-4a70-9b38-e000d2fbdc79",
"hrid" : "hold000000000010",
"instanceId": "cf23adf0-61ba-4887-bf82-956c4aae2260",
"sourceId": "7fbd5d84-abcd-1978-8899-6cb173998bbd",
"callNumber": "some-callnumber",
"permanentLocationId": "fcd64ce1-6995-48f0-840e-89ffa2288371",
"holdingsStatements": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"id": "e9285a1c-1dfc-4380-868c-e74073003f43",
"hrid" : "hold000000000011",
"instanceId": "e54b1f4d-7d05-4b1a-9368-3c36b75d8ac6",
"sourceId": "7fbd5d84-abcd-1978-8899-6cb173998bbd",
"callNumber": "M1366.S67 T73 2017",
"permanentLocationId": "fcd64ce1-6995-48f0-840e-89ffa2288371",
"holdingsStatements": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"id": "55f48dc6-efa7-4cfe-bc7c-4786efe493e3",
"hrid" : "hold000000000012",
"instanceId": "bbd4a5e1-c9f3-44b9-bfdf-d184e04f0ba0",
"sourceId": "7fbd5d84-abcd-1978-8899-6cb173998bbd",
"permanentLocationId": "f34d27c6-a8eb-461b-acd6-5dea81771e70"
}

1 change: 1 addition & 0 deletions src/main/java/org/folio/rest/impl/TenantRefApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ Future<Integer> loadData(TenantAttributes attributes, String tenantId,
tl.add("location-units/campuses");
tl.add("location-units/libraries");
tl.add("locations");
tl.add("holdings-sources");
tl.add("instances", INSTANCES);
tl.add("holdingsrecords", HOLDINGS);
tl.add("items", ITEMS);
Expand Down
27 changes: 14 additions & 13 deletions src/test/java/org/folio/rest/api/AuditDeleteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public void testOnlyDeletedItemsAreStoredInAuditTable() throws Exception {
.withPermanentLoanType(canCirculateLoanTypeId)
.withBarcode("766043059304")
.create());
final JsonObject record = itemsClient.getAll().get(0);
final String itemId = record.getString("id");
final JsonObject recordJsonObject = itemsClient.getAll().get(0);
final String itemId = recordJsonObject.getString("id");
//when
record.remove("yearCaption");
itemsClient.replace(UUID.fromString(itemId), record);
recordJsonObject.remove("yearCaption");
itemsClient.replace(UUID.fromString(itemId), recordJsonObject);
//then
assertThat(getRecordsFromAuditTable(AUDIT_ITEM).size(), is(0));
//when
Expand All @@ -84,11 +84,11 @@ public void testOnlyDeletedInstancesAreStoredInAuditTable()
ExecutionException {

//given
final JsonObject record = instancesClient.getAll().get(0);
UUID instanceId = UUID.fromString(record.getString("id"));
final JsonObject recordJsonObject = instancesClient.getAll().get(0);
UUID instanceId = UUID.fromString(recordJsonObject.getString("id"));
//when
record.remove("notes");
instancesClient.replace(instanceId, record);
recordJsonObject.remove("notes");
instancesClient.replace(instanceId, recordJsonObject);
//then
assertThat(getRecordsFromAuditTable(AUDIT_INSTANCE).size(), is(0));
//when
Expand All @@ -106,12 +106,13 @@ public void testOnlyDeletedHoldingsAreStoredInAuditTable()
ExecutionException {

//given
final JsonObject record = holdingsClient.getAll().get(0);
final JsonObject recordJsonObject = holdingsClient.getAll().get(0);
//when
record.put("permanentLocationId", ANNEX_LIBRARY_LOCATION_ID.toString());
record.remove("holdingsItems");
record.remove("bareHoldingsItems");
holdingsClient.replace(holdingsRecordId, record);
recordJsonObject.put("permanentLocationId", ANNEX_LIBRARY_LOCATION_ID.toString());
recordJsonObject.put("sourceId", getPreparedHoldingSourceId().toString());
recordJsonObject.remove("holdingsItems");
recordJsonObject.remove("bareHoldingsItems");
holdingsClient.replace(holdingsRecordId, recordJsonObject);
//then
assertThat(getRecordsFromAuditTable(AUDIT_HOLDINGS_RECORD).size(), is(0));
//when
Expand Down
37 changes: 21 additions & 16 deletions src/test/java/org/folio/rest/api/BoundWithStorageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,24 @@ public void canCreateAndOrDeleteBoundWithPartsBycSetOfParts() {
"Expected initial boundWith to contain two parts.",
initiallyCreatedParts.size(), is(2));

IndividualResource part1 = new IndividualResource(
boundWithPartsClient.getById(
UUID.fromString(initiallyCreatedParts.get(0).getString("id"))));

IndividualResource part2 = new IndividualResource(
boundWithPartsClient.getById(
UUID.fromString(initiallyCreatedParts.get(1).getString("id"))));
// Uncomment to store in part1 in case of using 'boundWithEventMessageChecks'
// IndividualResource part1 =
new IndividualResource(boundWithPartsClient.getById(
UUID.fromString(initiallyCreatedParts.get(0).getString("id"))
));

// Uncomment to store in part2 in case of using 'boundWithEventMessageChecks'
// IndividualResource part2 =
new IndividualResource(boundWithPartsClient.getById(
UUID.fromString(initiallyCreatedParts.get(1).getString("id"))
));

// The published checks fail with ConditionTimeout more often than not on this developer's
// box. (Could it be a contributing factor that the box uses 90-100% of all four CPUs for
// most of the 14 minutes that Inventory Storage's tests take?)
// Increasing the wait from 10 to 30 seconds makes the tests pass more often than not.
//* boundWithEventMessageChecks.createdMessagePublished(part1, instance1.getId());
//* boundWithEventMessageChecks.createdMessagePublished(part2, instance2.getId());
// "boundWithEventMessageChecks.createdMessagePublished(part1, instance1.getId());"
// "boundWithEventMessageChecks.createdMessagePublished(part2, instance2.getId());"

// Listing the main holdings record plus two more
JsonObject boundWithFirstUpdate = createBoundWithCompositeJson(item.getId(),
Expand Down Expand Up @@ -266,7 +270,7 @@ public void canDeleteAllPartsOfBoundWithByOnlyProvidingMainHoldingsRecordId() {
JsonObject initialSample = createBoundWithCompositeJson(item.getId(),
Collections.singletonList(holdingsRecord2.getId()));
Response responseOnInitial = putCompositeBoundWith(initialSample);
logger.info("Response, initial sample: " + responseOnInitial.getBody());
logger.info(String.format("Response, initial sample: %s", responseOnInitial.getBody()));
assertThat(
"Expected 204 - no content on initial request",
responseOnInitial.getStatusCode(), is(204));
Expand All @@ -281,8 +285,8 @@ public void canDeleteAllPartsOfBoundWithByOnlyProvidingMainHoldingsRecordId() {
Collections.singletonList(holdingsRecord1.getId()));
Response responseOnOnlyMainHoldingsInListOfContents
= putCompositeBoundWith(onlyMainHoldingsRecordInListOfContents);
logger.info("Response on request with only the main holdings ID in: "
+ responseOnOnlyMainHoldingsInListOfContents.getBody());
logger.info(String.format("Response on request with only the main holdings ID in: %s",
responseOnOnlyMainHoldingsInListOfContents.getBody()));
assertThat(
"Expected 204 - no content on request with only the main holdings ID in",
responseOnOnlyMainHoldingsInListOfContents.getStatusCode(), is(204));
Expand All @@ -305,8 +309,8 @@ public void providingOnlyMainHoldingsRecordIdWhenBoundWithDoesNotExistYetHasNoEf
Collections.singletonList(holdingsRecord1.getId()));
Response responseOnOnlyMainHoldingsInListOfContents
= putCompositeBoundWith(onlyMainHoldingsRecordInListOfContents);
logger.info("Response on request with only the main holdings ID in: "
+ responseOnOnlyMainHoldingsInListOfContents.getBody());
logger.info(String.format("Response on request with only the main holdings ID in: %s",
responseOnOnlyMainHoldingsInListOfContents.getBody()));
assertThat(
"Expected 204 - no content on request with only the main holdings ID in",
responseOnOnlyMainHoldingsInListOfContents.getStatusCode(), is(204));
Expand All @@ -330,8 +334,8 @@ public void providingEmptyListOfPartsWhenBoundWithDoesNotExistYetHasNoEffect() {
List.of());
Response responseOnEmptyListOfContents
= putCompositeBoundWith(emptyListOfContents);
logger.info("Response on request with empty list of part: "
+ responseOnEmptyListOfContents.getBody());
logger.info(String.format("Response on request with empty list of part: %s",
responseOnEmptyListOfContents.getBody()));
assertThat(
"Expected 204 - no content on request on empty list of parts",
responseOnEmptyListOfContents.getStatusCode(), is(204));
Expand Down Expand Up @@ -422,6 +426,7 @@ private IndividualResource createInstance(String title) {
private IndividualResource createHoldingsRecord(UUID instanceId) {
HoldingRequestBuilder holdingRequestBuilder = new HoldingRequestBuilder()
.forInstance(instanceId)
.withSource(getPreparedHoldingSourceId())
.withPermanentLocation(MAIN_LIBRARY_LOCATION_ID);
return holdingsClient.create(holdingRequestBuilder.create(), TENANT_ID,
Map.of(XOkapiHeaders.URL, mockServer.baseUrl()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void canMigrateToEffectiveLocationForItemsWithPermanentLocationOnly() thr
InterruptedException, ExecutionException, TimeoutException {
createHoldingsRecord(new HoldingRequestBuilder()
.withId(HOLDINGS_ID)
.withSource(getPreparedHoldingSourceId())
.forInstance(INSTANCE_ID)
.withPermanentLocation(MAIN_LIBRARY_LOCATION_ID));

Expand All @@ -78,6 +79,7 @@ public void canMigrateToEffectiveLocationForItemsWithTemporaryLocation() throws
InterruptedException, ExecutionException, TimeoutException {
createHoldingsRecord(new HoldingRequestBuilder()
.withId(HOLDINGS_ID)
.withSource(getPreparedHoldingSourceId())
.forInstance(INSTANCE_ID)
.withTemporaryLocation(ANNEX_LIBRARY_LOCATION_ID)
.withPermanentLocation(MAIN_LIBRARY_LOCATION_ID));
Expand Down
Loading
Loading