Search in sources :

Example 1 with InvolvementRecord

use of com.khartec.waltz.schema.tables.records.InvolvementRecord in project waltz by khartec.

the class ChangeInitiativeGenerator method buildPersonLinks.

private static Stream<InvolvementRecord> buildPersonLinks(ChangeInitiativeRecord r, List<String> employeeIds) {
    return IntStream.range(0, 5).mapToObj(i -> {
        InvolvementRecord record = new InvolvementRecord();
        record.setKindId(Long.valueOf(rnd.nextInt(13) + 1));
        record.setProvenance("dummy");
        record.setEntityId(r.getId());
        record.setEntityKind(EntityKind.CHANGE_INITIATIVE.name());
        record.setEmployeeId(ListUtilities.randomPick(employeeIds));
        return record;
    });
}
Also used : InvolvementRecord(com.khartec.waltz.schema.tables.records.InvolvementRecord)

Example 2 with InvolvementRecord

use of com.khartec.waltz.schema.tables.records.InvolvementRecord in project waltz by khartec.

the class EndUserAppInvolvmentGenerator method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    List<Long> appIds = dsl.select(END_USER_APPLICATION.ID).from(END_USER_APPLICATION).fetch(END_USER_APPLICATION.ID);
    List<String> empIds = dsl.select(PERSON.EMPLOYEE_ID).from(PERSON).innerJoin(PERSON_HIERARCHY).on(PERSON.EMPLOYEE_ID.eq(PERSON_HIERARCHY.EMPLOYEE_ID)).where(PERSON_HIERARCHY.LEVEL.lt(4)).fetch(PERSON.EMPLOYEE_ID);
    List<InvolvementRecord> records = ListUtilities.map(appIds, id -> {
        InvolvementRecord record = dsl.newRecord(INVOLVEMENT);
        record.setProvenance("RANDOM_GENERATOR");
        record.setEmployeeId(randomPick(empIds));
        record.setEntityId(id);
        record.setEntityKind(EntityKind.END_USER_APPLICATION.name());
        record.setKindId(Long.valueOf(rnd.nextInt(13) + 1));
        return record;
    });
    System.out.println("---saving: " + records.size());
    dsl.batchInsert(records).execute();
    System.out.println("---done");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DSLContext(org.jooq.DSLContext) InvolvementRecord(com.khartec.waltz.schema.tables.records.InvolvementRecord)

Example 3 with InvolvementRecord

use of com.khartec.waltz.schema.tables.records.InvolvementRecord in project waltz by khartec.

the class InvolvementGenerator method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    List<String> developers = getEmployeeIdsByTitle(dsl, "%Developer%");
    List<String> managers = getEmployeeIdsByTitle(dsl, "%Manager%");
    List<String> analysts = getEmployeeIdsByTitle(dsl, "%Analyst%");
    List<String> administrators = getEmployeeIdsByTitle(dsl, "%Administrator%");
    List<String> qa = getEmployeeIdsByTitle(dsl, "%QA%");
    List<String> directors = getEmployeeIdsByTitle(dsl, "%Director%");
    ;
    List<Long> orgUnitIds = dsl.select(ORGANISATIONAL_UNIT.ID).from(ORGANISATIONAL_UNIT).fetch(ORGANISATIONAL_UNIT.ID);
    Map<String, Long> involvementKindMap = dsl.select(INVOLVEMENT_KIND.NAME, INVOLVEMENT_KIND.ID).from(INVOLVEMENT_KIND).fetch().stream().collect(toMap(r -> r.getValue(INVOLVEMENT_KIND.NAME), r -> r.getValue(INVOLVEMENT_KIND.ID)));
    List<Long> inHouseApps = getAppIdsByKind(dsl, ApplicationKind.IN_HOUSE);
    List<Long> hostedApps = getAppIdsByKind(dsl, ApplicationKind.INTERNALLY_HOSTED);
    List<Long> externalApps = getAppIdsByKind(dsl, ApplicationKind.EXTERNALLY_HOSTED);
    List<Long> eucApps = getAppIdsByKind(dsl, ApplicationKind.EUC);
    List<InvolvementRecord> devInvolvements = inHouseApps.stream().map(id -> toAppRef(id)).flatMap(appRef -> mkInvolvments(appRef, developers, involvementKindMap.get("Developer"), 7)).collect(Collectors.toList());
    List<InvolvementRecord> qaInvolvements = concat(inHouseApps, hostedApps).stream().map(id -> toAppRef(id)).flatMap(appRef -> mkInvolvments(appRef, qa, involvementKindMap.get("Quality Assurance"), 3)).collect(Collectors.toList());
    List<InvolvementRecord> projectManagerInvolvements = concat(inHouseApps, externalApps, hostedApps, eucApps).stream().map(id -> toAppRef(id)).flatMap(appRef -> mkInvolvments(appRef, managers, involvementKindMap.get("Project Manager"), 1)).collect(Collectors.toList());
    List<InvolvementRecord> supportManagerInvolvments = concat(inHouseApps, externalApps, hostedApps).stream().map(id -> toAppRef(id)).flatMap(appRef -> mkInvolvments(appRef, managers, involvementKindMap.get("Support Manager"), 1)).collect(Collectors.toList());
    List<InvolvementRecord> analystInvolvments = concat(inHouseApps, externalApps, hostedApps).stream().map(id -> toAppRef(id)).flatMap(appRef -> mkInvolvments(appRef, analysts, involvementKindMap.get("Business Analyst"), 3)).collect(Collectors.toList());
    List<InvolvementRecord> ouArchitects = orgUnitIds.stream().map(id -> new InvolvementRecord(EntityKind.ORG_UNIT.name(), id, randomPick(directors), "RANDOM_GENERATOR", Long.valueOf(rnd.nextInt(13) + 1))).collect(Collectors.toList());
    List<InvolvementRecord> ouSponsors = orgUnitIds.stream().map(id -> new InvolvementRecord(EntityKind.ORG_UNIT.name(), id, randomPick(directors), "RANDOM_GENERATOR", Long.valueOf(rnd.nextInt(13) + 1))).collect(Collectors.toList());
    dsl.delete(INVOLVEMENT).execute();
    dsl.batchInsert(devInvolvements).execute();
    dsl.batchInsert(qaInvolvements).execute();
    dsl.batchInsert(supportManagerInvolvments).execute();
    dsl.batchInsert(projectManagerInvolvements).execute();
    dsl.batchInsert(analystInvolvments).execute();
    dsl.batchInsert(ouArchitects).execute();
    dsl.batchInsert(ouSponsors).execute();
    System.out.println("Done");
}
Also used : IntStream(java.util.stream.IntStream) InvolvementRecord(com.khartec.waltz.schema.tables.records.InvolvementRecord) ImmutableEntityReference(com.khartec.waltz.model.ImmutableEntityReference) INVOLVEMENT_KIND(com.khartec.waltz.schema.tables.InvolvementKind.INVOLVEMENT_KIND) PERSON(com.khartec.waltz.schema.tables.Person.PERSON) EntityReference(com.khartec.waltz.model.EntityReference) Random(java.util.Random) INVOLVEMENT(com.khartec.waltz.schema.tables.Involvement.INVOLVEMENT) Collectors(java.util.stream.Collectors) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ListUtilities.concat(com.khartec.waltz.common.ListUtilities.concat) EntityKind(com.khartec.waltz.model.EntityKind) ListUtilities.randomPick(com.khartec.waltz.common.ListUtilities.randomPick) List(java.util.List) ORGANISATIONAL_UNIT(com.khartec.waltz.schema.tables.OrganisationalUnit.ORGANISATIONAL_UNIT) Stream(java.util.stream.Stream) DIConfiguration(com.khartec.waltz.service.DIConfiguration) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) DSLContext(org.jooq.DSLContext) APPLICATION(com.khartec.waltz.schema.tables.Application.APPLICATION) ApplicationKind(com.khartec.waltz.model.application.ApplicationKind) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DSLContext(org.jooq.DSLContext) InvolvementRecord(com.khartec.waltz.schema.tables.records.InvolvementRecord)

Aggregations

InvolvementRecord (com.khartec.waltz.schema.tables.records.InvolvementRecord)3 DSLContext (org.jooq.DSLContext)2 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)2 ListUtilities.concat (com.khartec.waltz.common.ListUtilities.concat)1 ListUtilities.randomPick (com.khartec.waltz.common.ListUtilities.randomPick)1 EntityKind (com.khartec.waltz.model.EntityKind)1 EntityReference (com.khartec.waltz.model.EntityReference)1 ImmutableEntityReference (com.khartec.waltz.model.ImmutableEntityReference)1 ApplicationKind (com.khartec.waltz.model.application.ApplicationKind)1 APPLICATION (com.khartec.waltz.schema.tables.Application.APPLICATION)1 INVOLVEMENT (com.khartec.waltz.schema.tables.Involvement.INVOLVEMENT)1 INVOLVEMENT_KIND (com.khartec.waltz.schema.tables.InvolvementKind.INVOLVEMENT_KIND)1 ORGANISATIONAL_UNIT (com.khartec.waltz.schema.tables.OrganisationalUnit.ORGANISATIONAL_UNIT)1 PERSON (com.khartec.waltz.schema.tables.Person.PERSON)1 DIConfiguration (com.khartec.waltz.service.DIConfiguration)1 List (java.util.List)1 Map (java.util.Map)1 Random (java.util.Random)1 Collectors (java.util.stream.Collectors)1 Collectors.toMap (java.util.stream.Collectors.toMap)1