Search in sources :

Example 1 with ApplicationDao

use of com.khartec.waltz.data.application.ApplicationDao in project waltz by khartec.

the class EntityStatisticGenerator method apply.

@Override
public Map<String, Integer> apply(ApplicationContext context) {
    DSLContext dsl = context.getBean(DSLContext.class);
    ApplicationDao applicationDao = context.getBean(ApplicationDao.class);
    OrganisationalUnitDao organisationalUnitDao = context.getBean(OrganisationalUnitDao.class);
    EntityStatisticValueDao valueDao = context.getBean(EntityStatisticValueDao.class);
    EntityStatisticDefinitionDao definitionDao = context.getBean(EntityStatisticDefinitionDao.class);
    EntityHierarchyService entityHierarchyService = context.getBean(EntityHierarchyService.class);
    Application[] applications = applicationDao.getAll().toArray(new Application[0]);
    OrganisationalUnit[] orgUnits = organisationalUnitDao.findAll().toArray(new OrganisationalUnit[0]);
    dsl.deleteFrom(ENTITY_STATISTIC_DEFINITION).where(ENTITY_STATISTIC_DEFINITION.PROVENANCE.eq("DEMO")).execute();
    System.out.println("deleted existing statistics (provenance: '" + PROVENANCE + "')");
    dsl.update(ENTITY_STATISTIC_VALUE).set(ENTITY_STATISTIC_VALUE.CURRENT, false).where(ENTITY_STATISTIC_VALUE.PROVENANCE.eq("DEMO")).execute();
    System.out.println("marked existing statistic values as non-current (provenance: '" + PROVENANCE + "')");
    definitionDao.insert(SDLC);
    definitionDao.insert(SDLC_TECH);
    definitionDao.insert(SDLC_PROCESS);
    definitionDao.insert(SDLC_JIRA);
    definitionDao.insert(SDLC_SVN);
    definitionDao.insert(SDLC_WIKI);
    definitionDao.insert(AUDIT);
    definitionDao.insert(SERVER_COUNT);
    definitionDao.insert(PRE_COMPUTED);
    createAdoptionStatsFor(SDLC_TECH, applications, valueDao);
    createAdoptionStatsFor(SDLC_PROCESS, applications, valueDao);
    createAdoptionStatsFor(SDLC_JIRA, applications, valueDao);
    createAdoptionStatsFor(SDLC_SVN, applications, valueDao);
    createAdoptionStatsFor(SDLC_WIKI, applications, valueDao);
    createIntStatsFor(AUDIT, applications, valueDao, 20, failIfPositiveFn);
    createIntStatsFor(SDLC, applications, valueDao, 20, failIfPositiveFn);
    createIntStatsFor(SERVER_COUNT, applications, valueDao, 20, (x, y) -> "VIRTUAL");
    createIntStatsFor(SERVER_COUNT, applications, valueDao, 20, (x, y) -> "BARE_METAL");
    createPreComputedStatsFor(PRE_COMPUTED, orgUnits, valueDao);
    entityHierarchyService.buildFor(EntityKind.ENTITY_STATISTIC);
    System.out.println("Rebuilt entity hierarchy");
    return null;
}
Also used : OrganisationalUnitDao(com.khartec.waltz.data.orgunit.OrganisationalUnitDao) EntityStatisticDefinitionDao(com.khartec.waltz.data.entity_statistic.EntityStatisticDefinitionDao) EntityStatisticValueDao(com.khartec.waltz.data.entity_statistic.EntityStatisticValueDao) EntityHierarchyService(com.khartec.waltz.service.entity_hierarchy.EntityHierarchyService) DSLContext(org.jooq.DSLContext) ApplicationDao(com.khartec.waltz.data.application.ApplicationDao) OrganisationalUnit(com.khartec.waltz.model.orgunit.OrganisationalUnit) Application(com.khartec.waltz.model.application.Application)

Example 2 with ApplicationDao

use of com.khartec.waltz.data.application.ApplicationDao in project waltz by khartec.

the class SoftwareUsageGenerator method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    SoftwarePackageDao softwarePackageDao = ctx.getBean(SoftwarePackageDao.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    ApplicationDao applicationDao = ctx.getBean(ApplicationDao.class);
    List<SoftwarePackage> allSoftware = softwarePackageDao.findAll();
    List<SoftwareUsageRecord> records = applicationDao.getAll().stream().flatMap(app -> IntStream.range(0, new Random().nextInt(4) + 1).mapToObj(x -> new SoftwareUsageRecord(app.id().get(), ListUtilities.randomPick(allSoftware).id().get(), "waltz-random"))).collect(Collectors.toList());
    System.out.println("-- deleting all software usages");
    dsl.deleteFrom(SOFTWARE_USAGE).where(SOFTWARE_USAGE.PROVENANCE.eq("waltz-sample")).execute();
    System.out.println(" -- storing usages ( " + records.size() + " )");
    dsl.batchInsert(records).execute();
    System.out.println(" -- done");
}
Also used : SoftwarePackageDao(com.khartec.waltz.data.software_catalog.SoftwarePackageDao) IntStream(java.util.stream.IntStream) SoftwarePackageDao(com.khartec.waltz.data.software_catalog.SoftwarePackageDao) ApplicationDao(com.khartec.waltz.data.application.ApplicationDao) SoftwareUsageRecord(com.khartec.waltz.schema.tables.records.SoftwareUsageRecord) ListUtilities(com.khartec.waltz.common.ListUtilities) Random(java.util.Random) Collectors(java.util.stream.Collectors) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) List(java.util.List) DIConfiguration(com.khartec.waltz.service.DIConfiguration) SoftwarePackage(com.khartec.waltz.model.software_catalog.SoftwarePackage) DSLContext(org.jooq.DSLContext) SOFTWARE_USAGE(com.khartec.waltz.schema.tables.SoftwareUsage.SOFTWARE_USAGE) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Random(java.util.Random) DSLContext(org.jooq.DSLContext) SoftwareUsageRecord(com.khartec.waltz.schema.tables.records.SoftwareUsageRecord) ApplicationDao(com.khartec.waltz.data.application.ApplicationDao) SoftwarePackage(com.khartec.waltz.model.software_catalog.SoftwarePackage)

Aggregations

ApplicationDao (com.khartec.waltz.data.application.ApplicationDao)2 DSLContext (org.jooq.DSLContext)2 ListUtilities (com.khartec.waltz.common.ListUtilities)1 EntityStatisticDefinitionDao (com.khartec.waltz.data.entity_statistic.EntityStatisticDefinitionDao)1 EntityStatisticValueDao (com.khartec.waltz.data.entity_statistic.EntityStatisticValueDao)1 OrganisationalUnitDao (com.khartec.waltz.data.orgunit.OrganisationalUnitDao)1 SoftwarePackageDao (com.khartec.waltz.data.software_catalog.SoftwarePackageDao)1 Application (com.khartec.waltz.model.application.Application)1 OrganisationalUnit (com.khartec.waltz.model.orgunit.OrganisationalUnit)1 SoftwarePackage (com.khartec.waltz.model.software_catalog.SoftwarePackage)1 SOFTWARE_USAGE (com.khartec.waltz.schema.tables.SoftwareUsage.SOFTWARE_USAGE)1 SoftwareUsageRecord (com.khartec.waltz.schema.tables.records.SoftwareUsageRecord)1 DIConfiguration (com.khartec.waltz.service.DIConfiguration)1 EntityHierarchyService (com.khartec.waltz.service.entity_hierarchy.EntityHierarchyService)1 List (java.util.List)1 Random (java.util.Random)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1