Instance nodes of specific classes specification
TypeScript type: InstanceNodesOfSpecificClassesSpecification.
Returns nodes for instances of specific ECClasses.
Attributes
Name | Required? | Type | Default |
---|---|---|---|
Filtering | |||
classes |
Yes | MultiSchemaClassesSpecification | MultiSchemaClassesSpecification[] |
|
excludedClasses |
No | MultiSchemaClassesSpecification | MultiSchemaClassesSpecification[] |
[] |
instanceFilter |
No | ECExpression | "" |
hideNodesInHierarchy |
No | boolean |
false |
hideIfNoChildren |
No | boolean |
false |
hideExpression |
No | ECExpression | "" |
suppressSimilarAncestorsCheck |
No | boolean |
false |
Ordering | |||
priority |
No | number |
1000 |
doNotSort |
No | boolean |
false |
Grouping | |||
groupByClass |
No | boolean |
true |
groupByLabel |
No | boolean |
true |
Misc. | |||
hasChildren |
No | "Always" | "Never" | "Unknown" |
"Unknown" |
relatedInstances |
No | RelatedInstanceSpecification[] |
[] |
nestedRules |
No | ChildNodeRule[] |
[] |
Attribute: classes
Defines a set of multi schema classes that specify which ECClasses need to be selected to form the result.
Type | MultiSchemaClassesSpecification | MultiSchemaClassesSpecification[] |
Is Required | Yes |
// The ruleset has a specification that returns nodes for instances of `bis.PhysicalModel` class and all
// its subclasses.
const ruleset: Ruleset = {
id: "example",
rules: [
{
ruleType: "RootNodes",
specifications: [
{
specType: "InstanceNodesOfSpecificClasses",
classes: { schemaName: "BisCore", classNames: ["PhysicalModel"], arePolymorphic: true },
},
],
},
],
};
Attribute: excludedClasses
Defines a set of multi schema classes that prevents specified ECClasses and subclasses from being selected by classes
attribute.
Type | MultiSchemaClassesSpecification | MultiSchemaClassesSpecification[] |
Is Required | No |
Default Value | [] |
// The ruleset has a specification that returns nodes for all instances of `bis.Model` class
// excluding instances of `bis.DefinitionModel`, `bis.GroupInformationModel` and their subclasses.
const ruleset: Ruleset = {
id: "example",
rules: [
{
ruleType: "RootNodes",
specifications: [
{
specType: "InstanceNodesOfSpecificClasses",
classes: { schemaName: "BisCore", classNames: ["Model"], arePolymorphic: true },
excludedClasses: { schemaName: "BisCore", classNames: ["DefinitionModel", "GroupInformationModel"], arePolymorphic: true },
},
],
},
],
};
Attribute: instanceFilter
Specifies an ECExpression for filtering instances of ECClasses specified through the classes
attribute.
Type | ECExpression |
Is Required | No |
Default Value | "" |
// The ruleset has a specification that returns nodes for `bis.ViewDefinition` instances whose
// `CodeValue` property value ends with "View 1".
const ruleset: Ruleset = {
id: "example",
rules: [
{
ruleType: "RootNodes",
specifications: [
{
specType: "InstanceNodesOfSpecificClasses",
classes: { schemaName: "BisCore", classNames: ["ViewDefinition"], arePolymorphic: true },
instanceFilter: `this.CodeValue ~ "%View 1"`,
},
],
},
],
};
Attribute: hideNodesInHierarchy
When true
, instances nodes produced by this specification are omitted and their children appear one hierarchy level higher. Note: only instance nodes are hidden - grouping nodes are not affected by this attribute.
Type | boolean |
Is Required | No |
Default Value | false |
// The ruleset contains a root node specification for `bis.PhysicalModel` nodes which are grouped by class and hidden. This
// means class grouping nodes are displayed, but instance nodes are hidden and instead their children are displayed. The
// children are determined by another rule.
const ruleset: Ruleset = {
id: "example",
rules: [
{
ruleType: "RootNodes",
specifications: [
{
specType: "InstanceNodesOfSpecificClasses",
classes: { schemaName: "BisCore", classNames: ["PhysicalModel"], arePolymorphic: true },
hideNodesInHierarchy: true,
},
],
},
{
ruleType: "ChildNodes",
specifications: [
{
specType: "CustomNode",
type: "child",
label: "Child",
},
],
},
],
};
hideNodesInHierarchy: false |
hideNodesInHierarchy: true |
---|---|
Attribute: hideIfNoChildren
Specifies whether nodes created through this specification should be hidden if they have no child nodes.
Type | boolean |
Is Required | No |
Default Value | false |
// The ruleset contains root node specifications for two custom nodes which are only
// displayed if they have children. One of them has children and the other - not, so
// only one of them is displayed
const ruleset: Ruleset = {
id: "example",
rules: [
{
ruleType: "RootNodes",
specifications: [
{
specType: "CustomNode",
type: "2d",
label: "2d Elements",
hideIfNoChildren: true,
},
{
specType: "CustomNode",
type: "3d",
label: "3d Elements",
hideIfNoChildren: true,
},
],
},
{
ruleType: "ChildNodes",
condition: `ParentNode.Type = "2d"`,
specifications: [
{
specType: "InstanceNodesOfSpecificClasses",
classes: { schemaName: "BisCore", classNames: ["GeometricElement2d"], arePolymorphic: true },
},
],
},
{
ruleType: "ChildNodes",
condition: `ParentNode.Type = "3d"`,
specifications: [
{
specType: "InstanceNodesOfSpecificClasses",
classes: { schemaName: "BisCore", classNames: ["GeometricElement3d"], arePolymorphic: true },
},
],
},
],
};
hideIfNoChildren: false |
hideIfNoChildren: true |
---|---|
Attribute: hideExpression
When specified ECExpression evaluates to true
, nodes produced by this specification are omitted and their children appear one hierarchy level higher.
Type | ECExpression |
Is Required | No |
Default Value | "" |
// The ruleset contains root node specifications for two custom nodes which are only
// displayed if they have children. One of them has children and the other - not, so
// only one of them is displayed
const ruleset: Ruleset = {
id: "example",
rules: [
{
ruleType: "RootNodes",
specifications: [
{
specType: "CustomNode",
type: "2d",
label: "2d Elements",
hideExpression: `ThisNode.HasChildren = FALSE`,
},
{
specType: "CustomNode",
type: "3d",
label: "3d Elements",
hideExpression: `ThisNode.HasChildren = FALSE`,
},
],
},
{
ruleType: "ChildNodes",
condition: `ParentNode.Type = "2d"`,
specifications: [
{
specType: "InstanceNodesOfSpecificClasses",
classes: { schemaName: "BisCore", classNames: ["GeometricElement2d"], arePolymorphic: true },
},
],
},
{
ruleType: "ChildNodes",
condition: `ParentNode.Type = "3d"`,
specifications: [
{
specType: "InstanceNodesOfSpecificClasses",
classes: { schemaName: "BisCore", classNames: ["GeometricElement3d"], arePolymorphic: true },
},
],
},
],
};
hideExpression evaluates to false |
hideExpression evaluates to true |
---|---|
Attribute: suppressSimilarAncestorsCheck
Specifies whether similar ancestor nodes' checking should be suppressed when creating nodes based on this specification. See more in Infinite Hierarchies Prevention page.
Type | boolean |
Is Required | No |
Default Value | false |
// The ruleset contains a root node specification that returns the root `bis.Subject` node. Also, there are two
// child node rules:
// - For any `bis.Model` node, return its contained `bis.Element` nodes.
// - For any `bis.Element` node, return its children `bis.Model` nodes.
// Children of the root `bis.Subject` are all in the single `bis.RepositoryModel` and some of their children are in the same
// `bis.RepositoryModel` as their parent. This means the `bis.RepositoryModel` node has to be repeated in the hierarchy, but
// that wouldn't happen due to duplicate nodes prevention, unless the `suppressSimilarAncestorsCheck` flag is set.
const ruleset: Ruleset = {
id: "example",
rules: [
{
ruleType: "RootNodes",
specifications: [
{
specType: "InstanceNodesOfSpecificClasses",
classes: { schemaName: "BisCore", classNames: ["Subject"] },
instanceFilter: `this.ECInstanceId = 1`,
groupByClass: false,
groupByLabel: false,
},
],
},
{
ruleType: "ChildNodes",
condition: `ParentNode.IsOfClass("Model", "BisCore")`,
specifications: [
{
specType: "RelatedInstanceNodes",
relationshipPaths: [
{
relationship: { schemaName: "BisCore", className: "ModelContainsElements" },
direction: "Forward",
},
],
groupByClass: false,
groupByLabel: false,
},
],
},
{
ruleType: "ChildNodes",
condition: `ParentNode.IsOfClass("Element", "BisCore")`,
specifications: [
{
specType: "RelatedInstanceNodes",
relationshipPaths: [
[
{
relationship: { schemaName: "BisCore", className: "ElementOwnsChildElements" },
direction: "Forward",
},
{
relationship: { schemaName: "BisCore", className: "ModelContainsElements" },
direction: "Backward",
},
],
],
suppressSimilarAncestorsCheck: true,
groupByClass: false,
groupByLabel: false,
},
],
},
],
};
Attribute: priority
Controls the order in which specifications are handled — specification with higher priority value is handled first. If priorities are equal, the specifications are handled in the order they appear in the ruleset.
Type | number |
Is Required | No |
Default Value | 1000 |
// This ruleset produces a list of `bis.PhysicalModel` and `bis.SpatialCategory` instances and groups them by
// class. "Spatial Category" group will appear first because it has been given a higher priority value.
const ruleset: Ruleset = {
id: "example",
rules: [
{
ruleType: "RootNodes",
specifications: [
{
specType: "InstanceNodesOfSpecificClasses",
priority: 1,
classes: { schemaName: "BisCore", classNames: ["PhysicalModel"], arePolymorphic: true },
},
{
specType: "InstanceNodesOfSpecificClasses",
priority: 2,
classes: { schemaName: "BisCore", classNames: ["SpatialCategory"], arePolymorphic: true },
},
],
},
],
};
Attribute: doNotSort
By default, nodes are sorted by their display label. This attribute allows suppressing sorting of nodes returned by this specification,
which can substantially improve performance when large numbers of nodes are involved. With this attribute set to true
, the order of
returned nodes is undefined.
Type | boolean |
Is Required | No |
Default Value | false |
// The ruleset has a specification that returns unsorted `bis.Model` nodes - the order is undefined.
const ruleset: Ruleset = {
id: "example",
rules: [
{
ruleType: "RootNodes",
specifications: [
{
specType: "InstanceNodesOfSpecificClasses",
classes: [{ schemaName: "BisCore", classNames: ["Model"], arePolymorphic: true }],
doNotSort: true,
},
],
},
],
};
Attribute: groupByClass
Controls whether returned instances should be grouped by ECClass.
Type | boolean |
Is Required | No |
Default Value | true |
// The ruleset contains a specification that returns `bis.Model` nodes without grouping them
// by class.
const ruleset: Ruleset = {
id: "example",
rules: [
{
ruleType: "RootNodes",
specifications: [
{
specType: "InstanceNodesOfSpecificClasses",
classes: [{ schemaName: "BisCore", classNames: ["Model"], arePolymorphic: true }],
groupByClass: false,
},
],
},
],
};
groupByClass: false |
groupByClass: true |
---|---|
Attribute: groupByLabel
Controls whether returned instances should be grouped by label.
Label grouping node is created only if all of these conditions match:
- There are at least two nodes with the same label.
- There's at least one sibling node with a different label.
Type | boolean |
Is Required | No |
Default Value | true |
// The ruleset contains a specification that returns `meta.ECPropertyDef` nodes without grouping them
// by label.
const ruleset: Ruleset = {
id: "example",
rules: [
{
ruleType: "RootNodes",
specifications: [
{
specType: "InstanceNodesOfSpecificClasses",
classes: [{ schemaName: "ECDbMeta", classNames: ["ECPropertyDef"] }],
groupByLabel: false,
},
],
},
],
};
groupByLabel: false |
groupByLabel: true |
---|---|
Attribute: hasChildren
Generally, when a node is created, the rules engine has to determine whether it has children before returning it. This requires evaluating child node rules and, usually, executing additional queries. This attribute allows telling the engine that nodes created by this specification always or never have children, which may substantially improve performance of creating nodes in cases when getting child nodes is expensive.
In case when the attribute value "lies":
When set to
Always
, the returned nodes always havehasChildren
flag set totrue
. Requesting children for such nodes returns empty list. It's up to the UI component to handle the case of parent node saying it has children but data source not returning any.When set to
Never
, the returned nodes always havehasChildren
set tofalse
. Requesting children for such nodes returns empty list even if there are child node rules that define children for it.
Type | "Always" | "Never" | "Unknown" |
Is Required | No |
Default Value | "Unknown" |
// This ruleset produces a hierarchy of a single root node that hosts a list of `Model` instances. Assuming all
// iModels contain at least one model, the result of this ruleset can be computed quicker by setting
// `hasChildren` attribute to `"Always"`.
const ruleset: Ruleset = {
id: "example",
rules: [
{
ruleType: "RootNodes",
specifications: [
{
specType: "CustomNode",
type: "T_ROOT_NODE",
label: "My Root Node",
hasChildren: "Always",
},
],
},
{
ruleType: "ChildNodes",
condition: `ParentNode.Type="T_ROOT_NODE"`,
specifications: [
{
specType: "InstanceNodesOfSpecificClasses",
classes: [{ schemaName: "BisCore", classNames: ["Model"], arePolymorphic: true }],
},
],
},
],
};
hasChildren: "Always" |
hasChildren: "Never" |
---|---|
Attribute: relatedInstances
Specifications of related instances that can be used when creating the nodes. There are several use cases when this is useful:
When there's a need to only load instances that have a related instance. Providing a related instance specification with isRequired set to
true
filters-out the instances that don't have the related instance.When there's a need to filter instances by a related instance value. The alias attribute may then be used in the
instanceFilter
attribute to reference related instance property values.When there's a need to group by related instance property values. Related instance classes are included when looking for grouping rules, which allows using related instance values for property grouping.
When there's a need to customize nodes based on related instance property values. Related instance classes are included when looking for customization rules, which allows referencing related instances and their properties in customization rule ECExpressions by their alias.
Type | RelatedInstanceSpecification[] |
Is Required | No |
Default Value | [] |
// The ruleset contains a root nodes' specification that returns nodes for `bis.Elements` that are in
// a category containing "a" in either `UserLabel` or `CodeValue` property.
const ruleset: Ruleset = {
id: "example",
rules: [
{
ruleType: "RootNodes",
specifications: [
{
specType: "InstanceNodesOfSpecificClasses",
classes: [{ schemaName: "BisCore", classNames: ["GeometricElement3d"], arePolymorphic: true }],
relatedInstances: [
{
relationshipPath: [
{
relationship: { schemaName: "BisCore", className: "GeometricElement3dIsInCategory" },
direction: "Forward",
},
],
alias: "category",
isRequired: true,
},
],
instanceFilter: `category.UserLabel ~ "%a%" OR category.CodeValue ~ "%a%"`,
},
],
},
],
};
Attribute: nestedRules
Specifications of nested child node rules that allow creating child nodes without the need of supplying a condition to match the parent node.
This is useful when the same instance node at different hierarchy levels needs to have different child nodes. Specifying a child node rule at the root level with condition to match the instance ECClass makes the rule create children for all nodes of that ECClass. When that's not desired, different child node rules may be specified as nested rules for specifications that return instance nodes of the same ECClass - that makes them have different children.
Type | ChildNodeRule[] |
Is Required | No |
Default Value | [] |
// The ruleset contains two root nodes' specifications:
// - The first one returns `bis.SpatialCategory` nodes
// - The second one returns `bis.PhysicalModel` nodes and also has a nested child node rule
// that creates a static "child" node.
// Nested rules apply only to nodes created by the same specification, so the static "child"
// node is created only for the `bis.PhysicalModel`, but not `bis.SpatialCategory`.
const ruleset: Ruleset = {
id: "example",
rules: [
{
ruleType: "RootNodes",
specifications: [
{
specType: "InstanceNodesOfSpecificClasses",
classes: [{ schemaName: "BisCore", classNames: ["SpatialCategory"] }],
groupByClass: false,
},
{
specType: "InstanceNodesOfSpecificClasses",
classes: [{ schemaName: "BisCore", classNames: ["PhysicalModel"] }],
groupByClass: false,
nestedRules: [
{
ruleType: "ChildNodes",
specifications: [
{
specType: "CustomNode",
type: "T_CHILD",
label: "child",
},
],
},
],
},
],
},
],
};
Deprecated attributes
Attribute: arePolymorphic
Tells whether selecting instances from ECClasses specified in classes
and excludedClasses
attributes should be polymorphic or not.
The attribute was replaced by arePolymorphic
attribute specified individually for each class definition
under classes
and excludedClasses
attributes. At the moment, to keep
backwards compatibility, this attribute acts as a fallback value in case the flag is not specified individually
for a class definition.
Type | boolean |
Is Required | No |
Default Value | false |
Last Updated: 13 May, 2024