Search in sources :

Example 1 with FlowClassificationRule

use of org.finos.waltz.model.flow_classification_rule.FlowClassificationRule in project waltz by khartec.

the class LogicalFlowGenerator method create.

@Override
public Map<String, Integer> create(ApplicationContext ctx) {
    FlowClassificationRuleDao flowClassificationRuleDao = ctx.getBean(FlowClassificationRuleDao.class);
    ApplicationService applicationDao = ctx.getBean(ApplicationService.class);
    OrganisationalUnitService orgUnitDao = ctx.getBean(OrganisationalUnitService.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    List<FlowClassificationRule> flowClassificationRules = flowClassificationRuleDao.findByEntityKind(EntityKind.ORG_UNIT);
    List<Application> apps = applicationDao.findAll();
    List<OrganisationalUnit> orgUnits = orgUnitDao.findAll();
    LocalDateTime now = LocalDateTime.now();
    Set<LogicalFlow> expectedFlows = flowClassificationRules.stream().flatMap(a -> {
        long orgUnitId = a.parentReference().id();
        return randomlySizedIntStream(0, 40).mapToObj(i -> randomAppPick(apps, orgUnitId).map(target -> ImmutableLogicalFlow.builder().source(a.applicationReference()).target(target).lastUpdatedBy("admin").provenance(SAMPLE_DATA_PROVENANCE).lastUpdatedAt(now).build()).orElse(null));
    }).filter(Objects::nonNull).collect(toSet());
    Set<LogicalFlow> probableFlows = flowClassificationRules.stream().flatMap(a -> randomlySizedIntStream(0, 30).mapToObj(i -> randomAppPick(apps, randomPick(orgUnits).id().get()).map(target -> ImmutableLogicalFlow.builder().source(a.applicationReference()).target(target).lastUpdatedBy("admin").provenance(SAMPLE_DATA_PROVENANCE).lastUpdatedAt(now).build()).orElse(null))).filter(Objects::nonNull).collect(toSet());
    Set<LogicalFlow> randomFlows = apps.stream().flatMap(a -> randomlySizedIntStream(0, 5).mapToObj(i -> randomAppPick(apps, randomPick(orgUnits).id().get()).map(target -> ImmutableLogicalFlow.builder().source(a.entityReference()).target(target).lastUpdatedBy("admin").provenance(SAMPLE_DATA_PROVENANCE).lastUpdatedAt(now).build()).orElse(null))).filter(Objects::nonNull).collect(toSet());
    Set<LogicalFlow> all = new HashSet<>();
    all.addAll(randomFlows);
    all.addAll(expectedFlows);
    all.addAll(probableFlows);
    Set<LogicalFlow> deduped = uniqBy(all, x -> Tuple.tuple(x.source(), x.target()));
    log("--- saving: " + deduped.size());
    Set<LogicalFlowRecord> records = SetUtilities.map(deduped, df -> LogicalFlowDao.TO_RECORD_MAPPER.apply(df, dsl));
    dsl.batchStore(records).execute();
    log("--- done");
    return null;
}
Also used : OrganisationalUnitService(org.finos.waltz.service.orgunit.OrganisationalUnitService) LocalDateTime(java.time.LocalDateTime) java.util(java.util) LogicalFlowDao(org.finos.waltz.data.logical_flow.LogicalFlowDao) ApplicationService(org.finos.waltz.service.application.ApplicationService) EntityKind(org.finos.waltz.model.EntityKind) SetUtilities.uniqBy(org.finos.waltz.common.SetUtilities.uniqBy) LocalDateTime(java.time.LocalDateTime) LogicalFlowRecord(org.finos.waltz.schema.tables.records.LogicalFlowRecord) LOGICAL_FLOW(org.finos.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW) FlowClassificationRuleDao(org.finos.waltz.data.flow_classification_rule.FlowClassificationRuleDao) FlowClassificationRule(org.finos.waltz.model.flow_classification_rule.FlowClassificationRule) DSLContext(org.jooq.DSLContext) Collectors.toSet(java.util.stream.Collectors.toSet) OrganisationalUnit(org.finos.waltz.model.orgunit.OrganisationalUnit) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) Application(org.finos.waltz.model.application.Application) ImmutableLogicalFlow(org.finos.waltz.model.logical_flow.ImmutableLogicalFlow) OrganisationalUnitService(org.finos.waltz.service.orgunit.OrganisationalUnitService) ApplicationContext(org.springframework.context.ApplicationContext) Collectors.toList(java.util.stream.Collectors.toList) Tuple(org.jooq.lambda.tuple.Tuple) ListUtilities(org.finos.waltz.common.ListUtilities) RandomUtilities.randomPick(org.finos.waltz.common.RandomUtilities.randomPick) SetUtilities(org.finos.waltz.common.SetUtilities) RandomUtilities.randomlySizedIntStream(org.finos.waltz.common.RandomUtilities.randomlySizedIntStream) EntityReference(org.finos.waltz.model.EntityReference) LogicalFlowRecord(org.finos.waltz.schema.tables.records.LogicalFlowRecord) FlowClassificationRuleDao(org.finos.waltz.data.flow_classification_rule.FlowClassificationRuleDao) DSLContext(org.jooq.DSLContext) OrganisationalUnit(org.finos.waltz.model.orgunit.OrganisationalUnit) FlowClassificationRule(org.finos.waltz.model.flow_classification_rule.FlowClassificationRule) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) ImmutableLogicalFlow(org.finos.waltz.model.logical_flow.ImmutableLogicalFlow) Application(org.finos.waltz.model.application.Application) ApplicationService(org.finos.waltz.service.application.ApplicationService)

Example 2 with FlowClassificationRule

use of org.finos.waltz.model.flow_classification_rule.FlowClassificationRule 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)

Aggregations

FlowClassificationRule (org.finos.waltz.model.flow_classification_rule.FlowClassificationRule)2 OrganisationalUnit (org.finos.waltz.model.orgunit.OrganisationalUnit)2 OrganisationalUnitService (org.finos.waltz.service.orgunit.OrganisationalUnitService)2 DSLContext (org.jooq.DSLContext)2 LocalDateTime (java.time.LocalDateTime)1 java.util (java.util)1 Collectors.toList (java.util.stream.Collectors.toList)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 ListUtilities (org.finos.waltz.common.ListUtilities)1 RandomUtilities.randomPick (org.finos.waltz.common.RandomUtilities.randomPick)1 RandomUtilities.randomlySizedIntStream (org.finos.waltz.common.RandomUtilities.randomlySizedIntStream)1 SetUtilities (org.finos.waltz.common.SetUtilities)1 SetUtilities.uniqBy (org.finos.waltz.common.SetUtilities.uniqBy)1 FlatNode (org.finos.waltz.common.hierarchy.FlatNode)1 Node (org.finos.waltz.common.hierarchy.Node)1 FlowClassificationRuleDao (org.finos.waltz.data.flow_classification_rule.FlowClassificationRuleDao)1 LogicalFlowDao (org.finos.waltz.data.logical_flow.LogicalFlowDao)1 OrganisationalUnitDao (org.finos.waltz.data.orgunit.OrganisationalUnitDao)1 EntityKind (org.finos.waltz.model.EntityKind)1 EntityReference (org.finos.waltz.model.EntityReference)1