Search in sources :

Example 6 with ApplicationService

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

the class AssetCostGenerator method create.

@Override
public Map<String, Integer> create(ApplicationContext ctx) {
    ApplicationService applicationService = ctx.getBean(ApplicationService.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    dsl.transaction(c -> {
        DSLContext tx = c.dsl();
        List<Application> apps = applicationService.findAll();
        List<CostRecord> appDevCosts = generateRecords(apps, WaltzUtilities.getOrCreateCostKind(tx, "Application Development", "APPLICATION_DEVELOPMENT"), 900_000);
        List<CostRecord> infraCosts = generateRecords(apps, WaltzUtilities.getOrCreateCostKind(tx, "Infrastructure", "INFRASTRUCTURE"), 50_000);
        List<CostRecord> cloudMigrationCosts = generateRecords(randomPickSome(apps, 0.4), WaltzUtilities.getOrCreateCostKind(tx, "Cloud Migration", "CLOUD"), 200_000);
        List<CostRecord> depreciationCosts = generateRecords(randomPickSome(apps, 0.6), WaltzUtilities.getOrCreateCostKind(tx, "Depreciation", "DEPRECIATION"), 100_000);
        tx.batchInsert(appDevCosts).execute();
        tx.batchInsert(infraCosts).execute();
        tx.batchInsert(cloudMigrationCosts).execute();
        tx.batchInsert(depreciationCosts).execute();
    });
    return null;
}
Also used : CostRecord(org.finos.waltz.schema.tables.records.CostRecord) DSLContext(org.jooq.DSLContext) Application(org.finos.waltz.model.application.Application) ApplicationService(org.finos.waltz.service.application.ApplicationService)

Example 7 with ApplicationService

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

the class AppGenerator method create.

@Override
public Map<String, Integer> create(ApplicationContext ctx) {
    DSLContext dsl = getDsl(ctx);
    ApplicationService applicationDao = ctx.getBean(ApplicationService.class);
    OrganisationalUnitService ouDao = ctx.getBean(OrganisationalUnitService.class);
    List<String> animals = Unchecked.supplier(() -> readLines(getClass().getResourceAsStream("/app-names.txt"))).get();
    OrganisationalUnit[] organisationalUnits = ouDao.findAll().toArray(new OrganisationalUnit[0]);
    List<AppRegistrationRequest> registrationRequests = new ArrayList<>();
    for (int i = 0; i < NUM_APPS; i++) {
        String animal = randomPick(animals.toArray(new String[0])) + " - " + i;
        OrganisationalUnit organisationalUnit = randomPick(organisationalUnits);
        LifecyclePhase phase = rnd.nextInt(10) > 7 ? randomPick(LifecyclePhase.values()) : LifecyclePhase.PRODUCTION;
        Criticality businessCriticality = rnd.nextInt(10) > 7 ? randomPick(Criticality.values()) : Criticality.HIGH;
        AppRegistrationRequest app = ImmutableAppRegistrationRequest.builder().name(animal).assetCode("wltz-0" + i).description("All about " + animal).applicationKind(randomPick(ApplicationKind.values())).lifecyclePhase(phase).overallRating(randomPick(RagRating.R, RagRating.A, RagRating.A, RagRating.G, RagRating.G)).organisationalUnitId(organisationalUnit.id().get()).businessCriticality(businessCriticality).build();
        registrationRequests.add(app);
    }
    registrationRequests.forEach(a -> applicationDao.registerApp(a, "admin"));
    return null;
}
Also used : OrganisationalUnitService(org.finos.waltz.service.orgunit.OrganisationalUnitService) ArrayList(java.util.ArrayList) DSLContext(org.jooq.DSLContext) OrganisationalUnit(org.finos.waltz.model.orgunit.OrganisationalUnit) LifecyclePhase(org.finos.waltz.model.application.LifecyclePhase) ImmutableAppRegistrationRequest(org.finos.waltz.model.application.ImmutableAppRegistrationRequest) AppRegistrationRequest(org.finos.waltz.model.application.AppRegistrationRequest) ApplicationService(org.finos.waltz.service.application.ApplicationService) Criticality(org.finos.waltz.model.Criticality)

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