Last active
August 29, 2015 14:25
-
-
Save robwormald/7198eef238bad91117fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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