@itwin/ecschema-editing 4.7.0-dev.8 → 4.8.0-dev.0
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/Differencing/Errors.d.ts +19 -0
- package/lib/cjs/Differencing/Errors.d.ts.map +1 -0
- package/lib/cjs/Differencing/Errors.js +24 -0
- package/lib/cjs/Differencing/Errors.js.map +1 -0
- package/lib/cjs/Differencing/SchemaConflicts.d.ts +0 -14
- package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaConflicts.js +1 -14
- package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts +4 -4
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +31 -31
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.d.ts +1 -1
- package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.js +6 -6
- package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
- package/lib/cjs/Editing/Constants.d.ts +6 -6
- package/lib/cjs/Editing/Constants.d.ts.map +1 -1
- package/lib/cjs/Editing/Constants.js +26 -31
- package/lib/cjs/Editing/Constants.js.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.d.ts +3 -3
- package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.js +18 -28
- package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
- package/lib/cjs/Editing/ECClasses.d.ts +24 -23
- package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/ECClasses.js +126 -156
- package/lib/cjs/Editing/ECClasses.js.map +1 -1
- package/lib/cjs/Editing/Editor.d.ts +10 -31
- package/lib/cjs/Editing/Editor.d.ts.map +1 -1
- package/lib/cjs/Editing/Editor.js +59 -43
- package/lib/cjs/Editing/Editor.js.map +1 -1
- package/lib/cjs/Editing/Entities.d.ts +9 -9
- package/lib/cjs/Editing/Entities.d.ts.map +1 -1
- package/lib/cjs/Editing/Entities.js +65 -85
- package/lib/cjs/Editing/Entities.js.map +1 -1
- package/lib/cjs/Editing/Enumerations.d.ts +6 -6
- package/lib/cjs/Editing/Enumerations.d.ts.map +1 -1
- package/lib/cjs/Editing/Enumerations.js +57 -55
- package/lib/cjs/Editing/Enumerations.js.map +1 -1
- package/lib/cjs/Editing/Exception.d.ts +257 -0
- package/lib/cjs/Editing/Exception.d.ts.map +1 -0
- package/lib/cjs/Editing/Exception.js +426 -0
- package/lib/cjs/Editing/Exception.js.map +1 -0
- package/lib/cjs/Editing/Formats.d.ts +6 -6
- package/lib/cjs/Editing/Formats.d.ts.map +1 -1
- package/lib/cjs/Editing/Formats.js +28 -33
- package/lib/cjs/Editing/Formats.js.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.d.ts +6 -6
- package/lib/cjs/Editing/InvertedUnits.d.ts.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.js +41 -56
- package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.d.ts +6 -6
- package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.js +50 -57
- package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
- package/lib/cjs/Editing/Mixins.d.ts +5 -5
- package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
- package/lib/cjs/Editing/Mixins.js +43 -58
- 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.d.ts +1 -5
- package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEntityClass.js +1 -45
- 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.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableNavigationProperty.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.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableStructProperty.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.d.ts +7 -7
- package/lib/cjs/Editing/Phenomena.d.ts.map +1 -1
- package/lib/cjs/Editing/Phenomena.js +23 -23
- package/lib/cjs/Editing/Phenomena.js.map +1 -1
- package/lib/cjs/Editing/Properties.d.ts +7 -6
- package/lib/cjs/Editing/Properties.d.ts.map +1 -1
- package/lib/cjs/Editing/Properties.js +99 -46
- package/lib/cjs/Editing/Properties.js.map +1 -1
- package/lib/cjs/Editing/PropertyCategories.d.ts +6 -6
- package/lib/cjs/Editing/PropertyCategories.d.ts.map +1 -1
- package/lib/cjs/Editing/PropertyCategories.js +29 -27
- package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.d.ts +15 -17
- package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.js +97 -101
- package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
- package/lib/cjs/Editing/SchemaItems.d.ts +13 -5
- package/lib/cjs/Editing/SchemaItems.d.ts.map +1 -1
- package/lib/cjs/Editing/SchemaItems.js +58 -6
- package/lib/cjs/Editing/SchemaItems.js.map +1 -1
- package/lib/cjs/Editing/Structs.d.ts +3 -3
- package/lib/cjs/Editing/Structs.d.ts.map +1 -1
- package/lib/cjs/Editing/Structs.js +17 -27
- package/lib/cjs/Editing/Structs.js.map +1 -1
- package/lib/cjs/Editing/UnitSystems.d.ts +7 -7
- package/lib/cjs/Editing/UnitSystems.d.ts.map +1 -1
- package/lib/cjs/Editing/UnitSystems.js +22 -20
- package/lib/cjs/Editing/UnitSystems.js.map +1 -1
- package/lib/cjs/Editing/Units.d.ts +6 -6
- package/lib/cjs/Editing/Units.d.ts.map +1 -1
- package/lib/cjs/Editing/Units.js +26 -35
- package/lib/cjs/Editing/Units.js.map +1 -1
- package/lib/cjs/Merging/CAClassMerger.js +2 -2
- package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ClassMerger.d.ts +1 -2
- package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ClassMerger.js +15 -39
- package/lib/cjs/Merging/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js +2 -3
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts +4 -5
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.js +8 -18
- package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.d.ts +1 -2
- package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.js +3 -10
- package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.js +8 -10
- package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.js +2 -3
- package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
- package/lib/cjs/Merging/MixinMerger.js +2 -2
- package/lib/cjs/Merging/MixinMerger.js.map +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.js +1 -2
- package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyCategoryMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/PropertyCategoryMerger.js +1 -2
- package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.d.ts +2 -3
- package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.js +21 -42
- package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts +5 -3
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.js +35 -33
- package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaItemMerger.d.ts +3 -4
- package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaItemMerger.js +3 -2
- 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 +8 -14
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
- package/lib/cjs/Merging/UnitSystemMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/UnitSystemMerger.js +1 -2
- package/lib/cjs/Merging/UnitSystemMerger.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.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.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.d.ts +1 -0
- package/lib/cjs/ecschema-editing.d.ts.map +1 -1
- package/lib/cjs/ecschema-editing.js +1 -0
- package/lib/cjs/ecschema-editing.js.map +1 -1
- package/package.json +9 -9
- package/public/locales/en/ECSchemaEditing.json +26 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyCategories.d.ts","sourceRoot":"","sources":["../../../src/Editing/PropertyCategories.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"PropertyCategories.d.ts","sourceRoot":"","sources":["../../../src/Editing/PropertyCategories.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAoB,qBAAqB,EAAE,aAAa,EAAkB,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC7H,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,WAAW;gBAC9B,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAa3G,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,qBAAqB,EAAE,qBAAqB,GAAG,OAAO,CAAC,aAAa,CAAC;IAS3G,WAAW,CAAC,eAAe,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ1F"}
|
|
@@ -9,43 +9,45 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.PropertyCategories = void 0;
|
|
11
11
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
+
const Exception_1 = require("./Exception");
|
|
13
|
+
const SchemaItems_1 = require("./SchemaItems");
|
|
12
14
|
/**
|
|
13
15
|
* @alpha
|
|
14
16
|
* A class allowing you to create schema items of type Property Category.
|
|
15
17
|
*/
|
|
16
|
-
class PropertyCategories {
|
|
17
|
-
constructor(
|
|
18
|
-
|
|
18
|
+
class PropertyCategories extends SchemaItems_1.SchemaItems {
|
|
19
|
+
constructor(schemaEditor) {
|
|
20
|
+
super(ecschema_metadata_1.SchemaItemType.PropertyCategory, schemaEditor);
|
|
19
21
|
}
|
|
20
22
|
async create(schemaKey, name, priority, displayLabel) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
try {
|
|
24
|
+
const newPropCategory = await this.createSchemaItem(schemaKey, this.schemaItemType, (schema) => schema.createPropertyCategory.bind(schema), name);
|
|
25
|
+
newPropCategory.setPriority(priority);
|
|
26
|
+
if (displayLabel)
|
|
27
|
+
newPropCategory.setDisplayLabel(displayLabel);
|
|
28
|
+
return newPropCategory.key;
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.CreateSchemaItemFailed, new Exception_1.SchemaItemId(this.schemaItemType, name, schemaKey), e);
|
|
32
|
+
}
|
|
29
33
|
}
|
|
30
34
|
async createFromProps(schemaKey, propertyCategoryProps) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return { errorMessage: `Failed to create class ${propertyCategoryProps.name} in schema ${schemaKey.toString(true)}.` };
|
|
39
|
-
await newPropCategory.fromJSON(propertyCategoryProps);
|
|
40
|
-
return { itemKey: newPropCategory.key };
|
|
35
|
+
try {
|
|
36
|
+
const newPropCategory = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createPropertyCategory.bind(schema), propertyCategoryProps);
|
|
37
|
+
return newPropCategory.key;
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.CreateSchemaItemFromProps, new Exception_1.SchemaItemId(this.schemaItemType, propertyCategoryProps.name, schemaKey), e);
|
|
41
|
+
}
|
|
41
42
|
}
|
|
42
43
|
async setPriority(propCategoryKey, priority) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
try {
|
|
45
|
+
const propertyCategory = await this.getSchemaItem(propCategoryKey);
|
|
46
|
+
propertyCategory.setPriority(priority);
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetPropertyCategoryPriority, new Exception_1.SchemaItemId(this.schemaItemType, propCategoryKey), e);
|
|
50
|
+
}
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
exports.PropertyCategories = PropertyCategories;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyCategories.js","sourceRoot":"","sources":["../../../src/Editing/PropertyCategories.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"PropertyCategories.js","sourceRoot":"","sources":["../../../src/Editing/PropertyCategories.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAA6H;AAG7H,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,yBAAW;IACjD,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;IACvD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,QAAgB,EAAE,YAAqB;QAC7F,IAAI,CAAC;YACH,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAmB,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAA4B,CAAC;YAC/L,eAAe,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YACtC,IAAI,YAAY;gBACd,eAAe,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAEhD,OAAO,eAAe,CAAC,GAAG,CAAC;QAC7B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClI,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,qBAA4C;QAC7F,IAAI,CAAC;YACH,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,qBAAqB,CAAC,CAAC;YAC5K,OAAO,eAAe,CAAC,GAAG,CAAC;QAC7B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,qBAAqB,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5J,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,eAA8B,EAAE,QAAgB;QACvE,IAAI,CAAC;YACH,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,aAAa,CAA0B,eAAe,CAAC,CAAC;YAC5F,gBAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACzC,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,2BAA2B,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC;QACvI,CAAC;IACH,CAAC;CACF;AAnCD,gDAmCC","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 { PropertyCategory, PropertyCategoryProps, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport { MutablePropertyCategory } from \"./Mutable/MutablePropertyCategory\";\r\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\r\nimport { SchemaItems } from \"./SchemaItems\";\r\n\r\n/**\r\n * @alpha\r\n * A class allowing you to create schema items of type Property Category.\r\n */\r\nexport class PropertyCategories extends SchemaItems {\r\n public constructor(schemaEditor: SchemaContextEditor) {\r\n super(SchemaItemType.PropertyCategory, schemaEditor);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, priority: number, displayLabel?: string): Promise<SchemaItemKey> {\r\n try {\r\n const newPropCategory = await this.createSchemaItem<PropertyCategory>(schemaKey, this.schemaItemType, (schema) => schema.createPropertyCategory.bind(schema), name) as MutablePropertyCategory;\r\n newPropCategory.setPriority(priority);\r\n if (displayLabel)\r\n newPropCategory.setDisplayLabel(displayLabel);\r\n\r\n return newPropCategory.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\r\n }\r\n }\r\n\r\n public async createFromProps(schemaKey: SchemaKey, propertyCategoryProps: PropertyCategoryProps): Promise<SchemaItemKey> {\r\n try {\r\n const newPropCategory = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createPropertyCategory.bind(schema), propertyCategoryProps);\r\n return newPropCategory.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, propertyCategoryProps.name!, schemaKey), e);\r\n }\r\n }\r\n\r\n public async setPriority(propCategoryKey: SchemaItemKey, priority: number): Promise<void> {\r\n try {\r\n const propertyCategory = await this.getSchemaItem<MutablePropertyCategory>(propCategoryKey);\r\n propertyCategory.setPriority(priority);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.SetPropertyCategoryPriority, new SchemaItemId(this.schemaItemType, propCategoryKey), e);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module Editing
|
|
3
3
|
*/
|
|
4
4
|
import { CustomAttribute, ECClassModifier, EntityClass, Mixin, NavigationPropertyProps, RelationshipClass, RelationshipClassProps, RelationshipConstraint, RelationshipEnd, RelationshipMultiplicity, SchemaItemKey, SchemaKey, StrengthDirection, StrengthType } from "@itwin/ecschema-metadata";
|
|
5
|
-
import {
|
|
5
|
+
import { SchemaContextEditor } from "./Editor";
|
|
6
6
|
import { ECClasses } from "./ECClasses";
|
|
7
7
|
import { NavigationProperties } from "./Properties";
|
|
8
8
|
/**
|
|
@@ -24,47 +24,45 @@ export declare class RelationshipClasses extends ECClasses {
|
|
|
24
24
|
* @param StrengthDirection The relationship StrengthDirection of the class.
|
|
25
25
|
* @param baseClassKey An optional SchemaItemKey that specifies the base relationship class.
|
|
26
26
|
*/
|
|
27
|
-
create(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, strength: StrengthType, direction: StrengthDirection, baseClassKey?: SchemaItemKey): Promise<
|
|
27
|
+
create(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, strength: StrengthType, direction: StrengthDirection, baseClassKey?: SchemaItemKey): Promise<SchemaItemKey>;
|
|
28
28
|
/**
|
|
29
29
|
* Sets the source RelationshipConstraint on the relationship.
|
|
30
30
|
* @param relationshipKey The SchemaItemKey for the relationship.
|
|
31
31
|
* @param source The RelationshipConstraint to add.
|
|
32
|
-
* @returns A promise of type SchemaItemEditResults.
|
|
33
32
|
*/
|
|
34
|
-
setSourceConstraint(relationshipKey: SchemaItemKey, source: RelationshipConstraint): Promise<
|
|
33
|
+
setSourceConstraint(relationshipKey: SchemaItemKey, source: RelationshipConstraint): Promise<void>;
|
|
35
34
|
/**
|
|
36
35
|
* Sets the target RelationshipConstraint on the relationship.
|
|
37
36
|
* @param relationshipKey The SchemaItemKey for the relationship.
|
|
38
37
|
* @param target The RelationshipConstraint to add.
|
|
39
|
-
* @returns A promise of type SchemaItemEditResults.
|
|
40
38
|
*/
|
|
41
|
-
setTargetConstraint(relationshipKey: SchemaItemKey, target: RelationshipConstraint): Promise<
|
|
39
|
+
setTargetConstraint(relationshipKey: SchemaItemKey, target: RelationshipConstraint): Promise<void>;
|
|
42
40
|
/**
|
|
43
41
|
* Creates a RelationshipClass through a RelationshipClassProps.
|
|
44
42
|
* @param schemaKey a SchemaKey of the Schema that will house the new object.
|
|
45
43
|
* @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.
|
|
46
44
|
*/
|
|
47
|
-
createFromProps(schemaKey: SchemaKey, relationshipProps: RelationshipClassProps): Promise<
|
|
45
|
+
createFromProps(schemaKey: SchemaKey, relationshipProps: RelationshipClassProps): Promise<SchemaItemKey>;
|
|
48
46
|
/**
|
|
49
47
|
* Sets the base class of a RelationshipClass.
|
|
50
48
|
* @param relationshipKey The SchemaItemKey of the RelationshipClass.
|
|
51
49
|
* @param baseClassKey The SchemaItemKey of the base class. Specifying 'undefined' removes the base class.
|
|
52
50
|
*/
|
|
53
|
-
setBaseClass(itemKey: SchemaItemKey, baseClassKey?: SchemaItemKey): Promise<
|
|
54
|
-
createNavigationProperty(relationshipKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<
|
|
51
|
+
setBaseClass(itemKey: SchemaItemKey, baseClassKey?: SchemaItemKey): Promise<void>;
|
|
52
|
+
createNavigationProperty(relationshipKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<void>;
|
|
55
53
|
/**
|
|
56
54
|
* Creates a Navigation Property through a NavigationPropertyProps.
|
|
57
55
|
* @param classKey a SchemaItemKey of the Relationship Class that will house the new property.
|
|
58
56
|
* @param navigationProps a json object that will be used to populate the new Navigation Property.
|
|
59
57
|
*/
|
|
60
|
-
createNavigationPropertyFromProps(relationshipKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<
|
|
61
|
-
setConstraintMultiplicity(constraint: RelationshipConstraint, multiplicity: RelationshipMultiplicity): Promise<
|
|
62
|
-
setConstraintPolymorphic(constraint: RelationshipConstraint, polymorphic: boolean): Promise<
|
|
63
|
-
setConstraintRelationshipEnd(constraint: RelationshipConstraint, relationshipEnd: RelationshipEnd): Promise<
|
|
64
|
-
setAbstractConstraint(constraint: RelationshipConstraint, abstractConstraint?: EntityClass | Mixin | RelationshipClass): Promise<
|
|
65
|
-
addConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<
|
|
66
|
-
removeConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<
|
|
67
|
-
addCustomAttributeToConstraint(constraint: RelationshipConstraint, customAttribute: CustomAttribute): Promise<
|
|
58
|
+
createNavigationPropertyFromProps(relationshipKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<void>;
|
|
59
|
+
setConstraintMultiplicity(constraint: RelationshipConstraint, multiplicity: RelationshipMultiplicity): Promise<void>;
|
|
60
|
+
setConstraintPolymorphic(constraint: RelationshipConstraint, polymorphic: boolean): Promise<void>;
|
|
61
|
+
setConstraintRelationshipEnd(constraint: RelationshipConstraint, relationshipEnd: RelationshipEnd): Promise<void>;
|
|
62
|
+
setAbstractConstraint(constraint: RelationshipConstraint, abstractConstraint?: EntityClass | Mixin | RelationshipClass): Promise<void>;
|
|
63
|
+
addConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<void>;
|
|
64
|
+
removeConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<void>;
|
|
65
|
+
addCustomAttributeToConstraint(constraint: RelationshipConstraint, customAttribute: CustomAttribute): Promise<void>;
|
|
68
66
|
private validate;
|
|
69
67
|
}
|
|
70
68
|
//# 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,EACL,eAAe,EAA2B,eAAe,EAAE,WAAW,EAAyC,KAAK,EAAE,uBAAuB,EAC7I,iBAAiB,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,eAAe,EAAE,wBAAwB,EAAE,aAAa,EAC3H,SAAS,EAAE,iBAAiB,EAAE,YAAY,EAC3C,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"RelationshipClasses.d.ts","sourceRoot":"","sources":["../../../src/Editing/RelationshipClasses.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,eAAe,EAA2B,eAAe,EAAE,WAAW,EAAyC,KAAK,EAAE,uBAAuB,EAC7I,iBAAiB,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,eAAe,EAAE,wBAAwB,EAAE,aAAa,EAC3H,SAAS,EAAE,iBAAiB,EAAE,YAAY,EAC3C,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGpD;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;gBAC7B,YAAY,EAAE,mBAAmB;IAIpD;;OAEG;IACH,SAAgB,oBAAoB,uBAAoE;IAExG;;;;;;;;OAQG;IACU,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,YAAY,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAa9L;;;;OAIG;IACU,mBAAmB,CAAC,eAAe,EAAE,aAAa,EAAE,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAS/G;;;;OAIG;IACU,mBAAmB,CAAC,eAAe,EAAE,aAAa,EAAE,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAS/G;;;;OAIG;IACU,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,iBAAiB,EAAE,sBAAsB,GAAG,OAAO,CAAC,aAAa,CAAC;IAarH;;;;OAIG;IACmB,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAc1F,wBAAwB,CAAC,eAAe,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IASnL;;;;OAIG;IACU,iCAAiC,CAAC,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1H,yBAAyB,CAAC,UAAU,EAAE,sBAAsB,EAAE,YAAY,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpH,wBAAwB,CAAC,UAAU,EAAE,sBAAsB,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjG,4BAA4B,CAAC,UAAU,EAAE,sBAAsB,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjH,qBAAqB,CAAC,UAAU,EAAE,sBAAsB,EAAE,kBAAkB,CAAC,EAAE,WAAW,GAAG,KAAK,GAAG,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBtI,kBAAkB,CAAC,UAAU,EAAE,sBAAsB,EAAE,OAAO,EAAE,WAAW,GAAG,KAAK,GAAG,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBvH,qBAAqB,CAAC,UAAU,EAAE,sBAAsB,EAAE,OAAO,EAAE,WAAW,GAAG,KAAK,GAAG,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAY1H,8BAA8B,CAAC,UAAU,EAAE,sBAAsB,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;YAkBlH,QAAQ;CAyBvB"}
|
|
@@ -12,6 +12,7 @@ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
|
12
12
|
const ECClasses_1 = require("./ECClasses");
|
|
13
13
|
const Rules = require("../Validation/ECRules");
|
|
14
14
|
const Properties_1 = require("./Properties");
|
|
15
|
+
const Exception_1 = require("./Exception");
|
|
15
16
|
/**
|
|
16
17
|
* @alpha
|
|
17
18
|
* A class extending ECClasses allowing you to create schema items of type RelationshipClass.
|
|
@@ -22,7 +23,7 @@ class RelationshipClasses extends ECClasses_1.ECClasses {
|
|
|
22
23
|
/**
|
|
23
24
|
* Allows access for editing of NavigationProperty attributes.
|
|
24
25
|
*/
|
|
25
|
-
this.navigationProperties = new Properties_1.NavigationProperties(this.schemaItemType, this.
|
|
26
|
+
this.navigationProperties = new Properties_1.NavigationProperties(this.schemaItemType, this.schemaEditor);
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
29
|
* Creates a RelationshipClass.
|
|
@@ -34,52 +35,39 @@ class RelationshipClasses extends ECClasses_1.ECClasses {
|
|
|
34
35
|
* @param baseClassKey An optional SchemaItemKey that specifies the base relationship class.
|
|
35
36
|
*/
|
|
36
37
|
async create(schemaKey, name, modifier, strength, direction, baseClassKey) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return { errorMessage: `Schema Key ${baseClassKey.schemaKey.toString(true)} not found in context` };
|
|
46
|
-
}
|
|
47
|
-
const baseClassItem = await baseClassSchema.lookupItem(baseClassKey);
|
|
48
|
-
if (baseClassItem === undefined)
|
|
49
|
-
return { errorMessage: `Unable to locate base class ${baseClassKey.fullName} in schema ${baseClassSchema.fullName}.` };
|
|
50
|
-
if (baseClassItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.RelationshipClass)
|
|
51
|
-
return { errorMessage: `${baseClassItem.fullName} is not of type Relationship Class.` };
|
|
52
|
-
newClass.baseClass = new ecschema_metadata_1.DelayedPromiseWithProps(baseClassKey, async () => baseClassItem);
|
|
38
|
+
try {
|
|
39
|
+
const newClass = await this.createClass(schemaKey, this.schemaItemType, (schema) => schema.createRelationshipClass.bind(schema), name, baseClassKey, modifier);
|
|
40
|
+
newClass.setStrength(strength);
|
|
41
|
+
newClass.setStrengthDirection(direction);
|
|
42
|
+
return newClass.key;
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.CreateSchemaItemFailed, new Exception_1.ClassId(this.schemaItemType, name, schemaKey), e);
|
|
53
46
|
}
|
|
54
|
-
newClass.setStrength(strength);
|
|
55
|
-
newClass.setStrengthDirection(direction);
|
|
56
|
-
return { itemKey: newClass.key };
|
|
57
47
|
}
|
|
58
48
|
/**
|
|
59
49
|
* Sets the source RelationshipConstraint on the relationship.
|
|
60
50
|
* @param relationshipKey The SchemaItemKey for the relationship.
|
|
61
51
|
* @param source The RelationshipConstraint to add.
|
|
62
|
-
* @returns A promise of type SchemaItemEditResults.
|
|
63
52
|
*/
|
|
64
53
|
async setSourceConstraint(relationshipKey, source) {
|
|
65
|
-
const relationship =
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
const relationship = await this.getSchemaItem(relationshipKey)
|
|
55
|
+
.catch((e) => {
|
|
56
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetSourceConstraint, new Exception_1.ClassId(this.schemaItemType, relationshipKey), e);
|
|
57
|
+
});
|
|
68
58
|
relationship.setSourceConstraint(source);
|
|
69
|
-
return { itemKey: relationshipKey };
|
|
70
59
|
}
|
|
71
60
|
/**
|
|
72
61
|
* Sets the target RelationshipConstraint on the relationship.
|
|
73
62
|
* @param relationshipKey The SchemaItemKey for the relationship.
|
|
74
63
|
* @param target The RelationshipConstraint to add.
|
|
75
|
-
* @returns A promise of type SchemaItemEditResults.
|
|
76
64
|
*/
|
|
77
65
|
async setTargetConstraint(relationshipKey, target) {
|
|
78
|
-
const relationship = await this.
|
|
79
|
-
|
|
80
|
-
|
|
66
|
+
const relationship = await this.getSchemaItem(relationshipKey)
|
|
67
|
+
.catch((e) => {
|
|
68
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetTargetConstraint, new Exception_1.ClassId(this.schemaItemType, relationshipKey), e);
|
|
69
|
+
});
|
|
81
70
|
relationship.setTargetConstraint(target);
|
|
82
|
-
return { itemKey: relationshipKey };
|
|
83
71
|
}
|
|
84
72
|
/**
|
|
85
73
|
* Creates a RelationshipClass through a RelationshipClassProps.
|
|
@@ -87,16 +75,15 @@ class RelationshipClasses extends ECClasses_1.ECClasses {
|
|
|
87
75
|
* @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.
|
|
88
76
|
*/
|
|
89
77
|
async createFromProps(schemaKey, relationshipProps) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return { itemKey: newClass.key };
|
|
78
|
+
try {
|
|
79
|
+
const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createRelationshipClass.bind(schema), relationshipProps);
|
|
80
|
+
await newClass.source.fromJSON(relationshipProps.source);
|
|
81
|
+
await newClass.target.fromJSON(relationshipProps.target);
|
|
82
|
+
return newClass.key;
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.CreateSchemaItemFromProps, new Exception_1.ClassId(this.schemaItemType, relationshipProps.name, schemaKey), e);
|
|
86
|
+
}
|
|
100
87
|
}
|
|
101
88
|
/**
|
|
102
89
|
* Sets the base class of a RelationshipClass.
|
|
@@ -104,26 +91,25 @@ class RelationshipClasses extends ECClasses_1.ECClasses {
|
|
|
104
91
|
* @param baseClassKey The SchemaItemKey of the base class. Specifying 'undefined' removes the base class.
|
|
105
92
|
*/
|
|
106
93
|
async setBaseClass(itemKey, baseClassKey) {
|
|
107
|
-
const relClass = await this.
|
|
94
|
+
const relClass = await this.schemaEditor.schemaContext.getSchemaItem(itemKey);
|
|
108
95
|
const baseClass = relClass?.baseClass;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
96
|
+
await super.setBaseClass(itemKey, baseClassKey);
|
|
97
|
+
try {
|
|
98
|
+
await this.validate(relClass);
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
relClass.baseClass = baseClass;
|
|
102
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetBaseClass, new Exception_1.ClassId(ecschema_metadata_1.SchemaItemType.RelationshipClass, itemKey), e);
|
|
116
103
|
}
|
|
117
|
-
return setResult;
|
|
118
104
|
}
|
|
119
105
|
async createNavigationProperty(relationshipKey, name, relationship, direction) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
106
|
+
try {
|
|
107
|
+
const relationshipClass = await this.getSchemaItem(relationshipKey);
|
|
108
|
+
await relationshipClass.createNavigationProperty(name, relationship, direction);
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.CreateNavigationProperty, new Exception_1.ClassId(ecschema_metadata_1.SchemaItemType.RelationshipClass, relationshipKey), e);
|
|
112
|
+
}
|
|
127
113
|
}
|
|
128
114
|
/**
|
|
129
115
|
* Creates a Navigation Property through a NavigationPropertyProps.
|
|
@@ -131,29 +117,26 @@ class RelationshipClasses extends ECClasses_1.ECClasses {
|
|
|
131
117
|
* @param navigationProps a json object that will be used to populate the new Navigation Property.
|
|
132
118
|
*/
|
|
133
119
|
async createNavigationPropertyFromProps(relationshipKey, navigationProps) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
120
|
+
try {
|
|
121
|
+
const relationshipClass = await this.getSchemaItem(relationshipKey);
|
|
122
|
+
const property = await relationshipClass.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);
|
|
123
|
+
await property.fromJSON(navigationProps);
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.CreateNavigationPropertyFromProps, new Exception_1.ClassId(ecschema_metadata_1.SchemaItemType.RelationshipClass, relationshipKey), e);
|
|
127
|
+
}
|
|
142
128
|
}
|
|
143
129
|
async setConstraintMultiplicity(constraint, multiplicity) {
|
|
144
130
|
const mutableConstraint = constraint;
|
|
145
131
|
mutableConstraint.multiplicity = multiplicity;
|
|
146
|
-
return { itemKey: constraint.relationshipClass.key };
|
|
147
132
|
}
|
|
148
133
|
async setConstraintPolymorphic(constraint, polymorphic) {
|
|
149
134
|
const mutableConstraint = constraint;
|
|
150
135
|
mutableConstraint.polymorphic = polymorphic;
|
|
151
|
-
return { itemKey: constraint.relationshipClass.key };
|
|
152
136
|
}
|
|
153
137
|
async setConstraintRelationshipEnd(constraint, relationshipEnd) {
|
|
154
138
|
const mutableConstraint = constraint;
|
|
155
139
|
mutableConstraint.relationshipEnd = relationshipEnd;
|
|
156
|
-
return { itemKey: constraint.relationshipClass.key };
|
|
157
140
|
}
|
|
158
141
|
async setAbstractConstraint(constraint, abstractConstraint) {
|
|
159
142
|
const existing = constraint.abstractConstraint;
|
|
@@ -164,73 +147,86 @@ class RelationshipClasses extends ECClasses_1.ECClasses {
|
|
|
164
147
|
else {
|
|
165
148
|
mutableConstraint.abstractConstraint = new ecschema_metadata_1.DelayedPromiseWithProps(abstractConstraint.key, async () => abstractConstraint);
|
|
166
149
|
}
|
|
167
|
-
|
|
168
|
-
|
|
150
|
+
try {
|
|
151
|
+
await this.validate(constraint.relationshipClass);
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
169
154
|
mutableConstraint.abstractConstraint = existing;
|
|
170
|
-
|
|
155
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetAbstractConstraint, new Exception_1.RelationshipConstraintId(constraint), e);
|
|
171
156
|
}
|
|
172
|
-
|
|
173
|
-
|
|
157
|
+
try {
|
|
158
|
+
await this.validate(constraint);
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
174
161
|
mutableConstraint.abstractConstraint = existing;
|
|
175
|
-
|
|
162
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetAbstractConstraint, new Exception_1.RelationshipConstraintId(constraint), e);
|
|
176
163
|
}
|
|
177
|
-
return { itemKey: constraint.relationshipClass.key };
|
|
178
164
|
}
|
|
179
165
|
async addConstraintClass(constraint, ecClass) {
|
|
180
166
|
const mutableConstraint = constraint;
|
|
181
167
|
mutableConstraint.addClass(ecClass);
|
|
182
|
-
|
|
183
|
-
|
|
168
|
+
try {
|
|
169
|
+
await this.validate(constraint.relationshipClass);
|
|
170
|
+
}
|
|
171
|
+
catch (e) {
|
|
184
172
|
mutableConstraint.removeClass(ecClass);
|
|
185
|
-
|
|
173
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.AddConstraintClass, new Exception_1.RelationshipConstraintId(constraint), e);
|
|
186
174
|
}
|
|
187
|
-
|
|
188
|
-
|
|
175
|
+
try {
|
|
176
|
+
await this.validate(constraint);
|
|
177
|
+
}
|
|
178
|
+
catch (e) {
|
|
189
179
|
mutableConstraint.removeClass(ecClass);
|
|
190
|
-
|
|
180
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.AddConstraintClass, new Exception_1.RelationshipConstraintId(constraint), e);
|
|
191
181
|
}
|
|
192
|
-
return { itemKey: constraint.relationshipClass.key };
|
|
193
182
|
}
|
|
194
183
|
async removeConstraintClass(constraint, ecClass) {
|
|
195
184
|
const mutableConstraint = constraint;
|
|
196
185
|
mutableConstraint.removeClass(ecClass);
|
|
197
|
-
|
|
198
|
-
|
|
186
|
+
try {
|
|
187
|
+
await this.validate(constraint);
|
|
188
|
+
}
|
|
189
|
+
catch (e) {
|
|
199
190
|
mutableConstraint.addClass(ecClass);
|
|
200
|
-
|
|
191
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.RemoveConstraintClass, new Exception_1.RelationshipConstraintId(constraint), e);
|
|
201
192
|
}
|
|
202
|
-
return { itemKey: constraint.relationshipClass.key };
|
|
203
193
|
}
|
|
204
194
|
async addCustomAttributeToConstraint(constraint, customAttribute) {
|
|
205
195
|
const mutableConstraint = constraint;
|
|
206
196
|
mutableConstraint.addCustomAttribute(customAttribute);
|
|
207
|
-
const
|
|
208
|
-
const
|
|
209
|
-
for await (const diagnostic of
|
|
210
|
-
|
|
197
|
+
const diagnosticIterable = Rules.validateCustomAttributeInstance(constraint, customAttribute);
|
|
198
|
+
const diagnostics = [];
|
|
199
|
+
for await (const diagnostic of diagnosticIterable) {
|
|
200
|
+
diagnostics.push(diagnostic);
|
|
211
201
|
}
|
|
212
|
-
if (
|
|
202
|
+
if (diagnostics.length > 0) {
|
|
213
203
|
this.removeCustomAttribute(constraint, customAttribute);
|
|
214
|
-
|
|
204
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.AddCustomAttributeToConstraint, new Exception_1.RelationshipConstraintId(constraint), new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.RuleViolation, new Exception_1.CustomAttributeId(customAttribute.className, constraint), undefined, diagnostics));
|
|
215
205
|
}
|
|
216
|
-
return { itemKey: constraint.relationshipClass.key };
|
|
217
206
|
}
|
|
218
207
|
async validate(relationshipOrConstraint) {
|
|
219
|
-
let
|
|
208
|
+
let diagnosticIterable;
|
|
209
|
+
let relationshipKey;
|
|
220
210
|
if (relationshipOrConstraint instanceof ecschema_metadata_1.RelationshipClass) {
|
|
221
|
-
|
|
211
|
+
diagnosticIterable = Rules.validateRelationship(relationshipOrConstraint);
|
|
212
|
+
relationshipKey = relationshipOrConstraint.key;
|
|
222
213
|
}
|
|
223
214
|
else {
|
|
224
|
-
|
|
215
|
+
diagnosticIterable = Rules.validateRelationshipConstraint(relationshipOrConstraint);
|
|
216
|
+
relationshipKey = relationshipOrConstraint.relationshipClass.key;
|
|
225
217
|
}
|
|
226
|
-
const
|
|
227
|
-
for await (const diagnostic of
|
|
228
|
-
|
|
218
|
+
const diagnostics = [];
|
|
219
|
+
for await (const diagnostic of diagnosticIterable) {
|
|
220
|
+
diagnostics.push(diagnostic);
|
|
229
221
|
}
|
|
230
|
-
if (
|
|
231
|
-
|
|
222
|
+
if (diagnostics.length > 0) {
|
|
223
|
+
if (relationshipOrConstraint instanceof ecschema_metadata_1.RelationshipClass) {
|
|
224
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.RuleViolation, new Exception_1.ClassId(ecschema_metadata_1.SchemaItemType.RelationshipClass, relationshipKey), undefined, diagnostics);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.RuleViolation, new Exception_1.RelationshipConstraintId(relationshipOrConstraint), undefined, diagnostics);
|
|
228
|
+
}
|
|
232
229
|
}
|
|
233
|
-
return {};
|
|
234
230
|
}
|
|
235
231
|
}
|
|
236
232
|
exports.RelationshipClasses = RelationshipClasses;
|