Nicolas Dietrich avatar Nicolas Dietrich committed 5e2c300 Merge

merge

Comments (0)

Files changed (4)

src/adhocracy.dbgraph/adhocracy/dbgraph/EmbeddedGraphConnection.py

-# -*- coding: utf-8 -*-
-
-from neo4j import GraphDatabase
-
-from zope.interface import implements
-
-from adhocracy.dbgraph.interfaces import IGraphConnection
-
-
-class EmbeddedGraphConnection():
-    implements(IGraphConnection)
-
-    def __init__(self, connection_string):
-
-        self.db = GraphDatabase(connection_string)
-
-
-    def shutdown(self):
-
-        self.db.shutdown()
-
-    def start_transaction(self):
-        pass
-

src/adhocracy.dbgraph/adhocracy/dbgraph/embeddedgraph.py

+# -*- coding: utf-8 -*-
+
+from neo4j import GraphDatabase
+
+from zope.interface import implements
+
+from adhocracy.dbgraph.interfaces import IGraph
+
+
+class EmbeddedGraph():
+    implements(IGraph)
+
+    def __init__(self, connection_string):
+        """Creates a new GraphConnection"""
+
+        self.db = GraphDatabase(connection_string)
+
+    def shutdown(self):
+        """Closes graph connection"""
+
+        self.db.shutdown()
+
+    def __init__(connection_string):
+        """Creates a new GraphConnection"""
+
+    def add_vertex(main_interface=IVertex):
+        """Adds a new vertex to the graph with the given
+           Interface.
+        """
+
+    def get_vertex(dbid):
+        """Retrieves an existing vertex from the graph
+           with the given dbid or None.
+        """
+
+    def get_vertices():
+        """Returns an iterator with all the vertices"""
+
+    def remove_vertex(vertex):
+        """Removes the given vertex"""
+
+    def add_edge(self, startVertex, endVertex, label, main_interface=IEdge):
+        """Creates a new edge with label(String)"""
+
+    def get_edge(dbid):
+        """Retrieves an existing edge from the graph
+           with the given dbid or None.
+        """
+
+    def get_edges():
+        """Returns an iterator with all the vertices"""
+
+    def remove_edge(edge):
+        """Removes the given edge"""
+
+    def clear():
+        """Dooms day machine"""
+
+    def start_transaction():
+        """Start Transaction to add new or create Elements"""
+
+    def stop_transaction():
+        """Stop Transaction"""

src/adhocracy.dbgraph/adhocracy/dbgraph/interfaces.py

+# -*- coding: utf-8 -*-
 from zope.interface import Interface
 
 
     Graph vertex object.
     """
 
+    def out_edges(label=None):
+        """Returns a generator with  all outgoing edges of the vertex.
+           label: Optional string parameter to filter the edges
+        """
+
+    def in_edges(label=None):
+        """Returns a generator with all incoming edges of the vertex.
+           label: Optional string parameter to filter the edges
+        """
+
 
 class IEdge(IElement):
     """
     Graph edge object.
     """
 
-    def get_property(key):
-        """Gets the value of the property for the given key"""
+    def start_vertex():
+        """Returns the origin vertex of the edge"""
 
-    def get_properties():
-        """Returns a dictionary with all properties (key/value)"""
+    def end_vertex():
+        """Returns the target vertex of the edge"""
 
-    def set_property(key, value):
-        """Sets the property of the element to the given value"""
+    def get_label():
+        """Returns the label of the edge"""
 
-    def set_properties(property_dictionary):
-        """Add properties. Existing properties are replaced."""
 
-    def remove_property(self, key):
-        """Removes the value of the property for the given key"""
-
-    def get_dbid(self):
-        """Returns the database id of the element"""
-
-    def get_main_interface():
-        """Returns the main interface."""
-
-    def initialize():
-        """Apply main interface that is stored in the
-           main_interface" property,
-        """
-
-
-class IGraphConnection(Interface):
+class IGraph(Interface):
     """
     The graph connection object.
     """
 
+    def __init__(connection_string):
+        """Creates a new GraphConnection"""
+
+    def shutdown():
+        """Closes graph connection"""
+
     def add_vertex(main_interface=IVertex):
         """Adds a new vertex to the graph with the given
            Interface.

src/adhocracy.dbgraph/adhocracy/dbgraph/tests.py

 import unittest
-from adhocracy.dbgraph.EmbeddedGraphConnection import EmbeddedGraphConnection
+from adhocracy.dbgraph.embeddedgraph import EmbeddedGraph
 
 
 class DBGraphTestSuite(unittest.TestCase):
 
     def setUp(self):
-        self.g = EmbeddedGraphConnection("testdb")
+        self.g = EmbeddedGraph("testdb")
         # TODO: use clear in setUp and/or teardown
 
     def testVertices(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.