use of org.finos.waltz.schema.tables.records.ChangeInitiativeRecord in project waltz by khartec.
the class ChangeInitiativeGenerator method createCiRecords.
private List<ChangeInitiativeRecord> createCiRecords(List<Long> ouIds) {
AtomicLong idCtr = new AtomicLong();
return IntStream.range(0, NUM_CHANGE_INITIATIVES).boxed().flatMap(i -> {
long initiativeId = idCtr.incrementAndGet();
Tuple4<Long, ChangeInitiativeKind, Long, String> initiative = tuple(initiativeId, INITIATIVE, null, mkName());
Stream<Tuple4<Long, ChangeInitiativeKind, Long, String>> children = IntStream.range(0, RND.nextInt(4)).boxed().flatMap(x -> {
long programmeId = idCtr.incrementAndGet();
Stream<Tuple4<Long, ChangeInitiativeKind, Long, String>> programmes = Stream.of(tuple(programmeId, PROGRAMME, initiativeId, mkName()));
Stream<Tuple4<Long, ChangeInitiativeKind, Long, String>> projects = IntStream.range(0, RND.nextInt(4)).boxed().map(y -> tuple(idCtr.incrementAndGet(), PROJECT, programmeId, mkName()));
return Stream.concat(programmes, projects);
});
return Stream.concat(Stream.of(initiative), children);
}).map(t -> buildChangeInitiativeRecord(t, ouIds)).collect(toList());
}
use of org.finos.waltz.schema.tables.records.ChangeInitiativeRecord in project waltz by khartec.
the class ChangeInitiativeGenerator method create.
@Override
public Map<String, Integer> create(ApplicationContext ctx) {
DSLContext dsl = getDsl(ctx);
List<Long> appIds = loadAllIds(dsl, APPLICATION.ID);
List<Long> ouIds = loadAllIds(dsl, ORGANISATIONAL_UNIT.ID);
List<Long> groupIds = loadAllIds(dsl, APPLICATION_GROUP.ID);
List<String> employeeIds = loadAllIds(dsl, PERSON.EMPLOYEE_ID);
List<ChangeInitiativeRecord> ciRecords = createCiRecords(ouIds);
dsl.batchInsert(ciRecords).execute();
LOG.info("Created: {} ci records", ciRecords.size());
List<Long> ciIds = loadAllIds(dsl, CHANGE_INITIATIVE.ID, CHANGE_INITIATIVE.PROVENANCE.eq(SAMPLE_DATA_PROVENANCE));
List<TableRecord<?>> relationships = StreamUtilities.concat(buildPersonLinks(ciIds, employeeIds), buildEntityRelationships(EntityKind.APP_GROUP, "RELATES_TO", ciIds, groupIds, 0.5, 2), buildEntityRelationships(EntityKind.APPLICATION, "SUPPORTS", ciIds, appIds, 0.6, 3)).collect(toList());
LOG.info("Storing {} relationships", relationships.size());
dsl.batchInsert(relationships).execute();
EntityHierarchyService ehSvc = ctx.getBean(EntityHierarchyService.class);
ehSvc.buildFor(EntityKind.CHANGE_INITIATIVE);
return null;
}
use of org.finos.waltz.schema.tables.records.ChangeInitiativeRecord in project waltz by khartec.
the class ChangeInitiativeGenerator method buildChangeInitiativeRecord.
private static ChangeInitiativeRecord buildChangeInitiativeRecord(Tuple4<Long, ChangeInitiativeKind, Long, String> t, List<Long> ouIds) {
ChangeInitiativeRecord record = new ChangeInitiativeRecord();
record.setDescription(t.v4);
record.setName(t.v4);
record.setProvenance("dummy");
record.setExternalId("EXT" + t.v1 + (t.v3 != null ? "_" + t.v3 : ""));
record.setKind(t.v2.name());
record.setLifecyclePhase(randomPick(LifecyclePhase.values()).name());
record.setId(t.v1);
record.setParentId(t.v3);
record.setStartDate(new Date(Instant.now().toEpochMilli()));
record.setEndDate(new Date(Instant.now().plusSeconds(RND.nextInt(60 * 60 * 24 * 365 * 2)).toEpochMilli()));
record.setOrganisationalUnitId(randomPick(ouIds));
record.setProvenance(SAMPLE_DATA_PROVENANCE);
return record;
}
Aggregations