Wednesday 8 August 2018

Rhapsody Tip #40 - Using context patterns to show a chain of elements in a table (Advanced)

I've reached video 40! This is an introduction to building table layouts with context patterns. Even simple tables in IBM Rational Rhapsody can be quite powerful. When we create a TableLayout, we can have each row represent a single element in the model, with each column displaying information about that element. We can also build relation tables, where the row represents a relationship between two elements. Alternatively, we can have a row in the table represent a hierarchy of elements in the model. To build a chain of elements as a table row, we can use a more advanced concept called a context pattern.

A context pattern is a comma-separated list of tokens. It is a way to describe a path of elements in the model. Each token in the pattern is a Rational Rhapsody metatype name that is either a core type or a term. This short video shows building a table that shows how blocks relate to safety goals which relate to hazards (new term types I've added to Rhapsody in a profile). The key tip is to know that to navigate to the end of a relation type you can put a colon (:). This, for example, allows us to traverse the relatesTo dependency to find the Hazard. The text in the curley brackets is a unique name for the context, weI can select the context in the Columns list for this. A couple of other options are also shown, such as collapsing the first column, changing the order, and using the Fill Defaults button. Enjoy!


  1. Is it possible to write a context pattern that will traverse dependencies in the direction opposite to that shown in your video, i.e. show what elements depend on an element (line 1) rather than the elements the element depends on (line 2)?

    1. StartElement <- DependentElement

    2. StartElement -> ElementDependedOn

    For the problem I am working on, I need to generate a table with column 1 listing all requirements in a particular package. Column 2 would list model elements that refine a requirement. Each new refine dependency would be on a separate row. If a requirement has no elements refining it, I just want the requirement listed in column 1 and a blank cell in column 2.

    1. Actually it is:

  2. You can order the columns differently to the order of the traversed dependency (or choose not to show info). Would that work for you?


Note: only a member of this blog may post a comment.