Sources: https://github.com/folio-org/mod-data-export/pull/65
The purpose of the PoC is to provide a solution to retrieve mapping profile transformations list to UI and apply them during export to convert inventory objects - instances, holdings, items to MARC records.
The solution contains parts that will be used in Q2 and Q3 releases of mod-data-export.
Q2 functionality
1) Building and retrieving a list of mapping profile transformations to UI. MappingProfileService interface provides a method getMappingProfileTrasnformations() that returns a list of specific transformations for holdings and item record types. It builds MappingProfileTransformation base on TransformationConfig enum values. MappingProfileTransformation contains id, JsonPath value, display name and record type. In Q2 MappingProfileService will not return transformations for key-value settings fields but it works only for simple fields. Therefore only a method buildSimpleTransformation should be used in Q2.
2) Traversing multiple holdings and items. Holdings records should be retrieved by instance ids from mod-invetory-storage by request to "/holdings-storage/holdings?query=(instanceId==id)". The same approach should be used to retrieve item records by holdings id - "/item-storage/items?query=(holdingsRecordId==id)". All received records should be appended to one common JSON objects with the following structure:
{ "holdings": [ { "field1: "value", ... }, ... ], "item": [ { "field1: "value", ... }, ... ], "instance": { "field1: "value", ... } }
Such new instance JSON objects are passed to MappingService and used during mapping. At the same time, for mapping rules DataSource.from JsonPath values are changed according to a new structure of instance JSON object. For example for instance "hrid" field it's changed from "$.hrid" to "$.instance.hrid".
3) Applying a mapping profile during generating MARC bib records on the fly. The mapping profile instance should be retrieved from the database by JobProfile in ExportManagerImpl. RuleFactory.create(MappingProfile mappingProfile) is called in MappingService to generate rules by MappingProfile or to retrieve default rules. For Q2 it's not required to create instance rules by mapping profile, but in case if MappingProfile contains Instance record type, then all instance default rules are load. Combining transformation values with default rules also is not included in Q2. Rules form RuleFactory are passed to RuleProcessor to start generating MARC bib records on the fly.
4) Sorting of the fields. Use SortedMarcFactoryImpl in MarcRecordWriter to apply the sorting of marc record fields by tag.
After Q2 functionality
1) Building and retrieving a list of mapping profile transformations to UI. MappingProfileService will be updated to retrieve a list of MappingProfileTransformation base on key-value settings fields. SettingsLoader is used to extract specific settings values for particular fields from mod-inventory-storage. Then a list of MappingProfileTransformation is built by settings values and specific TransformationConfig.
2) Combining transformation values with default rules. In case when transformation value, for instance field is empty, then default for a specific field is taken by matching MappingProfileRule.path value with DataSource.from value of default rules.