Commit bfec4467 authored by Fintan Mc Gee's avatar Fintan Mc Gee

Removed unwanted node types from Histrgaph Query ( DHListViewController.js)

Added bulk updates of multiple nodes to server and layering funbcionality ( sendiong 100s of updates was killing the server)
parent 758277ea
......@@ -525,18 +525,33 @@ var updateNodePositions_cb = function (req, res) {
var updateNodeData_cb = function (req, res) {
sLog.debug_log("***********updateNodeData_cb" + JSON.stringify(req.body) + "\n\n");
sLog.debug_log("***********graphDB.userGraphs" + JSON.stringify(graphDB.userGraphs) + "\n\n");
var nodeCount= 0;
var returnMessage = "Updated node property completed";
if(req.body.nodePropObjs) {
if(req.body.nodePropObj) {
req.body.nodeUids.forEach(function (nUid) {
for(var key in req.body.nodePropObj) {
if(req.body.nodePropObj[key]) {
graphObj.userGraphs[req.user.username].getLayerByName(req.body.nodeLayerName).setNodeProperty(nUid, key, req.body.nodePropObj[key]);
}
req.body.nodeUids.forEach(function (nUid,nodeIndex) {
var nodePropObj;
if(req.body.nodePropObjs.length === 1 ){
nodePropObj =req.body.nodePropObjs[0]
}else if(req.body.nodePropObjs.length === req.body.nodeUids.length){
nodePropObj =req.body.nodePropObjs[nodeIndex]
}
else {
returnMessage = "Invlaid number of properties sent for nodes: Should be or the same as the number of nodes";
}
for(var key in nodePropObj) {
if(nodePropObj[key]) {
graphObj.userGraphs[req.user.username].getLayerByName(req.body.nodeLayerName).setNodeProperty(nUid, key, nodePropObj[key]);
}
}
nodeCount++;
})
}
res.json({msg:"Updated node property completed"});
res.json({msg:returnMessage, updatedNodeCount:nodeCount});
};
/**************************************
......
......@@ -179,7 +179,7 @@ angular.module('blizaarModule.controllers')
//check if a valid name has been selected
var nameSearch = binarySearchTextArray($scope.model.inputName,$scope.model.availableNames),
//first label must be the type of the entity we are querying on
otherTargetLabels = [$scope.model.inputType,"audio","collection","comment","create","cvce","date","diagram","entity","epublication","inquiry","institution","location","map","observation","organization","person","photo","place","positioning","resource","social_group","table","text","theme","topic","type"],
otherTargetLabels = [$scope.model.inputType,"audio","collection","comment","create","date","diagram",,"epublication","inquiry","institution","location","map","observation","organization","person","photo","place","positioning","resource","social_group","table","text","type"],
targetLabels = [],
relationshipTypes = [],
merge = false;
......
......@@ -875,28 +875,38 @@ angular.module('blizaarModule.services')
/**************************************
* updateAServer NodeData
* Functionality: Updates the vlue of the specified node for the specified property in the specified layer
* If a single property obj is sent , its values are used to update all nodes.
* of the same amount of proery objects are send each updates the uid at the same index
*
* Created By : Fintan McGee (LIST)
* Date: 03/03/2016
*******************************/
updateNodeDataToServer : function(nodeLayerName,nodeUids,nodePropObj) {
updateNodeDataToServer : function(nodeLayerName,nodeUids,nodePropObjs) {
if(!Array.isArray(nodeUids)) {
nodeUids = [nodeUids];
}
if(!Array.isArray(nodePropObjs)) {
nodePropObjs = [nodePropObjs];
}
// if(nodeUids.length > 1) {
// console.log("Sending update for " + nodeUids.length + " to the server" )
// }
// sending position map to server
return $http({
method: 'post',
url: '/updateNodeData', // url where to get data.
headers: { 'Content-Type': 'application/json' }, // set the headers so angular passing info as form data (not request payload)
data: { graphName: self.currenytGraphName,
data: { graphName: self.currentGraphName,
nodeLayerName:nodeLayerName,
nodeUids: nodeUids,
nodePropObj: nodePropObj // used when multiple fields are to be updated, key
nodePropObjs: nodePropObjs // used when multiple fields are to be updated, key
}
})// Success case
.then(function (response) {
console.log("Updated position of " + response.data.updatedNodeCount + " nodes on the server");
console.log("Updated Node Data of " + response.data.updatedNodeCount + " nodes on the server");
},
// Error handling
function (err) {
......
......@@ -239,6 +239,9 @@ angular.module('blizaarModule.services')
var master = multiLayerGraphService.getGraph();
master.buildAdjacencyList();
var bulkDataLineUpdateDataStructure = {nodes:[],propertySets:[]};
var bulkLabelUpdateDataStructure = {nodes:[],propertySets:[]};
master.nodes.forEach(function(n) {
if(master.checkNodeType(n.uid,"DataLine") || master.checkNodeType(n.uid,"Spot") ) {
var neighbours = master.getNeighbours(n);
......@@ -255,8 +258,10 @@ angular.module('blizaarModule.services')
n.Id = n.Id_single;
var updateObj = master.copyDistinctNodeAttributes(n.uid, neighbourNode.uid);
n.Id = undefined;
updateObj.Id = undefined;
dataService.updateNodeDataToServer("MasterLayer",[n.uid], updateObj);
//updateObj.Id = undefined;
bulkDataLineUpdateDataStructure.nodes.push(neighbourNode.uid);
bulkDataLineUpdateDataStructure.propertySets.push(updateObj);
}
});
}
......@@ -265,10 +270,16 @@ angular.module('blizaarModule.services')
}
}
// dataService.updateNodeDataToServer("MasterLayer",bulkDataLineUpdateDataStructure.nodes, bulkDataLineUpdateDataStructure.propertySets);
n.BLZ_label = n.PlantGroupID|| n.Id_single || n.pr_Descr || n.Id || n.name ;
dataService.updateNodeDataToServer("MasterLayer",[n.uid], {BLZ_label:n.BLZ_label});
bulkLabelUpdateDataStructure.nodes.push(n.uid);
bulkLabelUpdateDataStructure.propertySets.push({BLZ_label: n.BLZ_label});
// dataService.updateNodeDataToServer("MasterLayer",[n.uid], {BLZ_label:n.BLZ_label});
//
});
dataService.updateNodeDataToServer("MasterLayer",bulkDataLineUpdateDataStructure.nodes, bulkDataLineUpdateDataStructure.propertySets);
dataService.updateNodeDataToServer("MasterLayer",bulkLabelUpdateDataStructure.nodes, bulkLabelUpdateDataStructure.propertySets);
this.createBioNodeInfoAndBarAttributes();
},
createBioNodeInfoAndBarAttributes: function() {
......@@ -318,7 +329,9 @@ angular.module('blizaarModule.services')
var nodeTypes = multiLayerGraphService.getGraph().getLabelCountMap();
var masterLayer = multiLayerGraphService.getGraph();
var bulkLabelUpdateDataStructure = {nodes:[],propertySets:[]};
// making full URLs form shortedn links
multiLayerGraphService.getGraph().nodes.forEach(function(n){
if(n.links_wiki) {
n.wikipedia_link = "https://en.wikipedia.org/wiki/" + n.links_wiki;
......@@ -334,10 +347,12 @@ angular.module('blizaarModule.services')
}
n.BLZ_label = n.name || n.title
dataService.updateNodeDataToServer("MasterLayer",[n.uid], {BLZ_label:n.BLZ_label, wikipedia_link: n.wikipedia_link, wikidata_link:n.wikidata_link,viaf_link:n.viaf_link, cvce_Link :n.cvce_Link });
bulkLabelUpdateDataStructure.nodes.push(n.uid);
bulkLabelUpdateDataStructure.propertySets.push({BLZ_label:n.BLZ_label, wikipedia_link: n.wikipedia_link, wikidata_link:n.wikidata_link,viaf_link:n.viaf_link, cvce_Link :n.cvce_Link });
// dataService.updateNodeDataToServer("MasterLayer",[n.uid], {BLZ_label:n.BLZ_label, wikipedia_link: n.wikipedia_link, wikidata_link:n.wikidata_link,viaf_link:n.viaf_link, cvce_Link :n.cvce_Link });
});
dataService.updateNodeDataToServer("MasterLayer",bulkLabelUpdateDataStructure.nodes, bulkLabelUpdateDataStructure.propertySets);
this.createDHNodeInfoAndBarAttributes();
},
......@@ -417,8 +432,15 @@ angular.module('blizaarModule.services')
dataService.updateLayerOnServer("createEmptyLayer", "organizations");
}
multiLayerGraphService.getGraph().addNodeLabelToLayer("organizations","organization").prepareGraph();
multiLayerGraphService.getGraph().addNodeLabelToLayer("organizations","social_group").prepareGraph();
dataService.updateLayerOnServer("addNodeLabelToLayer", "organizations","social_group");
if(multiLayerGraphService.getGraph().getLayerByName("organizations").nodes.length > 0) {
multiLayerGraphService.getGraph().induceLinksInLayer("organizations");
dataService.updateLayerOnServer("addNodeLabelToLayer", "organizations", "organization");
dataService.updateLayerOnServer("induceLinksInLayer", "organizations");
var organisationLayerNodeUids = [];
......@@ -450,16 +472,27 @@ angular.module('blizaarModule.services')
}
multiLayerGraphService.getGraph().addNodeLabelToLayer("documents","resource").prepareGraph();
dataService.updateLayerOnServer("addNodeLabelToLayer", "documents","resource");
multiLayerGraphService.getGraph().addNodeLabelToLayer("documents","collection").prepareGraph();
dataService.updateLayerOnServer("addNodeLabelToLayer", "documents","collection");
// multiLayerGraphService.getGraph().addNodeLabelToLayer("documents","subunit").prepareGraph();
// dataService.updateLayerOnServer("addNodeLabelToLayer", "documents","subunit");
// multiLayerGraphService.getGraph().addNodeLabelToLayer("documents","theme").prepareGraph();
// dataService.updateLayerOnServer("addNodeLabelToLayer", "documents","theme");
// multiLayerGraphService.getGraph().addNodeLabelToLayer("documents","topic").prepareGraph();
// dataService.updateLayerOnServer("addNodeLabelToLayer", "documents","topic");
var documentsLayerNodeUids = [];
multiLayerGraphService.getLayerByName("documents").nodes.forEach(function(n,index){
multiLayerGraphService.getLayerByName("documents").nodes.forEach(function(n,index) {
documentsLayerNodeUids.push(n.uid);
n.type = "resource";
n.label = "resource";
n.colorCategory = "resource";
n.BLZ_order = index;
multiLayerGraphService.getGraph().node[n.uid].type = "resource";
multiLayerGraphService.getGraph().node[n.uid].label = "resource";
multiLayerGraphService.getGraph().node[n.uid].colorCategory = "resource";
multiLayerGraphService.getGraph().node[n.uid].type = n.type;
multiLayerGraphService.getGraph().node[n.uid].label = n.label;
multiLayerGraphService.getGraph().node[n.uid].colorCategory = n.colorCategory;
});
......@@ -543,6 +576,8 @@ angular.module('blizaarModule.services')
multiLayerGraphService.prepareLayersForDisplay();
multiLayerGraphService.getGraph().buildInterLayerEdgeMap();
}
multiLayerGraphService.getGraph().setColorCategories("type");
//$scope.refreshGraph();
},
/**************************************
......@@ -925,6 +960,7 @@ angular.module('blizaarModule.services')
layerNames.forEach(function(temporalLayer){
multiLayerGraphService.getGraph().induceLinksInLayer(temporalLayer);
dataService.updateLayerOnServer("induceLinksInLayer", temporalLayer);
multiLayerGraphService.getGraph().getLayerByName(temporalLayer).orderNodes("type", "true");
});
},
/**************************************
......
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