Search in sources :

Example 1 with ApplicationService

use of org.finos.waltz.service.application.ApplicationService in project waltz by khartec.

the class DiagramToDotExport method main.

public static void main(String[] args) throws IOException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    FlowDiagramService flowDiagramService = ctx.getBean(FlowDiagramService.class);
    FlowDiagramEntityService flowDiagramEntityService = ctx.getBean(FlowDiagramEntityService.class);
    ApplicationService applicationService = ctx.getBean(ApplicationService.class);
    LogicalFlowService logicalFlowService = ctx.getBean(LogicalFlowService.class);
    EntityReference diagRef = mkRef(EntityKind.FLOW_DIAGRAM, 1L);
    IdSelectionOptions options = IdSelectionOptions.mkOpts(diagRef, HierarchyQueryScope.EXACT);
    List<Application> apps = applicationService.findByAppIdSelector(options);
    List<LogicalFlow> flows = logicalFlowService.findBySelector(options);
    Map<Long, Application> appsById = indexBy(a -> a.id().get(), apps);
    System.out.println("------");
    String digraph = String.format("digraph G { %s %s}", renderApplications(apps), renderFlows(flows, appsById));
    System.out.println(digraph);
    System.out.println("-----");
/*
        digraph G {
            "Welcome" -> "To"
            "To" -> "Web"
            "To" -> "GraphViz!"
        }
        */
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) LogicalFlowService(org.finos.waltz.service.logical_flow.LogicalFlowService) FlowDiagramEntityService(org.finos.waltz.service.flow_diagram.FlowDiagramEntityService) FlowDiagramService(org.finos.waltz.service.flow_diagram.FlowDiagramService) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) EntityReference(org.finos.waltz.model.EntityReference) Application(org.finos.waltz.model.application.Application) ApplicationService(org.finos.waltz.service.application.ApplicationService) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions)

Example 2 with ApplicationService

use of org.finos.waltz.service.application.ApplicationService in project waltz by khartec.

the class InvolvementImporter method main.

public static void main(String[] args) throws IOException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    ApplicationService applicationService = ctx.getBean(ApplicationService.class);
    PersonService personService = ctx.getBean(PersonService.class);
    Map<String, Application> appsByExtId = indexBy(a -> ExternalIdValue.orElse(a.assetCode(), null), applicationService.findAll());
    Map<String, Person> peopleByName = indexBy(p -> toSurnameFirstname(p.displayName()).toLowerCase(), personService.all());
    Siphon<String[]> incorrectSizeSiphon = mkSiphon(arr -> arr.length != 3);
    Siphon<Tuple2<String, ?>> unknownAppSiphon = mkSiphon(t -> !appsByExtId.containsKey(t.v1));
    Siphon<Tuple2<?, String>> unknownPersonSiphon = mkSiphon(t -> !peopleByName.containsKey(t.v2.toLowerCase()));
    Siphon<Tuple2<Application, ?>> retiredAppSiphon = mkSiphon(t -> t.v1.lifecyclePhase() == LifecyclePhase.RETIRED);
    List<Tuple2<Application, Person>> r = IOUtilities.streamLines(classLoader.getResourceAsStream(fileName)).map(line -> line.split("\t")).filter(d -> incorrectSizeSiphon.test(d)).map(arr -> Tuple.tuple(arr[1], arr[0])).filter(t -> unknownAppSiphon.test(t)).map(t -> t.map1(extId -> appsByExtId.get(extId))).filter(t -> retiredAppSiphon.test(t)).filter(t -> unknownPersonSiphon.test(t)).map(t -> t.map2(n -> peopleByName.get(n.toLowerCase()))).collect(Collectors.toList());
    Set<Application> distinctApps = r.stream().map(t -> t.v1).distinct().collect(Collectors.toSet());
    Set<Person> distinctPeople = r.stream().map(t -> t.v2).distinct().collect(Collectors.toSet());
    System.out.println("----");
    System.out.println("Wrong size count: " + incorrectSizeSiphon.getResults().size());
    System.out.println("Apps not found count: " + unknownAppSiphon.getResults().size());
    System.out.println("Retired app count: " + retiredAppSiphon.getResults().size());
    System.out.println("Person not found count: " + unknownPersonSiphon.getResults().size());
    System.out.println("----");
    System.out.println("Good record count: " + r.size());
    System.out.println("Distinct App count: " + distinctApps.size());
    System.out.println("Distinct People count: " + distinctPeople.size());
    Map<String, Long> unknownPersonCounts = countBy(Tuple2::v2, unknownPersonSiphon.getResults());
    DebugUtilities.dump(unknownPersonCounts);
}
Also used : LifecyclePhase(org.finos.waltz.model.application.LifecyclePhase) ApplicationService(org.finos.waltz.service.application.ApplicationService) Application(org.finos.waltz.model.application.Application) ArrayUtilities(org.finos.waltz.common.ArrayUtilities) Set(java.util.Set) StreamUtilities.mkSiphon(org.finos.waltz.common.StreamUtilities.mkSiphon) DIConfiguration(org.finos.waltz.service.DIConfiguration) IOException(java.io.IOException) PersonService(org.finos.waltz.service.person.PersonService) MapUtilities.countBy(org.finos.waltz.common.MapUtilities.countBy) Collectors(java.util.stream.Collectors) IOUtilities(org.finos.waltz.common.IOUtilities) Person(org.finos.waltz.model.person.Person) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MapUtilities.indexBy(org.finos.waltz.common.MapUtilities.indexBy) Tuple2(org.jooq.lambda.tuple.Tuple2) List(java.util.List) DebugUtilities(org.finos.waltz.common.DebugUtilities) ExternalIdValue(org.finos.waltz.model.external_identifier.ExternalIdValue) Tuple(org.jooq.lambda.tuple.Tuple) Map(java.util.Map) Siphon(org.finos.waltz.common.StreamUtilities.Siphon) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) PersonService(org.finos.waltz.service.person.PersonService) Tuple2(org.jooq.lambda.tuple.Tuple2) Application(org.finos.waltz.model.application.Application) Person(org.finos.waltz.model.person.Person) ApplicationService(org.finos.waltz.service.application.ApplicationService)

Example 3 with ApplicationService

use of org.finos.waltz.service.application.ApplicationService 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 4 with ApplicationService

use of org.finos.waltz.service.application.ApplicationService in project waltz by khartec.

the class AllocationHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    AllocationSchemeService schemesService = ctx.getBean(AllocationSchemeService.class);
    MeasurableService measurableService = ctx.getBean(MeasurableService.class);
    MeasurableCategoryDao categoryDao = ctx.getBean(MeasurableCategoryDao.class);
    MeasurableRatingService ratingService = ctx.getBean(MeasurableRatingService.class);
    ApplicationService applicationService = ctx.getBean(ApplicationService.class);
    Tuple4<Application, MeasurableCategory, List<Measurable>, AllocationScheme> stuff = setup(dsl, schemesService, measurableService, categoryDao, applicationService);
    addRating(ratingService, stuff, 0);
    addRating(ratingService, stuff, 1);
    // addRating(ratingService, stuff, 2);
    // addAllocation(dsl, stuff, 0, 50);
    addAllocation(dsl, stuff, 1, 20);
    Long measurableCategory = stuff.v2.id().get();
    dumpRatings(dsl, stuff.v4);
    dumpAllocs(dsl, stuff.v4);
    doDiff(dsl, measurableCategory);
    System.out.println(ratingService.findByCategory(measurableCategory));
}
Also used : MeasurableRatingService(org.finos.waltz.service.measurable_rating.MeasurableRatingService) ImmutableAllocationScheme(org.finos.waltz.model.allocation_scheme.ImmutableAllocationScheme) AllocationScheme(org.finos.waltz.model.allocation_scheme.AllocationScheme) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MeasurableService(org.finos.waltz.service.measurable.MeasurableService) MeasurableCategoryDao(org.finos.waltz.data.measurable_category.MeasurableCategoryDao) AllocationSchemeService(org.finos.waltz.service.allocation_schemes.AllocationSchemeService) MeasurableCategory(org.finos.waltz.model.measurable_category.MeasurableCategory) List(java.util.List) ApplicationService(org.finos.waltz.service.application.ApplicationService)

Example 5 with ApplicationService

use of org.finos.waltz.service.application.ApplicationService in project waltz by khartec.

the class ApplicationIdSelectorHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    ApplicationIdSelectorFactory factory = new ApplicationIdSelectorFactory();
    DSLContext dsl = ctx.getBean(DSLContext.class);
    ApplicationService applicationService = ctx.getBean(ApplicationService.class);
    IdSelectionOptions options = mkOpts(EntityReference.mkRef(EntityKind.DATA_TYPE, 5000L), HierarchyQueryScope.CHILDREN);
    Select<Record1<Long>> selector = factory.apply(options);
    dsl.settings().withRenderFormatted(true);
    List<Application> apps = applicationService.findByAppIdSelector(options);
    System.out.println("--- sz: " + apps.size());
    apps.forEach(System.out::println);
    System.out.println("--- done");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory) DSLContext(org.jooq.DSLContext) Application(org.finos.waltz.model.application.Application) ApplicationService(org.finos.waltz.service.application.ApplicationService) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Aggregations

ApplicationService (org.finos.waltz.service.application.ApplicationService)7 Application (org.finos.waltz.model.application.Application)5 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)4 DSLContext (org.jooq.DSLContext)3 List (java.util.List)2 EntityReference (org.finos.waltz.model.EntityReference)2 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)2 LifecyclePhase (org.finos.waltz.model.application.LifecyclePhase)2 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)2 OrganisationalUnit (org.finos.waltz.model.orgunit.OrganisationalUnit)2 Tuple (org.jooq.lambda.tuple.Tuple)2 IOException (java.io.IOException)1 LocalDateTime (java.time.LocalDateTime)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Collectors.toList (java.util.stream.Collectors.toList)1 Collectors.toSet (java.util.stream.Collectors.toSet)1