Search in sources :

Example 1 with AuthoritativenessRatingValue

use of org.finos.waltz.model.rating.AuthoritativenessRatingValue in project waltz by khartec.

the class LogicalFlowDecoratorSummaryDao 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);
        AuthoritativenessRatingValue rating = AuthoritativenessRatingValue.of(r.getValue(LOGICAL_FLOW_DECORATOR.RATING));
        Integer count = r.getValue(countField);
        return ImmutableDecoratorRatingSummary.builder().decoratorEntityReference(decoratorRef).rating(rating).count(count).build();
    });
}
Also used : AuthoritativenessRatingValue(org.finos.waltz.model.rating.AuthoritativenessRatingValue) EntityReference(org.finos.waltz.model.EntityReference) EntityKind(org.finos.waltz.model.EntityKind)

Example 2 with AuthoritativenessRatingValue

use of org.finos.waltz.model.rating.AuthoritativenessRatingValue in project waltz by khartec.

the class FlowClassificationRuleResolverTest method existingVantageAndDataTypeAndDifferentSourceThenDiscouraged.

@Test
public void existingVantageAndDataTypeAndDifferentSourceThenDiscouraged() {
    List<FlowClassificationRuleVantagePoint> vantagePoints = new ArrayList<>();
    vantagePoints.add(ImmutableFlowClassificationRuleVantagePoint.builder().vantagePoint(vantagePoint).vantagePointRank(1).dataType(EntityReference.mkRef(EntityKind.DATA_TYPE, 20)).dataTypeRank(1).applicationId(205L).classificationCode(AuthoritativenessRatingValue.of("PRIMARY").value()).ruleId(1L).build());
    FlowClassificationRuleResolver flowClassificationRuleResolver = new FlowClassificationRuleResolver(vantagePoints);
    AuthoritativenessRatingValue rating = flowClassificationRuleResolver.resolve(vantagePoint, sourceApp, 20L);
    assertEquals(AuthoritativenessRatingValue.DISCOURAGED, rating);
}
Also used : ImmutableFlowClassificationRuleVantagePoint(org.finos.waltz.model.flow_classification_rule.ImmutableFlowClassificationRuleVantagePoint) FlowClassificationRuleVantagePoint(org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint) AuthoritativenessRatingValue(org.finos.waltz.model.rating.AuthoritativenessRatingValue) ListUtilities.newArrayList(org.finos.waltz.common.ListUtilities.newArrayList) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 3 with AuthoritativenessRatingValue

use of org.finos.waltz.model.rating.AuthoritativenessRatingValue in project waltz by khartec.

the class FlowClassificationRuleResolverTest method whenResolveWithMissingVantagePointThenReturnsNoOpinion.

@Test
public void whenResolveWithMissingVantagePointThenReturnsNoOpinion() {
    List<FlowClassificationRuleVantagePoint> vantagePoints = new ArrayList<>();
    FlowClassificationRuleResolver flowClassificationRuleResolver = new FlowClassificationRuleResolver(vantagePoints);
    AuthoritativenessRatingValue rating = flowClassificationRuleResolver.resolve(vantagePoint, sourceApp, 20L);
    assertEquals(AuthoritativenessRatingValue.NO_OPINION, rating);
}
Also used : ImmutableFlowClassificationRuleVantagePoint(org.finos.waltz.model.flow_classification_rule.ImmutableFlowClassificationRuleVantagePoint) FlowClassificationRuleVantagePoint(org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint) AuthoritativenessRatingValue(org.finos.waltz.model.rating.AuthoritativenessRatingValue) ListUtilities.newArrayList(org.finos.waltz.common.ListUtilities.newArrayList) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 4 with AuthoritativenessRatingValue

use of org.finos.waltz.model.rating.AuthoritativenessRatingValue in project waltz by khartec.

the class FlowClassificationRuleGenerator method create.

@Override
public Map<String, Integer> create(ApplicationContext ctx) {
    DSLContext dsl = getDsl(ctx);
    List<Long> appIds = getAppIds(dsl);
    List<Long> ouIds = dsl.select(ORGANISATIONAL_UNIT.ID).from(ORGANISATIONAL_UNIT).fetch(ORGANISATIONAL_UNIT.ID);
    List<Long> typeIds = dsl.select(DATA_TYPE.ID).from(DATA_TYPE).fetch(DATA_TYPE.ID);
    List<AuthoritativenessRatingValue> classificationValues = asList(AuthoritativenessRatingValue.of("PRIMARY"), AuthoritativenessRatingValue.of("SECONDARY"), AuthoritativenessRatingValue.DISCOURAGED, AuthoritativenessRatingValue.NO_OPINION);
    List<String> colors = asList(HexStrings.AMBER, HexStrings.RED, HexStrings.GREEN);
    Set<FlowClassificationRecord> classificationRecords = classificationValues.stream().map(v -> {
        FlowClassificationRecord record = dsl.newRecord(FLOW_CLASSIFICATION);
        record.setCode(v.value());
        record.setName(capitalise(v.value()));
        record.setColor(randomPick(colors));
        return record;
    }).collect(toSet());
    dsl.batchInsert(classificationRecords).execute();
    List<Long> classificationIds = dsl.select(FLOW_CLASSIFICATION.ID).from(FLOW_CLASSIFICATION).where(FLOW_CLASSIFICATION.CODE.notIn(AuthoritativenessRatingValue.DISCOURAGED.value(), AuthoritativenessRatingValue.NO_OPINION.value())).fetch(FLOW_CLASSIFICATION.ID);
    List<FlowClassificationRuleRecord> records = typeIds.stream().flatMap(t -> IntStream.range(0, 2 + rnd.nextInt(2)).mapToObj(i -> {
        FlowClassificationRuleRecord record = dsl.newRecord(FLOW_CLASSIFICATION_RULE);
        record.setDataTypeId(t);
        record.setFlowClassificationId(randomPick(classificationIds));
        record.setApplicationId(randomPick(appIds));
        record.setParentId(randomPick(ouIds));
        record.setParentKind(EntityKind.ORG_UNIT.name());
        record.setProvenance(SAMPLE_DATA_PROVENANCE);
        record.setLastUpdatedAt(nowUtcTimestamp());
        record.setLastUpdatedBy(SAMPLE_DATA_USER);
        return record;
    })).collect(Collectors.toList());
    dsl.batchStore(records).execute();
    return null;
}
Also used : IntStream(java.util.stream.IntStream) AuthoritativenessRatingValue(org.finos.waltz.model.rating.AuthoritativenessRatingValue) FLOW_CLASSIFICATION(org.finos.waltz.schema.Tables.FLOW_CLASSIFICATION) StringUtilities.capitalise(org.finos.waltz.common.StringUtilities.capitalise) HexStrings(org.finos.waltz.common.ColorUtilities.HexStrings) EntityKind(org.finos.waltz.model.EntityKind) Set(java.util.Set) Random(java.util.Random) ApplicationContext(org.springframework.context.ApplicationContext) Collectors(java.util.stream.Collectors) RandomUtilities(org.finos.waltz.common.RandomUtilities) FLOW_CLASSIFICATION_RULE(org.finos.waltz.schema.Tables.FLOW_CLASSIFICATION_RULE) List(java.util.List) DateTimeUtilities.nowUtcTimestamp(org.finos.waltz.common.DateTimeUtilities.nowUtcTimestamp) FlowClassificationRecord(org.finos.waltz.schema.tables.records.FlowClassificationRecord) FlowClassificationRuleRecord(org.finos.waltz.schema.tables.records.FlowClassificationRuleRecord) ORGANISATIONAL_UNIT(org.finos.waltz.schema.tables.OrganisationalUnit.ORGANISATIONAL_UNIT) ListUtilities.asList(org.finos.waltz.common.ListUtilities.asList) Map(java.util.Map) RandomUtilities.randomPick(org.finos.waltz.common.RandomUtilities.randomPick) DSLContext(org.jooq.DSLContext) Collectors.toSet(java.util.stream.Collectors.toSet) DATA_TYPE(org.finos.waltz.schema.tables.DataType.DATA_TYPE) FlowClassificationRuleRecord(org.finos.waltz.schema.tables.records.FlowClassificationRuleRecord) FlowClassificationRecord(org.finos.waltz.schema.tables.records.FlowClassificationRecord) AuthoritativenessRatingValue(org.finos.waltz.model.rating.AuthoritativenessRatingValue) DSLContext(org.jooq.DSLContext)

Example 5 with AuthoritativenessRatingValue

use of org.finos.waltz.model.rating.AuthoritativenessRatingValue in project waltz by khartec.

the class FlowClassificationRuleResolverTest method whenResolveWithExistingVantageButMissingDataTypeThenReturnsNoOpinion.

@Test
public void whenResolveWithExistingVantageButMissingDataTypeThenReturnsNoOpinion() {
    List<FlowClassificationRuleVantagePoint> vantagePoints = new ArrayList<>();
    vantagePoints.add(ImmutableFlowClassificationRuleVantagePoint.builder().vantagePoint(vantagePoint).vantagePointRank(1).dataType(EntityReference.mkRef(EntityKind.DATA_TYPE, 10)).dataTypeRank(1).applicationId(200L).classificationCode(AuthoritativenessRatingValue.of("SECONDARY").value()).ruleId(1L).build());
    FlowClassificationRuleResolver flowClassificationRuleResolver = new FlowClassificationRuleResolver(vantagePoints);
    AuthoritativenessRatingValue rating = flowClassificationRuleResolver.resolve(vantagePoint, sourceApp, 20L);
    assertEquals(AuthoritativenessRatingValue.NO_OPINION, rating);
}
Also used : ImmutableFlowClassificationRuleVantagePoint(org.finos.waltz.model.flow_classification_rule.ImmutableFlowClassificationRuleVantagePoint) FlowClassificationRuleVantagePoint(org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint) AuthoritativenessRatingValue(org.finos.waltz.model.rating.AuthoritativenessRatingValue) ListUtilities.newArrayList(org.finos.waltz.common.ListUtilities.newArrayList) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Aggregations

AuthoritativenessRatingValue (org.finos.waltz.model.rating.AuthoritativenessRatingValue)7 FlowClassificationRuleVantagePoint (org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint)5 ArrayList (java.util.ArrayList)4 ListUtilities.newArrayList (org.finos.waltz.common.ListUtilities.newArrayList)4 ImmutableFlowClassificationRuleVantagePoint (org.finos.waltz.model.flow_classification_rule.ImmutableFlowClassificationRuleVantagePoint)4 Test (org.junit.jupiter.api.Test)4 EntityKind (org.finos.waltz.model.EntityKind)3 Collectors (java.util.stream.Collectors)2 EntityReference (org.finos.waltz.model.EntityReference)2 java.util (java.util)1 List (java.util.List)1 Map (java.util.Map)1 Random (java.util.Random)1 Set (java.util.Set)1 Predicate (java.util.function.Predicate)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 IntStream (java.util.stream.IntStream)1 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)1 HexStrings (org.finos.waltz.common.ColorUtilities.HexStrings)1 DateTimeUtilities.nowUtcTimestamp (org.finos.waltz.common.DateTimeUtilities.nowUtcTimestamp)1