-
Notifications
You must be signed in to change notification settings - Fork 208
/
FunctionalElements.ts
149 lines (130 loc) · 5.63 KB
/
FunctionalElements.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Elements
*/
import { Id64String } from "@itwin/core-bentley";
import {
FunctionalElementProps, IModel, InformationPartitionElementProps, ModelProps, RelatedElement, TypeDefinitionElementProps,
} from "@itwin/core-common";
import { InformationPartitionElement, RoleElement, TypeDefinitionElement } from "../Element";
import { IModelDb } from "../IModelDb";
import { RoleModel } from "../Model";
import { SubjectOwnsPartitionElements } from "../NavigationRelationship";
import { DrawingGraphicRepresentsElement, ElementRefersToElements } from "../Relationship";
/** A FunctionalPartition element is a key part of the iModel information hierarchy and is always parented
* to a Subject and broken down by a FunctionalModel.
* @public
*/
export class FunctionalPartition extends InformationPartitionElement {
/** @internal */
public static override get className(): string { return "FunctionalPartition"; }
protected constructor(props: InformationPartitionElementProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** A container for persisting FunctionalElements.
* @public
*/
export class FunctionalModel extends RoleModel {
/** @internal */
public static override get className(): string { return "FunctionalModel"; }
public constructor(props: ModelProps, iModel: IModelDb) {
super(props, iModel);
}
/** Insert a FunctionalPartition and a FunctionalModel that breaks it down.
* @param iModelDb Insert into this iModel
* @param parentSubjectId The FunctionalPartition will be inserted as a child of this Subject element.
* @param name The name of the FunctionalPartition that the new FunctionalModel will break down.
* @returns The Id of the newly inserted FunctionalPartition and FunctionalModel (same value).
* @throws [[IModelError]] if there is an insert problem.
*/
public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string): Id64String {
const partitionProps: InformationPartitionElementProps = {
classFullName: FunctionalPartition.classFullName,
model: IModel.repositoryModelId,
parent: new SubjectOwnsPartitionElements(parentSubjectId),
code: FunctionalPartition.createCode(iModelDb, parentSubjectId, name),
};
const partitionId = iModelDb.elements.insertElement(partitionProps);
return iModelDb.models.insertModel({
classFullName: this.classFullName,
modeledElement: { id: partitionId },
});
}
}
/** A FunctionalElement captures functional requirements that will ultimately be fulfilled by a PhysicalElement.
* @public
*/
export abstract class FunctionalElement extends RoleElement {
/** @internal */
public static override get className(): string { return "FunctionalElement"; }
protected constructor(props: FunctionalElementProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** A FunctionalBreakdownElement is a *folder* node in the functional hierarchy.
* @public
*/
export abstract class FunctionalBreakdownElement extends FunctionalElement {
/** @internal */
public static override get className(): string { return "FunctionalBreakdownElement"; }
protected constructor(props: FunctionalElementProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** @public */
export class FunctionalComposite extends FunctionalBreakdownElement {
/** @internal */
public static override get className(): string { return "FunctionalComposite"; }
protected constructor(props: FunctionalElementProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** A FunctionalComponentElement is a *leaf* node in the functional hierarchy.
* @public
*/
export abstract class FunctionalComponentElement extends FunctionalElement {
/** @internal */
public static override get className(): string { return "FunctionalComponentElement"; }
protected constructor(props: FunctionalElementProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** Defines a set of properties (the 'type') that can be associated with a Functional Element.
* @public
*/
export abstract class FunctionalType extends TypeDefinitionElement {
/** @internal */
public static override get className(): string { return "FunctionalType"; }
protected constructor(props: TypeDefinitionElementProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** Relates a [[FunctionalElement]] to its [[FunctionalType]]
* @public
*/
export class FunctionalElementIsOfType extends RelatedElement {
/** @internal */
public static get className(): string { return "FunctionalElementIsOfType"; }
public static classFullName = "Functional:FunctionalElementIsOfType";
public constructor(id: Id64String, relClassName: string = FunctionalElementIsOfType.classFullName) {
super({ id, relClassName });
}
}
/** Relates a [[PhysicalElement]] to the [[FunctionalElement]] elements that it fulfills.
* @public
*/
export class PhysicalElementFulfillsFunction extends ElementRefersToElements {
/** @internal */
public static override get className(): string { return "PhysicalElementFulfillsFunction"; }
}
/** Relates a [[DrawingGraphic]] to the [[FunctionalElement]] that it represents
* @public
*/
export class DrawingGraphicRepresentsFunctionalElement extends DrawingGraphicRepresentsElement {
/** @internal */
public static override get className(): string { return "DrawingGraphicRepresentsFunctionalElement"; }
}