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());
}
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");
}
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())));
}
Aggregations