use of org.jooq.lambda.tuple.Tuple4 in project waltz by khartec.
the class PersonResolver method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIBaseConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
InvolvementNameToIdResolver involvementNameToIdResolver = new InvolvementNameToIdResolver(dsl);
PersonNameToEmpIdResolver personNameToEmpIdResolver = new PersonNameToEmpIdResolver(dsl);
OrgNameToIdResolver orgNameToIdResolver = new OrgNameToIdResolver(dsl);
Siphon<Tuple4<String, String, Optional<Long>, Optional<String>>> noOrgSiphon = mkSiphon(t -> !t.v3.isPresent());
Siphon<Tuple4<String, String, Optional<Long>, Optional<String>>> noPersonSiphon = mkSiphon(t -> !t.v4.isPresent());
Set<Tuple3<Long, String, Long>> orgEmpInvTuples = involvementNameToIdResolver.resolve(involvementKindName).map(involvementKindId -> data.stream().flatMap(t -> Stream.of(t.v2.split(" / ")).map(name -> tuple(t.v1, name))).distinct().map(t -> t.concat(orgNameToIdResolver.resolve(t.v1))).map(t -> t.concat(personNameToEmpIdResolver.resolve(t.v2))).filter(noOrgSiphon).filter(noPersonSiphon).map(t -> t.skip2().map1(// empId
Optional::get).map2(// orgId
Optional::get).concat(involvementKindId)).collect(Collectors.toSet())).orElseThrow(() -> new IllegalArgumentException(format("Cannot find involvement kind: %s", involvementKindName)));
dump("No Org", noOrgSiphon, t -> t.v1);
dump("No Person", noPersonSiphon, t -> t.v2);
Set<InvolvementRecord> records = map(orgEmpInvTuples, t -> new InvolvementRecord(EntityKind.ORG_UNIT.name(), t.v1, t.v2, provenance, t.v3, true));
dsl.batchInsert(records).execute();
}
use of org.jooq.lambda.tuple.Tuple4 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());
}
Aggregations