Search in sources :

Example 66 with LogicalFlow

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");
}
Also used : LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) EntityReference(org.finos.waltz.model.EntityReference) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 67 with LogicalFlow

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()));
}
Also used : PhysicalSpecification(org.finos.waltz.model.physical_specification.PhysicalSpecification) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow)

Example 68 with LogicalFlow

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());
}
Also used : AuthoritativenessRatingValue(org.finos.waltz.model.rating.AuthoritativenessRatingValue) java.util(java.util) LogicalFlowDao(org.finos.waltz.data.logical_flow.LogicalFlowDao) FlowClassification(org.finos.waltz.model.flow_classification.FlowClassification) ApplicationService(org.finos.waltz.service.application.ApplicationService) EntityKind(org.finos.waltz.model.EntityKind) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) FlowClassificationDao(org.finos.waltz.data.flow_classification_rule.FlowClassificationDao) DataType(org.finos.waltz.model.datatype.DataType) SetUtilities.map(org.finos.waltz.common.SetUtilities.map) FlowClassificationRuleVantagePoint(org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint) FlowClassificationRuleDao(org.finos.waltz.data.flow_classification_rule.FlowClassificationRuleDao) Service(org.springframework.stereotype.Service) IdUtilities.indexById(org.finos.waltz.model.utils.IdUtilities.indexById) Logger(org.slf4j.Logger) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) Application(org.finos.waltz.model.application.Application) DataTypeDecorator(org.finos.waltz.model.datatype.DataTypeDecorator) Predicate(java.util.function.Predicate) ListUtilities.isEmpty(org.finos.waltz.common.ListUtilities.isEmpty) ImmutableDataTypeDecorator(org.finos.waltz.model.datatype.ImmutableDataTypeDecorator) Collectors(java.util.stream.Collectors) FlowClassificationRuleResolver(org.finos.waltz.service.flow_classification_rule.FlowClassificationRuleResolver) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) ListUtilities.filter(org.finos.waltz.common.ListUtilities.filter) EntityReference(org.finos.waltz.model.EntityReference) DataTypeDao(org.finos.waltz.data.data_type.DataTypeDao) FlowClassification(org.finos.waltz.model.flow_classification.FlowClassification) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) AuthoritativenessRatingValue(org.finos.waltz.model.rating.AuthoritativenessRatingValue) DataType(org.finos.waltz.model.datatype.DataType) Application(org.finos.waltz.model.application.Application) FlowClassificationRuleResolver(org.finos.waltz.service.flow_classification_rule.FlowClassificationRuleResolver)

Example 69 with LogicalFlow

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());
}
Also used : LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow)

Example 70 with LogicalFlow

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;
    }
}
Also used : PhysicalSpecification(org.finos.waltz.model.physical_specification.PhysicalSpecification) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow)

Aggregations

LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)72 BaseInMemoryIntegrationTest (org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest)52 Test (org.junit.jupiter.api.Test)52 EntityReference (org.finos.waltz.model.EntityReference)40 PhysicalSpecification (org.finos.waltz.model.physical_specification.PhysicalSpecification)21 ImmutablePhysicalSpecification (org.finos.waltz.model.physical_specification.ImmutablePhysicalSpecification)15 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)13 DataTypeDecorator (org.finos.waltz.model.datatype.DataTypeDecorator)13 LogicalFlowService (org.finos.waltz.service.logical_flow.LogicalFlowService)13 Autowired (org.springframework.beans.factory.annotation.Autowired)13 Collections.emptyList (java.util.Collections.emptyList)12 List (java.util.List)12 SetUtilities.map (org.finos.waltz.common.SetUtilities.map)12 Collection (java.util.Collection)11 IdSelectionOptions.mkOpts (org.finos.waltz.model.IdSelectionOptions.mkOpts)11 Collections.emptySet (java.util.Collections.emptySet)10 SetUtilities.asSet (org.finos.waltz.common.SetUtilities.asSet)10 Assertions (org.junit.jupiter.api.Assertions)10 DateTimeUtilities (org.finos.waltz.common.DateTimeUtilities)9 org.finos.waltz.integration_test.inmem.helpers (org.finos.waltz.integration_test.inmem.helpers)9