Skip to content

Commit

Permalink
Hierarchy builder: Add base class grouping and merge groupings into s…
Browse files Browse the repository at this point in the history
…ingle operator (#321)

* Add baseClassGrouping

* Add baseClassGrouping

* Fix merge git crap

* Add latest updates

* Add base class grouping and hiding

* Add check for relationship and entity class

* test coverage

* Remove commented code

* Add changeset

* BaseClassGroupingNodeKey removal and sortByBaseClass reduce time complexity to O(n^2)

* Fix group hiding

* Merge schemaName and className into fullClassName

* Move createGroupingHandlers to Grouping.ts

* move grouping merge params to separate function

* Add new line after file header

* fix formatting

* Remove @beta tags from non exported apis

* Use sortNodesByLabel in sortNodesByLabelOperator

* Raname GroupingHandlerReturn to GroupingHandlerResult

* Rename GroupingHandlerType to GroupingHandler

* remove export

* Remove export

* Remove allNodes and use nodes instead

* Add comment

* add internal tag

* Move label grouping creation to a function

* Use Promise.all to save time

* Add createBaseClassGroupingHandlers

* Add !classNameIsInNodeBaseClassList check

* Remove redundant check

* Remove checking if grouped node

* Remove 3 similar functions for one

* run pnpm extract api

* Fix import

* Fix group hiding

* Remove isGrouping check, it is not used

* Code cleanup

* Update packages/hierarchy-builder/src/hierarchy-builder/queries/NodeSelectClauseFactory.ts

Co-authored-by: Grigas <[email protected]>

* Update packages/hierarchy-builder/src/hierarchy-builder/internal/Common.ts

Co-authored-by: Grigas <[email protected]>

* Update packages/hierarchy-builder/src/hierarchy-builder/internal/Common.ts

Co-authored-by: Grigas <[email protected]>

* Update packages/hierarchy-builder/src/hierarchy-builder/internal/operators/Grouping.ts

Co-authored-by: Grigas <[email protected]>

* Update packages/hierarchy-builder/src/hierarchy-builder/internal/operators/grouping/BaseClassGrouping.ts

Co-authored-by: Grigas <[email protected]>

* Update packages/hierarchy-builder/src/hierarchy-builder/internal/operators/grouping/BaseClassGrouping.ts

Co-authored-by: Grigas <[email protected]>

* Update packages/hierarchy-builder/src/hierarchy-builder/internal/operators/grouping/BaseClassGrouping.ts

Co-authored-by: Grigas <[email protected]>

* Renaming changes

* Add grouping result under grouping attribute

* Remove redundant code

* Remove groupNodesFromHandlerCreator

* Add ungroupedNodes

* Add assert to avoid check if array

* Add docs to @beta

* Remove root subject from tests

* Show correct label for base class grouping node

* Rename describe blocks

* Move createProvider to IModelUtils

* Cleanup baseClassGrouping

* base class grouping test cleanup

* group hiding add full stack tests

* Remove for loop

* Add better explanation

* Remove allNodes and rename to grouped and ungrouped

* Update packages/hierarchy-builder/src/hierarchy-builder/HierarchyNode.ts

Co-authored-by: Grigas <[email protected]>

* Simplify the api

* Update packages/hierarchy-builder/src/hierarchy-builder/HierarchyNode.ts

Co-authored-by: Grigas <[email protected]>

* Apply suggestion

* Update packages/hierarchy-builder/src/hierarchy-builder/internal/operators/Grouping.ts

Co-authored-by: Grigas <[email protected]>

* Update packages/hierarchy-builder/src/hierarchy-builder/internal/operators/grouping/GroupHiding.ts

Co-authored-by: Grigas <[email protected]>

* Remove redundant code

* Move createProvider to hierarchy-builder/Utils.ts

* Update packages/full-stack-tests/src/hierarchy-builder/grouping/GroupHiding.test.ts

Co-authored-by: Grigas <[email protected]>

* Update imports

* simplify test cases

* Remove userLabel from tests which don't need it

* Update tests to use one function to create hierarchy

* Prettier change

* Simplify unit tests

* Update packages/hierarchy-builder/src/test/internal/operators/grouping/LabelGrouping.test.ts

Co-authored-by: Grigas <[email protected]>

* Update grouping to not use groupNodes() twice

* Define ecClass in tests that need it

* Rename base classes

* Update packages/hierarchy-builder/src/test/internal/operators/Grouping.test.ts

Co-authored-by: Grigas <[email protected]>

* Remove grouping params where it's not necessary

* Check what applyGroupingHidingParamsStub got called with

* Add check that createBaseClassGroupingHandlersStub receives input nodes

* Remove .only

* Increase test coverage

---------

Co-authored-by: Grigas <[email protected]>
  • Loading branch information
JonasDov and grigasp authored Oct 27, 2023
1 parent 7dc9e66 commit 901f2fa
Show file tree
Hide file tree
Showing 34 changed files with 2,680 additions and 717 deletions.
2 changes: 2 additions & 0 deletions .changeset/sixty-needles-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
22 changes: 22 additions & 0 deletions packages/full-stack-tests/src/hierarchy-builder/Utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/

import { IModelConnection } from "@itwin/core-frontend";
import { SchemaContext } from "@itwin/ecschema-metadata";
import { ECSchemaRpcLocater } from "@itwin/ecschema-rpcinterface-common";
import { createECSqlQueryExecutor, createMetadataProvider } from "@itwin/presentation-core-interop";
import { HierarchyProvider, IHierarchyLevelDefinitionsFactory } from "@itwin/presentation-hierarchy-builder";

export function createProvider(props: { imodel: IModelConnection; hierarchy: IHierarchyLevelDefinitionsFactory }) {
const { imodel, hierarchy } = props;
const schemas = new SchemaContext();
schemas.addLocater(new ECSchemaRpcLocater(imodel.getRpcProps()));
const metadataProvider = createMetadataProvider(schemas);
return new HierarchyProvider({
metadataProvider,
hierarchyDefinition: hierarchy,
queryExecutor: createECSqlQueryExecutor(imodel),
});
}
Loading

0 comments on commit 901f2fa

Please sign in to comment.