Skip to content

Commit

Permalink
[CIRC-2036] Add new 'displaySummarry' field to the Item schema (#1438)
Browse files Browse the repository at this point in the history
* [MODORDERS-1017] - Add displaySummary field

* [MODORDERS-1017] - Add displaySummary field

* CIRC-2036 update schema with displaySummary field

* CIRC-2036 fix code smell issue

* CIRC-2036 fix code smell

* CIRC-2036 refactoring

* CIRC-2036 Fix Sonar reliability issue

* CIRC-2036 refactoring

---------

Co-authored-by: Dzmitry_Butramyou <[email protected]>
Co-authored-by: alexanderkurash <[email protected]>
3 people authored Mar 7, 2024
1 parent aaf8270 commit 4cda9ba
Showing 13 changed files with 66 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ramls/loan.json
Original file line number Diff line number Diff line change
@@ -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",
Original file line number Diff line number Diff line change
@@ -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;
}

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
@@ -243,6 +243,10 @@ public String getChronology() {
return description.getChronology();
}

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

public String getNumberOfPieces() {
return description.getNumberOfPieces();
}
Original file line number Diff line number Diff line change
@@ -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;
@@ -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
@@ -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) {
Original file line number Diff line number Diff line change
@@ -208,6 +208,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();
Original file line number Diff line number Diff line change
@@ -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,
Original file line number Diff line number Diff line change
@@ -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())
Original file line number Diff line number Diff line change
@@ -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())
Original file line number Diff line number Diff line change
@@ -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()));
@@ -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()
Original file line number Diff line number Diff line change
@@ -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")
1 change: 1 addition & 0 deletions src/test/java/api/requests/StaffSlipsTests.java
Original file line number Diff line number Diff line change
@@ -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"));
47 changes: 46 additions & 1 deletion src/test/java/api/support/builders/ItemBuilder.java
Original file line number Diff line number Diff line change
@@ -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(
@@ -67,6 +68,7 @@ private ItemBuilder(
String volume,
List<String> yearCaption,
String chronology,
String displaySummary,
String numberOfPieces,
String descriptionOfPieces) {

@@ -87,6 +89,7 @@ private ItemBuilder(
this.volume = volume;
this.yearCaption = yearCaption;
this.chronology = chronology;
this.displaySummary = displaySummary;
this.numberOfPieces = numberOfPieces;
this.descriptionOfPieces = descriptionOfPieces;
}
@@ -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);

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

0 comments on commit 4cda9ba

Please sign in to comment.