|
|
Context Patterns |
A context pattern is a method that describes a path through elements in the model. This might be ownership, relations, dependencies, or anything else.

Context patterns are used in various places in Rhapsody, including Queries and Table Views.
A context pattern is a set of comma-separated token expressions (tokens*). Patterns are either search-based patterns (used in queries) or table-based patterns (used in table layouts). The only real difference in the pattern is that table-based patterns also contain names for the tokens (surrounded by curly braces) that may then be used in table layout columns. For example, a search-based pattern that looked for a Project, then any top-level packages, then any use cases in those packages would look like this:
Project,Package,UseCase
The same pattern used in a table might look like this:
Project,{pkg}Package,{uc}UseCase
Note that the name is optional. In the pattern above, Rhapsody would try to match Project as part of the search, but that token would not be available for use in the table layout. Rhapsody table layouts have a convenient button to automatically populate columns based on the token names in the layout (this button is only visible if the layout has a context pattern):
*A basic token is either a metaclass or a new term stereotype. Also (although this is undocumented in Rhapsody) you may use ModelElement as a token (which matches any model element or any type).
An important point to note is that patterns used by Queries in Rhapsody do not need the Project token – in fact if the pattern starts with Project, then the query will return nothing. This is not true of table patterns. Recursion is discussed in more detail in another section, but a useful tip is to start the pattern with Project* - the * basically means ‘this might be there, or it might not’ (see Occurrence)
Context Pattern concepts are explained in the sections below: