Skip to content

Removed former docs for TreeView models #1904

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

Merged
merged 1 commit into from
Jun 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 0 additions & 65 deletions advanced/odata.md
Original file line number Diff line number Diff line change
Expand Up @@ -1138,71 +1138,6 @@ GET SalesOrganizations?$apply=
/ancestors(..., ID, filter(contains(Name, 'New York')), keep start)
```

#### Modeling Recursive Hierarchies

Recursive hierarchies are parent-child hierarchies, where each entity references its parent and through that defines the hierarchical structure. A common example is a company organization structure or HR reporting, where each employee entity references another employee a as direct report or manager.

##### Domain Model

The simplest domain model looks as follows:

```cds
entity Employee : Hierarchy {
key ID : UUID;
parent : Association to Employee;
fullName : String;
}

aspect Hierarchy {
virtual LimitedDescendantCount : Integer64;
virtual DistanceFromRoot : Integer64;
virtual DrillState : String;
virtual LimitedRank : Integer64;
}
```

The entity `Employee` has the element `ID`, which identifies the hierarchy node. The `parent` association references the same entity, which establishes the parent-child relationship.

##### Virtual Elements of a Hierarchy

The `Hierarchy` aspect defines a set of virtual elements, automatically calculated by the backend at runtime, to describe the state of the hierarchy. This information is requested by the UI to correctly render the hierarchy in a *TreeTable* during user interaction.

##### Service Model

The following service defines the projection on the domain model.

```cds
service HRService {
entity HREmployee as projection on Employee;
}
```


##### OData v4 Annotations for Fiori

To link the backend and Fiori UI, the projected service entity must be enriched with the following annotations.

```cds
annotate HRService.HREmployee with @Aggregation.RecursiveHierarchy #EmployeeHierarchy: {
$Type: 'Aggregation.RecursiveHierarchyType',
NodeProperty: ID,
ParentNavigationProperty: parent
};
```

Here the `EmployeeHierarchy` specifies a hierarchy qualifier, `NodeProperty` (identifying the hierarchy node) is linked to `ID` of the entity `HREmployee`, and the `ParentNavigationProperty` is linked to a corresponding `parent` association.

```cds
annotate HRService.HREmployee with @Hierarchy.RecursiveHierarchy #EmployeeHierarchy: {
$Type: 'Hierarchy.RecursiveHierarchyType',
LimitedDescendantCount: LimitedDescendantCount,
DistanceFromRoot: DistanceFromRoot,
DrillState: DrillState,
LimitedRank: LimitedRank
};
```

Here the same qualifier `EmployeeHierarchy` is referenced to list the names of the [virtual elements of the hierarchy](#virtual-elements-of-a-hierarchy).

### Aggregation Methods

Expand Down
Loading