Search in sources :

Example 1 with AuthoritativeSourceResolver

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;
}
Also used : AuthoritativeRatingVantagePoint(com.khartec.waltz.model.authoritativesource.AuthoritativeRatingVantagePoint) AuthoritativeSourceResolver(com.khartec.waltz.service.authoritative_source.AuthoritativeSourceResolver)

Example 2 with AuthoritativeSourceResolver

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());
}
Also used : java.util(java.util) AuthoritativeSourceResolver(com.khartec.waltz.service.authoritative_source.AuthoritativeSourceResolver) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) EntityReference(com.khartec.waltz.model.EntityReference) AuthoritativeRatingVantagePoint(com.khartec.waltz.model.authoritativesource.AuthoritativeRatingVantagePoint) LogicalFlow(com.khartec.waltz.model.logical_flow.LogicalFlow) EntityKind(com.khartec.waltz.model.EntityKind) ImmutableLogicalFlowDecorator(com.khartec.waltz.model.data_flow_decorator.ImmutableLogicalFlowDecorator) Service(org.springframework.stereotype.Service) LogicalFlowDao(com.khartec.waltz.data.logical_flow.LogicalFlowDao) ApplicationService(com.khartec.waltz.service.application.ApplicationService) Application(com.khartec.waltz.model.application.Application) Logger(org.slf4j.Logger) Checks.checkNotNull(com.khartec.waltz.common.Checks.checkNotNull) AuthoritativenessRating(com.khartec.waltz.model.rating.AuthoritativenessRating) AuthoritativeSourceDao(com.khartec.waltz.data.authoritative_source.AuthoritativeSourceDao) Collectors(java.util.stream.Collectors) DataTypeDao(com.khartec.waltz.data.data_type.DataTypeDao) LogicalFlowDecorator(com.khartec.waltz.model.data_flow_decorator.LogicalFlowDecorator) Collectors.toList(java.util.stream.Collectors.toList) SetUtilities.map(com.khartec.waltz.common.SetUtilities.map) DataType(com.khartec.waltz.model.datatype.DataType) ListUtilities.isEmpty(com.khartec.waltz.common.ListUtilities.isEmpty) IdUtilities.indexById(com.khartec.waltz.model.utils.IdUtilities.indexById) AuthoritativeSourceResolver(com.khartec.waltz.service.authoritative_source.AuthoritativeSourceResolver) LogicalFlow(com.khartec.waltz.model.logical_flow.LogicalFlow) DataType(com.khartec.waltz.model.datatype.DataType) AuthoritativenessRating(com.khartec.waltz.model.rating.AuthoritativenessRating) Application(com.khartec.waltz.model.application.Application)

Aggregations

AuthoritativeRatingVantagePoint (com.khartec.waltz.model.authoritativesource.AuthoritativeRatingVantagePoint)2 AuthoritativeSourceResolver (com.khartec.waltz.service.authoritative_source.AuthoritativeSourceResolver)2 Checks.checkNotNull (com.khartec.waltz.common.Checks.checkNotNull)1 ListUtilities.isEmpty (com.khartec.waltz.common.ListUtilities.isEmpty)1 SetUtilities.map (com.khartec.waltz.common.SetUtilities.map)1 AuthoritativeSourceDao (com.khartec.waltz.data.authoritative_source.AuthoritativeSourceDao)1 DataTypeDao (com.khartec.waltz.data.data_type.DataTypeDao)1 LogicalFlowDao (com.khartec.waltz.data.logical_flow.LogicalFlowDao)1 EntityKind (com.khartec.waltz.model.EntityKind)1 EntityReference (com.khartec.waltz.model.EntityReference)1 Application (com.khartec.waltz.model.application.Application)1 ImmutableLogicalFlowDecorator (com.khartec.waltz.model.data_flow_decorator.ImmutableLogicalFlowDecorator)1 LogicalFlowDecorator (com.khartec.waltz.model.data_flow_decorator.LogicalFlowDecorator)1 DataType (com.khartec.waltz.model.datatype.DataType)1 LogicalFlow (com.khartec.waltz.model.logical_flow.LogicalFlow)1 AuthoritativenessRating (com.khartec.waltz.model.rating.AuthoritativenessRating)1 IdUtilities.indexById (com.khartec.waltz.model.utils.IdUtilities.indexById)1 ApplicationService (com.khartec.waltz.service.application.ApplicationService)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1