use of org.finos.waltz.jobs.tools.resolvers.OrgNameToIdResolver 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();
}
Aggregations