ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pallav...@apache.org
Subject ambari git commit: AMBARI-22089. Hive View 2.0 - Unable to update existing saved queries, view creates new records under saved queries tab (pallavkul)
Date Wed, 04 Oct 2017 18:50:06 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.6 ed1f9520c -> c523eb971


AMBARI-22089. Hive View 2.0 - Unable to update existing saved queries, view creates new records
under saved queries tab (pallavkul)


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

Branch: refs/heads/branch-2.6
Commit: c523eb9719c6c2d05acc54234426e7dd0ed269b7
Parents: ed1f952
Author: pallavkul <pallav.kul@gmail.com>
Authored: Fri Sep 29 20:50:43 2017 +0530
Committer: pallavkul <pallav.kul@gmail.com>
Committed: Thu Oct 5 00:19:46 2017 +0530

----------------------------------------------------------------------
 .../savedQueries/SavedQueryResourceManager.java | 17 ++++--
 .../resources/ui/app/routes/queries/query.js    | 63 +++++++++++++++-----
 .../hive20/src/main/resources/ui/yarn.lock      |  2 +-
 3 files changed, 61 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c523eb97/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/savedQueries/SavedQueryResourceManager.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/savedQueries/SavedQueryResourceManager.java
b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/savedQueries/SavedQueryResourceManager.java
index 3690683..fff202c 100644
--- a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/savedQueries/SavedQueryResourceManager.java
+++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/savedQueries/SavedQueryResourceManager.java
@@ -115,12 +115,17 @@ public class SavedQueryResourceManager extends PersonalCRUDResourceManager<Saved
   }
 
   @Override
-  public SavedQuery update(SavedQuery newObject, String id) throws ItemNotFound {
-    SavedQuery savedQuery = super.update(newObject, id);
-    // Emptying short query so that in next read, this gets updated with proper value
-    // from the queryFile
-    emptyShortQueryField(savedQuery);
-    return savedQuery;
+  public SavedQuery update(SavedQuery object, String id) throws ItemNotFound {
+    String query = object.getShortQuery();
+    object.setShortQuery(makeShortQuery(query));
+    object = super.update(object, id);
+    try {
+      createDefaultQueryFile(object, query);
+
+    } catch (ServiceFormattedException e) {
+      cleanupAfterErrorAndThrowAgain(object, e);
+    }
+    return object;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/c523eb97/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js b/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js
index 9e8b6db..3e5adc1 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js
@@ -631,44 +631,79 @@ export default Ember.Route.extend(UILoggerMixin, {
       let owner = this.get('controller.model').get('owner');
       let queryFile = this.get('controller.model').get('queryFile');
       let logFile = this.get('controller.model').get('logFile');
+      let shortQuery = (currentQuery.length > 0) ? currentQuery : ";";
+      let savedQueryId = this.get('controller.model').get('id');
 
-      let payload = {"title" : newTitle,
-        "dataBase": selectedDb,
-        "owner" : owner,
-        "shortQuery" : (currentQuery.length > 0) ? currentQuery : ";",
-        "queryFile" : queryFile,
-        "logFile" : logFile};
+
+      this.store.findAll('savedQuery').then(savedQueries => {
+        return savedQueries.toArray();
+      }).then((existingSavedQueries) =>{
+
+        var queryExist = existingSavedQueries.filterBy('id', savedQueryId).get('firstObject');
+
+        if(queryExist){
+          this.send('updateSavedQuery',  queryExist.get('id'));
+        } else{
+          this.send('addSavedQuery', selectedDb, newTitle, owner, shortQuery );
+        }
+
+
+      });
+
+    },
+
+    addSavedQuery(selectedDb, newTitle, owner, shortQuery){
 
       let newSaveQuery = this.get('store').createRecord('saved-query',
         { dataBase:selectedDb,
           title:newTitle,
-          queryFile: queryFile,
           owner: owner,
-          shortQuery: (currentQuery.length > 0) ? currentQuery : ";"
+          shortQuery: shortQuery
         });
 
-
       newSaveQuery.save().then((data) => {
-        console.log('saved query saved');
-
         this.get('controller.model').set('title', newTitle);
         this.get('controller.model').set('isQueryDirty', false);
         this.get('controller').set('worksheetModalSuccess', true);
-
         Ember.run.later(() => {
           this.get('controller').set('showWorksheetModal', false);
           this.closeWorksheetAfterSave();
         }, 2 * 1000);
-
       });
 
     },
 
+    updateSavedQuery(savedQueryId){
+          let currentQuery = this.get('controller.model').get('query');
+          let selectedDb = this.get('controller.model').get('selectedDb');
+          let owner = this.get('controller.model').get('owner');
+
+          this.get('store').findRecord('saved-query', savedQueryId ).then(savedQuery =>
{
+            savedQuery.set('shortQuery', (currentQuery.length > 0) ? currentQuery : ";");
+            savedQuery.set('dataBase', selectedDb );
+            savedQuery.set('owner', owner );
+
+            savedQuery.save().then(savedQuery => {
+
+                this.get('controller.model').set('isQueryDirty', false);
+                this.get('controller').set('worksheetModalSuccess', true);
+
+                Ember.run.later(() => {
+                  this.get('controller').set('showWorksheetModal', false);
+                  this.closeWorksheetAfterSave();
+                }, 2 * 1000);
+            })
+
+          });
+
+
+    },
+
     closeWorksheetModal(){
       this.get('controller').set('showWorksheetModal', false);
       this.closeWorksheetAfterSave();
       this.get('controller.model').set('tabDataToClose', null);
-  },
+    },
 
     expandQueryEdidorPanel(){
       if(!this.get('isQueryEdidorPaneExpanded')){

http://git-wip-us.apache.org/repos/asf/ambari/blob/c523eb97/contrib/views/hive20/src/main/resources/ui/yarn.lock
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/yarn.lock b/contrib/views/hive20/src/main/resources/ui/yarn.lock
index 477a15c..607cf81 100644
--- a/contrib/views/hive20/src/main/resources/ui/yarn.lock
+++ b/contrib/views/hive20/src/main/resources/ui/yarn.lock
@@ -569,7 +569,7 @@ babel-plugin-transform-es2015-block-scoped-functions@^6.22.0:
   dependencies:
     babel-runtime "^6.22.0"
 
-babel-plugin-transform-es2015-block-scoping@^6.23.0:
+babel-plugin-transform-es2015-block-scoping@^6.23.0, babel-plugin-transform-es2015-block-scoping@^6.24.1:
   version "6.24.1"
   resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.24.1.tgz#76c295dc3a4741b1665adfd3167215dcff32a576"
   dependencies:


Mime
View raw message