@itwin/presentation-backend
Version:
Backend of iTwin.js Presentation library
38 lines • 1.5 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 Core
*/
import { DefinitionElement } from "@itwin/core-backend";
import { Code } from "@itwin/core-common";
import { normalizeVersion } from "../Utils.js";
import { PresentationRules } from "./PresentationRulesDomain.js";
/** @internal */
export class Ruleset extends DefinitionElement {
/**
* Name of the `Ruleset` element class.
*/
static get className() {
return "Ruleset";
}
/**
* Generates a unique code for a ruleset
* @param iModelDb DB the ruleset is supposed to be inserted into
* @param modelId ID of a the model this ruleset should be created in
* @param ruleset The ruleset code is being created for
*/
static createRulesetCode(iModelDb, modelId, ruleset) {
let codeValue = ruleset.id;
if (ruleset.version) {
codeValue += `@${normalizeVersion(ruleset.version)}`;
}
return new Code({
spec: iModelDb.codeSpecs.getByName(PresentationRules.CodeSpec.Ruleset).id,
scope: modelId.toString(),
value: codeValue,
});
}
}
//# sourceMappingURL=RulesetElements.js.map