|
|
@ -112,6 +112,7 @@ import com.fasterxml.jackson.databind.JsonNode; |
|
|
|
import com.fasterxml.jackson.databind.node.ArrayNode; |
|
|
|
import com.fasterxml.jackson.databind.node.ArrayNode; |
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode; |
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode; |
|
|
|
import com.google.common.collect.ImmutableMap; |
|
|
|
import com.google.common.collect.ImmutableMap; |
|
|
|
|
|
|
|
import com.google.common.collect.Lists; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* process definition service impl |
|
|
|
* process definition service impl |
|
|
@ -203,6 +204,13 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check whether the new process define name exist
|
|
|
|
|
|
|
|
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(project.getCode(), name); |
|
|
|
|
|
|
|
if (definition != null) { |
|
|
|
|
|
|
|
putMsg(result, Status.PROCESS_DEFINITION_NAME_EXIST, name); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<ProcessTaskRelationLog> taskRelationList = JSONUtils.toList(taskRelationJson, ProcessTaskRelationLog.class); |
|
|
|
List<ProcessTaskRelationLog> taskRelationList = JSONUtils.toList(taskRelationJson, ProcessTaskRelationLog.class); |
|
|
|
Map<String, Object> checkRelationJson = checkTaskRelationList(taskRelationList, taskRelationJson); |
|
|
|
Map<String, Object> checkRelationJson = checkTaskRelationList(taskRelationList, taskRelationJson); |
|
|
|
if (checkRelationJson.get(Constants.STATUS) != Status.SUCCESS) { |
|
|
|
if (checkRelationJson.get(Constants.STATUS) != Status.SUCCESS) { |
|
|
@ -296,13 +304,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
List<ProcessDefinition> resourceList = processDefinitionMapper.queryAllDefinitionList(projectCode); |
|
|
|
List<ProcessDefinition> resourceList = processDefinitionMapper.queryAllDefinitionList(projectCode); |
|
|
|
|
|
|
|
List<DagData> dagDataList = resourceList.stream().map(processService::genDagData).collect(Collectors.toList()); |
|
|
|
resourceList.forEach(processDefinition -> { |
|
|
|
result.put(Constants.DATA_LIST, dagDataList); |
|
|
|
ProcessData processData = processService.genProcessData(processDefinition); |
|
|
|
|
|
|
|
processDefinition.setProcessDefinitionJson(JSONUtils.toJsonString(processData)); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.put(Constants.DATA_LIST, resourceList); |
|
|
|
|
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -458,6 +461,14 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_ALLOWED_EDIT, processDefinition.getName()); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_ALLOWED_EDIT, processDefinition.getName()); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!name.equals(processDefinition.getName())) { |
|
|
|
|
|
|
|
// check whether the new process define name exist
|
|
|
|
|
|
|
|
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(project.getCode(), name); |
|
|
|
|
|
|
|
if (definition != null) { |
|
|
|
|
|
|
|
putMsg(result, Status.PROCESS_DEFINITION_NAME_EXIST, name); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
processDefinition.set(projectCode, name, description, globalParams, locations, connects, timeout, tenant.getId()); |
|
|
|
processDefinition.set(projectCode, name, description, globalParams, locations, connects, timeout, tenant.getId()); |
|
|
|
return updateProcessDefine(loginUser, result, taskRelationList, processDefinition); |
|
|
|
return updateProcessDefine(loginUser, result, taskRelationList, processDefinition); |
|
|
@ -1174,63 +1185,59 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* get task node details based on process definition |
|
|
|
* get task node details based on process definition |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @param loginUser loginUser |
|
|
|
|
|
|
|
* @param projectCode project code |
|
|
|
* @param defineCode define code |
|
|
|
* @param defineCode define code |
|
|
|
* @return task node list |
|
|
|
* @return task node list |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Map<String, Object> getTaskNodeListByDefinitionCode(Long defineCode) { |
|
|
|
public Map<String, Object> getTaskNodeListByDefinitionCode(User loginUser, long projectCode, long defineCode) { |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Project project = projectMapper.queryByCode(projectCode); |
|
|
|
|
|
|
|
//check user access for project
|
|
|
|
|
|
|
|
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, project.getName()); |
|
|
|
|
|
|
|
if (result.get(Constants.STATUS) != Status.SUCCESS) { |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(defineCode); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(defineCode); |
|
|
|
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, defineCode); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, defineCode); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
ProcessData processData = processService.genProcessData(processDefinition); |
|
|
|
DagData dagData = processService.genDagData(processDefinition); |
|
|
|
|
|
|
|
result.put(Constants.DATA_LIST, dagData.getTaskDefinitionList()); |
|
|
|
//process data check
|
|
|
|
|
|
|
|
if (null == processData) { |
|
|
|
|
|
|
|
logger.error("process data is null"); |
|
|
|
|
|
|
|
putMsg(result, Status.DATA_IS_NOT_VALID, JSONUtils.toJsonString(processData)); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<TaskNode> taskNodeList = (processData.getTasks() == null) ? new ArrayList<>() : processData.getTasks(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.put(Constants.DATA_LIST, taskNodeList); |
|
|
|
|
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
return result; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* get task node details based on process definition |
|
|
|
* get task node details map based on process definition |
|
|
|
* |
|
|
|
* |
|
|
|
* @param defineCodeList define code list |
|
|
|
* @param loginUser loginUser |
|
|
|
|
|
|
|
* @param projectCode project code |
|
|
|
|
|
|
|
* @param defineCodes define codes |
|
|
|
* @return task node list |
|
|
|
* @return task node list |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Map<String, Object> getTaskNodeListByDefinitionCodeList(String defineCodeList) { |
|
|
|
public Map<String, Object> getNodeListMapByDefinitionCodes(User loginUser, long projectCode, String defineCodes) { |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Project project = projectMapper.queryByCode(projectCode); |
|
|
|
|
|
|
|
//check user access for project
|
|
|
|
Map<Integer, List<TaskNode>> taskNodeMap = new HashMap<>(); |
|
|
|
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, project.getName()); |
|
|
|
String[] codeArr = defineCodeList.split(","); |
|
|
|
if (result.get(Constants.STATUS) != Status.SUCCESS) { |
|
|
|
List<Long> codeList = new ArrayList<>(); |
|
|
|
return result; |
|
|
|
for (String definitionCode : codeArr) { |
|
|
|
|
|
|
|
codeList.add(Long.parseLong(definitionCode)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryByCodes(codeList); |
|
|
|
|
|
|
|
|
|
|
|
Set<Long> defineCodeSet = Lists.newArrayList(defineCodes.split(Constants.COMMA)).stream().map(Long::parseLong).collect(Collectors.toSet()); |
|
|
|
|
|
|
|
List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryByCodes(defineCodeSet); |
|
|
|
if (CollectionUtils.isEmpty(processDefinitionList)) { |
|
|
|
if (CollectionUtils.isEmpty(processDefinitionList)) { |
|
|
|
logger.info("process definition not exists"); |
|
|
|
logger.info("process definition not exists"); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, defineCodeList); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, defineCodes); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Map<Long, List<TaskDefinitionLog>> taskNodeMap = new HashMap<>(); |
|
|
|
for (ProcessDefinition processDefinition : processDefinitionList) { |
|
|
|
for (ProcessDefinition processDefinition : processDefinitionList) { |
|
|
|
ProcessData processData = processService.genProcessData(processDefinition); |
|
|
|
DagData dagData = processService.genDagData(processDefinition); |
|
|
|
List<TaskNode> taskNodeList = (processData.getTasks() == null) ? new ArrayList<>() : processData.getTasks(); |
|
|
|
taskNodeMap.put(processDefinition.getCode(), dagData.getTaskDefinitionList()); |
|
|
|
taskNodeMap.put(processDefinition.getId(), taskNodeList); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
result.put(Constants.DATA_LIST, taskNodeMap); |
|
|
|
result.put(Constants.DATA_LIST, taskNodeMap); |
|
|
@ -1635,10 +1642,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
|
|
|
|
|
|
|
|
// check the if pageNo or pageSize less than 1
|
|
|
|
// check the if pageNo or pageSize less than 1
|
|
|
|
if (pageNo <= 0 || pageSize <= 0) { |
|
|
|
if (pageNo <= 0 || pageSize <= 0) { |
|
|
|
putMsg(result |
|
|
|
putMsg(result, Status.QUERY_PROCESS_DEFINITION_VERSIONS_PAGE_NO_OR_PAGE_SIZE_LESS_THAN_1_ERROR, pageNo, pageSize); |
|
|
|
, Status.QUERY_PROCESS_DEFINITION_VERSIONS_PAGE_NO_OR_PAGE_SIZE_LESS_THAN_1_ERROR |
|
|
|
|
|
|
|
, pageNo |
|
|
|
|
|
|
|
, pageSize); |
|
|
|
|
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1656,8 +1660,6 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
IPage<ProcessDefinitionLog> processDefinitionVersionsPaging = processDefinitionLogMapper.queryProcessDefinitionVersionsPaging(page, processDefinition.getCode()); |
|
|
|
IPage<ProcessDefinitionLog> processDefinitionVersionsPaging = processDefinitionLogMapper.queryProcessDefinitionVersionsPaging(page, processDefinition.getCode()); |
|
|
|
List<ProcessDefinitionLog> processDefinitionLogs = processDefinitionVersionsPaging.getRecords(); |
|
|
|
List<ProcessDefinitionLog> processDefinitionLogs = processDefinitionVersionsPaging.getRecords(); |
|
|
|
|
|
|
|
|
|
|
|
ProcessData processData = processService.genProcessData(processDefinition); |
|
|
|
|
|
|
|
processDefinition.setProcessDefinitionJson(JSONUtils.toJsonString(processData)); |
|
|
|
|
|
|
|
pageInfo.setLists(processDefinitionLogs); |
|
|
|
pageInfo.setLists(processDefinitionLogs); |
|
|
|
pageInfo.setTotalCount((int) processDefinitionVersionsPaging.getTotal()); |
|
|
|
pageInfo.setTotalCount((int) processDefinitionVersionsPaging.getTotal()); |
|
|
|
return ImmutableMap.of( |
|
|
|
return ImmutableMap.of( |
|
|
|