Search in sources :

Example 1 with Node

use of org.finos.waltz.common.hierarchy.Node in project waltz by khartec.

the class LogicalFlowDecoratorRatingsServiceHarness method main.

public static void main(String[] args) throws SQLException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    FlowClassificationRuleService authoritativeSourceService = ctx.getBean(FlowClassificationRuleService.class);
    List<FlowClassificationRule> authSources = authoritativeSourceService.findAll();
    OrganisationalUnitService organisationalUnitService = ctx.getBean(OrganisationalUnitService.class);
    OrganisationalUnitDao organisationalUnitDao = ctx.getBean(OrganisationalUnitDao.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    dsl.select(ORGANISATIONAL_UNIT.fields()).from(ORGANISATIONAL_UNIT).fetch(organisationalUnitDao.TO_DOMAIN_MAPPER);
    EntityHierarchyService hierarchyService = ctx.getBean(EntityHierarchyService.class);
    List<OrganisationalUnit> allOrgUnits = organisationalUnitService.findAll();
    List<FlatNode<OrganisationalUnit, Long>> ouNodes = ListUtilities.map(allOrgUnits, ou -> new FlatNode<>(ou.id().get(), ou.parentId(), ou));
    Forest<OrganisationalUnit, Long> ouForest = HierarchyUtilities.toForest(ouNodes);
    Map<Long, Node<OrganisationalUnit, Long>> nodeMap = ouForest.getAllNodes();
}
Also used : OrganisationalUnitService(org.finos.waltz.service.orgunit.OrganisationalUnitService) OrganisationalUnitDao(org.finos.waltz.data.orgunit.OrganisationalUnitDao) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityHierarchyService(org.finos.waltz.service.entity_hierarchy.EntityHierarchyService) Node(org.finos.waltz.common.hierarchy.Node) FlatNode(org.finos.waltz.common.hierarchy.FlatNode) DSLContext(org.jooq.DSLContext) OrganisationalUnit(org.finos.waltz.model.orgunit.OrganisationalUnit) FlowClassificationRule(org.finos.waltz.model.flow_classification_rule.FlowClassificationRule) FlowClassificationRuleService(org.finos.waltz.service.flow_classification_rule.FlowClassificationRuleService) FlatNode(org.finos.waltz.common.hierarchy.FlatNode)

Example 2 with Node

use of org.finos.waltz.common.hierarchy.Node 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(Node::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 : Node(org.finos.waltz.common.hierarchy.Node) FlatNode(org.finos.waltz.common.hierarchy.FlatNode) PersonHierarchyRecord(org.finos.waltz.schema.tables.records.PersonHierarchyRecord) Person(org.finos.waltz.model.person.Person) LinkedList(java.util.LinkedList)

Aggregations

FlatNode (org.finos.waltz.common.hierarchy.FlatNode)2 Node (org.finos.waltz.common.hierarchy.Node)2 LinkedList (java.util.LinkedList)1 OrganisationalUnitDao (org.finos.waltz.data.orgunit.OrganisationalUnitDao)1 FlowClassificationRule (org.finos.waltz.model.flow_classification_rule.FlowClassificationRule)1 OrganisationalUnit (org.finos.waltz.model.orgunit.OrganisationalUnit)1 Person (org.finos.waltz.model.person.Person)1 PersonHierarchyRecord (org.finos.waltz.schema.tables.records.PersonHierarchyRecord)1 EntityHierarchyService (org.finos.waltz.service.entity_hierarchy.EntityHierarchyService)1 FlowClassificationRuleService (org.finos.waltz.service.flow_classification_rule.FlowClassificationRuleService)1 OrganisationalUnitService (org.finos.waltz.service.orgunit.OrganisationalUnitService)1 DSLContext (org.jooq.DSLContext)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1