use of org.finos.waltz.schema.tables.records.OrganisationalUnitRecord in project waltz by khartec.
the class BaseInMemoryIntegrationTest method createOrgUnit.
public Long createOrgUnit(String nameStem, Long parentId) {
OrganisationalUnitRecord record = getDsl().newRecord(ORGANISATIONAL_UNIT);
record.setId(counter.incrementAndGet());
record.setName(nameStem + "Name");
record.setDescription(nameStem + "Desc");
record.setParentId(parentId);
record.setLastUpdatedAt(DateTimeUtilities.nowUtcTimestamp());
record.setLastUpdatedBy("admin");
record.setProvenance("integration-test");
record.insert();
return record.getId();
}
use of org.finos.waltz.schema.tables.records.OrganisationalUnitRecord in project waltz by khartec.
the class OrgUnitGenerator method create.
@Override
public Map<String, Integer> create(ApplicationContext ctx) {
DSLContext dsl = getDsl(ctx);
Supplier<List<String>> lineSupplier = Unchecked.supplier(() -> readLines(getClass().getResourceAsStream("/org-units.csv")));
List<OrganisationalUnitRecord> records = lineSupplier.get().stream().skip(1).map(line -> line.split(",")).filter(cells -> cells.length > 2).map(cells -> {
OrganisationalUnitRecord record = new OrganisationalUnitRecord();
record.setId(longVal(cells[0]));
record.setParentId(longVal(cells[1]));
record.setName(cells[2]);
if (cells.length > 3) {
record.setDescription(cells[3]);
}
record.setLastUpdatedAt(new Timestamp(System.currentTimeMillis()));
return record;
}).collect(Collectors.toList());
log("Inserting new OU's");
dsl.batchInsert(records).execute();
EntityHierarchyService ehSvc = ctx.getBean(EntityHierarchyService.class);
ehSvc.buildFor(EntityKind.ORG_UNIT);
return MapUtilities.newHashMap("created", records.size());
}
Aggregations