-
Notifications
You must be signed in to change notification settings - Fork 27
combine task status with its checker #247
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,4 +42,6 @@ | |
|
||
boolean optional(); | ||
|
||
String[] selectOptions() default {}; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ | |
import com.redhat.parodos.workflow.execution.entity.WorkFlowTaskExecution; | ||
import com.redhat.parodos.workflow.execution.repository.WorkFlowRepository; | ||
import com.redhat.parodos.workflow.execution.repository.WorkFlowTaskRepository; | ||
import com.redhat.parodos.workflow.task.enums.WorkFlowTaskStatus; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.ArrayList; | ||
|
@@ -148,12 +147,18 @@ private WorkStatusResponseDTO getWorkStatusResponseDTOFromWorkFlow(WorkFlowWorkD | |
|
||
WorkFlowExecution workExecution = workFlowRepository.findFirstByMainWorkFlowExecutionAndWorkFlowDefinitionId( | ||
workFlowExecution, workFlowWorkDefinition.getWorkDefinitionId()); | ||
|
||
/* | ||
* the workflow execution might be null when there is pending checker before it | ||
*/ | ||
ParodosWorkStatus workStatus = workExecution == null | ||
|| WorkFlowStatus.IN_PROGRESS.equals(workExecution.getStatus()) ? ParodosWorkStatus.PENDING | ||
: ParodosWorkStatus.valueOf(workExecution.getStatus().name()); | ||
ParodosWorkStatus workStatus; | ||
|
||
if (workExecution == null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. switch? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the logic here has some redundency, I have fixed it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch |
||
workStatus = ParodosWorkStatus.PENDING; | ||
} | ||
else { | ||
workStatus = ParodosWorkStatus.valueOf(workExecution.getStatus().name()); | ||
} | ||
|
||
return WorkStatusResponseDTO.builder().name(workFlowDefinition.getName()).type(WorkType.WORKFLOW) | ||
.status(workStatus).works(new ArrayList<>()).workExecution(workExecution) | ||
|
@@ -175,9 +180,19 @@ private WorkStatusResponseDTO getWorkStatusResponseDTOFromWorkFlowTask( | |
ParodosWorkStatus workStatus = ParodosWorkStatus.PENDING; | ||
|
||
if (workFlowTaskExecutionOptional.isPresent()) { | ||
workStatus = WorkFlowTaskStatus.IN_PROGRESS.equals(workFlowTaskExecutionOptional.get().getStatus()) | ||
? ParodosWorkStatus.PENDING | ||
: ParodosWorkStatus.valueOf(workFlowTaskExecutionOptional.get().getStatus().name()); | ||
workStatus = ParodosWorkStatus.valueOf(workFlowTaskExecutionOptional.get().getStatus().name()); | ||
if (workFlowTaskDefinition.getWorkFlowCheckerMappingDefinition() != null) { | ||
workStatus = Optional | ||
.ofNullable(workFlowRepository.findFirstByMainWorkFlowExecutionAndWorkFlowDefinitionId( | ||
workFlowExecution.getMainWorkFlowExecution(), | ||
workFlowTaskDefinition | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you use the service instead of the repository, definitions are in another package, and service should be used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just found there will be cyclic dependency if I use workflowService here, as workflowDelegate is also dependent of workflowService: https://github.com/RichardW98/parodos/blob/combine-task-checker-status/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/service/WorkFlowServiceImpl.java#L72 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. personally I think workflowService should depend on its delegate but not in reverse. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have created a ticket in our board to rearrange dependencies: https://issues.redhat.com/browse/FLPATH-290 |
||
.getWorkFlowCheckerMappingDefinition().getCheckWorkFlow().getId())) | ||
.map(WorkFlowExecution::getStatus) | ||
.map(checkerStatus -> WorkFlowStatus.FAILED.equals(checkerStatus) | ||
? ParodosWorkStatus.IN_PROGRESS : ParodosWorkStatus.valueOf(checkerStatus.name())) | ||
.orElse(ParodosWorkStatus.COMPLETED.equals(workStatus) ? ParodosWorkStatus.IN_PROGRESS | ||
: workStatus); | ||
} | ||
} | ||
|
||
return WorkStatusResponseDTO.builder().name(workFlowTaskDefinition.getName()).type(WorkType.TASK) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this break is not needed at all, n?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need it to avoid the errors (workflow with id not found) when app starts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in java, if no break then it continues to the case after it regardless if matches