ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [28/50] [abbrv] ambari git commit: AMBARI-14507. Attempt to Open a Saved Query Returns Unexpected Results. (Dipayan Bhowmick via yusaku)
Date Fri, 08 Jan 2016 18:15:45 GMT
AMBARI-14507. Attempt to Open a Saved Query Returns Unexpected Results. (Dipayan Bhowmick via
yusaku)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ac2def33
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ac2def33
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ac2def33

Branch: refs/heads/branch-dev-patch-upgrade
Commit: ac2def335ad387e7e8ef92584223cee30d1a70bd
Parents: 9b99d49
Author: Yusaku Sako <yusaku@hortonworks.com>
Authored: Wed Jan 6 12:24:17 2016 -0800
Committer: Yusaku Sako <yusaku@hortonworks.com>
Committed: Wed Jan 6 12:24:17 2016 -0800

----------------------------------------------------------------------
 .../savedQueries/SavedQueryResourceManager.java   | 18 ++++++++++++++++--
 .../ui/hive-web/app/controllers/open-queries.js   |  8 +++++++-
 2 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ac2def33/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/savedQueries/SavedQueryResourceManager.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/savedQueries/SavedQueryResourceManager.java
b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/savedQueries/SavedQueryResourceManager.java
index 76a9888..21a3967 100644
--- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/savedQueries/SavedQueryResourceManager.java
+++ b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/savedQueries/SavedQueryResourceManager.java
@@ -116,6 +116,11 @@ public class SavedQueryResourceManager extends PersonalCRUDResourceManager<Saved
     storageFactory.getStorage().store(SavedQuery.class, savedQuery);
   }
 
+  private void emptyShortQueryField(SavedQuery query) {
+    query.setShortQuery("");
+    storageFactory.getStorage().store(SavedQuery.class, query);
+  }
+
   /**
    * Generate short preview of query.
    * Remove SET settings like "set hive.execution.engine=tez;" from beginning
@@ -132,13 +137,22 @@ public class SavedQueryResourceManager extends PersonalCRUDResourceManager<Saved
   @Override
   public SavedQuery update(SavedQuery newObject, String id) throws ItemNotFound {
     SavedQuery savedQuery = super.update(newObject, id);
-    fillShortQueryField(savedQuery);
+    // Emptying short query so that in next read, this gets updated with proper value
+    // from the queryFile
+    emptyShortQueryField(savedQuery);
     return savedQuery;
   }
 
   @Override
   public List<SavedQuery> readAll(FilteringStrategy filteringStrategy) {
-    return super.readAll(filteringStrategy);
+    List<SavedQuery> queries = super.readAll(filteringStrategy);
+    for(SavedQuery query : queries) {
+      String shortQuery = query.getShortQuery();
+      if(shortQuery == null || shortQuery.isEmpty()) {
+        fillShortQueryField(query);
+      }
+    }
+    return queries;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/ac2def33/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/open-queries.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/open-queries.js
b/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/open-queries.js
index 611d8fe..a4048be 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/open-queries.js
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/open-queries.js
@@ -249,6 +249,11 @@ export default Ember.ArrayController.extend({
         file.set('fileContent', oldQuery.get('fileContent'));
       }
 
+      // Rollback the oldQuery if it is a DS model (type: 'savedQuery)
+      if (oldQuery.get('constructor.typeKey') !== undefined) {
+        oldQuery.rollback();
+      }
+
       self.removeObject(oldQuery);
       self.pushObject(file);
 
@@ -354,11 +359,12 @@ export default Ember.ArrayController.extend({
 
           defer.promise.then(function (text) {
             model.set('title', text);
-            self.save(model, query).then(function () {
+            self.save(model, query, false, text).then(function () {
               self.closeTab(tab, true);
             });
           }, function () {
             model.rollback();
+            query.rollback();
             self.closeTab(tab, true);
           });
         }


Mime
View raw message