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();
}
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;
}
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);
}
Aggregations