Skip to content

Commit b940776

Browse files
committed
Flow Classification Rule UI rework
- fixing null data types (all) handling - fixing consumer overrides #CTCTOWALTZ-3092 #7058
1 parent 4cb2e9e commit b940776

4 files changed

Lines changed: 58 additions & 34 deletions

File tree

waltz-ng/client/common/svelte/DataTypeNodeTooltipContent.svelte

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import DescriptionFade from "./DescriptionFade.svelte";
77
import NoData from "./NoData.svelte";
88
import {messageSeverity} from "../services/enums/message-severity";
9+
import Markdown from "./Markdown.svelte";
910
1011
export let name;
1112
export let description;
@@ -52,7 +53,7 @@
5253
</div>
5354
</div>
5455
<div class="row">
55-
<div class="col-sm-12 help-block small">
56+
<div class="col-sm-12 help-block">
5657
This indicates the rating of the flow according whether this source entity is authorised to distribute this data type
5758
</div>
5859
</div>
@@ -70,14 +71,16 @@
7071
</div>
7172
</div>
7273
<div class="row">
73-
<div class="col-sm-12 help-block small">
74+
<div class="col-sm-12 help-block">
7475
This rating expresses whether the target entity has a preference for or against this type of data being documented against it
7576
</div>
7677
</div>
7778
{#if !_.isEmpty(inboundMessage)}
7879
<div class="row">
7980
<div class="col-sm-12">
80-
<NoData type={_.lowerCase(_.get(messageSeverity, [inboundSeverity, "name"], "info"))}>{inboundMessage}</NoData>
81+
<NoData type={_.lowerCase(_.get(messageSeverity, [inboundSeverity, "name"], "info"))}>
82+
<Markdown text={inboundMessage}/>
83+
</NoData>
8184
</div>
8285
</div>
8386
{/if}

waltz-service/src/main/java/org/finos/waltz/service/flow_classification_rule/FlowClassificationRuleResolver.java

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.jooq.lambda.tuple.Tuple2;
2626

2727
import java.util.Collection;
28-
import java.util.Comparator;
2928
import java.util.List;
3029
import java.util.Map;
3130
import java.util.Optional;
@@ -36,6 +35,7 @@
3635
import static org.finos.waltz.common.Checks.checkNotNull;
3736
import static org.finos.waltz.common.CollectionUtilities.head;
3837
import static org.finos.waltz.common.CollectionUtilities.sort;
38+
import static org.finos.waltz.common.ListUtilities.asList;
3939
import static org.finos.waltz.common.MapUtilities.groupAndThen;
4040
import static org.finos.waltz.common.MapUtilities.isEmpty;
4141
import static org.finos.waltz.service.flow_classification_rule.FlowClassificationRuleUtilities.flowClassificationRuleVantagePointComparator;
@@ -76,6 +76,22 @@ public FlowClassificationRuleResolver(FlowDirection direction, List<FlowClassifi
7676
}
7777

7878

79+
/**
80+
* Given a collection of vantages points (maybe) return the first
81+
* after sorting them in (descending) rank order.
82+
*
83+
* @param vantagePoints
84+
* @return
85+
*/
86+
public static Optional<FlowClassificationRuleVantagePoint> getMostSpecificRanked(Collection<FlowClassificationRuleVantagePoint> vantagePoints) {
87+
List<FlowClassificationRuleVantagePoint> sorted = sort(
88+
vantagePoints,
89+
flowClassificationRuleVantagePointComparator);
90+
return head(
91+
sorted); //note the reversal of parameters because we want descending order
92+
}
93+
94+
7995
/**
8096
* Given a vantage point, a supplier and a data type this method will give back
8197
* an authoritativeness rating.
@@ -102,21 +118,41 @@ public Tuple2<AuthoritativenessRatingValue, Optional<FlowClassificationRuleVanta
102118
return tuple(AuthoritativenessRatingValue.NO_OPINION, Optional.empty());
103119
}
104120

121+
Map<EntityReference, Optional<FlowClassificationRuleVantagePoint>> allDataTypeEntityRule = vpEntity.getOrDefault(null, emptyMap());
105122
Map<EntityReference, Optional<FlowClassificationRuleVantagePoint>> dtEntity = vpEntity.getOrDefault(dataTypeId, emptyMap());
123+
Map<EntityReference, Optional<FlowClassificationRuleVantagePoint>> allDataTypeGroupRule = vpGroup.getOrDefault(null, emptyMap());
106124
Map<EntityReference, Optional<FlowClassificationRuleVantagePoint>> dataTypeGroup = vpGroup.getOrDefault(dataTypeId, emptyMap());
107125

108-
if(isEmpty(dataTypeGroup) && isEmpty(dtEntity)) {
126+
if(isEmpty(dataTypeGroup) && isEmpty(dtEntity) && isEmpty(allDataTypeEntityRule) && isEmpty(allDataTypeGroupRule)) {
109127
return tuple(AuthoritativenessRatingValue.NO_OPINION, Optional.empty());
110128
}
111129

112-
Optional<FlowClassificationRuleVantagePoint> maybeRule = isEmpty(dtEntity)
113-
? dataTypeGroup.getOrDefault(
114-
subject,
115-
Optional.empty())
116-
: dtEntity.getOrDefault(
117-
subject,
130+
List<Map<EntityReference, Optional<FlowClassificationRuleVantagePoint>>> dataTypeCoverage = asList(dtEntity, dataTypeGroup, allDataTypeEntityRule, allDataTypeGroupRule);
131+
132+
Optional<FlowClassificationRuleVantagePoint> pointToPointRule = dtEntity.getOrDefault(
133+
subject,
134+
Optional.empty());
135+
136+
Optional<FlowClassificationRuleVantagePoint> vantagePointRule = dataTypeGroup.getOrDefault(
137+
subject,
138+
Optional.empty());
139+
140+
Optional<FlowClassificationRuleVantagePoint> allDtToPointRule = allDataTypeEntityRule.getOrDefault(
141+
subject,
142+
Optional.empty());
143+
144+
Optional<FlowClassificationRuleVantagePoint> alLDtToGroupRule = allDataTypeGroupRule.getOrDefault(
145+
subject,
118146
Optional.empty());
119147

148+
List<Optional<FlowClassificationRuleVantagePoint>> rules = asList(pointToPointRule, vantagePointRule, allDtToPointRule, alLDtToGroupRule);
149+
150+
Optional<FlowClassificationRuleVantagePoint> maybeRule = rules
151+
.stream()
152+
.filter(Optional::isPresent)
153+
.map(Optional::get)
154+
.findFirst();
155+
120156
AuthoritativenessRatingValue defaultRating = direction == FlowDirection.OUTBOUND
121157
? AuthoritativenessRatingValue.DISCOURAGED // at least one rule covering this scope and data type to reach this point
122158
: AuthoritativenessRatingValue.NO_OPINION;
@@ -125,35 +161,20 @@ public Tuple2<AuthoritativenessRatingValue, Optional<FlowClassificationRuleVanta
125161
.map(r -> AuthoritativenessRatingValue.of(r.classificationCode()))
126162
.orElse(defaultRating);
127163

128-
Optional<FlowClassificationRuleVantagePoint> discouragedRule = determineDefaultRuleId(dataTypeGroup);
164+
Optional<FlowClassificationRuleVantagePoint> discouragedRule = determineDefaultRuleId(dataTypeCoverage);
129165

130166
return tuple(ratingValue, ofNullable(maybeRule.orElse(discouragedRule.orElse(null))));
131167
}
132168

133-
private Optional<FlowClassificationRuleVantagePoint> determineDefaultRuleId(Map<EntityReference, Optional<FlowClassificationRuleVantagePoint>> dataTypeGroup) {
134-
return dataTypeGroup
135-
.values()
169+
private Optional<FlowClassificationRuleVantagePoint> determineDefaultRuleId(List<Map<EntityReference, Optional<FlowClassificationRuleVantagePoint>>> dtCoverageRules) {
170+
return dtCoverageRules
136171
.stream()
172+
.flatMap(d -> d.values().stream())
137173
.filter(Optional::isPresent)
138174
.map(Optional::get)
139175
.sorted(flowClassificationRuleVantagePointComparator)
140176
.findFirst();
141177
}
142178

143179

144-
/**
145-
* Given a collection of vantages points (maybe) return the first
146-
* after sorting them in (descending) rank order.
147-
*
148-
* @param vantagePoints
149-
* @return
150-
*/
151-
public static Optional<FlowClassificationRuleVantagePoint> getMostSpecificRanked(Collection<FlowClassificationRuleVantagePoint> vantagePoints) {
152-
List<FlowClassificationRuleVantagePoint> sorted = sort(
153-
vantagePoints,
154-
flowClassificationRuleVantagePointComparator);
155-
return head(
156-
sorted); //note the reversal of parameters because we want descending order
157-
}
158-
159180
}

waltz-service/src/main/java/org/finos/waltz/service/flow_classification_rule/FlowClassificationRuleService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,13 @@ private int recalculateRatingsForPopulation(Set<FlowDataType> population) {
254254
EntityHierarchy dtHierarchy = entityHierarchyService.fetchHierarchyForKind(EntityKind.DATA_TYPE);
255255

256256
LOG.debug("Applying rules to population");
257-
Map<Long, Tuple2<Long, FlowClassificationRuleUtilities.MatchOutcome>> lfdIdToOutboundRuleIdMap = time("inbound vps", () -> applyVantagePoints(
257+
Map<Long, Tuple2<Long, FlowClassificationRuleUtilities.MatchOutcome>> lfdIdToOutboundRuleIdMap = time("outbound vps", () -> applyVantagePoints(
258258
FlowDirection.OUTBOUND,
259259
outboundRuleVantagePoints,
260260
population,
261261
ouHierarchy,
262262
dtHierarchy));
263-
Map<Long, Tuple2<Long, FlowClassificationRuleUtilities.MatchOutcome>> lfdIdToInboundRuleIdMap = time("outbound vps", () -> applyVantagePoints(
263+
Map<Long, Tuple2<Long, FlowClassificationRuleUtilities.MatchOutcome>> lfdIdToInboundRuleIdMap = time("inbound vps", () -> applyVantagePoints(
264264
FlowDirection.INBOUND,
265265
inboundRuleVantagePoints,
266266
population,

waltz-service/src/main/java/org/finos/waltz/service/flow_classification_rule/FlowClassificationRuleUtilities.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ protected static Map<Long, Tuple2<Long, MatchOutcome>> applyVantagePoints(FlowDi
5252
.flatMap(d -> dtHierarchy.findAncestors(d.dtId()).stream())
5353
.collect(Collectors.toSet());
5454

55-
Set<FlowClassificationRuleVantagePoint> filteredRules = ruleVantagePoints
55+
List<FlowClassificationRuleVantagePoint> filteredRules = ruleVantagePoints
5656
.stream()
5757
.filter(rvp -> rvp.dataTypeId() == null || ruleDataTypes.contains(rvp.dataTypeId()))
58-
.collect(Collectors.toSet());
58+
.collect(Collectors.toList());
5959

6060
filteredRules
6161
.forEach(rvp -> {

0 commit comments

Comments
 (0)