Mercurial > hg > Members > nobuyasu > Consensus
comparison 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 |
comparison
equal
deleted
inserted
replaced
7:2122c50278bd | 8:7b314898fddd |
---|---|
1 package models; | 1 package models; |
2 | |
3 import scala.reflect.generic.Trees.This; | |
2 | 4 |
3 import com.tinkerpop.blueprints.Graph; | 5 import com.tinkerpop.blueprints.Graph; |
4 import com.tinkerpop.blueprints.Vertex; | 6 import com.tinkerpop.blueprints.Vertex; |
5 import com.tinkerpop.blueprints.impls.tg.TinkerGraph; | 7 import com.tinkerpop.blueprints.impls.tg.TinkerGraph; |
6 | 8 |
7 public class TPGraph { | 9 public class TPGraph { |
8 | 10 |
9 private static TPGraph instance = new TPGraph(); | 11 private static TPGraph instance = new TPGraph(); |
10 private Object claimRootId; | 12 private Object claimRootId; |
11 private Object userRootId; | 13 private Object userRootId; |
14 | |
15 protected final String CHILD = "child"; | |
12 | 16 |
13 private TPGraph() { | 17 private TPGraph() { |
14 | 18 |
15 } | 19 } |
16 | 20 |
37 | 41 |
38 public Graph getGraph() { | 42 public Graph getGraph() { |
39 return graph; | 43 return graph; |
40 } | 44 } |
41 | 45 |
42 public void setClaimRootVertex(Vertex v) { | 46 public void setClaimRootId(Object id) { |
43 this.claimRootId = v.getId(); | 47 this.claimRootId = id; |
44 } | 48 } |
45 | 49 |
46 public Object getClaimRootVertex() { | 50 public void setUserRootId(Object id) { |
47 return this.claimRootId; | 51 this.userRootId = id; |
48 } | 52 } |
49 | 53 |
50 public void setUserRootVertex(Vertex v) { | 54 public Object getUserRootId() { |
51 this.userRootId = v.getId(); | 55 return userRootId; |
56 } | |
57 | |
58 public Vertex getClaimRootVertex() { | |
59 return graph.getVertex(userRootId); | |
52 } | 60 } |
53 | 61 |
54 public Object getUserRootVertex() { | 62 public Vertex getUserRootVertex() { |
55 return userRootId; | 63 return graph.getVertex(userRootId); |
56 } | 64 } |
65 | |
66 public void setLabelToRootUser(UserModel user) { | |
67 Vertex rootUser = getUserRootVertex(); | |
68 | |
69 /* | |
70 * rootUser ---child---> newUser | |
71 */ | |
72 graph.addEdge(null, rootUser, user.getVertex(), CHILD); | |
73 } | |
74 | |
75 | |
57 | 76 |
58 public void shutdownGraph() { | 77 public void shutdownGraph() { |
59 graph.shutdown(); | 78 graph.shutdown(); |
60 } | 79 } |
61 | 80 |
81 | |
82 | |
83 | |
62 | 84 |
63 | 85 |
64 } | 86 } |