Java 类org.jooq.TableRecord 实例源码

项目:waltz    文件:ChangeInitiativeGenerator.java   
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");


}
项目:waltz    文件:ChangeInitiativeGenerator.java   
private static Stream<TableRecord<?>> maybeBuildGroupLink(ChangeInitiativeRecord r, List<Long> groupIds) {
    if (rnd.nextInt(100) < 5) {
        EntityRelationshipRecord record = new EntityRelationshipRecord();
        record.setKindA(APP_GROUP.name());
        record.setIdA(ListUtilities.randomPick(groupIds));
        record.setKindB(EntityKind.CHANGE_INITIATIVE.name());
        record.setIdB(r.getId());
        record.setRelationship(RelationshipKind.RELATES_TO.name());
        return Stream.of(record);
    } else {
        return Stream.empty();
    }
}
项目:waltz    文件:ProcessGenerator.java   
public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);

    Set<TableRecord<?>> records = new HashSet<>();

    for (long g = 1; g < 5; g++ ) {
        ProcessRecord record = new ProcessRecord();
        record.setDescription("Process Group: " + g);
        record.setName("Process Group " + g);
        record.setId(g);
        record.setLevel(1);
        record.setLevel_1(g);
        records.add(record);
        for (long p = 0; p < 10; p++) {
            long id = (g * 100) + p;
            ProcessRecord record2 = new ProcessRecord();
            String name = randomPick(p1)
                    + " "
                    + randomPick(p2);
            record2.setDescription("Process: " + name);
            record2.setName(name);
            record2.setId(id);
            record2.setParentId(g);
            record2.setLevel(2);
            record2.setLevel_1(g);
            record2.setLevel_2(id);
            records.add(record2);

        }
    }

    System.out.println("-- deleting");
    dsl.deleteFrom(PROCESS).execute();
    System.out.println("-- inserting");
    dsl.batchInsert(records).execute();
    System.out.println(" -- done");

}
项目:waltz    文件:ChangeInitiativeGenerator.java   
private static Stream<TableRecord<?>> buildLinks(ChangeInitiativeRecord r,
                                                 List<Long> groupIds,
                                                 List<String> employeeIds) {
    return Stream.concat(maybeBuildGroupLink(r, groupIds), buildPersonLinks(r, employeeIds));
}