Mercurial > hg > Members > nobuyasu > Consensus
changeset 37:bc3ac73320f9
fix const value FAILED from FAIL
line wrap: on
line diff
--- a/app/controllers/Claim.java Thu Oct 04 00:01:40 2012 +0900 +++ b/app/controllers/Claim.java Thu Oct 04 00:31:09 2012 +0900 @@ -31,12 +31,15 @@ return badRequest("Please set title"); } JsonNode usersJson = json.get(NodeModel.USERS); // Users (class JsonNode) + if (usersJson == null) { + return badRequest("Please set users"); + } String type = json.findPath(NodeModel.TYPE).getTextValue(); // Type (majority|unanimously) ClaimModel newClaim = new ClaimModel(graph.addVertex(null)); tpGraph.setLabelToAuthor(newClaim, author); newClaim.setClaimProperties(toulmin, type); String[] users = toStringArray(usersJson); - Boolean flag = tpGraph.setLabelStatusToUsers(newClaim, users, NodeModel.L_REQUEST, NodeModel.FAIL); + tpGraph.setLabelStatusToUsers(newClaim, users, NodeModel.L_REQUEST, NodeModel.UNKNOWN); tpGraph.setLabelToRootClaim(newClaim); return created(); } @@ -62,6 +65,9 @@ return badRequest("Please set title"); } JsonNode usersJson = json.get(NodeModel.USERS); + if (usersJson == null) { + return badRequest("Please set users"); + } String type = json.findPath(NodeModel.TYPE).getTextValue(); // Type (majority|unanimously) claim.setClaimProperties(toulmin, type); Object[] users = toStringObject(usersJson); @@ -90,12 +96,15 @@ return badRequest("Please set title"); } JsonNode usersJson = json.get(NodeModel.USERS); // Users (class JsonNode) + if (usersJson == null) { + return badRequest("Please set users"); + } String type = json.findPath(NodeModel.TYPE).getTextValue(); // Type (majority|unanimously) ClaimModel newClaim = new ClaimModel(graph.addVertex(null)); tpGraph.setLabelToAuthor(newClaim, author); newClaim.setClaimProperties(toulmin, type); String[] users = toStringArray(usersJson); - tpGraph.setLabelStatusToUsers(newClaim, users, NodeModel.L_REQUEST, NodeModel.FAIL); + tpGraph.setLabelStatusToUsers(newClaim, users, NodeModel.L_REQUEST, NodeModel.UNKNOWN); tpGraph.setLabelToRootClaim(newClaim); ClaimModel mentionV = new ClaimModel(graph.getVertex(id)); tpGraph.setLabelMention(mentionV, newClaim, mentionType); @@ -129,6 +138,9 @@ } private static Object[] toStringObject(JsonNode jsonNode) { + if (jsonNode == null) { + return null; + } int length = jsonNode.size(); if (length == 0) { return null; @@ -141,6 +153,9 @@ } private static String[] toStringArray(JsonNode jsonNode) { + if (jsonNode == null) { + return null; + } int length = jsonNode.size(); if (length == 0) { return null;
--- a/app/models/ClaimModel.java Thu Oct 04 00:01:40 2012 +0900 +++ b/app/models/ClaimModel.java Thu Oct 04 00:31:09 2012 +0900 @@ -142,7 +142,7 @@ t.put(BACKING, b); t.put(REBUTTLE, r); setProperty(TYPE, type); - setProperty(STATUS, FAIL); // Default Status is fail. + setProperty(STATUS, UNKNOWN); // Default Status is unknown. setProperty(TOULMIN, t); } }
--- a/app/models/NodeModel.java Thu Oct 04 00:01:40 2012 +0900 +++ b/app/models/NodeModel.java Thu Oct 04 00:31:09 2012 +0900 @@ -45,7 +45,7 @@ public static final String STATUS = "status"; // Status statement public static final String PASS = "pass"; - public static final String FAIL = "fail"; + public static final String FAILED = "failed"; public static final String AGREED = "agreed"; public static final String DENIED = "denied"; public static final String UNKNOWN = "unknown";
Binary file target/scala-2.9.1/classes/Routes$$anonfun$routes$1$$anonfun$apply$1$$anonfun$apply$2.class has changed
Binary file target/scala-2.9.1/classes/Routes$$anonfun$routes$1$$anonfun$apply$3$$anonfun$apply$4.class has changed
Binary file target/scala-2.9.1/classes/Routes$$anonfun$routes$1$$anonfun$apply$5$$anonfun$apply$6.class has changed
Binary file target/scala-2.9.1/classes/controllers/ref/ReverseApplication$$anonfun$hello$1.class has changed
Binary file target/scala-2.9.1/classes/controllers/ref/ReverseApplication$$anonfun$index$1.class has changed
Binary file target/scala-2.9.1/classes/controllers/ref/ReverseAssets$$anonfun$at$1.class has changed
--- a/target/scala-2.9.1/classes/routes Thu Oct 04 00:01:40 2012 +0900 +++ b/target/scala-2.9.1/classes/routes Thu Oct 04 00:31:09 2012 +0900 @@ -15,6 +15,7 @@ POST /claims/create controllers.Claim.crateClaim() POST /claims/:mentionType/:id/create controllers.Claim.createMention(mentionType: String ,id: String) +POST /claims/edit/:id controllers.Claim.editClaim(id: String) GET /consensus/browse/:id controllers.Claim.getClaimTree(id: String)
Binary file target/scala-2.9.1/classes_managed/Routes$$anonfun$routes$1$$anonfun$apply$1$$anonfun$apply$2.class has changed
Binary file target/scala-2.9.1/classes_managed/Routes$$anonfun$routes$1$$anonfun$apply$1.class has changed
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/Routes$$anonfun$routes$1$$anonfun$apply$5$$anonfun$apply$6.class has changed
Binary file target/scala-2.9.1/classes_managed/Routes$$anonfun$routes$1$$anonfun$apply$5.class has changed
Binary file target/scala-2.9.1/classes_managed/controllers/javascript/ReverseApplication.class has changed
Binary file target/scala-2.9.1/classes_managed/controllers/javascript/ReverseAssets.class has changed
Binary file target/scala-2.9.1/classes_managed/controllers/ref/ReverseApplication$$anonfun$hello$1.class has changed
Binary file target/scala-2.9.1/classes_managed/controllers/ref/ReverseApplication$$anonfun$index$1.class has changed
Binary file target/scala-2.9.1/classes_managed/controllers/ref/ReverseAssets$$anonfun$at$1.class has changed
--- a/target/scala-2.9.1/src_managed/main/controllers/routes.java Thu Oct 04 00:01:40 2012 +0900 +++ b/target/scala-2.9.1/src_managed/main/controllers/routes.java Thu Oct 04 00:31:09 2012 +0900 @@ -1,6 +1,6 @@ // @SOURCE:/Users/aotokage/workspace/Consensus/conf/routes -// @HASH:f5c672b7256d9fa8e950b3ac1ed290083dabeefe -// @DATE:Wed Oct 03 15:56:50 JST 2012 +// @HASH:9e0fa937ed92ecd1dae3165cbcac7424dc77d60f +// @DATE:Wed Oct 03 23:35:23 JST 2012 package controllers;
--- a/target/scala-2.9.1/src_managed/main/routes_reverseRouting.scala Thu Oct 04 00:01:40 2012 +0900 +++ b/target/scala-2.9.1/src_managed/main/routes_reverseRouting.scala Thu Oct 04 00:31:09 2012 +0900 @@ -1,6 +1,6 @@ // @SOURCE:/Users/aotokage/workspace/Consensus/conf/routes -// @HASH:f5c672b7256d9fa8e950b3ac1ed290083dabeefe -// @DATE:Wed Oct 03 15:56:50 JST 2012 +// @HASH:9e0fa937ed92ecd1dae3165cbcac7424dc77d60f +// @DATE:Wed Oct 03 23:35:23 JST 2012 import play.core._ import play.core.Router._ @@ -12,9 +12,10 @@ import Router.queryString -// @LINE:27 +// @LINE:28 +// @LINE:24 // @LINE:23 -// @LINE:22 +// @LINE:19 // @LINE:18 // @LINE:17 // @LINE:16 @@ -28,6 +29,7 @@ // @LINE:6 package controllers { +// @LINE:19 // @LINE:18 // @LINE:17 // @LINE:16 @@ -45,16 +47,8 @@ // @LINE:18 -// @LINE:14 -def getClaimTree(id:String) = { - (id) match { -// @LINE:14 -case (id) if true => Call("GET", "/claims/consensus/" + implicitly[PathBindable[String]].unbind("id", id)) - -// @LINE:18 -case (id) if true => Call("GET", "/consensus/browse/" + implicitly[PathBindable[String]].unbind("id", id)) - - } +def editClaim(id:String) = { + Call("POST", "/claims/edit/" + implicitly[PathBindable[String]].unbind("id", id)) } @@ -69,21 +63,35 @@ Call("GET", "/claims/browse/" + implicitly[PathBindable[String]].unbind("id", id)) } + +// @LINE:19 +// @LINE:14 +def getClaimTree(id:String) = { + (id) match { +// @LINE:14 +case (id) if true => Call("GET", "/claims/consensus/" + implicitly[PathBindable[String]].unbind("id", id)) + +// @LINE:19 +case (id) if true => Call("GET", "/consensus/browse/" + implicitly[PathBindable[String]].unbind("id", id)) + + } +} + } +// @LINE:24 // @LINE:23 -// @LINE:22 // @LINE:6 class ReverseApplication { -// @LINE:23 +// @LINE:24 def test() = { Call("GET", "/test") } @@ -95,7 +103,7 @@ } -// @LINE:22 +// @LINE:23 def hello() = { Call("POST", "/hello") } @@ -106,13 +114,13 @@ } -// @LINE:27 +// @LINE:28 class ReverseAssets { -// @LINE:27 +// @LINE:28 def at(file:String) = { Call("GET", "/assets/" + implicitly[PathBindable[String]].unbind("file", file)) } @@ -171,9 +179,10 @@ -// @LINE:27 +// @LINE:28 +// @LINE:24 // @LINE:23 -// @LINE:22 +// @LINE:19 // @LINE:18 // @LINE:17 // @LINE:16 @@ -187,6 +196,7 @@ // @LINE:6 package controllers.javascript { +// @LINE:19 // @LINE:18 // @LINE:17 // @LINE:16 @@ -209,17 +219,11 @@ // @LINE:18 -// @LINE:14 -def getClaimTree = JavascriptReverseRoute( - "controllers.Claim.getClaimTree", +def editClaim = JavascriptReverseRoute( + "controllers.Claim.editClaim", """ function(id) { - if (true) { - return _wA({method:"GET", url:"/claims/consensus/" + (""" + implicitly[PathBindable[String]].javascriptUnbind + """)("id", id)}) - } - if (true) { - return _wA({method:"GET", url:"/consensus/browse/" + (""" + implicitly[PathBindable[String]].javascriptUnbind + """)("id", id)}) - } + return _wA({method:"POST", url:"/claims/edit/" + (""" + implicitly[PathBindable[String]].javascriptUnbind + """)("id", id)}) } """ ) @@ -246,21 +250,38 @@ """ ) + +// @LINE:19 +// @LINE:14 +def getClaimTree = JavascriptReverseRoute( + "controllers.Claim.getClaimTree", + """ + function(id) { + if (true) { + return _wA({method:"GET", url:"/claims/consensus/" + (""" + implicitly[PathBindable[String]].javascriptUnbind + """)("id", id)}) + } + if (true) { + return _wA({method:"GET", url:"/consensus/browse/" + (""" + implicitly[PathBindable[String]].javascriptUnbind + """)("id", id)}) + } + } + """ +) + } +// @LINE:24 // @LINE:23 -// @LINE:22 // @LINE:6 class ReverseApplication { -// @LINE:23 +// @LINE:24 def test = JavascriptReverseRoute( "controllers.Application.test", """ @@ -282,7 +303,7 @@ ) -// @LINE:22 +// @LINE:23 def hello = JavascriptReverseRoute( "controllers.Application.hello", """ @@ -298,13 +319,13 @@ } -// @LINE:27 +// @LINE:28 class ReverseAssets { -// @LINE:27 +// @LINE:28 def at = JavascriptReverseRoute( "controllers.Assets.at", """ @@ -393,9 +414,10 @@ -// @LINE:27 +// @LINE:28 +// @LINE:24 // @LINE:23 -// @LINE:22 +// @LINE:19 // @LINE:18 // @LINE:17 // @LINE:16 @@ -409,6 +431,7 @@ // @LINE:6 package controllers.ref { +// @LINE:19 // @LINE:18 // @LINE:17 // @LINE:16 @@ -425,9 +448,9 @@ ) -// @LINE:14 -def getClaimTree(id:String) = new play.api.mvc.HandlerRef( - controllers.Claim.getClaimTree(id), HandlerDef(this, "controllers.Claim", "getClaimTree", Seq(classOf[String])) +// @LINE:18 +def editClaim(id:String) = new play.api.mvc.HandlerRef( + controllers.Claim.editClaim(id), HandlerDef(this, "controllers.Claim", "editClaim", Seq(classOf[String])) ) @@ -442,21 +465,27 @@ controllers.Claim.getClaimInfo(id), HandlerDef(this, "controllers.Claim", "getClaimInfo", Seq(classOf[String])) ) + +// @LINE:14 +def getClaimTree(id:String) = new play.api.mvc.HandlerRef( + controllers.Claim.getClaimTree(id), HandlerDef(this, "controllers.Claim", "getClaimTree", Seq(classOf[String])) +) + } +// @LINE:24 // @LINE:23 -// @LINE:22 // @LINE:6 class ReverseApplication { -// @LINE:23 +// @LINE:24 def test() = new play.api.mvc.HandlerRef( controllers.Application.test(), HandlerDef(this, "controllers.Application", "test", Seq()) ) @@ -468,7 +497,7 @@ ) -// @LINE:22 +// @LINE:23 def hello() = new play.api.mvc.HandlerRef( controllers.Application.hello(), HandlerDef(this, "controllers.Application", "hello", Seq()) ) @@ -479,13 +508,13 @@ } -// @LINE:27 +// @LINE:28 class ReverseAssets { -// @LINE:27 +// @LINE:28 def at(path:String, file:String) = new play.api.mvc.HandlerRef( controllers.Assets.at(path, file), HandlerDef(this, "controllers.Assets", "at", Seq(classOf[String], classOf[String])) )
--- a/target/scala-2.9.1/src_managed/main/routes_routing.scala Thu Oct 04 00:01:40 2012 +0900 +++ b/target/scala-2.9.1/src_managed/main/routes_routing.scala Thu Oct 04 00:31:09 2012 +0900 @@ -1,6 +1,6 @@ // @SOURCE:/Users/aotokage/workspace/Consensus/conf/routes -// @HASH:f5c672b7256d9fa8e950b3ac1ed290083dabeefe -// @DATE:Wed Oct 03 15:56:50 JST 2012 +// @HASH:9e0fa937ed92ecd1dae3165cbcac7424dc77d60f +// @DATE:Wed Oct 03 23:35:23 JST 2012 import play.core._ import play.core.Router._ @@ -55,21 +55,25 @@ // @LINE:18 -val controllers_Claim_getClaimTree10 = Route("GET", PathPattern(List(StaticPart("/consensus/browse/"),DynamicPart("id", """[^/]+""")))) +val controllers_Claim_editClaim10 = Route("POST", PathPattern(List(StaticPart("/claims/edit/"),DynamicPart("id", """[^/]+""")))) -// @LINE:22 -val controllers_Application_hello11 = Route("POST", PathPattern(List(StaticPart("/hello")))) +// @LINE:19 +val controllers_Claim_getClaimTree11 = Route("GET", PathPattern(List(StaticPart("/consensus/browse/"),DynamicPart("id", """[^/]+""")))) // @LINE:23 -val controllers_Application_test12 = Route("GET", PathPattern(List(StaticPart("/test")))) +val controllers_Application_hello12 = Route("POST", PathPattern(List(StaticPart("/hello")))) -// @LINE:27 -val controllers_Assets_at13 = Route("GET", PathPattern(List(StaticPart("/assets/"),DynamicPart("file", """.+""")))) +// @LINE:24 +val controllers_Application_test13 = Route("GET", PathPattern(List(StaticPart("/test")))) -def documentation = List(("""GET""","""/""","""controllers.Application.index()"""),("""PUT""","""/users/create/$name<[^/]+>""","""controllers.User.createUser(name:String)"""),("""GET""","""/users/browse/$name<[^/]+>""","""controllers.User.getUser(name:String)"""),("""GET""","""/users/requests/$name<[^/]+>""","""controllers.User.getUserRequests(name:String)"""),("""GET""","""/users/consensus/$name<[^/]+>""","""controllers.User.getUserConsensus(name:String)"""),("""GET""","""/users/claims/$name<[^/]+>""","""controllers.User.getUserClaims(name:String)"""),("""GET""","""/claims/browse/$id<[^/]+>""","""controllers.Claim.getClaimInfo(id:String)"""),("""GET""","""/claims/consensus/$id<[^/]+>""","""controllers.Claim.getClaimTree(id:String)"""),("""POST""","""/claims/create""","""controllers.Claim.crateClaim()"""),("""POST""","""/claims/$mentionType<[^/]+>/$id<[^/]+>/create""","""controllers.Claim.createMention(mentionType:String, id:String)"""),("""GET""","""/consensus/browse/$id<[^/]+>""","""controllers.Claim.getClaimTree(id:String)"""),("""POST""","""/hello""","""controllers.Application.hello()"""),("""GET""","""/test""","""controllers.Application.test()"""),("""GET""","""/assets/$file<.+>""","""controllers.Assets.at(path:String = "/public", file:String)""")) + +// @LINE:28 +val controllers_Assets_at14 = Route("GET", PathPattern(List(StaticPart("/assets/"),DynamicPart("file", """.+""")))) + +def documentation = List(("""GET""","""/""","""controllers.Application.index()"""),("""PUT""","""/users/create/$name<[^/]+>""","""controllers.User.createUser(name:String)"""),("""GET""","""/users/browse/$name<[^/]+>""","""controllers.User.getUser(name:String)"""),("""GET""","""/users/requests/$name<[^/]+>""","""controllers.User.getUserRequests(name:String)"""),("""GET""","""/users/consensus/$name<[^/]+>""","""controllers.User.getUserConsensus(name:String)"""),("""GET""","""/users/claims/$name<[^/]+>""","""controllers.User.getUserClaims(name:String)"""),("""GET""","""/claims/browse/$id<[^/]+>""","""controllers.Claim.getClaimInfo(id:String)"""),("""GET""","""/claims/consensus/$id<[^/]+>""","""controllers.Claim.getClaimTree(id:String)"""),("""POST""","""/claims/create""","""controllers.Claim.crateClaim()"""),("""POST""","""/claims/$mentionType<[^/]+>/$id<[^/]+>/create""","""controllers.Claim.createMention(mentionType:String, id:String)"""),("""POST""","""/claims/edit/$id<[^/]+>""","""controllers.Claim.editClaim(id:String)"""),("""GET""","""/consensus/browse/$id<[^/]+>""","""controllers.Claim.getClaimTree(id:String)"""),("""POST""","""/hello""","""controllers.Application.hello()"""),("""GET""","""/test""","""controllers.Application.test()"""),("""GET""","""/assets/$file<.+>""","""controllers.Assets.at(path:String = "/public", file:String)""")) def routes:PartialFunction[RequestHeader,Handler] = { @@ -155,31 +159,39 @@ // @LINE:18 -case controllers_Claim_getClaimTree10(params) => { +case controllers_Claim_editClaim10(params) => { + call(params.fromPath[String]("id", None)) { (id) => + invokeHandler(_root_.controllers.Claim.editClaim(id), HandlerDef(this, "controllers.Claim", "editClaim", Seq(classOf[String]))) + } +} + + +// @LINE:19 +case controllers_Claim_getClaimTree11(params) => { call(params.fromPath[String]("id", None)) { (id) => invokeHandler(_root_.controllers.Claim.getClaimTree(id), HandlerDef(this, "controllers.Claim", "getClaimTree", Seq(classOf[String]))) } } -// @LINE:22 -case controllers_Application_hello11(params) => { +// @LINE:23 +case controllers_Application_hello12(params) => { call { invokeHandler(_root_.controllers.Application.hello(), HandlerDef(this, "controllers.Application", "hello", Nil)) } } -// @LINE:23 -case controllers_Application_test12(params) => { +// @LINE:24 +case controllers_Application_test13(params) => { call { invokeHandler(_root_.controllers.Application.test(), HandlerDef(this, "controllers.Application", "test", Nil)) } } -// @LINE:27 -case controllers_Assets_at13(params) => { +// @LINE:28 +case controllers_Assets_at14(params) => { call(Param[String]("path", Right("/public")), params.fromPath[String]("file", None)) { (path, file) => invokeHandler(_root_.controllers.Assets.at(path, file), HandlerDef(this, "controllers.Assets", "at", Seq(classOf[String], classOf[String]))) }
--- a/test/RequestTest.java Thu Oct 04 00:01:40 2012 +0900 +++ b/test/RequestTest.java Thu Oct 04 00:31:09 2012 +0900 @@ -31,8 +31,6 @@ getClaimInfo(user1Claim.get(0).asInt()); editClaimInfo(user1, users2, user1Claim.get(0).asInt()); getClaimInfo(user1Claim.get(0).asInt()); - -/* String[] users3 = {user1}; for (int i=0; i<user1Claim.size(); i++) { int claimId = user1Claim.get(i).asInt(); @@ -54,7 +52,6 @@ getClaimInfo(user1Claim.get(i).asInt()); break; } - */ } public static JsonNode editClaimInfo(String author, String[] users, int id) { @@ -129,7 +126,7 @@ jobj.put(NodeModel.L_AUTHOR, author); ArrayNode usersArray = jobj.putArray(NodeModel.USERS); for (String u : users) usersArray.add(u); - jobj.put(NodeModel.TYPE, NodeModel.UNANIMOUSLY); + jobj.put(NodeModel.TYPE, NodeModel.MAJORITY ); return jobj; }