Browse Source

[Bug] [dolphinscheduler-api] in the task define list, when edit task, should show pre node list (#12695)

* backend : add pre node list

* resolve workflow error

Co-authored-by: fanwanlong <fanwanlong@kezaihui.com>
3.2.0-release
jackfanwan 2 years ago committed by GitHub
parent
commit
23ead4f0e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
  2. 82
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/TaskDefinitionVo.java

11
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java

@ -39,6 +39,7 @@ import org.apache.dolphinscheduler.api.service.ProjectService;
import org.apache.dolphinscheduler.api.service.TaskDefinitionService; import org.apache.dolphinscheduler.api.service.TaskDefinitionService;
import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.api.vo.TaskDefinitionVo;
import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.constants.Constants;
import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.ConditionType; import org.apache.dolphinscheduler.common.enums.ConditionType;
@ -1022,7 +1023,15 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
logger.error("Task definition does not exist, taskDefinitionCode:{}.", taskCode); logger.error("Task definition does not exist, taskDefinitionCode:{}.", taskCode);
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, String.valueOf(taskCode)); putMsg(result, Status.TASK_DEFINE_NOT_EXIST, String.valueOf(taskCode));
} else { } else {
result.put(Constants.DATA_LIST, taskDefinition); List<ProcessTaskRelation> taskRelationList = processTaskRelationMapper
.queryByCode(projectCode, 0, 0, taskCode);
if (CollectionUtils.isNotEmpty(taskRelationList)) {
taskRelationList = taskRelationList.stream()
.filter(v -> v.getPreTaskCode() != 0).collect(Collectors.toList());
}
TaskDefinitionVo taskDefinitionVo = TaskDefinitionVo.fromTaskDefinition(taskDefinition);
taskDefinitionVo.setProcessTaskRelationList(taskRelationList);
result.put(Constants.DATA_LIST, taskDefinitionVo);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
} }
return result; return result;

82
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/TaskDefinitionVo.java

@ -0,0 +1,82 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.vo;
import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation;
import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
import java.util.List;
import lombok.Data;
/**
* @author fanwanlong
*/
@Data
public class TaskDefinitionVo extends TaskDefinition {
/**
* process task related list
*/
private List<ProcessTaskRelation> processTaskRelationList;
public TaskDefinitionVo() {
}
public TaskDefinitionVo(List<ProcessTaskRelation> processTaskRelationList) {
this.processTaskRelationList = processTaskRelationList;
}
public static TaskDefinitionVo fromTaskDefinition(TaskDefinition taskDefinition) {
TaskDefinitionVo taskDefinitionVo = new TaskDefinitionVo();
taskDefinitionVo.setId(taskDefinition.getId());
taskDefinitionVo.setCode(taskDefinition.getCode());
taskDefinitionVo.setName(taskDefinition.getName());
taskDefinitionVo.setVersion(taskDefinition.getVersion());
taskDefinitionVo.setDescription(taskDefinition.getDescription());
taskDefinitionVo.setProjectCode(taskDefinition.getProjectCode());
taskDefinitionVo.setUserId(taskDefinition.getUserId());
taskDefinitionVo.setTaskType(taskDefinition.getTaskType());
taskDefinitionVo.setTaskParams(taskDefinition.getTaskParams());
taskDefinitionVo.setTaskParamList(taskDefinition.getTaskParamList());
taskDefinitionVo.setTaskParamMap(taskDefinition.getTaskParamMap());
taskDefinitionVo.setFlag(taskDefinition.getFlag());
taskDefinitionVo.setTaskPriority(taskDefinition.getTaskPriority());
taskDefinitionVo.setUserName(taskDefinition.getUserName());
taskDefinitionVo.setProjectName(taskDefinition.getProjectName());
taskDefinitionVo.setWorkerGroup(taskDefinition.getWorkerGroup());
taskDefinitionVo.setEnvironmentCode(taskDefinition.getEnvironmentCode());
taskDefinitionVo.setFailRetryTimes(taskDefinition.getFailRetryTimes());
taskDefinitionVo.setFailRetryInterval(taskDefinition.getFailRetryInterval());
taskDefinitionVo.setTimeoutFlag(taskDefinition.getTimeoutFlag());
taskDefinitionVo.setTimeoutNotifyStrategy(taskDefinition.getTimeoutNotifyStrategy());
taskDefinitionVo.setTimeout(taskDefinition.getTimeout());
taskDefinitionVo.setDelayTime(taskDefinition.getDelayTime());
taskDefinitionVo.setResourceIds(taskDefinition.getResourceIds());
taskDefinitionVo.setCreateTime(taskDefinition.getCreateTime());
taskDefinitionVo.setUpdateTime(taskDefinition.getUpdateTime());
taskDefinitionVo.setModifyBy(taskDefinition.getModifyBy());
taskDefinitionVo.setTaskGroupId(taskDefinition.getTaskGroupId());
taskDefinitionVo.setTaskGroupPriority(taskDefinition.getTaskGroupPriority());
taskDefinitionVo.setCpuQuota(taskDefinition.getCpuQuota());
taskDefinitionVo.setMemoryMax(taskDefinition.getMemoryMax());
taskDefinitionVo.setTaskExecuteType(taskDefinition.getTaskExecuteType());
return taskDefinitionVo;
}
}
Loading…
Cancel
Save