🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Practical expressions to get insights into your model content
This page was created by Wikiadmin on 2023-12-20. Last edited by Wikiadmin on 2026-07-29.

You can use these OCL queries in the MDriven Designer Model Debugger to inventory ViewModels and actions in your model and identify how they are used.

Before you start

The queries on this page inspect the MDriven model itself: its ViewModels, actions, columns, categories, and related metadata. They do not query your application data.

Run these expressions only in the MDriven Designer Model Debugger. In most places in MDriven Designer, right-click and choose Extras, then choose Open Model Debugger…. The debugger opens against the model terms, where you can execute OCL to find the metadata you need. See Documentation:Using the model debugger to change the model itself for the broader workflow, including changing model metadata.

A ViewModel is represented in these queries by a Span. An action is represented by AbstractAction. Each query begins with allinstances, which gets all instances of the specified meta-model type, then narrows or projects the result with collection operators.

For example, select(span|...) retains each span for which the condition is true, while collect(span|...) returns the selected details for each span. Learn the OCL syntax and collection operators in Learn OCL and Documentation:Turnkey session 7: Expressions.

Find ViewModels shown by actions

Use this query to list every ViewModel that has at least one action that shows it:

Span.allinstances->select(span|span.ShowByActions->notEmpty)->collect(span|span.Name,span.Class.Name,span.Category.Name,span.ShowByActions.ListPresentationTypedDetails->ascommalist,span.CodeComment)

The result collects these details for each ViewModel:

Result value What it tells you
span.Name The ViewModel name.
span.Class.Name The class associated with the ViewModel.
span.Category.Name The ViewModel category.
span.ShowByActions.ListPresentationTypedDetails->ascommalist A comma-separated description of the actions that show the ViewModel.
span.CodeComment The ViewModel code comment.

For example, use this inventory when you need to find which actions open a ViewModel before renaming it, changing its category, or reviewing its purpose.

Find actions that navigate to another view

Use this query to find actions with a BringUpViewModel value. These are actions that navigate to another ViewModel:

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 shows the action name and type, presentation details, menu group, and whether the destination ViewModel is configured as modal or as a pop-up. For example, filter this result visually by ViewModelIsModal when reviewing actions that open modal dialogs.

Find server-side ViewModels

Use this query to list ViewModels that are not shown by an action and have criteria for server-side execution:

Span.allinstances->select(span|span.ShowByActions->isempty and span.CriteriaForServerSideExecute->notempty) ->collect(span|span.Name,span.Class.Name,span.Category.Name,span.CodeComment)

The output includes the ViewModel name, associated class, category, and code comment. For example, this helps you locate server-side ViewModels that may not appear in an inventory based only on UI actions.

Find OpenDocument report templates

A ViewModel with an owned column named ReportFileName indicates a template for OpenDocument reports. Use this query to list those ViewModels and their report-file expressions:

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 fourth collected value is the Expression of the first owned column named ReportFileName. For example, use the result to find report templates when you know a report filename but do not know which ViewModel defines it.

Find actions that do not navigate

Use this query to find actions that do not bring up another ViewModel. These actions may perform other work, such as changing data:

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)

The result includes:

  • The action name and OCL type.
  • Presentation details and menu group.
  • The ViewModel context for a ContextAction.
  • The target class for a ClassAction.
  • The AreYouSureQuestion value, which identifies actions configured to request confirmation.

For example, use this query when auditing actions that change data so that you can review their context, target class, and confirmation question.

Adapt a query safely

  1. Run an original query first and inspect its result. This confirms that the relevant metadata exists in your model.
  2. Keep the initial allinstances type unchanged unless you intend to inspect a different meta-model type.
  3. Change the condition inside select to narrow the result. For example, add another Boolean condition with and when you need a smaller set.
  4. Change the values inside collect to return the fields you need. Keep a name field in the output so that you can identify each result.
  5. Use the Model Debugger result to locate the item in MDriven Designer before making model changes.

If you need a reusable UI for inspecting or exporting meta-model information, you can create ViewModels over the ExtendedModelLayer as described in Documentation:MDriven Designer and Modlr extensions–exporting data.

See also