|
|
|
@ -20,12 +20,20 @@ package org.apache.dolphinscheduler.api.service.impl;
|
|
|
|
|
import org.apache.dolphinscheduler.api.enums.Status; |
|
|
|
|
import org.apache.dolphinscheduler.api.service.BaseService; |
|
|
|
|
import org.apache.dolphinscheduler.api.service.ProcessTaskRelationService; |
|
|
|
|
import org.apache.dolphinscheduler.api.service.ProjectService; |
|
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
|
import org.apache.dolphinscheduler.common.enums.ConditionType; |
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; |
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; |
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelationLog; |
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.Project; |
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskDefinition; |
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.User; |
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; |
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationLogMapper; |
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; |
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; |
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; |
|
|
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.HashMap; |
|
|
|
@ -46,8 +54,14 @@ public class ProcessTaskRelationServiceImpl extends BaseService implements
|
|
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ProcessTaskRelationServiceImpl.class); |
|
|
|
|
|
|
|
|
|
//@Autowired
|
|
|
|
|
//private ProjectMapper projectMapper;
|
|
|
|
|
@Autowired |
|
|
|
|
private ProjectMapper projectMapper; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private ProjectService projectService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private ProcessDefinitionMapper processDefineMapper; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private ProcessTaskRelationMapper processTaskRelationMapper; |
|
|
|
@ -55,12 +69,15 @@ public class ProcessTaskRelationServiceImpl extends BaseService implements
|
|
|
|
|
@Autowired |
|
|
|
|
private ProcessTaskRelationLogMapper processTaskRelationLogMapper; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private TaskDefinitionMapper taskDefinitionMapper; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* create process task relation |
|
|
|
|
* |
|
|
|
|
* @param loginUser login user |
|
|
|
|
* @param name relation name |
|
|
|
|
* @param projectCode process code |
|
|
|
|
* @param projectName process name |
|
|
|
|
* @param processDefinitionCode process definition code |
|
|
|
|
* @param preTaskCode pre task code |
|
|
|
|
* @param postTaskCode post task code |
|
|
|
@ -72,20 +89,39 @@ public class ProcessTaskRelationServiceImpl extends BaseService implements
|
|
|
|
|
@Override |
|
|
|
|
public Map<String, Object> createProcessTaskRelation(User loginUser, |
|
|
|
|
String name, |
|
|
|
|
Long projectCode, |
|
|
|
|
String projectName, |
|
|
|
|
Long processDefinitionCode, |
|
|
|
|
Long preTaskCode, |
|
|
|
|
Long postTaskCode, |
|
|
|
|
String conditionType, |
|
|
|
|
String conditionParams) { |
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
// TODO check projectCode
|
|
|
|
|
// TODO check processDefinitionCode
|
|
|
|
|
// TODO check preTaskCode and postTaskCode
|
|
|
|
|
Project project = projectMapper.queryByName(projectName); |
|
|
|
|
// check project auth
|
|
|
|
|
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName); |
|
|
|
|
Status resultStatus = (Status) checkResult.get(Constants.STATUS); |
|
|
|
|
if (resultStatus != Status.SUCCESS) { |
|
|
|
|
return checkResult; |
|
|
|
|
} |
|
|
|
|
// check processDefinitionCode
|
|
|
|
|
ProcessDefinition processDefinition = processDefineMapper.queryByCode(processDefinitionCode); |
|
|
|
|
if (processDefinition == null) { |
|
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processDefinitionCode); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
// check preTaskCode and postTaskCode
|
|
|
|
|
checkTaskDefinitionCode(result, preTaskCode); |
|
|
|
|
if (postTaskCode > 0) { |
|
|
|
|
checkTaskDefinitionCode(result, postTaskCode); |
|
|
|
|
} |
|
|
|
|
resultStatus = (Status) result.get(Constants.STATUS); |
|
|
|
|
if (resultStatus != Status.SUCCESS) { |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
Date now = new Date(); |
|
|
|
|
ProcessTaskRelation processTaskRelation = new ProcessTaskRelation(name, |
|
|
|
|
1, |
|
|
|
|
projectCode, |
|
|
|
|
project.getCode(), |
|
|
|
|
processDefinitionCode, |
|
|
|
|
preTaskCode, |
|
|
|
|
postTaskCode, |
|
|
|
@ -104,5 +140,11 @@ public class ProcessTaskRelationServiceImpl extends BaseService implements
|
|
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void checkTaskDefinitionCode(Map<String, Object> result, Long taskCode) { |
|
|
|
|
TaskDefinition taskDefinition = taskDefinitionMapper.queryByDefinitionCode(taskCode); |
|
|
|
|
if (taskDefinition == null) { |
|
|
|
|
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCode); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|