Mercurial > hg > Members > nobuyasu > Consensus
view 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 source
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; public class TPGraph { private static TPGraph instance = new TPGraph(); private Object claimRootId; private Object userRootId; protected final String CHILD = "child"; private TPGraph() { } public static TPGraph getInstance() { return instance; } private Graph graph; private String path = null; public void setPath(String path) { this.path = path; } public Graph newGraph() { if (path == null) { graph = new TinkerGraph(); } else { graph = new TinkerGraph(path); } return graph; } public Graph getGraph() { return graph; } public void setClaimRootId(Object id) { this.claimRootId = id; } public void setUserRootId(Object id) { this.userRootId = id; } public Object getUserRootId() { return userRootId; } public Vertex getClaimRootVertex() { return graph.getVertex(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(); } }