# HG changeset patch # User one # Date 1349207085 -32400 # Node ID e246e0dac9c88ab887fb502834f7113186e88962 # Parent ad7cfb1f9d0305b3e19a39afbadb868004e60dd4 modified checkConsensus diff -r ad7cfb1f9d03 -r e246e0dac9c8 app/models/TPGraph.java --- a/app/models/TPGraph.java Wed Oct 03 03:52:03 2012 +0900 +++ b/app/models/TPGraph.java Wed Oct 03 04:44:45 2012 +0900 @@ -1,5 +1,6 @@ package models; +import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; @@ -114,23 +115,42 @@ public Object[] checkConsensus(HashSet set) { Iterator iter = set.iterator(); - while(iter.hasNext()) { + + while (iter.hasNext()) { Object childId = iter.next(); - Object parentId; - while ( (parentId = checkUpperVertex(childId)) != null){ + ArrayList array = getAllUpperVertex(childId); + for (Object parentId: array.toArray()) { if (set.contains(parentId)) { - set.remove(childId); - iter = set.iterator(); - childId = parentId; - continue; + if (set.contains(childId)) { + + // This behavior is anxiety. + set.remove(childId); + iter = set.iterator(); + } + childId = parentId; } - childId = parentId; } } return set.toArray(); } - public Object checkUpperVertex(Object id) { + + public ArrayList getAllUpperVertex(Object id) { + Vertex startV = graph.getVertex(id); + GremlinPipeline pipe = new GremlinPipeline(); + pipe.start(startV).in(NodeModel.L_QUESTION, NodeModel.L_REFUTATION, NodeModel.L_SUGGESTION); + ArrayList vertexArray = new ArrayList(); + + while (pipe.hasNext()) { + Object e = pipe.next().getId(); + vertexArray.add(e); + pipe.start(graph.getVertex(e)).in(NodeModel.L_QUESTION, NodeModel.L_REFUTATION, NodeModel.L_SUGGESTION); + } + + return vertexArray; + } + + public Object getOneUpperVertex(Object id) { Vertex startV = graph.getVertex(id); GremlinPipeline pipe = new GremlinPipeline(); pipe.start(startV).in(NodeModel.L_QUESTION, NodeModel.L_REFUTATION, NodeModel.L_SUGGESTION); diff -r ad7cfb1f9d03 -r e246e0dac9c8 logs/application.log --- a/logs/application.log Wed Oct 03 03:52:03 2012 +0900 +++ b/logs/application.log Wed Oct 03 04:44:45 2012 +0900 @@ -1,12 +1,6 @@ -2012-10-03 03:39:11,946 - [INFO] - from play in main +2012-10-03 04:40:32,947 - [INFO] - from play in main Listening for HTTP on port 9000... -2012-10-03 03:39:18,488 - [INFO] - from play in play-akka.actor.default-dispatcher-1 +2012-10-03 04:40:40,342 - [INFO] - from play in play-akka.actor.default-dispatcher-1 Application started (Dev) -2012-10-03 03:40:19,534 - [INFO] - from application in play-akka.actor.default-dispatcher-3 -Application shutdown... - -2012-10-03 03:40:19,554 - [INFO] - from play in play-akka.actor.default-dispatcher-3 -Application started (Dev) - diff -r ad7cfb1f9d03 -r e246e0dac9c8 target/scala-2.9.1/cache/compile/compile Binary file target/scala-2.9.1/cache/compile/compile has changed diff -r ad7cfb1f9d03 -r e246e0dac9c8 test/RequestTest.java --- a/test/RequestTest.java Wed Oct 03 03:52:03 2012 +0900 +++ b/test/RequestTest.java Wed Oct 03 04:44:45 2012 +0900 @@ -29,27 +29,27 @@ createUser(user3); String[] users1 = {user2,user3}; -// createClaim(user1, users1); + createClaim(user1, users1); String[] users2 = {user2}; -// createClaim(user1, users2); + createClaim(user1, users2); getUser(user1); - getUserInfo(user1,"claims/"); + getUserInfo(user1,"consensus/"); + String[] users3 = {user1}; - createMention(user2, users3, NodeModel.L_QUESTION, "5"); createMention(user3, users3, NodeModel.L_REFUTATION, "5"); createMention(user2, users3, NodeModel.L_QUESTION, "10"); createMention(user3, users3, NodeModel.L_REFUTATION, "10"); - + getUserInfo(user1,"requests/"); getUserInfo(user1,"claims/"); + getUserInfo(user1,"consensus/"); - getUserInfo(user1,"requests/"); getUserInfo(user2,"claims/"); getUserInfo(user2,"consensus/"); @@ -57,12 +57,11 @@ getUserInfo(user3,"claims/"); getUserInfo(user3,"consensus/"); -/* getUserInfo(user3,"requests/"); getUserInfo(user3,"claims/"); getUserInfo(user2,"consensus/"); getUserInfo(user3,"consensus/"); -*/ + } public static void createMention(String author, String[] users, String type, Object id) throws JSONException {