Search in sources :

Example 1 with FlowClassificationRuleVantagePoint

use of org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint in project waltz by khartec.

the class LogicalFlowDecoratorRatingsCalculator method lookupFlowClassificationRule.

private Optional<Long> lookupFlowClassificationRule(Map<Long, DataType> typesById, Map<Long, LogicalFlow> flowsById, Map<Long, Application> targetAppsById, FlowClassificationRuleResolver resolver, DataTypeDecorator decorator) {
    LogicalFlow flow = flowsById.get(decorator.dataFlowId());
    EntityReference vantagePoint = lookupVantagePoint(targetAppsById, flow);
    EntityReference source = flow.source();
    Optional<FlowClassificationRuleVantagePoint> flowClassificationRuleVantagePoint = resolver.resolveAuthSource(vantagePoint, source, decorator.dataTypeId());
    return flowClassificationRuleVantagePoint.map(FlowClassificationRuleVantagePoint::ruleId);
}
Also used : FlowClassificationRuleVantagePoint(org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) EntityReference(org.finos.waltz.model.EntityReference)

Example 2 with FlowClassificationRuleVantagePoint

use of org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint in project waltz by khartec.

the class LogicalFlowDecoratorDao method updateDecoratorsForFlowClassificationRule.

public int updateDecoratorsForFlowClassificationRule(FlowClassificationRuleVantagePoint flowClassificationRuleVantagePoint) {
    LogicalFlowDecorator lfd = LOGICAL_FLOW_DECORATOR.as("lfd");
    EntityReference vantagePoint = flowClassificationRuleVantagePoint.vantagePoint();
    Long appId = flowClassificationRuleVantagePoint.applicationId();
    EntityReference dataType = flowClassificationRuleVantagePoint.dataType();
    String classificationCode = flowClassificationRuleVantagePoint.classificationCode();
    SelectConditionStep<Record1<Long>> orgUnitSubselect = DSL.select(ENTITY_HIERARCHY.ID).from(ENTITY_HIERARCHY).where(ENTITY_HIERARCHY.KIND.eq(vantagePoint.kind().name())).and(ENTITY_HIERARCHY.ANCESTOR_ID.eq(vantagePoint.id()));
    SelectConditionStep<Record1<Long>> dataTypeSubselect = DSL.select(ENTITY_HIERARCHY.ID).from(ENTITY_HIERARCHY).where(ENTITY_HIERARCHY.KIND.eq(DATA_TYPE.name())).and(ENTITY_HIERARCHY.ANCESTOR_ID.eq(dataType.id()));
    Condition usingFlowClassificationRule = LOGICAL_FLOW.SOURCE_ENTITY_ID.eq(appId);
    Condition notUsingFlowClassificationRule = LOGICAL_FLOW.SOURCE_ENTITY_ID.ne(appId);
    Function2<Condition, String, Update<LogicalFlowDecoratorRecord>> mkQuery = (appScopingCondition, ratingName) -> dsl.update(LOGICAL_FLOW_DECORATOR).set(LOGICAL_FLOW_DECORATOR.RATING, ratingName).set(LOGICAL_FLOW_DECORATOR.FLOW_CLASSIFICATION_RULE_ID, flowClassificationRuleVantagePoint.ruleId()).where(LOGICAL_FLOW_DECORATOR.ID.in(DSL.select(lfd.ID).from(lfd).innerJoin(LOGICAL_FLOW).on(LOGICAL_FLOW.ID.eq(lfd.LOGICAL_FLOW_ID)).innerJoin(APPLICATION).on(APPLICATION.ID.eq(LOGICAL_FLOW.TARGET_ENTITY_ID).and(LOGICAL_FLOW.TARGET_ENTITY_KIND.eq(EntityKind.APPLICATION.name()))).where(LOGICAL_FLOW.SOURCE_ENTITY_KIND.eq(EntityKind.APPLICATION.name()).and(appScopingCondition).and(APPLICATION.ORGANISATIONAL_UNIT_ID.in(orgUnitSubselect)).and(lfd.DECORATOR_ENTITY_KIND.eq(DATA_TYPE.name())).and(lfd.DECORATOR_ENTITY_ID.in(dataTypeSubselect))).and(lfd.RATING.in(AuthoritativenessRatingValue.NO_OPINION.value(), AuthoritativenessRatingValue.DISCOURAGED.value()))));
    Update<LogicalFlowDecoratorRecord> updateAuthSources = mkQuery.apply(usingFlowClassificationRule, classificationCode);
    Update<LogicalFlowDecoratorRecord> updateNonAuthSources = mkQuery.apply(notUsingFlowClassificationRule, AuthoritativenessRatingValue.DISCOURAGED.value());
    int authSourceUpdateCount = updateAuthSources.execute();
    int nonAuthSourceUpdateCount = updateNonAuthSources.execute();
    return authSourceUpdateCount + nonAuthSourceUpdateCount;
}
Also used : AuthoritativenessRatingValue(org.finos.waltz.model.rating.AuthoritativenessRatingValue) DSL(org.jooq.impl.DSL) APPLICATION(org.finos.waltz.schema.tables.Application.APPLICATION) LogicalFlowDecoratorRecord(org.finos.waltz.schema.tables.records.LogicalFlowDecoratorRecord) EntityKind(org.finos.waltz.model.EntityKind) LOGICAL_DATA_FLOW(org.finos.waltz.model.EntityKind.LOGICAL_DATA_FLOW) Autowired(org.springframework.beans.factory.annotation.Autowired) ListUtilities.newArrayList(org.finos.waltz.common.ListUtilities.newArrayList) Function(java.util.function.Function) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) LOGICAL_FLOW(org.finos.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW) LOGICAL_NOT_REMOVED(org.finos.waltz.data.logical_flow.LogicalFlowDao.LOGICAL_NOT_REMOVED) FlowClassificationRuleVantagePoint(org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint) Function2(org.jooq.lambda.function.Function2) org.jooq(org.jooq) PHYSICAL_FLOW(org.finos.waltz.schema.Tables.PHYSICAL_FLOW) LogicalFlowDecorator(org.finos.waltz.schema.tables.LogicalFlowDecorator) Repository(org.springframework.stereotype.Repository) ENTITY_HIERARCHY(org.finos.waltz.schema.tables.EntityHierarchy.ENTITY_HIERARCHY) EntityLifecycleStatus(org.finos.waltz.model.EntityLifecycleStatus) LOGICAL_FLOW_DECORATOR(org.finos.waltz.schema.tables.LogicalFlowDecorator.LOGICAL_FLOW_DECORATOR) DataTypeDecorator(org.finos.waltz.model.datatype.DataTypeDecorator) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) DataTypeUsageCharacteristics(org.finos.waltz.model.datatype.DataTypeUsageCharacteristics) Set(java.util.Set) ImmutableDataTypeUsageCharacteristics(org.finos.waltz.model.datatype.ImmutableDataTypeUsageCharacteristics) ImmutableDataTypeDecorator(org.finos.waltz.model.datatype.ImmutableDataTypeDecorator) String.format(java.lang.String.format) PHYSICAL_SPEC_DATA_TYPE(org.finos.waltz.schema.tables.PhysicalSpecDataType.PHYSICAL_SPEC_DATA_TYPE) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) InlineSelectFieldFactory(org.finos.waltz.data.InlineSelectFieldFactory) SetUtilities(org.finos.waltz.common.SetUtilities) EntityReference(org.finos.waltz.model.EntityReference) Optional(java.util.Optional) DATA_TYPE(org.finos.waltz.model.EntityKind.DATA_TYPE) LogicalFlowDecoratorRecord(org.finos.waltz.schema.tables.records.LogicalFlowDecoratorRecord) LogicalFlowDecorator(org.finos.waltz.schema.tables.LogicalFlowDecorator) FlowClassificationRuleVantagePoint(org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint) EntityReference(org.finos.waltz.model.EntityReference)

Example 3 with FlowClassificationRuleVantagePoint

use of org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint 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 4 with FlowClassificationRuleVantagePoint

use of org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint 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 5 with FlowClassificationRuleVantagePoint

use of org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint 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

FlowClassificationRuleVantagePoint (org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint)8 ListUtilities.newArrayList (org.finos.waltz.common.ListUtilities.newArrayList)5 ImmutableFlowClassificationRuleVantagePoint (org.finos.waltz.model.flow_classification_rule.ImmutableFlowClassificationRuleVantagePoint)5 AuthoritativenessRatingValue (org.finos.waltz.model.rating.AuthoritativenessRatingValue)5 Test (org.junit.jupiter.api.Test)5 ArrayList (java.util.ArrayList)4 EntityReference (org.finos.waltz.model.EntityReference)2 String.format (java.lang.String.format)1 Timestamp (java.sql.Timestamp)1 Collection (java.util.Collection)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Function (java.util.function.Function)1 Collectors.toList (java.util.stream.Collectors.toList)1 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)1 SetUtilities (org.finos.waltz.common.SetUtilities)1 InlineSelectFieldFactory (org.finos.waltz.data.InlineSelectFieldFactory)1 LOGICAL_NOT_REMOVED (org.finos.waltz.data.logical_flow.LogicalFlowDao.LOGICAL_NOT_REMOVED)1 EntityKind (org.finos.waltz.model.EntityKind)1