changeset 23:cad8e054fe4b

modifying getConsensus action
author one
date Tue, 02 Oct 2012 23:46:55 +0900
parents 6506b8742343
children 81d1d7c7bcde
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/streams/compile/compile/$global/out test/RequestTest.java
diffstat 7 files changed, 213 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/app/controllers/User.java	Tue Oct 02 23:11:50 2012 +0900
+++ b/app/controllers/User.java	Tue Oct 02 23:46:55 2012 +0900
@@ -1,6 +1,8 @@
 package controllers;
 
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
 
 import com.tinkerpop.blueprints.Graph;
 import com.tinkerpop.blueprints.Vertex;
@@ -67,8 +69,10 @@
 			return notFound("user: "+name+" not found");
 		} else {
 			UserModel user = new UserModel(v);
-			Object[] consensus = user.getUserConsensus();
-			if (consensus == null) return notFound("Consensus not found");
+			System.out.println(name);
+			HashSet<Object> set = user.getClaimsAndRequests();
+			if (set == null) return notFound("Consensus not found");
+			Object[] consensus = tpGraph.checkConsensus(set);
 			return created(Json.toJson(consensus));
 		}		
 	}
@@ -92,4 +96,6 @@
 	
 	
 	
+	
+	
 }
--- a/app/models/TPGraph.java	Tue Oct 02 23:11:50 2012 +0900
+++ b/app/models/TPGraph.java	Tue Oct 02 23:46:55 2012 +0900
@@ -1,5 +1,8 @@
 package models;
 
+import java.util.HashSet;
+import java.util.Iterator;
+
 import com.tinkerpop.blueprints.Graph;
 import com.tinkerpop.blueprints.Vertex;
 import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
@@ -103,6 +106,25 @@
 		return true;
 	}
 	
+	public Object[] checkConsensus(HashSet<Object> set) {
+		HashSet<Object> consensus = new HashSet<Object>();
+		Iterator<Object> iter = set.iterator();
+		while(iter.hasNext()) {
+			Object o = iter.next();
+			Iterator<Object> iter2 = set.iterator();
+			while(iter2.hasNext()) {
+				Object o2 = iter2.next();
+			}
+		}
+		return consensus.toArray();
+	}
+	
+	private Object checkUpperVertex(Object id) {
+		Vertex v = graph.getVertex(id);
+		
+		return null;
+	}
+	
 	
 	public void shutdownGraph() {
 		graph.shutdown();
--- a/app/models/UserModel.java	Tue Oct 02 23:11:50 2012 +0900
+++ b/app/models/UserModel.java	Tue Oct 02 23:46:55 2012 +0900
@@ -2,6 +2,8 @@
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
 
 import com.tinkerpop.blueprints.Vertex;
 import com.tinkerpop.gremlin.java.GremlinPipeline;
@@ -32,8 +34,18 @@
 		return getEdgeInUser(L_AUTHOR);
 	}
 	
-	public Object[] getUserConsensus() {
-		return null;
+	public HashSet<Object> getClaimsAndRequests() {
+		Object[] claims = getUserClaims();
+		Object[] requests = getUserRequests();
+		HashSet<Object> set = new HashSet<Object>();
+		if (claims != null)
+			for (Object id : claims) set.add(id);
+		if (requests != null)
+			for (Object id : requests) set.add(id);
+		if (set.size() == 0) return null;
+		return set;
+		
+
 	}
 	
 	public HashMap<Object,Object[]> getUserInfo() {
--- a/logs/application.log	Tue Oct 02 23:11:50 2012 +0900
+++ b/logs/application.log	Tue Oct 02 23:46:55 2012 +0900
@@ -10,3 +10,119 @@
 2012-10-02 22:49:44,238 - [INFO] - from play in play-akka.actor.default-dispatcher-3 
 Application started (Dev)
 
+2012-10-02 23:10:27,284 - [INFO] - from application in play-akka.actor.default-dispatcher-3 
+Application shutdown...
+
+2012-10-02 23:10:27,300 - [INFO] - from play in play-akka.actor.default-dispatcher-3 
+Application started (Dev)
+
+2012-10-02 23:22:42,479 - [INFO] - from application in play-akka.actor.default-dispatcher-3 
+Application shutdown...
+
+2012-10-02 23:22:42,494 - [INFO] - from play in play-akka.actor.default-dispatcher-3 
+Application started (Dev)
+
+2012-10-02 23:22:42,883 - [ERROR] - from application in play-akka.actor.actions-dispatcher-8 
+
+
+! @6bpch86jn - Internal server error, for request [GET /users/consensus/yosiaki] ->
+
+play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[NullPointerException: null]]
+	at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) [play_2.9.1.jar:2.0.3]
+	at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) [play_2.9.1.jar:2.0.3]
+	at akka.actor.Actor$class.apply(Actor.scala:318) [akka-actor.jar:2.0.2]
+	at play.core.ActionInvoker.apply(Invoker.scala:113) [play_2.9.1.jar:2.0.3]
+	at akka.actor.ActorCell.invoke(ActorCell.scala:626) [akka-actor.jar:2.0.2]
+	at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:197) [akka-actor.jar:2.0.2]
+	at akka.dispatch.Mailbox.run(Mailbox.scala:179) [akka-actor.jar:2.0.2]
+	at akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:516) [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.UserModel.getUserConsensus(UserModel.java:41) ~[classes/:na]
+	at controllers.User.getUserConsensus(User.java:70) ~[classes/:na]
+	at Routes$$anonfun$routes$1$$anonfun$apply$9$$anonfun$apply$10.apply(routes_routing.scala:96) ~[classes/:na]
+	at Routes$$anonfun$routes$1$$anonfun$apply$9$$anonfun$apply$10.apply(routes_routing.scala:96) ~[classes/:na]
+	at play.core.Router$HandlerInvoker$$anon$4$$anon$1.invocation(Router.scala:1086) ~[play_2.9.1.jar:2.0.3]
+	at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:33) ~[play_2.9.1.jar:2.0.3]
+	at play.GlobalSettings$1.call(GlobalSettings.java:57) ~[play_2.9.1.jar:2.0.3]
+	at play.core.j.JavaAction$class.apply(JavaAction.scala:74) ~[play_2.9.1.jar:2.0.3]
+	at play.core.Router$HandlerInvoker$$anon$4$$anon$1.apply(Router.scala:1085) ~[play_2.9.1.jar:2.0.3]
+	at play.core.ActionInvoker$$anonfun$receive$1$$anonfun$6.apply(Invoker.scala:126) ~[play_2.9.1.jar:2.0.3]
+	at play.core.ActionInvoker$$anonfun$receive$1$$anonfun$6.apply(Invoker.scala:126) ~[play_2.9.1.jar:2.0.3]
+	at play.utils.Threads$.withContextClassLoader(Threads.scala:17) ~[play_2.9.1.jar:2.0.3]
+	at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:125) [play_2.9.1.jar:2.0.3]
+	... 11 common frames omitted
+
+2012-10-02 23:23:50,595 - [ERROR] - from application in play-akka.actor.actions-dispatcher-8 
+
+
+! @6bpch86jo - Internal server error, for request [GET /users/consensus/takaaki] ->
+
+play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[NullPointerException: null]]
+	at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) [play_2.9.1.jar:2.0.3]
+	at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) [play_2.9.1.jar:2.0.3]
+	at akka.actor.Actor$class.apply(Actor.scala:318) [akka-actor.jar:2.0.2]
+	at play.core.ActionInvoker.apply(Invoker.scala:113) [play_2.9.1.jar:2.0.3]
+	at akka.actor.ActorCell.invoke(ActorCell.scala:626) [akka-actor.jar:2.0.2]
+	at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:197) [akka-actor.jar:2.0.2]
+	at akka.dispatch.Mailbox.run(Mailbox.scala:179) [akka-actor.jar:2.0.2]
+	at akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:516) [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.UserModel.getUserConsensus(UserModel.java:41) ~[classes/:na]
+	at controllers.User.getUserConsensus(User.java:70) ~[classes/:na]
+	at Routes$$anonfun$routes$1$$anonfun$apply$9$$anonfun$apply$10.apply(routes_routing.scala:96) ~[classes/:na]
+	at Routes$$anonfun$routes$1$$anonfun$apply$9$$anonfun$apply$10.apply(routes_routing.scala:96) ~[classes/:na]
+	at play.core.Router$HandlerInvoker$$anon$4$$anon$1.invocation(Router.scala:1086) ~[play_2.9.1.jar:2.0.3]
+	at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:33) ~[play_2.9.1.jar:2.0.3]
+	at play.GlobalSettings$1.call(GlobalSettings.java:57) ~[play_2.9.1.jar:2.0.3]
+	at play.core.j.JavaAction$class.apply(JavaAction.scala:74) ~[play_2.9.1.jar:2.0.3]
+	at play.core.Router$HandlerInvoker$$anon$4$$anon$1.apply(Router.scala:1085) ~[play_2.9.1.jar:2.0.3]
+	at play.core.ActionInvoker$$anonfun$receive$1$$anonfun$6.apply(Invoker.scala:126) ~[play_2.9.1.jar:2.0.3]
+	at play.core.ActionInvoker$$anonfun$receive$1$$anonfun$6.apply(Invoker.scala:126) ~[play_2.9.1.jar:2.0.3]
+	at play.utils.Threads$.withContextClassLoader(Threads.scala:17) ~[play_2.9.1.jar:2.0.3]
+	at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:125) [play_2.9.1.jar:2.0.3]
+	... 11 common frames omitted
+
+2012-10-02 23:25:18,100 - [INFO] - from application in play-akka.actor.default-dispatcher-3 
+Application shutdown...
+
+2012-10-02 23:25:18,113 - [INFO] - from play in play-akka.actor.default-dispatcher-3 
+Application started (Dev)
+
+2012-10-02 23:26:56,118 - [INFO] - from application in play-akka.actor.default-dispatcher-3 
+Application shutdown...
+
+2012-10-02 23:26:56,131 - [INFO] - from play in play-akka.actor.default-dispatcher-3 
+Application started (Dev)
+
+2012-10-02 23:28:11,987 - [INFO] - from application in play-akka.actor.default-dispatcher-3 
+Application shutdown...
+
+2012-10-02 23:28:12,010 - [INFO] - from play in play-akka.actor.default-dispatcher-3 
+Application started (Dev)
+
+2012-10-02 23:28:40,691 - [INFO] - from application in play-akka.actor.default-dispatcher-3 
+Application shutdown...
+
+2012-10-02 23:28:40,704 - [INFO] - from play in play-akka.actor.default-dispatcher-3 
+Application started (Dev)
+
+2012-10-02 23:29:01,665 - [INFO] - from application in play-akka.actor.default-dispatcher-3 
+Application shutdown...
+
+2012-10-02 23:29:01,686 - [INFO] - from play in play-akka.actor.default-dispatcher-3 
+Application started (Dev)
+
+2012-10-02 23:31:25,581 - [INFO] - from application in play-akka.actor.default-dispatcher-3 
+Application shutdown...
+
+2012-10-02 23:31:25,594 - [INFO] - from play in play-akka.actor.default-dispatcher-3 
+Application started (Dev)
+
Binary file target/scala-2.9.1/cache/compile/compile has changed
--- a/target/streams/compile/compile/$global/out	Tue Oct 02 23:11:50 2012 +0900
+++ b/target/streams/compile/compile/$global/out	Tue Oct 02 23:46:55 2012 +0900
@@ -1,1 +1,48 @@
-[info] Compiling 1 Java source to /Users/aotokage/workspace/Consensus/target/scala-2.9.1/classes...
+[info] Compiling 3 Java sources to /Users/aotokage/workspace/Consensus/target/scala-2.9.1/classes...
+[error] /Users/aotokage/workspace/Consensus/app/models/UserModel.java:55: cannot find symbol
+[error] symbol  : method getUserConsensus()
+[error] location: class models.UserModel
+[error] 		hash.put(NodeModel.CONSENSUS, getUserConsensus());
+[error] 		                              ^
+[error] 1 error
+javac returned nonzero exit code
+	at sbt.compiler.JavaCompiler$$anon$1.apply(JavaCompiler.scala:26)
+	at sbt.AggressiveCompile$$anonfun$5$$anonfun$compileJava$1$1.apply$mcV$sp(AggressiveCompile.scala:76)
+	at sbt.classfile.Analyze$.apply(Analyze.scala:93)
+	at sbt.AggressiveCompile$$anonfun$5.compileJava$1(AggressiveCompile.scala:75)
+	at sbt.AggressiveCompile$$anonfun$5.apply(AggressiveCompile.scala:79)
+	at sbt.AggressiveCompile$$anonfun$5.apply(AggressiveCompile.scala:57)
+	at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:21)
+	at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:19)
+	at sbt.inc.Incremental$.cycle(Incremental.scala:33)
+	at sbt.inc.Incremental$.compile(Incremental.scala:20)
+	at sbt.inc.IncrementalCompile$.apply(Compile.scala:17)
+	at sbt.AggressiveCompile.compile2(AggressiveCompile.scala:87)
+	at sbt.AggressiveCompile.compile1(AggressiveCompile.scala:41)
+	at sbt.AggressiveCompile.apply(AggressiveCompile.scala:28)
+	at sbt.Compiler$.apply(Compiler.scala:107)
+	at sbt.Defaults$$anonfun$compileTask$1.apply(Defaults.scala:479)
+	at sbt.Defaults$$anonfun$compileTask$1.apply(Defaults.scala:479)
+	at sbt.Scoped$$anonfun$hf2$1.apply(Structure.scala:473)
+	at sbt.Scoped$$anonfun$hf2$1.apply(Structure.scala:473)
+	at scala.Function1$$anonfun$compose$1.apply(Function1.scala:41)
+	at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$11.apply(Structure.scala:295)
+	at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$11.apply(Structure.scala:295)
+	at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
+	at sbt.std.Transform$$anon$5.work(System.scala:67)
+	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:221)
+	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:221)
+	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
+	at sbt.Execute.work(Execute.scala:227)
+	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:221)
+	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:221)
+	at sbt.CompletionService$$anon$1$$anon$2.call(CompletionService.scala:26)
+	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
+	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
+	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
+	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
+	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
+	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
+	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
+	at java.lang.Thread.run(Thread.java:680)
+[error] {file:/Users/aotokage/workspace/Consensus/}Consensus/compile:compile: javac returned nonzero exit code
--- a/test/RequestTest.java	Tue Oct 02 23:11:50 2012 +0900
+++ b/test/RequestTest.java	Tue Oct 02 23:46:55 2012 +0900
@@ -22,22 +22,19 @@
 		createUser(user2);
 		createUser(user3);
 
-		
-/*
-		getUser(user1);
-		getUserInfo(user1,"claims/");
-		getUserInfo(user1,"consensus/");
-*/
 		String[] users = {user2,user3};
 		createClaim(user1, users);
 		createClaim(user1, users);
 
+/*
 		getUser(user1);
 		getUserInfo(user2,"requests/");
+		getUserInfo(user2,"claims/");
+*/
+
 		getUserInfo(user3,"requests/");
-		getUserInfo(user2,"claims/");
 		getUserInfo(user3,"claims/");
-
+		getUserInfo(user3,"consensus/");
 
 	}