Reverted the enum for userTaskType for now

This commit is contained in:
Ram Narayan Balaji 2025-09-08 22:16:25 +05:30
parent 9f12597658
commit e75d1bf482
4 changed files with 14 additions and 50 deletions

View File

@ -47,7 +47,6 @@ import org.openmetadata.service.Entity;
import org.openmetadata.service.OpenMetadataApplicationConfig;
import org.openmetadata.service.clients.pipeline.PipelineServiceClientFactory;
import org.openmetadata.service.exception.UnhandledServerException;
import org.openmetadata.service.governance.workflows.elements.nodes.userTask.UserTaskType;
import org.openmetadata.service.governance.workflows.flowable.sql.SqlMapper;
import org.openmetadata.service.governance.workflows.flowable.sql.UnlockExecutionSql;
import org.openmetadata.service.governance.workflows.flowable.sql.UnlockJobSql;
@ -837,8 +836,12 @@ public class WorkflowHandler {
LOG.debug(
"Extracted subprocess ID: '{}' from task key '{}'", subProcessId, taskDefinitionKey);
// Get all possible termination message patterns from the enum
List<String> messagePatterns = UserTaskType.getAllTerminationPatterns(subProcessId);
// Try both possible termination message patterns
// UserApprovalTask uses: subProcessId_terminateProcess
// ChangeReviewTask uses: subProcessId_terminateChangeReviewProcess
String[] messagePatterns = {
subProcessId + "_terminateProcess", subProcessId + "_terminateChangeReviewProcess"
};
for (String messageName : messagePatterns) {
LOG.debug("Checking for message subscription: {}", messageName);

View File

@ -197,10 +197,10 @@ public class ChangeReviewTask implements NodeInterface {
}
private BoundaryEvent getTerminationEvent(String subProcessId) {
// Use the enum to get the termination message suffix for this task type
String uniqueMessageName =
getFlowableElementId(
subProcessId, UserTaskType.CHANGE_REVIEW_TASK.getTerminationMessageSuffix());
// Use a consistent format that matches what getFlowableElementId produces
// This ensures uniqueness per node within the workflow definition
// ChangeReviewTask uses terminateChangeReviewProcess to distinguish from UserApprovalTask
String uniqueMessageName = getFlowableElementId(subProcessId, "terminateChangeReviewProcess");
Message terminationMessage = new Message();
terminationMessage.setId(uniqueMessageName);

View File

@ -195,10 +195,10 @@ public class UserApprovalTask implements NodeInterface {
}
private BoundaryEvent getTerminationEvent(String subProcessId) {
// Use the enum to get the termination message suffix for this task type
String uniqueMessageName =
getFlowableElementId(
subProcessId, UserTaskType.USER_APPROVAL_TASK.getTerminationMessageSuffix());
// Use a consistent format that matches what getFlowableElementId produces
// This ensures uniqueness per node within the workflow definition
// Format: subProcessId.terminateProcess (where subProcessId is the node name)
String uniqueMessageName = getFlowableElementId(subProcessId, "terminateProcess");
Message terminationMessage = new Message();
terminationMessage.setId(uniqueMessageName);

View File

@ -1,39 +0,0 @@
package org.openmetadata.service.governance.workflows.elements.nodes.userTask;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public enum UserTaskType {
USER_APPROVAL_TASK("terminateProcess"),
CHANGE_REVIEW_TASK("terminateChangeReviewProcess");
private final String terminationMessageSuffix;
UserTaskType(String terminationMessageSuffix) {
this.terminationMessageSuffix = terminationMessageSuffix;
}
public String getTerminationMessageSuffix() {
return terminationMessageSuffix;
}
public String getTerminationMessageName(String subProcessId) {
return subProcessId + "_" + terminationMessageSuffix;
}
public static List<String> getAllTerminationPatterns(String subProcessId) {
return Arrays.stream(values())
.map(type -> type.getTerminationMessageName(subProcessId))
.collect(Collectors.toList());
}
public static String findTerminationPattern(String messageName) {
for (UserTaskType type : values()) {
if (messageName.endsWith("_" + type.getTerminationMessageSuffix())) {
return type.getTerminationMessageSuffix();
}
}
return null;
}
}