Browse Source

[Feature][JsonSplit]fix modifyBy field (#5112)

* Modify Project and ProjectUser Mapper

* Modify Project and ProjectUser Mapper

* project_code is bigint(20)

* modify ERROR name

* modify saveProcessDefine, remove the duplicate code with createTaskAndRelation

* modify import/export processdefinition, add genProcessData

* fix ut and bug

* code style

* repalce project_id with code

* conflicts solve

* conflicts solve

* conflicts solve

* bugfix

* modify listResources mothod and remove getResourceIds mothod

* 1

* conflicts solve

* modify listResources mothod and remove getResourceIds mothod

* modify listResources mothod and remove getResourceIds mothod

* replace processDefinitionVersion with processDefinitionLog

* codestyle

* codestyle

* add mapper module ut

* codestyle

* fix ProcessInstanceMapperTest

* codestyle

* conflicts solve

* conflicts solve

* conflicts solve

* conflicts solve

* conflicts solve

* fix ProcessInstanceMapperTest

* fix ProjectMapperTest/ProjectUserMapperTest/ScheduleMapperTest

* fix ProjectMapperTest/ProjectUserMapperTest/ScheduleMapperTest

* fix TaskInstanceMapperTest

* add TaskDefinitionLogMapperTest/TaskDefinitionMapperTest and bugfix

* codestyle

* codestyle

* Refactor process lineage

* Refactor process lineage

* codestyle

* codestyle

* Refactor process lineage

* Refactor process lineage

* add WorkFlowLineageMapperTest/WorkFlowLineageServiceTest

* add WorkFlowLineageMapperTest/WorkFlowLineageServiceTest

* add ProcessServiceTest

* 1

* 1

* fix modifyBy field

* 1

* ut fix
pull/3/MERGE
Simon 4 years ago committed by GitHub
parent
commit
21b7b77d50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
  2. 5
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionLogMapper.java
  3. 8
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionLogMapper.xml
  4. 23
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionLogMapperTest.java

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

@ -66,6 +66,7 @@ import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper;
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper;
import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper;
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.apache.dolphinscheduler.service.permission.PermissionCheck;
import org.apache.dolphinscheduler.service.process.ProcessService;
@ -123,6 +124,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
@Autowired
private ProjectService projectService;
@Autowired
private UserMapper userMapper;
@Autowired
private ProcessDefinitionLogMapper processDefinitionLogMapper;
@ -270,11 +274,20 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
IPage<ProcessDefinition> processDefinitionIPage = processDefinitionMapper.queryDefineListPaging(
page, searchVal, userId, project.getCode(), isAdmin(loginUser));
processDefinitionIPage.setRecords(processDefinitionIPage.getRecords());
List<ProcessDefinition> records = processDefinitionIPage.getRecords();
for (ProcessDefinition pd : records) {
ProcessDefinitionLog processDefinitionLog = processDefinitionLogMapper.queryMaxVersionDefinitionLog(pd.getCode());
int operator = processDefinitionLog.getOperator();
User user = userMapper.selectById(operator);
pd.setModifyBy(user.getUserName());
}
processDefinitionIPage.setRecords(records);
PageInfo<ProcessDefinition> pageInfo = new PageInfo<>(pageNo, pageSize);
pageInfo.setTotalCount((int) processDefinitionIPage.getTotal());
pageInfo.setLists(processDefinitionIPage.getRecords());
pageInfo.setLists(records);
result.put(Constants.DATA_LIST, pageInfo);
putMsg(result, Status.SUCCESS);

5
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionLogMapper.java

@ -55,6 +55,11 @@ public interface ProcessDefinitionLogMapper extends BaseMapper<ProcessDefinition
*/
Integer queryMaxVersionForDefinition(@Param("processDefinitionCode") long processDefinitionCode);
/**
* query max version definition log
*/
ProcessDefinitionLog queryMaxVersionDefinitionLog(@Param("processDefinitionCode") long processDefinitionCode);
/**
* query the certain process definition version info by process definition code and version number
*

8
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionLogMapper.xml

@ -56,6 +56,14 @@
where code = #{processDefinitionCode}
</select>
<select id="queryMaxVersionDefinitionLog" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog">
select
<include refid="baseSql"/>
from t_ds_process_definition_log
where code = #{processDefinitionCode} order by version desc limit 1
</select>
<select id="queryProcessDefinitionVersionsPaging"
resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog">
select

23
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionLogMapperTest.java

@ -107,7 +107,7 @@ public class ProcessDefinitionLogMapperTest {
@Test
public void testQueryByDefinitionName() {
ProcessDefinitionLog processDefinitionLog = insertOne();
insertOne();
Project project = new Project();
project.setCode(1L);
project.setName("ut project");
@ -130,7 +130,7 @@ public class ProcessDefinitionLogMapperTest {
@Test
public void testQueryByDefinitionCode() {
ProcessDefinitionLog processDefinitionLog = insertOne();
insertOne();
List<ProcessDefinitionLog> processDefinitionLogs = processDefinitionLogMapper
.queryByDefinitionCode(1L);
@ -139,7 +139,7 @@ public class ProcessDefinitionLogMapperTest {
@Test
public void testQueryByDefinitionCodeAndVersion() {
ProcessDefinitionLog processDefinitionLog = insertOne();
insertOne();
ProcessDefinitionLog processDefinitionLogs = processDefinitionLogMapper
.queryByDefinitionCodeAndVersion(1L, 1);
@ -148,8 +148,8 @@ public class ProcessDefinitionLogMapperTest {
@Test
public void testQueryMaxVersionForDefinition() {
ProcessDefinitionLog processDefinitionLog = insertOne();
ProcessDefinitionLog processDefinitionLog1 = insertTwo();
insertOne();
insertTwo();
Integer version = processDefinitionLogMapper.queryMaxVersionForDefinition(1L);
Assert.assertEquals(2, version == null ? 1 : version);
@ -157,7 +157,7 @@ public class ProcessDefinitionLogMapperTest {
@Test
public void testQueryProcessDefinitionVersionsPaging() {
ProcessDefinitionLog processDefinitionLog = insertOne();
insertOne();
Page<ProcessDefinitionLog> page = new Page(1, 3);
IPage<ProcessDefinitionLog> processDefinitionLogs = processDefinitionLogMapper.queryProcessDefinitionVersionsPaging(page, 1L);
Assert.assertNotEquals(processDefinitionLogs.getTotal(), 0);
@ -165,10 +165,19 @@ public class ProcessDefinitionLogMapperTest {
@Test
public void testDeleteByProcessDefinitionCodeAndVersion() {
ProcessDefinitionLog processDefinitionLog = insertOne();
insertOne();
Page<ProcessDefinitionLog> page = new Page(1, 3);
int processDefinitionLogs = processDefinitionLogMapper.deleteByProcessDefinitionCodeAndVersion(1L, 1);
Assert.assertNotEquals(processDefinitionLogs, 0);
}
@Test
public void testQueryMaxVersionDefinitionLog() {
insertOne();
insertTwo();
ProcessDefinitionLog processDefinitionLog2 = processDefinitionLogMapper.queryMaxVersionDefinitionLog(1L);
Assert.assertEquals(2, processDefinitionLog2.getVersion());
}
}

Loading…
Cancel
Save