|
|
@ -21,6 +21,7 @@ import org.apache.dolphinscheduler.api.enums.Status; |
|
|
|
import org.apache.dolphinscheduler.api.service.ProjectService; |
|
|
|
import org.apache.dolphinscheduler.api.service.ProjectService; |
|
|
|
import org.apache.dolphinscheduler.api.service.TaskDefinitionService; |
|
|
|
import org.apache.dolphinscheduler.api.service.TaskDefinitionService; |
|
|
|
import org.apache.dolphinscheduler.api.utils.CheckUtils; |
|
|
|
import org.apache.dolphinscheduler.api.utils.CheckUtils; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.api.utils.PageInfo; |
|
|
|
import org.apache.dolphinscheduler.api.utils.Result; |
|
|
|
import org.apache.dolphinscheduler.api.utils.Result; |
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
|
|
|
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
|
|
@ -36,6 +37,7 @@ import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.UserMapper; |
|
|
|
import org.apache.dolphinscheduler.service.process.ProcessService; |
|
|
|
import org.apache.dolphinscheduler.service.process.ProcessService; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
@ -52,6 +54,9 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* task definition service impl |
|
|
|
* task definition service impl |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -78,6 +83,9 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private ProcessService processService; |
|
|
|
private ProcessService processService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private UserMapper userMapper; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* create task definition |
|
|
|
* create task definition |
|
|
|
* |
|
|
|
* |
|
|
@ -159,7 +167,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe |
|
|
|
totalSuccessNumber++; |
|
|
|
totalSuccessNumber++; |
|
|
|
} |
|
|
|
} |
|
|
|
for (TaskDefinitionLog taskDefinitionToUpdate : updateTaskDefinitionLogs) { |
|
|
|
for (TaskDefinitionLog taskDefinitionToUpdate : updateTaskDefinitionLogs) { |
|
|
|
TaskDefinition task = taskDefinitionMapper.queryByDefinitionCode(taskDefinitionToUpdate.getCode()); |
|
|
|
TaskDefinition task = taskDefinitionMapper.queryByCode(taskDefinitionToUpdate.getCode()); |
|
|
|
if (task == null) { |
|
|
|
if (task == null) { |
|
|
|
newTaskDefinitionLogs.add(taskDefinitionToUpdate); |
|
|
|
newTaskDefinitionLogs.add(taskDefinitionToUpdate); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -203,7 +211,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TaskDefinition taskDefinition = taskDefinitionMapper.queryByDefinitionName(project.getCode(), taskName); |
|
|
|
TaskDefinition taskDefinition = taskDefinitionMapper.queryByName(project.getCode(), taskName); |
|
|
|
if (taskDefinition == null) { |
|
|
|
if (taskDefinition == null) { |
|
|
|
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskName); |
|
|
|
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskName); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -268,7 +276,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_STATE_ONLINE); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_STATE_ONLINE); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
TaskDefinition taskDefinition = taskDefinitionMapper.queryByDefinitionCode(taskCode); |
|
|
|
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode); |
|
|
|
if (taskDefinition == null) { |
|
|
|
if (taskDefinition == null) { |
|
|
|
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCode); |
|
|
|
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCode); |
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -332,7 +340,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_STATE_ONLINE); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_STATE_ONLINE); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
TaskDefinition taskDefinition = taskDefinitionMapper.queryByDefinitionCode(taskCode); |
|
|
|
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode); |
|
|
|
if (taskDefinition == null) { |
|
|
|
if (taskDefinition == null) { |
|
|
|
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCode); |
|
|
|
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCode); |
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -340,46 +348,123 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe |
|
|
|
TaskDefinitionLog taskDefinitionLog = taskDefinitionLogMapper.queryByDefinitionCodeAndVersion(taskCode, version); |
|
|
|
TaskDefinitionLog taskDefinitionLog = taskDefinitionLogMapper.queryByDefinitionCodeAndVersion(taskCode, version); |
|
|
|
taskDefinitionLog.setUserId(loginUser.getId()); |
|
|
|
taskDefinitionLog.setUserId(loginUser.getId()); |
|
|
|
taskDefinitionLog.setUpdateTime(new Date()); |
|
|
|
taskDefinitionLog.setUpdateTime(new Date()); |
|
|
|
taskDefinitionMapper.updateById(taskDefinitionLog); |
|
|
|
int switchVersion = taskDefinitionMapper.updateById(taskDefinitionLog); |
|
|
|
|
|
|
|
if (switchVersion > 0) { |
|
|
|
result.put(Constants.DATA_LIST, taskCode); |
|
|
|
result.put(Constants.DATA_LIST, taskCode); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
putMsg(result, Status.SWITCH_TASK_DEFINITION_VERSION_ERROR); |
|
|
|
|
|
|
|
} |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Map<String, Object> queryTaskDefinitionVersions(User loginUser, long projectCode, int pageNo, int pageSize, long taskCode) { |
|
|
|
public Result queryTaskDefinitionVersions(User loginUser, |
|
|
|
return null; |
|
|
|
long projectCode, |
|
|
|
|
|
|
|
long taskCode, |
|
|
|
|
|
|
|
int pageNo, |
|
|
|
|
|
|
|
int pageSize) { |
|
|
|
|
|
|
|
Result result = new Result(); |
|
|
|
|
|
|
|
Project project = projectMapper.queryByCode(projectCode); |
|
|
|
|
|
|
|
// check user access for project
|
|
|
|
|
|
|
|
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectCode); |
|
|
|
|
|
|
|
Status resultStatus = (Status) checkResult.get(Constants.STATUS); |
|
|
|
|
|
|
|
if (resultStatus != Status.SUCCESS) { |
|
|
|
|
|
|
|
putMsg(result, resultStatus); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
PageInfo<TaskDefinitionLog> pageInfo = new PageInfo<>(pageNo, pageSize); |
|
|
|
|
|
|
|
Page<TaskDefinitionLog> page = new Page<>(pageNo, pageSize); |
|
|
|
|
|
|
|
IPage<TaskDefinitionLog> taskDefinitionVersionsPaging = taskDefinitionLogMapper.queryTaskDefinitionVersionsPaging(page, taskCode); |
|
|
|
|
|
|
|
List<TaskDefinitionLog> taskDefinitionLogs = taskDefinitionVersionsPaging.getRecords(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pageInfo.setTotalList(taskDefinitionLogs); |
|
|
|
|
|
|
|
pageInfo.setTotal((int) taskDefinitionVersionsPaging.getTotal()); |
|
|
|
|
|
|
|
result.setData(pageInfo); |
|
|
|
|
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Map<String, Object> deleteByCodeAndVersion(User loginUser, long projectCode, long taskCode, int version) { |
|
|
|
public Map<String, Object> deleteByCodeAndVersion(User loginUser, long projectCode, long taskCode, int version) { |
|
|
|
return null; |
|
|
|
Project project = projectMapper.queryByCode(projectCode); |
|
|
|
|
|
|
|
//check user access for project
|
|
|
|
|
|
|
|
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); |
|
|
|
|
|
|
|
if (result.get(Constants.STATUS) != Status.SUCCESS) { |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (taskDefinition == null) { |
|
|
|
|
|
|
|
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCode); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
int delete = taskDefinitionLogMapper.deleteByCodeAndVersion(taskCode, version); |
|
|
|
|
|
|
|
if (delete > 0) { |
|
|
|
|
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
putMsg(result, Status.DELETE_TASK_DEFINITION_VERSION_ERROR); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Map<String, Object> queryTaskDefinitionDetail(User loginUser, long projectCode, long taskCode) { |
|
|
|
public Map<String, Object> queryTaskDefinitionDetail(User loginUser, long projectCode, long taskCode) { |
|
|
|
return null; |
|
|
|
Project project = projectMapper.queryByCode(projectCode); |
|
|
|
|
|
|
|
//check user access for project
|
|
|
|
|
|
|
|
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); |
|
|
|
|
|
|
|
if (result.get(Constants.STATUS) != Status.SUCCESS) { |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode); |
|
|
|
public Result queryTaskDefinitionListPaging(User loginUser, |
|
|
|
if (taskDefinition == null) { |
|
|
|
long projectCode, |
|
|
|
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCode); |
|
|
|
String searchVal, |
|
|
|
} else { |
|
|
|
Integer userId, |
|
|
|
result.put(Constants.DATA_LIST, taskDefinition); |
|
|
|
Integer pageNo, |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
Integer pageSize) { |
|
|
|
} |
|
|
|
return null; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Result queryTaskDefinitionByTaskType(User loginUser, |
|
|
|
public Result queryTaskDefinitionListPaging(User loginUser, |
|
|
|
long projectCode, |
|
|
|
long projectCode, |
|
|
|
String taskType, |
|
|
|
String taskType, |
|
|
|
String searchVal, |
|
|
|
String searchVal, |
|
|
|
Integer userId, |
|
|
|
Integer userId, |
|
|
|
Integer pageNo, |
|
|
|
Integer pageNo, |
|
|
|
Integer pageSize) { |
|
|
|
Integer pageSize) { |
|
|
|
return null; |
|
|
|
Result result = new Result(); |
|
|
|
|
|
|
|
Project project = projectMapper.queryByCode(projectCode); |
|
|
|
|
|
|
|
//check user access for project
|
|
|
|
|
|
|
|
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectCode); |
|
|
|
|
|
|
|
Status resultStatus = (Status) checkResult.get(Constants.STATUS); |
|
|
|
|
|
|
|
if (resultStatus != Status.SUCCESS) { |
|
|
|
|
|
|
|
putMsg(result, resultStatus); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(taskType)) { |
|
|
|
|
|
|
|
taskType = taskType.toUpperCase(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Page<TaskDefinition> page = new Page<>(pageNo, pageSize); |
|
|
|
|
|
|
|
IPage<TaskDefinition> taskDefinitionIPage = taskDefinitionMapper.queryDefineListPaging( |
|
|
|
|
|
|
|
page, projectCode, taskType, searchVal, userId, isAdmin(loginUser)); |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(taskType)) { |
|
|
|
|
|
|
|
List<TaskDefinition> records = taskDefinitionIPage.getRecords(); |
|
|
|
|
|
|
|
for (TaskDefinition pd : records) { |
|
|
|
|
|
|
|
TaskDefinitionLog taskDefinitionLog = taskDefinitionLogMapper.queryByDefinitionCodeAndVersion(pd.getCode(), pd.getVersion()); |
|
|
|
|
|
|
|
User user = userMapper.selectById(taskDefinitionLog.getOperator()); |
|
|
|
|
|
|
|
pd.setModifyBy(user.getUserName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
taskDefinitionIPage.setRecords(records); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
PageInfo<TaskDefinition> pageInfo = new PageInfo<>(pageNo, pageSize); |
|
|
|
|
|
|
|
pageInfo.setTotal((int) taskDefinitionIPage.getTotal()); |
|
|
|
|
|
|
|
pageInfo.setTotalList(taskDefinitionIPage.getRecords()); |
|
|
|
|
|
|
|
result.setData(pageInfo); |
|
|
|
|
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -405,4 +490,3 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|