@ -17,28 +17,14 @@
package org.apache.dolphinscheduler.api.service.impl ;
package org.apache.dolphinscheduler.api.service.impl ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.TASK_DEFINITION_MOVE ;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.VERSION_DELETE ;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.VERSION_LIST ;
import com.fasterxml.jackson.databind.JsonNode ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_BATCH_COPY ;
import com.fasterxml.jackson.databind.node.ArrayNode ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_CREATE ;
import com.fasterxml.jackson.databind.node.ObjectNode ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_DEFINITION ;
import com.google.common.collect.Lists ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_DEFINITION_DELETE ;
import org.apache.commons.collections4.CollectionUtils ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_DEFINITION_EXPORT ;
import org.apache.commons.lang3.StringUtils ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_EXPORT ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_IMPORT ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_ONLINE_OFFLINE ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_SWITCH_TO_THIS_VERSION ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_TREE_VIEW ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_UPDATE ;
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS_DEFINE_CODE ;
import static org.apache.dolphinscheduler.common.Constants.COPY_SUFFIX ;
import static org.apache.dolphinscheduler.common.Constants.DEFAULT_WORKER_GROUP ;
import static org.apache.dolphinscheduler.common.Constants.EMPTY_STRING ;
import static org.apache.dolphinscheduler.common.Constants.IMPORT_SUFFIX ;
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.COMPLEX_TASK_TYPES ;
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_SQL ;
import org.apache.dolphinscheduler.api.dto.DagDataSchedule ;
import org.apache.dolphinscheduler.api.dto.DagDataSchedule ;
import org.apache.dolphinscheduler.api.dto.ScheduleParam ;
import org.apache.dolphinscheduler.api.dto.ScheduleParam ;
import org.apache.dolphinscheduler.api.dto.treeview.Instance ;
import org.apache.dolphinscheduler.api.dto.treeview.Instance ;
@ -65,9 +51,9 @@ import org.apache.dolphinscheduler.common.enums.TimeoutFlag;
import org.apache.dolphinscheduler.common.enums.UserType ;
import org.apache.dolphinscheduler.common.enums.UserType ;
import org.apache.dolphinscheduler.common.enums.WarningType ;
import org.apache.dolphinscheduler.common.enums.WarningType ;
import org.apache.dolphinscheduler.common.graph.DAG ;
import org.apache.dolphinscheduler.common.graph.DAG ;
import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager ;
import org.apache.dolphinscheduler.common.model.TaskNode ;
import org.apache.dolphinscheduler.common.model.TaskNode ;
import org.apache.dolphinscheduler.common.model.TaskNodeRelation ;
import org.apache.dolphinscheduler.common.model.TaskNodeRelation ;
import org.apache.dolphinscheduler.common.thread.Stopper ;
import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils ;
import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils ;
import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils.CodeGenerateException ;
import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils.CodeGenerateException ;
import org.apache.dolphinscheduler.common.utils.DateUtils ;
import org.apache.dolphinscheduler.common.utils.DateUtils ;
@ -106,10 +92,16 @@ import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode;
import org.apache.dolphinscheduler.plugin.task.api.parameters.SqlParameters ;
import org.apache.dolphinscheduler.plugin.task.api.parameters.SqlParameters ;
import org.apache.dolphinscheduler.service.process.ProcessService ;
import org.apache.dolphinscheduler.service.process.ProcessService ;
import org.apache.dolphinscheduler.service.task.TaskPluginManager ;
import org.apache.dolphinscheduler.service.task.TaskPluginManager ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.http.MediaType ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import org.springframework.web.multipart.MultipartFile ;
import org.apache.commons.collections4.CollectionUtils ;
import javax.servlet.ServletOutputStream ;
import org.apache.commons.lang3.StringUtils ;
import javax.servlet.http.HttpServletResponse ;
import java.io.BufferedOutputStream ;
import java.io.BufferedOutputStream ;
import java.io.BufferedReader ;
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.IOException ;
@ -133,23 +125,27 @@ import java.util.stream.Collectors;
import java.util.zip.ZipEntry ;
import java.util.zip.ZipEntry ;
import java.util.zip.ZipInputStream ;
import java.util.zip.ZipInputStream ;
import javax.servlet.ServletOutputStream ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.TASK_DEFINITION_MOVE ;
import javax.servlet.http.HttpServletResponse ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.VERSION_DELETE ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.VERSION_LIST ;
import org.slf4j.Logger ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_BATCH_COPY ;
import org.slf4j.LoggerFactory ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_CREATE ;
import org.springframework.beans.factory.annotation.Autowired ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_DEFINITION ;
import org.springframework.http.MediaType ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_DEFINITION_DELETE ;
import org.springframework.stereotype.Service ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_DEFINITION_EXPORT ;
import org.springframework.transaction.annotation.Transactional ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_EXPORT ;
import org.springframework.web.multipart.MultipartFile ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_IMPORT ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_ONLINE_OFFLINE ;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_SWITCH_TO_THIS_VERSION ;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_TREE_VIEW ;
import com.fasterxml.jackson.databind.JsonNode ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_UPDATE ;
import com.fasterxml.jackson.databind.node.ArrayNode ;
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS_DEFINE_CODE ;
import com.fasterxml.jackson.databind.node.ObjectNode ;
import static org.apache.dolphinscheduler.common.Constants.COPY_SUFFIX ;
import com.google.common.collect.Lists ;
import static org.apache.dolphinscheduler.common.Constants.DEFAULT_WORKER_GROUP ;
import static org.apache.dolphinscheduler.common.Constants.EMPTY_STRING ;
import static org.apache.dolphinscheduler.common.Constants.IMPORT_SUFFIX ;
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.COMPLEX_TASK_TYPES ;
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_SQL ;
/ * *
/ * *
* process definition service impl
* process definition service impl
@ -246,7 +242,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
ProcessExecutionTypeEnum executionType ) {
ProcessExecutionTypeEnum executionType ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_CREATE ) ;
Map < String , Object > result =
projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_CREATE ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
@ -265,8 +262,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
if ( checkTaskDefinitions . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( checkTaskDefinitions . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return checkTaskDefinitions ;
return checkTaskDefinitions ;
}
}
List < ProcessTaskRelationLog > taskRelationList = JSONUtils . toList ( taskRelationJson , ProcessTaskRelationLog . class ) ;
List < ProcessTaskRelationLog > taskRelationList =
Map < String , Object > checkRelationJson = checkTaskRelationList ( taskRelationList , taskRelationJson , taskDefinitionLogs ) ;
JSONUtils . toList ( taskRelationJson , ProcessTaskRelationLog . class ) ;
Map < String , Object > checkRelationJson =
checkTaskRelationList ( taskRelationList , taskRelationJson , taskDefinitionLogs ) ;
if ( checkRelationJson . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( checkRelationJson . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return checkRelationJson ;
return checkRelationJson ;
}
}
@ -286,7 +285,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
putMsg ( result , Status . INTERNAL_SERVER_ERROR_ARGS ) ;
putMsg ( result , Status . INTERNAL_SERVER_ERROR_ARGS ) ;
return result ;
return result ;
}
}
ProcessDefinition processDefinition = new ProcessDefinition ( projectCode , name , processDefinitionCode , description ,
ProcessDefinition processDefinition =
new ProcessDefinition ( projectCode , name , processDefinitionCode , description ,
globalParams , locations , timeout , loginUser . getId ( ) , tenantId ) ;
globalParams , locations , timeout , loginUser . getId ( ) , tenantId ) ;
processDefinition . setExecutionType ( executionType ) ;
processDefinition . setExecutionType ( executionType ) ;
@ -298,7 +298,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
ProcessDefinition processDefinition ,
ProcessDefinition processDefinition ,
List < TaskDefinitionLog > taskDefinitionLogs , String otherParamsJson ) {
List < TaskDefinitionLog > taskDefinitionLogs , String otherParamsJson ) {
Map < String , Object > result = new HashMap < > ( ) ;
Map < String , Object > result = new HashMap < > ( ) ;
int saveTaskResult = processService . saveTaskDefine ( loginUser , processDefinition . getProjectCode ( ) , taskDefinitionLogs , Boolean . TRUE ) ;
int saveTaskResult = processService . saveTaskDefine ( loginUser , processDefinition . getProjectCode ( ) ,
taskDefinitionLogs , Boolean . TRUE ) ;
if ( saveTaskResult = = Constants . EXIT_CODE_SUCCESS ) {
if ( saveTaskResult = = Constants . EXIT_CODE_SUCCESS ) {
logger . info ( "The task has not changed, so skip" ) ;
logger . info ( "The task has not changed, so skip" ) ;
}
}
@ -311,7 +312,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
putMsg ( result , Status . CREATE_PROCESS_DEFINITION_ERROR ) ;
putMsg ( result , Status . CREATE_PROCESS_DEFINITION_ERROR ) ;
throw new ServiceException ( Status . CREATE_PROCESS_DEFINITION_ERROR ) ;
throw new ServiceException ( Status . CREATE_PROCESS_DEFINITION_ERROR ) ;
}
}
int insertResult = processService . saveTaskRelation ( loginUser , processDefinition . getProjectCode ( ) , processDefinition . getCode ( ) ,
int insertResult = processService . saveTaskRelation ( loginUser , processDefinition . getProjectCode ( ) ,
processDefinition . getCode ( ) ,
insertVersion , taskRelationList , taskDefinitionLogs , Boolean . TRUE ) ;
insertVersion , taskRelationList , taskDefinitionLogs , Boolean . TRUE ) ;
if ( insertResult = = Constants . EXIT_CODE_SUCCESS ) {
if ( insertResult = = Constants . EXIT_CODE_SUCCESS ) {
putMsg ( result , Status . SUCCESS ) ;
putMsg ( result , Status . SUCCESS ) ;
@ -324,7 +326,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
return result ;
return result ;
}
}
private Map < String , Object > checkTaskDefinitionList ( List < TaskDefinitionLog > taskDefinitionLogs , String taskDefinitionJson ) {
private Map < String , Object > checkTaskDefinitionList ( List < TaskDefinitionLog > taskDefinitionLogs ,
String taskDefinitionJson ) {
Map < String , Object > result = new HashMap < > ( ) ;
Map < String , Object > result = new HashMap < > ( ) ;
try {
try {
if ( taskDefinitionLogs . isEmpty ( ) ) {
if ( taskDefinitionLogs . isEmpty ( ) ) {
@ -352,7 +355,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
return result ;
return result ;
}
}
private Map < String , Object > checkTaskRelationList ( List < ProcessTaskRelationLog > taskRelationList , String taskRelationJson , List < TaskDefinitionLog > taskDefinitionLogs ) {
private Map < String , Object > checkTaskRelationList ( List < ProcessTaskRelationLog > taskRelationList ,
String taskRelationJson ,
List < TaskDefinitionLog > taskDefinitionLogs ) {
Map < String , Object > result = new HashMap < > ( ) ;
Map < String , Object > result = new HashMap < > ( ) ;
try {
try {
if ( taskRelationList = = null | | taskRelationList . isEmpty ( ) ) {
if ( taskRelationList = = null | | taskRelationList . isEmpty ( ) ) {
@ -361,16 +366,19 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
return result ;
return result ;
}
}
List < ProcessTaskRelation > processTaskRelations = taskRelationList . stream ( )
List < ProcessTaskRelation > processTaskRelations = taskRelationList . stream ( )
. map ( processTaskRelationLog - > JSONUtils . parseObject ( JSONUtils . toJsonString ( processTaskRelationLog ) , ProcessTaskRelation . class ) )
. map ( processTaskRelationLog - > JSONUtils . parseObject ( JSONUtils . toJsonString ( processTaskRelationLog ) ,
ProcessTaskRelation . class ) )
. collect ( Collectors . toList ( ) ) ;
. collect ( Collectors . toList ( ) ) ;
List < TaskNode > taskNodeList = processService . transformTask ( processTaskRelations , taskDefinitionLogs ) ;
List < TaskNode > taskNodeList = processService . transformTask ( processTaskRelations , taskDefinitionLogs ) ;
if ( taskNodeList . size ( ) ! = taskRelationList . size ( ) ) {
if ( taskNodeList . size ( ) ! = taskRelationList . size ( ) ) {
Set < Long > postTaskCodes = taskRelationList . stream ( ) . map ( ProcessTaskRelationLog : : getPostTaskCode ) . collect ( Collectors . toSet ( ) ) ;
Set < Long > postTaskCodes = taskRelationList . stream ( ) . map ( ProcessTaskRelationLog : : getPostTaskCode )
. collect ( Collectors . toSet ( ) ) ;
Set < Long > taskNodeCodes = taskNodeList . stream ( ) . map ( TaskNode : : getCode ) . collect ( Collectors . toSet ( ) ) ;
Set < Long > taskNodeCodes = taskNodeList . stream ( ) . map ( TaskNode : : getCode ) . collect ( Collectors . toSet ( ) ) ;
Collection < Long > codes = CollectionUtils . subtract ( postTaskCodes , taskNodeCodes ) ;
Collection < Long > codes = CollectionUtils . subtract ( postTaskCodes , taskNodeCodes ) ;
if ( CollectionUtils . isNotEmpty ( codes ) ) {
if ( CollectionUtils . isNotEmpty ( codes ) ) {
logger . error ( "the task code is not exist" ) ;
logger . error ( "the task code is not exist" ) ;
putMsg ( result , Status . TASK_DEFINE_NOT_EXIST , org . apache . commons . lang . StringUtils . join ( codes , Constants . COMMA ) ) ;
putMsg ( result , Status . TASK_DEFINE_NOT_EXIST ,
org . apache . commons . lang . StringUtils . join ( codes , Constants . COMMA ) ) ;
return result ;
return result ;
}
}
}
}
@ -407,7 +415,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
public Map < String , Object > queryProcessDefinitionList ( User loginUser , long projectCode ) {
public Map < String , Object > queryProcessDefinitionList ( User loginUser , long projectCode ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_DEFINITION ) ;
Map < String , Object > result =
projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_DEFINITION ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
@ -429,7 +438,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
public Map < String , Object > queryProcessDefinitionSimpleList ( User loginUser , long projectCode ) {
public Map < String , Object > queryProcessDefinitionSimpleList ( User loginUser , long projectCode ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_DEFINITION ) ;
Map < String , Object > result =
projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_DEFINITION ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
@ -460,11 +470,14 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @return process definition page
* @return process definition page
* /
* /
@Override
@Override
public Result queryProcessDefinitionListPaging ( User loginUser , long projectCode , String searchVal , String otherParamsJson , Integer userId , Integer pageNo , Integer pageSize ) {
public Result queryProcessDefinitionListPaging ( User loginUser , long projectCode , String searchVal ,
String otherParamsJson , Integer userId , Integer pageNo ,
Integer pageSize ) {
Result result = new Result ( ) ;
Result result = new Result ( ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > checkResult = projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_DEFINITION ) ;
Map < String , Object > checkResult =
projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_DEFINITION ) ;
Status resultStatus = ( Status ) checkResult . get ( Constants . STATUS ) ;
Status resultStatus = ( Status ) checkResult . get ( Constants . STATUS ) ;
if ( resultStatus ! = Status . SUCCESS ) {
if ( resultStatus ! = Status . SUCCESS ) {
putMsg ( result , resultStatus ) ;
putMsg ( result , resultStatus ) ;
@ -477,7 +490,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
List < ProcessDefinition > records = processDefinitionIPage . getRecords ( ) ;
List < ProcessDefinition > records = processDefinitionIPage . getRecords ( ) ;
for ( ProcessDefinition pd : records ) {
for ( ProcessDefinition pd : records ) {
ProcessDefinitionLog processDefinitionLog = processDefinitionLogMapper . queryByDefinitionCodeAndVersion ( pd . getCode ( ) , pd . getVersion ( ) ) ;
ProcessDefinitionLog processDefinitionLog =
processDefinitionLogMapper . queryByDefinitionCodeAndVersion ( pd . getCode ( ) , pd . getVersion ( ) ) ;
User user = userMapper . selectById ( processDefinitionLog . getOperator ( ) ) ;
User user = userMapper . selectById ( processDefinitionLog . getOperator ( ) ) ;
pd . setModifyBy ( user . getUserName ( ) ) ;
pd . setModifyBy ( user . getUserName ( ) ) ;
}
}
@ -503,7 +517,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
public Map < String , Object > queryProcessDefinitionByCode ( User loginUser , long projectCode , long code ) {
public Map < String , Object > queryProcessDefinitionByCode ( User loginUser , long projectCode , long code ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_DEFINITION ) ;
Map < String , Object > result =
projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_DEFINITION ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
@ -527,7 +542,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
public Map < String , Object > queryProcessDefinitionByName ( User loginUser , long projectCode , String name ) {
public Map < String , Object > queryProcessDefinitionByName ( User loginUser , long projectCode , String name ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_DEFINITION ) ;
Map < String , Object > result =
projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_DEFINITION ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
@ -577,7 +593,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
ProcessExecutionTypeEnum executionType ) {
ProcessExecutionTypeEnum executionType ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_UPDATE ) ;
Map < String , Object > result =
projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_UPDATE ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
@ -590,8 +607,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
if ( checkTaskDefinitions . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( checkTaskDefinitions . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return checkTaskDefinitions ;
return checkTaskDefinitions ;
}
}
List < ProcessTaskRelationLog > taskRelationList = JSONUtils . toList ( taskRelationJson , ProcessTaskRelationLog . class ) ;
List < ProcessTaskRelationLog > taskRelationList =
Map < String , Object > checkRelationJson = checkTaskRelationList ( taskRelationList , taskRelationJson , taskDefinitionLogs ) ;
JSONUtils . toList ( taskRelationJson , ProcessTaskRelationLog . class ) ;
Map < String , Object > checkRelationJson =
checkTaskRelationList ( taskRelationList , taskRelationJson , taskDefinitionLogs ) ;
if ( checkRelationJson . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( checkRelationJson . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return checkRelationJson ;
return checkRelationJson ;
}
}
@ -625,10 +644,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
return result ;
return result ;
}
}
}
}
ProcessDefinition processDefinitionDeepCopy = JSONUtils . parseObject ( JSONUtils . toJsonString ( processDefinition ) , ProcessDefinition . class ) ;
ProcessDefinition processDefinitionDeepCopy =
JSONUtils . parseObject ( JSONUtils . toJsonString ( processDefinition ) , ProcessDefinition . class ) ;
processDefinition . set ( projectCode , name , description , globalParams , locations , timeout , tenantId ) ;
processDefinition . set ( projectCode , name , description , globalParams , locations , timeout , tenantId ) ;
processDefinition . setExecutionType ( executionType ) ;
processDefinition . setExecutionType ( executionType ) ;
return updateDagDefine ( loginUser , taskRelationList , processDefinition , processDefinitionDeepCopy , taskDefinitionLogs , otherParamsJson ) ;
return updateDagDefine ( loginUser , taskRelationList , processDefinition , processDefinitionDeepCopy ,
taskDefinitionLogs , otherParamsJson ) ;
}
}
/ * *
/ * *
@ -639,15 +660,20 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @param processDefinition ProcessDefinition you change task definition and task relation
* @param processDefinition ProcessDefinition you change task definition and task relation
* @param taskRelationList All the latest task relation list from process definition
* @param taskRelationList All the latest task relation list from process definition
* /
* /
private void taskUsedInOtherTaskValid ( ProcessDefinition processDefinition , List < ProcessTaskRelationLog > taskRelationList ) {
private void taskUsedInOtherTaskValid ( ProcessDefinition processDefinition ,
List < ProcessTaskRelation > oldProcessTaskRelationList = processTaskRelationMapper . queryByProcessCode ( processDefinition . getProjectCode ( ) , processDefinition . getCode ( ) ) ;
List < ProcessTaskRelationLog > taskRelationList ) {
Set < ProcessTaskRelationLog > oldProcessTaskRelationSet = oldProcessTaskRelationList . stream ( ) . map ( ProcessTaskRelationLog : : new ) . collect ( Collectors . toSet ( ) ) ;
List < ProcessTaskRelation > oldProcessTaskRelationList = processTaskRelationMapper
. queryByProcessCode ( processDefinition . getProjectCode ( ) , processDefinition . getCode ( ) ) ;
Set < ProcessTaskRelationLog > oldProcessTaskRelationSet =
oldProcessTaskRelationList . stream ( ) . map ( ProcessTaskRelationLog : : new ) . collect ( Collectors . toSet ( ) ) ;
StringBuilder sb = new StringBuilder ( ) ;
StringBuilder sb = new StringBuilder ( ) ;
for ( ProcessTaskRelationLog oldProcessTaskRelation : oldProcessTaskRelationSet ) {
for ( ProcessTaskRelationLog oldProcessTaskRelation : oldProcessTaskRelationSet ) {
boolean oldTaskExists = taskRelationList . stream ( ) . anyMatch ( relation - > oldProcessTaskRelation . getPostTaskCode ( ) = = relation . getPostTaskCode ( ) ) ;
boolean oldTaskExists = taskRelationList . stream ( )
. anyMatch ( relation - > oldProcessTaskRelation . getPostTaskCode ( ) = = relation . getPostTaskCode ( ) ) ;
if ( ! oldTaskExists ) {
if ( ! oldTaskExists ) {
Optional < String > taskDepMsg = workFlowLineageService . taskDepOnTaskMsg (
Optional < String > taskDepMsg = workFlowLineageService . taskDepOnTaskMsg (
processDefinition . getProjectCode ( ) , oldProcessTaskRelation . getProcessDefinitionCode ( ) , oldProcessTaskRelation . getPostTaskCode ( ) ) ;
processDefinition . getProjectCode ( ) , oldProcessTaskRelation . getProcessDefinitionCode ( ) ,
oldProcessTaskRelation . getPostTaskCode ( ) ) ;
taskDepMsg . ifPresent ( sb : : append ) ;
taskDepMsg . ifPresent ( sb : : append ) ;
}
}
if ( sb . length ( ) ! = 0 ) {
if ( sb . length ( ) ! = 0 ) {
@ -663,7 +689,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
List < TaskDefinitionLog > taskDefinitionLogs ,
List < TaskDefinitionLog > taskDefinitionLogs ,
String otherParamsJson ) {
String otherParamsJson ) {
Map < String , Object > result = new HashMap < > ( ) ;
Map < String , Object > result = new HashMap < > ( ) ;
int saveTaskResult = processService . saveTaskDefine ( loginUser , processDefinition . getProjectCode ( ) , taskDefinitionLogs , Boolean . TRUE ) ;
int saveTaskResult = processService . saveTaskDefine ( loginUser , processDefinition . getProjectCode ( ) ,
taskDefinitionLogs , Boolean . TRUE ) ;
if ( saveTaskResult = = Constants . EXIT_CODE_SUCCESS ) {
if ( saveTaskResult = = Constants . EXIT_CODE_SUCCESS ) {
logger . info ( "The task has not changed, so skip" ) ;
logger . info ( "The task has not changed, so skip" ) ;
}
}
@ -673,10 +700,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
}
boolean isChange = false ;
boolean isChange = false ;
if ( processDefinition . equals ( processDefinitionDeepCopy ) & & saveTaskResult = = Constants . EXIT_CODE_SUCCESS ) {
if ( processDefinition . equals ( processDefinitionDeepCopy ) & & saveTaskResult = = Constants . EXIT_CODE_SUCCESS ) {
List < ProcessTaskRelationLog > processTaskRelationLogList = processTaskRelationLogMapper . queryByProcessCodeAndVersion ( processDefinition . getCode ( ) , processDefinition . getVersion ( ) ) ;
List < ProcessTaskRelationLog > processTaskRelationLogList = processTaskRelationLogMapper
. queryByProcessCodeAndVersion ( processDefinition . getCode ( ) , processDefinition . getVersion ( ) ) ;
if ( taskRelationList . size ( ) = = processTaskRelationLogList . size ( ) ) {
if ( taskRelationList . size ( ) = = processTaskRelationLogList . size ( ) ) {
Set < ProcessTaskRelationLog > taskRelationSet = taskRelationList . stream ( ) . collect ( Collectors . toSet ( ) ) ;
Set < ProcessTaskRelationLog > taskRelationSet = taskRelationList . stream ( ) . collect ( Collectors . toSet ( ) ) ;
Set < ProcessTaskRelationLog > processTaskRelationLogSet = processTaskRelationLogList . stream ( ) . collect ( Collectors . toSet ( ) ) ;
Set < ProcessTaskRelationLog > processTaskRelationLogSet =
processTaskRelationLogList . stream ( ) . collect ( Collectors . toSet ( ) ) ;
if ( taskRelationSet . size ( ) = = processTaskRelationLogSet . size ( ) ) {
if ( taskRelationSet . size ( ) = = processTaskRelationLogSet . size ( ) ) {
taskRelationSet . removeAll ( processTaskRelationLogSet ) ;
taskRelationSet . removeAll ( processTaskRelationLogSet ) ;
if ( ! taskRelationSet . isEmpty ( ) ) {
if ( ! taskRelationSet . isEmpty ( ) ) {
@ -693,7 +722,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
}
if ( isChange ) {
if ( isChange ) {
processDefinition . setUpdateTime ( new Date ( ) ) ;
processDefinition . setUpdateTime ( new Date ( ) ) ;
int insertVersion = processService . saveProcessDefine ( loginUser , processDefinition , Boolean . TRUE , Boolean . TRUE ) ;
int insertVersion =
processService . saveProcessDefine ( loginUser , processDefinition , Boolean . TRUE , Boolean . TRUE ) ;
if ( insertVersion < = 0 ) {
if ( insertVersion < = 0 ) {
putMsg ( result , Status . UPDATE_PROCESS_DEFINITION_ERROR ) ;
putMsg ( result , Status . UPDATE_PROCESS_DEFINITION_ERROR ) ;
throw new ServiceException ( Status . UPDATE_PROCESS_DEFINITION_ERROR ) ;
throw new ServiceException ( Status . UPDATE_PROCESS_DEFINITION_ERROR ) ;
@ -729,11 +759,13 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
public Map < String , Object > verifyProcessDefinitionName ( User loginUser , long projectCode , String name ) {
public Map < String , Object > verifyProcessDefinitionName ( User loginUser , long projectCode , String name ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_CREATE ) ;
Map < String , Object > result =
projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_CREATE ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
ProcessDefinition processDefinition = processDefinitionMapper . verifyByDefineName ( project . getCode ( ) , name . trim ( ) ) ;
ProcessDefinition processDefinition =
processDefinitionMapper . verifyByDefineName ( project . getCode ( ) , name . trim ( ) ) ;
if ( processDefinition = = null ) {
if ( processDefinition = = null ) {
putMsg ( result , Status . SUCCESS ) ;
putMsg ( result , Status . SUCCESS ) ;
} else {
} else {
@ -756,16 +788,19 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
}
// check process instances is already running
// check process instances is already running
List < ProcessInstance > processInstances = processInstanceService . queryByProcessDefineCodeAndStatus ( processDefinition . getCode ( ) , Constants . NOT_TERMINATED_STATES ) ;
List < ProcessInstance > processInstances = processInstanceService
. queryByProcessDefineCodeAndStatus ( processDefinition . getCode ( ) , Constants . NOT_TERMINATED_STATES ) ;
if ( CollectionUtils . isNotEmpty ( processInstances ) ) {
if ( CollectionUtils . isNotEmpty ( processInstances ) ) {
throw new ServiceException ( Status . DELETE_PROCESS_DEFINITION_EXECUTING_FAIL , processInstances . size ( ) ) ;
throw new ServiceException ( Status . DELETE_PROCESS_DEFINITION_EXECUTING_FAIL , processInstances . size ( ) ) ;
}
}
// check process used by other task, including subprocess and dependent task type
// check process used by other task, including subprocess and dependent task type
Set < TaskMainInfo > taskDepOnProcess = workFlowLineageService . queryTaskDepOnProcess ( processDefinition . getProjectCode ( ) , processDefinition . getCode ( ) ) ;
Set < TaskMainInfo > taskDepOnProcess = workFlowLineageService
. queryTaskDepOnProcess ( processDefinition . getProjectCode ( ) , processDefinition . getCode ( ) ) ;
if ( CollectionUtils . isNotEmpty ( taskDepOnProcess ) ) {
if ( CollectionUtils . isNotEmpty ( taskDepOnProcess ) ) {
String taskDepDetail = taskDepOnProcess . stream ( )
String taskDepDetail = taskDepOnProcess . stream ( )
. map ( task - > String . format ( Constants . FORMAT_S_S_COLON , task . getProcessDefinitionName ( ) , task . getTaskName ( ) ) )
. map ( task - > String . format ( Constants . FORMAT_S_S_COLON , task . getProcessDefinitionName ( ) ,
task . getTaskName ( ) ) )
. collect ( Collectors . joining ( Constants . COMMA ) ) ;
. collect ( Collectors . joining ( Constants . COMMA ) ) ;
throw new ServiceException ( Status . DELETE_PROCESS_DEFINITION_USE_BY_OTHER_FAIL , taskDepDetail ) ;
throw new ServiceException ( Status . DELETE_PROCESS_DEFINITION_USE_BY_OTHER_FAIL , taskDepDetail ) ;
}
}
@ -784,7 +819,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
public Map < String , Object > deleteProcessDefinitionByCode ( User loginUser , long projectCode , long code ) {
public Map < String , Object > deleteProcessDefinitionByCode ( User loginUser , long projectCode , long code ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_DEFINITION_DELETE ) ;
Map < String , Object > result =
projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_DEFINITION_DELETE ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
@ -842,10 +878,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* /
* /
@Override
@Override
@Transactional
@Transactional
public Map < String , Object > releaseProcessDefinition ( User loginUser , long projectCode , long code , ReleaseState releaseState ) {
public Map < String , Object > releaseProcessDefinition ( User loginUser , long projectCode , long code ,
ReleaseState releaseState ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_ONLINE_OFFLINE ) ;
Map < String , Object > result =
projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_ONLINE_OFFLINE ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
@ -863,7 +901,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
}
switch ( releaseState ) {
switch ( releaseState ) {
case ONLINE :
case ONLINE :
List < ProcessTaskRelation > relationList = processService . findRelationByCode ( code , processDefinition . getVersion ( ) ) ;
List < ProcessTaskRelation > relationList =
processService . findRelationByCode ( code , processDefinition . getVersion ( ) ) ;
if ( CollectionUtils . isEmpty ( relationList ) ) {
if ( CollectionUtils . isEmpty ( relationList ) ) {
putMsg ( result , Status . PROCESS_DAG_IS_EMPTY ) ;
putMsg ( result , Status . PROCESS_DAG_IS_EMPTY ) ;
return result ;
return result ;
@ -876,7 +915,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
int updateProcess = processDefinitionMapper . updateById ( processDefinition ) ;
int updateProcess = processDefinitionMapper . updateById ( processDefinition ) ;
Schedule schedule = scheduleMapper . queryByProcessDefinitionCode ( code ) ;
Schedule schedule = scheduleMapper . queryByProcessDefinitionCode ( code ) ;
if ( updateProcess > 0 & & schedule ! = null ) {
if ( updateProcess > 0 & & schedule ! = null ) {
logger . info ( "set schedule offline, project code: {}, schedule id: {}, process definition code: {}" , projectCode , schedule . getId ( ) , code ) ;
logger . info ( "set schedule offline, project code: {}, schedule id: {}, process definition code: {}" ,
projectCode , schedule . getId ( ) , code ) ;
// set status
// set status
schedule . setReleaseState ( releaseState ) ;
schedule . setReleaseState ( releaseState ) ;
int updateSchedule = scheduleMapper . updateById ( schedule ) ;
int updateSchedule = scheduleMapper . updateById ( schedule ) ;
@ -900,24 +940,29 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* batch export process definition by codes
* batch export process definition by codes
* /
* /
@Override
@Override
public void batchExportProcessDefinitionByCodes ( User loginUser , long projectCode , String codes , HttpServletResponse response ) {
public void batchExportProcessDefinitionByCodes ( User loginUser , long projectCode , String codes ,
HttpServletResponse response ) {
if ( org . apache . commons . lang . StringUtils . isEmpty ( codes ) ) {
if ( org . apache . commons . lang . StringUtils . isEmpty ( codes ) ) {
return ;
return ;
}
}
Project project = projectMapper . queryByCode ( projectCode ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_DEFINITION_EXPORT ) ;
Map < String , Object > result =
projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_DEFINITION_EXPORT ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return ;
return ;
}
}
Set < Long > defineCodeSet = Lists . newArrayList ( codes . split ( Constants . COMMA ) ) . stream ( ) . map ( Long : : parseLong ) . collect ( Collectors . toSet ( ) ) ;
Set < Long > defineCodeSet = Lists . newArrayList ( codes . split ( Constants . COMMA ) ) . stream ( ) . map ( Long : : parseLong )
. collect ( Collectors . toSet ( ) ) ;
List < ProcessDefinition > processDefinitionList = processDefinitionMapper . queryByCodes ( defineCodeSet ) ;
List < ProcessDefinition > processDefinitionList = processDefinitionMapper . queryByCodes ( defineCodeSet ) ;
if ( CollectionUtils . isEmpty ( processDefinitionList ) ) {
if ( CollectionUtils . isEmpty ( processDefinitionList ) ) {
return ;
return ;
}
}
// check processDefinition exist in project
// check processDefinition exist in project
List < ProcessDefinition > processDefinitionListInProject = processDefinitionList . stream ( ) . filter ( o - > projectCode = = o . getProjectCode ( ) ) . collect ( Collectors . toList ( ) ) ;
List < ProcessDefinition > processDefinitionListInProject = processDefinitionList . stream ( )
List < DagDataSchedule > dagDataSchedules = processDefinitionListInProject . stream ( ) . map ( this : : exportProcessDagData ) . collect ( Collectors . toList ( ) ) ;
. filter ( o - > projectCode = = o . getProjectCode ( ) ) . collect ( Collectors . toList ( ) ) ;
List < DagDataSchedule > dagDataSchedules =
processDefinitionListInProject . stream ( ) . map ( this : : exportProcessDagData ) . collect ( Collectors . toList ( ) ) ;
if ( CollectionUtils . isNotEmpty ( dagDataSchedules ) ) {
if ( CollectionUtils . isNotEmpty ( dagDataSchedules ) ) {
downloadProcessDefinitionFile ( response , dagDataSchedules ) ;
downloadProcessDefinitionFile ( response , dagDataSchedules ) ;
}
}
@ -1034,7 +1079,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
Map < String , DataSource > dataSourceCache = new HashMap < > ( 1 ) ;
Map < String , DataSource > dataSourceCache = new HashMap < > ( 1 ) ;
Map < String , Long > taskNameToCode = new HashMap < > ( 16 ) ;
Map < String , Long > taskNameToCode = new HashMap < > ( 16 ) ;
Map < String , List < String > > taskNameToUpstream = new HashMap < > ( 16 ) ;
Map < String , List < String > > taskNameToUpstream = new HashMap < > ( 16 ) ;
try ( ZipInputStream zIn = new ZipInputStream ( file . getInputStream ( ) ) ;
try (
ZipInputStream zIn = new ZipInputStream ( file . getInputStream ( ) ) ;
BufferedReader bufferedReader = new BufferedReader ( new InputStreamReader ( zIn ) ) ) {
BufferedReader bufferedReader = new BufferedReader ( new InputStreamReader ( zIn ) ) ) {
// build process definition
// build process definition
processDefinition = new ProcessDefinition ( projectCode ,
processDefinition = new ProcessDefinition ( projectCode ,
@ -1060,7 +1106,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
totalSizeArchive + = nBytes ;
totalSizeArchive + = nBytes ;
long compressionRatio = totalSizeEntry / entry . getCompressedSize ( ) ;
long compressionRatio = totalSizeEntry / entry . getCompressedSize ( ) ;
if ( compressionRatio > THRESHOLD_RATIO ) {
if ( compressionRatio > THRESHOLD_RATIO ) {
throw new IllegalStateException ( "ratio between compressed and uncompressed data is highly suspicious, looks like a Zip Bomb Attack" ) ;
throw new IllegalStateException (
"ratio between compressed and uncompressed data is highly suspicious, looks like a Zip Bomb Attack" ) ;
}
}
int commentIndex = line . indexOf ( "-- " ) ;
int commentIndex = line . indexOf ( "-- " ) ;
if ( commentIndex > = 0 ) {
if ( commentIndex > = 0 ) {
@ -1113,7 +1160,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
}
dataSourceCache . put ( datasourceName , dataSource ) ;
dataSourceCache . put ( datasourceName , dataSource ) ;
TaskDefinitionLog taskDefinition = buildNormalSqlTaskDefinition ( taskName , dataSource , sql . substring ( 0 , sql . length ( ) - 1 ) ) ;
TaskDefinitionLog taskDefinition =
buildNormalSqlTaskDefinition ( taskName , dataSource , sql . substring ( 0 , sql . length ( ) - 1 ) ) ;
taskDefinitionList . add ( taskDefinition ) ;
taskDefinitionList . add ( taskDefinition ) ;
taskNameToCode . put ( taskDefinition . getName ( ) , taskDefinition . getCode ( ) ) ;
taskNameToCode . put ( taskDefinition . getName ( ) , taskDefinition . getCode ( ) ) ;
@ -1121,11 +1169,13 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
}
if ( totalSizeArchive > THRESHOLD_SIZE ) {
if ( totalSizeArchive > THRESHOLD_SIZE ) {
throw new IllegalStateException ( "the uncompressed data size is too much for the application resource capacity" ) ;
throw new IllegalStateException (
"the uncompressed data size is too much for the application resource capacity" ) ;
}
}
if ( totalEntryArchive > THRESHOLD_ENTRIES ) {
if ( totalEntryArchive > THRESHOLD_ENTRIES ) {
throw new IllegalStateException ( "too much entries in this archive, can lead to inodes exhaustion of the system" ) ;
throw new IllegalStateException (
"too much entries in this archive, can lead to inodes exhaustion of the system" ) ;
}
}
}
}
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -1144,7 +1194,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
continue ;
continue ;
}
}
for ( String upstream : upstreams ) {
for ( String upstream : upstreams ) {
ProcessTaskRelationLog processTaskRelation = buildNormalTaskRelation ( taskNameToCode . get ( upstream ) , entry . getValue ( ) ) ;
ProcessTaskRelationLog processTaskRelation =
buildNormalTaskRelation ( taskNameToCode . get ( upstream ) , entry . getValue ( ) ) ;
processTaskRelationList . add ( processTaskRelation ) ;
processTaskRelationList . add ( processTaskRelation ) ;
}
}
}
}
@ -1175,7 +1226,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
return null ;
return null ;
}
}
private TaskDefinitionLog buildNormalSqlTaskDefinition ( String taskName , DataSource dataSource , String sql ) throws CodeGenerateException {
private TaskDefinitionLog buildNormalSqlTaskDefinition ( String taskName , DataSource dataSource ,
String sql ) throws CodeGenerateException {
TaskDefinitionLog taskDefinition = new TaskDefinitionLog ( ) ;
TaskDefinitionLog taskDefinition = new TaskDefinitionLog ( ) ;
taskDefinition . setName ( taskName ) ;
taskDefinition . setName ( taskName ) ;
taskDefinition . setFlag ( Flag . YES ) ;
taskDefinition . setFlag ( Flag . YES ) ;
@ -1206,7 +1258,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
/ * *
/ * *
* check and import
* check and import
* /
* /
protected boolean checkAndImport ( User loginUser , long projectCode , Map < String , Object > result , DagDataSchedule dagDataSchedule , String otherParamsJson ) {
protected boolean checkAndImport ( User loginUser , long projectCode , Map < String , Object > result ,
DagDataSchedule dagDataSchedule , String otherParamsJson ) {
if ( ! checkImportanceParams ( dagDataSchedule , result ) ) {
if ( ! checkImportanceParams ( dagDataSchedule , result ) ) {
return false ;
return false ;
}
}
@ -1216,7 +1269,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
String processDefinitionName = recursionProcessDefinitionName ( projectCode , processDefinition . getName ( ) , 1 ) ;
String processDefinitionName = recursionProcessDefinitionName ( projectCode , processDefinition . getName ( ) , 1 ) ;
String importProcessDefinitionName = getNewName ( processDefinitionName , IMPORT_SUFFIX ) ;
String importProcessDefinitionName = getNewName ( processDefinitionName , IMPORT_SUFFIX ) ;
// unique check
// unique check
Map < String , Object > checkResult = verifyProcessDefinitionName ( loginUser , projectCode , importProcessDefinitionName ) ;
Map < String , Object > checkResult =
verifyProcessDefinitionName ( loginUser , projectCode , importProcessDefinitionName ) ;
if ( Status . SUCCESS . equals ( checkResult . get ( Constants . STATUS ) ) ) {
if ( Status . SUCCESS . equals ( checkResult . get ( Constants . STATUS ) ) ) {
putMsg ( result , Status . SUCCESS ) ;
putMsg ( result , Status . SUCCESS ) ;
} else {
} else {
@ -1279,7 +1333,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
processTaskRelationLog . setPostTaskVersion ( Constants . VERSION_FIRST ) ;
processTaskRelationLog . setPostTaskVersion ( Constants . VERSION_FIRST ) ;
taskRelationLogList . add ( processTaskRelationLog ) ;
taskRelationLogList . add ( processTaskRelationLog ) ;
}
}
if ( StringUtils . isNotEmpty ( processDefinition . getLocations ( ) ) & & JSONUtils . checkJsonValid ( processDefinition . getLocations ( ) ) ) {
if ( StringUtils . isNotEmpty ( processDefinition . getLocations ( ) )
& & JSONUtils . checkJsonValid ( processDefinition . getLocations ( ) ) ) {
ArrayNode arrayNode = JSONUtils . parseArray ( processDefinition . getLocations ( ) ) ;
ArrayNode arrayNode = JSONUtils . parseArray ( processDefinition . getLocations ( ) ) ;
ArrayNode newArrayNode = JSONUtils . createArrayNode ( ) ;
ArrayNode newArrayNode = JSONUtils . createArrayNode ( ) ;
for ( int i = 0 ; i < arrayNode . size ( ) ; i + + ) {
for ( int i = 0 ; i < arrayNode . size ( ) ; i + + ) {
@ -1296,7 +1351,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
}
processDefinition . setCreateTime ( new Date ( ) ) ;
processDefinition . setCreateTime ( new Date ( ) ) ;
processDefinition . setUpdateTime ( new Date ( ) ) ;
processDefinition . setUpdateTime ( new Date ( ) ) ;
Map < String , Object > createDagResult = createDagDefine ( loginUser , taskRelationLogList , processDefinition , Lists . newArrayList ( ) , otherParamsJson ) ;
Map < String , Object > createDagResult = createDagDefine ( loginUser , taskRelationLogList , processDefinition ,
Lists . newArrayList ( ) , otherParamsJson ) ;
if ( Status . SUCCESS . equals ( createDagResult . get ( Constants . STATUS ) ) ) {
if ( Status . SUCCESS . equals ( createDagResult . get ( Constants . STATUS ) ) ) {
putMsg ( createDagResult , Status . SUCCESS ) ;
putMsg ( createDagResult , Status . SUCCESS ) ;
} else {
} else {
@ -1340,7 +1396,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
}
private String recursionProcessDefinitionName ( long projectCode , String processDefinitionName , int num ) {
private String recursionProcessDefinitionName ( long projectCode , String processDefinitionName , int num ) {
ProcessDefinition processDefinition = processDefinitionMapper . queryByDefineName ( projectCode , processDefinitionName ) ;
ProcessDefinition processDefinition =
processDefinitionMapper . queryByDefineName ( projectCode , processDefinitionName ) ;
if ( processDefinition ! = null ) {
if ( processDefinition ! = null ) {
if ( num > 1 ) {
if ( num > 1 ) {
String str = processDefinitionName . substring ( 0 , processDefinitionName . length ( ) - 3 ) ;
String str = processDefinitionName . substring ( 0 , processDefinitionName . length ( ) - 3 ) ;
@ -1361,7 +1418,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @return check result code
* @return check result code
* /
* /
@Override
@Override
public Map < String , Object > checkProcessNodeList ( String processTaskRelationJson , List < TaskDefinitionLog > taskDefinitionLogsList ) {
public Map < String , Object > checkProcessNodeList ( String processTaskRelationJson ,
List < TaskDefinitionLog > taskDefinitionLogsList ) {
Map < String , Object > result = new HashMap < > ( ) ;
Map < String , Object > result = new HashMap < > ( ) ;
try {
try {
if ( processTaskRelationJson = = null ) {
if ( processTaskRelationJson = = null ) {
@ -1370,7 +1428,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
return result ;
return result ;
}
}
List < ProcessTaskRelation > taskRelationList = JSONUtils . toList ( processTaskRelationJson , ProcessTaskRelation . class ) ;
List < ProcessTaskRelation > taskRelationList =
JSONUtils . toList ( processTaskRelationJson , ProcessTaskRelation . class ) ;
// Check whether the task node is normal
// Check whether the task node is normal
List < TaskNode > taskNodes = processService . transformTask ( taskRelationList , taskDefinitionLogsList ) ;
List < TaskNode > taskNodes = processService . transformTask ( taskRelationList , taskDefinitionLogsList ) ;
@ -1458,7 +1517,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
return result ;
return result ;
}
}
Set < Long > defineCodeSet = Lists . newArrayList ( codes . split ( Constants . COMMA ) ) . stream ( ) . map ( Long : : parseLong ) . collect ( Collectors . toSet ( ) ) ;
Set < Long > defineCodeSet = Lists . newArrayList ( codes . split ( Constants . COMMA ) ) . stream ( ) . map ( Long : : parseLong )
. collect ( Collectors . toSet ( ) ) ;
List < ProcessDefinition > processDefinitionList = processDefinitionMapper . queryByCodes ( defineCodeSet ) ;
List < ProcessDefinition > processDefinitionList = processDefinitionMapper . queryByCodes ( defineCodeSet ) ;
if ( CollectionUtils . isEmpty ( processDefinitionList ) ) {
if ( CollectionUtils . isEmpty ( processDefinitionList ) ) {
logger . info ( "process definition not exists" ) ;
logger . info ( "process definition not exists" ) ;
@ -1500,12 +1560,14 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
public Map < String , Object > queryAllProcessDefinitionByProjectCode ( User loginUser , long projectCode ) {
public Map < String , Object > queryAllProcessDefinitionByProjectCode ( User loginUser , long projectCode ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_DEFINITION ) ;
Map < String , Object > result =
projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_DEFINITION ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
List < ProcessDefinition > processDefinitions = processDefinitionMapper . queryAllDefinitionList ( projectCode ) ;
List < ProcessDefinition > processDefinitions = processDefinitionMapper . queryAllDefinitionList ( projectCode ) ;
List < DagData > dagDataList = processDefinitions . stream ( ) . map ( processService : : genDagData ) . collect ( Collectors . toList ( ) ) ;
List < DagData > dagDataList =
processDefinitions . stream ( ) . map ( processService : : genDagData ) . collect ( Collectors . toList ( ) ) ;
result . put ( Constants . DATA_LIST , dagDataList ) ;
result . put ( Constants . DATA_LIST , dagDataList ) ;
putMsg ( result , Status . SUCCESS ) ;
putMsg ( result , Status . SUCCESS ) ;
return result ;
return result ;
@ -1520,7 +1582,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
@Override
@Override
public Map < String , Object > queryProcessDefinitionListByProjectCode ( long projectCode ) {
public Map < String , Object > queryProcessDefinitionListByProjectCode ( long projectCode ) {
Map < String , Object > result = new HashMap < > ( ) ;
Map < String , Object > result = new HashMap < > ( ) ;
List < DependentSimplifyDefinition > processDefinitions = processDefinitionMapper . queryDefinitionListByProjectCodeAndProcessDefinitionCodes ( projectCode , null ) ;
List < DependentSimplifyDefinition > processDefinitions =
processDefinitionMapper . queryDefinitionListByProjectCodeAndProcessDefinitionCodes ( projectCode , null ) ;
result . put ( Constants . DATA_LIST , processDefinitions ) ;
result . put ( Constants . DATA_LIST , processDefinitions ) ;
putMsg ( result , Status . SUCCESS ) ;
putMsg ( result , Status . SUCCESS ) ;
return result ;
return result ;
@ -1534,15 +1597,18 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @return task definition list in the process definition
* @return task definition list in the process definition
* /
* /
@Override
@Override
public Map < String , Object > queryTaskDefinitionListByProcessDefinitionCode ( long projectCode , Long processDefinitionCode ) {
public Map < String , Object > queryTaskDefinitionListByProcessDefinitionCode ( long projectCode ,
Long processDefinitionCode ) {
Map < String , Object > result = new HashMap < > ( ) ;
Map < String , Object > result = new HashMap < > ( ) ;
Set < Long > definitionCodesSet = new HashSet < > ( ) ;
Set < Long > definitionCodesSet = new HashSet < > ( ) ;
definitionCodesSet . add ( processDefinitionCode ) ;
definitionCodesSet . add ( processDefinitionCode ) ;
List < DependentSimplifyDefinition > processDefinitions = processDefinitionMapper . queryDefinitionListByProjectCodeAndProcessDefinitionCodes ( projectCode , definitionCodesSet ) ;
List < DependentSimplifyDefinition > processDefinitions = processDefinitionMapper
. queryDefinitionListByProjectCodeAndProcessDefinitionCodes ( projectCode , definitionCodesSet ) ;
// query process task relation
// query process task relation
List < ProcessTaskRelation > processTaskRelations = processTaskRelationMapper . queryProcessTaskRelationsByProcessDefinitionCode (
List < ProcessTaskRelation > processTaskRelations =
processTaskRelationMapper . queryProcessTaskRelationsByProcessDefinitionCode (
processDefinitions . get ( 0 ) . getCode ( ) ,
processDefinitions . get ( 0 ) . getCode ( ) ,
processDefinitions . get ( 0 ) . getVersion ( ) ) ;
processDefinitions . get ( 0 ) . getVersion ( ) ) ;
@ -1595,8 +1661,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
// List of process instances
// List of process instances
List < ProcessInstance > processInstanceList = processInstanceService . queryByProcessDefineCode ( code , limit ) ;
List < ProcessInstance > processInstanceList = processInstanceService . queryByProcessDefineCode ( code , limit ) ;
processInstanceList . forEach ( processInstance - > processInstance . setDuration ( DateUtils . format2Duration ( processInstance . getStartTime ( ) , processInstance . getEndTime ( ) ) ) ) ;
processInstanceList . forEach ( processInstance - > processInstance
List < TaskDefinitionLog > taskDefinitionList = processService . genTaskDefineList ( processTaskRelationMapper . queryByProcessCode ( processDefinition . getProjectCode ( ) , processDefinition . getCode ( ) ) ) ;
. setDuration ( DateUtils . format2Duration ( processInstance . getStartTime ( ) , processInstance . getEndTime ( ) ) ) ) ;
List < TaskDefinitionLog > taskDefinitionList = processService . genTaskDefineList ( processTaskRelationMapper
. queryByProcessCode ( processDefinition . getProjectCode ( ) , processDefinition . getCode ( ) ) ) ;
Map < Long , TaskDefinitionLog > taskDefinitionMap = taskDefinitionList . stream ( )
Map < Long , TaskDefinitionLog > taskDefinitionMap = taskDefinitionList . stream ( )
. collect ( Collectors . toMap ( TaskDefinitionLog : : getCode , taskDefinitionLog - > taskDefinitionLog ) ) ;
. collect ( Collectors . toMap ( TaskDefinitionLog : : getCode , taskDefinitionLog - > taskDefinitionLog ) ) ;
@ -1612,8 +1680,11 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
for ( int i = limit - 1 ; i > = 0 ; i - - ) {
for ( int i = limit - 1 ; i > = 0 ; i - - ) {
ProcessInstance processInstance = processInstanceList . get ( i ) ;
ProcessInstance processInstance = processInstanceList . get ( i ) ;
Date endTime = processInstance . getEndTime ( ) = = null ? new Date ( ) : processInstance . getEndTime ( ) ;
Date endTime = processInstance . getEndTime ( ) = = null ? new Date ( ) : processInstance . getEndTime ( ) ;
parentTreeViewDto . getInstances ( ) . add ( new Instance ( processInstance . getId ( ) , processInstance . getName ( ) , processInstance . getProcessDefinitionCode ( ) ,
parentTreeViewDto . getInstances ( )
"" , processInstance . getState ( ) . toString ( ) , processInstance . getStartTime ( ) , endTime , processInstance . getHost ( ) ,
. add ( new Instance ( processInstance . getId ( ) , processInstance . getName ( ) ,
processInstance . getProcessDefinitionCode ( ) ,
"" , processInstance . getState ( ) . toString ( ) , processInstance . getStartTime ( ) , endTime ,
processInstance . getHost ( ) ,
DateUtils . format2Readable ( endTime . getTime ( ) - processInstance . getStartTime ( ) . getTime ( ) ) ) ) ;
DateUtils . format2Readable ( endTime . getTime ( ) - processInstance . getStartTime ( ) . getTime ( ) ) ) ) ;
}
}
@ -1624,7 +1695,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
runningNodeMap . put ( startNode , parentTreeViewDtoList ) ;
runningNodeMap . put ( startNode , parentTreeViewDtoList ) ;
}
}
while ( Stopper . isRunning ( ) ) {
while ( ! ServerLifeCycleManager . isStopped ( ) ) {
Set < String > postNodeList ;
Set < String > postNodeList ;
Iterator < Map . Entry < String , List < TreeViewDto > > > iter = runningNodeMap . entrySet ( ) . iterator ( ) ;
Iterator < Map . Entry < String , List < TreeViewDto > > > iter = runningNodeMap . entrySet ( ) . iterator ( ) ;
while ( iter . hasNext ( ) ) {
while ( iter . hasNext ( ) ) {
@ -1640,7 +1711,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
// set treeViewDto instances
// set treeViewDto instances
for ( int i = limit - 1 ; i > = 0 ; i - - ) {
for ( int i = limit - 1 ; i > = 0 ; i - - ) {
ProcessInstance processInstance = processInstanceList . get ( i ) ;
ProcessInstance processInstance = processInstanceList . get ( i ) ;
TaskInstance taskInstance = taskInstanceMapper . queryByInstanceIdAndCode ( processInstance . getId ( ) , Long . parseLong ( nodeCode ) ) ;
TaskInstance taskInstance = taskInstanceMapper . queryByInstanceIdAndCode ( processInstance . getId ( ) ,
Long . parseLong ( nodeCode ) ) ;
if ( taskInstance = = null ) {
if ( taskInstance = = null ) {
treeViewDto . getInstances ( ) . add ( new Instance ( - 1 , "not running" , 0 , "null" ) ) ;
treeViewDto . getInstances ( ) . add ( new Instance ( - 1 , "not running" , 0 , "null" ) ) ;
} else {
} else {
@ -1654,9 +1726,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
subProcessCode = Long . parseLong ( JSONUtils . parseObject (
subProcessCode = Long . parseLong ( JSONUtils . parseObject (
taskDefinition . getTaskParams ( ) ) . path ( CMD_PARAM_SUB_PROCESS_DEFINE_CODE ) . asText ( ) ) ;
taskDefinition . getTaskParams ( ) ) . path ( CMD_PARAM_SUB_PROCESS_DEFINE_CODE ) . asText ( ) ) ;
}
}
treeViewDto . getInstances ( ) . add ( new Instance ( taskInstance . getId ( ) , taskInstance . getName ( ) , taskInstance . getTaskCode ( ) ,
treeViewDto . getInstances ( ) . add ( new Instance ( taskInstance . getId ( ) , taskInstance . getName ( ) ,
taskInstance . getTaskType ( ) , taskInstance . getState ( ) . toString ( ) , taskInstance . getStartTime ( ) , taskInstance . getEndTime ( ) ,
taskInstance . getTaskCode ( ) ,
taskInstance . getHost ( ) , DateUtils . format2Readable ( endTime . getTime ( ) - startTime . getTime ( ) ) , subProcessCode ) ) ;
taskInstance . getTaskType ( ) , taskInstance . getState ( ) . toString ( ) ,
taskInstance . getStartTime ( ) , taskInstance . getEndTime ( ) ,
taskInstance . getHost ( ) ,
DateUtils . format2Readable ( endTime . getTime ( ) - startTime . getTime ( ) ) , subProcessCode ) ) ;
}
}
}
}
for ( TreeViewDto pTreeViewDto : parentTreeViewDtoList ) {
for ( TreeViewDto pTreeViewDto : parentTreeViewDtoList ) {
@ -1755,7 +1830,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
long projectCode ,
long projectCode ,
String codes ,
String codes ,
long targetProjectCode ) {
long targetProjectCode ) {
Map < String , Object > result = checkParams ( loginUser , projectCode , codes , targetProjectCode , TASK_DEFINITION_MOVE ) ;
Map < String , Object > result =
checkParams ( loginUser , projectCode , codes , targetProjectCode , TASK_DEFINITION_MOVE ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
@ -1788,7 +1864,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
if ( projectCode ! = targetProjectCode ) {
if ( projectCode ! = targetProjectCode ) {
Project targetProject = projectMapper . queryByCode ( targetProjectCode ) ;
Project targetProject = projectMapper . queryByCode ( targetProjectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > targetResult = projectService . checkProjectAndAuth ( loginUser , targetProject , targetProjectCode , perm ) ;
Map < String , Object > targetResult =
projectService . checkProjectAndAuth ( loginUser , targetProject , targetProjectCode , perm ) ;
if ( targetResult . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( targetResult . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return targetResult ;
return targetResult ;
}
}
@ -1802,16 +1879,21 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
String processDefinitionCodes ,
String processDefinitionCodes ,
Map < String , Object > result ,
Map < String , Object > result ,
boolean isCopy ) {
boolean isCopy ) {
Set < Long > definitionCodes = Arrays . stream ( processDefinitionCodes . split ( Constants . COMMA ) ) . map ( Long : : parseLong ) . collect ( Collectors . toSet ( ) ) ;
Set < Long > definitionCodes = Arrays . stream ( processDefinitionCodes . split ( Constants . COMMA ) ) . map ( Long : : parseLong )
. collect ( Collectors . toSet ( ) ) ;
List < ProcessDefinition > processDefinitionList = processDefinitionMapper . queryByCodes ( definitionCodes ) ;
List < ProcessDefinition > processDefinitionList = processDefinitionMapper . queryByCodes ( definitionCodes ) ;
Set < Long > queryCodes = processDefinitionList . stream ( ) . map ( ProcessDefinition : : getCode ) . collect ( Collectors . toSet ( ) ) ;
Set < Long > queryCodes =
processDefinitionList . stream ( ) . map ( ProcessDefinition : : getCode ) . collect ( Collectors . toSet ( ) ) ;
// definitionCodes - queryCodes
// definitionCodes - queryCodes
Set < Long > diffCode = definitionCodes . stream ( ) . filter ( code - > ! queryCodes . contains ( code ) ) . collect ( Collectors . toSet ( ) ) ;
Set < Long > diffCode =
definitionCodes . stream ( ) . filter ( code - > ! queryCodes . contains ( code ) ) . collect ( Collectors . toSet ( ) ) ;
diffCode . forEach ( code - > failedProcessList . add ( code + "[null]" ) ) ;
diffCode . forEach ( code - > failedProcessList . add ( code + "[null]" ) ) ;
for ( ProcessDefinition processDefinition : processDefinitionList ) {
for ( ProcessDefinition processDefinition : processDefinitionList ) {
List < ProcessTaskRelation > processTaskRelations =
List < ProcessTaskRelation > processTaskRelations =
processTaskRelationMapper . queryByProcessCode ( processDefinition . getProjectCode ( ) , processDefinition . getCode ( ) ) ;
processTaskRelationMapper . queryByProcessCode ( processDefinition . getProjectCode ( ) ,
List < ProcessTaskRelationLog > taskRelationList = processTaskRelations . stream ( ) . map ( ProcessTaskRelationLog : : new ) . collect ( Collectors . toList ( ) ) ;
processDefinition . getCode ( ) ) ;
List < ProcessTaskRelationLog > taskRelationList =
processTaskRelations . stream ( ) . map ( ProcessTaskRelationLog : : new ) . collect ( Collectors . toList ( ) ) ;
processDefinition . setProjectCode ( targetProjectCode ) ;
processDefinition . setProjectCode ( targetProjectCode ) ;
String otherParamsJson = doOtherOperateProcess ( loginUser , processDefinition ) ;
String otherParamsJson = doOtherOperateProcess ( loginUser , processDefinition ) ;
if ( isCopy ) {
if ( isCopy ) {
@ -1839,7 +1921,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
processTaskRelationLog . setPreTaskCode ( taskCodeMap . get ( processTaskRelationLog . getPreTaskCode ( ) ) ) ;
processTaskRelationLog . setPreTaskCode ( taskCodeMap . get ( processTaskRelationLog . getPreTaskCode ( ) ) ) ;
}
}
if ( processTaskRelationLog . getPostTaskCode ( ) > 0 ) {
if ( processTaskRelationLog . getPostTaskCode ( ) > 0 ) {
processTaskRelationLog . setPostTaskCode ( taskCodeMap . get ( processTaskRelationLog . getPostTaskCode ( ) ) ) ;
processTaskRelationLog
. setPostTaskCode ( taskCodeMap . get ( processTaskRelationLog . getPostTaskCode ( ) ) ) ;
}
}
}
}
final long oldProcessDefinitionCode = processDefinition . getCode ( ) ;
final long oldProcessDefinitionCode = processDefinition . getCode ( ) ;
@ -1879,14 +1962,16 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
}
}
}
try {
try {
result . putAll ( createDagDefine ( loginUser , taskRelationList , processDefinition , taskDefinitionLogs , otherParamsJson ) ) ;
result . putAll ( createDagDefine ( loginUser , taskRelationList , processDefinition , taskDefinitionLogs ,
otherParamsJson ) ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
putMsg ( result , Status . COPY_PROCESS_DEFINITION_ERROR ) ;
putMsg ( result , Status . COPY_PROCESS_DEFINITION_ERROR ) ;
throw new ServiceException ( Status . COPY_PROCESS_DEFINITION_ERROR ) ;
throw new ServiceException ( Status . COPY_PROCESS_DEFINITION_ERROR ) ;
}
}
} else {
} else {
try {
try {
result . putAll ( updateDagDefine ( loginUser , taskRelationList , processDefinition , null , Lists . newArrayList ( ) , otherParamsJson ) ) ;
result . putAll ( updateDagDefine ( loginUser , taskRelationList , processDefinition , null ,
Lists . newArrayList ( ) , otherParamsJson ) ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
putMsg ( result , Status . MOVE_PROCESS_DEFINITION_ERROR ) ;
putMsg ( result , Status . MOVE_PROCESS_DEFINITION_ERROR ) ;
throw new ServiceException ( Status . MOVE_PROCESS_DEFINITION_ERROR ) ;
throw new ServiceException ( Status . MOVE_PROCESS_DEFINITION_ERROR ) ;
@ -1931,10 +2016,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* /
* /
@Override
@Override
@Transactional
@Transactional
public Map < String , Object > switchProcessDefinitionVersion ( User loginUser , long projectCode , long code , int version ) {
public Map < String , Object > switchProcessDefinitionVersion ( User loginUser , long projectCode , long code ,
int version ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_SWITCH_TO_THIS_VERSION ) ;
Map < String , Object > result =
projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_SWITCH_TO_THIS_VERSION ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
@ -1945,9 +2032,11 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
return result ;
return result ;
}
}
ProcessDefinitionLog processDefinitionLog = processDefinitionLogMapper . queryByDefinitionCodeAndVersion ( code , version ) ;
ProcessDefinitionLog processDefinitionLog =
processDefinitionLogMapper . queryByDefinitionCodeAndVersion ( code , version ) ;
if ( Objects . isNull ( processDefinitionLog ) ) {
if ( Objects . isNull ( processDefinitionLog ) ) {
putMsg ( result , Status . SWITCH_PROCESS_DEFINITION_VERSION_NOT_EXIST_PROCESS_DEFINITION_VERSION_ERROR , processDefinition . getCode ( ) , version ) ;
putMsg ( result , Status . SWITCH_PROCESS_DEFINITION_VERSION_NOT_EXIST_PROCESS_DEFINITION_VERSION_ERROR ,
processDefinition . getCode ( ) , version ) ;
return result ;
return result ;
}
}
int switchVersion = processService . switchVersion ( processDefinition , processDefinitionLog ) ;
int switchVersion = processService . switchVersion ( processDefinition , processDefinitionLog ) ;
@ -1972,9 +2061,11 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
Map < String , Object > result , List < String > failedProcessList , boolean isCopy ) {
Map < String , Object > result , List < String > failedProcessList , boolean isCopy ) {
if ( ! failedProcessList . isEmpty ( ) ) {
if ( ! failedProcessList . isEmpty ( ) ) {
if ( isCopy ) {
if ( isCopy ) {
putMsg ( result , Status . COPY_PROCESS_DEFINITION_ERROR , srcProjectCode , targetProjectCode , String . join ( "," , failedProcessList ) ) ;
putMsg ( result , Status . COPY_PROCESS_DEFINITION_ERROR , srcProjectCode , targetProjectCode ,
String . join ( "," , failedProcessList ) ) ;
} else {
} else {
putMsg ( result , Status . MOVE_PROCESS_DEFINITION_ERROR , srcProjectCode , targetProjectCode , String . join ( "," , failedProcessList ) ) ;
putMsg ( result , Status . MOVE_PROCESS_DEFINITION_ERROR , srcProjectCode , targetProjectCode ,
String . join ( "," , failedProcessList ) ) ;
}
}
} else {
} else {
putMsg ( result , Status . SUCCESS ) ;
putMsg ( result , Status . SUCCESS ) ;
@ -1992,11 +2083,13 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @return the pagination process definition versions info of the certain process definition
* @return the pagination process definition versions info of the certain process definition
* /
* /
@Override
@Override
public Result queryProcessDefinitionVersions ( User loginUser , long projectCode , int pageNo , int pageSize , long code ) {
public Result queryProcessDefinitionVersions ( User loginUser , long projectCode , int pageNo , int pageSize ,
long code ) {
Result result = new Result ( ) ;
Result result = new Result ( ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > checkResult = projectService . checkProjectAndAuth ( loginUser , project , projectCode , VERSION_LIST ) ;
Map < String , Object > checkResult =
projectService . checkProjectAndAuth ( loginUser , project , projectCode , VERSION_LIST ) ;
Status resultStatus = ( Status ) checkResult . get ( Constants . STATUS ) ;
Status resultStatus = ( Status ) checkResult . get ( Constants . STATUS ) ;
if ( resultStatus ! = Status . SUCCESS ) {
if ( resultStatus ! = Status . SUCCESS ) {
putMsg ( result , resultStatus ) ;
putMsg ( result , resultStatus ) ;
@ -2004,7 +2097,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
}
PageInfo < ProcessDefinitionLog > pageInfo = new PageInfo < > ( pageNo , pageSize ) ;
PageInfo < ProcessDefinitionLog > pageInfo = new PageInfo < > ( pageNo , pageSize ) ;
Page < ProcessDefinitionLog > page = new Page < > ( pageNo , pageSize ) ;
Page < ProcessDefinitionLog > page = new Page < > ( pageNo , pageSize ) ;
IPage < ProcessDefinitionLog > processDefinitionVersionsPaging = processDefinitionLogMapper . queryProcessDefinitionVersionsPaging ( page , code , projectCode ) ;
IPage < ProcessDefinitionLog > processDefinitionVersionsPaging =
processDefinitionLogMapper . queryProcessDefinitionVersionsPaging ( page , code , projectCode ) ;
List < ProcessDefinitionLog > processDefinitionLogs = processDefinitionVersionsPaging . getRecords ( ) ;
List < ProcessDefinitionLog > processDefinitionLogs = processDefinitionVersionsPaging . getRecords ( ) ;
pageInfo . setTotalList ( processDefinitionLogs ) ;
pageInfo . setTotalList ( processDefinitionLogs ) ;
@ -2014,7 +2108,6 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
return result ;
return result ;
}
}
/ * *
/ * *
* delete one certain process definition by version number and process definition code
* delete one certain process definition by version number and process definition code
*
*
@ -2026,10 +2119,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* /
* /
@Override
@Override
@Transactional
@Transactional
public Map < String , Object > deleteProcessDefinitionVersion ( User loginUser , long projectCode , long code , int version ) {
public Map < String , Object > deleteProcessDefinitionVersion ( User loginUser , long projectCode , long code ,
int version ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , VERSION_DELETE ) ;
Map < String , Object > result =
projectService . checkProjectAndAuth ( loginUser , project , projectCode , VERSION_DELETE ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
@ -2080,7 +2175,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
ProcessExecutionTypeEnum executionType ) {
ProcessExecutionTypeEnum executionType ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_CREATE ) ;
Map < String , Object > result =
projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_CREATE ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
@ -2111,7 +2207,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
putMsg ( result , Status . INTERNAL_SERVER_ERROR_ARGS ) ;
putMsg ( result , Status . INTERNAL_SERVER_ERROR_ARGS ) ;
return result ;
return result ;
}
}
ProcessDefinition processDefinition = new ProcessDefinition ( projectCode , name , processDefinitionCode , description ,
ProcessDefinition processDefinition =
new ProcessDefinition ( projectCode , name , processDefinitionCode , description ,
globalParams , "" , timeout , loginUser . getId ( ) , tenantId ) ;
globalParams , "" , timeout , loginUser . getId ( ) , tenantId ) ;
processDefinition . setExecutionType ( executionType ) ;
processDefinition . setExecutionType ( executionType ) ;
result = createEmptyDagDefine ( loginUser , processDefinition ) ;
result = createEmptyDagDefine ( loginUser , processDefinition ) ;
@ -2145,7 +2242,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
return result ;
return result ;
}
}
protected Map < String , Object > createDagSchedule ( User loginUser , ProcessDefinition processDefinition , String scheduleJson ) {
protected Map < String , Object > createDagSchedule ( User loginUser , ProcessDefinition processDefinition ,
String scheduleJson ) {
Map < String , Object > result = new HashMap < > ( ) ;
Map < String , Object > result = new HashMap < > ( ) ;
Schedule scheduleObj = JSONUtils . parseObject ( scheduleJson , Schedule . class ) ;
Schedule scheduleObj = JSONUtils . parseObject ( scheduleJson , Schedule . class ) ;
if ( scheduleObj = = null ) {
if ( scheduleObj = = null ) {
@ -2164,16 +2262,20 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
putMsg ( result , Status . REQUEST_PARAMS_NOT_VALID_ERROR , scheduleObj . getCrontab ( ) ) ;
putMsg ( result , Status . REQUEST_PARAMS_NOT_VALID_ERROR , scheduleObj . getCrontab ( ) ) ;
return result ;
return result ;
}
}
scheduleObj . setWarningType ( scheduleObj . getWarningType ( ) = = null ? WarningType . NONE : scheduleObj . getWarningType ( ) ) ;
scheduleObj
. setWarningType ( scheduleObj . getWarningType ( ) = = null ? WarningType . NONE : scheduleObj . getWarningType ( ) ) ;
scheduleObj . setWarningGroupId ( scheduleObj . getWarningGroupId ( ) = = 0 ? 1 : scheduleObj . getWarningGroupId ( ) ) ;
scheduleObj . setWarningGroupId ( scheduleObj . getWarningGroupId ( ) = = 0 ? 1 : scheduleObj . getWarningGroupId ( ) ) ;
scheduleObj . setFailureStrategy ( scheduleObj . getFailureStrategy ( ) = = null ? FailureStrategy . CONTINUE : scheduleObj . getFailureStrategy ( ) ) ;
scheduleObj . setFailureStrategy (
scheduleObj . getFailureStrategy ( ) = = null ? FailureStrategy . CONTINUE : scheduleObj . getFailureStrategy ( ) ) ;
scheduleObj . setCreateTime ( now ) ;
scheduleObj . setCreateTime ( now ) ;
scheduleObj . setUpdateTime ( now ) ;
scheduleObj . setUpdateTime ( now ) ;
scheduleObj . setUserId ( loginUser . getId ( ) ) ;
scheduleObj . setUserId ( loginUser . getId ( ) ) ;
scheduleObj . setReleaseState ( ReleaseState . OFFLINE ) ;
scheduleObj . setReleaseState ( ReleaseState . OFFLINE ) ;
scheduleObj . setProcessInstancePriority ( scheduleObj . getProcessInstancePriority ( ) = = null ? Priority . MEDIUM : scheduleObj . getProcessInstancePriority ( ) ) ;
scheduleObj . setProcessInstancePriority ( scheduleObj . getProcessInstancePriority ( ) = = null ? Priority . MEDIUM
: scheduleObj . getProcessInstancePriority ( ) ) ;
scheduleObj . setWorkerGroup ( scheduleObj . getWorkerGroup ( ) = = null ? "default" : scheduleObj . getWorkerGroup ( ) ) ;
scheduleObj . setWorkerGroup ( scheduleObj . getWorkerGroup ( ) = = null ? "default" : scheduleObj . getWorkerGroup ( ) ) ;
scheduleObj . setEnvironmentCode ( scheduleObj . getEnvironmentCode ( ) = = null ? - 1 : scheduleObj . getEnvironmentCode ( ) ) ;
scheduleObj
. setEnvironmentCode ( scheduleObj . getEnvironmentCode ( ) = = null ? - 1 : scheduleObj . getEnvironmentCode ( ) ) ;
scheduleMapper . insert ( scheduleObj ) ;
scheduleMapper . insert ( scheduleObj ) ;
putMsg ( result , Status . SUCCESS ) ;
putMsg ( result , Status . SUCCESS ) ;
@ -2212,7 +2314,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
ProcessExecutionTypeEnum executionType ) {
ProcessExecutionTypeEnum executionType ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_UPDATE ) ;
Map < String , Object > result =
projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_UPDATE ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
@ -2249,11 +2352,14 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
return result ;
return result ;
}
}
}
}
ProcessDefinition processDefinitionDeepCopy = JSONUtils . parseObject ( JSONUtils . toJsonString ( processDefinition ) , ProcessDefinition . class ) ;
ProcessDefinition processDefinitionDeepCopy =
JSONUtils . parseObject ( JSONUtils . toJsonString ( processDefinition ) , ProcessDefinition . class ) ;
processDefinition . set ( projectCode , name , description , globalParams , "" , timeout , tenantId ) ;
processDefinition . set ( projectCode , name , description , globalParams , "" , timeout , tenantId ) ;
processDefinition . setExecutionType ( executionType ) ;
processDefinition . setExecutionType ( executionType ) ;
List < ProcessTaskRelationLog > taskRelationList = processTaskRelationLogMapper . queryByProcessCodeAndVersion ( processDefinition . getCode ( ) , processDefinition . getVersion ( ) ) ;
List < ProcessTaskRelationLog > taskRelationList = processTaskRelationLogMapper
result = updateDagDefine ( loginUser , taskRelationList , processDefinition , processDefinitionDeepCopy , Lists . newArrayList ( ) , otherParamsJson ) ;
. queryByProcessCodeAndVersion ( processDefinition . getCode ( ) , processDefinition . getVersion ( ) ) ;
result = updateDagDefine ( loginUser , taskRelationList , processDefinition , processDefinitionDeepCopy ,
Lists . newArrayList ( ) , otherParamsJson ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
@ -2282,9 +2388,11 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
throw new ServiceException ( Status . DATA_IS_NOT_VALID ) ;
throw new ServiceException ( Status . DATA_IS_NOT_VALID ) ;
}
}
// set default value
// set default value
FailureStrategy failureStrategy = schedule . getFailureStrategy ( ) = = null ? FailureStrategy . CONTINUE : schedule . getFailureStrategy ( ) ;
FailureStrategy failureStrategy =
schedule . getFailureStrategy ( ) = = null ? FailureStrategy . CONTINUE : schedule . getFailureStrategy ( ) ;
WarningType warningType = schedule . getWarningType ( ) = = null ? WarningType . NONE : schedule . getWarningType ( ) ;
WarningType warningType = schedule . getWarningType ( ) = = null ? WarningType . NONE : schedule . getWarningType ( ) ;
Priority processInstancePriority = schedule . getProcessInstancePriority ( ) = = null ? Priority . MEDIUM : schedule . getProcessInstancePriority ( ) ;
Priority processInstancePriority =
schedule . getProcessInstancePriority ( ) = = null ? Priority . MEDIUM : schedule . getProcessInstancePriority ( ) ;
int warningGroupId = schedule . getWarningGroupId ( ) = = 0 ? 1 : schedule . getWarningGroupId ( ) ;
int warningGroupId = schedule . getWarningGroupId ( ) = = 0 ? 1 : schedule . getWarningGroupId ( ) ;
String workerGroup = schedule . getWorkerGroup ( ) = = null ? "default" : schedule . getWorkerGroup ( ) ;
String workerGroup = schedule . getWorkerGroup ( ) = = null ? "default" : schedule . getWorkerGroup ( ) ;
long environmentCode = schedule . getEnvironmentCode ( ) = = null ? - 1 : schedule . getEnvironmentCode ( ) ;
long environmentCode = schedule . getEnvironmentCode ( ) = = null ? - 1 : schedule . getEnvironmentCode ( ) ;
@ -2319,10 +2427,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* /
* /
@Transactional
@Transactional
@Override
@Override
public Map < String , Object > releaseWorkflowAndSchedule ( User loginUser , long projectCode , long code , ReleaseState releaseState ) {
public Map < String , Object > releaseWorkflowAndSchedule ( User loginUser , long projectCode , long code ,
ReleaseState releaseState ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_ONLINE_OFFLINE ) ;
Map < String , Object > result =
projectService . checkProjectAndAuth ( loginUser , project , projectCode , WORKFLOW_ONLINE_OFFLINE ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
@ -2344,7 +2454,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
}
switch ( releaseState ) {
switch ( releaseState ) {
case ONLINE :
case ONLINE :
List < ProcessTaskRelation > relationList = processService . findRelationByCode ( code , processDefinition . getVersion ( ) ) ;
List < ProcessTaskRelation > relationList =
processService . findRelationByCode ( code , processDefinition . getVersion ( ) ) ;
if ( CollectionUtils . isEmpty ( relationList ) ) {
if ( CollectionUtils . isEmpty ( relationList ) ) {
putMsg ( result , Status . PROCESS_DAG_IS_EMPTY ) ;
putMsg ( result , Status . PROCESS_DAG_IS_EMPTY ) ;
return result ;
return result ;
@ -2357,7 +2468,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
processDefinition . setReleaseState ( releaseState ) ;
processDefinition . setReleaseState ( releaseState ) ;
int updateProcess = processDefinitionMapper . updateById ( processDefinition ) ;
int updateProcess = processDefinitionMapper . updateById ( processDefinition ) ;
if ( updateProcess > 0 ) {
if ( updateProcess > 0 ) {
logger . info ( "set schedule offline, project code: {}, schedule id: {}, process definition code: {}" , projectCode , scheduleObj . getId ( ) , code ) ;
logger . info ( "set schedule offline, project code: {}, schedule id: {}, process definition code: {}" ,
projectCode , scheduleObj . getId ( ) , code ) ;
// set status
// set status
scheduleObj . setReleaseState ( ReleaseState . OFFLINE ) ;
scheduleObj . setReleaseState ( ReleaseState . OFFLINE ) ;
int updateSchedule = scheduleMapper . updateById ( scheduleObj ) ;
int updateSchedule = scheduleMapper . updateById ( scheduleObj ) ;
@ -2384,7 +2496,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @param otherParamsJson
* @param otherParamsJson
* /
* /
@Override
@Override
public void saveOtherRelation ( User loginUser , ProcessDefinition processDefinition , Map < String , Object > result , String otherParamsJson ) {
public void saveOtherRelation ( User loginUser , ProcessDefinition processDefinition , Map < String , Object > result ,
String otherParamsJson ) {
}
}