|
|
@ -52,7 +52,6 @@ import org.apache.dolphinscheduler.common.utils.StringUtils; |
|
|
|
import org.apache.dolphinscheduler.common.utils.placeholder.BusinessTimeUtils; |
|
|
|
import org.apache.dolphinscheduler.common.utils.placeholder.BusinessTimeUtils; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessData; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessData; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Project; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Project; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; |
|
|
@ -72,7 +71,6 @@ import java.io.ByteArrayInputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStreamReader; |
|
|
|
import java.io.InputStreamReader; |
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
import java.text.ParseException; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.Date; |
|
|
@ -425,12 +423,12 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce |
|
|
|
* @param locations locations |
|
|
|
* @param locations locations |
|
|
|
* @param connects connects |
|
|
|
* @param connects connects |
|
|
|
* @return update result code |
|
|
|
* @return update result code |
|
|
|
* @throws ParseException parse exception for json parse |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Transactional |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Map<String, Object> updateProcessInstance(User loginUser, String projectName, Integer processInstanceId, |
|
|
|
public Map<String, Object> updateProcessInstance(User loginUser, String projectName, Integer processInstanceId, |
|
|
|
String processInstanceJson, String scheduleTime, Boolean syncDefine, |
|
|
|
String processInstanceJson, String scheduleTime, Boolean syncDefine, |
|
|
|
Flag flag, String locations, String connects) throws ParseException { |
|
|
|
Flag flag, String locations, String connects) { |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Project project = projectMapper.queryByName(projectName); |
|
|
|
Project project = projectMapper.queryByName(projectName); |
|
|
|
//check project permission
|
|
|
|
//check project permission
|
|
|
@ -461,10 +459,10 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce |
|
|
|
} |
|
|
|
} |
|
|
|
Tenant tenant = processService.getTenantForProcess(processData.getTenantId(), |
|
|
|
Tenant tenant = processService.getTenantForProcess(processData.getTenantId(), |
|
|
|
processDefinition.getUserId()); |
|
|
|
processDefinition.getUserId()); |
|
|
|
setProcessInstance(processInstance, tenant, scheduleTime, locations, |
|
|
|
setProcessInstance(processInstance, tenant, scheduleTime, processData); |
|
|
|
connects, processInstanceJson, processData); |
|
|
|
|
|
|
|
int updateDefine = 1; |
|
|
|
int updateDefine = 1; |
|
|
|
if (Boolean.TRUE.equals(syncDefine)) { |
|
|
|
if (Boolean.TRUE.equals(syncDefine)) { |
|
|
|
|
|
|
|
processDefinition.setId(processDefineMapper.queryByCode(processInstance.getProcessDefinitionCode()).getId()); |
|
|
|
updateDefine = syncDefinition(loginUser, project, locations, connects, |
|
|
|
updateDefine = syncDefinition(loginUser, project, locations, connects, |
|
|
|
processInstance, processDefinition, processData); |
|
|
|
processInstance, processDefinition, processData); |
|
|
|
|
|
|
|
|
|
|
@ -495,37 +493,29 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce |
|
|
|
processDefinition.setTimeout(processInstance.getTimeout()); |
|
|
|
processDefinition.setTimeout(processInstance.getTimeout()); |
|
|
|
processDefinition.setUpdateTime(new Date()); |
|
|
|
processDefinition.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
|
|
|
|
int updateDefine = processService.saveProcessDefinition(loginUser, project, processDefinition.getName(), |
|
|
|
return processService.saveProcessDefinition(loginUser, project, processDefinition.getName(), |
|
|
|
processDefinition.getDescription(), locations, connects, |
|
|
|
processDefinition.getDescription(), locations, connects, |
|
|
|
processData, processDefinition); |
|
|
|
processData, processDefinition, false); |
|
|
|
return updateDefine; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* update process instance attributes |
|
|
|
* update process instance attributes |
|
|
|
* |
|
|
|
|
|
|
|
* @return false if check failed or |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void setProcessInstance(ProcessInstance processInstance, Tenant tenant, |
|
|
|
private void setProcessInstance(ProcessInstance processInstance, Tenant tenant, String scheduleTime, ProcessData processData) { |
|
|
|
String scheduleTime, String locations, String connects, String processInstanceJson, |
|
|
|
|
|
|
|
ProcessData processData) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date schedule = processInstance.getScheduleTime(); |
|
|
|
Date schedule = processInstance.getScheduleTime(); |
|
|
|
if (scheduleTime != null) { |
|
|
|
if (scheduleTime != null) { |
|
|
|
schedule = DateUtils.getScheduleDate(scheduleTime); |
|
|
|
schedule = DateUtils.getScheduleDate(scheduleTime); |
|
|
|
} |
|
|
|
} |
|
|
|
processInstance.setScheduleTime(schedule); |
|
|
|
processInstance.setScheduleTime(schedule); |
|
|
|
processInstance.setLocations(locations); |
|
|
|
|
|
|
|
processInstance.setConnects(connects); |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(processInstanceJson)) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<Property> globalParamList = processData.getGlobalParams(); |
|
|
|
List<Property> globalParamList = processData.getGlobalParams(); |
|
|
|
Map<String, String> globalParamMap = Optional.ofNullable(globalParamList).orElse(Collections.emptyList()).stream().collect(Collectors.toMap(Property::getProp, Property::getValue)); |
|
|
|
Map<String, String> globalParamMap = Optional.ofNullable(globalParamList) |
|
|
|
|
|
|
|
.orElse(Collections.emptyList()) |
|
|
|
|
|
|
|
.stream() |
|
|
|
|
|
|
|
.collect(Collectors.toMap(Property::getProp, Property::getValue)); |
|
|
|
String globalParams = ParameterUtils.curingGlobalParams(globalParamMap, globalParamList, |
|
|
|
String globalParams = ParameterUtils.curingGlobalParams(globalParamMap, globalParamList, |
|
|
|
processInstance.getCmdTypeIfComplement(), schedule); |
|
|
|
processInstance.getCmdTypeIfComplement(), schedule); |
|
|
|
int timeout = processData.getTimeout(); |
|
|
|
processInstance.setTimeout(processData.getTimeout()); |
|
|
|
processInstance.setTimeout(timeout); |
|
|
|
|
|
|
|
if (tenant != null) { |
|
|
|
if (tenant != null) { |
|
|
|
processInstance.setTenantCode(tenant.getTenantCode()); |
|
|
|
processInstance.setTenantCode(tenant.getTenantCode()); |
|
|
|
} |
|
|
|
} |
|
|
@ -706,13 +696,10 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce |
|
|
|
throw new RuntimeException("workflow instance is null"); |
|
|
|
throw new RuntimeException("workflow instance is null"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinitionLog processDefinitionLog = processDefinitionLogMapper.queryByDefinitionCodeAndVersion( |
|
|
|
ProcessDefinition processDefinition = processDefinitionLogMapper.queryByDefinitionCodeAndVersion( |
|
|
|
processInstance.getProcessDefinitionCode(), |
|
|
|
processInstance.getProcessDefinitionCode(), |
|
|
|
processInstance.getProcessDefinitionVersion() |
|
|
|
processInstance.getProcessDefinitionVersion() |
|
|
|
); |
|
|
|
); |
|
|
|
ProcessDefinition processDefinition = JSONUtils.parseObject(JSONUtils.toJsonString(processDefinitionLog), |
|
|
|
|
|
|
|
ProcessDefinition.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GanttDto ganttDto = new GanttDto(); |
|
|
|
GanttDto ganttDto = new GanttDto(); |
|
|
|
DAG<String, TaskNode, TaskNodeRelation> dag = processService.genDagGraph(processDefinition); |
|
|
|
DAG<String, TaskNode, TaskNodeRelation> dag = processService.genDagGraph(processDefinition); |
|
|
|
//topological sort
|
|
|
|
//topological sort
|
|
|
|