6. Relationships

Mapping validation can be used for checking that data has traveled correctly from source to target. Mapping validation takes a source file and a target file as input and compares values and structures in them according to mapping rules.

Mapping validation can be used for checking that data has travelled correctly from source to target. Mapping validation takes a source file and a target file as input and compares values and structures in them according to mapping rules.

In the picture below we have a source file structure on the left side and a target file structure on the right. The data from the highlighted fields of the source file should travel to the highlighted fields of the target file.

elements to be mapped

 

To be able to create a validation rule we need to create a relationship which can be used when writing rules between files. For this particular example we want to create a relationship between Header element of the source file and OriginalMessages of the target.

relationship to be created.png

 

The relationship takes the following information:

Name

HeaderToOriginalMessages

Context 1

HeaderType1

Context 1 name

SourceHeader

Context 2

OriginalMessageType1

Context 2 name

TargetOriginalMessages

Execute

SourceHeader.Id = TargetOriginalMessages.OriginalHeaderId

 

After the relationship is created a “virtual element” is created to both to the source and to the target. You can move from source to the target and vice versa by using the name of this virtual element which is defined in the relationship.

It kind of looks like in the picture below.  You could for example check if the value of the OriginalControlSum element in the target message matches with the value of ControlSum element in the source file.

Context: OriginalMessageType1

OCL rule: self.SourceHeader.ControlSum = self.OriginalControlSum

source_content_in_target.png