Skip to content

Commit

Permalink
Merge pull request #48 from msf-ocba/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
vgarciabnz authored May 4, 2017
2 parents 15906ae + 65b2928 commit 59cdd64
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 143 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
24 changes: 13 additions & 11 deletions app/admin/admin.controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,45 +178,47 @@ adminModule.controller('adminMainController', ['$scope', '$translate', 'adminOUG

$scope.submitDS = function() {
console.log($scope.selectedDS);
adminDSFactory.get_DS_set.query($scope.selectedDS,function(response1){
adminDSFactory.upd_DS.query($scope.selectedDS,function(response2){
adminDSFactory.get_DS_set.query($scope.selectedDS).$promise.then(function(response1){
return adminDSFactory.upd_DS.query($scope.selectedDS,function(response2){
console.log(response2);
if (response2) {
$scope.blacklist_datasets = $scope.selectedDS;
}
});
}, function() {
adminDSFactory.set_DS.query($scope.selectedDS,function(response2){
return adminDSFactory.set_DS.query($scope.selectedDS,function(response2){
console.log(response2);
if (response2) {
$scope.blacklist_datasets = $scope.selectedDS;
}
});
}).then(function(){
window.location.reload(true)
});
window.location.reload(true);
};

if ($scope.blacklist_indicatorgroups) {
$scope.selectedIG = JSON.stringify($scope.blacklist_indicatorgroups);
}

$scope.submitIG = function() {
console.log($scope.selectedIG);;
adminIGFactory.get_IG_set.query($scope.selectedIG,function(response1){
adminIGFactory.upd_IG.query($scope.selectedIG,function(response2){
console.log(response);
if (response) {
console.log($scope.selectedIG);
adminIGFactory.get_IG_set.query($scope.selectedIG).$promise.then(function(response1){
return adminIGFactory.upd_IG.query($scope.selectedIG,function(response2){
console.log(response2);
if (response2) {
$scope.blacklist_indicatorgroups = $scope.selectedIG;
}
});
}, function() {
adminIGFactory.set_IG.query($scope.selectedIG,function(response){
return adminIGFactory.set_IG.query($scope.selectedIG,function(response){
console.log(response);
if (response) {
$scope.blacklist_indicatorgroups = $scope.selectedIG;
}
});
}).then(function(){
window.location.reload(true)
});
window.location.reload(true);
};
}]);
228 changes: 106 additions & 122 deletions app/search/search.controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
if (result !== null) {
return result.length > 1 ? result[2] : "x";
}
}
};

$scope.getDenominator = function(indicator) {
var re = /(DENOM:)(.*)/;
var result = re.exec(indicator.displayDescription);
if (result !== null) {
return result.length > 1 ? result[2] : "x";
}
}
};

$scope.getDescription = function(indicator) {
var re = /(.*)(NUM:)/;
Expand All @@ -188,147 +188,115 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
} else {
return indicator.displayDescription;
}
}
};

$scope.parseFormula = function(formula, dataElements, categoryOptionCombos) {
var operatorRegex = /}\s*[\+\-\*]\s*#/g;
var dataElementRegex = /#\{\w*}/g;
var dataElementCatRegex = /#\{\w*.\w*}/g;
return formula
.replace(operatorRegex, function (nexus) {
var operator = nexus.split("}")[1].trim().charAt(0);
return "}<br><b>" + operator + "</b> #";
})
.replace(dataElementRegex, function (dataElementWithCurlyBraces) {
var deId = dataElementWithCurlyBraces.substr(0, dataElementWithCurlyBraces.length - 1).substr(2);

return dataElements[deId] ? dataElements[deId].object_name : deId;;
})
.replace(dataElementCatRegex, function (dataElementCatWithCurlyBraces) {
var deId = dataElementCatWithCurlyBraces.split("{")[1].split(".")[0];
var catId = dataElementCatWithCurlyBraces.split(".")[1].split("}")[0];

var dataElement = dataElements[deId] ? dataElements[deId].object_name : deId;
var categoryOptionCombo = categoryOptionCombos[catId] ? categoryOptionCombos[catId].object_name : catId;

return dataElement + " <i>(" + categoryOptionCombo + ")</i>";
});
};

$scope.$watch('servicesList', function(){

var start = new Date();
//console.log('servicesList available?', $scope.servicesList);
if ($scope.servicesList) {

var temp = {};
var categoryOptionCombosTemp = {};

searchAllFactory.get_dataElements.query(function(response){
searchAllFactory.qry_dataElementsAll.query().$promise.then(function(response){
//console.log('get_dataElements', response);
response.dataElements.forEach(function(obj) {

if(filterObjects(obj,"dataElement")){

temp[obj.id] = {
object_type: 'dataElement',
object_id: obj.id,
object_code: obj.code,
object_name: obj.displayName,
object_form: obj.displayFormName,
//objectGroup + service
var temp_arr = {
objectGroup_id: [],
objectGroup_code: [],
objectGroup_name: [],
service_id: [],
service_code: [],
service_name: []
};
}
});
//console.log('get_dataElements refactored', temp);
$scope.loaded.get_dataElements = true;
$scope.allObjects = Object.keys(temp).map(function(key) { return temp[key]; });

searchAllFactory.get_dataElementsDescriptions.query(function(response){
//console.log('get_dataElementsDescriptions', response);
response.dataElements.forEach(function(obj) {

if(filterObjects(obj,"dataElement")){

temp[obj.id].object_description = obj.displayDescription;

};
});
//console.log('get_dataElementsDescriptions refactored', temp);
$scope.loaded.get_dataElementsDescriptions = true;
$scope.allObjects = Object.keys(temp).map(function(key) { return temp[key]; });

});
searchAllFactory.get_dataElementsGroups.query(function(response){
//console.log('get_dataElementsGroups', response);
response.dataElements.forEach(function(obj) {

if(filterObjects(obj,"dataElement")){

//objectGroup + service
var temp_arr = {
objectGroup_id: [],
objectGroup_code: [],
objectGroup_name: [],
service_id: [],
service_code: [],
service_name: []
};

obj.dataSetElements.forEach(function(grp) {
if(grp.dataSet.attributeValues.length > 0 && grp.dataSet.attributeValues[0].value){
var servicesCode = grp.dataSet.attributeValues[0].value.split('_');
servicesCode.shift();
servicesCode.forEach(function(code) {
if($scope.servicesList[code]){
temp_arr.service_id.push($scope.servicesList[code].service_id);
temp_arr.service_code.push($scope.servicesList[code].service_code);
temp_arr.service_name.push($scope.servicesList[code].service_name);
}else{
console.log("search: Cannot find any service with code: " + code);
}
});
}
temp_arr.objectGroup_id.push(grp.dataSet.id);
temp_arr.objectGroup_code.push(grp.dataSet.code);
temp_arr.objectGroup_name.push(grp.dataSet.displayName);


});

temp[obj.id].objectGroup_id = temp_arr.objectGroup_id.join(', ');
temp[obj.id].objectGroup_code = temp_arr.objectGroup_code.join(', ');
temp[obj.id].objectGroup_name = temp_arr.objectGroup_name.join(', ');
temp[obj.id].service_id = temp_arr.service_id.join(', ');
temp[obj.id].service_code = temp_arr.service_code.join(', ');
temp[obj.id].service_name =temp_arr.service_name.join(', ');

}

});
//console.log('get_dataElementsGroups refactored', temp);
$scope.loaded.get_dataElementsGroups = true;
$scope.allObjects = Object.keys(temp).map(function(key) { return temp[key]; });

});
});



searchAllFactory.get_indicators.query(function(response){
//console.log('get_indicators', response);
response.indicators.forEach(function(obj) {

if(filterObjects(obj,"indicator")){
obj.dataSetElements.forEach(function(grp) {
if(grp.dataSet.attributeValues.length > 0 && grp.dataSet.attributeValues[0].value){
var servicesCode = grp.dataSet.attributeValues[0].value.split('_');
servicesCode.shift();
servicesCode.forEach(function(code) {
if($scope.servicesList[code]){
temp_arr.service_id.push($scope.servicesList[code].service_id);
temp_arr.service_code.push($scope.servicesList[code].service_code);
temp_arr.service_name.push($scope.servicesList[code].service_name);
}else{
console.log("search: Cannot find any service with code: " + code);
}
});
}
temp_arr.objectGroup_id.push(grp.dataSet.id);
temp_arr.objectGroup_code.push(grp.dataSet.code);
temp_arr.objectGroup_name.push(grp.dataSet.displayName);


});

temp[obj.id] = {
object_type: 'indicator',
object_type: 'dataElement',
object_id: obj.id,
object_code: obj.code,
object_name: obj.displayName,
object_form: obj.displayFormName,
object_description: obj.displayDescription,
objectGroup_id: temp_arr.objectGroup_id.join(', '),
objectGroup_code: temp_arr.objectGroup_code.join(', '),
objectGroup_name: temp_arr.objectGroup_name.join(', '),
service_id: temp_arr.service_id.join(', '),
service_code: temp_arr.service_code.join(', '),
service_name: temp_arr.service_name.join(', ')
};

}

});
//console.log('get_indicators refactored', temp);
$scope.loaded.get_indicators = true;
$scope.allObjects = Object.keys(temp).map(function(key) { return temp[key]; });

searchAllFactory.get_indicatorsDescriptions.query(function(response){
//console.log('get_indicatorsDescriptions', response);
response.indicators.forEach(function(obj) {

if(filterObjects(obj,"indicator")){
//console.log('get_dataElements refactored', temp);
$scope.loaded.get_dataElements = true;
$scope.loaded.get_dataElementsDescriptions = true;
$scope.loaded.get_dataElementsGroups = true;

temp[obj.id].object_den_description = $scope.getDenominator(obj);
temp[obj.id].object_den_ids = obj.denominator;
temp[obj.id].object_num_description = $scope.getNumerator(obj);
temp[obj.id].object_num_ids = obj.numerator;
temp[obj.id].object_description = $scope.getDescription(obj);
return "done";

}).then(function() {
return searchAllFactory.get_categoryOptionCombosAll.query().$promise.then(function(response){
response.categoryOptionCombos.forEach(function(obj) {
categoryOptionCombosTemp[obj.id] = {
id: obj.id,
object_name: obj.displayName
}

});
//console.log('get_indicatorsDescriptions refactored', temp);
$scope.loaded.get_indicatorsDescriptions = true;
$scope.allObjects = Object.keys(temp).map(function(key) { return temp[key]; });

});
searchAllFactory.get_indicatorGroups.query(function(response){
//console.log('get_indicatorGroups', response);
}).then(function(){
return searchAllFactory.get_indicatorsAll.query().$promise.then(function(response){
//console.log('get_indicators', response);
response.indicators.forEach(function(obj) {

if(filterObjects(obj,"indicator")){
Expand Down Expand Up @@ -363,22 +331,38 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope

});

temp[obj.id].objectGroup_id = temp_arr.objectGroup_id.join(', ');
temp[obj.id].objectGroup_code = temp_arr.objectGroup_code.join(', ');
temp[obj.id].objectGroup_name = temp_arr.objectGroup_name.join(', ');
temp[obj.id].service_id = temp_arr.service_id.join(', ');
temp[obj.id].service_code = temp_arr.service_code.join(', ');
temp[obj.id].service_name =temp_arr.service_name.join(', ');
temp[obj.id] = {
object_type: 'indicator',
object_id: obj.id,
object_code: obj.code,
object_name: obj.displayName,
object_form: obj.displayFormName,
object_den_description: $scope.getDenominator(obj),
object_den_ids: $scope.parseFormula(obj.denominator, temp, categoryOptionCombosTemp),
object_num_description: $scope.getNumerator(obj),
object_num_ids: $scope.parseFormula(obj.numerator,temp, categoryOptionCombosTemp),
object_description: $scope.getDescription(obj),
objectGroup_id: temp_arr.objectGroup_id.join(', '),
objectGroup_code: temp_arr.objectGroup_code.join(', '),
objectGroup_name: temp_arr.objectGroup_name.join(', '),
service_id: temp_arr.service_id.join(', '),
service_code: temp_arr.service_code.join(', '),
service_name: temp_arr.service_name.join(', ')
};

}

});
//console.log('get_indicatorGroups refactored', temp);
//console.log('get_indicators refactored', temp);
$scope.loaded.get_indicators = true;
$scope.loaded.get_indicatorsDescriptions = true;
$scope.loaded.get_indicatorGroups = true;
$scope.allObjects = Object.keys(temp).map(function(key) { return temp[key]; });

return "done";
});

}).then(function log(){
console.log("Loading time of search table: " + (Date.now() - start) + " milliseconds.");
});
}
});
Expand Down
Loading

0 comments on commit 59cdd64

Please sign in to comment.