ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject incubator-ignite git commit: IGNITE-843 Implemented jdbc drivers load from agent and extract metadata from database via agent.
Date Sat, 15 Aug 2015 01:54:12 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 3a1c1529d -> 7d6d4043c


IGNITE-843 Implemented jdbc drivers load from agent and extract metadata from database via
agent.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7d6d4043
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7d6d4043
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7d6d4043

Branch: refs/heads/ignite-843
Commit: 7d6d4043cb70ea4d1e86c7cdfca3017d18043476
Parents: 3a1c152
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Sat Aug 15 08:54:06 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Sat Aug 15 08:54:06 2015 +0700

----------------------------------------------------------------------
 .../main/js/controllers/metadata-controller.js  | 113 ++++++++++++-------
 .../main/js/controllers/models/metadata.json    |  18 +--
 .../control-center-web/src/main/js/package.json |   2 +-
 .../src/main/js/routes/agent.js                 |   4 +-
 4 files changed, 79 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d6d4043/modules/control-center-web/src/main/js/controllers/metadata-controller.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/metadata-controller.js b/modules/control-center-web/src/main/js/controllers/metadata-controller.js
index c3e41cf..cb2e6dd 100644
--- a/modules/control-center-web/src/main/js/controllers/metadata-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/metadata-controller.js
@@ -41,62 +41,88 @@ controlCenterModule.controller('metadataController', [
 
             $scope.compactJavaName = $common.compactJavaName;
 
-            $scope.databases = [
-                {value: 'oracle', label: 'Oracle database'},
-                {value: 'db2', label: 'IBM DB2'},
-                {value: 'mssql', label: 'MS SQL Server'},
-                {value: 'postgre', label: 'PostgreSQL'},
-                {value: 'mysql', label: 'MySQL'},
-                {value: 'h2', label: 'H2 database'}
-            ];
-
-            var presets = {
-                oracle: {
+            var presets = [
+                {
                     db: 'oracle',
-                    drvClass: 'oracle.jdbc.OracleDriver',
-                    drvUrl: 'jdbc:oracle:thin:@[host]:[port]:[database]',
+                    jdbcDriverClass: 'oracle.jdbc.OracleDriver',
+                    jdbcUrl: 'jdbc:oracle:thin:@[host]:[port]:[database]',
                     user: 'system'
                 },
-                db2: {
+                {
                     db: 'db2',
-                    drvClass: 'com.ibm.db2.jcc.DB2Driver',
-                    drvUrl: 'jdbc:db2://[host]:[port]/[database]',
+                    jdbcDriverClass: 'com.ibm.db2.jcc.DB2Driver',
+                    jdbcUrl: 'jdbc:db2://[host]:[port]/[database]',
                     user: 'db2admin'
                 },
-                mssql: {
+                {
                     db: 'mssql',
-                    drvClass: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
-                    drvUrl: 'jdbc:sqlserver://[host]:[port][;databaseName=database]',
+                    jdbcDriverClass: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
+                    jdbcUrl: 'jdbc:sqlserver://[host]:[port][;databaseName=database]',
                     user: 'sa'
                 },
-                postgre: {
+                {
                     db: 'postgre',
-                    drvClass: 'org.postgresql.Driver', drvUrl: 'jdbc:postgresql://[host]:[port]/[database]',
+                    jdbcDriverClass: 'org.postgresql.Driver',
+                    jdbcUrl: 'jdbc:postgresql://[host]:[port]/[database]',
                     user: 'sa'
                 },
-                mysql: {
+                {
                     db: 'mysql',
-                    drvClass: 'com.mysql.jdbc.Driver',
-                    drvUrl: 'jdbc:mysql://[host]:[port]/[database]', user: 'root'
+                    jdbcDriverClass: 'com.mysql.jdbc.Driver',
+                    jdbcUrl: 'jdbc:mysql://[host]:[port]/[database]',
+                    user: 'root'
                 },
-                h2: {
-                    db: 'h2,',
-                    drvClass: 'org.h2.Driver',
-                    drvUrl: 'jdbc:h2:[database]',
+                {
+                    db: 'h2',
+                    jdbcDriverClass: 'org.h2.Driver',
+                    jdbcUrl: 'jdbc:h2:tcp://[host]/[database]',
                     user: 'sa'
                 }
+            ];
+
+            $scope.preset = {
+                db: 'unknown',
+                jdbcDriverClass: '',
+                jdbcDriverJar: '',
+                jdbcUrl: 'jdbc:[database]',
+                user: 'sa'
             };
 
-            $scope.preset = presets['oracle'];
+            var jdbcDrivers = [];
 
-            $scope.$watch('preset.db', function (newDb) {
-                if (newDb) {
-                    var newPreset = presets[newDb];
-                    var curPreset = $scope.preset;
+            function _findPreset(jdbcDriverJar) {
+                var idx = _.findIndex(jdbcDrivers, function (jdbcDriver) {
+                   return  jdbcDriver.jdbcDriverJar == jdbcDriverJar;
+                });
 
-                    curPreset.drvClass = newPreset.drvClass;
-                    curPreset.drvUrl = newPreset.drvUrl;
-                    curPreset.user = newPreset.user;
+                if (idx >= 0) {
+                    var jdbcDriverClass = jdbcDrivers[idx].jdbcDriverClass;
+
+                    idx = _.findIndex(presets, function (preset) {
+                        return preset.jdbcDriverClass == jdbcDriverClass;
+                    });
+
+                    if (idx >= 0)
+                        return presets[idx];
+                }
+
+                return {
+                    db: 'unknown',
+                    jdbcDriverClass: '',
+                    jdbcDriverJar: '',
+                    jdbcUrl: 'jdbc:[database]',
+                    user: 'sa'
+                }
+            }
+
+            $scope.$watch('preset.jdbcDriverJar', function (jdbcDriverJar) {
+                if (jdbcDriverJar) {
+                    var newPreset = _findPreset(jdbcDriverJar);
+
+                    $scope.preset.db = newPreset.db;
+                    $scope.preset.jdbcDriverClass = newPreset.jdbcDriverClass;
+                    $scope.preset.jdbcUrl = newPreset.jdbcUrl;
+                    $scope.preset.user = newPreset.user;
                 }
             }, true);
 
@@ -160,7 +186,6 @@ controlCenterModule.controller('metadataController', [
                 $scope.loadMeta.allSelected = _.every($scope.loadMeta.tables, 'use', true);
             };
 
-
             // Pre-fetch modal dialogs.
             var loadMetaModal = $modal({scope: $scope, templateUrl: 'metadata/metadata-load',
show: false});
 
@@ -169,11 +194,13 @@ controlCenterModule.controller('metadataController', [
                 $http.post('/agent/drivers')
                     .success(function (drivers) {
                         if (drivers && drivers.length > 0) {
-                            $scope.drivers = _.map(drivers, function (driver) {
-                                return {value: driver, label: driver};
+                            $scope.jdbcDriverJars = _.map(drivers, function (driver) {
+                                return {value: driver.jdbcDriverJar, label: driver.jdbcDriverJar};
                             });
 
-                            $scope.preset.drvJar = drivers[0];
+                            jdbcDrivers = drivers;
+
+                            $scope.preset.jdbcDriverJar = drivers[0].jdbcDriverJar;
 
                             loadMetaModal.$promise.then(function () {
                                 $scope.loadMeta.action = 'connect';
@@ -181,7 +208,7 @@ controlCenterModule.controller('metadataController', [
 
                                 loadMetaModal.show();
 
-                                $focus('db');
+                                $focus('jdbcUrl');
                             });
                         }
                         else
@@ -201,7 +228,7 @@ controlCenterModule.controller('metadataController', [
             };
 
             $scope.loadMetadataFromDb = function () {
-                $http.post('/agent/metadata')
+                $http.post('/agent/metadata', $scope.preset)
                     .success(function (tables) {
                         $scope.loadMeta.tables = _.map(tables, function (tbl) {
                             return {schemaName: tbl.schema, tableName: tbl.tbl};
@@ -231,7 +258,7 @@ controlCenterModule.controller('metadataController', [
             $scope.saveSelectedMetadata = function (preset) {
                 loadMetaModal.hide();
 
-                $common.showError("Saving selected metadatanot ready yet!");
+                $common.showError("Saving selected metadata not ready yet!");
             };
 
             // When landing on the page, get metadatas and show them.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d6d4043/modules/control-center-web/src/main/js/controllers/models/metadata.json
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/models/metadata.json b/modules/control-center-web/src/main/js/controllers/models/metadata.json
index 4e8bed2..aeec92b 100644
--- a/modules/control-center-web/src/main/js/controllers/models/metadata.json
+++ b/modules/control-center-web/src/main/js/controllers/models/metadata.json
@@ -192,19 +192,10 @@
   ],
   "metadataDb": [
     {
-      "label": "Database preset",
-      "type": "select",
-      "model": "db",
-      "items": "databases",
-      "tip": [
-        "Select database type to connect for loading tables metadata."
-      ]
-    },
-    {
       "label": "Driver JAR",
       "type": "select",
-      "model": "drvJar",
-      "items": "drivers",
+      "model": "jdbcDriverJar",
+      "items": "jdbcDriverJars",
       "tip": [
         "Select appropriate JAR with JDBC driver."
       ]
@@ -212,7 +203,7 @@
     {
       "label": "JDBC Driver",
       "type": "text",
-      "model": "drvClass",
+      "model": "jdbcDriverClass",
       "placeholder": "Full class name of JDBC driver",
       "tip": [
         "Full class name of JDBC driver that will be used to connect to database."
@@ -221,7 +212,8 @@
     {
       "label": "JDBC URL",
       "type": "text",
-      "model": "drvUrl",
+      "model": "jdbcUrl",
+      "id": "jdbcUrl",
       "placeholder": "JDBC URL",
       "tip": [
         "JDBC URL for connecting to database.",

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d6d4043/modules/control-center-web/src/main/js/package.json
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/package.json b/modules/control-center-web/src/main/js/package.json
index b230a36..1a1fcd7 100644
--- a/modules/control-center-web/src/main/js/package.json
+++ b/modules/control-center-web/src/main/js/package.json
@@ -46,6 +46,6 @@
     "morgan": "~1.6.1",
     "supertest": "^1.0.1",
     "mocha": "~2.2.5",
-    "should": "~7.0.3"
+    "should": "~7.0.4"
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d6d4043/modules/control-center-web/src/main/js/routes/agent.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/agent.js b/modules/control-center-web/src/main/js/routes/agent.js
index 6019ba1..1b0e8bb 100644
--- a/modules/control-center-web/src/main/js/routes/agent.js
+++ b/modules/control-center-web/src/main/js/routes/agent.js
@@ -109,7 +109,9 @@ router.post('/metadata', function (req, res) {
     var client = _client(req, res);
 
     if (client) {
-        client.extractMetadata('h2-1.4.188.jar', 'org.h2.Driver', 'jdbc:h2:tcp://localhost/c:/temp/agent',
{user: 'sa'}, true, function (err, meta) {
+        var params = req.body;
+
+        client.extractMetadata(params.jdbcDriverJar, params.jdbcDriverClass, params.jdbcUrl,
{user: params.user}, true, function (err, meta) {
             if (err)
                 return res.status(500).send(err);
 


Mime
View raw message