@itwin/ecschema-editing 4.4.0-dev.3 → 4.4.0-dev.30
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 +16 -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 +2 -0
- package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/ECClasses.js +28 -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.d.ts +10 -0
- package/lib/cjs/Editing/Mutable/MutableArrayProperty.d.ts.map +1 -0
- package/lib/cjs/Editing/Mutable/MutableArrayProperty.js +16 -0
- package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -0
- package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableClass.d.ts +2 -0
- package/lib/cjs/Editing/Mutable/MutableClass.d.ts.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.d.ts +13 -0
- package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.d.ts.map +1 -0
- package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js +16 -0
- package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -0
- package/lib/cjs/Editing/Mutable/MutableProperty.d.ts +6 -1
- package/lib/cjs/Editing/Mutable/MutableProperty.d.ts.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.d.ts +15 -0
- package/lib/cjs/Merging/AnyPropertyMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/AnyPropertyMerger.js +71 -0
- package/lib/cjs/Merging/AnyPropertyMerger.js.map +1 -0
- package/lib/cjs/Merging/ArrayPropertyMerger.d.ts +32 -0
- package/lib/cjs/Merging/ArrayPropertyMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/ArrayPropertyMerger.js +143 -0
- package/lib/cjs/Merging/ArrayPropertyMerger.js.map +1 -0
- package/lib/cjs/Merging/CAClassMerger.d.ts +6 -8
- package/lib/cjs/Merging/CAClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/CAClassMerger.js +27 -10
- package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ClassMerger.d.ts +14 -6
- package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ClassMerger.js +133 -35
- package/lib/cjs/Merging/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ClassPropertyMerger.d.ts +16 -0
- package/lib/cjs/Merging/ClassPropertyMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/ClassPropertyMerger.js +90 -0
- package/lib/cjs/Merging/ClassPropertyMerger.js.map +1 -0
- 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.d.ts +11 -0
- package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/EntityClassMerger.js +26 -0
- package/lib/cjs/Merging/EntityClassMerger.js.map +1 -0
- 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.d.ts +11 -0
- package/lib/cjs/Merging/MixinMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/MixinMerger.js +38 -0
- package/lib/cjs/Merging/MixinMerger.js.map +1 -0
- package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.d.ts +24 -0
- package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.js +106 -0
- package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.js.map +1 -0
- 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 +16 -3
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
- package/lib/cjs/Merging/StructClassMerger.d.ts +10 -0
- package/lib/cjs/Merging/StructClassMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/StructClassMerger.js +13 -0
- package/lib/cjs/Merging/StructClassMerger.js.map +1 -0
- package/lib/cjs/Merging/StructPropertyMerger.d.ts +11 -0
- package/lib/cjs/Merging/StructPropertyMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/StructPropertyMerger.js +47 -0
- package/lib/cjs/Merging/StructPropertyMerger.js.map +1 -0
- 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 +15 -15
- package/public/locales/en/ECSchemaEditing.json +26 -26
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnyPropertyMerger = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
8
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
class AnyPropertyMerger {
|
|
13
|
+
constructor(context) {
|
|
14
|
+
this.context = context;
|
|
15
|
+
}
|
|
16
|
+
async createFromProps(_classKey, property) {
|
|
17
|
+
return { errorMessage: `Property Type ${(0, ecschema_metadata_1.propertyTypeToString)(property.propertyType)} is not implemented.` };
|
|
18
|
+
}
|
|
19
|
+
isPropertyEditResults(obj) {
|
|
20
|
+
return typeof obj === "object" && "errorMessage" in obj;
|
|
21
|
+
}
|
|
22
|
+
async getPropertyProps(property) {
|
|
23
|
+
let props = {};
|
|
24
|
+
if (property.category !== undefined) {
|
|
25
|
+
const sourceCategory = await property.category;
|
|
26
|
+
const itemKey = new ecschema_metadata_1.SchemaItemKey(sourceCategory.name, this.context.sourceSchema.schemaKey.matches(sourceCategory.schema.schemaKey)
|
|
27
|
+
? this.context.targetSchema.schemaKey
|
|
28
|
+
: sourceCategory.schema.schemaKey);
|
|
29
|
+
const targetCategory = await this.context.targetSchema.lookupItem(itemKey);
|
|
30
|
+
if (targetCategory === undefined) {
|
|
31
|
+
return { errorMessage: `Unable to locate the property category class ${sourceCategory.name} in the merged schema.` };
|
|
32
|
+
}
|
|
33
|
+
props = { ...props, category: targetCategory.fullName };
|
|
34
|
+
}
|
|
35
|
+
if (property.kindOfQuantity !== undefined) {
|
|
36
|
+
const sourceKoq = await property.kindOfQuantity;
|
|
37
|
+
const itemKey = new ecschema_metadata_1.SchemaItemKey(sourceKoq.name, this.context.sourceSchema.schemaKey.matches(sourceKoq.schema.schemaKey)
|
|
38
|
+
? this.context.targetSchema.schemaKey
|
|
39
|
+
: sourceKoq.schema.schemaKey);
|
|
40
|
+
const targetKoq = await this.context.targetSchema.lookupItem(itemKey);
|
|
41
|
+
if (targetKoq === undefined) {
|
|
42
|
+
return { errorMessage: `Unable to locate the property kind of quantity ${sourceKoq.name} in the merged schema.` };
|
|
43
|
+
}
|
|
44
|
+
props = { ...props, kindOfQuantity: targetKoq.fullName };
|
|
45
|
+
}
|
|
46
|
+
return props;
|
|
47
|
+
}
|
|
48
|
+
async mergeAttributes(property, attributeName, attributeNewValue, _attributeOldValue) {
|
|
49
|
+
const mutableProperty = property;
|
|
50
|
+
switch (attributeName) {
|
|
51
|
+
case "description":
|
|
52
|
+
mutableProperty.setDescription(attributeNewValue);
|
|
53
|
+
return true;
|
|
54
|
+
case "label":
|
|
55
|
+
mutableProperty.setLabel(attributeNewValue);
|
|
56
|
+
return true;
|
|
57
|
+
case "isReadOnly":
|
|
58
|
+
mutableProperty.setIsReadOnly(attributeNewValue);
|
|
59
|
+
return true;
|
|
60
|
+
case "priority":
|
|
61
|
+
mutableProperty.setPriority(attributeNewValue);
|
|
62
|
+
return true;
|
|
63
|
+
case "type":
|
|
64
|
+
case "primitiveType":
|
|
65
|
+
return { errorMessage: `Changing the property '${property.name}' ${attributeName} is not supported.` };
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.AnyPropertyMerger = AnyPropertyMerger;
|
|
71
|
+
//# sourceMappingURL=AnyPropertyMerger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnyPropertyMerger.js","sourceRoot":"","sources":["../../../src/Merging/AnyPropertyMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA0I;A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AAO,EAAE,YAAY,EAAE,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"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ArrayProperty, EnumerationArrayProperty, PrimitiveArrayProperty, SchemaItemKey, StructArrayProperty } from "@itwin/ecschema-metadata";
|
|
2
|
+
import { AnyPropertyMerger } from "./AnyPropertyMerger";
|
|
3
|
+
import { PropertyEditResults } from "../Editing/Editor";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
declare class ArrayPropertyMerger<TArrayProperty extends ArrayProperty> extends AnyPropertyMerger<TArrayProperty> {
|
|
8
|
+
mergeAttributes(property: TArrayProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare class StructArrayPropertyMerger extends ArrayPropertyMerger<StructArrayProperty> {
|
|
14
|
+
mergeAttributes(property: StructArrayProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean>;
|
|
15
|
+
createFromProps(classKey: SchemaItemKey, property: StructArrayProperty): Promise<PropertyEditResults>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare class EnumerationArrayPropertyMerger extends ArrayPropertyMerger<EnumerationArrayProperty> {
|
|
21
|
+
mergeAttributes(property: EnumerationArrayProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean>;
|
|
22
|
+
createFromProps(classKey: SchemaItemKey, property: EnumerationArrayProperty): Promise<PropertyEditResults>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export declare class PrimitiveArraPropertyMerger extends ArrayPropertyMerger<PrimitiveArrayProperty> {
|
|
28
|
+
mergeAttributes(property: PrimitiveArrayProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean>;
|
|
29
|
+
createFromProps(classKey: SchemaItemKey, property: PrimitiveArrayProperty): Promise<PropertyEditResults>;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=ArrayPropertyMerger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayPropertyMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/ArrayPropertyMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAe,wBAAwB,EAAE,sBAAsB,EAAE,aAAa,EAAE,mBAAmB,EAAyC,MAAM,0BAA0B,CAAC;AAEnM,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGxD;;GAEG;AACH,cAAM,mBAAmB,CAAC,cAAc,SAAS,aAAa,CAAG,SAAQ,iBAAiB,CAAE,cAAc,CA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
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PrimitiveArraPropertyMerger = exports.EnumerationArrayPropertyMerger = exports.StructArrayPropertyMerger = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
8
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
9
|
+
const AnyPropertyMerger_1 = require("./AnyPropertyMerger");
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
class ArrayPropertyMerger extends AnyPropertyMerger_1.AnyPropertyMerger {
|
|
14
|
+
async mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue) {
|
|
15
|
+
const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);
|
|
16
|
+
if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
|
|
17
|
+
return results;
|
|
18
|
+
}
|
|
19
|
+
const mutableProperty = property;
|
|
20
|
+
switch (attributeName) {
|
|
21
|
+
case "minOccurs":
|
|
22
|
+
mutableProperty.setMinOccurs(attributeNewValue);
|
|
23
|
+
return true;
|
|
24
|
+
case "maxOccurs":
|
|
25
|
+
mutableProperty.setMaxOccurs(attributeNewValue);
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
class StructArrayPropertyMerger extends ArrayPropertyMerger {
|
|
35
|
+
async mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue) {
|
|
36
|
+
const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);
|
|
37
|
+
if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
|
|
38
|
+
return results;
|
|
39
|
+
}
|
|
40
|
+
switch (attributeName) {
|
|
41
|
+
case "structClass": {
|
|
42
|
+
if (attributeOldValue !== undefined) {
|
|
43
|
+
return { errorMessage: `Changing the property '${property.name}' structClass is not supported.` };
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
async createFromProps(classKey, property) {
|
|
51
|
+
const results = await super.getPropertyProps(property);
|
|
52
|
+
if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
|
|
53
|
+
return results;
|
|
54
|
+
}
|
|
55
|
+
const itemKey = new ecschema_metadata_1.SchemaItemKey(property.structClass.name, this.context.sourceSchema.schemaKey.matches(property.structClass.schema.schemaKey)
|
|
56
|
+
? this.context.targetSchema.schemaKey
|
|
57
|
+
: property.structClass.schema.schemaKey);
|
|
58
|
+
const type = await this.context.targetSchema.lookupItem(itemKey);
|
|
59
|
+
if (type === undefined) {
|
|
60
|
+
return { errorMessage: `Unable to locate the struct class ${property.structClass.name} in the merged schema.` };
|
|
61
|
+
}
|
|
62
|
+
const props = {
|
|
63
|
+
...property.toJSON(),
|
|
64
|
+
...results,
|
|
65
|
+
typeName: type.fullName,
|
|
66
|
+
};
|
|
67
|
+
return this.context.editor.entities.createStructArrayPropertyFromProps(classKey, property.name, type, props);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.StructArrayPropertyMerger = StructArrayPropertyMerger;
|
|
71
|
+
/**
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
class EnumerationArrayPropertyMerger extends ArrayPropertyMerger {
|
|
75
|
+
async mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue) {
|
|
76
|
+
const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);
|
|
77
|
+
if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
|
|
78
|
+
return results;
|
|
79
|
+
}
|
|
80
|
+
switch (attributeName) {
|
|
81
|
+
case "enumeration": {
|
|
82
|
+
if (attributeOldValue !== undefined) {
|
|
83
|
+
return { errorMessage: `Changing the property '${property.name}' enumeration is not supported.` };
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
async createFromProps(classKey, property) {
|
|
91
|
+
const results = await super.getPropertyProps(property);
|
|
92
|
+
if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
|
|
93
|
+
return results;
|
|
94
|
+
}
|
|
95
|
+
if (property.enumeration === undefined) {
|
|
96
|
+
return { errorMessage: `Property '${property.fullName}' is missing the required 'enumeration' attribute.` };
|
|
97
|
+
}
|
|
98
|
+
const enumeration = await property.enumeration;
|
|
99
|
+
const itemKey = new ecschema_metadata_1.SchemaItemKey(enumeration.name, this.context.sourceSchema.schemaKey.matches(enumeration.schema.schemaKey)
|
|
100
|
+
? this.context.targetSchema.schemaKey
|
|
101
|
+
: enumeration.schema.schemaKey);
|
|
102
|
+
const type = await this.context.targetSchema.lookupItem(itemKey);
|
|
103
|
+
if (type === undefined) {
|
|
104
|
+
return { errorMessage: `Unable to locate the enumeration class ${enumeration.name} in the merged schema.` };
|
|
105
|
+
}
|
|
106
|
+
const props = {
|
|
107
|
+
...property.toJSON(),
|
|
108
|
+
...results,
|
|
109
|
+
};
|
|
110
|
+
return this.context.editor.entities.createEnumerationArrayPropertyFromProps(classKey, property.name, type, props);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.EnumerationArrayPropertyMerger = EnumerationArrayPropertyMerger;
|
|
114
|
+
/**
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
class PrimitiveArraPropertyMerger extends ArrayPropertyMerger {
|
|
118
|
+
async mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue) {
|
|
119
|
+
const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);
|
|
120
|
+
if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
|
|
121
|
+
return results;
|
|
122
|
+
}
|
|
123
|
+
switch (attributeName) {
|
|
124
|
+
case "primitiveType": {
|
|
125
|
+
return { errorMessage: `Changing the property '${property.name}' typeName is not supported.` };
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
async createFromProps(classKey, property) {
|
|
131
|
+
const results = await super.getPropertyProps(property);
|
|
132
|
+
if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
|
|
133
|
+
return results;
|
|
134
|
+
}
|
|
135
|
+
const props = {
|
|
136
|
+
...property.toJSON(),
|
|
137
|
+
...results,
|
|
138
|
+
};
|
|
139
|
+
return this.context.editor.entities.createPrimitiveArrayPropertyFromProps(classKey, property.name, property.primitiveType, props);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.PrimitiveArraPropertyMerger = PrimitiveArraPropertyMerger;
|
|
143
|
+
//# sourceMappingURL=ArrayPropertyMerger.js.map
|
|
@@ -0,0 +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,G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,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,13 +1,11 @@
|
|
|
1
|
-
import { CustomAttributeClass } from "@itwin/ecschema-metadata";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { CustomAttributeClass, SchemaKey } from "@itwin/ecschema-metadata";
|
|
2
|
+
import { ClassMerger } from "./ClassMerger";
|
|
3
|
+
import { SchemaItemEditResults } from "../Editing/Editor";
|
|
4
4
|
/**
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
|
-
export default class CAClassMerger extends ClassMerger {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
protected createPropertyValueResolver(): Promise<PropertyValueResolver<CustomAttributeClass>>;
|
|
7
|
+
export default class CAClassMerger extends ClassMerger<CustomAttributeClass> {
|
|
8
|
+
protected create(schemaKey: SchemaKey, ecClass: CustomAttributeClass): Promise<SchemaItemEditResults>;
|
|
9
|
+
protected mergeAttributes(ecClass: CustomAttributeClass, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean>;
|
|
12
10
|
}
|
|
13
11
|
//# sourceMappingURL=CAClassMerger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CAClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/CAClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"CAClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/CAClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAqC,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC9G,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG1D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW,CAAC,oBAAoB,CAAC;cAEjD,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;cAI3F,eAAe,CAAC,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC;CAoBzL"}
|
|
@@ -1,19 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*---------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
5
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
6
|
+
*--------------------------------------------------------------------------------------------*/
|
|
7
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
3
8
|
const ClassMerger_1 = require("./ClassMerger");
|
|
4
9
|
/**
|
|
5
10
|
* @internal
|
|
6
11
|
*/
|
|
7
|
-
class CAClassMerger extends ClassMerger_1.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
async
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
class CAClassMerger extends ClassMerger_1.ClassMerger {
|
|
13
|
+
async create(schemaKey, ecClass) {
|
|
14
|
+
return this.context.editor.customAttributes.create(schemaKey, ecClass.name, ecClass.containerType);
|
|
15
|
+
}
|
|
16
|
+
async mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue) {
|
|
17
|
+
const results = await super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);
|
|
18
|
+
if (results === true || this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {
|
|
19
|
+
return results;
|
|
20
|
+
}
|
|
21
|
+
const mutableCAClass = ecClass;
|
|
22
|
+
switch (attributeName) {
|
|
23
|
+
case "appliesTo":
|
|
24
|
+
if (attributeOldValue !== undefined && attributeOldValue !== attributeNewValue) {
|
|
25
|
+
const containerType = (0, ecschema_metadata_1.parseCustomAttributeContainerType)(`${attributeOldValue}, ${attributeNewValue}`);
|
|
26
|
+
if (containerType === undefined) {
|
|
27
|
+
return { errorMessage: "An invalid custom attribute class containerType has been provided." };
|
|
28
|
+
}
|
|
29
|
+
mutableCAClass.setContainerType(containerType);
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
17
34
|
}
|
|
18
35
|
}
|
|
19
36
|
exports.default = CAClassMerger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CAClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/CAClassMerger.ts"],"names":[],"mappings":";;
|
|
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,12 +1,20 @@
|
|
|
1
|
-
import { ECClass, SchemaItemKey } from "@itwin/ecschema-metadata";
|
|
1
|
+
import { ECClass, Mixin, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
|
|
2
|
+
import { SchemaItemEditResults } from "../Editing/Editor";
|
|
3
|
+
import { SchemaMergeContext } from "./SchemaMerger";
|
|
2
4
|
import { ClassChanges } from "../Validation/SchemaChanges";
|
|
3
|
-
import { SchemaItemMerger } from "./SchemaItemMerger";
|
|
4
5
|
/**
|
|
5
6
|
* @internal
|
|
6
7
|
*/
|
|
7
|
-
export
|
|
8
|
-
protected
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export declare class ClassMerger<TClass extends ECClass> {
|
|
9
|
+
protected readonly context: SchemaMergeContext;
|
|
10
|
+
constructor(context: SchemaMergeContext);
|
|
11
|
+
protected create(_schemaKey: SchemaKey, ecClass: TClass): Promise<SchemaItemEditResults>;
|
|
12
|
+
protected addMixin(itemKey: SchemaItemKey, mixin: Mixin): Promise<SchemaItemEditResults>;
|
|
13
|
+
protected mergeAttributes(ecClass: TClass, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean>;
|
|
14
|
+
protected isSchemaItemEditResults(obj: any): obj is SchemaItemEditResults;
|
|
15
|
+
private setBaseClass;
|
|
16
|
+
private addMixins;
|
|
17
|
+
private mergeAttributeValueChanges;
|
|
18
|
+
static mergeChanges(context: SchemaMergeContext, classChanges: Iterable<ClassChanges>): Promise<void>;
|
|
11
19
|
}
|
|
12
20
|
//# sourceMappingURL=ClassMerger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"ClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAmB,KAAK,EAAsB,aAAa,EAA0B,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACjJ,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAA8B,YAAY,EAA2C,MAAM,6BAA6B,CAAC;AAIhI;;GAEG;AACH,qBAAa,WAAW,CAAC,MAAM,SAAS,OAAO;IAC7C,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;gBAEnC,OAAO,EAAE,kBAAkB;cAIvB,MAAM,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;cAI9E,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,qBAAqB,CAAC;cAI9E,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC;IAgCjK,SAAS,CAAC,uBAAuB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,qBAAqB;YAI3D,YAAY;YAwBZ,SAAS;YAkBT,0BAA0B;WAmBpB,YAAY,CAAC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC;CAmDnG"}
|
|
@@ -1,55 +1,153 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
exports.ClassMerger = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
7
8
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
8
9
|
const SchemaChanges_1 = require("../Validation/SchemaChanges");
|
|
9
|
-
const
|
|
10
|
+
const ClassPropertyMerger_1 = require("./ClassPropertyMerger");
|
|
11
|
+
const CustomAttributeMerger_1 = require("./CustomAttributeMerger");
|
|
10
12
|
/**
|
|
11
13
|
* @internal
|
|
12
14
|
*/
|
|
13
|
-
class ClassMerger
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
class ClassMerger {
|
|
16
|
+
constructor(context) {
|
|
17
|
+
this.context = context;
|
|
18
|
+
}
|
|
19
|
+
async create(_schemaKey, ecClass) {
|
|
20
|
+
return { errorMessage: `${(0, ecschema_metadata_1.schemaItemTypeToString)(ecClass.schemaItemType)} class type is not implemented.` };
|
|
21
|
+
}
|
|
22
|
+
async addMixin(itemKey, mixin) {
|
|
23
|
+
return { errorMessage: `Adding mixin '${mixin.name}' to '${itemKey.name}' class is not implemented.` };
|
|
24
|
+
}
|
|
25
|
+
async mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue) {
|
|
26
|
+
const mutableClass = ecClass;
|
|
27
|
+
switch (attributeName) {
|
|
28
|
+
case "schemaItemType":
|
|
29
|
+
if (attributeOldValue !== undefined && attributeOldValue !== attributeNewValue) {
|
|
30
|
+
return { errorMessage: `Changing the class '${ecClass.name}' type is not supported.` };
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
case "label":
|
|
34
|
+
mutableClass.setDisplayLabel(attributeNewValue);
|
|
35
|
+
return true;
|
|
36
|
+
case "description":
|
|
37
|
+
mutableClass.setDescription(attributeNewValue);
|
|
38
|
+
return true;
|
|
39
|
+
case "modifier":
|
|
40
|
+
const modifier = (0, ecschema_metadata_1.parseClassModifier)(attributeNewValue);
|
|
41
|
+
if (modifier === undefined) {
|
|
42
|
+
return { errorMessage: "An invalid class modifier has been provided." };
|
|
43
|
+
}
|
|
44
|
+
if (attributeOldValue === undefined || modifier === ecschema_metadata_1.ECClassModifier.None) {
|
|
45
|
+
mutableClass.setModifier(modifier);
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
return { errorMessage: `Changing the class '${ecClass.name}' modifier is not supported.` };
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
isSchemaItemEditResults(obj) {
|
|
53
|
+
return typeof obj === "object" && "errorMessage" in obj;
|
|
54
|
+
}
|
|
55
|
+
async setBaseClass(itemKey, baseClassDelta, changeType) {
|
|
56
|
+
const [sourceBaseClass, targetBaseClass] = baseClassDelta.diagnostic.messageArgs;
|
|
57
|
+
if (sourceBaseClass !== undefined) {
|
|
58
|
+
const baseClassKey = new ecschema_metadata_1.SchemaItemKey(sourceBaseClass.name, sourceBaseClass.schema.schemaKey.matches(this.context.sourceSchema.schemaKey)
|
|
59
|
+
? this.context.targetSchema.schemaKey
|
|
60
|
+
: sourceBaseClass.schema.schemaKey);
|
|
61
|
+
if (changeType === SchemaChanges_1.ChangeType.Missing && targetBaseClass === undefined) {
|
|
62
|
+
return this.context.editor.entities.setBaseClass(itemKey, baseClassKey);
|
|
63
|
+
}
|
|
64
|
+
if (targetBaseClass !== undefined) {
|
|
65
|
+
const baseClass = await this.context.targetSchema.lookupItem(baseClassKey);
|
|
66
|
+
if (baseClass === undefined) {
|
|
67
|
+
return { errorMessage: `'${baseClassKey.name}' class could not be located in the merged schema.` };
|
|
68
|
+
}
|
|
69
|
+
if (await baseClass.is(targetBaseClass)) {
|
|
70
|
+
return this.context.editor.entities.setBaseClass(itemKey, baseClassKey);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
20
73
|
}
|
|
74
|
+
return { errorMessage: `Changing the class '${itemKey.name}' baseClass is not supported.` };
|
|
21
75
|
}
|
|
22
|
-
async
|
|
23
|
-
if (
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
76
|
+
async addMixins(itemKey, entityMixinChanges, changeType) {
|
|
77
|
+
if (changeType === SchemaChanges_1.ChangeType.Missing) {
|
|
78
|
+
for (const entityMixinChange of entityMixinChanges) {
|
|
79
|
+
for (const change of entityMixinChange.entityMixinChange) {
|
|
80
|
+
const mixins = change.diagnostic.messageArgs;
|
|
81
|
+
for (const mixin of mixins) {
|
|
82
|
+
const result = await this.addMixin(itemKey, mixin);
|
|
83
|
+
if (result.errorMessage !== undefined) {
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
30
88
|
}
|
|
31
|
-
|
|
32
|
-
|
|
89
|
+
return {};
|
|
90
|
+
}
|
|
91
|
+
return { errorMessage: `Changing the class '${itemKey.name}' mixins is not supported.` };
|
|
92
|
+
}
|
|
93
|
+
async mergeAttributeValueChanges(itemKey, propertyValueChanges) {
|
|
94
|
+
if (propertyValueChanges.length === 0) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const targetItem = await this.context.targetSchema.lookupItem(itemKey);
|
|
98
|
+
if (targetItem === undefined) {
|
|
99
|
+
throw new Error(`'${itemKey.name}' class could not be located in the merged schema.`);
|
|
100
|
+
}
|
|
101
|
+
for (const change of propertyValueChanges) {
|
|
102
|
+
const [attributeName, attributeNewValue, attributeOldValue] = change.diagnostic.messageArgs;
|
|
103
|
+
const results = await this.mergeAttributes(targetItem, attributeName, attributeNewValue, attributeOldValue);
|
|
104
|
+
if (this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {
|
|
105
|
+
throw new Error(results.errorMessage);
|
|
33
106
|
}
|
|
34
107
|
}
|
|
35
108
|
}
|
|
36
|
-
async
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
109
|
+
static async mergeChanges(context, classChanges) {
|
|
110
|
+
const merger = new this(context);
|
|
111
|
+
for (const change of classChanges) {
|
|
112
|
+
const sourceItem = (await change.schema.getItem(change.ecTypeName));
|
|
113
|
+
let targetItemKey = new ecschema_metadata_1.SchemaItemKey(change.ecTypeName, context.targetSchema.schemaKey);
|
|
114
|
+
const changeType = change.schemaItemMissing?.changeType;
|
|
115
|
+
if (changeType === SchemaChanges_1.ChangeType.Missing) {
|
|
116
|
+
if (await context.targetSchema.lookupItem(targetItemKey) !== undefined) {
|
|
117
|
+
throw new Error(`Merged schema already contains a class '${change.ecTypeName}'.`);
|
|
118
|
+
}
|
|
119
|
+
const results = await merger.create(context.targetSchema.schemaKey, sourceItem);
|
|
120
|
+
if (results.errorMessage !== undefined) {
|
|
121
|
+
throw new Error(results.errorMessage);
|
|
122
|
+
}
|
|
123
|
+
targetItemKey = results.itemKey;
|
|
124
|
+
}
|
|
125
|
+
if (change.baseClassDelta !== undefined) {
|
|
126
|
+
const results = await merger.setBaseClass(targetItemKey, change.baseClassDelta, changeType);
|
|
127
|
+
if (results.errorMessage !== undefined) {
|
|
128
|
+
throw new Error(results.errorMessage);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (change.entityMixinChanges.size > 0) {
|
|
132
|
+
const results = await merger.addMixins(targetItemKey, change.entityMixinChanges.values(), changeType);
|
|
133
|
+
if (results.errorMessage !== undefined) {
|
|
134
|
+
throw new Error(results.errorMessage);
|
|
135
|
+
}
|
|
41
136
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
: await this.context.editor.entities.createPrimitivePropertyFromProps(itemKey, propertyChange.ecTypeName, property.primitiveType, primitiveProps);
|
|
137
|
+
await merger.mergeAttributeValueChanges(targetItemKey, change.propertyValueChanges);
|
|
138
|
+
let mergeResults = await ClassPropertyMerger_1.ClassPropertyMerger.mergeChanges(context, targetItemKey, change.propertyChanges.values());
|
|
139
|
+
if (mergeResults.errorMessage !== undefined) {
|
|
140
|
+
throw new Error(mergeResults.errorMessage);
|
|
47
141
|
}
|
|
48
|
-
|
|
49
|
-
|
|
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
|
+
});
|
|
146
|
+
if (mergeResults.errorMessage !== undefined) {
|
|
147
|
+
throw new Error(mergeResults.errorMessage);
|
|
50
148
|
}
|
|
51
149
|
}
|
|
52
150
|
}
|
|
53
151
|
}
|
|
54
|
-
exports.
|
|
152
|
+
exports.ClassMerger = ClassMerger;
|
|
55
153
|
//# sourceMappingURL=ClassMerger.js.map
|