Add support for nested Unit references
OSDU R3 schemas have introduced the notion of unit references (either to meta or external records) that live in the same structures as the data in the data block. This means the frame of reference service needs to be able to deal with these references, and this is especially an issue for nested array data where a unique path using "." notation can't be defined. Array notation would generally be used, e.g. data.VerticalMeasurement[4], etc.
In this solution the Frame Of reference (FOR) is always embedded in the meta block.
Homogeneous Cases: (We have to update specified fields for all the items in the nested array)
GIVEN an embedded FOR for an array of objects WHEN I can declare without an index one or many properties within the objects e.g.
{ "kind": "Unit", "name": "ft", "persistableReference": "{"abcd":{"a":0.0,"b":0.3048,"c":1.0,"d":0.0},"symbol":"ft","baseMeasurement":{"ancestry":"L","type":"UM"},"type":"UAD"}", "unitOfMeasureID": "partition-id:reference-data--UnitOfMeasure:ft:", "propertyNames": [ "VerticalMeasurement.VerticalMeasurement", "Markers[].MarkerMeasuredDepth", "Markers[].PositiveVerticalDelta", "Markers[].NegativeVerticalDelta" ] }
THEN all properties declared for that object within that array use the same FOR and should be converted the same way (see attachment for expected result in Work product component 'normalized' example)
GIVEN an embedded FOR for an array of objects WHEN I can declare without an index one or many properties within the objects e.g.
{ "kind": "Unit", "name": "m", "persistableReference": "{"abcd":{"a":0.0,"b":1.0,"c":1.0,"d":0.0},"symbol":"m","baseMeasurement":{"ancestry":"L","type":"UM"},"type":"UAD"}", "unitOfMeasureID": "namespace:reference-data--UnitOfMeasure:m:", "propertyNames": [ "Markers[].MarkerMeasuredDepth" } AND WHEN object 2 has an error converting THEN the error message should declare the specific object with the error e.g. error converting Markers[1].MarkerMeasuredDepth because ....
InHomogeneous Cases: (We have to update specified fields for specifying the items in the nested array)
GIVEN an embedded FOR for an array of objects WHEN I can declare with an index to a specific object in the array e.g. data.VerticalMeasurement[2] { "kind": "Unit", "name": "ft", "persistableReference": "{"abcd":{"a":0.0,"b":0.3048,"c":1.0,"d":0.0},"symbol":"ft","baseMeasurement":{"ancestry":"L","type":"UM"},"type":"UAD"}", "unitOfMeasureID": "partition-id:reference-data--UnitOfMeasure:ft:", "propertyNames": [ "VerticalMeasurement.VerticalMeasurement", "Markers[0].MarkerMeasuredDepth", "Markers[2].MarkerMeasuredDepth", "Markers[].PositiveVerticalDelta", "Markers[].NegativeVerticalDelta" ] }, { "kind": "Unit", "name": "yd", "PersistableReference": "{"abcd":{"a":0.0,"b":0.9144,"c":1.0,"d":0.0},"symbol":"yd","baseMeasurement":{"ancestry":"L","type":"UM"},"type":"UAD"}", "unitOfMeasureID": "partition-id:reference-data--UnitOfMeasure:yd:", "propertyNames": [ "Markers[1].MarkerMeasuredDepth" ] },
THEN it only converts the object indexes declared (see attachment for expected result in Work product component 'normalized' example)
GIVEN an embedded FOR for an array of objects WHEN I can declare the same FOR multiple times for the same object e.g.
{ "kind": "Unit", "name": "rad", "persistableReference": "{"abcd":{"a":0.0,"b":1.0,"c":1.0,"d":0.0},"symbol":"rad","baseMeasurement":{"ancestry":"A","type":"UM"},"type":"UAD"}", "unitOfMeasureID": "namespace:reference-data--UnitOfMeasure:rad:", "propertyNames": [ "Markers[].SurfaceDipAngle" ] }}{ "kind": "Unit", "name": "rad", "persistableReference": "{"abcd":{"a":0.0,"b":1.0,"c":1.0,"d":0.0},"symbol":"rad","baseMeasurement":{"ancestry":"A","type":"UM"},"type":"UAD"}", "unitOfMeasureID": "namespace:reference-data--UnitOfMeasure:rad:", "propertyNames": [ "Markers[2].SurfaceDipAngle" ] }} Then last conversion declared wins meaning all objects in first declaration get converted to the initial FOR and the object[2] gets converted in another FOR