use of org.finos.waltz.model.rating.AuthoritativenessRatingValue in project waltz by khartec.
the class FlowClassificationRuleResolverTest method existingEntriesThenReturnsMostSpecificRating.
@Test
public void existingEntriesThenReturnsMostSpecificRating() {
List<FlowClassificationRuleVantagePoint> vantagePoints = new ArrayList<>();
vantagePoints.add(ImmutableFlowClassificationRuleVantagePoint.builder().vantagePoint(vantagePoint).vantagePointRank(1).dataType(EntityReference.mkRef(EntityKind.DATA_TYPE, 20)).dataTypeRank(2).applicationId(205L).classificationCode(AuthoritativenessRatingValue.of("PRIMARY").value()).ruleId(1L).build());
vantagePoints.add(ImmutableFlowClassificationRuleVantagePoint.builder().vantagePoint(vantagePoint).vantagePointRank(2).dataType(EntityReference.mkRef(EntityKind.DATA_TYPE, 20)).dataTypeRank(3).applicationId(200L).classificationCode(AuthoritativenessRatingValue.of("SECONDARY").value()).ruleId(1L).build());
FlowClassificationRuleResolver flowClassificationRuleResolver = new FlowClassificationRuleResolver(vantagePoints);
AuthoritativenessRatingValue rating = flowClassificationRuleResolver.resolve(vantagePoint, sourceApp, 20L);
assertEquals(AuthoritativenessRatingValue.of("SECONDARY"), rating);
}
use of org.finos.waltz.model.rating.AuthoritativenessRatingValue in project waltz by khartec.
the class LogicalFlowDecoratorRatingsCalculator method calculate.
public Collection<DataTypeDecorator> calculate(Collection<DataTypeDecorator> decorators) {
List<LogicalFlow> appToAppFlows = filter(IS_APP_TO_APP_FLOW, loadFlows(decorators));
if (isEmpty(appToAppFlows))
return Collections.emptyList();
List<Application> targetApps = loadTargetApplications(appToAppFlows);
List<DataType> dataTypes = dataTypeDao.findAll();
Set<FlowClassification> flowClassifications = flowClassificationDao.findAll();
Map<Long, DataType> typesById = indexById(dataTypes);
Map<Long, LogicalFlow> flowsById = indexById(appToAppFlows);
Map<Long, Application> targetAppsById = indexById(targetApps);
FlowClassificationRuleResolver resolver = createResolver(targetApps);
return decorators.stream().filter(d -> flowsById.containsKey(d.dataFlowId())).map(decorator -> {
try {
if (decorator.decoratorEntity().kind() != EntityKind.DATA_TYPE) {
return decorator;
} else {
AuthoritativenessRatingValue rating = lookupRating(flowsById, targetAppsById, resolver, decorator);
Optional<Long> ruleId = lookupFlowClassificationRule(typesById, flowsById, targetAppsById, resolver, decorator);
return ImmutableDataTypeDecorator.copyOf(decorator).withRating(rating).withFlowClassificationRuleId(ruleId);
}
} catch (Exception e) {
LOG.warn("Failed to calculate rating for decorator: {}, reason: {}", decorator, e.getMessage());
return null;
}
}).filter(Objects::nonNull).collect(Collectors.toSet());
}
Aggregations