IGNITE-5369 Added support for _key and _val names on QueryEntity XML and code 
generation.


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

Branch: refs/heads/ignite-2.1
Commit: eb37f538f55a471258e49ee2fbf0e8f234829def
Parents: e5c2ec5
Author: vsisko <vsi...@gridgain.com>
Authored: Fri Jul 7 23:22:59 2017 +0700
Committer: Alexey Kuznetsov <akuznet...@gridgain.com>
Committed: Fri Jul 7 23:22:59 2017 +0700

----------------------------------------------------------------------
 .../internal/visor/query/VisorQueryEntity.java  | 32 +++++++++++++++++--
 modules/web-console/backend/app/mongo.js        |  2 ++
 .../generator/AbstractTransformer.js            |  4 +--
 .../generator/ConfigurationGenerator.js         | 33 +++++++++++++++-----
 .../states/configuration/domains/query.pug      |  9 ++++++
 .../frontend/controllers/domains-controller.js  |  7 +++--
 6 files changed, 73 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/eb37f538/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryEntity.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryEntity.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryEntity.java
index 9f4dfe7..c67918a 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryEntity.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryEntity.java
@@ -58,6 +58,12 @@ public class VisorQueryEntity extends 
VisorDataTransferObject {
     /** Table name. */
     private String tblName;
 
+    /** Key name. Can be used in field list to denote the key as a whole. */
+    private String keyFieldName;
+
+    /** Value name. Can be used in field list to denote the entire value. */
+    private String valFieldName;
+
     /** Fields to create group indexes for. */
     private List<VisorQueryIndex> grps;
 
@@ -108,6 +114,10 @@ public class VisorQueryEntity extends 
VisorDataTransferObject {
 
         for (QueryIndex qryIdx : qryIdxs)
             grps.add(new VisorQueryIndex(qryIdx));
+
+        tblName = q.getTableName();
+        keyFieldName = q.getKeyFieldName();
+        valFieldName = q.getValueFieldName();
     }
 
     /**
@@ -153,6 +163,20 @@ public class VisorQueryEntity extends 
VisorDataTransferObject {
     }
 
     /**
+     * @return Key name. Can be used in field list to denote the key as a 
whole.
+     */
+    public String getKeyFieldName() {
+        return keyFieldName;
+    }
+
+    /**
+     * @return Value name. Can be used in field list to denote the entire 
value.
+     */
+    public String getValueFieldName() {
+        return valFieldName;
+    }
+
+    /**
      * @return Fields to create group indexes for.
      */
     public List<VisorQueryIndex> getGroups() {
@@ -166,8 +190,10 @@ public class VisorQueryEntity extends 
VisorDataTransferObject {
         U.writeCollection(out, keyFields);
         IgfsUtils.writeStringMap(out, qryFlds);
         U.writeMap(out, aliases);
-        U.writeString(out, tblName);
         U.writeCollection(out, grps);
+        U.writeString(out, tblName);
+        U.writeString(out, keyFieldName);
+        U.writeString(out, valFieldName);
     }
 
     /** {@inheritDoc} */
@@ -177,8 +203,10 @@ public class VisorQueryEntity extends 
VisorDataTransferObject {
         keyFields = U.readList(in);
         qryFlds = IgfsUtils.readStringMap(in);
         aliases = U.readMap(in);
-        tblName = U.readString(in);
         grps = U.readList(in);
+        tblName = U.readString(in);
+        keyFieldName = U.readString(in);
+        valFieldName = U.readString(in);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/eb37f538/modules/web-console/backend/app/mongo.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/app/mongo.js 
b/modules/web-console/backend/app/mongo.js
index 32796e6..aa11e0b 100644
--- a/modules/web-console/backend/app/mongo.js
+++ b/modules/web-console/backend/app/mongo.js
@@ -106,6 +106,8 @@ module.exports.factory = function(passportMongo, settings, 
pluginMongo, mongoose
         queryMetadata: {type: String, enum: ['Annotations', 'Configuration']},
         kind: {type: String, enum: ['query', 'store', 'both']},
         tableName: String,
+        keyFieldName: String,
+        valueFieldName: String,
         databaseSchema: String,
         databaseTable: String,
         keyType: String,

http://git-wip-us.apache.org/repos/asf/ignite/blob/eb37f538/modules/web-console/frontend/app/modules/configuration/generator/AbstractTransformer.js
----------------------------------------------------------------------
diff --git 
a/modules/web-console/frontend/app/modules/configuration/generator/AbstractTransformer.js
 
b/modules/web-console/frontend/app/modules/configuration/generator/AbstractTransformer.js
index 0e4537e..4d66a64 100644
--- 
a/modules/web-console/frontend/app/modules/configuration/generator/AbstractTransformer.js
+++ 
b/modules/web-console/frontend/app/modules/configuration/generator/AbstractTransformer.js
@@ -304,8 +304,8 @@ export default class AbstractTransformer {
     }
 
     // Generate domain model for query group.
-    static domainModelQuery(domain) {
-        return this.toSection(this.generator.domainModelQuery(domain));
+    static domainModelQuery(domain, available) {
+        return this.toSection(this.generator.domainModelQuery(domain, 
available));
     }
 
     // Generate domain model for store group.

http://git-wip-us.apache.org/repos/asf/ignite/blob/eb37f538/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js
----------------------------------------------------------------------
diff --git 
a/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js
 
b/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js
index f850dce..8c9b14c 100644
--- 
a/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js
+++ 
b/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js
@@ -1672,13 +1672,30 @@ export default class IgniteConfigurationGenerator {
     }
 
     // Generate domain model for query group.
-    static domainModelQuery(domain, cfg = 
this.domainConfigurationBean(domain)) {
+    static domainModelQuery(domain, available, cfg = 
this.domainConfigurationBean(domain)) {
         if (cfg.valueOf('queryMetadata') === 'Configuration') {
-            const fields = _.map(domain.fields,
-                (e) => ({name: e.name, className: 
javaTypes.fullClassName(e.className)}));
+            const fields = _.filter(_.map(domain.fields,
+                (e) => ({name: e.name, className: 
javaTypes.fullClassName(e.className)})), (field) => {
+                return field.name !== domain.keyFieldName && field.name !== 
domain.valueFieldName;
+            });
+
+            cfg.stringProperty('tableName');
+
+            if (available('2.0.0')) {
+                cfg.stringProperty('keyFieldName')
+                    .stringProperty('valueFieldName');
+
+                const keyFieldName = cfg.valueOf('keyFieldName');
+                const valFieldName = cfg.valueOf('valueFieldName');
+
+                if (keyFieldName)
+                    fields.push({name: keyFieldName, className: 
javaTypes.fullClassName(domain.keyType)});
+
+                if (valFieldName)
+                    fields.push({name: valFieldName, className: 
javaTypes.fullClassName(domain.valueType)});
+            }
 
-            cfg.stringProperty('tableName')
-                .mapProperty('fields', fields, 'fields', true)
+            cfg.mapProperty('fields', fields, 'fields', true)
                 .mapProperty('aliases', 'aliases');
 
             const indexes = _.map(domain.indexes, (index) =>
@@ -2131,12 +2148,12 @@ export default class IgniteConfigurationGenerator {
     }
 
     // Generate domain models configs.
-    static cacheDomains(domains, ccfg) {
+    static cacheDomains(domains, available, ccfg) {
         const qryEntities = _.reduce(domains, (acc, domain) => {
             if (_.isNil(domain.queryMetadata) || domain.queryMetadata === 
'Configuration') {
                 const qryEntity = this.domainModelGeneral(domain);
 
-                this.domainModelQuery(domain, qryEntity);
+                this.domainModelQuery(domain, available, qryEntity);
 
                 acc.push(qryEntity);
             }
@@ -2160,7 +2177,7 @@ export default class IgniteConfigurationGenerator {
         this.cacheRebalance(cache, ccfg);
         this.cacheNearServer(cache, ccfg);
         this.cacheStatistics(cache, ccfg);
-        this.cacheDomains(cache.domains, ccfg);
+        this.cacheDomains(cache.domains, available, ccfg);
 
         return ccfg;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/eb37f538/modules/web-console/frontend/app/modules/states/configuration/domains/query.pug
----------------------------------------------------------------------
diff --git 
a/modules/web-console/frontend/app/modules/states/configuration/domains/query.pug
 
b/modules/web-console/frontend/app/modules/states/configuration/domains/query.pug
index b8564dc..19cb83d 100644
--- 
a/modules/web-console/frontend/app/modules/states/configuration/domains/query.pug
+++ 
b/modules/web-console/frontend/app/modules/states/configuration/domains/query.pug
@@ -67,6 +67,15 @@ mixin table-index-item-edit(prefix, index, sortAvailable, 
idAddition)
                 div(ng-if=`${model}.queryMetadata === 'Configuration'`)
                     .settings-row
                         +text('Table name:', `${model}.tableName`, 
'"tableName"', 'false', 'Enter table name', 'Table name for this query entity')
+                    div(ng-if='$ctrl.available("2.0.0")')
+                        .settings-row
+                            +text('Key field name:', `${model}.keyFieldName`, 
'"keyFieldName"', 'false', 'Enter key field name',
+                                'Key name.<br/>' +
+                                'Can be used in field list to denote the key 
as a whole')
+                        .settings-row
+                            +text('Value field name:', 
`${model}.valueFieldName`, '"valueFieldName"', 'false', 'Enter value field 
name',
+                                'Value name.<br/>' +
+                                'Can be used in field list to denote the 
entire value')
                     .settings-row
                         +ignite-form-group(ng-model=queryFields 
ng-form=queryFieldsForm)
                             ignite-form-field-label(id='queryFields')

http://git-wip-us.apache.org/repos/asf/ignite/blob/eb37f538/modules/web-console/frontend/controllers/domains-controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/controllers/domains-controller.js 
b/modules/web-console/frontend/controllers/domains-controller.js
index 7a16c50..7c87ce0 100644
--- a/modules/web-console/frontend/controllers/domains-controller.js
+++ b/modules/web-console/frontend/controllers/domains-controller.js
@@ -18,10 +18,12 @@
 import templateUrl from 'views/configuration/domains-import.tpl.pug';
 
 // Controller for Domain model screen.
-export default ['$rootScope', '$scope', '$http', '$state', '$filter', 
'$timeout', '$modal', 'IgniteLegacyUtils', 'IgniteMessages', 'IgniteFocus', 
'IgniteConfirm', 'IgniteConfirmBatch', 'IgniteInput', 'IgniteLoading', 
'IgniteModelNormalizer', 'IgniteUnsavedChangesGuard', 'AgentManager', 
'IgniteLegacyTable', 'IgniteConfigurationResource', 'IgniteErrorPopover', 
'IgniteFormUtils', 'JavaTypes', 'SqlTypes', 'IgniteActivitiesData',
-    function($root, $scope, $http, $state, $filter, $timeout, $modal, 
LegacyUtils, Messages, Focus, Confirm, ConfirmBatch, Input, Loading, 
ModelNormalizer, UnsavedChangesGuard, agentMgr, LegacyTable, Resource, 
ErrorPopover, FormUtils, JavaTypes, SqlTypes, ActivitiesData) {
+export default ['$rootScope', '$scope', '$http', '$state', '$filter', 
'$timeout', '$modal', 'IgniteLegacyUtils', 'IgniteMessages', 'IgniteFocus', 
'IgniteConfirm', 'IgniteConfirmBatch', 'IgniteInput', 'IgniteLoading', 
'IgniteModelNormalizer', 'IgniteUnsavedChangesGuard', 'AgentManager', 
'IgniteLegacyTable', 'IgniteConfigurationResource', 'IgniteErrorPopover', 
'IgniteFormUtils', 'JavaTypes', 'SqlTypes', 'IgniteActivitiesData', 
'IgniteVersion',
+    function($root, $scope, $http, $state, $filter, $timeout, $modal, 
LegacyUtils, Messages, Focus, Confirm, ConfirmBatch, Input, Loading, 
ModelNormalizer, UnsavedChangesGuard, agentMgr, LegacyTable, Resource, 
ErrorPopover, FormUtils, JavaTypes, SqlTypes, ActivitiesData, Version) {
         UnsavedChangesGuard.install($scope);
 
+        this.available = Version.available.bind(Version);
+
         const emptyDomain = {empty: true};
 
         let __original_value;
@@ -941,6 +943,7 @@ export default ['$rootScope', '$scope', '$http', '$state', 
'$filter', '$timeout'
                         const keyField = newDomain.keyFields[0];
 
                         newDomain.keyType = keyField.javaType;
+                        newDomain.keyFieldName = keyField.javaFieldName;
 
                         // Exclude key column from query fields.
                         newDomain.fields = _.filter(newDomain.fields, (field) 
=> field.name !== keyField.javaFieldName);

Reply via email to