uOttawaUniversity of Ottawa - Canadas University
list of dots

Umple User Manual    [Previous]   [Next]   

Loading

Tracing Constraints

Constraints can be imposed upon the traced UML entity to limit the scope of tracing to when a certain condition is true. MOTL provides a set of constraints that can be classified into a prefix and postfix constraints.

  • Condition
    Conditions consist of a left hand side, Boolean operator and a right hand side. Either side can refer to a UML attribute, role name, state, state value or constant. PreConditions are evaluated prior to the operation being traced, while PostConditions are the opposite.
  • Number of Occurrences
    Trace will be recorded for a specific number of appearances, then tracing stops.
  • Record clause
    Record clause postfix gives the flexibility to record another model element or a specific string.
  • Life Timeline
    There are two cases. (1) trace the UML construct from its creation and stop when the trace condition is satisfied. (2) Tracing will begin only after the trace condition is satisfied and will then continue nonstop.

Example

class Student
{
  name;
  Integer id;

  // trace code is injected in attribute setter with specified precondition
  trace name where [name == "john"];

  // trace code is injected in attribute setter with specified postcondition
  trace id giving [id > 9000];

  // this example traces attribute name whenever its value is changed for 5 times 
  trace name for 5;
}

class Professor {
  name;
  1 -- * Student supervisor;
  
  // trace code is injected in attribute setter with role name cardinality condition
  trace name where [ supervisor cardinality > 10];
}


      

Load the above code into UmpleOnline

 

Another Example

class Student
{
  name;
  Integer id;
  // trace attribute id and record provided string message as part of  the trace output
  trace id record "i am tracing attribute name";
  
  status {
    s1 { e1 -> s2; }
    s2 {}
  }
  // trace whenever we enter/exit state "s1" and record attribute name
  trace s1 record name;
}


      

Load the above code into UmpleOnline

 

Another Example

class Student
{
  name;
  Integer id;
  
  // tracing of attribute name starts and doesn't stop until condition becomes true
  trace name until [name == "john"];

  // tracing of attribute id until condition becomes true and then always continue tracing 
  trace id after [id == 234];
}


      

Load the above code into UmpleOnline

 

Syntax


traceCondition : [=conditionType:where|until|after|giving]? [ [[constraintToken]] ]

traceFor- : for [traceFor]

// A constraint is an expression optionally be surrounded in round brackets or negated
constraint- : [[constraintBody]] [[linkingOp]]? | [[constraintExpr]] [[linkingOp]]?