Case Studies

We provide two case studies for iOCL, which include 1) one publicly-open case study named RoyalAndLoyal case study and 2) one real world case study from Cancer Registry of Norway (CRN).

We design in total 10 constraints for the RoyalAndLoyal case study with the aim at illustrating how to use iOCL. Please download RoyalAndLoyal case study and try to specify constraints (shown as below) using iOCL.


# Context Type Operation Constraint
1 Membership Invariant ((self.currentLevel.name = 'Silver' ) implies ( self.card.color = RandLColor::silver ) and self.currentLevel.name = 'Gold' ) implies self.card.color = RandLColor::gold
2 Membership Invariant self.programs.partners->forAll(p | p.deliveredServices->forAll(d | d.pointsEarned = 0 )) implies self.account->isEmpty()
3 CustomerCard Invariant self.transactions->select(t | t.points > 100 ) ->notEmpty() = true
4 ProgramPartner Invariant self.programs->collect(pr | pr.participants ) ->asSet() ->size() = self.numberOfCustomers
5 LoyaltyAccount Invariant self.points > 0 implies self.transactions->exists(t | t.points > 0 )
6 Customer Invariant self.memberships->collect(me | me.account ) ->reject(ac | ac.points >= 0 ) ->isEmpty() = 1
7 Customer Invariant ( self.gender = Gender::male ) implies self.title = 'Mr'
8 TransactionReport Invariant self.lines->collect(l | l.date ) ->forAll(da | da.isBefore( self.until ) = true )
9 LoyaltyProgram Invariant self.memberships->collect(me | me.account ) ->isUnique(ac | ac.number )
10 LoyaltyProgram Operation Body getServices(pp : ProgramPartner ) : Set(Service) self.partners->collect(pa | pa.deliveredServices ) ->asSet()

The CRN case study includes one domain model, five model instances and in total 10 OCL constraints for specifying cancer coding rules (shown as below). Please download the CRN case study here.


# Context Type Constraint
1 CancerMessage Invariant (self.morfology = '720039' or self.morfology = '730039') implies self.basis = 98
2 CancerMessage Invariant self.topography = '420' implies (self.basis = 33 or self.basis = 38 or self.basis = 45 or self.basis = 47)
3 CancerMessage Invariant (self.surgery = 35 or self.surgery = 7 or self.surgery = 9) implies (self.messageType = 'H' or self.messageType = 'K' or self.messageType = 'R')
4 CancerMessage Invariant (self.surgery = 7 and self.messageType = 'H') implies (self.basis = 60 or self.basis = 98)
5 CancerMessage Invariant ( (self.basis=45 or self.basis = 46 or self.basis = 47) implies self.surgery = 99 ) and (self.basis = 2 implies self.surgery <> 10)
6 CancerCase Invariant (self.morfology = '7400.09' or self.morfology = '7405.09' or self.morfology = '7410.09') implies (self.surgery = 1 or self.surgery = 2 or self.surgery = 7 or self.surgery = 10)
7 CancerCase Invariant self.basis = 33 implies (self.topography = '42.0' or self.topography = '421')
8 CancerCase Invariant self.surgery = 17 or self.surgery = 18 or self.surgery = 29 implies self.gender = GenderType::Female
9 CancerCase Invariant (self.topography = 'C70' or self.topography = 'C71' or self.topography = 'C72') implies self.surgery <>1
10 CancerCase Invariant self.surgery = 14 implies (self.topography = '619' or self.topography = '67X' or self.topography = '73X')