Search in sources :

Example 16 with PhysicalSpecification

use of org.finos.waltz.model.physical_specification.PhysicalSpecification in project waltz by khartec.

the class PhysicalFlowServiceTest method create_canReactivateSpecIfRequired.

@Test
public void create_canReactivateSpecIfRequired() {
    String username = mkName("createCanReactivateSpecIfRequired");
    EntityReference a = appHelper.createNewApp(mkName("a"), ouIds.a);
    EntityReference b = appHelper.createNewApp(mkName("b"), ouIds.a1);
    LogicalFlow ab = lfHelper.createLogicalFlow(a, b);
    Long specId = psHelper.createPhysicalSpec(a, mkName("createIfDuplicateFlowWillReturnFailureWithMessage"));
    psSvc.markRemovedIfUnused(ImmutablePhysicalSpecificationDeleteCommand.builder().specificationId(specId).build(), username);
    PhysicalSpecification specOnceRemoved = psSvc.getById(specId);
    assertTrue(specOnceRemoved.isRemoved(), "Specification is only soft deleted prior to reactivation");
    ImmutableFlowAttributes flowAttrs = ImmutableFlowAttributes.builder().frequency(FrequencyKind.DAILY).criticality(Criticality.MEDIUM).transport(TransportKindValue.UNKNOWN).basisOffset(0).build();
    ImmutablePhysicalFlowCreateCommand createCommand = ImmutablePhysicalFlowCreateCommand.builder().logicalFlowId(ab.entityReference().id()).specification(specOnceRemoved).flowAttributes(flowAttrs).build();
    PhysicalFlowCreateCommandResponse createResp = pfSvc.create(createCommand, username);
    assertEquals(CommandOutcome.SUCCESS, createResp.outcome(), "Successfully creates flow when spec needs to be reactivated");
    PhysicalFlow newPhysFlow = pfSvc.getById(createResp.entityReference().id());
    PhysicalSpecification reactivatedSpec = psSvc.getById(newPhysFlow.specificationId());
    assertFalse(reactivatedSpec.isRemoved(), "Specification is active after new flow is created");
    assertEquals(specId, Long.valueOf(reactivatedSpec.entityReference().id()), "Specification associated to flow has the correct id");
}
Also used : ImmutablePhysicalSpecification(org.finos.waltz.model.physical_specification.ImmutablePhysicalSpecification) PhysicalSpecification(org.finos.waltz.model.physical_specification.PhysicalSpecification) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 17 with PhysicalSpecification

use of org.finos.waltz.model.physical_specification.PhysicalSpecification in project waltz by khartec.

the class PhysicalFlowServiceTest method create_shouldRestoreLogicalFlowIfRemoved.

@Test
public void create_shouldRestoreLogicalFlowIfRemoved() {
    EntityReference a = appHelper.createNewApp(mkName("a"), ouIds.a);
    EntityReference b = appHelper.createNewApp(mkName("b"), ouIds.a1);
    LogicalFlow ab = lfHelper.createLogicalFlow(a, b);
    Long specId = psHelper.createPhysicalSpec(a, mkName("delete"));
    PhysicalSpecification spec = psSvc.getById(specId);
    assertThrows(IllegalArgumentException.class, () -> pfSvc.create(null, mkName("create")), "Should throw exception if null object passed into create");
    ImmutableFlowAttributes flowAttrs = ImmutableFlowAttributes.builder().frequency(FrequencyKind.DAILY).criticality(Criticality.MEDIUM).transport(TransportKindValue.UNKNOWN).basisOffset(0).build();
    ImmutablePhysicalFlowCreateCommand createCommand = ImmutablePhysicalFlowCreateCommand.builder().logicalFlowId(ab.entityReference().id()).specification(spec).flowAttributes(flowAttrs).build();
    lfSvc.removeFlow(ab.entityReference().id(), mkName("create"));
    PhysicalFlowCreateCommandResponse createRespWithRemovedFlow = pfSvc.create(createCommand, mkName("create"));
    assertEquals(CommandOutcome.SUCCESS, createRespWithRemovedFlow.outcome(), "Should restore removed logical flows and create physical");
    LogicalFlow abAfterFlowAdded = lfSvc.getById(ab.entityReference().id());
    assertFalse(abAfterFlowAdded.isRemoved(), "Logical flows should be active if physicals have been added");
}
Also used : ImmutablePhysicalSpecification(org.finos.waltz.model.physical_specification.ImmutablePhysicalSpecification) PhysicalSpecification(org.finos.waltz.model.physical_specification.PhysicalSpecification) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 18 with PhysicalSpecification

use of org.finos.waltz.model.physical_specification.PhysicalSpecification in project waltz by khartec.

the class PhysicalFlowHelper method createPhysicalFlow.

public PhysicalFlowCreateCommandResponse createPhysicalFlow(Long flowId, Long specId, String name) {
    PhysicalSpecification spec = physicalSpecificationService.getById(specId);
    ImmutableFlowAttributes flowAttributes = ImmutableFlowAttributes.builder().transport(TransportKindValue.UNKNOWN).description("").basisOffset(1).criticality(Criticality.MEDIUM).frequency(FrequencyKind.DAILY).build();
    ImmutablePhysicalFlowCreateCommand createCmd = ImmutablePhysicalFlowCreateCommand.builder().logicalFlowId(flowId).specification(spec).flowAttributes(flowAttributes).build();
    return physicalFlowService.create(createCmd, mkName(name));
}
Also used : PhysicalSpecification(org.finos.waltz.model.physical_specification.PhysicalSpecification)

Example 19 with PhysicalSpecification

use of org.finos.waltz.model.physical_specification.PhysicalSpecification 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 20 with PhysicalSpecification

use of org.finos.waltz.model.physical_specification.PhysicalSpecification 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

PhysicalSpecification (org.finos.waltz.model.physical_specification.PhysicalSpecification)21 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)16 ImmutablePhysicalSpecification (org.finos.waltz.model.physical_specification.ImmutablePhysicalSpecification)13 BaseInMemoryIntegrationTest (org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest)9 Test (org.junit.jupiter.api.Test)9 PhysicalFlow (org.finos.waltz.model.physical_flow.PhysicalFlow)4 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)3 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Service (org.springframework.stereotype.Service)3 String.format (java.lang.String.format)2 LocalDateTime (java.time.LocalDateTime)2 Collection (java.util.Collection)2 List (java.util.List)2 Set (java.util.Set)2 DateTimeUtilities.nowUtc (org.finos.waltz.common.DateTimeUtilities.nowUtc)2 ListUtilities.newArrayList (org.finos.waltz.common.ListUtilities.newArrayList)2 StringUtilities.isEmpty (org.finos.waltz.common.StringUtilities.isEmpty)2 PhysicalFlowDao (org.finos.waltz.data.physical_flow.PhysicalFlowDao)2 org.finos.waltz.model (org.finos.waltz.model)2