Search in sources :

Example 96 with DSLContext

use of org.jooq.DSLContext in project waltz by khartec.

the class DataFlowHarness method main.

public static void main(String[] args) throws ParseException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    LogicalFlowService service = ctx.getBean(LogicalFlowService.class);
    LogicalFlowDao dao = ctx.getBean(LogicalFlowDao.class);
    LogicalFlowIdSelectorFactory factory = ctx.getBean(LogicalFlowIdSelectorFactory.class);
    IdSelectionOptions options = IdSelectionOptions.mkOpts(EntityReference.mkRef(EntityKind.ORG_UNIT, 5000), HierarchyQueryScope.CHILDREN);
    Select<Record1<Long>> selector = factory.apply(options);
    System.out.println(selector);
    List<LogicalFlow> flows = dao.findBySelector(selector);
    flows.forEach(System.out::println);
    // by data type
    EntityReference dataType = EntityReference.mkRef(EntityKind.DATA_TYPE, 6000);
    IdSelectionOptions dataTypeOptions = IdSelectionOptions.mkOpts(dataType, HierarchyQueryScope.CHILDREN);
    List<LogicalFlow> byDataTypeFlows = service.findBySelector(dataTypeOptions);
    byDataTypeFlows.forEach(System.out::println);
    System.out.println(byDataTypeFlows.size());
}
Also used : LogicalFlowIdSelectorFactory(com.khartec.waltz.data.logical_flow.LogicalFlowIdSelectorFactory) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) LogicalFlowService(com.khartec.waltz.service.logical_flow.LogicalFlowService) LogicalFlow(com.khartec.waltz.model.logical_flow.LogicalFlow) EntityReference(com.khartec.waltz.model.EntityReference) DSLContext(org.jooq.DSLContext) LogicalFlowDao(com.khartec.waltz.data.logical_flow.LogicalFlowDao) IdSelectionOptions(com.khartec.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 97 with DSLContext

use of org.jooq.DSLContext in project waltz by khartec.

the class DataTypeUsageHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    DataTypeUsageDao dao = ctx.getBean(DataTypeUsageDao.class);
    DataTypeUsageService svc = ctx.getBean(DataTypeUsageService.class);
    long st = System.currentTimeMillis();
    dao.recalculateForAllApplications();
    List<DataTypeUsage> dtUsages = svc.findForDataTypeSelector(mkOpts(mkRef(EntityKind.DATA_TYPE, 3000), HierarchyQueryScope.CHILDREN));
    System.out.println("Data Type usages: " + dtUsages.size());
    List<DataTypeUsage> actorUsages = svc.findForEntity(mkRef(EntityKind.ACTOR, 16L));
    System.out.println("Actor usages: " + actorUsages.size());
    System.out.println("Took " + (System.currentTimeMillis() - st));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DataTypeUsage(com.khartec.waltz.model.data_type_usage.DataTypeUsage) DSLContext(org.jooq.DSLContext) DataTypeUsageDao(com.khartec.waltz.data.data_type_usage.DataTypeUsageDao) DataTypeUsageService(com.khartec.waltz.service.usage_info.DataTypeUsageService)

Example 98 with DSLContext

use of org.jooq.DSLContext in project waltz by khartec.

the class DatabaseHarness method main.

public static void main(String[] args) throws ParseException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DatabaseInformationService databaseInfoService = ctx.getBean(DatabaseInformationService.class);
    DatabaseInformationDao databaseDao = ctx.getBean(DatabaseInformationDao.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    /*
        List<DatabaseInformation> dbs = databaseDao.findByApplicationId(801L);
        System.out.println(dbs.size());


        List<Tally<String>> eolCounts = calculateStringTallies(
                dsl,
                DATABASE_INFORMATION,
                DSL.when(DATABASE_INFORMATION.END_OF_LIFE_DATE.lt(DSL.currentDate()), DSL.inline(EndOfLifeStatus.END_OF_LIFE.name()))
                        .otherwise(DSL.inline(EndOfLifeStatus.NOT_END_OF_LIFE.name())),
                DSL.trueCondition());

        System.out.println(eolCounts);
        */
    IdSelectionOptions options = ImmutableIdSelectionOptions.builder().entityReference(ImmutableEntityReference.builder().kind(EntityKind.ORG_UNIT).id(10).build()).scope(HierarchyQueryScope.CHILDREN).build();
    for (int i = 0; i < 5; i++) {
        HarnessUtilities.time("stats", () -> databaseInfoService.findStatsForAppIdSelector(options));
    }
}
Also used : DatabaseInformationDao(com.khartec.waltz.data.database_information.DatabaseInformationDao) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DSLContext(org.jooq.DSLContext) DatabaseInformationService(com.khartec.waltz.service.database_information.DatabaseInformationService)

Example 99 with DSLContext

use of org.jooq.DSLContext in project waltz by khartec.

the class DrillGridDefinitionHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    DrillGridDefinitionDao dao = ctx.getBean(DrillGridDefinitionDao.class);
    dao.findAll().stream().forEach(System.out::println);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DSLContext(org.jooq.DSLContext) DrillGridDefinitionDao(com.khartec.waltz.data.drill_grid.DrillGridDefinitionDao)

Example 100 with DSLContext

use of org.jooq.DSLContext in project waltz by khartec.

the class LogicalFlowDecoratorRatingsServiceHarness method main.

public static void main(String[] args) throws SQLException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    AuthoritativeSourceService authoritativeSourceService = ctx.getBean(AuthoritativeSourceService.class);
    List<AuthoritativeSource> 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(com.khartec.waltz.service.orgunit.OrganisationalUnitService) OrganisationalUnitDao(com.khartec.waltz.data.orgunit.OrganisationalUnitDao) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityHierarchyService(com.khartec.waltz.service.entity_hierarchy.EntityHierarchyService) Node(com.khartec.waltz.common.hierarchy.Node) FlatNode(com.khartec.waltz.common.hierarchy.FlatNode) AuthoritativeSource(com.khartec.waltz.model.authoritativesource.AuthoritativeSource) DSLContext(org.jooq.DSLContext) AuthoritativeSourceService(com.khartec.waltz.service.authoritative_source.AuthoritativeSourceService) OrganisationalUnit(com.khartec.waltz.model.orgunit.OrganisationalUnit) FlatNode(com.khartec.waltz.common.hierarchy.FlatNode)

Aggregations

DSLContext (org.jooq.DSLContext)109 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)55 Connection (java.sql.Connection)23 SQLException (java.sql.SQLException)17 List (java.util.List)17 DIConfiguration (com.khartec.waltz.service.DIConfiguration)14 Collectors (java.util.stream.Collectors)14 EntityKind (com.khartec.waltz.model.EntityKind)11 ArrayList (java.util.ArrayList)9 DSL (org.jooq.impl.DSL)9 EntityReference (com.khartec.waltz.model.EntityReference)8 Timestamp (java.sql.Timestamp)8 Random (java.util.Random)8 IntStream (java.util.stream.IntStream)8 Application (com.khartec.waltz.model.application.Application)7 LogicalFlowDao (com.khartec.waltz.data.logical_flow.LogicalFlowDao)6 OrganisationalUnit (com.khartec.waltz.model.orgunit.OrganisationalUnit)6 Field (org.jooq.Field)6 Record1 (org.jooq.Record1)6 Test (org.junit.Test)6