use of com.khartec.waltz.schema.tables.records.OrganisationalUnitRecord in project waltz by khartec.
the class OrgUnitGenerator method main.
public static void main(String[] args) throws IOException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
List<String> lines = readLines(OrgUnitGenerator.class.getResourceAsStream("/org-units.csv"));
System.out.println("Deleting existing OU's");
dsl.deleteFrom(ORGANISATIONAL_UNIT).execute();
List<OrganisationalUnitRecord> records = lines.stream().skip(1).map(line -> StringUtils.splitPreserveAllTokens(line, ",")).filter(cells -> cells.length == 4).map(cells -> {
OrganisationalUnitRecord record = new OrganisationalUnitRecord();
record.setId(longVal(cells[0]));
record.setParentId(longVal(cells[1]));
record.setName(cells[2]);
record.setDescription(cells[3]);
record.setUpdatedAt(new Timestamp(System.currentTimeMillis()));
System.out.println(record);
return record;
}).collect(Collectors.toList());
System.out.println("Inserting new OU's");
dsl.batchInsert(records).execute();
System.out.println("Done");
}
Aggregations