Search in sources :

Example 1 with ChangeSetRecord

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;
}
Also used : LocalDateTime(java.time.LocalDateTime) ChangeSetRecord(org.finos.waltz.schema.tables.records.ChangeSetRecord) ChangeSetRecord(org.finos.waltz.schema.tables.records.ChangeSetRecord) Arrays(java.util.Arrays) EntityKind(org.finos.waltz.model.EntityKind) Timestamp(java.sql.Timestamp) LocalDateTime(java.time.LocalDateTime) Random(java.util.Random) ApplicationContext(org.springframework.context.ApplicationContext) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) RandomUtilities(org.finos.waltz.common.RandomUtilities) List(java.util.List) INVOLVEMENT(org.finos.waltz.schema.tables.Involvement.INVOLVEMENT) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CHANGE_INITIATIVE(org.finos.waltz.schema.tables.ChangeInitiative.CHANGE_INITIATIVE) Map(java.util.Map) RandomUtilities.randomPick(org.finos.waltz.common.RandomUtilities.randomPick) CHANGE_SET(org.finos.waltz.schema.tables.ChangeSet.CHANGE_SET) DSLContext(org.jooq.DSLContext) EntityLifecycleStatus(org.finos.waltz.model.EntityLifecycleStatus) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DSLContext(org.jooq.DSLContext)

Aggregations

String.format (java.lang.String.format)1 Timestamp (java.sql.Timestamp)1 LocalDateTime (java.time.LocalDateTime)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 Random (java.util.Random)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Collectors (java.util.stream.Collectors)1 RandomUtilities (org.finos.waltz.common.RandomUtilities)1 RandomUtilities.randomPick (org.finos.waltz.common.RandomUtilities.randomPick)1 EntityKind (org.finos.waltz.model.EntityKind)1 EntityLifecycleStatus (org.finos.waltz.model.EntityLifecycleStatus)1 CHANGE_INITIATIVE (org.finos.waltz.schema.tables.ChangeInitiative.CHANGE_INITIATIVE)1 CHANGE_SET (org.finos.waltz.schema.tables.ChangeSet.CHANGE_SET)1 INVOLVEMENT (org.finos.waltz.schema.tables.Involvement.INVOLVEMENT)1 ChangeSetRecord (org.finos.waltz.schema.tables.records.ChangeSetRecord)1 DSLContext (org.jooq.DSLContext)1 ApplicationContext (org.springframework.context.ApplicationContext)1