ruanwenjun commented on code in PR #10621:
URL: https://github.com/apache/dolphinscheduler/pull/10621#discussion_r929487417
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java:
##########
@@ -1876,6 +1879,31 @@ protected void doBatchOperateProcessDefinition(User
loginUser,
}
}
+ /**
+ * 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
+ */
+ private String getNewName(String originalName, String suffix) {
+ StringBuilder newName = new StringBuilder();
+ if (originalName.contains(suffix)) {
+ final String originalTimeStamp =
originalName.substring(originalName.lastIndexOf(suffix) + suffix.length());
+ try {
+ SimpleDateFormat dateFormat = new
SimpleDateFormat(Constants.YYYYMMDDHHMMSSSSS);
+ dateFormat.parse(originalTimeStamp);
+ //replace timestamp in originalName
+ newName.append(originalName, 0,
originalName.lastIndexOf(suffix))
+ .append(suffix)
+ .append(DateUtils.getCurrentTimeStamp());
+ return newName.toString();
+ } catch (Exception e) {
+ logger.error("error while parse last timestamp in {}",
originalName);
Review Comment:
It's better to directly throw exception here, if the code is right, there
are should not exist exception.
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java:
##########
@@ -1876,6 +1879,31 @@ protected void doBatchOperateProcessDefinition(User
loginUser,
}
}
+ /**
+ * 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
+ */
+ private String getNewName(String originalName, String suffix) {
+ StringBuilder newName = new StringBuilder();
+ if (originalName.contains(suffix)) {
+ final String originalTimeStamp =
originalName.substring(originalName.lastIndexOf(suffix) + suffix.length());
+ try {
+ SimpleDateFormat dateFormat = new
SimpleDateFormat(Constants.YYYYMMDDHHMMSSSSS);
+ dateFormat.parse(originalTimeStamp);
Review Comment:
This is unnecessary?
```suggestion
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]