use of org.finos.waltz.model.EntityReference 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.model.EntityReference in project waltz by khartec.
the class ShortestPath method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
LogicalFlowDao logicalFlowDao = ctx.getBean(LogicalFlowDao.class);
ApplicationDao applicationDao = ctx.getBean(ApplicationDao.class);
List<LogicalFlow> allActive = logicalFlowDao.findAllActive();
Graph<EntityReference, DefaultEdge> g = createGraph(allActive);
Application targetApp = findFirstMatchByCode(applicationDao, targetAssetCode);
Stream.of(sourceAssetCodes).map(assetCode -> findFirstMatchByCode(applicationDao, assetCode)).filter(Objects::nonNull).map(sourceApp -> {
System.out.printf("Route from: %s (%s)\n----------------------\n", sourceApp.name(), ExternalIdValue.orElse(sourceApp.assetCode(), ""));
return sourceApp.entityReference();
}).filter(sourceRef -> {
if (!g.containsVertex(sourceRef)) {
System.out.println("No flows defined for application\n\n");
return false;
}
return true;
}).map(sourceRef -> findShortestPath(g, sourceRef, targetApp.entityReference())).filter(route -> {
if (route == null) {
System.out.println("No route found\n\n");
return false;
}
return true;
}).forEach(route -> {
List<DefaultEdge> edgeList = route.getEdgeList();
Set<Long> appIds = edgeList.stream().flatMap(e -> Stream.of(g.getEdgeSource(e).id(), g.getEdgeTarget(e).id())).collect(toSet());
Map<Long, Application> appsById = MapUtilities.indexBy(a -> a.id().get(), applicationDao.findByIds(appIds));
edgeList.forEach(edge -> {
Application source = appsById.get(g.getEdgeSource(edge).id());
Application target = appsById.get(g.getEdgeTarget(edge).id());
System.out.printf("%s (%s) -> %s (%s) \n", source.name(), ExternalIdValue.orElse(source.assetCode(), ""), target.name(), ExternalIdValue.orElse(target.assetCode(), ""));
});
System.out.println();
System.out.println();
});
}
use of org.finos.waltz.model.EntityReference in project waltz by khartec.
the class MeasurableHarness method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
MeasurableIdSelectorFactory factory = new MeasurableIdSelectorFactory();
MeasurableService measurableService = ctx.getBean(MeasurableService.class);
EntityReference ref = mkRef(EntityKind.PERSON, 172272);
IdSelectionOptions options = mkOpts(ref, HierarchyQueryScope.CHILDREN);
Select<Record1<Long>> selector = factory.apply(options);
System.out.println("--selector");
System.out.println(selector);
System.out.println("---");
List<Measurable> measurables = measurableService.findByMeasurableIdSelector(options);
measurables.forEach(System.out::println);
System.out.println("-----");
measurables.stream().filter(m -> OptionalUtilities.contentsEqual(m.id(), 486L)).forEach(System.out::println);
System.out.println(measurables.size());
}
use of org.finos.waltz.model.EntityReference in project waltz by khartec.
the class MeasurableRatingHarness method main.
public static void main(String[] args) throws ParseException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
MeasurableRatingDao measurableRatingDao = ctx.getBean(MeasurableRatingDao.class);
MeasurableIdSelectorFactory measurableIdSelectorFactory = new MeasurableIdSelectorFactory();
EntityReference direct = mkRef(MEASURABLE, 18310);
EntityReference indirect = mkRef(MEASURABLE, 18064);
IdSelectionOptions directOpts = IdSelectionOptions.mkOpts(direct, CHILDREN);
IdSelectionOptions indirectOpts = IdSelectionOptions.mkOpts(indirect, CHILDREN);
Select<Record1<Long>> directSelector = measurableIdSelectorFactory.apply(directOpts);
Select<Record1<Long>> indirectSelector = measurableIdSelectorFactory.apply(indirectOpts);
List<MeasurableRatingTally> directTallies = measurableRatingDao.statsForRelatedMeasurable(directSelector);
List<MeasurableRatingTally> indirectTallies = measurableRatingDao.statsForRelatedMeasurable(indirectSelector);
List<Tally<Long>> tallies = measurableRatingDao.tallyByMeasurableCategoryId(1L);
System.out.println(tallies);
}
use of org.finos.waltz.model.EntityReference 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));
}
Aggregations