Mercurial > hg > Members > nobuyasu > Consensus
changeset 64:7121a35a61b9
modified InitialData.java
line wrap: on
line diff
--- a/app/Global.java Tue Nov 13 04:54:29 2012 +0900 +++ b/app/Global.java Tue Nov 13 05:26:27 2012 +0900 @@ -1,36 +1,15 @@ import init.InitialData; -import org.codehaus.jackson.node.ObjectNode; - -import models.ClaimModel; -import models.NodeModel; import models.TPGraph; -import models.UserModel; -import init.InitialData; - -import com.tinkerpop.blueprints.Graph; -import com.tinkerpop.blueprints.Vertex; - import play.Application; import play.GlobalSettings; import play.Logger; -import play.libs.Json; public class Global extends GlobalSettings { @Override public void onStart(Application app) { -/* - TPGraph tpGraph = TPGraph.getInstance(); - tpGraph.setPath(null); - Graph graph = tpGraph.getGraph(); - // Graph graph = tpGraph.newGraph(); - Vertex claimV = graph.addVertex(null); - tpGraph.setClaimRootId(claimV.getId()); - Vertex userV = graph.addVertex(null); - tpGraph.setUserRootId(userV.getId()); - */ - initialData(); + InitialData.init(); } @Override @@ -40,98 +19,4 @@ tpGraph.shutdownGraph(); TPGraph.resetInstance(); } - - - public void initialData() { - - InitialData.init(); - -/* - 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}; - String[] otherUser2 = {user1,user3}; - String[] otherUser3 = {user1,user2}; - - UserModel user1Model = new UserModel(graph.addVertex(user1)); - UserModel user2Model = new UserModel(graph.addVertex(user2)); - UserModel user3Model = new UserModel(graph.addVertex(user3)); - - tpGraph.setLabelToRootUser(user1Model); - tpGraph.setLabelToRootUser(user2Model); - tpGraph.setLabelToRootUser(user3Model); - - 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); -*/ - } - - private void createClaimForMention(ClaimModel claim, ObjectNode t, String author, String[] users, String type) { - createClaimSetToulmin(claim, t, author, users, type); - } - - private void createFirstClaim(ClaimModel claim, ObjectNode t, String author, String[] users, String type) { - TPGraph tpGraph = TPGraph.getInstance(); - createClaimSetToulmin(claim, t, author, users, type); - tpGraph.setLabelToRootClaim(claim); - } - - private void createClaimSetToulmin(ClaimModel claim, ObjectNode t, String author, String[] users, String type) { - TPGraph tpGraph = TPGraph.getInstance(); - tpGraph.setLabelToAuthor(claim, author); - claim.setClaimProperties(t, NodeModel.UNANIMOUSLY); - tpGraph.setLabelStatusToUsers(claim, users, NodeModel.L_REQUEST, type); - claim.computeAndUpdateStatus(); - } - - private ObjectNode createToulmin(String title) { - ObjectNode t = Json.newObject(); - t.put(NodeModel.TITLE, title); - t.put(NodeModel.CONTENTS,title); - t.put(NodeModel.QUALIFIER,""); - t.put(NodeModel.DATA,""); - t.put(NodeModel.WARRANT,""); - t.put(NodeModel.BACKING,""); - t.put(NodeModel.REBUTTLE,""); - return t; - } - - - - - }
--- a/app/init/InitialData.java Tue Nov 13 04:54:29 2012 +0900 +++ b/app/init/InitialData.java Tue Nov 13 05:26:27 2012 +0900 @@ -1,4 +1,6 @@ package init; +import java.util.ArrayList; + import models.ClaimModel; import models.NodeModel; import models.TPGraph; @@ -20,10 +22,78 @@ } public static void init() { - instance.initTinkerGraph(); + instance.enterDataDemo1(); + instance.enterDataDemo2(); } - public static void initTinkerGraph() { + public static void enterDataDemo2() { + TPGraph tpGraph = TPGraph.getInstance(); + Graph graph = tpGraph.getGraph(); + String tatsumi = "Tatsumi"; + String yana = "Yana"; + String ikuhiro = "Ikuhiro"; + String shiomi = "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); + + ClaimModel claimModel2 = new ClaimModel(graph.addVertex(null)); + ObjectNode t2 = createToulmin("壊れたマシンと同じ程度の物があればいいです。"); + String[] usersClaim2 = { tatsumi }; + createClaimForMention(claimModel2, t2, yana, usersClaim2, + NodeModel.DENIED); + tpGraph.setLabelMention(claimModel1, claimModel2, + NodeModel.L_SUGGESTION); + + ClaimModel claimModel3 = new ClaimModel(graph.addVertex(null)); + ObjectNode t3 = createToulmin("MacProの最新版がいいでしょう。"); + String[] usersClaim3 = { yana }; + createClaimForMention(claimModel3, t3, tatsumi, usersClaim3, + 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 }; + createClaimForMention(claimModel4, t4, tatsumi, usersClaim4, + NodeModel.DENIED); + tpGraph.setLabelMention(claimModel1, claimModel4, + NodeModel.L_SUGGESTION); + + ClaimModel claimModel5 = new ClaimModel(graph.addVertex(null)); + ObjectNode t5 = createToulmin("MacProの最新は高いのでやめましょう。"); + String[] usersClaim5 = { tatsumi}; + createClaimForMention(claimModel5, t5, shiomi, usersClaim5, + NodeModel.AGREED); + tpGraph.setLabelMention(claimModel4, claimModel5, + NodeModel.L_REFUTATION); + + ClaimModel claimModel6 = new ClaimModel(graph.addVertex(null)); + ObjectNode t6 = createToulmin("MacProの最速マシンである必要はありません。"); + String[] usersClaim6 = { tatsumi }; + createClaimForMention(claimModel6, t6, shiomi, usersClaim6, + NodeModel.AGREED); + tpGraph.setLabelMention(claimModel4, claimModel6, + NodeModel.L_REFUTATION); + + + } + + public static void enterDataDemo1() { TPGraph tpGraph = TPGraph.getInstance(); tpGraph.setPath(null); Graph graph = tpGraph.newGraph(); @@ -37,16 +107,14 @@ String user3 = "Yosiaki"; String[] otherUser1 = { user2, user3 }; - String[] otherUser2 = { user1, user3 }; - String[] otherUser3 = { user1, user2 }; - UserModel user1Model = new UserModel(graph.addVertex(user1)); - UserModel user2Model = new UserModel(graph.addVertex(user2)); - UserModel user3Model = new UserModel(graph.addVertex(user3)); + UserModel userModel1 = new UserModel(graph.addVertex(user1)); + UserModel userModel2 = new UserModel(graph.addVertex(user2)); + UserModel userModel3 = new UserModel(graph.addVertex(user3)); - tpGraph.setLabelToRootUser(user1Model); - tpGraph.setLabelToRootUser(user2Model); - tpGraph.setLabelToRootUser(user3Model); + tpGraph.setLabelToRootUser(userModel1); + tpGraph.setLabelToRootUser(userModel2); + tpGraph.setLabelToRootUser(userModel3); ClaimModel claimModel1 = new ClaimModel(graph.addVertex(null)); ObjectNode t1 = createToulmin("アプリでGraphDBを利用する。");
Binary file target/scala-2.9.1/classes_managed/Routes$$anonfun$routes$1$$anonfun$apply$3$$anonfun$apply$4.class has changed
Binary file target/scala-2.9.1/classes_managed/Routes$$anonfun$routes$1$$anonfun$apply$3.class has changed
Binary file target/scala-2.9.1/classes_managed/controllers/ref/ReverseApplication$$anonfun$hello$1.class has changed