@itwin/core-backend
Version:
iTwin.js backend components
117 lines • 4.88 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* 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 { IModel, RelatedElement, } from "@itwin/core-common";
import { InformationPartitionElement, RoleElement, TypeDefinitionElement } from "../Element";
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 {
static get className() { return "FunctionalPartition"; }
constructor(props, iModel) {
super(props, iModel);
}
}
/** A container for persisting FunctionalElements.
* @public
*/
export class FunctionalModel extends RoleModel {
static get className() { return "FunctionalModel"; }
constructor(props, iModel) {
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.
*/
static insert(iModelDb, parentSubjectId, name) {
const partitionProps = {
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 class FunctionalElement extends RoleElement {
static get className() { return "FunctionalElement"; }
constructor(props, iModel) {
super(props, iModel);
}
}
/** A FunctionalBreakdownElement is a *folder* node in the functional hierarchy.
* @public
*/
export class FunctionalBreakdownElement extends FunctionalElement {
static get className() { return "FunctionalBreakdownElement"; }
constructor(props, iModel) {
super(props, iModel);
}
}
/** @public */
export class FunctionalComposite extends FunctionalBreakdownElement {
static get className() { return "FunctionalComposite"; }
constructor(props, iModel) {
super(props, iModel);
}
}
/** A FunctionalComponentElement is a *leaf* node in the functional hierarchy.
* @public
*/
export class FunctionalComponentElement extends FunctionalElement {
static get className() { return "FunctionalComponentElement"; }
constructor(props, iModel) {
super(props, iModel);
}
}
/** Defines a set of properties (the 'type') that can be associated with a Functional Element.
* @public
*/
export class FunctionalType extends TypeDefinitionElement {
static get className() { return "FunctionalType"; }
constructor(props, iModel) {
super(props, iModel);
}
}
/** Relates a [[FunctionalElement]] to its [[FunctionalType]]
* @public
*/
export class FunctionalElementIsOfType extends RelatedElement {
static get className() { return "FunctionalElementIsOfType"; }
static classFullName = "Functional:FunctionalElementIsOfType";
constructor(id, relClassName = FunctionalElementIsOfType.classFullName) {
super({ id, relClassName });
}
}
/** Relates a [[PhysicalElement]] to the [[FunctionalElement]] elements that it fulfills.
* @public
*/
export class PhysicalElementFulfillsFunction extends ElementRefersToElements {
static get className() { return "PhysicalElementFulfillsFunction"; }
}
/** Relates a [[DrawingGraphic]] to the [[FunctionalElement]] that it represents
* @public
*/
export class DrawingGraphicRepresentsFunctionalElement extends DrawingGraphicRepresentsElement {
static get className() { return "DrawingGraphicRepresentsFunctionalElement"; }
}
//# sourceMappingURL=FunctionalElements.js.map