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();
});
}
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);
}
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);
}
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;
}
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);
}
Aggregations