Beispiel #1
0
    def toggle_user_updownvote_graph(self, login, gid, direction):

        direction in ('up', 'down')
        user = User.get_by_login(self.db, login)
        graph = GraphNode.get_by_name(self.db, gid)
        vote = user.get_vote_graph(gid)

        if direction == 'up':
            if vote['upvote']:
                user.rm_upvote_graph(gid)
                vote['upvote'] = False
            else:
                user.upvote_graph(gid)
                vote['upvote'] = True
                vote['downvote'] = False
        if direction == 'down':
            if vote['downvote']:
                user.rm_downvote_graph(gid)
                vote['downvote'] = False
            else:
                user.downvote_graph(gid)
                vote['upvote'] = False
                vote['downvote'] = True

        vote.update({
            'username': login,
            'graph': gid,
            'action': '%svote' % direction,
            'time': datetime.datetime.now().isoformat()
        })
        return vote
Beispiel #2
0
 def get_edge_types(self, gid):
     """ returns node types that belongs to a graph gid
     : param gid : graph name
     
     """
     graph = GraphNode.get_by_name(self.db, gid)
     return graph.get_edge_types()
Beispiel #3
0
 def find_edges(self,
                graph_name,
                edgetype_name,
                properties,
                start=0,
                size=100):
     graph = GraphNode.get_by_name(self.db, graph_name)
     edgetype = EdgeType.get_by_name(self.db, graph, edgetype_name)
     return [
         x.as_dict() for x in UEdge.find_in_graph(self.db, graph, edgetype,
                                                  properties, start, size)
     ]
Beispiel #4
0
 def find_nodes(self,
                graph_name,
                nodetype_uuid,
                properties,
                start=0,
                size=100):
     graph = GraphNode.get_by_name(self.db, graph_name)
     nodetype = NodeType.get_by_uuid(self.db, nodetype_uuid)
     return [
         x.as_dict() for x in UNode.find_in_graph(
             self.db, graph_name, nodetype.uuid, properties, start, size)
     ]
Beispiel #5
0
    def create_edge_type(self,
                         username,
                         graph_name,
                         name,
                         properties,
                         description=""):
        graph = GraphNode.get_by_name(self.db, graph_name)
        edgetype = EdgeType(graph, name, properties, description)
        self.db.create(edgetype.node, edgetype.belongs_rel)

        #TODO: log user action

        return edgetype.as_dict()
Beispiel #6
0
 def proxemie(self,
              graph_name,
              p0,
              weights=None,
              filter_edges=None,
              filter_nodes=None,
              limit=50,
              n_step=3):
     graph = GraphNode.get_by_name(self.db, graph_name)
     return graph.proxemieMC(p0,
                             weights=weights,
                             filter_edges=filter_edges,
                             filter_nodes=filter_nodes,
                             limit=limit,
                             n_step=n_step,
                             n_walk=10000)
Beispiel #7
0
 def find_edge_type(self, graph_name, type_name):
     graph = GraphNode.get_by_name(self.db, graph_name)
     return EdgeType.get_by_name(self.db, graph, type_name).as_dict()
Beispiel #8
0
 def destroy_graph(self, graph_name):
     return GraphNode.get_by_name(self.db, graph_name).destroy()
Beispiel #9
0
 def get_user_updownvote_graph(self, login, gid):
     user = User.get_by_login(self.db, login)
     graph = GraphNode.get_by_name(self.db, gid)
     return user.get_vote_graph(gid)
Beispiel #10
0
 def get_starred_node_uuids(self, graphname):
     return [
         node for node in GraphNode.get_by_name(
             self.db, graphname).get_starred_node_uuids()
     ]
Beispiel #11
0
 def complete_label(self, graph_name, what, prefix, start=0, size=100):
     graph = GraphNode.get_by_name(self.db, graph_name)
     return graph.complete_label(what, prefix, start, size)
Beispiel #12
0
 def get_graph_metadata(self, name):
     return GraphNode.get_by_name(self.db, name).get_metadata()
Beispiel #13
0
 def get_graph_infos(self, name):
     return GraphNode.get_by_name(self.db, name).as_dict()
Beispiel #14
0
 def update_graph(self, user, graph_name, properties):
     graph = GraphNode.get_by_name(self.db, graph_name)
     graph.set_properties(properties)
     graph.node.push()
     return graph
Beispiel #15
0
 def get_edge_list(self, graph_name, nodes_uuids):
     return GraphNode.get_by_name(self.db,
                                  graph_name).get_subgraph(nodes_uuids)
Beispiel #16
0
 def get_edges(self, graph_name, edges_uuids):
     return GraphNode.get_by_name(self.db,
                                  graph_name).get_edge_list(edges_uuids)
Beispiel #17
0
 def get_starred_node_count(self, graphname):
     return GraphNode.get_by_name(self.db,
                                  graphname).get_starred_node_count()
Beispiel #18
0
 def set_nodes_starred(self, gid, nodes_uuids, starred):
     graph = GraphNode.get_by_name(self.db, gid)
     if starred:
         graph.star(nodes_uuids)
     else:
         graph.unstar(nodes_uuids)
Beispiel #19
0
    def rm_upvote_graph(self, login, graphname):
        user = self.get_user(login)
        graph = GraphNode.get_by_name(self.db, graphname)

        pass