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.
Difference between revisions of "Papyrus/UserGuide/Profile Constraints"
(→How to) |
|||
Line 21: | Line 21: | ||
*1. Select the UML Profile element in the Model Explorer | *1. Select the UML Profile element in the Model Explorer | ||
− | *2. Select the Profile tab in the | + | *2. Select the Profile tab in the Properties View |
− | *3. Click on the registered profile button | + | *3. Click on the "Apply registered profile" button |
*4. Select the "DSML Validation" profile | *4. Select the "DSML Validation" profile | ||
Line 29: | Line 29: | ||
<center> | <center> | ||
[[Image:PapyrusDSML-profileApplication.png]]<br> | [[Image:PapyrusDSML-profileApplication.png]]<br> | ||
− | + | Applying the DSML Validation Profile | |
</center> | </center> | ||
− | *5. Select the | + | *5. Select the UML Constraint element in the Model Explorer or diagram |
− | *6. Select the | + | *6. Select the Profile tab of the Properties View |
− | *7. Click on the | + | *7. Click on the "Apply stereotype" button |
*8. Select the ValidationRule stereotype | *8. Select the ValidationRule stereotype | ||
Line 42: | Line 42: | ||
<center> | <center> | ||
[[Image:PapyrusDSML-stereotypeApplication.png]]<br> | [[Image:PapyrusDSML-stereotypeApplication.png]]<br> | ||
− | + | Applying the ValidationRule Stereotype | |
</center> | </center> | ||
− | *9. Edit stereotype | + | *9. Edit the stereotype properties to define information about the behavior of the validation |
<center> | <center> | ||
[[Image:PapyrusDSML-AnnotationEdition.png]]<br> | [[Image:PapyrusDSML-AnnotationEdition.png]]<br> | ||
− | Edit DSML | + | Edit DSML Stereotype Properties<br/> |
</center> | </center> | ||
− | |||
− | |||
= Generation from Constraints = | = Generation from Constraints = | ||
Line 62: | Line 60: | ||
Constraints expressed in OCL can be validated directly in the tool. This is not the case for Java constraints which must be placed in a suitable plugin. However, Papyrus supports the generation of this plugin. | Constraints expressed in OCL can be validated directly in the tool. This is not the case for Java constraints which must be placed in a suitable plugin. However, Papyrus supports the generation of this plugin. | ||
− | ==Generate constraints directly into the definition== | + | ==Generate constraints directly into the profile definition== |
− | Constraints written in OCL within | + | Constraints written in OCL within a UML Profile can be generated into the definition of the profile and read during the validation of the model to which the profile is applied. |
− | + | How to embed the constraint definitions into a UML Profile: | |
− | + | ||
− | + | *1. Save the profile | |
+ | *2. Papyrus asks to you if "Would you like to define it" (the profile), select Yes | ||
+ | *3. Ensure "Save OCL constraint in the definition" is selected (the box is checked by default in later versions of Papyrus)<br/> | ||
<center> | <center> | ||
[[image:PapyrusDSML-ConstraintDefinition.png]]<br> | [[image:PapyrusDSML-ConstraintDefinition.png]]<br> | ||
− | Save OCL | + | Save OCL Constraints in the Profile Definition |
</center> | </center> | ||
==Generate constraints as EMF validation plugins== | ==Generate constraints as EMF validation plugins== | ||
− | The user can generate plugins that wrap | + | The user can generate plugins that wrap constraints and can be used in the EMF plugin validation.<br> |
The constraint can be generated in Java code, or directly from OCL.<br> | The constraint can be generated in Java code, or directly from OCL.<br> | ||
− | + | How to embed the generate constraints into a plugin: | |
− | Select the UML Profile element in the Model Explorer | + | |
+ | *1. Select the UML Profile element in the Model Explorer | ||
+ | *2. Right click UML Profile element | ||
+ | *3. Select create validation plugin for this DSML from the context menu | ||
<center> | <center> | ||
− | Click right on the | + | Click right on the Model Explorer-> create validation plugin for this DSML<br> |
[[image:PapyrusDSML-PluginValidationGeneration.png]]<br/> | [[image:PapyrusDSML-PluginValidationGeneration.png]]<br/> | ||
</center> | </center> |
Revision as of 05:00, 20 May 2014
Contents
Validate OCL Constraints of a Profile
Papyrus supports an additional profile for defining Domain Specific Modeling Languages (DSML) that refines how constraints are validated. The additional profile enables a more precise specification of validation properties, for example:
- Mode: Defines if the validation of the constraint is done in “batch” or “live” mode
- Severity: Defines the severity of the constraint violation. It can be one of INFORMATION, WARNING or ERROR. The latter is the default severity (if none is specified). 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.
- Message: Defines the message that will be displayed if the constraint is violated
- Description: Provides a description of the constraint
- Enabled by default: Defined if this constraint should be enabled by default or not
CAVEAT: The information added via the DSML profile is not currently taken into account during OCL validation. The support will be added soon.
Advanced users can also define:
- Id: The constraint id
- Status code: The plug-in unique status code, useful for logging.
- Target: The element to be validated
How to apply the DSML validation profile:
- 1. Select the UML Profile element in the Model Explorer
- 2. Select the Profile tab in the Properties View
- 3. Click on the "Apply registered profile" button
- 4. Select the "DSML Validation" profile
- 5. Select the UML Constraint element in the Model Explorer or diagram
- 6. Select the Profile tab of the Properties View
- 7. Click on the "Apply stereotype" button
- 8. Select the ValidationRule stereotype
- 9. Edit the stereotype properties to define information about the behavior of the validation
Generation from Constraints
Constraints expressed in OCL can be validated directly in the tool. This is not the case for Java constraints which must be placed in a suitable plugin. However, Papyrus supports the generation of this plugin.
Generate constraints directly into the profile definition
Constraints written in OCL within a UML Profile can be generated into the definition of the profile and read during the validation of the model to which the profile is applied.
How to embed the constraint definitions into a UML Profile:
- 1. Save the profile
- 2. Papyrus asks to you if "Would you like to define it" (the profile), select Yes
- 3. Ensure "Save OCL constraint in the definition" is selected (the box is checked by default in later versions of Papyrus)
Generate constraints as EMF validation plugins
The user can generate plugins that wrap constraints and can be used in the EMF plugin validation.
The constraint can be generated in Java code, or directly from OCL.
How to embed the generate constraints into a plugin:
- 1. Select the UML Profile element in the Model Explorer
- 2. Right click UML Profile element
- 3. Select create validation plugin for this DSML from the context menu
Click right on the Model Explorer-> create validation plugin for this DSML
Then a wizard to create the validation is launched. You have to give a name for you validation plugin.
Then you need to install the created plugin.