Search in sources :

Example 1 with ChangeLogRecord

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

the class ChangeLogGenerator method create.

@Override
public Map<String, Integer> create(ApplicationContext ctx) {
    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 -> {
        Long appId = randomPick(appIds);
        LocalDateTime when = now().minus(randomIntBetween(0, 365), ChronoUnit.DAYS);
        return Stream.of(mkChangeLog(appId, email, when), mkChangeLog(appId, email, when), mkChangeLog(randomPick(appIds), email, when), mkChangeLog(appId, randomPick(emails), when));
    }).collect(toSet());
    dsl.batchInsert(records).execute();
    log("Inserted " + records.size() + " change log entries");
    return null;
}
Also used : APPLICATION(org.finos.waltz.schema.tables.Application.APPLICATION) EntityKind(org.finos.waltz.model.EntityKind) ChangeLogRecord(org.finos.waltz.schema.tables.records.ChangeLogRecord) Timestamp(java.sql.Timestamp) RandomUtilities.randomIntBetween(org.finos.waltz.common.RandomUtilities.randomIntBetween) LocalDateTime(java.time.LocalDateTime) Set(java.util.Set) Severity(org.finos.waltz.model.Severity) ApplicationContext(org.springframework.context.ApplicationContext) CHANGE_LOG(org.finos.waltz.schema.tables.ChangeLog.CHANGE_LOG) Tuple2(org.jooq.lambda.tuple.Tuple2) List(java.util.List) ChronoUnit(java.time.temporal.ChronoUnit) Stream(java.util.stream.Stream) Tuple.tuple(org.jooq.lambda.tuple.Tuple.tuple) Map(java.util.Map) RandomUtilities.randomPick(org.finos.waltz.common.RandomUtilities.randomPick) SetUtilities(org.finos.waltz.common.SetUtilities) DSLContext(org.jooq.DSLContext) LocalDateTime.now(java.time.LocalDateTime.now) Collectors.toSet(java.util.stream.Collectors.toSet) PERSON(org.finos.waltz.schema.tables.Person.PERSON) LocalDateTime(java.time.LocalDateTime) DSLContext(org.jooq.DSLContext) ChangeLogRecord(org.finos.waltz.schema.tables.records.ChangeLogRecord)

Example 2 with ChangeLogRecord

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

the class ChangeLogGenerator method mkChangeLog.

private static ChangeLogRecord mkChangeLog(long appId, String email, LocalDateTime when) {
    Tuple2<String, EntityKind> messageTemplate = randomPick(messages);
    ChangeLogRecord record = new ChangeLogRecord();
    record.setMessage(messageTemplate.v1);
    record.setParentId(appId);
    record.setParentKind(EntityKind.APPLICATION.name());
    record.setChildKind(messageTemplate.v2.name());
    record.setUserId(email);
    record.setSeverity(Severity.INFORMATION.name());
    record.setCreatedAt(Timestamp.valueOf(when));
    return record;
}
Also used : ChangeLogRecord(org.finos.waltz.schema.tables.records.ChangeLogRecord) EntityKind(org.finos.waltz.model.EntityKind)

Aggregations

EntityKind (org.finos.waltz.model.EntityKind)2 ChangeLogRecord (org.finos.waltz.schema.tables.records.ChangeLogRecord)2 Timestamp (java.sql.Timestamp)1 LocalDateTime (java.time.LocalDateTime)1 LocalDateTime.now (java.time.LocalDateTime.now)1 ChronoUnit (java.time.temporal.ChronoUnit)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 Stream (java.util.stream.Stream)1 RandomUtilities.randomIntBetween (org.finos.waltz.common.RandomUtilities.randomIntBetween)1 RandomUtilities.randomPick (org.finos.waltz.common.RandomUtilities.randomPick)1 SetUtilities (org.finos.waltz.common.SetUtilities)1 Severity (org.finos.waltz.model.Severity)1 APPLICATION (org.finos.waltz.schema.tables.Application.APPLICATION)1 CHANGE_LOG (org.finos.waltz.schema.tables.ChangeLog.CHANGE_LOG)1 PERSON (org.finos.waltz.schema.tables.Person.PERSON)1 DSLContext (org.jooq.DSLContext)1 Tuple.tuple (org.jooq.lambda.tuple.Tuple.tuple)1