Search in sources :

Example 36 with DSLContext

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

the class SoftwareCatalogHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    SoftwareCatalogService softwareCatalogService = ctx.getBean(SoftwareCatalogService.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    EntityReference ref = ImmutableEntityReference.builder().kind(EntityKind.ORG_UNIT).id(20L).build();
    IdSelectionOptions options = ImmutableIdSelectionOptions.builder().entityReference(ref).scope(HierarchyQueryScope.CHILDREN).build();
    SoftwareSummaryStatistics stats = softwareCatalogService.findStatisticsForAppIdSelector(options);
    System.out.println("stats:" + stats);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) SoftwareCatalogService(com.khartec.waltz.service.software_catalog.SoftwareCatalogService) DSLContext(org.jooq.DSLContext) SoftwareSummaryStatistics(com.khartec.waltz.model.software_catalog.SoftwareSummaryStatistics)

Example 37 with DSLContext

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

the class SpecificationHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    PhysicalSpecificationDao physicalSpecificationDao = ctx.getBean(PhysicalSpecificationDao.class);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DSLContext(org.jooq.DSLContext) PhysicalSpecificationDao(com.khartec.waltz.data.physical_specification.PhysicalSpecificationDao)

Example 38 with DSLContext

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

the class UserHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    UserRoleService userRoleService = ctx.getBean(UserRoleService.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    int rc = dsl.insertInto(USER).set(USER.USER_NAME, "kamran").set(USER.PASSWORD, "1234").onDuplicateKeyIgnore().execute();
    System.out.println(rc);
// 
// ImmutableLoginRequest loginRequest = ImmutableLoginRequest.builder()
// .userName("dwatkins")
// .password("wrong")
// .build();
// 
// boolean authenticated = userService.authenticate(loginRequest);
// System.out.println(authenticated);
// 
// userRoleService.findAllUsers().forEach(System.out::println);
}
Also used : UserRoleService(com.khartec.waltz.service.user.UserRoleService) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DSLContext(org.jooq.DSLContext)

Example 39 with DSLContext

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

the class AppGenerator method main.

public static void main(String[] args) throws IOException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    ApplicationService applicationDao = ctx.getBean(ApplicationService.class);
    OrganisationalUnitService ouDao = ctx.getBean(OrganisationalUnitService.class);
    List<String> animals = IOUtilities.readLines(AppGenerator.class.getClassLoader().getResourceAsStream("animals.txt"));
    OrganisationalUnit[] organisationalUnits = ouDao.findAll().toArray(new OrganisationalUnit[0]);
    List<AppRegistrationRequest> registrationRequests = new ArrayList<>();
    for (int i = 0; i < 5000; 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);
    }
    dsl.deleteFrom(AUTHORITATIVE_SOURCE).execute();
    dsl.deleteFrom(APPLICATION).execute();
    registrationRequests.forEach(a -> applicationDao.registerApp(a, "admin"));
}
Also used : OrganisationalUnitService(com.khartec.waltz.service.orgunit.OrganisationalUnitService) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ArrayList(java.util.ArrayList) DSLContext(org.jooq.DSLContext) OrganisationalUnit(com.khartec.waltz.model.orgunit.OrganisationalUnit) LifecyclePhase(com.khartec.waltz.model.application.LifecyclePhase) AppRegistrationRequest(com.khartec.waltz.model.application.AppRegistrationRequest) ImmutableAppRegistrationRequest(com.khartec.waltz.model.application.ImmutableAppRegistrationRequest) ApplicationService(com.khartec.waltz.service.application.ApplicationService) Criticality(com.khartec.waltz.model.Criticality)

Example 40 with DSLContext

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

the class AssetCostGenerator method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    ApplicationService applicationService = ctx.getBean(ApplicationService.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    List<AssetCostRecord> appDevCosts = generateRecords(applicationService, "APPLICATION_DEVELOPMENT", 100_0000);
    List<AssetCostRecord> infraCosts = generateRecords(applicationService, "INFRASTRUCTURE", 5_000);
    dsl.deleteFrom(ASSET_COST).where(ASSET_COST.YEAR.eq(year)).and(ASSET_COST.PROVENANCE.eq(provenance)).execute();
    dsl.batchInsert(appDevCosts).execute();
    dsl.batchInsert(infraCosts).execute();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DSLContext(org.jooq.DSLContext) AssetCostRecord(com.khartec.waltz.schema.tables.records.AssetCostRecord) ApplicationService(com.khartec.waltz.service.application.ApplicationService)

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