Kevin Brightwell edited this page Aug 26, 2015 · 1 revision
Clone this wiki locally

Draft Manual Page - Tracing Associations

This is one of a set of Draft manual pages

This will describe the syntax and semantics an MOTL or Umple feature being developed.When we have agreed on it, we will move towards test cases, implmentation and formal manual pages.

Tracing Associations


Tracing an association in MOTL works in a manner very much the same as tracing attributes. But with a couple of key differences:

  • The name of the association to be traced is either the class at the 'other' end of the association or the role name (if this exists). If there are multiple associations to other classes, then a role name is required. A role name is also required for reflexive associations.

  • Tracing of setting (with the set keyword) means tracing any of the methods that can add or delete a link (i.e. set, add and remove methods).

  • The actual trigger for adding or removing a link can be in either end of a bi-directional association. The resulting trace would be the same.

  • If tracing directives are placed on the same association in the classes at both ends, then tracing occurs twice.

  • For a '1' or 0..1' end of an association, it is possible to trace an attribute of the association (as in OCL using the dot notation). In future this may be generalized to allow such references on many ends.

The same conditional, occurrence and timeline directives can be used as for attributes.

There is one new keyword for a condition: 'cardinality' in a condition refers to the cardinality of the 'other end' of the association. 'cardinality(assocname)' refers to the cardinality of the named association. The latter can be used in a condition when tracing attributes or state machines. Cardinality is the number of links of the association from the current object.


TBD - place here all relevant non-terminals each in double-square brackets.


class CourseSection
  1 -- * Registration;

  // Tracing a simple association with a named class
  // Will trace all create/remove/update/delete of links of both ends
  // Note that links are bidirectional; only one trace record will occur per change
  trace Registration;
class Registration;



class Company {
  1 -- * Person employee;

  // Tracing an association identified by role name
  trace employee;
class Person {}



class RegularFlight {}
class SpecificFlight {}
association {
  // Tracing a standalone association using the word trace alone
  // means tracing any change to it
  // if the class or role name at either end is specified, the result would be the same
  1 RegularFlight -- * SpecificFlight;



// This show how tracing can be performed on an association
class CourseSection {

  // Associations that will be used to demonstrate tracing
  1 -- * Registration registrants;
  * -- 1 Course;

  // trace the association when the number of students exceeds 20
  // refer to the association by role name
  trace registrants where cardinality > 20;

  // another trace of this association, using the class name
  trace Registration where cardinality == 0 record "no students";

  // tracing an attribute of an association
  trace Registration where Course.level == 4;

class Course {
  Integer level;

class Registration {

class Student {

  // Trace changes and accesses in grade for each registration
  trace get,set Registration.grade; 
  1 -- * Registration;