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