Mercurial > hg > Members > nobuyasu > Consensus
changeset 74:c5ddd2cc52e1 draft
create copyConsensusTree method.
author | one |
---|---|
date | Thu, 07 Mar 2013 18:40:22 +0900 |
parents | b17c8a25195e |
children | 9448734399db |
files | app/controllers/Claim.java app/models/ClaimModel.java app/models/TPGraph.java logs/application.log target/scala-2.9.1/cache/compile/compile |
diffstat | 5 files changed, 55 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controllers/Claim.java Wed Mar 06 16:57:13 2013 +0900 +++ b/app/controllers/Claim.java Thu Mar 07 18:40:22 2013 +0900 @@ -160,6 +160,21 @@ targetClaim.computeAndUpdateStatus(); return created(); } + + public static Result copyClaims(String id) { + TPGraph tpGraph = TPGraph.getInstance(); + Graph graph = tpGraph.getGraph(); + ClaimModel claim = new ClaimModel(graph.getVertex(id)); + if ( claim.getVertex() == null) { + return badRequest("Claim id " + id + " does not exist."); + } + ClaimModel topClaim = ClaimModel(graph.getVertex(tpGraph.getTopClaimVertex(id))); + + + return ok(); + } + + public static Result getClaimInfo(String id) { TPGraph tpGraph = TPGraph.getInstance();
--- a/app/models/ClaimModel.java Wed Mar 06 16:57:13 2013 +0900 +++ b/app/models/ClaimModel.java Thu Mar 07 18:40:22 2013 +0900 @@ -448,7 +448,8 @@ tpGraph.setLabelToAuthor(newClaim, author); copyRequestEdges(newClaim); return newClaim; - } - + + + }
--- a/app/models/TPGraph.java Wed Mar 06 16:57:13 2013 +0900 +++ b/app/models/TPGraph.java Thu Mar 07 18:40:22 2013 +0900 @@ -100,6 +100,11 @@ return setLabel(claim.getVertex(), authorVertex, NodeModel.L_AUTHOR); } + public Edge setLabelPrev(ClaimModel fromClaim, ClaimModel toClaim) { + // fromClaim ---prev---> toClaim + return setLabel(fromClaim.getVertex(), toClaim.getVertex(), NodeModel.L_PREV ); + } + public Boolean setLabelToUsers(ClaimModel claim, String[] users, String label) { for (String userName: users) { Vertex userVertex = graph.getVertex(userName); @@ -175,7 +180,7 @@ iter = set.iterator(); while (iter.hasNext()) { Object childId = iter.next(); - ArrayList<Object> array = getAllUpperVertex(childId); + ArrayList<Object> array = getAllUpperVertexId(childId); for (Object parentId: array) { /* * If there is a number of the number of parent and child in the [set], @@ -197,7 +202,7 @@ /* * Return CLAIM numbers of above [id] CLAIM. */ - public ArrayList<Object> getAllUpperVertex(Object id) { + public ArrayList<Object> getAllUpperVertexId(Object id) { Vertex startV = graph.getVertex(id); ArrayList<Object> vertexArray = new ArrayList<Object>(); while (true) { @@ -214,7 +219,7 @@ return vertexArray; } - public Object getOneUpperVertex(Object id) { + public Object getOneUpperClaimVertexId(Object id) { Vertex startV = graph.getVertex(id); GremlinPipeline<Vertex,Vertex> pipe = new GremlinPipeline<Vertex,Vertex>(); pipe.start(startV).in(NodeModel.L_QUESTION, NodeModel.L_REFUTATION, NodeModel.L_SUGGESTION); @@ -226,6 +231,32 @@ } } + public Object getTopClaimVertexId(Object id) { + Object v = id; + Object upV = id; + while (upV != null) { + v = upV; + upV = getOneUpperClaimVertexId(v); + } + return v; + } + + private void copyDownClaimVertexAndSetLabel(ClaimModel cliam, String label) { + GremlinPipeline<Vertex, Vertex> pipe = new GremlinPipeline<Vertex, Vertex>(); + pipe.start(claim.getVertex()).outE(label); + + } + + public ClaimModel copyConsensusTree(ClaimModel claim) { + ClaimModel topClaim = new ClaimModel(graph.getVertex(getTopClaimVertexId(claim.getId()))); + + + ClaimModel copiedTopClaim = new ClaimModel(graph.addVertex(null)); + + return copiedTopClaim; + } + + public void shutdownGraph() { if (path == null) { return;
--- a/logs/application.log Wed Mar 06 16:57:13 2013 +0900 +++ b/logs/application.log Thu Mar 07 18:40:22 2013 +0900 @@ -1,9 +1,9 @@ -2013-02-22 19:37:21,212 - [INFO] - from play in main +2013-03-06 17:10:08,718 - [INFO] - from play in main Listening for HTTP on port 9000... -2013-02-22 19:37:32,151 - [INFO] - from play in play-akka.actor.default-dispatcher-2 +2013-03-06 17:24:42,902 - [INFO] - from play in play-akka.actor.default-dispatcher-3 Application started (Dev) -2013-03-05 12:04:39,229 - [INFO] - from application in main +2013-03-06 17:25:02,562 - [INFO] - from application in main Application shutdown...