@itwin/ecschema-editing 4.4.0-dev.9 → 4.5.0-dev.2
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.
- package/CHANGELOG.md +6 -1
- package/lib/cjs/Editing/Constants.js.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
- package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/ECClasses.js +5 -0
- package/lib/cjs/Editing/ECClasses.js.map +1 -1
- package/lib/cjs/Editing/Editor.d.ts +1 -1
- package/lib/cjs/Editing/Editor.d.ts.map +1 -1
- package/lib/cjs/Editing/Editor.js +1 -1
- package/lib/cjs/Editing/Editor.js.map +1 -1
- package/lib/cjs/Editing/Entities.d.ts.map +1 -1
- package/lib/cjs/Editing/Entities.js +8 -6
- package/lib/cjs/Editing/Entities.js.map +1 -1
- package/lib/cjs/Editing/Enumerations.js.map +1 -1
- package/lib/cjs/Editing/Formats.d.ts.map +1 -1
- package/lib/cjs/Editing/Formats.js +2 -0
- package/lib/cjs/Editing/Formats.js.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.d.ts +1 -0
- package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.js +20 -0
- package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
- package/lib/cjs/Editing/Mixins.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts +2 -1
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts +9 -1
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
- package/lib/cjs/Editing/Phenomena.js.map +1 -1
- package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.d.ts +33 -2
- package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.js +148 -22
- package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
- package/lib/cjs/Editing/SchemaItems.js.map +1 -1
- package/lib/cjs/Editing/Structs.js.map +1 -1
- package/lib/cjs/Editing/UnitSystems.js.map +1 -1
- package/lib/cjs/Editing/Units.js.map +1 -1
- package/lib/cjs/Merging/AnyPropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/ArrayPropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ClassMerger.js +9 -1
- package/lib/cjs/Merging/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ClassPropertyMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ClassPropertyMerger.js +8 -1
- package/lib/cjs/Merging/ClassPropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts +21 -0
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/CustomAttributeMerger.js +51 -0
- package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -0
- package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts +15 -0
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/KindOfQuantityMerger.js +66 -0
- package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -0
- package/lib/cjs/Merging/MixinMerger.js.map +1 -1
- package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaItemFactory.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaItemFactory.js +10 -0
- package/lib/cjs/Merging/SchemaItemFactory.js.map +1 -1
- package/lib/cjs/Merging/SchemaItemMerger.d.ts +2 -1
- package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaItemMerger.js +11 -4
- package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js +7 -0
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
- package/lib/cjs/Merging/StructClassMerger.js.map +1 -1
- package/lib/cjs/Merging/StructPropertyMerger.js.map +1 -1
- package/lib/cjs/Validation/Diagnostic.js.map +1 -1
- package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/ECRules.d.ts +13 -3
- package/lib/cjs/Validation/ECRules.d.ts.map +1 -1
- package/lib/cjs/Validation/ECRules.js +30 -11
- package/lib/cjs/Validation/ECRules.js.map +1 -1
- package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
- package/lib/cjs/Validation/Rules.js.map +1 -1
- package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts +1 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.js +2 -4
- package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
- package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
- package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/lib/cjs/ecschema-editing.js.map +1 -1
- package/package.json +9 -9
- package/public/locales/en/ECSchemaEditing.json +26 -26
|
@@ -1,16 +1,39 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Editing
|
|
3
3
|
*/
|
|
4
|
-
import { RelationshipClass, RelationshipClassProps, SchemaItemKey, SchemaKey, StrengthDirection } from "@itwin/ecschema-metadata";
|
|
4
|
+
import { ECClassModifier, EntityClass, Mixin, NavigationPropertyProps, RelationshipClass, RelationshipClassProps, RelationshipConstraint, RelationshipEnd, RelationshipMultiplicity, SchemaItemKey, SchemaKey, StrengthDirection, StrengthType } from "@itwin/ecschema-metadata";
|
|
5
5
|
import { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from "./Editor";
|
|
6
6
|
import { ECClasses } from "./ECClasses";
|
|
7
7
|
/**
|
|
8
8
|
* @alpha
|
|
9
9
|
* A class extending ECClasses allowing you to create schema items of type RelationshipClass.
|
|
10
|
-
* Can only create RelationshipClass objects using RelationshipClassProps for now.
|
|
11
10
|
*/
|
|
12
11
|
export declare class RelationshipClasses extends ECClasses {
|
|
13
12
|
constructor(_schemaEditor: SchemaContextEditor);
|
|
13
|
+
/**
|
|
14
|
+
* Creates a RelationshipClass.
|
|
15
|
+
* @param schemaKey a SchemaKey of the Schema that will house the new object.
|
|
16
|
+
* @param name The name of the new class.
|
|
17
|
+
* @param modifier The ECClassModifier of the new class.
|
|
18
|
+
* @param strength The relationship StrengthType of the class.
|
|
19
|
+
* @param StrengthDirection The relationship StrengthDirection of the class.
|
|
20
|
+
* @param baseClassKey An optional SchemaItemKey that specifies the base relationship class.
|
|
21
|
+
*/
|
|
22
|
+
create(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, strength: StrengthType, direction: StrengthDirection, baseClassKey?: SchemaItemKey): Promise<SchemaItemEditResults>;
|
|
23
|
+
/**
|
|
24
|
+
* Sets the source RelationshipConstraint on the relationship.
|
|
25
|
+
* @param relationshipKey The SchemaItemKey for the relationship.
|
|
26
|
+
* @param source The RelationshipConstraint to add.
|
|
27
|
+
* @returns A promise of type SchemaItemEditResults.
|
|
28
|
+
*/
|
|
29
|
+
setSourceConstraint(relationshipKey: SchemaItemKey, source: RelationshipConstraint): Promise<SchemaItemEditResults>;
|
|
30
|
+
/**
|
|
31
|
+
* Sets the target RelationshipConstraint on the relationship.
|
|
32
|
+
* @param relationshipKey The SchemaItemKey for the relationship.
|
|
33
|
+
* @param target The RelationshipConstraint to add.
|
|
34
|
+
* @returns A promise of type SchemaItemEditResults.
|
|
35
|
+
*/
|
|
36
|
+
setTargetConstraint(relationshipKey: SchemaItemKey, target: RelationshipConstraint): Promise<SchemaItemEditResults>;
|
|
14
37
|
/**
|
|
15
38
|
* Creates a RelationshipClass through a RelationshipClassProps.
|
|
16
39
|
* @param schemaKey a SchemaKey of the Schema that will house the new object.
|
|
@@ -18,5 +41,13 @@ export declare class RelationshipClasses extends ECClasses {
|
|
|
18
41
|
*/
|
|
19
42
|
createFromProps(schemaKey: SchemaKey, relationshipProps: RelationshipClassProps): Promise<SchemaItemEditResults>;
|
|
20
43
|
createNavigationProperty(relationshipKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<PropertyEditResults>;
|
|
44
|
+
createNavigationPropertyFromProps(relationshipKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<PropertyEditResults>;
|
|
45
|
+
setConstraintMultiplicity(constraint: RelationshipConstraint, multiplicity: RelationshipMultiplicity): Promise<SchemaItemEditResults>;
|
|
46
|
+
setConstraintPolymorphic(constraint: RelationshipConstraint, polymorphic: boolean): Promise<SchemaItemEditResults>;
|
|
47
|
+
setConstraintRelationshipEnd(constraint: RelationshipConstraint, relationshipEnd: RelationshipEnd): Promise<SchemaItemEditResults>;
|
|
48
|
+
setAbstractConstraint(constraint: RelationshipConstraint, abstractConstraint?: EntityClass | Mixin | RelationshipClass): Promise<SchemaItemEditResults>;
|
|
49
|
+
addConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<SchemaItemEditResults>;
|
|
50
|
+
removeConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<SchemaItemEditResults>;
|
|
51
|
+
private validate;
|
|
21
52
|
}
|
|
22
53
|
//# sourceMappingURL=RelationshipClasses.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipClasses.d.ts","sourceRoot":"","sources":["../../../src/Editing/RelationshipClasses.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"RelationshipClasses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C;IAarL,iCAAiC,CAAC,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,uBAAuB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAczI,yBAAyB,CAAC,UAAU,EAAE,sBAAsB,EAAE,YAAY,EAAE,wBAAwB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAMrI,wBAAwB,CAAC,UAAU,EAAE,sBAAsB,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAMlH,4BAA4B,CAAC,UAAU,EAAE,sBAAsB,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAMlI,qBAAqB,CAAC,UAAU,EAAE,sBAAsB,EAAE,kBAAkB,CAAC,EAAE,WAAW,GAAG,KAAK,GAAG,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAyBvJ,kBAAkB,CAAC,UAAU,EAAE,sBAAsB,EAAE,OAAO,EAAE,WAAW,GAAG,KAAK,GAAG,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAmBxI,qBAAqB,CAAC,UAAU,EAAE,sBAAsB,EAAE,OAAO,EAAE,WAAW,GAAG,KAAK,GAAG,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC;YAa1I,QAAQ;CAoBvB"}
|
|
@@ -10,32 +10,72 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.RelationshipClasses = void 0;
|
|
11
11
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
12
|
const ECClasses_1 = require("./ECClasses");
|
|
13
|
+
const Rules = require("../Validation/ECRules");
|
|
13
14
|
/**
|
|
14
15
|
* @alpha
|
|
15
16
|
* A class extending ECClasses allowing you to create schema items of type RelationshipClass.
|
|
16
|
-
* Can only create RelationshipClass objects using RelationshipClassProps for now.
|
|
17
17
|
*/
|
|
18
18
|
class RelationshipClasses extends ECClasses_1.ECClasses {
|
|
19
19
|
constructor(_schemaEditor) {
|
|
20
20
|
super(_schemaEditor);
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Creates a RelationshipClass.
|
|
24
|
+
* @param schemaKey a SchemaKey of the Schema that will house the new object.
|
|
25
|
+
* @param name The name of the new class.
|
|
26
|
+
* @param modifier The ECClassModifier of the new class.
|
|
27
|
+
* @param strength The relationship StrengthType of the class.
|
|
28
|
+
* @param StrengthDirection The relationship StrengthDirection of the class.
|
|
29
|
+
* @param baseClassKey An optional SchemaItemKey that specifies the base relationship class.
|
|
30
|
+
*/
|
|
31
|
+
async create(schemaKey, name, modifier, strength, direction, baseClassKey) {
|
|
32
|
+
const schema = await this._schemaEditor.getSchema(schemaKey);
|
|
33
|
+
if (schema === undefined) {
|
|
34
|
+
return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
|
|
35
|
+
}
|
|
36
|
+
const newClass = (await schema.createRelationshipClass(name, modifier));
|
|
37
|
+
if (baseClassKey !== undefined) {
|
|
38
|
+
const baseClassSchema = !baseClassKey.schemaKey.matches(schema.schemaKey) ? await this._schemaEditor.getSchema(baseClassKey.schemaKey) : schema;
|
|
39
|
+
if (baseClassSchema === undefined) {
|
|
40
|
+
return { errorMessage: `Schema Key ${baseClassKey.schemaKey.toString(true)} not found in context` };
|
|
41
|
+
}
|
|
42
|
+
const baseClassItem = await baseClassSchema.lookupItem(baseClassKey);
|
|
43
|
+
if (baseClassItem === undefined)
|
|
44
|
+
return { errorMessage: `Unable to locate base class ${baseClassKey.fullName} in schema ${baseClassSchema.fullName}.` };
|
|
45
|
+
if (baseClassItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.RelationshipClass)
|
|
46
|
+
return { errorMessage: `${baseClassItem.fullName} is not of type Relationship Class.` };
|
|
47
|
+
newClass.baseClass = new ecschema_metadata_1.DelayedPromiseWithProps(baseClassKey, async () => baseClassItem);
|
|
48
|
+
}
|
|
49
|
+
newClass.setStrength(strength);
|
|
50
|
+
newClass.setStrengthDirection(direction);
|
|
51
|
+
return { itemKey: newClass.key };
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Sets the source RelationshipConstraint on the relationship.
|
|
55
|
+
* @param relationshipKey The SchemaItemKey for the relationship.
|
|
56
|
+
* @param source The RelationshipConstraint to add.
|
|
57
|
+
* @returns A promise of type SchemaItemEditResults.
|
|
58
|
+
*/
|
|
59
|
+
async setSourceConstraint(relationshipKey, source) {
|
|
60
|
+
const relationship = (await this._schemaEditor.schemaContext.getSchemaItem(relationshipKey));
|
|
61
|
+
if (relationship === undefined)
|
|
62
|
+
return { itemKey: relationshipKey, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };
|
|
63
|
+
relationship.setSourceConstraint(source);
|
|
64
|
+
return { itemKey: relationshipKey };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Sets the target RelationshipConstraint on the relationship.
|
|
68
|
+
* @param relationshipKey The SchemaItemKey for the relationship.
|
|
69
|
+
* @param target The RelationshipConstraint to add.
|
|
70
|
+
* @returns A promise of type SchemaItemEditResults.
|
|
71
|
+
*/
|
|
72
|
+
async setTargetConstraint(relationshipKey, target) {
|
|
73
|
+
const relationship = (await this._schemaEditor.schemaContext.getSchemaItem(relationshipKey));
|
|
74
|
+
if (relationship === undefined)
|
|
75
|
+
return { itemKey: relationshipKey, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };
|
|
76
|
+
relationship.setTargetConstraint(target);
|
|
77
|
+
return { itemKey: relationshipKey };
|
|
78
|
+
}
|
|
39
79
|
/**
|
|
40
80
|
* Creates a RelationshipClass through a RelationshipClassProps.
|
|
41
81
|
* @param schemaKey a SchemaKey of the Schema that will house the new object.
|
|
@@ -48,8 +88,6 @@ class RelationshipClasses extends ECClasses_1.ECClasses {
|
|
|
48
88
|
if (relationshipProps.name === undefined)
|
|
49
89
|
return { errorMessage: `No name was supplied within props.` };
|
|
50
90
|
const newClass = (await schema.createRelationshipClass(relationshipProps.name));
|
|
51
|
-
if (newClass === undefined)
|
|
52
|
-
return { errorMessage: `Failed to create class ${relationshipProps.name} in schema ${schemaKey.toString(true)}.` };
|
|
53
91
|
await newClass.fromJSON(relationshipProps);
|
|
54
92
|
await newClass.source.fromJSON(relationshipProps.source);
|
|
55
93
|
await newClass.target.fromJSON(relationshipProps.target);
|
|
@@ -58,12 +96,100 @@ class RelationshipClasses extends ECClasses_1.ECClasses {
|
|
|
58
96
|
async createNavigationProperty(relationshipKey, name, relationship, direction) {
|
|
59
97
|
const relationshipClass = (await this._schemaEditor.schemaContext.getSchemaItem(relationshipKey));
|
|
60
98
|
if (relationshipClass === undefined)
|
|
61
|
-
|
|
99
|
+
return { itemKey: relationshipKey, propertyName: name, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };
|
|
62
100
|
if (relationshipClass.schemaItemType !== ecschema_metadata_1.SchemaItemType.RelationshipClass)
|
|
63
|
-
|
|
101
|
+
return { itemKey: relationshipKey, propertyName: name, errorMessage: `Expected ${relationshipKey.fullName} to be of type Relationship Class.` };
|
|
64
102
|
await relationshipClass.createNavigationProperty(name, relationship, direction);
|
|
65
103
|
return { itemKey: relationshipKey, propertyName: name };
|
|
66
104
|
}
|
|
105
|
+
async createNavigationPropertyFromProps(relationshipKey, navigationProps) {
|
|
106
|
+
const relationshipClass = (await this._schemaEditor.schemaContext.getSchemaItem(relationshipKey));
|
|
107
|
+
if (relationshipClass === undefined)
|
|
108
|
+
return { itemKey: relationshipKey, propertyName: navigationProps.name, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };
|
|
109
|
+
if (relationshipClass.schemaItemType !== ecschema_metadata_1.SchemaItemType.RelationshipClass)
|
|
110
|
+
return { itemKey: relationshipKey, propertyName: navigationProps.name, errorMessage: `Expected ${relationshipKey.fullName} to be of type Relationship Class.` };
|
|
111
|
+
const property = await relationshipClass.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);
|
|
112
|
+
await property.fromJSON(navigationProps);
|
|
113
|
+
return { itemKey: relationshipKey, propertyName: navigationProps.name };
|
|
114
|
+
}
|
|
115
|
+
async setConstraintMultiplicity(constraint, multiplicity) {
|
|
116
|
+
const mutableConstraint = constraint;
|
|
117
|
+
mutableConstraint.multiplicity = multiplicity;
|
|
118
|
+
return { itemKey: constraint.relationshipClass.key };
|
|
119
|
+
}
|
|
120
|
+
async setConstraintPolymorphic(constraint, polymorphic) {
|
|
121
|
+
const mutableConstraint = constraint;
|
|
122
|
+
mutableConstraint.polymorphic = polymorphic;
|
|
123
|
+
return { itemKey: constraint.relationshipClass.key };
|
|
124
|
+
}
|
|
125
|
+
async setConstraintRelationshipEnd(constraint, relationshipEnd) {
|
|
126
|
+
const mutableConstraint = constraint;
|
|
127
|
+
mutableConstraint.relationshipEnd = relationshipEnd;
|
|
128
|
+
return { itemKey: constraint.relationshipClass.key };
|
|
129
|
+
}
|
|
130
|
+
async setAbstractConstraint(constraint, abstractConstraint) {
|
|
131
|
+
const existing = constraint.abstractConstraint;
|
|
132
|
+
const mutableConstraint = constraint;
|
|
133
|
+
if (undefined === abstractConstraint) {
|
|
134
|
+
mutableConstraint.abstractConstraint = undefined;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
mutableConstraint.abstractConstraint = new ecschema_metadata_1.DelayedPromiseWithProps(abstractConstraint.key, async () => abstractConstraint);
|
|
138
|
+
}
|
|
139
|
+
let result = await this.validate(constraint.relationshipClass);
|
|
140
|
+
if (result.errorMessage) {
|
|
141
|
+
mutableConstraint.abstractConstraint = existing;
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
result = await this.validate(constraint);
|
|
145
|
+
if (result.errorMessage) {
|
|
146
|
+
mutableConstraint.abstractConstraint = existing;
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
return { itemKey: constraint.relationshipClass.key };
|
|
150
|
+
}
|
|
151
|
+
async addConstraintClass(constraint, ecClass) {
|
|
152
|
+
const mutableConstraint = constraint;
|
|
153
|
+
mutableConstraint.addClass(ecClass);
|
|
154
|
+
let result = await this.validate(constraint.relationshipClass);
|
|
155
|
+
if (result.errorMessage) {
|
|
156
|
+
mutableConstraint.removeClass(ecClass);
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
result = await this.validate(constraint);
|
|
160
|
+
if (result.errorMessage) {
|
|
161
|
+
mutableConstraint.removeClass(ecClass);
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
return { itemKey: constraint.relationshipClass.key };
|
|
165
|
+
}
|
|
166
|
+
async removeConstraintClass(constraint, ecClass) {
|
|
167
|
+
const mutableConstraint = constraint;
|
|
168
|
+
mutableConstraint.removeClass(ecClass);
|
|
169
|
+
const result = await this.validate(constraint);
|
|
170
|
+
if (result.errorMessage) {
|
|
171
|
+
mutableConstraint.addClass(ecClass);
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
return { itemKey: constraint.relationshipClass.key };
|
|
175
|
+
}
|
|
176
|
+
async validate(relationshipOrConstraint) {
|
|
177
|
+
let diagnostics;
|
|
178
|
+
if (relationshipOrConstraint instanceof ecschema_metadata_1.RelationshipClass) {
|
|
179
|
+
diagnostics = Rules.validateRelationship(relationshipOrConstraint);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
diagnostics = Rules.validateRelationshipConstraint(relationshipOrConstraint);
|
|
183
|
+
}
|
|
184
|
+
const errorMessages = [];
|
|
185
|
+
for await (const diagnostic of diagnostics) {
|
|
186
|
+
errorMessages.push(`${diagnostic.code}: ${diagnostic.messageText}`);
|
|
187
|
+
}
|
|
188
|
+
if (errorMessages.length > 0) {
|
|
189
|
+
return { errorMessage: errorMessages.join("\r\n") };
|
|
190
|
+
}
|
|
191
|
+
return {};
|
|
192
|
+
}
|
|
67
193
|
}
|
|
68
194
|
exports.RelationshipClasses = RelationshipClasses;
|
|
69
195
|
//# sourceMappingURL=RelationshipClasses.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipClasses.js","sourceRoot":"","sources":["../../../src/Editing/RelationshipClasses.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAGkC;AAElC,2CAAwC;AAGxC;;;;GAIG;AACH,MAAa,mBAAoB,SAAQ,qBAAS;IAChD,YAAmB,aAAkC;QACnD,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;IAED,+DAA+D;IAC/D,oEAAoE;IACpE,oQAAoQ;IACpQ,kEAAkE;IAClE,sHAAsH;IAEtH,yGAAyG;IACzG,kCAAkC;IAClC,wGAAwG;IACxG,MAAM;IAEN,mCAAmC;IACnC,qFAAqF;IACrF,sHAAsH;IACtH,MAAM;IACN,oCAAoC;IACpC,8CAA8C;IAE9C,sCAAsC;IACtC,IAAI;IAEJ;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,iBAAyC;QAC1F,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,IAAI,iBAAiB,CAAC,IAAI,KAAK,SAAS;YACtC,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,uBAAuB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAA6B,CAAC;QAC5G,IAAI,QAAQ,KAAK,SAAS;YACxB,OAAO,EAAE,YAAY,EAAE,0BAA0B,iBAAiB,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAErH,MAAM,QAAQ,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;QAC3C,MAAM,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QACzD,MAAM,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAEzD,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;IACnC,CAAC;IAEM,KAAK,CAAC,wBAAwB,CAAC,eAA8B,EAAE,IAAY,EAAE,YAAwC,EAAE,SAAqC;QACjK,MAAM,iBAAiB,GAAG,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAA2B,eAAe,CAAC,CAAC,CAAC;QAE5H,IAAI,iBAAiB,KAAK,SAAS;YACjC,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,sBAAsB,eAAe,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QAEzI,IAAI,iBAAiB,CAAC,cAAc,KAAK,kCAAc,CAAC,iBAAiB;YACvE,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,qBAAqB,EAAE,YAAY,eAAe,CAAC,QAAQ,oCAAoC,CAAC,CAAC;QAE5I,MAAM,iBAAiB,CAAC,wBAAwB,CAAC,IAAI,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;QAChF,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IAC1D,CAAC;CACF;AA9DD,kDA8DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport {\r\n ECObjectsError, ECObjectsStatus, RelationshipClass, RelationshipClassProps, SchemaItemKey, SchemaItemType,\r\n SchemaKey, StrengthDirection,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { ECClasses } from \"./ECClasses\";\r\nimport { MutableRelationshipClass } from \"./Mutable/MutableRelationshipClass\";\r\n\r\n/**\r\n * @alpha\r\n * A class extending ECClasses allowing you to create schema items of type RelationshipClass.\r\n * Can only create RelationshipClass objects using RelationshipClassProps for now.\r\n */\r\nexport class RelationshipClasses extends ECClasses {\r\n public constructor(_schemaEditor: SchemaContextEditor) {\r\n super(_schemaEditor);\r\n }\r\n\r\n // // TODO: Add relationshipConstraint, multiplicity arguments.\r\n // // Note: This method is not done yet, there's a lot of arguments.\r\n // public async create(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, strength: StrengthType, direction: StrengthDirection, sourceMultiplicity: RelationshipMultiplicity, targetMultiplicity: RelationshipMultiplicity, baseClass?: SchemaItemKey) {\r\n // const schema = await this._schemaEditor.getSchema(schemaKey);\r\n // if (schema === undefined) return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n // const newClass = (await schema.createRelationshipClass(name, modifier)) as MutableRelationshipClass;\r\n // if (newClass === undefined) {\r\n // return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\r\n // }\r\n\r\n // if (baseClass !== undefined) {\r\n // const baseClassItem = await schema.lookupItem(baseClass) as RelationshipClass;\r\n // newClass.baseClass = new DelayedPromiseWithProps<SchemaItemKey, ECClass>(baseClass, async () => baseClassItem);\r\n // }\r\n // newClass.setStrength(strength);\r\n // newClass.setStrengthDirection(direction);\r\n\r\n // return { itemKey: newClass.key };\r\n // }\r\n\r\n /**\r\n * Creates a RelationshipClass through a RelationshipClassProps.\r\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\r\n * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.\r\n */\r\n public async createFromProps(schemaKey: SchemaKey, relationshipProps: RelationshipClassProps): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(schemaKey);\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n if (relationshipProps.name === undefined)\r\n return { errorMessage: `No name was supplied within props.` };\r\n\r\n const newClass = (await schema.createRelationshipClass(relationshipProps.name)) as MutableRelationshipClass;\r\n if (newClass === undefined)\r\n return { errorMessage: `Failed to create class ${relationshipProps.name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n await newClass.fromJSON(relationshipProps);\r\n await newClass.source.fromJSON(relationshipProps.source);\r\n await newClass.target.fromJSON(relationshipProps.target);\r\n\r\n return { itemKey: newClass.key };\r\n }\r\n\r\n public async createNavigationProperty(relationshipKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<PropertyEditResults> {\r\n const relationshipClass = (await this._schemaEditor.schemaContext.getSchemaItem<MutableRelationshipClass>(relationshipKey));\r\n\r\n if (relationshipClass === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Relationship Class ${relationshipKey.fullName} not found in schema context.`);\r\n\r\n if (relationshipClass.schemaItemType !== SchemaItemType.RelationshipClass)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${relationshipKey.fullName} to be of type Relationship Class.`);\r\n\r\n await relationshipClass.createNavigationProperty(name, relationship, direction);\r\n return { itemKey: relationshipKey, propertyName: name };\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RelationshipClasses.js","sourceRoot":"","sources":["../../../src/Editing/RelationshipClasses.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAIkC;AAElC,2CAAwC;AAExC,+CAA+C;AAG/C;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,qBAAS;IA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C,oBAAoB,CAAC,wBAAwB,CAAC,CAAC;SACpE;aAAM;YACL,WAAW,GAAG,KAAK,CAAC,8BAA8B,CAAC,wBAAwB,CAAC,CAAC;SAC9E;QAED,MAAM,aAAa,GAAG,EAAE,CAAC;QACzB,IAAI,KAAK,EAAE,MAAM,UAAU,IAAI,WAAW,EAAE;YAC1C,aAAa,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,IAAI,KAAK,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;SACrE;QAED,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;YAC5B,OAAO,EAAE,YAAY,EAAE,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;SACrD;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AA1ND,kDA0NC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport {\n DelayedPromiseWithProps, ECClassModifier, EntityClass, LazyLoadedRelationshipConstraintClass, Mixin, NavigationPropertyProps,\n RelationshipClass, RelationshipClassProps, RelationshipConstraint, RelationshipEnd, RelationshipMultiplicity, SchemaItemKey, SchemaItemType,\n SchemaKey, StrengthDirection, StrengthType,\n} from \"@itwin/ecschema-metadata\";\nimport { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableRelationshipClass, MutableRelationshipConstraint } from \"./Mutable/MutableRelationshipClass\";\nimport * as Rules from \"../Validation/ECRules\";\nimport { RelationshipConstraintDiagnostic, SchemaItemDiagnostic } from \"../Validation/Diagnostic\";\n\n/**\n * @alpha\n * A class extending ECClasses allowing you to create schema items of type RelationshipClass.\n */\nexport class RelationshipClasses extends ECClasses {\n public constructor(_schemaEditor: SchemaContextEditor) {\n super(_schemaEditor);\n }\n\n /**\n * Creates a RelationshipClass.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param name The name of the new class.\n * @param modifier The ECClassModifier of the new class.\n * @param strength The relationship StrengthType of the class.\n * @param StrengthDirection The relationship StrengthDirection of the class.\n * @param baseClassKey An optional SchemaItemKey that specifies the base relationship class.\n */\n public async create(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, strength: StrengthType, direction: StrengthDirection, baseClassKey?: SchemaItemKey): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined) {\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n }\n\n const newClass = (await schema.createRelationshipClass(name, modifier)) as MutableRelationshipClass;\n if (baseClassKey !== undefined) {\n const baseClassSchema = !baseClassKey.schemaKey.matches(schema.schemaKey) ? await this._schemaEditor.getSchema(baseClassKey.schemaKey) : schema;\n if (baseClassSchema === undefined) {\n return { errorMessage: `Schema Key ${baseClassKey.schemaKey.toString(true)} not found in context` };\n }\n\n const baseClassItem = await baseClassSchema.lookupItem<RelationshipClass>(baseClassKey);\n if (baseClassItem === undefined)\n return { errorMessage: `Unable to locate base class ${baseClassKey.fullName} in schema ${baseClassSchema.fullName}.` };\n\n if (baseClassItem.schemaItemType !== SchemaItemType.RelationshipClass)\n return { errorMessage: `${baseClassItem.fullName} is not of type Relationship Class.` };\n\n newClass.baseClass = new DelayedPromiseWithProps<SchemaItemKey, RelationshipClass>(baseClassKey, async () => baseClassItem);\n }\n\n newClass.setStrength(strength);\n newClass.setStrengthDirection(direction);\n\n return { itemKey: newClass.key };\n }\n\n /**\n * Sets the source RelationshipConstraint on the relationship.\n * @param relationshipKey The SchemaItemKey for the relationship.\n * @param source The RelationshipConstraint to add.\n * @returns A promise of type SchemaItemEditResults.\n */\n public async setSourceConstraint(relationshipKey: SchemaItemKey, source: RelationshipConstraint): Promise<SchemaItemEditResults> {\n const relationship = (await this._schemaEditor.schemaContext.getSchemaItem<MutableRelationshipClass>(relationshipKey));\n\n if (relationship === undefined)\n return { itemKey: relationshipKey, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };\n\n relationship.setSourceConstraint(source);\n return { itemKey: relationshipKey };\n }\n\n /**\n * Sets the target RelationshipConstraint on the relationship.\n * @param relationshipKey The SchemaItemKey for the relationship.\n * @param target The RelationshipConstraint to add.\n * @returns A promise of type SchemaItemEditResults.\n */\n public async setTargetConstraint(relationshipKey: SchemaItemKey, target: RelationshipConstraint): Promise<SchemaItemEditResults> {\n const relationship = (await this._schemaEditor.schemaContext.getSchemaItem<MutableRelationshipClass>(relationshipKey));\n\n if (relationship === undefined)\n return { itemKey: relationshipKey, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };\n\n relationship.setTargetConstraint(target);\n return { itemKey: relationshipKey };\n }\n\n /**\n * Creates a RelationshipClass through a RelationshipClassProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, relationshipProps: RelationshipClassProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (relationshipProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newClass = (await schema.createRelationshipClass(relationshipProps.name)) as MutableRelationshipClass;\n await newClass.fromJSON(relationshipProps);\n await newClass.source.fromJSON(relationshipProps.source);\n await newClass.target.fromJSON(relationshipProps.target);\n\n return { itemKey: newClass.key };\n }\n\n public async createNavigationProperty(relationshipKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<PropertyEditResults> {\n const relationshipClass = (await this._schemaEditor.schemaContext.getSchemaItem<MutableRelationshipClass>(relationshipKey));\n\n if (relationshipClass === undefined)\n return { itemKey: relationshipKey, propertyName: name, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };\n\n if (relationshipClass.schemaItemType !== SchemaItemType.RelationshipClass)\n return { itemKey: relationshipKey, propertyName: name, errorMessage: `Expected ${relationshipKey.fullName} to be of type Relationship Class.` };\n\n await relationshipClass.createNavigationProperty(name, relationship, direction);\n return { itemKey: relationshipKey, propertyName: name };\n }\n\n public async createNavigationPropertyFromProps(relationshipKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<PropertyEditResults> {\n const relationshipClass = (await this._schemaEditor.schemaContext.getSchemaItem<MutableRelationshipClass>(relationshipKey));\n\n if (relationshipClass === undefined)\n return { itemKey: relationshipKey, propertyName: navigationProps.name, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };\n\n if (relationshipClass.schemaItemType !== SchemaItemType.RelationshipClass)\n return { itemKey: relationshipKey, propertyName: navigationProps.name, errorMessage: `Expected ${relationshipKey.fullName} to be of type Relationship Class.` };\n\n const property = await relationshipClass.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);\n await property.fromJSON(navigationProps);\n return { itemKey: relationshipKey, propertyName: navigationProps.name };\n }\n\n public async setConstraintMultiplicity(constraint: RelationshipConstraint, multiplicity: RelationshipMultiplicity): Promise<SchemaItemEditResults> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.multiplicity = multiplicity;\n return { itemKey: constraint.relationshipClass.key };\n }\n\n public async setConstraintPolymorphic(constraint: RelationshipConstraint, polymorphic: boolean): Promise<SchemaItemEditResults> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.polymorphic = polymorphic;\n return { itemKey: constraint.relationshipClass.key };\n }\n\n public async setConstraintRelationshipEnd(constraint: RelationshipConstraint, relationshipEnd: RelationshipEnd): Promise<SchemaItemEditResults> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.relationshipEnd = relationshipEnd;\n return { itemKey: constraint.relationshipClass.key };\n }\n\n public async setAbstractConstraint(constraint: RelationshipConstraint, abstractConstraint?: EntityClass | Mixin | RelationshipClass): Promise<SchemaItemEditResults> {\n const existing: LazyLoadedRelationshipConstraintClass | undefined = constraint.abstractConstraint;\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n\n if (undefined === abstractConstraint) {\n mutableConstraint.abstractConstraint = undefined;\n } else {\n mutableConstraint.abstractConstraint = new DelayedPromiseWithProps(abstractConstraint.key, async () => abstractConstraint);\n }\n\n let result = await this.validate(constraint.relationshipClass);\n if (result.errorMessage) {\n mutableConstraint.abstractConstraint = existing;\n return result;\n }\n\n result = await this.validate(constraint);\n if (result.errorMessage) {\n mutableConstraint.abstractConstraint = existing;\n return result;\n }\n\n return { itemKey: constraint.relationshipClass.key };\n }\n\n public async addConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<SchemaItemEditResults> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.addClass(ecClass);\n\n let result = await this.validate(constraint.relationshipClass);\n if (result.errorMessage) {\n mutableConstraint.removeClass(ecClass);\n return result;\n }\n\n result = await this.validate(constraint);\n if (result.errorMessage) {\n mutableConstraint.removeClass(ecClass);\n return result;\n }\n\n return { itemKey: constraint.relationshipClass.key };\n }\n\n public async removeConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<SchemaItemEditResults> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.removeClass(ecClass);\n\n const result = await this.validate(constraint);\n if (result.errorMessage) {\n mutableConstraint.addClass(ecClass);\n return result;\n }\n\n return { itemKey: constraint.relationshipClass.key };\n }\n\n private async validate(relationshipOrConstraint: RelationshipClass | RelationshipConstraint): Promise<SchemaItemEditResults> {\n let diagnostics: AsyncIterable<SchemaItemDiagnostic<RelationshipClass, any[]>> | AsyncIterable<RelationshipConstraintDiagnostic<any[]>>;\n\n if (relationshipOrConstraint instanceof RelationshipClass) {\n diagnostics = Rules.validateRelationship(relationshipOrConstraint);\n } else {\n diagnostics = Rules.validateRelationshipConstraint(relationshipOrConstraint);\n }\n\n const errorMessages = [];\n for await (const diagnostic of diagnostics) {\n errorMessages.push(`${diagnostic.code}: ${diagnostic.messageText}`);\n }\n\n if (errorMessages.length > 0) {\n return { errorMessage: errorMessages.join(\"\\r\\n\") };\n }\n\n return {};\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaItems.js","sourceRoot":"","sources":["../../../src/Editing/SchemaItems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAA2G;AAG3G;;;GAGG;AACH,MAAa,WAAW;IACtB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,UAAU,CAAC,aAA4B,EAAE,cAA+B;QACnF,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAEvF,IAAI,UAAU,KAAK,SAAS;YAC1B,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,eAAe,aAAa,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QAEhI,MAAM,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC5C,CAAC;CACF;AAVD,kCAUC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"SchemaItems.js","sourceRoot":"","sources":["../../../src/Editing/SchemaItems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAA2G;AAG3G;;;GAGG;AACH,MAAa,WAAW;IACtB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,UAAU,CAAC,aAA4B,EAAE,cAA+B;QACnF,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAEvF,IAAI,UAAU,KAAK,SAAS;YAC1B,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,eAAe,aAAa,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QAEhI,MAAM,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC5C,CAAC;CACF;AAVD,kCAUC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { ECObjectsError, ECObjectsStatus, SchemaItemKey, SchemaItemProps } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\n\n/**\n * @internal\n * A class allowing you to edit the schema item base class.\n */\nexport class SchemaItems {\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\n public async applyProps(schemaItemKey: SchemaItemKey, schemItemProps: SchemaItemProps): Promise<void> {\n const schemaItem = await this._schemaEditor.schemaContext.getSchemaItem(schemaItemKey);\n\n if (schemaItem === undefined)\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Schema Item ${schemaItemKey.fullName} not found in schema context.`);\n\n await schemaItem.fromJSON(schemItemProps);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Structs.js","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAqJ;AAErJ,2CAAwC;AAGxC;;GAEG;AACH,MAAa,OAAQ,SAAQ,qBAAS;IACpC,YAAmB,aAAkC;QACnD,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB,EAAE,SAAyB;QACtG,MAAM,MAAM,GAAG,MAAM,IAAI,CAA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AY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,IAAI,WAAW,CAAC,IAAI,KAAK,SAAS;YAChC,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAiB,CAAC;QACpF,IAAI,QAAQ,KAAK,SAAS;YACxB,OAAO,EAAE,YAAY,EAAE,0BAA0B,WAAW,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAE/G,MAAM,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACrC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;IACnC,CAAC;CACF;AAnDD,0BAmDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"Structs.js","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAqJ;AAErJ,2CAAwC;AAGxC;;GAEG;AACH,MAAa,OAAQ,SAAQ,qBAAS;IACpC,YAAmB,aAAkC;QACnD,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB,EAAE,SAAyB;QACtG,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAu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AAC,CAAiB,CAAC;QACpF,IAAI,QAAQ,KAAK,SAAS;YACxB,OAAO,EAAE,YAAY,EAAE,0BAA0B,WAAW,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAE/G,MAAM,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACrC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;IACnC,CAAC;CACF;AAnDD,0BAmDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { DelayedPromiseWithProps, ECClass, SchemaItemKey, SchemaItemType, SchemaKey, StructClass, StructClassProps } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableClass, MutableStructClass } from \"./Mutable/MutableClass\";\n\n/**\n * @alpha A class extending ECClasses allowing you to create schema items of type StructClass.\n */\nexport class Structs extends ECClasses {\n public constructor(_schemaEditor: SchemaContextEditor) {\n super(_schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string, baseClass?: SchemaItemKey): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n const newClass = (await schema.createStructClass(name)) as MutableStructClass;\n if (newClass === undefined)\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\n\n if (baseClass !== undefined) {\n const baseClassItem = await schema.lookupItem<StructClass>(baseClass);\n if (baseClassItem === undefined)\n return { errorMessage: `Unable to locate base class ${baseClass.fullName} in schema ${schema.fullName}.` };\n\n if (baseClassItem.schemaItemType !== SchemaItemType.StructClass)\n return { errorMessage: `${baseClassItem.fullName} is not of type Struct Class.` };\n\n newClass.baseClass = new DelayedPromiseWithProps<SchemaItemKey, ECClass>(baseClass, async () => baseClassItem);\n }\n\n if (displayLabel)\n newClass.setDisplayLabel(displayLabel);\n\n return { itemKey: newClass.key };\n }\n\n /**\n * Creates a StructClass through a StructClassProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param structProps a json object that will be used to populate the new StructClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, structProps: StructClassProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (structProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newClass = (await schema.createStructClass(structProps.name)) as MutableClass;\n if (newClass === undefined)\n return { errorMessage: `Failed to create class ${structProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newClass.fromJSON(structProps);\n return { itemKey: newClass.key };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitSystems.js","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAMH;;;GAGG;AACH,MAAa,WAAW;IACtB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB;QAC3E,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,MAAM,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAsB,CAAC;QACjF,IAAI,YAAY;YACd,aAAa,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QAE9C,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC;IACxC,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,eAAgC;QACjF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,IAAI,eAAe,CAAC,IAAI,KAAK,SAAS;YACpC,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAsB,CAAC;QACjG,IAAI,aAAa,KAAK,SAAS;YAC7B,OAAO,EAAE,YAAY,EAAE,0BAA0B,eAAe,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAEnH,MAAM,aAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC9C,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC;IACxC,CAAC;CACF;AA7BD,kCA6BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"UnitSystems.js","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAMH;;;GAGG;AACH,MAAa,WAAW;IACtB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAA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copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { SchemaKey, UnitSystemProps } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableUnitSystem } from \"./Mutable/MutableUnitSystem\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type UnitSystems.\n */\nexport class UnitSystems {\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n const newUnitSystem = (await schema.createUnitSystem(name)) as MutableUnitSystem;\n if (displayLabel)\n newUnitSystem.setDisplayLabel(displayLabel);\n\n return { itemKey: newUnitSystem.key };\n }\n\n public async createFromProps(schemaKey: SchemaKey, unitSystemProps: UnitSystemProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (unitSystemProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newUnitSystem = (await schema.createUnitSystem(unitSystemProps.name)) as MutableUnitSystem;\n if (newUnitSystem === undefined)\n return { errorMessage: `Failed to create class ${unitSystemProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newUnitSystem.fromJSON(unitSystemProps);\n return { itemKey: newUnitSystem.key };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Units.js","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAA0J;AAI1J;;;GAGG;AACH,MAAa,KAAK;IAChB,6CAA6C;IAC7C,Y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ent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"Units.js","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAA0J;AAI1J;;;GAGG;AACH,MAAa,KAAK;IAChB,6CAA6C;IAC7C,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAE7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAkB,EAAE,UAAyB,EAAE,UAAyB,EAAE,YAAqB;QACrJ,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,MAAM,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAgB,CAAC;QAC/D,IAAI,OAAO,KAAK,SAAS;YACvB,OAAO,EAAE,YAAY,EAAE,0BAA0B,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAEnG,MAAM,cAAc,GAAG,MAAM,MAAM,CAAC,UAAU,CAAa,UAAU,CAAC,CAAC;QACvE,IAAI,cAAc,KAAK,SAAS;YAC9B,OAAO,EAAE,YAAY,EAAE,+BAA+B,UAAU,CAAC,QAAQ,cAAc,MAAM,CAAC,QAAQ,GAAG,EAAE,CAAC;QAE9G,IAAI,cAAc,CAAC,cAAc,KAAK,kCAAc,CAAC,UAAU;YAC7D,OAAO,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC,QAAQ,6BAA6B,EAAE,CAAC;QAE/E,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAA4B,UAAU,EAAE,KAAK,IAAI,EAA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AAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7G,MAAM,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAClC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;IAClC,CAAC;CACF;AAtDD,sBAsDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { DelayedPromiseWithProps, Phenomenon, SchemaItemKey, SchemaItemType, SchemaItemUnitProps, SchemaKey, UnitSystem } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableUnit } from \"./Mutable/MutableUnit\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Unit.\n */\nexport class Units {\n // TODO: Add more setters for all attributes.\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\n\n public async create(schemaKey: SchemaKey, name: string, definition: string, phenomenon: SchemaItemKey, unitSystem: SchemaItemKey, displayLabel?: string): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n const newUnit = (await schema.createUnit(name)) as MutableUnit;\n if (newUnit === undefined)\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\n\n const phenomenonItem = await schema.lookupItem<Phenomenon>(phenomenon);\n if (phenomenonItem === undefined)\n return { errorMessage: `Unable to locate phenomenon ${phenomenon.fullName} in schema ${schema.fullName}.` };\n\n if (phenomenonItem.schemaItemType !== SchemaItemType.Phenomenon)\n return { errorMessage: `${phenomenon.fullName} is not of type Phenomenon.` };\n\n await newUnit.setPhenomenon(new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(phenomenon, async () => phenomenonItem));\n\n const unitSystemItem = await schema.lookupItem<UnitSystem>(unitSystem);\n if (unitSystemItem === undefined)\n return { errorMessage: `Unable to locate unit system ${unitSystem.fullName} in schema ${schema.fullName}.` };\n\n if (unitSystemItem.schemaItemType !== SchemaItemType.UnitSystem)\n return { errorMessage: `${unitSystem.fullName} is not of type UnitSystem.` };\n\n await newUnit.setUnitSystem(new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystem, async () => unitSystemItem));\n\n await newUnit.setDefinition(definition);\n\n if (displayLabel)\n newUnit.setDisplayLabel(displayLabel);\n\n return { itemKey: newUnit.key };\n }\n\n public async createFromProps(schemaKey: SchemaKey, unitProps: SchemaItemUnitProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (unitProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newUnit = (await schema.createUnit(unitProps.name));\n if (newUnit === undefined)\n return { errorMessage: `Failed to create class ${unitProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newUnit.fromJSON(unitProps);\n return { itemKey: newUnit.key };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnyPropertyMerger.js","sourceRoot":"","sources":["../../../src/Merging/AnyPropertyMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA0I;AAK1I;;GAEG;AACH,MAAa,iBAAiB;IAG5B,YAAY,OAA2B;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAwB,EAAE,QAAmB;QACxE,OAAO,EAAE,YAAY,EAAE,iBAAiB,IAAA,wCAAoB,EAAC,QAAQ,CAAC,YAAY,CAAC,sBAAsB,EAAE,CAAC;IAC9G,CAAC;IAES,qBAAqB,CAAC,GAAQ;QACtC,OAAO,OAAO,GAAG,KAAK,Q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SAAS,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,UAAU,CAAiB,OAAO,CAAC,CAAC;YACtF,IAAI,SAAS,KAAK,SAAS,EAAE;gBAC3B,OAAO,EAAE,YAAY,EAAE,kDAAkD,SAAS,CAAC,IAAI,wBAAwB,EAAE,CAAC;aACnH;YACD,KAAK,GAAG,EAAC,GAAG,KAAK,EAAE,cAAc,EAAE,SAAS,CAAC,QAAQ,EAAC,CAAC;SACxD;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,QAAmB,EAAE,aAAqB,EAAE,iBAAsB,EAAE,kBAAuB;QACtH,MAAM,eAAe,GAAG,QAAsC,CAAC;QAC/D,QAAO,aAAa,EAAE;YACpB,KAAK,aAAa;gBAChB,eAAe,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;gBAClD,OAAO,IAAI,CAAC;YACd,KAAK,OAAO;gBACV,eAAe,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;gBAC5C,OAAO,IAAI,CAAC;YACd,KAAK,YAAY;gBACf,eAAe,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;gBACjD,OAAO,IAAI,CAAC;YACd,KAAK,UAAU;gBACb,eAAe,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;gBAC/C,OAAO,IAAI,CAAC;YACd,KAAK,MAAM,CAAC;YACZ,KAAK,eAAe;gBAClB,OAAO,EAAE,YAAY,EAAE,0BAA0B,QAAQ,CAAC,IAAI,KAAK,aAAa,oBAAoB,EAAE,CAAC;SAC1G;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAnED,8CAmEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"AnyPropertyMerger.js","sourceRoot":"","sources":["../../../src/Merging/AnyPropertyMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA0I;AAK1I;;GAEG;AACH,MAAa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0BAA0B,QAAQ,CAAC,IAAI,KAAK,aAAa,oBAAoB,EAAE,CAAC;SAC1G;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAnED,8CAmEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { KindOfQuantity, Property, PropertyCategory, PropertyProps, propertyTypeToString, SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { PropertyEditResults } from \"../Editing/Editor\";\nimport { MutableProperty } from \"../Editing/Mutable/MutableProperty\";\n\n/**\n * @internal\n */\nexport class AnyPropertyMerger<TProperty extends Property> {\n protected readonly context: SchemaMergeContext;\n\n constructor(context: SchemaMergeContext) {\n this.context = context;\n }\n\n public async createFromProps(_classKey: SchemaItemKey, property: TProperty): Promise<PropertyEditResults> {\n return { errorMessage: `Property Type ${propertyTypeToString(property.propertyType)} is not implemented.` };\n }\n\n protected isPropertyEditResults(obj: any): obj is PropertyEditResults {\n return typeof obj === \"object\" && \"errorMessage\" in obj;\n }\n\n protected async getPropertyProps(property: TProperty): Promise<PropertyEditResults | PropertyProps> {\n let props = {} as PropertyProps;\n\n if (property.category !== undefined) {\n const sourceCategory = await property.category;\n const itemKey = new SchemaItemKey(sourceCategory.name, this.context.sourceSchema.schemaKey.matches(sourceCategory.schema.schemaKey)\n ? this.context.targetSchema.schemaKey\n : sourceCategory.schema.schemaKey,\n );\n const targetCategory = await this.context.targetSchema.lookupItem<PropertyCategory>(itemKey);\n if (targetCategory === undefined) {\n return { errorMessage: `Unable to locate the property category class ${sourceCategory.name} in the merged schema.` };\n }\n props = {...props, category: targetCategory.fullName};\n }\n\n if (property.kindOfQuantity !== undefined) {\n const sourceKoq = await property.kindOfQuantity;\n const itemKey = new SchemaItemKey(sourceKoq.name, this.context.sourceSchema.schemaKey.matches(sourceKoq.schema.schemaKey)\n ? this.context.targetSchema.schemaKey\n : sourceKoq.schema.schemaKey,\n );\n const targetKoq = await this.context.targetSchema.lookupItem<KindOfQuantity>(itemKey);\n if (targetKoq === undefined) {\n return { errorMessage: `Unable to locate the property kind of quantity ${sourceKoq.name} in the merged schema.` };\n }\n props = {...props, kindOfQuantity: targetKoq.fullName};\n }\n return props;\n }\n\n public async mergeAttributes(property: TProperty, attributeName: string, attributeNewValue: any, _attributeOldValue: any): Promise<PropertyEditResults | boolean> {\n const mutableProperty = property as unknown as MutableProperty;\n switch(attributeName) {\n case \"description\":\n mutableProperty.setDescription(attributeNewValue);\n return true;\n case \"label\":\n mutableProperty.setLabel(attributeNewValue);\n return true;\n case \"isReadOnly\":\n mutableProperty.setIsReadOnly(attributeNewValue);\n return true;\n case \"priority\":\n mutableProperty.setPriority(attributeNewValue);\n return true;\n case \"type\":\n case \"primitiveType\":\n return { errorMessage: `Changing the property '${property.name}' ${attributeName} is not supported.` };\n }\n return false;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayPropertyMerger.js","sourceRoot":"","sources":["../../../src/Merging/ArrayPropertyMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAmM;AAEnM,2DAAwD;AAIxD;;GAEG;AACH,MAAM,mBAA2D,SAAQ,qCAAkC;IACzF,KAAK,CAAC,eAAe,CAAC,QAAwB,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QACnI,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,eAAe,CAAC,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;QAC3G,IAAI,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;YACjG,OAAO,OAAO,CAAC;SAChB;QAED,MAAM,eAAe,GAAG,QAA2C,CAAC;QACpE,QA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3BD,kEA2BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { ArrayProperty, Enumeration, EnumerationArrayProperty, PrimitiveArrayProperty, SchemaItemKey, StructArrayProperty, StructArrayPropertyProps, StructClass } from \"@itwin/ecschema-metadata\";\r\nimport { PrimitiveArrayPropertyProps } from \"@itwin/ecschema-metadata/src/Deserialization/JsonProps\";\r\nimport { AnyPropertyMerger } from \"./AnyPropertyMerger\";\r\nimport { PropertyEditResults } from \"../Editing/Editor\";\r\nimport { MutableArrayProperty } from \"../Editing/Mutable/MutableArrayProperty\";\r\n\r\n/**\r\n * @internal\r\n */\r\nclass ArrayPropertyMerger<TArrayProperty extends ArrayProperty> extends AnyPropertyMerger <TArrayProperty> {\r\n public override async mergeAttributes(property: TArrayProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\r\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n const mutableProperty = property as unknown as MutableArrayProperty;\r\n switch (attributeName) {\r\n case \"minOccurs\":\r\n mutableProperty.setMinOccurs(attributeNewValue);\r\n return true;\r\n\r\n case \"maxOccurs\":\r\n mutableProperty.setMaxOccurs(attributeNewValue);\r\n return true;\r\n\r\n }\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class StructArrayPropertyMerger extends ArrayPropertyMerger <StructArrayProperty> {\r\n public override async mergeAttributes(property: StructArrayProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\r\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n switch (attributeName) {\r\n case \"structClass\": {\r\n if (attributeOldValue !== undefined) {\r\n return { errorMessage: `Changing the property '${property.name}' structClass is not supported.` };\r\n }\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n public override async createFromProps(classKey: SchemaItemKey, property: StructArrayProperty): Promise<PropertyEditResults> {\r\n const results = await super.getPropertyProps(property);\r\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n const itemKey = new SchemaItemKey(property.structClass.name, this.context.sourceSchema.schemaKey.matches(property.structClass.schema.schemaKey)\r\n ? this.context.targetSchema.schemaKey\r\n : property.structClass.schema.schemaKey,\r\n );\r\n const type = await this.context.targetSchema.lookupItem<StructClass>(itemKey);\r\n if (type === undefined) {\r\n return { errorMessage: `Unable to locate the struct class ${property.structClass.name} in the merged schema.` };\r\n }\r\n\r\n const props: StructArrayPropertyProps = {\r\n ...property.toJSON(),\r\n ...results,\r\n typeName: type.fullName,\r\n };\r\n return this.context.editor.entities.createStructArrayPropertyFromProps(classKey, property.name, type, props);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class EnumerationArrayPropertyMerger extends ArrayPropertyMerger <EnumerationArrayProperty> {\r\n public override async mergeAttributes(property: EnumerationArrayProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\r\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n switch (attributeName) {\r\n case \"enumeration\": {\r\n if (attributeOldValue !== undefined) {\r\n return { errorMessage: `Changing the property '${property.name}' enumeration is not supported.` };\r\n }\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n public override async createFromProps(classKey: SchemaItemKey, property: EnumerationArrayProperty): Promise<PropertyEditResults> {\r\n const results = await super.getPropertyProps(property);\r\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n if (property.enumeration === undefined) {\r\n return { errorMessage: `Property '${property.fullName}' is missing the required 'enumeration' attribute.` };\r\n }\r\n\r\n const enumeration = await property.enumeration;\r\n const itemKey = new SchemaItemKey(enumeration.name, this.context.sourceSchema.schemaKey.matches(enumeration.schema.schemaKey)\r\n ? this.context.targetSchema.schemaKey\r\n : enumeration.schema.schemaKey,\r\n );\r\n const type = await this.context.targetSchema.lookupItem<Enumeration>(itemKey);\r\n if (type === undefined) {\r\n return { errorMessage: `Unable to locate the enumeration class ${enumeration.name} in the merged schema.` };\r\n }\r\n\r\n const props: PrimitiveArrayPropertyProps = {\r\n ...property.toJSON(),\r\n ...results,\r\n };\r\n return this.context.editor.entities.createEnumerationArrayPropertyFromProps(classKey, property.name, type, props);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class PrimitiveArraPropertyMerger extends ArrayPropertyMerger <PrimitiveArrayProperty> {\r\n public override async mergeAttributes(property: PrimitiveArrayProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\r\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n switch (attributeName) {\r\n case \"primitiveType\": {\r\n return { errorMessage: `Changing the property '${property.name}' typeName is not supported.`};\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n public override async createFromProps(classKey: SchemaItemKey, property: PrimitiveArrayProperty): Promise<PropertyEditResults> {\r\n const results = await super.getPropertyProps(property);\r\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n const props: PrimitiveArrayPropertyProps = {\r\n ...property.toJSON(),\r\n ...results,\r\n };\r\n return this.context.editor.entities.createPrimitiveArrayPropertyFromProps(classKey, property.name, property.primitiveType, props);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":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CAAC;aAC/F;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEe,KAAK,CAAC,eAAe,CAAC,QAAuB,EAAE,QAAgC;QAC7F,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACvD,IAAI,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;YAC7E,OAAO,OAAO,CAAC;SAChB;QAED,MAAM,KAAK,GAAgC;YACzC,GAAG,QAAQ,CAAC,MAAM,EAAE;YACpB,GAAG,OAAO;SACX,CAAC;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,qCAAqC,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IACpI,CAAC;CACF;AA3BD,kEA2BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { ArrayProperty, Enumeration, EnumerationArrayProperty, PrimitiveArrayProperty, SchemaItemKey, StructArrayProperty, StructArrayPropertyProps, StructClass } from \"@itwin/ecschema-metadata\";\nimport { PrimitiveArrayPropertyProps } from \"@itwin/ecschema-metadata/src/Deserialization/JsonProps\";\nimport { AnyPropertyMerger } from \"./AnyPropertyMerger\";\nimport { PropertyEditResults } from \"../Editing/Editor\";\nimport { MutableArrayProperty } from \"../Editing/Mutable/MutableArrayProperty\";\n\n/**\n * @internal\n */\nclass ArrayPropertyMerger<TArrayProperty extends ArrayProperty> extends AnyPropertyMerger <TArrayProperty> {\n public override async mergeAttributes(property: TArrayProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n const mutableProperty = property as unknown as MutableArrayProperty;\n switch (attributeName) {\n case \"minOccurs\":\n mutableProperty.setMinOccurs(attributeNewValue);\n return true;\n\n case \"maxOccurs\":\n mutableProperty.setMaxOccurs(attributeNewValue);\n return true;\n\n }\n return false;\n }\n}\n\n/**\n * @internal\n */\nexport class StructArrayPropertyMerger extends ArrayPropertyMerger <StructArrayProperty> {\n public override async mergeAttributes(property: StructArrayProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n switch (attributeName) {\n case \"structClass\": {\n if (attributeOldValue !== undefined) {\n return { errorMessage: `Changing the property '${property.name}' structClass is not supported.` };\n }\n return true;\n }\n }\n return false;\n }\n\n public override async createFromProps(classKey: SchemaItemKey, property: StructArrayProperty): Promise<PropertyEditResults> {\n const results = await super.getPropertyProps(property);\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n const itemKey = new SchemaItemKey(property.structClass.name, this.context.sourceSchema.schemaKey.matches(property.structClass.schema.schemaKey)\n ? this.context.targetSchema.schemaKey\n : property.structClass.schema.schemaKey,\n );\n const type = await this.context.targetSchema.lookupItem<StructClass>(itemKey);\n if (type === undefined) {\n return { errorMessage: `Unable to locate the struct class ${property.structClass.name} in the merged schema.` };\n }\n\n const props: StructArrayPropertyProps = {\n ...property.toJSON(),\n ...results,\n typeName: type.fullName,\n };\n return this.context.editor.entities.createStructArrayPropertyFromProps(classKey, property.name, type, props);\n }\n}\n\n/**\n * @internal\n */\nexport class EnumerationArrayPropertyMerger extends ArrayPropertyMerger <EnumerationArrayProperty> {\n public override async mergeAttributes(property: EnumerationArrayProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n switch (attributeName) {\n case \"enumeration\": {\n if (attributeOldValue !== undefined) {\n return { errorMessage: `Changing the property '${property.name}' enumeration is not supported.` };\n }\n return true;\n }\n }\n return false;\n }\n\n public override async createFromProps(classKey: SchemaItemKey, property: EnumerationArrayProperty): Promise<PropertyEditResults> {\n const results = await super.getPropertyProps(property);\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n if (property.enumeration === undefined) {\n return { errorMessage: `Property '${property.fullName}' is missing the required 'enumeration' attribute.` };\n }\n\n const enumeration = await property.enumeration;\n const itemKey = new SchemaItemKey(enumeration.name, this.context.sourceSchema.schemaKey.matches(enumeration.schema.schemaKey)\n ? this.context.targetSchema.schemaKey\n : enumeration.schema.schemaKey,\n );\n const type = await this.context.targetSchema.lookupItem<Enumeration>(itemKey);\n if (type === undefined) {\n return { errorMessage: `Unable to locate the enumeration class ${enumeration.name} in the merged schema.` };\n }\n\n const props: PrimitiveArrayPropertyProps = {\n ...property.toJSON(),\n ...results,\n };\n return this.context.editor.entities.createEnumerationArrayPropertyFromProps(classKey, property.name, type, props);\n }\n}\n\n/**\n * @internal\n */\nexport class PrimitiveArraPropertyMerger extends ArrayPropertyMerger <PrimitiveArrayProperty> {\n public override async mergeAttributes(property: PrimitiveArrayProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n switch (attributeName) {\n case \"primitiveType\": {\n return { errorMessage: `Changing the property '${property.name}' typeName is not supported.`};\n }\n }\n return false;\n }\n\n public override async createFromProps(classKey: SchemaItemKey, property: PrimitiveArrayProperty): Promise<PropertyEditResults> {\n const results = await super.getPropertyProps(property);\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n const props: PrimitiveArrayPropertyProps = {\n ...property.toJSON(),\n ...results,\n };\n return this.context.editor.entities.createPrimitiveArrayPropertyFromProps(classKey, property.name, property.primitiveType, props);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CAClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/CAClassMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAA8G;AAC9G,+CAA4C;AAI5C;;GAEG;AACH,MAAqB,aAAc,SAAQ,yBAAiC;IAEvD,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAA6B;QACjF,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACrG,CAAC;IAEkB,KAAK,CAAC,eAAe,CAAC,OAA6B,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QAC3I,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;QAC1G,IAAI,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;YACnG,OAAO,OAAO,CAAC;SAChB;QAED,MAAM,cAAc,GAAG,OAAoC,CAAC;QAC5D,QAAO,aAAa,EAAE;YACpB,KAAK,WAAW;gBACd,IAAI,iBAAiB,KAAK,SAAS,IAAI,iBAAiB,KAAK,iBAAiB,EAAE;oBAC9E,MAAM,aAAa,GAAG,IAAA,qDAAiC,EAAC,GAAG,iBAAiB,KAAK,iBAAiB,EAAE,CAAC,CAAC;oBACtG,IAAI,aAAa,KAAK,SAAS,EAAE;wBAC/B,OAAO,EAAE,YAAY,EAAE,oEAAoE,EAAC,CAAC;qBAC9F;oBACD,cAAc,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;iBAChD;gBACD,OAAO,IAAI,CAAC;SACf;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA1BD,gCA0BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"CAClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/CAClassMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAA8G;AAC9G,+CAA4C;AAI5C;;GAEG;AACH,MAAqB,aAAc,SAAQ,yBAAiC;IAEvD,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAA6B;QACjF,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACrG,CAAC;IAEkB,KAAK,CAAC,eAAe,CAAC,OAA6B,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QAC3I,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;QAC1G,IAAI,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;YACnG,OAAO,OAAO,CAAC;SAChB;QAED,MAAM,cAAc,GAAG,OAAoC,CAAC;QAC5D,QAAO,aAAa,EAAE;YACpB,KAAK,WAAW;gBACd,IAAI,iBAAiB,KAAK,SAAS,IAAI,iBAAiB,KAAK,iBAAiB,EAAE;oBAC9E,MAAM,aAAa,GAAG,IAAA,qDAAiC,EAAC,GAAG,iBAAiB,KAAK,iBAAiB,EAAE,CAAC,CAAC;oBACtG,IAAI,aAAa,KAAK,SAAS,EAAE;wBAC/B,OAAO,EAAE,YAAY,EAAE,oEAAoE,EAAC,CAAC;qBAC9F;oBACD,cAAc,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;iBAChD;gBACD,OAAO,IAAI,CAAC;SACf;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA1BD,gCA0BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { CustomAttributeClass, parseCustomAttributeContainerType, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { ClassMerger } from \"./ClassMerger\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\nimport { MutableCAClass } from \"../Editing/Mutable/MutableCAClass\";\n\n/**\n * @internal\n */\nexport default class CAClassMerger extends ClassMerger<CustomAttributeClass> {\n\n protected override async create(schemaKey: SchemaKey, ecClass: CustomAttributeClass): Promise<SchemaItemEditResults> {\n return this.context.editor.customAttributes.create(schemaKey, ecClass.name, ecClass.containerType);\n }\n\n protected override async mergeAttributes(ecClass: CustomAttributeClass, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\n const results = await super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);\n if (results === true || this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n const mutableCAClass = ecClass as unknown as MutableCAClass;\n switch(attributeName) {\n case \"appliesTo\":\n if (attributeOldValue !== undefined && attributeOldValue !== attributeNewValue) {\n const containerType = parseCustomAttributeContainerType(`${attributeOldValue}, ${attributeNewValue}`);\n if (containerType === undefined) {\n return { errorMessage: \"An invalid custom attribute class containerType has been provided.\"};\n }\n mutableCAClass.setContainerType(containerType);\n }\n return true;\n }\n return false;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.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BpB,YAAY,CAAC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC;CAmDnG"}
|
|
@@ -8,6 +8,7 @@ exports.ClassMerger = void 0;
|
|
|
8
8
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
9
9
|
const SchemaChanges_1 = require("../Validation/SchemaChanges");
|
|
10
10
|
const ClassPropertyMerger_1 = require("./ClassPropertyMerger");
|
|
11
|
+
const CustomAttributeMerger_1 = require("./CustomAttributeMerger");
|
|
11
12
|
/**
|
|
12
13
|
* @internal
|
|
13
14
|
*/
|
|
@@ -134,7 +135,14 @@ class ClassMerger {
|
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
await merger.mergeAttributeValueChanges(targetItemKey, change.propertyValueChanges);
|
|
137
|
-
|
|
138
|
+
let mergeResults = await ClassPropertyMerger_1.ClassPropertyMerger.mergeChanges(context, targetItemKey, change.propertyChanges.values());
|
|
139
|
+
if (mergeResults.errorMessage !== undefined) {
|
|
140
|
+
throw new Error(mergeResults.errorMessage);
|
|
141
|
+
}
|
|
142
|
+
// merge custom attributes
|
|
143
|
+
mergeResults = await (0, CustomAttributeMerger_1.mergeCustomAttributes)(merger.context, change.customAttributeChanges.values(), async (ca) => {
|
|
144
|
+
return merger.context.editor.entities.addCustomAttribute(targetItemKey, ca);
|
|
145
|
+
});
|
|
138
146
|
if (mergeResults.errorMessage !== undefined) {
|
|
139
147
|
throw new Error(mergeResults.errorMessage);
|
|
140
148
|
}
|