This is an automated email from the ASF dual-hosted git repository.

wenjun pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new cc2f17ddcc [Enhancement][API] Copy workflow with scheduler info 
(#10677)
cc2f17ddcc is described below

commit cc2f17ddcc3649bf9f1222e01c00e95053d376ad
Author: zhuxt2015 <[email protected]>
AuthorDate: Wed Jul 27 13:45:45 2022 +0800

    [Enhancement][API] Copy workflow with scheduler info (#10677)
    
    * support batch copy workflow with scheduler
---
 .../api/service/impl/ProcessDefinitionServiceImpl.java    | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
index 4b493c6025..8e49ffea27 100644
--- 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
+++ 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
@@ -1716,6 +1716,7 @@ public class ProcessDefinitionServiceImpl extends 
BaseServiceImpl implements Pro
      * @param targetProjectCode targetProjectCode
      */
     @Override
+    @Transactional
     public Map<String, Object> batchCopyProcessDefinition(User loginUser,
                                                           long projectCode,
                                                           String codes,
@@ -1834,6 +1835,7 @@ public class ProcessDefinitionServiceImpl extends 
BaseServiceImpl implements Pro
                         
processTaskRelationLog.setPostTaskCode(taskCodeMap.get(processTaskRelationLog.getPostTaskCode()));
                     }
                 }
+                final long oldProcessDefinitionCode = 
processDefinition.getCode();
                 try {
                     
processDefinition.setCode(CodeGenerateUtils.getInstance().genCode());
                 } catch (CodeGenerateException e) {
@@ -1856,6 +1858,19 @@ public class ProcessDefinitionServiceImpl extends 
BaseServiceImpl implements Pro
                     }
                     
processDefinition.setLocations(JSONUtils.toJsonString(jsonNodes));
                 }
+                //copy timing configuration
+                Schedule scheduleObj = 
scheduleMapper.queryByProcessDefinitionCode(oldProcessDefinitionCode);
+                if (scheduleObj != null) {
+                    
scheduleObj.setProcessDefinitionCode(processDefinition.getCode());
+                    scheduleObj.setReleaseState(ReleaseState.OFFLINE);
+                    scheduleObj.setCreateTime(date);
+                    scheduleObj.setUpdateTime(date);
+                    int insertResult = scheduleMapper.insert(scheduleObj);
+                    if (insertResult != 1) {
+                        putMsg(result, Status.CREATE_SCHEDULE_ERROR);
+                        throw new 
ServiceException(Status.CREATE_SCHEDULE_ERROR);
+                    }
+                }
                 try {
                     result.putAll(createDagDefine(loginUser, taskRelationList, 
processDefinition, taskDefinitionLogs, otherParamsJson));
                 } catch (Exception e) {

Reply via email to