Search in sources :

Example 1 with FlatNode

use of com.khartec.waltz.common.hierarchy.FlatNode in project waltz by khartec.

the class LogicalFlowDecoratorRatingsServiceHarness method main.

public static void main(String[] args) throws SQLException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    AuthoritativeSourceService authoritativeSourceService = ctx.getBean(AuthoritativeSourceService.class);
    List<AuthoritativeSource> 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(com.khartec.waltz.service.orgunit.OrganisationalUnitService) OrganisationalUnitDao(com.khartec.waltz.data.orgunit.OrganisationalUnitDao) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityHierarchyService(com.khartec.waltz.service.entity_hierarchy.EntityHierarchyService) Node(com.khartec.waltz.common.hierarchy.Node) FlatNode(com.khartec.waltz.common.hierarchy.FlatNode) AuthoritativeSource(com.khartec.waltz.model.authoritativesource.AuthoritativeSource) DSLContext(org.jooq.DSLContext) AuthoritativeSourceService(com.khartec.waltz.service.authoritative_source.AuthoritativeSourceService) OrganisationalUnit(com.khartec.waltz.model.orgunit.OrganisationalUnit) FlatNode(com.khartec.waltz.common.hierarchy.FlatNode)

Aggregations

FlatNode (com.khartec.waltz.common.hierarchy.FlatNode)1 Node (com.khartec.waltz.common.hierarchy.Node)1 OrganisationalUnitDao (com.khartec.waltz.data.orgunit.OrganisationalUnitDao)1 AuthoritativeSource (com.khartec.waltz.model.authoritativesource.AuthoritativeSource)1 OrganisationalUnit (com.khartec.waltz.model.orgunit.OrganisationalUnit)1 AuthoritativeSourceService (com.khartec.waltz.service.authoritative_source.AuthoritativeSourceService)1 EntityHierarchyService (com.khartec.waltz.service.entity_hierarchy.EntityHierarchyService)1 OrganisationalUnitService (com.khartec.waltz.service.orgunit.OrganisationalUnitService)1 DSLContext (org.jooq.DSLContext)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1