use of org.finos.waltz.service.flow_classification_rule.FlowClassificationRuleResolver 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());
}
use of org.finos.waltz.service.flow_classification_rule.FlowClassificationRuleResolver in project waltz by khartec.
the class LogicalFlowDecoratorRatingsCalculator method createResolver.
private FlowClassificationRuleResolver createResolver(Collection<Application> targetApps) {
Set<Long> orgIds = map(targetApps, app -> app.organisationalUnitId());
List<FlowClassificationRuleVantagePoint> flowClassificationRuleVantagePoints = flowClassificationRuleDao.findExpandedFlowClassificationRuleVantagePoints(orgIds);
FlowClassificationRuleResolver resolver = new FlowClassificationRuleResolver(flowClassificationRuleVantagePoints);
return resolver;
}
Aggregations