Mercurial > hg > Members > nobuyasu > Consensus
diff app/models/TPGraph.java @ 76:41b6f3788cc3 draft
TPGraph wrap graph
author | one |
---|---|
date | Fri, 08 Mar 2013 16:18:53 +0900 |
parents | 9448734399db |
children | 4c5b3e990712 |
line wrap: on
line diff
--- a/app/models/TPGraph.java Thu Mar 07 20:08:15 2013 +0900 +++ b/app/models/TPGraph.java Fri Mar 08 16:18:53 2013 +0900 @@ -54,6 +54,18 @@ return graph; } + public Vertex addVertex(Object vId) { + return graph.addVertex(vId); + } + + public Vertex getVertex(Object vId) { + return graph.getVertex(vId); + } + + public Edge getEdge(Object eId) { + return graph.getEdge(eId); + } + public void setClaimRootId(Object id) { this.claimRootId = id; } @@ -69,13 +81,13 @@ public Object getUserRootId() { return userRootId; } - + public Vertex getClaimRootVertex() { - return graph.getVertex(claimRootId); + return getVertex(claimRootId); } public Vertex getUserRootVertex() { - return graph.getVertex(userRootId); + return getVertex(userRootId); } private Edge setLabel(Vertex fromV, Vertex toV, String label) { @@ -95,7 +107,7 @@ } public Edge setLabelToAuthor(ClaimModel claim, String author) { - Vertex authorVertex = graph.getVertex(author); + Vertex authorVertex = getVertex(author); // claim ---author---> authorVertex(userVertex) return setLabel(claim.getVertex(), authorVertex, NodeModel.L_AUTHOR); } @@ -107,7 +119,7 @@ public Boolean setLabelToUsers(ClaimModel claim, String[] users, String label) { for (String userName: users) { - Vertex userVertex = graph.getVertex(userName); + Vertex userVertex = getVertex(userName); if (userVertex == null) { return false; } @@ -117,7 +129,7 @@ } public Boolean setLabelStatusToUser(ClaimModel claim, String userName, String label, String status) { - Vertex userVertex = graph.getVertex(userName); + Vertex userVertex = getVertex(userName); if (userVertex == null) { return false; } @@ -141,7 +153,7 @@ } public Object[] searchAllUser() { - Vertex userRootVertex = graph.getVertex(getUserRootId()); + Vertex userRootVertex = getVertex(getUserRootId()); GremlinPipeline<Vertex,Vertex> pipe = new GremlinPipeline<Vertex,Vertex>(); pipe.start(userRootVertex).out(CHILD); ArrayList<Object> userArray = new ArrayList<Object>(); @@ -203,7 +215,7 @@ * Return CLAIM numbers of above [id] CLAIM. */ public ArrayList<Object> getAllUpperVertexId(Object id) { - Vertex startV = graph.getVertex(id); + Vertex startV = getVertex(id); ArrayList<Object> vertexArray = new ArrayList<Object>(); while (true) { GremlinPipeline<Vertex,Vertex> pipe = new GremlinPipeline<Vertex,Vertex>(); @@ -220,7 +232,7 @@ } public Object getOneUpperClaimVertexId(Object id) { - Vertex startV = graph.getVertex(id); + Vertex startV = getVertex(id); GremlinPipeline<Vertex,Vertex> pipe = new GremlinPipeline<Vertex,Vertex>(); pipe.start(startV).in(NodeModel.L_QUESTION, NodeModel.L_REFUTATION, NodeModel.L_SUGGESTION); if (pipe.hasNext()) { @@ -261,6 +273,9 @@ return latestTopClaim; } + /* + * TODO: update TimeStamp + */ public ClaimModel copyConsensusTree(ClaimModel claim) { ClaimModel oldTopClaim = new ClaimModel(graph.getVertex(getTopClaimVertexId(claim.getId()))); ClaimModel latestTopClaim = copyDownClaims(oldTopClaim);