use of org.finos.waltz.model.EntityReference in project waltz by khartec.
the class AssessmentRatingDao method store.
public boolean store(SaveAssessmentRatingCommand command) {
checkNotNull(command, "command cannot be null");
AssessmentRatingRecord record = TO_RECORD_MAPPER.apply(command);
EntityReference ref = command.entityReference();
boolean isUpdate = dsl.fetchExists(dsl.select(ASSESSMENT_RATING.fields()).from(ASSESSMENT_RATING).where(ASSESSMENT_RATING.ENTITY_KIND.eq(ref.kind().name())).and(ASSESSMENT_RATING.ENTITY_ID.eq(ref.id())).and(ASSESSMENT_RATING.ASSESSMENT_DEFINITION_ID.eq(command.assessmentDefinitionId())));
return isUpdate ? dsl.executeUpdate(record) == 1 : dsl.executeInsert(record) == 1;
}
use of org.finos.waltz.model.EntityReference in project waltz by khartec.
the class ApplicationIdSelectorFactory method apply.
public Select<Record1<Long>> apply(IdSelectionOptions options) {
checkNotNull(options, "options cannot be null");
EntityReference ref = options.entityReference();
switch(ref.kind()) {
case ACTOR:
return mkForActor(options);
case APP_GROUP:
return mkForAppGroup(options);
case APPLICATION:
return mkForApplication(options);
case CHANGE_INITIATIVE:
return mkForEntityRelationship(options);
case DATA_TYPE:
return mkForDataType(options);
case FLOW_DIAGRAM:
return mkForFlowDiagram(options);
case LICENCE:
return mkForLicence(options);
case LOGICAL_DATA_FLOW:
return mkForLogicalDataFlow(options);
case MEASURABLE:
return mkForMeasurable(options);
case SCENARIO:
return mkForScenario(options);
case SERVER:
return mkForServer(options);
case ORG_UNIT:
return mkForOrgUnit(options);
case PERSON:
return mkForPerson(options);
case PHYSICAL_FLOW:
return mkForPhysicalFlow(options);
case PHYSICAL_SPECIFICATION:
return mkForPhysicalSpec(options);
case SOFTWARE:
return mkForSoftwarePackage(options);
case SOFTWARE_VERSION:
return mkForSoftwareVersion(options);
case TAG:
return mkForTag(options);
case DATABASE:
return mkForDatabase(options);
case PROCESS_DIAGRAM:
return mkForProcessDiagram(options);
default:
throw new IllegalArgumentException("Cannot create selector for entity kind: " + ref.kind());
}
}
use of org.finos.waltz.model.EntityReference 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.model.EntityReference in project waltz by khartec.
the class EndUserAppIdSelectorFactory method apply.
@Override
public Select<Record1<Long>> apply(IdSelectionOptions options) {
checkNotNull(options, "options cannot be null");
EntityReference ref = options.entityReference();
switch(ref.kind()) {
case ORG_UNIT:
return mkForOrgUnit(options);
case PERSON:
return mkForPerson(options);
default:
throw new IllegalArgumentException("Cannot create selector for entity kind: " + ref.kind());
}
}
use of org.finos.waltz.model.EntityReference in project waltz by khartec.
the class DiagramToDotExport method main.
public static void main(String[] args) throws IOException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
FlowDiagramService flowDiagramService = ctx.getBean(FlowDiagramService.class);
FlowDiagramEntityService flowDiagramEntityService = ctx.getBean(FlowDiagramEntityService.class);
ApplicationService applicationService = ctx.getBean(ApplicationService.class);
LogicalFlowService logicalFlowService = ctx.getBean(LogicalFlowService.class);
EntityReference diagRef = mkRef(EntityKind.FLOW_DIAGRAM, 1L);
IdSelectionOptions options = IdSelectionOptions.mkOpts(diagRef, HierarchyQueryScope.EXACT);
List<Application> apps = applicationService.findByAppIdSelector(options);
List<LogicalFlow> flows = logicalFlowService.findBySelector(options);
Map<Long, Application> appsById = indexBy(a -> a.id().get(), apps);
System.out.println("------");
String digraph = String.format("digraph G { %s %s}", renderApplications(apps), renderFlows(flows, appsById));
System.out.println(digraph);
System.out.println("-----");
/*
digraph G {
"Welcome" -> "To"
"To" -> "Web"
"To" -> "GraphViz!"
}
*/
}
Aggregations