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

[CIRC-2036] Add new 'displaySummarry' field to the Item schema #1438

Merged
merged 8 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
4 changes: 4 additions & 0 deletions ramls/loan.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@
"type": "string",
"readonly": true
},
"displaySummary": {
"description": "Display summary about the item",
"type": "string"
},
"callNumberComponents": {
"description": "Elements of a full call number",
"$ref": "schema/call-number-components.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public static class ActualCostRecordItem {
private final String volume;
private final String enumeration;
private final String chronology;
private final String displaySummary;
private final String copyNumber;
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/folio/circulation/domain/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ public String getChronology() {
return description.getChronology();
}

public String getDisplaySummary() {
return description.getDisplaySummary();
}

public String getNumberOfPieces() {
return description.getNumberOfPieces();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@Value
public class ItemDescription {
public static ItemDescription unknown() {
return new ItemDescription(null, null, null, null, null, null, null, List.of());
return new ItemDescription(null, null, null, null, null, null, null, null, List.of());
}

String barcode;
Expand All @@ -19,5 +19,6 @@ public static ItemDescription unknown() {
String chronology;
String numberOfPieces;
String descriptionOfPieces;
String displaySummary;
@NonNull Collection<String> yearCaption;
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ private static void addItemProperties(JsonObject request, Item item) {
}
write(itemSummary, "volume", item.getVolume());
write(itemSummary, "chronology", item.getChronology());
write(itemSummary, "displaySummary", item.getDisplaySummary());

ItemStatus status = item.getStatus();
if (status != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.Optional;
import java.util.stream.Stream;

import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -98,7 +97,7 @@ public static JsonObject createCheckInContext(CheckInContext context) {
JsonObject staffSlipContext = createStaffSlipContext(item, firstRequest);
JsonObject itemContext = staffSlipContext.getJsonObject(ITEM);

if (ObjectUtils.allNotNull(item, itemContext)) {
if (item != null && itemContext != null) {
write(itemContext, "lastCheckedInDateTime", ClockUtil.getZonedDateTime());
if (item.getInTransitDestinationServicePoint() != null) {
itemContext.put("toServicePoint", item.getInTransitDestinationServicePoint().getName());
Expand Down Expand Up @@ -208,6 +207,7 @@ private static JsonObject createItemContext(Item item) {
.put("loanType", item.getLoanTypeName())
.put("copy", copyNumber)
.put("numberOfPieces", item.getNumberOfPieces())
.put("displaySummary", item.getDisplaySummary())
.put("descriptionOfPieces", item.getDescriptionOfPieces());

Location location = item.getLocation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public JsonObject createItemSummary(Item item) {
write(itemSummary, "callNumber", item.getCallNumber());
write(itemSummary, "enumeration", item.getEnumeration());
write(itemSummary, "chronology", item.getChronology());
write(itemSummary, "displaySummary", item.getDisplaySummary());
write(itemSummary, "volume", item.getVolume());
write(itemSummary, "copyNumber", item.getCopyNumber());
write(itemSummary, CALL_NUMBER_COMPONENTS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ private JsonObject buildEntry(Item item) {
write(entry, "contributors", mapContributorNamesToJson(item));
write(entry, "callNumber", item.getCallNumber());
write(entry, "enumeration", item.getEnumeration());
write(entry, "displaySummary", item.getDisplaySummary());
write(entry, "volume", item.getVolume());
write(entry, "yearCaption", item.getYearCaption());
writeNamedObject(entry, "status", ofNullable(item.getStatus())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ private ActualCostRecord buildActualCostRecord(ActualCostRecordContext context)
.withVolume(item.getVolume())
.withChronology(item.getChronology())
.withEnumeration(item.getEnumeration())
.withDisplaySummary(item.getDisplaySummary())
.withCopyNumber(item.getCopyNumber()))
.withInstance(new ActualCostRecordInstance()
.withId(instance.getId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public static JsonObject toJson(ActualCostRecord actualCostRecord) {
write(itemJson, "volume", item.getVolume());
write(itemJson, "enumeration", item.getEnumeration());
write(itemJson, "chronology", item.getChronology());
write(itemJson, "displaySummary", item.getDisplaySummary());
write(itemJson, "copyNumber", item.getCopyNumber());
write(itemJson, "effectiveCallNumberComponents",
createCallNumberComponents(item.getEffectiveCallNumberComponents()));
Expand Down Expand Up @@ -152,6 +153,7 @@ public static ActualCostRecord toDomain(JsonObject representation) {
.withVolume(getProperty(item, "volume"))
.withEnumeration(getProperty(item, "enumeration"))
.withChronology(getProperty(item, "chronology"))
.withDisplaySummary(getProperty(item, "displaySummary"))
.withCopyNumber(getProperty(item, "copyNumber"))
.withEffectiveCallNumberComponents(CallNumberComponents.fromItemJson(item)),
new ActualCostRecordInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private ItemDescription getDescription(JsonObject representation) {
getProperty(representation, "copyNumber"),
getProperty(representation, "volume"),
getProperty(representation, "chronology"),
getProperty(representation, "displaySummary"),
getProperty(representation, "numberOfPieces"),
getProperty(representation, "descriptionOfPieces"),
toStream(representation, "yearCaption")
Expand Down
1 change: 1 addition & 0 deletions src/test/java/api/requests/StaffSlipsTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ void responseContainsSlipWithAllAvailableTokens(String countryCode, String prima
assertEquals(item.getEnumeration(), itemContext.getString("enumeration"));
assertEquals(item.getVolume(), itemContext.getString("volume"));
assertEquals(item.getChronology(), itemContext.getString("chronology"));
assertEquals(item.getDisplaySummary(), itemContext.getString("displaySummary"));
assertEquals(yearCaptionsToken, itemContext.getString("yearCaption"));
assertEquals(materialTypeName, itemContext.getString("materialType"));
assertEquals(loanTypeName, itemContext.getString("loanType"));
Expand Down
47 changes: 46 additions & 1 deletion src/test/java/api/support/builders/ItemBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ public class ItemBuilder extends JsonBuilder implements Builder {
private List<String> yearCaption;
private String volume;
private final String chronology;
private String displaySummary;
private String numberOfPieces;
private String descriptionOfPieces;

public ItemBuilder() {
this(UUID.randomUUID(), null, "565578437802", AVAILABLE,
null, null, null, null, null, null, null, null, null, null, null, Collections.emptyList(),
null, null, null);
null, null, null, null);
}

private ItemBuilder(
Expand All @@ -67,6 +68,7 @@ private ItemBuilder(
String volume,
List<String> yearCaption,
String chronology,
String displaySummary,
String numberOfPieces,
String descriptionOfPieces) {

Expand All @@ -87,6 +89,7 @@ private ItemBuilder(
this.volume = volume;
this.yearCaption = yearCaption;
this.chronology = chronology;
this.displaySummary = displaySummary;
this.numberOfPieces = numberOfPieces;
this.descriptionOfPieces = descriptionOfPieces;
}
Expand All @@ -112,6 +115,7 @@ public JsonObject create() {
put(itemRequest, "volume", volume);
put(itemRequest, "yearCaption", yearCaption);
put(itemRequest, "chronology", chronology);
put(itemRequest, "displaySummary", displaySummary);
put(itemRequest, "numberOfPieces", numberOfPieces);
put(itemRequest, "descriptionOfPieces", descriptionOfPieces);

Expand Down Expand Up @@ -181,6 +185,7 @@ public ItemBuilder withStatus(String status) {
this.volume,
this.yearCaption,
this.chronology,
this.displaySummary,
this.numberOfPieces,
this.descriptionOfPieces);
}
Expand All @@ -204,6 +209,7 @@ public ItemBuilder withBarcode(String barcode) {
this.volume,
this.yearCaption,
this.chronology,
this.displaySummary,
this.numberOfPieces,
this.descriptionOfPieces);
}
Expand Down Expand Up @@ -235,6 +241,7 @@ public ItemBuilder withPermanentLocation(UUID locationId) {
this.volume,
this.yearCaption,
this.chronology,
this.displaySummary,
this.numberOfPieces,
this.descriptionOfPieces);
}
Expand Down Expand Up @@ -266,6 +273,7 @@ public ItemBuilder withTemporaryLocation(UUID locationId) {
this.volume,
this.yearCaption,
this.chronology,
this.displaySummary,
this.numberOfPieces,
this.descriptionOfPieces);
}
Expand Down Expand Up @@ -293,6 +301,7 @@ public ItemBuilder forHolding(UUID holdingId) {
this.volume,
this.yearCaption,
this.chronology,
this.displaySummary,
this.numberOfPieces,
this.descriptionOfPieces);
}
Expand All @@ -316,6 +325,7 @@ public ItemBuilder withMaterialType(UUID materialTypeId) {
this.volume,
this.yearCaption,
this.chronology,
this.displaySummary,
this.numberOfPieces,
this.descriptionOfPieces);
}
Expand All @@ -339,6 +349,7 @@ public ItemBuilder withPermanentLoanType(UUID loanTypeId) {
this.volume,
this.yearCaption,
this.chronology,
this.displaySummary,
this.numberOfPieces,
this.descriptionOfPieces);
}
Expand All @@ -362,6 +373,7 @@ public ItemBuilder withTemporaryLoanType(UUID loanTypeId) {
this.volume,
this.yearCaption,
this.chronology,
this.displaySummary,
this.numberOfPieces,
this.descriptionOfPieces);
}
Expand All @@ -385,6 +397,7 @@ public ItemBuilder withId(UUID id) {
this.volume,
this.yearCaption,
this.chronology,
this.displaySummary,
this.numberOfPieces,
this.descriptionOfPieces);
}
Expand All @@ -408,6 +421,7 @@ public ItemBuilder withEnumeration(String enumeration) {
this.volume,
this.yearCaption,
this.chronology,
this.displaySummary,
this.numberOfPieces,
this.descriptionOfPieces);
}
Expand All @@ -431,6 +445,7 @@ public ItemBuilder withCopyNumber(String copyNumber) {
this.volume,
this.yearCaption,
this.chronology,
this.displaySummary,
this.numberOfPieces,
this.descriptionOfPieces);
}
Expand Down Expand Up @@ -458,6 +473,7 @@ public ItemBuilder withCallNumber(
this.volume,
this.yearCaption,
this.chronology,
this.displaySummary,
this.numberOfPieces,
this.descriptionOfPieces);
}
Expand All @@ -481,6 +497,7 @@ public ItemBuilder withVolume(String volume) {
volume,
this.yearCaption,
this.chronology,
this.displaySummary,
this.numberOfPieces,
this.descriptionOfPieces);
}
Expand All @@ -504,6 +521,7 @@ public ItemBuilder withYearCaption(List<String> yearCaption) {
this.volume,
yearCaption,
this.chronology,
this.displaySummary,
this.numberOfPieces,
this.descriptionOfPieces);
}
Expand All @@ -527,6 +545,31 @@ public ItemBuilder withChronology(String chronology) {
this.volume,
this.yearCaption,
chronology,
this.displaySummary,
this.numberOfPieces,
this.descriptionOfPieces);
}

public ItemBuilder withDisplaySummary(String displaySummary) {
return new ItemBuilder(
this.id,
this.holdingId,
this.barcode,
this.status,
this.permanentLocationId,
this.temporaryLocationId,
this.materialTypeId,
this.permanentLoanTypeId,
this.temporaryLoanTypeId,
this.enumeration,
this.copyNumber,
this.itemLevelCallNumber,
this.itemLevelCallNumberPrefix,
this.itemLevelCallNumberSuffix,
this.volume,
this.yearCaption,
this.chronology,
displaySummary,
this.numberOfPieces,
this.descriptionOfPieces);
}
Expand All @@ -550,6 +593,7 @@ public ItemBuilder withNumberOfPieces(String numberOfPieces) {
this.volume,
this.yearCaption,
this.chronology,
this.displaySummary,
numberOfPieces,
this.descriptionOfPieces);
}
Expand All @@ -573,6 +617,7 @@ public ItemBuilder withDescriptionOfPieces(String descriptionOfPieces) {
this.volume,
this.yearCaption,
this.chronology,
this.displaySummary,
this.numberOfPieces,
descriptionOfPieces);
}
Expand Down