Search in sources :

Example 1 with APPLICATION_GROUP

use of com.khartec.waltz.schema.tables.ApplicationGroup.APPLICATION_GROUP in project waltz by khartec.

the class ChangeInitiativeGenerator method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    List<Long> groupIds = dsl.select(APPLICATION_GROUP.ID).from(APPLICATION_GROUP).fetch(APPLICATION_GROUP.ID);
    List<String> employeeIds = dsl.select(PERSON.EMPLOYEE_ID).from(PERSON).fetch(PERSON.EMPLOYEE_ID);
    List<Long> orgUnitIds = dsl.select(ORGANISATIONAL_UNIT.ID).from(ORGANISATIONAL_UNIT).fetch(ORGANISATIONAL_UNIT.ID);
    List<TableRecord<?>> records = LongStream.range(0, 400).mapToObj(i -> {
        String name = randomPick(p1) + " " + randomPick(p2) + " " + randomPick(p3);
        Long ouId = randomPick(orgUnitIds.toArray(new Long[0]));
        return Tuple.tuple(i, name, ouId);
    }).map(t -> buildChangeInitiativeRecord(t)).flatMap(r -> Stream.concat(Stream.of(r), buildLinks(r, groupIds, employeeIds))).collect(toList());
    System.out.println("-- deleting");
    dsl.deleteFrom(CHANGE_INITIATIVE).execute();
    System.out.println("-- inserting");
    dsl.batchInsert(records).execute();
    System.out.println(" -- done");
}
Also used : IntStream(java.util.stream.IntStream) InvolvementRecord(com.khartec.waltz.schema.tables.records.InvolvementRecord) Random(java.util.Random) EntityKind(com.khartec.waltz.model.EntityKind) Tuple3(org.jooq.lambda.tuple.Tuple3) DIConfiguration(com.khartec.waltz.service.DIConfiguration) DSLContext(org.jooq.DSLContext) APP_GROUP(com.khartec.waltz.model.EntityKind.APP_GROUP) LongStream(java.util.stream.LongStream) LifecyclePhase(com.khartec.waltz.model.application.LifecyclePhase) ArrayUtilities.randomPick(com.khartec.waltz.common.ArrayUtilities.randomPick) ListUtilities(com.khartec.waltz.common.ListUtilities) PERSON(com.khartec.waltz.schema.tables.Person.PERSON) TableRecord(org.jooq.TableRecord) Instant(java.time.Instant) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Date(java.sql.Date) List(java.util.List) ORGANISATIONAL_UNIT(com.khartec.waltz.schema.tables.OrganisationalUnit.ORGANISATIONAL_UNIT) Collectors.toList(java.util.stream.Collectors.toList) Tuple(org.jooq.lambda.tuple.Tuple) Stream(java.util.stream.Stream) EntityRelationshipRecord(com.khartec.waltz.schema.tables.records.EntityRelationshipRecord) APPLICATION_GROUP(com.khartec.waltz.schema.tables.ApplicationGroup.APPLICATION_GROUP) RelationshipKind(com.khartec.waltz.model.entity_relationship.RelationshipKind) CHANGE_INITIATIVE(com.khartec.waltz.schema.tables.ChangeInitiative.CHANGE_INITIATIVE) ChangeInitiativeRecord(com.khartec.waltz.schema.tables.records.ChangeInitiativeRecord) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DSLContext(org.jooq.DSLContext) TableRecord(org.jooq.TableRecord)

Aggregations

ArrayUtilities.randomPick (com.khartec.waltz.common.ArrayUtilities.randomPick)1 ListUtilities (com.khartec.waltz.common.ListUtilities)1 EntityKind (com.khartec.waltz.model.EntityKind)1 APP_GROUP (com.khartec.waltz.model.EntityKind.APP_GROUP)1 LifecyclePhase (com.khartec.waltz.model.application.LifecyclePhase)1 RelationshipKind (com.khartec.waltz.model.entity_relationship.RelationshipKind)1 APPLICATION_GROUP (com.khartec.waltz.schema.tables.ApplicationGroup.APPLICATION_GROUP)1 CHANGE_INITIATIVE (com.khartec.waltz.schema.tables.ChangeInitiative.CHANGE_INITIATIVE)1 ORGANISATIONAL_UNIT (com.khartec.waltz.schema.tables.OrganisationalUnit.ORGANISATIONAL_UNIT)1 PERSON (com.khartec.waltz.schema.tables.Person.PERSON)1 ChangeInitiativeRecord (com.khartec.waltz.schema.tables.records.ChangeInitiativeRecord)1 EntityRelationshipRecord (com.khartec.waltz.schema.tables.records.EntityRelationshipRecord)1 InvolvementRecord (com.khartec.waltz.schema.tables.records.InvolvementRecord)1 DIConfiguration (com.khartec.waltz.service.DIConfiguration)1 Date (java.sql.Date)1 Instant (java.time.Instant)1 List (java.util.List)1 Random (java.util.Random)1 Collectors.toList (java.util.stream.Collectors.toList)1 IntStream (java.util.stream.IntStream)1