How to use the @bentley/bentleyjs-core.Id64.fromJSON function in @bentley/bentleyjs-core

To help you get started, we’ve selected a few @bentley/bentleyjs-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imodeljs / imodeljs / test-apps / agent-test-app / src / QueryAgent.ts View on Github external
changeContent.instanceChanges = this._iModelDb!.withPreparedStatement("SELECT ECInstanceId FROM ecchange.change.InstanceChange WHERE Summary.Id=? ORDER BY ECInstanceId", (stmt: ECSqlStatement): any[] => {
            stmt.bindId(1, changeSummary.id);
            const instanceChanges = new Array();
            while (stmt.step() === DbResult.BE_SQLITE_ROW) {
                const row = stmt.getRow();

                const instanceChange: any = ChangeSummaryManager.queryInstanceChange(this._iModelDb!, Id64.fromJSON(row.id));
                switch (instanceChange.opCode) {
                    case ChangeOpCode.Insert: {
                        // Get the instance after the insert
                        const rows: any[] = this._iModelDb!.executeQuery(ChangeSummaryManager.buildPropertyValueChangesECSql(this._iModelDb!, instanceChange, ChangedValueState.AfterInsert));
                        assert(rows.length === 1);
                        instanceChange.after = rows[0];
                        break;
                    }
                    case ChangeOpCode.Update: {
                        // Get the instance before the update
                        let rows: any[] = this._iModelDb!.executeQuery(ChangeSummaryManager.buildPropertyValueChangesECSql(this._iModelDb!, instanceChange, ChangedValueState.BeforeUpdate));
                        assert(rows.length === 1);
                        instanceChange.before = rows[0];
                        // Get the instance after the update
                        rows = this._iModelDb!.executeQuery(ChangeSummaryManager.buildPropertyValueChangesECSql(this._iModelDb!, instanceChange, ChangedValueState.AfterUpdate));
                        assert(rows.length === 1);
github imodeljs / imodeljs / core / backend / src / IModelDb.ts View on Github external
public insertModel(props: ModelProps): Id64String {
      if (props.isPrivate === undefined) // temporarily work around bug in addon
        props.isPrivate = false;

      const jsClass = this._iModel.getJsClass(props.classFullName) as any; // "as any" so we can call the protected methods
      jsClass.onInsert(props);

      const val = this._iModel.nativeDb.insertModel(JSON.stringify(props));
      if (val.error)
        throw new IModelError(val.error.status, "inserting model", Logger.logWarning, loggerCategory);

      props.id = Id64.fromJSON(JSON.parse(val.result!).id);
      jsClass.onInserted(props.id);
      return props.id;
    }
github imodeljs / imodeljs / core / backend / src / BriefcaseManager.ts View on Github external
return JSON.parse(json, (key: any, value: any) => {
      if (key === "state") {
        return (value as number);
      }
      // If the key is a number, it is an array member.
      if (!Number.isNaN(Number.parseInt(key, 10))) {
        const code = new HubCode();
        Object.assign(code, value);
        code.codeSpecId = Id64.fromJSON(value.codeSpecId);
        code.briefcaseId = briefcase.briefcaseId;
        return code;
      }
      return value;
    }) as HubCode[];
  }
github imodeljs / imodeljs / core / common / src / ViewProps.ts View on Github external
const ovrsArray = JsonUtils.asArray(this._json.subCategoryOvr);
    if (undefined !== ovrsArray) {
      for (const ovrJson of ovrsArray) {
        const subCatId = Id64.fromJSON(ovrJson.subCategory);
        if (Id64.isValid(subCatId)) {
          const subCatOvr = SubCategoryOverride.fromJSON(ovrJson);
          if (subCatOvr.anyOverridden)
            this.changeSubCategoryOverride(subCatId, false, subCatOvr);
        }
      }
    }

    const exElemArray = JsonUtils.asArray(this._json.excludedElements);
    if (undefined !== exElemArray) {
      for (const exElemStr of exElemArray) {
        const exElem = Id64.fromJSON(exElemStr);
        if (Id64.isValid(exElem)) {
          this._excludedElements.add(exElem);
        }
      }
    }
  }
github imodeljs / imodeljs / core / backend / src / Relationship.ts View on Github external
constructor(props: RelationshipProps, iModel: IModelDb) {
    super(props, iModel);
    this.sourceId = Id64.fromJSON(props.sourceId);
    this.targetId = Id64.fromJSON(props.targetId);
  }
github imodeljs / imodeljs / core / common / src / SubCategoryAppearance.ts View on Github external
private constructor(props: SubCategoryAppearance.Props) {
    if (undefined !== props.invisible) this.invisible = JsonUtils.asBool(props.invisible);
    if (undefined !== props.color) this.color = ColorDef.fromJSON(props.color);
    if (undefined !== props.weight) this.weight = JsonUtils.asInt(props.weight);
    if (undefined !== props.style) this.style = Id64.fromJSON(props.style);
    if (undefined !== props.material) this.material = Id64.fromJSON(props.material);
    if (undefined !== props.priority) this.priority = JsonUtils.asInt(props.priority);
    if (undefined !== props.transp) this.transparency = JsonUtils.asDouble(props.transp);
  }
github imodeljs / imodeljs / presentation / common / src / KeySet.ts View on Github external
public add(value: Keys | Key, pred?: (key: Key) => boolean): KeySet {
    if (!value)
      throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);
    const sizeBefore = this.size;
    if (this.isKeySet(value)) {
      this.addKeySet(value, pred);
    } else if (this.isKeysArray(value)) {
      value.forEach((key) => (!pred || pred(key)) ? this.add(key) : undefined);
    } else if (Key.isEntityProps(value)) {
      this.add({ className: value.classFullName, id: Id64.fromJSON(value.id) } as InstanceKey);
    } else if (Key.isInstanceKey(value)) {
      if (!this._instanceKeys.has(value.className))
        this._instanceKeys.set(value.className, new Set());
      this._instanceKeys.get(value.className)!.add(value.id);
    } else if (Key.isNodeKey(value)) {
      this._nodeKeys.add(JSON.stringify(value));
    } else {
      throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);
    }
    if (this.size !== sizeBefore)
      this._guid = Guid.createValue();
    return this;
  }
github imodeljs / imodeljs / core / common / src / SubCategoryAppearance.ts View on Github external
private constructor(props: SubCategoryAppearance.Props) {
    if (undefined !== props.invisible) this.invisible = JsonUtils.asBool(props.invisible);
    if (undefined !== props.color) this.color = ColorDef.fromJSON(props.color);
    if (undefined !== props.weight) this.weight = JsonUtils.asInt(props.weight);
    if (undefined !== props.style) this.style = Id64.fromJSON(props.style);
    if (undefined !== props.material) this.material = Id64.fromJSON(props.material);
    if (undefined !== props.priority) this.priority = JsonUtils.asInt(props.priority);
    if (undefined !== props.transp) this.transparency = JsonUtils.asDouble(props.transp);
  }
github imodeljs / imodeljs / core / common / src / ViewProps.ts View on Github external
public constructor(jsonProperties: { styles?: DisplayStyleSettingsProps }) {
    if (undefined === jsonProperties.styles)
      jsonProperties.styles = {};

    this._json = jsonProperties.styles;
    this._viewFlags = ViewFlags.fromJSON(this._json.viewflags);
    this._background = ColorDef.fromJSON(this._json.backgroundColor);
    this._monochrome = undefined !== this._json.monochromeColor ? ColorDef.fromJSON(this._json.monochromeColor) : ColorDef.white.clone();
    this._backgroundMap = BackgroundMapSettings.fromJSON(this._json.backgroundMap);

    const ovrsArray = JsonUtils.asArray(this._json.subCategoryOvr);
    if (undefined !== ovrsArray) {
      for (const ovrJson of ovrsArray) {
        const subCatId = Id64.fromJSON(ovrJson.subCategory);
        if (Id64.isValid(subCatId)) {
          const subCatOvr = SubCategoryOverride.fromJSON(ovrJson);
          if (subCatOvr.anyOverridden)
            this.changeSubCategoryOverride(subCatId, false, subCatOvr);
        }
      }
    }

    const exElemArray = JsonUtils.asArray(this._json.excludedElements);
    if (undefined !== exElemArray) {
      for (const exElemStr of exElemArray) {
        const exElem = Id64.fromJSON(exElemStr);
        if (Id64.isValid(exElem)) {
          this._excludedElements.add(exElem);
        }
      }
github imodeljs / imodeljs / core / backend / src / CodeSpecs.ts View on Github external
return this._imodel.withPreparedStatement("SELECT ECInstanceId as id FROM BisCore.CodeSpec WHERE Name=?", (stmt: ECSqlStatement) => {
      stmt.bindString(1, name);
      if (DbResult.BE_SQLITE_ROW !== stmt.step())
        throw new IModelError(IModelStatus.NotFound, "CodeSpec not found", Logger.logWarning, loggingCategory, () => ({ name }));
      return Id64.fromJSON(stmt.getRow().id);
    });
  }