kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lid...@apache.org
Subject [3/9] kylin git commit: KYLIN-2222 web ui uses rest api to decide which dim encoding is valid for different typed columns
Date Fri, 17 Feb 2017 00:52:31 GMT
KYLIN-2222 web ui uses rest api to decide which dim encoding is valid for different typed columns

Signed-off-by: Hongbin Ma <mahongbin@apache.org>


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

Branch: refs/heads/master-hbase0.98
Commit: b8a96dbf4df3ffa267c6cbdcadce9a1ea62b18bf
Parents: 61784b4
Author: luguosheng <550175214@qq.com>
Authored: Thu Feb 16 16:18:00 2017 +0800
Committer: Hongbin Ma <mahongbin@apache.org>
Committed: Thu Feb 16 16:27:10 2017 +0800

----------------------------------------------------------------------
 webapp/app/js/controllers/cubeAdvanceSetting.js |  4 +-
 webapp/app/js/controllers/cubeEdit.js           | 41 ++++----------------
 webapp/app/js/controllers/cubeMeasures.js       |  4 +-
 webapp/app/js/controllers/cubeSchema.js         | 15 ++++++-
 webapp/app/js/model/modelsManager.js            | 36 ++++++++++++++++-
 5 files changed, 61 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/b8a96dbf/webapp/app/js/controllers/cubeAdvanceSetting.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubeAdvanceSetting.js b/webapp/app/js/controllers/cubeAdvanceSetting.js
index 7aaa604..5e7de33 100644
--- a/webapp/app/js/controllers/cubeAdvanceSetting.js
+++ b/webapp/app/js/controllers/cubeAdvanceSetting.js
@@ -18,7 +18,7 @@
 
 'use strict';
 
-KylinApp.controller('CubeAdvanceSettingCtrl', function ($scope, $modal,cubeConfig,MetaModel,cubesManager,CubeDescModel,SweetAlert,VdmUtil)
{
+KylinApp.controller('CubeAdvanceSettingCtrl', function ($scope, $modal,cubeConfig,MetaModel,cubesManager,CubeDescModel,SweetAlert,VdmUtil,modelsManager)
{
   $scope.cubesManager = cubesManager;
 
   var needLengthKeyList=cubeConfig.needSetLengthEncodingList;
@@ -27,7 +27,7 @@ KylinApp.controller('CubeAdvanceSettingCtrl', function ($scope, $modal,cubeConfi
     item.encoding=$scope.removeVersion(item.encoding);
     var _valueLength;
     var tableName=VdmUtil.getNameSpaceTopName(item.column);
-    var databaseName=$scope.getDatabaseByColumnName(item.column);
+    var databaseName=modelsManager.getDatabaseByColumnName(item.column);
     var baseKey=item.encoding.replace(/:\d+/,'');
     if(needLengthKeyList.indexOf(baseKey)>-1){
       var result=/:(\d+)/.exec(item.encoding);

http://git-wip-us.apache.org/repos/asf/kylin/blob/b8a96dbf/webapp/app/js/controllers/cubeEdit.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubeEdit.js b/webapp/app/js/controllers/cubeEdit.js
index 32c630c..bc0bceb 100755
--- a/webapp/app/js/controllers/cubeEdit.js
+++ b/webapp/app/js/controllers/cubeEdit.js
@@ -22,13 +22,12 @@
 KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $location, $templateCache,
$interpolate, MessageService, TableService, CubeDescService, CubeService, loadingRequest,
SweetAlert, $log, cubeConfig, CubeDescModel, MetaModel, TableModel, ModelDescService, modelsManager,
cubesManager, ProjectModel, StreamingModel, StreamingService,VdmUtil) {
   $scope.cubeConfig = cubeConfig;
   $scope.metaModel = {};
-  $scope.tableAliasMap={};
-  $scope.aliasTableMap={};
-  $scope.aliasName=[];
-  $scope.availableFactTables = [];
-  $scope.availableLookupTables = [];
   $scope.modelsManager = modelsManager;
-
+  $scope.tableAliasMap=$scope.modelsManager.tableAliasMap;
+  $scope.aliasTableMap=$scope.modelsManager.aliasTableMap;
+  $scope.availableFactTables =$scope.modelsManager.availableFactTables;
+  $scope.availableLookupTables =$scope.modelsManager.availableLookupTables;
+  $scope.aliasName=$scope.modelsManager.aliasName;
   //add or edit ?
   var absUrl = $location.absUrl();
   $scope.cubeMode = absUrl.indexOf("/cubes/add") != -1 ? 'addNewCube' : absUrl.indexOf("/cubes/edit")
!= -1 ? 'editExistCube' : 'default';
@@ -39,20 +38,7 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams,
$locatio
     return;
   }
 
-  $scope.getTypeVersion=function(typename){
-    var searchResult=/\[v(\d+)\]/.exec(typename);
-    if(searchResult&&searchResult.length){
-      return searchResult.length&&searchResult[1]||1;
-    }else{
-      return 1;
-    }
-  }
-  $scope.removeVersion=function(typename){
-    if(typename){
-      return typename.replace(/\[v\d+\]/g,"");
-    }
-    return "";
-  }
+
   //init encoding list
   $scope.store = {
     supportedEncoding:[],
@@ -108,7 +94,7 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams,
$locatio
   }
   $scope.getEncodings =function (name){
     var filterName=name;
-    var columnType= $scope.getColumnTypeByAliasName(filterName);
+    var columnType= modelsManager.getColumnTypeByColumnName(filterName);
     var matchList=VdmUtil.getObjValFromLikeKey($scope.store.encodingMaps,columnType);
     var encodings =$scope.store.supportedEncoding,filterEncoding;
     if($scope.isEdit){
@@ -324,18 +310,7 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams,
$locatio
         if (!modelsManager.getModels().length) {
           ModelDescService.query({model_name: $scope.cubeMetaFrame.model_name}, function
(_model) {
             $scope.metaModel.model = _model;
-            var rootFactTable = VdmUtil.removeNameSpace($scope.metaModel.model.fact_table);
-            $scope.aliasName.push(rootFactTable);
-            $scope.aliasTableMap[rootFactTable]=$scope.metaModel.model.fact_table;
-            $scope.tableAliasMap[$scope.metaModel.model.fact_table]=rootFactTable;
-            angular.forEach($scope.metaModel.model.lookups,function(joinTable){
-              if(!joinTable.alias){
-                joinTable.alias=VdmUtil.removeNameSpace(joinTable.table);
-              }
-              $scope.aliasTableMap[joinTable.alias]=joinTable.table;
-              $scope.tableAliasMap[joinTable.table]=joinTable.alias;
-              $scope.aliasName.push(joinTable.alias);
-            });
+            $scope.modelsManager.initAliasMapByModelSchema($scope.metaModel);
           });
         }
         $scope.state.cubeSchema = angular.toJson($scope.cubeMetaFrame, true);

http://git-wip-us.apache.org/repos/asf/kylin/blob/b8a96dbf/webapp/app/js/controllers/cubeMeasures.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubeMeasures.js b/webapp/app/js/controllers/cubeMeasures.js
index fc146ba..03e913a 100644
--- a/webapp/app/js/controllers/cubeMeasures.js
+++ b/webapp/app/js/controllers/cubeMeasures.js
@@ -18,7 +18,7 @@
 
 'use strict';
 
-KylinApp.controller('CubeMeasuresCtrl', function ($scope, $modal,MetaModel,cubesManager,CubeDescModel,SweetAlert,VdmUtil,TableModel,cubeConfig)
{
+KylinApp.controller('CubeMeasuresCtrl', function ($scope, $modal,MetaModel,cubesManager,CubeDescModel,SweetAlert,VdmUtil,TableModel,cubeConfig,modelsManager)
{
   $scope.num=0;
   $scope.convertedColumns=[];
   $scope.groupby=[];
@@ -31,7 +31,7 @@ KylinApp.controller('CubeMeasuresCtrl', function ($scope, $modal,MetaModel,cubes
   $scope.initUpdateMeasureStatus();
   var needLengthKeyList=cubeConfig.needSetLengthEncodingList;
   $scope.getEncodings =function (name){
-    var columnType = $scope.getColumnTypeByAliasName(name);
+    var columnType = modelsManager.getColumnTypeByColumnName(name);
     var encodings =$scope.store.supportedEncoding,filterEncoding=[];
     var matchList=VdmUtil.getObjValFromLikeKey($scope.store.encodingMaps,columnType);
     if($scope.isEdit) {

http://git-wip-us.apache.org/repos/asf/kylin/blob/b8a96dbf/webapp/app/js/controllers/cubeSchema.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubeSchema.js b/webapp/app/js/controllers/cubeSchema.js
index 4beeebe..6aeea3c 100755
--- a/webapp/app/js/controllers/cubeSchema.js
+++ b/webapp/app/js/controllers/cubeSchema.js
@@ -39,7 +39,20 @@ KylinApp.controller('CubeSchemaCtrl', function ($scope, QueryService, UserServic
 
     $scope.allCubes = [];
 
-
+    $scope.getTypeVersion=function(typename){
+      var searchResult=/\[v(\d+)\]/.exec(typename);
+      if(searchResult&&searchResult.length){
+        return searchResult.length&&searchResult[1]||1;
+      }else{
+        return 1;
+      }
+    }
+    $scope.removeVersion=function(typename){
+      if(typename){
+        return typename.replace(/\[v\d+\]/g,"");
+      }
+      return "";
+    }
   // ~ init
     if (!$scope.state) {
         $scope.state = {mode: "view"};

http://git-wip-us.apache.org/repos/asf/kylin/blob/b8a96dbf/webapp/app/js/model/modelsManager.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/model/modelsManager.js b/webapp/app/js/model/modelsManager.js
index faa8d39..f00f5cc 100644
--- a/webapp/app/js/model/modelsManager.js
+++ b/webapp/app/js/model/modelsManager.js
@@ -16,7 +16,7 @@
  * limitations under the License.
 */
 
-KylinApp.service('modelsManager',function(ModelService,CubeService,$q,AccessService,ProjectModel,$log){
+KylinApp.service('modelsManager',function(ModelService,CubeService,$q,AccessService,ProjectModel,VdmUtil,TableModel){
     var _this = this;
     this.models=[];
     this.modelNameList = [];
@@ -92,5 +92,39 @@ KylinApp.service('modelsManager',function(ModelService,CubeService,$q,AccessServ
 
         return defer.promise;
     };
+    //init alias map
+    this.tableAliasMap={};
+    this.aliasTableMap={};
+    this.availableFactTables=[];
+    this.availableLookupTables=[];
+    this.aliasName=[];
+
+    this.initAliasMapByModelSchema=function(metaModel){
+      var rootFactTable = VdmUtil.removeNameSpace(metaModel.model.fact_table);
+      this.availableFactTables.push(rootFactTable);
+      this.aliasName.push(rootFactTable);
+      this.aliasTableMap[rootFactTable]=metaModel.model.fact_table;
+      this.tableAliasMap[metaModel.model.fact_table]=rootFactTable;
+      var _this=this;
+      angular.forEach(metaModel.model.lookups,function(joinTable){
+        if(!joinTable.alias){
+          joinTable.alias=VdmUtil.removeNameSpace(joinTable.table);
+        }
+        if(joinTable.kind=="FACT"){
+          _this.availableFactTables.push(joinTable.alias);
+        }else{
+          _this.availableLookupTables.push(joinTable.alias);
+        }
+        _this.aliasTableMap[joinTable.alias]=joinTable.table;
+        _this.tableAliasMap[joinTable.table]=joinTable.alias;
+        _this.aliasName.push(joinTable.alias);
+      });
+    }
+    this.getDatabaseByColumnName=function(column){
+      return  VdmUtil.getNameSpaceTopName(this.aliasTableMap[VdmUtil.getNameSpaceTopName(column)])
+    }
+    this.getColumnTypeByColumnName=function(column){
+      return TableModel.columnNameTypeMap[this.aliasTableMap[VdmUtil.getNameSpaceTopName(column)]+'.'+VdmUtil.removeNameSpace(column)];
+    }
 
 });


Mime
View raw message