Search in sources :

Example 31 with DSLContext

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

the class MsSqlSearchHarness method main.

public static void main(String[] args) {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    SqlServerAppSearch appSearch = new SqlServerAppSearch();
    EntitySearchOptions searchOptions = ImmutableEntitySearchOptions.builder().addEntityKinds(EntityKind.APPLICATION).userId("admin").limit(50).build();
    List<Application> results = appSearch.search(dsl, "sap", searchOptions);
    results.stream().filter(a -> a.entityLifecycleStatus() != EntityLifecycleStatus.REMOVED).forEach(a -> System.out.println(a.name() + " - " + a.lifecyclePhase()));
}
Also used : Application(com.khartec.waltz.model.application.Application) ImmutableEntitySearchOptions(com.khartec.waltz.model.entity_search.ImmutableEntitySearchOptions) List(java.util.List) SqlServerAppSearch(com.khartec.waltz.data.application.search.SqlServerAppSearch) DIConfiguration(com.khartec.waltz.service.DIConfiguration) DSLContext(org.jooq.DSLContext) EntitySearchOptions(com.khartec.waltz.model.entity_search.EntitySearchOptions) ApplicationContext(org.springframework.context.ApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityKind(com.khartec.waltz.model.EntityKind) EntityLifecycleStatus(com.khartec.waltz.model.EntityLifecycleStatus) ApplicationContext(org.springframework.context.ApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) SqlServerAppSearch(com.khartec.waltz.data.application.search.SqlServerAppSearch) ImmutableEntitySearchOptions(com.khartec.waltz.model.entity_search.ImmutableEntitySearchOptions) EntitySearchOptions(com.khartec.waltz.model.entity_search.EntitySearchOptions) DSLContext(org.jooq.DSLContext) Application(com.khartec.waltz.model.application.Application)

Example 32 with DSLContext

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

the class PersonHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    PersonDao personDao = ctx.getBean(PersonDao.class);
    int c = dsl.fetchCount(PERSON, PERSON.MANAGER_EMPLOYEE_ID.eq("").or(PERSON.MANAGER_EMPLOYEE_ID.isNull()));
    int c2 = dsl.fetchCount(DSL.selectDistinct(PERSON_HIERARCHY.MANAGER_ID).from(PERSON_HIERARCHY).where(PERSON_HIERARCHY.LEVEL.eq(1)));
    System.out.println(c);
    System.out.println(c2);
}
Also used : PersonDao(com.khartec.waltz.data.person.PersonDao) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DSLContext(org.jooq.DSLContext)

Example 33 with DSLContext

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

the class PhysicalSpecificationHarness method main.

public static void main(String[] args) throws ParseException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    PhysicalSpecificationSearchDao searcher = ctx.getBean(PhysicalSpecificationSearchDao.class);
    searcher.search("sap", EntitySearchOptions.mkForEntity(EntityKind.PHYSICAL_SPECIFICATION)).forEach(ps -> System.out.println(ps.name()));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) PhysicalSpecificationSearchDao(com.khartec.waltz.data.physical_specification.search.PhysicalSpecificationSearchDao) DSLContext(org.jooq.DSLContext)

Example 34 with DSLContext

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

the class ServerComplexityHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    OrganisationalUnitDao ouDao = ctx.getBean(OrganisationalUnitDao.class);
    ServerComplexityService serverService = ctx.getBean(ServerComplexityService.class);
    ComplexityRatingService complexityService = ctx.getBean(ComplexityRatingService.class);
    // EntityReference entityReference = EntityReference.mkRef(EntityKind.PERSON, 1);
    EntityReference entityReference = EntityReference.mkRef(EntityKind.PERSON, 63);
    List<ComplexityRating> complexity = FunctionUtilities.time("complexity", () -> complexityService.findForAppIdSelector(IdSelectionOptions.mkOpts(entityReference, HierarchyQueryScope.CHILDREN)));
}
Also used : OrganisationalUnitDao(com.khartec.waltz.data.orgunit.OrganisationalUnitDao) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ComplexityRatingService(com.khartec.waltz.service.complexity.ComplexityRatingService) ServerComplexityService(com.khartec.waltz.service.complexity.ServerComplexityService) EntityReference(com.khartec.waltz.model.EntityReference) DSLContext(org.jooq.DSLContext) ComplexityRating(com.khartec.waltz.model.complexity.ComplexityRating)

Example 35 with DSLContext

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

the class ServerHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    ServerInformationService serverInfoService = ctx.getBean(ServerInformationService.class);
    ServerInformationDao serverInfoDao = ctx.getBean(ServerInformationDao.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    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", () -> serverInfoService.findStatsForAppSelector(options));
    }
    String sql = "\n" + "select \n" + "  coalesce(\n" + "    sum(case [server_information].[is_virtual] when 1 then 1\n" + "                                               else 0\n" + "        end), \n" + "    0) [virtual_count], \n" + "  coalesce(\n" + "    sum(case [server_information].[is_virtual] when 1 then 0\n" + "                                               else 1\n" + "        end), \n" + "    0) [physical_count]\n" + "from [server_information]\n" + "where [server_information].[asset_code] in (\n" + "  select [application].[asset_code]\n" + "  from [application]\n" + "  where [application].[id] in (\n" + "    select [application].[id]\n" + "    from [application]\n" + "    where [application].[organisational_unit_id] in (\n" + "      130, 260, 70, 200, 10, 140, 270, 80, 210, 20, 150, 280, 90, 220, 30, 160, \n" + "      290, 100, 230, 40, 170, 300, 110, 240, 50, 180, 120, 250, 60, 190\n" + "    )\n" + "  )\n" + ");\n";
    FunctionUtilities.time("raw q", () -> {
        dsl.connection(conn -> {
            PreparedStatement stmt = conn.prepareStatement(sql);
            ResultSet rs = stmt.executeQuery();
            while (rs.next()) {
                System.out.println(rs.getBigDecimal(1) + " - " + rs.getBigDecimal(2));
            }
        });
        return null;
    });
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ServerInformationDao(com.khartec.waltz.data.server_information.ServerInformationDao) ServerInformationService(com.khartec.waltz.service.server_information.ServerInformationService) ResultSet(java.sql.ResultSet) DSLContext(org.jooq.DSLContext) PreparedStatement(java.sql.PreparedStatement)

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