Skip to content

Instantly share code, notes, and snippets.

@robwormald
Last active Aug 29, 2015
Embed
What would you like to do?
function processVertex(parent, vertices, children) {
var vertex = null, vertexChildren = null;
if (children && angular.isArray(children)) {
_.each(children, function(id) {
// find child in old data model by vertex id
vertex = _.find(vertices, { vertexId: id });
if (vertex) {
if (!parent.nodes) {
parent.nodes = [];
}
// stash any children of the current old vertices data model child
vertexChildren = vertex.directChildVertexIds;
// new child in new vertices data model format
switch (vertex.type) {
case ProfileConstants.VertexType.QUALIFIER_VERTEX:
QualifierRuleService.get(vertex.referenceId)
.then(function(qualifier) {
processNode(parent, vertices, vertex, qualifier, vertexChildren);
})
.catch(function() {
return false;
});
break;
"vertices" : [
{
"vertexId" : "1",
"type" : "GROUPING_VERTEX",
"operator" : "ALL",
"queryHash" : NumberLong(-8431829764980288999),
"rating" : 1.0,
"directChildVertexIds" : [
"1.1",
"1.2",
"1.3"
]
},
{
"vertexId" : "1.3",
"parentVertexId" : "1",
"referenceId" : ObjectId("52d5886bd12ed6a02ee8b62c"),
"type" : "QUALIFIER_VERTEX",
"operator" : "IN",
"queryHash" : NumberLong(1199367963879916109),
"value" : "3",
"rating" : 1.0
},
{
"vertexId" : "1.2",
"parentVertexId" : "1",
"referenceId" : ObjectId("53b1aaf4e14ab322c09cf8b5"),
"type" : "QUALIFIER_VERTEX",
"operator" : "IN",
"queryHash" : NumberLong(-5244767043845059617),
"value" : "501,515,517,555,623,803",
"rating" : 1.0
},
{
"vertexId" : "1.1",
"parentVertexId" : "1",
"referenceId" : ObjectId("52d5886bd12ed6a02ee8b639"),
"type" : "QUALIFIER_VERTEX",
"operator" : "GREATER_THAN_OR_EQUALS",
"queryHash" : NumberLong(4530585763684417183),
"value" : "7",
"rating" : 1.0
}
],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment