use of org.finos.waltz.data.orgunit.OrganisationalUnitDao in project waltz by khartec.
the class FlowSummaryWithTypesAndPhysicalsExport method main.
public static void main(String[] args) throws IOException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
ApplicationIdSelectorFactory appIdSelectorFactory = new ApplicationIdSelectorFactory();
ApplicationDao applicationDao = ctx.getBean(ApplicationDao.class);
OrganisationalUnitDao organisationalUnitDao = ctx.getBean(OrganisationalUnitDao.class);
LogicalFlowDao logicalFlowDao = ctx.getBean(LogicalFlowDao.class);
LogicalFlowDecoratorDao decoratorDao = ctx.getBean(LogicalFlowDecoratorDao.class);
DataTypeDao dataTypeDao = ctx.getBean(DataTypeDao.class);
Select<Record1<Long>> appSelector = mkAppIdSelector(appIdSelectorFactory);
Select<Record1<Long>> logicalFlowSelector = mkLogicalFlowSelectorFromAppSelector(appSelector);
System.out.println("Loading apps");
Set<Application> allApps = fromCollection(applicationDao.findAll());
System.out.println("Loading in scope apps");
Set<Long> inScopeAppIds = toIds(applicationDao.findByAppIdSelector(appSelector));
System.out.println("Loading OUs");
List<OrganisationalUnit> allOUs = organisationalUnitDao.findAll();
System.out.println("Loading DTs");
List<DataType> allDataTypes = dataTypeDao.findAll();
System.out.println("Loading Logical Flows");
List<LogicalFlow> logicalFlows = logicalFlowDao.findBySelector(logicalFlowSelector);
System.out.println("Loading decorators");
List<DataTypeDecorator> decorators = decoratorDao.findByAppIdSelector(appSelector);
System.out.println("Loading phys flows");
Map<Long, Collection<Tuple7<Long, String, String, String, String, String, String>>> physicalsByLogical = loadPhysicalsByLogical(dsl, logicalFlowSelector);
System.out.println("Indexing");
Map<Optional<Long>, Application> appsById = indexByOptId(allApps);
Map<Optional<Long>, DataType> dataTypesById = indexByOptId(allDataTypes);
Map<Optional<Long>, OrganisationalUnit> ousById = indexByOptId(allOUs);
Map<Long, Collection<DataTypeDecorator>> decoratorsByLogicalFlowId = groupBy(DataTypeDecorator::dataFlowId, decorators);
System.out.println("Processing");
CsvListWriter csvWriter = setupCSVWriter();
logicalFlows.stream().filter(lf -> lf.source().kind() == EntityKind.APPLICATION && lf.target().kind() == EntityKind.APPLICATION).map(Tuple::tuple).map(t -> t.concat(appsById.get(Optional.of(t.v1.source().id())))).map(t -> t.concat(appsById.get(Optional.of(t.v1.target().id())))).filter(t -> t.v2 != null && t.v3 != null).map(t -> t.concat(ousById.get(Optional.of(t.v2.organisationalUnitId())))).map(t -> t.concat(ousById.get(Optional.of(t.v3.organisationalUnitId())))).map(t -> t.concat(decoratorsByLogicalFlowId.getOrDefault(t.v1.id().orElse(-1L), emptyList()).stream().filter(d -> d.decoratorEntity().kind() == EntityKind.DATA_TYPE).map(d -> dataTypesById.get(Optional.of(d.decoratorEntity().id()))).sorted(Comparator.comparing(NameProvider::name)).collect(Collectors.toList()))).map(t -> t.concat(inScopeAppIds.contains(t.v2.id().get()))).map(t -> t.concat(inScopeAppIds.contains(t.v3.id().get()))).flatMap(t -> physicalsByLogical.getOrDefault(t.v1.id().orElse(-1L), newArrayList(tuple(-1L, "-", "-", "-", "-", "-", "-"))).stream().map(p -> t.concat(p.skip1()))).map(t -> newArrayList(// src
t.v2.name(), t.v2.assetCode().map(ExternalIdValue::value).orElse(""), t.v2.applicationKind().name(), t.v2.entityLifecycleStatus().name(), // src OU
Optional.ofNullable(t.v4).map(NameProvider::name).orElse("?"), t.v7.toString(), // trg
t.v3.name(), t.v3.assetCode().map(ExternalIdValue::value).orElse(""), t.v3.applicationKind().name(), t.v3.entityLifecycleStatus().name(), // trg OU
Optional.ofNullable(t.v5).map(NameProvider::name).orElse("?"), t.v8.toString(), StringUtilities.joinUsing(t.v6, NameProvider::name, ","), t.v9, t.v10, t.v11, t.v12, t.v13, t.v14)).forEach(Unchecked.consumer(csvWriter::write));
}
use of org.finos.waltz.data.orgunit.OrganisationalUnitDao in project waltz by khartec.
the class EndUserAppGenerator method create.
@Override
public Map<String, Integer> create(ApplicationContext ctx) {
OrganisationalUnitDao organisationalUnitDao = ctx.getBean(OrganisationalUnitDao.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
Set<Long> ids = IdUtilities.toIds(organisationalUnitDao.findAll());
String[] subjects = { "Trade", "Risk", "Balance", "PnL", "Rate", "Fines", "Party", "Confirmations", "Settlement", "Instruction", "Person", "Profit", "Margin", "Finance", "Account" };
String[] types = { "Report", "Summary", "Draft", "Calculations", "Breaks", "Record", "Statement", "Information", "Pivot" };
String[] tech = { "MS ACCESS", "MS EXCEL", "VBA" };
final Long[] idCounter = { 1L };
ids.forEach(ouId -> {
for (int i = 0; i < getRandom().nextInt(3); i++) {
EndUserApplicationRecord record = dsl.newRecord(END_USER_APPLICATION);
String name = String.format("%s %s %s %s", randomPick(subjects), randomPick(subjects), randomPick(types), randomPick(types));
record.setName(name);
record.setDescription("About the " + name + " End user app");
record.setKind(randomPick(tech));
record.setRiskRating(randomPick(Criticality.values()).name());
record.setLifecyclePhase(randomPick(LifecyclePhase.values()).name());
record.setOrganisationalUnitId(ouId);
record.setId(idCounter[0]++);
record.insert();
}
});
return null;
}
use of org.finos.waltz.data.orgunit.OrganisationalUnitDao 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.data.orgunit.OrganisationalUnitDao in project waltz by khartec.
the class LogicalFlowDecoratorRatingsServiceHarness method main.
public static void main(String[] args) throws SQLException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
FlowClassificationRuleService authoritativeSourceService = ctx.getBean(FlowClassificationRuleService.class);
List<FlowClassificationRule> authSources = authoritativeSourceService.findAll();
OrganisationalUnitService organisationalUnitService = ctx.getBean(OrganisationalUnitService.class);
OrganisationalUnitDao organisationalUnitDao = ctx.getBean(OrganisationalUnitDao.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
dsl.select(ORGANISATIONAL_UNIT.fields()).from(ORGANISATIONAL_UNIT).fetch(organisationalUnitDao.TO_DOMAIN_MAPPER);
EntityHierarchyService hierarchyService = ctx.getBean(EntityHierarchyService.class);
List<OrganisationalUnit> allOrgUnits = organisationalUnitService.findAll();
List<FlatNode<OrganisationalUnit, Long>> ouNodes = ListUtilities.map(allOrgUnits, ou -> new FlatNode<>(ou.id().get(), ou.parentId(), ou));
Forest<OrganisationalUnit, Long> ouForest = HierarchyUtilities.toForest(ouNodes);
Map<Long, Node<OrganisationalUnit, Long>> nodeMap = ouForest.getAllNodes();
}
use of org.finos.waltz.data.orgunit.OrganisationalUnitDao in project waltz by khartec.
the class OrgUnitHarness method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
OrganisationalUnitDao dao = ctx.getBean(OrganisationalUnitDao.class);
dao.getById(1L);
}
Aggregations