Search in sources :

Example 6 with EntityHierarchyService

use of org.finos.waltz.service.entity_hierarchy.EntityHierarchyService 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 7 with EntityHierarchyService

use of org.finos.waltz.service.entity_hierarchy.EntityHierarchyService in project waltz by khartec.

the class ChangeInitiativeGenerator method create.

@Override
public Map<String, Integer> create(ApplicationContext ctx) {
    DSLContext dsl = getDsl(ctx);
    List<Long> appIds = loadAllIds(dsl, APPLICATION.ID);
    List<Long> ouIds = loadAllIds(dsl, ORGANISATIONAL_UNIT.ID);
    List<Long> groupIds = loadAllIds(dsl, APPLICATION_GROUP.ID);
    List<String> employeeIds = loadAllIds(dsl, PERSON.EMPLOYEE_ID);
    List<ChangeInitiativeRecord> ciRecords = createCiRecords(ouIds);
    dsl.batchInsert(ciRecords).execute();
    LOG.info("Created: {} ci records", ciRecords.size());
    List<Long> ciIds = loadAllIds(dsl, CHANGE_INITIATIVE.ID, CHANGE_INITIATIVE.PROVENANCE.eq(SAMPLE_DATA_PROVENANCE));
    List<TableRecord<?>> relationships = StreamUtilities.concat(buildPersonLinks(ciIds, employeeIds), buildEntityRelationships(EntityKind.APP_GROUP, "RELATES_TO", ciIds, groupIds, 0.5, 2), buildEntityRelationships(EntityKind.APPLICATION, "SUPPORTS", ciIds, appIds, 0.6, 3)).collect(toList());
    LOG.info("Storing {} relationships", relationships.size());
    dsl.batchInsert(relationships).execute();
    EntityHierarchyService ehSvc = ctx.getBean(EntityHierarchyService.class);
    ehSvc.buildFor(EntityKind.CHANGE_INITIATIVE);
    return null;
}
Also used : EntityHierarchyService(org.finos.waltz.service.entity_hierarchy.EntityHierarchyService) AtomicLong(java.util.concurrent.atomic.AtomicLong) ChangeInitiativeRecord(org.finos.waltz.schema.tables.records.ChangeInitiativeRecord)

Example 8 with EntityHierarchyService

use of org.finos.waltz.service.entity_hierarchy.EntityHierarchyService in project waltz by khartec.

the class BaseInMemoryIntegrationTest method rebuildHierarchy.

protected void rebuildHierarchy(EntityKind kind) {
    EntityHierarchyService ehSvc = ctx.getBean(EntityHierarchyService.class);
    ehSvc.buildFor(kind);
}
Also used : EntityHierarchyService(org.finos.waltz.service.entity_hierarchy.EntityHierarchyService)

Aggregations

EntityHierarchyService (org.finos.waltz.service.entity_hierarchy.EntityHierarchyService)8 DSLContext (org.jooq.DSLContext)5 List (java.util.List)2 Map (java.util.Map)2 Supplier (java.util.function.Supplier)2 Collectors (java.util.stream.Collectors)2 IOUtilities.readLines (org.finos.waltz.common.IOUtilities.readLines)2 StringUtilities (org.finos.waltz.common.StringUtilities)2 OrganisationalUnitDao (org.finos.waltz.data.orgunit.OrganisationalUnitDao)2 EntityKind (org.finos.waltz.model.EntityKind)2 OrganisationalUnit (org.finos.waltz.model.orgunit.OrganisationalUnit)2 Unchecked (org.jooq.lambda.Unchecked)2 ApplicationContext (org.springframework.context.ApplicationContext)2 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)2 Timestamp (java.sql.Timestamp)1 Arrays (java.util.Arrays)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Checks.checkNotEmpty (org.finos.waltz.common.Checks.checkNotEmpty)1 MapUtilities (org.finos.waltz.common.MapUtilities)1 FlatNode (org.finos.waltz.common.hierarchy.FlatNode)1