Skip to content
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

Filtering a Subject results in an Error #147

Open
ViliusRuskys opened this issue Feb 7, 2024 · 0 comments
Open

Filtering a Subject results in an Error #147

ViliusRuskys opened this issue Feb 7, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ViliusRuskys
Copy link
Contributor

Consider this Subject hierarchy:

root_Subject
^
Subject_A
^
Subject_B
^
PhysicalPartition_1

Lets say a user wants to filter out Subject_A and all of the data that it owns (including elements modeled by PhysicalPartition_1)
One way to do it would be to add Subject_A to the excluded element list by calling excludeElement(<Subject_A id>) which effectively makes it so that Subject_A, Subject_B and PhysicalPartition_1 will be excluded as well because transformer will not step into this hierarchy branch anymore.
However, the PhysicalModel_1 that is modeling PhysicalPartition_1 is not aware of this hierarchy. Models are queried and exported by their modeling hierarchy instead. In this case thePhysicalModel_1 is a sub-model of repository model (which models root_Subject).
When the transformer calls this.exportSubModels(IModel.repositoryModelId); it tries to export PhysicalModel_1 and fails to do so because the Partition element was filtered out.

To workaround this we need to add the PhysicalPartition_1 id into excluded element list. This works because ExportModel will only be invoked if its partition element is not excluded.
For that I wrote a ECSql query that recursively selects all Subjects in a hierarchy.

WITH RECURSIVE child_of_subject(subjectId) AS 
(
	SELECT ECInstanceId FROM bis.Subject WHERE ECInstanceId IN(<TOP SUBJECT ID>)
	UNION
	SELECT s.ECInstanceId FROM bis.Subject s INNER JOIN child_of_subject ON s.Parent.Id = child_of_subject.subjectId
)
SELECT * FROM child_of_subject

Running this will fetch all of the subjects' ids that are beneath the "TOP SUBJECT ID" (including itself). I then queried all child elements of these subjects which selected all of their child partitions and added them to excluded element list.

@nick4598 nick4598 added the bug Something isn't working label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants