@itwin/grouping-mapping-widget 0.35.1 → 0.35.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyUtils.js +5 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyUtils.js.map +1 -1
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyUtils.js +5 -1
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyUtils.js.map +1 -1
- package/package.json +1 -1
|
@@ -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([],
|
|
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,EAA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AAE;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 // 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,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,CAA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,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"]}
|
|
@@ -100,8 +100,12 @@ export const convertPresentationFields = (propertyFields) => {
|
|
|
100
100
|
propertyFields.forEach((property) => {
|
|
101
101
|
switch (property.type.valueFormat) {
|
|
102
102
|
case PropertyValueFormat.Primitive: {
|
|
103
|
+
const propertiesField = property;
|
|
104
|
+
if (!propertiesField.properties) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
103
107
|
// Generate base ECProperty
|
|
104
|
-
const extractedPrimitives = extractPrimitives([],
|
|
108
|
+
const extractedPrimitives = extractPrimitives([], propertiesField);
|
|
105
109
|
extractedPrimitives.forEach((extractedPrimitive) => {
|
|
106
110
|
extractedPrimitive.sourceSchema = "*";
|
|
107
111
|
extractedPrimitive.sourceClassName = "*";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupPropertyUtils.js","sourceRoot":"","sources":["../../../../../src/components/Properties/GroupProperties/GroupPropertyUtils.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACxJ,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;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;IACl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,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,0BAA0B,CAAC,YAAY;KACrD,CAAC;IACF,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,YAAY,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;IACxF,OAAO,UAAU,CAAC;AACpB,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 { 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,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACxJ,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;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,EA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,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 { 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"]}
|