ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject incubator-ignite git commit: IGNITE-843 WIP generate metadata from db tables meta.
Date Thu, 20 Aug 2015 17:16:17 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 ca73da147 -> de8dcc625


IGNITE-843 WIP generate metadata from db tables meta.


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

Branch: refs/heads/ignite-843
Commit: de8dcc62550d698fc6f8bc2e6c1735cbfeab6679
Parents: ca73da1
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Fri Aug 21 00:16:08 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Fri Aug 21 00:16:08 2015 +0700

----------------------------------------------------------------------
 .../main/js/controllers/metadata-controller.js  | 86 ++++++++++++++------
 1 file changed, 62 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/de8dcc62/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 feff6b1..7f1cdb2 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
@@ -316,40 +316,78 @@ controlCenterModule.controller('metadataController', [
                                 javaName: toJavaName(name), javaType: jdbcType.javaType}
                         }
 
+                        function colType(colName) {
+                            var col = _.find(table.cols, function(col) {
+                                return col.name == colName;
+                            });
+
+                            if (col)
+                                return $common.findJdbcType(col.type).javaType;
+
+                            return 'Unknown';
+                        }
+
                         _.forEach(table.cols, function(col) {
-                            var name = col.name;
+                            var colName = col.name;
                             var jdbcType = $common.findJdbcType(col.type);
 
-                            qryFields.push(queryField(name, jdbcType));
+                            qryFields.push(queryField(colName, jdbcType));
 
-                            if (_.includes(table.ascCols, name))
-                                ascFields.push(queryField(name, jdbcType));
+                            if (_.includes(table.ascCols, colName))
+                                ascFields.push(queryField(colName, jdbcType));
 
-                            if (_.includes(table.descCols, name))
-                                descFields.push(queryField(name, jdbcType));
+                            if (_.includes(table.descCols, colName))
+                                descFields.push(queryField(colName, jdbcType));
 
                             if (col.key)
-                                keyFields.push(dbField(name, jdbcType));
+                                keyFields.push(dbField(colName, jdbcType));
+
+                            valFields.push(dbField(colName, jdbcType));
+                        });
+
+                        var idxs = table.idxs;
+
+                        if (table.idxs) {
+                            var indexes = Object.keys(idxs);
+
+                            _.forEach(indexes, function (indexName) {
+                                var index = idxs[indexName];
+
+                                var fields = Object.keys(index);
+
+                                if (fields.length > 1)
+                                    groups.push(
+                                        {name: indexName, fields: _.map(fields, function
(fieldName) {
+                                            return {
+                                                name: fieldName,
+                                                className: colType(fieldName),
+                                                direction: index[fieldName]
+                                            };
+                                        })});
+                            });
+                        }
+
+                        var metaName = toProperCase(tableName);
 
-                            valFields.push(dbField(name, jdbcType));
+                        var meta = _.find($scope.metadatas, function (meta) {
+                            return meta.name == metaName;
                         });
 
-                        var newItem = {
-                            space: $scope.spaces[0],
-                            name: toProperCase(tableName),
-                            databaseSchema: table.schema,
-                            databaseTable: tableName,
-                            keyType: valType + 'Key',
-                            valueType: valType,
-                            queryFields: qryFields,
-                            ascendingFields: ascFields,
-                            descendingFields: descFields,
-                            groups: groups,
-                            keyFields: keyFields,
-                            valueFields: valFields
-                        };
-
-                        save(newItem);
+                        if (!meta)
+                            meta = {space: $scope.spaces[0], name: metaName};
+
+                        meta.databaseSchema = table.schema;
+                        meta.databaseTable = tableName;
+                        meta.keyType = valType + 'Key';
+                        meta.valueType = valType;
+                        meta.queryFields = qryFields;
+                        meta.ascendingFields = ascFields;
+                        meta.descendingFields = descFields;
+                        meta.groups = groups;
+                        meta.keyFields = keyFields;
+                        meta.valueFields = valFields;
+
+                        save(meta);
                     }
                 });
             };


Mime
View raw message