Search in sources :

Example 1 with UpdateExecutionStatusCommand

use of org.finos.waltz.model.change_unit.UpdateExecutionStatusCommand in project waltz by khartec.

the class ModifyCommandProcessor method modifyPhysicalFlow.

private CommandResponse<UpdateExecutionStatusCommand> modifyPhysicalFlow(UpdateExecutionStatusCommand command, ChangeUnit changeUnit, String userName) {
    doBasicValidation(command, changeUnit, userName);
    PhysicalFlow subject = physicalFlowService.getById(changeUnit.subjectEntity().id());
    checkNotNull(subject, "subject not found: " + changeUnit.subjectEntity());
    checkTrue(subject.entityLifecycleStatus().equals(changeUnit.subjectInitialStatus()), "current subject status does not match initial change unit status: " + subject);
    // fetch attribute changes
    List<AttributeChange> attributeChanges = attributeChangeService.findByChangeUnitId(changeUnit.id().get());
    boolean success = attributeChanges.stream().map(a -> processAttributeChange(a, changeUnit, userName)).allMatch(a -> a == true);
    return ImmutableCommandResponse.<UpdateExecutionStatusCommand>builder().entityReference(subject.entityReference()).originalCommand(command).outcome(success ? CommandOutcome.SUCCESS : CommandOutcome.FAILURE).message("Modified physical flow: " + subject + " attributes").build();
}
Also used : CommandResponse(org.finos.waltz.model.command.CommandResponse) ChangeUnit(org.finos.waltz.model.change_unit.ChangeUnit) PhysicalFlowService(org.finos.waltz.service.physical_flow.PhysicalFlowService) CommandOutcome(org.finos.waltz.model.command.CommandOutcome) AttributeChangeCommandProcessor(org.finos.waltz.service.change_unit.AttributeChangeCommandProcessor) Autowired(org.springframework.beans.factory.annotation.Autowired) PhysicalFlow(org.finos.waltz.model.physical_flow.PhysicalFlow) Checks.checkTrue(org.finos.waltz.common.Checks.checkTrue) List(java.util.List) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) ChangeUnitCommandProcessor(org.finos.waltz.service.change_unit.ChangeUnitCommandProcessor) Collectors.toMap(java.util.stream.Collectors.toMap) ImmutableCommandResponse(org.finos.waltz.model.command.ImmutableCommandResponse) AttributeChange(org.finos.waltz.model.attribute_change.AttributeChange) UpdateExecutionStatusCommand(org.finos.waltz.model.change_unit.UpdateExecutionStatusCommand) Service(org.springframework.stereotype.Service) ChangeAction(org.finos.waltz.model.change_unit.ChangeAction) Map(java.util.Map) AttributeChangeService(org.finos.waltz.service.attribute_change.AttributeChangeService) AttributeChange(org.finos.waltz.model.attribute_change.AttributeChange) PhysicalFlow(org.finos.waltz.model.physical_flow.PhysicalFlow)

Aggregations

List (java.util.List)1 Map (java.util.Map)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)1 Checks.checkTrue (org.finos.waltz.common.Checks.checkTrue)1 AttributeChange (org.finos.waltz.model.attribute_change.AttributeChange)1 ChangeAction (org.finos.waltz.model.change_unit.ChangeAction)1 ChangeUnit (org.finos.waltz.model.change_unit.ChangeUnit)1 UpdateExecutionStatusCommand (org.finos.waltz.model.change_unit.UpdateExecutionStatusCommand)1 CommandOutcome (org.finos.waltz.model.command.CommandOutcome)1 CommandResponse (org.finos.waltz.model.command.CommandResponse)1 ImmutableCommandResponse (org.finos.waltz.model.command.ImmutableCommandResponse)1 PhysicalFlow (org.finos.waltz.model.physical_flow.PhysicalFlow)1 AttributeChangeService (org.finos.waltz.service.attribute_change.AttributeChangeService)1 AttributeChangeCommandProcessor (org.finos.waltz.service.change_unit.AttributeChangeCommandProcessor)1 ChangeUnitCommandProcessor (org.finos.waltz.service.change_unit.ChangeUnitCommandProcessor)1 PhysicalFlowService (org.finos.waltz.service.physical_flow.PhysicalFlowService)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Service (org.springframework.stereotype.Service)1