Customizing the Query Definition

The Base Query Definition should not be modified. Doing so risks disabling Dynamic Visualization entirely. Instead, the best approach to creating alternative/custom queries is to copy this Item and modify the copy to adjust/add whatever changes are necessary. This section identifies the scope of changes that are permissible and how to make those changes.1

Adding Properties

Any Property can be added to the base Query Definition if the Core Properties (see Section Base Query Definition) are not removed. In addition, there are no restrictions on the set of Properties added to additional related Query Items. Properties are mapped to Tree nodes or columns in the Tree Grid View Definition (see Section Tree Grid View Definitions) Doing so exposes the values of these Properties in the Dynamic Viewer or Streaming Viewer.

Note
Properties must be added to the Query Definition for them to be mapped in a Tree Grid View Definition.

Adding related content

Related ItemTypes – that is, the ItemTypes that are related to any ItemType via an Item Property – can be included in a Query Definition for the Dynamic Viewer and Streaming Viewer. As noted in Section 3D Visualization Navigation Tool, this mechanism enables users to see content related to parts displayed in the 3D View. A related ItemType is added as a separate Query Item in the Query Definition.

Note
Query Items must be mapped in the Tree Grid View Definition for related Items to be included in the Tree Grid View.

Any related ItemTypes can be included but it’s important to note that the Base Query Definition must not be altered and the context ItemType must be associated with the CAD ItemType. Related ItemTypes use a Join Condition to determine how rows from the two associated ItemType tables should relate. By default, these Join Conditions use the id Property of one of the Query Items in the Join. This Join Condition can be altered, but users should understand the ItemType data model they are referring to when doing so.

Since the Part ItemType represents a core Business Object in PLM, it is likely that users will want to see the Part Items associated with the CAD Items returned in the Base query. Parts are associated with CAD Items by default using the Part CAD relationship. Part Items, using this relationship, are the source and CAD Items are the related. Thus, if users want to include the Part CAD relationship as a ‘referencing Item’ in the Query Definition, they need to include the Part Item using the following steps as described by Figure 16 and Figure 17. Similar steps can be used when adding content that references the selected Query Item – that is, has an Item Property that ‘points to’ the ItemType of the selected Query Item.

Conditions and Filters

Conditional logic can be used to filter the content that is returned from the execution of a Query Definition. Where Conditions on the Query Items are used to add conditional logic. For example, the following Where Condition, applied to a related Part Item, results in only those Parts with the String ‘valve’ included somewhere in the Part Name being included in the query results.

Note
Properties used in Condition statements should be included with the Query Item. For example, the Name Property would need to be included with the Part Query Item for it to apply in this condition. Note also that the example in above figure will only filter Part Items, the Part CAD relationship Items will still be included in the query results.
Warning
Federated Properties cannot be used in a Where Condition.

Conditional logic applied to any ItemType that is added to the Base Query Items can be done without affecting the Dynamic Viewer or Streaming Viewer. However, Administrators must use caution when applying conditions to the Query Items that are part of the Base Query Definition. For this purpose, the following information should be referenced:

  1. Conditions that filter an assembly will result in all descendant CAD Items being filtered.
  2. It is possible to filter CAD Items based on conditions applied to related content. For example, to filter component CAD Items based on conditions applied to related Parts:

    • The Condition applied to the Part Query Item can be whatever logic is necessary to isolate specific Part Items.
    • The Condition applied to the Part CAD Query Item uses the ‘Exists()’ function. This function effectively applies a SQL Inner Join between the Part CAD and Part Tables. The result is the rows for the Part CAD Items are reduced to only those with related Part rows in this case. That is, only Part CAD Items are returned if there are related Part Items returned which are filtered by some logic.
    • The Condition applied to the CAD Query Item needs to only associate the related part filter to CAD Items that represent components (non-Assembly Items). To do this, include the condition on the existence of the Part CAD Items. If a row is included, then include the CAD Item as well.
    Warning
    Federated Properties cannot be used in Where Conditions.

  3. Use caution when applying filters to CAD Query Items. They are reused and exist to execute recursive sub-queries. In this case, the CAD Query Item represents both Assemblies and Components. Applied Conditional logic needs to consider that when Parts in a Dynamic View are placed, they require the application of the full lineage of Transformations from the root CAD Item to each leaf Component CAD Item.
  4. If Conditions are applied to CAD Instance Query Items, instances of the related CAD Item are also filtered.
  5. The Base Query Definition has a Condition that filters the File Item (view file) related by a File Representation based on the Representation ‘kind’; which is SCS. If this Condition is modified, it may result in the corresponding 3D geometry being removed.

Query Parameters

Query Parameters used in Query Definitions provide the ability to add ‘placeholders’ for actual values used in Conditional statements. This is useful when there is a need to provide some level of control for additional filtering on the part of the end-user. It is possible to use a Parameter in place of the hard-coded value ‘*valve*’. In this case, Users can provide any value they would like to use in place of the default to filter based on the name of the related Part. The below figure shows the added Parameter ‘partNameFilter’ which can then be used in place of the value ‘valve’. This example uses the default Parameter value of ‘*’ which is a wildcard character that will result in all names chosen in this case. Also, for this example the Parameter is placed in between two ‘%’ characters which will cause the name value given to be valid within the actual Part Name for the Part Items.7 For example, a Parameter value of ‘intake’ would match Part Names: ‘Intake Valve’, ‘Left Intake Spring’, ‘Right Intake’ and ‘Intake’. Parameters are added using the Query Parameter Dialog and referenced within a Condition Statement by preceding the Parameter Name with a ‘$’. Query Parameters must be added to the Tree Grid View Definition to be exposed to the user.

Structure Resolution

Query Parameters enable another query mechanism to control the display of content – Structure Resolution. Structure Resolution is used to identify a specific generation of an Item. This is especially useful for CAD structures since the CAD Structure Relationship is fixed by default. This means that a CAD Structure hierarchy will be based on the CAD Items and specific relationships created from the CAD Connector (see Section CAD Data Model). Updates to individual CAD Items do not necessarily involve an update to the CAD Structure Relationship. As a result, Assembly CAD Items will ‘point to’ a generation of a CAD component that isn’t the latest.

Structure Resolution focuses on the Released state of generations of Items. It can be applied based on the following conditions/Modes:

  • Default: Uses the generation of the Item that the Relationship Item includes. That is, it will be the Item with an ID matching the related_id Property of the Relationship.
  • Latest: Uses the generation of the Item with the highest value.
  • LatestReleased: Uses the generation of the Item with the highest value which is also Released.
  • Latest Released or Latest: Uses the generation of the Item with the highest value which is also Released or the Latest if there are no Released generations.

Enabling Structure Resolution

Structure Resolution is enabled for the Base Query Definition (Section Base Query Definition). However, to incorporate it a new Query Definition must be created – as defined earlier in this section – and Structure Resolution enabled for it. The following steps describe how to add Structure Resolution to a Query Definition that derives from the Base Query Definition.

Step 1: Create Structure Resolution Mode Parameter

Applying a specific Structure Resolution Mode (‘Default’, ‘Latest’, etc.) is done using a Query Parameter. Using the Query Parameters Dialog, add a Parameter to be used for Structure Resolution Mode. For example ‘StructureResolutionMode’ and assign the default value ‘Aras.Resolution.EntryPoint;Default’.

Note
Be sure to check the syntax of the Default Value for the Parameter. It is used to select a specific List Item as set in the Tree Grid View Definition and described in Step 4.

Step 2: Incorporate the Query Parameter

The added Query Parameter must be incorporated into the Query Definition in order for it to be used/exposed to the end-user. Add it as part of the Join Condition of the Child CAD Query Item as shown in the figure. Replace the default Join Condition – ‘[CAD Structure].related_id = CAD.id’ with the following – ‘'$StructureResolutionMode;parent.related_id’ = CAD.id’.

Note
Be sure to check the syntax of the Join Condition. It must be as specified above (without the outer quotes). This assumes the value StructureResolutionMode was used for the Query Parameter Name. The Structure Resolution Mode Query Parameter can only be inserted once in a Query Definition. It cannot be used/applied to more than one Query Item.

Step 3: Add Resolve Query Entry Point Method

Show the Relationship Tabs for the Query Definition in the Form View if they are not shown. This can be done by selecting Tabs On for the Default Structure View in the qry_QueryDefinition ItemType form. Once shown, select the qry_QueryDefinitionEvent Relationship Tab. A Method needs to be added to the OnBeforeExecute event. To do this, select the Select Items Icon to create a Relationship and select the qry_ResolveStructureEntryPoint Method and assign it to the OnBeforeExecute event as shown in the figure.

Step 4: Add the Query Parameter to the Tree Grid View Definition

For the Query Parameter to be used, it must be enabled (made visible) in the Tree Grid View Definition used for the 3D View. Open the Map Parameters Dialog in the Tree Grid View Definition within the Editor View. Select the Visible check box for the StructureResolutionMode row. The Data Type is a List and the Data Source is the List qry_StructureResolution.

With this Configuration, users will be able to select specific Resolution Modes by opening the Query Parameters Dialog in the Tree Grid View used within the 3D Viewer.

Applying a Where Condition Against Resolved Items

It is possible to add a Where Condition to a Query Item that is used for Structure Resolution (e.g., CAD). Doing so allows the Administrator to apply an additional condition (filter) when resolving the Structure of Items with fixed Relationships (such as CAD / CAD Structure). For example, assuming the CAD Structure in the following diagram:

To use a Structure Resolution of ‘Latest’ and apply an additional condition to only include CAD Items that were In Review (that is, with a CAD.State = ‘In Review’) then Where and Join conditions like the following could be added to the Query Item:

Note the addition of the left-side of the Join Condition:

‘$StructureResolutionMode;parent.related_id;ApplyChildWhereMode=ResolutionTargetResolved’ = CAD.id]

Executing this Query Definition, with Structure Resolution of ‘Latest Released’ with return.

In this example, only the CAD Item – CS3, version 5 is returned because of the added Where Condition of ‘CAD.State = ‘In Review’.