Commit f805eeff authored by Adrien PARROT's avatar Adrien PARROT
Browse files

Factorization on searchPage Controller

parent 9fda2199
......@@ -100,6 +100,7 @@ sap.ui.controller("conceptmapper.mapperPage", {
},
algo_one : function (oEvt) {
sap.ui.getCore().byId("algo1Toggle").setPressed(true);
sap.ui.getCore().byId("algo2Toggle").setPressed(false);
sap.ui.getCore().byId("algo3Toggle").setPressed(false);
......
function getConceptsAjax(oData, oTable_ref, oRowsNumber) {
function setBasicResearchParams() {
//standard, valid, domain, voc, lang, mini, max, search
var oStandardMCB_ref = sap.ui.getCore().byId('oStandardMCB').getSelectedItems();
var oStandardMCB_list = [];
for (var i in oStandardMCB_ref) {
oStandardMCB_list.push(oStandardMCB_ref[i].getProperty('text'));
}
var oValidMCB_ref = sap.ui.getCore().byId('oValidMCB').getSelectedItems();
var oValidMCB_list = [];
for (var i in oValidMCB_ref) {
oValidMCB_list.push(oValidMCB_ref[i].getProperty('text'));
}
var oDomainMCB_ref = sap.ui.getCore().byId('oDomainMCB').getSelectedItems();
var oDomainMCB_list = [];
for (var i in oDomainMCB_ref) {
oDomainMCB_list.push(oDomainMCB_ref[i].getProperty('text'));
}
var oVocMCB_ref = sap.ui.getCore().byId('oVocMCB').getSelectedItems();
var oVocMCB_list = [];
for (var i in oVocMCB_ref) {
oVocMCB_list.push(oVocMCB_ref[i].getProperty('text'));
}
var oLangMCB_ref = sap.ui.getCore().byId('oLangMCB').getSelectedItems();
var oLangMCB_list = [];
for (var i in oLangMCB_ref) {
oLangMCB_list.push(oLangMCB_ref[i].getProperty('text'));
}
var oData = {};
oData.mini = parseInt(sap.ui.getCore().byId('oMiniIB').getProperty('value'));
oData.maxi = parseInt(sap.ui.getCore().byId('oMaxiIB').getProperty('value'));
oData.search_string = sap.ui.getCore().byId('searchField').getProperty('value');
// Standard => 'S' , Classification => 'C', Non-Standard => Null
oData.standard_concept = oStandardMCB_list;
// Valid => null, Deleted => 'D', Updated => 'U'
oData.invalid_reason = oValidMCB_list;
oData.domain_id = oDomainMCB_list;
oData.vocabulary_id = oVocMCB_list;
oData.m_language_id = oLangMCB_list;
// oData.user_id = [];
// oData.frequency_id = [];
var oRowsNumber = parseInt(sap.ui.getCore().byId('oRowInPageInput').getProperty('value'));
if (!isNaN(oRowsNumber) && Number.isInteger(oRowsNumber)) {
var oTable_ref = sap.ui.getCore().byId('oTable');
oData.limit = oRowsNumber;
}
return [oData, oTable_ref];
}
function getConceptsAjax(oData, oTable_ref) {
// var URL_concepts = "http://127.0.0.1:5000/api/concepts";
var URL_concepts = "http://omop-mapper.fgh.ovh/api/concepts";
......@@ -19,7 +84,7 @@ function getConceptsAjax(oData, oTable_ref, oRowsNumber) {
success: function(data) {
if (oData.limit) {
oTable_ref.setVisibleRowCount(oRowsNumber);
oTable_ref.setVisibleRowCount(oData.limit);
}
console.log(data);
......@@ -86,14 +151,14 @@ function getConceptsMapperAjax(oData) {
var concept = data.docs[i];
concept.concept_name = concept.concept_name.replace(/<strong>/g, '').replace(/<\/strong>/g, '');
if (concept.concept_id >= 2000000000 && concept.is_mapped == 'S') {
concept.status = 'Success';
} else if (concept.concept_id >= 2000000000 &&
(concept.is_mapped == 'NS' || concept.is_mapped == 'R')){
concept.status = 'Warning';
} else {
concept.status = 'None';
}
// if (concept.concept_id >= 2000000000 && concept.is_mapped == 'S') {
// concept.status = 'Success';
// } else if (concept.concept_id >= 2000000000 &&
// (concept.is_mapped == 'NS' || concept.is_mapped == 'R')){
// concept.status = 'Warning';
// } else {
// concept.status = 'None';
// }
// Vert : Success
......@@ -154,77 +219,26 @@ var oItemTemplateStandard = new sap.ui.core.Item({
});
sap.ui.controller("conceptmapper.searchPage", {
searcher : function (oEvt, first) {
var oStandardMCB_ref = sap.ui.getCore().byId('oStandardMCB').getSelectedItems();
var oStandardMCB_list = [];
for (var i in oStandardMCB_ref) {
oStandardMCB_list.push(oStandardMCB_ref[i].getProperty('text'));
}
var oValidMCB_ref = sap.ui.getCore().byId('oValidMCB').getSelectedItems();
var oValidMCB_list = [];
for (var i in oValidMCB_ref) {
oValidMCB_list.push(oValidMCB_ref[i].getProperty('text'));
}
var oDomainMCB_ref = sap.ui.getCore().byId('oDomainMCB').getSelectedItems();
var oDomainMCB_list = [];
for (var i in oDomainMCB_ref) {
oDomainMCB_list.push(oDomainMCB_ref[i].getProperty('text'));
}
searcher : function (oEvt) {
var oVocMCB_ref = sap.ui.getCore().byId('oVocMCB').getSelectedItems();
var oVocMCB_list = [];
for (var i in oVocMCB_ref) {
oVocMCB_list.push(oVocMCB_ref[i].getProperty('text'));
}
var oLangMCB_ref = sap.ui.getCore().byId('oLangMCB').getSelectedItems();
var oLangMCB_list = [];
for (var i in oLangMCB_ref) {
oLangMCB_list.push(oLangMCB_ref[i].getProperty('text'));
}
if (first !== 'undefined' && first === 1) {
oLangMCB_list = ['FR'];
}
var oRowsNumber = parseInt(sap.ui.getCore().byId('oRowInPageInput').getProperty('value'));
var oData = {};
if (!isNaN(oRowsNumber) && Number.isInteger(oRowsNumber)) {
var oTable_ref = sap.ui.getCore().byId('oTable');
oData.limit = oRowsNumber;
}
oData.mini = parseInt(sap.ui.getCore().byId('oMiniIB').getProperty('value'));
oData.maxi = parseInt(sap.ui.getCore().byId('oMaxiIB').getProperty('value'));
oData.search_string = sap.ui.getCore().byId('searchField').getProperty('value');
// Standard => 'S' , Classification => 'C', Non-Standard => Null
oData.standard_concept = oStandardMCB_list;
// Valid => null, Deleted => 'D', Updated => 'U'
oData.invalid_reason = oValidMCB_list;
oData.domain_id = oDomainMCB_list;
oData.vocabulary_id = oVocMCB_list;
oData.m_language_id = oLangMCB_list;
// oData.user_id = [];
// oData.frequency_id = [];
//debugger;
//Set basic params : standard, valid, domain, voc, lang, mini, max, search, row number
var list = setBasicResearchParams();
var oData = list[0];
var oTable_ref = list[1];
parseInt(sap.ui.getCore().byId('oSearchFielGoToPage').resetProperty('value'));
// GET AJAX call on conceptSSSSS
getConceptsAjax(oData, oTable_ref, oRowsNumber);
getConceptsAjax(oData, oTable_ref);
var oModel = sap.ui.getCore().getModel('conceptsModel');
var aPageFound = oModel.getProperty("/page_found");
......@@ -243,7 +257,6 @@ sap.ui.controller("conceptmapper.searchPage", {
sap.ui.getCore().byId('oButtonCurrentPage').setText(buttonTextShown);
sap.ui.getCore().byId('oButtonTotalPages').setText(buttonTextFound);
// GET AJAX call on conceptSSSSS
},
......@@ -251,71 +264,24 @@ sap.ui.controller("conceptmapper.searchPage", {
prevPage : function (oEvt) {
var oStandardMCB_ref = sap.ui.getCore().byId('oStandardMCB').getSelectedItems();
var oStandardMCB_list = [];
for (var i in oStandardMCB_ref) {
oStandardMCB_list.push(oStandardMCB_ref[i].getProperty('text'));
}
var oValidMCB_ref = sap.ui.getCore().byId('oValidMCB').getSelectedItems();
var oValidMCB_list = [];
for (var i in oValidMCB_ref) {
oValidMCB_list.push(oValidMCB_ref[i].getProperty('text'));
}
var oDomainMCB_ref = sap.ui.getCore().byId('oDomainMCB').getSelectedItems();
var oDomainMCB_list = [];
for (var i in oDomainMCB_ref) {
oDomainMCB_list.push(oDomainMCB_ref[i].getProperty('text'));
}
var oVocMCB_ref = sap.ui.getCore().byId('oVocMCB').getSelectedItems();
var oVocMCB_list = [];
for (var i in oVocMCB_ref) {
oVocMCB_list.push(oVocMCB_ref[i].getProperty('text'));
}
var oLangMCB_ref = sap.ui.getCore().byId('oLangMCB').getSelectedItems();
var oLangMCB_list = [];
for (var i in oLangMCB_ref) {
oLangMCB_list.push(oLangMCB_ref[i].getProperty('text'));
}
//Set basic params : standard, valid, domain, voc, lang, mini, max, search, row number
var list = setBasicResearchParams();
var oData = list[0];
var oTable_ref = list[1];
var oRowsNumber = parseInt(sap.ui.getCore().byId('oRowInPageInput').getProperty('value'));
var oData = {};
if (!isNaN(oRowsNumber) && Number.isInteger(oRowsNumber)) {
var oTable_ref = sap.ui.getCore().byId('oTable');
oData.limit = oRowsNumber;
}
oData.mini = parseInt(sap.ui.getCore().byId('oMiniIB').getProperty('value'));
oData.maxi = parseInt(sap.ui.getCore().byId('oMaxiIB').getProperty('value'));
oData.search_string = sap.ui.getCore().byId('searchField').getProperty('value');
// Standard => 'S' , Classification => 'C', Non-Standard => Null
oData.standard_concept = oStandardMCB_list;
// Valid => null, Deleted => 'D', Updated => 'U'
oData.invalid_reason = oValidMCB_list;
oData.domain_id = oDomainMCB_list;
oData.vocabulary_id = oVocMCB_list;
oData.m_language_id = oLangMCB_list;
// oData.user_id = [];
// oData.frequency_id = [];
var oModel = sap.ui.getCore().getModel('conceptsModel');
var aPageShown = oModel.getProperty("/page_shown");
oData.page = aPageShown;
if (oData.page <= 1) {
sap.ui.getCore().byId('oButtonPrev').setEnabled(false);
}
sap.ui.getCore().byId('oButtonNext').setEnabled(true);
getConceptsAjax(oData, oTable_ref, oRowsNumber);
getConceptsAjax(oData, oTable_ref);
buttonTextShown = 'Current page : ' + oData.page;
//buttonTextFound = 'Total page(s) : ' + aPageFound;
......@@ -331,62 +297,11 @@ sap.ui.controller("conceptmapper.searchPage", {
nextPage : function (oEvt) {
var oStandardMCB_ref = sap.ui.getCore().byId('oStandardMCB').getSelectedItems();
var oStandardMCB_list = [];
for (var i in oStandardMCB_ref) {
oStandardMCB_list.push(oStandardMCB_ref[i].getProperty('text'));
}
//Set basic params : standard, valid, domain, voc, lang, mini, max, search, row number
var list = setBasicResearchParams();
var oData = list[0];
var oTable_ref = list[1];
var oValidMCB_ref = sap.ui.getCore().byId('oValidMCB').getSelectedItems();
var oValidMCB_list = [];
for (var i in oValidMCB_ref) {
oValidMCB_list.push(oValidMCB_ref[i].getProperty('text'));
}
var oDomainMCB_ref = sap.ui.getCore().byId('oDomainMCB').getSelectedItems();
var oDomainMCB_list = [];
for (var i in oDomainMCB_ref) {
oDomainMCB_list.push(oDomainMCB_ref[i].getProperty('text'));
}
var oVocMCB_ref = sap.ui.getCore().byId('oVocMCB').getSelectedItems();
var oVocMCB_list = [];
for (var i in oVocMCB_ref) {
oVocMCB_list.push(oVocMCB_ref[i].getProperty('text'));
}
var oLangMCB_ref = sap.ui.getCore().byId('oLangMCB').getSelectedItems();
var oLangMCB_list = [];
for (var i in oLangMCB_ref) {
oLangMCB_list.push(oLangMCB_ref[i].getProperty('text'));
}
var oRowsNumber = parseInt(sap.ui.getCore().byId('oRowInPageInput').getProperty('value'));
var oData = {};
if (!isNaN(oRowsNumber) && Number.isInteger(oRowsNumber)) {
var oTable_ref = sap.ui.getCore().byId('oTable');
oData.limit = oRowsNumber;
}
oData.mini = parseInt(sap.ui.getCore().byId('oMiniIB').getProperty('value'));
oData.maxi = parseInt(sap.ui.getCore().byId('oMaxiIB').getProperty('value'));
oData.search_string = sap.ui.getCore().byId('searchField').getProperty('value');
// Standard => 'S' , Classification => 'C', Non-Standard => Null
oData.standard_concept = oStandardMCB_list;
// Valid => null, Deleted => 'D', Updated => 'U'
oData.invalid_reason = oValidMCB_list;
oData.domain_id = oDomainMCB_list;
oData.vocabulary_id = oVocMCB_list;
oData.m_language_id = oLangMCB_list;
// oData.user_id = [];
// oData.frequency_id = [];
var oModel = sap.ui.getCore().getModel('conceptsModel');
var aPageShown = oModel.getProperty("/page_shown");
var aPageFound = oModel.getProperty("/page_found");
......@@ -399,7 +314,7 @@ sap.ui.controller("conceptmapper.searchPage", {
oData.page = aPageShown + 2;
getConceptsAjax(oData, oTable_ref, oRowsNumber);
getConceptsAjax(oData, oTable_ref);
buttonTextShown = 'Current page : ' + oData.page;
//buttonTextFound = 'Total page(s) : ' + aPageFound;
......@@ -414,68 +329,20 @@ sap.ui.controller("conceptmapper.searchPage", {
searcherGoToPage : function (oEvt) {
var oStandardMCB_ref = sap.ui.getCore().byId('oStandardMCB').getSelectedItems();
var oStandardMCB_list = [];
for (var i in oStandardMCB_ref) {
oStandardMCB_list.push(oStandardMCB_ref[i].getProperty('text'));
}
var oValidMCB_ref = sap.ui.getCore().byId('oValidMCB').getSelectedItems();
var oValidMCB_list = [];
for (var i in oValidMCB_ref) {
oValidMCB_list.push(oValidMCB_ref[i].getProperty('text'));
}
var oDomainMCB_ref = sap.ui.getCore().byId('oDomainMCB').getSelectedItems();
var oDomainMCB_list = [];
for (var i in oDomainMCB_ref) {
oDomainMCB_list.push(oDomainMCB_ref[i].getProperty('text'));
}
var oVocMCB_ref = sap.ui.getCore().byId('oVocMCB').getSelectedItems();
var oVocMCB_list = [];
for (var i in oVocMCB_ref) {
oVocMCB_list.push(oVocMCB_ref[i].getProperty('text'));
}
var oLangMCB_ref = sap.ui.getCore().byId('oLangMCB').getSelectedItems();
var oLangMCB_list = [];
for (var i in oLangMCB_ref) {
oLangMCB_list.push(oLangMCB_ref[i].getProperty('text'));
}
var list = setBasicResearchParams();
var oData = list[0];
var oTable_ref = list[1];
var oRowsNumber = parseInt(sap.ui.getCore().byId('oRowInPageInput').getProperty('value'));
var oData = {};
if (!isNaN(oRowsNumber) && Number.isInteger(oRowsNumber)) {
var oTable_ref = sap.ui.getCore().byId('oTable');
oData.limit = oRowsNumber;
}
oData.mini = parseInt(sap.ui.getCore().byId('oMiniIB').getProperty('value'));
oData.maxi = parseInt(sap.ui.getCore().byId('oMaxiIB').getProperty('value'));
oData.page = parseInt(sap.ui.getCore().byId('oSearchFielGoToPage').getProperty('value'));
if (oData.page <= 0) {
oData.page = 1;
}
oData.search_string = sap.ui.getCore().byId('searchField').getProperty('value');
// Standard => 'S' , Classification => 'C', Non-Standard => Null
oData.standard_concept = oStandardMCB_list;
// Valid => null, Deleted => 'D', Updated => 'U'
oData.invalid_reason = oValidMCB_list;
oData.domain_id = oDomainMCB_list;
oData.vocabulary_id = oVocMCB_list;
oData.m_language_id = oLangMCB_list;
// oData.user_id = [];
// oData.frequency_id = [];
// GET AJAX call on conceptSSSSS
getConceptsAjax(oData, oTable_ref, oRowsNumber);
getConceptsAjax(oData, oTable_ref);
var oModel = sap.ui.getCore().getModel('conceptsModel');
......@@ -539,11 +406,8 @@ sap.ui.controller("conceptmapper.searchPage", {
var search_string = "";
for (var i in idx) {
//console.log(idx[i]);
//var concept = oTable_ref.getRows()[idx[i]].getCells();
debugger;
var domain_id = oTable_ref.getRows()[idx[i]].getCells()[7].getProperty('text');
console.log(domain_id);
oDomainMCB_list.indexOf(domain_id) === -1 ? oDomainMCB_list.push(domain_id):console.log("This item already exists");
......@@ -574,17 +438,7 @@ sap.ui.controller("conceptmapper.searchPage", {
console.log(error);
}
})
// listToMap.push({
// "concept_id": concept[0].getProperty('text'),
//
// // peut etre a enlever et faire une requete AJAX pour avoir la traduction
// "concept_name": concept[1].getProperty('htmlText').replace(/<strong>/g, '').replace(/<\/strong>/g, ''),
// "vocabulary_id": concept[4].getProperty('text'),
// "domain_id": concept[7].getProperty('text'),
// });
}
var oData = {"to_map": listToMap, "to_map_number": idx.length};
......@@ -593,83 +447,15 @@ sap.ui.controller("conceptmapper.searchPage", {
sap.ui.getCore().setModel(oModel, "conceptsDetailModel");
console.log("searcher: ", search_string);
// mapperModel to construct
// var oStandardMCB_ref = sap.ui.getCore().byId('oStandardMapperMCB').getSelectedItems();
// debase = Standard
var oStandardMCB_list = ["Standard"];
// for (var i in oStandardMCB_ref) {
// oStandardMCB_list.push(oStandardMCB_ref[i].getProperty('text'));
// }
//
// var oDomainMCB_ref = sap.ui.getCore().byId('oDomainMapperMCB').getSelectedItems();
// var oDomainMCB_list = [];
// for (var i in oDomainMCB_ref) {
// oDomainMCB_list.push(oDomainMCB_ref[i].getProperty('text'));
// }
// var oVocMCB_ref = sap.ui.getCore().byId('oVocMapperMCB').getSelectedItems();
// var oVocMCB_list = [];
// for (var i in oVocMCB_ref) {
// oVocMCB_list.push(oVocMCB_ref[i].getProperty('text'));
// }
// var oLangMCB_ref = sap.ui.getCore().byId('oLangMCB').getSelectedItems();
// var oLangMCB_list = [];
// for (var i in oLangMCB_ref) {
// oLangMCB_list.push(oLangMCB_ref[i].getProperty('text'));
// }
//
// if (first !== 'undefined' && first === 1) {
// oLangMCB_list = ['FR'];
// }
// var oRowsNumber = parseInt(sap.ui.getCore().byId('oRowInPageInput').getProperty('value'));
var oData = {};
//
// if (!isNaN(oRowsNumber) && Number.isInteger(oRowsNumber)) {
// var oTable_ref = sap.ui.getCore().byId('oTable');
// oData.limit = oRowsNumber;
// }
// oData.mini = parseInt(sap.ui.getCore().byId('oMiniIB').getProperty('value'));
// oData.maxi = parseInt(sap.ui.getCore().byId('oMaxiIB').getProperty('value'));
oData.search_string = search_string;
// Standard => 'S' , Classification => 'C', Non-Standard => Null
oData.standard_concept = oStandardMCB_list;
// Valid => null, Deleted => 'D', Updated => 'U'
// oData.invalid_reason = oValidMCB_list;
oData.standard_concept = ['Standard'];
oData.domain_id = oDomainMCB_list;
// oData.vocabulary_id = oVocMCB_list;
// oData.m_language_id = oLangMCB_list;
// oData.user_id = [];
// oData.frequency_id = [];
//debugger;
oData.limit = 50;
//parseInt(sap.ui.getCore().byId('oSearchFielGoToPage').resetProperty('value'));
getConceptsMapperAjax(oData);
var oModel = new sap.ui.model.json.JSONModel(oData);
......@@ -1144,10 +930,6 @@ sap.ui.controller("conceptmapper.searchPage", {
"key" : "200",
"text" : "200"
},
// {
// "key" : "EN",
// "text" : "EN"
// }
]
};
oModel.setData(mData);
......@@ -1171,6 +953,26 @@ sap.ui.controller("conceptmapper.searchPage", {
sap.ui.getCore().setModel(oModel, "language");
var oModel = new sap.ui.model.json.JSONModel();
var mData = {
"selected" : [],
"items" : [{
"key" : "Standard",
"text" : "Standard"
},
{
"key" : "Non-Standard",
"text" : "Non-Standard"
},
{
"key" : "Not mapped",
"text" : "Not Mapped"
}
]
};
oModel.setData(mData);
sap.ui.getCore().setModel(oModel, "mapToModel");
var oModel = new sap.ui.model.json.JSONModel();
var mData = {
......
......@@ -129,6 +129,24 @@ sap.ui.jsview("conceptmapper.searchPage", {
},