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");
}
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");
}
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));
}
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()));
}
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;
}
}
Aggregations