Mercurial > hg > Members > nobuyasu > Consensus
diff app/models/TPGraph.java @ 8:7b314898fddd
create action User.getUser()
author | one |
---|---|
date | Mon, 01 Oct 2012 19:53:43 +0900 |
parents | 2122c50278bd |
children | d050b7fb4cda |
line wrap: on
line diff
--- a/app/models/TPGraph.java Mon Oct 01 18:51:30 2012 +0900 +++ b/app/models/TPGraph.java Mon Oct 01 19:53:43 2012 +0900 @@ -1,5 +1,7 @@ package models; +import scala.reflect.generic.Trees.This; + import com.tinkerpop.blueprints.Graph; import com.tinkerpop.blueprints.Vertex; import com.tinkerpop.blueprints.impls.tg.TinkerGraph; @@ -10,6 +12,8 @@ private Object claimRootId; private Object userRootId; + protected final String CHILD = "child"; + private TPGraph() { } @@ -39,26 +43,44 @@ return graph; } - public void setClaimRootVertex(Vertex v) { - this.claimRootId = v.getId(); + public void setClaimRootId(Object id) { + this.claimRootId = id; } - public Object getClaimRootVertex() { - return this.claimRootId; + public void setUserRootId(Object id) { + this.userRootId = id; } - public void setUserRootVertex(Vertex v) { - this.userRootId = v.getId(); + public Object getUserRootId() { + return userRootId; + } + + public Vertex getClaimRootVertex() { + return graph.getVertex(userRootId); } - public Object getUserRootVertex() { - return userRootId; + public Vertex getUserRootVertex() { + return graph.getVertex(userRootId); } + + public void setLabelToRootUser(UserModel user) { + Vertex rootUser = getUserRootVertex(); + + /* + * rootUser ---child---> newUser + */ + graph.addEdge(null, rootUser, user.getVertex(), CHILD); + } + + public void shutdownGraph() { graph.shutdown(); } + + + }