-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attempting to remove CypherTranslator
- Loading branch information
1 parent
abcf8aa
commit 3924f9f
Showing
8 changed files
with
51 additions
and
66 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module Neo4j | ||
module Core | ||
module GraphJSON | ||
def self.to_graph_json(objects) | ||
nodes = {} | ||
edges = {} | ||
|
||
objects.each do |object| | ||
case object | ||
when Neo4j::ActiveNode, Neo4j::Server::CypherNode | ||
nodes[object.neo_id] = { | ||
id: object.neo_id, | ||
labels: (object.is_a?(Neo4j::ActiveNode) ? [object.class.name] : object.labels), | ||
properties: object.attributes | ||
} | ||
when Neo4j::ActiveRel, Neo4j::Server::CypherRelationship | ||
edges[[object.start_node.neo_id, object.end_node.neo_id]] = { | ||
source: object.start_node.neo_id, | ||
target: object.end_node.neo_id, | ||
type: object.rel_type, | ||
properties: object.props | ||
} | ||
else | ||
fail "Invalid value found: #{object.inspect}" | ||
end | ||
end | ||
|
||
{ | ||
nodes: nodes.values, | ||
edges: edges.values | ||
}.to_json | ||
end | ||
end | ||
end | ||
end |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.