-
Notifications
You must be signed in to change notification settings - Fork 208
/
FunctionalSchema.ts
40 lines (36 loc) · 1.62 KB
/
FunctionalSchema.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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Schema
*/
import * as path from "path";
import { DbResult } from "@itwin/core-bentley";
import { IModelError } from "@itwin/core-common";
import { ClassRegistry } from "../ClassRegistry";
import { IModelDb } from "../IModelDb";
import { KnownLocations } from "../IModelHost";
import { Schema, Schemas } from "../Schema";
import * as elementsModule from "./FunctionalElements";
/** @public */
export class FunctionalSchema extends Schema {
public static override get schemaName(): string { return "Functional"; }
public static get schemaFilePath(): string { return path.join(KnownLocations.nativeAssetsDir, "ECSchemas", "Domain", `${FunctionalSchema.schemaName}.ecschema.xml`); }
public static registerSchema() {
if (this !== Schemas.getRegisteredSchema(this.schemaName)) {
Schemas.unregisterSchema(this.schemaName);
Schemas.registerSchema(this);
ClassRegistry.registerModule(elementsModule, this);
}
}
/** @public */
public static async importSchema(iModelDb: IModelDb) {
if (iModelDb.isBriefcaseDb())
await iModelDb.acquireSchemaLock();
const stat = iModelDb.nativeDb.importFunctionalSchema();
if (DbResult.BE_SQLITE_OK !== stat) {
throw new IModelError(stat, "Error importing Functional schema");
}
}
}