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