@itwin/core-backend 5.12.2 → 5.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -60,7 +60,7 @@ import * as semver from "semver";
60
60
  import * as sinon from "sinon";
61
61
  import { DbResult, Guid, Id64, IModelStatus, Logger, OpenMode, ProcessDetector } from "@itwin/core-bentley";
62
62
  import { EditTxn, withEditTxn } from "../../EditTxn";
63
- import { BisCodeSpec, BriefcaseIdValue, Code, CodeScopeSpec, CodeSpec, ColorByName, ColorDef, DisplayStyleSettings, EcefLocation, FontMap, FontType, GeoCoordStatus, GeographicCRS, GeometryParams, GeometryStreamBuilder, ImageSourceFormat, IModel, IModelError, QueryBinder, RelatedElement, RenderMode, SchemaState, SubCategoryAppearance, TextureMapping, TextureMapUnits, ViewFlags, } from "@itwin/core-common";
63
+ import { BisCodeSpec, BriefcaseIdValue, Code, CodeScopeSpec, CodeSpec, ColorByName, ColorDef, DisplayStyleSettings, EcefLocation, FontMap, FontType, GeoCoordStatus, GeographicCRS, GeometryParams, GeometryStreamBuilder, ImageSourceFormat, IModel, IModelError, QueryBinder, Rank, RelatedElement, RenderMode, SchemaState, SubCategoryAppearance, TextureMapping, TextureMapUnits, ViewFlags, } from "@itwin/core-common";
64
64
  import { Geometry, LineString3d, Loop, Matrix4d, Point3d, PolyfaceBuilder, Range3d, StrokeOptions, Transform, YawPitchRollAngles, } from "@itwin/core-geometry";
65
65
  import { V2CheckpointManager } from "../../CheckpointManager";
66
66
  import { _nativeDb, BisCoreSchema, Category, ClassRegistry, DefinitionContainer, DefinitionGroup, DefinitionGroupGroupsDefinitions, DefinitionModel, DefinitionPartition, DictionaryModel, DisplayStyle3d, DocumentPartition, DrawingGraphic, Element, ElementDrivesElement, ElementGroupsMembers, ElementOwnsChildElements, GenericGraphicalType2d, GeometricElement2d, GeometricElement3d, GeometricModel, GroupInformationPartition, IModelDb, IModelHost, IModelJsFs, InformationPartitionElement, InformationRecordElement, LinkPartition, Model, PhysicalElement, PhysicalModel, PhysicalObject, PhysicalPartition, RenderMaterialElement, SnapshotDb, SpatialCategory, SqliteValueType, StandaloneDb, SubCategory, Subject, Texture, } from "../../core-backend";
@@ -1527,6 +1527,67 @@ describe("iModel", () => {
1527
1527
  txn.end();
1528
1528
  iModelDb.close();
1529
1529
  });
1530
+ describe("DefinitionSet.rank", () => {
1531
+ function setRank(iModelDb, id, className, rank) {
1532
+ withEditTxn(iModelDb, (txn) => txn.updateElement({ id, classFullName: className, rank }));
1533
+ }
1534
+ it("should insert, update, read and serialize rank", () => {
1535
+ const iModelFileName = IModelTestUtils.prepareOutputFile("IModel", "DefinitionSetRank.bim");
1536
+ const iModelDb = StandaloneDb.createEmpty(iModelFileName, { rootSubject: { name: "DefinitionSetRank" } });
1537
+ const containerId = withEditTxn(iModelDb, (txn) => DefinitionContainer.insert(txn, IModel.dictionaryId, Code.createEmpty()));
1538
+ const groupId = withEditTxn(iModelDb, (txn) => DefinitionGroup.create(iModelDb, IModel.dictionaryId, Code.createEmpty()).insert(txn));
1539
+ // Freshly inserted DefinitionSets have no rank persisted.
1540
+ assert.isUndefined(iModelDb.elements.getElementProps(containerId).rank);
1541
+ assert.isUndefined(iModelDb.elements.getElement(containerId).rank);
1542
+ setRank(iModelDb, containerId, DefinitionContainer.classFullName, Rank.Application);
1543
+ setRank(iModelDb, groupId, DefinitionGroup.classFullName, Rank.Domain);
1544
+ const containerProps = iModelDb.elements.getElementProps(containerId);
1545
+ assert.equal(containerProps.rank, Rank.Application);
1546
+ const container = iModelDb.elements.getElement(containerId);
1547
+ assert.equal(container.rank, Rank.Application);
1548
+ assert.equal(container.toJSON().rank, Rank.Application);
1549
+ const group = iModelDb.elements.getElement(groupId);
1550
+ assert.equal(group.rank, Rank.Domain);
1551
+ assert.equal(group.toJSON().rank, Rank.Domain);
1552
+ iModelDb.close();
1553
+ });
1554
+ it("should serialize/deserialize DefinitionSet.rank via DefinitionSet.serialize/deserialize", () => {
1555
+ const iModelFileName = IModelTestUtils.prepareOutputFile("IModel", "DefinitionSetRankSerialize.bim");
1556
+ const iModelDb = StandaloneDb.createEmpty(iModelFileName, { rootSubject: { name: "DefinitionSetRankSerialize" } });
1557
+ const props = {
1558
+ classFullName: DefinitionContainer.classFullName,
1559
+ model: IModel.dictionaryId,
1560
+ code: Code.createEmpty(),
1561
+ rank: Rank.User,
1562
+ };
1563
+ const row = DefinitionContainer.serialize(props, iModelDb);
1564
+ assert.equal(row.rank, Rank.User);
1565
+ const propsWithoutRank = {
1566
+ classFullName: DefinitionContainer.classFullName,
1567
+ model: IModel.dictionaryId,
1568
+ code: Code.createEmpty(),
1569
+ };
1570
+ const rowWithoutRank = DefinitionContainer.serialize(propsWithoutRank, iModelDb);
1571
+ assert.isUndefined(rowWithoutRank.rank);
1572
+ iModelDb.close();
1573
+ });
1574
+ it("should insert a DefinitionContainer with rank property", () => {
1575
+ const iModelFileName = IModelTestUtils.prepareOutputFile("IModel", "DefinitionContainerRank.bim");
1576
+ const iModelDb = StandaloneDb.createEmpty(iModelFileName, { rootSubject: { name: "DefinitionContainerRank" } });
1577
+ const containerId = withEditTxn(iModelDb, (txn) => {
1578
+ const containerProps = {
1579
+ classFullName: DefinitionContainer.classFullName,
1580
+ model: IModel.dictionaryId,
1581
+ code: Code.createEmpty(),
1582
+ rank: Rank.Application,
1583
+ };
1584
+ return txn.insertElement(containerProps);
1585
+ });
1586
+ const inserted = iModelDb.elements.getElementProps(containerId);
1587
+ assert.equal(inserted.rank, Rank.Application);
1588
+ iModelDb.close();
1589
+ });
1590
+ });
1530
1591
  it("should set EC properties of various types", async () => {
1531
1592
  const testImodel = imodel1;
1532
1593
  assert.doesNotThrow(() => testImodel.schemaContext.getSchemaItemSync("TestBim:TestPhysicalObject", EntityClass), "TestPhysicalObject is expected to be defined in TestBim.ecschema.xml");