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"; ...@@ -9,13 +9,16 @@ $TITLE="ISITITLE";
$query = str_replace( '__and__', '&', $_GET["query"] ); $query = str_replace( '__and__', '&', $_GET["query"] );
$elems = json_decode($query); $elems = json_decode($query);
$table = ""; $table = "";
$column = ""; $column = "";
$id=""; $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"){ if($type=="social"){
$table = "ISIAUTHOR"; $table = "ISIAUTHOR";
...@@ -54,6 +57,7 @@ if (count($elems)==1){// un seul mot est sélectionné, on compte les mots multi ...@@ -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 $factor=ceil(count($elems)/5); //les scores sont moins haut
$sql=''; $sql='';
foreach($elems as $elem){ foreach($elems as $elem){
// echo("elem: ".$elem."<br/>");
$sql.=' '.$column.'="'.$elem.'" OR '; $sql.=' '.$column.'="'.$elem.'" OR ';
} }
$sql=substr($sql, 0, -3); $sql=substr($sql, 0, -3);
...@@ -70,6 +74,7 @@ $sum=0; ...@@ -70,6 +74,7 @@ $sum=0;
// echo "<br>"; // echo "<br>";
// echo "$sql"; // echo "$sql";
// echo "<br>";
//The final query! //The final query!
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
include('parameters_details.php'); include('parameters_details.php');
$max_item_displayed=6; $max_item_displayed=6;
echo('graphdb: '. $graphdb.'<br/>');
$base = new PDO("sqlite:../" .$graphdb); $base = new PDO("sqlite:../" .$graphdb);
include('default_div.php'); include('default_div.php');
......
<?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 = array();
# $gexf_db["data/terrorism/terrorism_bi.gexf"] = "data/terrorism/data.db"; # $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"; ...@@ -15,7 +14,7 @@ $gexf_db["data/AXA/RiskV2PageRank5000.gexf"] = "data/AXA/data.db";
// TESTS // TESTS
$gexf_db["data/ProgrammeDesCandidats.gexf"] = "foobar"; // $gexf_db["data/ProgrammeDesCandidats.gexf"] = "foobar";
$gexf= str_replace('"','',$_GET["gexf"]); $gexf= str_replace('"','',$_GET["gexf"]);
......
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
"gexfs": { "gexfs": {
"ProgrammeDesCandidats.enrichi.gexf": { "ProgrammeDesCandidats.enrichi.gexf": {
"social": {}, "social": {},
"semantic": {"table":"terms"} "semantic": {}
}, },
"ProgrammeDesCandidats.gexf": { "ProgrammeDesCandidats.gexf": {
"social": {}, "social": {},
"semantic": {"table":"terms"} "semantic": {}
} }
} }
}, },
...@@ -33,8 +33,14 @@ ...@@ -33,8 +33,14 @@
"data/AXA": { "data/AXA": {
"first" : "RiskV2PageRank1000.gexf", "first" : "RiskV2PageRank1000.gexf",
"gexfs": { "gexfs": {
"RiskV2PageRank1000.gexf": {}, "RiskV2PageRank1000.gexf": {
"RiskV2PageRank5000.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 ) { ...@@ -347,15 +347,11 @@ function set_ClustersLegend ( daclass, groupedByTicks ) {
// NB: this variant only for nodetype semantic // NB: this variant only for nodetype semantic
function getTopPapers(nodetypeLegacy){ function getTopPapers(nodetypeLegacy){
if (nodetypeLegacy == 'semantic' && TW.conf.getRelatedDocs) { if (TW.conf.getRelatedDocs) {
jsonparams=getSelections(); if (TW.conf.relatedDocsType == "twitter") {
// POSS remove restriction on 'semantic' nodes for twitter results about authors
var joined_q = jsonparams.map(function(w) {return '('+w+')'}).join(' AND ') if (nodetypeLegacy == 'semantic') {
// console.log(jsonparams)
// theHtml = "<p> jsonparams:"+jsonparams+" </p>"
//
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: TW.conf.relatedDocsAPI, url: TW.conf.relatedDocsAPI,
...@@ -384,6 +380,45 @@ function getTopPapers(nodetypeLegacy){ ...@@ -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) { function clickInsideTweet(e, tweetSrcUrl) {
......
...@@ -36,9 +36,8 @@ TW.conf = (function(TW){ ...@@ -36,9 +36,8 @@ TW.conf = (function(TW){
TWConf.getRelatedDocs = true TWConf.getRelatedDocs = true
TWConf.relatedDocsAPI = "http://127.0.0.1:5000/twitter_search" TWConf.relatedDocsAPI = "http://127.0.0.1:5000/twitter_search"
TWConf.relatedDocsType = "wosLocalDB" // accepted: "twitter" | "wosLocalDB"
// £TODO : allow to choose between twitter or elasticsearch topPapers (choic of post-process function in extras_explorer) // POSSible: "elastic"
// TWConf.relatedDocsType
// ======================= // =======================
// DATA FACETS AND LEGENDS // DATA FACETS AND LEGENDS
......
...@@ -978,5 +978,6 @@ function jsActionOnGexfSelector(gexfBasename){ ...@@ -978,5 +978,6 @@ function jsActionOnGexfSelector(gexfBasename){
mainStartGraph(newDataRes["format"], newDataRes["data"], TW.instance) mainStartGraph(newDataRes["format"], newDataRes["data"], TW.instance)
writeLabel(gexfBasename) writeLabel(gexfBasename)
TW.File = gexfPath
} }
//============================= </OTHER ACTIONS > =============================// //============================= </OTHER ACTIONS > =============================//
...@@ -7,10 +7,14 @@ TW.Edges = []; ...@@ -7,10 +7,14 @@ TW.Edges = [];
TW.Relations = {} // edges sorted by source/target type TW.Relations = {} // edges sorted by source/target type
TW.Clusters = []; // "by value" facet index built in parseCustom 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.partialGraph = null // will contain the sigma visible graph instance
TW.labels=[]; // fulltext search list TW.labels=[]; // fulltext search list
TW.gexfPaths={}; // for file selectors iff servermenu 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.categories = []; // possible node types and their inverted map
TW.catDict = {}; TW.catDict = {};
...@@ -217,10 +221,6 @@ function syncRemoteGraphData () { ...@@ -217,10 +221,6 @@ function syncRemoteGraphData () {
// -> gexf file path is in the urlparam @file // -> gexf file path is in the urlparam @file
// -> gexf file path is already specified in TW.conf.sourceFile // -> gexf file path is already specified in TW.conf.sourceFile
// ===================
var the_file = "";
// ===================
// menufile case : a list of source files in ./db.json // menufile case : a list of source files in ./db.json
if (sourcemode == 'servermenu') { if (sourcemode == 'servermenu') {
console.log("reading from FILEMENU TW.conf.sourceMenu") console.log("reading from FILEMENU TW.conf.sourceMenu")
...@@ -246,11 +246,11 @@ function syncRemoteGraphData () { ...@@ -246,11 +246,11 @@ function syncRemoteGraphData () {
// the first or a specified one (ie both mode and file params are present) // the first or a specified one (ie both mode and file params are present)
if( isUndef(getUrlParam.file) ) { if( isUndef(getUrlParam.file) ) {
the_file = first_path+"/"+first_file TW.File = first_path+"/"+first_file
mapLabel = first_file mapLabel = first_file
} else { } else {
// £POSS; match on the full paths from db.json // £POSS; match on the full paths from db.json
the_file = first_path+"/"+getUrlParam.file TW.File = first_path+"/"+getUrlParam.file
mapLabel = getUrlParam.file mapLabel = getUrlParam.file
} }
...@@ -268,18 +268,24 @@ function syncRemoteGraphData () { ...@@ -268,18 +268,24 @@ function syncRemoteGraphData () {
if (TW.conf.debug.logFetchers) if (TW.conf.debug.logFetchers)
console.log("\t\t\t"+gexfBasename) console.log("\t\t\t"+gexfBasename)
// for associated wosLocalDBs sql queries
if (theGexfs[aGexf]) {
// -------------------------->8------------------------------------------ TW.fields[path+"/"+aGexf] = {"semantic":null, "social":null}
// £TODO this part is underspecified if (theGexfs[aGexf]["semantic"] && theGexfs[aGexf]["semantic"]["table"]) {
// if used in some usecases, port it to nodetypes TW.fields[path+"/"+aGexf]['semantic'] = theGexfs[aGexf]["semantic"]["table"]
// otherwise remove }
// console.log("\t\t\ttable:"+theGexfs[aGexf]["semantic"]["table"]) if (theGexfs[aGexf]["social"] && theGexfs[aGexf]["social"]["table"]) {
// TW.field[path+"/"+aGexf] = theGexfs[aGexf]["semantic"]["table"] TW.fields[path+"/"+aGexf]['social'] = theGexfs[aGexf]["social"]["table"]
// ex : data/AXA/RiskV2PageRank5000.gexf:"ISItermsAxa_2015" }
// -------------------------->8------------------------------------------ }
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>' files_selector += '<option '+cssFileSelected+'>'+gexfBasename+'</option>'
} }
// console.log( files_selector ) // console.log( files_selector )
...@@ -290,23 +296,23 @@ function syncRemoteGraphData () { ...@@ -290,23 +296,23 @@ function syncRemoteGraphData () {
// direct urlparam file case // direct urlparam file case
else if( !isUndef(getUrlParam.file) ) { else if( !isUndef(getUrlParam.file) ) {
the_file = getUrlParam.file TW.File = getUrlParam.file
} }
// direct file fallback case: specified file in settings_explorer // direct file fallback case: specified file in settings_explorer
else if (TW.conf.sourceFile && linkCheck(TW.conf.sourceFile)) { else if (TW.conf.sourceFile && linkCheck(TW.conf.sourceFile)) {
console.log("no @file arg: trying TW.conf.sourceFile from settings") console.log("no @file arg: trying TW.conf.sourceFile from settings")
the_file = TW.conf.sourceFile; TW.File = TW.conf.sourceFile;
} }
else { else {
console.error(`No specified input and neither db.json nor TW.conf.sourceFile ${TW.conf.sourceFile} are present`) 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"] inData = finalRes["data"]
inFormat = finalRes["format"] inFormat = finalRes["format"]
if (TW.conf.debug.logFetchers) { 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: format', inFormat)
console.log(' fetch result: typeof data', typeof inData) console.log(' fetch result: typeof data', typeof inData)
console.log("\n============================\n") console.log("\n============================\n")
......
...@@ -433,8 +433,6 @@ function updateRelatedNodesPanel( sels , same, oppos ) { ...@@ -433,8 +433,6 @@ function updateRelatedNodesPanel( sels , same, oppos ) {
sameNodesDIV+= '</div>'; sameNodesDIV+= '</div>';
} }
// getTopPapers("semantic");
informationDIV += '<br><h4>Information:</h4><ul>'; informationDIV += '<br><h4>Information:</h4><ul>';
informationDIV += htmlfied_nodesatts( sels ).join("<br>\n") informationDIV += htmlfied_nodesatts( sels ).join("<br>\n")
informationDIV += '</ul><br>'; 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