I want to evaluate constraints in both UML class diagram and Complete OCL file. I searched but I only found examples where the methods are in the same class. Below is an example of an UML diagram class about which I have the following questions:
How to define Context and Operations (parameters/arguments), since both are in other class, according class diagram above ?
How to navigate between both classes in OCL complete file ?
Does the OCL Complete file allow the use of commands: def, let, if-then-else, etc. ?
Thanks in advance.
UML does not support Collections or Maps. Rather it has multiplicities and qualified associations. For the usual common cases it is sufficient to specify an unlimited upper bound, and unique and ordered polarities to configure the UML multiplicity of a Bag/OrderedSet/Sequence/Set for OCL.
UML supports templates but OMG OCL does not, although OMG OCL is aligned to UML. Rather OMG OCL has magic "T" and "T1" types that looks remarkably like template parameters without being defined as such. The Pivot-based Eclipse OCL that prototypes solutions to many OMG OCL problems implements templates and so allows a UML user to define a DataType property whose type templates the relevant collection/map type from the Eclipse OCL Standard Library.
For flat collections using the library type is just an alternative approach. For nested collections, that UML does not support, using the DataType to define all or all but one levels of nesting is the only option.
(Papyrus uses the Pivot-based Eclipse OCL.)
Complete OCL should work normally; UML multiplicities are converted to/interpreted as OCL collection types. In the Pivot-based Eclipse OCL there is a legacy syntax that uses () to reference e.g. Set(MyClass) but a novel/familiar <> to declare e.g. MyAggregate<E>
.