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;
}
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;
}
Aggregations