Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

batch copy or move process #2753 #2884

Merged
merged 54 commits into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
53c2ba2
batch copy or move process
Jun 3, 2020
9a4ad29
batch copy or move process
Jun 3, 2020
247503a
batch copy or move process
Jun 3, 2020
55a21cd
batch copy or move process
Jun 3, 2020
309fa0c
batch copy or move process
Jun 3, 2020
4694500
batch copy or move process
Jun 3, 2020
bb41a4f
batch copy or move process
Jun 3, 2020
2b71e4e
Merge branch 'dev' into batch_copy_or_move_process
davidzollo Jun 6, 2020
a273966
Merge branch 'dev' into batch_copy_or_move_process
zixi0825 Jun 10, 2020
97815cd
batch copy or move process sovle code smell
Jun 18, 2020
79504d9
Merge branch 'dev' of https://github.com/apache/incubator-dolphinsche…
Jun 18, 2020
19794ca
batch copy or move process sovle code smell
Jun 18, 2020
1ed2361
batch copy or move process sovle code smell
Jun 18, 2020
5ede5e3
batch copy or move process sovle code smell
Jun 18, 2020
0431b9d
batch copy or move process sovle code smell
Jun 18, 2020
c18e98b
batch copy or move process sovle code smell
Jun 19, 2020
81c9d08
batch copy or move process sovle code smell
Jun 19, 2020
6ac6186
batch copy or move process sovle code smell
Jun 19, 2020
8317b00
Merge branch 'dev' into batch_copy_or_move_process
zixi0825 Jun 19, 2020
32695ec
Merge branch 'dev' into batch_copy_or_move_process
zixi0825 Jun 22, 2020
d49376b
Merge branch 'dev' into batch_copy_or_move_process
zixi0825 Jun 23, 2020
b7187b8
Merge branch 'dev' into batch_copy_or_move_process
zixi0825 Jun 24, 2020
25ae29b
batch copy or move process
Jun 24, 2020
f70cd74
Merge branch 'dev' of https://github.com/apache/incubator-dolphinsche…
Jun 24, 2020
9ad7592
Merge branch 'batch_copy_or_move_process' of https://github.com/zixi0…
Jun 24, 2020
2d3f32c
batch copy or move process
Jun 24, 2020
e286313
batch copy or move process
Jun 24, 2020
b495b3b
batch copy or move process
Jun 24, 2020
14a2c73
batch copy or move process
Jun 28, 2020
d268fd4
Merge branch 'dev' of https://github.com/apache/incubator-dolphinsche…
Jun 28, 2020
c8c3cb9
batch copy or move process
Jun 28, 2020
02c6529
Merge branch 'dev' of https://github.com/apache/incubator-dolphinsche…
Jun 28, 2020
ac4f15f
Merge branch 'dev' into batch_copy_or_move_process
zixi0825 Jun 28, 2020
7cdc432
Merge branch 'dev' into batch_copy_or_move_process
zixi0825 Jun 29, 2020
68695b8
Merge branch 'dev' into batch_copy_or_move_process
zixi0825 Jun 30, 2020
33e636c
Merge branch 'dev' into batch_copy_or_move_process
zixi0825 Jul 2, 2020
0c46ee8
Merge branch 'dev' into batch_copy_or_move_process
zixi0825 Jul 8, 2020
d747553
Roll back the package.json file
Jul 10, 2020
b257d1e
Merge branch 'dev' of https://github.com/apache/incubator-dolphinsche…
Jul 10, 2020
d9fee86
Merge branch 'batch_copy_or_move_process' of https://github.com/zixi0…
Jul 10, 2020
11a5f50
Merge branch 'dev' into batch_copy_or_move_process
zixi0825 Jul 10, 2020
b38b012
Merge branch 'dev' into batch_copy_or_move_process
zixi0825 Jul 11, 2020
ef54785
fix conflicts in MonitorService
Jul 18, 2020
a4428dd
Merge branch 'batch_copy_or_move_process' of https://github.com/zixi0…
Jul 18, 2020
76cf566
rerun test
zixi0825 Jul 19, 2020
123e272
revert blank
Jul 29, 2020
a86b4e1
Merge branch 'dev' of https://github.com/apache/incubator-dolphinsche…
Jul 29, 2020
23897a4
Merge branch 'batch_copy_or_move_process' of https://github.com/zixi0…
Jul 29, 2020
2153681
Merge branch 'dev' into batch_copy_or_move_process
davidzollo Aug 1, 2020
47edf92
resolve conflicts
Aug 11, 2020
240b712
resolve conflicts
Aug 11, 2020
a8b7c95
resolve conflicts
Aug 11, 2020
002b2e6
resolve ut error
Aug 11, 2020
ee4f85e
resolve sonar error
Aug 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,65 @@ public Result createProcessDefinition(@ApiIgnore @RequestAttribute(value = Const
}

/**
* 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));
}

/**
Expand Down Expand Up @@ -365,7 +403,7 @@ public Result getNodeListByDefinitionId(
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);
Expand Down Expand Up @@ -420,7 +458,7 @@ public Result batchDeleteProcessDefinitionByIds(@ApiIgnore @RequestAttribute(val
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(",");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public Result batchDeleteProcessInstanceByIds(@RequestAttribute(value = Constant
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(",");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
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;
Expand Down Expand Up @@ -226,6 +227,25 @@ public Result queryAuthorizedProject(@ApiIgnore @RequestAttribute(value = Consta
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
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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", "资源不存在"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -74,7 +74,7 @@ public HashMap<String, Object> queryAlertgroup() {
*/
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;
}
Expand All @@ -101,7 +101,7 @@ public Map<String, Object> listPaging(User loginUser, String searchVal, Integer
* @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;
Expand Down Expand Up @@ -138,7 +138,7 @@ public Map<String, Object> createAlertgroup(User loginUser, String groupName, Al
* @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;
Expand Down Expand Up @@ -179,7 +179,7 @@ public Map<String, Object> updateAlertgroup(User loginUser, int id, String group
*/
@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
Expand Down Expand Up @@ -209,7 +209,7 @@ public Map<String, Object> delAlertgroupById(User loginUser, int id) {
* @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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -340,7 +340,7 @@ private void handlePasswd(List<DataSource> dataSourceList) {
* @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;

Expand Down Expand Up @@ -674,7 +674,7 @@ public Map<String, Object> unauthDatasource(User loginUser, Integer userId) {
* @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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public Map<String, Object> execProcessInstance(User loginUser, String projectNam
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);
Expand Down Expand Up @@ -176,7 +176,7 @@ private boolean checkMasterExists(Map<String, Object> result) {
* @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);
Expand All @@ -201,7 +201,7 @@ public Map<String, Object> checkProcessDefinitionValid(ProcessDefinition process
* @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);
Expand Down Expand Up @@ -294,7 +294,7 @@ private boolean checkTenantSuitable(ProcessDefinition processDefinition) {
*/
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) {
Expand Down Expand Up @@ -339,7 +339,7 @@ private Map<String, Object> checkExecuteType(ProcessInstance processInstance, Ex
* @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);
Expand All @@ -365,7 +365,7 @@ private Map<String, Object> updateProcessInstancePrepare(ProcessInstance process
* @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);
Expand Down
Loading