Calculated Collections (Profile)

Calculated collections define a read-only connection between an object instance and a group of other objects of the specified type. The logic of the collection is defined using VBScript.

Calculated collections, unlike extended collections (see Extended Collections and Compositions (Profile)) cannot be modified by the user.

You can create calculated collections to:
  • Display user-defined dependencies for a selected object. The calculated collection is displayed in the Dependencies tab of the object property sheet.

  • Fine-tune impact analysis by creating your own calculated collections in order to be able to better evaluate the impact of a change. For example, in a model where columns and domains can diverge, you can create a calculated collection on the domain metaclass that lists all the columns that use the domain and have identical data type.

  • Improve your reports. You can drag and drop any book or list item under any other report book and modify its default collection in order to document a specific aspect of the model (see Core Features Guide > Storing, Sharing and Reporting on Models > Reports > The Report Editor > Adding Items to a Report > Modifying the Collection of an Item).

  • Improve GTL generation since you can loop on user-defined calculated collections.

For example, in an OOM, you may need to create a list of sequence diagrams using an operation, and can create a calculated collection on the operation metaclass that retrieves this information. In a BPM, you could create a calculated collection on the process metaclass that lists the CDM entities created from data associated with the process.

  1. Right-click a metaclass, stereotype, or criterion and select New > Calculated Collection.
  2. Enter the following properties as appropriate:

    Property

    Description

    Name

    Specifies the name of the calculated collection for use in scripts.

    Label

    Specifies the display name of the collection, which will appear as the name of the tab associated with the collection in the parent object property sheet.

    Comment

    [optional] Describes the calculated collection.

    Target Type

    Specifies the metaclass whose instances will appear in the collection. The list displays only metaclasses that can be directly instantiated in the current model or package, such as classes or tables, and not sub-objects such as class attributes or table columns.

    Click the Select a Metaclass tool to the right of this field to choose a metaclass from another type of model.

    Target Stereotype

    [optional] Specifies a stereotype to filter the target type. You can select an existing stereotype from the list or enter a new one.

    List Columns

    Specifies the columns displayed by default on the collection property sheet tab.
  3. Click the Calculated Collection Script tab and enter a script that will calculate which objects will form the collection.

    If appropriate, you can reuse functions on the Global Script tab, which is used for sharing library functions and static attributes in the resource file. You can declare global variables on this tab, but you should be aware that they will not be reinitialized each time the collection is calculated, and keep their value until you modify the resource file, or the PowerDesigner session ends. This may cause errors, especially when variables reference objects that can be modified or deleted. Make sure you reinitialize the global variable if you do not want to keep the value from a previous run.

    For more information on defining a script and using the Global Script tab, see Example: PDM Custom Check and Global Script (Profile).

  4. Click Apply to save your changes.


    You can view the tab associated with the collection by opening the property sheet of a metaclass instance.