use of com.khartec.waltz.schema.tables.records.PersonHierarchyRecord in project waltz by khartec.
the class PersonHierarchyService method toHierarchyRecords.
private List<PersonHierarchyRecord> toHierarchyRecords(Forest<Person, String> forest) {
List<PersonHierarchyRecord> records = new LinkedList<>();
for (Node<Person, String> node : forest.getAllNodes().values()) {
List<Person> ancestors = ListUtilities.reverse(HierarchyUtilities.parents(node).stream().map(n -> n.getData()).collect(Collectors.toList()));
for (int i = 0; i < ancestors.size(); i++) {
String ancestorId = ancestors.get(i).employeeId();
String selfId = node.getData().employeeId();
PersonHierarchyRecord record = new PersonHierarchyRecord(ancestorId, selfId, i + 1);
records.add(record);
}
}
return records;
}
Aggregations