use of org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint in project waltz by khartec.
the class LogicalFlowDecoratorRatingsCalculator method lookupFlowClassificationRule.
private Optional<Long> lookupFlowClassificationRule(Map<Long, DataType> typesById, Map<Long, LogicalFlow> flowsById, Map<Long, Application> targetAppsById, FlowClassificationRuleResolver resolver, DataTypeDecorator decorator) {
LogicalFlow flow = flowsById.get(decorator.dataFlowId());
EntityReference vantagePoint = lookupVantagePoint(targetAppsById, flow);
EntityReference source = flow.source();
Optional<FlowClassificationRuleVantagePoint> flowClassificationRuleVantagePoint = resolver.resolveAuthSource(vantagePoint, source, decorator.dataTypeId());
return flowClassificationRuleVantagePoint.map(FlowClassificationRuleVantagePoint::ruleId);
}
use of org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint in project waltz by khartec.
the class LogicalFlowDecoratorDao method updateDecoratorsForFlowClassificationRule.
public int updateDecoratorsForFlowClassificationRule(FlowClassificationRuleVantagePoint flowClassificationRuleVantagePoint) {
LogicalFlowDecorator lfd = LOGICAL_FLOW_DECORATOR.as("lfd");
EntityReference vantagePoint = flowClassificationRuleVantagePoint.vantagePoint();
Long appId = flowClassificationRuleVantagePoint.applicationId();
EntityReference dataType = flowClassificationRuleVantagePoint.dataType();
String classificationCode = flowClassificationRuleVantagePoint.classificationCode();
SelectConditionStep<Record1<Long>> orgUnitSubselect = DSL.select(ENTITY_HIERARCHY.ID).from(ENTITY_HIERARCHY).where(ENTITY_HIERARCHY.KIND.eq(vantagePoint.kind().name())).and(ENTITY_HIERARCHY.ANCESTOR_ID.eq(vantagePoint.id()));
SelectConditionStep<Record1<Long>> dataTypeSubselect = DSL.select(ENTITY_HIERARCHY.ID).from(ENTITY_HIERARCHY).where(ENTITY_HIERARCHY.KIND.eq(DATA_TYPE.name())).and(ENTITY_HIERARCHY.ANCESTOR_ID.eq(dataType.id()));
Condition usingFlowClassificationRule = LOGICAL_FLOW.SOURCE_ENTITY_ID.eq(appId);
Condition notUsingFlowClassificationRule = LOGICAL_FLOW.SOURCE_ENTITY_ID.ne(appId);
Function2<Condition, String, Update<LogicalFlowDecoratorRecord>> mkQuery = (appScopingCondition, ratingName) -> dsl.update(LOGICAL_FLOW_DECORATOR).set(LOGICAL_FLOW_DECORATOR.RATING, ratingName).set(LOGICAL_FLOW_DECORATOR.FLOW_CLASSIFICATION_RULE_ID, flowClassificationRuleVantagePoint.ruleId()).where(LOGICAL_FLOW_DECORATOR.ID.in(DSL.select(lfd.ID).from(lfd).innerJoin(LOGICAL_FLOW).on(LOGICAL_FLOW.ID.eq(lfd.LOGICAL_FLOW_ID)).innerJoin(APPLICATION).on(APPLICATION.ID.eq(LOGICAL_FLOW.TARGET_ENTITY_ID).and(LOGICAL_FLOW.TARGET_ENTITY_KIND.eq(EntityKind.APPLICATION.name()))).where(LOGICAL_FLOW.SOURCE_ENTITY_KIND.eq(EntityKind.APPLICATION.name()).and(appScopingCondition).and(APPLICATION.ORGANISATIONAL_UNIT_ID.in(orgUnitSubselect)).and(lfd.DECORATOR_ENTITY_KIND.eq(DATA_TYPE.name())).and(lfd.DECORATOR_ENTITY_ID.in(dataTypeSubselect))).and(lfd.RATING.in(AuthoritativenessRatingValue.NO_OPINION.value(), AuthoritativenessRatingValue.DISCOURAGED.value()))));
Update<LogicalFlowDecoratorRecord> updateAuthSources = mkQuery.apply(usingFlowClassificationRule, classificationCode);
Update<LogicalFlowDecoratorRecord> updateNonAuthSources = mkQuery.apply(notUsingFlowClassificationRule, AuthoritativenessRatingValue.DISCOURAGED.value());
int authSourceUpdateCount = updateAuthSources.execute();
int nonAuthSourceUpdateCount = updateNonAuthSources.execute();
return authSourceUpdateCount + nonAuthSourceUpdateCount;
}
use of org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint in project waltz by khartec.
the class FlowClassificationRuleResolverTest method existingVantageAndDataTypeAndDifferentSourceThenDiscouraged.
@Test
public void existingVantageAndDataTypeAndDifferentSourceThenDiscouraged() {
List<FlowClassificationRuleVantagePoint> vantagePoints = new ArrayList<>();
vantagePoints.add(ImmutableFlowClassificationRuleVantagePoint.builder().vantagePoint(vantagePoint).vantagePointRank(1).dataType(EntityReference.mkRef(EntityKind.DATA_TYPE, 20)).dataTypeRank(1).applicationId(205L).classificationCode(AuthoritativenessRatingValue.of("PRIMARY").value()).ruleId(1L).build());
FlowClassificationRuleResolver flowClassificationRuleResolver = new FlowClassificationRuleResolver(vantagePoints);
AuthoritativenessRatingValue rating = flowClassificationRuleResolver.resolve(vantagePoint, sourceApp, 20L);
assertEquals(AuthoritativenessRatingValue.DISCOURAGED, rating);
}
use of org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint in project waltz by khartec.
the class FlowClassificationRuleResolverTest method whenResolveWithMissingVantagePointThenReturnsNoOpinion.
@Test
public void whenResolveWithMissingVantagePointThenReturnsNoOpinion() {
List<FlowClassificationRuleVantagePoint> vantagePoints = new ArrayList<>();
FlowClassificationRuleResolver flowClassificationRuleResolver = new FlowClassificationRuleResolver(vantagePoints);
AuthoritativenessRatingValue rating = flowClassificationRuleResolver.resolve(vantagePoint, sourceApp, 20L);
assertEquals(AuthoritativenessRatingValue.NO_OPINION, rating);
}
use of org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint in project waltz by khartec.
the class FlowClassificationRuleResolverTest method whenResolveWithExistingVantageButMissingDataTypeThenReturnsNoOpinion.
@Test
public void whenResolveWithExistingVantageButMissingDataTypeThenReturnsNoOpinion() {
List<FlowClassificationRuleVantagePoint> vantagePoints = new ArrayList<>();
vantagePoints.add(ImmutableFlowClassificationRuleVantagePoint.builder().vantagePoint(vantagePoint).vantagePointRank(1).dataType(EntityReference.mkRef(EntityKind.DATA_TYPE, 10)).dataTypeRank(1).applicationId(200L).classificationCode(AuthoritativenessRatingValue.of("SECONDARY").value()).ruleId(1L).build());
FlowClassificationRuleResolver flowClassificationRuleResolver = new FlowClassificationRuleResolver(vantagePoints);
AuthoritativenessRatingValue rating = flowClassificationRuleResolver.resolve(vantagePoint, sourceApp, 20L);
assertEquals(AuthoritativenessRatingValue.NO_OPINION, rating);
}
Aggregations