summaryrefslogtreecommitdiffstats
path: root/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-sample/drools-controller.js
blob: 1d4659e3c56717fd30584e57c47f1be5341d08b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
appDS2.controller('droolsController', function($scope, $modal, $routeParams, DroolsService, modalService) {
	$scope.tableDate=[];
	$scope.resultsString = "";
	$scope.postDroolsBean={
			droolsFile:'',
			className:'',
			selectedRules:''
	};
	$scope.filenameFromUrl = $routeParams.filename;
	if($scope.filenameFromUrl!='' && $scope.filenameFromUrl!='0')
		$scope.postDroolsBean.droolsFile = $scope.filenameFromUrl
	$scope.execute = function(postDroolsBean) {
		if($scope.postDroolsBean.droolsFile=='' ||$scope.postDroolsBean.className=='' || $scope.postDroolsBean.selectedRules=='' ){
			modalService.errorPopUp ("Required fields cannot be empty");
			return;
		}
		var uuu = "post_drools/execute";
		var postData={postDroolsBean:postDroolsBean};
		DroolsService.executeDrools(postData).then(function(data){	
			$scope.resultsString=data.resultsString;
			modalService.successPopUp($scope.resultsString);
		},function(error){
			modalService.errorPopUp (error);
		});
	};	
});

appDS2.controller('droolsListController', function($scope, $modal, DroolsService, modalService) {
	$scope.tableDate=[];
	$scope.resultsString = "";
	$scope.postDroolsBean="";
	
	$scope.getDroolsList = function(){
		DroolsService.getDroolsList().then(function(data){
			var j = data;
			$scope.tableData = JSON.parse(j.data);
			$scope.buildTable();
		},function(error){
			modalService.errorPopUp (error);
		});
	}
	
	$scope.buildTable = function(){
		for(x in $scope.tableData){
			if($scope.tableData[x].active_yn=='Y')
				$scope.tableData[x].active_yn=true;
			else
				$scope.tableData[x].active_yn=false;
		}
	}	
    
});