|
|
@ -29,6 +29,7 @@ import org.apache.dolphinscheduler.dao.entity.Alert; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessAlertContent; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessAlertContent; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessInstance; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProjectUser; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskInstance; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
@ -94,12 +95,16 @@ public class AlertManager { |
|
|
|
* @return process instance format content |
|
|
|
* @return process instance format content |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public String getContentProcessInstance(ProcessInstance processInstance, |
|
|
|
public String getContentProcessInstance(ProcessInstance processInstance, |
|
|
|
List<TaskInstance> taskInstances) { |
|
|
|
List<TaskInstance> taskInstances, |
|
|
|
|
|
|
|
ProjectUser projectUser) { |
|
|
|
|
|
|
|
|
|
|
|
String res = ""; |
|
|
|
String res = ""; |
|
|
|
if (processInstance.getState().typeIsSuccess()) { |
|
|
|
if (processInstance.getState().typeIsSuccess()) { |
|
|
|
List<ProcessAlertContent> successTaskList = new ArrayList<>(1); |
|
|
|
List<ProcessAlertContent> successTaskList = new ArrayList<>(1); |
|
|
|
ProcessAlertContent processAlertContent = ProcessAlertContent.newBuilder() |
|
|
|
ProcessAlertContent processAlertContent = ProcessAlertContent.newBuilder() |
|
|
|
|
|
|
|
.projectId(projectUser.getProjectId()) |
|
|
|
|
|
|
|
.projectName(projectUser.getProjectName()) |
|
|
|
|
|
|
|
.owner(projectUser.getUserName()) |
|
|
|
.processId(processInstance.getId()) |
|
|
|
.processId(processInstance.getId()) |
|
|
|
.processName(processInstance.getName()) |
|
|
|
.processName(processInstance.getName()) |
|
|
|
.processType(processInstance.getCommandType()) |
|
|
|
.processType(processInstance.getCommandType()) |
|
|
@ -120,6 +125,9 @@ public class AlertManager { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
ProcessAlertContent processAlertContent = ProcessAlertContent.newBuilder() |
|
|
|
ProcessAlertContent processAlertContent = ProcessAlertContent.newBuilder() |
|
|
|
|
|
|
|
.projectId(projectUser.getProjectId()) |
|
|
|
|
|
|
|
.projectName(projectUser.getProjectName()) |
|
|
|
|
|
|
|
.owner(projectUser.getUserName()) |
|
|
|
.processId(processInstance.getId()) |
|
|
|
.processId(processInstance.getId()) |
|
|
|
.processName(processInstance.getName()) |
|
|
|
.processName(processInstance.getName()) |
|
|
|
.taskId(task.getId()) |
|
|
|
.taskId(task.getId()) |
|
|
@ -196,7 +204,8 @@ public class AlertManager { |
|
|
|
* @param taskInstances task instance list |
|
|
|
* @param taskInstances task instance list |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void sendAlertProcessInstance(ProcessInstance processInstance, |
|
|
|
public void sendAlertProcessInstance(ProcessInstance processInstance, |
|
|
|
List<TaskInstance> taskInstances) { |
|
|
|
List<TaskInstance> taskInstances, |
|
|
|
|
|
|
|
ProjectUser projectUser) { |
|
|
|
|
|
|
|
|
|
|
|
if (Flag.YES == processInstance.getIsSubProcess()) { |
|
|
|
if (Flag.YES == processInstance.getIsSubProcess()) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -231,7 +240,7 @@ public class AlertManager { |
|
|
|
alert.setTitle(cmdName + " " + success); |
|
|
|
alert.setTitle(cmdName + " " + success); |
|
|
|
ShowType showType = processInstance.getState().typeIsSuccess() ? ShowType.TEXT : ShowType.TABLE; |
|
|
|
ShowType showType = processInstance.getState().typeIsSuccess() ? ShowType.TEXT : ShowType.TABLE; |
|
|
|
alert.setShowType(showType); |
|
|
|
alert.setShowType(showType); |
|
|
|
String content = getContentProcessInstance(processInstance, taskInstances); |
|
|
|
String content = getContentProcessInstance(processInstance, taskInstances, projectUser); |
|
|
|
alert.setContent(content); |
|
|
|
alert.setContent(content); |
|
|
|
alert.setAlertType(AlertType.EMAIL); |
|
|
|
alert.setAlertType(AlertType.EMAIL); |
|
|
|
alert.setAlertGroupId(processInstance.getWarningGroupId()); |
|
|
|
alert.setAlertGroupId(processInstance.getWarningGroupId()); |
|
|
|