Commit dfe24513 authored by Aalekh Jain's avatar Aalekh Jain
Browse files

Updated `WorkflowRunServiceImpl.java`

parent 1ff4de91
......@@ -18,10 +18,12 @@ import org.opengroup.osdu.workflow.gsm.WorkflowStatusPublisher;
import org.opengroup.osdu.workflow.logging.AuditLogger;
import org.opengroup.osdu.workflow.model.*;
import org.opengroup.osdu.workflow.provider.interfaces.IWorkflowEngineService;
import org.opengroup.osdu.workflow.provider.interfaces.IWorkflowManagerService;
import org.opengroup.osdu.workflow.provider.interfaces.IWorkflowMetadataRepository;
import org.opengroup.osdu.workflow.provider.interfaces.IWorkflowRunRepository;
import org.opengroup.osdu.workflow.provider.interfaces.IWorkflowRunService;
import org.opengroup.osdu.workflow.provider.interfaces.IWorkflowSystemMetadataRepository;
import org.springframework.stereotype.Service;
import static org.opengroup.osdu.core.common.model.status.Status.FAILED;
......@@ -50,8 +52,12 @@ public class WorkflowRunServiceImpl implements IWorkflowRunService {
private static final String KEY_DAG_NAME = "dagName";
private static final Integer WORKFLOW_RUN_LIMIT = 100;
private final IWorkflowManagerService workflowManagerService;
private final IWorkflowMetadataRepository workflowMetadataRepository;
private final IWorkflowSystemMetadataRepository workflowSystemMetadataRepository;
private final IWorkflowRunRepository workflowRunRepository;
private final DpsHeaders dpsHeaders;
......@@ -66,7 +72,7 @@ public class WorkflowRunServiceImpl implements IWorkflowRunService {
@Override
public WorkflowRunResponse triggerWorkflow(final String workflowName, final TriggerWorkflowRequest request) {
final WorkflowMetadata workflowMetadata = workflowMetadataRepository.getWorkflow(workflowName);
final WorkflowMetadata workflowMetadata = workflowManagerService.getWorkflowByName(workflowName);
final String workflowId = workflowMetadata.getWorkflowId();
final String runId = request.getRunId() != null ? request.getRunId() : UUID.randomUUID().toString();
String dagName = null;
......@@ -78,7 +84,7 @@ public class WorkflowRunServiceImpl implements IWorkflowRunService {
dagName = workflowMetadata.getWorkflowName();
}
final WorkflowEngineRequest rq = new WorkflowEngineRequest(runId, workflowId, workflowName, dagName);
final WorkflowEngineRequest rq = new WorkflowEngineRequest(runId, workflowId, workflowName, dagName, workflowMetadata.isSystemWorkflow());
final Map<String, Object> context = createWorkflowPayload(workflowName, runId, dpsHeaders.getCorrelationId(), request);
TriggerWorkflowResponse rs = workflowEngineService.triggerWorkflow(rq, context);
final WorkflowRun workflowRun = buildWorkflowRun(rq, rs);
......@@ -116,8 +122,8 @@ public class WorkflowRunServiceImpl implements IWorkflowRunService {
public List<WorkflowRun> getAllRunInstancesOfWorkflow(String workflowName,
Map<String, Object> params)
throws WorkflowNotFoundException {
// Calling getWorkflow will throw WorkflowNotFoundException
workflowMetadataRepository.getWorkflow(workflowName);
// Calling getWorkflowByName will throw WorkflowNotFoundException
workflowManagerService.getWorkflowByName(workflowName);
return workflowRunRepository.getAllRunInstancesOfWorkflow(workflowName, params);
}
......@@ -214,10 +220,10 @@ public class WorkflowRunServiceImpl implements IWorkflowRunService {
private WorkflowRun fetchAndUpdateWorkflowRunStatus(final WorkflowRun workflowRun) {
List<WorkflowStatusType> activeStatusTypes = WorkflowStatusType.getActiveStatusTypes();
if (activeStatusTypes.contains(workflowRun.getStatus())) {
final WorkflowMetadata workflowMetadata = workflowMetadataRepository.getWorkflow(workflowRun.getWorkflowName());
final WorkflowMetadata workflowMetadata = workflowManagerService.getWorkflowByName(workflowRun.getWorkflowName());
final String workflowName = workflowMetadata.getWorkflowName();
final WorkflowEngineRequest rq = new WorkflowEngineRequest(workflowName,
workflowRun.getStartTimeStamp(), workflowRun.getWorkflowEngineExecutionDate());
workflowRun.getStartTimeStamp(), workflowRun.getWorkflowEngineExecutionDate(), workflowMetadata.isSystemWorkflow());
final WorkflowStatusType currentStatusType = workflowEngineService.getWorkflowRunStatus(rq);
if (currentStatusType != workflowRun.getStatus() && currentStatusType != null) {
if (getCompletedStatusTypes().contains(currentStatusType)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment