@itwin/core-backend
Version:
iTwin.js backend components
146 lines • 7.17 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
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SynchronizationConfigLink = exports.ExternalSourceGroup = exports.ExternalSourceAttachment = exports.ExternalSource = void 0;
const core_geometry_1 = require("@itwin/core-geometry");
const core_common_1 = require("@itwin/core-common");
const Element_1 = require("./Element");
const NavigationRelationship_1 = require("./NavigationRelationship");
/** An ExternalSource refers to an 'information container' found in a repository. In some cases, the container is the entire repository.
* @note The associated ECClass was added to the BisCore schema in version 1.0.13
* @beta
*/
class ExternalSource extends Element_1.InformationReferenceElement {
/** The repository that contains this ExternalSource. */
repository;
/** The name of the iModel Connecter that processed this ExternalSource. */
connectorName;
/** The version of the iModel Connecter that processed this ExternalSource. */
connectorVersion;
/** @internal */
static get className() { return "ExternalSource"; }
constructor(props, iModel) {
super(props, iModel);
if (props.repository)
this.repository = new NavigationRelationship_1.ExternalSourceIsInRepository(core_common_1.RelatedElement.idFromJson(props.repository));
}
toJSON() {
return super.toJSON(); // Entity.toJSON takes care of auto-handled properties
}
/** The [[CodeSpec]] for ExternalSource elements is not automatically created, so this method ensures that it exists. */
static ensureCodeSpec(iModelDb) {
try {
const codeSpec = iModelDb.codeSpecs.getByName(core_common_1.BisCodeSpec.externalSource);
return codeSpec.id;
}
catch {
return iModelDb.codeSpecs.insert(core_common_1.BisCodeSpec.externalSource, core_common_1.CodeScopeSpec.Type.Repository);
}
}
/** Create a Code for an ExternalSource element given a name that is meant to be unique within the scope of the iModel.
* @param iModelDb The IModelDb
* @param codeValue The ExternalSource name
* @see [[ensureCodeSpec]]
*/
static createCode(iModelDb, codeValue) {
const codeSpec = iModelDb.codeSpecs.getByName(core_common_1.BisCodeSpec.externalSource);
return new core_common_1.Code({ spec: codeSpec.id, scope: core_common_1.IModel.rootSubjectId, value: codeValue });
}
collectReferenceIds(referenceIds) {
super.collectReferenceIds(referenceIds);
if (this.repository)
referenceIds.addElement(this.repository.id);
}
}
exports.ExternalSource = ExternalSource;
/** Attachment of an ExternalSource
* @note The associated ECClass was added to the BisCore schema in version 1.0.13
* @beta
*/
class ExternalSourceAttachment extends Element_1.InformationReferenceElement {
/** The [[ExternalSource]] that is attached by this ExternalSourceAttachment. */
attaches;
/** Specifies whether the attached [[ExternalSource]] provides context or models a part of the whole. */
role;
/** The translation or offset in global coordinates of the attached [[ExternalSource]] relative to the ExternalSource that attaches it. */
translation;
/** The Yaw angle (in degrees) of the attached [[ExternalSource]] relative to the ExternalSource that attaches it. */
yaw;
/** The Pitch angle (in degrees) of the attached [[ExternalSource]] relative to the ExternalSource that attaches it. */
pitch;
/** The Roll angle (in degrees) of the attached [[ExternalSource]] relative to the ExternalSource that attaches it. */
roll;
/** The scale of the attached [[ExternalSource]] relative to the ExternalSource that attaches it. */
scale;
/** @internal */
static get className() { return "ExternalSourceAttachment"; }
constructor(props, iModel) {
super(props, iModel);
if (props.attaches)
this.attaches = new NavigationRelationship_1.ExternalSourceAttachmentAttachesSource(core_common_1.RelatedElement.idFromJson(props.attaches));
if (props.translation)
this.translation = core_geometry_1.Point3d.fromJSON(props.translation);
if (props.scale)
this.scale = core_geometry_1.Point3d.fromJSON(props.scale);
}
toJSON() {
return super.toJSON(); // Entity.toJSON takes care of auto-handled properties
}
/** The [[CodeSpec]] for ExternalSourceAttachment elements is not automatically created, so this method ensures that it exists. */
static ensureCodeSpec(iModelDb) {
try {
const codeSpec = iModelDb.codeSpecs.getByName(core_common_1.BisCodeSpec.externalSourceAttachment);
return codeSpec.id;
}
catch {
return iModelDb.codeSpecs.insert(core_common_1.BisCodeSpec.externalSourceAttachment, core_common_1.CodeScopeSpec.Type.ParentElement);
}
}
/** Create a Code for an ExternalSourceAttachment element given a name that is meant to be unique within the scope of its parent [[ExternalSource]].
* @param iModelDb The IModelDb
* @param scopeElementId The parent ExternalSource
* @param codeValue The ExternalSourceAttachment name
* @see [[ensureCodeSpec]]
*/
static createCode(iModelDb, scopeElementId, codeValue) {
const codeSpec = iModelDb.codeSpecs.getByName(core_common_1.BisCodeSpec.externalSourceAttachment);
return new core_common_1.Code({ spec: codeSpec.id, scope: scopeElementId, value: codeValue });
}
}
exports.ExternalSourceAttachment = ExternalSourceAttachment;
/** A group of ExternalSources that are collectively a source of information for one or more elements.
* @note The associated ECClass was added to the BisCore schema in version 1.0.13
* @beta
*/
class ExternalSourceGroup extends ExternalSource {
/** @internal */
static get className() { return "ExternalSourceGroup"; }
constructor(props, iModel) {
super(props, iModel);
}
}
exports.ExternalSourceGroup = ExternalSourceGroup;
/** Link to the Configuration for an iModel Synchronization Job
* @note The associated ECClass was added to the BisCore schema in version 1.0.13
* @beta
*/
class SynchronizationConfigLink extends Element_1.UrlLink {
/** Date/Time of last successful run of this synchronization configuration */
lastSuccessfulRun;
/** @internal */
static get className() { return "SynchronizationConfigLink"; }
constructor(props, iModel) {
super(props, iModel);
}
toJSON() {
return super.toJSON(); // Entity.toJSON takes care of auto-handled properties
}
}
exports.SynchronizationConfigLink = SynchronizationConfigLink;
//# sourceMappingURL=ExternalSource.js.map