Search in sources :

Example 1 with AuthoritativenessRating

use of com.khartec.waltz.model.rating.AuthoritativenessRating in project waltz by khartec.

the class AuthoritativeSourceResolverTest method existingEntriesThenReturnsMostSpecificRating.

@Test
public void existingEntriesThenReturnsMostSpecificRating() {
    List<AuthoritativeRatingVantagePoint> vantagePoints = new ArrayList<>();
    vantagePoints.add(ImmutableAuthoritativeRatingVantagePoint.builder().vantagePoint(vantagePoint).rank(1).dataTypeCode("REF_DATA").applicationId(205L).rating(AuthoritativenessRating.PRIMARY).build());
    vantagePoints.add(ImmutableAuthoritativeRatingVantagePoint.builder().vantagePoint(vantagePoint).rank(2).dataTypeCode("REF_DATA").applicationId(200L).rating(AuthoritativenessRating.SECONDARY).build());
    AuthoritativeSourceResolver authoritativeSourceResolver = new AuthoritativeSourceResolver(vantagePoints);
    AuthoritativenessRating rating = authoritativeSourceResolver.resolve(vantagePoint, sourceApp, "REF_DATA");
    Assert.assertEquals(AuthoritativenessRating.SECONDARY, rating);
}
Also used : ImmutableAuthoritativeRatingVantagePoint(com.khartec.waltz.model.authoritativesource.ImmutableAuthoritativeRatingVantagePoint) AuthoritativeRatingVantagePoint(com.khartec.waltz.model.authoritativesource.AuthoritativeRatingVantagePoint) ArrayList(java.util.ArrayList) AuthoritativenessRating(com.khartec.waltz.model.rating.AuthoritativenessRating) Test(org.junit.Test)

Example 2 with AuthoritativenessRating

use of com.khartec.waltz.model.rating.AuthoritativenessRating in project waltz by khartec.

the class AuthoritativeSourceResolverTest method whenResolveWithMissingVantagePointThenReturnsNoOpinion.

@Test
public void whenResolveWithMissingVantagePointThenReturnsNoOpinion() {
    List<AuthoritativeRatingVantagePoint> vantagePoints = new ArrayList<>();
    AuthoritativeSourceResolver authoritativeSourceResolver = new AuthoritativeSourceResolver(vantagePoints);
    AuthoritativenessRating rating = authoritativeSourceResolver.resolve(vantagePoint, sourceApp, "REF_DATA");
    Assert.assertEquals(AuthoritativenessRating.NO_OPINION, rating);
}
Also used : ImmutableAuthoritativeRatingVantagePoint(com.khartec.waltz.model.authoritativesource.ImmutableAuthoritativeRatingVantagePoint) AuthoritativeRatingVantagePoint(com.khartec.waltz.model.authoritativesource.AuthoritativeRatingVantagePoint) ArrayList(java.util.ArrayList) AuthoritativenessRating(com.khartec.waltz.model.rating.AuthoritativenessRating) Test(org.junit.Test)

Example 3 with AuthoritativenessRating

use of com.khartec.waltz.model.rating.AuthoritativenessRating in project waltz by khartec.

the class AuthoritativeSourceResolverTest method whenResolveWithExistingVantageButMissingDataTypeThenReturnsNoOpinion.

@Test
public void whenResolveWithExistingVantageButMissingDataTypeThenReturnsNoOpinion() {
    List<AuthoritativeRatingVantagePoint> vantagePoints = new ArrayList<>();
    vantagePoints.add(ImmutableAuthoritativeRatingVantagePoint.builder().vantagePoint(vantagePoint).rank(1).dataTypeCode("TRADE_DATA").applicationId(200L).rating(AuthoritativenessRating.SECONDARY).build());
    AuthoritativeSourceResolver authoritativeSourceResolver = new AuthoritativeSourceResolver(vantagePoints);
    AuthoritativenessRating rating = authoritativeSourceResolver.resolve(vantagePoint, sourceApp, "REF_DATA");
    Assert.assertEquals(AuthoritativenessRating.NO_OPINION, rating);
}
Also used : ImmutableAuthoritativeRatingVantagePoint(com.khartec.waltz.model.authoritativesource.ImmutableAuthoritativeRatingVantagePoint) AuthoritativeRatingVantagePoint(com.khartec.waltz.model.authoritativesource.AuthoritativeRatingVantagePoint) ArrayList(java.util.ArrayList) AuthoritativenessRating(com.khartec.waltz.model.rating.AuthoritativenessRating) Test(org.junit.Test)

Example 4 with AuthoritativenessRating

use of com.khartec.waltz.model.rating.AuthoritativenessRating in project waltz by khartec.

the class AuthoritativeSourceResolverTest method existingVantageAndDataTypeAndDifferentSourceThenDiscouraged.

@Test
public void existingVantageAndDataTypeAndDifferentSourceThenDiscouraged() {
    List<AuthoritativeRatingVantagePoint> vantagePoints = new ArrayList<>();
    vantagePoints.add(ImmutableAuthoritativeRatingVantagePoint.builder().vantagePoint(vantagePoint).rank(1).dataTypeCode("REF_DATA").applicationId(205L).rating(AuthoritativenessRating.PRIMARY).build());
    AuthoritativeSourceResolver authoritativeSourceResolver = new AuthoritativeSourceResolver(vantagePoints);
    AuthoritativenessRating rating = authoritativeSourceResolver.resolve(vantagePoint, sourceApp, "REF_DATA");
    Assert.assertEquals(AuthoritativenessRating.DISCOURAGED, rating);
}
Also used : ImmutableAuthoritativeRatingVantagePoint(com.khartec.waltz.model.authoritativesource.ImmutableAuthoritativeRatingVantagePoint) AuthoritativeRatingVantagePoint(com.khartec.waltz.model.authoritativesource.AuthoritativeRatingVantagePoint) ArrayList(java.util.ArrayList) AuthoritativenessRating(com.khartec.waltz.model.rating.AuthoritativenessRating) Test(org.junit.Test)

Example 5 with AuthoritativenessRating

use of com.khartec.waltz.model.rating.AuthoritativenessRating 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

AuthoritativenessRating (com.khartec.waltz.model.rating.AuthoritativenessRating)6 AuthoritativeRatingVantagePoint (com.khartec.waltz.model.authoritativesource.AuthoritativeRatingVantagePoint)5 ImmutableAuthoritativeRatingVantagePoint (com.khartec.waltz.model.authoritativesource.ImmutableAuthoritativeRatingVantagePoint)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 EntityKind (com.khartec.waltz.model.EntityKind)2 EntityReference (com.khartec.waltz.model.EntityReference)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 ImmutableEntityReference (com.khartec.waltz.model.ImmutableEntityReference)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 IdUtilities.indexById (com.khartec.waltz.model.utils.IdUtilities.indexById)1