Browse Source

[Feature][jsonsplit] repalce project_id with code (#4904)

* 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
pull/3/MERGE
Simon 4 years ago committed by GitHub
parent
commit
c342980032
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 40
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataAnalysisServiceImpl.java
  2. 25
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
  3. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
  4. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/exportprocess/DependentParam.java
  5. 10
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataAnalysisServiceTest.java
  6. 16
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
  7. 4
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectServiceTest.java
  8. 4
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinition.java
  9. 4
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/CommandMapper.java
  10. 4
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapper.java
  11. 20
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.java
  12. 4
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapper.java
  13. 2
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.java
  14. 6
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/CommandMapper.xml
  15. 6
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapper.xml
  16. 45
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.xml
  17. 6
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapper.xml
  18. 6
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.xml
  19. 9
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/CommandMapperTest.java
  20. 12
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapperTest.java
  21. 38
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapperTest.java
  22. 4
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapperTest.java
  23. 8
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapperTest.java
  24. 10
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java

40
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataAnalysisServiceImpl.java

@ -102,7 +102,7 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
projectId,
startDate,
endDate,
(start, end, projectIds) -> this.taskInstanceMapper.countTaskInstanceStateByUser(start, end, projectIds));
(start, end, projectCodes) -> this.taskInstanceMapper.countTaskInstanceStateByUser(start, end, projectCodes));
}
/**
@ -121,7 +121,7 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
projectId,
startDate,
endDate,
(start, end, projectIds) -> this.processInstanceMapper.countInstanceStateByUser(start, end, projectIds));
(start, end, projectCodes) -> this.processInstanceMapper.countInstanceStateByUser(start, end, projectCodes));
// process state count needs to remove state of forced success
if (result.containsKey(Constants.STATUS) && result.get(Constants.STATUS).equals(Status.SUCCESS)) {
((TaskCountDto)result.get(Constants.DATA_LIST)).removeStateFromCountList(ExecutionStatus.FORCED_SUCCESS);
@ -130,7 +130,7 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
}
private Map<String, Object> countStateByProject(User loginUser, int projectId, String startDate, String endDate
, TriFunction<Date, Date, Integer[], List<ExecuteStatusCount>> instanceStateCounter) {
, TriFunction<Date, Date, Long[], List<ExecuteStatusCount>> instanceStateCounter) {
Map<String, Object> result = new HashMap<>();
boolean checkProject = checkProject(loginUser, projectId, result);
if (!checkProject) {
@ -148,9 +148,10 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
}
}
Integer[] projectIdArray = getProjectIdsArrays(loginUser, projectId);
Project project = projectMapper.selectById(projectId);
Long[] projectCodeArray = getProjectCodesArrays(loginUser, project.getCode());
List<ExecuteStatusCount> processInstanceStateCounts =
instanceStateCounter.apply(start, end, projectIdArray);
instanceStateCounter.apply(start, end, projectCodeArray);
if (processInstanceStateCounts != null) {
TaskCountDto taskCountResult = new TaskCountDto(processInstanceStateCounts);
@ -172,9 +173,10 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
public Map<String, Object> countDefinitionByUser(User loginUser, int projectId) {
Map<String, Object> result = new HashMap<>();
Integer[] projectIdArray = getProjectIdsArrays(loginUser, projectId);
Project project = projectMapper.selectById(projectId);
Long[] projectCodeArray = getProjectCodesArrays(loginUser, project.getCode());
List<DefinitionGroupByUser> defineGroupByUsers = processDefinitionMapper.countDefinitionGroupByUser(
loginUser.getId(), projectIdArray, isAdmin(loginUser));
loginUser.getId(), projectCodeArray, isAdmin(loginUser));
DefineUserDto dto = new DefineUserDto(defineGroupByUsers);
result.put(Constants.DATA_LIST, dto);
@ -201,6 +203,8 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
return result;
}
Project project = projectMapper.selectById(projectId);
/**
* find all the task lists in the project under the user
* statistics based on task status execution, failure, completion, wait, total
@ -222,14 +226,14 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
}
}
Integer[] projectIdArray = getProjectIdsArrays(loginUser, projectId);
Long[] projectCodeArray = getProjectCodesArrays(loginUser, project.getCode());
// count normal command state
Map<CommandType, Integer> normalCountCommandCounts = commandMapper.countCommandState(loginUser.getId(), start, end, projectIdArray)
Map<CommandType, Integer> normalCountCommandCounts = commandMapper.countCommandState(loginUser.getId(), start, end, projectCodeArray)
.stream()
.collect(Collectors.toMap(CommandCount::getCommandType, CommandCount::getCount));
// count error command state
Map<CommandType, Integer> errorCommandCounts = errorCommandMapper.countCommandState(start, end, projectIdArray)
Map<CommandType, Integer> errorCommandCounts = errorCommandMapper.countCommandState(start, end, projectCodeArray)
.stream()
.collect(Collectors.toMap(CommandCount::getCommandType, CommandCount::getCount));
@ -245,17 +249,17 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
return result;
}
private Integer[] getProjectIdsArrays(User loginUser, int projectId) {
List<Integer> projectIds = new ArrayList<>();
if (projectId != 0) {
projectIds.add(projectId);
private Long[] getProjectCodesArrays(User loginUser, Long projectCode) {
List<Long> projectCodes = new ArrayList<>();
if (projectCode != 0) {
projectCodes.add(projectCode);
} else if (loginUser.getUserType() == UserType.GENERAL_USER) {
projectIds = processService.getProjectIdListHavePerm(loginUser.getId());
if (projectIds.isEmpty()) {
projectIds.add(0);
projectCodes = processService.getProjectIdListHavePerm(loginUser.getId());
if (projectCodes.isEmpty()) {
projectCodes.add(0L);
}
}
return projectIds.toArray(new Integer[0]);
return projectCodes.toArray(new Long[0]);
}
/**

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

@ -276,7 +276,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
return checkResult;
}
List<ProcessDefinition> resourceList = processDefinitionMapper.queryAllDefinitionList(project.getId());
List<ProcessDefinition> resourceList = processDefinitionMapper.queryAllDefinitionList(project.getCode());
resourceList.stream().forEach(processDefinition -> {
ProcessData processData = processService.genProcessData(processDefinition);
@ -314,7 +314,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
Page<ProcessDefinition> page = new Page<>(pageNo, pageSize);
IPage<ProcessDefinition> processDefinitionIPage = processDefinitionMapper.queryDefineListPaging(
page, searchVal, userId, project.getId(), isAdmin(loginUser));
page, searchVal, userId, project.getCode(), isAdmin(loginUser));
List<ProcessDefinition> records = processDefinitionIPage.getRecords();
records.stream().forEach(processDefinition -> {
@ -377,7 +377,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
return checkResult;
}
ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(project.getId(), processDefinitionName);
ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(project.getCode(), processDefinitionName);
if (processDefinition == null) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processDefinitionName);
@ -440,7 +440,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
if (!name.equals(processDefinition.getName())) {
// check whether the new process define name exist
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(project.getId(), name);
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(project.getCode(), name);
if (definition != null) {
putMsg(result, Status.PROCESS_DEFINITION_NAME_EXIST, name);
return result;
@ -479,7 +479,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
if (resultEnum != Status.SUCCESS) {
return checkResult;
}
ProcessDefinition processDefinition = processDefinitionMapper.verifyByDefineName(project.getId(), name);
ProcessDefinition processDefinition = processDefinitionMapper.verifyByDefineName(project.getCode(), name);
if (processDefinition == null) {
putMsg(result, Status.SUCCESS);
} else {
@ -847,7 +847,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
//use currentProjectName to query
Project targetProject = projectMapper.queryByName(currentProjectName);
if (null != targetProject) {
processDefinitionName = recursionProcessDefinitionName(targetProject.getId(),
processDefinitionName = recursionProcessDefinitionName(targetProject.getCode(),
processDefinitionName, 1);
}
@ -1077,7 +1077,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
String subProcessJson = JSONUtils.toJsonString(processService.genProcessData(subProcess));
//check current project has sub process
ProcessDefinition currentProjectSubProcess = processDefinitionMapper.queryByDefineName(targetProject.getId(), subProcess.getName());
ProcessDefinition currentProjectSubProcess = processDefinitionMapper.queryByDefineName(targetProject.getCode(), subProcess.getName());
if (null == currentProjectSubProcess) {
ArrayNode subJsonArray = (ArrayNode) JSONUtils.parseObject(subProcessJson).get(TASKS);
@ -1116,7 +1116,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
//modify task node
ProcessDefinition newSubProcessDefine = processDefinitionMapper.queryByDefineName(subProcess.getProjectId(), subProcess.getName());
ProcessDefinition newSubProcessDefine = processDefinitionMapper.queryByDefineName(subProcess.getCode(), subProcess.getName());
if (null != newSubProcessDefine) {
subProcessCodeMap.put(subProcessCode, newSubProcessDefine.getCode());
@ -1262,7 +1262,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
HashMap<String, Object> result = new HashMap<>();
List<ProcessDefinition> resourceList = processDefinitionMapper.queryAllDefinitionList(projectId);
Project project = projectMapper.selectById(projectId);
List<ProcessDefinition> resourceList = processDefinitionMapper.queryAllDefinitionList(project.getCode());
resourceList.stream().forEach(processDefinition -> {
ProcessData processData = processService.genProcessData(processDefinition);
processDefinition.setProcessDefinitionJson(JSONUtils.toJsonString(processData));
@ -1432,8 +1433,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
return graph.hasCycle();
}
private String recursionProcessDefinitionName(Integer projectId, String processDefinitionName, int num) {
ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(projectId, processDefinitionName);
private String recursionProcessDefinitionName(Long projectCode, String processDefinitionName, int num) {
ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(projectCode, processDefinitionName);
if (processDefinition != null) {
if (num > 1) {
String str = processDefinitionName.substring(0, processDefinitionName.length() - 3);
@ -1444,7 +1445,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
} else {
return processDefinitionName;
}
return recursionProcessDefinitionName(projectId, processDefinitionName, num + 1);
return recursionProcessDefinitionName(projectCode, processDefinitionName, num + 1);
}
private Map<String, Object> copyProcessDefinition(User loginUser,

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java

@ -224,7 +224,7 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
return result;
}
List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryAllDefinitionList(projectId);
List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryAllDefinitionList(project.getCode());
if (!processDefinitionList.isEmpty()) {
putMsg(result, Status.DELETE_PROJECT_ERROR_DEFINES_NOT_NULL);

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/exportprocess/DependentParam.java

@ -91,7 +91,7 @@ public class DependentParam implements ProcessAddTaskParam, InitializingBean {
ObjectNode dependentItem = (ObjectNode) dependItemList.path(k);
Project dependentItemProject = projectMapper.queryByName(dependentItem.path("projectName").asText());
if(dependentItemProject != null){
ProcessDefinition definition = processDefineMapper.queryByDefineName(dependentItemProject.getId(),dependentItem.path("definitionName").asText());
ProcessDefinition definition = processDefineMapper.queryByDefineName(dependentItemProject.getCode(),dependentItem.path("definitionName").asText());
if(definition != null){
dependentItem.put("projectId",dependentItemProject.getId());
dependentItem.put("definitionId",definition.getId());

10
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataAnalysisServiceTest.java

@ -130,7 +130,7 @@ public class DataAnalysisServiceTest {
//SUCCESS
Mockito.when(taskInstanceMapper.countTaskInstanceStateByUser(DateUtils.getScheduleDate(startDate),
DateUtils.getScheduleDate(endDate), new Integer[]{1})).thenReturn(getTaskInstanceStateCounts());
DateUtils.getScheduleDate(endDate), new Long[]{1L})).thenReturn(getTaskInstanceStateCounts());
result = dataAnalysisService.countTaskStateByProject(user, 1, startDate, endDate);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
@ -156,7 +156,7 @@ public class DataAnalysisServiceTest {
// when counting general user's task status then return user's task status count
user.setUserType(UserType.GENERAL_USER);
Mockito.when(processService.getProjectIdListHavePerm(anyInt()))
.thenReturn(Collections.singletonList(123));
.thenReturn(Collections.singletonList(123L));
ExecuteStatusCount executeStatusCount = new ExecuteStatusCount();
executeStatusCount.setExecutionStatus(ExecutionStatus.RUNNING_EXECUTION);
executeStatusCount.setCount(10);
@ -216,7 +216,7 @@ public class DataAnalysisServiceTest {
//SUCCESS
Mockito.when(processInstanceMapper.countInstanceStateByUser(DateUtils.getScheduleDate(startDate),
DateUtils.getScheduleDate(endDate), new Integer[]{1})).thenReturn(getTaskInstanceStateCounts());
DateUtils.getScheduleDate(endDate), new Long[]{1L})).thenReturn(getTaskInstanceStateCounts());
result = dataAnalysisService.countProcessInstanceStateByProject(user, 1, startDate, endDate);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
}
@ -241,10 +241,10 @@ public class DataAnalysisServiceTest {
commandCount.setCommandType(CommandType.START_PROCESS);
commandCounts.add(commandCount);
Mockito.when(commandMapper.countCommandState(0, DateUtils.getScheduleDate(startDate),
DateUtils.getScheduleDate(endDate), new Integer[]{1})).thenReturn(commandCounts);
DateUtils.getScheduleDate(endDate), new Long[]{1L})).thenReturn(commandCounts);
Mockito.when(errorCommandMapper.countCommandState(DateUtils.getScheduleDate(startDate),
DateUtils.getScheduleDate(endDate), new Integer[]{1})).thenReturn(commandCounts);
DateUtils.getScheduleDate(endDate), new Long[]{1L})).thenReturn(commandCounts);
result = dataAnalysisService.countCommandState(user, 1, startDate, endDate);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));

16
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java

@ -279,7 +279,7 @@ public class ProcessDefinitionServiceTest {
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result);
List<ProcessDefinition> resourceList = new ArrayList<>();
resourceList.add(getProcessDefinition());
Mockito.when(processDefineMapper.queryAllDefinitionList(project.getId())).thenReturn(resourceList);
Mockito.when(processDefineMapper.queryAllDefinitionList(project.getCode())).thenReturn(resourceList);
Map<String, Object> checkSuccessRes = processDefinitionService.queryProcessDefinitionList(loginUser, "project_test1");
Assert.assertEquals(Status.SUCCESS, checkSuccessRes.get(Constants.STATUS));
}
@ -313,7 +313,7 @@ public class ProcessDefinitionServiceTest {
Mockito.any(IPage.class)
, Mockito.eq("")
, Mockito.eq(loginUser.getId())
, Mockito.eq(project.getId())
, Mockito.eq(project.getCode())
, Mockito.anyBoolean())).thenReturn(page);
Map<String, Object> map1 = processDefinitionService.queryProcessDefinitionListPaging(
@ -391,7 +391,7 @@ public class ProcessDefinitionServiceTest {
//project check auth success, instance not exist
putMsg(result, Status.SUCCESS, projectName);
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result);
Mockito.when(processDefineMapper.queryByDefineName(project.getId(), "test_def")).thenReturn(null);
Mockito.when(processDefineMapper.queryByDefineName(project.getCode(), "test_def")).thenReturn(null);
String processDefinitionJson = "{\"globalParams\":[],\"tasks\":[{\"conditionResult\":"
+ "{\"failedNode\":[\"\"],\"successNode\":[\"\"]},\"delayTime\":\"0\",\"dependence\":{}"
@ -407,7 +407,7 @@ public class ProcessDefinitionServiceTest {
Assert.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, instanceNotexitRes.get(Constants.STATUS));
//instance exit
Mockito.when(processDefineMapper.queryByDefineName(project.getId(), "test")).thenReturn(getProcessDefinition());
Mockito.when(processDefineMapper.queryByDefineName(project.getCode(), "test")).thenReturn(getProcessDefinition());
Map<String, Object> successRes = processDefinitionService.queryProcessDefinitionByName(loginUser,
"project_test1", "test");
Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS));
@ -691,13 +691,13 @@ public class ProcessDefinitionServiceTest {
//project check auth success, process not exist
putMsg(result, Status.SUCCESS, projectName);
Mockito.when(processDefineMapper.verifyByDefineName(project.getId(), "test_pdf")).thenReturn(null);
Mockito.when(processDefineMapper.verifyByDefineName(project.getCode(), "test_pdf")).thenReturn(null);
Map<String, Object> processNotExistRes = processDefinitionService.verifyProcessDefinitionName(loginUser,
"project_test1", "test_pdf");
Assert.assertEquals(Status.SUCCESS, processNotExistRes.get(Constants.STATUS));
//process exist
Mockito.when(processDefineMapper.verifyByDefineName(project.getId(), "test_pdf")).thenReturn(getProcessDefinition());
Mockito.when(processDefineMapper.verifyByDefineName(project.getCode(), "test_pdf")).thenReturn(getProcessDefinition());
Map<String, Object> processExistRes = processDefinitionService.verifyProcessDefinitionName(loginUser,
"project_test1", "test_pdf");
Assert.assertEquals(Status.PROCESS_DEFINITION_NAME_EXIST, processExistRes.get(Constants.STATUS));
@ -791,7 +791,8 @@ public class ProcessDefinitionServiceTest {
processDefinition.setProcessDefinitionJson(SHELL_JSON);
List<ProcessDefinition> processDefinitionList = new ArrayList<>();
processDefinitionList.add(processDefinition);
Mockito.when(processDefineMapper.queryAllDefinitionList(projectId)).thenReturn(processDefinitionList);
Project project = projectMapper.selectById(projectId);
Mockito.when(processDefineMapper.queryAllDefinitionList(project.getCode())).thenReturn(processDefinitionList);
Map<String, Object> successRes = processDefinitionService.queryProcessDefinitionAllByProjectId(projectId);
Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS));
}
@ -1276,6 +1277,7 @@ public class ProcessDefinitionServiceTest {
*/
private Project getProject(String projectName) {
Project project = new Project();
project.setCode(1L);
project.setId(1);
project.setName(projectName);
project.setUserId(1);

4
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectServiceTest.java

@ -216,7 +216,7 @@ public class ProjectServiceTest {
Assert.assertEquals(Status.USER_NO_OPERATION_PROJECT_PERM, result.get(Constants.STATUS));
//DELETE_PROJECT_ERROR_DEFINES_NOT_NULL
Mockito.when(processDefinitionMapper.queryAllDefinitionList(1)).thenReturn(getProcessDefinitions());
Mockito.when(processDefinitionMapper.queryAllDefinitionList(1L)).thenReturn(getProcessDefinitions());
loginUser.setUserType(UserType.ADMIN_USER);
result = projectService.deleteProject(loginUser, 1);
logger.info(result.toString());
@ -224,7 +224,7 @@ public class ProjectServiceTest {
//success
Mockito.when(projectMapper.deleteById(1)).thenReturn(1);
Mockito.when(processDefinitionMapper.queryAllDefinitionList(1)).thenReturn(new ArrayList<>());
Mockito.when(processDefinitionMapper.queryAllDefinitionList(1L)).thenReturn(new ArrayList<>());
result = projectService.deleteProject(loginUser, 1);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));

4
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinition.java

@ -72,6 +72,7 @@ public class ProcessDefinition {
* project id
* TODO: delete
*/
@TableField(exist = false)
private int projectId;
/**
@ -83,6 +84,7 @@ public class ProcessDefinition {
* definition json string
* TODO: delete
*/
@TableField(exist = false)
private String processDefinitionJson;
/**
@ -171,11 +173,13 @@ public class ProcessDefinition {
/**
* modify user name
*/
@TableField(exist = false)
private String modifyBy;
/**
* resource ids
*/
@TableField(exist = false)
private String resourceIds;
/**

4
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/CommandMapper.java

@ -41,14 +41,14 @@ public interface CommandMapper extends BaseMapper<Command> {
* @param userId userId
* @param startTime startTime
* @param endTime endTime
* @param projectIdArray projectIdArray
* @param projectCodeArray projectCodeArray
* @return CommandCount list
*/
List<CommandCount> countCommandState(
@Param("userId") int userId,
@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("projectIdArray") Integer[] projectIdArray);
@Param("projectCodeArray") Long[] projectCodeArray);

4
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapper.java

@ -33,11 +33,11 @@ public interface ErrorCommandMapper extends BaseMapper<ErrorCommand> {
* count command state
* @param startTime startTime
* @param endTime endTime
* @param projectIdArray projectIdArray
* @param projectCodeArray projectCodeArray
* @return CommandCount list
*/
List<CommandCount> countCommandState(
@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("projectIdArray") Integer[] projectIdArray);
@Param("projectCodeArray") Long[] projectCodeArray);
}

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

@ -62,21 +62,21 @@ public interface ProcessDefinitionMapper extends BaseMapper<ProcessDefinition> {
/**
* verify process definition by name
*
* @param projectId projectId
* @param projectCode projectCode
* @param name name
* @return process definition
*/
ProcessDefinition verifyByDefineName(@Param("projectId") int projectId,
ProcessDefinition verifyByDefineName(@Param("projectCode") Long projectCode,
@Param("processDefinitionName") String name);
/**
* query process definition by name
*
* @param projectId projectId
* @param projectCode projectCode
* @param name name
* @return process definition
*/
ProcessDefinition queryByDefineName(@Param("projectId") int projectId,
ProcessDefinition queryByDefineName(@Param("projectCode") Long projectCode,
@Param("processDefinitionName") String name);
/**
@ -93,23 +93,23 @@ public interface ProcessDefinitionMapper extends BaseMapper<ProcessDefinition> {
* @param page page
* @param searchVal searchVal
* @param userId userId
* @param projectId projectId
* @param projectCode projectCode
* @param isAdmin isAdmin
* @return process definition IPage
*/
IPage<ProcessDefinition> queryDefineListPaging(IPage<ProcessDefinition> page,
@Param("searchVal") String searchVal,
@Param("userId") int userId,
@Param("projectId") int projectId,
@Param("projectCode") Long projectCode,
@Param("isAdmin") boolean isAdmin);
/**
* query all process definition list
*
* @param projectId projectId
* @param projectCode projectCode
* @return process definition list
*/
List<ProcessDefinition> queryAllDefinitionList(@Param("projectId") int projectId);
List<ProcessDefinition> queryAllDefinitionList(@Param("projectCode") Long projectCode);
/**
* query process definition by ids
@ -131,13 +131,13 @@ public interface ProcessDefinitionMapper extends BaseMapper<ProcessDefinition> {
* count process definition group by user
*
* @param userId userId
* @param projectIds projectIds
* @param projectCodes projectCodes
* @param isAdmin isAdmin
* @return process definition list
*/
List<DefinitionGroupByUser> countDefinitionGroupByUser(
@Param("userId") Integer userId,
@Param("projectIds") Integer[] projectIds,
@Param("projectCodes") Long[] projectCodes,
@Param("isAdmin") boolean isAdmin);
/**

4
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapper.java

@ -145,13 +145,13 @@ public interface ProcessInstanceMapper extends BaseMapper<ProcessInstance> {
* count process instance state by user
* @param startTime startTime
* @param endTime endTime
* @param projectIds projectIds
* @param projectCodes projectCodes
* @return ExecuteStatusCount list
*/
List<ExecuteStatusCount> countInstanceStateByUser(
@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("projectIds") Integer[] projectIds);
@Param("projectCodes") Long[] projectCodes);
/**
* query process instance by processDefinitionId

2
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.java

@ -58,7 +58,7 @@ public interface TaskInstanceMapper extends BaseMapper<TaskInstance> {
List<ExecuteStatusCount> countTaskInstanceStateByUser(
@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("projectIds") Integer[] projectIds);
@Param("projectCodes") Long[] projectCodes);
IPage<TaskInstance> queryTaskInstanceListPaging(IPage<TaskInstance> page,
@Param("projectId") int projectId,

6
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/CommandMapper.xml

@ -32,9 +32,9 @@
select cmd.command_type as command_type, count(1) as count
from t_ds_command cmd, t_ds_process_definition process
where cmd.process_definition_id = process.id
<if test="projectIdArray != null and projectIdArray.length != 0">
and process.project_id in
<foreach collection="projectIdArray" index="index" item="i" open="(" close=")" separator=",">
<if test="projectCodeArray != null and projectCodeArray.length != 0">
and process.project_code in
<foreach collection="projectCodeArray" index="index" item="i" open="(" close=")" separator=",">
#{i}
</foreach>
</if>

6
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapper.xml

@ -22,9 +22,9 @@
select cmd.command_type as command_type, count(1) as count
from t_ds_error_command cmd, t_ds_process_definition process
where cmd.process_definition_id = process.id
<if test="projectIdArray != null and projectIdArray.length != 0">
and process.project_id in
<foreach collection="projectIdArray" index="index" item="i" open="(" close=")" separator=",">
<if test="projectCodeArray != null and projectCodeArray.length != 0">
and process.project_code in
<foreach collection="projectCodeArray" index="index" item="i" open="(" close=")" separator=",">
#{i}
</foreach>
</if>

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

@ -19,17 +19,17 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper">
<sql id="baseSql">
id, code, name, version, release_state, project_id, project_code, user_id, description,
id, code, name, version, release_state, project_code, user_id, description,
global_params, flag, locations, connects, warning_group_id, create_time, timeout,
tenant_id, update_time, modify_by, resource_ids
tenant_id, update_time
</sql>
<select id="verifyByDefineName" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
select pd.id, pd.name, pd.version, pd.release_state, pd.project_id, pd.user_id, pd.description,
select pd.id, pd.code, pd.name, pd.version, pd.release_state, pd.project_code, pd.user_id, pd.description,
pd.global_params, pd.flag, pd.locations, pd.connects, pd.warning_group_id, pd.create_time, pd.timeout,
pd.tenant_id, pd.update_time, pd.modify_by, pd.resource_ids
pd.tenant_id, pd.update_time
from t_ds_process_definition pd
WHERE pd.project_id = #{projectId}
WHERE pd.project_code = #{projectCode}
and pd.name = #{processDefinitionName}
</select>
@ -58,28 +58,27 @@
</select>
<select id="queryByDefineName" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
select pd.id, pd.name, pd.version, pd.release_state, pd.project_id, pd.user_id, pd.description,
select pd.id, pd.code, pd.name, pd.version, pd.release_state, pd.project_code, p.id as project_id, pd.user_id, pd.description,
pd.global_params, pd.flag, pd.locations, pd.connects, pd.warning_group_id, pd.create_time, pd.timeout,
pd.tenant_id, pd.update_time, pd.modify_by, pd.resource_ids,
pd.tenant_id, pd.update_time,
u.user_name,p.name as project_name,t.tenant_code,q.queue,q.queue_name
from t_ds_process_definition pd
JOIN t_ds_user u ON pd.user_id = u.id
JOIN t_ds_project p ON pd.project_id = p.id
JOIN t_ds_project p ON pd.project_code = p.code
JOIN t_ds_tenant t ON t.id = u.tenant_id
JOIN t_ds_queue q ON t.queue_id = q.id
WHERE p.id = #{projectId}
WHERE p.code = #{projectCode}
and pd.name = #{processDefinitionName}
</select>
<select id="queryDefineListPaging" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
SELECT td.id, td.name, td.version, td.release_state, td.project_id, td.user_id, td.description,
td.global_params,
td.flag, td.warning_group_id, td.timeout, td.tenant_id, td.modify_by, td.update_time, td.create_time,
SELECT td.id, td.name, td.version, td.release_state, td.project_code, td.user_id, td.description,
td.global_params, td.flag, td.warning_group_id, td.timeout, td.tenant_id, td.update_time, td.create_time,
sc.schedule_release_state, tu.user_name
FROM t_ds_process_definition td
left join (select process_definition_id,release_state as schedule_release_state from t_ds_schedules group by
process_definition_id,release_state) sc on sc.process_definition_id = td.id
left join t_ds_user tu on td.user_id = tu.id
where td.project_id = #{projectId}
where td.project_code = #{projectCode}
<if test=" searchVal != null and searchVal != ''">
and td.name like concat('%', #{searchVal}, '%')
</if>
@ -93,7 +92,7 @@
select
<include refid="baseSql"/>
from t_ds_process_definition
where project_id = #{projectId}
where project_code = #{projectCode}
order by create_time desc
</select>
<select id="queryDefinitionListByTenant" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
@ -116,9 +115,9 @@
FROM t_ds_process_definition td
JOIN t_ds_user tu on tu.id=td.user_id
where 1 = 1
<if test="projectIds != null and projectIds.length != 0">
and td.project_id in
<foreach collection="projectIds" index="index" item="i" open="(" separator="," close=")">
<if test="projectCodes != null and projectCodes.length != 0">
and td.project_code in
<foreach collection="projectCodes" index="index" item="i" open="(" separator="," close=")">
#{i}
</foreach>
</if>
@ -126,17 +125,15 @@
</select>
<select id="queryByDefineId" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
SELECT
pd.id, pd.name, pd.version, pd.release_state, pd.project_id, pd.user_id, pd.description,
pd.id, pd.code, pd.name, pd.version, pd.release_state, pd.project_code, pd.user_id, pd.description,
pd.global_params, pd.flag, pd.locations, pd.connects, pd.warning_group_id, pd.create_time, pd.timeout,
pd.tenant_id, pd.update_time, pd.modify_by, pd.resource_ids,
u.user_name,
p.name AS project_name
pd.tenant_id, pd.update_time, u.user_name,p.name AS project_name
FROM
t_ds_process_definition pd,
t_ds_user u,
t_ds_project p
WHERE
pd.user_id = u.id AND pd.project_id = p.id
pd.user_id = u.id AND pd.project_code = p.code
AND pd.id = #{processDefineId}
</select>
@ -154,8 +151,8 @@
</select>
<select id="listProjectIds" resultType="java.lang.Integer">
SELECT DISTINCT(project_id) as project_id
FROM t_ds_process_definition
SELECT DISTINCT(id) as project_id
FROM t_ds_project
</select>

6
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapper.xml

@ -154,9 +154,9 @@
<if test="startTime != null and endTime != null">
and t.start_time <![CDATA[ >= ]]> #{startTime} and t.start_time <![CDATA[ <= ]]> #{endTime}
</if>
<if test="projectIds != null and projectIds.length != 0">
and p.id in
<foreach collection="projectIds" index="index" item="i" open="(" close=")" separator=",">
<if test="projectCodes != null and projectCodes.length != 0">
and p.code in
<foreach collection="projectCodes" index="index" item="i" open="(" close=")" separator=",">
#{i}
</foreach>
</if>

6
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.xml

@ -75,9 +75,9 @@
left join t_ds_process_definition d on d.code=t.process_definition_code
left join t_ds_project p on p.id=d.project_id
where 1=1
<if test="projectIds != null and projectIds.length != 0">
and d.project_id in
<foreach collection="projectIds" index="index" item="i" open="(" separator="," close=")">
<if test="projectCodes != null and projectCodes.length != 0">
and d.project_code in
<foreach collection="projectCodes" index="index" item="i" open="(" separator="," close=")">
#{i}
</foreach>
</if>

9
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/CommandMapperTest.java

@ -156,13 +156,13 @@ public class CommandMapperTest {
CommandCount expectedCommandCount = createCommandMap(count, CommandType.START_PROCESS, processDefinition.getId());
Integer[] projectIdArray = {processDefinition.getProjectId()};
Long[] projectCodeArray = {processDefinition.getProjectCode()};
Date startTime = DateUtils.stringToDate("2019-12-29 00:10:00");
Date endTime = DateUtils.stringToDate("2019-12-29 23:59:59");
List<CommandCount> actualCommandCounts = commandMapper.countCommandState(0, startTime, endTime, projectIdArray);
List<CommandCount> actualCommandCounts = commandMapper.countCommandState(0, startTime, endTime, projectCodeArray);
assertThat(actualCommandCounts.size(),greaterThanOrEqualTo(1));
}
@ -197,10 +197,13 @@ public class CommandMapperTest {
*/
private ProcessDefinition createProcessDefinition(){
ProcessDefinition processDefinition = new ProcessDefinition();
processDefinition.setCode(1L);
processDefinition.setReleaseState(ReleaseState.ONLINE);
processDefinition.setName("ut test");
processDefinition.setProjectId(1);
processDefinition.setProjectCode(1L);
processDefinition.setFlag(Flag.YES);
processDefinition.setCreateTime(new Date());
processDefinition.setUpdateTime(new Date());
processDefinitionMapper.insert(processDefinition);

12
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapperTest.java

@ -74,7 +74,7 @@ public class ErrorCommandMapperTest {
ProcessDefinition processDefinition = new ProcessDefinition();
processDefinition.setName("def 1");
processDefinition.setProjectId(1010);
processDefinition.setProjectCode(1010L);
processDefinition.setUserId(101);
processDefinition.setUpdateTime(new Date());
processDefinition.setCreateTime(new Date());
@ -87,16 +87,16 @@ public class ErrorCommandMapperTest {
List<CommandCount> commandCounts = errorCommandMapper.countCommandState(
null,
null,
new Integer[0]
new Long[0]
);
Integer[] projectIdArray = new Integer[2];
projectIdArray[0] = processDefinition.getProjectId();
projectIdArray[1] = 200;
Long[] projectCodeArray = new Long[2];
projectCodeArray[0] = processDefinition.getProjectCode();
projectCodeArray[1] = 200L;
List<CommandCount> commandCounts2 = errorCommandMapper.countCommandState(
null,
null,
projectIdArray
projectCodeArray
);
Assert.assertNotEquals(commandCounts.size(), 0);

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

@ -72,8 +72,9 @@ public class ProcessDefinitionMapperTest {
private ProcessDefinition insertOne() {
//insertOne
ProcessDefinition processDefinition = new ProcessDefinition();
processDefinition.setCode(1L);
processDefinition.setName("def 1");
processDefinition.setProjectId(1010);
processDefinition.setProjectCode(1010L);
processDefinition.setUserId(101);
processDefinition.setUpdateTime(new Date());
processDefinition.setCreateTime(new Date());
@ -89,8 +90,9 @@ public class ProcessDefinitionMapperTest {
private ProcessDefinition insertTwo() {
//insertOne
ProcessDefinition processDefinition = new ProcessDefinition();
processDefinition.setCode(1L);
processDefinition.setName("def 2");
processDefinition.setProjectId(1010);
processDefinition.setProjectCode(1010L);
processDefinition.setUserId(101);
processDefinition.setUpdateTime(new Date());
processDefinition.setCreateTime(new Date());
@ -138,8 +140,10 @@ public class ProcessDefinitionMapperTest {
@Test
public void testVerifyByDefineName() {
Project project = new Project();
project.setCode(1L);
project.setName("ut project");
project.setUserId(4);
project.setCreateTime(new Date());
projectMapper.insert(project);
Queue queue = new Queue();
queue.setQueue("queue");
@ -158,14 +162,15 @@ public class ProcessDefinitionMapperTest {
userMapper.insert(user);
//insertOne
ProcessDefinition processDefinition = new ProcessDefinition();
processDefinition.setCode(1L);
processDefinition.setName("def 1");
processDefinition.setProjectId(project.getId());
processDefinition.setProjectCode(project.getCode());
processDefinition.setUpdateTime(new Date());
processDefinition.setCreateTime(new Date());
processDefinition.setTenantId(tenant.getId());
processDefinition.setUserId(user.getId());
processDefinitionMapper.insert(processDefinition);
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(10, "xxx");
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(10L, "xxx");
Assert.assertEquals(definition, null);
}
@ -176,7 +181,9 @@ public class ProcessDefinitionMapperTest {
public void testQueryByDefineName() {
Project project = new Project();
project.setName("ut project");
project.setCode(1L);
project.setUserId(4);
project.setCreateTime(new Date());
projectMapper.insert(project);
Queue queue = new Queue();
@ -199,15 +206,16 @@ public class ProcessDefinitionMapperTest {
//insertOne
ProcessDefinition processDefinition = new ProcessDefinition();
processDefinition.setCode(1L);
processDefinition.setName("def 1");
processDefinition.setProjectId(project.getId());
processDefinition.setProjectCode(project.getCode());
processDefinition.setUpdateTime(new Date());
processDefinition.setCreateTime(new Date());
processDefinition.setTenantId(tenant.getId());
processDefinition.setUserId(user.getId());
processDefinitionMapper.insert(processDefinition);
ProcessDefinition processDefinition1 = processDefinitionMapper.queryByDefineName(project.getId(), "def 1");
ProcessDefinition processDefinition1 = processDefinitionMapper.queryByDefineName(project.getCode(), "def 1");
Assert.assertNotEquals(processDefinition1, null);
}
@ -217,8 +225,9 @@ public class ProcessDefinitionMapperTest {
@Test
public void testQueryDefinitionListByTenant() {
ProcessDefinition processDefinition = new ProcessDefinition();
processDefinition.setCode(1L);
processDefinition.setName("def 1");
processDefinition.setProjectId(888);
processDefinition.setProjectCode(888L);
processDefinition.setUpdateTime(new Date());
processDefinition.setCreateTime(new Date());
processDefinition.setTenantId(999);
@ -234,8 +243,10 @@ public class ProcessDefinitionMapperTest {
@Test
public void testQueryByDefineId() {
Project project = new Project();
project.setCode(1L);
project.setName("ut project");
project.setUserId(4);
project.setCreateTime(new Date());
projectMapper.insert(project);
Queue queue = new Queue();
@ -258,8 +269,9 @@ public class ProcessDefinitionMapperTest {
//insertOne
ProcessDefinition processDefinition = new ProcessDefinition();
processDefinition.setCode(1L);
processDefinition.setName("def 1");
processDefinition.setProjectId(project.getId());
processDefinition.setProjectCode(project.getCode());
processDefinition.setUpdateTime(new Date());
processDefinition.setCreateTime(new Date());
processDefinition.setTenantId(tenant.getId());
@ -276,7 +288,7 @@ public class ProcessDefinitionMapperTest {
public void testQueryDefineListPaging() {
ProcessDefinition processDefinition = insertOne();
Page<ProcessDefinition> page = new Page(1, 3);
IPage<ProcessDefinition> processDefinitionIPage = processDefinitionMapper.queryDefineListPaging(page, "def", 101, 1010, true);
IPage<ProcessDefinition> processDefinitionIPage = processDefinitionMapper.queryDefineListPaging(page, "def", 101, 1010L, true);
Assert.assertNotEquals(processDefinitionIPage.getTotal(), 0);
}
@ -286,7 +298,7 @@ public class ProcessDefinitionMapperTest {
@Test
public void testQueryAllDefinitionList() {
ProcessDefinition processDefinition = insertOne();
List<ProcessDefinition> processDefinitionIPage = processDefinitionMapper.queryAllDefinitionList(1010);
List<ProcessDefinition> processDefinitionIPage = processDefinitionMapper.queryAllDefinitionList(1010L);
Assert.assertNotEquals(processDefinitionIPage.size(), 0);
}
@ -328,11 +340,11 @@ public class ProcessDefinitionMapperTest {
processDefinition.setUserId(user.getId());
processDefinitionMapper.updateById(processDefinition);
Integer[] projectIds = new Integer[1];
projectIds[0] = processDefinition.getProjectId();
Long[] projectCodes = new Long[1];
projectCodes[0] = processDefinition.getProjectCode();
List<DefinitionGroupByUser> processDefinitions = processDefinitionMapper.countDefinitionGroupByUser(
processDefinition.getUserId(),
projectIds,
projectCodes,
user.getUserType() == UserType.ADMIN_USER
);
Assert.assertNotEquals(processDefinitions.size(), 0);

4
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapperTest.java

@ -262,9 +262,9 @@ public class ProcessInstanceMapperTest {
processInstance.setProcessDefinitionId(processDefinition.getId());
int update = processInstanceMapper.updateById(processInstance);
Integer[] projectIds = new Integer[]{processDefinition.getProjectId()};
Long[] projectCodes = new Long[]{processDefinition.getProjectCode()};
List<ExecuteStatusCount> executeStatusCounts = processInstanceMapper.countInstanceStateByUser(null, null, projectIds);
List<ExecuteStatusCount> executeStatusCounts = processInstanceMapper.countInstanceStateByUser(null, null, projectCodes);
Assert.assertNotEquals(executeStatusCounts.size(), 0);

8
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapperTest.java

@ -230,7 +230,7 @@ public class TaskInstanceMapperTest {
TaskInstance task = insertOne();
ProcessDefinition definition = new ProcessDefinition();
definition.setProjectId(1111);
definition.setProjectCode(1111L);
processDefinitionMapper.insert(definition);
task.setProcessDefinitionId(definition.getId());
taskInstanceMapper.updateById(task);
@ -259,7 +259,10 @@ public class TaskInstanceMapperTest {
TaskInstance task = insertOne();
ProcessDefinition definition = new ProcessDefinition();
definition.setCode(1111L);
definition.setProjectId(1111);
definition.setProjectCode(1111L);
processDefinitionMapper.insert(definition);
task.setProcessDefinitionId(definition.getId());
taskInstanceMapper.updateById(task);
@ -267,7 +270,7 @@ public class TaskInstanceMapperTest {
List<ExecuteStatusCount> count = taskInstanceMapper.countTaskInstanceStateByUser(
null, null,
new Integer[]{definition.getProjectId()}
new Long[]{definition.getProjectCode()}
);
processDefinitionMapper.deleteById(definition.getId());
@ -283,6 +286,7 @@ public class TaskInstanceMapperTest {
ProcessDefinition definition = new ProcessDefinition();
definition.setProjectId(1111);
definition.setProjectCode(1111L);
processDefinitionMapper.insert(definition);
ProcessInstance processInstance = new ProcessInstance();

10
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java

@ -2027,15 +2027,15 @@ public class ProcessService {
* get have perm project ids
*
* @param userId userId
* @return project ids
* @return project codes
*/
public List<Integer> getProjectIdListHavePerm(int userId) {
public List<Long> getProjectIdListHavePerm(int userId) {
List<Integer> projectIdList = new ArrayList<>();
List<Long> projectCodeList = new ArrayList<>();
for (Project project : getProjectListHavePerm(userId)) {
projectIdList.add(project.getId());
projectCodeList.add(project.getCode());
}
return projectIdList;
return projectCodeList;
}
/**

Loading…
Cancel
Save