use of org.jooq.TableRecord 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");
}
use of org.jooq.TableRecord in project waltz by khartec.
the class ProcessGenerator method main.
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");
}
use of org.jooq.TableRecord in project jOOQ by jOOQ.
the class AbstractResult method formatInsert.
@Override
public final void formatInsert(Writer writer, Table<?> table, Field<?>... f) {
DSLContext ctx = configuration.dsl();
try {
for (R record : this) {
if (table == null)
if (record instanceof TableRecord)
table = ((TableRecord<?>) record).getTable();
else
table = table(name("UNKNOWN_TABLE"));
writer.append(ctx.renderInlined(insertInto(table, f).values(record.intoArray()))).append(";\n");
}
writer.flush();
} catch (java.io.IOException e) {
throw new IOException("Exception while writing INSERTs", e);
}
}
Aggregations