You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2016/09/12 11:20:50 UTC
[02/35] kylin git commit: KYLIN-1926-FK-PK-data-type-matching
KYLIN-1926-FK-PK-data-type-matching
Signed-off-by: Jason <ji...@163.com>
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/4ede67e3
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/4ede67e3
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/4ede67e3
Branch: refs/heads/1.5.x-HBase1.x
Commit: 4ede67e3f5a3bb1439d34263edb09c7ebf334675
Parents: eb92f96
Author: chenzhx <34...@qq.com>
Authored: Wed Sep 7 10:48:46 2016 +0800
Committer: Jason <ji...@163.com>
Committed: Wed Sep 7 11:39:28 2016 +0800
----------------------------------------------------------------------
webapp/app/js/controllers/cubeModel.js | 45 ++++++++++++--------
.../app/partials/modelDesigner/data_model.html | 5 ++-
2 files changed, 30 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/4ede67e3/webapp/app/js/controllers/cubeModel.js
----------------------------------------------------------------------
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;
http://git-wip-us.apache.org/repos/asf/kylin/blob/4ede67e3/webapp/app/partials/modelDesigner/data_model.html
----------------------------------------------------------------------
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 @@
<div ng-repeat="joinIndex in [] | range: newLookup.join.primary_key.length">
<div>
<select style="width: 45%" chosen data-placeholder="Fact Table Column"
- ng-model="newLookup.join.foreign_key[$index]"
+ ng-model="newLookup.join.foreign_key[$index]" ng-change="changeKey($index)"
ng-options="columns.name as columns.name for columns in getColumnsByTable(modelsManager.selectedModel.fact_table)" >
<option value=""></option>
</select>
<b>=</b>
<select style="width: 45%" chosen data-placeholder="Lookup Table Column"
- ng-model="newLookup.join.primary_key[$index]"
+ ng-model="newLookup.join.primary_key[$index]" ng-change="changeKey($index)"
ng-options="columns.name as columns.name for columns in getColumnsByTable(newLookup.table)" >
<option value=""></option>
</select>
@@ -173,6 +173,7 @@
</button>
</div>
<div class="space-4"></div>
+ <small class="help-block red" ng-show="newLookup.join.isCompatible[$index]==false"><i class="fa fa-exclamation-triangle"></i> <b>Column Type incompatible {{newLookup.join.primary_key[$index]}} [{{newLookup.join.pk_type[$index]}}],{{newLookup.join.foreign_key[$index]}}[{{newLookup.join.fk_type[$index]}}].</b></small>
</div>
</div>
</div>