@ -17,28 +17,14 @@
package org.apache.dolphinscheduler.api.service.impl ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.TASK_DEFINITION_MOVE ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.VERSION_DELETE ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.VERSION_LIST ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_BATCH_COPY ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_CREATE ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_DEFINITION ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_DEFINITION_DELETE ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_DEFINITION_EXPORT ;
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 com.baomidou.mybatisplus.core.metadata.IPage ;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page ;
import com.fasterxml.jackson.databind.JsonNode ;
import com.fasterxml.jackson.databind.node.ArrayNode ;
import com.fasterxml.jackson.databind.node.ObjectNode ;
import com.google.common.collect.Lists ;
import org.apache.commons.collections4.CollectionUtils ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.dolphinscheduler.api.dto.DagDataSchedule ;
import org.apache.dolphinscheduler.api.dto.ScheduleParam ;
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.WarningType ;
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.TaskNodeRelation ;
import org.apache.dolphinscheduler.common.thread.Stopper ;
import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils ;
import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils.CodeGenerateException ;
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.service.process.ProcessService ;
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 org.apache.commons.lang3.StringUtils ;
import javax.servlet.ServletOutputStream ;
import javax.servlet.http.HttpServletResponse ;
import java.io.BufferedOutputStream ;
import java.io.BufferedReader ;
import java.io.IOException ;
@ -133,23 +125,27 @@ import java.util.stream.Collectors;
import java.util.zip.ZipEntry ;
import java.util.zip.ZipInputStream ;
import javax.servlet.ServletOutputStream ;
import javax.servlet.http.HttpServletResponse ;
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 com.baomidou.mybatisplus.core.metadata.IPage ;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page ;
import com.fasterxml.jackson.databind.JsonNode ;
import com.fasterxml.jackson.databind.node.ArrayNode ;
import com.fasterxml.jackson.databind.node.ObjectNode ;
import com.google.common.collect.Lists ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.TASK_DEFINITION_MOVE ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.VERSION_DELETE ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.VERSION_LIST ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_BATCH_COPY ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_CREATE ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_DEFINITION ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_DEFINITION_DELETE ;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_DEFINITION_EXPORT ;
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 ;
/ * *
* process definition service impl
@ -246,7 +242,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
ProcessExecutionTypeEnum executionType ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
// 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 ) {
return result ;
}
@ -265,8 +262,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
if ( checkTaskDefinitions . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return checkTaskDefinitions ;
}
List < ProcessTaskRelationLog > taskRelationList = JSONUtils . toList ( taskRelationJson , ProcessTaskRelationLog . class ) ;
Map < String , Object > checkRelationJson = checkTaskRelationList ( taskRelationList , taskRelationJson , taskDefinitionLogs ) ;
List < ProcessTaskRelationLog > taskRelationList =
JSONUtils . toList ( taskRelationJson , ProcessTaskRelationLog . class ) ;
Map < String , Object > checkRelationJson =
checkTaskRelationList ( taskRelationList , taskRelationJson , taskDefinitionLogs ) ;
if ( checkRelationJson . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return checkRelationJson ;
}
@ -286,7 +285,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
putMsg ( result , Status . INTERNAL_SERVER_ERROR_ARGS ) ;
return result ;
}
ProcessDefinition processDefinition = new ProcessDefinition ( projectCode , name , processDefinitionCode , description ,
ProcessDefinition processDefinition =
new ProcessDefinition ( projectCode , name , processDefinitionCode , description ,
globalParams , locations , timeout , loginUser . getId ( ) , tenantId ) ;
processDefinition . setExecutionType ( executionType ) ;
@ -298,7 +298,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
ProcessDefinition processDefinition ,
List < TaskDefinitionLog > taskDefinitionLogs , String otherParamsJson ) {
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 ) {
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 ) ;
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 ) ;
if ( insertResult = = Constants . EXIT_CODE_SUCCESS ) {
putMsg ( result , Status . SUCCESS ) ;
@ -324,7 +326,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
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 < > ( ) ;
try {
if ( taskDefinitionLogs . isEmpty ( ) ) {
@ -352,7 +355,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
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 < > ( ) ;
try {
if ( taskRelationList = = null | | taskRelationList . isEmpty ( ) ) {
@ -361,16 +366,19 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
return result ;
}
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 ( ) ) ;
List < TaskNode > taskNodeList = processService . transformTask ( processTaskRelations , taskDefinitionLogs ) ;
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 ( ) ) ;
Collection < Long > codes = CollectionUtils . subtract ( postTaskCodes , taskNodeCodes ) ;
if ( CollectionUtils . isNotEmpty ( codes ) ) {
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 ;
}
}
@ -407,7 +415,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
public Map < String , Object > queryProcessDefinitionList ( User loginUser , long projectCode ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
// 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 ) {
return result ;
}
@ -429,7 +438,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
public Map < String , Object > queryProcessDefinitionSimpleList ( User loginUser , long projectCode ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
// 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 ) {
return result ;
}
@ -460,11 +470,14 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @return process definition page
* /
@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 ( ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// 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 ) ;
if ( resultStatus ! = Status . SUCCESS ) {
putMsg ( result , resultStatus ) ;
@ -477,7 +490,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
List < ProcessDefinition > records = processDefinitionIPage . getRecords ( ) ;
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 ( ) ) ;
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 ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
// 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 ) {
return result ;
}
@ -527,7 +542,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
public Map < String , Object > queryProcessDefinitionByName ( User loginUser , long projectCode , String name ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
// 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 ) {
return result ;
}
@ -577,7 +593,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
ProcessExecutionTypeEnum executionType ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
// 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 ) {
return result ;
}
@ -590,8 +607,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
if ( checkTaskDefinitions . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return checkTaskDefinitions ;
}
List < ProcessTaskRelationLog > taskRelationList = JSONUtils . toList ( taskRelationJson , ProcessTaskRelationLog . class ) ;
Map < String , Object > checkRelationJson = checkTaskRelationList ( taskRelationList , taskRelationJson , taskDefinitionLogs ) ;
List < ProcessTaskRelationLog > taskRelationList =
JSONUtils . toList ( taskRelationJson , ProcessTaskRelationLog . class ) ;
Map < String , Object > checkRelationJson =
checkTaskRelationList ( taskRelationList , taskRelationJson , taskDefinitionLogs ) ;
if ( checkRelationJson . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return checkRelationJson ;
}
@ -625,10 +644,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
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 . 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 taskRelationList All the latest task relation list from process definition
* /
private void taskUsedInOtherTaskValid ( ProcessDefinition processDefinition , List < ProcessTaskRelationLog > taskRelationList ) {
List < ProcessTaskRelation > oldProcessTaskRelationList = processTaskRelationMapper . queryByProcessCode ( processDefinition . getProjectCode ( ) , processDefinition . getCode ( ) ) ;
Set < ProcessTaskRelationLog > oldProcessTaskRelationSet = oldProcessTaskRelationList . stream ( ) . map ( ProcessTaskRelationLog : : new ) . collect ( Collectors . toSet ( ) ) ;
private void taskUsedInOtherTaskValid ( ProcessDefinition processDefinition ,
List < ProcessTaskRelationLog > taskRelationList ) {
List < ProcessTaskRelation > oldProcessTaskRelationList = processTaskRelationMapper
. queryByProcessCode ( processDefinition . getProjectCode ( ) , processDefinition . getCode ( ) ) ;
Set < ProcessTaskRelationLog > oldProcessTaskRelationSet =
oldProcessTaskRelationList . stream ( ) . map ( ProcessTaskRelationLog : : new ) . collect ( Collectors . toSet ( ) ) ;
StringBuilder sb = new StringBuilder ( ) ;
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 ) {
Optional < String > taskDepMsg = workFlowLineageService . taskDepOnTaskMsg (
processDefinition . getProjectCode ( ) , oldProcessTaskRelation . getProcessDefinitionCode ( ) , oldProcessTaskRelation . getPostTaskCode ( ) ) ;
processDefinition . getProjectCode ( ) , oldProcessTaskRelation . getProcessDefinitionCode ( ) ,
oldProcessTaskRelation . getPostTaskCode ( ) ) ;
taskDepMsg . ifPresent ( sb : : append ) ;
}
if ( sb . length ( ) ! = 0 ) {
@ -663,7 +689,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
List < TaskDefinitionLog > taskDefinitionLogs ,
String otherParamsJson ) {
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 ) {
logger . info ( "The task has not changed, so skip" ) ;
}
@ -673,10 +700,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
boolean isChange = false ;
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 ( ) ) {
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 ( ) ) {
taskRelationSet . removeAll ( processTaskRelationLogSet ) ;
if ( ! taskRelationSet . isEmpty ( ) ) {
@ -693,7 +722,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
if ( isChange ) {
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 ) {
putMsg ( result , 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 ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
// 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 ) {
return result ;
}
ProcessDefinition processDefinition = processDefinitionMapper . verifyByDefineName ( project . getCode ( ) , name . trim ( ) ) ;
ProcessDefinition processDefinition =
processDefinitionMapper . verifyByDefineName ( project . getCode ( ) , name . trim ( ) ) ;
if ( processDefinition = = null ) {
putMsg ( result , Status . SUCCESS ) ;
} else {
@ -756,16 +788,19 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
// 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 ) ) {
throw new ServiceException ( Status . DELETE_PROCESS_DEFINITION_EXECUTING_FAIL , processInstances . size ( ) ) ;
}
// 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 ) ) {
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 ) ) ;
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 ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
// 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 ) {
return result ;
}
@ -842,10 +878,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* /
@Override
@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 ) ;
// 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 ) {
return result ;
}
@ -863,7 +901,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
switch ( releaseState ) {
case ONLINE :
List < ProcessTaskRelation > relationList = processService . findRelationByCode ( code , processDefinition . getVersion ( ) ) ;
List < ProcessTaskRelation > relationList =
processService . findRelationByCode ( code , processDefinition . getVersion ( ) ) ;
if ( CollectionUtils . isEmpty ( relationList ) ) {
putMsg ( result , Status . PROCESS_DAG_IS_EMPTY ) ;
return result ;
@ -876,7 +915,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
int updateProcess = processDefinitionMapper . updateById ( processDefinition ) ;
Schedule schedule = scheduleMapper . queryByProcessDefinitionCode ( code ) ;
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
schedule . setReleaseState ( releaseState ) ;
int updateSchedule = scheduleMapper . updateById ( schedule ) ;
@ -900,24 +940,29 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* batch export process definition by codes
* /
@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 ) ) {
return ;
}
Project project = projectMapper . queryByCode ( projectCode ) ;
// 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 ) {
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 ) ;
if ( CollectionUtils . isEmpty ( processDefinitionList ) ) {
return ;
}
// check processDefinition exist in project
List < ProcessDefinition > processDefinitionListInProject = processDefinitionList . stream ( ) . filter ( o - > projectCode = = o . getProjectCode ( ) ) . collect ( Collectors . toList ( ) ) ;
List < DagDataSchedule > dagDataSchedules = processDefinitionListInProject . stream ( ) . map ( this : : exportProcessDagData ) . collect ( Collectors . toList ( ) ) ;
List < ProcessDefinition > processDefinitionListInProject = processDefinitionList . stream ( )
. filter ( o - > projectCode = = o . getProjectCode ( ) ) . collect ( Collectors . toList ( ) ) ;
List < DagDataSchedule > dagDataSchedules =
processDefinitionListInProject . stream ( ) . map ( this : : exportProcessDagData ) . collect ( Collectors . toList ( ) ) ;
if ( CollectionUtils . isNotEmpty ( dagDataSchedules ) ) {
downloadProcessDefinitionFile ( response , dagDataSchedules ) ;
}
@ -1034,7 +1079,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
Map < String , DataSource > dataSourceCache = new HashMap < > ( 1 ) ;
Map < String , Long > taskNameToCode = 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 ) ) ) {
// build process definition
processDefinition = new ProcessDefinition ( projectCode ,
@ -1060,7 +1106,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
totalSizeArchive + = nBytes ;
long compressionRatio = totalSizeEntry / entry . getCompressedSize ( ) ;
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 ( "-- " ) ;
if ( commentIndex > = 0 ) {
@ -1113,7 +1160,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
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 ) ;
taskNameToCode . put ( taskDefinition . getName ( ) , taskDefinition . getCode ( ) ) ;
@ -1121,11 +1169,13 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
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 ) {
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 ) {
@ -1144,7 +1194,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
continue ;
}
for ( String upstream : upstreams ) {
ProcessTaskRelationLog processTaskRelation = buildNormalTaskRelation ( taskNameToCode . get ( upstream ) , entry . getValue ( ) ) ;
ProcessTaskRelationLog processTaskRelation =
buildNormalTaskRelation ( taskNameToCode . get ( upstream ) , entry . getValue ( ) ) ;
processTaskRelationList . add ( processTaskRelation ) ;
}
}
@ -1175,7 +1226,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
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 ( ) ;
taskDefinition . setName ( taskName ) ;
taskDefinition . setFlag ( Flag . YES ) ;
@ -1206,7 +1258,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
/ * *
* 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 ) ) {
return false ;
}
@ -1216,7 +1269,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
String processDefinitionName = recursionProcessDefinitionName ( projectCode , processDefinition . getName ( ) , 1 ) ;
String importProcessDefinitionName = getNewName ( processDefinitionName , IMPORT_SUFFIX ) ;
// 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 ) ) ) {
putMsg ( result , Status . SUCCESS ) ;
} else {
@ -1279,7 +1333,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
processTaskRelationLog . setPostTaskVersion ( Constants . VERSION_FIRST ) ;
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 newArrayNode = JSONUtils . createArrayNode ( ) ;
for ( int i = 0 ; i < arrayNode . size ( ) ; i + + ) {
@ -1296,7 +1351,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
processDefinition . setCreateTime ( 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 ) ) ) {
putMsg ( createDagResult , Status . SUCCESS ) ;
} else {
@ -1340,7 +1396,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
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 ( num > 1 ) {
String str = processDefinitionName . substring ( 0 , processDefinitionName . length ( ) - 3 ) ;
@ -1361,7 +1418,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @return check result code
* /
@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 < > ( ) ;
try {
if ( processTaskRelationJson = = null ) {
@ -1370,7 +1428,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
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
List < TaskNode > taskNodes = processService . transformTask ( taskRelationList , taskDefinitionLogsList ) ;
@ -1458,7 +1517,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
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 ) ;
if ( CollectionUtils . isEmpty ( processDefinitionList ) ) {
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 ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
// 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 ) {
return result ;
}
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 ) ;
putMsg ( result , Status . SUCCESS ) ;
return result ;
@ -1520,7 +1582,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
@Override
public Map < String , Object > queryProcessDefinitionListByProjectCode ( long projectCode ) {
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 ) ;
putMsg ( result , Status . SUCCESS ) ;
return result ;
@ -1534,15 +1597,18 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @return task definition list in the process definition
* /
@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 < > ( ) ;
Set < Long > definitionCodesSet = new HashSet < > ( ) ;
definitionCodesSet . add ( processDefinitionCode ) ;
List < DependentSimplifyDefinition > processDefinitions = processDefinitionMapper . queryDefinitionListByProjectCodeAndProcessDefinitionCodes ( projectCode , definitionCodesSet ) ;
List < DependentSimplifyDefinition > processDefinitions = processDefinitionMapper
. queryDefinitionListByProjectCodeAndProcessDefinitionCodes ( projectCode , definitionCodesSet ) ;
// query process task relation
List < ProcessTaskRelation > processTaskRelations = processTaskRelationMapper . queryProcessTaskRelationsByProcessDefinitionCode (
List < ProcessTaskRelation > processTaskRelations =
processTaskRelationMapper . queryProcessTaskRelationsByProcessDefinitionCode (
processDefinitions . get ( 0 ) . getCode ( ) ,
processDefinitions . get ( 0 ) . getVersion ( ) ) ;
@ -1595,8 +1661,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
// List of process instances
List < ProcessInstance > processInstanceList = processInstanceService . queryByProcessDefineCode ( code , limit ) ;
processInstanceList . forEach ( processInstance - > processInstance . setDuration ( DateUtils . format2Duration ( processInstance . getStartTime ( ) , processInstance . getEndTime ( ) ) ) ) ;
List < TaskDefinitionLog > taskDefinitionList = processService . genTaskDefineList ( processTaskRelationMapper . queryByProcessCode ( processDefinition . getProjectCode ( ) , processDefinition . getCode ( ) ) ) ;
processInstanceList . forEach ( processInstance - > processInstance
. setDuration ( DateUtils . format2Duration ( processInstance . getStartTime ( ) , processInstance . getEndTime ( ) ) ) ) ;
List < TaskDefinitionLog > taskDefinitionList = processService . genTaskDefineList ( processTaskRelationMapper
. queryByProcessCode ( processDefinition . getProjectCode ( ) , processDefinition . getCode ( ) ) ) ;
Map < Long , TaskDefinitionLog > taskDefinitionMap = taskDefinitionList . stream ( )
. 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 - - ) {
ProcessInstance processInstance = processInstanceList . get ( i ) ;
Date endTime = processInstance . getEndTime ( ) = = null ? new Date ( ) : processInstance . getEndTime ( ) ;
parentTreeViewDto . getInstances ( ) . add ( new Instance ( processInstance . getId ( ) , processInstance . getName ( ) , processInstance . getProcessDefinitionCode ( ) ,
"" , processInstance . getState ( ) . toString ( ) , processInstance . getStartTime ( ) , endTime , processInstance . getHost ( ) ,
parentTreeViewDto . getInstances ( )
. add ( new Instance ( processInstance . getId ( ) , processInstance . getName ( ) ,
processInstance . getProcessDefinitionCode ( ) ,
"" , processInstance . getState ( ) . toString ( ) , processInstance . getStartTime ( ) , endTime ,
processInstance . getHost ( ) ,
DateUtils . format2Readable ( endTime . getTime ( ) - processInstance . getStartTime ( ) . getTime ( ) ) ) ) ;
}
@ -1624,7 +1695,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
runningNodeMap . put ( startNode , parentTreeViewDtoList ) ;
}
while ( Stopper . isRunning ( ) ) {
while ( ! ServerLifeCycleManager . isStopped ( ) ) {
Set < String > postNodeList ;
Iterator < Map . Entry < String , List < TreeViewDto > > > iter = runningNodeMap . entrySet ( ) . iterator ( ) ;
while ( iter . hasNext ( ) ) {
@ -1640,7 +1711,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
// set treeViewDto instances
for ( int i = limit - 1 ; i > = 0 ; 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 ) {
treeViewDto . getInstances ( ) . add ( new Instance ( - 1 , "not running" , 0 , "null" ) ) ;
} else {
@ -1654,9 +1726,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
subProcessCode = Long . parseLong ( JSONUtils . parseObject (
taskDefinition . getTaskParams ( ) ) . path ( CMD_PARAM_SUB_PROCESS_DEFINE_CODE ) . asText ( ) ) ;
}
treeViewDto . getInstances ( ) . add ( new Instance ( taskInstance . getId ( ) , taskInstance . getName ( ) , taskInstance . getTaskCode ( ) ,
taskInstance . getTaskType ( ) , taskInstance . getState ( ) . toString ( ) , taskInstance . getStartTime ( ) , taskInstance . getEndTime ( ) ,
taskInstance . getHost ( ) , DateUtils . format2Readable ( endTime . getTime ( ) - startTime . getTime ( ) ) , subProcessCode ) ) ;
treeViewDto . getInstances ( ) . add ( new Instance ( taskInstance . getId ( ) , taskInstance . getName ( ) ,
taskInstance . getTaskCode ( ) ,
taskInstance . getTaskType ( ) , taskInstance . getState ( ) . toString ( ) ,
taskInstance . getStartTime ( ) , taskInstance . getEndTime ( ) ,
taskInstance . getHost ( ) ,
DateUtils . format2Readable ( endTime . getTime ( ) - startTime . getTime ( ) ) , subProcessCode ) ) ;
}
}
for ( TreeViewDto pTreeViewDto : parentTreeViewDtoList ) {
@ -1755,7 +1830,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
long projectCode ,
String codes ,
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 ) {
return result ;
}
@ -1788,7 +1864,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
if ( projectCode ! = targetProjectCode ) {
Project targetProject = projectMapper . queryByCode ( targetProjectCode ) ;
// 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 ) {
return targetResult ;
}
@ -1802,16 +1879,21 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
String processDefinitionCodes ,
Map < String , Object > result ,
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 ) ;
Set < Long > queryCodes = processDefinitionList . stream ( ) . map ( ProcessDefinition : : getCode ) . collect ( Collectors . toSet ( ) ) ;
Set < Long > queryCodes =
processDefinitionList . stream ( ) . map ( ProcessDefinition : : getCode ) . collect ( Collectors . toSet ( ) ) ;
// 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]" ) ) ;
for ( ProcessDefinition processDefinition : processDefinitionList ) {
List < ProcessTaskRelation > processTaskRelations =
processTaskRelationMapper . queryByProcessCode ( processDefinition . getProjectCode ( ) , processDefinition . getCode ( ) ) ;
List < ProcessTaskRelationLog > taskRelationList = processTaskRelations . stream ( ) . map ( ProcessTaskRelationLog : : new ) . collect ( Collectors . toList ( ) ) ;
processTaskRelationMapper . queryByProcessCode ( processDefinition . getProjectCode ( ) ,
processDefinition . getCode ( ) ) ;
List < ProcessTaskRelationLog > taskRelationList =
processTaskRelations . stream ( ) . map ( ProcessTaskRelationLog : : new ) . collect ( Collectors . toList ( ) ) ;
processDefinition . setProjectCode ( targetProjectCode ) ;
String otherParamsJson = doOtherOperateProcess ( loginUser , processDefinition ) ;
if ( isCopy ) {
@ -1839,7 +1921,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
processTaskRelationLog . setPreTaskCode ( taskCodeMap . get ( processTaskRelationLog . getPreTaskCode ( ) ) ) ;
}
if ( processTaskRelationLog . getPostTaskCode ( ) > 0 ) {
processTaskRelationLog . setPostTaskCode ( taskCodeMap . get ( processTaskRelationLog . getPostTaskCode ( ) ) ) ;
processTaskRelationLog
. setPostTaskCode ( taskCodeMap . get ( processTaskRelationLog . getPostTaskCode ( ) ) ) ;
}
}
final long oldProcessDefinitionCode = processDefinition . getCode ( ) ;
@ -1879,14 +1962,16 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
}
try {
result . putAll ( createDagDefine ( loginUser , taskRelationList , processDefinition , taskDefinitionLogs , otherParamsJson ) ) ;
result . putAll ( createDagDefine ( loginUser , taskRelationList , processDefinition , taskDefinitionLogs ,
otherParamsJson ) ) ;
} catch ( Exception e ) {
putMsg ( result , Status . COPY_PROCESS_DEFINITION_ERROR ) ;
throw new ServiceException ( Status . COPY_PROCESS_DEFINITION_ERROR ) ;
}
} else {
try {
result . putAll ( updateDagDefine ( loginUser , taskRelationList , processDefinition , null , Lists . newArrayList ( ) , otherParamsJson ) ) ;
result . putAll ( updateDagDefine ( loginUser , taskRelationList , processDefinition , null ,
Lists . newArrayList ( ) , otherParamsJson ) ) ;
} catch ( Exception e ) {
putMsg ( result , 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
@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 ) ;
// 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 ) {
return result ;
}
@ -1945,9 +2032,11 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
return result ;
}
ProcessDefinitionLog processDefinitionLog = processDefinitionLogMapper . queryByDefinitionCodeAndVersion ( code , version ) ;
ProcessDefinitionLog processDefinitionLog =
processDefinitionLogMapper . queryByDefinitionCodeAndVersion ( code , version ) ;
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 ;
}
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 ) {
if ( ! failedProcessList . isEmpty ( ) ) {
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 {
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 {
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
* /
@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 ( ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// 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 ) ;
if ( resultStatus ! = Status . SUCCESS ) {
putMsg ( result , resultStatus ) ;
@ -2004,7 +2097,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
PageInfo < ProcessDefinitionLog > pageInfo = new PageInfo < > ( 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 ( ) ;
pageInfo . setTotalList ( processDefinitionLogs ) ;
@ -2014,7 +2108,6 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
return result ;
}
/ * *
* delete one certain process definition by version number and process definition code
*
@ -2026,10 +2119,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* /
@Override
@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 ) ;
// 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 ) {
return result ;
}
@ -2080,7 +2175,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
ProcessExecutionTypeEnum executionType ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
// 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 ) {
return result ;
}
@ -2111,7 +2207,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
putMsg ( result , Status . INTERNAL_SERVER_ERROR_ARGS ) ;
return result ;
}
ProcessDefinition processDefinition = new ProcessDefinition ( projectCode , name , processDefinitionCode , description ,
ProcessDefinition processDefinition =
new ProcessDefinition ( projectCode , name , processDefinitionCode , description ,
globalParams , "" , timeout , loginUser . getId ( ) , tenantId ) ;
processDefinition . setExecutionType ( executionType ) ;
result = createEmptyDagDefine ( loginUser , processDefinition ) ;
@ -2145,7 +2242,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
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 < > ( ) ;
Schedule scheduleObj = JSONUtils . parseObject ( scheduleJson , Schedule . class ) ;
if ( scheduleObj = = null ) {
@ -2164,16 +2262,20 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
putMsg ( result , Status . REQUEST_PARAMS_NOT_VALID_ERROR , scheduleObj . getCrontab ( ) ) ;
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 . setFailureStrategy ( scheduleObj . getFailureStrategy ( ) = = null ? FailureStrategy . CONTINUE : scheduleObj . getFailureStrategy ( ) ) ;
scheduleObj . setFailureStrategy (
scheduleObj . getFailureStrategy ( ) = = null ? FailureStrategy . CONTINUE : scheduleObj . getFailureStrategy ( ) ) ;
scheduleObj . setCreateTime ( now ) ;
scheduleObj . setUpdateTime ( now ) ;
scheduleObj . setUserId ( loginUser . getId ( ) ) ;
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 . setEnvironmentCode ( scheduleObj . getEnvironmentCode ( ) = = null ? - 1 : scheduleObj . getEnvironmentCode ( ) ) ;
scheduleObj
. setEnvironmentCode ( scheduleObj . getEnvironmentCode ( ) = = null ? - 1 : scheduleObj . getEnvironmentCode ( ) ) ;
scheduleMapper . insert ( scheduleObj ) ;
putMsg ( result , Status . SUCCESS ) ;
@ -2212,7 +2314,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
ProcessExecutionTypeEnum executionType ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
// 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 ) {
return result ;
}
@ -2249,11 +2352,14 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
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 . setExecutionType ( executionType ) ;
List < ProcessTaskRelationLog > taskRelationList = processTaskRelationLogMapper . queryByProcessCodeAndVersion ( processDefinition . getCode ( ) , processDefinition . getVersion ( ) ) ;
result = updateDagDefine ( loginUser , taskRelationList , processDefinition , processDefinitionDeepCopy , Lists . newArrayList ( ) , otherParamsJson ) ;
List < ProcessTaskRelationLog > taskRelationList = processTaskRelationLogMapper
. queryByProcessCodeAndVersion ( processDefinition . getCode ( ) , processDefinition . getVersion ( ) ) ;
result = updateDagDefine ( loginUser , taskRelationList , processDefinition , processDefinitionDeepCopy ,
Lists . newArrayList ( ) , otherParamsJson ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
}
@ -2282,9 +2388,11 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
throw new ServiceException ( Status . DATA_IS_NOT_VALID ) ;
}
// 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 ( ) ;
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 ( ) ;
String workerGroup = schedule . getWorkerGroup ( ) = = null ? "default" : schedule . getWorkerGroup ( ) ;
long environmentCode = schedule . getEnvironmentCode ( ) = = null ? - 1 : schedule . getEnvironmentCode ( ) ;
@ -2319,10 +2427,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* /
@Transactional
@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 ) ;
// 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 ) {
return result ;
}
@ -2344,7 +2454,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
switch ( releaseState ) {
case ONLINE :
List < ProcessTaskRelation > relationList = processService . findRelationByCode ( code , processDefinition . getVersion ( ) ) ;
List < ProcessTaskRelation > relationList =
processService . findRelationByCode ( code , processDefinition . getVersion ( ) ) ;
if ( CollectionUtils . isEmpty ( relationList ) ) {
putMsg ( result , Status . PROCESS_DAG_IS_EMPTY ) ;
return result ;
@ -2357,7 +2468,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
processDefinition . setReleaseState ( releaseState ) ;
int updateProcess = processDefinitionMapper . updateById ( processDefinition ) ;
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
scheduleObj . setReleaseState ( ReleaseState . OFFLINE ) ;
int updateSchedule = scheduleMapper . updateById ( scheduleObj ) ;
@ -2384,7 +2496,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @param otherParamsJson
* /
@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 ) {
}