Search in sources :

Example 1 with ChangeLogRecord

use of com.khartec.waltz.schema.tables.records.ChangeLogRecord in project waltz by khartec.

the class ChangeLogGenerator method mkChangeLog.

private static ChangeLogRecord mkChangeLog(long appId, String email) {
    ChangeLogRecord record = new ChangeLogRecord();
    record.setMessage("Dummy");
    record.setParentId(appId);
    record.setParentKind(EntityKind.APPLICATION.name());
    record.setUserId(email);
    record.setSeverity(Severity.INFORMATION.name());
    return record;
}
Also used : ChangeLogRecord(com.khartec.waltz.schema.tables.records.ChangeLogRecord)

Example 2 with ChangeLogRecord

use of com.khartec.waltz.schema.tables.records.ChangeLogRecord 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

ChangeLogRecord (com.khartec.waltz.schema.tables.records.ChangeLogRecord)2 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 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