There are many public videos and PDF slides on various aspects of this topic offered by other SysML educators, but wading through them to find a solution to a particular task can be extremely time consuming and inefficient.
This trail progressively collates for your convenience solutions to clearly stated common query tasks required to create Derived Properties for use in columns in query view tables (such as Generic Table Diagrams) and elsewhere.
Each slide in this trail shows a Derived Property solution for a particular mini model for you to adapt; some of them require one or more supporting reusable OpaqueBehaviors defined in the model, typically used in a Structured Expression via Operation From Model in the Expression Editor.
Note that once a Derived Property is defined for a particular element type it will be accessible by name also in the RHS of each Metachain Navigation step, as well as via the Traceability section of the spec dialog for corresponding model elements.
Note also that there is a difference between creating a mere Custom Column that is only available for particular table and a Derived Property on a column, which becomes available model wide.
You can access and extract just about any information from the model using custom scripting against the MagicDraw/Cameo Java API, but it is not always the most convenient way to do it, and requires knowledge of the quite complex Java API. Wherever possible, solutions requiring no or minimal custom scripting are offered here. Note also that there are often many different solutions to accessing model info for a given task, not every possible solution is shown, just at least one practical solution for each stated task.
The examples in this slide use the following prefix naming conventions for derived properties:
- DP = A Derived Property (with unspecified implementation strategy)
- DPSN = A Derived Property that uses Simple Navigation
- DPMN = A Derived Property that uses Metachain Navigation
- DPS = A Derived Property that uses a Custom Script
- DPSG = A Derived Property that uses a Custom Script with Groovy
- DPSO = A Derived Property that uses a Custom Script with OCL
- DPSJ = A Derived Property that uses a Custom Script with JavaScript Rhino
- DPF = A Derived Property that uses a Filter
- DPU = A Derived Property that uses a Union
- DPE = A Derived Property that uses an Exclude
- DPIR = A Derived Property that uses an Implied Relation
- DPTT = A Derived Property that uses a Type Test
- DPPT = A Derived Property that uses a Property Test
- DPOFM = A Derived Property that uses a Property Test
- DPR = A Derived Property that uses recursion
- DPN = A Derived Property that uses nesting
The above may also be combined for complex cases. Note also that the display of a Derived Property name uses tool-specific parsing of the actual name, and may not display on column names exactly as you entered it in creation of the Derived Property.