Skip to content

Commit

Permalink
Merge pull request #7054 from deutschebank/db-contrib/waltz-7047-euda…
Browse files Browse the repository at this point in the history
…-flow-viz

Db contrib/waltz 7047 euda flow viz
  • Loading branch information
davidwatkins73 authored Apr 15, 2024
2 parents 293dda5 + 7d47360 commit 460c4ce
Show file tree
Hide file tree
Showing 24 changed files with 152 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public Select<Record1<Long>> apply(IdSelectionOptions options) {
switch(options.entityReference().kind()) {
case ACTOR:
case APPLICATION:
// all physical flows where the app is a source or target
case END_USER_APPLICATION:
// all physical flows where the node is a source or target
return mkForFlowEndpoint(options);
case ALL:
case APP_GROUP:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,23 @@ public class FlowDiagramEntityDao {
EntityKind.ACTOR,
EntityKind.CHANGE_INITIATIVE,
EntityKind.DATA_TYPE,
EntityKind.END_USER_APPLICATION,
EntityKind.LOGICAL_DATA_FLOW,
EntityKind.MEASURABLE,
EntityKind.PHYSICAL_FLOW);

private static Field<String> ENTITY_NAME_FIELD = InlineSelectFieldFactory.mkNameField(
private static final Field<String> ENTITY_NAME_FIELD = InlineSelectFieldFactory.mkNameField(
fde.ENTITY_ID,
fde.ENTITY_KIND,
POSSIBLE_ENTITY_KINDS);


private static Field<String> ENTITY_LIFECYCLE_PHASE_FIELD = InlineSelectFieldFactory.mkEntityLifecycleField(
private static final Field<String> ENTITY_LIFECYCLE_PHASE_FIELD = InlineSelectFieldFactory.mkEntityLifecycleField(
fde.ENTITY_ID,
fde.ENTITY_KIND,
POSSIBLE_ENTITY_KINDS);



private static final RecordMapper<Record, FlowDiagramEntity> TO_DOMAIN_MAPPER = r -> {
FlowDiagramEntityRecord record = r.into(FLOW_DIAGRAM_ENTITY);
EntityReference ref = mkRef(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,23 @@ public class LogicalFlowDao {
private static final Field<String> SOURCE_NAME_FIELD = InlineSelectFieldFactory.mkNameField(
LOGICAL_FLOW.SOURCE_ENTITY_ID,
LOGICAL_FLOW.SOURCE_ENTITY_KIND,
newArrayList(EntityKind.APPLICATION, EntityKind.ACTOR));
newArrayList(EntityKind.APPLICATION, EntityKind.ACTOR, EntityKind.END_USER_APPLICATION));


private static final Field<String> TARGET_NAME_FIELD = InlineSelectFieldFactory.mkNameField(
LOGICAL_FLOW.TARGET_ENTITY_ID,
LOGICAL_FLOW.TARGET_ENTITY_KIND,
newArrayList(EntityKind.APPLICATION, EntityKind.ACTOR));
newArrayList(EntityKind.APPLICATION, EntityKind.ACTOR, EntityKind.END_USER_APPLICATION));

private static final Field<String> SOURCE_EXTERNAL_ID_FIELD = InlineSelectFieldFactory.mkExternalIdField(
LOGICAL_FLOW.SOURCE_ENTITY_ID,
LOGICAL_FLOW.SOURCE_ENTITY_KIND,
newArrayList(EntityKind.APPLICATION, EntityKind.ACTOR));
newArrayList(EntityKind.APPLICATION, EntityKind.ACTOR, EntityKind.END_USER_APPLICATION));

private static final Field<String> TARGET_EXTERNAL_ID_FIELD = InlineSelectFieldFactory.mkExternalIdField(
LOGICAL_FLOW.TARGET_ENTITY_ID,
LOGICAL_FLOW.TARGET_ENTITY_KIND,
newArrayList(EntityKind.APPLICATION, EntityKind.ACTOR));
newArrayList(EntityKind.APPLICATION, EntityKind.ACTOR, EntityKind.END_USER_APPLICATION));


public static final RecordMapper<Record, LogicalFlow> TO_DOMAIN_MAPPER = r -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.finos.waltz.data.logical_flow;

import org.finos.waltz.model.EntityReference;
import org.finos.waltz.schema.tables.Application;
import org.finos.waltz.data.IdSelectorFactory;
import org.finos.waltz.data.SelectorUtilities;
Expand Down Expand Up @@ -62,7 +63,8 @@ public Select<Record1<Long>> apply(IdSelectionOptions options) {
checkNotNull(options, "options cannot be null");
switch (options.entityReference().kind()) {
case ACTOR:
return mkForActor(options);
case END_USER_APPLICATION:
return mkForSpecificNode(options);
case ALL:
case APPLICATION:
case APP_GROUP:
Expand Down Expand Up @@ -93,14 +95,16 @@ public Select<Record1<Long>> apply(IdSelectionOptions options) {
}
}

private Select<Record1<Long>> mkForActor(IdSelectionOptions options) {

private Select<Record1<Long>> mkForSpecificNode(IdSelectionOptions options) {
SelectorUtilities.ensureScopeIsExact(options);
EntityReference ref = options.entityReference();

Condition sourceCondition = LOGICAL_FLOW.SOURCE_ENTITY_ID.eq(options.entityReference().id())
.and(LOGICAL_FLOW.SOURCE_ENTITY_KIND.eq(EntityKind.ACTOR.name()));
Condition sourceCondition = LOGICAL_FLOW.SOURCE_ENTITY_ID.eq(ref.id())
.and(LOGICAL_FLOW.SOURCE_ENTITY_KIND.eq(ref.kind().name()));

Condition targetCondition = LOGICAL_FLOW.TARGET_ENTITY_ID.eq(options.entityReference().id())
.and(LOGICAL_FLOW.TARGET_ENTITY_KIND.eq(EntityKind.ACTOR.name()));
Condition targetCondition = LOGICAL_FLOW.TARGET_ENTITY_ID.eq(ref.id())
.and(LOGICAL_FLOW.TARGET_ENTITY_KIND.eq(ref.kind().name()));

return DSL
.select(LOGICAL_FLOW.ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class LogicalFlowStatsDao {
private static final org.finos.waltz.schema.tables.LogicalFlowDecorator lfd = LogicalFlowDecorator.LOGICAL_FLOW_DECORATOR.as("lfd");
private static final Application counterpart_app = APPLICATION.as("counterpart_app");
private static final Actor counterpart_actor = ACTOR.as("counterpart_actor");
private static final EndUserApplication counterpart_euc = END_USER_APPLICATION.as("counterpart_euc");
private static final DataType rollup_dt = Tables.DATA_TYPE.as("rollup_dt");
private static final DataType actual_dt = Tables.DATA_TYPE.as("actual_dt");

Expand Down Expand Up @@ -256,8 +257,10 @@ public Map<FlowDirection, Set<FlowInfo>> getFlowInfoByDirection(EntityReference

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 sourceEucCondition = lf.SOURCE_ENTITY_ID.eq(counterpart_euc.ID).and(lf.SOURCE_ENTITY_KIND.eq(EntityKind.END_USER_APPLICATION.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 targetEucCondition = lf.TARGET_ENTITY_ID.eq(counterpart_euc.ID).and(lf.TARGET_ENTITY_KIND.eq(EntityKind.END_USER_APPLICATION.name()));

Condition dataTypeCondition = datatypeId == null ? rollup_dt.PARENT_ID.isNull() : rollup_dt.PARENT_ID.eq(datatypeId);

Expand All @@ -267,13 +270,15 @@ public Map<FlowDirection, Set<FlowInfo>> getFlowInfoByDirection(EntityReference
SelectConditionStep<Record11<Long, Long, String, Long, Long, String, String, Long, String, String, String>> sourceQry = mkDirectionalQuery(
sourceAppCondition,
sourceActorCondition,
sourceEucCondition,
dataTypeCondition,
isDownstream,
INBOUND);

SelectConditionStep<Record11<Long, Long, String, Long, Long, String, String, Long, String, String, String>> targetQry = mkDirectionalQuery(
targetAppCondition,
targetActorCondition,
targetEucCondition,
dataTypeCondition,
isUpstream,
OUTBOUND);
Expand Down Expand Up @@ -315,6 +320,7 @@ record -> {

private SelectConditionStep<Record11<Long, Long, String, Long, Long, String, String, Long, String, String, String>> mkDirectionalQuery(Condition appDirectionCondition,
Condition actorDirectionCondition,
Condition eucDirectionCondition,
Condition dataTypeCondition,
Condition parentDirection,
FlowDirection direction) {
Expand All @@ -326,10 +332,13 @@ private SelectConditionStep<Record11<Long, Long, String, Long, Long, String, Str
FLOW_CLASSIFICATION.ID,
actual_dt.ID,
actual_dt.NAME,
DSL.when(counterpart_app.ID.isNotNull(), DSL.val("APPLICATION")).otherwise(DSL.val("ACTOR")).as("counterpart_kind"),
DSL.coalesce(counterpart_app.ID, counterpart_actor.ID).as("counterpart_id"),
DSL.when(counterpart_app.ID.isNotNull(), DSL.val(EntityKind.APPLICATION.name()))
.when(counterpart_actor.ID.isNotNull(), DSL.val(EntityKind.ACTOR.name()))
.when(counterpart_euc.ID.isNotNull(), DSL.val(EntityKind.END_USER_APPLICATION.name()))
.as("counterpart_kind"),
DSL.coalesce(counterpart_app.ID, counterpart_actor.ID, counterpart_euc.ID).as("counterpart_id"),
lf.ENTITY_LIFECYCLE_STATUS,
DSL.coalesce(counterpart_app.NAME, counterpart_actor.NAME).as("counterpart_name"),
DSL.coalesce(counterpart_app.NAME, counterpart_actor.NAME, counterpart_euc.NAME).as("counterpart_name"),
DSL.val(direction.name()).as("direction"))
.from(lf)
.innerJoin(lfd).on(lf.ID.eq(lfd.LOGICAL_FLOW_ID))
Expand All @@ -341,6 +350,7 @@ private SelectConditionStep<Record11<Long, Long, String, Long, Long, String, Str
.innerJoin(FLOW_CLASSIFICATION).on(lfd.RATING.eq(FLOW_CLASSIFICATION.CODE))
.leftJoin(counterpart_app).on(appDirectionCondition)
.leftJoin(counterpart_actor).on(actorDirectionCondition)
.leftJoin(counterpart_euc).on(eucDirectionCondition)
.where(NOT_REMOVED)
.and(dataTypeCondition)
.and(parentDirection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public Select<Record1<Long>> apply(IdSelectionOptions options) {
case APPLICATION:
case ACTOR:
case APP_GROUP:
case END_USER_APPLICATION:
case CHANGE_INITIATIVE:
case MEASURABLE:
case ORG_UNIT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public Select<Record1<Long>> apply(IdSelectionOptions options) {
switch(options.entityReference().kind()) {
case ACTOR:
case APPLICATION:
return mkForApplicationOrActor(options);
case END_USER_APPLICATION:
return mkForSpecificNode(options);
case PHYSICAL_FLOW:
return mkForPhysicalFlow(options);
case LOGICAL_DATA_ELEMENT:
Expand All @@ -72,7 +73,7 @@ public Select<Record1<Long>> apply(IdSelectionOptions options) {
}


private Select<Record1<Long>> mkForApplicationOrActor(IdSelectionOptions options) {
private Select<Record1<Long>> mkForSpecificNode(IdSelectionOptions options) {
SelectorUtilities.ensureScopeIsExact(options);

Condition lifecycleCondition = options.entityLifecycleStatuses().contains(EntityLifecycleStatus.REMOVED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public Select<Record1<Long>> apply(IdSelectionOptions options) {
checkNotNull(options, "options cannot be null");
switch(options.entityReference().kind()) {
case ACTOR:
case END_USER_APPLICATION:
return mkForSpecificEntity(options);
case ALL:
case APPLICATION:
case CHANGE_INITIATIVE:
Expand All @@ -58,6 +60,18 @@ public Select<Record1<Long>> apply(IdSelectionOptions options) {
}


private Select<Record1<Long>> mkForSpecificEntity(IdSelectionOptions options) {

return DSL
.select(PROCESS_DIAGRAM_ENTITY.DIAGRAM_ID)
.from(PROCESS_DIAGRAM_ENTITY)
.innerJoin(MEASURABLE_RATING).on(PROCESS_DIAGRAM_ENTITY.ENTITY_ID.eq(MEASURABLE_RATING.MEASURABLE_ID)
.and(PROCESS_DIAGRAM_ENTITY.ENTITY_KIND.eq(EntityKind.MEASURABLE.name())))
.where(MEASURABLE_RATING.ENTITY_ID.eq(options.entityReference().id())
.and(MEASURABLE_RATING.ENTITY_KIND.eq(options.entityReference().kind().name())));
}


private Select<Record1<Long>> mkViaApplication(IdSelectionOptions options) {

Select<Record1<Long>> relatedApplications = applicationIdSelectorFactory.apply(options);
Expand Down
17 changes: 17 additions & 0 deletions waltz-ng/client/common/entity-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import _ from "lodash";
import {checkIsEntityRef} from "./checks";
import {CORE_API} from "./services/core-api-utils";
import {applicationStore} from "../svelte-stores/application-store";
import {actorStore} from "../svelte-stores/actor-store";
import {endUserApplicationStore} from "../svelte-stores/end-user-application-store";

export function sameRef(r1, r2, options = { skipChecks: false }) {
if (! options.skipChecks) {
Expand Down Expand Up @@ -138,6 +141,20 @@ export function loadEntity(serviceBroker, entityRef) {
}


export function loadSvelteEntity(entityRef, force = false) {
const id = entityRef.id;
switch (entityRef.kind) {
case "APPLICATION":
return applicationStore.getById(id, force);
case "ACTOR":
return actorStore.getById(id, force);
case "END_USER_APPLICATION":
return endUserApplicationStore.getById(id, force);
default:
throw "Don't know how to load entity for kind: " + entityRef.kind;
}
}

export function loadByExtId(serviceBroker, kind, extId) {
try {
const remoteCall = determineLoadByExtIdCall(kind);
Expand Down
1 change: 1 addition & 0 deletions waltz-ng/client/common/selector-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export function determineDownwardsScopeForKind(kind) {
case "APPLICATION":
case "APP_GROUP":
case "CHANGE_INITIATIVE":
case "END_USER_APPLICATION":
case "FLOW_DIAGRAM":
case "LICENCE":
case "LEGAL_ENTITY":
Expand Down
4 changes: 4 additions & 0 deletions waltz-ng/client/common/svelte/ViewLink.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
path: ctx => `flow-diagram/${ctx.id}`,
title: "Flow Diagram View"
},
"main.end-user-application.view": {
path: ctx => `end-user-application/id/${ctx.id}`,
title: "End User Application View"
},
"main.flow-classification-rule.view": {
path: ctx => `flow-classification-rule/${ctx.id}`,
title: "Flow Classification Rule View"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import LogicalDataFlowPanel from "./LogicalDataFlowInfoPanel.svelte"
import SurveyInstanceInfoPanel from "./SurveyInstanceInfoPanel.svelte";
import PersonInfoPanel from "./PersonInfoPanel.svelte";
import EndUserApplicationInfoPanel from "./EndUserApplicationInfoPanel.svelte";
export let primaryEntityRef;
Expand All @@ -21,6 +22,8 @@
return ChangeInitiativeInfoPanel;
case "DATA_TYPE":
return DataTypeInfoPanel;
case "END_USER_APPLICATION":
return EndUserApplicationInfoPanel;
case "LOGICAL_DATA_FLOW":
return LogicalDataFlowPanel;
case "MEASURABLE":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,14 @@
import Icon from "../../../common/svelte/Icon.svelte";
import NoData from "../../../common/svelte/NoData.svelte";
import {flowClassificationStore} from "../../../svelte-stores/flow-classification-store";
import {sameRef} from "../../../common/entity-utils";
import {loadSvelteEntity, sameRef} from "../../../common/entity-utils";
export let primaryEntityRef;
let flowGraphSummaryCall = logicalFlowStore.getFlowGraphSummary(primaryEntityRef, null);
let flowClassificationCall = flowClassificationStore.findAll()
let physicalFlowCall = physicalFlowStore.findBySelector(mkSelectionOptions(primaryEntityRef, "EXACT"));
let entityCall = primaryEntityRef.kind === 'APPLICATION'
? applicationStore.getById(primaryEntityRef.id)
: actorStore.getById(primaryEntityRef.id);
let entityCall = loadSvelteEntity(primaryEntityRef);
let breadcrumbs = [];
let additionalBreadcrumbs = [];
Expand Down Expand Up @@ -75,8 +73,8 @@
$: baseBreadcrumb = {
id: -1,
name: $flowDirection === flowDirections.INBOUND
? `${$focusClient?.name || entity.name} Inbound flows`
: `${$focusClient?.name || entity.name} Outbound flows`,
? `${$focusClient?.name || entity?.name} Inbound flows`
: `${$focusClient?.name || entity?.name} Outbound flows`,
classes: "breadcrumb-root",
onClick: () => {
const parent = $focusClient || entity
Expand All @@ -87,7 +85,7 @@
$: homeBreadcrumb = {
id: -2,
name: `Home (${entity.name})`,
name: `Home (${entity?.name})`,
classes: "breadcrumb-home",
onClick: () => {
$focusClient = null;
Expand Down Expand Up @@ -197,7 +195,7 @@
}
</script>
{#if entity}
<div class="row">
<div class="col-md-12">
<ol class="breadcrumb">
Expand Down Expand Up @@ -299,6 +297,7 @@
</div>
</div>
</div>
{/if}
<style>
svg {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const colors = {
ACTOR: {
fill: "#f0e9ff",
stroke: "#9f75fd"
},
END_USER_APPLICATION: {
fill: "#fff0e9",
stroke: "#fd9575"
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
const shapes = {
ACTOR: (widthHint = 100) => Object.assign({}, mkTrapezoidShape(widthHint), {icon: "\uf2be"}, {svgIcon: getSymbol("user")}), // user-circle-o
APPLICATION: (widthHint = 100) => Object.assign({}, mkRectShape(widthHint), {icon: "\uf108"}, {svgIcon: getSymbol("desktop")}), // desktop
END_USER_APPLICATION: (widthHint = 100) => Object.assign({}, mkRectShape(widthHint), {icon: "\uf109"}), // laptop
EUC: (widthHint = 100) => Object.assign({}, mkRectShape(widthHint), {icon: "\uf109"}), // laptop
DEFAULT: (widthHint = 100) => Object.assign({}, mkRectShape(widthHint), {icon: "\uf096"})
};
Expand All @@ -68,14 +69,14 @@
$: associatedGroups = _.filter(groups, g => _.includes(g.data.applicationIds, node.data.id));
$: classes = [
"wfd-node",
$overlay.appliedOverlay && !_.includes(associatedGroups, $overlay.appliedOverlay)
? "wfd-not-active"
: "wfd-active",
$selectedNode && toGraphId($selectedNode) === node.id
? 'wfd-selected-node'
: ''
].join(" ");
"wfd-node",
$overlay.appliedOverlay && !_.includes(associatedGroups, $overlay.appliedOverlay)
? "wfd-not-active"
: "wfd-active",
$selectedNode && toGraphId($selectedNode) === node.id
? 'wfd-selected-node'
: '']
.join(" ");
$: nodeStyling = determineStylingBasedUponLifecycle(node.data.entityLifecycleStatus);
Expand Down
Loading

0 comments on commit 460c4ce

Please sign in to comment.