Browse Source

[Feature][API] Refactor get dependent node information api (#9591)

* feature_8922

* fix comment error

* remove unused import

* fix unused import
3.0.0/version-upgrade
xiangzihao 3 years ago committed by GitHub
parent
commit
a3bf10c88d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 43
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionController.java
  2. 17
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java
  3. 54
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
  4. 2
      dolphinscheduler-api/src/main/resources/i18n/messages.properties
  5. 2
      dolphinscheduler-api/src/main/resources/i18n/messages_en_US.properties
  6. 2
      dolphinscheduler-api/src/main/resources/i18n/messages_zh_CN.properties
  7. 2
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DependentProcessDefinition.java
  8. 63
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DependentSimplifyDefinition.java
  9. 10
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.java
  10. 10
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessTaskRelationMapper.java
  11. 13
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.xml
  12. 10
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessTaskRelationMapper.xml

43
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionController.java

@ -566,6 +566,49 @@ public class ProcessDefinitionController extends BaseController {
return returnDataList(result);
}
/**
* get process definition list map by project code
*
* @param loginUser login user
* @param projectCode project code
* @return process definition list data
*/
@ApiOperation(value = "getProcessListByProjectCode", notes = "GET_PROCESS_LIST_BY_PROCESS_CODE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectCode", value = "PROJECT_CODE", required = true, type = "Long", example = "100")
})
@GetMapping(value = "/query-process-definition-list")
@ResponseStatus(HttpStatus.OK)
@ApiException(GET_TASKS_LIST_BY_PROCESS_DEFINITION_ID_ERROR)
public Result getProcessListByProjectCodes(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode
) {
Map<String, Object> result = processDefinitionService.queryProcessDefinitionListByProjectCode(projectCode);
return returnDataList(result);
}
/**
* get task definition list by process definition code
*
* @param loginUser login user
* @param projectCode project code
* @return process definition list data
*/
@ApiOperation(value = "getTaskListByProcessDefinitionCode", notes = "GET_TASK_LIST_BY_PROCESS_CODE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectCode", value = "PROJECT_CODE", required = true, type = "Long", example = "100"),
@ApiImplicitParam(name = "processDefinitionCode", value = "PROCESS_DEFINITION_CODE", required = true, dataType = "Long", example = "100"),
})
@GetMapping(value = "/query-task-definition-list")
@ResponseStatus(HttpStatus.OK)
@ApiException(GET_TASKS_LIST_BY_PROCESS_DEFINITION_ID_ERROR)
public Result getTaskListByProcessDefinitionCode(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode,
@RequestParam(value = "processDefinitionCode") Long processDefinitionCode) {
Map<String, Object> result = processDefinitionService.queryTaskDefinitionListByProcessDefinitionCode(projectCode, processDefinitionCode);
return returnDataList(result);
}
/**
* delete process definition by code
*

17
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java

@ -296,6 +296,23 @@ public interface ProcessDefinitionService {
*/
Map<String, Object> queryAllProcessDefinitionByProjectCode(User loginUser, long projectCode);
/**
* query process definition list by project code
*
* @param projectCode project code
* @return process definitions in the project
*/
Map<String, Object> queryProcessDefinitionListByProjectCode(long projectCode);
/**
* query process definition list by project code
*
* @param projectCode project code
* @param processDefinitionCode process definition code
* @return process definitions in the project
*/
Map<String, Object> queryTaskDefinitionListByProcessDefinitionCode(long projectCode, Long processDefinitionCode);
/**
* Encapsulates the TreeView structure
*

54
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java

@ -43,6 +43,7 @@ import org.apache.dolphinscheduler.common.enums.Flag;
import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.ProcessExecutionTypeEnum;
import org.apache.dolphinscheduler.common.enums.ReleaseState;
import org.apache.dolphinscheduler.dao.entity.DependentSimplifyDefinition;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy;
import org.apache.dolphinscheduler.common.enums.TimeoutFlag;
import org.apache.dolphinscheduler.common.enums.UserType;
@ -101,6 +102,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -1419,6 +1421,58 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
return result;
}
/**
* query process definition list by project code
*
* @param projectCode project code
* @return process definition list in the project
*/
@Override
public Map<String, Object> queryProcessDefinitionListByProjectCode(long projectCode) {
Map<String, Object> result = new HashMap<>();
List<DependentSimplifyDefinition> processDefinitions = processDefinitionMapper.queryDefinitionListByProjectCodeAndProcessDefinitionCodes(projectCode, null);
result.put(Constants.DATA_LIST, processDefinitions);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* query process definition list by process definition code
*
* @param projectCode project code
* @param processDefinitionCode process definition code
* @return task definition list in the process definition
*/
@Override
public Map<String, Object> queryTaskDefinitionListByProcessDefinitionCode(long projectCode, Long processDefinitionCode) {
Map<String, Object> result = new HashMap<>();
Set<Long> definitionCodesSet = new HashSet<>();
definitionCodesSet.add(processDefinitionCode);
List<DependentSimplifyDefinition> processDefinitions = processDefinitionMapper.queryDefinitionListByProjectCodeAndProcessDefinitionCodes(projectCode, definitionCodesSet);
//query process task relation
List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryProcessTaskRelationsByProcessDefinitionCode(
processDefinitions.get(0).getCode(),
processDefinitions.get(0).getVersion());
//query task definition log
List<TaskDefinitionLog> taskDefinitionLogsList = processService.genTaskDefineList(processTaskRelations);
List<DependentSimplifyDefinition> taskDefinitionList = new ArrayList<>();
for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogsList) {
DependentSimplifyDefinition dependentSimplifyDefinition = new DependentSimplifyDefinition();
dependentSimplifyDefinition.setCode(taskDefinitionLog.getCode());
dependentSimplifyDefinition.setName(taskDefinitionLog.getName());
dependentSimplifyDefinition.setVersion(taskDefinitionLog.getVersion());
taskDefinitionList.add(dependentSimplifyDefinition);
}
result.put(Constants.DATA_LIST, taskDefinitionList);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* Encapsulates the TreeView structure
*

2
dolphinscheduler-api/src/main/resources/i18n/messages.properties

@ -299,3 +299,5 @@ OPERATION_TYPE=operation type
TASK_DEFINITION_TAG=task definition related operation
PROCESS_TASK_RELATION_TAG=process task relation related operation
ENVIRONMENT_TAG=environment related operation
GET_PROCESS_LIST_BY_PROCESS_CODE_NOTES=query process definition list by project code
GET_TASK_LIST_BY_PROCESS_CODE_NOTES=query task definition list by process definition code

2
dolphinscheduler-api/src/main/resources/i18n/messages_en_US.properties

@ -358,3 +358,5 @@ OPERATION_TYPE=operation type
TASK_DEFINITION_TAG=task definition related operation
PROCESS_TASK_RELATION_TAG=process task relation related operation
ENVIRONMENT_TAG=environment related operation
GET_PROCESS_LIST_BY_PROCESS_CODE_NOTES=query process definition list by project code
GET_TASK_LIST_BY_PROCESS_CODE_NOTES=query task definition list by process definition code

2
dolphinscheduler-api/src/main/resources/i18n/messages_zh_CN.properties

@ -355,3 +355,5 @@ OPERATION_TYPE=操作类型
TASK_DEFINITION_TAG=任务定义相关操作
PROCESS_TASK_RELATION_TAG=工作流关系相关操作
ENVIRONMENT_TAG=环境相关操作
GET_PROCESS_LIST_BY_PROCESS_CODE_NOTES=通过项目代码查询工作流定义
GET_TASK_LIST_BY_PROCESS_CODE_NOTES=通过工作流定义代码查询任务定义

2
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DependentProcessDefinition.java

@ -110,7 +110,7 @@ public class DependentProcessDefinition {
return this.processDefinitionName;
}
public void setprocessDefinitionName(String name) {
public void setProcessDefinitionName(String name) {
this.processDefinitionName = name;
}

63
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DependentSimplifyDefinition.java

@ -0,0 +1,63 @@
/*
* 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.dao.entity;
/**
* dependent node simplify definition
*/
public class DependentSimplifyDefinition {
/**
* definition code
*/
private Long code;
/**
* definition name
*/
private String name;
/**
* definition version
*/
private Integer version;
public Long getCode() {
return this.code;
}
public void setCode(Long code) {
this.code = code;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public Integer getVersion() {
return this.version;
}
public void setVersion(Integer version) {
this.version = version;
}
}

10
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.java

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.dao.mapper;
import org.apache.dolphinscheduler.dao.entity.DefinitionGroupByUser;
import org.apache.dolphinscheduler.dao.entity.DependentSimplifyDefinition;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
import org.apache.ibatis.annotations.MapKey;
@ -124,6 +125,15 @@ public interface ProcessDefinitionMapper extends BaseMapper<ProcessDefinition> {
*/
List<ProcessDefinition> queryAllDefinitionList(@Param("projectCode") long projectCode);
/**
* query process definition list
*
* @param projectCode projectCode
* @return process definition list
*/
List<DependentSimplifyDefinition> queryDefinitionListByProjectCodeAndProcessDefinitionCodes(@Param("projectCode") long projectCode,
@Param("codes") Collection<Long> codes);
/**
* query process definition by ids
*

10
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessTaskRelationMapper.java

@ -124,6 +124,16 @@ public interface ProcessTaskRelationMapper extends BaseMapper<ProcessTaskRelatio
*/
List<ProcessTaskRelation> queryUpstreamByCodes(@Param("projectCode") long projectCode, @Param("taskCode") long taskCode, @Param("preTaskCodes") Long[] preTaskCodes);
/**
* query process task relation by process definition code
*
* @param processDefinitionCode process definition code
* @param processDefinitionVersion process definition version
* @return ProcessTaskRelation
*/
List<ProcessTaskRelation> queryProcessTaskRelationsByProcessDefinitionCode(@Param("processDefinitionCode") long processDefinitionCode,
@Param("processDefinitionVersion") Integer processDefinitionVersion);
/**
* count upstream by codes
*

13
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.xml

@ -94,6 +94,19 @@
where project_code = #{projectCode}
order by create_time desc
</select>
<select id="queryDefinitionListByProjectCodeAndProcessDefinitionCodes" resultType="org.apache.dolphinscheduler.dao.entity.DependentSimplifyDefinition">
select
code, name, version
from t_ds_process_definition
where 1=1
AND project_code = #{projectCode}
<if test="codes != null and codes.size() != 0">
and code in
<foreach collection="codes" index="index" item="i" open="(" separator="," close=")">
#{i}
</foreach>
</if>
</select>
<select id="queryDefinitionListByTenant" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
select
<include refid="baseSql"/>

10
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessTaskRelationMapper.xml

@ -128,6 +128,16 @@
group by process_definition_code
</select>
<select id="queryProcessTaskRelationsByProcessDefinitionCode" resultType="org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation">
SELECT
<include refid="baseSql"/>
FROM
t_ds_process_task_relation
WHERE 1=1
AND process_definition_code = #{processDefinitionCode}
AND process_definition_version = #{processDefinitionVersion}
</select>
<update id="batchUpdateProcessTaskRelationPreTask" parameterType="java.util.List">
<foreach collection="processTaskRelationList" item="processTaskRelation" index="index" open="" close="" separator=";">
update t_ds_process_task_relation

Loading…
Cancel
Save