PAPYRUS
  Welcome  
  Papyrus 4 UML  
- Papyrus for MARTE  
- Papyrus for SysML  
- Papyrus for CCM  
- Papyrus for EAST-ADL  
- Papyrus Add-ins  
  Download  
  Model library  
  Documentation  
Team  
Licence  
Bug report  
FAQ  



How to use OCL constraints in Papyrus
  • Introduction
  • Declaring OCL constraint
  • Validating UML models
  • Author

  •  Introduction

    Papyrus provides facilities to write OCL constraint with a content assistant (code completion). OCL constraints declared in a profile may be evaluated on user models. This document illustrates these two features with a simple profile.

     Declaring OCL constraint

    We first create a simple profile named MyProfile. We create a Stereotype called MySubClass.

    To declare a constraint, we have to select the Constraints panel, then click on the red cross to add one constraint. The right part of this panel holds the constraint.

    The Level combo choice is to selecting the context of the OCL evaluation. M1 is for user model level, that's the legal way to write constraints (here a instance of the meta-class Stereotype). M2 is for the meta class of the current element (metaclass Stereotype).

    The following screenshot shows the choices proposed by the content assistor. We can call it by pressing Ctrl + Space.

    For this example, we create two constraints:

    • to check a tag value: self.aValue > 4
    • to check a naming convention: self.base_Class.name.substring(1,4)='Imp_'

     Validating UML models

    We create a simple UML model and apply our stereotype on the class named AClass.

    To validate this model, we have to switch to the UML editor, then right click on the model and select Validate OCL constraints defined in Stereotypes.

    Once done, a pop up menu shows the results. They are also reported in the Problem view.

    Note that constraints on Stereotype support inheritance mechanisms.


     Author

    François Lagarde (CEA LIST)

    Date: 2007/07/26


    papyrus - Last update : 26/07/2007 18:31:11 - Legal Notice
    © CEA 2003-2010 All Rights Reserved