Search in sources :

Example 6 with AuthoritativenessRating

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

the class LogicalFlowDecoratorDao method summarizeForCondition.

private List<DecoratorRatingSummary> summarizeForCondition(Condition condition) {
    // this is intentionally TARGET only as we use to calculate auth source stats
    Condition dataFlowJoinCondition = LOGICAL_FLOW.ID.eq(LOGICAL_FLOW_DECORATOR.LOGICAL_FLOW_ID);
    Collection<Field<?>> groupingFields = newArrayList(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_KIND, LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_ID, LOGICAL_FLOW_DECORATOR.RATING);
    Field<Integer> countField = DSL.count(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_ID).as("count");
    return dsl.select(groupingFields).select(countField).from(LOGICAL_FLOW_DECORATOR).innerJoin(LOGICAL_FLOW).on(dsl.renderInlined(dataFlowJoinCondition)).where(dsl.renderInlined(condition)).groupBy(groupingFields).fetch(r -> {
        EntityKind decoratorEntityKind = EntityKind.valueOf(r.getValue(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_KIND));
        long decoratorEntityId = r.getValue(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_ID);
        EntityReference decoratorRef = EntityReference.mkRef(decoratorEntityKind, decoratorEntityId);
        AuthoritativenessRating rating = AuthoritativenessRating.valueOf(r.getValue(LOGICAL_FLOW_DECORATOR.RATING));
        Integer count = r.getValue(countField);
        return ImmutableDecoratorRatingSummary.builder().decoratorEntityReference(decoratorRef).rating(rating).count(count).build();
    });
}
Also used : ImmutableEntityReference(com.khartec.waltz.model.ImmutableEntityReference) EntityReference(com.khartec.waltz.model.EntityReference) AuthoritativenessRating(com.khartec.waltz.model.rating.AuthoritativenessRating) EntityKind(com.khartec.waltz.model.EntityKind)

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