Unverified Commit 46ab86d6 authored by zixi0825's avatar zixi0825 Committed by GitHub
Browse files

batch copy or move process #2753 (#2884)



* 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: default avatarsunchaohe <sunzhaohe@linklogis.com>
Co-authored-by: default avatardailidong <dailidong66@gmail.com>
parent a7a1156f
Loading
Loading
Loading
Loading
+49 −11
Original line number Diff line number Diff line
@@ -99,23 +99,61 @@ public class ProcessDefinitionController extends BaseController {
     *
     * @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(",");
+1 −1
Original line number Diff line number Diff line
@@ -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(",");
+20 −0
Original line number Diff line number Diff line
@@ -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
     *
+15 −9
Original line number Diff line number Diff line
@@ -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", "资源不存在"),
+6 −6
Original line number Diff line number Diff line
@@ -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
Loading