use of org.finos.waltz.service.entity_hierarchy.EntityHierarchyService in project waltz by khartec.
the class EntityHierarchyHarness method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
EntityHierarchyService svc = ctx.getBean(EntityHierarchyService.class);
svc.buildFor(EntityKind.ORG_UNIT);
}
use of org.finos.waltz.service.entity_hierarchy.EntityHierarchyService in project waltz by khartec.
the class EntityStatisticGenerator method create.
public Map<String, Integer> create(ApplicationContext context) {
DSLContext dsl = context.getBean(DSLContext.class);
ApplicationDao applicationDao = context.getBean(ApplicationDao.class);
OrganisationalUnitDao organisationalUnitDao = context.getBean(OrganisationalUnitDao.class);
EntityStatisticValueDao valueDao = context.getBean(EntityStatisticValueDao.class);
EntityStatisticDefinitionDao definitionDao = context.getBean(EntityStatisticDefinitionDao.class);
EntityHierarchyService entityHierarchyService = context.getBean(EntityHierarchyService.class);
Application[] applications = applicationDao.findAll().toArray(new Application[0]);
OrganisationalUnit[] orgUnits = organisationalUnitDao.findAll().toArray(new OrganisationalUnit[0]);
dsl.deleteFrom(ENTITY_STATISTIC_DEFINITION).where(ENTITY_STATISTIC_DEFINITION.PROVENANCE.eq("DEMO")).execute();
log("deleted existing statistics (provenance: '" + SAMPLE_DATA_PROVENANCE + "')");
dsl.update(ENTITY_STATISTIC_VALUE).set(ENTITY_STATISTIC_VALUE.CURRENT, false).where(ENTITY_STATISTIC_VALUE.PROVENANCE.eq("DEMO")).execute();
log("marked existing statistic values as non-current (provenance: '" + SAMPLE_DATA_PROVENANCE + "')");
definitionDao.insert(SDLC);
definitionDao.insert(SDLC_TECH);
definitionDao.insert(SDLC_PROCESS);
definitionDao.insert(SDLC_JIRA);
definitionDao.insert(SDLC_SVN);
definitionDao.insert(SDLC_WIKI);
definitionDao.insert(AUDIT);
definitionDao.insert(SERVER_COUNT);
definitionDao.insert(PRE_COMPUTED);
createAdoptionStatsFor(SDLC_TECH, applications, valueDao);
createAdoptionStatsFor(SDLC_PROCESS, applications, valueDao);
createAdoptionStatsFor(SDLC_JIRA, applications, valueDao);
createAdoptionStatsFor(SDLC_SVN, applications, valueDao);
createAdoptionStatsFor(SDLC_WIKI, applications, valueDao);
createIntStatsFor(AUDIT, applications, valueDao, 20, failIfPositiveFn);
createIntStatsFor(SDLC, applications, valueDao, 20, failIfPositiveFn);
createIntStatsFor(SERVER_COUNT, applications, valueDao, 20, (x, y) -> "VIRTUAL");
createIntStatsFor(SERVER_COUNT, applications, valueDao, 20, (x, y) -> "BARE_METAL");
createPreComputedStatsFor(PRE_COMPUTED, orgUnits, valueDao);
entityHierarchyService.buildFor(EntityKind.ENTITY_STATISTIC);
log("Rebuilt entity hierarchy");
return null;
}
use of org.finos.waltz.service.entity_hierarchy.EntityHierarchyService in project waltz by khartec.
the class DataTypeGenerator method create.
@Override
public Map<String, Integer> create(ApplicationContext ctx) {
DSLContext dsl = getDsl(ctx);
dsl.deleteFrom(DATA_TYPE).execute();
dsl.insertInto(DATA_TYPE).set(DATA_TYPE.CODE, "BOOK").set(DATA_TYPE.DESCRIPTION, "Book Data").set(DATA_TYPE.NAME, "Book Data").set(DATA_TYPE.ID, 1000L).execute();
dsl.insertInto(DATA_TYPE).set(DATA_TYPE.CODE, "PARTY").set(DATA_TYPE.DESCRIPTION, "Party Data").set(DATA_TYPE.NAME, "Counterparty etc.").set(DATA_TYPE.ID, 2000L).execute();
dsl.insertInto(DATA_TYPE).set(DATA_TYPE.CODE, "PRICING").set(DATA_TYPE.DESCRIPTION, "Pricing Data").set(DATA_TYPE.NAME, "Pricing Data").set(DATA_TYPE.ID, 3000L).execute();
dsl.insertInto(DATA_TYPE).set(DATA_TYPE.CODE, "TRADE").set(DATA_TYPE.DESCRIPTION, "Trade Data").set(DATA_TYPE.NAME, "Transactions etc.").set(DATA_TYPE.ID, 4000L).execute();
dsl.insertInto(DATA_TYPE).set(DATA_TYPE.CODE, "RATE").set(DATA_TYPE.DESCRIPTION, "Rates").set(DATA_TYPE.NAME, "Interest rates etc").set(DATA_TYPE.ID, 5000L).execute();
dsl.insertInto(DATA_TYPE).set(DATA_TYPE.CODE, "CURRENCY").set(DATA_TYPE.DESCRIPTION, "Currency").set(DATA_TYPE.NAME, "Currencies etc").set(DATA_TYPE.ID, 6000L).execute();
dsl.insertInto(DATA_TYPE).set(DATA_TYPE.CODE, "VIRTUAL_CURRENCIES").set(DATA_TYPE.DESCRIPTION, "Virtual Currencies eg: Bitcoin").set(DATA_TYPE.NAME, "Virtual Currencies").set(DATA_TYPE.ID, 6100L).set(DATA_TYPE.PARENT_ID, 6000L).execute();
dsl.insertInto(DATA_TYPE).set(DATA_TYPE.CODE, "UNKNOWN").set(DATA_TYPE.DESCRIPTION, "Unknown").set(DATA_TYPE.NAME, "Unknown").set(DATA_TYPE.ID, 1L).set(DATA_TYPE.UNKNOWN, true).execute();
EntityHierarchyService ehSvc = ctx.getBean(EntityHierarchyService.class);
ehSvc.buildFor(EntityKind.DATA_TYPE);
return null;
}
use of org.finos.waltz.service.entity_hierarchy.EntityHierarchyService in project waltz by khartec.
the class MeasurableGenerator method create.
@Override
public Map<String, Integer> create(ApplicationContext ctx) {
DSLContext dsl = getDsl(ctx);
System.out.println("Importing data for category: " + category);
Supplier<List<String>> lineSupplier = Unchecked.supplier(() -> readLines(getClass().getResourceAsStream("/" + category + ".tsv")));
long categoryId = getCategory(dsl);
List<String> lines = lineSupplier.get();
List<String[]> sheet = lineSupplier.get().stream().skip(1).map(line -> line.split("\\t")).filter(cells -> cells.length > 3).collect(Collectors.toList());
List<MeasurableRecord> records = sheet.stream().map(cells -> {
MeasurableRecord record = dsl.newRecord(MEASURABLE);
record.setName(cells[2]);
record.setDescription(cells[3]);
record.setMeasurableCategoryId(categoryId);
record.setLastUpdatedBy("admin");
record.setProvenance(SAMPLE_DATA_PROVENANCE);
record.setConcrete(!StringUtilities.isEmpty(cells[1]));
record.setExternalId(category + " _ " + cells[0]);
return record;
}).collect(Collectors.toList());
dsl.batchStore(records).execute();
sheet.stream().filter(cells -> !StringUtilities.isEmpty(cells[1])).forEach(cells -> {
String pExtId = cells[1];
System.out.println(Arrays.toString(cells));
long pId = dsl.select(MEASURABLE.ID).from(MEASURABLE).where(MEASURABLE.EXTERNAL_ID.eq(category + " _ " + pExtId)).fetchOne(MEASURABLE.ID);
dsl.update(MEASURABLE).set(MEASURABLE.PARENT_ID, pId).where(MEASURABLE.EXTERNAL_ID.equal(category + " _ " + cells[0])).execute();
});
EntityHierarchyService ehSvc = ctx.getBean(EntityHierarchyService.class);
ehSvc.buildFor(EntityKind.MEASURABLE);
return null;
}
use of org.finos.waltz.service.entity_hierarchy.EntityHierarchyService 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