Skip to content

Commit

Permalink
Merge branch 'master' into MODORDERS-585
Browse files Browse the repository at this point in the history
  • Loading branch information
yuntianhu authored Jan 31, 2024
2 parents cc02c81 + c897c88 commit 7d7f740
Show file tree
Hide file tree
Showing 26 changed files with 148 additions and 91 deletions.
8 changes: 4 additions & 4 deletions descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@
},
{
"id": "receiving",
"version": "1.2",
"version": "2.0",
"handlers": [
{
"methods": [
Expand Down Expand Up @@ -475,7 +475,7 @@
},
{
"id": "pieces",
"version": "2.1",
"version": "3.0",
"handlers": [
{
"methods": ["GET"],
Expand Down Expand Up @@ -1062,11 +1062,11 @@
},
{
"id": "orders-storage.pieces",
"version": "4.0"
"version": "5.0"
},
{
"id": "orders-storage.receiving-history",
"version": "3.2"
"version": "4.0"
},
{
"id": "orders-storage.reporting-codes",
Expand Down
28 changes: 18 additions & 10 deletions src/main/java/org/folio/helper/CheckinHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static org.folio.service.inventory.InventoryManager.ITEM_BARCODE;
import static org.folio.service.inventory.InventoryManager.ITEM_CHRONOLOGY;
import static org.folio.service.inventory.InventoryManager.ITEM_DISCOVERY_SUPPRESS;
import static org.folio.service.inventory.InventoryManager.ITEM_DISPLAY_SUMMARY;
import static org.folio.service.inventory.InventoryManager.ITEM_ENUMERATION;
import static org.folio.service.inventory.InventoryManager.ITEM_LEVEL_CALL_NUMBER;
import static org.folio.service.inventory.InventoryManager.ITEM_STATUS;
Expand All @@ -23,7 +24,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -237,7 +237,7 @@ private void updatePieceWithCheckinInfo(Piece piece) {
CheckInPiece checkinPiece = piecesByLineId.get(piece.getPoLineId())
.get(piece.getId());

piece.setCaption(checkinPiece.getCaption());
piece.setDisplaySummary(checkinPiece.getDisplaySummary());
piece.setComment(checkinPiece.getComment());

if (StringUtils.isNotEmpty(checkinPiece.getLocationId())) {
Expand Down Expand Up @@ -335,6 +335,19 @@ private Future<Void> checkinItem(JsonObject itemRecord, CheckInPiece checkinPiec

// Update item record with checkIn details
itemRecord.put(ITEM_STATUS, new JsonObject().put(ITEM_STATUS_NAME, checkinPiece.getItemStatus().value()));

if (StringUtils.isNotEmpty(checkinPiece.getDisplaySummary())) {
itemRecord.put(ITEM_DISPLAY_SUMMARY, checkinPiece.getDisplaySummary());
}
if (StringUtils.isNotEmpty(checkinPiece.getEnumeration())) {
itemRecord.put(ITEM_ENUMERATION, checkinPiece.getEnumeration());
}
if (StringUtils.isNotEmpty(checkinPiece.getCopyNumber())) {
itemRecord.put(COPY_NUMBER, checkinPiece.getCopyNumber());
}
if (StringUtils.isNotEmpty(checkinPiece.getChronology())) {
itemRecord.put(ITEM_CHRONOLOGY, checkinPiece.getChronology());
}
if (StringUtils.isNotEmpty(checkinPiece.getBarcode())) {
itemRecord.put(ITEM_BARCODE, checkinPiece.getBarcode());
}
Expand All @@ -344,14 +357,9 @@ private Future<Void> checkinItem(JsonObject itemRecord, CheckInPiece checkinPiec
if (StringUtils.isNotEmpty(checkinPiece.getCallNumber())) {
itemRecord.put(ITEM_LEVEL_CALL_NUMBER, checkinPiece.getCallNumber());
}
Optional.ofNullable(checkinPiece.getEnumeration())
.ifPresentOrElse(enumeration -> itemRecord.put(ITEM_ENUMERATION, enumeration), () -> itemRecord.remove(ITEM_ENUMERATION));
Optional.ofNullable(checkinPiece.getCopyNumber())
.ifPresentOrElse(copyNumber -> itemRecord.put(COPY_NUMBER, copyNumber), () -> itemRecord.remove(COPY_NUMBER));
Optional.ofNullable(checkinPiece.getChronology())
.ifPresentOrElse(chronology -> itemRecord.put(ITEM_CHRONOLOGY, chronology), () -> itemRecord.remove(ITEM_CHRONOLOGY));
Optional.ofNullable(checkinPiece.getDiscoverySuppress())
.ifPresentOrElse(discSup -> itemRecord.put(ITEM_DISCOVERY_SUPPRESS, discSup), () -> itemRecord.remove(ITEM_DISCOVERY_SUPPRESS));
if (checkinPiece.getDiscoverySuppress() != null) {
itemRecord.put(ITEM_DISCOVERY_SUPPRESS, checkinPiece.getDiscoverySuppress());
}

return inventoryManager.updateItem(itemRecord, requestContext);
}
Expand Down
24 changes: 16 additions & 8 deletions src/main/java/org/folio/helper/ReceivingHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static org.folio.service.inventory.InventoryManager.COPY_NUMBER;
import static org.folio.service.inventory.InventoryManager.ITEM_BARCODE;
import static org.folio.service.inventory.InventoryManager.ITEM_CHRONOLOGY;
import static org.folio.service.inventory.InventoryManager.ITEM_DISPLAY_SUMMARY;
import static org.folio.service.inventory.InventoryManager.ITEM_ENUMERATION;
import static org.folio.service.inventory.InventoryManager.ITEM_LEVEL_CALL_NUMBER;
import static org.folio.service.inventory.InventoryManager.ITEM_STATUS;
Expand All @@ -21,7 +22,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -256,7 +256,7 @@ private void updatePieceWithReceivingInfo(Piece piece) {
ReceivedItem receivedItem = piecesByLineId.get(piece.getPoLineId())
.get(piece.getId());

piece.setCaption(receivedItem.getCaption());
piece.setDisplaySummary(receivedItem.getDisplaySummary());
piece.setComment(receivedItem.getComment());
if (StringUtils.isNotEmpty(receivedItem.getLocationId())) {
piece.setLocationId(receivedItem.getLocationId());
Expand Down Expand Up @@ -288,18 +288,26 @@ private void updatePieceWithReceivingInfo(Piece piece) {
private Future<Void> receiveItem(JsonObject itemRecord, ReceivedItem receivedItem, RequestContext requestContext) {
// Update item record with receiving details
itemRecord.put(ITEM_STATUS, new JsonObject().put(ITEM_STATUS_NAME, receivedItem.getItemStatus().value()));

if (StringUtils.isNotEmpty(receivedItem.getDisplaySummary())) {
itemRecord.put(ITEM_DISPLAY_SUMMARY, receivedItem.getDisplaySummary());
}
if (StringUtils.isNotEmpty(receivedItem.getEnumeration())) {
itemRecord.put(ITEM_ENUMERATION, receivedItem.getEnumeration());
}
if (StringUtils.isNotEmpty(receivedItem.getCopyNumber())) {
itemRecord.put(COPY_NUMBER, receivedItem.getCopyNumber());
}
if (StringUtils.isNotEmpty(receivedItem.getChronology())) {
itemRecord.put(ITEM_CHRONOLOGY, receivedItem.getChronology());
}
if (StringUtils.isNotEmpty(receivedItem.getBarcode())) {
itemRecord.put(ITEM_BARCODE, receivedItem.getBarcode());
}
if (StringUtils.isNotEmpty(receivedItem.getCallNumber())) {
itemRecord.put(ITEM_LEVEL_CALL_NUMBER, receivedItem.getCallNumber());
}
Optional.ofNullable(receivedItem.getEnumeration())
.ifPresentOrElse(enumeration -> itemRecord.put(ITEM_ENUMERATION, enumeration), () -> itemRecord.remove(ITEM_ENUMERATION));
Optional.ofNullable(receivedItem.getCopyNumber())
.ifPresentOrElse(copyNumber -> itemRecord.put(COPY_NUMBER, copyNumber), () -> itemRecord.remove(COPY_NUMBER));
Optional.ofNullable(receivedItem.getChronology())
.ifPresentOrElse(chronology -> itemRecord.put(ITEM_CHRONOLOGY, chronology), () -> itemRecord.remove(ITEM_CHRONOLOGY));

return inventoryManager.updateItem(itemRecord, requestContext);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public class InventoryManager {
public static final String ITEM_ENUMERATION = "enumeration";
public static final String ITEM_CHRONOLOGY = "chronology";
public static final String ITEM_DISCOVERY_SUPPRESS = "discoverySuppress";
public static final String ITEM_DISPLAY_SUMMARY = "displaySummary";
public static final String CONTRIBUTOR_NAME = "name";
public static final String CONTRIBUTOR_NAME_TYPE_ID = "contributorNameTypeId";
public static final String CONTRIBUTOR_NAME_TYPES = "contributorNameTypes";
Expand Down Expand Up @@ -1269,6 +1270,9 @@ private Future<List<JsonObject>> fetchHoldingsByFundIds(List<String> holdingIds,
}

void updateItemWithPieceFields(Piece piece, JsonObject item) {
if (StringUtils.isNotEmpty(piece.getDisplaySummary())) {
item.put(ITEM_DISPLAY_SUMMARY, piece.getDisplaySummary());
}
if (StringUtils.isNotEmpty(piece.getEnumeration())) {
item.put(ITEM_ENUMERATION, piece.getEnumeration());
}
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/org/folio/helper/CheckinHelperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ void shouldTestGetItemCreateNeededCheckinPieces() {
String poLine2 = UUID.randomUUID().toString();
CheckinCollection checkinCollection = new CheckinCollection();
ToBeCheckedIn toBeCheckedIn1 = new ToBeCheckedIn().withPoLineId(poLine1);
CheckInPiece checkInPiece1 = new CheckInPiece().withId(UUID.randomUUID().toString()).withCreateItem(true).withCaption("1");
CheckInPiece checkInPiece2 = new CheckInPiece().withId(UUID.randomUUID().toString()).withCreateItem(false).withCaption("2");
CheckInPiece checkInPiece1 = new CheckInPiece().withId(UUID.randomUUID().toString()).withCreateItem(true).withDisplaySummary("1");
CheckInPiece checkInPiece2 = new CheckInPiece().withId(UUID.randomUUID().toString()).withCreateItem(false).withDisplaySummary("2");
toBeCheckedIn1.withCheckInPieces(List.of(checkInPiece1, checkInPiece2));

ToBeCheckedIn toBeCheckedIn2 = new ToBeCheckedIn().withPoLineId(poLine1);
CheckInPiece checkInPiece3 = new CheckInPiece().withId(UUID.randomUUID().toString()).withCreateItem(true).withCaption("3")
CheckInPiece checkInPiece3 = new CheckInPiece().withId(UUID.randomUUID().toString()).withCreateItem(true).withDisplaySummary("3")
.withEnumeration("Enum1").withCopyNumber("CN1").withChronology("Ch1").withDiscoverySuppress(true).withDisplayOnHolding(true);
toBeCheckedIn2.withCheckInPieces(List.of(checkInPiece3));

ToBeCheckedIn toBeCheckedIn3 = new ToBeCheckedIn().withPoLineId(poLine2);
CheckInPiece checkInPiece4 = new CheckInPiece().withId(UUID.randomUUID().toString()).withCreateItem(true).withCaption("4")
CheckInPiece checkInPiece4 = new CheckInPiece().withId(UUID.randomUUID().toString()).withCreateItem(true).withDisplaySummary("4")
.withEnumeration("Enum2").withCopyNumber("CN2").withChronology("Ch2").withDiscoverySuppress(false).withDisplayOnHolding(false);
toBeCheckedIn3.withCheckInPieces(List.of(checkInPiece4));

Expand All @@ -120,16 +120,16 @@ void shouldTestGetItemCreateNeededCheckinPieces() {

assertEquals(1, map.get(poLine2).size());
CheckInPiece actCheckInPiece1 = map.get(poLine1).stream()
.filter(checkInPiece -> "3".equals(checkInPiece.getCaption()))
.filter(checkInPiece -> "3".equals(checkInPiece.getDisplaySummary()))
.findFirst().get();
assertEquals("3", actCheckInPiece1.getCaption());
assertEquals("3", actCheckInPiece1.getDisplaySummary());
assertEquals("Enum1", actCheckInPiece1.getEnumeration());
assertEquals("CN1", actCheckInPiece1.getCopyNumber());
assertEquals("Ch1", actCheckInPiece1.getChronology());
assertEquals(true, actCheckInPiece1.getDiscoverySuppress());
assertEquals(true, actCheckInPiece1.getDisplayOnHolding());
CheckInPiece actCheckInPiece2 = map.get(poLine2).get(0);
assertEquals("4", actCheckInPiece2.getCaption());
assertEquals("4", actCheckInPiece2.getDisplaySummary());
assertEquals("Enum2", actCheckInPiece2.getEnumeration());
assertEquals("CN2", actCheckInPiece2.getCopyNumber());
assertEquals("Ch2", actCheckInPiece2.getChronology());
Expand Down
19 changes: 19 additions & 0 deletions src/test/java/org/folio/rest/impl/CheckinReceivingApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
import static org.folio.rest.impl.MockServer.getPoLineUpdates;
import static org.folio.rest.jaxrs.model.ProcessingStatus.Type.SUCCESS;
import static org.folio.rest.jaxrs.model.ReceivedItem.ItemStatus.ON_ORDER;
import static org.folio.service.inventory.InventoryManager.COPY_NUMBER;
import static org.folio.service.inventory.InventoryManager.ITEM_ACCESSION_NUMBER;
import static org.folio.service.inventory.InventoryManager.ITEM_CHRONOLOGY;
import static org.folio.service.inventory.InventoryManager.ITEM_DISCOVERY_SUPPRESS;
import static org.folio.service.inventory.InventoryManager.ITEM_DISPLAY_SUMMARY;
import static org.folio.service.inventory.InventoryManager.ITEM_ENUMERATION;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.emptyString;
Expand Down Expand Up @@ -241,6 +247,19 @@ void testPostCheckInPhysicalWithMissingItem() {
assertThat(item.getJsonObject(ITEM_STATUS).getString(ITEM_STATUS_NAME), equalTo(CheckInPiece.ItemStatus.IN_PROCESS.value()));
});

for (int i = 0; i < itemUpdates.size(); i++) {
JsonObject item = itemUpdates.get(i);
CheckInPiece piece = checkInRq.getToBeCheckedIn().get(0).getCheckInPieces().get(i);
assertEquals(piece.getDisplaySummary(), item.getString(ITEM_DISPLAY_SUMMARY));
assertEquals(piece.getEnumeration(), item.getString(ITEM_ENUMERATION));
assertEquals(piece.getCopyNumber(), item.getString(COPY_NUMBER));
assertEquals(piece.getChronology(), item.getString(ITEM_CHRONOLOGY));
assertEquals(piece.getBarcode(), item.getString(ITEM_BARCODE));
assertEquals(piece.getAccessionNumber(), item.getString(ITEM_ACCESSION_NUMBER));
assertEquals(piece.getCallNumber(), item.getString(ITEM_LEVEL_CALL_NUMBER));
assertEquals(piece.getDiscoverySuppress(), item.getBoolean(ITEM_DISCOVERY_SUPPRESS));
}

polUpdates.forEach(pol -> {
PoLine poLine = pol.mapTo(PoLine.class);
assertThat(poLine.getCheckinItems(), is(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import static org.folio.service.inventory.InventoryManager.ITEM_BARCODE;
import static org.folio.service.inventory.InventoryManager.ITEM_CHRONOLOGY;
import static org.folio.service.inventory.InventoryManager.ITEM_DISCOVERY_SUPPRESS;
import static org.folio.service.inventory.InventoryManager.ITEM_DISPLAY_SUMMARY;
import static org.folio.service.inventory.InventoryManager.ITEM_ENUMERATION;
import static org.folio.service.inventory.InventoryManager.ITEM_LEVEL_CALL_NUMBER;
import static org.folio.service.inventory.InventoryManager.ITEM_PURCHASE_ORDER_LINE_IDENTIFIER;
Expand Down Expand Up @@ -527,6 +528,7 @@ void testUpdateItemWithPieceFields() {
inventoryManager.updateItemWithPieceFields(piece, item);

// then
assertEquals(piece.getDisplaySummary(), item.getString(ITEM_DISPLAY_SUMMARY));
assertEquals(piece.getEnumeration(), item.getString(ITEM_ENUMERATION));
assertEquals(piece.getCopyNumber(), item.getString(COPY_NUMBER));
assertEquals(piece.getChronology(), item.getString(ITEM_CHRONOLOGY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ void shouldNotTryToUpdateItemWhenUpdatingPieceThatDoesNotHaveItem()
JsonObject holding = new JsonObject().put(ID, holdingId);
holding.put(HOLDING_PERMANENT_LOCATION_ID, UUID.randomUUID().toString());
Piece pieceFromStorage = new Piece().withId(pieceId).withTitleId(titleId).withPoLineId(lineId).withHoldingId(holdingId).withFormat(Piece.Format.PHYSICAL);
Piece pieceToUpdate = new Piece().withId(pieceId).withTitleId(titleId).withPoLineId(lineId).withHoldingId(holdingId).withFormat(Piece.Format.PHYSICAL).withCaption(caption);
Piece pieceToUpdate = new Piece().withId(pieceId).withTitleId(titleId).withPoLineId(lineId).withHoldingId(holdingId).withFormat(Piece.Format.PHYSICAL).withDisplaySummary(caption);
Location loc = new Location().withHoldingId(holdingId).withQuantityElectronic(1).withQuantity(1);
Cost cost = new Cost().withQuantityElectronic(1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@
"barcode": "",
"callNumber": "PR 8923 W6 L36 1990 c.3",
"comment": "Very important note",
"caption": "Vol. 1",
"displaySummary": "Vol. 1",
"createItem": false,
"supplement": false,
"locationId": "fcd64ce1-6995-48f0-840e-89ffa2288371",
"materialTypeId": "3cdc2cd3-6646-43bf-aacc-37934aeae36c",
"productId": "9780547840482",
"productIdType": "bae22dfa-5ea8-43aa-b61d-8da89ba339c4",
"accessionNumber": "1956.1",
"enumeration": "enum",
"copyNumber": "cp",
"chronology": "chronology",
"discoverySuppress": null,
"itemDescription": "This is the piece with no items",
"electronicBookplate": "This book is from the Harvard University library",
"itemStatus": "In process"
Expand All @@ -26,14 +30,18 @@
"barcode": "",
"callNumber": "BF2050 .M335 1999",
"comment": "Very important note",
"caption": "Vol. 2",
"displaySummary": "Vol. 2",
"createItem": false,
"supplement": true,
"locationId": "f34d27c6-a8eb-461b-acd6-5dea81771e70",
"materialTypeId": "93da93b3-5c2c-4077-b92d-12341d2070d2",
"productId": "2573-0797",
"productIdType": "31dcaba7-bce1-4a12-bd06-9ce901422285",
"accessionNumber": "2002.4",
"enumeration": "enum2",
"copyNumber": "cp2",
"chronology": "chronology2",
"discoverySuppress": true,
"itemDescription": "This is the piece with no items",
"electronicBookplate": "This book is from the Florida University library",
"itemStatus":"In process"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@
"barcode": "6015021",
"callNumber": "PR 8923 W6 L36 1990 c.3",
"comment": "Checkin Physical",
"caption": "Vol. 1",
"displaySummary": "Vol. 1",
"createItem": false,
"supplement": false,
"locationId": "fcd64ce1-6995-48f0-840e-89ffa2288371",
"materialTypeId": "3cdc2cd3-6646-43bf-aacc-37934aeae36c",
"productId": "9780547840482",
"productIdType": "bae22dfa-5ea8-43aa-b61d-8da89ba339c4",
"accessionNumber": "1956.1",
"enumeration": "enum",
"copyNumber": "cp",
"chronology": "chronology",
"discoverySuppress": null,
"itemDescription": "This is the piece with item",
"electronicBookplate": "This book is from the Harvard University library"
},
Expand All @@ -25,14 +29,18 @@
"barcode": "6015022",
"callNumber": "BF2050 .M335 1999",
"comment": "Checkin Physical",
"caption": "Vol. 2",
"displaySummary": "Vol. 2",
"createItem": false,
"supplement": true,
"locationId": "f34d27c6-a8eb-461b-acd6-5dea81771e70",
"materialTypeId": "93da93b3-5c2c-4077-b92d-12341d2070d2",
"productId": "2573-0797",
"productIdType": "31dcaba7-bce1-4a12-bd06-9ce901422285",
"accessionNumber": "2002.4",
"enumeration": "enum2",
"copyNumber": "cp2",
"chronology": "chronology2",
"discoverySuppress": true,
"itemDescription": "This is the piece with item",
"electronicBookplate": "This book is from the Florida University library"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "af372ac8-5ffb-4560-8b96-3945a12e121b",
"caption": "Tutorial Volume 5",
"displaySummary": "Tutorial Volume 5",
"comment": "Special Edition",
"format": "Physical",
"itemId": "522a501a-56b5-48d9-b28a-3a8f02482d97",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "fccaca78-ee0b-4579-930d-670bf5102ab0",
"caption": "Tutorial Volume 5",
"displaySummary": "Tutorial Volume 5",
"comment": "Special Edition",
"format": "Physical",
"itemId": "522a501a-56b5-48d9-b28a-3a8f02482d97",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "5dbe5481-e5c1-4119-95bc-58e52ffd8374",
"caption": "Tutorial Volume 13",
"displaySummary": "Tutorial Volume 13",
"comment": "Standard Edition",
"format": "Electronic",
"itemId": "522a501a-56b5-48d9-b28a-3a8f02482d97",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "4e717549-f915-47d6-b300-3672a7d7970f",
"caption": "Tutorial Volume 12",
"displaySummary": "Tutorial Volume 12",
"comment": "Special Edition 3",
"format": "Physical",
"itemId": "522a501a-56b5-48d9-b28a-3a8f02482d97",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "5b454292-6aaa-474f-9510-b59a564e0c8d",
"caption": "Tutorial Volume 9",
"displaySummary": "Tutorial Volume 9",
"comment": "Special Edition 9",
"format": "Physical",
"itemId": "522a501a-56b5-48d9-b28a-3a8f02482d97",
Expand Down
Loading

0 comments on commit 7d7f740

Please sign in to comment.