Browse Source

Merge remote-tracking branch 'upstream/json_split' into spilit

pull/3/MERGE
lenboo 4 years ago
parent
commit
0571681ac4
  1. 128
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
  2. 9
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
  3. 433
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinitionLog.java
  4. 249
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessTaskRelationLog.java
  5. 19
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java
  6. 392
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinitionLog.java
  7. 63
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionLogMapperTest.java
  8. 62
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionMapperTest.java
  9. 47
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java

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

@ -115,7 +115,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
private static final Logger logger = LoggerFactory.getLogger(ProcessDefinitionServiceImpl.class);
private static final String PROCESSDEFINITIONID = "processDefinitionId";
private static final String PROCESSDEFINITIONCODE = "processDefinitionCode";
private static final String RELEASESTATE = "releaseState";
@ -277,6 +277,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
List<ProcessDefinition> resourceList = processDefinitionMapper.queryAllDefinitionList(project.getId());
resourceList.stream().forEach(processDefinition -> {
ProcessData processData = processService.genProcessData(processDefinition);
processDefinition.setProcessDefinitionJson(JSONUtils.toJsonString(processData));
});
result.put(Constants.DATA_LIST, resourceList);
putMsg(result, Status.SUCCESS);
@ -310,6 +316,13 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
IPage<ProcessDefinition> processDefinitionIPage = processDefinitionMapper.queryDefineListPaging(
page, searchVal, userId, project.getId(), isAdmin(loginUser));
List<ProcessDefinition> records = processDefinitionIPage.getRecords();
records.stream().forEach(processDefinition -> {
ProcessData processData = processService.genProcessData(processDefinition);
processDefinition.setProcessDefinitionJson(JSONUtils.toJsonString(processData));
});
processDefinitionIPage.setRecords(records);
PageInfo<ProcessDefinition> pageInfo = new PageInfo<>(pageNo, pageSize);
pageInfo.setTotalCount((int) processDefinitionIPage.getTotal());
pageInfo.setLists(processDefinitionIPage.getRecords());
@ -340,6 +353,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
ProcessDefinition processDefinition = processDefinitionMapper.selectById(processId);
ProcessData processData = processService.genProcessData(processDefinition);
processDefinition.setProcessDefinitionJson(JSONUtils.toJsonString(processData));
if (processDefinition == null) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processId);
} else {
@ -362,6 +379,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(project.getId(), processDefinitionName);
ProcessData processData = processService.genProcessData(processDefinition);
processDefinition.setProcessDefinitionJson(JSONUtils.toJsonString(processData));
if (processDefinition == null) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processDefinitionName);
} else {
@ -534,8 +554,6 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
}
// TODO: replace id to code
// ProcessDefinition processDefinition = processDefineMapper.deleteByCode(processDefinitionCode);
int delete = processDefinitionMapper.deleteById(processDefinitionId);
processTaskRelationMapper.deleteByCode(project.getCode(), processDefinition.getCode());
if (delete > 0) {
@ -657,10 +675,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
//get workflow info
int processDefinitionId = Integer.parseInt(strProcessDefinitionId);
ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineId(processDefinitionId);
if (null != processDefinition) {
String processDefinitionJson = JSONUtils.toJsonString(processService.genProcessData(processDefinition));
processDefinition.setProcessDefinitionJson(processDefinitionJson);
processDefinitionList.add(exportProcessMetaData(processDefinitionId, processDefinition));
}
}
return processDefinitionList;
}
@ -718,15 +736,16 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @return export process metadata string
*/
public ProcessMeta exportProcessMetaData(Integer processDefinitionId, ProcessDefinition processDefinition) {
String processDefinitionJson = processDefinition.getProcessDefinitionJson();
//correct task param which has data source or dependent param
String correctProcessDefinitionJson = addExportTaskNodeSpecialParam(processDefinition.getProcessDefinitionJson());
String correctProcessDefinitionJson = addExportTaskNodeSpecialParam(processDefinitionJson);
processDefinition.setProcessDefinitionJson(correctProcessDefinitionJson);
//export process metadata
ProcessMeta exportProcessMeta = new ProcessMeta();
exportProcessMeta.setProjectName(processDefinition.getProjectName());
exportProcessMeta.setProcessDefinitionName(processDefinition.getName());
exportProcessMeta.setProcessDefinitionJson(processDefinition.getProcessDefinitionJson());
exportProcessMeta.setProcessDefinitionJson(processDefinitionJson);
exportProcessMeta.setProcessDefinitionDescription(processDefinition.getDescription());
exportProcessMeta.setProcessDefinitionLocations(processDefinition.getLocations());
exportProcessMeta.setProcessDefinitionConnects(processDefinition.getConnects());
@ -963,15 +982,15 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
}
//recursive sub-process parameter correction map key for old process id value for new process id
Map<Integer, Integer> subProcessIdMap = new HashMap<>();
//recursive sub-process parameter correction map key for old process code value for new process code
Map<Long, Long> subProcessCodeMap = new HashMap<>();
List<Object> subProcessList = StreamUtils.asStream(jsonArray.elements())
.filter(elem -> checkTaskHasSubProcess(JSONUtils.parseObject(elem.toString()).path("type").asText()))
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(subProcessList)) {
importSubProcess(loginUser, targetProject, jsonArray, subProcessIdMap);
importSubProcess(loginUser, targetProject, jsonArray, subProcessCodeMap);
}
jsonObject.set(TASKS, jsonArray);
@ -1038,9 +1057,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @param loginUser login user
* @param targetProject target project
* @param jsonArray process task array
* @param subProcessIdMap correct sub process id map
* @param subProcessCodeMap correct sub process id map
*/
private void importSubProcess(User loginUser, Project targetProject, ArrayNode jsonArray, Map<Integer, Integer> subProcessIdMap) {
private void importSubProcess(User loginUser, Project targetProject, ArrayNode jsonArray, Map<Long, Long> subProcessCodeMap) {
for (int i = 0; i < jsonArray.size(); i++) {
ObjectNode taskNode = (ObjectNode) jsonArray.path(i);
String taskType = taskNode.path("type").asText();
@ -1050,68 +1069,59 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
//get sub process info
ObjectNode subParams = (ObjectNode) taskNode.path("params");
Integer subProcessId = subParams.path(PROCESSDEFINITIONID).asInt();
ProcessDefinition subProcess = processDefinitionMapper.queryByDefineId(subProcessId);
Long subProcessCode = subParams.path(PROCESSDEFINITIONCODE).asLong();
ProcessDefinition subProcess = processDefinitionMapper.queryByCode(subProcessCode);
//check is sub process exist in db
if (null == subProcess) {
continue;
}
String subProcessJson = subProcess.getProcessDefinitionJson();
String subProcessJson = JSONUtils.toJsonString(processService.genProcessData(subProcess));
//check current project has sub process
ProcessDefinition currentProjectSubProcess = processDefinitionMapper.queryByDefineName(targetProject.getId(), subProcess.getName());
if (null == currentProjectSubProcess) {
ArrayNode subJsonArray = (ArrayNode) JSONUtils.parseObject(subProcess.getProcessDefinitionJson()).get(TASKS);
ArrayNode subJsonArray = (ArrayNode) JSONUtils.parseObject(subProcessJson).get(TASKS);
List<Object> subProcessList = StreamUtils.asStream(subJsonArray.elements())
.filter(item -> checkTaskHasSubProcess(JSONUtils.parseObject(item.toString()).path("type").asText()))
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(subProcessList)) {
importSubProcess(loginUser, targetProject, subJsonArray, subProcessIdMap);
importSubProcess(loginUser, targetProject, subJsonArray, subProcessCodeMap);
//sub process processId correct
if (!subProcessIdMap.isEmpty()) {
if (!subProcessCodeMap.isEmpty()) {
for (Map.Entry<Integer, Integer> entry : subProcessIdMap.entrySet()) {
String oldSubProcessId = "\"processDefinitionId\":" + entry.getKey();
String newSubProcessId = "\"processDefinitionId\":" + entry.getValue();
subProcessJson = subProcessJson.replaceAll(oldSubProcessId, newSubProcessId);
for (Map.Entry<Long, Long> entry : subProcessCodeMap.entrySet()) {
String oldSubProcessCode = "\"processDefinitionCode\":" + entry.getKey();
String newSubProcessCode = "\"processDefinitionCode\":" + entry.getValue();
subProcessJson = subProcessJson.replaceAll(oldSubProcessCode, newSubProcessCode);
}
subProcessIdMap.clear();
subProcessCodeMap.clear();
}
}
//if sub-process recursion
Date now = new Date();
//create sub process in target project
ProcessDefinition processDefine = new ProcessDefinition();
processDefine.setName(subProcess.getName());
processDefine.setVersion(subProcess.getVersion());
processDefine.setReleaseState(subProcess.getReleaseState());
processDefine.setProjectId(targetProject.getId());
processDefine.setUserId(loginUser.getId());
processDefine.setProcessDefinitionJson(subProcessJson);
processDefine.setDescription(subProcess.getDescription());
processDefine.setLocations(subProcess.getLocations());
processDefine.setConnects(subProcess.getConnects());
processDefine.setTimeout(subProcess.getTimeout());
processDefine.setTenantId(subProcess.getTenantId());
processDefine.setGlobalParams(subProcess.getGlobalParams());
processDefine.setCreateTime(now);
processDefine.setUpdateTime(now);
processDefine.setFlag(subProcess.getFlag());
processDefine.setWarningGroupId(subProcess.getWarningGroupId());
processDefinitionMapper.insert(processDefine);
logger.info("create sub process, project: {}, process name: {}", targetProject.getName(), processDefine.getName());
try {
createProcessDefinition(loginUser
, targetProject.getName(),
subProcess.getName(),
subProcessJson,
subProcess.getDescription(),
subProcess.getLocations(),
subProcess.getConnects());
logger.info("create sub process, project: {}, process name: {}", targetProject.getName(), subProcess.getName());
} catch (Exception e) {
logger.error("import process meta json data: {}", e.getMessage(), e);
}
//modify task node
ProcessDefinition newSubProcessDefine = processDefinitionMapper.queryByDefineName(processDefine.getProjectId(), processDefine.getName());
ProcessDefinition newSubProcessDefine = processDefinitionMapper.queryByDefineName(subProcess.getProjectId(), subProcess.getName());
if (null != newSubProcessDefine) {
subProcessIdMap.put(subProcessId, newSubProcessDefine.getId());
subParams.put(PROCESSDEFINITIONID, newSubProcessDefine.getId());
subProcessCodeMap.put(subProcessCode, newSubProcessDefine.getCode());
subParams.put(PROCESSDEFINITIONCODE, newSubProcessDefine.getId());
taskNode.set("params", subParams);
}
}
@ -1187,15 +1197,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, defineId);
return result;
}
String processDefinitionJson = processDefinition.getProcessDefinitionJson();
ProcessData processData = JSONUtils.parseObject(processDefinitionJson, ProcessData.class);
ProcessData processData = processService.genProcessData(processDefinition);
//process data check
if (null == processData) {
logger.error("process data is null");
putMsg(result, Status.DATA_IS_NOT_VALID, processDefinitionJson);
putMsg(result, Status.DATA_IS_NOT_VALID, JSONUtils.toJsonString(processData));
return result;
}
@ -1233,8 +1240,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
for (ProcessDefinition processDefinition : processDefinitionList) {
String processDefinitionJson = processDefinition.getProcessDefinitionJson();
ProcessData processData = JSONUtils.parseObject(processDefinitionJson, ProcessData.class);
ProcessData processData = processService.genProcessData(processDefinition);
List<TaskNode> taskNodeList = (processData.getTasks() == null) ? new ArrayList<>() : processData.getTasks();
taskNodeMap.put(processDefinition.getId(), taskNodeList);
}
@ -1258,6 +1264,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
HashMap<String, Object> result = new HashMap<>();
List<ProcessDefinition> resourceList = processDefinitionMapper.queryAllDefinitionList(projectId);
resourceList.stream().forEach(processDefinition -> {
ProcessData processData = processService.genProcessData(processDefinition);
processDefinition.setProcessDefinitionJson(JSONUtils.toJsonString(processData));
});
result.put(Constants.DATA_LIST, resourceList);
putMsg(result, Status.SUCCESS);
@ -1449,16 +1459,18 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processId);
return result;
} else {
ProcessData processData = JSONUtils.parseObject(processDefinition.getProcessDefinitionJson(), ProcessData.class);
ProcessData processData = processService.genProcessData(processDefinition);
List<TaskNode> taskNodeList = processData.getTasks();
taskNodeList.stream().forEach(taskNode -> {
taskNode.setCode(0L);
});
processData.setTasks(taskNodeList);
String processDefinitionJson = JSONUtils.toJsonString(processData);
return createProcessDefinition(
loginUser,
targetProject.getName(),
processDefinition.getName() + "_copy_" + DateUtils.getCurrentTimeStamp(),
processDefinition.getProcessDefinitionJson(),
processDefinitionJson,
processDefinition.getDescription(),
processDefinition.getLocations(),
processDefinition.getConnects());

9
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java

@ -17,8 +17,9 @@
package org.apache.dolphinscheduler.api.service.impl;
import static org.apache.dolphinscheduler.api.enums.Status.DATA_IS_NOT_VALID;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.BaseService;
import org.apache.dolphinscheduler.api.service.ProjectService;
import org.apache.dolphinscheduler.api.service.TaskDefinitionService;
import org.apache.dolphinscheduler.api.utils.CheckUtils;
@ -102,7 +103,8 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
TaskNode taskNode = JSONUtils.parseObject(taskDefinitionJson, TaskNode.class);
checkTaskNode(result, taskNode, taskDefinitionJson);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
if (result.get(Constants.STATUS) == DATA_IS_NOT_VALID
|| result.get(Constants.STATUS) == Status.PROCESS_NODE_S_PARAMETER_INVALID) {
return result;
}
TaskDefinition taskDefinition = new TaskDefinition();
@ -218,7 +220,8 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
}
TaskNode taskNode = JSONUtils.parseObject(taskDefinitionJson, TaskNode.class);
checkTaskNode(result, taskNode, taskDefinitionJson);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
if (result.get(Constants.STATUS) == DATA_IS_NOT_VALID
|| result.get(Constants.STATUS) == Status.PROCESS_NODE_S_PARAMETER_INVALID) {
return result;
}
int update = processService.updateTaskDefinition(loginUser, project.getCode(), taskNode, taskDefinition);

433
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinitionLog.java

@ -17,169 +17,16 @@
package org.apache.dolphinscheduler.dao.entity;
import org.apache.dolphinscheduler.common.enums.Flag;
import org.apache.dolphinscheduler.common.enums.ReleaseState;
import org.apache.dolphinscheduler.common.process.Property;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* process definition log
*/
@TableName("t_ds_process_definition_log")
public class ProcessDefinitionLog {
/**
* id
*/
@TableId(value = "id", type = IdType.AUTO)
private int id;
/**
* code
*/
private Long code;
/**
* name
*/
private String name;
/**
* version
*/
private int version;
/**
* release state : online/offline
*/
private ReleaseState releaseState;
/**
* project code
*/
private Long projectCode;
/**
* description
*/
private String description;
/**
* user defined parameters
*/
private String globalParams;
/**
* user defined parameter list
*/
@TableField(exist = false)
private List<Property> globalParamList;
/**
* user define parameter map
*/
@TableField(exist = false)
private Map<String, String> globalParamMap;
/**
* create time
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/**
* update time
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
/**
* process is valid: yes/no
*/
private Flag flag;
/**
* process user id
*/
private int userId;
/**
* user name
*/
@TableField(exist = false)
private String userName;
/**
* project name
*/
@TableField(exist = false)
private String projectName;
/**
* locations array for web
*/
private String locations;
/**
* receivers
*/
private String receivers;
/**
* receivers cc
*/
private String receiversCc;
/**
* schedule release state : online/offline
*/
@TableField(exist = false)
private ReleaseState scheduleReleaseState;
/**
* process warning time out. unit: minute
*/
private int timeout;
/**
* tenant id
*/
private int tenantId;
/**
* modify user name
*/
private String modifyBy;
/**
* warningGroupId
*/
@TableField(exist = false)
private int warningGroupId;
/**
* connects array for web
*/
private String connects;
/**
* resource ids
*/
private String resourceIds;
public class ProcessDefinitionLog extends ProcessDefinition {
/**
* operator
@ -192,21 +39,37 @@ public class ProcessDefinitionLog {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date operateTime;
public int getWarningGroupId() {
return warningGroupId;
public ProcessDefinitionLog() {
super();
}
public ProcessDefinitionLog(ProcessDefinition processDefinition) {
this.setId(processDefinition.getId());
this.setCode(processDefinition.getCode());
this.setName(processDefinition.getName());
this.setVersion(processDefinition.getVersion());
this.setReleaseState(processDefinition.getReleaseState());
this.setProjectCode(processDefinition.getProjectCode());
this.setDescription(processDefinition.getDescription());
this.setGlobalParams(processDefinition.getGlobalParams());
this.setGlobalParamList(processDefinition.getGlobalParamList());
this.setGlobalParamMap(processDefinition.getGlobalParamMap());
this.setCreateTime(processDefinition.getCreateTime());
this.setUpdateTime(processDefinition.getUpdateTime());
this.setFlag(processDefinition.getFlag());
this.setUserId(processDefinition.getUserId());
this.setUserName(processDefinition.getUserName());
this.setProjectName(processDefinition.getProjectName());
this.setLocations(processDefinition.getLocations());
this.setConnects(processDefinition.getConnects());
this.setScheduleReleaseState(processDefinition.getScheduleReleaseState());
this.setTimeout(processDefinition.getTimeout());
this.setTenantId(processDefinition.getTenantId());
this.setModifyBy(processDefinition.getModifyBy());
this.setResourceIds(processDefinition.getResourceIds());
this.setWarningGroupId(processDefinition.getWarningGroupId());
}
public void setWarningGroupId(int warningGroupId) {
this.warningGroupId = warningGroupId;
}
public String getConnects() {
return connects;
}
public void setConnects(String connects) {
this.connects = connects;
}
public int getOperator() {
return operator;
@ -224,240 +87,4 @@ public class ProcessDefinitionLog {
this.operateTime = operateTime;
}
public Long getCode() {
return code;
}
public void setCode(Long code) {
this.code = code;
}
public Long getProjectCode() {
return projectCode;
}
public void setProjectCode(Long projectCode) {
this.projectCode = projectCode;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public ReleaseState getReleaseState() {
return releaseState;
}
public void setReleaseState(ReleaseState releaseState) {
this.releaseState = releaseState;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Flag getFlag() {
return flag;
}
public void setFlag(Flag flag) {
this.flag = flag;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getProjectName() {
return projectName;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public String getGlobalParams() {
return globalParams;
}
public void setGlobalParams(String globalParams) {
if (globalParams == null) {
this.globalParamList = new ArrayList<>();
} else {
this.globalParamList = JSONUtils.toList(globalParams, Property.class);
}
this.globalParams = globalParams;
}
public List<Property> getGlobalParamList() {
return globalParamList;
}
public void setGlobalParamList(List<Property> globalParamList) {
this.globalParams = JSONUtils.toJsonString(globalParamList);
this.globalParamList = globalParamList;
}
public Map<String, String> getGlobalParamMap() {
if (globalParamMap == null && StringUtils.isNotEmpty(globalParams)) {
List<Property> propList = JSONUtils.toList(globalParams, Property.class);
globalParamMap = propList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue));
}
return globalParamMap;
}
public void setGlobalParamMap(Map<String, String> globalParamMap) {
this.globalParamMap = globalParamMap;
}
public String getLocations() {
return locations;
}
public void setLocations(String locations) {
this.locations = locations;
}
public String getReceivers() {
return receivers;
}
public void setReceivers(String receivers) {
this.receivers = receivers;
}
public String getReceiversCc() {
return receiversCc;
}
public void setReceiversCc(String receiversCc) {
this.receiversCc = receiversCc;
}
public ReleaseState getScheduleReleaseState() {
return scheduleReleaseState;
}
public void setScheduleReleaseState(ReleaseState scheduleReleaseState) {
this.scheduleReleaseState = scheduleReleaseState;
}
public String getResourceIds() {
return resourceIds;
}
public void setResourceIds(String resourceIds) {
this.resourceIds = resourceIds;
}
public int getTimeout() {
return timeout;
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}
public int getTenantId() {
return tenantId;
}
public void setTenantId(int tenantId) {
this.tenantId = tenantId;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getModifyBy() {
return modifyBy;
}
public void setModifyBy(String modifyBy) {
this.modifyBy = modifyBy;
}
@Override
public String toString() {
return "ProcessDefinitionLog{"
+ "id=" + id
+ ", code=" + code
+ ", name='" + name + '\''
+ ", version=" + version
+ ", releaseState=" + releaseState
+ ", projectCode=" + projectCode
+ ", description='" + description + '\''
+ ", globalParams='" + globalParams + '\''
+ ", globalParamList=" + globalParamList
+ ", globalParamMap=" + globalParamMap
+ ", createTime=" + createTime
+ ", updateTime=" + updateTime
+ ", flag=" + flag
+ ", userId=" + userId
+ ", userName='" + userName + '\''
+ ", projectName='" + projectName + '\''
+ ", locations='" + locations + '\''
+ ", receivers='" + receivers + '\''
+ ", receiversCc='" + receiversCc + '\''
+ ", scheduleReleaseState=" + scheduleReleaseState
+ ", timeout=" + timeout
+ ", tenantId=" + tenantId
+ ", modifyBy='" + modifyBy + '\''
+ ", warningGroupId=" + warningGroupId
+ ", connects='" + connects + '\''
+ ", resourceIds='" + resourceIds + '\''
+ ", operator=" + operator
+ ", operateTime=" + operateTime
+ '}';
}
}

249
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessTaskRelationLog.java

@ -17,96 +17,16 @@
package org.apache.dolphinscheduler.dao.entity;
import org.apache.dolphinscheduler.common.enums.ConditionType;
import org.apache.dolphinscheduler.common.process.Property;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* process task relation log
*/
@TableName("t_ds_process_task_relation_log")
public class ProcessTaskRelationLog {
/**
* id
*/
@TableId(value = "id", type = IdType.AUTO)
private int id;
/**
* name
*/
private String name;
/**
* process version
*/
private int processDefinitionVersion;
/**
* project code
*/
private long projectCode;
/**
* process code
*/
private long processDefinitionCode;
/**
* pre task code
*/
private long preTaskCode;
/**
* pre node version
*/
private int preNodeVersion;
/**
* post task code
*/
private long postTaskCode;
/**
* post node version
*/
private int postNodeVersion;
/**
* condition type
*/
private ConditionType conditionType;
/**
* condition parameters
*/
private String conditionParams;
/**
* condition parameter list
*/
@TableField(exist = false)
private List<Property> conditionParamList;
/**
* condition parameter map
*/
@TableField(exist = false)
private Map<String, String> conditionParamMap;
public class ProcessTaskRelationLog extends ProcessTaskRelation {
/**
* operator user id
@ -119,132 +39,29 @@ public class ProcessTaskRelationLog {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date operateTime;
/**
* create time
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/**
* update time
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
public String getName() {
return name;
public ProcessTaskRelationLog() {
super();
}
public void setName(String name) {
this.name = name;
public ProcessTaskRelationLog(ProcessTaskRelation processTaskRelation) {
super();
this.setId(processTaskRelation.getId());
this.setName(processTaskRelation.getName());
this.setProcessDefinitionCode(processTaskRelation.getProcessDefinitionCode());
this.setProcessDefinitionVersion(processTaskRelation.getProcessDefinitionVersion());
this.setProjectCode(processTaskRelation.getProjectCode());
this.setPreTaskCode(processTaskRelation.getPreTaskCode());
this.setPreNodeVersion(processTaskRelation.getPreNodeVersion());
this.setPostTaskCode(processTaskRelation.getPostTaskCode());
this.setPostNodeVersion(processTaskRelation.getPostNodeVersion());
this.setConditionType(processTaskRelation.getConditionType());
this.setConditionParams(processTaskRelation.getConditionParams());
this.setConditionParamList(processTaskRelation.getConditionParamList());
this.setConditionParamMap(processTaskRelation.getConditionParamMap());
this.setCreateTime(processTaskRelation.getCreateTime());
this.setUpdateTime(processTaskRelation.getUpdateTime());
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getConditionParams() {
return conditionParams;
}
public void setConditionParams(String conditionParams) {
if (conditionParams == null) {
this.conditionParamList = new ArrayList<>();
} else {
this.conditionParamList = JSONUtils.toList(conditionParams, Property.class);
}
this.conditionParams = conditionParams;
}
public List<Property> getConditionParamList() {
return conditionParamList;
}
public void setConditionParamList(List<Property> conditionParamList) {
this.conditionParams = JSONUtils.toJsonString(conditionParamList);
this.conditionParamList = conditionParamList;
}
public Map<String, String> getConditionParamMap() {
if (conditionParamMap == null && StringUtils.isNotEmpty(conditionParams)) {
List<Property> propList = JSONUtils.toList(conditionParams, Property.class);
conditionParamMap = propList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue));
}
return conditionParamMap;
}
public void setConditionParamMap(Map<String, String> conditionParamMap) {
this.conditionParamMap = conditionParamMap;
}
public int getProcessDefinitionVersion() {
return processDefinitionVersion;
}
public void setProcessDefinitionVersion(int processDefinitionVersion) {
this.processDefinitionVersion = processDefinitionVersion;
}
public long getProjectCode() {
return projectCode;
}
public void setProjectCode(long projectCode) {
this.projectCode = projectCode;
}
public long getProcessDefinitionCode() {
return processDefinitionCode;
}
public void setProcessDefinitionCode(long processDefinitionCode) {
this.processDefinitionCode = processDefinitionCode;
}
public long getPreTaskCode() {
return preTaskCode;
}
public void setPreTaskCode(long preTaskCode) {
this.preTaskCode = preTaskCode;
}
public long getPostTaskCode() {
return postTaskCode;
}
public void setPostTaskCode(long postTaskCode) {
this.postTaskCode = postTaskCode;
}
public ConditionType getConditionType() {
return conditionType;
}
public void setConditionType(ConditionType conditionType) {
this.conditionType = conditionType;
}
public int getOperator() {
return operator;
@ -262,30 +79,4 @@ public class ProcessTaskRelationLog {
this.operateTime = operateTime;
}
public void set(ProcessTaskRelation processTaskRelation) {
this.name = processTaskRelation.getName();
this.processDefinitionVersion = processTaskRelation.getProcessDefinitionVersion();
this.projectCode = processTaskRelation.getProjectCode();
this.processDefinitionCode = processTaskRelation.getProcessDefinitionCode();
this.preTaskCode = processTaskRelation.getPreTaskCode();
this.postTaskCode = processTaskRelation.getPostTaskCode();
this.conditionType = processTaskRelation.getConditionType();
this.conditionParams = processTaskRelation.getConditionParams();
}
public int getPostNodeVersion() {
return postNodeVersion;
}
public void setPostNodeVersion(int postNodeVersion) {
this.postNodeVersion = postNodeVersion;
}
public int getPreNodeVersion() {
return preNodeVersion;
}
public void setPreNodeVersion(int preNodeVersion) {
this.preNodeVersion = preNodeVersion;
}
}

19
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java

@ -14,16 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.dao.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.dolphinscheduler.common.enums.*;
import org.apache.dolphinscheduler.common.enums.Flag;
import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy;
import org.apache.dolphinscheduler.common.enums.TaskType;
import org.apache.dolphinscheduler.common.enums.TimeoutFlag;
import org.apache.dolphinscheduler.common.process.Property;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
@ -33,6 +30,12 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* task definition

392
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinitionLog.java

@ -17,142 +17,16 @@
package org.apache.dolphinscheduler.dao.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.dolphinscheduler.common.enums.*;
import org.apache.dolphinscheduler.common.process.Property;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* task definition log
*/
@TableName("t_ds_task_definition_log")
public class TaskDefinitionLog {
/**
* id
*/
@TableId(value = "id", type = IdType.AUTO)
private int id;
/**
* code
*/
private long code;
/**
* name
*/
private String name;
/**
* version
*/
private int version;
/**
* description
*/
private String description;
/**
* project code
*/
private long projectCode;
/**
* task user id
*/
private int userId;
/**
* task type
*/
private TaskType taskType;
/**
* user defined parameters
*/
private String taskParams;
/**
* user defined parameter list
*/
@TableField(exist = false)
private List<Property> taskParamList;
/**
* user define parameter map
*/
@TableField(exist = false)
private Map<String, String> taskParamMap;
/**
* task is valid: yes/no
*/
private Flag flag;
/**
* task priority
*/
private Priority taskPriority;
/**
* user name
*/
@TableField(exist = false)
private String userName;
/**
* project name
*/
@TableField(exist = false)
private String projectName;
/**
* worker group
*/
private String workerGroup;
/**
* fail retry times
*/
private int failRetryTimes;
/**
* fail retry interval
*/
private int failRetryInterval;
/**
* timeout flag
*/
private TimeoutFlag timeoutFlag;
/**
* timeout notify strategy
*/
private TaskTimeoutStrategy taskTimeoutStrategy;
/**
* task warning time out. unit: minute
*/
private int timeout;
/**
* resource ids
*/
private String resourceIds;
public class TaskDefinitionLog extends TaskDefinition {
/**
* operator user id
@ -165,203 +39,36 @@ public class TaskDefinitionLog {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date operateTime;
/**
* create time
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/**
* update time
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Flag getFlag() {
return flag;
}
public void setFlag(Flag flag) {
this.flag = flag;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getProjectName() {
return projectName;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public String getTaskParams() {
return taskParams;
}
public void setTaskParams(String taskParams) {
if (taskParams == null) {
this.taskParamList = new ArrayList<>();
} else {
this.taskParamList = JSONUtils.toList(taskParams, Property.class);
}
this.taskParams = taskParams;
}
public List<Property> getTaskParamList() {
return taskParamList;
}
public void setTaskParamList(List<Property> taskParamList) {
this.taskParams = JSONUtils.toJsonString(taskParamList);
this.taskParamList = taskParamList;
}
public Map<String, String> getTaskParamMap() {
if (taskParamMap == null && StringUtils.isNotEmpty(taskParams)) {
List<Property> propList = JSONUtils.toList(taskParams, Property.class);
taskParamMap = propList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue));
}
return taskParamMap;
}
public void setTaskParamMap(Map<String, String> taskParamMap) {
this.taskParamMap = taskParamMap;
}
public int getTimeout() {
return timeout;
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public long getCode() {
return code;
}
public void setCode(long code) {
this.code = code;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public long getProjectCode() {
return projectCode;
}
public void setProjectCode(long projectCode) {
this.projectCode = projectCode;
}
public TaskType getTaskType() {
return taskType;
}
public void setTaskType(TaskType taskType) {
this.taskType = taskType;
}
public Priority getTaskPriority() {
return taskPriority;
}
public void setTaskPriority(Priority taskPriority) {
this.taskPriority = taskPriority;
}
public String getWorkerGroup() {
return workerGroup;
}
public void setWorkerGroup(String workerGroup) {
this.workerGroup = workerGroup;
}
public int getFailRetryTimes() {
return failRetryTimes;
}
public void setFailRetryTimes(int failRetryTimes) {
this.failRetryTimes = failRetryTimes;
}
public int getFailRetryInterval() {
return failRetryInterval;
}
public void setFailRetryInterval(int failRetryInterval) {
this.failRetryInterval = failRetryInterval;
}
public TaskTimeoutStrategy getTaskTimeoutStrategy() {
return taskTimeoutStrategy;
}
public void setTaskTimeoutStrategy(TaskTimeoutStrategy taskTimeoutStrategy) {
this.taskTimeoutStrategy = taskTimeoutStrategy;
public TaskDefinitionLog() {
super();
}
public TaskDefinitionLog(TaskDefinition taskDefinition) {
super();
this.setId(taskDefinition.getId());
this.setCode(taskDefinition.getCode());
this.setVersion(taskDefinition.getVersion());
this.setName(taskDefinition.getName());
this.setDescription(taskDefinition.getDescription());
this.setUserId(taskDefinition.getUserId());
this.setUserName(taskDefinition.getUserName());
this.setWorkerGroup(taskDefinition.getWorkerGroup());
this.setProjectCode(taskDefinition.getProjectCode());
this.setProjectName(taskDefinition.getProjectName());
this.setResourceIds(taskDefinition.getResourceIds());
this.setTaskParams(taskDefinition.getTaskParams());
this.setTaskParamList(taskDefinition.getTaskParamList());
this.setTaskParamMap(taskDefinition.getTaskParamMap());
this.setTaskPriority(taskDefinition.getTaskPriority());
this.setTaskTimeoutStrategy(taskDefinition.getTaskTimeoutStrategy());
this.setTaskType(taskDefinition.getTaskType());
this.setTimeout(taskDefinition.getTimeout());
this.setTimeoutFlag(taskDefinition.getTimeoutFlag());
this.setUpdateTime(taskDefinition.getUpdateTime());
this.setCreateTime(taskDefinition.getCreateTime());
this.setFailRetryInterval(taskDefinition.getFailRetryInterval());
this.setFailRetryTimes(taskDefinition.getFailRetryTimes());
this.setFlag(taskDefinition.getFlag());
}
public int getOperator() {
@ -379,41 +86,4 @@ public class TaskDefinitionLog {
public void setOperateTime(Date operateTime) {
this.operateTime = operateTime;
}
public TimeoutFlag getTimeoutFlag() {
return timeoutFlag;
}
public void setTimeoutFlag(TimeoutFlag timeoutFlag) {
this.timeoutFlag = timeoutFlag;
}
public String getResourceIds() {
return resourceIds;
}
public void setResourceIds(String resourceIds) {
this.resourceIds = resourceIds;
}
public void set(TaskDefinition taskDefinition) {
this.code = taskDefinition.getCode();
this.name = taskDefinition.getName();
this.version = taskDefinition.getVersion();
this.description = taskDefinition.getDescription();
this.projectCode = taskDefinition.getProjectCode();
this.userId = taskDefinition.getUserId();
this.taskType = taskDefinition.getTaskType();
this.taskParams = taskDefinition.getTaskParams();
this.flag = taskDefinition.getFlag();
this.taskPriority = taskDefinition.getTaskPriority();
this.workerGroup = taskDefinition.getWorkerGroup();
this.failRetryTimes = taskDefinition.getFailRetryTimes();
this.failRetryInterval = taskDefinition.getFailRetryInterval();
this.timeoutFlag = taskDefinition.getTimeoutFlag();
this.taskTimeoutStrategy = taskDefinition.getTaskTimeoutStrategy();
this.timeout = taskDefinition.getTimeout();
this.createTime = taskDefinition.getCreateTime();
this.updateTime = taskDefinition.getUpdateTime();
}
}

63
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionLogMapperTest.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.mapper;
import org.apache.dolphinscheduler.common.enums.TaskType;
import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog;
import java.util.Date;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
@Rollback(true)
public class TaskDefinitionLogMapperTest {
@Autowired
TaskDefinitionLogMapper taskDefinitionLogMapper;
public TaskDefinitionLog insertOne() {
TaskDefinitionLog taskDefinition = new TaskDefinitionLog();
taskDefinition.setCode(888888L);
taskDefinition.setName("unit-test");
taskDefinition.setProjectCode(111111L);
taskDefinition.setTaskType(TaskType.SHELL);
taskDefinition.setUserId(99);
taskDefinition.setVersion(1);
taskDefinition.setCreateTime(new Date());
taskDefinition.setUpdateTime(new Date());
taskDefinitionLogMapper.insert(taskDefinition);
return taskDefinition;
}
@Test
public void testInsert() {
TaskDefinitionLog taskDefinitionLog = insertOne();
Assert.assertNotEquals(taskDefinitionLog.getId(), 0);
}
}

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

@ -0,0 +1,62 @@
/*
* 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.mapper;
import org.apache.dolphinscheduler.common.enums.TaskType;
import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
import java.util.Date;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
@Rollback(true)
public class TaskDefinitionMapperTest {
@Autowired
TaskDefinitionMapper taskDefinitionMapper;
public TaskDefinition insertOne() {
TaskDefinition taskDefinition = new TaskDefinition();
taskDefinition.setCode(888888L);
taskDefinition.setName("unit-test");
taskDefinition.setProjectCode(111111L);
taskDefinition.setTaskType(TaskType.SHELL);
taskDefinition.setUserId(99);
taskDefinition.setVersion(1);
taskDefinition.setCreateTime(new Date());
taskDefinition.setUpdateTime(new Date());
taskDefinitionMapper.insert(taskDefinition);
return taskDefinition;
}
@Test
public void testInsert() {
TaskDefinition taskDefinition = insertOne();
Assert.assertNotEquals(taskDefinition.getId(), 0);
}
}

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

@ -404,10 +404,7 @@ public class ProcessService {
* covert log to process definition
*/
public ProcessDefinition convertFromLog(ProcessDefinitionLog processDefinitionLog) {
ProcessDefinition definition = null;
if (null != processDefinitionLog) {
definition = JSONUtils.parseObject(JSONUtils.toJsonString(processDefinitionLog), ProcessDefinition.class);
}
ProcessDefinition definition = processDefinitionLog;
if (null != definition) {
definition.setId(0);
}
@ -2148,8 +2145,7 @@ public class ProcessService {
return Constants.EXIT_CODE_FAILURE;
}
ProcessDefinition tmpDefinition = JSONUtils.parseObject(JSONUtils.toJsonString(processDefinitionLog),
ProcessDefinition.class);
ProcessDefinition tmpDefinition = processDefinitionLog;
tmpDefinition.setId(processDefinition.getId());
tmpDefinition.setReleaseState(ReleaseState.OFFLINE);
tmpDefinition.setFlag(Flag.YES);
@ -2171,8 +2167,7 @@ public class ProcessService {
}
List<ProcessTaskRelationLog> processTaskRelationLogList = processTaskRelationLogMapper.queryByProcessCodeAndVersion(processDefinition.getCode(), processDefinition.getVersion());
for (ProcessTaskRelationLog processTaskRelationLog : processTaskRelationLogList) {
ProcessTaskRelation processTaskRelation = JSONUtils.parseObject(JSONUtils.toJsonString(processTaskRelationLog),
ProcessTaskRelation.class);
ProcessTaskRelation processTaskRelation = processTaskRelationLog;
processTaskRelationMapper.insert(processTaskRelation);
}
}
@ -2196,8 +2191,7 @@ public class ProcessService {
setTaskFromTaskNode(taskNode, taskDefinition);
int update = taskDefinitionMapper.updateById(taskDefinition);
// save task definition log
TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog();
taskDefinitionLog.set(taskDefinition);
TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog(taskDefinition);
taskDefinitionLog.setOperator(operator.getId());
taskDefinitionLog.setOperateTime(now);
int insert = taskDefinitionLogMapper.insert(taskDefinitionLog);
@ -2332,25 +2326,27 @@ public class ProcessService {
List<String> depList = taskNode.getDepList();
if (CollectionUtils.isNotEmpty(depList)) {
for (String preTaskName : depList) {
builderRelationList.add(new ProcessTaskRelation("",// todo relation name
builderRelationList.add(new ProcessTaskRelation("",
processDefinition.getVersion(),
projectCode,
processDefinition.getCode(),
taskNameAndCode.get(preTaskName),
taskNameAndCode.get(taskNode.getName()),
ConditionType.of("none"), // todo conditionType
ConditionType.of("none"),
taskNode.getConditionResult(),
now,
now));
}
} else {
builderRelationList.add(new ProcessTaskRelation("",// todo relation name
// todo relation name
builderRelationList.add(new ProcessTaskRelation("",
processDefinition.getVersion(),
projectCode,
processDefinition.getCode(),
0L,
taskNameAndCode.get(taskNode.getName()),
ConditionType.of("none"), // todo conditionType
// todo conditionType
ConditionType.of("none"),
taskNode.getConditionResult(),
now,
now));
@ -2359,8 +2355,7 @@ public class ProcessService {
for (ProcessTaskRelation processTaskRelation : builderRelationList) {
processTaskRelationMapper.insert(processTaskRelation);
// save process task relation log
ProcessTaskRelationLog processTaskRelationLog = new ProcessTaskRelationLog();
processTaskRelationLog.set(processTaskRelation);
ProcessTaskRelationLog processTaskRelationLog = new ProcessTaskRelationLog(processTaskRelation);
processTaskRelationLog.setOperator(operator.getId());
processTaskRelationLog.setOperateTime(now);
processTaskRelationLogMapper.insert(processTaskRelationLog);
@ -2377,9 +2372,7 @@ public class ProcessService {
setTaskFromTaskNode(taskNode, taskDefinition);
// save the new task definition
int insert = taskDefinitionMapper.insert(taskDefinition);
// save task definition log
TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog();
taskDefinitionLog.set(taskDefinition);
TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog(taskDefinition);
taskDefinitionLog.setOperator(operator.getId());
taskDefinitionLog.setOperateTime(now);
int logInsert = taskDefinitionLogMapper.insert(taskDefinitionLog);
@ -2428,11 +2421,25 @@ public class ProcessService {
processVersion);
List<ProcessTaskRelation> processTaskRelations = new ArrayList<>();
for (ProcessTaskRelationLog processTaskRelationLog : taskRelationLogs) {
processTaskRelations.add(JSONUtils.parseObject(JSONUtils.toJsonString(processTaskRelationLog), ProcessTaskRelation.class));
processTaskRelations.add(processTaskRelationLog);
}
return processTaskRelations;
}
/**
* generate ProcessData
*/
public ProcessData genProcessData(ProcessDefinition processDefinition) {
List<TaskNode> taskNodes = genTaskNodeList(processDefinition.getCode()
, processDefinition.getVersion());
ProcessData processData = new ProcessData();
processData.setTasks(taskNodes);
processData.setGlobalParams(JSONUtils.toList(processDefinition.getGlobalParams(), Property.class));
processData.setTenantId(processDefinition.getTenantId());
processData.setTimeout(processDefinition.getTimeout());
return processData;
}
public List<TaskNode> genTaskNodeList(Long processCode, int processVersion) {
List<ProcessTaskRelation> processTaskRelations = this.getProcessTaskRelationList(processCode, processVersion);
Set<TaskDefinition> taskDefinitionSet = new HashSet<>();

Loading…
Cancel
Save