Search in sources :

Example 1 with FlowDirection

use of org.finos.waltz.model.FlowDirection in project waltz by khartec.

the class LogicalFlowDecoratorService method findFlowIdsByDataTypeForParentsAndChildren.

private Set<LogicalFlowDecoratorStat> findFlowIdsByDataTypeForParentsAndChildren(Map<DataTypeDirectionKey, List<Long>> logicalFlowIdsByDataType) {
    List<DataType> dataTypes = dataTypeDao.findAll();
    Map<Optional<Long>, DataType> dataTypesById = indexBy(IdProvider::id, dataTypes);
    return dataTypes.stream().map(dt -> {
        DataType exactDataType = dataTypesById.get(dt.id());
        Set<DataTypeDirectionKey> keysForDatatype = filterKeySetByDataTypeId(logicalFlowIdsByDataType, asSet(dt.id().get()));
        Set<DataType> parentDataTypes = getParents(exactDataType, dataTypesById);
        Set<DataTypeDirectionKey> keysForParents = filterKeySetByDataTypeId(logicalFlowIdsByDataType, getIds(parentDataTypes));
        Set<DataType> childDataTypes = getChildren(exactDataType, dataTypesById);
        Set<DataTypeDirectionKey> keysForChildren = filterKeySetByDataTypeId(logicalFlowIdsByDataType, getIds(childDataTypes));
        Set<DataTypeDirectionKey> allKeys = union(keysForDatatype, keysForParents, keysForChildren);
        Set<Long> allFlowIds = getFlowsFromKeys(logicalFlowIdsByDataType, allKeys);
        Map<FlowDirection, Integer> typeToFlowCountMap = getTypeToFlowCountMap(logicalFlowIdsByDataType, allKeys);
        return mkLogicalFlowDecoratorStat(dt, typeToFlowCountMap, allFlowIds);
    }).filter(r -> r.totalCount() > 0).collect(Collectors.toSet());
}
Also used : AuthoritativenessRatingValue(org.finos.waltz.model.rating.AuthoritativenessRatingValue) java.util(java.util) LogicalFlowDao(org.finos.waltz.data.logical_flow.LogicalFlowDao) org.finos.waltz.model(org.finos.waltz.model) Autowired(org.springframework.beans.factory.annotation.Autowired) SetUtilities.asSet(org.finos.waltz.common.SetUtilities.asSet) CollectionUtilities.map(org.finos.waltz.common.CollectionUtilities.map) ImmutableChangeLog(org.finos.waltz.model.changelog.ImmutableChangeLog) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) DataType(org.finos.waltz.model.datatype.DataType) LogicalFlowDecoratorSummaryDao(org.finos.waltz.data.data_flow_decorator.LogicalFlowDecoratorSummaryDao) ChangeLog(org.finos.waltz.model.changelog.ChangeLog) Record1(org.jooq.Record1) Service(org.springframework.stereotype.Service) LogicalFlowService(org.finos.waltz.service.logical_flow.LogicalFlowService) FlowDirection(org.finos.waltz.model.FlowDirection) IdUtilities.indexById(org.finos.waltz.model.utils.IdUtilities.indexById) DataTypeUsageService(org.finos.waltz.service.usage_info.DataTypeUsageService) ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory) Select(org.jooq.Select) ChangeLogService(org.finos.waltz.service.changelog.ChangeLogService) Checks.checkNotEmpty(org.finos.waltz.common.Checks.checkNotEmpty) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) Collections.emptySet(java.util.Collections.emptySet) DataTypeDecorator(org.finos.waltz.model.datatype.DataTypeDecorator) Collections.emptyList(java.util.Collections.emptyList) ImmutableLogicalFlowMeasures(org.finos.waltz.model.logical_flow.ImmutableLogicalFlowMeasures) ImmutableDataTypeDecorator(org.finos.waltz.model.datatype.ImmutableDataTypeDecorator) Collectors(java.util.stream.Collectors) Collectors.joining(java.util.stream.Collectors.joining) MapUtilities.indexBy(org.finos.waltz.common.MapUtilities.indexBy) org.finos.waltz.model.data_flow_decorator(org.finos.waltz.model.data_flow_decorator) SetUtilities.union(org.finos.waltz.common.SetUtilities.union) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) LogicalFlowDecoratorDao(org.finos.waltz.data.datatype_decorator.LogicalFlowDecoratorDao) Stream(java.util.stream.Stream) Tuple.tuple(org.jooq.lambda.tuple.Tuple.tuple) ListUtilities.asList(org.finos.waltz.common.ListUtilities.asList) ListUtilities(org.finos.waltz.common.ListUtilities) DateTimeUtilities.nowUtc(org.finos.waltz.common.DateTimeUtilities.nowUtc) SetUtilities(org.finos.waltz.common.SetUtilities) Checks(org.finos.waltz.common.Checks) DataTypeDao(org.finos.waltz.data.data_type.DataTypeDao) LogicalFlowStatsDao(org.finos.waltz.data.logical_flow.LogicalFlowStatsDao) FlowDirection(org.finos.waltz.model.FlowDirection) DataType(org.finos.waltz.model.datatype.DataType)

Example 2 with FlowDirection

use of org.finos.waltz.model.FlowDirection in project waltz by khartec.

the class LogicalFlowStatsHarness method main.

public static void main(String[] args) throws ParseException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    LogicalFlowStatsDao dao = ctx.getBean(LogicalFlowStatsDao.class);
    Map<FlowDirection, Set<FlowInfo>> flowInfoByDirection = dao.getFlowInfoByDirection(mkRef(EntityKind.APPLICATION, 20506L), null);
    System.out.println("--done");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Set(java.util.Set) FlowDirection(org.finos.waltz.model.FlowDirection) DSLContext(org.jooq.DSLContext) LogicalFlowStatsDao(org.finos.waltz.data.logical_flow.LogicalFlowStatsDao)

Example 3 with FlowDirection

use of org.finos.waltz.model.FlowDirection in project waltz by khartec.

the class LogicalFlowStatsDao method getFlowInfoByDirection.

public Map<FlowDirection, Set<FlowInfo>> getFlowInfoByDirection(EntityReference ref, Long datatypeId) {
    Condition sourceAppCondition = lf.SOURCE_ENTITY_ID.eq(counterpart_app.ID).and(lf.SOURCE_ENTITY_KIND.eq(EntityKind.APPLICATION.name()));
    Condition sourceActorCondition = lf.SOURCE_ENTITY_ID.eq(counterpart_actor.ID).and(lf.SOURCE_ENTITY_KIND.eq(EntityKind.ACTOR.name()));
    Condition targetAppCondition = lf.TARGET_ENTITY_ID.eq(counterpart_app.ID).and(lf.TARGET_ENTITY_KIND.eq(EntityKind.APPLICATION.name()));
    Condition targetActorCondition = lf.TARGET_ENTITY_ID.eq(counterpart_actor.ID).and(lf.TARGET_ENTITY_KIND.eq(EntityKind.ACTOR.name()));
    Condition dataTypeCondition = datatypeId == null ? rollup_dt.PARENT_ID.isNull() : rollup_dt.PARENT_ID.eq(datatypeId);
    Condition isUpstream = lf.SOURCE_ENTITY_ID.eq(ref.id()).and(lf.SOURCE_ENTITY_KIND.eq(ref.kind().name()));
    Condition isDownstream = lf.TARGET_ENTITY_ID.eq(ref.id()).and(lf.TARGET_ENTITY_KIND.eq(ref.kind().name()));
    SelectConditionStep<Record11<Long, Long, String, Long, Long, String, String, Long, String, String, String>> sourceQry = mkDirectionalQuery(sourceAppCondition, sourceActorCondition, dataTypeCondition, isDownstream, INBOUND);
    SelectConditionStep<Record11<Long, Long, String, Long, Long, String, String, Long, String, String, String>> targetQry = mkDirectionalQuery(targetAppCondition, targetActorCondition, dataTypeCondition, isUpstream, OUTBOUND);
    SelectOrderByStep<Record11<Long, Long, String, Long, Long, String, String, Long, String, String, String>> unionedData = sourceQry.union(targetQry);
    return unionedData.fetch().stream().collect(groupingBy(record -> {
        String directionStr = record.get("direction", String.class);
        return FlowDirection.valueOf(directionStr);
    }, mapping(r -> {
        EntityReference rollupDtRef = mkRef(DATA_TYPE, r.get(rollup_dt.ID), r.get(rollup_dt.NAME));
        EntityReference actualDtRef = mkRef(DATA_TYPE, r.get(actual_dt.ID), r.get(actual_dt.NAME));
        EntityReference counterpartRef = mkRef(EntityKind.valueOf(r.get("counterpart_kind", String.class)), r.get("counterpart_id", Long.class), r.get("counterpart_name", String.class));
        return (FlowInfo) ImmutableFlowInfo.builder().classificationId(r.get(FLOW_CLASSIFICATION.ID)).rollupDataType(rollupDtRef).actualDataType(actualDtRef).counterpart(counterpartRef).flowEntityLifecycleStatus(EntityLifecycleStatus.valueOf(r.get(lf.ENTITY_LIFECYCLE_STATUS))).flowId(r.get(lf.ID)).build();
    }, toSet())));
}
Also used : org.finos.waltz.schema.tables(org.finos.waltz.schema.tables) DSL(org.jooq.impl.DSL) APPLICATION(org.finos.waltz.schema.tables.Application.APPLICATION) Tables(org.finos.waltz.schema.Tables) EntityKind(org.finos.waltz.model.EntityKind) Tally(org.finos.waltz.model.tally.Tally) Autowired(org.springframework.beans.factory.annotation.Autowired) Supplier(java.util.function.Supplier) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) BigDecimal(java.math.BigDecimal) LOGICAL_FLOW(org.finos.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW) Future(java.util.concurrent.Future) DataType(org.finos.waltz.schema.tables.DataType) org.jooq(org.jooq) Map(java.util.Map) TallyPack(org.finos.waltz.model.tally.TallyPack) FlowDirection(org.finos.waltz.model.FlowDirection) Repository(org.springframework.stereotype.Repository) EntityLifecycleStatus(org.finos.waltz.model.EntityLifecycleStatus) ImmutableTally(org.finos.waltz.model.tally.ImmutableTally) Unchecked(org.jooq.lambda.Unchecked) JooqUtilities(org.finos.waltz.data.JooqUtilities) Set(java.util.Set) org.finos.waltz.model.logical_flow(org.finos.waltz.model.logical_flow) Collectors(java.util.stream.Collectors) DBExecutorPoolInterface(org.finos.waltz.data.DBExecutorPoolInterface) List(java.util.List) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) INBOUND(org.finos.waltz.model.FlowDirection.INBOUND) LogicalFlow(org.finos.waltz.schema.tables.LogicalFlow) EntityReference(org.finos.waltz.model.EntityReference) ImmutableTallyPack(org.finos.waltz.model.tally.ImmutableTallyPack) OUTBOUND(org.finos.waltz.model.FlowDirection.OUTBOUND) DATA_TYPE(org.finos.waltz.model.EntityKind.DATA_TYPE) REMOVED(org.finos.waltz.model.EntityLifecycleStatus.REMOVED) EntityReference(org.finos.waltz.model.EntityReference)

Aggregations

FlowDirection (org.finos.waltz.model.FlowDirection)3 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)2 LogicalFlowStatsDao (org.finos.waltz.data.logical_flow.LogicalFlowStatsDao)2 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 BigDecimal (java.math.BigDecimal)1 java.util (java.util)1 Collections.emptyList (java.util.Collections.emptyList)1 Collections.emptySet (java.util.Collections.emptySet)1 List (java.util.List)1 Map (java.util.Map)1 Future (java.util.concurrent.Future)1 Supplier (java.util.function.Supplier)1 Collectors.joining (java.util.stream.Collectors.joining)1 Stream (java.util.stream.Stream)1 Checks (org.finos.waltz.common.Checks)1 Checks.checkNotEmpty (org.finos.waltz.common.Checks.checkNotEmpty)1 CollectionUtilities.map (org.finos.waltz.common.CollectionUtilities.map)1