|
|
|
@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.api.utils.CheckUtils;
|
|
|
|
|
import org.apache.dolphinscheduler.api.utils.PageInfo; |
|
|
|
|
import org.apache.dolphinscheduler.api.utils.Result; |
|
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
|
import org.apache.dolphinscheduler.common.enums.Flag; |
|
|
|
|
import org.apache.dolphinscheduler.common.enums.ReleaseState; |
|
|
|
|
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
|
|
|
|
import org.apache.dolphinscheduler.common.utils.SnowFlakeUtils; |
|
|
|
@ -175,14 +176,22 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
|
|
|
|
|
if (result.get(Constants.STATUS) != Status.SUCCESS) { |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
// TODO
|
|
|
|
|
List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryByTaskCode(taskCode); |
|
|
|
|
if (taskCode == 0) { |
|
|
|
|
putMsg(result, Status.DELETE_TASK_DEFINE_BY_CODE_ERROR); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode); |
|
|
|
|
if (taskDefinition.getFlag() == Flag.YES) { |
|
|
|
|
putMsg(result, Status.TASK_DEFINE_STATE_ONLINE, taskCode); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryDownstreamByTaskCode(taskCode); |
|
|
|
|
if (!processTaskRelationList.isEmpty()) { |
|
|
|
|
Set<Long> processDefinitionCodes = processTaskRelationList |
|
|
|
|
Set<Long> postTaskCodes = processTaskRelationList |
|
|
|
|
.stream() |
|
|
|
|
.map(ProcessTaskRelation::getProcessDefinitionCode) |
|
|
|
|
.map(ProcessTaskRelation::getPostTaskCode) |
|
|
|
|
.collect(Collectors.toSet()); |
|
|
|
|
putMsg(result, Status.PROCESS_TASK_RELATION_EXIST, StringUtils.join(processDefinitionCodes, ",")); |
|
|
|
|
putMsg(result, Status.TASK_HAS_DOWNSTREAM, StringUtils.join(postTaskCodes, ",")); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
int delete = taskDefinitionMapper.deleteByCode(taskCode); |
|
|
|
@ -338,6 +347,10 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
|
|
|
|
|
if (taskDefinition == null) { |
|
|
|
|
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCode); |
|
|
|
|
} else { |
|
|
|
|
if (taskDefinition.getVersion() == version) { |
|
|
|
|
putMsg(result, Status.MAIN_TABLE_USING_VERSION); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
int delete = taskDefinitionLogMapper.deleteByCodeAndVersion(taskCode, version); |
|
|
|
|
if (delete > 0) { |
|
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|