|
|
@ -25,7 +25,6 @@ import org.apache.dolphinscheduler.api.dto.treeview.TreeViewDto; |
|
|
|
import org.apache.dolphinscheduler.api.enums.Status; |
|
|
|
import org.apache.dolphinscheduler.api.enums.Status; |
|
|
|
import org.apache.dolphinscheduler.api.service.BaseService; |
|
|
|
import org.apache.dolphinscheduler.api.service.BaseService; |
|
|
|
import org.apache.dolphinscheduler.api.service.ProcessDefinitionService; |
|
|
|
import org.apache.dolphinscheduler.api.service.ProcessDefinitionService; |
|
|
|
import org.apache.dolphinscheduler.api.service.ProcessDefinitionVersionService; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.api.service.ProcessInstanceService; |
|
|
|
import org.apache.dolphinscheduler.api.service.ProcessInstanceService; |
|
|
|
import org.apache.dolphinscheduler.api.service.ProcessTaskRelationService; |
|
|
|
import org.apache.dolphinscheduler.api.service.ProcessTaskRelationService; |
|
|
|
import org.apache.dolphinscheduler.api.service.ProjectService; |
|
|
|
import org.apache.dolphinscheduler.api.service.ProjectService; |
|
|
@ -64,10 +63,10 @@ import org.apache.dolphinscheduler.common.utils.TaskParametersUtils; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessData; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessData; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionVersion; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Project; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Project; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Schedule; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Schedule; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskDefinition; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.User; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.User; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionLogMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionLogMapper; |
|
|
@ -135,9 +134,6 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private ProjectService projectService; |
|
|
|
private ProjectService projectService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private ProcessDefinitionVersionService processDefinitionVersionService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private TaskDefinitionService taskDefinitionService; |
|
|
|
private TaskDefinitionService taskDefinitionService; |
|
|
|
|
|
|
|
|
|
|
@ -148,7 +144,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
private ProcessDefinitionLogMapper processDefinitionLogMapper; |
|
|
|
private ProcessDefinitionLogMapper processDefinitionLogMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private ProcessDefinitionMapper processDefineMapper; |
|
|
|
private ProcessDefinitionMapper processDefinitionMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private ProcessInstanceService processInstanceService; |
|
|
|
private ProcessInstanceService processInstanceService; |
|
|
@ -212,6 +208,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
processDefinition.setName(name); |
|
|
|
processDefinition.setName(name); |
|
|
|
|
|
|
|
processDefinition.setVersion(1); |
|
|
|
processDefinition.setReleaseState(ReleaseState.OFFLINE); |
|
|
|
processDefinition.setReleaseState(ReleaseState.OFFLINE); |
|
|
|
processDefinition.setUserId(loginUser.getId()); |
|
|
|
processDefinition.setUserId(loginUser.getId()); |
|
|
|
processDefinition.setDescription(desc); |
|
|
|
processDefinition.setDescription(desc); |
|
|
@ -220,7 +217,6 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
processDefinition.setTimeout(processData.getTimeout()); |
|
|
|
processDefinition.setTimeout(processData.getTimeout()); |
|
|
|
processDefinition.setTenantId(processData.getTenantId()); |
|
|
|
processDefinition.setTenantId(processData.getTenantId()); |
|
|
|
processDefinition.setModifyBy(loginUser.getUserName()); |
|
|
|
processDefinition.setModifyBy(loginUser.getUserName()); |
|
|
|
processDefinition.setResourceIds(getResourceIds(processData)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//custom global params
|
|
|
|
//custom global params
|
|
|
|
List<Property> globalParamsList = processData.getGlobalParams(); |
|
|
|
List<Property> globalParamsList = processData.getGlobalParams(); |
|
|
@ -234,7 +230,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
processDefinition.setFlag(Flag.YES); |
|
|
|
processDefinition.setFlag(Flag.YES); |
|
|
|
|
|
|
|
|
|
|
|
// save the new process definition
|
|
|
|
// save the new process definition
|
|
|
|
processDefineMapper.insert(processDefinition); |
|
|
|
processDefinitionMapper.insert(processDefinition); |
|
|
|
|
|
|
|
|
|
|
|
// parse and save the taskDefinition and processTaskRelation
|
|
|
|
// parse and save the taskDefinition and processTaskRelation
|
|
|
|
try { |
|
|
|
try { |
|
|
@ -273,11 +269,6 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
processDefinitionLog.setOperateTime(now); |
|
|
|
processDefinitionLog.setOperateTime(now); |
|
|
|
processDefinitionLogMapper.insert(processDefinitionLog); |
|
|
|
processDefinitionLogMapper.insert(processDefinitionLog); |
|
|
|
|
|
|
|
|
|
|
|
// add process definition version
|
|
|
|
|
|
|
|
long version = processDefinitionVersionService.addProcessDefinitionVersion(processDefinition); |
|
|
|
|
|
|
|
processDefinition.setVersion(version); |
|
|
|
|
|
|
|
processDefineMapper.updateVersionByProcessDefinitionId(processDefinition.getId(), version); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return processDefinition object with ID
|
|
|
|
// return processDefinition object with ID
|
|
|
|
result.put(Constants.DATA_LIST, processDefinition.getId()); |
|
|
|
result.put(Constants.DATA_LIST, processDefinition.getId()); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
@ -341,7 +332,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
return checkResult; |
|
|
|
return checkResult; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<ProcessDefinition> resourceList = processDefineMapper.queryAllDefinitionList(project.getId()); |
|
|
|
List<ProcessDefinition> resourceList = processDefinitionMapper.queryAllDefinitionList(project.getId()); |
|
|
|
result.put(Constants.DATA_LIST, resourceList); |
|
|
|
result.put(Constants.DATA_LIST, resourceList); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
|
|
|
|
|
|
@ -372,7 +363,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Page<ProcessDefinition> page = new Page<>(pageNo, pageSize); |
|
|
|
Page<ProcessDefinition> page = new Page<>(pageNo, pageSize); |
|
|
|
IPage<ProcessDefinition> processDefinitionIPage = processDefineMapper.queryDefineListPaging( |
|
|
|
IPage<ProcessDefinition> processDefinitionIPage = processDefinitionMapper.queryDefineListPaging( |
|
|
|
page, searchVal, userId, project.getId(), isAdmin(loginUser)); |
|
|
|
page, searchVal, userId, project.getId(), isAdmin(loginUser)); |
|
|
|
|
|
|
|
|
|
|
|
PageInfo<ProcessDefinition> pageInfo = new PageInfo<>(pageNo, pageSize); |
|
|
|
PageInfo<ProcessDefinition> pageInfo = new PageInfo<>(pageNo, pageSize); |
|
|
@ -404,7 +395,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
return checkResult; |
|
|
|
return checkResult; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processDefineMapper.selectById(processId); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.selectById(processId); |
|
|
|
if (processDefinition == null) { |
|
|
|
if (processDefinition == null) { |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processId); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processId); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -426,7 +417,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
return checkResult; |
|
|
|
return checkResult; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processDefineMapper.queryByDefineName(project.getId(), processDefinitionName); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(project.getId(), processDefinitionName); |
|
|
|
if (processDefinition == null) { |
|
|
|
if (processDefinition == null) { |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processDefinitionName); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processDefinitionName); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -472,43 +463,55 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
if ((checkProcessJson.get(Constants.STATUS) != Status.SUCCESS)) { |
|
|
|
if ((checkProcessJson.get(Constants.STATUS) != Status.SUCCESS)) { |
|
|
|
return checkProcessJson; |
|
|
|
return checkProcessJson; |
|
|
|
} |
|
|
|
} |
|
|
|
ProcessDefinition processDefine = processService.findProcessDefineById(id); |
|
|
|
// TODO processDefinitionMapper.queryByCode
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processService.findProcessDefineById(id); |
|
|
|
// check process definition exists
|
|
|
|
// check process definition exists
|
|
|
|
if (processDefine == null) { |
|
|
|
if (processDefinition == null) { |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, id); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, id); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
if (processDefine.getReleaseState() == ReleaseState.ONLINE) { |
|
|
|
if (processDefinition.getReleaseState() == ReleaseState.ONLINE) { |
|
|
|
// online can not permit edit
|
|
|
|
// online can not permit edit
|
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_ALLOWED_EDIT, processDefine.getName()); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_ALLOWED_EDIT, processDefinition.getName()); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!name.equals(processDefine.getName())) { |
|
|
|
if (!name.equals(processDefinition.getName())) { |
|
|
|
// check whether the new process define name exist
|
|
|
|
// check whether the new process define name exist
|
|
|
|
ProcessDefinition definition = processDefineMapper.verifyByDefineName(project.getId(), name); |
|
|
|
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(project.getId(), name); |
|
|
|
if (definition != null) { |
|
|
|
if (definition != null) { |
|
|
|
putMsg(result, Status.VERIFY_PROCESS_DEFINITION_NAME_UNIQUE_ERROR, name); |
|
|
|
putMsg(result, Status.VERIFY_PROCESS_DEFINITION_NAME_UNIQUE_ERROR, name); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// get the processdefinitionjson before saving,and then save the name and taskid
|
|
|
|
// get the processdefinitionjson before saving,and then save the name and taskid
|
|
|
|
String oldJson = processDefine.getProcessDefinitionJson(); |
|
|
|
String oldJson = processDefinition.getProcessDefinitionJson(); |
|
|
|
processDefinitionJson = processService.changeJson(processData,oldJson); |
|
|
|
processDefinitionJson = processService.changeJson(processData, oldJson); |
|
|
|
Date now = new Date(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
processDefine.setId(id); |
|
|
|
// update TaskDefinition
|
|
|
|
processDefine.setName(name); |
|
|
|
ProcessData newProcessData = JSONUtils.parseObject(processDefinitionJson, ProcessData.class); |
|
|
|
processDefine.setReleaseState(ReleaseState.OFFLINE); |
|
|
|
List<TaskNode> taskNodeList = (newProcessData.getTasks() == null) ? new ArrayList<>() : newProcessData.getTasks(); |
|
|
|
processDefine.setProjectId(project.getId()); |
|
|
|
|
|
|
|
processDefine.setProcessDefinitionJson(processDefinitionJson); |
|
|
|
for (TaskNode task : taskNodeList) { |
|
|
|
processDefine.setDescription(desc); |
|
|
|
// TODO update by code directly
|
|
|
|
processDefine.setLocations(locations); |
|
|
|
Map<String, Object> stringObjectMap = taskDefinitionService.queryTaskDefinitionByName(loginUser, projectName, task.getName()); |
|
|
|
processDefine.setConnects(connects); |
|
|
|
TaskDefinition taskDefinition = (TaskDefinition) stringObjectMap.get(Constants.DATA_LIST); |
|
|
|
processDefine.setTimeout(processData.getTimeout()); |
|
|
|
taskDefinitionService.updateTaskDefinition(loginUser, projectName, taskDefinition.getCode(), JSONUtils.toJsonString(task)); |
|
|
|
processDefine.setTenantId(processData.getTenantId()); |
|
|
|
} |
|
|
|
processDefine.setModifyBy(loginUser.getUserName()); |
|
|
|
|
|
|
|
processDefine.setResourceIds(getResourceIds(processData)); |
|
|
|
List<ProcessDefinitionLog> processDefinitionLogs = processDefinitionLogMapper.queryByDefinitionCode(processDefinition.getCode()); |
|
|
|
|
|
|
|
int version = getNextVersion(processDefinitionLogs); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date now = new Date(); |
|
|
|
|
|
|
|
processDefinition.setVersion(version); |
|
|
|
|
|
|
|
processDefinition.setName(name); |
|
|
|
|
|
|
|
processDefinition.setReleaseState(ReleaseState.OFFLINE); |
|
|
|
|
|
|
|
processDefinition.setProjectCode(project.getCode()); |
|
|
|
|
|
|
|
processDefinition.setDescription(desc); |
|
|
|
|
|
|
|
processDefinition.setLocations(locations); |
|
|
|
|
|
|
|
processDefinition.setConnects(connects); |
|
|
|
|
|
|
|
processDefinition.setTimeout(processData.getTimeout()); |
|
|
|
|
|
|
|
processDefinition.setTenantId(processData.getTenantId()); |
|
|
|
|
|
|
|
|
|
|
|
//custom global params
|
|
|
|
//custom global params
|
|
|
|
List<Property> globalParamsList = new ArrayList<>(); |
|
|
|
List<Property> globalParamsList = new ArrayList<>(); |
|
|
@ -516,23 +519,39 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
Set<Property> userDefParamsSet = new HashSet<>(processData.getGlobalParams()); |
|
|
|
Set<Property> userDefParamsSet = new HashSet<>(processData.getGlobalParams()); |
|
|
|
globalParamsList = new ArrayList<>(userDefParamsSet); |
|
|
|
globalParamsList = new ArrayList<>(userDefParamsSet); |
|
|
|
} |
|
|
|
} |
|
|
|
processDefine.setGlobalParamList(globalParamsList); |
|
|
|
processDefinition.setGlobalParamList(globalParamsList); |
|
|
|
processDefine.setUpdateTime(now); |
|
|
|
processDefinition.setUpdateTime(now); |
|
|
|
processDefine.setFlag(Flag.YES); |
|
|
|
processDefinition.setFlag(Flag.YES); |
|
|
|
|
|
|
|
|
|
|
|
// add process definition version
|
|
|
|
|
|
|
|
long version = processDefinitionVersionService.addProcessDefinitionVersion(processDefine); |
|
|
|
|
|
|
|
processDefine.setVersion(version); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (processDefineMapper.updateById(processDefine) > 0) { |
|
|
|
processDefinition.setVersion(version); |
|
|
|
|
|
|
|
int update = processDefinitionMapper.updateById(processDefinition); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// save processDefinitionLog
|
|
|
|
|
|
|
|
ProcessDefinitionLog processDefinitionLog = JSONUtils.parseObject( |
|
|
|
|
|
|
|
JSONUtils.toJsonString(processDefinition), ProcessDefinitionLog.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
processDefinitionLog.setOperator(loginUser.getId()); |
|
|
|
|
|
|
|
processDefinitionLog.setOperateTime(now); |
|
|
|
|
|
|
|
int insert = processDefinitionLogMapper.insert(processDefinitionLog); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (update > 0 && insert > 0) { |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
result.put(Constants.DATA_LIST, processDefineMapper.queryByDefineId(id)); |
|
|
|
result.put(Constants.DATA_LIST, processDefinition); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
putMsg(result, Status.UPDATE_PROCESS_DEFINITION_ERROR); |
|
|
|
putMsg(result, Status.UPDATE_PROCESS_DEFINITION_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int getNextVersion(List<ProcessDefinitionLog> processDefinitionLogs) { |
|
|
|
|
|
|
|
return processDefinitionLogs |
|
|
|
|
|
|
|
.stream() |
|
|
|
|
|
|
|
.map(ProcessDefinitionLog::getVersion) |
|
|
|
|
|
|
|
.max((x, y) -> x > y ? x : y) |
|
|
|
|
|
|
|
.orElse(0) + 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* verify process definition name unique |
|
|
|
* verify process definition name unique |
|
|
|
* |
|
|
|
* |
|
|
@ -552,7 +571,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
if (resultEnum != Status.SUCCESS) { |
|
|
|
if (resultEnum != Status.SUCCESS) { |
|
|
|
return checkResult; |
|
|
|
return checkResult; |
|
|
|
} |
|
|
|
} |
|
|
|
ProcessDefinition processDefinition = processDefineMapper.verifyByDefineName(project.getId(), name); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.verifyByDefineName(project.getId(), name); |
|
|
|
if (processDefinition == null) { |
|
|
|
if (processDefinition == null) { |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -582,7 +601,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
return checkResult; |
|
|
|
return checkResult; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processDefineMapper.selectById(processDefinitionId); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.selectById(processDefinitionId); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: replace id to code
|
|
|
|
// TODO: replace id to code
|
|
|
|
// ProcessDefinition processDefinition = processDefineMapper.selectByCode(processDefinitionCode);
|
|
|
|
// ProcessDefinition processDefinition = processDefineMapper.selectByCode(processDefinitionCode);
|
|
|
@ -628,7 +647,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
|
|
|
|
|
|
|
|
// TODO: replace id to code
|
|
|
|
// TODO: replace id to code
|
|
|
|
// ProcessDefinition processDefinition = processDefineMapper.deleteByCode(processDefinitionCode);
|
|
|
|
// ProcessDefinition processDefinition = processDefineMapper.deleteByCode(processDefinitionCode);
|
|
|
|
int delete = processDefineMapper.deleteById(processDefinitionId); |
|
|
|
int delete = processDefinitionMapper.deleteById(processDefinitionId); |
|
|
|
|
|
|
|
|
|
|
|
if (delete > 0) { |
|
|
|
if (delete > 0) { |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
@ -665,7 +684,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processDefineMapper.selectById(id); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.selectById(id); |
|
|
|
|
|
|
|
|
|
|
|
switch (releaseState) { |
|
|
|
switch (releaseState) { |
|
|
|
case ONLINE: |
|
|
|
case ONLINE: |
|
|
@ -684,11 +703,11 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
processDefinition.setReleaseState(releaseState); |
|
|
|
processDefinition.setReleaseState(releaseState); |
|
|
|
processDefineMapper.updateById(processDefinition); |
|
|
|
processDefinitionMapper.updateById(processDefinition); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case OFFLINE: |
|
|
|
case OFFLINE: |
|
|
|
processDefinition.setReleaseState(releaseState); |
|
|
|
processDefinition.setReleaseState(releaseState); |
|
|
|
processDefineMapper.updateById(processDefinition); |
|
|
|
processDefinitionMapper.updateById(processDefinition); |
|
|
|
List<Schedule> scheduleList = scheduleMapper.selectAllByProcessDefineArray( |
|
|
|
List<Schedule> scheduleList = scheduleMapper.selectAllByProcessDefineArray( |
|
|
|
new int[]{processDefinition.getId()} |
|
|
|
new int[]{processDefinition.getId()} |
|
|
|
); |
|
|
|
); |
|
|
@ -748,7 +767,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
for (String strProcessDefinitionId : processDefinitionIdArray) { |
|
|
|
for (String strProcessDefinitionId : processDefinitionIdArray) { |
|
|
|
//get workflow info
|
|
|
|
//get workflow info
|
|
|
|
int processDefinitionId = Integer.parseInt(strProcessDefinitionId); |
|
|
|
int processDefinitionId = Integer.parseInt(strProcessDefinitionId); |
|
|
|
ProcessDefinition processDefinition = processDefineMapper.queryByDefineId(processDefinitionId); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineId(processDefinitionId); |
|
|
|
if (null != processDefinition) { |
|
|
|
if (null != processDefinition) { |
|
|
|
processDefinitionList.add(exportProcessMetaData(processDefinitionId, processDefinition)); |
|
|
|
processDefinitionList.add(exportProcessMetaData(processDefinitionId, processDefinition)); |
|
|
|
} |
|
|
|
} |
|
|
@ -1143,14 +1162,14 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
//get sub process info
|
|
|
|
//get sub process info
|
|
|
|
ObjectNode subParams = (ObjectNode) taskNode.path("params"); |
|
|
|
ObjectNode subParams = (ObjectNode) taskNode.path("params"); |
|
|
|
Integer subProcessId = subParams.path(PROCESSDEFINITIONID).asInt(); |
|
|
|
Integer subProcessId = subParams.path(PROCESSDEFINITIONID).asInt(); |
|
|
|
ProcessDefinition subProcess = processDefineMapper.queryByDefineId(subProcessId); |
|
|
|
ProcessDefinition subProcess = processDefinitionMapper.queryByDefineId(subProcessId); |
|
|
|
//check is sub process exist in db
|
|
|
|
//check is sub process exist in db
|
|
|
|
if (null == subProcess) { |
|
|
|
if (null == subProcess) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
String subProcessJson = subProcess.getProcessDefinitionJson(); |
|
|
|
String subProcessJson = subProcess.getProcessDefinitionJson(); |
|
|
|
//check current project has sub process
|
|
|
|
//check current project has sub process
|
|
|
|
ProcessDefinition currentProjectSubProcess = processDefineMapper.queryByDefineName(targetProject.getId(), subProcess.getName()); |
|
|
|
ProcessDefinition currentProjectSubProcess = processDefinitionMapper.queryByDefineName(targetProject.getId(), subProcess.getName()); |
|
|
|
|
|
|
|
|
|
|
|
if (null == currentProjectSubProcess) { |
|
|
|
if (null == currentProjectSubProcess) { |
|
|
|
ArrayNode subJsonArray = (ArrayNode) JSONUtils.parseObject(subProcess.getProcessDefinitionJson()).get(TASKS); |
|
|
|
ArrayNode subJsonArray = (ArrayNode) JSONUtils.parseObject(subProcess.getProcessDefinitionJson()).get(TASKS); |
|
|
@ -1194,12 +1213,12 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
processDefine.setUpdateTime(now); |
|
|
|
processDefine.setUpdateTime(now); |
|
|
|
processDefine.setFlag(subProcess.getFlag()); |
|
|
|
processDefine.setFlag(subProcess.getFlag()); |
|
|
|
processDefine.setWarningGroupId(subProcess.getWarningGroupId()); |
|
|
|
processDefine.setWarningGroupId(subProcess.getWarningGroupId()); |
|
|
|
processDefineMapper.insert(processDefine); |
|
|
|
processDefinitionMapper.insert(processDefine); |
|
|
|
|
|
|
|
|
|
|
|
logger.info("create sub process, project: {}, process name: {}", targetProject.getName(), processDefine.getName()); |
|
|
|
logger.info("create sub process, project: {}, process name: {}", targetProject.getName(), processDefine.getName()); |
|
|
|
|
|
|
|
|
|
|
|
//modify task node
|
|
|
|
//modify task node
|
|
|
|
ProcessDefinition newSubProcessDefine = processDefineMapper.queryByDefineName(processDefine.getProjectId(), processDefine.getName()); |
|
|
|
ProcessDefinition newSubProcessDefine = processDefinitionMapper.queryByDefineName(processDefine.getProjectId(), processDefine.getName()); |
|
|
|
|
|
|
|
|
|
|
|
if (null != newSubProcessDefine) { |
|
|
|
if (null != newSubProcessDefine) { |
|
|
|
subProcessIdMap.put(subProcessId, newSubProcessDefine.getId()); |
|
|
|
subProcessIdMap.put(subProcessId, newSubProcessDefine.getId()); |
|
|
@ -1273,7 +1292,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
public Map<String, Object> getTaskNodeListByDefinitionId(Integer defineId) { |
|
|
|
public Map<String, Object> getTaskNodeListByDefinitionId(Integer defineId) { |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processDefineMapper.selectById(defineId); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.selectById(defineId); |
|
|
|
if (processDefinition == null) { |
|
|
|
if (processDefinition == null) { |
|
|
|
logger.info("process define not exists"); |
|
|
|
logger.info("process define not exists"); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, defineId); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, defineId); |
|
|
@ -1317,7 +1336,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
idIntList.add(Integer.parseInt(definitionId)); |
|
|
|
idIntList.add(Integer.parseInt(definitionId)); |
|
|
|
} |
|
|
|
} |
|
|
|
Integer[] idArray = idIntList.toArray(new Integer[0]); |
|
|
|
Integer[] idArray = idIntList.toArray(new Integer[0]); |
|
|
|
List<ProcessDefinition> processDefinitionList = processDefineMapper.queryDefinitionListByIdList(idArray); |
|
|
|
List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryDefinitionListByIdList(idArray); |
|
|
|
if (CollectionUtils.isEmpty(processDefinitionList)) { |
|
|
|
if (CollectionUtils.isEmpty(processDefinitionList)) { |
|
|
|
logger.info("process definition not exists"); |
|
|
|
logger.info("process definition not exists"); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, defineIdList); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, defineIdList); |
|
|
@ -1349,7 +1368,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> result = new HashMap<>(5); |
|
|
|
HashMap<String, Object> result = new HashMap<>(5); |
|
|
|
|
|
|
|
|
|
|
|
List<ProcessDefinition> resourceList = processDefineMapper.queryAllDefinitionList(projectId); |
|
|
|
List<ProcessDefinition> resourceList = processDefinitionMapper.queryAllDefinitionList(projectId); |
|
|
|
result.put(Constants.DATA_LIST, resourceList); |
|
|
|
result.put(Constants.DATA_LIST, resourceList); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
|
|
|
|
|
|
@ -1368,7 +1387,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
public Map<String, Object> viewTree(Integer processId, Integer limit) throws Exception { |
|
|
|
public Map<String, Object> viewTree(Integer processId, Integer limit) throws Exception { |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processDefineMapper.selectById(processId); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.selectById(processId); |
|
|
|
if (null == processDefinition) { |
|
|
|
if (null == processDefinition) { |
|
|
|
logger.info("process define not exists"); |
|
|
|
logger.info("process define not exists"); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processDefinition); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processDefinition); |
|
|
@ -1540,7 +1559,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String recursionProcessDefinitionName(Integer projectId, String processDefinitionName, int num) { |
|
|
|
private String recursionProcessDefinitionName(Integer projectId, String processDefinitionName, int num) { |
|
|
|
ProcessDefinition processDefinition = processDefineMapper.queryByDefineName(projectId, processDefinitionName); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(projectId, 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); |
|
|
@ -1560,7 +1579,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(5); |
|
|
|
Map<String, Object> result = new HashMap<>(5); |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processDefineMapper.selectById(processId); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.selectById(processId); |
|
|
|
if (processDefinition == null) { |
|
|
|
if (processDefinition == null) { |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processId); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processId); |
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -1695,7 +1714,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
return checkResult; |
|
|
|
return checkResult; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processDefineMapper.queryByDefineId(processDefinitionId); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineId(processDefinitionId); |
|
|
|
if (Objects.isNull(processDefinition)) { |
|
|
|
if (Objects.isNull(processDefinition)) { |
|
|
|
putMsg(result |
|
|
|
putMsg(result |
|
|
|
, Status.SWITCH_PROCESS_DEFINITION_VERSION_NOT_EXIST_PROCESS_DEFINITION_ERROR |
|
|
|
, Status.SWITCH_PROCESS_DEFINITION_VERSION_NOT_EXIST_PROCESS_DEFINITION_ERROR |
|
|
@ -1703,28 +1722,28 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinitionVersion processDefinitionVersion = processDefinitionVersionService |
|
|
|
ProcessDefinitionLog processDefinitionLog = processDefinitionLogMapper |
|
|
|
.queryByProcessDefinitionIdAndVersion(processDefinitionId, version); |
|
|
|
.queryByDefinitionCodeAndVersion(processDefinition.getCode(),version); |
|
|
|
if (Objects.isNull(processDefinitionVersion)) { |
|
|
|
|
|
|
|
|
|
|
|
if (Objects.isNull(processDefinitionLog)) { |
|
|
|
putMsg(result |
|
|
|
putMsg(result |
|
|
|
, Status.SWITCH_PROCESS_DEFINITION_VERSION_NOT_EXIST_PROCESS_DEFINITION_VERSION_ERROR |
|
|
|
, Status.SWITCH_PROCESS_DEFINITION_VERSION_NOT_EXIST_PROCESS_DEFINITION_VERSION_ERROR |
|
|
|
, processDefinitionId |
|
|
|
, processDefinition.getCode() |
|
|
|
, version); |
|
|
|
, version); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
processDefinition.setVersion(processDefinitionVersion.getVersion()); |
|
|
|
processDefinition.setVersion(processDefinitionLog.getVersion()); |
|
|
|
processDefinition.setProcessDefinitionJson(processDefinitionVersion.getProcessDefinitionJson()); |
|
|
|
processDefinition.setDescription(processDefinitionLog.getDescription()); |
|
|
|
processDefinition.setDescription(processDefinitionVersion.getDescription()); |
|
|
|
processDefinition.setLocations(processDefinitionLog.getLocations()); |
|
|
|
processDefinition.setLocations(processDefinitionVersion.getLocations()); |
|
|
|
processDefinition.setConnects(processDefinitionLog.getConnects()); |
|
|
|
processDefinition.setConnects(processDefinitionVersion.getConnects()); |
|
|
|
processDefinition.setTimeout(processDefinitionLog.getTimeout()); |
|
|
|
processDefinition.setTimeout(processDefinitionVersion.getTimeout()); |
|
|
|
processDefinition.setGlobalParams(processDefinitionLog.getGlobalParams()); |
|
|
|
processDefinition.setGlobalParams(processDefinitionVersion.getGlobalParams()); |
|
|
|
|
|
|
|
processDefinition.setUpdateTime(new Date()); |
|
|
|
processDefinition.setUpdateTime(new Date()); |
|
|
|
processDefinition.setWarningGroupId(processDefinitionVersion.getWarningGroupId()); |
|
|
|
processDefinition.setWarningGroupId(processDefinitionLog.getWarningGroupId()); |
|
|
|
processDefinition.setResourceIds(processDefinitionVersion.getResourceIds()); |
|
|
|
processDefinition.setResourceIds(processDefinitionLog.getResourceIds()); |
|
|
|
|
|
|
|
|
|
|
|
if (processDefineMapper.updateById(processDefinition) > 0) { |
|
|
|
if (processDefinitionMapper.updateById(processDefinition) > 0) { |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
putMsg(result, Status.SWITCH_PROCESS_DEFINITION_VERSION_ERROR); |
|
|
|
putMsg(result, Status.SWITCH_PROCESS_DEFINITION_VERSION_ERROR); |
|
|
@ -1784,7 +1803,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
* @param processDefinitionId processDefinitionId |
|
|
|
* @param processDefinitionId processDefinitionId |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void setFailedProcessList(List<String> failedProcessList, String processDefinitionId) { |
|
|
|
private void setFailedProcessList(List<String> failedProcessList, String processDefinitionId) { |
|
|
|
ProcessDefinition processDefinition = processDefineMapper.queryByDefineId(Integer.valueOf(processDefinitionId)); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineId(Integer.valueOf(processDefinitionId)); |
|
|
|
if (processDefinition != null) { |
|
|
|
if (processDefinition != null) { |
|
|
|
failedProcessList.add(processDefinitionId + "[" + processDefinition.getName() + "]"); |
|
|
|
failedProcessList.add(processDefinitionId + "[" + processDefinition.getName() + "]"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -1823,7 +1842,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processDefineMapper.selectById(processId); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.selectById(processId); |
|
|
|
if (processDefinition == null) { |
|
|
|
if (processDefinition == null) { |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processId); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processId); |
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -1831,7 +1850,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements |
|
|
|
|
|
|
|
|
|
|
|
processDefinition.setProjectId(targetProject.getId()); |
|
|
|
processDefinition.setProjectId(targetProject.getId()); |
|
|
|
processDefinition.setUpdateTime(new Date()); |
|
|
|
processDefinition.setUpdateTime(new Date()); |
|
|
|
if (processDefineMapper.updateById(processDefinition) > 0) { |
|
|
|
if (processDefinitionMapper.updateById(processDefinition) > 0) { |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
putMsg(result, Status.UPDATE_PROCESS_DEFINITION_ERROR); |
|
|
|
putMsg(result, Status.UPDATE_PROCESS_DEFINITION_ERROR); |
|
|
|