From 1b7b0debb224eca34eb72c58d17e06adcf9fc29b Mon Sep 17 00:00:00 2001 From: chenzhx <346839943@qq.com> Date: Wed, 7 Sep 2016 10:48:46 +0800 Subject: [PATCH] KYLIN-1926-FK-PK-data-type-matching --- webapp/app/js/controllers/cubeModel.js | 45 ++++++++++++++--------- webapp/app/partials/modelDesigner/data_model.html | 5 ++- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/webapp/app/js/controllers/cubeModel.js b/webapp/app/js/controllers/cubeModel.js index be931f3..b20a829 100644 --- a/webapp/app/js/controllers/cubeModel.js +++ b/webapp/app/js/controllers/cubeModel.js @@ -59,7 +59,10 @@ KylinApp.controller('CubeModelCtrl', function ($location,$scope, $modal,cubeConf join: { type: '', primary_key: [], - foreign_key: [] + foreign_key: [], + isCompatible:[], + pk_type:[], + fk_type:[] } }; }; @@ -82,7 +85,6 @@ KylinApp.controller('CubeModelCtrl', function ($location,$scope, $modal,cubeConf backdrop: 'static', scope: $scope }); - modalInstance.result.then(function () { if (!$scope.lookupState.editing) { $scope.doneAddLookup(); @@ -163,14 +165,37 @@ KylinApp.controller('CubeModelCtrl', function ($location,$scope, $modal,cubeConf }; + $scope.changeKey = function(index){ + var fact_table = modelsManager.selectedModel.fact_table; + var lookup_table = $scope.newLookup.table; + var pk_column = $scope.newLookup.join.primary_key[index]; + var fk_column = $scope.newLookup.join.foreign_key[index]; + if(pk_column!=='null'&&fk_column!=='null'){ + $scope.newLookup.join.pk_type[index] = TableModel.getColumnType(pk_column,lookup_table); + $scope.newLookup.join.fk_type[index] = TableModel.getColumnType(fk_column,fact_table); + if($scope.newLookup.join.pk_type[index]!==$scope.newLookup.join.fk_type[index]){ + $scope.newLookup.join.isCompatible[index]=false; + }else{ + $scope.newLookup.join.isCompatible[index]=true; + } + + } + } + $scope.addNewJoin = function(){ $scope.newLookup.join.primary_key.push("null"); $scope.newLookup.join.foreign_key.push("null"); + $scope.newLookup.join.fk_type.push("null"); + $scope.newLookup.join.pk_type.push("null"); + $scope.newLookup.join.isCompatible.push(true); }; $scope.removeJoin = function($index){ $scope.newLookup.join.primary_key.splice($index,1); $scope.newLookup.join.foreign_key.splice($index,1); + $scope.newLookup.join.fk_type.splice($index,1); + $scope.newLookup.join.pk_type.splice($index,1); + $scope.newLookup.join.isCompatible.splice($index,1); }; $scope.resetParams = function () { @@ -195,22 +220,6 @@ KylinApp.controller('CubeModelCtrl', function ($location,$scope, $modal,cubeConf } } - //column type validate - var fact_table = modelsManager.selectedModel.fact_table; - var lookup_table = $scope.newLookup.table; - - for(var i = 0;i<$scope.newLookup.join.primary_key.length;i++){ - var pk_column = $scope.newLookup.join.primary_key[i]; - var fk_column = $scope.newLookup.join.foreign_key[i]; - if(pk_column!=='null'&&fk_column!=='null'){ - var pk_type = TableModel.getColumnType(pk_column,lookup_table); - var fk_type = TableModel.getColumnType(fk_column,fact_table); - if(pk_type!==fk_type){ - errors.push(" Column Type incompatible "+pk_column+"["+pk_type+"]"+","+fk_column+"["+fk_type+"]."); - } - } - } - var errorInfo = ""; angular.forEach(errors,function(item){ errorInfo+="\n"+item; diff --git a/webapp/app/partials/modelDesigner/data_model.html b/webapp/app/partials/modelDesigner/data_model.html index d1a9cdd..662d0d9 100644 --- a/webapp/app/partials/modelDesigner/data_model.html +++ b/webapp/app/partials/modelDesigner/data_model.html @@ -157,13 +157,13 @@