MODDICORE-146 SPIKE: Instance & SRS record updates need to honor MARC field protections
Problem statement
When updating an instance record with an action profile for instance update field protections entered in Settings need to be honored to avoid changing instance fields controlled by marc record fields which are protected by fields protections settings.
Currently, only processing of action profile for updating a MARC record supports field protections rules entered in Settings.
See MARC field protections for additional information from the user perspective.
Current action profile processing flow for instance update
The mod-inventory module consumes "DI_INVENTORY_INSTANCE_MATCHED" message from Kafka with incoming record and matched instance that should be updated. The mod-inventory performs mapping of incoming record to instance and updates target instance in mod-inventory-storage through REST API. After that, mod-inventory sends a "DI_INVENTORY_INSTANCE_UPDATED_READY_FOR_POST_PROCESSING" message to Kafka with updated instance. mod-source-record-storage consumes "DI_INVENTORY_INSTANCE_UPDATED_READY_FOR_POST_PROCESSING" message to update incoming record fields in storage with target instance id and hrid.
Approach
During investigation was found that logic for fields protections can not be directly introduced to the default mapper engine since protections field logic requires an existing record as well.
Currently, an incoming record from the "ID_INVENTORY_INSTANCE_MATCHED" message is used as a source of data for instance mapping. Therefore, there may be cases when some instance fields under the MARC record fields control can be changed during instance update.
Field protections can be achieved by updating existing record content with incoming record content according to protection fields logic. After that, the updated record should be used as a source for instance mapping. Since field protections logic relies on fields of incoming and existing records it is necessary to add an additional call to mod-source-record-storage module for retrieving an existing MARC record for the target instance.
- The mod-inventory module consumes a "DI_INVENTORY_INSTANCE_MATCHED" message from Kafka with an incoming MARC record and matched instance that should be updated. The processing of such messages is dispatched to the ReplaceInstanceEventHandler event handler.
- Obtaining existing MARC record that related to the instance by performing "GET /source-storage/records/{instanceId}/formatted?idType=INSTANCE" call for record preparation before instance mapping invocation.
Record preparation means updating existing record fields by fields from the incoming record according to fields protection logic described on the MARC field protections page. Field protection rules/settings are already available for the handler and can be retrieved from MappingParameters (MappingParameters#getMarcFieldProtectionSettings()
). After that prepared record is used as a source for instance mapping.
Logic to update the MARC record fields can be implemented as a util method and extracted to the data-import-processing-core library to be reused by other event handlers if it would be necessary. - An instance update result (mapped instance) is sent to mod-inventory-storage by calling the corresponding REST endpoint.
- A message with instance update result is sent to Kafka and then it is consumed by mod-source-record-storage to update parsed content of related MARC record.
Proposed changes to accomplish field protections during instance update
- for data-import-processing-core library a util method should be added that takes incoming, existing record, and field protection settings and performs existing record update with incoming record fields according to protection fields logic - MODDICORE-265Getting issue details... STATUS
- for mod-inventory module it is necessary to add an additional call to mod-source-record-storage to obtain existing MARC record and perform record preparation using the method mentioned in the previous bullet point. Populate a payload of instance update result message with prepared record to be saved in the mod-source-record-storage - MODINV-686Getting issue details... STATUS