use of org.finos.waltz.schema.tables.records.LogicalFlowDecoratorRecord 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.records.LogicalFlowDecoratorRecord in project waltz by khartec.
the class LogicalFlowDecorationGenerator method create.
@Override
public Map<String, Integer> create(ApplicationContext ctx) {
DSLContext dsl = ctx.getBean(DSLContext.class);
List<Long> flowIds = dsl.select(LOGICAL_FLOW.ID).from(LOGICAL_FLOW).fetch(LOGICAL_FLOW.ID);
List<Long> typeIds = dsl.select(DATA_TYPE.ID).from(DATA_TYPE).fetch(DATA_TYPE.ID);
List<LogicalFlowDecoratorRecord> records = map(flowIds, id -> {
LogicalFlowDecoratorRecord record = dsl.newRecord(LOGICAL_FLOW_DECORATOR);
record.setLogicalFlowId(id);
record.setDecoratorEntityId(randomPick(typeIds));
record.setDecoratorEntityKind(EntityKind.DATA_TYPE.name());
record.setProvenance(SAMPLE_DATA_PROVENANCE);
record.setLastUpdatedBy("admin");
record.setLastUpdatedAt(Timestamp.from(Instant.now()));
return record;
});
Set<LogicalFlowDecoratorRecord> deduped = uniqBy(records, r -> "lfd:" + r.getLogicalFlowId() + "_" + r.getDecoratorEntityId() + "_" + r.getDecoratorEntityKind());
log("--- saving: " + deduped.size());
dsl.batchStore(deduped).execute();
log("--- done");
return null;
}
use of org.finos.waltz.schema.tables.records.LogicalFlowDecoratorRecord in project waltz by khartec.
the class WaltzUtilities method mkLogicalFlowDecoratorRecord.
public static LogicalFlowDecoratorRecord mkLogicalFlowDecoratorRecord(long flowId, long dtId, String provenance) {
LogicalFlowDecoratorRecord decorator = new LogicalFlowDecoratorRecord();
decorator.setLogicalFlowId(flowId);
decorator.setDecoratorEntityKind(EntityKind.DATA_TYPE.name());
decorator.setDecoratorEntityId(dtId);
decorator.setProvenance(provenance);
decorator.setLastUpdatedAt(nowUtcTimestamp());
decorator.setLastUpdatedBy("admin");
decorator.setRating(AuthoritativenessRatingValue.NO_OPINION.value());
return decorator;
}
Aggregations