use of org.finos.waltz.schema.tables.LogicalFlowDecorator.LOGICAL_FLOW_DECORATOR 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;
}
use of org.finos.waltz.schema.tables.LogicalFlowDecorator.LOGICAL_FLOW_DECORATOR in project waltz by khartec.
the class FlowLineageHarness method findIncomingByRefs.
private static void findIncomingByRefs(DSLContext dsl, Set<EntityReference> entityReferences) {
Map<EntityKind, Collection<EntityReference>> refsByKind = groupBy(ref -> ref.kind(), entityReferences);
Condition anyTargetMatches = refsByKind.entrySet().stream().map(entry -> LOGICAL_FLOW.TARGET_ENTITY_KIND.eq(entry.getKey().name()).and(LOGICAL_FLOW.TARGET_ENTITY_ID.in(map(entry.getValue(), ref -> ref.id())))).collect(Collectors.reducing(DSL.falseCondition(), (acc, c) -> acc.or(c)));
System.out.println(anyTargetMatches);
Field<String> SOURCE_NAME_FIELD = InlineSelectFieldFactory.mkNameField(LOGICAL_FLOW.SOURCE_ENTITY_ID, LOGICAL_FLOW.SOURCE_ENTITY_KIND, newArrayList(EntityKind.APPLICATION, EntityKind.ACTOR));
dsl.select(LOGICAL_FLOW.fields()).select(SOURCE_NAME_FIELD).from(LOGICAL_FLOW).where(anyTargetMatches.and(LogicalFlowDao.LOGICAL_NOT_REMOVED)).forEach(System.out::println);
dsl.select().from(LOGICAL_FLOW_DECORATOR).innerJoin(LOGICAL_FLOW).on(LOGICAL_FLOW.ID.eq(LOGICAL_FLOW_DECORATOR.LOGICAL_FLOW_ID)).where(anyTargetMatches).forEach(System.out::println);
}
Aggregations