@itwin/ecschema-editing 4.7.0-dev.15 → 4.7.0-dev.16

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.
Files changed (171) hide show
  1. package/lib/cjs/Differencing/Errors.js.map +1 -1
  2. package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
  3. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  4. package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
  5. package/lib/cjs/Editing/Constants.d.ts +6 -6
  6. package/lib/cjs/Editing/Constants.d.ts.map +1 -1
  7. package/lib/cjs/Editing/Constants.js +26 -31
  8. package/lib/cjs/Editing/Constants.js.map +1 -1
  9. package/lib/cjs/Editing/CustomAttributes.d.ts +3 -3
  10. package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
  11. package/lib/cjs/Editing/CustomAttributes.js +18 -28
  12. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  13. package/lib/cjs/Editing/ECClasses.d.ts +24 -23
  14. package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
  15. package/lib/cjs/Editing/ECClasses.js +126 -156
  16. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  17. package/lib/cjs/Editing/Editor.d.ts +10 -31
  18. package/lib/cjs/Editing/Editor.d.ts.map +1 -1
  19. package/lib/cjs/Editing/Editor.js +59 -43
  20. package/lib/cjs/Editing/Editor.js.map +1 -1
  21. package/lib/cjs/Editing/Entities.d.ts +9 -9
  22. package/lib/cjs/Editing/Entities.d.ts.map +1 -1
  23. package/lib/cjs/Editing/Entities.js +65 -85
  24. package/lib/cjs/Editing/Entities.js.map +1 -1
  25. package/lib/cjs/Editing/Enumerations.d.ts +6 -6
  26. package/lib/cjs/Editing/Enumerations.d.ts.map +1 -1
  27. package/lib/cjs/Editing/Enumerations.js +57 -55
  28. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  29. package/lib/cjs/Editing/Exception.d.ts +257 -0
  30. package/lib/cjs/Editing/Exception.d.ts.map +1 -0
  31. package/lib/cjs/Editing/Exception.js +426 -0
  32. package/lib/cjs/Editing/Exception.js.map +1 -0
  33. package/lib/cjs/Editing/Formats.d.ts +6 -6
  34. package/lib/cjs/Editing/Formats.d.ts.map +1 -1
  35. package/lib/cjs/Editing/Formats.js +28 -33
  36. package/lib/cjs/Editing/Formats.js.map +1 -1
  37. package/lib/cjs/Editing/InvertedUnits.d.ts +6 -6
  38. package/lib/cjs/Editing/InvertedUnits.d.ts.map +1 -1
  39. package/lib/cjs/Editing/InvertedUnits.js +41 -56
  40. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  41. package/lib/cjs/Editing/KindOfQuantities.d.ts +6 -6
  42. package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
  43. package/lib/cjs/Editing/KindOfQuantities.js +50 -57
  44. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  45. package/lib/cjs/Editing/Mixins.d.ts +5 -5
  46. package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
  47. package/lib/cjs/Editing/Mixins.js +43 -58
  48. package/lib/cjs/Editing/Mixins.js.map +1 -1
  49. package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -1
  50. package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
  51. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  52. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  53. package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts +1 -5
  54. package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts.map +1 -1
  55. package/lib/cjs/Editing/Mutable/MutableEntityClass.js +1 -45
  56. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  57. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  58. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  59. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  60. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  61. package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
  62. package/lib/cjs/Editing/Mutable/MutableNavigationProperty.js.map +1 -1
  63. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  64. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
  65. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  66. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  67. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  68. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  69. package/lib/cjs/Editing/Mutable/MutableStructProperty.js.map +1 -1
  70. package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
  71. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  72. package/lib/cjs/Editing/Phenomena.d.ts +7 -7
  73. package/lib/cjs/Editing/Phenomena.d.ts.map +1 -1
  74. package/lib/cjs/Editing/Phenomena.js +23 -23
  75. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  76. package/lib/cjs/Editing/Properties.d.ts +7 -6
  77. package/lib/cjs/Editing/Properties.d.ts.map +1 -1
  78. package/lib/cjs/Editing/Properties.js +99 -46
  79. package/lib/cjs/Editing/Properties.js.map +1 -1
  80. package/lib/cjs/Editing/PropertyCategories.d.ts +6 -6
  81. package/lib/cjs/Editing/PropertyCategories.d.ts.map +1 -1
  82. package/lib/cjs/Editing/PropertyCategories.js +29 -27
  83. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  84. package/lib/cjs/Editing/RelationshipClasses.d.ts +15 -17
  85. package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
  86. package/lib/cjs/Editing/RelationshipClasses.js +97 -101
  87. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  88. package/lib/cjs/Editing/SchemaItems.d.ts +13 -5
  89. package/lib/cjs/Editing/SchemaItems.d.ts.map +1 -1
  90. package/lib/cjs/Editing/SchemaItems.js +58 -6
  91. package/lib/cjs/Editing/SchemaItems.js.map +1 -1
  92. package/lib/cjs/Editing/Structs.d.ts +3 -3
  93. package/lib/cjs/Editing/Structs.d.ts.map +1 -1
  94. package/lib/cjs/Editing/Structs.js +17 -27
  95. package/lib/cjs/Editing/Structs.js.map +1 -1
  96. package/lib/cjs/Editing/UnitSystems.d.ts +7 -7
  97. package/lib/cjs/Editing/UnitSystems.d.ts.map +1 -1
  98. package/lib/cjs/Editing/UnitSystems.js +22 -20
  99. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  100. package/lib/cjs/Editing/Units.d.ts +6 -6
  101. package/lib/cjs/Editing/Units.d.ts.map +1 -1
  102. package/lib/cjs/Editing/Units.js +26 -35
  103. package/lib/cjs/Editing/Units.js.map +1 -1
  104. package/lib/cjs/Merging/CAClassMerger.js +2 -2
  105. package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
  106. package/lib/cjs/Merging/ClassMerger.d.ts +1 -2
  107. package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
  108. package/lib/cjs/Merging/ClassMerger.js +15 -39
  109. package/lib/cjs/Merging/ClassMerger.js.map +1 -1
  110. package/lib/cjs/Merging/ConstantMerger.d.ts.map +1 -1
  111. package/lib/cjs/Merging/ConstantMerger.js +2 -3
  112. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  113. package/lib/cjs/Merging/CustomAttributeMerger.d.ts +4 -5
  114. package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
  115. package/lib/cjs/Merging/CustomAttributeMerger.js +8 -18
  116. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
  117. package/lib/cjs/Merging/EntityClassMerger.d.ts +1 -2
  118. package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -1
  119. package/lib/cjs/Merging/EntityClassMerger.js +3 -10
  120. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
  121. package/lib/cjs/Merging/EnumerationMerger.d.ts.map +1 -1
  122. package/lib/cjs/Merging/EnumerationMerger.js +8 -10
  123. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  124. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
  125. package/lib/cjs/Merging/KindOfQuantityMerger.js +2 -3
  126. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
  127. package/lib/cjs/Merging/MixinMerger.js +2 -2
  128. package/lib/cjs/Merging/MixinMerger.js.map +1 -1
  129. package/lib/cjs/Merging/PhenomenonMerger.d.ts.map +1 -1
  130. package/lib/cjs/Merging/PhenomenonMerger.js +1 -2
  131. package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
  132. package/lib/cjs/Merging/PropertyCategoryMerger.d.ts.map +1 -1
  133. package/lib/cjs/Merging/PropertyCategoryMerger.js +1 -2
  134. package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
  135. package/lib/cjs/Merging/PropertyMerger.d.ts +2 -3
  136. package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -1
  137. package/lib/cjs/Merging/PropertyMerger.js +21 -42
  138. package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
  139. package/lib/cjs/Merging/RelationshipClassMerger.d.ts +5 -3
  140. package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -1
  141. package/lib/cjs/Merging/RelationshipClassMerger.js +19 -31
  142. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
  143. package/lib/cjs/Merging/SchemaItemMerger.d.ts +3 -4
  144. package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +1 -1
  145. package/lib/cjs/Merging/SchemaItemMerger.js +3 -2
  146. package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
  147. package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
  148. package/lib/cjs/Merging/SchemaMerger.js +2 -8
  149. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  150. package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
  151. package/lib/cjs/Merging/UnitSystemMerger.d.ts.map +1 -1
  152. package/lib/cjs/Merging/UnitSystemMerger.js +1 -2
  153. package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
  154. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  155. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  156. package/lib/cjs/Validation/ECRules.js.map +1 -1
  157. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  158. package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
  159. package/lib/cjs/Validation/Rules.js.map +1 -1
  160. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  161. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  162. package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
  163. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  164. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  165. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  166. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  167. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  168. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  169. package/lib/cjs/ecschema-editing.js.map +1 -1
  170. package/package.json +9 -9
  171. 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,EAAmC,qBAAqB,EAAE,aAAa,EAAkB,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC5I,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtE;;;GAGG;AACH,qBAAa,kBAAkB;IACV,SAAS,CAAC,aAAa,EAAE,mBAAmB;gBAAlC,aAAa,EAAE,mBAAmB;IAClD,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAanH,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,qBAAqB,EAAE,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAgBnH,WAAW,CAAC,eAAe,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAW1F"}
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(_schemaEditor) {
18
- this._schemaEditor = _schemaEditor;
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
- const schema = await this._schemaEditor.getSchema(schemaKey);
22
- if (schema === undefined)
23
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
24
- const newPropCategory = (await schema.createPropertyCategory(name));
25
- newPropCategory.setPriority(priority);
26
- if (displayLabel)
27
- newPropCategory.setDisplayLabel(displayLabel);
28
- return { itemKey: newPropCategory.key };
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
- const schema = await this._schemaEditor.getSchema(schemaKey);
32
- if (schema === undefined)
33
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
34
- if (propertyCategoryProps.name === undefined)
35
- return { errorMessage: `No name was supplied within props.` };
36
- const newPropCategory = (await schema.createPropertyCategory(propertyCategoryProps.name));
37
- if (newPropCategory === undefined)
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
- const propertyCategory = (await this._schemaEditor.schemaContext.getSchemaItem(propCategoryKey));
44
- if (propertyCategory === undefined)
45
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Property Category ${propCategoryKey.fullName} not found in schema context.`);
46
- if (propertyCategory.schemaItemType !== ecschema_metadata_1.SchemaItemType.PropertyCategory)
47
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${propCategoryKey.fullName} to be of type Property Category.`);
48
- propertyCategory.setPriority(priority);
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,gEAA4I;AAI5I;;;GAGG;AACH,MAAa,kBAAkB;IAC7B,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,QAAgB,EAAE,YAAqB;QAC7F,MAAM,MAA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CAAC,WAAW,CAAC,eAA8B,EAAE,QAAgB;QACvE,MAAM,gBAAgB,GAAG,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAA0B,eAAe,CAAC,CAAC,CAAC;QAE1H,IAAI,gBAAgB,KAAK,SAAS;YAChC,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,qBAAqB,eAAe,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QAExI,IAAI,gBAAgB,CAAC,cAAc,KAAK,kCAAc,CAAC,gBAAgB;YACrE,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,qBAAqB,EAAE,YAAY,eAAe,CAAC,QAAQ,mCAAmC,CAAC,CAAC;QAE3I,gBAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC;CACF;AA1CD,gDA0CC","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 { ECObjectsError, ECObjectsStatus, PropertyCategoryProps, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { MutablePropertyCategory } from \"./Mutable/MutablePropertyCategory\";\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 {\r\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\r\n public async create(schemaKey: SchemaKey, name: string, priority: number, displayLabel?: string): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(schemaKey);\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n const newPropCategory = (await schema.createPropertyCategory(name)) as MutablePropertyCategory;\r\n newPropCategory.setPriority(priority);\r\n if (displayLabel)\r\n newPropCategory.setDisplayLabel(displayLabel);\r\n\r\n return { itemKey: newPropCategory.key };\r\n }\r\n\r\n public async createFromProps(schemaKey: SchemaKey, propertyCategoryProps: PropertyCategoryProps): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(schemaKey);\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n if (propertyCategoryProps.name === undefined)\r\n return { errorMessage: `No name was supplied within props.` };\r\n\r\n const newPropCategory = (await schema.createPropertyCategory(propertyCategoryProps.name)) as MutablePropertyCategory;\r\n if (newPropCategory === undefined)\r\n return { errorMessage: `Failed to create class ${propertyCategoryProps.name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n await newPropCategory.fromJSON(propertyCategoryProps);\r\n return { itemKey: newPropCategory.key };\r\n }\r\n\r\n public async setPriority(propCategoryKey: SchemaItemKey, priority: number): Promise<void> {\r\n const propertyCategory = (await this._schemaEditor.schemaContext.getSchemaItem<MutablePropertyCategory>(propCategoryKey));\r\n\r\n if (propertyCategory === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Property Category ${propCategoryKey.fullName} not found in schema context.`);\r\n\r\n if (propertyCategory.schemaItemType !== SchemaItemType.PropertyCategory)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${propCategoryKey.fullName} to be of type Property Category.`);\r\n\r\n propertyCategory.setPriority(priority);\r\n }\r\n}\r\n"]}
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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AEM,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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { PropertyCategory, PropertyCategoryProps, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutablePropertyCategory } from \"./Mutable/MutablePropertyCategory\";\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\nimport { SchemaItems } from \"./SchemaItems\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Property Category.\n */\nexport class PropertyCategories extends SchemaItems {\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.PropertyCategory, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, priority: number, displayLabel?: string): Promise<SchemaItemKey> {\n try {\n const newPropCategory = await this.createSchemaItem<PropertyCategory>(schemaKey, this.schemaItemType, (schema) => schema.createPropertyCategory.bind(schema), name) as MutablePropertyCategory;\n newPropCategory.setPriority(priority);\n if (displayLabel)\n newPropCategory.setDisplayLabel(displayLabel);\n\n return newPropCategory.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n public async createFromProps(schemaKey: SchemaKey, propertyCategoryProps: PropertyCategoryProps): Promise<SchemaItemKey> {\n try {\n const newPropCategory = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createPropertyCategory.bind(schema), propertyCategoryProps);\n return newPropCategory.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, propertyCategoryProps.name!, schemaKey), e);\n }\n }\n\n public async setPriority(propCategoryKey: SchemaItemKey, priority: number): Promise<void> {\n try {\n const propertyCategory = await this.getSchemaItem<MutablePropertyCategory>(propCategoryKey);\n propertyCategory.setPriority(priority);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.SetPropertyCategoryPriority, new SchemaItemId(this.schemaItemType, propCategoryKey), e);\n }\n }\n}\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 { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from "./Editor";
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<SchemaItemEditResults>;
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<SchemaItemEditResults>;
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<SchemaItemEditResults>;
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<SchemaItemEditResults>;
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<SchemaItemEditResults>;
54
- createNavigationProperty(relationshipKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<PropertyEditResults>;
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<PropertyEditResults>;
61
- setConstraintMultiplicity(constraint: RelationshipConstraint, multiplicity: RelationshipMultiplicity): Promise<SchemaItemEditResults>;
62
- setConstraintPolymorphic(constraint: RelationshipConstraint, polymorphic: boolean): Promise<SchemaItemEditResults>;
63
- setConstraintRelationshipEnd(constraint: RelationshipConstraint, relationshipEnd: RelationshipEnd): Promise<SchemaItemEditResults>;
64
- setAbstractConstraint(constraint: RelationshipConstraint, abstractConstraint?: EntityClass | Mixin | RelationshipClass): Promise<SchemaItemEditResults>;
65
- addConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<SchemaItemEditResults>;
66
- removeConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<SchemaItemEditResults>;
67
- addCustomAttributeToConstraint(constraint: RelationshipConstraint, customAttribute: CustomAttribute): Promise<SchemaItemEditResults>;
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,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;gBAC7B,YAAY,EAAE,mBAAmB;IAIpD;;OAEG;IACH,SAAgB,oBAAoB,uBAAqE;IAEzG;;;;;;;;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,qBAAqB,CAAC;IA6BtM;;;;;OAKG;IACU,mBAAmB,CAAC,eAAe,EAAE,aAAa,EAAE,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAUhI;;;;;OAKG;IACU,mBAAmB,CAAC,eAA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AAI,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._schemaEditor);
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
- const schema = await this._schemaEditor.getSchema(schemaKey);
38
- if (schema === undefined) {
39
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
40
- }
41
- const newClass = (await schema.createRelationshipClass(name, modifier));
42
- if (baseClassKey !== undefined) {
43
- const baseClassSchema = !baseClassKey.schemaKey.matches(schema.schemaKey) ? await this._schemaEditor.getSchema(baseClassKey.schemaKey) : schema;
44
- if (baseClassSchema === undefined) {
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 = (await this._schemaEditor.schemaContext.getSchemaItem(relationshipKey));
66
- if (relationship === undefined)
67
- return { itemKey: relationshipKey, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };
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._schemaEditor.schemaContext.getSchemaItem(relationshipKey);
79
- if (relationship === undefined)
80
- return { itemKey: relationshipKey, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };
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
- const schema = await this._schemaEditor.getSchema(schemaKey);
91
- if (schema === undefined)
92
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
93
- if (relationshipProps.name === undefined)
94
- return { errorMessage: `No name was supplied within props.` };
95
- const newClass = (await schema.createRelationshipClass(relationshipProps.name));
96
- await newClass.fromJSON(relationshipProps);
97
- await newClass.source.fromJSON(relationshipProps.source);
98
- await newClass.target.fromJSON(relationshipProps.target);
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._schemaEditor.schemaContext.getSchemaItem(itemKey);
94
+ const relClass = await this.schemaEditor.schemaContext.getSchemaItem(itemKey);
108
95
  const baseClass = relClass?.baseClass;
109
- const setResult = await super.setBaseClass(itemKey, baseClassKey);
110
- if (setResult.errorMessage === undefined) {
111
- const result = await this.validate(relClass);
112
- if (result.errorMessage !== undefined) {
113
- relClass.baseClass = baseClass;
114
- return { itemKey, errorMessage: result.errorMessage };
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
- const relationshipClass = (await this._schemaEditor.schemaContext.getSchemaItem(relationshipKey));
121
- if (relationshipClass === undefined)
122
- return { itemKey: relationshipKey, propertyName: name, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };
123
- if (relationshipClass.schemaItemType !== ecschema_metadata_1.SchemaItemType.RelationshipClass)
124
- return { itemKey: relationshipKey, propertyName: name, errorMessage: `Expected ${relationshipKey.fullName} to be of type Relationship Class.` };
125
- await relationshipClass.createNavigationProperty(name, relationship, direction);
126
- return { itemKey: relationshipKey, propertyName: name };
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
- const relationshipClass = await this._schemaEditor.schemaContext.getSchemaItem(relationshipKey);
135
- if (relationshipClass === undefined)
136
- return { itemKey: relationshipKey, propertyName: navigationProps.name, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };
137
- if (relationshipClass.schemaItemType !== ecschema_metadata_1.SchemaItemType.RelationshipClass)
138
- return { itemKey: relationshipKey, propertyName: navigationProps.name, errorMessage: `Expected ${relationshipKey.fullName} to be of type Relationship Class.` };
139
- const property = await relationshipClass.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);
140
- await property.fromJSON(navigationProps);
141
- return { itemKey: relationshipKey, propertyName: navigationProps.name };
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
- let result = await this.validate(constraint.relationshipClass);
168
- if (result.errorMessage) {
150
+ try {
151
+ await this.validate(constraint.relationshipClass);
152
+ }
153
+ catch (e) {
169
154
  mutableConstraint.abstractConstraint = existing;
170
- return result;
155
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetAbstractConstraint, new Exception_1.RelationshipConstraintId(constraint), e);
171
156
  }
172
- result = await this.validate(constraint);
173
- if (result.errorMessage) {
157
+ try {
158
+ await this.validate(constraint);
159
+ }
160
+ catch (e) {
174
161
  mutableConstraint.abstractConstraint = existing;
175
- return result;
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
- let result = await this.validate(constraint.relationshipClass);
183
- if (result.errorMessage) {
168
+ try {
169
+ await this.validate(constraint.relationshipClass);
170
+ }
171
+ catch (e) {
184
172
  mutableConstraint.removeClass(ecClass);
185
- return result;
173
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.AddConstraintClass, new Exception_1.RelationshipConstraintId(constraint), e);
186
174
  }
187
- result = await this.validate(constraint);
188
- if (result.errorMessage) {
175
+ try {
176
+ await this.validate(constraint);
177
+ }
178
+ catch (e) {
189
179
  mutableConstraint.removeClass(ecClass);
190
- return result;
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
- const result = await this.validate(constraint);
198
- if (result.errorMessage) {
186
+ try {
187
+ await this.validate(constraint);
188
+ }
189
+ catch (e) {
199
190
  mutableConstraint.addClass(ecClass);
200
- return result;
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 diagnostics = Rules.validateCustomAttributeInstance(constraint, customAttribute);
208
- const result = { errorMessage: "" };
209
- for await (const diagnostic of diagnostics) {
210
- result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\r\n`;
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 (result.errorMessage) {
202
+ if (diagnostics.length > 0) {
213
203
  this.removeCustomAttribute(constraint, customAttribute);
214
- return result;
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 diagnostics;
208
+ let diagnosticIterable;
209
+ let relationshipKey;
220
210
  if (relationshipOrConstraint instanceof ecschema_metadata_1.RelationshipClass) {
221
- diagnostics = Rules.validateRelationship(relationshipOrConstraint);
211
+ diagnosticIterable = Rules.validateRelationship(relationshipOrConstraint);
212
+ relationshipKey = relationshipOrConstraint.key;
222
213
  }
223
214
  else {
224
- diagnostics = Rules.validateRelationshipConstraint(relationshipOrConstraint);
215
+ diagnosticIterable = Rules.validateRelationshipConstraint(relationshipOrConstraint);
216
+ relationshipKey = relationshipOrConstraint.relationshipClass.key;
225
217
  }
226
- const errorMessages = [];
227
- for await (const diagnostic of diagnostics) {
228
- errorMessages.push(`${diagnostic.code}: ${diagnostic.messageText}`);
218
+ const diagnostics = [];
219
+ for await (const diagnostic of diagnosticIterable) {
220
+ diagnostics.push(diagnostic);
229
221
  }
230
- if (errorMessages.length > 0) {
231
- return { errorMessage: errorMessages.join("\r\n") };
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;