mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-12-03 04:39:00 +08:00
* batch copy or move process * batch copy or move process * batch copy or move process * batch copy or move process * batch copy or move process * batch copy or move process * batch copy or move process * batch copy or move process sovle code smell * batch copy or move process sovle code smell * batch copy or move process sovle code smell * batch copy or move process sovle code smell * batch copy or move process sovle code smell * batch copy or move process sovle code smell * batch copy or move process sovle code smell * batch copy or move process sovle code smell * batch copy or move process * batch copy or move process * batch copy or move process * batch copy or move process * batch copy or move process * batch copy or move process * Roll back the package.json file * rerun test * revert blank * resolve conflicts * resolve conflicts * resolve ut error * resolve sonar error Co-authored-by: sunchaohe <sunzhaohe@linklogis.com> Co-authored-by: dailidong <dailidong66@gmail.com>
This commit is contained in:
parent
a7a1156ff1
commit
46ab86d6df
@ -95,27 +95,65 @@ public class ProcessDefinitionController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* copy process definition
|
||||
* copy process definition
|
||||
*
|
||||
* @param loginUser login user
|
||||
* @param projectName project name
|
||||
* @param processId process definition id
|
||||
* @param processDefinitionIds process definition ids
|
||||
* @param targetProjectId target project id
|
||||
* @return copy result code
|
||||
*/
|
||||
@ApiOperation(value = "copyProcessDefinition", notes= "COPY_PROCESS_DEFINITION_NOTES")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "processId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100")
|
||||
@ApiImplicitParam(name = "processDefinitionIds", value = "PROCESS_DEFINITION_IDS", required = true, dataType = "String", example = "3,4"),
|
||||
@ApiImplicitParam(name = "targetProjectId", value = "TARGET_PROJECT_ID", required = true, type = "Integer")
|
||||
})
|
||||
@PostMapping(value = "/copy")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@ApiException(COPY_PROCESS_DEFINITION_ERROR)
|
||||
@ApiException(BATCH_COPY_PROCESS_DEFINITION_ERROR)
|
||||
public Result copyProcessDefinition(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
|
||||
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName,
|
||||
@RequestParam(value = "processId", required = true) int processId) throws JsonProcessingException {
|
||||
logger.info("copy process definition, login user:{}, project name:{}, process definition id:{}",
|
||||
loginUser.getUserName(), projectName, processId);
|
||||
Map<String, Object> result = processDefinitionService.copyProcessDefinition(loginUser, projectName, processId);
|
||||
return returnDataList(result);
|
||||
@RequestParam(value = "processDefinitionIds", required = true) String processDefinitionIds,
|
||||
@RequestParam(value = "targetProjectId",required = true) int targetProjectId) {
|
||||
logger.info("batch copy process definition, login user:{}, project name:{}, process definition ids:{},target project id:{}",
|
||||
StringUtils.replaceNRTtoUnderline(loginUser.getUserName()),
|
||||
StringUtils.replaceNRTtoUnderline(projectName),
|
||||
StringUtils.replaceNRTtoUnderline(processDefinitionIds),
|
||||
StringUtils.replaceNRTtoUnderline(String.valueOf(targetProjectId)));
|
||||
|
||||
return returnDataList(
|
||||
processDefinitionService.batchCopyProcessDefinition(loginUser,projectName,processDefinitionIds,targetProjectId));
|
||||
}
|
||||
|
||||
/**
|
||||
* move process definition
|
||||
*
|
||||
* @param loginUser login user
|
||||
* @param projectName project name
|
||||
* @param processDefinitionIds process definition ids
|
||||
* @param targetProjectId target project id
|
||||
* @return move result code
|
||||
*/
|
||||
@ApiOperation(value = "moveProcessDefinition", notes= "MOVE_PROCESS_DEFINITION_NOTES")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "processDefinitionIds", value = "PROCESS_DEFINITION_IDS", required = true, dataType = "String", example = "3,4"),
|
||||
@ApiImplicitParam(name = "targetProjectId", value = "TARGET_PROJECT_ID", required = true, type = "Integer")
|
||||
})
|
||||
@PostMapping(value = "/move")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@ApiException(BATCH_MOVE_PROCESS_DEFINITION_ERROR)
|
||||
public Result moveProcessDefinition(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
|
||||
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName,
|
||||
@RequestParam(value = "processDefinitionIds", required = true) String processDefinitionIds,
|
||||
@RequestParam(value = "targetProjectId",required = true) int targetProjectId) {
|
||||
logger.info("batch move process definition, login user:{}, project name:{}, process definition ids:{},target project id:{}",
|
||||
StringUtils.replaceNRTtoUnderline(loginUser.getUserName()),
|
||||
StringUtils.replaceNRTtoUnderline(projectName),
|
||||
StringUtils.replaceNRTtoUnderline(processDefinitionIds),
|
||||
StringUtils.replaceNRTtoUnderline(String.valueOf(targetProjectId)));
|
||||
|
||||
return returnDataList(
|
||||
processDefinitionService.batchMoveProcessDefinition(loginUser,projectName,processDefinitionIds,targetProjectId));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -365,7 +403,7 @@ public class ProcessDefinitionController extends BaseController {
|
||||
public Result getNodeListByDefinitionIdList(
|
||||
@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
|
||||
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName,
|
||||
@RequestParam("processDefinitionIdList") String processDefinitionIdList) throws Exception {
|
||||
@RequestParam("processDefinitionIdList") String processDefinitionIdList) {
|
||||
|
||||
logger.info("query task node name list by definitionId list, login user:{}, project name:{}, id list: {}",
|
||||
loginUser.getUserName(), projectName, processDefinitionIdList);
|
||||
@ -420,7 +458,7 @@ public class ProcessDefinitionController extends BaseController {
|
||||
logger.info("delete process definition by ids, login user:{}, project name:{}, process definition ids:{}",
|
||||
loginUser.getUserName(), projectName, processDefinitionIds);
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
List<String> deleteFailedIdList = new ArrayList<>();
|
||||
if (StringUtils.isNotEmpty(processDefinitionIds)) {
|
||||
String[] processDefinitionIdArray = processDefinitionIds.split(",");
|
||||
|
@ -370,7 +370,7 @@ public class ProcessInstanceController extends BaseController {
|
||||
logger.info("delete process instance by ids, login user:{}, project name:{}, process instance ids :{}",
|
||||
loginUser.getUserName(), projectName, processInstanceIds);
|
||||
// task queue
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
List<String> deleteFailedIdList = new ArrayList<>();
|
||||
if (StringUtils.isNotEmpty(processInstanceIds)) {
|
||||
String[] processInstanceIdArray = processInstanceIds.split(",");
|
||||
|
@ -23,6 +23,7 @@ import org.apache.dolphinscheduler.api.service.ProjectService;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@ -226,6 +227,25 @@ public class ProjectController extends BaseController {
|
||||
return returnDataList(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* query user created project
|
||||
*
|
||||
* @param loginUser login user
|
||||
* @return projects which the user create
|
||||
*/
|
||||
@ApiOperation(value = "queryProjectCreatedByUser", notes = "QUERY_USER_CREATED_PROJECT_NOTES")
|
||||
|
||||
@GetMapping(value = "/login-user-created-project")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@ApiException(QUERY_USER_CREATED_PROJECT_ERROR)
|
||||
public Result queryProjectCreatedByUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
|
||||
logger.info("login user {}, query authorized project by user id: {}.",
|
||||
StringUtils.replaceNRTtoUnderline(loginUser.getUserName()),
|
||||
StringUtils.replaceNRTtoUnderline(String.valueOf(loginUser.getId())));
|
||||
Map<String, Object> result = projectService.queryProjectCreatedByUser(loginUser);
|
||||
return returnDataList(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* import process definition
|
||||
*
|
||||
|
@ -168,15 +168,21 @@ public enum Status {
|
||||
PREVIEW_SCHEDULE_ERROR(10139,"preview schedule error", "预览调度配置错误"),
|
||||
PARSE_TO_CRON_EXPRESSION_ERROR(10140,"parse cron to cron expression error", "解析调度表达式错误"),
|
||||
SCHEDULE_START_TIME_END_TIME_SAME(10141,"The start time must not be the same as the end", "开始时间不能和结束时间一样"),
|
||||
DELETE_TENANT_BY_ID_FAIL(100142,"delete tenant by id fail, for there are {0} process instances in executing using it", "删除租户失败,有[{0}]个运行中的工作流实例正在使用"),
|
||||
DELETE_TENANT_BY_ID_FAIL_DEFINES(100143,"delete tenant by id fail, for there are {0} process definitions using it", "删除租户失败,有[{0}]个工作流定义正在使用"),
|
||||
DELETE_TENANT_BY_ID_FAIL_USERS(100144,"delete tenant by id fail, for there are {0} users using it", "删除租户失败,有[{0}]个用户正在使用"),
|
||||
DELETE_WORKER_GROUP_BY_ID_FAIL(100145,"delete worker group by id fail, for there are {0} process instances in executing using it", "删除Worker分组失败,有[{0}]个运行中的工作流实例正在使用"),
|
||||
QUERY_WORKER_GROUP_FAIL(100146,"query worker group fail ", "查询worker分组失败"),
|
||||
DELETE_WORKER_GROUP_FAIL(100147,"delete worker group fail ", "删除worker分组失败"),
|
||||
QUERY_WORKFLOW_LINEAGE_ERROR(10143,"query workflow lineage error", "查询血缘失败"),
|
||||
COPY_PROCESS_DEFINITION_ERROR(10148,"copy process definition error", "复制工作流错误"),
|
||||
USER_DISABLED(10149,"The current user is disabled", "当前用户已停用"),
|
||||
DELETE_TENANT_BY_ID_FAIL(10142,"delete tenant by id fail, for there are {0} process instances in executing using it", "删除租户失败,有[{0}]个运行中的工作流实例正在使用"),
|
||||
DELETE_TENANT_BY_ID_FAIL_DEFINES(10143,"delete tenant by id fail, for there are {0} process definitions using it", "删除租户失败,有[{0}]个工作流定义正在使用"),
|
||||
DELETE_TENANT_BY_ID_FAIL_USERS(10144,"delete tenant by id fail, for there are {0} users using it", "删除租户失败,有[{0}]个用户正在使用"),
|
||||
DELETE_WORKER_GROUP_BY_ID_FAIL(10145,"delete worker group by id fail, for there are {0} process instances in executing using it", "删除Worker分组失败,有[{0}]个运行中的工作流实例正在使用"),
|
||||
QUERY_WORKER_GROUP_FAIL(10146,"query worker group fail ", "查询worker分组失败"),
|
||||
DELETE_WORKER_GROUP_FAIL(10147,"delete worker group fail ", "删除worker分组失败"),
|
||||
USER_DISABLED(10148,"The current user is disabled", "当前用户已停用"),
|
||||
COPY_PROCESS_DEFINITION_ERROR(10149,"copy process definition from {0} to {1} error : {2}", "从{0}复制工作流到{1}错误 : {2}"),
|
||||
MOVE_PROCESS_DEFINITION_ERROR(10150,"move process definition from {0} to {1} error : {2}", "从{0}移动工作流到{1}错误 : {2}"),
|
||||
QUERY_USER_CREATED_PROJECT_ERROR(10151,"query user created project error error", "查询用户创建的项目错误"),
|
||||
PROCESS_DEFINITION_IDS_IS_EMPTY(10152,"process definition ids is empty", "工作流IDS不能为空"),
|
||||
BATCH_COPY_PROCESS_DEFINITION_ERROR(10153,"batch copy process definition error", "复制工作流错误"),
|
||||
BATCH_MOVE_PROCESS_DEFINITION_ERROR(10154,"batch move process definition error", "移动工作流错误"),
|
||||
QUERY_WORKFLOW_LINEAGE_ERROR(10155,"query workflow lineage error", "查询血缘失败"),
|
||||
|
||||
UDF_FUNCTION_NOT_EXIST(20001, "UDF function not found", "UDF函数不存在"),
|
||||
UDF_FUNCTION_EXISTS(20002, "UDF function already exists", "UDF函数已存在"),
|
||||
RESOURCE_NOT_EXIST(20004, "resource not exist", "资源不存在"),
|
||||
|
@ -55,7 +55,7 @@ public class AlertGroupService extends BaseService{
|
||||
*/
|
||||
public HashMap<String, Object> queryAlertgroup() {
|
||||
|
||||
HashMap<String, Object> result = new HashMap<>(5);
|
||||
HashMap<String, Object> result = new HashMap<>();
|
||||
List<AlertGroup> alertGroups = alertGroupMapper.queryAllGroupList();
|
||||
result.put(Constants.DATA_LIST, alertGroups);
|
||||
putMsg(result, Status.SUCCESS);
|
||||
@ -74,7 +74,7 @@ public class AlertGroupService extends BaseService{
|
||||
*/
|
||||
public Map<String, Object> listPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (checkAdmin(loginUser, result)) {
|
||||
return result;
|
||||
}
|
||||
@ -101,7 +101,7 @@ public class AlertGroupService extends BaseService{
|
||||
* @return create result code
|
||||
*/
|
||||
public Map<String, Object> createAlertgroup(User loginUser, String groupName, AlertType groupType, String desc) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
//only admin can operate
|
||||
if (checkAdmin(loginUser, result)){
|
||||
return result;
|
||||
@ -138,7 +138,7 @@ public class AlertGroupService extends BaseService{
|
||||
* @return update result code
|
||||
*/
|
||||
public Map<String, Object> updateAlertgroup(User loginUser, int id, String groupName, AlertType groupType, String desc) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
if (checkAdmin(loginUser, result)){
|
||||
return result;
|
||||
@ -179,7 +179,7 @@ public class AlertGroupService extends BaseService{
|
||||
*/
|
||||
@Transactional(rollbackFor = RuntimeException.class)
|
||||
public Map<String, Object> delAlertgroupById(User loginUser, int id) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put(Constants.STATUS, false);
|
||||
|
||||
//only admin can operate
|
||||
@ -209,7 +209,7 @@ public class AlertGroupService extends BaseService{
|
||||
* @return grant result code
|
||||
*/
|
||||
public Map<String, Object> grantUser(User loginUser, int alertgroupId, String userIds) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put(Constants.STATUS, false);
|
||||
|
||||
//only admin can operate
|
||||
|
@ -88,7 +88,7 @@ public class DataSourceService extends BaseService{
|
||||
*/
|
||||
public Map<String, Object> createDataSource(User loginUser, String name, String desc, DbType type, String parameter) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
// check name can use or not
|
||||
if (checkName(name)) {
|
||||
putMsg(result, Status.DATASOURCE_EXIST);
|
||||
@ -340,7 +340,7 @@ public class DataSourceService extends BaseService{
|
||||
* @return data source list page
|
||||
*/
|
||||
public Map<String, Object> queryDataSourceList(User loginUser, Integer type) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
List<DataSource> datasourceList;
|
||||
|
||||
@ -674,7 +674,7 @@ public class DataSourceService extends BaseService{
|
||||
* @return authorized result code
|
||||
*/
|
||||
public Map<String, Object> authedDatasource(User loginUser, Integer userId) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
if (!isAdmin(loginUser)) {
|
||||
putMsg(result, Status.USER_NO_OPERATION_PERM);
|
||||
|
@ -98,7 +98,7 @@ public class ExecutorService extends BaseService{
|
||||
TaskDependType taskDependType, WarningType warningType, int warningGroupId,
|
||||
String receivers, String receiversCc, RunMode runMode,
|
||||
Priority processInstancePriority, String workerGroup, Integer timeout) throws ParseException {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
// timeout is invalid
|
||||
if (timeout <= 0 || timeout > MAX_TASK_TIMEOUT) {
|
||||
putMsg(result,Status.TASK_TIMEOUT_PARAMS_ERROR);
|
||||
@ -176,7 +176,7 @@ public class ExecutorService extends BaseService{
|
||||
* @return check result code
|
||||
*/
|
||||
public Map<String, Object> checkProcessDefinitionValid(ProcessDefinition processDefinition, int processDefineId){
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (processDefinition == null) {
|
||||
// check process definition exists
|
||||
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST,processDefineId);
|
||||
@ -201,7 +201,7 @@ public class ExecutorService extends BaseService{
|
||||
* @return execute result code
|
||||
*/
|
||||
public Map<String, Object> execute(User loginUser, String projectName, Integer processInstanceId, ExecuteType executeType) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Project project = projectMapper.queryByName(projectName);
|
||||
|
||||
Map<String, Object> checkResult = checkResultAndAuth(loginUser, projectName, project);
|
||||
@ -294,7 +294,7 @@ public class ExecutorService extends BaseService{
|
||||
*/
|
||||
private Map<String, Object> checkExecuteType(ProcessInstance processInstance, ExecuteType executeType) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
ExecutionStatus executionStatus = processInstance.getState();
|
||||
boolean checkResult = false;
|
||||
switch (executeType) {
|
||||
@ -339,7 +339,7 @@ public class ExecutorService extends BaseService{
|
||||
* @return update result
|
||||
*/
|
||||
private Map<String, Object> updateProcessInstancePrepare(ProcessInstance processInstance, CommandType commandType, ExecutionStatus executionStatus) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
processInstance.setCommandType(commandType);
|
||||
processInstance.addHistoryCmd(commandType);
|
||||
@ -365,7 +365,7 @@ public class ExecutorService extends BaseService{
|
||||
* @return insert result code
|
||||
*/
|
||||
private Map<String, Object> insertCommand(User loginUser, Integer instanceId, Integer processDefinitionId, CommandType commandType) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Command command = new Command();
|
||||
command.setCommandType(commandType);
|
||||
command.setProcessDefinitionId(processDefinitionId);
|
||||
|
@ -56,7 +56,7 @@ public class MonitorService extends BaseService {
|
||||
* @return data base state
|
||||
*/
|
||||
public Map<String,Object> queryDatabaseState(User loginUser) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
List<MonitorRecord> monitorRecordList = monitorDBDao.queryDatabaseState();
|
||||
|
||||
@ -75,7 +75,7 @@ public class MonitorService extends BaseService {
|
||||
*/
|
||||
public Map<String,Object> queryMaster(User loginUser) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
List<Server> masterServers = getServerListFromZK(true);
|
||||
result.put(Constants.DATA_LIST, masterServers);
|
||||
@ -91,7 +91,7 @@ public class MonitorService extends BaseService {
|
||||
* @return zookeeper information list
|
||||
*/
|
||||
public Map<String,Object> queryZookeeperState(User loginUser) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
List<ZookeeperRecord> zookeeperRecordList = zookeeperMonitor.zookeeperInfoList();
|
||||
|
||||
@ -111,7 +111,7 @@ public class MonitorService extends BaseService {
|
||||
*/
|
||||
public Map<String,Object> queryWorker(User loginUser) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
List<WorkerServerModel> workerServers = getServerListFromZK(false)
|
||||
.stream()
|
||||
.map((Server server) -> {
|
||||
|
@ -17,13 +17,10 @@
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.dolphinscheduler.dao.entity.ProcessData;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
/**
|
||||
@ -88,21 +85,36 @@ public interface ProcessDefinitionService {
|
||||
* @param processId process definition id
|
||||
* @return process definition detail
|
||||
*/
|
||||
|
||||
Map<String, Object> queryProcessDefinitionById(User loginUser,
|
||||
String projectName,
|
||||
Integer processId);
|
||||
|
||||
/**
|
||||
* copy process definition
|
||||
*
|
||||
* @param loginUser login user
|
||||
* @param projectName project name
|
||||
* @param processId process definition id
|
||||
* @return copy result code
|
||||
* batch copy process definition
|
||||
* @param loginUser loginUser
|
||||
* @param projectName projectName
|
||||
* @param processDefinitionIds processDefinitionIds
|
||||
* @param targetProjectId targetProjectId
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> copyProcessDefinition(User loginUser,
|
||||
String projectName,
|
||||
Integer processId) throws JsonProcessingException;
|
||||
Map<String, Object> batchCopyProcessDefinition(User loginUser,
|
||||
String projectName,
|
||||
String processDefinitionIds,
|
||||
int targetProjectId);
|
||||
|
||||
/**
|
||||
* batch move process definition
|
||||
* @param loginUser loginUser
|
||||
* @param projectName projectName
|
||||
* @param processDefinitionIds processDefinitionIds
|
||||
* @param targetProjectId targetProjectId
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> batchMoveProcessDefinition(User loginUser,
|
||||
String projectName,
|
||||
String processDefinitionIds,
|
||||
int targetProjectId);
|
||||
|
||||
/**
|
||||
* update process definition
|
||||
@ -187,7 +199,6 @@ public interface ProcessDefinitionService {
|
||||
MultipartFile file,
|
||||
String currentProjectName);
|
||||
|
||||
|
||||
/**
|
||||
* check the process definition node meets the specifications
|
||||
*
|
||||
@ -214,7 +225,6 @@ public interface ProcessDefinitionService {
|
||||
*/
|
||||
Map<String, Object> getTaskNodeListByDefinitionIdList(String defineIdList);
|
||||
|
||||
|
||||
/**
|
||||
* query process definition all by project id
|
||||
*
|
||||
|
@ -178,7 +178,7 @@ public class ProcessInstanceService extends BaseService {
|
||||
* @return process instance detail
|
||||
*/
|
||||
public Map<String, Object> queryProcessInstanceById(User loginUser, String projectName, Integer processId) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Project project = projectMapper.queryByName(projectName);
|
||||
|
||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
|
||||
@ -217,7 +217,7 @@ public class ProcessInstanceService extends BaseService {
|
||||
String searchVal, String executorName,ExecutionStatus stateType, String host,
|
||||
Integer pageNo, Integer pageSize) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Project project = projectMapper.queryByName(projectName);
|
||||
|
||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
|
||||
@ -540,7 +540,7 @@ public class ProcessInstanceService extends BaseService {
|
||||
@Transactional(rollbackFor = RuntimeException.class)
|
||||
public Map<String, Object> deleteProcessInstanceById(User loginUser, String projectName, Integer processInstanceId) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Project project = projectMapper.queryByName(projectName);
|
||||
|
||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
|
||||
@ -580,7 +580,7 @@ public class ProcessInstanceService extends BaseService {
|
||||
* @return variables data
|
||||
*/
|
||||
public Map<String, Object> viewVariables(Integer processInstanceId) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
ProcessInstance processInstance = processInstanceMapper.queryDetailById(processInstanceId);
|
||||
|
||||
|
@ -33,9 +33,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.utils.CheckUtils.checkDesc;
|
||||
|
||||
/**
|
||||
@ -43,7 +41,7 @@ import static org.apache.dolphinscheduler.api.utils.CheckUtils.checkDesc;
|
||||
*HttpTask./
|
||||
**/
|
||||
@Service
|
||||
public class ProjectService extends BaseService{
|
||||
public class ProjectService extends BaseService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProjectService.class);
|
||||
|
||||
@ -66,7 +64,7 @@ public class ProjectService extends BaseService{
|
||||
*/
|
||||
public Map<String, Object> createProject(User loginUser, String name, String desc) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Map<String, Object> descCheck = checkDesc(desc);
|
||||
if (descCheck.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return descCheck;
|
||||
@ -105,7 +103,7 @@ public class ProjectService extends BaseService{
|
||||
*/
|
||||
public Map<String, Object> queryById(Integer projectId) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Project project = projectMapper.selectById(projectId);
|
||||
|
||||
if (project != null) {
|
||||
@ -126,7 +124,7 @@ public class ProjectService extends BaseService{
|
||||
* @return true if the login user have permission to see the project
|
||||
*/
|
||||
public Map<String, Object> checkProjectAndAuth(User loginUser, Project project, String projectName) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (project == null) {
|
||||
putMsg(result, Status.PROJECT_NOT_FOUNT, projectName);
|
||||
} else if (!checkReadPermission(loginUser, project)) {
|
||||
@ -191,7 +189,7 @@ public class ProjectService extends BaseService{
|
||||
* @return delete result code
|
||||
*/
|
||||
public Map<String, Object> deleteProject(User loginUser, Integer projectId) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Project project = projectMapper.selectById(projectId);
|
||||
Map<String, Object> checkResult = getCheckResult(loginUser, project);
|
||||
if (checkResult != null) {
|
||||
@ -245,7 +243,7 @@ public class ProjectService extends BaseService{
|
||||
* @return update result code
|
||||
*/
|
||||
public Map<String, Object> update(User loginUser, Integer projectId, String projectName, String desc) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
Map<String, Object> descCheck = checkDesc(desc);
|
||||
if (descCheck.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
@ -284,7 +282,7 @@ public class ProjectService extends BaseService{
|
||||
* @return the projects which user have not permission to see
|
||||
*/
|
||||
public Map<String, Object> queryUnauthorizedProject(User loginUser, Integer userId) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (checkAdmin(loginUser, result)) {
|
||||
return result;
|
||||
}
|
||||
@ -347,6 +345,26 @@ public class ProjectService extends BaseService{
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* query authorized project
|
||||
*
|
||||
* @param loginUser login user
|
||||
* @return projects which the user have permission to see, Except for items created by this user
|
||||
*/
|
||||
public Map<String, Object> queryProjectCreatedByUser(User loginUser) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
if (checkAdmin(loginUser, result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
List<Project> projects = projectMapper.queryProjectCreatedByUser(loginUser.getId());
|
||||
result.put(Constants.DATA_LIST, projects);
|
||||
putMsg(result,Status.SUCCESS);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* check whether have read permission
|
||||
|
@ -59,7 +59,7 @@ public class QueueService extends BaseService {
|
||||
* @return queue list
|
||||
*/
|
||||
public Map<String, Object> queryList(User loginUser) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (checkAdmin(loginUser, result)) {
|
||||
return result;
|
||||
}
|
||||
@ -81,7 +81,7 @@ public class QueueService extends BaseService {
|
||||
* @return queue list
|
||||
*/
|
||||
public Map<String, Object> queryList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (checkAdmin(loginUser, result)) {
|
||||
return result;
|
||||
}
|
||||
@ -110,7 +110,7 @@ public class QueueService extends BaseService {
|
||||
* @return create result
|
||||
*/
|
||||
public Map<String, Object> createQueue(User loginUser, String queue, String queueName) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (checkAdmin(loginUser, result)) {
|
||||
return result;
|
||||
}
|
||||
@ -159,7 +159,7 @@ public class QueueService extends BaseService {
|
||||
* @return update result code
|
||||
*/
|
||||
public Map<String, Object> updateQueue(User loginUser, int id, String queue, String queueName) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (checkAdmin(loginUser, result)) {
|
||||
return result;
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ public class ResourcesService extends BaseService {
|
||||
|
||||
putMsg(result, Status.SUCCESS);
|
||||
Map<Object, Object> dataMap = new BeanMap(resource);
|
||||
Map<String, Object> resultMap = new HashMap<>(5);
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
for (Map.Entry<Object, Object> entry: dataMap.entrySet()) {
|
||||
if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) {
|
||||
resultMap.put(entry.getKey().toString(), entry.getValue());
|
||||
@ -447,7 +447,7 @@ public class ResourcesService extends BaseService {
|
||||
*/
|
||||
public Map<String, Object> queryResourceListPaging(User loginUser, int direcotryId, ResourceType type, String searchVal, Integer pageNo, Integer pageSize) {
|
||||
|
||||
HashMap<String, Object> result = new HashMap<>(5);
|
||||
HashMap<String, Object> result = new HashMap<>();
|
||||
Page<Resource> page = new Page(pageNo, pageSize);
|
||||
int userId = loginUser.getId();
|
||||
if (isAdmin(loginUser)) {
|
||||
@ -548,7 +548,7 @@ public class ResourcesService extends BaseService {
|
||||
*/
|
||||
public Map<String, Object> queryResourceList(User loginUser, ResourceType type) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
int userId = loginUser.getId();
|
||||
if(isAdmin(loginUser)){
|
||||
@ -571,7 +571,7 @@ public class ResourcesService extends BaseService {
|
||||
*/
|
||||
public Map<String, Object> queryResourceJarList(User loginUser, ResourceType type) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
int userId = loginUser.getId();
|
||||
if(isAdmin(loginUser)){
|
||||
userId = 0;
|
||||
@ -1094,7 +1094,7 @@ public class ResourcesService extends BaseService {
|
||||
* @return unauthorized result code
|
||||
*/
|
||||
public Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
//only admin can operate
|
||||
if (checkAdmin(loginUser, result)) {
|
||||
return result;
|
||||
@ -1146,7 +1146,7 @@ public class ResourcesService extends BaseService {
|
||||
* @return authorized result
|
||||
*/
|
||||
public Map<String, Object> authorizedFile(User loginUser, Integer userId) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (checkAdmin(loginUser, result)){
|
||||
return result;
|
||||
}
|
||||
|
@ -452,7 +452,7 @@ public class SchedulerService extends BaseService {
|
||||
* @return schedule list
|
||||
*/
|
||||
public Map<String, Object> queryScheduleList(User loginUser, String projectName) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Project project = projectMapper.queryByName(projectName);
|
||||
|
||||
// check project auth
|
||||
@ -534,7 +534,7 @@ public class SchedulerService extends BaseService {
|
||||
*/
|
||||
public Map<String, Object> deleteScheduleById(User loginUser, String projectName, Integer scheduleId) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Project project = projectMapper.queryByName(projectName);
|
||||
|
||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
|
||||
@ -583,7 +583,7 @@ public class SchedulerService extends BaseService {
|
||||
* @return the next five fire time
|
||||
*/
|
||||
public Map<String,Object> previewSchedule(User loginUser, String projectName, String schedule) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
CronExpression cronExpression;
|
||||
ScheduleParam scheduleParam = JSONUtils.parseObject(schedule, ScheduleParam.class);
|
||||
Date now = new Date();
|
||||
|
@ -83,7 +83,7 @@ public class TaskInstanceService extends BaseService {
|
||||
Integer processInstanceId, String taskName, String executorName, String startDate,
|
||||
String endDate, String searchVal, ExecutionStatus stateType,String host,
|
||||
Integer pageNo, Integer pageSize) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Project project = projectMapper.queryByName(projectName);
|
||||
|
||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
|
||||
|
@ -86,7 +86,7 @@ public class TenantService extends BaseService{
|
||||
int queueId,
|
||||
String desc) throws Exception {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put(Constants.STATUS, false);
|
||||
if (checkAdmin(loginUser, result)) {
|
||||
return result;
|
||||
@ -138,7 +138,7 @@ public class TenantService extends BaseService{
|
||||
*/
|
||||
public Map<String,Object> queryTenantList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (checkAdmin(loginUser, result)) {
|
||||
return result;
|
||||
}
|
||||
@ -169,7 +169,7 @@ public class TenantService extends BaseService{
|
||||
*/
|
||||
public Map<String, Object> updateTenant(User loginUser,int id,String tenantCode, String tenantName, int queueId, String desc) throws Exception {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put(Constants.STATUS, false);
|
||||
|
||||
if (checkAdmin(loginUser, result)) {
|
||||
@ -235,7 +235,7 @@ public class TenantService extends BaseService{
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map<String, Object> deleteTenantById(User loginUser, int id) throws Exception {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
if (checkAdmin(loginUser, result)) {
|
||||
return result;
|
||||
@ -292,7 +292,7 @@ public class TenantService extends BaseService{
|
||||
*/
|
||||
public Map<String, Object> queryTenantList(User loginUser) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
List<Tenant> resourceList = tenantMapper.selectList(null);
|
||||
result.put(Constants.DATA_LIST, resourceList);
|
||||
@ -307,7 +307,7 @@ public class TenantService extends BaseService{
|
||||
* @return tenant list
|
||||
*/
|
||||
public Map<String, Object> queryTenantList(String tenantCode) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
List<Tenant> resourceList = tenantMapper.queryByTenantCode(tenantCode);
|
||||
if (CollectionUtils.isNotEmpty(resourceList)) {
|
||||
|
@ -151,7 +151,7 @@ public class UdfFuncService extends BaseService{
|
||||
*/
|
||||
public Map<String, Object> queryUdfFuncDetail(int id) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
UdfFunc udfFunc = udfFuncMapper.selectById(id);
|
||||
if (udfFunc == null) {
|
||||
putMsg(result, Status.RESOURCE_NOT_EXIST);
|
||||
@ -247,7 +247,7 @@ public class UdfFuncService extends BaseService{
|
||||
* @return udf function list page
|
||||
*/
|
||||
public Map<String, Object> queryUdfFuncListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
|
||||
PageInfo pageInfo = new PageInfo<Resource>(pageNo, pageSize);
|
||||
@ -286,7 +286,7 @@ public class UdfFuncService extends BaseService{
|
||||
* @return resource list
|
||||
*/
|
||||
public Map<String, Object> queryResourceList(User loginUser, Integer type) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
List<UdfFunc> udfFuncList = udfFuncMapper.getUdfFuncByType(loginUser.getId(), type);
|
||||
|
||||
result.put(Constants.DATA_LIST, udfFuncList);
|
||||
|
@ -102,7 +102,7 @@ public class UsersService extends BaseService {
|
||||
String queue,
|
||||
int state) throws Exception {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
//check all user params
|
||||
String msg = this.checkUserParams(userName, userPassword, email, phone);
|
||||
@ -230,7 +230,7 @@ public class UsersService extends BaseService {
|
||||
* @return user list page
|
||||
*/
|
||||
public Map<String, Object> queryUserList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
|
||||
return result;
|
||||
@ -270,7 +270,7 @@ public class UsersService extends BaseService {
|
||||
String phone,
|
||||
String queue,
|
||||
int state) throws Exception {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put(Constants.STATUS, false);
|
||||
|
||||
User user = userMapper.selectById(userId);
|
||||
@ -393,7 +393,7 @@ public class UsersService extends BaseService {
|
||||
* @throws Exception exception when operate hdfs
|
||||
*/
|
||||
public Map<String, Object> deleteUserById(User loginUser, int id) throws Exception {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
//only admin can operate
|
||||
if (!isAdmin(loginUser)) {
|
||||
putMsg(result, Status.USER_NO_OPERATION_PERM, id);
|
||||
@ -433,7 +433,7 @@ public class UsersService extends BaseService {
|
||||
*/
|
||||
@Transactional(rollbackFor = RuntimeException.class)
|
||||
public Map<String, Object> grantProject(User loginUser, int userId, String projectIds) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put(Constants.STATUS, false);
|
||||
|
||||
//only admin can operate
|
||||
@ -483,7 +483,7 @@ public class UsersService extends BaseService {
|
||||
*/
|
||||
@Transactional(rollbackFor = RuntimeException.class)
|
||||
public Map<String, Object> grantResources(User loginUser, int userId, String resourceIds) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
//only admin can operate
|
||||
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
|
||||
return result;
|
||||
@ -580,7 +580,7 @@ public class UsersService extends BaseService {
|
||||
*/
|
||||
@Transactional(rollbackFor = RuntimeException.class)
|
||||
public Map<String, Object> grantUDFFunction(User loginUser, int userId, String udfIds) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
//only admin can operate
|
||||
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
|
||||
@ -627,7 +627,7 @@ public class UsersService extends BaseService {
|
||||
*/
|
||||
@Transactional(rollbackFor = RuntimeException.class)
|
||||
public Map<String, Object> grantDataSource(User loginUser, int userId, String datasourceIds) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put(Constants.STATUS, false);
|
||||
|
||||
//only admin can operate
|
||||
@ -707,7 +707,7 @@ public class UsersService extends BaseService {
|
||||
* @return user list
|
||||
*/
|
||||
public Map<String, Object> queryAllGeneralUsers(User loginUser) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
//only admin can operate
|
||||
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
|
||||
return result;
|
||||
@ -728,7 +728,7 @@ public class UsersService extends BaseService {
|
||||
* @return user list
|
||||
*/
|
||||
public Map<String, Object> queryUserList(User loginUser) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
//only admin can operate
|
||||
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
|
||||
return result;
|
||||
@ -772,7 +772,7 @@ public class UsersService extends BaseService {
|
||||
*/
|
||||
public Map<String, Object> unauthorizedUser(User loginUser, Integer alertgroupId) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
//only admin can operate
|
||||
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
|
||||
return result;
|
||||
@ -808,7 +808,7 @@ public class UsersService extends BaseService {
|
||||
* @return authorized result code
|
||||
*/
|
||||
public Map<String, Object> authorizedUser(User loginUser, Integer alertgroupId) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
//only admin can operate
|
||||
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
|
||||
return result;
|
||||
|
@ -63,7 +63,7 @@ public class WorkerGroupService extends BaseService {
|
||||
// list to index
|
||||
Integer toIndex = (pageNo - 1) * pageSize + pageSize;
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (checkAdmin(loginUser, result)) {
|
||||
return result;
|
||||
}
|
||||
|
@ -33,10 +33,8 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.dolphinscheduler.api.dto.ProcessMeta;
|
||||
import org.apache.dolphinscheduler.api.dto.treeview.Instance;
|
||||
import org.apache.dolphinscheduler.api.dto.treeview.TreeViewDto;
|
||||
@ -94,7 +92,6 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
@ -129,7 +126,6 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
|
||||
@Autowired
|
||||
private ProcessInstanceMapper processInstanceMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
private TaskInstanceMapper taskInstanceMapper;
|
||||
|
||||
@ -330,41 +326,6 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* copy process definition
|
||||
*
|
||||
* @param loginUser login user
|
||||
* @param projectName project name
|
||||
* @param processId process definition id
|
||||
* @return copy result code
|
||||
*/
|
||||
public Map<String, Object> copyProcessDefinition(User loginUser, String projectName, Integer processId) throws JsonProcessingException {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Project project = projectMapper.queryByName(projectName);
|
||||
|
||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
|
||||
Status resultStatus = (Status) checkResult.get(Constants.STATUS);
|
||||
if (resultStatus != Status.SUCCESS) {
|
||||
return checkResult;
|
||||
}
|
||||
|
||||
ProcessDefinition processDefinition = processDefineMapper.selectById(processId);
|
||||
if (processDefinition == null) {
|
||||
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processId);
|
||||
return result;
|
||||
} else {
|
||||
return createProcessDefinition(
|
||||
loginUser,
|
||||
projectName,
|
||||
processDefinition.getName() + "_copy_" + System.currentTimeMillis(),
|
||||
processDefinition.getProcessDefinitionJson(),
|
||||
processDefinition.getDescription(),
|
||||
processDefinition.getLocations(),
|
||||
processDefinition.getConnects());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* update process definition
|
||||
*
|
||||
@ -963,7 +924,6 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* import process add special task param
|
||||
*
|
||||
@ -1010,7 +970,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
|
||||
* @param processDefinitionId process definition id
|
||||
* @return insert schedule flag
|
||||
*/
|
||||
private int importProcessSchedule(User loginUser, String currentProjectName, ProcessMeta processMeta,
|
||||
public int importProcessSchedule(User loginUser, String currentProjectName, ProcessMeta processMeta,
|
||||
String processDefinitionName, Integer processDefinitionId) {
|
||||
Date now = new Date();
|
||||
Schedule scheduleObj = new Schedule();
|
||||
@ -1489,5 +1449,248 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
|
||||
return recursionProcessDefinitionName(projectId, processDefinitionName, num + 1);
|
||||
}
|
||||
|
||||
private Map<String, Object> copyProcessDefinition(User loginUser,
|
||||
Integer processId,
|
||||
Project targetProject) throws JsonProcessingException {
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
ProcessDefinition processDefinition = processDefineMapper.selectById(processId);
|
||||
if (processDefinition == null) {
|
||||
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processId);
|
||||
return result;
|
||||
} else {
|
||||
return createProcessDefinition(
|
||||
loginUser,
|
||||
targetProject.getName(),
|
||||
processDefinition.getName() + "_copy_" + System.currentTimeMillis(),
|
||||
processDefinition.getProcessDefinitionJson(),
|
||||
processDefinition.getDescription(),
|
||||
processDefinition.getLocations(),
|
||||
processDefinition.getConnects());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* batch copy process definition
|
||||
* @param loginUser loginUser
|
||||
* @param projectName projectName
|
||||
* @param processDefinitionIds processDefinitionIds
|
||||
* @param targetProjectId targetProjectId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> batchCopyProcessDefinition(User loginUser,
|
||||
String projectName,
|
||||
String processDefinitionIds,
|
||||
int targetProjectId){
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
List<String> failedProcessList = new ArrayList<>();
|
||||
|
||||
if (StringUtils.isEmpty(processDefinitionIds)) {
|
||||
putMsg(result, Status.PROCESS_DEFINITION_IDS_IS_EMPTY, processDefinitionIds);
|
||||
return result;
|
||||
}
|
||||
|
||||
//check src project auth
|
||||
Map<String, Object> checkResult = checkProjectAndAuth(loginUser, projectName);
|
||||
if (checkResult != null) {
|
||||
return checkResult;
|
||||
}
|
||||
|
||||
Project targetProject = projectMapper.queryDetailById(targetProjectId);
|
||||
if(targetProject == null){
|
||||
putMsg(result, Status.PROJECT_NOT_FOUNT, targetProjectId);
|
||||
return result;
|
||||
}
|
||||
|
||||
if(!(targetProject.getName()).equals(projectName)){
|
||||
Map<String, Object> checkTargetProjectResult = checkProjectAndAuth(loginUser, targetProject.getName());
|
||||
if (checkTargetProjectResult != null) {
|
||||
return checkTargetProjectResult;
|
||||
}
|
||||
}
|
||||
|
||||
String[] processDefinitionIdList = processDefinitionIds.split(Constants.COMMA);
|
||||
doBatchCopyProcessDefinition(loginUser, targetProject, failedProcessList, processDefinitionIdList);
|
||||
|
||||
checkBatchOperateResult(projectName,targetProject.getName(),result,failedProcessList,true);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* batch move process definition
|
||||
* @param loginUser loginUser
|
||||
* @param projectName projectName
|
||||
* @param processDefinitionIds processDefinitionIds
|
||||
* @param targetProjectId targetProjectId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> batchMoveProcessDefinition(User loginUser,
|
||||
String projectName,
|
||||
String processDefinitionIds,
|
||||
int targetProjectId) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
List<String> failedProcessList = new ArrayList<>();
|
||||
|
||||
//check src project auth
|
||||
Map<String, Object> checkResult = checkProjectAndAuth(loginUser, projectName);
|
||||
if (checkResult != null) {
|
||||
return checkResult;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(processDefinitionIds)) {
|
||||
putMsg(result, Status.PROCESS_DEFINITION_IDS_IS_EMPTY, processDefinitionIds);
|
||||
return result;
|
||||
}
|
||||
|
||||
Project targetProject = projectMapper.queryDetailById(targetProjectId);
|
||||
if(targetProject == null){
|
||||
putMsg(result, Status.PROJECT_NOT_FOUNT, targetProjectId);
|
||||
return result;
|
||||
}
|
||||
|
||||
if(!(targetProject.getName()).equals(projectName)){
|
||||
Map<String, Object> checkTargetProjectResult = checkProjectAndAuth(loginUser, targetProject.getName());
|
||||
if (checkTargetProjectResult != null) {
|
||||
return checkTargetProjectResult;
|
||||
}
|
||||
}
|
||||
|
||||
String[] processDefinitionIdList = processDefinitionIds.split(Constants.COMMA);
|
||||
doBatchMoveProcessDefinition(targetProject, failedProcessList, processDefinitionIdList);
|
||||
|
||||
checkBatchOperateResult(projectName,targetProject.getName(),result,failedProcessList,false);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* do batch move process definition
|
||||
* @param targetProject targetProject
|
||||
* @param failedProcessList failedProcessList
|
||||
* @param processDefinitionIdList processDefinitionIdList
|
||||
*/
|
||||
private void doBatchMoveProcessDefinition(Project targetProject, List<String> failedProcessList, String[] processDefinitionIdList) {
|
||||
for(String processDefinitionId:processDefinitionIdList){
|
||||
try {
|
||||
Map<String, Object> moveProcessDefinitionResult =
|
||||
moveProcessDefinition(Integer.valueOf(processDefinitionId),targetProject);
|
||||
if (!Status.SUCCESS.equals(moveProcessDefinitionResult.get(Constants.STATUS))) {
|
||||
setFailedProcessList(failedProcessList, processDefinitionId);
|
||||
logger.error((String) moveProcessDefinitionResult.get(Constants.MSG));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
setFailedProcessList(failedProcessList, processDefinitionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* batch copy process definition
|
||||
* @param loginUser loginUser
|
||||
* @param targetProject targetProject
|
||||
* @param failedProcessList failedProcessList
|
||||
* @param processDefinitionIdList processDefinitionIdList
|
||||
*/
|
||||
private void doBatchCopyProcessDefinition(User loginUser, Project targetProject, List<String> failedProcessList, String[] processDefinitionIdList) {
|
||||
for(String processDefinitionId:processDefinitionIdList){
|
||||
try {
|
||||
Map<String, Object> copyProcessDefinitionResult =
|
||||
copyProcessDefinition(loginUser,Integer.valueOf(processDefinitionId),targetProject);
|
||||
if (!Status.SUCCESS.equals(copyProcessDefinitionResult.get(Constants.STATUS))) {
|
||||
setFailedProcessList(failedProcessList, processDefinitionId);
|
||||
logger.error((String) copyProcessDefinitionResult.get(Constants.MSG));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
setFailedProcessList(failedProcessList, processDefinitionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set failed processList
|
||||
* @param failedProcessList failedProcessList
|
||||
* @param processDefinitionId processDefinitionId
|
||||
*/
|
||||
private void setFailedProcessList(List<String> failedProcessList, String processDefinitionId) {
|
||||
ProcessDefinition processDefinition = processDefineMapper.queryByDefineId(Integer.valueOf(processDefinitionId));
|
||||
if(processDefinition != null){
|
||||
failedProcessList.add(processDefinitionId+"["+processDefinition.getName()+"]");
|
||||
}else{
|
||||
failedProcessList.add(processDefinitionId+"[null]");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check project and auth
|
||||
* @param loginUser loginUser
|
||||
* @param projectName projectName
|
||||
* @return
|
||||
*/
|
||||
private Map<String, Object> checkProjectAndAuth(User loginUser, String projectName) {
|
||||
Project project = projectMapper.queryByName(projectName);
|
||||
|
||||
//check user access for project
|
||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
|
||||
Status resultStatus = (Status) checkResult.get(Constants.STATUS);
|
||||
|
||||
if (resultStatus != Status.SUCCESS) {
|
||||
return checkResult;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* move process definition
|
||||
* @param processId processId
|
||||
* @param targetProject targetProject
|
||||
* @return move result code
|
||||
*/
|
||||
private Map<String, Object> moveProcessDefinition(Integer processId,
|
||||
Project targetProject) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
ProcessDefinition processDefinition = processDefineMapper.selectById(processId);
|
||||
if (processDefinition == null) {
|
||||
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processId);
|
||||
return result;
|
||||
} else {
|
||||
processDefinition.setProjectId(targetProject.getId());
|
||||
processDefinition.setUpdateTime(new Date());
|
||||
if (processDefineMapper.updateById(processDefinition) > 0) {
|
||||
putMsg(result, Status.SUCCESS);
|
||||
} else {
|
||||
putMsg(result, Status.UPDATE_PROCESS_DEFINITION_ERROR);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check batch operate result
|
||||
* @param srcProjectName srcProjectName
|
||||
* @param targetProjectName targetProjectName
|
||||
* @param result result
|
||||
* @param failedProcessList failedProcessList
|
||||
* @param isCopy isCopy
|
||||
*/
|
||||
private void checkBatchOperateResult(String srcProjectName,String targetProjectName,
|
||||
Map<String, Object> result, List<String> failedProcessList,boolean isCopy) {
|
||||
if (!failedProcessList.isEmpty()) {
|
||||
if(isCopy){
|
||||
putMsg(result, Status.COPY_PROCESS_DEFINITION_ERROR, srcProjectName, targetProjectName,String.join(",", failedProcessList));
|
||||
}else{
|
||||
putMsg(result, Status.MOVE_PROCESS_DEFINITION_ERROR, srcProjectName, targetProjectName,String.join(",", failedProcessList));
|
||||
}
|
||||
} else {
|
||||
putMsg(result, Status.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,6 @@ PROCESS_DEFINITION_ID=process definition id
|
||||
PROCESS_DEFINITION_IDS=process definition ids
|
||||
RELEASE_PROCESS_DEFINITION_NOTES=release process definition
|
||||
QUERY_PROCESS_DEFINITION_BY_ID_NOTES=query process definition by id
|
||||
COPY_PROCESS_DEFINITION_NOTES=copy process definition
|
||||
QUERY_PROCESS_DEFINITION_LIST_NOTES=query process definition list
|
||||
QUERY_PROCESS_DEFINITION_LIST_PAGING_NOTES=query process definition list paging
|
||||
QUERY_ALL_DEFINITION_LIST_NOTES=query all definition list
|
||||
@ -253,4 +252,9 @@ AUTHORIZED_DATA_SOURCE_NOTES=authorized data source
|
||||
DELETE_SCHEDULER_BY_ID_NOTES=delete scheduler by id
|
||||
QUERY_ALERT_GROUP_LIST_PAGING_NOTES=query alert group list paging
|
||||
EXPORT_PROCESS_DEFINITION_BY_ID_NOTES=export process definition by id
|
||||
BATCH_EXPORT_PROCESS_DEFINITION_BY_IDS_NOTES= batch export process definition by ids
|
||||
BATCH_EXPORT_PROCESS_DEFINITION_BY_IDS_NOTES= batch export process definition by ids
|
||||
QUERY_USER_CREATED_PROJECT_NOTES= query user created project
|
||||
COPY_PROCESS_DEFINITION_NOTES= copy process definition notes
|
||||
MOVE_PROCESS_DEFINITION_NOTES= move process definition notes
|
||||
TARGET_PROJECT_ID= target project id
|
||||
IS_COPY = is copy
|
||||
|
@ -173,7 +173,6 @@ PROCESS_DEFINITION_ID=process definition id
|
||||
PROCESS_DEFINITION_IDS=process definition ids
|
||||
RELEASE_PROCESS_DEFINITION_NOTES=release process definition
|
||||
QUERY_PROCESS_DEFINITION_BY_ID_NOTES=query process definition by id
|
||||
COPY_PROCESS_DEFINITION_NOTES=copy process definition
|
||||
QUERY_PROCESS_DEFINITION_LIST_NOTES=query process definition list
|
||||
QUERY_PROCESS_DEFINITION_LIST_PAGING_NOTES=query process definition list paging
|
||||
QUERY_ALL_DEFINITION_LIST_NOTES=query all definition list
|
||||
@ -254,3 +253,8 @@ DELETE_SCHEDULER_BY_ID_NOTES=delete scheduler by id
|
||||
QUERY_ALERT_GROUP_LIST_PAGING_NOTES=query alert group list paging
|
||||
EXPORT_PROCESS_DEFINITION_BY_ID_NOTES=export process definition by id
|
||||
BATCH_EXPORT_PROCESS_DEFINITION_BY_IDS_NOTES= batch export process definition by ids
|
||||
QUERY_USER_CREATED_PROJECT_NOTES= query user created project
|
||||
COPY_PROCESS_DEFINITION_NOTES= copy process definition notes
|
||||
MOVE_PROCESS_DEFINITION_NOTES= move process definition notes
|
||||
TARGET_PROJECT_ID= target project id
|
||||
IS_COPY = is copy
|
||||
|
@ -171,7 +171,6 @@ UPDATE_PROCESS_DEFINITION_NOTES=更新流程定义
|
||||
PROCESS_DEFINITION_ID=流程定义ID
|
||||
RELEASE_PROCESS_DEFINITION_NOTES=发布流程定义
|
||||
QUERY_PROCESS_DEFINITION_BY_ID_NOTES=查询流程定义通过流程定义ID
|
||||
COPY_PROCESS_DEFINITION_NOTES=复制流程定义
|
||||
QUERY_PROCESS_DEFINITION_LIST_NOTES=查询流程定义列表
|
||||
QUERY_PROCESS_DEFINITION_LIST_PAGING_NOTES=分页查询流程定义列表
|
||||
QUERY_ALL_DEFINITION_LIST_NOTES=查询所有流程定义
|
||||
@ -252,4 +251,9 @@ DELETE_SCHEDULER_BY_ID_NOTES=根据定时id删除定时数据
|
||||
QUERY_ALERT_GROUP_LIST_PAGING_NOTES=分页查询告警组列表
|
||||
EXPORT_PROCESS_DEFINITION_BY_ID_NOTES=通过工作流ID导出工作流定义
|
||||
BATCH_EXPORT_PROCESS_DEFINITION_BY_IDS_NOTES=批量导出工作流定义
|
||||
QUERY_USER_CREATED_PROJECT_NOTES= 查询用户创建的项目
|
||||
COPY_PROCESS_DEFINITION_NOTES= 复制工作流定义
|
||||
MOVE_PROCESS_DEFINITION_NOTES= 移动工作流定义
|
||||
TARGET_PROJECT_ID= 目标项目ID
|
||||
IS_COPY = 是否复制
|
||||
|
||||
|
@ -24,11 +24,12 @@ import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.enums.ReleaseState;
|
||||
import org.apache.dolphinscheduler.common.enums.UserType;
|
||||
import org.apache.dolphinscheduler.common.model.TaskNode;
|
||||
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
|
||||
import org.apache.dolphinscheduler.dao.entity.Resource;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
import org.junit.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
@ -48,7 +49,7 @@ import java.util.Map;
|
||||
* process definition controller test
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.Silent.class)
|
||||
public class ProcessDefinitionControllerTest{
|
||||
public class ProcessDefinitionControllerTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ProcessDefinitionControllerTest.class);
|
||||
|
||||
@ -79,7 +80,7 @@ public class ProcessDefinitionControllerTest{
|
||||
String name = "dag_test";
|
||||
String description = "desc test";
|
||||
String connects = "[]";
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.SUCCESS);
|
||||
result.put("processDefinitionId",1);
|
||||
|
||||
@ -103,7 +104,7 @@ public class ProcessDefinitionControllerTest{
|
||||
@Test
|
||||
public void testVerifyProcessDefinitionName() throws Exception {
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.PROCESS_INSTANCE_EXIST);
|
||||
String projectName = "test";
|
||||
String name = "dag_test";
|
||||
@ -125,7 +126,7 @@ public class ProcessDefinitionControllerTest{
|
||||
String description = "desc test";
|
||||
String connects = "[]";
|
||||
int id = 1;
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.SUCCESS);
|
||||
result.put("processDefinitionId",1);
|
||||
|
||||
@ -141,7 +142,7 @@ public class ProcessDefinitionControllerTest{
|
||||
public void testReleaseProcessDefinition() throws Exception {
|
||||
String projectName = "test";
|
||||
int id = 1;
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
Mockito.when(processDefinitionService.releaseProcessDefinition(user, projectName,id,ReleaseState.OFFLINE.ordinal())).thenReturn(result);
|
||||
@ -169,7 +170,7 @@ public class ProcessDefinitionControllerTest{
|
||||
processDefinition.setName(name);
|
||||
processDefinition.setProcessDefinitionJson(json);
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.SUCCESS);
|
||||
result.put(Constants.DATA_LIST, processDefinition);
|
||||
|
||||
@ -180,16 +181,33 @@ public class ProcessDefinitionControllerTest{
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyProcessDefinition() throws Exception {
|
||||
public void testBatchCopyProcessDefinition() throws Exception {
|
||||
|
||||
String projectName = "test";
|
||||
int id = 1;
|
||||
int targetProjectId = 2;
|
||||
String id = "1";
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
Mockito.when(processDefinitionService.copyProcessDefinition(user, projectName,id)).thenReturn(result);
|
||||
Result response = processDefinitionController.copyProcessDefinition(user, projectName,id);
|
||||
Mockito.when(processDefinitionService.batchCopyProcessDefinition(user,projectName,id,targetProjectId)).thenReturn(result);
|
||||
Result response = processDefinitionController.copyProcessDefinition(user, projectName,id,targetProjectId);
|
||||
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(),response.getCode().intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBatchMoveProcessDefinition() throws Exception {
|
||||
|
||||
String projectName = "test";
|
||||
int targetProjectId = 2;
|
||||
String id = "1";
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
Mockito.when(processDefinitionService.batchMoveProcessDefinition(user,projectName,id,targetProjectId)).thenReturn(result);
|
||||
Result response = processDefinitionController.moveProcessDefinition(user, projectName,id,targetProjectId);
|
||||
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(),response.getCode().intValue());
|
||||
}
|
||||
@ -201,7 +219,7 @@ public class ProcessDefinitionControllerTest{
|
||||
String projectName = "test";
|
||||
List<ProcessDefinition> resourceList = getDefinitionList();
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.SUCCESS);
|
||||
result.put(Constants.DATA_LIST, resourceList);
|
||||
|
||||
@ -256,7 +274,7 @@ public class ProcessDefinitionControllerTest{
|
||||
String projectName = "test";
|
||||
int id = 1;
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
Mockito.when(processDefinitionService.deleteProcessDefinitionById(user, projectName,id)).thenReturn(result);
|
||||
@ -270,7 +288,7 @@ public class ProcessDefinitionControllerTest{
|
||||
String projectName = "test";
|
||||
int id = 1;
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
Mockito.when(processDefinitionService.getTaskNodeListByDefinitionId(id)).thenReturn(result);
|
||||
@ -284,7 +302,7 @@ public class ProcessDefinitionControllerTest{
|
||||
String projectName = "test";
|
||||
String idList = "1,2,3";
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
Mockito.when(processDefinitionService.getTaskNodeListByDefinitionIdList(idList)).thenReturn(result);
|
||||
|
@ -76,7 +76,7 @@ public class AlertGroupServiceTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testQueryAlertgroup(){
|
||||
public void testQueryAlertGroup(){
|
||||
|
||||
Mockito.when(alertGroupMapper.queryAllGroupList()).thenReturn(getList());
|
||||
HashMap<String, Object> result= alertGroupService.queryAlertgroup();
|
||||
|
@ -54,7 +54,7 @@ public class ExecutorServiceTest {
|
||||
@Test
|
||||
public void putMsgWithParamsTest() {
|
||||
|
||||
Map<String,Object> map = new HashMap<>(5);
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
putMsgWithParams(map, Status.PROJECT_ALREADY_EXISTS);
|
||||
|
||||
logger.info(map.toString());
|
||||
|
@ -86,8 +86,6 @@ public class ProcessDefinitionServiceTest {
|
||||
@Mock
|
||||
private ScheduleMapper scheduleMapper;
|
||||
|
||||
|
||||
|
||||
@Mock
|
||||
private ProcessService processService;
|
||||
|
||||
@ -130,7 +128,7 @@ public class ProcessDefinitionServiceTest {
|
||||
loginUser.setId(-1);
|
||||
loginUser.setUserType(UserType.GENERAL_USER);
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.PROJECT_NOT_FOUNT, projectName);
|
||||
|
||||
//project not found
|
||||
@ -159,7 +157,7 @@ public class ProcessDefinitionServiceTest {
|
||||
loginUser.setId(-1);
|
||||
loginUser.setUserType(UserType.GENERAL_USER);
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.PROJECT_NOT_FOUNT, projectName);
|
||||
|
||||
//project not found
|
||||
@ -180,7 +178,7 @@ public class ProcessDefinitionServiceTest {
|
||||
loginUser.setId(-1);
|
||||
loginUser.setUserType(UserType.GENERAL_USER);
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.PROJECT_NOT_FOUNT, projectName);
|
||||
|
||||
//project check auth fail
|
||||
@ -209,13 +207,15 @@ public class ProcessDefinitionServiceTest {
|
||||
String projectName = "project_test1";
|
||||
Mockito.when(projectMapper.queryByName(projectName)).thenReturn(getProject(projectName));
|
||||
|
||||
Mockito.when(projectMapper.queryDetailById(1)).thenReturn(getProject(projectName));
|
||||
|
||||
Project project = getProject(projectName);
|
||||
|
||||
User loginUser = new User();
|
||||
loginUser.setId(-1);
|
||||
loginUser.setUserType(UserType.GENERAL_USER);
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
//project check auth success, instance not exist
|
||||
putMsg(result, Status.SUCCESS, projectName);
|
||||
Mockito.when(projectService.checkProjectAndAuth(loginUser,project,projectName)).thenReturn(result);
|
||||
@ -227,7 +227,7 @@ public class ProcessDefinitionServiceTest {
|
||||
//instance exit
|
||||
Mockito.when(processDefineMapper.selectById(46)).thenReturn(definition);
|
||||
|
||||
Map<String, Object> createProcessResult = new HashMap<>(5);
|
||||
Map<String, Object> createProcessResult = new HashMap<>();
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
Mockito.when(processDefinitionService.createProcessDefinition(
|
||||
@ -239,8 +239,51 @@ public class ProcessDefinitionServiceTest {
|
||||
definition.getLocations(),
|
||||
definition.getConnects())).thenReturn(createProcessResult);
|
||||
|
||||
Map<String, Object> successRes = processDefinitionService.copyProcessDefinition(loginUser,
|
||||
"project_test1", 46);
|
||||
Map<String, Object> successRes = processDefinitionService.batchCopyProcessDefinition(loginUser,"project_test1",
|
||||
"46",1);
|
||||
Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBatchMoveProcessDefinition() throws Exception{
|
||||
String projectName = "project_test1";
|
||||
Mockito.when(projectMapper.queryByName(projectName)).thenReturn(getProject(projectName));
|
||||
|
||||
String projectName2 = "project_test2";
|
||||
Mockito.when(projectMapper.queryByName(projectName2)).thenReturn(getProject(projectName2));
|
||||
|
||||
int targetProjectId = 2;
|
||||
Mockito.when(projectMapper.queryDetailById(targetProjectId)).thenReturn(getProjectById(targetProjectId));
|
||||
|
||||
Project project = getProject(projectName);
|
||||
Project targetProject = getProjectById(targetProjectId);
|
||||
|
||||
User loginUser = new User();
|
||||
loginUser.setId(-1);
|
||||
loginUser.setUserType(UserType.GENERAL_USER);
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.SUCCESS, projectName);
|
||||
|
||||
Map<String, Object> result2 = new HashMap<>();
|
||||
putMsg(result2, Status.SUCCESS, targetProject.getName());
|
||||
|
||||
Mockito.when(projectService.checkProjectAndAuth(loginUser,project,projectName)).thenReturn(result);
|
||||
Mockito.when(projectService.checkProjectAndAuth(loginUser,targetProject,targetProject.getName())).thenReturn(result2);
|
||||
|
||||
ProcessDefinition definition = getProcessDefinition();
|
||||
definition.setLocations("{\"tasks-36196\":{\"name\":\"ssh_test1\",\"targetarr\":\"\",\"x\":141,\"y\":70}}");
|
||||
definition.setProcessDefinitionJson("{\"globalParams\":[],\"tasks\":[{\"type\":\"SHELL\",\"id\":\"tasks-36196\",\"name\":\"ssh_test1\",\"params\":{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"aa=\\\"1234\\\"\\necho ${aa}\"},\"desc\":\"\",\"runFlag\":\"NORMAL\",\"dependence\":{},\"maxRetryTimes\":\"0\",\"retryInterval\":\"1\",\"timeout\":{\"strategy\":\"\",\"interval\":null,\"enable\":false},\"taskInstancePriority\":\"MEDIUM\",\"workerGroupId\":-1,\"preTasks\":[]}],\"tenantId\":-1,\"timeout\":0}");
|
||||
definition.setConnects("[]");
|
||||
//instance exit
|
||||
Mockito.when(processDefineMapper.updateById(definition)).thenReturn(46);
|
||||
Mockito.when(processDefineMapper.selectById(46)).thenReturn(definition);
|
||||
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
|
||||
Map<String, Object> successRes = processDefinitionService.batchMoveProcessDefinition(loginUser,"project_test1",
|
||||
"46",2);
|
||||
|
||||
Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS));
|
||||
}
|
||||
@ -256,7 +299,7 @@ public class ProcessDefinitionServiceTest {
|
||||
loginUser.setUserType(UserType.GENERAL_USER);
|
||||
|
||||
//project check auth fail
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.PROJECT_NOT_FOUNT, projectName);
|
||||
Mockito.when(projectService.checkProjectAndAuth(loginUser,project,projectName)).thenReturn(result);
|
||||
Map<String, Object> map = processDefinitionService.deleteProcessDefinitionById(loginUser, "project_test1", 6);
|
||||
@ -336,7 +379,7 @@ public class ProcessDefinitionServiceTest {
|
||||
loginUser.setUserType(UserType.GENERAL_USER);
|
||||
|
||||
//project check auth fail
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.PROJECT_NOT_FOUNT, projectName);
|
||||
Mockito.when(projectService.checkProjectAndAuth(loginUser,project,projectName)).thenReturn(result);
|
||||
Map<String, Object> map = processDefinitionService.releaseProcessDefinition(loginUser, "project_test1",
|
||||
@ -379,7 +422,7 @@ public class ProcessDefinitionServiceTest {
|
||||
loginUser.setUserType(UserType.GENERAL_USER);
|
||||
|
||||
//project check auth fail
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.PROJECT_NOT_FOUNT, projectName);
|
||||
Mockito.when(projectService.checkProjectAndAuth(loginUser,project,projectName)).thenReturn(result);
|
||||
Map<String, Object> map = processDefinitionService.verifyProcessDefinitionName(loginUser,
|
||||
@ -558,7 +601,7 @@ public class ProcessDefinitionServiceTest {
|
||||
loginUser.setUserType(UserType.ADMIN_USER);
|
||||
|
||||
String currentProjectName = "testProject";
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.SUCCESS, currentProjectName);
|
||||
|
||||
ProcessDefinition shellDefinition2 = new ProcessDefinition();
|
||||
@ -601,7 +644,7 @@ public class ProcessDefinitionServiceTest {
|
||||
loginUser.setId(1);
|
||||
loginUser.setUserType(UserType.ADMIN_USER);
|
||||
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
String projectName = "project_test1";
|
||||
@ -657,6 +700,19 @@ public class ProcessDefinitionServiceTest {
|
||||
return project;
|
||||
}
|
||||
|
||||
/**
|
||||
* get mock Project
|
||||
* @param projectId projectId
|
||||
* @return Project
|
||||
*/
|
||||
private Project getProjectById(int projectId){
|
||||
Project project = new Project();
|
||||
project.setId(1);
|
||||
project.setName("project_test2");
|
||||
project.setUserId(1);
|
||||
return project;
|
||||
}
|
||||
|
||||
/**
|
||||
* get mock schedule
|
||||
* @return schedule
|
||||
|
@ -112,7 +112,7 @@ public class ProcessInstanceServiceTest {
|
||||
public void testQueryProcessInstanceList() {
|
||||
String projectName = "project_test1";
|
||||
User loginUser = getAdminUser();
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.PROJECT_NOT_FOUNT, projectName);
|
||||
|
||||
//project auth fail
|
||||
@ -201,7 +201,7 @@ public class ProcessInstanceServiceTest {
|
||||
public void testQueryProcessInstanceById() {
|
||||
String projectName = "project_test1";
|
||||
User loginUser = getAdminUser();
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.PROJECT_NOT_FOUNT, projectName);
|
||||
|
||||
//project auth fail
|
||||
@ -239,7 +239,7 @@ public class ProcessInstanceServiceTest {
|
||||
public void testQueryTaskListByProcessId() throws IOException {
|
||||
String projectName = "project_test1";
|
||||
User loginUser = getAdminUser();
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.PROJECT_NOT_FOUNT, projectName);
|
||||
|
||||
//project auth fail
|
||||
@ -288,7 +288,7 @@ public class ProcessInstanceServiceTest {
|
||||
public void testQuerySubProcessInstanceByTaskId() {
|
||||
String projectName = "project_test1";
|
||||
User loginUser = getAdminUser();
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.PROJECT_NOT_FOUNT, projectName);
|
||||
|
||||
//project auth fail
|
||||
@ -334,7 +334,7 @@ public class ProcessInstanceServiceTest {
|
||||
public void testUpdateProcessInstance() throws ParseException {
|
||||
String projectName = "project_test1";
|
||||
User loginUser = getAdminUser();
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.PROJECT_NOT_FOUNT, projectName);
|
||||
|
||||
//project auth fail
|
||||
@ -390,7 +390,7 @@ public class ProcessInstanceServiceTest {
|
||||
public void testQueryParentInstanceBySubId() {
|
||||
String projectName = "project_test1";
|
||||
User loginUser = getAdminUser();
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.PROJECT_NOT_FOUNT, projectName);
|
||||
|
||||
//project auth fail
|
||||
@ -431,7 +431,7 @@ public class ProcessInstanceServiceTest {
|
||||
public void testDeleteProcessInstanceById() {
|
||||
String projectName = "project_test1";
|
||||
User loginUser = getAdminUser();
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.PROJECT_NOT_FOUNT, projectName);
|
||||
|
||||
//project auth fail
|
||||
|
@ -266,6 +266,26 @@ public class ProjectServiceTest {
|
||||
List<Project> projects = (List<Project>) result.get(Constants.DATA_LIST);
|
||||
Assert.assertTrue(CollectionUtils.isNotEmpty(projects));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryCreatedProject(){
|
||||
|
||||
User loginUser = getLoginUser();
|
||||
|
||||
Mockito.when(projectMapper.queryProjectCreatedByUser(1)).thenReturn(getList());
|
||||
//USER_NO_OPERATION_PERM
|
||||
Map<String, Object> result = projectService.queryProjectCreatedByUser(loginUser);
|
||||
logger.info(result.toString());
|
||||
Assert.assertEquals(Status.USER_NO_OPERATION_PERM,result.get(Constants.STATUS));
|
||||
|
||||
//success
|
||||
loginUser.setUserType(UserType.ADMIN_USER);
|
||||
result = projectService.queryProjectCreatedByUser(loginUser);
|
||||
logger.info(result.toString());
|
||||
List<Project> projects = (List<Project>) result.get(Constants.DATA_LIST);
|
||||
Assert.assertTrue(CollectionUtils.isNotEmpty(projects));
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testQueryAllProjectList(){
|
||||
|
@ -78,7 +78,7 @@ public class TaskInstanceServiceTest {
|
||||
|
||||
String projectName = "project_test1";
|
||||
User loginUser = getAdminUser();
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.PROJECT_NOT_FOUNT, projectName);
|
||||
|
||||
//project auth fail
|
||||
|
@ -37,4 +37,8 @@ public class StringUtils {
|
||||
public static boolean isNotBlank(String s){
|
||||
return !isBlank(s);
|
||||
}
|
||||
|
||||
public static String replaceNRTtoUnderline(String src){
|
||||
return src.replaceAll("[\n|\r|\t]", "_");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user