- Practical expressions to get insights into your model content
Use these OCL expressions in the **MDriven Designer Model Debugger** to inventory ViewModels and actions in your model, identify navigation behavior, and find report templates.
> **Scope:** The expressions on this page can only be executed in the **MDriven Designer Model Debugger**. They inspect the MDriven model itself; they are not expressions for a runtime application ViewModel.
- Before you start
A **ViewModel** is a transformation of part of your model into a view that can be presented as a user interface. An **action** is model behavior that a user can invoke from a ViewModel. These expressions query the model definitions for those ViewModels and actions.
To open the Model Debugger:
1. In MDriven Designer, right-click in an applicable location. 2. Select **Extras**. 3. Select **Open Model Debugger…**. 4. Enter one expression from this page and execute it.
For more information about opening the debugger and using it to inspect or alter the model, see Documentation:Using the model debugger to change the model itself.
- Read the expression pattern
The expressions use OCL (Object Constraint Language) to query model metadata:
- `allinstances` starts with every instance of a model-meta class, such as every `Span` or `AbstractAction`. - `select(x|condition)` filters that collection. - `collect(x|...)` returns the fields you want to inspect. - `notEmpty` and `isEmpty` test whether an association or value contains anything.
For example, `Span.allinstances` starts with every `Span` in the model. The first query below filters that set to spans with at least one show action, then returns the name, class, category, action details, and comment for each matching span.
- ViewModels exposed by actions
Use this query to find every ViewModel that has at least one action that shows it:
```ocl Span.allinstances->select(span|span.ShowByActions->notEmpty)->collect(span|span.Name,span.Class.Name,span.Category.Name,span.ShowByActions.ListPresentationTypedDetails->ascommalist,span.CodeComment) ```
This returns the following information for each matching ViewModel:
| Returned value | Use it to understand | |---|---| | `span.Name` | The ViewModel name. | | `span.Class.Name` | The model class associated with the ViewModel. | | `span.Category.Name` | The ViewModel category. | | `span.ShowByActions.ListPresentationTypedDetails->ascommalist` | The actions that show the ViewModel, rendered as a comma-separated list. | | `span.CodeComment` | Documentation or notes stored with the ViewModel. |
- Example use:** Run this before reorganizing menus. You can see which ViewModels are reachable through actions and identify ViewModels that lack useful comments.
- Actions that navigate to another ViewModel
Use this query to find actions that bring up another ViewModel:
```ocl AbstractAction.allinstances->select(aa|aa.BringUpViewModel->notEmpty)->collect(aa|aa.Name,aa.OclType.asstring,aa.ListPresentationTypedDetails,aa.MenuGroup.Name,aa.ViewModelIsModal,aa.ViewModelIsPopUp) ```
The result includes the action name and type, its presentation details, menu group, and whether the target ViewModel is configured as modal or as a pop-up.
| Returned value | Use it to understand | |---|---| | `aa.Name` | The action name. | | `aa.OclType.asstring` | The action type as text. | | `aa.ListPresentationTypedDetails` | How the action is presented. | | `aa.MenuGroup.Name` | The menu group containing the action. | | `aa.ViewModelIsModal` | Whether the ViewModel is opened modally. | | `aa.ViewModelIsPopUp` | Whether the ViewModel is opened as a pop-up. |
- Example use:** Review this list when standardizing navigation. Filter your results by inspecting the modal and pop-up values to find actions that open views differently from the rest of the application.
- Server-side ViewModels
Use this query to find ViewModels intended for server-side execution:
```ocl Span.allinstances->select(span|span.ShowByActions->isempty and span.CriteriaForServerSideExecute->notempty) ->collect(span|span.Name,span.Class.Name,span.Category.Name,span.CodeComment) ```
A matching ViewModel has no actions that show it (`ShowByActions` is empty) and has a non-empty `CriteriaForServerSideExecute`.
- Example use:** Run this when documenting processing that is not opened by a user action. The output gives you the ViewModel name, associated class, category, and its code comment.
- OpenDocument report templates
Use this query to find ViewModels with a `ReportFileName` column. That column indicates that the ViewModel is a template for an OpenDocument report:
```ocl Span.allinstances->select(span|span.OwnedColumns->exists(c|c.Name='ReportFileName')) ->collect(span|span.Name,span.Class.Name,span.Category.Name,span.OwnedColumns->select(c|c.Name='ReportFileName')->first.Expression,span.CodeComment) ```
The query returns the ViewModel identity, the expression of its `ReportFileName` column, and its code comment.
- Example use:** Use this inventory before updating report templates. It identifies each ViewModel that carries the report-file-name convention and shows the configured expression for that column.
- Actions that do not navigate
Use this query to find actions that do not bring up another ViewModel. These actions can perform other work, such as changing data:
```ocl AbstractAction.allinstances->select(aa|aa.BringUpViewModel->isEmpty)->collect(aa|aa.Name,aa.OclType.asstring,aa.ListPresentationTypedDetails,aa.MenuGroup.Name,aa->safecast(ContextAction).ViewModelContext.Name,aa->safecast(ClassAction).ClassToPerformActionOn.Name,aa.AreYouSureQuestion) ```
This output is useful for reviewing behavior-oriented actions separately from navigation actions.
| Returned value | Use it to understand | |---|---| | `aa.Name` | The action name. | | `aa.OclType.asstring` | The action type. | | `aa.ListPresentationTypedDetails` | The action presentation details. | | `aa.MenuGroup.Name` | The action menu group. | | `aa->safecast(ContextAction).ViewModelContext.Name` | The ViewModel context when the action is a `ContextAction`. | | `aa->safecast(ClassAction).ClassToPerformActionOn.Name` | The target class when the action is a `ClassAction`. | | `aa.AreYouSureQuestion` | The confirmation question configured for the action. |
`safeCast` lets one query return properties that apply to different action kinds. For example, a context action can provide a ViewModel context, while a class action can provide the class on which it performs its action.
- Example use:** Review this list before a release to identify data-changing actions and check whether actions that need confirmation have an `AreYouSureQuestion`.
- Use the results as model documentation
These queries are most useful when you turn their results into reviewable model knowledge:
1. Run the ViewModel query to identify user-reachable views. 2. Run the navigation-action query to understand how users move between views. 3. Run the non-navigation-action query to review actions that change data or perform other work. 4. Run the server-side and report-template queries to document behavior that may not be visible from ordinary navigation. 5. Use `CodeComment` results to find model elements that need clearer documentation.
Keep queries focused on inspection. If you need to change the model through the debugger, follow Documentation:Using the model debugger to change the model itself.
- Related documentation
- Documentation:Using the model debugger to change the model itself — Open the Model Debugger and use it to inspect or alter model metadata. - Documentation:Designer — MDriven Designer documentation and modeling topics. - MDriven Core Concepts — Definitions of MDriven Designer and ViewModels. - Training:Certain important constructs — OCL and EAL concepts, including query methods. - Documentation:PSExpression , or how to do things in the DB from MDriven — Database-oriented PSExpression functionality; this is separate from Model Debugger inspection expressions. - Training:Seeker view — Database-backed OCL criteria used for seeker searches; this is separate from queries against the model itself.
