|
@@ -32,8 +32,10 @@ import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationCon
|
|
|
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_TREE_VIEW;
|
|
|
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_UPDATE;
|
|
|
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS_DEFINE_CODE;
|
|
|
+import static org.apache.dolphinscheduler.common.Constants.COPY_SUFFIX;
|
|
|
import static org.apache.dolphinscheduler.common.Constants.DEFAULT_WORKER_GROUP;
|
|
|
import static org.apache.dolphinscheduler.common.Constants.EMPTY_STRING;
|
|
|
+import static org.apache.dolphinscheduler.common.Constants.IMPORT_SUFFIX;
|
|
|
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.COMPLEX_TASK_TYPES;
|
|
|
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_SQL;
|
|
|
|
|
@@ -1010,7 +1012,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
if (index > 0) {
|
|
|
processDefinitionName = processDefinitionName.substring(0, index);
|
|
|
}
|
|
|
- processDefinitionName = processDefinitionName + "_import_" + DateUtils.getCurrentTimeStamp();
|
|
|
+ processDefinitionName = getNewName(processDefinitionName, IMPORT_SUFFIX);
|
|
|
|
|
|
ProcessDefinition processDefinition;
|
|
|
List<TaskDefinitionLog> taskDefinitionList = new ArrayList<>();
|
|
@@ -1206,8 +1208,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
|
|
|
// generate import processDefinitionName
|
|
|
String processDefinitionName = recursionProcessDefinitionName(projectCode, processDefinition.getName(), 1);
|
|
|
- String importProcessDefinitionName = processDefinitionName + "_import_" + DateUtils.getCurrentTimeStamp();
|
|
|
-
|
|
|
+ String importProcessDefinitionName = getNewName(processDefinitionName, IMPORT_SUFFIX);
|
|
|
//unique check
|
|
|
Map<String, Object> checkResult = verifyProcessDefinitionName(loginUser, projectCode, importProcessDefinitionName);
|
|
|
if (Status.SUCCESS.equals(checkResult.get(Constants.STATUS))) {
|
|
@@ -1844,7 +1845,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
}
|
|
|
processDefinition.setId(0);
|
|
|
processDefinition.setUserId(loginUser.getId());
|
|
|
- processDefinition.setName(processDefinition.getName() + "_copy_" + DateUtils.getCurrentTimeStamp());
|
|
|
+ processDefinition.setName(getNewName(processDefinition.getName(), COPY_SUFFIX));
|
|
|
final Date date = new Date();
|
|
|
processDefinition.setCreateTime(date);
|
|
|
processDefinition.setUpdateTime(date);
|
|
@@ -1891,6 +1892,28 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * get new Task name or Process name when copy or import operate
|
|
|
+ * @param originalName Task or Process original name
|
|
|
+ * @param suffix "_copy_" or "_import_"
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String getNewName(String originalName, String suffix) {
|
|
|
+ StringBuilder newName = new StringBuilder();
|
|
|
+ String regex = String.format(".*%s\\d{17}$", suffix);
|
|
|
+ if (originalName.matches(regex)) {
|
|
|
+ //replace timestamp of originalName
|
|
|
+ return newName.append(originalName, 0, originalName.lastIndexOf(suffix))
|
|
|
+ .append(suffix)
|
|
|
+ .append(DateUtils.getCurrentTimeStamp())
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ return newName.append(originalName)
|
|
|
+ .append(suffix)
|
|
|
+ .append(DateUtils.getCurrentTimeStamp())
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* switch the defined process definition version
|
|
|
*
|