Search in sources :

Example 1 with PersonHierarchyRecord

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;
}
Also used : PersonHierarchyRecord(com.khartec.waltz.schema.tables.records.PersonHierarchyRecord) Person(com.khartec.waltz.model.person.Person) LinkedList(java.util.LinkedList)

Aggregations

Person (com.khartec.waltz.model.person.Person)1 PersonHierarchyRecord (com.khartec.waltz.schema.tables.records.PersonHierarchyRecord)1 LinkedList (java.util.LinkedList)1