|
|
|
@ -40,7 +40,6 @@ import org.apache.dolphinscheduler.common.graph.DAG;
|
|
|
|
|
import org.apache.dolphinscheduler.common.model.TaskNode; |
|
|
|
|
import org.apache.dolphinscheduler.common.model.TaskNodeRelation; |
|
|
|
|
import org.apache.dolphinscheduler.common.thread.Stopper; |
|
|
|
|
import org.apache.dolphinscheduler.common.utils.CollectionUtils; |
|
|
|
|
import org.apache.dolphinscheduler.common.utils.DateUtils; |
|
|
|
|
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
|
|
|
|
import org.apache.dolphinscheduler.common.utils.SnowFlakeUtils; |
|
|
|
@ -72,7 +71,7 @@ import org.apache.dolphinscheduler.dao.mapper.UserMapper;
|
|
|
|
|
import org.apache.dolphinscheduler.service.permission.PermissionCheck; |
|
|
|
|
import org.apache.dolphinscheduler.service.process.ProcessService; |
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
|
|
|
|
|
|
import java.io.BufferedOutputStream; |
|
|
|
|
import java.io.IOException; |
|
|
|
@ -165,15 +164,15 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
/** |
|
|
|
|
* create process definition |
|
|
|
|
* |
|
|
|
|
* @param loginUser login user |
|
|
|
|
* @param projectCode project code |
|
|
|
|
* @param name process definition name |
|
|
|
|
* @param description description |
|
|
|
|
* @param globalParams global params |
|
|
|
|
* @param locations locations for nodes |
|
|
|
|
* @param timeout timeout |
|
|
|
|
* @param tenantCode tenantCode |
|
|
|
|
* @param taskRelationJson relation json for nodes |
|
|
|
|
* @param loginUser login user |
|
|
|
|
* @param projectCode project code |
|
|
|
|
* @param name process definition name |
|
|
|
|
* @param description description |
|
|
|
|
* @param globalParams global params |
|
|
|
|
* @param locations locations for nodes |
|
|
|
|
* @param timeout timeout |
|
|
|
|
* @param tenantCode tenantCode |
|
|
|
|
* @param taskRelationJson relation json for nodes |
|
|
|
|
* @param taskDefinitionJson taskDefinitionJson |
|
|
|
|
* @return create result code |
|
|
|
|
*/ |
|
|
|
@ -294,8 +293,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
List<ProcessTaskRelation> processTaskRelations = taskRelationList.stream() |
|
|
|
|
.map(processTaskRelationLog -> JSONUtils.parseObject(JSONUtils.toJsonString(processTaskRelationLog), ProcessTaskRelation.class)) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
.map(processTaskRelationLog -> JSONUtils.parseObject(JSONUtils.toJsonString(processTaskRelationLog), ProcessTaskRelation.class)) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
List<TaskNode> taskNodeList = processService.transformTask(processTaskRelations, taskDefinitionLogs); |
|
|
|
|
if (taskNodeList.size() != taskRelationList.size()) { |
|
|
|
|
Set<Long> postTaskCodes = taskRelationList.stream().map(ProcessTaskRelationLog::getPostTaskCode).collect(Collectors.toSet()); |
|
|
|
@ -303,7 +302,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
Collection<Long> codes = CollectionUtils.subtract(postTaskCodes, taskNodeCodes); |
|
|
|
|
if (CollectionUtils.isNotEmpty(codes)) { |
|
|
|
|
logger.error("the task code is not exit"); |
|
|
|
|
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, StringUtils.join(codes, Constants.COMMA)); |
|
|
|
|
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, org.apache.commons.lang.StringUtils.join(codes, Constants.COMMA)); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -332,7 +331,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
/** |
|
|
|
|
* query process definition list |
|
|
|
|
* |
|
|
|
|
* @param loginUser login user |
|
|
|
|
* @param loginUser login user |
|
|
|
|
* @param projectCode project code |
|
|
|
|
* @return definition list |
|
|
|
|
*/ |
|
|
|
@ -384,12 +383,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
/** |
|
|
|
|
* query process definition list paging |
|
|
|
|
* |
|
|
|
|
* @param loginUser login user |
|
|
|
|
* @param loginUser login user |
|
|
|
|
* @param projectCode project code |
|
|
|
|
* @param searchVal search value |
|
|
|
|
* @param userId user id |
|
|
|
|
* @param pageNo page number |
|
|
|
|
* @param pageSize page size |
|
|
|
|
* @param searchVal search value |
|
|
|
|
* @param userId user id |
|
|
|
|
* @param pageNo page number |
|
|
|
|
* @param pageSize page size |
|
|
|
|
* @return process definition page |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
@ -406,7 +405,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
|
|
|
|
|
Page<ProcessDefinition> page = new Page<>(pageNo, pageSize); |
|
|
|
|
IPage<ProcessDefinition> processDefinitionIPage = processDefinitionMapper.queryDefineListPaging( |
|
|
|
|
page, searchVal, userId, project.getCode(), isAdmin(loginUser)); |
|
|
|
|
page, searchVal, userId, project.getCode(), isAdmin(loginUser)); |
|
|
|
|
|
|
|
|
|
List<ProcessDefinition> records = processDefinitionIPage.getRecords(); |
|
|
|
|
for (ProcessDefinition pd : records) { |
|
|
|
@ -427,9 +426,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
/** |
|
|
|
|
* query detail of process definition |
|
|
|
|
* |
|
|
|
|
* @param loginUser login user |
|
|
|
|
* @param loginUser login user |
|
|
|
|
* @param projectCode project code |
|
|
|
|
* @param code process definition code |
|
|
|
|
* @param code process definition code |
|
|
|
|
* @return process definition detail |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
@ -479,16 +478,16 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
/** |
|
|
|
|
* update process definition |
|
|
|
|
* |
|
|
|
|
* @param loginUser login user |
|
|
|
|
* @param projectCode project code |
|
|
|
|
* @param name process definition name |
|
|
|
|
* @param code process definition code |
|
|
|
|
* @param description description |
|
|
|
|
* @param globalParams global params |
|
|
|
|
* @param locations locations for nodes |
|
|
|
|
* @param timeout timeout |
|
|
|
|
* @param tenantCode tenantCode |
|
|
|
|
* @param taskRelationJson relation json for nodes |
|
|
|
|
* @param loginUser login user |
|
|
|
|
* @param projectCode project code |
|
|
|
|
* @param name process definition name |
|
|
|
|
* @param code process definition code |
|
|
|
|
* @param description description |
|
|
|
|
* @param globalParams global params |
|
|
|
|
* @param locations locations for nodes |
|
|
|
|
* @param timeout timeout |
|
|
|
|
* @param tenantCode tenantCode |
|
|
|
|
* @param taskRelationJson relation json for nodes |
|
|
|
|
* @param taskDefinitionJson taskDefinitionJson |
|
|
|
|
* @return update result code |
|
|
|
|
*/ |
|
|
|
@ -583,7 +582,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR); |
|
|
|
|
} |
|
|
|
|
int insertResult = processService.saveTaskRelation(loginUser, processDefinition.getProjectCode(), |
|
|
|
|
processDefinition.getCode(), insertVersion, taskRelationList, taskDefinitionLogs); |
|
|
|
|
processDefinition.getCode(), insertVersion, taskRelationList, taskDefinitionLogs); |
|
|
|
|
if (insertResult == Constants.EXIT_CODE_SUCCESS) { |
|
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
result.put(Constants.DATA_LIST, processDefinition); |
|
|
|
@ -597,9 +596,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
/** |
|
|
|
|
* verify process definition name unique |
|
|
|
|
* |
|
|
|
|
* @param loginUser login user |
|
|
|
|
* @param loginUser login user |
|
|
|
|
* @param projectCode project code |
|
|
|
|
* @param name name |
|
|
|
|
* @param name name |
|
|
|
|
* @return true if process definition name not exists, otherwise false |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
@ -719,20 +718,6 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
|
|
|
|
|
switch (releaseState) { |
|
|
|
|
case ONLINE: |
|
|
|
|
// To check resources whether they are already cancel authorized or deleted
|
|
|
|
|
String resourceIds = processDefinition.getResourceIds(); |
|
|
|
|
if (StringUtils.isNotBlank(resourceIds)) { |
|
|
|
|
Integer[] resourceIdArray = Arrays.stream(resourceIds.split(Constants.COMMA)).map(Integer::parseInt).toArray(Integer[]::new); |
|
|
|
|
PermissionCheck<Integer> permissionCheck = new PermissionCheck<>(AuthorizationType.RESOURCE_FILE_ID, processService, resourceIdArray, loginUser.getId(), logger); |
|
|
|
|
try { |
|
|
|
|
permissionCheck.checkPermission(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
logger.error(e.getMessage(), e); |
|
|
|
|
putMsg(result, Status.RESOURCE_NOT_EXIST_OR_NO_PERMISSION, RELEASESTATE); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
processDefinition.setReleaseState(releaseState); |
|
|
|
|
processDefinitionMapper.updateById(processDefinition); |
|
|
|
|
break; |
|
|
|
@ -769,7 +754,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void batchExportProcessDefinitionByCodes(User loginUser, long projectCode, String codes, HttpServletResponse response) { |
|
|
|
|
if (StringUtils.isEmpty(codes)) { |
|
|
|
|
if (org.apache.commons.lang.StringUtils.isEmpty(codes)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
Project project = projectMapper.queryByCode(projectCode); |
|
|
|
@ -1339,7 +1324,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(processDefinitionCodes)) { |
|
|
|
|
if (org.apache.commons.lang.StringUtils.isEmpty(processDefinitionCodes)) { |
|
|
|
|
putMsg(result, Status.PROCESS_DEFINITION_CODES_IS_EMPTY, processDefinitionCodes); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
@ -1369,7 +1354,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
diffCode.forEach(code -> failedProcessList.add(code + "[null]")); |
|
|
|
|
for (ProcessDefinition processDefinition : processDefinitionList) { |
|
|
|
|
List<ProcessTaskRelation> processTaskRelations = |
|
|
|
|
processTaskRelationMapper.queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode()); |
|
|
|
|
processTaskRelationMapper.queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode()); |
|
|
|
|
List<ProcessTaskRelationLog> taskRelationList = processTaskRelations.stream().map(ProcessTaskRelationLog::new).collect(Collectors.toList()); |
|
|
|
|
processDefinition.setProjectCode(targetProjectCode); |
|
|
|
|
if (isCopy) { |
|
|
|
@ -1407,8 +1392,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
* |
|
|
|
|
* @param loginUser login user |
|
|
|
|
* @param projectCode project code |
|
|
|
|
* @param code process definition code |
|
|
|
|
* @param version the version user want to switch |
|
|
|
|
* @param code process definition code |
|
|
|
|
* @param version the version user want to switch |
|
|
|
|
* @return switch process definition version result code |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
@ -1444,11 +1429,11 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
/** |
|
|
|
|
* check batch operate result |
|
|
|
|
* |
|
|
|
|
* @param srcProjectCode srcProjectCode |
|
|
|
|
* @param srcProjectCode srcProjectCode |
|
|
|
|
* @param targetProjectCode targetProjectCode |
|
|
|
|
* @param result result |
|
|
|
|
* @param result result |
|
|
|
|
* @param failedProcessList failedProcessList |
|
|
|
|
* @param isCopy isCopy |
|
|
|
|
* @param isCopy isCopy |
|
|
|
|
*/ |
|
|
|
|
private void checkBatchOperateResult(long srcProjectCode, long targetProjectCode, |
|
|
|
|
Map<String, Object> result, List<String> failedProcessList, boolean isCopy) { |
|
|
|
@ -1466,11 +1451,11 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
/** |
|
|
|
|
* query the pagination versions info by one certain process definition code |
|
|
|
|
* |
|
|
|
|
* @param loginUser login user info to check auth |
|
|
|
|
* @param loginUser login user info to check auth |
|
|
|
|
* @param projectCode project code |
|
|
|
|
* @param pageNo page number |
|
|
|
|
* @param pageSize page size |
|
|
|
|
* @param code process definition code |
|
|
|
|
* @param pageNo page number |
|
|
|
|
* @param pageSize page size |
|
|
|
|
* @param code process definition code |
|
|
|
|
* @return the pagination process definition versions info of the certain process definition |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
@ -1500,10 +1485,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
/** |
|
|
|
|
* delete one certain process definition by version number and process definition code |
|
|
|
|
* |
|
|
|
|
* @param loginUser login user info to check auth |
|
|
|
|
* @param loginUser login user info to check auth |
|
|
|
|
* @param projectCode project code |
|
|
|
|
* @param code process definition code |
|
|
|
|
* @param version version number |
|
|
|
|
* @param code process definition code |
|
|
|
|
* @param version version number |
|
|
|
|
* @return delete result code |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|