ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject ignite git commit: IGNITE-843 WIP link caches and metadata.
Date Tue, 08 Sep 2015 17:39:25 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843 9f96779f5 -> 211b86527


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/211b8652
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/211b8652
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/211b8652

Branch: refs/heads/ignite-843
Commit: 211b865277f8a1806389a35b2c26e34588ed7dcd
Parents: 9f96779
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Wed Sep 9 00:39:17 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Wed Sep 9 00:39:17 2015 +0700

----------------------------------------------------------------------
 .../main/js/controllers/caches-controller.js    | 52 +++++---------------
 .../main/js/controllers/metadata-controller.js  | 17 +------
 .../src/main/js/controllers/models/caches.json  | 40 ++++++---------
 .../main/js/controllers/models/metadata.json    | 15 ++++++
 modules/control-center-web/src/main/js/db.js    | 12 ++---
 .../src/main/js/routes/caches.js                | 38 +++++++-------
 .../src/main/js/routes/clusters.js              |  2 +-
 .../main/js/routes/generator/generator-java.js  | 30 +++--------
 .../main/js/routes/generator/generator-xml.js   | 31 +++---------
 .../src/main/js/routes/metadata.js              | 51 ++++++++++++++++---
 .../src/main/js/routes/summary.js               |  2 +-
 11 files changed, 127 insertions(+), 163 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/211b8652/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 c6e12dc..4d5fb1c 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
@@ -122,8 +122,7 @@ controlCenterModule.controller('cachesController', [
                 });
 
             $scope.caches = [];
-            $scope.queryMetadata = [];
-            $scope.storeMetadata = [];
+            $scope.metadatas = [];
 
             $scope.preview = {
                 general: {xml: '', java: '', allDefaults: true},
@@ -228,16 +227,8 @@ controlCenterModule.controller('cachesController', [
             // Fill cache previews.
             function generatePreview(val) {
                 if ($common.isDefined(val)) {
-                    var qryMeta = _.reduce($scope.queryMetadata, function(memo, meta){
-                        if (_.contains(val.queryMetadata, meta.value)) {
-                            memo.push(meta.meta);
-                        }
-
-                        return memo;
-                    }, []);
-
-                    var storeMeta = _.reduce($scope.storeMetadata, function(memo, meta){
-                        if (_.contains(val.storeMetadata, meta.value)) {
+                    var metadatas = _.reduce($scope.metadatas, function(memo, meta){
+                        if (_.contains(val.metadatas, meta.value)) {
                             memo.push(meta.meta);
                         }
 
@@ -246,20 +237,20 @@ controlCenterModule.controller('cachesController', [
 
                     var varName = 'cache';
 
-                    $scope.preview.general.xml = $generatorXml.cacheGeneral(val).join('');
-                    $scope.preview.general.java = $generatorJava.cacheGeneral(val, varName).join('');
+                    $scope.preview.general.xml = $generatorXml.cacheMetadatas(metadatas,
$generatorXml.cacheGeneral(val)).join('');
+                    $scope.preview.general.java = $generatorJava.cacheMetadatas(metadatas,
varName, $generatorJava.cacheGeneral(val, varName)).join('');
                     $scope.preview.general.allDefaults = $common.isEmptyString($scope.preview.general.xml);
 
                     $scope.preview.memory.xml = $generatorXml.cacheMemory(val).join('');
                     $scope.preview.memory.java = $generatorJava.cacheMemory(val, varName).join('');
                     $scope.preview.memory.allDefaults = $common.isEmptyString($scope.preview.memory.xml);
 
-                    $scope.preview.query.xml = $generatorXml.cacheMetadatas(qryMeta, null,
$generatorXml.cacheQuery(val)).join('');
-                    $scope.preview.query.java = $generatorJava.cacheMetadatas(qryMeta, null,
varName, $generatorJava.cacheQuery(val, varName)).join('');
+                    $scope.preview.query.xml = $generatorXml.cacheQuery(val).join('');
+                    $scope.preview.query.java = $generatorJava.cacheQuery(val, varName).join('');
                     $scope.preview.query.allDefaults = $common.isEmptyString($scope.preview.query.xml);
 
-                    $scope.preview.store.xml = $generatorXml.cacheMetadatas(null, storeMeta,
$generatorXml.cacheStore(val)).join('');
-                    $scope.preview.store.java = $generatorJava.cacheMetadatas(null, storeMeta,
varName, $generatorJava.cacheStore(val, varName)).join('');
+                    $scope.preview.store.xml = $generatorXml.cacheStore(val).join('');
+                    $scope.preview.store.java = $generatorJava.cacheStore(val, varName).join('');
                     $scope.preview.store.allDefaults = $common.isEmptyString($scope.preview.store.xml);
 
                     $scope.preview.concurrency.xml = $generatorXml.cacheConcurrency(val).join('');
@@ -287,31 +278,15 @@ controlCenterModule.controller('cachesController', [
                     $scope.caches = data.caches;
                     $scope.clusters = data.clusters;
 
-                    var metadatas = _.map(data.metadatas, function (meta) {
+                    $scope.metadatas = _.map(data.metadatas, function (meta) {
                         return {value: meta._id, label: meta.name, kind: meta.kind, meta:
meta}
                     });
 
-                    _.forEach(metadatas, function (meta) {
-                        var kind = meta.kind;
-
-                        if (kind == 'query' || kind == 'both')
-                            $scope.queryMetadata.push(meta);
-
-                        if (kind == 'store' || kind == 'both')
-                            $scope.storeMetadata.push(meta);
-                    });
-
                     var restoredItem = angular.fromJson(sessionStorage.cacheBackupItem);
 
                     if (restoredItem) {
-                        restoredItem.queryMetadata = _.filter(restoredItem.queryMetadata,
function (metaId) {
-                            return _.findIndex(metadatas, function (scopeMeta) {
-                                    return scopeMeta.value == metaId;
-                                }) >= 0;
-                        });
-
-                        restoredItem.storeMetadata = _.filter(restoredItem.storeMetadata,
function (metaId) {
-                            return _.findIndex(metadatas, function (scopeMeta) {
+                        restoredItem.metadatas = _.filter(restoredItem.metadatas, function
(metaId) {
+                            return _.findIndex($scope.metadatas, function (scopeMeta) {
                                     return scopeMeta.value == metaId;
                                 }) >= 0;
                         });
@@ -419,8 +394,7 @@ controlCenterModule.controller('cachesController', [
                     readFromBackup: true,
                     copyOnRead: true,
                     clusters: [],
-                    queryMetadata: [],
-                    spaceMetadata: []
+                    metadatas: []
                 };
 
                 $scope.selectItem(undefined, newItem);

http://git-wip-us.apache.org/repos/asf/ignite/blob/211b8652/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 7622571..2620f81 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
@@ -577,6 +577,7 @@ controlCenterModule.controller('metadataController', [
             $http.post('metadata/list')
                 .success(function (data) {
                     $scope.spaces = data.spaces;
+                    $scope.caches = data.caches;
                     $scope.metadatas = data.metadatas;
 
                     var restoredItem = angular.fromJson(sessionStorage.metadataBackupItem);
@@ -588,20 +589,6 @@ controlCenterModule.controller('metadataController', [
                             });
 
                             if (idx >= 0) {
-                                // Remove deleted metadata.
-                                restoredItem.queryMetadata = _.filter(restoredItem.queryMetadata,
function (metaId) {
-                                    return _.findIndex($scope.metadatas, function (scopeMeta)
{
-                                            return scopeMeta.value == metaId;
-                                        }) >= 0;
-                                });
-
-                                // Remove deleted metadata.
-                                restoredItem.storeMetadata = _.filter(restoredItem.storeMetadata,
function (metaId) {
-                                    return _.findIndex($scope.metadatas, function (scopeMeta)
{
-                                            return scopeMeta.value == metaId;
-                                        }) >= 0;
-                                });
-
                                 setSelectedAndBackupItem($scope.metadatas[idx], restoredItem,
sessionStorage.metadataBackupItemChanged);
                             }
                             else {
@@ -663,7 +650,7 @@ controlCenterModule.controller('metadataController', [
                     $common.ensureActivePanel($scope.panels, 'metadata', 'metadataName');
                 });
 
-                setSelectedAndBackupItem(undefined, {space: $scope.spaces[0]._id});
+                setSelectedAndBackupItem(undefined, {space: $scope.spaces[0]._id, caches:
[]});
             };
 
             function queryConfigured(item) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/211b8652/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 e8a62ce..6c1037f 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
@@ -46,6 +46,21 @@
           }
         },
         {
+          "label": "Metadata",
+          "id": "metadata",
+          "type": "dropdown-multiple",
+          "model": "metadatas",
+          "placeholder": "Choose metadata",
+          "items": "metadatas",
+          "tip": [
+            "Select cache type metadata to describe types in cache."
+          ],
+          "addLink": {
+            "label": "Add metadata(s)",
+            "ref": "/configuration/metadata"
+          }
+        },
+        {
           "label": "Mode",
           "id": "cacheMode",
           "type": "dropdown",
@@ -353,21 +368,6 @@
           ]
         },
         {
-          "label": "Metadata",
-          "id": "queryMetadata",
-          "type": "dropdown-multiple",
-          "model": "queryMetadata",
-          "placeholder": "Choose metadata",
-          "items": "queryMetadata",
-          "tip": [
-            "Select cache type metadata to describe types in cache."
-          ],
-          "addLink": {
-            "label": "Add metadata(s)",
-            "ref": "/configuration/metadata"
-          }
-        },
-        {
           "ui": "table-pair",
           "id": "indexedTypes",
           "type": "indexedTypes",
@@ -463,16 +463,6 @@
                     "  <li>H2 database.</li>",
                     "</ul>"
                   ]
-                },
-                {
-                  "label": "Metadata",
-                  "type": "dropdown-multiple",
-                  "model": "storeMetadata",
-                  "placeholder": "Choose metadata",
-                  "items": "storeMetadata",
-                  "tip": [
-                    "Select cache type metadata to associate database with cache."
-                  ]
                 }
               ]
             },

http://git-wip-us.apache.org/repos/asf/ignite/blob/211b8652/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 45da452..b80b2ee 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
@@ -33,6 +33,21 @@
           "placeholder": "Input name"
         },
         {
+          "label": "Caches",
+          "id": "caches",
+          "type": "dropdown-multiple",
+          "model": "caches",
+          "placeholder": "Choose caches",
+          "items": "caches",
+          "tip": [
+            "Select caches to associate database with cache."
+          ],
+          "addLink": {
+            "label": "Add cache(s)",
+            "ref": "/configuration/caches"
+          }
+        },
+        {
           "label": "Key type",
           "id": "keyType",
           "type": "withJavaBuildInTypes",

http://git-wip-us.apache.org/repos/asf/ignite/blob/211b8652/modules/control-center-web/src/main/js/db.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/db.js b/modules/control-center-web/src/main/js/db.js
index 817bfdb..02a9250 100644
--- a/modules/control-center-web/src/main/js/db.js
+++ b/modules/control-center-web/src/main/js/db.js
@@ -73,6 +73,7 @@ exports.Space = mongoose.model('Space', new Schema({
 var CacheTypeMetadataSchema = new Schema({
     space: {type: ObjectId, ref: 'Space'},
     name: String,
+    caches: [{type: ObjectId, ref: 'Cache'}],
     kind: {type: String, enum: ['query', 'store', 'both']},
     databaseSchema: String,
     databaseTable: String,
@@ -95,6 +96,7 @@ var CacheSchema = new Schema({
     space: {type: ObjectId, ref: 'Space'},
     name: String,
     clusters: [{type: ObjectId, ref: 'Cluster'}],
+    metadatas: [{type: ObjectId, ref: 'CacheTypeMetadata'}],
     cacheMode: {type: String, enum: ['PARTITIONED', 'REPLICATED', 'LOCAL']},
     atomicityMode: {type: String, enum: ['ATOMIC', 'TRANSACTIONAL']},
 
@@ -134,7 +136,6 @@ var CacheSchema = new Schema({
     rebalanceTimeout: Number,
     rebalanceThrottle: Number,
 
-    storeMetadata: [{type: ObjectId, ref: 'CacheTypeMetadata'}],
     cacheStoreFactory: {
         kind: {
             type: String,
@@ -177,7 +178,6 @@ var CacheSchema = new Schema({
     sqlEscapeAll: Boolean,
     sqlOnheapRowCacheSize: Number,
     longQueryWarningTimeout: Number,
-    queryMetadata: [{type: ObjectId, ref: 'CacheTypeMetadata'}],
     indexedTypes: [{keyClass: String, valueClass: String}],
     sqlFunctionClasses: [String],
     statisticsEnabled: Boolean,
@@ -214,10 +214,7 @@ var CacheSchema = new Schema({
 
 // Install deep populate plugin.
 CacheSchema.plugin(deepPopulate, {
-    whitelist: [
-        'queryMetadata',
-        'storeMetadata'
-    ]
+    whitelist: ['metadatas']
 });
 
 // Define Cache model.
@@ -336,8 +333,7 @@ var ClusterSchema = new Schema({
 ClusterSchema.plugin(deepPopulate, {
     whitelist: [
         'caches',
-        'caches.queryMetadata',
-        'caches.storeMetadata'
+        'caches.metadatas'
     ]
 });
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/211b8652/modules/control-center-web/src/main/js/routes/caches.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/caches.js b/modules/control-center-web/src/main/js/routes/caches.js
index a9a0402..e9f7a44 100644
--- a/modules/control-center-web/src/main/js/routes/caches.js
+++ b/modules/control-center-web/src/main/js/routes/caches.js
@@ -59,14 +59,7 @@ router.post('/list', function (req, res) {
                                         });
 
                                         // Remove deleted metadata.
-                                        cache.queryMetadata = _.filter(cache.queryMetadata,
function (metaId) {
-                                            return _.findIndex(metadatas, function (meta)
{
-                                                    return meta._id.equals(metaId);
-                                                }) >= 0;
-                                        });
-
-                                        // Remove deleted metadata.
-                                        cache.storeMetadata = _.filter(cache.storeMetadata,
function (metaId) {
+                                        cache.metadatas = _.filter(cache.metadatas, function
(metaId) {
                                             return _.findIndex(metadatas, function (meta)
{
                                                     return meta._id.equals(metaId);
                                                 }) >= 0;
@@ -75,11 +68,12 @@ router.post('/list', function (req, res) {
 
                                     res.json({
                                         spaces: spaces,
-                                        clusters: clusters.map(function(cluster) {
+                                        clusters: clusters.map(function (cluster) {
                                             return {value: cluster._id, label: cluster.name};
                                         }),
                                         metadatas: metadatas,
-                                        caches: caches});
+                                        caches: caches
+                                    });
                                 }
                             });
                         }
@@ -97,18 +91,25 @@ router.post('/save', function (req, res) {
     var params = req.body;
     var cacheId = params._id;
     var clusters = params.clusters;
+    var metadatas = params.metadatas;
 
-    if (params._id){
+    if (params._id) {
         db.Cache.update({_id: cacheId}, params, {upsert: true}, function (err) {
             if (db.processed(err, res))
-                db.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}},
{multi: true}, function(err) {
+                db.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}},
{multi: true}, function (err) {
                     if (db.processed(err, res))
-                        db.Cluster.update({_id: {$nin: clusters}}, {$pull: {caches: cacheId}},
{multi: true}, function(err) {
+                        db.Cluster.update({_id: {$nin: clusters}}, {$pull: {caches: cacheId}},
{multi: true}, function (err) {
                             if (db.processed(err, res))
-                                res.send(params._id);
+                                db.CacheTypeMetadata.update({_id: {$in: metadatas}}, {$addToSet:
{caches: cacheId}}, {multi: true}, function (err) {
+                                    if (db.processed(err, res))
+                                        db.CacheTypeMetadata.update({_id: {$nin: metadatas}},
{$pull: {caches: cacheId}}, {multi: true}, function (err) {
+                                            if (db.processed(err, res))
+                                                res.send(params._id);
+                                        });
+                                });
                         });
                 });
-        });
+        })
     }
     else
         db.Cache.findOne({space: params.space, name: params.name}, function (err, cache)
{
@@ -120,9 +121,12 @@ router.post('/save', function (req, res) {
                     if (db.processed(err, res)) {
                         cacheId = cache._id;
 
-                        db.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}},
{multi: true}, function(err) {
+                        db.Cluster.update({_id: {$in: clusters}}, {$addToSet: {caches: cacheId}},
{multi: true}, function (err) {
                             if (db.processed(err, res))
-                                res.send(cacheId);
+                                db.CacheTypeMetadata.update({_id: {$in: metadatas}}, {$addToSet:
{caches: cacheId}}, {multi: true}, function (err) {
+                                    if (db.processed(err, res))
+                                        res.send(cacheId);
+                                });
                         });
                     }
                 });

http://git-wip-us.apache.org/repos/asf/ignite/blob/211b8652/modules/control-center-web/src/main/js/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/clusters.js b/modules/control-center-web/src/main/js/routes/clusters.js
index 21caee7..6d2208c 100644
--- a/modules/control-center-web/src/main/js/routes/clusters.js
+++ b/modules/control-center-web/src/main/js/routes/clusters.js
@@ -41,7 +41,7 @@ router.post('/list', function (req, res) {
             });
 
             // Get all caches for spaces.
-            db.Cache.find({space: {$in: space_ids}}).sort('name').deepPopulate('queryMetadata
storeMetadata').exec(function (err, caches) {
+            db.Cache.find({space: {$in: space_ids}}).sort('name').deepPopulate('metadatas').exec(function
(err, caches) {
                 if (db.processed(err, res)) {
                     // Get all clusters for spaces.
                     db.Cluster.find({space: {$in: space_ids}}).sort('name').exec(function
(err, clusters) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/211b8652/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 4f4aeab..4b48805 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
@@ -989,35 +989,17 @@ $generatorJava.cacheMetadata = function(meta, res) {
 };
 
 // Generate cache type metadata configs.
-$generatorJava.cacheMetadatas = function (qryMeta, storeMeta, varName, res) {
+$generatorJava.cacheMetadatas = function (metadatas, varName, res) {
     if (!res)
         res = $generatorCommon.builder();
 
     // Generate cache type metadata configs.
-    if ((qryMeta && qryMeta.length > 0) || (storeMeta && storeMeta.length
> 0)) {
+    if (metadatas && metadatas.length > 0) {
         $generatorJava.declareVariable(res, $generatorJava.needNewVariable(res, 'types'),
'types', 'java.util.Collection', 'java.util.ArrayList', 'org.apache.ignite.cache.CacheTypeMetadata');
 
-        var metaNames = [];
-
-        if (qryMeta && qryMeta.length > 0) {
-            _.forEach(qryMeta, function (meta) {
-                if (!_.contains(metaNames, meta.name)) {
-                    metaNames.push(meta.name);
-
-                    $generatorJava.cacheMetadata(meta, res);
-                }
-            });
-        }
-
-        if (storeMeta && storeMeta.length > 0) {
-            _.forEach(storeMeta, function (meta) {
-                if (!_.contains(metaNames, meta.name)) {
-                    metaNames.push(meta.name);
-
-                    $generatorJava.cacheMetadata(meta, res);
-                }
-            });
-        }
+        _.forEach(metadatas, function (meta) {
+            $generatorJava.cacheMetadata(meta, res);
+        });
 
         res.line(varName + '.setTypeMetadata(types);');
 
@@ -1048,7 +1030,7 @@ $generatorJava.cache = function(cache, varName, res) {
 
     $generatorJava.cacheStatistics(cache, varName, res);
 
-    $generatorJava.cacheMetadatas(cache.queryMetadata, cache.storeMetadata, varName, res);
+    $generatorJava.cacheMetadatas(cache.metadatas, varName, res);
 };
 
 // Generate cluster caches.

http://git-wip-us.apache.org/repos/asf/ignite/blob/211b8652/modules/control-center-web/src/main/js/routes/generator/generator-xml.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/generator/generator-xml.js b/modules/control-center-web/src/main/js/routes/generator/generator-xml.js
index f5d6971..183369d 100644
--- a/modules/control-center-web/src/main/js/routes/generator/generator-xml.js
+++ b/modules/control-center-web/src/main/js/routes/generator/generator-xml.js
@@ -872,38 +872,19 @@ $generatorXml.cacheMetadata = function(meta, res) {
 };
 
 // Generate cache type metadata configs.
-$generatorXml.cacheMetadatas = function(qryMeta, storeMeta, res) {
+$generatorXml.cacheMetadatas = function(metadatas, res) {
     if (!res)
         res = $generatorCommon.builder();
 
-    if ((qryMeta && qryMeta.length > 0) ||
-        (storeMeta && storeMeta.length > 0)) {
+    if (metadatas && metadatas.length > 0) {
         res.emptyLineIfNeeded();
 
         res.startBlock('<property name="typeMetadata">');
         res.startBlock('<list>');
 
-        var metaNames = [];
-
-        if (qryMeta && qryMeta.length > 0) {
-            _.forEach(qryMeta, function (meta) {
-                if (!_.contains(metaNames, meta.name)) {
-                    metaNames.push(meta.name);
-
-                    $generatorXml.cacheMetadata(meta, res);
-                }
-            });
-        }
-
-        if (storeMeta && storeMeta.length > 0) {
-            _.forEach(storeMeta, function (meta) {
-                if (!_.contains(metaNames, meta.name)) {
-                    metaNames.push(meta.name);
-
-                    $generatorXml.cacheMetadata(meta, res);
-                }
-            });
-        }
+        _.forEach(metadatas, function (meta) {
+            $generatorXml.cacheMetadata(meta, res);
+        });
 
         res.endBlock('</list>');
         res.endBlock('</property>');
@@ -937,7 +918,7 @@ $generatorXml.cache = function(cache, res) {
 
     $generatorXml.cacheStatistics(cache, res);
 
-    $generatorXml.cacheMetadatas(cache.queryMetadata, cache.storeMetadata, res);
+    $generatorXml.cacheMetadatas(cache.metadatas, res);
 
     res.endBlock('</bean>');
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/211b8652/modules/control-center-web/src/main/js/routes/metadata.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/metadata.js b/modules/control-center-web/src/main/js/routes/metadata.js
index 68b5922..f889b99 100644
--- a/modules/control-center-web/src/main/js/routes/metadata.js
+++ b/modules/control-center-web/src/main/js/routes/metadata.js
@@ -44,10 +44,31 @@ router.post('/list', function (req, res) {
                 return value._id;
             });
 
-            // Get all metadata for spaces.
-            db.CacheTypeMetadata.find({space: {$in: space_ids}}).sort('name').exec(function
(err, metadatas) {
-                if (db.processed(err, res))
-                    res.json({spaces: spaces, metadatas: metadatas});
+            // Get all caches for spaces.
+            db.Cache.find({space: {$in: space_ids}}).sort('name').exec(function (err, caches)
{
+                if (db.processed(err, res)) {
+                    // Get all metadata for spaces.
+                    db.CacheTypeMetadata.find({space: {$in: space_ids}}).sort('name').exec(function
(err, metadatas) {
+                        if (db.processed(err, res)) {
+                            // Remove deleted caches.
+                            _.forEach(metadatas, function (meta) {
+                                meta.caches = _.filter(meta.caches, function (cacheId) {
+                                    return _.findIndex(caches, function (cache) {
+                                            return cache._id.equals(cacheId);
+                                        }) >= 0;
+                                });
+                            });
+
+                            res.json({
+                                spaces: spaces,
+                                caches: caches.map(function (cache) {
+                                    return {value: cache._id, label: cache.name};
+                                }),
+                                metadatas: metadatas
+                            });
+                        }
+                    });
+                }
             });
         }
     });
@@ -57,10 +78,20 @@ router.post('/list', function (req, res) {
  * Save metadata.
  */
 router.post('/save', function (req, res) {
+    var params = req.body;
+    var metaId = params._id;
+    var caches = params.caches;
+
     if (req.body._id)
         db.CacheTypeMetadata.update({_id: req.body._id}, req.body, {upsert: true}, function
(err) {
             if (db.processed(err, res))
-                res.send(req.body._id);
+                db.Cache.update({_id: {$in: caches}}, {$addToSet: {metadatas: metaId}}, {multi:
true}, function (err) {
+                    if (db.processed(err, res))
+                        db.Cache.update({_id: {$nin: caches}}, {$pull: {metadatas: metaId}},
{multi: true}, function (err) {
+                            if (db.processed(err, res))
+                                res.send(params._id);
+                        });
+                });
         });
     else {
         db.CacheTypeMetadata.findOne({space: req.body.space, name: req.body.name}, function
(err, metadata) {
@@ -69,10 +100,14 @@ router.post('/save', function (req, res) {
                     return res.status(500).send('Cache type metadata with name: "' + metadata.name
+ '" already exist.');
 
                 (new db.CacheTypeMetadata(req.body)).save(function (err, metadata) {
-                    if (err)
-                        return res.status(500).send(err.message);
+                    if (db.processed(err, res)) {
+                        metaId = metadata._id;
 
-                    res.send(metadata._id);
+                        db.Cache.update({_id: {$in: caches}}, {$addToSet: {metadatas: metaId}},
{multi: true}, function (err) {
+                            if (db.processed(err, res))
+                                res.send(metaId);
+                        });
+                    }
                 });
             }
         });

http://git-wip-us.apache.org/repos/asf/ignite/blob/211b8652/modules/control-center-web/src/main/js/routes/summary.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/summary.js b/modules/control-center-web/src/main/js/routes/summary.js
index c1b102f..eca0140 100644
--- a/modules/control-center-web/src/main/js/routes/summary.js
+++ b/modules/control-center-web/src/main/js/routes/summary.js
@@ -36,7 +36,7 @@ router.get('/', function (req, res) {
 
 router.post('/download', function (req, res) {
     // Get cluster with all inner objects (caches, metadata).
-    db.Cluster.findById(req.body._id).deepPopulate('caches caches.queryMetadata caches.storeMetadata').exec(function
(err, cluster) {
+    db.Cluster.findById(req.body._id).deepPopulate('caches caches.metadatas').exec(function
(err, cluster) {
         if (err)
             return res.status(500).send(err.message);
 


Mime
View raw message