use of org.finos.waltz.data.application.ApplicationIdSelectorFactory in project waltz by khartec.
the class FlowSummaryWithTypesAndPhysicalsExport method mkAppIdSelector.
private static Select<Record1<Long>> mkAppIdSelector(ApplicationIdSelectorFactory appIdSelectorFactory) {
EntityReference infraRef = mkRef(EntityKind.ORG_UNIT, 6811);
EntityReference entRiskRef = mkRef(EntityKind.ORG_UNIT, 3125);
EntityReference regCtrlRef = mkRef(EntityKind.ORG_UNIT, 2761);
Function<EntityReference, Select<Record1<Long>>> mkOrgUnitSelector = (ref) -> DSL.select(ENTITY_HIERARCHY.ID).from(ENTITY_HIERARCHY).where(ENTITY_HIERARCHY.ANCESTOR_ID.eq(ref.id())).and(ENTITY_HIERARCHY.KIND.eq(ref.kind().name()));
Select<Record1<Long>> ouSelector = DSL.selectFrom(mkOrgUnitSelector.apply(infraRef).unionAll(mkOrgUnitSelector.apply(entRiskRef)).unionAll(mkOrgUnitSelector.apply(regCtrlRef)).asTable());
return DSL.select(APPLICATION.ID).from(APPLICATION).where(APPLICATION.ORGANISATIONAL_UNIT_ID.in(ouSelector)).and(APPLICATION.LIFECYCLE_PHASE.notEqual(EntityLifecycleStatus.REMOVED.name())).and(APPLICATION.IS_REMOVED.isFalse());
}
use of org.finos.waltz.data.application.ApplicationIdSelectorFactory 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.application.ApplicationIdSelectorFactory in project waltz by khartec.
the class AppGroupHarness method main.
public static void main(String[] args) throws InsufficientPrivelegeException {
System.out.println("--- start");
ApplicationIdSelectorFactory appSelectorFactory = new ApplicationIdSelectorFactory();
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
FavouritesService service = ctx.getBean(FavouritesService.class);
Collection<AppGroupEntry> appGroupEntries = service.addApplication("jessica.woodland-scott@db.com", 15792);
System.out.println("--- done");
}
use of org.finos.waltz.data.application.ApplicationIdSelectorFactory in project waltz by khartec.
the class ReportGridHarness method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIBaseConfiguration.class);
ReportGridDao dao = ctx.getBean(ReportGridDao.class);
System.out.println("Starting....");
EntityReference cib = mkRef(EntityKind.APP_GROUP, 11261);
EntityReference infra = mkRef(EntityKind.ORG_UNIT, 6811);
EntityReference justWaltz = mkRef(EntityKind.APPLICATION, 20506);
EntityReference justWaltzGroup = mkRef(EntityKind.APP_GROUP, 433);
EntityReference orgUnit = mkRef(EntityKind.ORG_UNIT, 95);
EntityReference everythingGroup = mkRef(EntityKind.APP_GROUP, 20827);
EntityReference flowDiagram = mkRef(EntityKind.FLOW_DIAGRAM, 1);
EntityReference mgr = mkRef(EntityKind.PERSON, 1);
Select<Record1<Long>> selector = new ApplicationIdSelectorFactory().apply(mkOpts(infra));
System.out.println("Made selector");
Set<ReportGridCell> a = FunctionUtilities.time("getCellData", () -> dao.findCellDataByGridId(3, selector));
Set<ReportGridCell> b = FunctionUtilities.time("getCellData", () -> dao.findCellDataByGridId(3, selector));
Set<ReportGridCell> c = FunctionUtilities.time("getCellData", () -> dao.findCellDataByGridId(3, selector));
Set<ReportGridCell> data = FunctionUtilities.time("getCellData", () -> dao.findCellDataByGridId(3, selector));
System.out.println(data.size());
System.out.println(first(data));
}
use of org.finos.waltz.data.application.ApplicationIdSelectorFactory in project waltz by khartec.
the class LogicalFlowHarness method main.
public static void main(String[] args) throws ParseException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
LogicalFlowDao dao = ctx.getBean(LogicalFlowDao.class);
LogicalFlowService service = ctx.getBean(LogicalFlowService.class);
ApplicationIdSelectorFactory factory = new ApplicationIdSelectorFactory();
IdSelectionOptions options = IdSelectionOptions.mkOpts(mkRef(EntityKind.PERSON, 262508), HierarchyQueryScope.CHILDREN);
for (int i = 0; i < 5; i++) {
List<LogicalFlow> flows = FunctionUtilities.time("Get flows", () -> service.findBySelector(options));
}
}
Aggregations