|
|
(5 intermediate revisions by 3 users not shown) |
Line 1: |
Line 1: |
| 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.
| | 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 [[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.
| | {{Edited|July|12|2024}} |
| | |
| [[File:Reverse derivation - 1.png|frameless]] | |
| | |
| [[File:Reverse derivation - 2.png|frameless|440x440px]]
| |
| | |
| [[File:Reverse derivation - 4.png|frameless|439x439px]] | |
| | |
| And it will give me this:
| |
| | |
| [[File:Reverse derivation - 5.png|frameless|434x434px]]
| |
| | |
| 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:
| |
| | |
| [[File:Reverse derivation - 6.png|frameless|424x424px]]
| |
| | |
| When I do a new property shows up DerivationOclSet. This ocl is written in EAL(Action language) and can change data (have side effects).
| |
| | |
| I will implement the string parsing of the FullName like this:
| |
| | |
| [[File:Reverse derivation - 7.png|frameless|422x422px]]
| |
| | |
| here comes the same EAL as text:
| |
| 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.
| |
| | |
| It will give med this:
| |
| | |
| [[File:Reverse derivation - 8.gif|frameless|336x336px]]
| |
| | |
| 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.
| |