ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [2/2] ignite git commit: IGNITE-843 WIP link caches and metadata.
Date Wed, 09 Sep 2015 06:01:17 GMT
IGNITE-843 WIP link caches and metadata.


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

Branch: refs/heads/ignite-843
Commit: e083c18c2e0424986b33feff228616bd20d1e9e0
Parents: d856287
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Wed Sep 9 13:01:51 2015 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Wed Sep 9 13:01:51 2015 +0700

----------------------------------------------------------------------
 .../main/js/controllers/caches-controller.js    | 29 ++++++++++++++++++--
 .../src/main/js/controllers/common-module.js    | 15 ++++++++++
 .../main/js/controllers/metadata-controller.js  | 23 +++-------------
 .../src/main/js/controllers/models/caches.json  |  1 +
 .../main/js/routes/generator/generator-java.js  |  2 +-
 5 files changed, 48 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e083c18c/modules/control-center-web/src/main/js/controllers/caches-controller.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/caches-controller.js b/modules/control-center-web/src/main/js/controllers/caches-controller.js
index ccc126b..15bcb5e 100644
--- a/modules/control-center-web/src/main/js/controllers/caches-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/caches-controller.js
@@ -299,10 +299,14 @@ controlCenterModule.controller('cachesController', [
                     else if ($scope.caches.length > 0)
                         $scope.selectItem($scope.caches[0]);
 
+                    function isStoreFactoryDefined(cache) {
+                        return $common.isDefined(cache)
+                            && $common.isDefined(cache.cacheStoreFactory)
+                            && $common.isDefined(cache.cacheStoreFactory.kind);
+                    }
+
                     $scope.$watch('backupItem', function (val) {
                         if (val) {
-                            sessionStorage.cacheBackupItem = angular.toJson(val);
-
                             // Collect cache metadatas.
                             var cacheMetadatas = _.reduce($scope.metadatas, function(memo,
meta){
                                 if (_.contains(val.metadatas, meta.value)) {
@@ -312,6 +316,25 @@ controlCenterModule.controller('cachesController', [
                                 return memo;
                             }, []);
 
+                            var prevVal = angular.fromJson(sessionStorage.cacheBackupItem);
+                            var prevCacheStore = isStoreFactoryDefined(prevVal);
+                            var newCacheStore = isStoreFactoryDefined(val);
+
+                            if (!prevCacheStore && !newCacheStore) {
+                                if (_.findIndex(cacheMetadatas, $common.metadataForStoreConfigured)
>= 0) {
+                                    val.cacheStoreFactory.kind = 'CacheJdbcPojoStoreFactory';
+
+                                    if (!val.readThrough && !val.writeThrough) {
+                                        val.readThrough = true;
+                                        val.writeThrough = true;
+                                    }
+
+                                    $timeout(function () {
+                                        $common.ensureActivePanel($scope.panels, 'store',
'dataSourceBean');
+                                    });
+                                }
+                            }
+
                             var varName = 'cache';
 
                             $scope.preview.general.xml = $generatorXml.cacheMetadatas(cacheMetadatas,
$generatorXml.cacheGeneral(val)).join('');
@@ -346,6 +369,8 @@ controlCenterModule.controller('cachesController', [
                             $scope.preview.statistics.java = $generatorJava.cacheStatistics(val,
varName).join('');
                             $scope.preview.statistics.allDefaults = $common.isEmptyString($scope.preview.statistics.xml);
 
+                            sessionStorage.cacheBackupItem = angular.toJson(val);
+
                             $common.markChanged($scope.ui.inputForm, 'cacheBackupItemChanged');
                         }
                     }, true);

http://git-wip-us.apache.org/repos/asf/ignite/blob/e083c18c/modules/control-center-web/src/main/js/controllers/common-module.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/common-module.js b/modules/control-center-web/src/main/js/controllers/common-module.js
index 3363fb2..c5eb0fc 100644
--- a/modules/control-center-web/src/main/js/controllers/common-module.js
+++ b/modules/control-center-web/src/main/js/controllers/common-module.js
@@ -599,6 +599,21 @@ controlCenterModule.service('$common', [
 
                 return true;
             },
+            metadataForQueryConfigured: function (meta) {
+                return meta
+                    && !(isEmptyArray(meta.queryFields)
+                    && isEmptyArray(meta.ascendingFields)
+                    && isEmptyArray(meta.descendingFields)
+                    && isEmptyArray(meta.textFields)
+                    && isEmptyArray(meta.groups))
+            },
+            metadataForStoreConfigured: function (meta) {
+                return meta
+                    && !(isEmptyString(meta.databaseSchema)
+                    && isEmptyString(meta.databaseTable)
+                    && isEmptyArray(meta.keyFields)
+                    && isEmptyArray(meta.valueFields))
+            },
             /**
              * Cut class name by width in pixel or width in symbol count.
              *

http://git-wip-us.apache.org/repos/asf/ignite/blob/e083c18c/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 e349b09..bcdb873 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
@@ -675,21 +675,6 @@ controlCenterModule.controller('metadataController', [
                 $scope.selectItem(undefined, {space: $scope.spaces[0]._id, caches: []});
             };
 
-            function queryConfigured(item) {
-                return !($common.isEmptyArray(item.queryFields)
-                    && $common.isEmptyArray(item.ascendingFields)
-                    && $common.isEmptyArray(item.descendingFields)
-                    && $common.isEmptyArray(item.textFields)
-                    && $common.isEmptyArray(item.groups))
-            }
-
-            function storeConfigured(item) {
-                return !($common.isEmptyString(item.databaseSchema)
-                    && $common.isEmptyString(item.databaseTable)
-                    && $common.isEmptyArray(item.keyFields)
-                    && $common.isEmptyArray(item.valueFields))
-            }
-
             // Check metadata logical consistency.
             function validate(item) {
                 if ($common.isEmptyString(item.name))
@@ -705,7 +690,7 @@ controlCenterModule.controller('metadataController', [
                 else if (!$common.isValidJavaClass('Value type', item.valueType, false, 'valueType'))
                     return false;
 
-                var qry = queryConfigured(item);
+                var qry = $common.metadataForQueryConfigured(item);
 
                 if (qry) {
                     var groups = item.groups;
@@ -725,7 +710,7 @@ controlCenterModule.controller('metadataController', [
                     }
                 }
 
-                var str = storeConfigured(item);
+                var str = $common.metadataForStoreConfigured(item);
 
                 if (str) {
                     if ($common.isEmptyString(item.databaseSchema))
@@ -749,8 +734,8 @@ controlCenterModule.controller('metadataController', [
 
             // Save cache type metadata into database.
             function save(item, quiet) {
-                var qry = queryConfigured(item);
-                var str = storeConfigured(item);
+                var qry = $common.metadataForQueryConfigured(item);
+                var str = $common.metadataForStoreConfigured(item);
 
                 item.kind = 'query';
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/e083c18c/modules/control-center-web/src/main/js/controllers/models/caches.json
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/models/caches.json b/modules/control-center-web/src/main/js/controllers/models/caches.json
index 6c1037f..e8a8c23 100644
--- a/modules/control-center-web/src/main/js/controllers/models/caches.json
+++ b/modules/control-center-web/src/main/js/controllers/models/caches.json
@@ -434,6 +434,7 @@
               "fields": [
                 {
                   "label": "Data source bean",
+                  "id": "dataSourceBean",
                   "type": "text",
                   "path": "cacheStoreFactory.CacheJdbcPojoStoreFactory",
                   "model": "dataSourceBean",

http://git-wip-us.apache.org/repos/asf/ignite/blob/e083c18c/modules/control-center-web/src/main/js/routes/generator/generator-java.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/generator/generator-java.js b/modules/control-center-web/src/main/js/routes/generator/generator-java.js
index 4b48805..51cd0f6 100644
--- a/modules/control-center-web/src/main/js/routes/generator/generator-java.js
+++ b/modules/control-center-web/src/main/js/routes/generator/generator-java.js
@@ -35,7 +35,7 @@ $generatorJava = {};
  * @returns {string} Valid java name.
  */
 $generatorJava.toJavaName = function (prefix, name) {
-    var javaName = name.replace(/[^A-Za-z_0-9]+/, '_');
+    var javaName = name ? name.replace(/[^A-Za-z_0-9]+/, '_') : 'dflt';
 
     return prefix + javaName.charAt(0).toLocaleUpperCase() + javaName.slice(1);
 };


Mime
View raw message