use of org.finos.waltz.model.EntityReference in project waltz by khartec.
the class PhysicalFlowUploadService method validateCommand.
// //////////////////// PRIVATE //////////////////////
// ///////////////////////////////////////////////////
private PhysicalFlowUploadCommandResponse validateCommand(Map<String, Actor> actorsByName, Map<String, Application> applicationsByAssetCode, Map<String, DataType> dataTypeMap, Aliases<TransportKindValue> transportAliases, PhysicalFlowUploadCommand cmd) {
checkNotNull(cmd, "cmd cannot be null");
Map<String, String> errors = new HashMap<>();
// resolve entity refs - source, target, owner
EntityReference source = getNodeRefByString(actorsByName, applicationsByAssetCode, cmd.source());
EntityReference target = getNodeRefByString(actorsByName, applicationsByAssetCode, cmd.target());
EntityReference owner = getNodeRefByString(actorsByName, applicationsByAssetCode, cmd.owner());
EntityReference dataType = getDataTypeByString(dataTypeMap, cmd.dataType());
if (source == null) {
errors.put("source", String.format("%s not found", cmd.source()));
}
if (target == null) {
errors.put("target", String.format("%s not found", cmd.target()));
}
if (owner == null) {
errors.put("owner", String.format("%s not found", cmd.owner()));
}
if (dataType == null) {
errors.put("dataType", String.format("%s not found", cmd.dataType()));
}
// resolve enums - format, frequency, transport, criticality
DataFormatKind format = DataFormatKind.parse(cmd.format(), (s) -> null);
if (format == null) {
errors.put("format", String.format("%s is not a recognised value", cmd.format()));
}
FrequencyKind frequency = FrequencyKind.parse(cmd.frequency(), (s) -> null);
if (frequency == null) {
errors.put("frequency", String.format("%s is not a recognised value", cmd.frequency()));
}
TransportKindValue transport = transportAliases.lookup(cmd.transport()).orElseGet(() -> {
errors.put("transport", String.format("%s is not a recognised value", cmd.transport()));
return null;
});
Criticality criticality = Criticality.parse(cmd.criticality(), (s) -> null);
if (criticality == null) {
errors.put("criticality", String.format("%s is not a recognised value", cmd.criticality()));
}
// check for nulls or duplicates in other fields
if (isEmpty(cmd.name())) {
errors.put("name", "name not provided");
}
Integer basisOffset = parseBasisOffset(cmd.basisOffset());
if (basisOffset == null) {
errors.put("basisOffset", String.format("%s is not a recognised value, expect this to be a number", cmd.basisOffset()));
}
ImmutablePhysicalFlowParsed parsedFlow = ImmutablePhysicalFlowParsed.builder().source(source).target(target).owner(owner).name(cmd.name()).format(format).specDescription(cmd.specDescription()).specExternalId(cmd.specExternalId()).frequency(frequency).transport(transport).criticality(criticality).description(cmd.description()).externalId(cmd.externalId()).basisOffset(basisOffset).dataType(dataType).build();
return ImmutablePhysicalFlowUploadCommandResponse.builder().parsedFlow(parsedFlow).errors(errors).originalCommand(cmd).outcome(errors.size() > 0 ? CommandOutcome.FAILURE : CommandOutcome.SUCCESS).build();
}
use of org.finos.waltz.model.EntityReference 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);
}
use of org.finos.waltz.model.EntityReference in project waltz by khartec.
the class LogicalFlowDecoratorRatingsCalculator method lookupRating.
private AuthoritativenessRatingValue lookupRating(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();
return resolver.resolve(vantagePoint, source, decorator.decoratorEntity().id());
}
use of org.finos.waltz.model.EntityReference 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.EntityReference in project waltz by khartec.
the class ChangeUnitIdSelectorFactory method mkForDirectEntity.
private Select<Record1<Long>> mkForDirectEntity(IdSelectionOptions options) {
SelectorUtilities.ensureScopeIsExact(options);
EntityReference ref = options.entityReference();
return DSL.select(CHANGE_UNIT.ID).from(CHANGE_UNIT).where(CHANGE_UNIT.SUBJECT_ENTITY_ID.eq(ref.id())).and(CHANGE_UNIT.SUBJECT_ENTITY_KIND.eq(ref.kind().name()));
}
Aggregations