use of org.finos.waltz.schema.tables.records.ChangeSetRecord in project waltz by khartec.
the class ChangeSetGenerator method create.
@Override
public Map<String, Integer> create(ApplicationContext ctx) {
DSLContext dsl = getDsl(ctx);
LocalDateTime now = LocalDateTime.now();
List<Long> ciIds = dsl.select(CHANGE_INITIATIVE.ID).from(CHANGE_INITIATIVE).fetch(CHANGE_INITIATIVE.ID);
AtomicInteger counter = new AtomicInteger(0);
List<ChangeSetRecord> groupRecords = Arrays.stream(names).map(n -> {
ChangeSetRecord record = dsl.newRecord(CHANGE_SET);
record.setParentEntityKind(EntityKind.CHANGE_INITIATIVE.name());
record.setParentEntityId(randomPick(ciIds));
record.setPlannedDate(Timestamp.valueOf(now));
record.setEntityLifecycleStatus(EntityLifecycleStatus.ACTIVE.name());
record.setName(n);
record.setDescription(format("%s : Description of %s", SAMPLE_DATA_PROVENANCE, n));
record.setLastUpdatedAt(Timestamp.valueOf(now));
record.setLastUpdatedBy("admin");
record.setExternalId(format("change-set-ext-%s", counter.addAndGet(1)));
record.setProvenance(SAMPLE_DATA_PROVENANCE);
return record;
}).collect(Collectors.toList());
dsl.batchStore(groupRecords).execute();
return null;
}
Aggregations