use of org.finos.waltz.service.person.PersonService in project waltz by khartec.
the class InvolvementImporter method main.
public static void main(String[] args) throws IOException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
ApplicationService applicationService = ctx.getBean(ApplicationService.class);
PersonService personService = ctx.getBean(PersonService.class);
Map<String, Application> appsByExtId = indexBy(a -> ExternalIdValue.orElse(a.assetCode(), null), applicationService.findAll());
Map<String, Person> peopleByName = indexBy(p -> toSurnameFirstname(p.displayName()).toLowerCase(), personService.all());
Siphon<String[]> incorrectSizeSiphon = mkSiphon(arr -> arr.length != 3);
Siphon<Tuple2<String, ?>> unknownAppSiphon = mkSiphon(t -> !appsByExtId.containsKey(t.v1));
Siphon<Tuple2<?, String>> unknownPersonSiphon = mkSiphon(t -> !peopleByName.containsKey(t.v2.toLowerCase()));
Siphon<Tuple2<Application, ?>> retiredAppSiphon = mkSiphon(t -> t.v1.lifecyclePhase() == LifecyclePhase.RETIRED);
List<Tuple2<Application, Person>> r = IOUtilities.streamLines(classLoader.getResourceAsStream(fileName)).map(line -> line.split("\t")).filter(d -> incorrectSizeSiphon.test(d)).map(arr -> Tuple.tuple(arr[1], arr[0])).filter(t -> unknownAppSiphon.test(t)).map(t -> t.map1(extId -> appsByExtId.get(extId))).filter(t -> retiredAppSiphon.test(t)).filter(t -> unknownPersonSiphon.test(t)).map(t -> t.map2(n -> peopleByName.get(n.toLowerCase()))).collect(Collectors.toList());
Set<Application> distinctApps = r.stream().map(t -> t.v1).distinct().collect(Collectors.toSet());
Set<Person> distinctPeople = r.stream().map(t -> t.v2).distinct().collect(Collectors.toSet());
System.out.println("----");
System.out.println("Wrong size count: " + incorrectSizeSiphon.getResults().size());
System.out.println("Apps not found count: " + unknownAppSiphon.getResults().size());
System.out.println("Retired app count: " + retiredAppSiphon.getResults().size());
System.out.println("Person not found count: " + unknownPersonSiphon.getResults().size());
System.out.println("----");
System.out.println("Good record count: " + r.size());
System.out.println("Distinct App count: " + distinctApps.size());
System.out.println("Distinct People count: " + distinctPeople.size());
Map<String, Long> unknownPersonCounts = countBy(Tuple2::v2, unknownPersonSiphon.getResults());
DebugUtilities.dump(unknownPersonCounts);
}
use of org.finos.waltz.service.person.PersonService in project waltz by khartec.
the class PersonDataGenerator method create.
@Override
public Map<String, Integer> create(ApplicationContext ctx) {
PersonService personService = ctx.getBean(PersonService.class);
PersonHierarchyService personHierarchyService = ctx.getBean(PersonHierarchyService.class);
List<Long> ouIds = getDsl(ctx).select(ORGANISATIONAL_UNIT.ID).from(ORGANISATIONAL_UNIT).fetch(ORGANISATIONAL_UNIT.ID);
Person person = fairy.person();
ImmutablePerson root = ImmutablePerson.builder().employeeId(person.getPassportNumber()).personKind(PersonKind.EMPLOYEE).userPrincipalName(person.getUsername()).title(randomPick(SampleData.jobTitles[0])).departmentName("CEO").displayName(person.getFullName()).email(person.getEmail()).organisationalUnitId(10L).isRemoved(false).build();
peeps.add(root);
visit(root, 1, ouIds);
personService.bulkSave(peeps);
ImmutablePerson admin = randomPick(peeps);
getDsl(ctx).update(PERSON).set(PERSON.USER_PRINCIPAL_NAME, "admin").set(PERSON.EMAIL, "admin").where(PERSON.EMPLOYEE_ID.eq(admin.employeeId())).execute();
personHierarchyService.build();
return MapUtilities.newHashMap("created", peeps.size());
}
Aggregations