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