Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename/deprecate BriefcaseIdValue.Standalone to BriefcaseIdValue.Unassigned #1051

Merged
merged 3 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion common/api/imodeljs-common.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,9 @@ export enum BriefcaseIdValue {
Illegal = 4294967295,
LastValid = 16777205,
Max = 16777216,
Standalone = 0
// @deprecated
Standalone = 0,
Unassigned = 0
}

// @beta
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/imodeljs-backend",
"comment": "rename (deprecate) BriefcaseIdValue.Standalone to BriefcaseIdValue.Unassigned to reduce confusion",
"type": "none"
}
],
"packageName": "@bentley/imodeljs-backend",
"email": "33296803+kabentley@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/imodeljs-common",
"comment": "rename (deprecate) BriefcaseIdValue.Standalone to BriefcaseIdValue.Unassigned to reduce confusion",
"type": "none"
}
],
"packageName": "@bentley/imodeljs-common",
"email": "33296803+kabentley@users.noreply.github.com"
}
4 changes: 2 additions & 2 deletions core/backend/src/BriefcaseManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class BriefcaseManager {
/** Determine whether the supplied briefcaseId is a standalone briefcase */
public static isStandaloneBriefcaseId(id: BriefcaseId) {
// eslint-disable-next-line deprecation/deprecation
return id === BriefcaseIdValue.Standalone || id === BriefcaseIdValue.DeprecatedStandalone;
return id === BriefcaseIdValue.Unassigned || id === BriefcaseIdValue.DeprecatedStandalone;
}

/** Determine whether the supplied briefcaseId is in the range of BriefcaseIds issued by iModelHub
Expand Down Expand Up @@ -229,7 +229,7 @@ export class BriefcaseManager {
* a filename, the local briefcase cache is used by creating a file with the briefcaseId as its name in the `briefcases` folder below the folder named
* for the IModelId.
* @note *It is invalid to edit briefcases on a shared network drive* and that is a sure way to corrupt your briefcase (see https://www.sqlite.org/howtocorrupt.html)
* @note The special briefcaseId [[BriefcaseIdValue.Standalone]] (0) can be used for a local briefcase that can accept changesets but may not be changed locally.
* @note The special briefcaseId [[BriefcaseIdValue.Unassigned]] (0) can be used for a local briefcase that can accept changesets but may not be changed locally.
* @see CheckpointManager.downloadCheckpoint
*/
public static async downloadBriefcase(requestContext: AuthorizedClientRequestContext, request: RequestNewBriefcaseArg): Promise<LocalBriefcaseProps> {
Expand Down
4 changes: 2 additions & 2 deletions core/backend/src/CheckpointManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ export class V1CheckpointManager {
nativeDb.deleteAllTxns();
}

if (nativeDb.getBriefcaseId() !== BriefcaseIdValue.Standalone)
nativeDb.resetBriefcaseId(BriefcaseIdValue.Standalone);
if (nativeDb.getBriefcaseId() !== BriefcaseIdValue.Unassigned)
nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);

// Validate the native briefcase against the checkpoint meta-data
try {
Expand Down
8 changes: 4 additions & 4 deletions core/backend/src/IModelDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2503,7 +2503,7 @@ export class SnapshotDb extends IModelDb {
if (DbResult.BE_SQLITE_OK !== status)
throw new IModelError(status, `Could not create snapshot iModel ${filePath}`, Logger.logError, loggerCategory);

status = nativeDb.resetBriefcaseId(BriefcaseIdValue.Standalone);
status = nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);
if (DbResult.BE_SQLITE_OK !== status)
throw new IModelError(status, `Could not set briefcaseId for snapshot iModel ${filePath}`, Logger.logError, loggerCategory);

Expand Down Expand Up @@ -2550,7 +2550,7 @@ export class SnapshotDb extends IModelDb {
nativeDb.deleteLocalValue(IModelDb._edit);
nativeDb.saveChanges();
nativeDb.deleteAllTxns();
nativeDb.resetBriefcaseId(BriefcaseIdValue.Standalone);
nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);
nativeDb.saveChanges();
const snapshotDb = new SnapshotDb(nativeDb, Guid.createValue()); // WIP: clean up copied file on error?
if (options?.createClassViews)
Expand Down Expand Up @@ -2646,7 +2646,7 @@ export class SnapshotDb extends IModelDb {
*
* Some additional details. Standalone iModels:
* - always have [Guid.empty]($bentley) for their contextId (they are "unassociated" files)
* - always have BriefcaseId === [BriefcaseIdValue.Standalone]($backend)
* - always have BriefcaseId === [BriefcaseIdValue.Unassigned]($backend)
* - are connected to the frontend via [BriefcaseConnection.openStandalone]($frontend)
* - may be opened without supplying any user credentials
* - may be opened read/write
Expand Down Expand Up @@ -2697,7 +2697,7 @@ export class StandaloneDb extends IModelDb {
nativeDb.saveLocalValue(IModelDb._edit, undefined === args.allowEdit ? "" : args.allowEdit);
nativeDb.saveProjectGuid(Guid.empty);

status = nativeDb.resetBriefcaseId(BriefcaseIdValue.Standalone);
status = nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);
if (DbResult.BE_SQLITE_OK !== status) {
nativeDb.closeIModel();
throw new IModelError(status, `Could not set briefcaseId for iModel: ${filePath}`, Logger.logError, loggerCategory);
Expand Down
4 changes: 2 additions & 2 deletions core/backend/src/perftest/ElementCRUD.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe("PerformanceElementsTests", () => {
const seedIModel = SnapshotDb.createEmpty(IModelTestUtils.prepareOutputFile("ElementCRUDPerformance", fileName), { rootSubject: { name: "PerfTest" } });
const testSchemaName = path.join(KnownTestLocations.assetsDir, "PerfTestDomain.ecschema.xml");
await seedIModel.importSchemas(new BackendRequestContext(), [testSchemaName]);
const result: DbResult = seedIModel.nativeDb.resetBriefcaseId(BriefcaseIdValue.Standalone);
const result: DbResult = seedIModel.nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);
assert.equal(DbResult.BE_SQLITE_OK, result);
assert.isDefined(seedIModel.getMetaData(`PerfTestDomain:${name}`), `${name}is present in iModel.`);
const [, newModelId] = IModelTestUtils.createAndInsertPhysicalPartitionAndModel(seedIModel, Code.createEmpty(), true);
Expand Down Expand Up @@ -342,7 +342,7 @@ describe("PerformanceElementsTests2d", () => {
const seedIModel = SnapshotDb.createEmpty(IModelTestUtils.prepareOutputFile("ElementCRUDPerformance2d", fileName), { rootSubject: { name: "PerfTest" } });
const testSchemaName = path.join(KnownTestLocations.assetsDir, "PerfTestDomain.ecschema.xml");
await seedIModel.importSchemas(new BackendRequestContext(), [testSchemaName]);
const result: DbResult = seedIModel.nativeDb.resetBriefcaseId(BriefcaseIdValue.Standalone);
const result: DbResult = seedIModel.nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);
assert.equal(DbResult.BE_SQLITE_OK, result);
assert.isDefined(seedIModel.getMetaData(`PerfTestDomain:${name}`), `${name}is present in iModel.`);

Expand Down
2 changes: 1 addition & 1 deletion core/backend/src/perftest/MixinImpact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe("SchemaDesignPerf Impact of Mixins", () => {
if (!IModelJsFs.existsSync(seedName)) {
const seedIModel = SnapshotDb.createEmpty(IModelTestUtils.prepareOutputFile("MixinPerformance", `mixin_${hCount}.bim`), { rootSubject: { name: "PerfTest" } });
await seedIModel.importSchemas(new BackendRequestContext(), [st]);
const result: DbResult = seedIModel.nativeDb.resetBriefcaseId(BriefcaseIdValue.Standalone);
const result: DbResult = seedIModel.nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);
assert.equal(DbResult.BE_SQLITE_OK, result);
assert.isDefined(seedIModel.getMetaData("TestMixinSchema:MixinElement"), "Mixin Class is not present in iModel.");
const [, newModelId] = IModelTestUtils.createAndInsertPhysicalPartitionAndModel(seedIModel, Code.createEmpty(), true);
Expand Down
2 changes: 1 addition & 1 deletion core/backend/src/perftest/PerfTestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class PerfTestDataMgr {
if (undefined === this.catId) {
this.catId = SpatialCategory.insert(this.db, IModel.dictionaryId, "MySpatialCategory", new SubCategoryAppearance({ color: ColorDef.fromString("rgb(255,0,0)").toJSON() }));
}
const result: DbResult = this.db.nativeDb.resetBriefcaseId(BriefcaseIdValue.Standalone);
const result: DbResult = this.db.nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);
assert.equal(DbResult.BE_SQLITE_OK, result);
this.db.saveChanges();
}
Expand Down
4 changes: 2 additions & 2 deletions core/backend/src/perftest/PolymorphicQuery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe("SchemaDesignPerf Polymorphic query", () => {
let spatialCategoryId = SpatialCategory.queryCategoryIdByName(seedIModel, IModel.dictionaryId, "MySpatialCategory");
if (undefined === spatialCategoryId)
spatialCategoryId = SpatialCategory.insert(seedIModel, IModel.dictionaryId, "MySpatialCategory", new SubCategoryAppearance({ color: ColorDef.fromString("rgb(255,0,0)").toJSON() }));
const result: DbResult = seedIModel.nativeDb.resetBriefcaseId(BriefcaseIdValue.Standalone);
const result: DbResult = seedIModel.nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);
assert.equal(DbResult.BE_SQLITE_OK, result);
assert.isDefined(seedIModel.getMetaData("TestPolySchema:TestElement"), "Base Class is not present in iModel.");
// create base class elements
Expand Down Expand Up @@ -173,7 +173,7 @@ describe("SchemaDesignPerf Polymorphic query", () => {
let spatialCategoryId = SpatialCategory.queryCategoryIdByName(seedIModel2, IModel.dictionaryId, "MySpatialCategory");
if (undefined === spatialCategoryId)
spatialCategoryId = SpatialCategory.insert(seedIModel2, IModel.dictionaryId, "MySpatialCategory", new SubCategoryAppearance({ color: ColorDef.fromString("rgb(255,0,0)").toJSON() }));
const result: DbResult = seedIModel2.nativeDb.resetBriefcaseId(BriefcaseIdValue.Standalone);
const result: DbResult = seedIModel2.nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);
assert.equal(DbResult.BE_SQLITE_OK, result);
assert.isDefined(seedIModel2.getMetaData("TestPolySchema:TestElement"), "Base Class is not present in iModel.");
// create base class elements
Expand Down
6 changes: 3 additions & 3 deletions core/backend/src/perftest/PropertiesImpact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe("SchemaDesignPerf Impact of Properties", () => {
if (!IModelJsFs.existsSync(seedName)) {
const seedIModel = SnapshotDb.createEmpty(IModelTestUtils.prepareOutputFile("PropPerformance", `props_${pCount}.bim`), { rootSubject: { name: "PerfTest" } });
await seedIModel.importSchemas(new BackendRequestContext(), [st]);
const result: DbResult = seedIModel.nativeDb.resetBriefcaseId(BriefcaseIdValue.Standalone);
const result: DbResult = seedIModel.nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);
assert.equal(DbResult.BE_SQLITE_OK, result);
assert.isDefined(seedIModel.getMetaData("TestPropsSchema:PropElement"), "PropsClass is present in iModel.");
const [, newModelId] = IModelTestUtils.createAndInsertPhysicalPartitionAndModel(seedIModel, Code.createEmpty(), true);
Expand Down Expand Up @@ -347,7 +347,7 @@ describe("SchemaDesignPerf Number of Indices", () => {
if (!IModelJsFs.existsSync(seedName)) {
const seedIModel = SnapshotDb.createEmpty(IModelTestUtils.prepareOutputFile("IndexPerformance", `index_${iCount}.bim`), { rootSubject: { name: "PerfTest" } });
await seedIModel.importSchemas(new BackendRequestContext(), [st]);
const result: DbResult = seedIModel.nativeDb.resetBriefcaseId(BriefcaseIdValue.Standalone);
const result: DbResult = seedIModel.nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);
assert.equal(DbResult.BE_SQLITE_OK, result);
assert.isDefined(seedIModel.getMetaData("TestIndexSchema:PropElement"), "PropsClass is present in iModel.");
const [, newModelId] = IModelTestUtils.createAndInsertPhysicalPartitionAndModel(seedIModel, Code.createEmpty(), true);
Expand Down Expand Up @@ -375,7 +375,7 @@ describe("SchemaDesignPerf Number of Indices", () => {
if (!IModelJsFs.existsSync(seedName)) {
const seedIModel = SnapshotDb.createEmpty(IModelTestUtils.prepareOutputFile("IndexPerformance", `index_perclass_${iCount}.bim`), { rootSubject: { name: "PerfTest" } });
await seedIModel.importSchemas(new BackendRequestContext(), [st]);
const result: DbResult = seedIModel.nativeDb.resetBriefcaseId(BriefcaseIdValue.Standalone);
const result: DbResult = seedIModel.nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);
assert.equal(DbResult.BE_SQLITE_OK, result);
assert.isDefined(seedIModel.getMetaData("TestIndexSchema:PropElement0"), "PropsClass is present in iModel.");
const [, newModelId] = IModelTestUtils.createAndInsertPhysicalPartitionAndModel(seedIModel, Code.createEmpty(), true);
Expand Down
2 changes: 1 addition & 1 deletion core/backend/src/perftest/RelationshipImpact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe("SchemaDesignPerf Relationship Comparison", () => {
if (!IModelJsFs.existsSync(seedName)) {
const seedIModel = SnapshotDb.createEmpty(IModelTestUtils.prepareOutputFile("RelationshipPerformance", "relationship.bim"), { rootSubject: { name: "PerfTest" } });
await seedIModel.importSchemas(new BackendRequestContext(), [st]);
const result: DbResult = seedIModel.nativeDb.resetBriefcaseId(BriefcaseIdValue.Standalone);
const result: DbResult = seedIModel.nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);
assert.equal(DbResult.BE_SQLITE_OK, result);
// first create Elements and then Relationship
const [, newModelId] = IModelTestUtils.createAndInsertPhysicalPartitionAndModel(seedIModel, Code.createEmpty(), true);
Expand Down
4 changes: 2 additions & 2 deletions core/backend/src/test/integration/BriefcaseManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,10 @@ describe("BriefcaseManager (#integration)", () => {
it("should set appropriate briefcase ids for FixedVersion, PullOnly and PullAndPush workflows", async () => {
const args = { requestContext, contextId: testContextId, iModelId: readOnlyTestIModelId, deleteFirst: true };
const iModel1 = await IModelTestUtils.openCheckpointUsingRpc(args);
assert.equal(BriefcaseIdValue.Standalone, iModel1.nativeDb.getBriefcaseId(), "checkpoint should be 0");
assert.equal(BriefcaseIdValue.Unassigned, iModel1.nativeDb.getBriefcaseId(), "checkpoint should be 0");

const iModel2 = await IModelTestUtils.openBriefcaseUsingRpc({ ...args, briefcaseId: 0 });
assert.equal(BriefcaseIdValue.Standalone, iModel2.briefcaseId, "pullOnly should be 0");
assert.equal(BriefcaseIdValue.Unassigned, iModel2.briefcaseId, "pullOnly should be 0");

const iModel3 = await IModelTestUtils.openBriefcaseUsingRpc(args);
assert.isTrue(iModel3.briefcaseId >= BriefcaseIdValue.FirstValid && iModel3.briefcaseId <= BriefcaseIdValue.LastValid, "valid briefcaseId");
Expand Down
2 changes: 1 addition & 1 deletion core/backend/src/test/integration/HubUtility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ export class HubUtility {
if (DbResult.BE_SQLITE_OK !== status)
throw new IModelError(status, "Could not open iModel");
nativeDb.deleteAllTxns();
nativeDb.resetBriefcaseId(BriefcaseIdValue.Standalone);
nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);
if (nativeDb.queryLocalValue("StandaloneEdit"))
nativeDb.deleteLocalValue("StandaloneEdit");
nativeDb.saveChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ describe("Element and ElementAspect roundtrip test for all type of properties",

const imodel = SnapshotDb.createEmpty(iModelPath, { rootSubject: { name: "RoundTripTest" } });
await imodel.importSchemas(new BackendRequestContext(), [testSchemaPath]);
const result: DbResult = imodel.nativeDb.resetBriefcaseId(BriefcaseIdValue.Standalone);
const result: DbResult = imodel.nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned);
assert.equal(DbResult.BE_SQLITE_OK, result);
IModelTestUtils.createAndInsertPhysicalPartitionAndModel(imodel, Code.createEmpty(), true);
let spatialCategoryId = SpatialCategory.queryCategoryIdByName(imodel, IModel.dictionaryId, categoryName);
Expand Down
16 changes: 8 additions & 8 deletions core/backend/src/test/standalone/IModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1961,7 +1961,7 @@ describe("iModel", () => {
assert.isTrue(standaloneDb1.isStandaloneDb());
assert.isTrue(standaloneDb1.isStandalone);
assert.isFalse(standaloneDb1.isReadonly, "Expect standalone iModels to be read-write during create");
assert.equal(standaloneDb1.getBriefcaseId(), BriefcaseIdValue.Standalone);
assert.equal(standaloneDb1.getBriefcaseId(), BriefcaseIdValue.Unassigned);
assert.equal(standaloneDb1.pathName, standaloneFile1);
assert.equal(standaloneDb1, StandaloneDb.tryFindByKey(standaloneDb1.key), "Should be in the list of open StandaloneDbs");
assert.isFalse(standaloneDb1.nativeDb.isEncrypted());
Expand Down Expand Up @@ -1999,10 +1999,10 @@ describe("iModel", () => {
assert.isFalse(snapshotDb1.isReadonly, "Expect snapshots to be read-write during create");
assert.isFalse(snapshotDb2.isReadonly, "Expect snapshots to be read-write during create");
assert.isFalse(snapshotDb3.isReadonly, "Expect snapshots to be read-write during create");
assert.equal(snapshotDb1.getBriefcaseId(), BriefcaseIdValue.Standalone);
assert.equal(snapshotDb2.getBriefcaseId(), BriefcaseIdValue.Standalone);
assert.equal(snapshotDb3.getBriefcaseId(), BriefcaseIdValue.Standalone);
assert.equal(imodel1.getBriefcaseId(), BriefcaseIdValue.Standalone);
assert.equal(snapshotDb1.getBriefcaseId(), BriefcaseIdValue.Unassigned);
assert.equal(snapshotDb2.getBriefcaseId(), BriefcaseIdValue.Unassigned);
assert.equal(snapshotDb3.getBriefcaseId(), BriefcaseIdValue.Unassigned);
assert.equal(imodel1.getBriefcaseId(), BriefcaseIdValue.Unassigned);
assert.equal(snapshotDb1.pathName, snapshotFile1);
assert.equal(snapshotDb2.pathName, snapshotFile2);
assert.equal(snapshotDb3.pathName, snapshotFile3);
Expand Down Expand Up @@ -2082,7 +2082,7 @@ describe("iModel", () => {

// create snapshot from scratch without a password, then unnecessarily specify a password to open
let snapshotDb1 = SnapshotDb.createFrom(imodel1, snapshotFile1);
assert.equal(snapshotDb1.getBriefcaseId(), BriefcaseIdValue.Standalone);
assert.equal(snapshotDb1.getBriefcaseId(), BriefcaseIdValue.Unassigned);
snapshotDb1.close();
snapshotDb1 = SnapshotDb.openFile(snapshotFile1, { password: "unnecessaryPassword" });
assert.isTrue(snapshotDb1.isSnapshotDb());
Expand All @@ -2093,7 +2093,7 @@ describe("iModel", () => {

// create snapshot from scratch and give it a password
let snapshotDb2 = SnapshotDb.createEmpty(snapshotFile2, { rootSubject: { name: "Password-Protected" }, password: "password", createClassViews: true });
assert.equal(snapshotDb2.getBriefcaseId(), BriefcaseIdValue.Standalone);
assert.equal(snapshotDb2.getBriefcaseId(), BriefcaseIdValue.Unassigned);
const subjectName2 = "TestSubject2";
const subjectId2: Id64String = Subject.insert(snapshotDb2, IModel.rootSubjectId, subjectName2);
assert.isTrue(Id64.isValidId64(subjectId2));
Expand All @@ -2108,7 +2108,7 @@ describe("iModel", () => {

// create a new snapshot from a non-password-protected snapshot and then give it a password
let snapshotDb3 = SnapshotDb.createFrom(imodel1, snapshotFile3, { password: "password" });
assert.equal(snapshotDb3.getBriefcaseId(), BriefcaseIdValue.Standalone);
assert.equal(snapshotDb3.getBriefcaseId(), BriefcaseIdValue.Unassigned);
snapshotDb3.close();
snapshotDb3 = SnapshotDb.openFile(snapshotFile3, { password: "password" });
assert.isTrue(snapshotDb3.isSnapshotDb());
Expand Down
Loading