changeset 65:39a8a4faf125

modified InitialData.java
author one
date Tue, 13 Nov 2012 05:45:08 +0900
parents 7121a35a61b9
children 95b83a1e09ac
files app/controllers/Claim.java app/init/InitialData.java logs/application.log target/scala-2.9.1/cache/compile/compile
diffstat 4 files changed, 204 insertions(+), 87 deletions(-) [+]
line wrap: on
line diff
--- a/app/controllers/Claim.java	Tue Nov 13 05:26:27 2012 +0900
+++ b/app/controllers/Claim.java	Tue Nov 13 05:45:08 2012 +0900
@@ -216,9 +216,6 @@
 	}
 	
 	public static Result reset() {
-		TPGraph tpGraph = TPGraph.getInstance();
-		tpGraph.shutdownGraph();
-		TPGraph.resetInstance();
 		InitialData.init();
 		return ok();
 	}
--- a/app/init/InitialData.java	Tue Nov 13 05:26:27 2012 +0900
+++ b/app/init/InitialData.java	Tue Nov 13 05:45:08 2012 +0900
@@ -15,37 +15,106 @@
 
 public class InitialData {
 
-	public static InitialData instance = new InitialData();
+	private static InitialData instance = new InitialData();
 	
+	static String tatsumi = "Tatsumi";
+	static String yana = "Yana";
+	static String ikuhiro = "Ikuhiro";
+	static String shiomi = "Shiomi";
+
+	static String takaaki = "Takaaki";
+	static String akifumi = "Akifumi";
+	static String yosiaki = "Yosiaki";
+
 	public InitialData() {
 		
 	}
 	
 	public static void init() {
+		TPGraph.resetInstance();
+		TPGraph tpGraph = TPGraph.getInstance();		
+		tpGraph.setPath(null);
+		Graph graph = tpGraph.newGraph();
+		Vertex claimV = graph.addVertex(null);
+		tpGraph.setClaimRootId(claimV.getId());
+		Vertex userV = graph.addVertex(null);
+		tpGraph.setUserRootId(userV.getId());
+		createDemoUsers();
 		instance.enterDataDemo1();
 		instance.enterDataDemo2();
 	}
 	
+	private static void createDemoUsers() {
+		TPGraph tpGraph = TPGraph.getInstance();
+		Graph graph = tpGraph.getGraph();
+		/* Demo1 Users */
+		UserModel userModel1 = new UserModel(graph.addVertex(takaaki));
+		UserModel userModel2 = new UserModel(graph.addVertex(akifumi));
+		UserModel userModel3 = new UserModel(graph.addVertex(yosiaki));
+		tpGraph.setLabelToRootUser(userModel1);
+		tpGraph.setLabelToRootUser(userModel2);
+		tpGraph.setLabelToRootUser(userModel3);
+		/* Demo2 Users */
+		UserModel userModel4 = new UserModel(graph.addVertex(tatsumi));
+		UserModel userModel5 = new UserModel(graph.addVertex(yana));
+		UserModel userModel6 = new UserModel(graph.addVertex(ikuhiro));
+		UserModel userModel7 = new UserModel(graph.addVertex(shiomi));
+		tpGraph.setLabelToRootUser(userModel4);
+		tpGraph.setLabelToRootUser(userModel5);
+		tpGraph.setLabelToRootUser(userModel6);
+		tpGraph.setLabelToRootUser(userModel7);
+	}
+	
+	public static void enterDataDemo1() {
+		TPGraph tpGraph = TPGraph.getInstance();
+		Graph graph = tpGraph.getGraph();
+		String[] otherUser1 = { akifumi, yosiaki, tatsumi, yana, shiomi, ikuhiro };
+
+		ClaimModel claimModel1 = new ClaimModel(graph.addVertex(null));
+		ObjectNode t1 = createToulmin("アプリでGraphDBを利用する。");
+		createFirstClaim(claimModel1, t1, takaaki, otherUser1, NodeModel.AGREED);
+
+		ClaimModel claimModel2 = new ClaimModel(graph.addVertex(null));
+		ObjectNode t2 = createToulmin("RDBを利用すべきである。");
+		String[] usersClaim2 = { takaaki };
+		createClaimForMention(claimModel2, t2, akifumi, usersClaim2,
+				NodeModel.DENIED);
+		tpGraph.setLabelMention(claimModel1, claimModel2,
+				NodeModel.L_REFUTATION);
+
+		ClaimModel claimModel3 = new ClaimModel(graph.addVertex(null));
+		ObjectNode t3 = createToulmin("RDBを利用すべきである。");
+		String[] usersClaim3 = { akifumi };
+		createClaimForMention(claimModel3, t3, takaaki, usersClaim3,
+				NodeModel.UNKNOWN);
+		tpGraph.setLabelMention(claimModel2, claimModel3,
+				NodeModel.L_REFUTATION);
+
+		ClaimModel claimModel4 = new ClaimModel(graph.addVertex(null));
+		ObjectNode t4 = createToulmin("どのGraphDBを利用するのか。");
+		createClaimForMention(claimModel4, t4, yosiaki, usersClaim2,
+				NodeModel.AGREED);
+		tpGraph.setLabelMention(claimModel1, claimModel4, NodeModel.L_QUESTION);
+
+		ClaimModel claimModel5 = new ClaimModel(graph.addVertex(null));
+		ObjectNode t5 = createToulmin("TinkerPopはどうか?");
+		String[] usersClaim5 = { yosiaki };
+		createClaimForMention(claimModel5, t5, takaaki, usersClaim5,
+				NodeModel.AGREED);
+		tpGraph.setLabelMention(claimModel4, claimModel5,
+				NodeModel.L_SUGGESTION);
+
+		claimModel3.computeAndUpdateStatus();
+		claimModel2.computeAndUpdateStatus();
+		tpGraph.setLabelStatusToUsers(claimModel1, usersClaim3, NodeModel.L_REQUEST, NodeModel.AGREED);
+
+	}
+	
 	public static void enterDataDemo2() {
 		TPGraph tpGraph = TPGraph.getInstance();
 		Graph graph = tpGraph.getGraph();
-		String tatsumi = "Tatsumi";
-		String yana = "Yana";
-		String ikuhiro = "Ikuhiro";
-		String shiomi = "Shiomi";
+		String[] usersClaim1 = {tatsumi,yana,ikuhiro,shiomi};
 
-		UserModel userModel4 = new UserModel(graph.addVertex(tatsumi));
-		UserModel userModel5 = new UserModel(graph.addVertex(yana));
-		UserModel userModel6 = new UserModel(graph.addVertex(ikuhiro));
-		UserModel userModel7 = new UserModel(graph.addVertex(shiomi));
-
-		tpGraph.setLabelToRootUser(userModel4);
-		tpGraph.setLabelToRootUser(userModel5);
-		tpGraph.setLabelToRootUser(userModel6);
-		tpGraph.setLabelToRootUser(userModel7);
-
-		String[] usersClaim1 = {tatsumi,yana,ikuhiro,shiomi};
-		
 		ClaimModel claimModel1 = new ClaimModel(graph.addVertex(null));
 		ObjectNode t1 = createToulmin("YanaのパソコンにMacPro QuadCoreを買う");
 		createFirstClaim(claimModel1, t1, yana, usersClaim1, NodeModel.AGREED);
@@ -57,7 +126,7 @@
 				NodeModel.DENIED);
 		tpGraph.setLabelMention(claimModel1, claimModel2,
 				NodeModel.L_SUGGESTION);
-		
+
 		ClaimModel claimModel3 = new ClaimModel(graph.addVertex(null));
 		ObjectNode t3 = createToulmin("MacProの最新版がいいでしょう。");
 		String[] usersClaim3 = { yana };
@@ -65,7 +134,7 @@
 				NodeModel.AGREED);
 		tpGraph.setLabelMention(claimModel2, claimModel3,
 				NodeModel.L_REFUTATION);
-		
+
 		ClaimModel claimModel4 = new ClaimModel(graph.addVertex(null));
 		ObjectNode t4 = createToulmin("MacProの最新版を買います。");
 		String[] usersClaim4 = { yana,ikuhiro,shiomi };
@@ -93,68 +162,7 @@
 		
 	}
 	
-	public static void enterDataDemo1() {
-		TPGraph tpGraph = TPGraph.getInstance();
-		tpGraph.setPath(null);
-		Graph graph = tpGraph.newGraph();
-		Vertex claimV = graph.addVertex(null);
-		tpGraph.setClaimRootId(claimV.getId());
-		Vertex userV = graph.addVertex(null);
-		tpGraph.setUserRootId(userV.getId());
-
-		String user1 = "Takaaki";
-		String user2 = "Akifumi";
-		String user3 = "Yosiaki";
-
-		String[] otherUser1 = { user2, user3 };
-
-		UserModel userModel1 = new UserModel(graph.addVertex(user1));
-		UserModel userModel2 = new UserModel(graph.addVertex(user2));
-		UserModel userModel3 = new UserModel(graph.addVertex(user3));
-
-		tpGraph.setLabelToRootUser(userModel1);
-		tpGraph.setLabelToRootUser(userModel2);
-		tpGraph.setLabelToRootUser(userModel3);
-
-		ClaimModel claimModel1 = new ClaimModel(graph.addVertex(null));
-		ObjectNode t1 = createToulmin("アプリでGraphDBを利用する。");
-		createFirstClaim(claimModel1, t1, user1, otherUser1, NodeModel.AGREED);
-
-		ClaimModel claimModel2 = new ClaimModel(graph.addVertex(null));
-		ObjectNode t2 = createToulmin("RDBを利用すべきである。");
-		String[] usersClaim2 = { user1 };
-		createClaimForMention(claimModel2, t2, user2, usersClaim2,
-				NodeModel.DENIED);
-		tpGraph.setLabelMention(claimModel1, claimModel2,
-				NodeModel.L_REFUTATION);
-
-		ClaimModel claimModel3 = new ClaimModel(graph.addVertex(null));
-		ObjectNode t3 = createToulmin("RDBを利用すべきである。");
-		String[] usersClaim3 = { user2 };
-		createClaimForMention(claimModel3, t3, user1, usersClaim3,
-				NodeModel.UNKNOWN);
-		tpGraph.setLabelMention(claimModel2, claimModel3,
-				NodeModel.L_REFUTATION);
-
-		ClaimModel claimModel4 = new ClaimModel(graph.addVertex(null));
-		ObjectNode t4 = createToulmin("どのGraphDBを利用するのか。");
-		createClaimForMention(claimModel4, t4, user3, usersClaim2,
-				NodeModel.AGREED);
-		tpGraph.setLabelMention(claimModel1, claimModel4, NodeModel.L_QUESTION);
-
-		ClaimModel claimModel5 = new ClaimModel(graph.addVertex(null));
-		ObjectNode t5 = createToulmin("TinkerPopはどうか?");
-		String[] usersClaim5 = { user3 };
-		createClaimForMention(claimModel5, t5, user1, usersClaim5,
-				NodeModel.AGREED);
-		tpGraph.setLabelMention(claimModel4, claimModel5,
-				NodeModel.L_SUGGESTION);
-
-		claimModel3.computeAndUpdateStatus();
-		claimModel2.computeAndUpdateStatus();
-		tpGraph.setLabelStatusToUsers(claimModel1, usersClaim3, NodeModel.L_REQUEST, NodeModel.AGREED);
-
-	}
+	
 
 	public static void createClaimForMention(ClaimModel claim, ObjectNode t,
 			String author, String[] users, String type) {
--- a/logs/application.log	Tue Nov 13 05:26:27 2012 +0900
+++ b/logs/application.log	Tue Nov 13 05:45:08 2012 +0900
@@ -1,9 +1,121 @@
-2012-11-13 04:53:03,286 - [INFO] - from play in main 
+2012-11-13 05:41:00,039 - [INFO] - from play in main 
 Listening for HTTP on port 9000...
 
-2012-11-13 04:53:06,805 - [INFO] - from play in play-akka.actor.default-dispatcher-1 
+2012-11-13 05:41:13,580 - [ERROR] - from application in New I/O  worker #1 
+
+
+! @6cb0n9b79 - Internal server error, for request [GET /index.html] ->
+
+play.api.UnexpectedException: Unexpected exception [IllegalArgumentException: Vertex with id already exists: Tatsumi]
+	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.IllegalArgumentException: Vertex with id already exists: Tatsumi
+	at com.tinkerpop.blueprints.util.ExceptionFactory.vertexWithIdAlreadyExists(ExceptionFactory.java:22) ~[blueprints-core-2.2.0-SNAPSHOT.jar:na]
+	at com.tinkerpop.blueprints.impls.tg.TinkerGraph.addVertex(TinkerGraph.java:205) ~[blueprints-core-2.2.0-SNAPSHOT.jar:na]
+	at init.InitialData.enterDataDemo2(InitialData.java:118) ~[classes/:na]
+	at init.InitialData.init(InitialData.java:43) ~[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
+
+2012-11-13 05:41:22,112 - [ERROR] - from application in New I/O  worker #1 
+
+
+! @6cb0n9b79 - Internal server error, for request [GET /] ->
+
+play.api.UnexpectedException: Unexpected exception [IllegalArgumentException: Vertex with id already exists: Tatsumi]
+	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.IllegalArgumentException: Vertex with id already exists: Tatsumi
+	at com.tinkerpop.blueprints.util.ExceptionFactory.vertexWithIdAlreadyExists(ExceptionFactory.java:22) ~[blueprints-core-2.2.0-SNAPSHOT.jar:na]
+	at com.tinkerpop.blueprints.impls.tg.TinkerGraph.addVertex(TinkerGraph.java:205) ~[blueprints-core-2.2.0-SNAPSHOT.jar:na]
+	at init.InitialData.enterDataDemo2(InitialData.java:118) ~[classes/:na]
+	at init.InitialData.init(InitialData.java:43) ~[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
+
+2012-11-13 05:42:17,743 - [INFO] - from application in play-akka.actor.default-dispatcher-1 
+Application shutdown...
+
+2012-11-13 05:42:17,772 - [INFO] - from play in play-akka.actor.default-dispatcher-1 
 Application started (Dev)
 
-2012-11-13 04:53:22,651 - [INFO] - from application in main 
+2012-11-13 05:42:48,349 - [INFO] - from application in play-akka.actor.default-dispatcher-1 
+Application shutdown...
+
+2012-11-13 05:42:48,374 - [INFO] - from play in play-akka.actor.default-dispatcher-1 
+Application started (Dev)
+
+2012-11-13 05:43:02,345 - [INFO] - from application in play-akka.actor.default-dispatcher-4 
+Application shutdown...
+
+2012-11-13 05:43:02,367 - [INFO] - from play in play-akka.actor.default-dispatcher-4 
+Application started (Dev)
+
+2012-11-13 05:43:22,901 - [INFO] - from application in play-akka.actor.default-dispatcher-4 
 Application shutdown...
 
+2012-11-13 05:43:22,923 - [INFO] - from play in play-akka.actor.default-dispatcher-4 
+Application started (Dev)
+
+2012-11-13 05:43:44,930 - [INFO] - from application in play-akka.actor.default-dispatcher-1 
+Application shutdown...
+
+2012-11-13 05:43:44,955 - [INFO] - from play in play-akka.actor.default-dispatcher-1 
+Application started (Dev)
+
+2012-11-13 05:43:49,353 - [INFO] - from application in play-akka.actor.default-dispatcher-4 
+Application shutdown...
+
+2012-11-13 05:43:49,375 - [INFO] - from play in play-akka.actor.default-dispatcher-4 
+Application started (Dev)
+
+2012-11-13 05:44:19,831 - [INFO] - from application in play-akka.actor.default-dispatcher-4 
+Application shutdown...
+
+2012-11-13 05:44:19,854 - [INFO] - from play in play-akka.actor.default-dispatcher-4 
+Application started (Dev)
+
Binary file target/scala-2.9.1/cache/compile/compile has changed