Browse Source

[Chore] remove unuse resource query (#16239)

* improve resource query
* remove unuse mapper method
dev
caishunfeng 6 months ago committed by GitHub
parent
commit
b686fed4be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 18
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.java
  2. 18
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionMapper.java
  3. 24
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.xml
  4. 10
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionMapper.xml
  5. 18
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapperTest.java
  6. 21
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionMapperTest.java

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

@ -21,12 +21,10 @@ import org.apache.dolphinscheduler.dao.entity.DependentSimplifyDefinition;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
import org.apache.dolphinscheduler.dao.model.WorkflowDefinitionCountDto;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -166,22 +164,6 @@ public interface ProcessDefinitionMapper extends BaseMapper<ProcessDefinition> {
@Param("userId") Integer userId,
@Param("releaseState") Integer releaseState);
/**
* list all resource ids
*
* @return resource ids list
*/
@MapKey("id")
List<Map<String, Object>> listResources();
/**
* list all resource ids by user id
*
* @return resource ids list
*/
@MapKey("id")
List<Map<String, Object>> listResourcesByUser(@Param("userId") Integer userId);
/**
* list all project ids
*

18
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionMapper.java

@ -23,12 +23,10 @@ import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog;
import org.apache.dolphinscheduler.dao.entity.TaskMainInfo;
import org.apache.dolphinscheduler.dao.model.WorkflowDefinitionCountDto;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -74,22 +72,6 @@ public interface TaskDefinitionMapper extends BaseMapper<TaskDefinition> {
*/
List<WorkflowDefinitionCountDto> countDefinitionGroupByUser(@Param("projectCodes") Long[] projectCodes);
/**
* list all resource ids and task_params containing resourceList
*
* @return task ids list
*/
@MapKey("id")
List<Map<String, Object>> listResources();
/**
* list all resource ids by user id
*
* @return resource ids list
*/
@MapKey("id")
List<Map<String, Object>> listResourcesByUser(@Param("userId") Integer userId);
/**
* delete task definition by code
*

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

@ -180,30 +180,6 @@
AND pd.id = #{processDefineId}
</select>
<select id="listResources" resultType="java.util.HashMap">
SELECT distinct pd.code, td.id as td_id, td.resource_ids
FROM t_ds_process_task_relation ptr
join t_ds_process_definition pd
on ptr.process_definition_code=pd.code and ptr.process_definition_version = pd.version
and ptr.project_code=pd.project_code and pd.release_state = 1
join t_ds_task_definition td
on (ptr.pre_task_code=td.code and ptr.pre_task_version=td.version)
or (ptr.post_task_code=td.code and ptr.post_task_version=td.version)
WHERE td.resource_ids is not null and td.resource_ids != ''
</select>
<select id="listResourcesByUser" resultType="java.util.HashMap">
SELECT distinct pd.code, td.id as td_id, td.resource_ids
FROM t_ds_process_task_relation ptr
join t_ds_process_definition pd
on ptr.process_definition_code=pd.code and ptr.process_definition_version = pd.version
and ptr.project_code=pd.project_code and pd.release_state = 1
join t_ds_task_definition td
on (ptr.pre_task_code=td.code and ptr.pre_task_version=td.version)
or (ptr.post_task_code=td.code and ptr.post_task_version=td.version)
WHERE td.resource_ids is not null and td.resource_ids != '' and td.user_id = #{userId}
</select>
<select id="listProjectIds" resultType="java.lang.Integer">
SELECT DISTINCT(id) as project_id
FROM t_ds_project

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

@ -71,17 +71,7 @@
from t_ds_task_definition
where code = #{code}
</select>
<select id="listResources" resultType="java.util.HashMap">
SELECT id,resource_ids
FROM t_ds_task_definition
WHERE resource_ids is not null and resource_ids != ''
</select>
<select id="listResourcesByUser" resultType="java.util.HashMap">
SELECT id,resource_ids
FROM t_ds_task_definition
WHERE user_id = #{userId} and resource_ids is not null and resource_ids != ''
</select>
<delete id="deleteByCode">
delete from t_ds_task_definition
where code = #{code}

18
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapperTest.java

@ -17,7 +17,6 @@
package org.apache.dolphinscheduler.dao.mapper;
import org.apache.dolphinscheduler.common.enums.ReleaseState;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.dao.BaseDaoTest;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
@ -29,7 +28,6 @@ import org.apache.dolphinscheduler.dao.model.WorkflowDefinitionCountDto;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import org.junit.jupiter.api.Assertions;
@ -302,22 +300,6 @@ public class ProcessDefinitionMapperTest extends BaseDaoTest {
Assertions.assertNotEquals(0, processDefinitions.size());
}
@Test
public void listResourcesTest() {
ProcessDefinition processDefinition = insertOne("def 1");
processDefinition.setReleaseState(ReleaseState.ONLINE);
List<Map<String, Object>> maps = processDefinitionMapper.listResources();
Assertions.assertNotNull(maps);
}
@Test
public void listResourcesByUserTest() {
ProcessDefinition processDefinition = insertOne("def 1");
processDefinition.setReleaseState(ReleaseState.ONLINE);
List<Map<String, Object>> maps = processDefinitionMapper.listResourcesByUser(processDefinition.getUserId());
Assertions.assertNotNull(maps);
}
@Test
public void listProjectIds() {
insertOne("def 1");

21
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionMapperTest.java

@ -129,27 +129,6 @@ public class TaskDefinitionMapperTest extends BaseDaoTest {
}
@Test
public void testListResources() {
TaskDefinition taskDefinition = insertOne();
List<Map<String, Object>> maps = taskDefinitionMapper.listResources();
Assertions.assertNotEquals(0, maps.size());
}
@Test
public void testListResourcesByUser() {
User user = new User();
user.setUserName("un");
userMapper.insert(user);
User un = userMapper.queryByUserNameAccurately("un");
TaskDefinition taskDefinition = insertOne(un.getId());
List<Map<String, Object>> maps = taskDefinitionMapper.listResourcesByUser(taskDefinition.getUserId());
Assertions.assertNotEquals(0, maps.size());
}
@Test
public void testDeleteByCode() {
TaskDefinition taskDefinition = insertOne();

Loading…
Cancel
Save