瀏覽代碼

HUE-7819 [metastore] Update table comment to metadata server if available

This way we keep the auditing via calling the metadata REST API.
We know display errors in case of problems when updating HMS.
Romain Rigaux 8 年之前
父節點
當前提交
9d7487e
共有 1 個文件被更改,包括 28 次插入9 次删除
  1. 28 9
      apps/metastore/src/metastore/static/metastore/js/metastore.model.js

+ 28 - 9
apps/metastore/src/metastore/static/metastore/js/metastore.model.js

@@ -443,15 +443,34 @@ var MetastoreTable = (function () {
     });
 
     self.comment.subscribe(function (newValue) {
-      $.post('/metastore/table/' + self.database.name + '/' + self.name + '/alter', {
-        source_type: self.sourceType,
-        comment: newValue ? newValue : ""
-      }, function () {
-        huePubSub.publish('assist.clear.db.cache', {
-          sourceType: self.sourceType,
-          databaseName: self.database.name
-        })
-      });
+      var updateCall;
+      var comment = newValue ? newValue : "";
+
+      if (self.navigatorEnabled) {
+        updateCall = $.post('/metadata/api/navigator/update_properties', {
+          id: ko.mapping.toJSON(self.navigatorStats().identity),
+          properties: ko.mapping.toJSON({description: comment})
+        });
+      } else {
+        updateCall = $.post('/metastore/table/' + self.database.name + '/' + self.name + '/alter', {
+          source_type: self.sourceType,
+          comment: comment
+        });
+      }
+
+      updateCall.done(function(data) {
+        if (data && data.status == 0) {
+         huePubSub.publish('assist.clear.db.cache', {
+           sourceType: self.sourceType,
+           databaseName: self.database.name
+         })
+       } else {
+         var message = data.message || data.data;
+         if (message) {
+           $(document).trigger("error", message);
+         }
+       }
+      })
     });
 
     self.refreshTableStats = function () {