use of com.khartec.waltz.service.authoritative_source.AuthoritativeSourceResolver in project waltz by khartec.
the class LogicalFlowDecoratorRatingsCalculator method createResolver.
private AuthoritativeSourceResolver createResolver(Collection<Application> targetApps) {
Set<Long> orgIds = map(targetApps, app -> app.organisationalUnitId());
List<AuthoritativeRatingVantagePoint> authoritativeRatingVantagePoints = authoritativeSourceDao.findAuthoritativeRatingVantagePoints(orgIds);
AuthoritativeSourceResolver resolver = new AuthoritativeSourceResolver(authoritativeRatingVantagePoints);
return resolver;
}
use of com.khartec.waltz.service.authoritative_source.AuthoritativeSourceResolver in project waltz by khartec.
the class LogicalFlowDecoratorRatingsCalculator method calculate.
public Collection<LogicalFlowDecorator> calculate(Collection<LogicalFlowDecorator> decorators) {
List<LogicalFlow> flows = loadFlows(decorators).stream().filter(f -> f.target().kind() == EntityKind.APPLICATION && f.source().kind() == EntityKind.APPLICATION).collect(toList());
if (isEmpty(flows))
return Collections.emptyList();
List<Application> targetApps = loadTargetApplications(flows);
List<DataType> dataTypes = dataTypeDao.getAll();
Map<Long, DataType> typesById = indexById(dataTypes);
Map<Long, LogicalFlow> flowsById = indexById(flows);
Map<Long, Application> targetAppsById = indexById(targetApps);
AuthoritativeSourceResolver resolver = createResolver(targetApps);
return decorators.stream().map(decorator -> {
try {
if (decorator.decoratorEntity().kind() != EntityKind.DATA_TYPE) {
return decorator;
} else {
AuthoritativenessRating rating = lookupRating(typesById, flowsById, targetAppsById, resolver, decorator);
return ImmutableLogicalFlowDecorator.copyOf(decorator).withRating(rating);
}
} catch (Exception e) {
LOG.warn("Failed to calculate rating for decorator: {}, reason: {}", decorator, e.getMessage());
return null;
}
}).filter(Objects::nonNull).collect(Collectors.toSet());
}
Aggregations