Browse Source

[FixBug][JsonSplit] depend task, the field "process definition id" modify to "process definition code" (#5377)

* fix: depend task, the field "process definition id" modify to "process definition code"

* fix: depend task, the field "process definition id" modify to "process definition code"

Co-authored-by: wen-hemin <wenhemin@apache.com>
pull/3/MERGE
wen-hemin 3 years ago committed by GitHub
parent
commit
fd54dc0ce2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 40
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionController.java
  2. 8
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java
  3. 26
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
  4. 12
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionControllerTest.java
  5. 26
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
  6. 50
      dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/dependItemList.vue
  7. 14
      dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/nodeStatus.vue

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

@ -515,53 +515,53 @@ public class ProcessDefinitionController extends BaseController {
}
/**
* get tasks list by process definition id
* get tasks list by process definition code
*
* @param loginUser login user
* @param projectName project name
* @param processDefinitionId process definition id
* @param loginUser login user
* @param projectName project name
* @param processDefinitionCode process definition code
* @return task list
*/
@ApiOperation(value = "getNodeListByDefinitionId", notes = "GET_NODE_LIST_BY_DEFINITION_ID_NOTES")
@ApiOperation(value = "getNodeListByDefinitionCode", notes = "GET_NODE_LIST_BY_DEFINITION_CODE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100")
@ApiImplicitParam(name = "processDefinitionCode", value = "PROCESS_DEFINITION_CODE", required = true, dataType = "Long", example = "100")
})
@GetMapping(value = "gen-task-list")
@ResponseStatus(HttpStatus.OK)
@ApiException(GET_TASKS_LIST_BY_PROCESS_DEFINITION_ID_ERROR)
public Result getNodeListByDefinitionId(
public Result getNodeListByDefinitionCode(
@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName,
@RequestParam("processDefinitionId") Integer processDefinitionId) throws Exception {
logger.info("query task node name list by definitionId, login user:{}, project name:{}, id : {}",
loginUser.getUserName(), projectName, processDefinitionId);
Map<String, Object> result = processDefinitionService.getTaskNodeListByDefinitionId(processDefinitionId);
@RequestParam("processDefinitionCode") Long processDefinitionCode) throws Exception {
logger.info("query task node name list by definitionCode, login user:{}, project name:{}, code : {}",
loginUser.getUserName(), projectName, processDefinitionCode);
Map<String, Object> result = processDefinitionService.getTaskNodeListByDefinitionCode(processDefinitionCode);
return returnDataList(result);
}
/**
* get tasks list by process definition id
* get tasks list by process definition code list
*
* @param loginUser login user
* @param projectName project name
* @param processDefinitionIdList process definition id list
* @param processDefinitionCodeList process definition code list
* @return node list data
*/
@ApiOperation(value = "getNodeListByDefinitionIdList", notes = "GET_NODE_LIST_BY_DEFINITION_ID_NOTES")
@ApiOperation(value = "getNodeListByDefinitionCodeList", notes = "GET_NODE_LIST_BY_DEFINITION_CODE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "processDefinitionIdList", value = "PROCESS_DEFINITION_ID_LIST", required = true, type = "String")
@ApiImplicitParam(name = "processDefinitionCodeList", value = "PROCESS_DEFINITION_CODE_LIST", required = true, type = "String")
})
@GetMapping(value = "get-task-list")
@ResponseStatus(HttpStatus.OK)
@ApiException(GET_TASKS_LIST_BY_PROCESS_DEFINITION_ID_ERROR)
public Result getNodeListByDefinitionIdList(
public Result getNodeListByDefinitionCodeList(
@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName,
@RequestParam("processDefinitionIdList") String processDefinitionIdList) {
@RequestParam("processDefinitionCodeList") String processDefinitionCodeList) {
logger.info("query task node name list by definitionId list, login user:{}, project name:{}, id list: {}",
loginUser.getUserName(), projectName, processDefinitionIdList);
Map<String, Object> result = processDefinitionService.getTaskNodeListByDefinitionIdList(processDefinitionIdList);
logger.info("query task node name list by definitionId list, login user:{}, project name:{}, code list: {}",
loginUser.getUserName(), projectName, processDefinitionCodeList);
Map<String, Object> result = processDefinitionService.getTaskNodeListByDefinitionCodeList(processDefinitionCodeList);
return returnDataList(result);
}

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

@ -231,18 +231,18 @@ public interface ProcessDefinitionService {
/**
* get task node details based on process definition
*
* @param defineId define id
* @param defineCode define code
* @return task node list
*/
Map<String, Object> getTaskNodeListByDefinitionId(Integer defineId);
Map<String, Object> getTaskNodeListByDefinitionCode(Long defineCode);
/**
* get task node details based on process definition
*
* @param defineIdList define id list
* @param defineCodeList define code list
* @return task node list
*/
Map<String, Object> getTaskNodeListByDefinitionIdList(String defineIdList);
Map<String, Object> getTaskNodeListByDefinitionCodeList(String defineCodeList);
/**
* query process definition all by project id

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

@ -1130,17 +1130,16 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
/**
* get task node details based on process definition
*
* @param defineId define id
* @param defineCode define code
* @return task node list
*/
@Override
public Map<String, Object> getTaskNodeListByDefinitionId(Integer defineId) {
public Map<String, Object> getTaskNodeListByDefinitionCode(Long defineCode) {
Map<String, Object> result = new HashMap<>();
ProcessDefinition processDefinition = processDefinitionMapper.selectById(defineId);
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(defineCode);
if (processDefinition == null) {
logger.info("process define not exists");
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, defineId);
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, defineCode);
return result;
}
ProcessData processData = processService.genProcessData(processDefinition);
@ -1164,24 +1163,23 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
/**
* get task node details based on process definition
*
* @param defineIdList define id list
* @param defineCodeList define code list
* @return task node list
*/
@Override
public Map<String, Object> getTaskNodeListByDefinitionIdList(String defineIdList) {
public Map<String, Object> getTaskNodeListByDefinitionCodeList(String defineCodeList) {
Map<String, Object> result = new HashMap<>();
Map<Integer, List<TaskNode>> taskNodeMap = new HashMap<>();
String[] idList = defineIdList.split(",");
List<Integer> idIntList = new ArrayList<>();
for (String definitionId : idList) {
idIntList.add(Integer.parseInt(definitionId));
String[] codeArr = defineCodeList.split(",");
List<Long> codeList = new ArrayList<>();
for (String definitionCode : codeArr) {
codeList.add(Long.parseLong(definitionCode));
}
Integer[] idArray = idIntList.toArray(new Integer[0]);
List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryDefinitionListByIdList(idArray);
List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryByCodes(codeList);
if (CollectionUtils.isEmpty(processDefinitionList)) {
logger.info("process definition not exists");
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, defineIdList);
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, defineCodeList);
return result;
}

12
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionControllerTest.java

@ -301,13 +301,13 @@ public class ProcessDefinitionControllerTest {
@Test
public void testGetNodeListByDefinitionId() throws Exception {
String projectName = "test";
int id = 1;
Long code = 1L;
Map<String, Object> result = new HashMap<>();
putMsg(result, Status.SUCCESS);
Mockito.when(processDefinitionService.getTaskNodeListByDefinitionId(id)).thenReturn(result);
Result response = processDefinitionController.getNodeListByDefinitionId(user, projectName, id);
Mockito.when(processDefinitionService.getTaskNodeListByDefinitionCode(code)).thenReturn(result);
Result response = processDefinitionController.getNodeListByDefinitionCode(user, projectName, code);
Assert.assertEquals(Status.SUCCESS.getCode(), response.getCode().intValue());
}
@ -315,13 +315,13 @@ public class ProcessDefinitionControllerTest {
@Test
public void testGetNodeListByDefinitionIdList() throws Exception {
String projectName = "test";
String idList = "1,2,3";
String codeList = "1,2,3";
Map<String, Object> result = new HashMap<>();
putMsg(result, Status.SUCCESS);
Mockito.when(processDefinitionService.getTaskNodeListByDefinitionIdList(idList)).thenReturn(result);
Result response = processDefinitionController.getNodeListByDefinitionIdList(user, projectName, idList);
Mockito.when(processDefinitionService.getTaskNodeListByDefinitionCodeList(codeList)).thenReturn(result);
Result response = processDefinitionController.getNodeListByDefinitionCodeList(user, projectName, codeList);
Assert.assertEquals(Status.SUCCESS.getCode(), response.getCode().intValue());
}

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

@ -61,6 +61,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -700,41 +701,42 @@ public class ProcessDefinitionServiceTest {
@Test
public void testGetTaskNodeListByDefinitionId() {
//process definition not exist
Mockito.when(processDefineMapper.selectById(46)).thenReturn(null);
Map<String, Object> processDefinitionNullRes = processDefinitionService.getTaskNodeListByDefinitionId(46);
Mockito.when(processDefineMapper.queryByCode(46L)).thenReturn(null);
Map<String, Object> processDefinitionNullRes = processDefinitionService.getTaskNodeListByDefinitionCode(46L);
Assert.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, processDefinitionNullRes.get(Constants.STATUS));
//process data null
ProcessDefinition processDefinition = getProcessDefinition();
Mockito.when(processDefineMapper.selectById(46)).thenReturn(processDefinition);
Map<String, Object> successRes = processDefinitionService.getTaskNodeListByDefinitionId(46);
Mockito.when(processDefineMapper.queryByCode(46L)).thenReturn(processDefinition);
Map<String, Object> successRes = processDefinitionService.getTaskNodeListByDefinitionCode(46L);
Assert.assertEquals(Status.DATA_IS_NOT_VALID, successRes.get(Constants.STATUS));
//success
Mockito.when(processService.genProcessData(Mockito.any())).thenReturn(new ProcessData());
Mockito.when(processDefineMapper.selectById(46)).thenReturn(processDefinition);
Map<String, Object> dataNotValidRes = processDefinitionService.getTaskNodeListByDefinitionId(46);
Mockito.when(processDefineMapper.queryByCode(46L)).thenReturn(processDefinition);
Map<String, Object> dataNotValidRes = processDefinitionService.getTaskNodeListByDefinitionCode(46L);
Assert.assertEquals(Status.SUCCESS, dataNotValidRes.get(Constants.STATUS));
}
@Test
public void testGetTaskNodeListByDefinitionIdList() {
//process definition not exist
String defineIdList = "46";
Integer[] idArray = {46};
Mockito.when(processDefineMapper.queryDefinitionListByIdList(idArray)).thenReturn(null);
Map<String, Object> processNotExistRes = processDefinitionService.getTaskNodeListByDefinitionIdList(defineIdList);
String defineCodeList = "46";
Long[] codeArray = {46L};
List<Long> codeList = Arrays.asList(codeArray);
Mockito.when(processDefineMapper.queryByCodes(codeList)).thenReturn(null);
Map<String, Object> processNotExistRes = processDefinitionService.getTaskNodeListByDefinitionCodeList(defineCodeList);
Assert.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, processNotExistRes.get(Constants.STATUS));
//process definition exist
ProcessDefinition processDefinition = getProcessDefinition();
List<ProcessDefinition> processDefinitionList = new ArrayList<>();
processDefinitionList.add(processDefinition);
Mockito.when(processDefineMapper.queryDefinitionListByIdList(idArray)).thenReturn(processDefinitionList);
Mockito.when(processDefineMapper.queryByCodes(codeList)).thenReturn(processDefinitionList);
ProcessData processData = getProcessData();
Mockito.when(processService.genProcessData(processDefinition)).thenReturn(processData);
Map<String, Object> successRes = processDefinitionService.getTaskNodeListByDefinitionIdList(defineIdList);
Map<String, Object> successRes = processDefinitionService.getTaskNodeListByDefinitionCodeList(defineCodeList);
Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS));
}

50
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/dependItemList.vue

@ -20,7 +20,7 @@
<el-select filterable :disabled="isDetails" style="width: 450px" v-model="el.projectId" @change="v => _onChangeProjectId(v, $index)" size="small">
<el-option v-for="item in projectList" :key="item.value" :value="item.value" :label="item.label"></el-option>
</el-select>
<el-select filterable :disabled="isDetails" style="width: 450px" v-model="el.definitionId" @change="v => _onChangeDefinitionId(v, $index)" size="small">
<el-select filterable :disabled="isDetails" style="width: 450px" v-model="el.definitionCode" @change="v => _onChangeDefinitionCode(v, $index)" size="small">
<el-option v-for="item in el.definitionList" :key="item.value" :value="item.value" :label="item.label"></el-option>
</el-select>
<el-select filterable :disabled="isDetails" style="width: 450px" v-model="el.depTasks" size="small">
@ -87,7 +87,7 @@
let projectId = this.projectList[0].value
this._getProcessByProjectId(projectId).then(definitionList => {
// dependItemList index
let is = (value) => _.some(this.dependItemList, { definitionId: value })
let is = (value) => _.some(this.dependItemList, { definitionCode: value })
let noArr = _.filter(definitionList, v => !is(v.value))
let value = noArr[0] && noArr[0].value || null
let val = value || definitionList[0].value
@ -124,26 +124,12 @@
resolve()
})
},
/**
* get processlist
*/
_getProcessList () {
return new Promise((resolve, reject) => {
let definitionList = _.map(_.cloneDeep(this.store.state.dag.processListS), v => {
return {
value: v.id,
label: v.name
}
})
resolve(definitionList)
})
},
_getProcessByProjectId (id) {
return new Promise((resolve, reject) => {
this.store.dispatch('dag/getProcessByProjectId', { projectId: id }).then(res => {
let definitionList = _.map(_.cloneDeep(res), v => {
return {
value: v.id,
value: v.code,
label: v.name
}
})
@ -154,14 +140,14 @@
/**
* get dependItemList
*/
_getDependItemList (ids, is = true) {
_getDependItemList (codes, is = true) {
return new Promise((resolve, reject) => {
if (is) {
this.store.dispatch('dag/getProcessTasksList', { processDefinitionId: ids }).then(res => {
this.store.dispatch('dag/getProcessTasksList', { processDefinitionCode: codes }).then(res => {
resolve(['ALL'].concat(_.map(res, v => v.name)))
})
} else {
this.store.dispatch('dag/getTaskListDefIdAll', { processDefinitionIdList: ids }).then(res => {
this.store.dispatch('dag/getTaskListDefIdAll', { processDefinitionCodeList: codes }).then(res => {
resolve(res)
})
}
@ -173,17 +159,17 @@
_onChangeProjectId (value, itemIndex) {
this._getProcessByProjectId(value).then(definitionList => {
/* this.$set(this.dependItemList, itemIndex, this._dlOldParams(value, definitionList, item)) */
let definitionId = definitionList[0].value
this._getDependItemList(definitionId).then(depTasksList => {
let definitionCode = definitionList[0].value
this._getDependItemList(definitionCode).then(depTasksList => {
let item = this.dependItemList[itemIndex]
// init set depTasks All
item.depTasks = 'ALL'
// set dependItemList item data
this.$set(this.dependItemList, itemIndex, this._cpOldParams(value, definitionId, definitionList, depTasksList, item))
this.$set(this.dependItemList, itemIndex, this._cpOldParams(value, definitionCode, definitionList, depTasksList, item))
})
})
},
_onChangeDefinitionId (value, itemIndex) {
_onChangeDefinitionCode (value, itemIndex) {
// get depItem list data
this._getDependItemList(value).then(depTasksList => {
let item = this.dependItemList[itemIndex]
@ -201,7 +187,7 @@
_rtNewParams (value, definitionList, depTasksList, projectId) {
return {
projectId: projectId,
definitionId: value,
definitionCode: value,
// dependItem need private definitionList
definitionList: definitionList,
depTasks: 'ALL',
@ -215,7 +201,7 @@
_rtOldParams (value, definitionList, depTasksList, item) {
return {
projectId: item.projectId,
definitionId: value,
definitionCode: value,
// dependItem need private definitionList
definitionList: definitionList,
depTasks: item.depTasks || 'ALL',
@ -227,11 +213,11 @@
}
},
_cpOldParams (value, definitionId, definitionList, depTasksList, item) {
_cpOldParams (value, definitionCode, definitionList, depTasksList, item) {
return {
projectId: value,
definitionList: definitionList,
definitionId: definitionId,
definitionCode: definitionCode,
depTasks: item.depTasks || 'ALL',
depTasksList: depTasksList,
cycle: item.cycle,
@ -266,13 +252,13 @@
})
})
} else {
// get definitionId ids
let ids = _.map(this.dependItemList, v => v.definitionId).join(',')
// get definitionCode codes
let codes = _.map(this.dependItemList, v => v.definitionCode).join(',')
// get item list
this._getDependItemList(ids, false).then(res => {
this._getDependItemList(codes, false).then(res => {
_.map(this.dependItemList, (v, i) => {
this._getProcessByProjectId(v.projectId).then(definitionList => {
this.$set(this.dependItemList, i, this._rtOldParams(v.definitionId, definitionList, ['ALL'].concat(_.map(res[v.definitionId] || [], v => v.name)), v))
this.$set(this.dependItemList, i, this._rtOldParams(v.definitionCode, definitionList, ['ALL'].concat(_.map(res[v.definitionCode] || [], v => v.name)), v))
})
})
})

14
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/nodeStatus.vue

@ -112,7 +112,7 @@
this.store.dispatch('dag/getProcessByProjectId', { projectId: id }).then(res => {
this.definitionList = _.map(_.cloneDeep(res), v => {
return {
value: v.id,
value: v.code,
label: v.name
}
})
@ -123,10 +123,10 @@
/**
* get dependItemList
*/
_getDependItemList (ids, is = true) {
_getDependItemList (codes, is = true) {
return new Promise((resolve, reject) => {
if (is) {
this.store.dispatch('dag/getProcessTasksList', { processDefinitionId: ids }).then(res => {
this.store.dispatch('dag/getProcessTasksList', { processDefinitionCodeList: codes }).then(res => {
resolve(['ALL'].concat(_.map(res, v => v.name)))
})
}
@ -163,13 +163,13 @@
if (!this.dependItemList.length) {
this.$emit('dependItemListEvent', _.concat(this.dependItemList, this._rtNewParams()))
} else {
// get definitionId ids
let ids = _.map(this.dependItemList, v => v.definitionId).join(',')
// get definitionCode codes
let codes = _.map(this.dependItemList, v => v.definitionCode).join(',')
// get item list
this._getDependItemList(ids, false).then(res => {
this._getDependItemList(codes, false).then(res => {
_.map(this.dependItemList, (v, i) => {
this._getProcessByProjectId(v.projectId).then(definitionList => {
this.$set(this.dependItemList, i, this._rtOldParams(v.definitionId, ['ALL'].concat(_.map(res[v.definitionId] || [], v => v.name)), v))
this.$set(this.dependItemList, i, this._rtOldParams(v.definitionCode, ['ALL'].concat(_.map(res[v.definitionCode] || [], v => v.name)), v))
})
})
})

Loading…
Cancel
Save