Commit fb0485ac authored by Romain Loth's avatar Romain Loth

debug new db.json + generalize TW.byType to gexfs if someday multiple types

cf. same for jsons in de6b4496
parent 4096b7d3
...@@ -9,7 +9,7 @@ ini_set('display_startup_errors',1); ...@@ -9,7 +9,7 @@ ini_set('display_startup_errors',1);
include('parameters_details.php'); include('parameters_details.php');
if ($_GET['dbtype'] == "sql") { if ($_GET['dbtype'] == "CortextDB") {
$base = new PDO("sqlite:".$mainpath.$graphdb); $base = new PDO("sqlite:".$mainpath.$graphdb);
include('default_div.php'); include('default_div.php');
} }
......
...@@ -1129,10 +1129,14 @@ function jsActionOnGexfSelector(graphBasename){ ...@@ -1129,10 +1129,14 @@ function jsActionOnGexfSelector(graphBasename){
// override default categories with the ones from db.json // override default categories with the ones from db.json
if (TW.gmenuInfos[graphPath]) { if (TW.gmenuInfos[graphPath]) {
if (TW.gmenuInfos[graphPath].node0 && TW.gmenuInfos[graphPath].node0.name) if (TW.gmenuInfos[graphPath][0] && TW.gmenuInfos[graphPath][0].name) {
TW.conf.catSem = TW.gmenuInfos[graphPath].node0.name TW.conf.catSem = TW.gmenuInfos[graphPath][0].name
if (TW.gmenuInfos[graphPath].node1 && TW.gmenuInfos[graphPath].node1.name) console.log("new catSem:", TW.conf.catSem)
TW.conf.catSem = TW.gmenuInfos[graphPath].node1.name }
if (TW.gmenuInfos[graphPath][1] && TW.gmenuInfos[graphPath][1].name) {
TW.conf.catSoc = TW.gmenuInfos[graphPath][1].name
console.log("new catSoc:", TW.conf.catSoc)
}
} }
mainStartGraph(newDataRes["format"], newDataRes["data"], TW.instance) mainStartGraph(newDataRes["format"], newDataRes["data"], TW.instance)
......
...@@ -284,7 +284,7 @@ function syncRemoteGraphData () { ...@@ -284,7 +284,7 @@ function syncRemoteGraphData () {
TW.gmenuInfos[path+"/"+aGraph][0] = gSrcEntry.node0 TW.gmenuInfos[path+"/"+aGraph][0] = gSrcEntry.node0
} }
if (gSrcEntry.node1) { if (gSrcEntry.node1) {
TW.gmenuInfos[path+"/"+aGraph][0] = gSrcEntry.node0 TW.gmenuInfos[path+"/"+aGraph][1] = gSrcEntry.node1
} }
} }
......
...@@ -192,8 +192,6 @@ function scanGexf(gexfContent) { ...@@ -192,8 +192,6 @@ function scanGexf(gexfContent) {
if (! isUndef(declaredAttrs.nodeAttrs[attr])) if (! isUndef(declaredAttrs.nodeAttrs[attr]))
attr = declaredAttrs.nodeAttrs[attr].title attr = declaredAttrs.nodeAttrs[attr].title
// console.log('attr', attr)
// THIS WILL BECOME catDict (if ncats == 1 => monopart) // THIS WILL BECOME catDict (if ncats == 1 => monopart)
if (attr=="category") categoriesDict[val]=val; if (attr=="category") categoriesDict[val]=val;
} }
...@@ -602,12 +600,18 @@ function dictfyGexf( gexf , categories ){ ...@@ -602,12 +600,18 @@ function dictfyGexf( gexf , categories ){
var catCount = {} var catCount = {}
for(var i in categories) catDict[categories[i]] = i; for(var i in categories) catDict[categories[i]] = i;
var edges={}, nodes={} var edges={}, nodes={}, nodesByType={}
var declaredAtts = gexfCheckAttributesMap(gexf) var declaredAtts = gexfCheckAttributesMap(gexf)
var nodesAttributes = declaredAtts.nodeAttrs var nodesAttributes = declaredAtts.nodeAttrs
// var edgesAttributes = declaredAtts.eAttrs // var edgesAttributes = declaredAtts.eAttrs
// NB nodesByType lists arrays of ids per nodetype
// (equivalent to TW.partialGraph.graph.getNodesByType but on full nodeset)
for(var i in categories) {
catDict[categories[i]] = i
nodesByType[i] = []
}
var elsNodes = gexf.getElementsByTagName('nodes') // The list of xml nodes 'nodes' (plural) var elsNodes = gexf.getElementsByTagName('nodes') // The list of xml nodes 'nodes' (plural)
TW.labels = []; TW.labels = [];
...@@ -744,6 +748,14 @@ function dictfyGexf( gexf , categories ){ ...@@ -744,6 +748,14 @@ function dictfyGexf( gexf , categories ){
// save record // save record
nodes[node.id] = node nodes[node.id] = node
// console.log("catDict", catDict)
// console.log("node.type", node.type)
if (!nodesByType[catDict[node.type]]) {
console.warn("unrecognized type:", node.type)
}
else {
nodesByType[catDict[node.type]].push(node.id)
}
if(parseFloat(node.size) < minNodeSize) if(parseFloat(node.size) < minNodeSize)
minNodeSize= parseFloat(node.size); minNodeSize= parseFloat(node.size);
...@@ -886,7 +898,7 @@ function dictfyGexf( gexf , categories ){ ...@@ -886,7 +898,7 @@ function dictfyGexf( gexf , categories ){
resDict.catCount = catCount; // ex: {'ISIterms':1877} ie #nodes resDict.catCount = catCount; // ex: {'ISIterms':1877} ie #nodes
resDict.nodes = nodes; // { nid1: {label:"...", size:"11.1", attributes:"...", color:"#aaa", etc}, nid2: ...} resDict.nodes = nodes; // { nid1: {label:"...", size:"11.1", attributes:"...", color:"#aaa", etc}, nid2: ...}
resDict.edges = edges; resDict.edges = edges;
resDict.byType = nodesByType;
return resDict; return resDict;
} }
...@@ -1055,7 +1067,12 @@ function dictfyJSON( data , categories ) { ...@@ -1055,7 +1067,12 @@ function dictfyJSON( data , categories ) {
// record // record
nodes[node.id] = node; nodes[node.id] = node;
nodesByType[catDict[node.type]].push(node.id) if (!nodesByType[catDict[node.type]]) {
console.warn("unrecognized type:", node.type)
}
else {
nodesByType[catDict[node.type]].push(node.id)
}
// creating a faceted index from node.attributes // creating a faceted index from node.attributes
if (TW.conf.scanClusters) { if (TW.conf.scanClusters) {
......
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