Skip to content

Commit

Permalink
ONECOND-2336
Browse files Browse the repository at this point in the history
  • Loading branch information
sangeetanadgir committed Aug 30, 2024
1 parent 8a7cb35 commit decd796
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public List<String> handle(EventHandler.Action action, Object payload, EventExec
} else {
taskStatus = Task.Status.COMPLETED;
}
logger.debug("ReferenceKeysMatchAction: Task Status " + taskStatus);

Map<String, Object> titleKeysMap = ScriptEvaluator.evaluateMap(params.titleKeys, payload);
Map<String, Object> titleVersionMap = ScriptEvaluator.evaluateMap(params.titleVersion, payload);

ReferenceKey eventRefKeys = new ReferenceKey();
eventRefKeys.titleKeys = mapper.convertValue(titleKeysMap, TitleKeys.class);
eventRefKeys.titleVersion = mapper.convertValue(titleVersionMap, TitleVersion.class);
logger.debug("ReferenceKeysMatchAction: Task titleKeysMap " + titleKeysMap);

// Get the current logging context (owner)
String ndcValue = NDC.peek();

Expand All @@ -82,7 +82,7 @@ public List<String> handle(EventHandler.Action action, Object payload, EventExec
} else {
tasks = executor.getPendingSystemTasks(Wait.NAME);
}
logger.debug("ReferenceKeysMatchAction: List of tasks " + tasks);

boolean taskNamesDefined = CollectionUtils.isNotEmpty(params.taskRefNames);
tasks.parallelStream().forEach(task -> {
boolean ndcCleanup = false;
Expand All @@ -91,41 +91,39 @@ public List<String> handle(EventHandler.Action action, Object payload, EventExec
ndcCleanup = true;
NDC.push(ndcValue);
}
logger.debug("ReferenceKeysMatchAction: Check for referenceKeys");
if (!task.getInputData().containsKey("referenceKeys")) {
return;
}
logger.debug("ReferenceKeysMatchAction: Check for taskNamesDefined");

if (taskNamesDefined && !params.taskRefNames.contains(task.getReferenceTaskName())) {
return;
}
logger.debug("ReferenceKeysMatchAction: Check for Workflows");

Workflow workflow = executor.getWorkflow(task.getWorkflowInstanceId(), false);
if (workflow == null) {
logger.debug("ReferenceKeysMatchAction: No workflow found with id " + task.getWorkflowInstanceId() + ", skipping " + task);
logger.debug("No workflow found with id " + task.getWorkflowInstanceId() + ", skipping " + task);
return;
}
logger.debug("ReferenceKeysMatchAction: Check for isTeminal");

if (workflow.getStatus().isTerminal()) {
return;
}
logger.debug("ReferenceKeysMatchAction: Get taskReferenceKeys");
Object taskReferenceKeys = task.getInputData().get("referenceKeys");
if (taskReferenceKeys == null) {
return;
}
if (!(taskReferenceKeys instanceof List)) {
logger.warn("ReferenceKeysMatchAction: Task input referenceKeys is not a list for " + task);
logger.warn("Task input referenceKeys is not a list for " + task);
return;
}
List<ReferenceKey> taskRefKeys = mapper.convertValue(taskReferenceKeys, new TypeReference<List<ReferenceKey>>() {
});
logger.debug("ReferenceKeysMatchAction: Perform Array Match");

// Array match
if (!matches(taskRefKeys, eventRefKeys)) {
return;
}
logger.debug("ReferenceKeysMatchAction: Update Task Status " + taskStatus);

//Otherwise update the task as we found it
task.setStatus(taskStatus);
task.getOutputData().put("conductor.event.name", ee.getEvent());
Expand Down

0 comments on commit decd796

Please sign in to comment.