use of org.finos.waltz.model.FlowDirection.OUTBOUND 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())));
}
Aggregations