Search in sources :

Example 1 with INBOUND

use of org.finos.waltz.model.FlowDirection.INBOUND 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

BigDecimal (java.math.BigDecimal)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Future (java.util.concurrent.Future)1 Supplier (java.util.function.Supplier)1 Collectors (java.util.stream.Collectors)1 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)1 DBExecutorPoolInterface (org.finos.waltz.data.DBExecutorPoolInterface)1 JooqUtilities (org.finos.waltz.data.JooqUtilities)1 EntityKind (org.finos.waltz.model.EntityKind)1 DATA_TYPE (org.finos.waltz.model.EntityKind.DATA_TYPE)1 EntityLifecycleStatus (org.finos.waltz.model.EntityLifecycleStatus)1 REMOVED (org.finos.waltz.model.EntityLifecycleStatus.REMOVED)1 EntityReference (org.finos.waltz.model.EntityReference)1 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)1 FlowDirection (org.finos.waltz.model.FlowDirection)1 INBOUND (org.finos.waltz.model.FlowDirection.INBOUND)1 OUTBOUND (org.finos.waltz.model.FlowDirection.OUTBOUND)1 org.finos.waltz.model.logical_flow (org.finos.waltz.model.logical_flow)1