Search in sources :

Example 36 with EntityReference

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());
}
Also used : OrganisationalUnitDao(org.finos.waltz.data.orgunit.OrganisationalUnitDao) java.util(java.util) LogicalFlowDao(org.finos.waltz.data.logical_flow.LogicalFlowDao) DSL(org.jooq.impl.DSL) Tables(org.finos.waltz.schema.Tables) EntityKind(org.finos.waltz.model.EntityKind) DIConfiguration(org.finos.waltz.service.DIConfiguration) ListUtilities.newArrayList(org.finos.waltz.common.ListUtilities.newArrayList) CsvPreference(org.supercsv.prefs.CsvPreference) Function(java.util.function.Function) Condition(org.jooq.Condition) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) DataType(org.finos.waltz.model.datatype.DataType) LOGICAL_FLOW(org.finos.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW) LOGICAL_NOT_REMOVED(org.finos.waltz.data.logical_flow.LogicalFlowDao.LOGICAL_NOT_REMOVED) Record1(org.jooq.Record1) CsvListWriter(org.supercsv.io.CsvListWriter) MapUtilities.groupBy(org.finos.waltz.common.MapUtilities.groupBy) Tuple7(org.jooq.lambda.tuple.Tuple7) DSLContext(org.jooq.DSLContext) OutputStreamWriter(java.io.OutputStreamWriter) ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory) Select(org.jooq.Select) StringUtilities(org.finos.waltz.common.StringUtilities) EntityLifecycleStatus(org.finos.waltz.model.EntityLifecycleStatus) OrganisationalUnit(org.finos.waltz.model.orgunit.OrganisationalUnit) Unchecked(org.jooq.lambda.Unchecked) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) Application(org.finos.waltz.model.application.Application) DataTypeDecorator(org.finos.waltz.model.datatype.DataTypeDecorator) Collections.emptyList(java.util.Collections.emptyList) IdUtilities.toIds(org.finos.waltz.model.utils.IdUtilities.toIds) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) NameProvider(org.finos.waltz.model.NameProvider) ApplicationDao(org.finos.waltz.data.application.ApplicationDao) LogicalFlowDecoratorDao(org.finos.waltz.data.datatype_decorator.LogicalFlowDecoratorDao) ExternalIdValue(org.finos.waltz.model.external_identifier.ExternalIdValue) Tuple(org.jooq.lambda.tuple.Tuple) Tuple.tuple(org.jooq.lambda.tuple.Tuple.tuple) EntityReference(org.finos.waltz.model.EntityReference) DataTypeDao(org.finos.waltz.data.data_type.DataTypeDao) IdUtilities.indexByOptId(org.finos.waltz.model.utils.IdUtilities.indexByOptId) SetUtilities.fromCollection(org.finos.waltz.common.SetUtilities.fromCollection) EntityReference(org.finos.waltz.model.EntityReference) Select(org.jooq.Select) Record1(org.jooq.Record1)

Example 37 with EntityReference

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();
    });
}
Also used : MapUtilities(org.finos.waltz.common.MapUtilities) LogicalFlowDao(org.finos.waltz.data.logical_flow.LogicalFlowDao) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) DefaultDirectedGraph(org.jgrapht.graph.DefaultDirectedGraph) DefaultEdge(org.jgrapht.graph.DefaultEdge) Application(org.finos.waltz.model.application.Application) Set(java.util.Set) DIConfiguration(org.finos.waltz.service.DIConfiguration) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DijkstraShortestPath(org.jgrapht.alg.shortestpath.DijkstraShortestPath) Objects(java.util.Objects) ApplicationDao(org.finos.waltz.data.application.ApplicationDao) GraphPath(org.jgrapht.GraphPath) List(java.util.List) ExternalIdValue(org.finos.waltz.model.external_identifier.ExternalIdValue) Stream(java.util.stream.Stream) SingleSourcePaths(org.jgrapht.alg.interfaces.ShortestPathAlgorithm.SingleSourcePaths) Map(java.util.Map) Graph(org.jgrapht.Graph) EntityReference(org.finos.waltz.model.EntityReference) Collectors.toSet(java.util.stream.Collectors.toSet) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DefaultEdge(org.jgrapht.graph.DefaultEdge) ApplicationDao(org.finos.waltz.data.application.ApplicationDao) LogicalFlowDao(org.finos.waltz.data.logical_flow.LogicalFlowDao) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) EntityReference(org.finos.waltz.model.EntityReference) Application(org.finos.waltz.model.application.Application)

Example 38 with EntityReference

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());
}
Also used : IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) OptionalUtilities(org.finos.waltz.common.OptionalUtilities) EntityKind(org.finos.waltz.model.EntityKind) IdSelectionOptions.mkOpts(org.finos.waltz.model.IdSelectionOptions.mkOpts) DIConfiguration(org.finos.waltz.service.DIConfiguration) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) List(java.util.List) Measurable(org.finos.waltz.model.measurable.Measurable) Record1(org.jooq.Record1) MeasurableService(org.finos.waltz.service.measurable.MeasurableService) EntityReference(org.finos.waltz.model.EntityReference) MeasurableIdSelectorFactory(org.finos.waltz.data.measurable.MeasurableIdSelectorFactory) Select(org.jooq.Select) HierarchyQueryScope(org.finos.waltz.model.HierarchyQueryScope) Measurable(org.finos.waltz.model.measurable.Measurable) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MeasurableIdSelectorFactory(org.finos.waltz.data.measurable.MeasurableIdSelectorFactory) EntityReference(org.finos.waltz.model.EntityReference) MeasurableService(org.finos.waltz.service.measurable.MeasurableService) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 39 with EntityReference

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);
}
Also used : Tally(org.finos.waltz.model.tally.Tally) MeasurableRatingTally(org.finos.waltz.model.tally.MeasurableRatingTally) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MeasurableIdSelectorFactory(org.finos.waltz.data.measurable.MeasurableIdSelectorFactory) MeasurableRatingDao(org.finos.waltz.data.measurable_rating.MeasurableRatingDao) EntityReference(org.finos.waltz.model.EntityReference) MeasurableRatingTally(org.finos.waltz.model.tally.MeasurableRatingTally) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 40 with EntityReference

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));
}
Also used : ReportGridCell(org.finos.waltz.model.report_grid.ReportGridCell) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory) ReportGridDao(org.finos.waltz.data.report_grid.ReportGridDao) EntityReference(org.finos.waltz.model.EntityReference) Record1(org.jooq.Record1)

Aggregations

EntityReference (org.finos.waltz.model.EntityReference)114 BaseInMemoryIntegrationTest (org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest)55 Test (org.junit.jupiter.api.Test)55 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)40 EntityKind (org.finos.waltz.model.EntityKind)23 List (java.util.List)21 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)19 Autowired (org.springframework.beans.factory.annotation.Autowired)17 DataTypeDecorator (org.finos.waltz.model.datatype.DataTypeDecorator)16 Set (java.util.Set)14 Collection (java.util.Collection)13 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)13 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)10 IdSelectionOptions.mkOpts (org.finos.waltz.model.IdSelectionOptions.mkOpts)9 DateTimeUtilities (org.finos.waltz.common.DateTimeUtilities)8 ListUtilities.newArrayList (org.finos.waltz.common.ListUtilities.newArrayList)8 Bookmark (org.finos.waltz.model.bookmark.Bookmark)8 Collections.emptyList (java.util.Collections.emptyList)7 Collectors (java.util.stream.Collectors)7 CollectionUtilities.first (org.finos.waltz.common.CollectionUtilities.first)7