Last Updated:

Context Patterns and Incoming Relationships

Andy Lapping Tip

Context Patterns are incredibly useful in Rhapsody. You can use them in searches, queries and table views and even to describe new browser definitions. If you havent used them before then checkout the links at the bottom of this page.

 Obtaining Incoming Relationships

Usually a context pattern traverse the model in a 'forward' or 'down the tree' direction. For example:

 

The context pattern Package,{view}View,{dep}Dependency: would give us the View(s) and the elements that they have dependencies to. But what if we wanted incoming dependencies instead ?

The help documentation mentions a to: relation, but it doesn't mention that there is in fact a from: relation as well. Combine that with rhapsody references and you can get incoming dependencies. Lets build that up (its always best to build and test context patterns as you go)

 

Get the Blocks from Packages:

Package,{blk}Block

Get the References of the Blocks:

Package,{blk}Block,{ref}references:

Filter on Dependencies:

Package,{blk}Block,{ref}references:.metaclass(Dependency)

Get the Element at the from end of the dependency:

Package,{blk}Block,{ref}references:.metaclass(Dependency),{view}from:

If you wanted to make sure you only got <<import>> dependencies you could add that too:

Package,{blk}Block,{ref}references:.metaclass(Dependency).stereotype(import),{view}from:

 Useful Links

Context Patterns in Tables

Sample Model from the Above Video

Combining Context Patterns and Java 

Allocation Tables (including a context pattern)

Context Patterns and tables Views