@itwin/grouping-mapping-widget 0.35.1 → 0.35.3

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.
@@ -112,7 +112,9 @@ class QueryBuilder {
112
112
  this.addRelatedToQuery(i, propertiesField, propertyName, propertyValue);
113
113
  }
114
114
  else {
115
- this.addPropertyToQuery(i, className, propertyName, propertyValue, this.needsQuote(propertiesField), isCategory, modeledElement, isAspect);
115
+ // Model properties with display values always need quotes
116
+ const needsQuote = !!modeledElement || this.needsQuote(propertiesField);
117
+ this.addPropertyToQuery(i, className, propertyName, propertyValue, needsQuote, isCategory, modeledElement, isAspect);
116
118
  }
117
119
  }
118
120
  return true;
@@ -189,7 +191,13 @@ class QueryBuilder {
189
191
  });
190
192
  return;
191
193
  }
192
- const foundPropertyClass = this.query.unions[unionIndex].properties.find((p) => p.className === className);
194
+ // Model properties should be kept separate to ensure proper JOIN generation
195
+ const foundPropertyClass = this.query.unions[unionIndex].properties.find((p) => {
196
+ // Don't merge Model properties with regular properties
197
+ if (!!modeledElementClass !== !!p.modeledElementClass)
198
+ return false;
199
+ return p.className === className;
200
+ });
193
201
  if (foundPropertyClass) {
194
202
  const foundJoin = foundPropertyClass?.classProperties.find((join) => join.name === propertyName);
195
203
  if (foundJoin) {
@@ -225,8 +233,8 @@ class QueryBuilder {
225
233
  continue;
226
234
  }
227
235
  else if (property.modeledElementClass) {
228
- querySegments.set(property.modeledElementClass, [`${property.modeledElementClass}.ECInstanceId = BisCore.Element.Model.id`]);
229
- whereSegments.push(`${property.modeledElementClass}.UserLabel = '${property.classProperties[0].value.toString()}' OR ${property.modeledElementClass}.CodeValue = '${property.classProperties[0].value.toString()}'`);
236
+ querySegments.set(property.modeledElementClass, [`${property.modeledElementClass}.ECInstanceId = ${baseClassName}.Model.id`]);
237
+ whereSegments.push(`(${property.modeledElementClass}.UserLabel = '${property.classProperties[0].value.toString()}' OR ${property.modeledElementClass}.CodeValue = '${property.classProperties[0].value.toString()}')`);
230
238
  continue;
231
239
  }
232
240
  const joinIdName = property.isAspect ? `${property.className}.Element.id` : `${property.className}.ECInstanceId`;
@@ -243,7 +251,8 @@ class QueryBuilder {
243
251
  const whereClause = `WHERE ${whereSegments.join(" AND ")}`;
244
252
  unionSegments.push([selectClause, ...joinClauses, whereClause].join(" "));
245
253
  }
246
- return unionSegments.join(" UNION ");
254
+ const result = unionSegments.join(" UNION ");
255
+ return result;
247
256
  }
248
257
  selectClause(baseProperty, baseClass) {
249
258
  if (baseClass) {
@@ -1 +1 @@
1
- {"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../../src/components/Groups/QueryBuilder/QueryBuilder.ts"],"names":[],"mappings":";;;AAOA,0DAA4D;AAC5D,wDAA+C;AAE/C,oDAAiD;AA0CjD,4FAA4F;AAC5F,MAAa,YAAY;IAMvB,YACmB,YAA8C,EAC9C,gBAAkC;QADlC,iBAAY,GAAZ,YAAY,CAAkC;QAC9C,qBAAgB,GAAhB,gBAAgB,CAAkB;QAwB7C,iBAAY,GAA+B,IAAI,GAAG,EAAE,CAAC;QAEtD,sBAAiB,GAAG,GAAG,EAAE;YAC9B,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;QAChC,CAAC,CAAC;QAEM,oBAAe,GAAG,KAAK,IAAI,EAAE;YACnC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;YAEvB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,EAAE;gBACjD,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC;aAC7E;QACH,CAAC,CAAC;QA2QM,2BAAsB,GAAG,CAAC,OAAqB,EAAE,aAAoC,EAAyB,EAAE;YACtH,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE;gBAChC,KAAK,MAAM,SAAS,IAAI,UAAU,CAAC,UAAU,EAAE;oBAC7C,MAAM,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AC,IAAI,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;IAEO,YAAY,CAAC,YAAuC,EAAE,SAAiC;QAC7F,IAAI,SAAS,EAAE;YACb,OAAO,UAAU,SAAS,CAAC,SAAS,kBAAkB,SAAS,CAAC,SAAS,mBAAmB,SAAS,CAAC,SAAS,EAAE,CAAC;SACnH;QAED,IAAI,YAAY,EAAE;YAChB,MAAM,UAAU,GAAG,YAAY,CAAC,QAAQ;gBACtC,CAAC,CAAC,GAAG,YAAY,CAAC,SAAS,0BAA0B;gBACrD,CAAC,CAAC,GAAG,YAAY,CAAC,SAAS,kBAAkB,YAAY,CAAC,SAAS,YAAY,CAAC;YAElF,OAAO,UAAU,UAAU,SAAS,YAAY,CAAC,SAAS,EAAE,CAAC;SAC9D;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;IA4BO,kBAAkB,CAAC,SAAiB;QAC1C,OAAO,mCAAmC,SAAS,wCAAwC,SAAS,KAAK,CAAC;IAC5G,CAAC;IAEO,OAAO,CAAC,CAAU;QACxB,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;;AAvVH,oCAwVC;AAvVyB,uCAA0B,GAAG,iCAAiC,CAAC;AAC/D,wCAA2B,GAAG,iCAAiC,CAAC;AAChE,qCAAwB,GAAG,CAAC,CAAC","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 type { PresentationPropertyDataProvider } from \"@itwin/presentation-components\";\nimport type { InstanceKey, NavigationPropertyValue, PropertiesField } from \"@itwin/presentation-common\";\nimport type { Primitives, PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { toaster } from \"@itwin/itwinui-react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { QueryBinder } from \"@itwin/core-common\";\n\nexport interface Query {\n unions: QueryUnion[];\n}\n\nexport interface QueryUnion {\n classes: QueryClass[];\n properties: QueryProperty[];\n}\n\nexport interface QueryClass {\n // schemaName.className\n className: string;\n classJoins: ClassJoin[];\n}\n\nexport interface ClassJoin {\n classProperty: string;\n joinClassName: string;\n joinClassProperty: string;\n}\n\nexport interface QueryProperty {\n className: string;\n classProperties: ClassProperty[];\n isCategory: boolean;\n modeledElementClass?: string;\n isAspect: boolean;\n}\n\nexport interface ClassProperty {\n name: string;\n value: Primitives.Value;\n needsQuote: boolean;\n}\n\nexport interface AddedProperty {\n propertyRecord: PropertyRecord;\n propertiesField: PropertiesField;\n}\n\n/* This class is to build adaptive and dynamic query for find similar property selections */\nexport class QueryBuilder {\n private static readonly MULTI_ASPECT_PRIMARY_CLASS = \"BisCore:ElementOwnsMultiAspects\";\n private static readonly UNIQUE_ASPECT_PRIMARY_CLASS = \"BisCore:ElementOwnsUniqueAspect\";\n private static readonly DEFAULT_DOUBLE_PRECISION = 4;\n private query: Query | undefined;\n\n constructor(\n private readonly dataProvider: PresentationPropertyDataProvider,\n private readonly iModelConnection: IModelConnection,\n ) {}\n\n private isCategory(propertyField: PropertiesField): boolean {\n const classInfo = propertyField.properties[0].property.navigationPropertyInfo?.classInfo;\n return classInfo?.name === \"BisCore:GeometricElement3dIsInCategory\";\n }\n\n private async getPotentialModeledElement(propertyField: PropertiesField, propertyRecord: PropertyRecord): Promise<string | undefined> {\n const classInfo = propertyField.properties[0].property.navigationPropertyInfo?.classInfo;\n if (propertyRecord.value?.valueFormat !== PropertyValueFormat.Primitive) return;\n const navigationPropertyValue = propertyRecord.value.value as NavigationPropertyValue;\n if (classInfo?.name === \"BisCore:ModelContainsElements\") {\n // https://www.itwinjs.org/bis/guide/fundamentals/model-fundamentals/#model-identity\n // Lookup the modeled element as they share the same ECInstanceId\n const modeledElementQuery = `SELECT ec_classname(ecclassid) FROM biscore.element WHERE ecinstanceid = ? LIMIT 1`;\n const queryBinder = new QueryBinder();\n queryBinder.bindString(1, navigationPropertyValue.id);\n const modeledElement = (await this.iModelConnection.createQueryReader(modeledElementQuery, queryBinder).next()).value[0];\n return modeledElement.replace(\":\", \".\");\n }\n return;\n }\n\n private _propertyMap: Map<string, AddedProperty> = new Map();\n\n public resetQueryBuilder = () => {\n this._propertyMap = new Map();\n };\n\n private regenerateQuery = async () => {\n this.query = undefined;\n\n for (const property of this._propertyMap.values()) {\n await this.buildProperty(property.propertyRecord, property.propertiesField);\n }\n };\n\n public async addProperty(prop: PropertyRecord): Promise<boolean> {\n // TODO: only handle primitive properties now\n if (prop.value?.valueFormat !== PropertyValueFormat.Primitive) {\n toaster.warning(\"Only primitive types are supported for now.\");\n return false;\n }\n if (prop.value.value === undefined) {\n return false;\n }\n\n const propertyField = (await this.dataProvider.getFieldByPropertyRecord(prop)) as PropertiesField;\n\n if (!propertyField) {\n toaster.negative(\"Error. Failed to fetch field for this property record.\");\n return false;\n }\n\n this._propertyMap.set(JSON.stringify(propertyField.getFieldDescriptor()), { propertyRecord: prop, propertiesField: propertyField });\n return true;\n }\n\n public async removeProperty(prop: PropertyRecord) {\n const propertyField = (await this.dataProvider.getFieldByPropertyRecord(prop)) as PropertiesField;\n\n this._propertyMap.delete(JSON.stringify(propertyField.getFieldDescriptor()));\n }\n\n private async buildProperty(prop: PropertyRecord, propertiesField: PropertiesField) {\n if (prop.value?.valueFormat !== PropertyValueFormat.Primitive || prop.value.value === undefined) {\n toaster.negative(\"Error. An unexpected error has occured while building a query.\");\n return;\n }\n\n function replaceAll(str: string, match: string, replacement: string) {\n return str.split(match).join(replacement);\n }\n // if property value has single quote, escape\n if ((typeof prop.value.value === \"string\" || prop.value.value instanceof String) && String(prop.value.value).indexOf(\"'\") >= 0) {\n prop.value.value = replaceAll(prop.value.value.toString(), \"'\", \"''\");\n }\n\n const pathToPrimaryClass = propertiesField.parent?.pathToPrimaryClass;\n\n // get the special cases\n const isNavigation: boolean = prop.property.typename.toLowerCase() === \"navigation\";\n const isCategory: boolean = isNavigation && this.isCategory(propertiesField);\n const modeledElement = await this.getPotentialModeledElement(propertiesField, prop);\n\n const isAspect: boolean =\n pathToPrimaryClass?.find(\n (a) => a.relationshipInfo?.name === QueryBuilder.UNIQUE_ASPECT_PRIMARY_CLASS || a.relationshipInfo?.name === QueryBuilder.MULTI_ASPECT_PRIMARY_CLASS,\n ) !== undefined;\n\n for (let i = 0; i < propertiesField.properties.length; i++) {\n const property = propertiesField.properties[i].property;\n\n const className = property.classInfo.name.replace(\":\", \".\");\n const propertyName = isNavigation ? (isCategory || modeledElement ? `${property.name}.CodeValue` : `${property.name}.id`) : property.name;\n const propertyValue = isNavigation\n ? isCategory || modeledElement\n ? prop.value.displayValue ?? \"\"\n : (prop.value.value as InstanceKey).id\n : prop.value.value;\n\n if (!isAspect && pathToPrimaryClass && pathToPrimaryClass.length > 0) {\n this.addRelatedToQuery(i, propertiesField, propertyName, propertyValue);\n } else {\n this.addPropertyToQuery(i, className, propertyName, propertyValue, this.needsQuote(propertiesField), isCategory, modeledElement, isAspect);\n }\n }\n return true;\n }\n\n private needsQuote(propertyField: PropertiesField): boolean {\n // list of property types that need quote around property value\n const typeName = propertyField.type.typeName.toLowerCase();\n return \"string\" === typeName || \"uri\" === typeName;\n }\n\n private addRelatedToQuery(unionIndex: number, propertyField: PropertiesField, propertyName: string, propertyValue: Primitives.Value) {\n const paths = [...(propertyField.parent?.pathToPrimaryClass ?? [])];\n paths.reverse().forEach((path) => {\n const sourceClassName = path.sourceClassInfo?.name.replace(\":\", \".\");\n const targetClassName = path.targetClassInfo?.name.replace(\":\", \".\");\n const relClassName = path.relationshipInfo?.name.replace(\":\", \".\");\n\n const relClassProperty = path.isForwardRelationship ? `SourceECInstanceId` : `TargetECInstanceId`;\n\n const relPropertyValue = path.isForwardRelationship ? `TargetECInstanceId` : `SourceECInstanceId`;\n\n this.addClassToQuery(unionIndex, targetClassName, `ECInstanceId`, relClassName, relPropertyValue);\n\n this.addClassToQuery(unionIndex, relClassName, relClassProperty, sourceClassName, `ECInstanceId`);\n\n if (path.sourceClassInfo?.name === propertyField.parent?.contentClassInfo.name) {\n this.addPropertyToQuery(unionIndex, sourceClassName, propertyName, propertyValue, this.needsQuote(propertyField), false, \"\", false);\n }\n });\n }\n\n private addClassToQuery(unionIndex: number, className: string, classProperty: string, joinClassName: string, joinClassProperty: string) {\n if (this.query === undefined) {\n this.query = { unions: [] };\n }\n\n const classJoin: ClassJoin = {\n classProperty,\n joinClassName,\n joinClassProperty,\n };\n\n const queryClass: QueryClass = {\n className,\n classJoins: [classJoin],\n };\n\n if (this.query.unions.length <= unionIndex) {\n this.query.unions.push({\n classes: [queryClass],\n properties: [],\n });\n return;\n }\n\n const foundClass = this.query.unions[unionIndex].classes.find((c) => c.className === className);\n\n if (foundClass) {\n const foundJoin = foundClass.classJoins.find(\n (join) => join.classProperty === classProperty && join.joinClassName === joinClassName && join.joinClassProperty === joinClassProperty,\n );\n\n if (!foundJoin) foundClass.classJoins.push(classJoin);\n return;\n }\n\n this.query.unions[unionIndex].classes.push(queryClass);\n }\n\n private addPropertyToQuery(\n unionIndex: number,\n className: string,\n propertyName: string,\n propertyValue: Primitives.Value,\n needsQuote: boolean,\n isCategory: boolean,\n modeledElementClass: string | undefined,\n isAspect: boolean,\n ) {\n if (this.query === undefined) {\n this.query = { unions: [] };\n }\n\n const queryJoin: ClassProperty = {\n name: propertyName,\n value: propertyValue,\n needsQuote,\n };\n\n const queryProperty: QueryProperty = {\n className,\n isCategory,\n modeledElementClass,\n isAspect,\n classProperties: [queryJoin],\n };\n\n if (this.query.unions.length <= unionIndex) {\n this.query.unions.push({\n classes: [],\n properties: [queryProperty],\n });\n return;\n }\n\n const foundPropertyClass = this.query.unions[unionIndex].properties.find((p) => p.className === className);\n\n if (foundPropertyClass) {\n const foundJoin = foundPropertyClass?.classProperties.find((join) => join.name === propertyName);\n\n if (foundJoin) {\n foundJoin.value = propertyValue;\n return;\n }\n\n foundPropertyClass.classProperties.push(queryJoin);\n return;\n }\n\n this.query.unions[unionIndex].properties.push(queryProperty);\n }\n\n public async buildQueryString() {\n await this.regenerateQuery();\n if (this.query === undefined || this.query.unions.find((u) => u.classes.length === 0 && u.properties.length === 0)) {\n return \"\";\n }\n\n const unionSegments: string[] = [];\n for (const union of this.query.unions) {\n const baseClass = union.classes[0];\n const baseProperty = union.properties[0];\n const baseClassName = baseClass ? baseClass.className : baseProperty?.className;\n const baseIdName = `${baseClassName}.ECInstanceId`;\n\n const selectClause = this.selectClause(baseProperty, baseClass);\n\n let querySegments: Map<string, string[]> = new Map();\n querySegments = this.relationalJoinSegments(union.classes, querySegments);\n\n const whereSegments: string[] = [];\n for (const property of union.properties) {\n if (property.isCategory) {\n if (property.className !== baseClassName)\n querySegments.set(\"BisCore.GeometricElement3d\", [`BisCore.GeometricElement3d.ECInstanceId = ${baseIdName}`]);\n\n querySegments.set(\"BisCore.Category\", [`BisCore.Category.ECInstanceId = BisCore.GeometricElement3d.category.id`]);\n whereSegments.push(this.categoryWhereQuery(property.classProperties[0].value.toString()));\n continue;\n } else if (property.modeledElementClass) {\n querySegments.set(property.modeledElementClass, [`${property.modeledElementClass}.ECInstanceId = BisCore.Element.Model.id`]);\n whereSegments.push(\n `${property.modeledElementClass}.UserLabel = '${property.classProperties[0].value.toString()}' OR ${property.modeledElementClass}.CodeValue = '${property.classProperties[0].value.toString()}'`,\n );\n continue;\n }\n\n const joinIdName = property.isAspect ? `${property.className}.Element.id` : `${property.className}.ECInstanceId`;\n\n if (!querySegments.has(property.className) && property.className !== baseClassName)\n querySegments.set(property.className, [`${joinIdName} = ${baseIdName}`]);\n\n for (const prop of property.classProperties) {\n whereSegments.push(this.propertyQuerySegment(property.className, prop, prop.needsQuote));\n }\n }\n\n const joinClauses: string[] = [];\n for (const key of querySegments.keys()) {\n joinClauses.push(`JOIN ${key} ON ${querySegments.get(key)?.join(\" AND \")}`);\n }\n\n const whereClause = `WHERE ${whereSegments.join(\" AND \")}`;\n\n unionSegments.push([selectClause, ...joinClauses, whereClause].join(\" \"));\n }\n\n return unionSegments.join(\" UNION \");\n }\n\n private selectClause(baseProperty: QueryProperty | undefined, baseClass: QueryClass | undefined) {\n if (baseClass) {\n return `SELECT ${baseClass.className}.ECInstanceId, ${baseClass.className}.ECClassId FROM ${baseClass.className}`;\n }\n\n if (baseProperty) {\n const baseIdName = baseProperty.isAspect\n ? `${baseProperty.className}.Element.id ECInstanceId`\n : `${baseProperty.className}.ECInstanceId, ${baseProperty.className}.ECClassId`;\n\n return `SELECT ${baseIdName} FROM ${baseProperty.className}`;\n }\n\n return \"\";\n }\n\n private relationalJoinSegments = (classes: QueryClass[], querySegments: Map<string, string[]>): Map<string, string[]> => {\n for (const queryClass of classes) {\n for (const classJoin of queryClass.classJoins) {\n const querySegment = [\n ...(querySegments.get(classJoin.joinClassName) ?? []),\n `${queryClass.className}.${classJoin.classProperty} = ${classJoin.joinClassName}.${classJoin.joinClassProperty}`,\n ];\n querySegments.set(classJoin.joinClassName, querySegment);\n }\n }\n\n return querySegments;\n };\n\n private propertyQuerySegment = (className: string, property: ClassProperty, needsQuote: boolean): string => {\n if (this.isFloat(property.value))\n return (\n `ROUND(${className}.${property.name}, ` +\n `${QueryBuilder.DEFAULT_DOUBLE_PRECISION}) = ` +\n `${Number(property.value).toFixed(QueryBuilder.DEFAULT_DOUBLE_PRECISION)}`\n );\n\n const propertyValue = needsQuote ? `'${property.value}'` : property.value;\n return `${className}.${property.name} = ${propertyValue}`;\n };\n\n private categoryWhereQuery(codeValue: string): string {\n return `((BisCore.Category.CodeValue = '${codeValue}') OR (BisCore.Category.UserLabel = '${codeValue}'))`;\n }\n\n private isFloat(n: unknown): boolean {\n return Number(n) === n && n % 1 !== 0;\n }\n}\n"]}
1
+ {"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../../src/components/Groups/QueryBuilder/QueryBuilder.ts"],"names":[],"mappings":";;;AAOA,0DAA4D;AAC5D,wDAA+C;AAE/C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,CAAC;SACnH;QAED,IAAI,YAAY,EAAE;YAChB,MAAM,UAAU,GAAG,YAAY,CAAC,QAAQ;gBACtC,CAAC,CAAC,GAAG,YAAY,CAAC,SAAS,0BAA0B;gBACrD,CAAC,CAAC,GAAG,YAAY,CAAC,SAAS,kBAAkB,YAAY,CAAC,SAAS,YAAY,CAAC;YAElF,OAAO,UAAU,UAAU,SAAS,YAAY,CAAC,SAAS,EAAE,CAAC;SAC9D;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;IA4BO,kBAAkB,CAAC,SAAiB;QAC1C,OAAO,mCAAmC,SAAS,wCAAwC,SAAS,KAAK,CAAC;IAC5G,CAAC;IAEO,OAAO,CAAC,CAAU;QACxB,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;;AA9VH,oCA+VC;AA9VyB,uCAA0B,GAAG,iCAAiC,CAAC;AAC/D,wCAA2B,GAAG,iCAAiC,CAAC;AAChE,qCAAwB,GAAG,CAAC,CAAC","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 type { PresentationPropertyDataProvider } from \"@itwin/presentation-components\";\nimport type { InstanceKey, NavigationPropertyValue, PropertiesField } from \"@itwin/presentation-common\";\nimport type { Primitives, PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { toaster } from \"@itwin/itwinui-react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { QueryBinder } from \"@itwin/core-common\";\n\nexport interface Query {\n unions: QueryUnion[];\n}\n\nexport interface QueryUnion {\n classes: QueryClass[];\n properties: QueryProperty[];\n}\n\nexport interface QueryClass {\n // schemaName.className\n className: string;\n classJoins: ClassJoin[];\n}\n\nexport interface ClassJoin {\n classProperty: string;\n joinClassName: string;\n joinClassProperty: string;\n}\n\nexport interface QueryProperty {\n className: string;\n classProperties: ClassProperty[];\n isCategory: boolean;\n modeledElementClass?: string;\n isAspect: boolean;\n}\n\nexport interface ClassProperty {\n name: string;\n value: Primitives.Value;\n needsQuote: boolean;\n}\n\nexport interface AddedProperty {\n propertyRecord: PropertyRecord;\n propertiesField: PropertiesField;\n}\n\n/* This class is to build adaptive and dynamic query for find similar property selections */\nexport class QueryBuilder {\n private static readonly MULTI_ASPECT_PRIMARY_CLASS = \"BisCore:ElementOwnsMultiAspects\";\n private static readonly UNIQUE_ASPECT_PRIMARY_CLASS = \"BisCore:ElementOwnsUniqueAspect\";\n private static readonly DEFAULT_DOUBLE_PRECISION = 4;\n private query: Query | undefined;\n\n constructor(\n private readonly dataProvider: PresentationPropertyDataProvider,\n private readonly iModelConnection: IModelConnection,\n ) {}\n\n private isCategory(propertyField: PropertiesField): boolean {\n const classInfo = propertyField.properties[0].property.navigationPropertyInfo?.classInfo;\n return classInfo?.name === \"BisCore:GeometricElement3dIsInCategory\";\n }\n\n private async getPotentialModeledElement(propertyField: PropertiesField, propertyRecord: PropertyRecord): Promise<string | undefined> {\n const classInfo = propertyField.properties[0].property.navigationPropertyInfo?.classInfo;\n if (propertyRecord.value?.valueFormat !== PropertyValueFormat.Primitive) return;\n const navigationPropertyValue = propertyRecord.value.value as NavigationPropertyValue;\n if (classInfo?.name === \"BisCore:ModelContainsElements\") {\n // https://www.itwinjs.org/bis/guide/fundamentals/model-fundamentals/#model-identity\n // Lookup the modeled element as they share the same ECInstanceId\n const modeledElementQuery = `SELECT ec_classname(ecclassid) FROM biscore.element WHERE ecinstanceid = ? LIMIT 1`;\n const queryBinder = new QueryBinder();\n queryBinder.bindString(1, navigationPropertyValue.id);\n const modeledElement = (await this.iModelConnection.createQueryReader(modeledElementQuery, queryBinder).next()).value[0];\n return modeledElement.replace(\":\", \".\");\n }\n return;\n }\n\n private _propertyMap: Map<string, AddedProperty> = new Map();\n\n public resetQueryBuilder = () => {\n this._propertyMap = new Map();\n };\n\n private regenerateQuery = async () => {\n this.query = undefined;\n\n for (const property of this._propertyMap.values()) {\n await this.buildProperty(property.propertyRecord, property.propertiesField);\n }\n };\n\n public async addProperty(prop: PropertyRecord): Promise<boolean> {\n // TODO: only handle primitive properties now\n if (prop.value?.valueFormat !== PropertyValueFormat.Primitive) {\n toaster.warning(\"Only primitive types are supported for now.\");\n return false;\n }\n if (prop.value.value === undefined) {\n return false;\n }\n\n const propertyField = (await this.dataProvider.getFieldByPropertyRecord(prop)) as PropertiesField;\n\n if (!propertyField) {\n toaster.negative(\"Error. Failed to fetch field for this property record.\");\n return false;\n }\n\n this._propertyMap.set(JSON.stringify(propertyField.getFieldDescriptor()), { propertyRecord: prop, propertiesField: propertyField });\n return true;\n }\n\n public async removeProperty(prop: PropertyRecord) {\n const propertyField = (await this.dataProvider.getFieldByPropertyRecord(prop)) as PropertiesField;\n\n this._propertyMap.delete(JSON.stringify(propertyField.getFieldDescriptor()));\n }\n\n private async buildProperty(prop: PropertyRecord, propertiesField: PropertiesField) {\n if (prop.value?.valueFormat !== PropertyValueFormat.Primitive || prop.value.value === undefined) {\n toaster.negative(\"Error. An unexpected error has occured while building a query.\");\n return;\n }\n\n function replaceAll(str: string, match: string, replacement: string) {\n return str.split(match).join(replacement);\n }\n // if property value has single quote, escape\n if ((typeof prop.value.value === \"string\" || prop.value.value instanceof String) && String(prop.value.value).indexOf(\"'\") >= 0) {\n prop.value.value = replaceAll(prop.value.value.toString(), \"'\", \"''\");\n }\n\n const pathToPrimaryClass = propertiesField.parent?.pathToPrimaryClass;\n\n // get the special cases\n const isNavigation: boolean = prop.property.typename.toLowerCase() === \"navigation\";\n const isCategory: boolean = isNavigation && this.isCategory(propertiesField);\n const modeledElement = await this.getPotentialModeledElement(propertiesField, prop);\n\n const isAspect: boolean =\n pathToPrimaryClass?.find(\n (a) => a.relationshipInfo?.name === QueryBuilder.UNIQUE_ASPECT_PRIMARY_CLASS || a.relationshipInfo?.name === QueryBuilder.MULTI_ASPECT_PRIMARY_CLASS,\n ) !== undefined;\n\n for (let i = 0; i < propertiesField.properties.length; i++) {\n const property = propertiesField.properties[i].property;\n\n const className = property.classInfo.name.replace(\":\", \".\");\n const propertyName = isNavigation ? (isCategory || modeledElement ? `${property.name}.CodeValue` : `${property.name}.id`) : property.name;\n const propertyValue = isNavigation\n ? isCategory || modeledElement\n ? prop.value.displayValue ?? \"\"\n : (prop.value.value as InstanceKey).id\n : prop.value.value;\n\n if (!isAspect && pathToPrimaryClass && pathToPrimaryClass.length > 0) {\n this.addRelatedToQuery(i, propertiesField, propertyName, propertyValue);\n } else {\n // Model properties with display values always need quotes\n const needsQuote = !!modeledElement || this.needsQuote(propertiesField);\n this.addPropertyToQuery(i, className, propertyName, propertyValue, needsQuote, isCategory, modeledElement, isAspect);\n }\n }\n return true;\n }\n\n private needsQuote(propertyField: PropertiesField): boolean {\n // list of property types that need quote around property value\n const typeName = propertyField.type.typeName.toLowerCase();\n return \"string\" === typeName || \"uri\" === typeName;\n }\n\n private addRelatedToQuery(unionIndex: number, propertyField: PropertiesField, propertyName: string, propertyValue: Primitives.Value) {\n const paths = [...(propertyField.parent?.pathToPrimaryClass ?? [])];\n paths.reverse().forEach((path) => {\n const sourceClassName = path.sourceClassInfo?.name.replace(\":\", \".\");\n const targetClassName = path.targetClassInfo?.name.replace(\":\", \".\");\n const relClassName = path.relationshipInfo?.name.replace(\":\", \".\");\n\n const relClassProperty = path.isForwardRelationship ? `SourceECInstanceId` : `TargetECInstanceId`;\n\n const relPropertyValue = path.isForwardRelationship ? `TargetECInstanceId` : `SourceECInstanceId`;\n\n this.addClassToQuery(unionIndex, targetClassName, `ECInstanceId`, relClassName, relPropertyValue);\n\n this.addClassToQuery(unionIndex, relClassName, relClassProperty, sourceClassName, `ECInstanceId`);\n\n if (path.sourceClassInfo?.name === propertyField.parent?.contentClassInfo.name) {\n this.addPropertyToQuery(unionIndex, sourceClassName, propertyName, propertyValue, this.needsQuote(propertyField), false, \"\", false);\n }\n });\n }\n\n private addClassToQuery(unionIndex: number, className: string, classProperty: string, joinClassName: string, joinClassProperty: string) {\n if (this.query === undefined) {\n this.query = { unions: [] };\n }\n\n const classJoin: ClassJoin = {\n classProperty,\n joinClassName,\n joinClassProperty,\n };\n\n const queryClass: QueryClass = {\n className,\n classJoins: [classJoin],\n };\n\n if (this.query.unions.length <= unionIndex) {\n this.query.unions.push({\n classes: [queryClass],\n properties: [],\n });\n return;\n }\n\n const foundClass = this.query.unions[unionIndex].classes.find((c) => c.className === className);\n\n if (foundClass) {\n const foundJoin = foundClass.classJoins.find(\n (join) => join.classProperty === classProperty && join.joinClassName === joinClassName && join.joinClassProperty === joinClassProperty,\n );\n\n if (!foundJoin) foundClass.classJoins.push(classJoin);\n return;\n }\n\n this.query.unions[unionIndex].classes.push(queryClass);\n }\n\n private addPropertyToQuery(\n unionIndex: number,\n className: string,\n propertyName: string,\n propertyValue: Primitives.Value,\n needsQuote: boolean,\n isCategory: boolean,\n modeledElementClass: string | undefined,\n isAspect: boolean,\n ) {\n if (this.query === undefined) {\n this.query = { unions: [] };\n }\n\n const queryJoin: ClassProperty = {\n name: propertyName,\n value: propertyValue,\n needsQuote,\n };\n\n const queryProperty: QueryProperty = {\n className,\n isCategory,\n modeledElementClass,\n isAspect,\n classProperties: [queryJoin],\n };\n\n if (this.query.unions.length <= unionIndex) {\n this.query.unions.push({\n classes: [],\n properties: [queryProperty],\n });\n return;\n }\n\n // Model properties should be kept separate to ensure proper JOIN generation\n const foundPropertyClass = this.query.unions[unionIndex].properties.find((p) => {\n // Don't merge Model properties with regular properties\n if (!!modeledElementClass !== !!p.modeledElementClass) return false;\n return p.className === className;\n });\n\n if (foundPropertyClass) {\n const foundJoin = foundPropertyClass?.classProperties.find((join) => join.name === propertyName);\n\n if (foundJoin) {\n foundJoin.value = propertyValue;\n return;\n }\n\n foundPropertyClass.classProperties.push(queryJoin);\n return;\n }\n\n this.query.unions[unionIndex].properties.push(queryProperty);\n }\n\n public async buildQueryString() {\n await this.regenerateQuery();\n if (this.query === undefined || this.query.unions.find((u) => u.classes.length === 0 && u.properties.length === 0)) {\n return \"\";\n }\n\n const unionSegments: string[] = [];\n for (const union of this.query.unions) {\n const baseClass = union.classes[0];\n const baseProperty = union.properties[0];\n const baseClassName = baseClass ? baseClass.className : baseProperty?.className;\n const baseIdName = `${baseClassName}.ECInstanceId`;\n\n const selectClause = this.selectClause(baseProperty, baseClass);\n\n let querySegments: Map<string, string[]> = new Map();\n querySegments = this.relationalJoinSegments(union.classes, querySegments);\n\n const whereSegments: string[] = [];\n for (const property of union.properties) {\n if (property.isCategory) {\n if (property.className !== baseClassName)\n querySegments.set(\"BisCore.GeometricElement3d\", [`BisCore.GeometricElement3d.ECInstanceId = ${baseIdName}`]);\n\n querySegments.set(\"BisCore.Category\", [`BisCore.Category.ECInstanceId = BisCore.GeometricElement3d.category.id`]);\n whereSegments.push(this.categoryWhereQuery(property.classProperties[0].value.toString()));\n continue;\n } else if (property.modeledElementClass) {\n querySegments.set(property.modeledElementClass, [`${property.modeledElementClass}.ECInstanceId = ${baseClassName}.Model.id`]);\n whereSegments.push(\n `(${property.modeledElementClass}.UserLabel = '${property.classProperties[0].value.toString()}' OR ${property.modeledElementClass}.CodeValue = '${property.classProperties[0].value.toString()}')`,\n );\n continue;\n }\n\n const joinIdName = property.isAspect ? `${property.className}.Element.id` : `${property.className}.ECInstanceId`;\n\n if (!querySegments.has(property.className) && property.className !== baseClassName)\n querySegments.set(property.className, [`${joinIdName} = ${baseIdName}`]);\n\n for (const prop of property.classProperties) {\n whereSegments.push(this.propertyQuerySegment(property.className, prop, prop.needsQuote));\n }\n }\n\n const joinClauses: string[] = [];\n for (const key of querySegments.keys()) {\n joinClauses.push(`JOIN ${key} ON ${querySegments.get(key)?.join(\" AND \")}`);\n }\n\n const whereClause = `WHERE ${whereSegments.join(\" AND \")}`;\n\n unionSegments.push([selectClause, ...joinClauses, whereClause].join(\" \"));\n }\n const result = unionSegments.join(\" UNION \");\n return result;\n }\n\n private selectClause(baseProperty: QueryProperty | undefined, baseClass: QueryClass | undefined) {\n if (baseClass) {\n return `SELECT ${baseClass.className}.ECInstanceId, ${baseClass.className}.ECClassId FROM ${baseClass.className}`;\n }\n\n if (baseProperty) {\n const baseIdName = baseProperty.isAspect\n ? `${baseProperty.className}.Element.id ECInstanceId`\n : `${baseProperty.className}.ECInstanceId, ${baseProperty.className}.ECClassId`;\n\n return `SELECT ${baseIdName} FROM ${baseProperty.className}`;\n }\n\n return \"\";\n }\n\n private relationalJoinSegments = (classes: QueryClass[], querySegments: Map<string, string[]>): Map<string, string[]> => {\n for (const queryClass of classes) {\n for (const classJoin of queryClass.classJoins) {\n const querySegment = [\n ...(querySegments.get(classJoin.joinClassName) ?? []),\n `${queryClass.className}.${classJoin.classProperty} = ${classJoin.joinClassName}.${classJoin.joinClassProperty}`,\n ];\n querySegments.set(classJoin.joinClassName, querySegment);\n }\n }\n\n return querySegments;\n };\n\n private propertyQuerySegment = (className: string, property: ClassProperty, needsQuote: boolean): string => {\n if (this.isFloat(property.value))\n return (\n `ROUND(${className}.${property.name}, ` +\n `${QueryBuilder.DEFAULT_DOUBLE_PRECISION}) = ` +\n `${Number(property.value).toFixed(QueryBuilder.DEFAULT_DOUBLE_PRECISION)}`\n );\n\n const propertyValue = needsQuote ? `'${property.value}'` : property.value;\n return `${className}.${property.name} = ${propertyValue}`;\n };\n\n private categoryWhereQuery(codeValue: string): string {\n return `((BisCore.Category.CodeValue = '${codeValue}') OR (BisCore.Category.UserLabel = '${codeValue}'))`;\n }\n\n private isFloat(n: unknown): boolean {\n return Number(n) === n && n % 1 !== 0;\n }\n}\n"]}
@@ -103,8 +103,12 @@ const convertPresentationFields = (propertyFields) => {
103
103
  propertyFields.forEach((property) => {
104
104
  switch (property.type.valueFormat) {
105
105
  case presentation_common_1.PropertyValueFormat.Primitive: {
106
+ const propertiesField = property;
107
+ if (!propertiesField.properties) {
108
+ return;
109
+ }
106
110
  // Generate base ECProperty
107
- const extractedPrimitives = extractPrimitives([], property);
111
+ const extractedPrimitives = extractPrimitives([], propertiesField);
108
112
  extractedPrimitives.forEach((extractedPrimitive) => {
109
113
  extractedPrimitive.sourceSchema = "*";
110
114
  extractedPrimitive.sourceClassName = "*";
@@ -1 +1 @@
1
- {"version":3,"file":"GroupPropertyUtils.js","sourceRoot":"","sources":["../../../../../src/components/Properties/GroupProperties/GroupPropertyUtils.ts"],"names":[],"mappings":";;;AAgBA,oEAAwJ;AACxJ,wEAA4D;AAC5D,6CAAwC;AAcxC,MAAM,WAAW,GAAG,CAAC,uBAA2C,EAAE,iBAAyB,EAAE,iBAA2B,EAAU,EAAE;IAClI,OAAO,GAAG,uBAAuB,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAC1F,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,iBAA2B,EAAE,aAA8B,EAAsB,EAAE,CAC5G,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;IACxC,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC5C,MAAM,YAAY,GAAG,aAAa,CAAC,KAAK,CAAC;IACzC,kCAAkC;IAClC,MAAM,uBAAuB,GAAG,aAAa,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAC5E,MAAM,wBAAwB,GAAG,QAAQ,CAAC,QAAQ,CAAC,sBAAsB,EAAE,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC;IAChG,MAAM,iBAAiB,GAAG,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC;IAC3D,MAAM,oBAAoB,GAAG,CAAC,GAAG,iBAAiB,EAAE,YAAY,CAAC,CAAC;IAElE,OAAO;QACL,YAAY;QACZ,YAAY,EAAE,GAAG;QACjB,eAAe,EAAE,GAAG;QACpB,mBAAmB,EAAE,oBAAoB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["/*---------------------------------------------------------------------------------------------\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 type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { ECPropertyReference } from \"@itwin/insights-client\";\nimport type {\n ContentDescriptorRequestOptions,\n Field,\n KeySet,\n NestedContentField,\n PropertiesField,\n Ruleset,\n RulesetVariable,\n StructFieldMemberDescription,\n} from \"@itwin/presentation-common\";\nimport { ContentSpecificationTypes, DefaultContentDisplayTypes, PropertyValueFormat, RelationshipMeaning, RuleTypes } from \"@itwin/presentation-common\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { deepEqual } from \"fast-equals\";\n\nexport interface PropertyMetaData {\n displayLabel: string;\n sourceSchema: string;\n sourceClassName: string;\n categoryLabel: string;\n actualECClassName: string;\n parentPropertyClassName: string | undefined;\n ecPropertyTraversal: string[];\n primitiveNavigationClass: string;\n key: string;\n}\n\nconst generateKey = (parentPropertyClassName: string | undefined, actualECClassName: string, propertyTraversal: string[]): string => {\n return `${parentPropertyClassName}|${actualECClassName}|${propertyTraversal.join(\"|\")}`;\n};\n\nconst extractPrimitives = (propertyTraversal: string[], propertyField: PropertiesField): PropertyMetaData[] =>\n propertyField.properties.map((property) => {\n const propertyName = property.property.name;\n const displayLabel = propertyField.label;\n // It belongs to this parent class\n const parentPropertyClassName = propertyField.parent?.contentClassInfo.name;\n const primitiveNavigationClass = property.property.navigationPropertyInfo?.classInfo.name ?? \"\";\n const actualECClassName = property.property.classInfo.name;\n const newPropertyTraversal = [...propertyTraversal, propertyName];\n\n return {\n displayLabel,\n sourceSchema: \"*\",\n sourceClassName: \"*\",\n ecPropertyTraversal: newPropertyTraversal,\n primitiveNavigationClass,\n actualECClassName,\n parentPropertyClassName,\n key: generateKey(parentPropertyClassName, actualECClassName, newPropertyTraversal),\n categoryLabel: propertyField.category.label,\n };\n });\n\nconst extractPrimitiveStructProperties = (\n propertyTraversal: string[],\n members: StructFieldMemberDescription[],\n categoryLabel: string,\n actualECClassName: string,\n parentPropertyClassName?: string,\n): PropertyMetaData[] =>\n members.flatMap((member) => {\n if (member.type.valueFormat === PropertyValueFormat.Primitive) {\n const propertyName = member.name;\n const displayLabel = member.label;\n const newPropertyTraversal = [...propertyTraversal, propertyName];\n\n return {\n displayLabel,\n sourceSchema: \"*\",\n sourceClassName: \"*\",\n ecPropertyTraversal: newPropertyTraversal,\n primitiveNavigationClass: \"\",\n actualECClassName,\n parentPropertyClassName,\n key: generateKey(parentPropertyClassName, actualECClassName, newPropertyTraversal),\n categoryLabel,\n };\n } else if (member.type.valueFormat === PropertyValueFormat.Struct) {\n const structName = member.name;\n return extractPrimitiveStructProperties(\n [...propertyTraversal, structName],\n member.type.members,\n categoryLabel,\n actualECClassName,\n parentPropertyClassName,\n );\n }\n\n return [];\n });\n\nconst extractStruct = (property: Field) => {\n if (property.type.valueFormat !== PropertyValueFormat.Struct) {\n return [];\n }\n\n const columnName = (property as PropertiesField).properties[0].property.name;\n const actualECClassName = (property as PropertiesField).properties[0].property.classInfo.name;\n return extractPrimitiveStructProperties([columnName], property.type.members, property.category.label, actualECClassName);\n};\n\nconst extractNested = (propertyTraversal: string[], propertyFields: Field[]): PropertyMetaData[] =>\n propertyFields.flatMap((property) => {\n // Generate base ECProperty\n switch (property.type.valueFormat) {\n case PropertyValueFormat.Primitive: {\n return extractPrimitives([...propertyTraversal], property as PropertiesField);\n }\n // Get structs\n case PropertyValueFormat.Struct: {\n const nestedContentField = property as NestedContentField;\n // Only handling single path and not handling nested content fields within navigations\n if (nestedContentField.pathToPrimaryClass && nestedContentField.pathToPrimaryClass.length > 1) {\n // Hardcoded navigation to external source repository metadata.\n if (nestedContentField.contentClassInfo.name === \"BisCore:RepositoryLink\") {\n return extractNested([...propertyTraversal, \"Source\", \"Repository\"], nestedContentField.nestedFields);\n }\n break;\n }\n\n switch (nestedContentField.relationshipMeaning) {\n // Aspects are not looked at again. Extraction does not support aspects within navigations.\n // Navigation properties\n case RelationshipMeaning.RelatedInstance: {\n if (\n // Deal with a TypeDefinition\n nestedContentField.pathToPrimaryClass[0].relationshipInfo.name === \"BisCore:GeometricElement3dHasTypeDefinition\"\n ) {\n return extractNested([...propertyTraversal, \"TypeDefinition\"], nestedContentField.nestedFields);\n }\n break;\n }\n default: {\n // Some elements don't have a path to primary class or relationship meaning..\n // Most likely a simple struct property\n if (!nestedContentField.pathToPrimaryClass) {\n return extractStruct(property);\n }\n }\n }\n }\n }\n return [];\n });\n\nexport const convertPresentationFields = (propertyFields: Field[]): PropertyMetaData[] => {\n const uniquePropertiesMap = new Map<string, PropertyMetaData>();\n\n propertyFields.forEach((property) => {\n switch (property.type.valueFormat) {\n case PropertyValueFormat.Primitive: {\n // Generate base ECProperty\n const extractedPrimitives = extractPrimitives([], property as PropertiesField);\n extractedPrimitives.forEach((extractedPrimitive) => {\n extractedPrimitive.sourceSchema = \"*\";\n extractedPrimitive.sourceClassName = \"*\";\n uniquePropertiesMap.set(extractedPrimitive.key, extractedPrimitive);\n });\n break;\n }\n case PropertyValueFormat.Struct: {\n // Get structs\n const nestedContentField = property as NestedContentField;\n // Only handling single path and not handling nested content fields within navigations\n if (nestedContentField.pathToPrimaryClass && nestedContentField.pathToPrimaryClass.length > 1) {\n break;\n }\n switch (nestedContentField.relationshipMeaning) {\n case RelationshipMeaning.SameInstance: {\n // Check for aspects.\n if (\n nestedContentField.pathToPrimaryClass[0].relationshipInfo.name === \"BisCore:ElementOwnsUniqueAspect\" ||\n nestedContentField.pathToPrimaryClass[0].relationshipInfo.name === \"BisCore:ElementOwnsMultiAspects\"\n ) {\n const fullClassName = nestedContentField.contentClassInfo.name;\n const sourceSchema = fullClassName.split(\":\")[0];\n const sourceClassName = fullClassName.split(\":\")[1];\n const extractedNested = extractNested([], nestedContentField.nestedFields);\n extractedNested.forEach((ecProperty) => {\n const propertyWithSchema = { ...ecProperty, sourceSchema, sourceClassName };\n uniquePropertiesMap.set(propertyWithSchema.key, propertyWithSchema);\n });\n }\n break;\n }\n case RelationshipMeaning.RelatedInstance: {\n // Navigation properties\n if (\n // Deal with a TypeDefinition\n nestedContentField.pathToPrimaryClass[0].relationshipInfo.name === \"BisCore:GeometricElement3dHasTypeDefinition\"\n ) {\n const extractedNested = extractNested([\"TypeDefinition\"], nestedContentField.nestedFields);\n extractedNested.forEach((ecProperty) => {\n uniquePropertiesMap.set(ecProperty.key, ecProperty);\n });\n }\n break;\n }\n default: {\n // Some elements don't have a path to primary class or relationship meaning..\n // Most likely a simple struct property\n if (!nestedContentField.pathToPrimaryClass) {\n const extractedStruct = extractStruct(property);\n extractedStruct.forEach((ecProperty) => {\n uniquePropertiesMap.set(ecProperty.key, ecProperty);\n });\n }\n }\n }\n }\n }\n });\n\n return Array.from(uniquePropertiesMap.values());\n};\n\nexport const convertToECProperties = (property: PropertyMetaData): ECPropertyReference[] => {\n const ecProperty: ECPropertyReference = {\n ecSchemaName: property.sourceSchema,\n ecClassName: property.sourceClassName,\n ecPropertyName: \"\",\n };\n switch (property.primitiveNavigationClass) {\n // Hardcode Models navigation path and label behavior\n case \"BisCore:ModelContainsElements\": {\n return [\n {\n ...ecProperty,\n ecPropertyName: [...property.ecPropertyTraversal, \"ModeledElement\", \"UserLabel\"].join(\".\"),\n },\n {\n ...ecProperty,\n ecPropertyName: [...property.ecPropertyTraversal, \"ModeledElement\", \"CodeValue\"].join(\".\"),\n },\n ];\n }\n // Hardcode Category and Physical Material navigation path and label behavior\n case \"BisCore:GeometricElement3dIsInCategory\":\n case \"BisCore:PhysicalElementIsOfPhysicalMaterial\":\n return [\n {\n ...ecProperty,\n ecPropertyName: [...property.ecPropertyTraversal, \"UserLabel\"].join(\".\"),\n },\n {\n ...ecProperty,\n ecPropertyName: [...property.ecPropertyTraversal, \"CodeValue\"].join(\".\"),\n },\n ];\n default: {\n return [\n {\n ...ecProperty,\n ecPropertyName: property.ecPropertyTraversal.join(\".\"),\n },\n ];\n }\n }\n};\n\nexport const findProperties = (ecProperties: ECPropertyReference[], propertiesMetaData: PropertyMetaData[]) => {\n let ecPropertiesCopy = [...ecProperties];\n const propertiesMetaDataResult: PropertyMetaData[] = new Array<PropertyMetaData>();\n let notFound = false;\n while (ecPropertiesCopy.length !== 0) {\n for (let i = 0; i < propertiesMetaData.length; i++) {\n const generatedProperty = convertToECProperties(propertiesMetaData[i]);\n const slicedEcProperties = ecPropertiesCopy.slice(0, generatedProperty.length);\n if (deepEqual(generatedProperty, slicedEcProperties)) {\n propertiesMetaDataResult.push(propertiesMetaData[i]);\n ecPropertiesCopy = ecPropertiesCopy.slice(generatedProperty.length);\n break;\n }\n if (i === propertiesMetaData.length - 1) {\n notFound = true;\n }\n }\n if (notFound) break;\n }\n return notFound ? [] : propertiesMetaDataResult;\n};\n\nexport const fetchPresentationDescriptor = async (iModelConnection: IModelConnection, keySet: KeySet) => {\n const ruleSet: Ruleset = {\n id: \"gmw-element-properties\",\n rules: [\n {\n ruleType: RuleTypes.Content,\n specifications: [\n {\n specType: ContentSpecificationTypes.SelectedNodeInstances,\n propertyOverrides: [\n {\n name: \"*\",\n isDisplayed: true,\n },\n ],\n },\n ],\n },\n ],\n };\n const requestOptions: ContentDescriptorRequestOptions<IModelConnection, KeySet, RulesetVariable> = {\n imodel: iModelConnection,\n keys: keySet,\n rulesetOrId: ruleSet,\n displayType: DefaultContentDisplayTypes.PropertyPane,\n };\n const descriptor = await Presentation.presentation.getContentDescriptor(requestOptions);\n return descriptor;\n};\n"]}
1
+ {"version":3,"file":"GroupPropertyUtils.js","sourceRoot":"","sources":["../../../../../src/components/Properties/GroupProperties/GroupPropertyUtils.ts"],"names":[],"mappings":";;;AAgBA,oEAAwJ;AACxJ,wEAA4D;AAC5D,6CAAwC;AAcxC,MAAM,WAAW,GAAG,CAAC,uBAA2C,EAAE,iBAAyB,EAAE,iBAA2B,EAAU,EAAE;IAClI,OAAO,GAAG,uBAAuB,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,IAAI,CAA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AAQ;YAAE,MAAM;KACrB;IACD,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,wBAAwB,CAAC;AAClD,CAAC,CAAC;AApBW,QAAA,cAAc,kBAoBzB;AAEK,MAAM,2BAA2B,GAAG,KAAK,EAAE,gBAAkC,EAAE,MAAc,EAAE,EAAE;IACtG,MAAM,OAAO,GAAY;QACvB,EAAE,EAAE,wBAAwB;QAC5B,KAAK,EAAE;YACL;gBACE,QAAQ,EAAE,+BAAS,CAAC,OAAO;gBAC3B,cAAc,EAAE;oBACd;wBACE,QAAQ,EAAE,+CAAyB,CAAC,qBAAqB;wBACzD,iBAAiB,EAAE;4BACjB;gCACE,IAAI,EAAE,GAAG;gCACT,WAAW,EAAE,IAAI;6BAClB;yBACF;qBACF;iBACF;aACF;SACF;KACF,CAAC;IACF,MAAM,cAAc,GAA+E;QACjG,MAAM,EAAE,gBAAgB;QACxB,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,OAAO;QACpB,WAAW,EAAE,gDAA0B,CAAC,YAAY;KACrD,CAAC;IACF,MAAM,UAAU,GAAG,MAAM,oCAAY,CAAC,YAAY,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;IACxF,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AA5BW,QAAA,2BAA2B,+BA4BtC","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 type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { ECPropertyReference } from \"@itwin/insights-client\";\nimport type {\n ContentDescriptorRequestOptions,\n Field,\n KeySet,\n NestedContentField,\n PropertiesField,\n Ruleset,\n RulesetVariable,\n StructFieldMemberDescription,\n} from \"@itwin/presentation-common\";\nimport { ContentSpecificationTypes, DefaultContentDisplayTypes, PropertyValueFormat, RelationshipMeaning, RuleTypes } from \"@itwin/presentation-common\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { deepEqual } from \"fast-equals\";\n\nexport interface PropertyMetaData {\n displayLabel: string;\n sourceSchema: string;\n sourceClassName: string;\n categoryLabel: string;\n actualECClassName: string;\n parentPropertyClassName: string | undefined;\n ecPropertyTraversal: string[];\n primitiveNavigationClass: string;\n key: string;\n}\n\nconst generateKey = (parentPropertyClassName: string | undefined, actualECClassName: string, propertyTraversal: string[]): string => {\n return `${parentPropertyClassName}|${actualECClassName}|${propertyTraversal.join(\"|\")}`;\n};\n\nconst extractPrimitives = (propertyTraversal: string[], propertyField: PropertiesField): PropertyMetaData[] =>\n propertyField.properties.map((property) => {\n const propertyName = property.property.name;\n const displayLabel = propertyField.label;\n // It belongs to this parent class\n const parentPropertyClassName = propertyField.parent?.contentClassInfo.name;\n const primitiveNavigationClass = property.property.navigationPropertyInfo?.classInfo.name ?? \"\";\n const actualECClassName = property.property.classInfo.name;\n const newPropertyTraversal = [...propertyTraversal, propertyName];\n\n return {\n displayLabel,\n sourceSchema: \"*\",\n sourceClassName: \"*\",\n ecPropertyTraversal: newPropertyTraversal,\n primitiveNavigationClass,\n actualECClassName,\n parentPropertyClassName,\n key: generateKey(parentPropertyClassName, actualECClassName, newPropertyTraversal),\n categoryLabel: propertyField.category.label,\n };\n });\n\nconst extractPrimitiveStructProperties = (\n propertyTraversal: string[],\n members: StructFieldMemberDescription[],\n categoryLabel: string,\n actualECClassName: string,\n parentPropertyClassName?: string,\n): PropertyMetaData[] =>\n members.flatMap((member) => {\n if (member.type.valueFormat === PropertyValueFormat.Primitive) {\n const propertyName = member.name;\n const displayLabel = member.label;\n const newPropertyTraversal = [...propertyTraversal, propertyName];\n\n return {\n displayLabel,\n sourceSchema: \"*\",\n sourceClassName: \"*\",\n ecPropertyTraversal: newPropertyTraversal,\n primitiveNavigationClass: \"\",\n actualECClassName,\n parentPropertyClassName,\n key: generateKey(parentPropertyClassName, actualECClassName, newPropertyTraversal),\n categoryLabel,\n };\n } else if (member.type.valueFormat === PropertyValueFormat.Struct) {\n const structName = member.name;\n return extractPrimitiveStructProperties(\n [...propertyTraversal, structName],\n member.type.members,\n categoryLabel,\n actualECClassName,\n parentPropertyClassName,\n );\n }\n\n return [];\n });\n\nconst extractStruct = (property: Field) => {\n if (property.type.valueFormat !== PropertyValueFormat.Struct) {\n return [];\n }\n\n const columnName = (property as PropertiesField).properties[0].property.name;\n const actualECClassName = (property as PropertiesField).properties[0].property.classInfo.name;\n return extractPrimitiveStructProperties([columnName], property.type.members, property.category.label, actualECClassName);\n};\n\nconst extractNested = (propertyTraversal: string[], propertyFields: Field[]): PropertyMetaData[] =>\n propertyFields.flatMap((property) => {\n // Generate base ECProperty\n switch (property.type.valueFormat) {\n case PropertyValueFormat.Primitive: {\n return extractPrimitives([...propertyTraversal], property as PropertiesField);\n }\n // Get structs\n case PropertyValueFormat.Struct: {\n const nestedContentField = property as NestedContentField;\n // Only handling single path and not handling nested content fields within navigations\n if (nestedContentField.pathToPrimaryClass && nestedContentField.pathToPrimaryClass.length > 1) {\n // Hardcoded navigation to external source repository metadata.\n if (nestedContentField.contentClassInfo.name === \"BisCore:RepositoryLink\") {\n return extractNested([...propertyTraversal, \"Source\", \"Repository\"], nestedContentField.nestedFields);\n }\n break;\n }\n\n switch (nestedContentField.relationshipMeaning) {\n // Aspects are not looked at again. Extraction does not support aspects within navigations.\n // Navigation properties\n case RelationshipMeaning.RelatedInstance: {\n if (\n // Deal with a TypeDefinition\n nestedContentField.pathToPrimaryClass[0].relationshipInfo.name === \"BisCore:GeometricElement3dHasTypeDefinition\"\n ) {\n return extractNested([...propertyTraversal, \"TypeDefinition\"], nestedContentField.nestedFields);\n }\n break;\n }\n default: {\n // Some elements don't have a path to primary class or relationship meaning..\n // Most likely a simple struct property\n if (!nestedContentField.pathToPrimaryClass) {\n return extractStruct(property);\n }\n }\n }\n }\n }\n return [];\n });\n\nexport const convertPresentationFields = (propertyFields: Field[]): PropertyMetaData[] => {\n const uniquePropertiesMap = new Map<string, PropertyMetaData>();\n\n propertyFields.forEach((property) => {\n switch (property.type.valueFormat) {\n case PropertyValueFormat.Primitive: {\n const propertiesField = property as PropertiesField;\n if (!propertiesField.properties) {\n return;\n }\n // Generate base ECProperty\n const extractedPrimitives = extractPrimitives([], propertiesField);\n extractedPrimitives.forEach((extractedPrimitive) => {\n extractedPrimitive.sourceSchema = \"*\";\n extractedPrimitive.sourceClassName = \"*\";\n uniquePropertiesMap.set(extractedPrimitive.key, extractedPrimitive);\n });\n break;\n }\n case PropertyValueFormat.Struct: {\n // Get structs\n const nestedContentField = property as NestedContentField;\n // Only handling single path and not handling nested content fields within navigations\n if (nestedContentField.pathToPrimaryClass && nestedContentField.pathToPrimaryClass.length > 1) {\n break;\n }\n switch (nestedContentField.relationshipMeaning) {\n case RelationshipMeaning.SameInstance: {\n // Check for aspects.\n if (\n nestedContentField.pathToPrimaryClass[0].relationshipInfo.name === \"BisCore:ElementOwnsUniqueAspect\" ||\n nestedContentField.pathToPrimaryClass[0].relationshipInfo.name === \"BisCore:ElementOwnsMultiAspects\"\n ) {\n const fullClassName = nestedContentField.contentClassInfo.name;\n const sourceSchema = fullClassName.split(\":\")[0];\n const sourceClassName = fullClassName.split(\":\")[1];\n const extractedNested = extractNested([], nestedContentField.nestedFields);\n extractedNested.forEach((ecProperty) => {\n const propertyWithSchema = { ...ecProperty, sourceSchema, sourceClassName };\n uniquePropertiesMap.set(propertyWithSchema.key, propertyWithSchema);\n });\n }\n break;\n }\n case RelationshipMeaning.RelatedInstance: {\n // Navigation properties\n if (\n // Deal with a TypeDefinition\n nestedContentField.pathToPrimaryClass[0].relationshipInfo.name === \"BisCore:GeometricElement3dHasTypeDefinition\"\n ) {\n const extractedNested = extractNested([\"TypeDefinition\"], nestedContentField.nestedFields);\n extractedNested.forEach((ecProperty) => {\n uniquePropertiesMap.set(ecProperty.key, ecProperty);\n });\n }\n break;\n }\n default: {\n // Some elements don't have a path to primary class or relationship meaning..\n // Most likely a simple struct property\n if (!nestedContentField.pathToPrimaryClass) {\n const extractedStruct = extractStruct(property);\n extractedStruct.forEach((ecProperty) => {\n uniquePropertiesMap.set(ecProperty.key, ecProperty);\n });\n }\n }\n }\n }\n }\n });\n\n return Array.from(uniquePropertiesMap.values());\n};\n\nexport const convertToECProperties = (property: PropertyMetaData): ECPropertyReference[] => {\n const ecProperty: ECPropertyReference = {\n ecSchemaName: property.sourceSchema,\n ecClassName: property.sourceClassName,\n ecPropertyName: \"\",\n };\n switch (property.primitiveNavigationClass) {\n // Hardcode Models navigation path and label behavior\n case \"BisCore:ModelContainsElements\": {\n return [\n {\n ...ecProperty,\n ecPropertyName: [...property.ecPropertyTraversal, \"ModeledElement\", \"UserLabel\"].join(\".\"),\n },\n {\n ...ecProperty,\n ecPropertyName: [...property.ecPropertyTraversal, \"ModeledElement\", \"CodeValue\"].join(\".\"),\n },\n ];\n }\n // Hardcode Category and Physical Material navigation path and label behavior\n case \"BisCore:GeometricElement3dIsInCategory\":\n case \"BisCore:PhysicalElementIsOfPhysicalMaterial\":\n return [\n {\n ...ecProperty,\n ecPropertyName: [...property.ecPropertyTraversal, \"UserLabel\"].join(\".\"),\n },\n {\n ...ecProperty,\n ecPropertyName: [...property.ecPropertyTraversal, \"CodeValue\"].join(\".\"),\n },\n ];\n default: {\n return [\n {\n ...ecProperty,\n ecPropertyName: property.ecPropertyTraversal.join(\".\"),\n },\n ];\n }\n }\n};\n\nexport const findProperties = (ecProperties: ECPropertyReference[], propertiesMetaData: PropertyMetaData[]) => {\n let ecPropertiesCopy = [...ecProperties];\n const propertiesMetaDataResult: PropertyMetaData[] = new Array<PropertyMetaData>();\n let notFound = false;\n while (ecPropertiesCopy.length !== 0) {\n for (let i = 0; i < propertiesMetaData.length; i++) {\n const generatedProperty = convertToECProperties(propertiesMetaData[i]);\n const slicedEcProperties = ecPropertiesCopy.slice(0, generatedProperty.length);\n if (deepEqual(generatedProperty, slicedEcProperties)) {\n propertiesMetaDataResult.push(propertiesMetaData[i]);\n ecPropertiesCopy = ecPropertiesCopy.slice(generatedProperty.length);\n break;\n }\n if (i === propertiesMetaData.length - 1) {\n notFound = true;\n }\n }\n if (notFound) break;\n }\n return notFound ? [] : propertiesMetaDataResult;\n};\n\nexport const fetchPresentationDescriptor = async (iModelConnection: IModelConnection, keySet: KeySet) => {\n const ruleSet: Ruleset = {\n id: \"gmw-element-properties\",\n rules: [\n {\n ruleType: RuleTypes.Content,\n specifications: [\n {\n specType: ContentSpecificationTypes.SelectedNodeInstances,\n propertyOverrides: [\n {\n name: \"*\",\n isDisplayed: true,\n },\n ],\n },\n ],\n },\n ],\n };\n const requestOptions: ContentDescriptorRequestOptions<IModelConnection, KeySet, RulesetVariable> = {\n imodel: iModelConnection,\n keys: keySet,\n rulesetOrId: ruleSet,\n displayType: DefaultContentDisplayTypes.PropertyPane,\n };\n const descriptor = await Presentation.presentation.getContentDescriptor(requestOptions);\n return descriptor;\n};\n"]}
@@ -1258,7 +1258,7 @@ exports.testCases = {
1258
1258
  },
1259
1259
  {
1260
1260
  name: "when property is a model, return a model query string",
1261
- expectedResult: "SELECT BisCore.B.ECInstanceId, BisCore.B.ECClassId FROM BisCore.B JOIN mockModeledElement ON mockModeledElement.ECInstanceId = BisCore.Element.Model.id WHERE mockModeledElement.UserLabel = 'displayValueString' OR mockModeledElement.CodeValue = 'displayValueString'",
1261
+ expectedResult: "SELECT BisCore.B.ECInstanceId, BisCore.B.ECClassId FROM BisCore.B JOIN mockModeledElement ON mockModeledElement.ECInstanceId = BisCore.B.Model.id WHERE (mockModeledElement.UserLabel = 'displayValueString' OR mockModeledElement.CodeValue = 'displayValueString')",
1262
1262
  operations: [
1263
1263
  {
1264
1264
  expectedResult: true,