Search in sources :

Example 1 with CHANGE_LOG

use of com.khartec.waltz.schema.tables.ChangeLog.CHANGE_LOG in project waltz by khartec.

the class ChangeLogGenerator method main.

public static void main(String[] args) {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    // get applications and emails
    List<Long> appIds = dsl.select(APPLICATION.ID).from(APPLICATION).fetch(APPLICATION.ID);
    List<String> emails = dsl.select(PERSON.EMAIL).from(PERSON).fetch(PERSON.EMAIL);
    Set<ChangeLogRecord> records = emails.stream().flatMap(email -> Stream.of(mkChangeLog(randomPick(appIds), email), mkChangeLog(randomPick(appIds), randomPick(emails)))).collect(toSet());
    dsl.deleteFrom(CHANGE_LOG).execute();
    dsl.batchInsert(records).execute();
    System.out.println("Inserted " + records.size() + " change log entries");
}
Also used : ChangeLogRecord(com.khartec.waltz.schema.tables.records.ChangeLogRecord) Set(java.util.Set) PERSON(com.khartec.waltz.schema.tables.Person.PERSON) Severity(com.khartec.waltz.model.Severity) ApplicationContext(org.springframework.context.ApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityKind(com.khartec.waltz.model.EntityKind) ListUtilities.randomPick(com.khartec.waltz.common.ListUtilities.randomPick) List(java.util.List) Stream(java.util.stream.Stream) DIConfiguration(com.khartec.waltz.service.DIConfiguration) DSLContext(org.jooq.DSLContext) APPLICATION(com.khartec.waltz.schema.tables.Application.APPLICATION) CHANGE_LOG(com.khartec.waltz.schema.tables.ChangeLog.CHANGE_LOG) Collectors.toSet(java.util.stream.Collectors.toSet) ApplicationContext(org.springframework.context.ApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DSLContext(org.jooq.DSLContext) ChangeLogRecord(com.khartec.waltz.schema.tables.records.ChangeLogRecord)

Aggregations

ListUtilities.randomPick (com.khartec.waltz.common.ListUtilities.randomPick)1 EntityKind (com.khartec.waltz.model.EntityKind)1 Severity (com.khartec.waltz.model.Severity)1 APPLICATION (com.khartec.waltz.schema.tables.Application.APPLICATION)1 CHANGE_LOG (com.khartec.waltz.schema.tables.ChangeLog.CHANGE_LOG)1 PERSON (com.khartec.waltz.schema.tables.Person.PERSON)1 ChangeLogRecord (com.khartec.waltz.schema.tables.records.ChangeLogRecord)1 DIConfiguration (com.khartec.waltz.service.DIConfiguration)1 List (java.util.List)1 Set (java.util.Set)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 Stream (java.util.stream.Stream)1 DSLContext (org.jooq.DSLContext)1 ApplicationContext (org.springframework.context.ApplicationContext)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1