You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by ki...@apache.org on 2021/07/04 15:46:58 UTC

[dolphinscheduler] branch dev updated: [Fix-5714] When updating the existing alarm instance, the creation time should't be updated (#5715)

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

kirs 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 cf99df3  [Fix-5714] When updating the existing alarm instance, the creation time should't be updated (#5715)
cf99df3 is described below

commit cf99df3de00ef63ee96b7ab00427c7385c42720a
Author: kyoty <ec...@gmail.com>
AuthorDate: Sun Jul 4 23:46:47 2021 +0800

    [Fix-5714] When updating the existing alarm instance, the creation time should't be updated (#5715)
    
    
    
    * add a new init method.
---
 .../api/service/impl/AlertPluginInstanceServiceImpl.java           | 7 +++----
 .../apache/dolphinscheduler/dao/entity/AlertPluginInstance.java    | 7 +++++++
 .../dolphinscheduler/dao/mapper/AlertPluginInstanceMapper.xml      | 2 +-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java
index ea4664e..abfb15e 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java
+++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java
@@ -35,6 +35,7 @@ import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -109,11 +110,9 @@ public class AlertPluginInstanceServiceImpl extends BaseServiceImpl implements A
     @Override
     public Map<String, Object> update(User loginUser, int pluginInstanceId, String instanceName, String pluginInstanceParams) {
 
-        AlertPluginInstance alertPluginInstance = new AlertPluginInstance();
         String paramsMapJson = parsePluginParamsMap(pluginInstanceParams);
-        alertPluginInstance.setPluginInstanceParams(paramsMapJson);
-        alertPluginInstance.setInstanceName(instanceName);
-        alertPluginInstance.setId(pluginInstanceId);
+        AlertPluginInstance alertPluginInstance = new AlertPluginInstance(pluginInstanceId, paramsMapJson, instanceName, new Date());
+
         Map<String, Object> result = new HashMap<>();
         int i = alertPluginInstanceMapper.updateById(alertPluginInstance);
 
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AlertPluginInstance.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AlertPluginInstance.java
index 202c06b..f94d220 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AlertPluginInstance.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AlertPluginInstance.java
@@ -80,6 +80,13 @@ public class AlertPluginInstance {
         this.instanceName = instanceName;
     }
 
+    public AlertPluginInstance(int id, String pluginInstanceParams, String instanceName, Date updateDate) {
+        this.id = id;
+        this.pluginInstanceParams = pluginInstanceParams;
+        this.updateTime = updateDate;
+        this.instanceName = instanceName;
+    }
+
     public int getId() {
         return id;
     }
diff --git a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AlertPluginInstanceMapper.xml b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AlertPluginInstanceMapper.xml
index febfaf7..b137a6c 100644
--- a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AlertPluginInstanceMapper.xml
+++ b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AlertPluginInstanceMapper.xml
@@ -49,4 +49,4 @@
         where instance_name = #{instanceName} limit 1
     </select>
 
-</mapper>
\ No newline at end of file
+</mapper>