Commit f3d96c2e authored by Romain Loth's avatar Romain Loth

WIP separated reldb entries in json for tabs by db kind AND nodetype

parent dba5a3c1
......@@ -5,19 +5,25 @@
"shale_and_ice.gexf": {
"node0": {
"name": "terms",
"reldbtype": "csv",
"reldbfile": "shale_and_ice.csv",
"reldbqcols": ["title"],
"reltemplate": "bib_details"
"reldbs": {
"csv": {
"file": "shale_and_ice.csv",
"qcols": ["title"],
"template": "bib_details"
}
}
}
},
"model_calibration.gexf": {
"node0": {
"name": "terms",
"reldbtype": "csv",
"reldbfile": "model_calibration.csv",
"reldbqcols": ["title"],
"reltemplate": "bib_details"
"reldbs": {
"csv": {
"file": "model_calibration.csv",
"qcols": ["title"],
"template": "bib_details"
}
}
}
}
}
......@@ -37,17 +43,23 @@
"mini_for_csv.gexf": {
"node0": {
"name": "term",
"reldbtype": "csv",
"reldbfile": "mini_for_csv.csv",
"reldbqcols": ["title","keywords","text"],
"reltemplate": "bib_details"
"reldbs": {
"csv": {
"file": "mini_for_csv.csv",
"qcols": ["title","keywords","text"],
"template": "bib_details"
}
}
},
"node1": {
"name": "person",
"reldbtype": "csv",
"reldbfile": "mini_for_csv.csv",
"reldbqcols": ["author"],
"reltemplate": "bib_details"
"reldbs": {
"csv": {
"file": "mini_for_csv.csv",
"qcols": ["author"],
"template": "bib_details"
}
}
}
},
"test_with_various_atts.gexf": {}
......@@ -69,13 +81,16 @@
"data/ClimateChange": {
"graphs": {
"Maps_S_800.gexf": {
"node0": {
"name": "ISItermsWhitelistV2Oct_5 & ISItermsWhitelistV2Oct_5",
"reldbqtable": "ISItermsWhitelistV2Oct_5",
"reldbfile" : "wos_climate-change_title_2014-2015.db",
"reldbtype": "CortextDB",
"reltemplate": "cortext_with_link"
"node0": {
"name": "ISItermsWhitelistV2Oct_5 & ISItermsWhitelistV2Oct_5",
"reldbs": {
"CortextDB": {
"file": "wos_climate-change_title_2014-2015.db",
"qtable": "ISItermsWhitelistV2Oct_5",
"reltemplate": "cortext_with_link"
}
}
}
}
}
}
......
......@@ -21,7 +21,10 @@ $mainpath=dirname(dirname(getcwd()))."/"; // default fs path to ProjectExplorer
$project_menu_path = "db.json";
// 3 - others
$ntypes = 2; // max node types
$ntypes = 2; // max node types (node0 & node1)
// accepted entries in db.json -> source -> reldbs -> dbtype
$supported_dbtypes = ['csv', 'CortextDB'];
// number of docs to display setting
$max_item_displayed = 7;
......@@ -38,7 +41,7 @@ $memport = 11211;
// CONFIGURATION PARAMS
// --------------------
// parse db.json project menu and create a conf by file
$conf = read_conf($mainpath.$project_menu_path, $ntypes);
$conf = read_conf($mainpath.$project_menu_path, $ntypes, $supported_dbtypes);
// =======================================
// echodump("== READ CONF ==<br>", $conf);
......
......@@ -17,7 +17,7 @@ function errmsg($message, $context, $more = "") {
// reading db.json associations
// source graph file <=> (db, dbtype, cols) as relatedDocs php API
function read_conf($filepath, $ntypes) {
function read_conf($filepath, $ntypes, $our_dbtypes) {
$project_menu_fh = fopen($filepath, "r");
$json_st = '';
while (!feof($project_menu_fh)) {
......@@ -37,7 +37,7 @@ function read_conf($filepath, $ntypes) {
continue;
}
foreach ($dir_items->graphs as $graph_file => $graph_conf){
// echodump("== $graph_file ==", $graph_conf);
echodump("== $graph_file ==", $graph_conf);
$gpath = $project_dir.'/'.$graph_file;
......@@ -45,21 +45,44 @@ function read_conf($filepath, $ntypes) {
// node0 <=> classic type 'semantic'
// node1 <=> classic type 'social'
// NB2 now additionnally, each nodetype can have several dbs configured !
$conf[$gpath] = array($ntypes);
for ($i = 0 ; $i < $ntypes ; $i++) {
// check node0, node1, etc to see if they at least have a reldbfile
// check node0, node1, etc to see if they at least have a reldb conf
if (! property_exists($graph_conf, 'node'.$i)
|| ! property_exists($graph_conf->{'node'.$i}, 'reldbfile') ) {
$conf[$gpath][$i] = array('active' => false);
|| ! property_exists($graph_conf->{'node'.$i}, 'reldbs') ) {
// all dbtypes inactive on this file and nodetype
foreach ($our_dbtypes as $dbtype) {
// $conf[$gpath][$i][$dbtype] = array('active' => false);
$conf[$gpath][$i] = array('active' => false);
}
continue;
}
else {
// we have a file for this type: copy entire conf
$conf[$gpath][$i] = (array)$graph_conf->{'node'.$i};
// further check for each configured db that is listed under reldbs
$dbinfos = $graph_conf->{'node'.$i}->reldbs;
foreach ($dbinfos as $dbtype => $dbconf) {
echodump("reldbtype", $dbtype);
echodump("reldbconf", $dbconf);
// valid conf cases
if (in_array($dbtype, $our_dbtypes) && $dbconf->file) {
// we have a file for this nodetype and dbtype: copy entire conf
$conf[$gpath][$i][$dbtype] = array();
$test = (array)$dbconf;
echodump("conf copy", $test);
// $conf[$gpath][$i][$dbtype] = (array)$dbconf;
}
}
echodump("got conf", $conf[$gpath][$i]);
$conf[$gpath][$i]['active'] = true;
$conf[$gpath][$i]['dir'] = $project_dir;
// $conf[$gpath][$i]['active'] = true;
// $conf[$gpath][$i]['dir'] = $project_dir;
}
// POSS here info on higher level may be propagated for lower ones
// (ex: if dbtype is on the project level, its value should count
......
......@@ -339,7 +339,7 @@ function set_ClustersLegend ( daclass, groupedByTicks ) {
// myFetcher('START', 'hello', function(aStr) {myFetcher(aStr, "world", displayFun)})
// }
function getTopPapers(){
function getTopPapers(choosenAPI){
// waiting image
let image='<img style="display:block; margin: 0px auto;" src="twlibs/img/loader.gif"></img>';
$("#topPapers").html(image);
......@@ -371,13 +371,15 @@ function getTopPapers(){
// do the first then the nested call
topPapersFetcher(
swNodetypes[0],
qWordsbySwType[swNodetypes[0]],
[[],[]],
function(priorJsonHits) {
swNodetypes[0], // <= the queried nodetype
qWordsbySwType[swNodetypes[0]], // <= the query as array of words
choosenAPI, // <= the API backend from db.json
[[],[]], // <= json hit arrays by nodetype
function(priorJsonHits) { // <= the callback
topPapersFetcher(
swNodetypes[1],
qWordsbySwType[swNodetypes[1]],
choosenAPI,
priorJsonHits,
displayTopPapers
)
......@@ -537,7 +539,7 @@ function displayTopPapers(jsonHits) {
let thisRelDocsConf = TW.gmenuInfos[TW.File][ndtypeId]
if (thisRelDocsConf && thisRelDocsConf.reltemplate) {
// console.log("my rendering hits template", thisRelDocsConf.reltemplate)
toHtmlFun = makeRendererFromTemplate(thisRelDocsConf.reltemplate)
}
else {
......
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