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 rework import domain model from db.
Date Mon, 18 Jan 2016 17:31:08 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc2 dfbbfdc01 -> 92ded8cf0


IGNITE-843 WIP rework import domain model from db.


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

Branch: refs/heads/ignite-843-rc2
Commit: 92ded8cf0b56bb4df64c847ec9af7fee813e77a9
Parents: dfbbfdc
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Tue Jan 19 00:31:04 2016 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Tue Jan 19 00:31:04 2016 +0700

----------------------------------------------------------------------
 .../main/js/controllers/domains-controller.js   | 69 +++++++++++++-------
 .../src/main/js/routes/domains.js               | 53 ++++++++++++---
 .../js/views/configuration/domains-import.jade  | 29 ++++----
 .../main/js/views/configuration/domains.jade    |  2 +-
 .../src/main/js/views/login.jade                |  8 +--
 5 files changed, 110 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/92ded8cf/modules/control-center-web/src/main/js/controllers/domains-controller.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/domains-controller.js b/modules/control-center-web/src/main/js/controllers/domains-controller.js
index ce49167..ceeb860 100644
--- a/modules/control-center-web/src/main/js/controllers/domains-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/domains-controller.js
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-// Controller for Domain models screen.
+// Controller for Domain model screen.
 consoleModule.controller('domainsController', function ($filter, $http, $timeout, $state,
$scope, $controller, $modal,
      $common,  $focus, $confirm, $confirmBatch, $clone, $table, $preview, $loading, $unsavedChangesGuard,
$agentDownload) {
         $unsavedChangesGuard.install($scope);
@@ -564,6 +564,9 @@ consoleModule.controller('domainsController', function ($filter, $http,
$timeout
         var IMPORT_DM_DFLT_PARTITIONED_CACHE = 'IMPORT_DM_DFLT_PARTITIONED_CACHE';
         var IMPORT_DM_DFLT_REPLICATED_CACHE = 'IMPORT_DM_DFLT_REPLICATED_CACHE';
 
+        $scope.ui.dfltTableCache = IMPORT_DM_NEW_CACHE;
+        $scope.ui.dfltTableTemplate = IMPORT_DM_DFLT_PARTITIONED_CACHE;
+
         /**
          * Load list of database tables.
          */
@@ -627,6 +630,19 @@ consoleModule.controller('domainsController', function ($filter, $http,
$timeout
                 });
         }
 
+        $scope.dfltTableTemplateVisible = function () {
+            return $scope.ui.dfltTableCache === IMPORT_DM_NEW_CACHE;
+        };
+
+        $scope.applyDefaults = function() {
+            _.forEach($scope.importDomain.displayedTables, function (table) {
+                table.editCache = false;
+                table.editTemplate = false;
+                table.cache = $scope.ui.dfltTableCache;
+                table.template = $scope.ui.dfltTableTemplate;
+            });
+        };
+
         $scope.curDbTable = null;
 
         $scope.startEditDbTableCache = function (tbl) {
@@ -756,7 +772,7 @@ consoleModule.controller('domainsController', function ($filter, $http,
$timeout
                 importDomainModal.hide();
         }
 
-        function _saveMetadata() {
+        function _saveDomainModel() {
             if ($common.isEmptyString($scope.ui.packageName))
                 return $common.showPopoverMessage(undefined, undefined, 'domainPackageName',
                     'Package should be not empty');
@@ -836,51 +852,56 @@ consoleModule.controller('domainsController', function ($filter, $http,
$timeout
                         });
                     }
 
-                    var metaFound = _.find($scope.metadatas, function (meta) {
+                    var domainFound = _.find($scope.metadatas, function (meta) {
                         return meta.valueType === valType;
                     });
 
-                    var meta = {
+                    var newDomain = {
                         confirm: false,
                         skip: false,
                         space: $scope.spaces[0],
                         caches: []
                     };
 
-                    if ($common.isDefined(metaFound)) {
-                        meta._id = metaFound._id;
-                        meta.caches = metaFound.caches;
-                        meta.confirm = true;
+                    if ($common.isDefined(domainFound)) {
+                        newDomain._id = domainFound._id;
+                        newDomain.caches = domainFound.caches;
+                        newDomain.confirm = true;
                     }
 
                     var dupSfx = (dup ? '_' + dupCnt : '');
 
-                    meta.keyType = valType + 'Key' + dupSfx;
+                    newDomain.keyType = valType + 'Key' + dupSfx;
 
-                    meta.keyType = valType + 'Key' + dupSfx;
-                    meta.valueType = valType + dupSfx;
-                    meta.databaseSchema = table.schema;
-                    meta.databaseTable = tableName;
-                    meta.fields = qryFields;
-                    meta.indexes = indexes;
-                    meta.keyFields = keyFields;
-                    meta.valueFields = valFields;
-                    meta.demo = $scope.importDomain.demo;
+                    newDomain.keyType = valType + 'Key' + dupSfx;
+                    newDomain.valueType = valType + dupSfx;
+                    newDomain.databaseSchema = table.schema;
+                    newDomain.databaseTable = tableName;
+                    newDomain.fields = qryFields;
+                    newDomain.indexes = indexes;
+                    newDomain.keyFields = keyFields;
+                    newDomain.valueFields = valFields;
+                    newDomain.demo = $scope.importDomain.demo;
 
                     // Use Java built-in type for key.
-                    if ($scope.ui.builtinKeys && meta.keyFields.length === 1)
-                        meta.keyType = meta.keyFields[0].jdbcType.javaType;
+                    if ($scope.ui.builtinKeys && newDomain.keyFields.length === 1)
+                        newDomain.keyType = newDomain.keyFields[0].jdbcType.javaType;
 
                     // Prepare caches for generation.
-                    if ($scope.ui.generateCaches)
-                        meta.newCache = {
+                    if ($scope.ui.generateCaches && table.cache !== IMPORT_DM_DO_NOT_GENERATE)
{
+                        newDomain.newCache = {
                             name: typeName + 'Cache',
+                            cache: table.cache,
                             dialect: $scope.importDomain.demo ? 'H2' : $scope.selectedPreset.db,
                             clusters: $scope.ui.generatedCachesClusters,
                             demo: $scope.importDomain.demo
                         };
 
-                    batch.push(meta);
+                        if (table.cache === IMPORT_DM_NEW_CACHE)
+                            newDomain.newCache.template = table.template;
+                    }
+
+                    batch.push(newDomain);
                     tables.push(tableName);
                 }
             });
@@ -937,7 +958,7 @@ consoleModule.controller('domainsController', function ($filter, $http,
$timeout
             else if ($scope.importDomain.action === 'tables')
                 _selectOptions();
             else if ($scope.importDomain.action === 'options')
-                _saveMetadata();
+                _saveDomainModel();
         };
 
         $scope.nextTooltipText = function () {

http://git-wip-us.apache.org/repos/asf/ignite/blob/92ded8cf/modules/control-center-web/src/main/js/routes/domains.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/domains.js b/modules/control-center-web/src/main/js/routes/domains.js
index 2f99be0..5c78ac0 100644
--- a/modules/control-center-web/src/main/js/routes/domains.js
+++ b/modules/control-center-web/src/main/js/routes/domains.js
@@ -126,6 +126,24 @@ function _saveMeta(meta, savedMetas, callback) {
         });
 }
 
+function _saveCacheAndMeta(res, generatedCaches, savedMetas, newCache, callback) {
+    // If cache not found, then create it and associate with domain model.
+    (new db.Cache(newCache)).save(function (err, cache) {
+        var cacheId = cache._id;
+
+        if (db.processed(err, res)) {
+            db.Cluster.update({_id: {$in: cache.clusters}}, {$addToSet: {caches: cacheId}},
{multi: true}, function (err) {
+                if (db.processed(err, res)) {
+                    meta.caches = [cacheId];
+                    generatedCaches.push({ value: cacheId, label: cache.name });
+
+                    _saveMeta(meta, savedMetas, callback);
+                }
+            });
+        }
+    });
+}
+
 function _save(metas, res) {
     var savedMetas = [];
     var generatedCaches = [];
@@ -142,8 +160,7 @@ function _save(metas, res) {
                             _saveMeta(meta, savedMetas, callback);
                         }
                         else {
-                            // If cache not found, then create it and associate with domain
model.
-                            (new db.Cache({
+                            var newCache = {
                                 space: meta.space,
                                 name: meta.newCache.name,
                                 clusters: meta.newCache.clusters,
@@ -159,20 +176,36 @@ function _save(metas, res) {
                                 readThrough: true,
                                 writeThrough: true,
                                 demo: meta.demo
-                            })).save(function (err, cache) {
-                                var cacheId = cache._id;
+                            };
 
-                                if (db.processed(err, res)) {
-                                    db.Cluster.update({_id: {$in: cache.clusters}}, {$addToSet:
{caches: cacheId}}, {multi: true}, function (err) {
+                            if (meta.cache === 'IMPORT_DM_NEW_CACHE') {
+                                if (meta.template === 'IMPORT_DM_DFLT_REPLICATED_CACHE')
+                                    newCache.cacheMode = 'REPLICATED';
+                                else {
+                                    db.Cache.findOne({_id: meta.template}, function (err,
cacheTemplate) {
                                         if (db.processed(err, res)) {
-                                            meta.caches = [cacheId];
-                                            generatedCaches.push({ value: cacheId, label:
cache.name });
+                                            if (cacheTemplate) {
+                                                newCache.cacheMode = cacheTemplate.cacheMode;
+                                                newCache.atomicityMode = cacheTemplate.atomicityMode;
 
-                                            _saveMeta(meta, savedMetas, callback);
+                                                if (cacheTemplate.cacheStoreFactory &&
cacheTemplate.cacheStoreFactory.kind === 'CacheJdbcPojoStoreFactory') {
+                                                    newCache.cacheStoreFactory.dataSourceBean
= cacheTemplate.cacheStoreFactory.dataSourceBean;
+                                                    newCache.cacheStoreFactory.dialect =
cacheTemplate.cacheStoreFactory.dialect;
+                                                    newCache.readThrough = cacheTemplate.readThrough;
+                                                    newCache.writeThrough = cacheTemplate.writeThrough
+                                                }
+                                            }
+
+                                            _saveCacheAndMeta(res, generatedCaches, savedMetas,
newCache, callback);
                                         }
                                     });
                                 }
-                            });
+                            }
+                            else {
+                                if (meta.template !== 'IMPORT_DM_DO_NOT_GENERATE')
+
+                                _saveMeta(res, generatedCaches, savedMetas, newCache, callback);
+                            }
                         }
                 });
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/92ded8cf/modules/control-center-web/src/main/js/views/configuration/domains-import.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/configuration/domains-import.jade
b/modules/control-center-web/src/main/js/views/configuration/domains-import.jade
index e8f4ea0..2a80fe7 100644
--- a/modules/control-center-web/src/main/js/views/configuration/domains-import.jade
+++ b/modules/control-center-web/src/main/js/views/configuration/domains-import.jade
@@ -31,7 +31,7 @@ mixin td-ellipses-lbl(w, lbl)
                 h4.modal-title(ng-if='!importDomain.demo') Import domain models from database
                 h4.modal-title(ng-if='importDomain.demo') Import domain models from demo
database
             .import-domain-model-wizard-page(ng-show='importDomain.action == "drivers"' style="margin-bottom:
256px;")
-            .import-domain-model-wizard-page(ng-show='importDomain.action == "connect" &&
importDomain.demo' style='margin-bottom: 141px')
+            .import-domain-model-wizard-page(ng-show='importDomain.action == "connect" &&
importDomain.demo' style='margin-bottom: 211px')
                 div(ng-if='demoConnection.db == "H2"')
                     label Demo description:
                     ul
@@ -45,7 +45,7 @@ mixin td-ellipses-lbl(w, lbl)
                             li Agent failed to resolve H2 database jar
                             li Copy h2-x.x.x.jar into agent '\jdbc-drivers' folder and try
again
                             li Refer to agent README.txt for more information
-            .import-domain-model-wizard-page(ng-show='importDomain.action == "connect" &&
!importDomain.demo')
+            .import-domain-model-wizard-page(ng-show='importDomain.action == "connect" &&
!importDomain.demo' style='margin-bottom: 90px')
                 form.form-horizontal(name='connectForm' novalidate)
                     .settings-row
                         label.col-xs-4.col-sm-2.col-md-2 Driver JAR:
@@ -98,7 +98,7 @@ mixin td-ellipses-lbl(w, lbl)
                         tbody
                             tr
                                 td(colspan='2')
-                                    .scrollable-y(style='height: 143px')
+                                    .scrollable-y(style='height: 213px')
                                         table.table-modal-striped(id='importSchemasData')
                                             tbody
                                                 tr(ng-repeat='schema in importDomain.displayedSchemas')
@@ -131,14 +131,14 @@ mixin td-ellipses-lbl(w, lbl)
                                     table.table-modal-striped(id='importTableData')
                                         tbody
                                             tr(ng-repeat='table in importDomain.displayedTables
track by $index')
-                                                td(width='30px' style='min-width: 30px; max-width:
30px')
+                                                td(width='30px')
                                                     input(type='checkbox' ng-model='table.use'
ng-change='selectTable()')
                                                 +td-ellipses-lbl('130px', '{{::table.schema}}')
                                                 +td-ellipses-lbl('160px', '{{::table.tbl}}')
-                                                td.td-ellipsis(width='160px' style='min-width:
160px; max-width: 160px' ng-show='ui.generateCaches')
+                                                td.td-ellipsis(width='160px' ng-show='ui.generateCaches')
                                                     button.select-toggle.form-control(ng-if='table.editCache'
bs-select ng-model='table.cache' data-container='false' bs-options='item.value as item.label
for item in importCaches')
                                                     a(ng-if='!table.editCache' ng-click='startEditDbTableCache(table)')
{{dbTableCache(table)}}
-                                                td.td-ellipsis(width='128px' style='min-width:
128px; max-width: 128px' ng-show='ui.generateCaches')
+                                                td.td-ellipsis(width='128px' ng-show='ui.generateCaches')
                                                     button.select-toggle.form-control(ng-if='table.editTemplate'
bs-select ng-model='table.template' style='max-width: 110px' data-container='false' bs-options='item.value
as item.label for item in importCacheTemplates')
                                                     a(ng-if='!table.editTemplate' ng-click='startEditDbTableTemplate(table)')
{{dbTableTemplate(table)}}
                 .settings-row
@@ -148,12 +148,17 @@ mixin td-ellipses-lbl(w, lbl)
                             | Generate caches
                         i.tipLabel.fa.fa-question-circle(bs-tooltip='' data-title='Separate
cache will be generated for each loaded table')
                     div
-                        label Cache:
-                        button.select-toggle.form-control(bs-select ng-model='dfltTableCache'
data-container='false' bs-options='item.value as item.label for item in importCaches')
-                        label Template:
-                        button.select-toggle.form-control(bs-select ng-model='dfltTableTemplate'
data-container='false' bs-options='item.value as item.label for item in importCacheTemplates')
-                        button.btn.btn-primary Apply to all
-            .import-domain-model-wizard-page(ng-show='importDomain.action == "options"' style='margin-bottom:
75px')
+                        .col-xs-5.col-sm-5.col-md-5
+                            label(style='float: left; line-height: 28px; margin-right: 10px')
Cache:
+                            .input-tip
+                                button.select-toggle.form-control(bs-select ng-model='ui.dfltTableCache'
ng-disabled='!ui.generateCaches' data-container='false' bs-options='item.value as item.label
for item in importCaches')
+                        .col-xs-5.col-sm-5.col-md-5(ng-show='dfltTableTemplateVisible()')
+                            label(style='float: left; line-height: 28px; margin: 0 10px')
Template:
+                            .input-tip
+                                button.select-toggle.form-control(bs-select ng-model='ui.dfltTableTemplate'
ng-disabled='!ui.generateCaches' data-container='false' bs-options='item.value as item.label
for item in importCacheTemplates')
+                        .col-xs-2.col-sm-2.col-md-2
+                            button.btn.btn-primary(style="margin: 0 0 0 5px" ng-disabled='!ui.generateCaches'
ng-click='applyDefaults()') Apply
+            .import-domain-model-wizard-page(ng-show='importDomain.action == "options"' style='margin-bottom:
176px')
                 form.form-horizontal(name='optionsForm' novalidate)
                     .settings-row
                         .col-xs-3.col-sm-2.col-md-2.required

http://git-wip-us.apache.org/repos/asf/ignite/blob/92ded8cf/modules/control-center-web/src/main/js/views/configuration/domains.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/configuration/domains.jade b/modules/control-center-web/src/main/js/views/configuration/domains.jade
index 7c4cd98..72d7eb5 100644
--- a/modules/control-center-web/src/main/js/views/configuration/domains.jade
+++ b/modules/control-center-web/src/main/js/views/configuration/domains.jade
@@ -25,7 +25,7 @@ include ../includes/controls
             li Import Domain models from Database
             li
                 ignite-dialog More info
-                    ignite-dialog-title Domain models screen
+                    ignite-dialog-title Domain model screen
                     ignite-dialog-content 
                         | Domain models can be assigned to specified #[a(ui-sref='base.configuration.caches')
caches].#[br]
                         | Generated cluster with caches and domain models configuration available
on #[a(ui-sref='base.configuration.summary') summary] screen.

http://git-wip-us.apache.org/repos/asf/ignite/blob/92ded8cf/modules/control-center-web/src/main/js/views/login.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/login.jade b/modules/control-center-web/src/main/js/views/login.jade
index 2ba170d..7be4726 100644
--- a/modules/control-center-web/src/main/js/views/login.jade
+++ b/modules/control-center-web/src/main/js/views/login.jade
@@ -104,15 +104,15 @@ header#header.header
                                 h3 Caches screen
                                 p Configure caches, link domain models to caches, link caches
to clusters
                         .item
-                            img(src='/images/domains.png', alt='Domain models screen')
+                            img(src='/images/domains.png', alt='Domain model screen')
                             .carousel-caption
-                                h3 Domain models screen
-                                p Manually enter domain models or load from database
+                                h3 Domain model screen
+                                p Manually enter domain model or import from database
                         .item
                             img(src='/images/summary.png', alt='Summary screen')
                             .carousel-caption
                                 h3 Summary screen
-                                p Download XML config, JAVA code, Docker file
+                                p Preview XML config, JAVA code,Docker file and download
project
                         .item
                             img(src='/images/query-table.png', alt='Query')
                             .carousel-caption


Mime
View raw message