Mercurial > hg > Members > nobuyasu > Consensus
comparison app/models/TPGraph.java @ 7:2122c50278bd
add Global.java, ande models/*
author | one |
---|---|
date | Mon, 01 Oct 2012 18:51:30 +0900 |
parents | |
children | 7b314898fddd |
comparison
equal
deleted
inserted
replaced
6:d6afc58ce3f5 | 7:2122c50278bd |
---|---|
1 package models; | |
2 | |
3 import com.tinkerpop.blueprints.Graph; | |
4 import com.tinkerpop.blueprints.Vertex; | |
5 import com.tinkerpop.blueprints.impls.tg.TinkerGraph; | |
6 | |
7 public class TPGraph { | |
8 | |
9 private static TPGraph instance = new TPGraph(); | |
10 private Object claimRootId; | |
11 private Object userRootId; | |
12 | |
13 private TPGraph() { | |
14 | |
15 } | |
16 | |
17 public static TPGraph getInstance() { | |
18 return instance; | |
19 } | |
20 | |
21 private Graph graph; | |
22 private String path = null; | |
23 | |
24 public void setPath(String path) { | |
25 this.path = path; | |
26 } | |
27 | |
28 public Graph newGraph() { | |
29 if (path == null) { | |
30 graph = new TinkerGraph(); | |
31 } else { | |
32 graph = new TinkerGraph(path); | |
33 | |
34 } | |
35 return graph; | |
36 } | |
37 | |
38 public Graph getGraph() { | |
39 return graph; | |
40 } | |
41 | |
42 public void setClaimRootVertex(Vertex v) { | |
43 this.claimRootId = v.getId(); | |
44 } | |
45 | |
46 public Object getClaimRootVertex() { | |
47 return this.claimRootId; | |
48 } | |
49 | |
50 public void setUserRootVertex(Vertex v) { | |
51 this.userRootId = v.getId(); | |
52 } | |
53 | |
54 public Object getUserRootVertex() { | |
55 return userRootId; | |
56 } | |
57 | |
58 public void shutdownGraph() { | |
59 graph.shutdown(); | |
60 } | |
61 | |
62 | |
63 | |
64 } |