-
Notifications
You must be signed in to change notification settings - Fork 2
Add test which introduces a EntityClass that has a CA 'QueryView' and a navigation property to exercise ECReferenceTypesCache #222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 7 commits
4c16be3
1e36d7d
2639ea9
7fd4cdd
e74c001
2d6b59c
0302eeb
47c9ccd
2f0454a
a5bb5de
d553f90
4edc7f6
a557cfd
504301d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "patch", | ||
| "comment": "handle queryViews with navigationProperties in the ECreferenceTypesCache", | ||
| "packageName": "@itwin/imodel-transformer", | ||
| "email": "22119573+nick4598@users.noreply.github.com", | ||
| "dependentChangeType": "patch" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,8 +43,8 @@ | |
| "node": ">=16" | ||
| }, | ||
| "pnpm": { | ||
| "overrides": { | ||
| "semver": "^7.5.2" | ||
| } | ||
| "overrides": { | ||
| "semver": "^7.5.2" | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| * @module iModels | ||
| */ | ||
|
|
||
| import { DbResult, TupleKeyedMap } from "@itwin/core-bentley"; | ||
| import { DbResult, Logger, TupleKeyedMap } from "@itwin/core-bentley"; | ||
| import { | ||
| ConcreteEntityTypes, | ||
| IModelError, | ||
|
|
@@ -24,6 +24,7 @@ import { | |
| } from "@itwin/ecschema-metadata"; | ||
| import * as assert from "assert"; | ||
| import { IModelDb } from "@itwin/core-backend"; | ||
| import { TransformerLoggerCategory } from "./TransformerLoggerCategory"; | ||
|
|
||
| /** The context for transforming a *source* Element to a *target* Element and remapping internal identifiers to the target iModel. | ||
| * @internal | ||
|
|
@@ -221,6 +222,38 @@ export class ECReferenceTypesCache { | |
| ECReferenceTypesCache.bisRootClassToRefType[sourceRootBisClass.name]; | ||
| const targetType = | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ColinKerr What is the recommended way to tell if a class is abstract or not? |
||
| ECReferenceTypesCache.bisRootClassToRefType[targetRootBisClass.name]; | ||
|
|
||
| const sourceCAs = sourceClass.getCustomAttributesSync(); | ||
| const targetCAs = targetClass.getCustomAttributesSync(); | ||
| for (const [customAttributeName, _customAttribute] of sourceCAs) { | ||
| // I've essentially captured the case that will cause us problems, but now the question is what to do about it? | ||
| if ( | ||
| customAttributeName.toLowerCase() === "ecdbmap.queryview" && | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Worried about potential performance implications, if I am checking the customattributes of every relationshipClass for the queryView attribute, will that be slow? Potential optimization is to only check if the sourceType or targetType are undefined? I imagine this is probably quite a small %age of any given transformer run, so maybe it doesn't matter?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Started timing it: Info | core-backend.IModelTransformer | Checked 1444 classes for QueryView custom attribute. This took 4ms. Its maybe overkill. |
||
| sourceType === undefined | ||
| ) { | ||
| // no sourceType means the rootBisClass.name is not in the bisRootClassToRefType map. | ||
| Logger.logInfo( | ||
| TransformerLoggerCategory.IModelTransformer, | ||
| `sourceClass: ${sourceClass.schema.name}:${sourceClass.name} has customAttribute which is QueryView and no sourceType in the rootClassToRefType map` | ||
|
nick4598 marked this conversation as resolved.
Outdated
|
||
| ); | ||
| return undefined; | ||
| } | ||
| } | ||
|
|
||
| for (const [customAttributeName, _customAttribute] of targetCAs) { | ||
| if ( | ||
| customAttributeName.toLowerCase() === "ecdbmap.queryview" && | ||
| targetType === undefined | ||
| ) { | ||
| // I've essentially captured the case that will cause us problems, but now the question is what to do about it? | ||
| Logger.logInfo( | ||
| TransformerLoggerCategory.IModelTransformer, | ||
| `targetClass: ${targetClass.schema.name}:${targetClass.name} has customAttribute which is QueryView and no sourceType in the rootClassToRefType map` | ||
|
nick4598 marked this conversation as resolved.
Outdated
|
||
| ); | ||
| return undefined; | ||
| } | ||
| } | ||
|
|
||
| const makeAssertMsg = (root: ECClass, cls: ECClass) => | ||
| [ | ||
| `An unknown root class '${root.fullName}' was encountered while populating`, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <ECSchema schemaName="TestGeneratedClassesNew" alias="tgcn" version="1.0.0" | ||
| xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.2"> | ||
| <ECSchemaReference name="CoreCustomAttributes" version="01.00.03" alias="CoreCA"/> | ||
| <ECSchemaReference name="BisCustomAttributes" version="01.00.00" alias="bisCA"/> | ||
| <ECSchemaReference name="ECdbMap" version="02.00.04" alias="ecdbmap"/> | ||
| <ECSchemaReference name="BisCore" version="01.00.16" alias="bis"/> | ||
|
|
||
| <ECEntityClass typeName="TestView" modifier="Abstract" displayLabel="Test View" description="a sample view"> | ||
| <ECCustomAttributes> | ||
| <QueryView xmlns="ECDbMap.02.00.04"> | ||
| <Query> | ||
| SELECT | ||
| pe.ECInstanceId, | ||
| pe.ECClassId, | ||
| pe.Yaw as Yaw, | ||
| NAVIGATION_VALUE(bis.PhysicalElement.Parent, pe.Parent.Id) as Parent | ||
| FROM bis.PhysicalElement pe | ||
| </Query> | ||
| </QueryView> | ||
| </ECCustomAttributes> | ||
| <ECProperty propertyName="Yaw" typeName="double" description="Yaw of the PhysicalElement"/> | ||
| <ECNavigationProperty propertyName="Parent" relationshipName="PhysicalElementOwnsTestView" direction="backward" description="The parent Element that owns this element"/> | ||
| </ECEntityClass> | ||
|
|
||
| <ECRelationshipClass typeName="PhysicalElementOwnsTestView" strength="embedding" modifier="None" description="Relationship between an PhysicalElement and a TestView."> | ||
| <Source multiplicity="(1..1)" roleLabel="owns" polymorphic="true"> | ||
| <Class class="bis:PhysicalElement"/> | ||
| </Source> | ||
| <Target multiplicity="(1..*)" roleLabel="is owned by" polymorphic="true"> | ||
| <Class class="TestView"/> | ||
| </Target> | ||
| </ECRelationshipClass> | ||
|
|
||
| </ECSchema> |
Uh oh!
There was an error while loading. Please reload this page.