use of org.finos.waltz.model.application.Application 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.model.application.Application in project waltz by khartec.
the class LogicalFlowDecoratorRatingsCalculator method lookupVantagePoint.
private EntityReference lookupVantagePoint(Map<Long, Application> targetAppsById, LogicalFlow flow) {
Application targetApp = targetAppsById.get(flow.target().id());
long targetOrgUnitId = targetApp.organisationalUnitId();
return EntityReference.mkRef(EntityKind.ORG_UNIT, targetOrgUnitId);
}
use of org.finos.waltz.model.application.Application in project waltz by khartec.
the class FlowClassificationRuleService method logUpdate.
private void logUpdate(FlowClassificationRuleUpdateCommand command, String username) {
FlowClassificationRule rule = getById(command.id().get());
if (rule == null) {
return;
}
String parentName = getParentEntityName(rule.parentReference());
DataType dataType = dataTypeDao.getById(rule.dataTypeId());
Application app = applicationDao.getById(rule.applicationReference().id());
FlowClassification classification = flowClassificationDao.getById(command.classificationId());
if (app != null && dataType != null && parentName != null) {
String msg = format("Updated flow classification rule: %s as the source application with rating: %s, for type: %s, for %s: %s", app.name(), classification.name(), dataType.name(), rule.parentReference().kind().prettyName(), parentName);
multiLog(username, rule.id().get(), rule.parentReference(), dataType, app, msg, Operation.UPDATE);
}
}
Aggregations