use of org.finos.waltz.model.logical_flow.LogicalFlow in project waltz by khartec.
the class AttestationPreCheckServiceTest method allowedToAttestAttestIfInExemptionGroupAndDeprecatedIncomingDataTypeFlows.
@Test
public void allowedToAttestAttestIfInExemptionGroupAndDeprecatedIncomingDataTypeFlows() throws InsufficientPrivelegeException {
EntityReference aRef = mkNewAppRef();
EntityReference bRef = mkNewAppRef();
// create flow with unknown datatype
long deprecatedId = createDeprecatedDataType();
LogicalFlow flow = lfHelper.createLogicalFlow(aRef, bRef);
lfHelper.createLogicalFlowDecorators(flow.entityReference(), asSet(deprecatedId));
createGroupWithApps(AttestationPreCheckDao.GROUP_LOGICAL_FLOW_ATTESTATION_EXEMPT_FROM_DEPRECATED_DATA_TYPE_CHECK, bRef);
List<String> bResult = aipcSvc.calcLogicalFlowPreCheckFailures(bRef);
assertTrue(bResult.isEmpty(), "should pass as target app is in exemption from deprecated flows group");
}
use of org.finos.waltz.model.logical_flow.LogicalFlow in project waltz by khartec.
the class ChangeLogService method preparePreambleAndEntitiesForChangeLogs.
private Tuple2<String, Set<EntityReference>> preparePreambleAndEntitiesForChangeLogs(PhysicalFlow physicalFlow) {
LogicalFlow logicalFlow = logicalFlowDao.getByFlowId(physicalFlow.logicalFlowId());
PhysicalSpecification specification = physicalSpecificationDao.getById(physicalFlow.specificationId());
String messagePreamble = format("Physical flow: %s, from: %s, to: %s", specification.name(), safeName(logicalFlow.source()), safeName(logicalFlow.target()));
return tuple(messagePreamble, asSet(physicalFlow.entityReference(), logicalFlow.entityReference(), logicalFlow.source(), logicalFlow.target()));
}
use of org.finos.waltz.model.logical_flow.LogicalFlow in project waltz by khartec.
the class LogicalFlowDecoratorRatingsCalculator method calculate.
public Collection<DataTypeDecorator> calculate(Collection<DataTypeDecorator> decorators) {
List<LogicalFlow> appToAppFlows = filter(IS_APP_TO_APP_FLOW, loadFlows(decorators));
if (isEmpty(appToAppFlows))
return Collections.emptyList();
List<Application> targetApps = loadTargetApplications(appToAppFlows);
List<DataType> dataTypes = dataTypeDao.findAll();
Set<FlowClassification> flowClassifications = flowClassificationDao.findAll();
Map<Long, DataType> typesById = indexById(dataTypes);
Map<Long, LogicalFlow> flowsById = indexById(appToAppFlows);
Map<Long, Application> targetAppsById = indexById(targetApps);
FlowClassificationRuleResolver resolver = createResolver(targetApps);
return decorators.stream().filter(d -> flowsById.containsKey(d.dataFlowId())).map(decorator -> {
try {
if (decorator.decoratorEntity().kind() != EntityKind.DATA_TYPE) {
return decorator;
} else {
AuthoritativenessRatingValue rating = lookupRating(flowsById, targetAppsById, resolver, decorator);
Optional<Long> ruleId = lookupFlowClassificationRule(typesById, flowsById, targetAppsById, resolver, decorator);
return ImmutableDataTypeDecorator.copyOf(decorator).withRating(rating).withFlowClassificationRuleId(ruleId);
}
} catch (Exception e) {
LOG.warn("Failed to calculate rating for decorator: {}, reason: {}", decorator, e.getMessage());
return null;
}
}).filter(Objects::nonNull).collect(Collectors.toSet());
}
use of org.finos.waltz.model.logical_flow.LogicalFlow in project waltz by khartec.
the class FlowDiagramService method makeForLogicalFlow.
private Long makeForLogicalFlow(EntityReference ref, String userId, String providedTitle) {
LogicalFlow logicalFlow = logicalFlowDao.getByFlowId(ref.id());
String title = isEmpty(providedTitle) ? format("%s -> %s flow diagram", logicalFlow.source().name(), logicalFlow.target().name()) : providedTitle;
ArrayList<FlowDiagramEntity> entities = newArrayList(mkDiagramEntity(logicalFlow), mkDiagramEntity(logicalFlow.source()), mkDiagramEntity(logicalFlow.target()));
return mkNewFlowDiagram(title, userId, entities, emptyList());
}
use of org.finos.waltz.model.logical_flow.LogicalFlow in project waltz by khartec.
the class DataTypeDecoratorService method auditEntityDataTypeChanges.
private void auditEntityDataTypeChanges(String userName, EntityReference entityReference, String currentDataTypeNames) {
String updatedDataTypeNames = getAssociatedDatatypeNamesAsCsv(entityReference);
switch(entityReference.kind()) {
case LOGICAL_DATA_FLOW:
LogicalFlow logicalFlow = logicalFlowDao.getByFlowId(entityReference.id());
String auditMessage = format("Logical Flow from %s to %s: Data types changed from [%s] to [%s]", logicalFlow.source().name().orElse(""), logicalFlow.target().name().orElse(""), currentDataTypeNames, updatedDataTypeNames);
audit(auditMessage, logicalFlow.source(), userName);
audit(auditMessage, logicalFlow.target(), userName);
break;
case PHYSICAL_SPECIFICATION:
PhysicalSpecification physicalSpecification = physicalSpecificationDao.getById(entityReference.id());
logicalFlowService.findBySelector(mkOpts(entityReference)).forEach(lf -> {
String message = format("Physical Specification [%s]: Data types changed from [%s] to [%s]", physicalSpecification.name(), currentDataTypeNames, updatedDataTypeNames);
audit(message, physicalSpecification.entityReference(), userName);
audit(message, lf.source(), userName);
audit(message, lf.target(), userName);
});
break;
}
}
Aggregations