Commit 9fda2199 authored by Adrien PARROT's avatar Adrien PARROT
Browse files

Begin of mapper page. change in searchPage

parent 6b96b084
......@@ -38,6 +38,15 @@ sap.ui.jsview("conceptmapper.conceptDetailPage", {
// })
// CONCEPT PANEL
// var synonymsString = "";
// var synonymsList = sap.ui.getCore().getModel('conceptDetailModel').oData.synonyms;
// for (var id in synonymsList) {
// if (synonymsString.length > 0) {
// synonymsString += ", ";
// }
// synonymsString = synonymsList[id].concept_synonym_name
// }
var oConceptPanelHeader = new sap.m.ObjectListItem(
"oConceptPanelHeader", {
// title : "Responsive ObjectHeader with attributes",
......@@ -68,6 +77,11 @@ sap.ui.jsview("conceptmapper.conceptDetailPage", {
}), new sap.m.ObjectAttribute({
title : "domain_id",
text : "{conceptDetailModel>/domain_id}",
}), new sap.m.ObjectAttribute({
title : "synonyms",
text: "{conceptDetailModel>/synonyms}",
wrapping : true
}),
]
......@@ -81,51 +95,226 @@ sap.ui.jsview("conceptmapper.conceptDetailPage", {
// RELATION PANEL
var oRelationList = new sap.m.List("oRelationList", {
// headerText : "relations list",
});
oRelationList.bindItems({
path : "conceptDetailModel>/relations",
template : new sap.m.ObjectListItem({
title : "{conceptDetailModel>concept_name}",
number : "{conceptDetailModel>standard_concept}",
numberUnit : "{conceptDetailModel>invalid_reason}",
type:"Active",
// var oRelationList = new sap.m.List("oRelationList", {
//// headerText : "relations list",
// });
// oRelationList.bindItems({
// path : "conceptDetailModel>/relations",
// template : new sap.m.ObjectListItem({
// title : "{conceptDetailModel>concept_name}",
// number : "{conceptDetailModel>standard_concept}",
// numberUnit : "{conceptDetailModel>invalid_reason}",
//
// type:"Active",
//
// press: [oController.goToConceptDetailol, oController ],
//
// attributes : [
// new sap.m.ObjectAttribute({
// title : "concept_id",
// text : "{conceptDetailModel>concept_id}",
//// active : true,
//// press : function() {
//// alert("you press me");
//// }
// }), new sap.m.ObjectAttribute({
// title : "concept_code",
// text : "{conceptDetailModel>concept_code}",
//
// }), new sap.m.ObjectAttribute({
// title : "concept_class_id",
// text : "{conceptDetailModel>concept_class_id}",
//// active : true,
// }), new sap.m.ObjectAttribute({
// title : "vocabulary_id",
// text : "{conceptDetailModel>vocabulary_id}",
// }), new sap.m.ObjectAttribute({
// title : "domain_id",
// text : "{conceptDetailModel>domain_id}",
// }), new sap.m.ObjectAttribute({
// title : "relationship_id",
// text : "{conceptDetailModel>relationship_id}",
// }),
//
// ]
// })
// });
press: [oController.goToConceptDetailol, oController ],
var aColumns = [
new sap.m.Column({
header : new sap.m.Label({
text : "Relationship_id"
}),
mergeDuplicates: true
}),
new sap.m.Column({
header : new sap.m.Label({
text : "Relates to domain"
}),
// width : '60%',
attributes : [
new sap.m.ObjectAttribute({
title : "concept_id",
text : "{conceptDetailModel>concept_id}",
// active : true,
// press : function() {
// alert("you press me");
// }
}), new sap.m.ObjectAttribute({
title : "concept_code",
text : "{conceptDetailModel>concept_code}",
}), new sap.m.ObjectAttribute({
title : "concept_class_id",
text : "{conceptDetailModel>concept_class_id}",
// active : true,
}), new sap.m.ObjectAttribute({
title : "vocabulary_id",
text : "{conceptDetailModel>vocabulary_id}",
}), new sap.m.ObjectAttribute({
title : "domain_id",
text : "{conceptDetailModel>domain_id}",
}), new sap.m.ObjectAttribute({
title : "relationship_id",
}),
new sap.m.Column({
header : new sap.m.Label({
text : "Relates to vocabulary"
})
}),
new sap.m.Column({
header : new sap.m.Label({
text : "Concept_id"
})
}),
new sap.m.Column({
header : new sap.m.Link({
text : "Concept_name"
}),
}),
new sap.m.Column({
header : new sap.m.Label({
text : "Standard"
}),
}),
new sap.m.Column({
header : new sap.m.Label({
text : "Valid"
}),
}),
];
var oTemplate = new sap.m.ColumnListItem({
//vAlign: "Middle",
//type : sap.m.ListType.Active,
type: "Active",
// detailPress: function() {
// sap.m.MessageToast.show("detail is predsdsssed");
// },
cells : [
new sap.m.Text({
text : "{conceptDetailModel>relationship_id}",
wrapping : false
}),
new sap.m.Text({
text : "{conceptDetailModel>domain_id}",
wrapping : true
}),
new sap.m.Text({
text : "{conceptDetailModel>vocabulary_id}",
wrapping : false
}),
new sap.m.Text({
text : "{conceptDetailModel>concept_id}",
wrapping : false
}),
new sap.m.Text({
text : "{conceptDetailModel>concept_name}",
wrapping : false
}),
new sap.m.Text({
text : "{conceptDetailModel>standard_concept}",
wrapping : false
}),
new sap.m.Text({
text : "{conceptDetailModel>invalid_reason}",
wrapping : false
}),
]
});
var oTableHeader = new sap.m.Toolbar({
content : [
new sap.m.Title({
text : "Choose a relation concept and click on the concept to map"
}),
new sap.m.ToolbarSpacer(),
new sap.m.Label({
text:"Choose the relation"
}),
]
})
//oRelationMapperMCB,
]
});
var oTable = new sap.m.Table({
growing: true,
growingThreshold: 10,
//growingScrollToLoad : true,
//footerText : "Static table footer text",
//headerToolbar : oTableHeader,
//infoToolbar : oTableInfo,
// swipeContent : oSwipe,
columns : aColumns,
// selectionChange : function(e) {
// sap.m.MessageToast.show("selection is changed");
// },
// "delete" : function(oEvent) {
// var oItem = oEvent.getParameter("listItem");
// sap.m.MessageBox.confirm("Are you sure to delete this record?", {
// onClose: function(sResult){
// if (sResult == sap.m.MessageBox.Action.CANCEL) {
// return;
// }
// oTable.removeItem(oItem);
// setTimeout(function() {
// oTable.focus();
// }, 0);
// }
// });
// },
itemPress : [ oController.mapper, oController ],
// itemPress : function(e) {
// sap.m.MessageToast.show("item is pressed");
// debugger;
// },
// paste: applyPastedData
});
oTable.bindItems({
path: "conceptDetailModel>/relations",
template : oTemplate,
key: "id"
});
//
//
//
//
//
//
//
//
//
//
var oHeaderPanel = new sap.m.Panel("oHeaderPanel", {
expandable : true,
......@@ -135,19 +324,19 @@ sap.ui.jsview("conceptmapper.conceptDetailPage", {
]
});
var oCommentPanel = new sap.m.Panel("oCommentPanel", {
expandable : true,
expanded : false,
headerText : "Add comment",
content : [ oConceptPanelComment
]
});
// var oCommentPanel = new sap.m.Panel("oCommentPanel", {
// expandable : true,
// expanded : false,
// headerText : "Add comment",
// content : [ oConceptPanelComment
//
// ]
// });
var oContentPanel = new sap.m.Panel("oContentPanel", {
expandable : false,
expanded : true,
headerText : "Relations table",
content : [ oRelationList ]
headerText : "Relationships table",
content : [ oTable ]
});
var oPage = new sap.m.Page({
......
function getConceptAjax(sVal) {
// var URL_concept = "http://127.0.0.1:5000/api/concept/";
var URL_concept = "http://omop-mapper.fgh.ovh/api/concept/";
if (sVal !== undefined) {
$.ajax({
type:"GET",
url: URL_concept + sVal,
dataType:"json",
async: false,
header: {
"Content-Type": "application/json",
},
success: function(oData, response, xhr) {
var oModel = new sap.ui.model.json.JSONModel(oData);
sap.ui.getCore().setModel(oModel, "conceptDetailModel");
console.log("connection");
},
error : function(error) {
alert("pb in the connection");
console.log(error);
}
})}
}
function getConceptsMapperAjax(oData) {
// var URL_concepts = "http://127.0.0.1:5000/api/concepts";
var URL_concepts = "http://omop-mapper.fgh.ovh/api/concepts";
console.log("concepts");
$.ajax({
type:"GET",
url:URL_concepts,
dataType:"json",
data: {"json" : JSON.stringify(oData)},
async: false,
//processData: false,
header: {
"Content-Type": "application/json",
},
success: function(data) {
//oData.limit = 50;
console.log(data);
debugger;
for (var i = 0; i < data.docs.length; i++) {
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';
}
// Vert : Success
// Orange : Warning
// Rouge : Error
// Bleu : Information
}
var oModel = new sap.ui.model.json.JSONModel(data);
sap.ui.getCore().setModel(oModel, "conceptsMapperModel");
console.log("connection");
},
error : function(error) {
sap.m.MessageToast.show("Connexion error");
console.log(error);
}
});
}
sap.ui.controller("conceptmapper.mapperPage", {
goToConceptDetail : function (oEvt) {
// GET AJAX call on concept
getConceptAjax(oEvt.getSource().getProperty('text'));
debugger;
app.to('idConceptDetailPage', 'slide'); //('fade', 'flip', 'show', 'slide =default')
},
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);
algo1Toggle
},
algo_two : function (oEvt) {
sap.ui.getCore().byId("algo1Toggle").setPressed(false);
sap.ui.getCore().byId("algo2Toggle").setPressed(true);
sap.ui.getCore().byId("algo3Toggle").setPressed(false);
},
algo_three : function (oEvt) {
sap.ui.getCore().byId("algo1Toggle").setPressed(false);
sap.ui.getCore().byId("algo2Toggle").setPressed(false);
sap.ui.getCore().byId("algo3Toggle").setPressed(true);
},
searcher : function() {
// mapperModel to construct
var oStandardMCB_ref = sap.ui.getCore().byId('oStandardMapperMCB').getSelectedItems();
var oStandardMCB_list = [];
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.limit = 50;
oData.search_string = sap.ui.getCore().byId('searchFieldMapper').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;
//parseInt(sap.ui.getCore().byId('oSearchFielGoToPage').resetProperty('value'));
getConceptsMapperAjax(oData);
var oModel = new sap.ui.model.json.JSONModel(oData);
sap.ui.getCore().setModel(oModel, "searchFieldMapperModel");
},
mapper : function(oEvt) {
// var URL_concept_relationship = "http://omop-mapper.fgh.ovh/api/concept_relationship/";
var URL_concept_relationship = "http://127.0.0.1:5000/concept_relationship/";
// conceptsDetailModel
var concepts = sap.ui.getCore().getModel('conceptsDetailModel').oData.to_map;
var oData = {};
oData.concept_id_2 = oEvt.getParameters().srcControl.getAggregation('cells')[0].getProperty('text');
oData.relationship_id = 'Maps to';
debugger;
for (var id in concepts) {
debugger;
$.ajax({
type:"POST",
url: URL_concept_relationship + concepts[id].concept_id,
dataType:"json",
async: false,
data: oData,
header: {
"Content-Type": "application/json",
},
success: function(oData, response, xhr) {
debugger;
var ret = "Item(s) mapped to " + concepts[id].concept_id
sap.m.MessageToast.show(ret);
console.log("connection");
},
error : function(error) {
alert("pb in the connection");
console.log(error);
}
});
}
},
/**
* Called when a controller is instantiated and its View controls (if available) are already created.
* Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.
* @memberOf conceptmapper.mapperPage
*/
onInit: function() {
var oModel = new sap.ui.model.json.JSONModel();
var mData = {
"selected" : ['Maps to'],
"items" : [{
"key" : "Maps to",
"text" : "Maps to"
},
{
"key" : "Mapped from",
"text" : "Mapped from"
}]
};
oModel.setData(mData);
sap.ui.getCore().setModel(oModel, "relationsModel");
},
/**
* Similar to onAfterRendering, but this hook is invoked before the controller's View is re-rendered
* (NOT before the first rendering! onInit() is used for that one!).
* @memberOf conceptmapper.mapperPage
*/
// onBeforeRendering: function() {
//
// },
/**
* Called when the View has been rendered (so its HTML is part of the document). Post-rendering manipulations of the HTML could be done here.
* This hook is the same one that SAPUI5 controls get after being rendered.