Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Papyrus/UserGuide/Profile Constraints

< Papyrus
Revision as of 07:08, 23 July 2013 by Cletavernier.eclipsesource.com (Talk | contribs) (Copy of the Profile Constraint documentation embedded in Papyrus 0.10.0)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

In order to validate constraints from a profile, first creation of constraint with specific annotations will be explained and then generation of validation will be explained.
File:ConstraintCreationUseCase.png
Figure 1: Constraint creation

Create a constraint

In the context of the construction of a profile, it is possible to add constraints.
A constraint is a condition or restriction expressed in a language for the purpose of declaring some of the semantics of an element.

How to

In the context of a profile diagram you can create a constraint from the palette.

File:DiagramConstraintCreation.png 

Figure 2: Constraint creation from the palette
From the model explorer, click right --> new child--> Create a new Constraint

 File:MEConstraintCreation.png

Figure 3: Constraint creation from the model explorer

Specify the context

Before editing a constraint, it is important to specify the constraint; it can be a stereotype, an operation.

How to

From the diagram, a context link can be added between the constraints and the context of the constraint:

File:DiagramContextLink.png

Figure 4: Context link creation in a the profile diagram

From the property view, the context can be specified:

File:PropertyviewContextlink.png

Figure 5: specify context from the property view

Specify the language

It is possible to precise the language of the constraint into Papyrus. The constraint body may be written into OCL, JAVA, or natural language.
In order to make constraints usable by the Papyrus, constraint must be written in OCL or JAVA.

How to

By default if your try to edit a constraint, default language will be OCL.
At the creation, after set the context, you can choose the editor for the constraint:

ConstraintEdition.png

Figure 6: choose the editor for the constraint
You can also specify the language in the property view:

  • Select the field specification and choose create or edit the associated opaque expression:
File:SpecificationCreation.png

Figure 7: creation of a specification for the constraint
You can add the language, see following figure:
File:OpaqueExpressionCreation.png
Figure 8: specify the language
Then if you want you write the body in the specified language:

File:FillOpaqueExpression.png

Figure 9: Write the body of the opaque expression

Specify the behavior of the constraint in the context of validation

Into Papyrus, the behavior of the constraint during the validation can be precise.
It is possible to precise:

  • The mode, if the validation of the constraint can be done, in t “batch” or “live” mode.
  • The severity: The severity of the problem if the constraint is violated. This correlates to the severity of tasks in the Tasks view of the Eclipse environment. The default severity (if none specified) is ERROR. The CANCEL severity should be used with caution, as it causes the validation operation to be interrupted, possibly resulting in the loss of valuable diagnostic information from other constraints.
  • The message: the message that will be displayed if the constraints is violated
  • The description: a description of the constraint
  • If it is enable by default: Indicates if this constraint should be enabled by default.

For advanced user you can also precise:

  • The Id : the constraint id
  • The status code: The plug-in unique status code, useful for logging.
  • the target of validation, the element to be validated

How to

Apply the DSML validation profile

  • 1. Select the profile root and apply the profile
  • 2. Select the profile tab in the property view
  • 3. Click on the registered profile button
  • 4. Selection the DSML validation profile
 File:DSMLprofileApplication.png

Figure 10: apply DSML profile
Apply Stereotype on constraint

  • 1. Select the constraint
  • 2. Select profile tab of the property view
  • 3. Click on apply profile button
  • 4. Select validationRule stereotype
 File:StereotypeApplication.png

Figure 11: Apply validationRule stereotype
Then you can edit property of stereotype to add information about the behavior of the validation

File:AnnotationEdition.png

Figure 12: edition of the property of stereotype


Generation from Constraints

File:UseCaseGeneration.png

Figure 13: Constraint generation

Generate constraints directly into the definition

Constraint written in OCL in the profile can be generated into the definition of the profile and taken in charge during the validation of the model.

How to

When you save the profile,Papyrus asks to you if want to define the profile.
Click on yes and then do not forget to check save OCL constraint in the definition

 File:ConstraintDefinition.png

Figure 14: save OCL constraints in the definition

Generate constraints as EMF validation plugins

The user can generate plugins that wrap constraint and can be used in the EMF plugin validation.
The constraint can be generated in Java code, or directly from OCL.

How to

Select the root profile
Click right on the model explorer-> create validation plugin for this DSML

File:PluginValidationGeneration.png


Then a wizard to create the validation is launched. You have to give a name for you validation plugin.

 File:Pluginwizard.png

Figure 15: wizard of constraint validation creation
The you need to install the created plugin.

Back to the top