Skip to content

MODINV-1406: Add customFields to item - #932

Draft
elsenhans wants to merge 3 commits into
masterfrom
MODINV-1406-add-customFields-to-item
Draft

MODINV-1406: Add customFields to item#932
elsenhans wants to merge 3 commits into
masterfrom
MODINV-1406-add-customFields-to-item

Conversation

@elsenhans

@elsenhans elsenhans commented Jul 31, 2026

Copy link
Copy Markdown

MODINV-1406
This PR is connected to folio-org/mod-inventory-storage#1251 (which is blocked)

Purpose

Background
mod-inventory-storage already integrates folio-custom-fields: it defines/persists custom field definitions via its own /custom-fields interface and accepts a customFields value on the stored item record. mod-inventory sits in front of storage with its own copy of the item schema and domain model, so without this change any customFields value sent by a client would be silently dropped (schema has additionalProperties: false) and never returned in responses.

Acceptance Criteria

  • POSTing/PUTting an item with customFields persists and returns that value unchanged via mod-inventory's API
  • Items without customFields omit the property from the response (no empty/null noise)
  • No changes needed to custom field definition management — that remains owned by mod-inventory-storage

Approach

  • Add customFields property to ramls/item.json (referencing a new ramls/customFields.json schema, generic object)
  • Add customFields field + getter/withCustomFields to Item.java, and ensure it's carried over in copyWithNewId/similar copy methods
  • Update ItemRepresentation.java to include customFields in the API response when present
  • Update ItemUtil.java mapping in both directions: request JSON → Item, Item → stored representation, stored representation → Item
  • Unit tests covering: field present/absent in response, round-trip through stored/request representations

Changes Checklist

  • API Changes: Document any API paths, methods, request or response bodies changed, added, or removed.
  • Database Schema Changes: Indicate any database schema changes and their impact. Confirm that migration scripts were created.
  • Interface Version Changes: Indicate any changes to interface versions.
  • Interface Dependencies: Document added or removed dependencies.
  • Permissions: Document any changes to permissions.
  • Logging: Confirm that logging is appropriately handled.
  • Unit Testing: Confirm that changed classes were covered by unit tests.
  • Integration Testing: Confirm that changed logic was covered by integration tests.
  • Manual Testing: Confirm that changes were tested on local or dev environment.
  • NEWS: Confirm that the NEWS file is updated with relevant information about the changes made in this pull request.

Related Issues

Learning and Resources (if applicable)

Discuss any research conducted during the development of this pull request. Include links to relevant blog posts, patterns, libraries, or addons that were used to solve the problem.

Screenshots (if applicable)

If this pull request involves any visual changes or new features, consider including screenshots or GIFs to illustrate the changes.

@elsenhans
elsenhans requested a review from a team as a code owner July 31, 2026 08:04
@elsenhans
elsenhans marked this pull request as draft July 31, 2026 08:05

@charismatic-claire charismatic-claire left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I basically approve. I just have some comprehensive questions and one remark about persistence. Cool. Thanks for letting me read this :)

Comment thread ramls/item.json
Comment thread src/main/java/org/folio/inventory/domain/items/Item.java
Comment thread src/test/java/org/folio/inventory/support/ItemUtilTest.java

@alb3rtino alb3rtino left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inventory interface version should be bumped as the item schema has been updated. Also require a custom-fields supporting item-storage interface, see folio-org/mod-inventory-storage#1251 (review).

@github-actions

Copy link
Copy Markdown

JSON Schema Changes (folio-org/mod-inventory)

  • Base: 896412cc03a501d298d94d513955f3f7f59abce4
  • Head: 3f522b9464e0c7a3bd681813f1901d55d4004e8a

Changed files

Status File (HEAD)
Added ramls/customFields.json
Modified ramls/item.json

Schema changes

ramls/customFields.json

--- ramls/customFields.json (base)
+++ ramls/customFields.json (head)
@@ -0,0 +1,7 @@
+{
+  "$schema": "http://json-schema.org/draft-07/schema#",
+  "additionalProperties": true,
+  "description": "Object that contains custom field",
+  "javaName": "CustomFields",
+  "type": "object"
+}

ramls/item.json

--- ramls/item.json (base)
+++ ramls/item.json (head)
@@ -165,6 +165,11 @@
       "description": "Copy number is the piece identifier. The copy number reflects if the library has a copy of a single-volume monograph; a copy of a multi-volume, (e.g. Copy 1, or C.7.)",
       "type": "string"
     },
+    "customFields": {
+      "$ref": "customFields.json",
+      "description": "Object that contains custom fields",
+      "type": "object"
+    },
     "descriptionOfPieces": {
       "description": "Text which descripe the pieces",
       "type": "string"

@elsenhans

Copy link
Copy Markdown
Author

@alb3rtino Thanks for the hint!
inventory and item-storage interface versions has been increased.

@elsenhans
elsenhans requested a review from alb3rtino August 11, 2026 13:13
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants