The UML model

 

The OCL rules

--
-- OCL22SQL test and demonstration constraints
--
-- Part of Dresden OCL Tookit, see LICENSE for license terms.
-- (c) 2005 Florian Heidenreich <mail@fheidenreich.de>
--
--
-- Use this constraint file with model university_example.xmi
--

package Uni

/*
* The academic grade of a persons supervisor must be greater
* than the academic grade of the supervised person.
*
* Used patterns: BASIC TYPE, NAVIGATION, CLASS AND ATTRIBUTE
*/

context Person
inv tudOclInv1: self.supervisor.grade.value > self.grade.value


/*
* The academic grade of a students supervisor must be greater
* than the academic grade of the supervised person.
*
* Used patterns: BASIC TYPE, NAVIGATION, CLASS AND ATTRIBUTE
*/

context Student
inv tudOclInv2: self.supervisor.grade.value > self.grade.value


/*
* The tax class of an employee depends on the academic grade
* of the employee
*
* Used patterns: BASIC TYPE, NAVIGATION, CLASS AND ATTRIBUTE
*/

context Employee
inv tudOclInv3: ((self.grade.name = 'diploma') implies (self.taxClass = 'tc1'))
and ((self.grade.name = 'doctor') implies (self.taxClass = 'tc2'))
and ((self.grade.name = 'professor') implies (self.taxClass = 'tc3'))

endpackage