ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [57/60] [abbrv] ignite git commit: IGNITE-5146 Simplified generation for user properties.
Date Thu, 04 May 2017 11:33:01 GMT
IGNITE-5146 Simplified generation for user properties.


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

Branch: refs/heads/ignite-5075-cacheStart
Commit: 6579197a86d6c6a4421aa20af8dbc792c2f49e44
Parents: 8be6813
Author: Vasiliy Sisko <vsisko@gridgain.com>
Authored: Thu May 4 11:42:58 2017 +0700
Committer: Andrey Novikov <anovikov@gridgain.com>
Committed: Thu May 4 11:42:58 2017 +0700

----------------------------------------------------------------------
 .../generator/Properties.service.js             | 63 ++++++++++----------
 1 file changed, 32 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6579197a/modules/web-console/frontend/app/modules/configuration/generator/Properties.service.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/configuration/generator/Properties.service.js
b/modules/web-console/frontend/app/modules/configuration/generator/Properties.service.js
index 8a6a471..882ac5b 100644
--- a/modules/web-console/frontend/app/modules/configuration/generator/Properties.service.js
+++ b/modules/web-console/frontend/app/modules/configuration/generator/Properties.service.js
@@ -24,54 +24,55 @@ export default class IgnitePropertiesGenerator {
     _collectProperties(bean) {
         const props = [];
 
-        _.forEach(bean.arguments, (arg) => {
-            switch (arg.clsName) {
-                case 'BEAN':
-                    props.push(...this._collectProperties(arg.value));
-
-                    break;
-                case 'PROPERTY':
-                case 'PROPERTY_CHAR':
-                case 'PROPERTY_INT':
-                    props.push(`${arg.value}=${arg.hint}`);
+        // Append properties for complex object.
+        const processBean = (bean) => {
+            const newProps = _.difference(this._collectProperties(bean), props);
 
-                    break;
-                default:
-                    // No-op.
-            }
-        });
+            if (!_.isEmpty(newProps)) {
+                props.push(...newProps);
 
-        _.forEach(bean.properties, (prop) => {
-            switch (prop.clsName) {
-                case 'DATA_SOURCE':
-                    props.push(...this._collectProperties(prop.value));
+                if (!_.isEmpty(_.last(props)))
                     props.push('');
+            }
+        };
 
-                    break;
-                case 'BEAN':
-                    props.push(...this._collectProperties(prop.value));
-
-                    break;
+        // Append properties from item.
+        const processItem = (item) => {
+            switch (item.clsName) {
                 case 'PROPERTY':
                 case 'PROPERTY_CHAR':
                 case 'PROPERTY_INT':
-                    props.push(`${prop.value}=${prop.hint}`);
+                    props.push(..._.difference([`${item.value}=${item.hint}`], props));
+
+                    break;
+                case 'BEAN':
+                case 'DATA_SOURCE':
+                    processBean(item.value);
 
                     break;
                 case 'ARRAY':
                 case 'COLLECTION':
-                    _.forEach(prop.items, (item) => {
-                        const itemLines = this._collectProperties(item);
+                    _.forEach(item.items, processBean);
 
-                        if (_.intersection(props, itemLines).length !== itemLines.length)
-                            props.push(...this._collectProperties(item));
+                    break;
+                case 'MAP':
+                    // Generate properties for all objects in keys and values of map.
+                    _.forEach(item.entries, (entry) => {
+                        processBean(entry.name);
+                        processBean(entry.value);
                     });
 
                     break;
                 default:
                     // No-op.
             }
-        });
+        };
+
+        // Generate properties for object arguments.
+        _.forEach(_.get(bean, 'arguments'), processItem);
+
+        // Generate properties for object properties.
+        _.forEach(_.get(bean, 'properties'), processItem);
 
         return props;
     }
@@ -84,7 +85,7 @@ export default class IgnitePropertiesGenerator {
 
         const sb = new StringBuilder();
 
-        sb.append(`# ${sb.generatedBy()}`);
+        sb.append(`# ${sb.generatedBy()}`).emptyLine();
 
         _.forEach(lines, (line) => sb.append(line));
 


Mime
View raw message