(Created page with "Derivation is when you provide an ocl expression in the definition of an Attribute of AssociationEnd. This expression is then the definition of the content of this object memb...")
Derivation is when you provide an ocl expression in the definition of an Attribute of AssociationEnd. This expression is then the definition of the content of this object member.
<message>Write the content here to display this box</message>
Reverse derivation is when you use code (EAL) to process a composite value into separate parts when updating.
Derivations are very powerful and remove the need for repeating definitions multiple times.
Please see [[Documentation:Derived settable attributes|Derived settable attributes]] for further explanation.
[[Category:Derivations]]
Example; a person has a given name and a surname but I often want to display them together as Fullname.
The only snag with this is that Full Name show up as read only. Read only is a consequence of being derived.
This is where '''Reverse Derivation''' comes into play. If I want the Full Name to be editable I will need to parse the result and split it into a Given Name and a Surname. For this parsing I will need some logic.
I can change the AttributeMode from Derived to DerivedSettable:
let parts=vInputParameter.Split(' '.ToCharArray().At0(0)) in
(
self.GivenName:=parts.At0(0);
self.Surname:=parts.At0(1)
)
The value the user supplies comes in the vInputParameter. I split this on blank-character (slit expects a char and ocl deals with strings so I convert the string to an array of chars and grab the first one). I now have a collection of hopefully 2 strings – one I assign to GivenName and one I assign to Surname.
The FullName is editable – and when a user changes it – the set-expression is executed – that in turn updates the parts that build up the FullName – that then is re-derived and gets updated.
This works on attributes – not derived associations.
Latest revision as of 05:28, 22 January 2025
This page was created by Alexandra on 2018-10-17. Last edited by Stephanie@mdriven.net on 2025-01-22.
Reverse derivation is when you use code (EAL) to process a composite value into separate parts when updating.