use of com.khartec.waltz.model.datatype.DataType in project waltz by khartec.
the class AuthoritativeSourceService method logRemoval.
private void logRemoval(long id, String username) {
AuthoritativeSource authSource = getById(id);
if (authSource == null) {
return;
}
OrganisationalUnit orgUnit = organisationalUnitDao.getById(authSource.parentReference().id());
DataType dataType = dataTypeDao.getByCode(authSource.dataType());
Application app = applicationDao.getById(authSource.applicationReference().id());
if (app != null && dataType != null && orgUnit != null) {
String msg = String.format("Removed %s as an authoritative source for type: %s for org: %s", app.name(), dataType.name(), orgUnit.name());
tripleLog(username, orgUnit, dataType, app, msg, Operation.REMOVE);
}
}
use of com.khartec.waltz.model.datatype.DataType in project waltz by khartec.
the class AuthSourceRatingCalculator method update.
private int[] update(DataType dataType, EntityReference vantageRef) {
LOG.info("Updating ratings for auth source - dataType: {}, vantage point: {}", dataType, vantageRef);
IdSelectionOptions selectorOptions = mkOpts(vantageRef, HierarchyQueryScope.CHILDREN);
Select<Record1<Long>> selector = appIdSelectorFactory.apply(selectorOptions);
Collection<LogicalFlowDecorator> impactedDecorators = logicalFlowDecoratorDao.findByEntityIdSelectorAndKind(EntityKind.APPLICATION, selector, EntityKind.DATA_TYPE).stream().filter(decorator -> decorator.decoratorEntity().id() == dataType.id().get()).collect(toList());
Collection<LogicalFlowDecorator> reRatedDecorators = ratingsCalculator.calculate(impactedDecorators);
Set<LogicalFlowDecorator> modifiedDecorators = SetUtilities.minus(fromCollection(reRatedDecorators), fromCollection(impactedDecorators));
LOG.info("Need to update {} ratings due to auth source change - dataType: {}, parent: {}", modifiedDecorators.size(), dataType, vantageRef);
return updateDecorators(modifiedDecorators);
}
use of com.khartec.waltz.model.datatype.DataType in project waltz by khartec.
the class AuthoritativeSourceService method logInsert.
private void logInsert(AuthoritativeSourceCreateCommand command, String username) {
OrganisationalUnit orgUnit = organisationalUnitDao.getById(command.orgUnitId());
DataType dataType = dataTypeDao.getById(command.dataTypeId());
Application app = applicationDao.getById(command.applicationId());
if (app != null && dataType != null && orgUnit != null) {
String msg = String.format("Registered %s as an authoritative source for type: %s for org: %s", app.name(), dataType.name(), orgUnit.name());
tripleLog(username, orgUnit, dataType, app, msg, Operation.ADD);
}
}
use of com.khartec.waltz.model.datatype.DataType in project waltz by khartec.
the class AuthoritativeSourceService method logUpdate.
private void logUpdate(AuthoritativeSourceUpdateCommand command, String username) {
AuthoritativeSource authSource = getById(command.id().get());
if (authSource == null) {
return;
}
OrganisationalUnit orgUnit = organisationalUnitDao.getById(authSource.parentReference().id());
DataType dataType = dataTypeDao.getByCode(authSource.dataType());
Application app = applicationDao.getById(authSource.applicationReference().id());
if (app != null && dataType != null && orgUnit != null) {
String msg = String.format("Updated %s as an authoritative source for type: %s for org: %s", app.name(), dataType.name(), orgUnit.name());
tripleLog(username, orgUnit, dataType, app, msg, Operation.UPDATE);
}
}
use of com.khartec.waltz.model.datatype.DataType 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