Skip to content

Commit

Permalink
Merge branch 'master' into db-contrib/waltz-7031-update-flow-viz-with…
Browse files Browse the repository at this point in the history
…-inbound-rating-toggle
  • Loading branch information
davidwatkins73 authored Apr 29, 2024
2 parents d4abd0e + 2170afb commit 93f3d6e
Show file tree
Hide file tree
Showing 22 changed files with 847 additions and 445 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public class FlowClassificationRuleDao {
private final static EntityHierarchy ehDataType = ENTITY_HIERARCHY.as("ehDataType");
public static final Field<Long> vantagePointId = DSL.coalesce(ehOrgUnit.ID, FLOW_CLASSIFICATION_RULE.PARENT_ID);
public static final Field<Integer> vantagePointLevel = DSL.coalesce(ehOrgUnit.LEVEL, 0).as("parentLevel");
public static final Field<Integer> dataTypeLevel = DSL.coalesce(ehDataType.LEVEL, 0).as("dataTypeLevel");
private static final Field<String> PARENT_NAME_FIELD = InlineSelectFieldFactory.mkNameField(
FLOW_CLASSIFICATION_RULE.PARENT_ID,
FLOW_CLASSIFICATION_RULE.PARENT_KIND,
Expand Down Expand Up @@ -164,18 +165,20 @@ public class FlowClassificationRuleDao {
};


private static final RecordMapper<Record, FlowClassificationRuleVantagePoint> TO_VANTAGE_MAPPER = r -> ImmutableFlowClassificationRuleVantagePoint
.builder()
.vantagePoint(mkRef(EntityKind.valueOf(r.get(FLOW_CLASSIFICATION_RULE.PARENT_KIND)), r.get(vantagePointId))) // could be child org unit
.vantagePointRank(r.get(vantagePointLevel))
.subjectReference(mkRef(EntityKind.valueOf(r.get(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_KIND)), r.get(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_ID)))
.classificationCode(r.get(FLOW_CLASSIFICATION.CODE))
.dataType(mkRef(EntityKind.DATA_TYPE, r.get(ehDataType.ID)))
.dataTypeRank(r.get(ehDataType.LEVEL))
.ruleId(r.get(FLOW_CLASSIFICATION_RULE.ID))
.message(r.get(FLOW_CLASSIFICATION_RULE.MESSAGE))
.messageSeverity(Severity.valueOf(r.get(FLOW_CLASSIFICATION_RULE.MESSAGE_SEVERITY)))
.build();
private static final RecordMapper<Record, FlowClassificationRuleVantagePoint> TO_VANTAGE_MAPPER = r -> {
return ImmutableFlowClassificationRuleVantagePoint
.builder()
.vantagePoint(mkRef(EntityKind.valueOf(r.get(FLOW_CLASSIFICATION_RULE.PARENT_KIND)), r.get(vantagePointId))) // could be child org unit
.vantagePointRank(r.get(vantagePointLevel))
.subjectReference(mkRef(EntityKind.valueOf(r.get(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_KIND)), r.get(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_ID)))
.classificationCode(r.get(FLOW_CLASSIFICATION.CODE))
.dataTypeId(r.get(ehDataType.ID))
.dataTypeRank(r.get(dataTypeLevel))
.ruleId(r.get(FLOW_CLASSIFICATION_RULE.ID))
.message(r.get(FLOW_CLASSIFICATION_RULE.MESSAGE))
.messageSeverity(Severity.valueOf(r.get(FLOW_CLASSIFICATION_RULE.MESSAGE_SEVERITY)))
.build();
};



Expand Down Expand Up @@ -366,7 +369,7 @@ public List<FlowClassificationRuleVantagePoint> findExpandedFlowClassificationRu
FLOW_CLASSIFICATION_RULE.PARENT_KIND,
vantagePointLevel,
ehDataType.ID,
ehDataType.LEVEL,
dataTypeLevel,
FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_ID,
FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_KIND,
FLOW_CLASSIFICATION.CODE,
Expand All @@ -376,7 +379,7 @@ public List<FlowClassificationRuleVantagePoint> findExpandedFlowClassificationRu
.from(FLOW_CLASSIFICATION_RULE)
.innerJoin(FLOW_CLASSIFICATION).on(FLOW_CLASSIFICATION.DIRECTION.eq(direction.name())
.and(FLOW_CLASSIFICATION_RULE.FLOW_CLASSIFICATION_ID.eq(FLOW_CLASSIFICATION.ID)))
.innerJoin(ehDataType)
.leftJoin(ehDataType)
.on(ehDataType.KIND.eq(EntityKind.DATA_TYPE.name())
.and(ehDataType.ANCESTOR_ID.eq(FLOW_CLASSIFICATION_RULE.DATA_TYPE_ID)))
.leftJoin(ehOrgUnit)
Expand All @@ -401,7 +404,7 @@ private List<FlowClassificationRuleVantagePoint> findFlowClassificationRuleVanta
FLOW_CLASSIFICATION_RULE.PARENT_KIND,
vantagePointLevel,
ehDataType.ID,
ehDataType.LEVEL,
dataTypeLevel,
FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_ID,
FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_KIND,
FLOW_CLASSIFICATION.CODE,
Expand All @@ -413,18 +416,16 @@ private List<FlowClassificationRuleVantagePoint> findFlowClassificationRuleVanta
.on(ehOrgUnit.ANCESTOR_ID.eq(FLOW_CLASSIFICATION_RULE.PARENT_ID)
.and(ehOrgUnit.KIND.eq(EntityKind.ORG_UNIT.name()))
.and(ehOrgUnit.ID.eq(ehOrgUnit.ANCESTOR_ID)))
.innerJoin(DataType.DATA_TYPE)
.on(DataType.DATA_TYPE.ID.eq(FLOW_CLASSIFICATION_RULE.DATA_TYPE_ID))
.innerJoin(ehDataType)
.on(ehDataType.ANCESTOR_ID.eq(DataType.DATA_TYPE.ID)
.leftJoin(ehDataType)
.on(ehDataType.ANCESTOR_ID.eq(FLOW_CLASSIFICATION_RULE.DATA_TYPE_ID)
.and(ehDataType.KIND.eq(EntityKind.DATA_TYPE.name()))
.and(ehDataType.ID.eq(ehDataType.ANCESTOR_ID)))
.innerJoin(FLOW_CLASSIFICATION).on(FLOW_CLASSIFICATION_RULE.FLOW_CLASSIFICATION_ID.eq(FLOW_CLASSIFICATION.ID))
.where(condition)
.orderBy(
FLOW_CLASSIFICATION_RULE.PARENT_KIND, //ACTOR, APPLICATION, ORG_UNIT
vantagePointLevel.desc(),
ehDataType.LEVEL.desc(),
dataTypeLevel.desc(),
vantagePointId,
ehDataType.ID,
FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private static Map<Long, Tuple2<Long, MatchOutcome>> applyVantagePoints(FlowDire
.forEach(rvp -> {

Set<Long> childOUs = findChildren(ouHierarchy, rvp.vantagePoint().id());
Set<Long> childDTs = findChildren(dtHierarchy, rvp.dataType().id());
Set<Long> childDTs = findChildren(dtHierarchy, rvp.dataTypeId());
population.forEach(p -> {
Tuple2<Long, MatchOutcome> currentRuleAndOutcome = lfdIdToRuleAndOutcomeMap.get(p.lfdId());
if (currentRuleAndOutcome != null && currentRuleAndOutcome.v2 == MatchOutcome.POSITIVE_MATCH) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.immutables.value.Value;

import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
Expand All @@ -11,19 +12,27 @@ public abstract class EntityHierarchy {

public abstract List<EntityHierarchyItem> hierarchyItems();

public Set<Long> findChildren(long parentId) {
return hierarchyItems()
.stream()
.filter(t -> t.id().isPresent() && t.parentId().isPresent() && t.parentId().get() == parentId)
.map(t -> t.id().get())
.collect(Collectors.toSet());
public Set<Long> findChildren(Long parentId) {
if(parentId == null) {
return Collections.emptySet();
} else {
return hierarchyItems()
.stream()
.filter(t -> t.id().isPresent() && t.parentId().isPresent() && t.parentId().get().equals(parentId))
.map(t -> t.id().get())
.collect(Collectors.toSet());
}
}

public Set<Long> findAncestors(long childId) {
return hierarchyItems()
.stream()
.filter(t -> t.id().isPresent() && t.parentId().isPresent() && t.id().get() == childId)
.map(t -> t.parentId().get())
.collect(Collectors.toSet());
public Set<Long> findAncestors(Long childId) {
if(childId == null) {
return Collections.emptySet();
} else {
return hierarchyItems()
.stream()
.filter(t -> t.id().isPresent() && t.parentId().isPresent() && t.id().get().equals(childId))
.map(t -> t.parentId().get())
.collect(Collectors.toSet());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public abstract class FlowClassificationRuleVantagePoint {

public abstract EntityReference vantagePoint();
public abstract int vantagePointRank();
public abstract EntityReference dataType();
@Nullable
public abstract Long dataTypeId();
public abstract int dataTypeRank();

public abstract EntityReference subjectReference();
Expand Down
2 changes: 1 addition & 1 deletion waltz-ng/client/common/services/enums/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export const entity = {
},
END_USER_APPLICATION: {
key: "END_USER_APPLICATION",
name: "End User App",
name: "End User Application",
icon: "table",
description: null,
position: 1200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import {loadFlowClassificationRatings} from "../../../flow-classification-rule/f


const bindings = {
summaryData: "<"
summaryData: "<",
ratingDirection: "<"
};


Expand Down Expand Up @@ -197,12 +198,18 @@ function controller($element, serviceBroker) {
const vm = initialiseData(this, initialState);

let svg = null;

const redraw = () => drawData(
svg,
enrichData(vm.summaryData, vm.flowClassifications),
vm.flowClassifications);

vm.$onChanges = () => redraw();
vm.$onChanges = () => {

loadFlowClassificationRatings(serviceBroker)
.then(xs => vm.flowClassifications = _.filter(xs, d => d.direction === vm.ratingDirection))
.then(redraw);
}

vm.$onInit = () => {
const holder = $element.find("svg")[0];
Expand All @@ -214,10 +221,6 @@ function controller($element, serviceBroker) {
drawBackground(svg);
drawTitleBar(svg);
drawCenterLabels(svg);

loadFlowClassificationRatings(serviceBroker)
.then(xs => vm.flowClassifications = xs)
.then(redraw);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

<content>
<div style="padding: 8px">
<waltz-application-flow-summary-graph summary-data="$ctrl.stats.chartData">
<waltz-application-flow-summary-graph summary-data="$ctrl.stats.chartData"
rating-direction="$ctrl.ratingDirection">
</waltz-application-flow-summary-graph>

<p class="small help-block">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ import {categorizeDirection} from "../../../logical-flow/logical-flow-utils";
import {nest} from "d3-collection";

import template from "./application-flow-summary-pane.html";
import {tallyBy} from "../../../common/tally-utils";
import {color} from "d3-color";
import indexByKeyForType from "../../../enum-value/enum-value-utilities";
import {entity} from "../../../common/services/enums/entity";
import {loadFlowClassificationRatings} from "../../../flow-classification-rule/flow-classification-utils";
import {flowDirection as FlowDirection} from "../../../common/services/enums/flow-direction";


const bindings = {
parentEntityRef: "<"
parentEntityRef: "<",
ratingDirection: "<"
};


Expand Down Expand Up @@ -64,21 +63,24 @@ function enrichDecorators(parentEntityRef, unknownDataTypeId, logicalFlows = [],
}


function calcStats(enrichedDecorators = []) {
function calcStats(enrichedDecorators = [], ratingDirection = FlowDirection.OUTBOUND.key) {

const byDirectionAndMappingStatus = nest()
.key(d => d.direction)
.key(d => d.mappingStatus)
.object(enrichedDecorators);

const ratingMapper = d => ratingDirection === FlowDirection.OUTBOUND.key ? d.decorator.rating : d.decorator.targetInboundRating;

const byDirectionAndAuthoritativeness = nest()
.key(d => d.direction)
.key(d => d.decorator.rating)
.key(ratingMapper)
.object(enrichedDecorators);

const chartData = nest()
.key(d => d.direction)
.key(d => d.mappingStatus)
.key(d => d.decorator.rating)
.key(ratingMapper)
.rollup(xs => xs.length)
.object(enrichedDecorators);

Expand Down Expand Up @@ -119,29 +121,23 @@ function controller($q, serviceBroker) {
logicalFlows,
decorators);

vm.stats = calcStats(vm.enrichedDecorators);
vm.stats = calcStats(vm.enrichedDecorators, vm.ratingDirection);
});

const physicalFlowPromise = serviceBroker
.loadViewData(
CORE_API.PhysicalFlowStore.findByEntityReference,
[vm.parentEntityRef])
.then(r => r.data);
};

const loadUnknownDataType = () => {
const loadUnknownDataTypeId = () => {
return serviceBroker
.loadAppData(CORE_API.DataTypeStore.findAll)
.then(r => findUnknownDataTypeId(r.data));
.then(r => console.log(r.data) || findUnknownDataTypeId(r.data));
};


vm.$onInit = () => {
loadUnknownDataType()
.then(unknownDataType => reload(unknownDataType.id));
vm.$onChanges = () => {
loadUnknownDataTypeId()
.then(dtId => reload(dtId));

loadFlowClassificationRatings(serviceBroker)
.then(xs => vm.flowClassificationCols = xs);
.then(xs => vm.flowClassificationCols = console.log({xs, rd: vm.ratingDirection})
|| _.filter(xs, d => d.direction === vm.ratingDirection));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ <h4>Bulk Insert Logical Data Flows</h4>
<div ng-if="$ctrl.dataTypeUsages.length > 0 || $ctrl.logicalFlows.length > 0">
<div class='row'>
<div class="col-sm-6">
<waltz-application-flow-summary-pane parent-entity-ref="$ctrl.parentEntityRef">
<waltz-application-flow-summary-pane parent-entity-ref="$ctrl.parentEntityRef"
rating-direction="$ctrl.visibility.ratingDirection">

</waltz-application-flow-summary-pane>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
assessmentDefinitions={allAssessmentDefinitions}/>
<br>
<PhysicalFlowTable {physicalFlows}
{flowClassifications}
assessmentDefinitions={allAssessmentDefinitions}/>
<div style="padding-top: 1em"
Expand Down
Loading

0 comments on commit 93f3d6e

Please sign in to comment.