You can inspect, add, and remove tagged values across many model elements with the Model Debugger; this page is for MDriven Designer users who need to correct or standardize tags in an existing model.
Tagged values (also called TVs) are UML metadata extensions: a tag name and a value attached to a model element. Use the Model Debugger when you need to audit or change many elements at once. For editing tags on an individual element, use the tag editor described in Documentation:Tagged values in the Designer.
Before you change tags
The model is itself an MDriven model, so the Model Debugger lets you query and change its meta-model. Read Documentation:Using the model debugger to change the model itself before making bulk changes.
- In MDriven Designer, right-click in the relevant location.
- Select Extras, then select Open Model Debugger....
- Run a read-only OCL query first to see exactly which elements match.
- Review the returned elements. Use the debugger's step functionality if you need to understand how an expression proceeds.
- Run the corresponding EAL update only when the query result has the intended scope.
- Validate the model with the green check mark after each update. If validation reports errors, investigate them before continuing; see Documentation:Check model error.
Do not use a bulk expression as a substitute for understanding the tag. A tag can affect generated code, UI behavior, or other model processing. For tags defined through tag extensions, confirm the applicable element type and allowed values in Documentation:Catching more information in your model.
Meta-model names used in the expressions
The expressions operate on the MDriven meta-model, not on your application classes directly.
| Your model concept | Meta-model type in these expressions | Example |
|---|---|---|
| ViewModel | Span
|
Find ViewModels tagged MVC.
|
| Association end | AssociationEnd
|
Add a deletion-rule tag to association ends. |
| A tag attached to an element | TaggedValue
|
Read Tag and Value, or create a new tagged value.
|
Gotcha: ViewModels are named Span in the meta-model. Therefore, use Span.allInstances, not a type named ViewModel, when querying ViewModels in the Model Debugger.
Find tagged elements
Start with a query. The following OCL finds every ViewModel that has a tag named MVC. It compares the tag name in uppercase, so it also finds tag names whose casing differs from MVC.
Span.allInstances->select(s | s.TaggedValue->select(tv | tv.Tag.toUpper='MVC')->notEmpty)
For example, run this before adding the MVC tag. The result shows the ViewModels that already have it, so you can confirm that the tag is used where you expect.
Add a tag to ViewModels that do not have it
The following EAL finds every ViewModel without an MVC tag and creates one with the value True. Existing ViewModels that already have a tag named MVC are excluded.
Span.allInstances->select(s | s.TaggedValue->select(tv | tv.Tag.toUpper='MVC')->isEmpty)->forEach(s |
let newtag = TaggedValue.Create in
(
newtag.Tag := 'MVC';
newtag.Value := 'True';
newtag.ModelElement := s
)
)
The update has three parts:
TaggedValue.Createcreates a new tagged-value object.newtag.Tagsets the tag name, hereMVC.newtag.Valuesets its value, hereTrue, andnewtag.ModelElementattaches it to the currentSpan.
After executing the update, run the query in Find tagged elements again. The result should now include the ViewModels to which the tag was added.
Add a deletion-rule tag to association ends
This EAL adds Eco.BusinessDeleteRule to every association end that does not already have that tag. It assigns the value NeedNotBeEmptyNoWarning.
AssociationEnd.allInstances->select(s | s.TaggedValue->select(tv | tv.Tag='Eco.BusinessDeleteRule')->isEmpty)->forEach(s |
let newtag = TaggedValue.Create in
(
newtag.Tag := 'Eco.BusinessDeleteRule';
newtag.Value := 'NeedNotBeEmptyNoWarning';
newtag.ModelElement := s
)
)
This expression deliberately tests for an existing tag before creating one. That avoids adding a second tagged value with the same tag name to an association end.
Remove a tagged value
To remove a tag, first use an OCL query to find the elements and tagged values that you intend to remove. Review the result in the Model Debugger, then manually alter or remove the matching tagged value there.
For example, begin by finding all ViewModels that have the MVC tag:
Span.allInstances->select(s | s.TaggedValue->select(tv | tv.Tag.toUpper='MVC')->notEmpty)
Use the result to inspect each matching element and remove the intended tagged value. This is appropriate when you need to remove a tag from a limited, reviewed set of elements. Validate the model when you are finished.
If you need a repeatable bulk-removal operation, first establish and test the required behavior in the Model Debugger on the specific tag and element type. Keep the query that identifies the target set and validate after the operation.
Choose the right editing method
| Need | Recommended method |
|---|---|
| Add, change, or remove a tag on one known element | Use the tagged-value editor in MDriven Designer. Refresh its wiki-based help when you need the current list of available Turnkey tags. |
| Find every use of a tag | Run an OCL query in the Model Debugger. |
| Add a known tag and value to every element missing it | Run a reviewed EAL expression in the Model Debugger, then validate. |
| Define your own typed tag and allowed value set | Use tag extensions rather than relying only on free-form tag names and values. |
