Commit 6977cfef authored by Romain Loth's avatar Romain Loth

reconnected settings choice for topPapers API 'localDB'

parent c2af00d8
......@@ -9,13 +9,16 @@ $TITLE="ISITITLE";
$query = str_replace( '__and__', '&', $_GET["query"] );
$elems = json_decode($query);
$table = "";
$column = "";
$id="";
$twjs=end( explode("/",getcwd()) )."/"; // LOCALDB folder.
// $twjs=end( explode("/",getcwd()) )."/"; // LOCALDB folder.
$twjs="LOCALDB/"; // LOCALDB folder.
// echo("count(elems): ".count($elems)."<br/>");
// echo("elems[0]: ".$elems[0]."<br/>");
// echo("is_array($elems): ".is_array($elems)."<br/>");
if($type=="social"){
$table = "ISIAUTHOR";
......@@ -54,6 +57,7 @@ if (count($elems)==1){// un seul mot est sélectionné, on compte les mots multi
$factor=ceil(count($elems)/5); //les scores sont moins haut
$sql='';
foreach($elems as $elem){
// echo("elem: ".$elem."<br/>");
$sql.=' '.$column.'="'.$elem.'" OR ';
}
$sql=substr($sql, 0, -3);
......@@ -70,6 +74,7 @@ $sum=0;
// echo "<br>";
// echo "$sql";
// echo "<br>";
//The final query!
......
......@@ -12,6 +12,9 @@
include('parameters_details.php');
$max_item_displayed=6;
echo('graphdb: '. $graphdb.'<br/>');
$base = new PDO("sqlite:../" .$graphdb);
include('default_div.php');
......
<?php
# £TODO WTF ??? => move params to settings_explorerjs ???
# loading an associated db for a given gexf as relatedDocs php API
$gexf_db = array();
# $gexf_db["data/terrorism/terrorism_bi.gexf"] = "data/terrorism/data.db";
......@@ -15,7 +14,7 @@ $gexf_db["data/AXA/RiskV2PageRank5000.gexf"] = "data/AXA/data.db";
// TESTS
$gexf_db["data/ProgrammeDesCandidats.gexf"] = "foobar";
// $gexf_db["data/ProgrammeDesCandidats.gexf"] = "foobar";
$gexf= str_replace('"','',$_GET["gexf"]);
......
......@@ -8,11 +8,11 @@
"gexfs": {
"ProgrammeDesCandidats.enrichi.gexf": {
"social": {},
"semantic": {"table":"terms"}
"semantic": {}
},
"ProgrammeDesCandidats.gexf": {
"social": {},
"semantic": {"table":"terms"}
"semantic": {}
}
}
},
......@@ -33,8 +33,14 @@
"data/AXA": {
"first" : "RiskV2PageRank1000.gexf",
"gexfs": {
"RiskV2PageRank1000.gexf": {},
"RiskV2PageRank5000.gexf": {}
"RiskV2PageRank1000.gexf": {
"social": { "table":"ISIAUTHOR" , "textCol":"data","forkeyCol":"id"},
"semantic": { "table":"ISItermsAxa_2015" , "textCol":"data","forkeyCol":"id"}
},
"RiskV2PageRank5000.gexf": {
"social": { "table":"ISIAUTHOR" , "textCol":"data","forkeyCol":"id"},
"semantic": { "table":"ISItermsAxa_2015" , "textCol":"data","forkeyCol":"id"}
}
}
}
}
......@@ -347,15 +347,11 @@ function set_ClustersLegend ( daclass, groupedByTicks ) {
// NB: this variant only for nodetype semantic
function getTopPapers(nodetypeLegacy){
if (nodetypeLegacy == 'semantic' && TW.conf.getRelatedDocs) {
if (TW.conf.getRelatedDocs) {
jsonparams=getSelections();
var joined_q = jsonparams.map(function(w) {return '('+w+')'}).join(' AND ')
// console.log(jsonparams)
// theHtml = "<p> jsonparams:"+jsonparams+" </p>"
//
if (TW.conf.relatedDocsType == "twitter") {
// POSS remove restriction on 'semantic' nodes for twitter results about authors
if (nodetypeLegacy == 'semantic') {
$.ajax({
type: 'GET',
url: TW.conf.relatedDocsAPI,
......@@ -384,6 +380,45 @@ function getTopPapers(nodetypeLegacy){
}
});
}
}
else if (TW.conf.relatedDocsType == "wosLocalDB") {
let thisgexf= TW.File;
let gexfinfos = TW.fields[thisgexf]
if (!gexfinfos || !gexfinfos[nodetypeLegacy]) {
$("#topPapers").show();
$("#topPapers").html(
`<p>Your settings for relatedDocsType are set on a local wos database, but your servermenu file does not provide any information about the wosLocalDB table to query for related documents on nodetype ${nodetypeLegacy}</p>`
);
}
else {
let jsonparams=JSON.stringify(TW.SystemState().selectionNids.map(function(nid){return TW.Nodes[nid].label}));
let bi=(TW.categories.length==2)?1:0;
jsonparams = jsonparams.split('&').join('__and__');
let querytable = gexfinfos[nodetypeLegacy]
let image='<img style="display:block; margin: 0px auto;" src="libs/img2/loader.gif"></img>';
$("#topPapers").show();
$("#topPapers").html(image);
$.ajax({
type: 'GET',
url: 'LOCALDB/info_div.php',
data: "type="+nodetypeLegacy+"&bi="+bi+"&query="+jsonparams+"&gexf="+thisgexf+"&index="+querytable,
//contentType: "application/json",
//dataType: 'json',
success : function(data){
console.log('LOCALDB/info_div.php?'+"type="+nodetypeLegacy+"&bi="+bi+"&query="+jsonparams+"&gexf="+thisgexf+"&index="+querytable);
$("#topPapers").html(data);
},
error: function(){
console.log('Page Not found: getTopPapers');
}
});
}
}
}
}
function newPopup(url) {
popupWindow = window.open(url,'popUpWindow','height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=no')
}
function clickInsideTweet(e, tweetSrcUrl) {
......
......@@ -36,9 +36,8 @@ TW.conf = (function(TW){
TWConf.getRelatedDocs = true
TWConf.relatedDocsAPI = "http://127.0.0.1:5000/twitter_search"
// £TODO : allow to choose between twitter or elasticsearch topPapers (choic of post-process function in extras_explorer)
// TWConf.relatedDocsType
TWConf.relatedDocsType = "wosLocalDB" // accepted: "twitter" | "wosLocalDB"
// POSSible: "elastic"
// =======================
// DATA FACETS AND LEGENDS
......
......@@ -978,5 +978,6 @@ function jsActionOnGexfSelector(gexfBasename){
mainStartGraph(newDataRes["format"], newDataRes["data"], TW.instance)
writeLabel(gexfBasename)
TW.File = gexfPath
}
//============================= </OTHER ACTIONS > =============================//
......@@ -7,10 +7,14 @@ TW.Edges = [];
TW.Relations = {} // edges sorted by source/target type
TW.Clusters = []; // "by value" facet index built in parseCustom
TW.File = "" // remember the currently opened file
TW.partialGraph = null // will contain the sigma visible graph instance
TW.labels=[]; // fulltext search list
TW.gexfPaths={}; // for file selectors iff servermenu
TW.fields={}; // for related db tablenames
// (iff servermenu && relatedDocsType == 'wosLocalDB')
TW.categories = []; // possible node types and their inverted map
TW.catDict = {};
......@@ -217,10 +221,6 @@ function syncRemoteGraphData () {
// -> gexf file path is in the urlparam @file
// -> gexf file path is already specified in TW.conf.sourceFile
// ===================
var the_file = "";
// ===================
// menufile case : a list of source files in ./db.json
if (sourcemode == 'servermenu') {
console.log("reading from FILEMENU TW.conf.sourceMenu")
......@@ -246,11 +246,11 @@ function syncRemoteGraphData () {
// the first or a specified one (ie both mode and file params are present)
if( isUndef(getUrlParam.file) ) {
the_file = first_path+"/"+first_file
TW.File = first_path+"/"+first_file
mapLabel = first_file
} else {
// £POSS; match on the full paths from db.json
the_file = first_path+"/"+getUrlParam.file
TW.File = first_path+"/"+getUrlParam.file
mapLabel = getUrlParam.file
}
......@@ -268,18 +268,24 @@ function syncRemoteGraphData () {
if (TW.conf.debug.logFetchers)
console.log("\t\t\t"+gexfBasename)
// for associated wosLocalDBs sql queries
if (theGexfs[aGexf]) {
// -------------------------->8------------------------------------------
// £TODO this part is underspecified
// if used in some usecases, port it to nodetypes
// otherwise remove
// console.log("\t\t\ttable:"+theGexfs[aGexf]["semantic"]["table"])
// TW.field[path+"/"+aGexf] = theGexfs[aGexf]["semantic"]["table"]
// ex : data/AXA/RiskV2PageRank5000.gexf:"ISItermsAxa_2015"
// -------------------------->8------------------------------------------
TW.fields[path+"/"+aGexf] = {"semantic":null, "social":null}
if (theGexfs[aGexf]["semantic"] && theGexfs[aGexf]["semantic"]["table"]) {
TW.fields[path+"/"+aGexf]['semantic'] = theGexfs[aGexf]["semantic"]["table"]
}
if (theGexfs[aGexf]["social"] && theGexfs[aGexf]["social"]["table"]) {
TW.fields[path+"/"+aGexf]['social'] = theGexfs[aGexf]["social"]["table"]
}
}
else {
TW.fields[path+"/"+aGexf] = null
}
// ^^^^^^ FIXME see if we got the expected behavior right
// (? specifications ?)
let cssFileSelected = (the_file==(path+"/"+aGexf))?"selected":""
let cssFileSelected = (TW.File==(path+"/"+aGexf))?"selected":""
files_selector += '<option '+cssFileSelected+'>'+gexfBasename+'</option>'
}
// console.log( files_selector )
......@@ -290,23 +296,23 @@ function syncRemoteGraphData () {
// direct urlparam file case
else if( !isUndef(getUrlParam.file) ) {
the_file = getUrlParam.file
TW.File = getUrlParam.file
}
// direct file fallback case: specified file in settings_explorer
else if (TW.conf.sourceFile && linkCheck(TW.conf.sourceFile)) {
console.log("no @file arg: trying TW.conf.sourceFile from settings")
the_file = TW.conf.sourceFile;
TW.File = TW.conf.sourceFile;
}
else {
console.error(`No specified input and neither db.json nor TW.conf.sourceFile ${TW.conf.sourceFile} are present`)
}
var finalRes = AjaxSync({ url: the_file });
var finalRes = AjaxSync({ url: TW.File });
inData = finalRes["data"]
inFormat = finalRes["format"]
if (TW.conf.debug.logFetchers) {
console.warn('@the_file', finalRes["OK"], the_file)
console.warn('@TW.File', finalRes["OK"], TW.File)
console.log(' fetch result: format', inFormat)
console.log(' fetch result: typeof data', typeof inData)
console.log("\n============================\n")
......
......@@ -433,8 +433,6 @@ function updateRelatedNodesPanel( sels , same, oppos ) {
sameNodesDIV+= '</div>';
}
// getTopPapers("semantic");
informationDIV += '<br><h4>Information:</h4><ul>';
informationDIV += htmlfied_nodesatts( sels ).join("<br>\n")
informationDIV += '</ul><br>';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment