Search in sources :

Example 1 with Person

use of io.codearte.jfairy.producer.person.Person in project waltz by khartec.

the class PersonDataGenerator method visit.

private static void visit(ImmutablePerson parent, int level) {
    if (level > MAX_DEPTH)
        return;
    int nextLevel = level + 1;
    int siblingCount = level == 1 ? jobTitles[1].length : rnd.nextInt(7) + 2;
    for (int i = 0; i < siblingCount; i++) {
        Person person = fairy.person();
        String jobTitle = level == 1 ? jobTitles[1][i] : randomPick(jobTitles[level >= jobTitles.length ? jobTitles.length - 1 : level]);
        ImmutablePerson p = ImmutablePerson.builder().managerEmployeeId(parent.employeeId()).employeeId(person.getPassportNumber()).personKind(PersonKind.EMPLOYEE).userPrincipalName(person.getUsername()).title(jobTitle).departmentName(randomPick(departmentNames)).displayName(person.getFullName()).email((counter++) + person.getEmail()).build();
        peeps.add(p);
        visit(p, nextLevel);
    }
}
Also used : ImmutablePerson(com.khartec.waltz.model.person.ImmutablePerson) ImmutablePerson(com.khartec.waltz.model.person.ImmutablePerson) Person(io.codearte.jfairy.producer.person.Person)

Example 2 with Person

use of io.codearte.jfairy.producer.person.Person in project waltz by khartec.

the class PersonDataGenerator method visit.

private static void visit(ImmutablePerson parent, int level, List<Long> orgUnitIds) {
    if (level > MAX_DEPTH)
        return;
    int nextLevel = level + 1;
    int siblingCount = level == 1 ? SampleData.jobTitles[1].length : rnd.nextInt(4) + 2;
    for (int i = 0; i < siblingCount; i++) {
        Person person = fairy.person();
        String jobTitle = level == 1 ? SampleData.jobTitles[1][i] : randomPick(SampleData.jobTitles[level >= SampleData.jobTitles.length ? SampleData.jobTitles.length - 1 : level]);
        Long ouId = orgUnitIds.get(rnd.nextInt(orgUnitIds.size()));
        ImmutablePerson p = ImmutablePerson.builder().managerEmployeeId(parent.employeeId()).employeeId(person.getPassportNumber()).personKind(PersonKind.EMPLOYEE).userPrincipalName(person.getUsername()).title(jobTitle).departmentName(randomPick(SampleData.departmentNames)).displayName(person.getFullName()).email((counter++) + person.getEmail()).organisationalUnitId(ouId).isRemoved(false).build();
        peeps.add(p);
        visit(p, nextLevel, orgUnitIds);
    }
}
Also used : ImmutablePerson(org.finos.waltz.model.person.ImmutablePerson) ImmutablePerson(org.finos.waltz.model.person.ImmutablePerson) Person(io.codearte.jfairy.producer.person.Person)

Example 3 with Person

use of io.codearte.jfairy.producer.person.Person 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());
}
Also used : PersonHierarchyService(org.finos.waltz.service.person_hierarchy.PersonHierarchyService) PersonService(org.finos.waltz.service.person.PersonService) ImmutablePerson(org.finos.waltz.model.person.ImmutablePerson) ImmutablePerson(org.finos.waltz.model.person.ImmutablePerson) Person(io.codearte.jfairy.producer.person.Person)

Example 4 with Person

use of io.codearte.jfairy.producer.person.Person in project waltz by khartec.

the class PersonDataGenerator method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    PersonService personService = ctx.getBean(PersonService.class);
    PersonHierarchyService personHierarchyService = ctx.getBean(PersonHierarchyService.class);
    Person person = fairy.person();
    ImmutablePerson root = ImmutablePerson.builder().employeeId(person.getPassportNumber()).personKind(PersonKind.EMPLOYEE).userPrincipalName(person.getUsername()).title(randomPick(jobTitles[0])).departmentName("CEO").displayName(person.getFullName()).email(person.getEmail()).build();
    peeps.add(root);
    visit(root, 1);
    System.out.println(peeps.size());
    personService.bulkSave(peeps);
    personHierarchyService.build();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) PersonHierarchyService(com.khartec.waltz.service.person_hierarchy.PersonHierarchyService) PersonService(com.khartec.waltz.service.person.PersonService) ImmutablePerson(com.khartec.waltz.model.person.ImmutablePerson) ImmutablePerson(com.khartec.waltz.model.person.ImmutablePerson) Person(io.codearte.jfairy.producer.person.Person)

Aggregations

Person (io.codearte.jfairy.producer.person.Person)4 ImmutablePerson (com.khartec.waltz.model.person.ImmutablePerson)2 ImmutablePerson (org.finos.waltz.model.person.ImmutablePerson)2 PersonService (com.khartec.waltz.service.person.PersonService)1 PersonHierarchyService (com.khartec.waltz.service.person_hierarchy.PersonHierarchyService)1 PersonService (org.finos.waltz.service.person.PersonService)1 PersonHierarchyService (org.finos.waltz.service.person_hierarchy.PersonHierarchyService)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1