Mercurial > hg > Members > nobuyasu > Consensus
changeset 78:f744331287ea draft
create getLatestUserConsensus Action
author | one |
---|---|
date | Fri, 08 Mar 2013 17:15:34 +0900 |
parents | 4c5b3e990712 |
children | 11dc5846b8c7 |
files | app/controllers/User.java app/models/TPGraph.java app/models/UserModel.java logs/application.log target/scala-2.9.1/cache/compile/compile target/scala-2.9.1/cache/update/output target/scala-2.9.1/classes/controllers/Application.class target/scala-2.9.1/src_managed/main/controllers/routes.java target/scala-2.9.1/src_managed/main/routes_reverseRouting.scala target/scala-2.9.1/src_managed/main/routes_routing.scala target/scala-2.9.1/src_managed/main/views/html/index.template.scala target/scala-2.9.1/src_managed/main/views/html/main.template.scala |
diffstat | 12 files changed, 129 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controllers/User.java Fri Mar 08 16:47:42 2013 +0900 +++ b/app/controllers/User.java Fri Mar 08 17:15:34 2013 +0900 @@ -79,6 +79,22 @@ return created(Json.toJson(consensus)); } } + + public static Result getLatestUserConsensus(String name) { + TPGraph tpGraph = TPGraph.getInstance(); + Vertex v = tpGraph.getVertex(name); + if (v == null) { + return notFound("user: "+name+" not found"); + } else { + UserModel user = new UserModel(v); + HashSet<Object> set = user.getLatestClaimsAndRequests(); + if (set == null) { + return notFound("Consensus not found"); + } + Object[] consensus = tpGraph.checkConsensus(set); + return created(Json.toJson(consensus)); + } + } public static Result getUserClaims(String name) { TPGraph tpGraph = TPGraph.getInstance();
--- a/app/models/TPGraph.java Fri Mar 08 16:47:42 2013 +0900 +++ b/app/models/TPGraph.java Fri Mar 08 17:15:34 2013 +0900 @@ -210,6 +210,8 @@ } return set.toArray(); } + + /* * Return CLAIM numbers of above [id] CLAIM.
--- a/app/models/UserModel.java Fri Mar 08 16:47:42 2013 +0900 +++ b/app/models/UserModel.java Fri Mar 08 17:15:34 2013 +0900 @@ -14,7 +14,7 @@ super(vertex); } - private Object[] getEdgeInUser(String labels) { + private Object[] getVertexRelatedUser(String labels) { GremlinPipeline<Vertex,Vertex> pipe = new GremlinPipeline<Vertex,Vertex>(); pipe.start(this.vertex).in(labels); ArrayList<Object> array = new ArrayList<Object>(); @@ -26,11 +26,37 @@ } public Object[] getUserRequests() { - return getEdgeInUser(L_REQUEST); + return getVertexRelatedUser(L_REQUEST); } public Object[] getUserClaims() { - return getEdgeInUser(L_AUTHOR); + return getVertexRelatedUser(L_AUTHOR); + } + + private Object[] getLatestVertexRelatedUser(String labels) { + TPGraph tpGraph = TPGraph.getInstance(); + Object[] vIds = getVertexRelatedUser(labels); + ArrayList<Object> array = new ArrayList<Object>(); + for (Object vId : vIds) { + GremlinPipeline<Vertex,Vertex> pipe = new GremlinPipeline<Vertex,Vertex>(); + pipe.start(tpGraph.getVertex(vId)).in(L_PREV); + /* + * c1 <--prev-- c1' <--prev-- c1'' + * c1'' is latest. + */ + if (!pipe.hasNext()) { + array.add(vId); + } + } + return array.toArray(); + } + + public Object[] getLatestUserRequests() { + return getLatestVertexRelatedUser(L_REQUEST); + } + + public Object[] getLatestUserClaims() { + return getLatestVertexRelatedUser(L_AUTHOR); } public HashSet<Object> getClaimsAndRequests() { @@ -39,6 +65,13 @@ return makeSet(requests, claims); } + public HashSet<Object> getLatestClaimsAndRequests() { + Object[] requests = getUserRequests(); + + Object[] claims = getUserClaims(); + return makeSet(requests, claims); + } + private HashSet<Object> makeSet(Object[] obj1, Object[] obj2) { HashSet<Object> set = new HashSet<Object>(); if (obj1 != null)
--- a/logs/application.log Fri Mar 08 16:47:42 2013 +0900 +++ b/logs/application.log Fri Mar 08 17:15:34 2013 +0900 @@ -1,18 +1,81 @@ -2013-03-07 20:17:42,790 - [INFO] - from play in main +2013-03-08 16:32:03,907 - [INFO] - from play in main Listening for HTTP on port 9000... -2013-03-07 20:17:47,414 - [INFO] - from play in play-akka.actor.default-dispatcher-1 -Application started (Dev) +2013-03-08 16:32:21,334 - [ERROR] - from application in New I/O worker #1 + + +! @6dh8bk8oc - Internal server error, for request [GET /] -> -2013-03-08 16:03:42,378 - [INFO] - from application in play-akka.actor.default-dispatcher-2 +play.api.UnexpectedException: Unexpected exception [NullPointerException: null] + at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$3$$anonfun$1.apply(ApplicationProvider.scala:134) ~[play_2.9.1.jar:2.0.3] + at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$3$$anonfun$1.apply(ApplicationProvider.scala:112) ~[play_2.9.1.jar:2.0.3] + at scala.Option.map(Option.scala:133) ~[scala-library.jar:0.11.3] + at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$3.apply(ApplicationProvider.scala:112) ~[play_2.9.1.jar:2.0.3] + at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$3.apply(ApplicationProvider.scala:110) ~[play_2.9.1.jar:2.0.3] + at scala.Either$RightProjection.flatMap(Either.scala:277) ~[scala-library.jar:0.11.3] + at play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:110) ~[play_2.9.1.jar:2.0.3] + at play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:110) ~[play_2.9.1.jar:2.0.3] + at akka.dispatch.Future$$anon$3.liftedTree1$1(Future.scala:195) ~[akka-actor.jar:2.0.2] + at akka.dispatch.Future$$anon$3.run(Future.scala:194) ~[akka-actor.jar:2.0.2] + at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:94) ~[akka-actor.jar:2.0.2] + at akka.jsr166y.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1381) ~[akka-actor.jar:2.0.2] + at akka.jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:259) ~[akka-actor.jar:2.0.2] + at akka.jsr166y.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975) ~[akka-actor.jar:2.0.2] + at akka.jsr166y.ForkJoinPool.runWorker(ForkJoinPool.java:1479) ~[akka-actor.jar:2.0.2] + at akka.jsr166y.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104) ~[akka-actor.jar:2.0.2] +Caused by: java.lang.NullPointerException: null + at models.TPGraph.addVertex(TPGraph.java:58) ~[classes/:na] + at init.InitialData.init(InitialData.java:35) ~[classes/:na] + at Global.onStart(Global.java:12) ~[classes/:na] + at play.core.j.JavaGlobalSettingsAdapter.onStart(JavaGlobalSettingsAdapter.scala:16) ~[play_2.9.1.jar:2.0.3] + at play.api.GlobalPlugin.onStart(Global.scala:134) ~[play_2.9.1.jar:2.0.3] + at play.api.Play$$anonfun$start$1.apply(Play.scala:60) ~[play_2.9.1.jar:2.0.3] + at play.api.Play$$anonfun$start$1.apply(Play.scala:60) ~[play_2.9.1.jar:2.0.3] + at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59) ~[scala-library.jar:0.11.3] + at scala.collection.immutable.List.foreach(List.scala:45) ~[scala-library.jar:0.11.3] + at play.api.Play$.start(Play.scala:60) ~[play_2.9.1.jar:2.0.3] + at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$3$$anonfun$1.apply(ApplicationProvider.scala:125) ~[play_2.9.1.jar:2.0.3] + ... 15 common frames omitted + +2013-03-08 16:35:18,020 - [INFO] - from application in play-akka.actor.default-dispatcher-1 Application shutdown... -2013-03-08 16:03:42,409 - [INFO] - from play in play-akka.actor.default-dispatcher-2 +2013-03-08 16:35:18,291 - [INFO] - from play in play-akka.actor.default-dispatcher-1 +Application started (Dev) + +2013-03-08 16:35:46,443 - [INFO] - from application in play-akka.actor.default-dispatcher-4 +Application shutdown... + +2013-03-08 16:35:46,464 - [INFO] - from play in play-akka.actor.default-dispatcher-4 +Application started (Dev) + +2013-03-08 16:36:49,997 - [INFO] - from application in play-akka.actor.default-dispatcher-4 +Application shutdown... + +2013-03-08 16:36:50,017 - [INFO] - from play in play-akka.actor.default-dispatcher-4 Application started (Dev) -2013-03-08 16:07:25,214 - [INFO] - from application in play-akka.actor.default-dispatcher-2 +2013-03-08 16:40:45,293 - [INFO] - from application in play-akka.actor.default-dispatcher-7 +Application shutdown... + +2013-03-08 16:40:45,312 - [INFO] - from play in play-akka.actor.default-dispatcher-7 +Application started (Dev) + +2013-03-08 16:40:50,750 - [INFO] - from application in play-akka.actor.default-dispatcher-7 Application shutdown... -2013-03-08 16:07:25,234 - [INFO] - from play in play-akka.actor.default-dispatcher-2 +2013-03-08 16:40:50,770 - [INFO] - from play in play-akka.actor.default-dispatcher-7 Application started (Dev) +2013-03-08 16:41:00,781 - [INFO] - from application in play-akka.actor.default-dispatcher-7 +Application shutdown... + +2013-03-08 16:41:00,804 - [INFO] - from play in play-akka.actor.default-dispatcher-7 +Application started (Dev) + +2013-03-08 16:41:12,377 - [INFO] - from application in play-akka.actor.default-dispatcher-7 +Application shutdown... + +2013-03-08 16:41:12,395 - [INFO] - from play in play-akka.actor.default-dispatcher-7 +Application started (Dev) +
--- a/target/scala-2.9.1/src_managed/main/controllers/routes.java Fri Mar 08 16:47:42 2013 +0900 +++ b/target/scala-2.9.1/src_managed/main/controllers/routes.java Fri Mar 08 17:15:34 2013 +0900 @@ -1,6 +1,6 @@ // @SOURCE:/Users/aotokage/workspace/Consensus/conf/routes // @HASH:3317ca87d73529fc1de270007d36f9a429867f66 -// @DATE:Thu Mar 07 18:55:07 JST 2013 +// @DATE:Fri Mar 08 16:32:07 JST 2013 package controllers;
--- a/target/scala-2.9.1/src_managed/main/routes_reverseRouting.scala Fri Mar 08 16:47:42 2013 +0900 +++ b/target/scala-2.9.1/src_managed/main/routes_reverseRouting.scala Fri Mar 08 17:15:34 2013 +0900 @@ -1,6 +1,6 @@ // @SOURCE:/Users/aotokage/workspace/Consensus/conf/routes // @HASH:3317ca87d73529fc1de270007d36f9a429867f66 -// @DATE:Thu Mar 07 18:55:07 JST 2013 +// @DATE:Fri Mar 08 16:32:07 JST 2013 import play.core._ import play.core.Router._
--- a/target/scala-2.9.1/src_managed/main/routes_routing.scala Fri Mar 08 16:47:42 2013 +0900 +++ b/target/scala-2.9.1/src_managed/main/routes_routing.scala Fri Mar 08 17:15:34 2013 +0900 @@ -1,6 +1,6 @@ // @SOURCE:/Users/aotokage/workspace/Consensus/conf/routes // @HASH:3317ca87d73529fc1de270007d36f9a429867f66 -// @DATE:Thu Mar 07 18:55:07 JST 2013 +// @DATE:Fri Mar 08 16:32:07 JST 2013 import play.core._ import play.core.Router._
--- a/target/scala-2.9.1/src_managed/main/views/html/index.template.scala Fri Mar 08 16:47:42 2013 +0900 +++ b/target/scala-2.9.1/src_managed/main/views/html/index.template.scala Fri Mar 08 17:15:34 2013 +0900 @@ -45,7 +45,7 @@ } /* -- GENERATED -- - DATE: Thu Mar 07 18:49:49 JST 2013 + DATE: Fri Mar 08 16:32:09 JST 2013 SOURCE: /Users/aotokage/workspace/Consensus/app/views/index.scala.html HASH: 40523c3560c255ffb9a20c98b65c17e640c1d57a MATRIX: 755->1|849->18|886->21|921->48|960->50|1005->61|1019->67|1073->100
--- a/target/scala-2.9.1/src_managed/main/views/html/main.template.scala Fri Mar 08 16:47:42 2013 +0900 +++ b/target/scala-2.9.1/src_managed/main/views/html/main.template.scala Fri Mar 08 17:15:34 2013 +0900 @@ -54,7 +54,7 @@ } /* -- GENERATED -- - DATE: Thu Mar 07 18:49:49 JST 2013 + DATE: Fri Mar 08 16:32:09 JST 2013 SOURCE: /Users/aotokage/workspace/Consensus/app/views/main.scala.html HASH: 6a9d3e71a4db67b23442aa0e15837c7026dc07bb MATRIX: 759->1|866->31|954->84|980->89|1077->151|1091->157|1146->191|1242->252|1256->258|1309->290|1370->315|1385->321|1452->366|1555->433|1584->440