Search in sources :

Example 1 with EntityStatisticDefinitionDao

use of org.finos.waltz.data.entity_statistic.EntityStatisticDefinitionDao in project waltz by khartec.

the class EntityStatisticGenerator method create.

public Map<String, Integer> create(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.findAll().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();
    log("deleted existing statistics (provenance: '" + SAMPLE_DATA_PROVENANCE + "')");
    dsl.update(ENTITY_STATISTIC_VALUE).set(ENTITY_STATISTIC_VALUE.CURRENT, false).where(ENTITY_STATISTIC_VALUE.PROVENANCE.eq("DEMO")).execute();
    log("marked existing statistic values as non-current (provenance: '" + SAMPLE_DATA_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);
    log("Rebuilt entity hierarchy");
    return null;
}
Also used : OrganisationalUnitDao(org.finos.waltz.data.orgunit.OrganisationalUnitDao) EntityStatisticDefinitionDao(org.finos.waltz.data.entity_statistic.EntityStatisticDefinitionDao) EntityStatisticValueDao(org.finos.waltz.data.entity_statistic.EntityStatisticValueDao) EntityHierarchyService(org.finos.waltz.service.entity_hierarchy.EntityHierarchyService) DSLContext(org.jooq.DSLContext) ApplicationDao(org.finos.waltz.data.application.ApplicationDao) OrganisationalUnit(org.finos.waltz.model.orgunit.OrganisationalUnit) Application(org.finos.waltz.model.application.Application)

Aggregations

ApplicationDao (org.finos.waltz.data.application.ApplicationDao)1 EntityStatisticDefinitionDao (org.finos.waltz.data.entity_statistic.EntityStatisticDefinitionDao)1 EntityStatisticValueDao (org.finos.waltz.data.entity_statistic.EntityStatisticValueDao)1 OrganisationalUnitDao (org.finos.waltz.data.orgunit.OrganisationalUnitDao)1 Application (org.finos.waltz.model.application.Application)1 OrganisationalUnit (org.finos.waltz.model.orgunit.OrganisationalUnit)1 EntityHierarchyService (org.finos.waltz.service.entity_hierarchy.EntityHierarchyService)1 DSLContext (org.jooq.DSLContext)1