Search in sources :

Example 1 with InvolvementNameToIdResolver

use of org.finos.waltz.jobs.tools.resolvers.InvolvementNameToIdResolver 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();
}
Also used : DebugUtilities.dump(org.finos.waltz.common.DebugUtilities.dump) InvolvementNameToIdResolver(org.finos.waltz.jobs.tools.resolvers.InvolvementNameToIdResolver) EntityKind(org.finos.waltz.model.EntityKind) Set(java.util.Set) StreamUtilities.mkSiphon(org.finos.waltz.common.StreamUtilities.mkSiphon) PersonNameToEmpIdResolver(org.finos.waltz.jobs.tools.resolvers.PersonNameToEmpIdResolver) DIBaseConfiguration(org.finos.waltz.service.DIBaseConfiguration) Collectors(java.util.stream.Collectors) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) String.format(java.lang.String.format) InvolvementRecord(org.finos.waltz.schema.tables.records.InvolvementRecord) SetUtilities.map(org.finos.waltz.common.SetUtilities.map) Tuple2(org.jooq.lambda.tuple.Tuple2) List(java.util.List) Tuple3(org.jooq.lambda.tuple.Tuple3) Stream(java.util.stream.Stream) Tuple4(org.jooq.lambda.tuple.Tuple4) Tuple.tuple(org.jooq.lambda.tuple.Tuple.tuple) ListUtilities(org.finos.waltz.common.ListUtilities) OrgNameToIdResolver(org.finos.waltz.jobs.tools.resolvers.OrgNameToIdResolver) DSLContext(org.jooq.DSLContext) Optional(java.util.Optional) Siphon(org.finos.waltz.common.StreamUtilities.Siphon) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Optional(java.util.Optional) DSLContext(org.jooq.DSLContext) PersonNameToEmpIdResolver(org.finos.waltz.jobs.tools.resolvers.PersonNameToEmpIdResolver) Tuple4(org.jooq.lambda.tuple.Tuple4) OrgNameToIdResolver(org.finos.waltz.jobs.tools.resolvers.OrgNameToIdResolver) Tuple3(org.jooq.lambda.tuple.Tuple3) InvolvementNameToIdResolver(org.finos.waltz.jobs.tools.resolvers.InvolvementNameToIdResolver) InvolvementRecord(org.finos.waltz.schema.tables.records.InvolvementRecord)

Aggregations

String.format (java.lang.String.format)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 DebugUtilities.dump (org.finos.waltz.common.DebugUtilities.dump)1 ListUtilities (org.finos.waltz.common.ListUtilities)1 SetUtilities.map (org.finos.waltz.common.SetUtilities.map)1 Siphon (org.finos.waltz.common.StreamUtilities.Siphon)1 StreamUtilities.mkSiphon (org.finos.waltz.common.StreamUtilities.mkSiphon)1 InvolvementNameToIdResolver (org.finos.waltz.jobs.tools.resolvers.InvolvementNameToIdResolver)1 OrgNameToIdResolver (org.finos.waltz.jobs.tools.resolvers.OrgNameToIdResolver)1 PersonNameToEmpIdResolver (org.finos.waltz.jobs.tools.resolvers.PersonNameToEmpIdResolver)1 EntityKind (org.finos.waltz.model.EntityKind)1 InvolvementRecord (org.finos.waltz.schema.tables.records.InvolvementRecord)1 DIBaseConfiguration (org.finos.waltz.service.DIBaseConfiguration)1 DSLContext (org.jooq.DSLContext)1 Tuple.tuple (org.jooq.lambda.tuple.Tuple.tuple)1 Tuple2 (org.jooq.lambda.tuple.Tuple2)1