# HG changeset patch # User one # Date 1349257429 -32400 # Node ID 5d422941b70255ff2c4a1c227c165731f781a9e1 # Parent fac4aa26ea04b0e0df569bd00b06e01f4e35034d fix diff -r fac4aa26ea04 -r 5d422941b702 app/controllers/Claim.java --- a/app/controllers/Claim.java Wed Oct 03 16:58:34 2012 +0900 +++ b/app/controllers/Claim.java Wed Oct 03 18:43:49 2012 +0900 @@ -42,6 +42,35 @@ } @BodyParser.Of(BodyParser.Json.class) + public static Result editClaim(String id) { + JsonNode json = request().body().asJson(); + String author = json.findPath(NodeModel.L_AUTHOR).getTextValue(); // Author + TPGraph tpGraph = TPGraph.getInstance(); + Graph graph = tpGraph.getGraph(); + Vertex claimVertex = graph.getVertex(id); + if ( claimVertex == null ) { + return badRequest("Claim id "+ id + "is not exist."); + } + if ( graph.getVertex(author) == null) { + return badRequest("Author "+ author + "is not exist."); + } + JsonNode toulmin = json.findPath(NodeModel.TOULMIN); + if (toulmin.findPath(NodeModel.TITLE) == null) { + return badRequest("Please set title"); + } + JsonNode usersJson = json.get(NodeModel.USERS); + String type = json.findPath(NodeModel.TYPE).getTextValue(); // Type (majority|unanimously) + ClaimModel claim = new ClaimModel(claimVertex); + tpGraph.setLabelToAuthor(claim, author); + claim.setClaimProperties(toulmin, type); + String[] users = toStringArray(usersJson); + tpGraph.setLabelStatusToUsers(claim, users, NodeModel.L_REQUEST, NodeModel.FAIL); + tpGraph.setLabelToRootClaim(claim); + return created(); + } + + + @BodyParser.Of(BodyParser.Json.class) public static Result createMention(String mentionType, String id) { if ( !(mentionType.equals(NodeModel.L_QUESTION) ||mentionType.equals(NodeModel.L_REFUTATION) @@ -83,7 +112,7 @@ ObjectNode claimInfo = claim.getSimpleClaimInfo(); ObjectNode result = Json.newObject(); result.put("status", "OK"); - result.put("message", claimInfo.toString()); + result.put("message", claimInfo); return ok(result); } @@ -98,6 +127,8 @@ ObjectNode resultEntity = consensusRoot.getClaimInfoTraverse(); return ok(resultEntity); } + + diff -r fac4aa26ea04 -r 5d422941b702 app/controllers/User.java --- a/app/controllers/User.java Wed Oct 03 16:58:34 2012 +0900 +++ b/app/controllers/User.java Wed Oct 03 18:43:49 2012 +0900 @@ -15,7 +15,6 @@ public class User extends Controller { public static Result createUser(String name) { - TPGraph tpGraph = TPGraph.getInstance(); Graph graph = tpGraph.getGraph(); Vertex v = null; @@ -23,7 +22,7 @@ try { v = graph.addVertex(name); } catch (IllegalArgumentException e) { - return status(CONFLICT, name+" is already exists"); + return status(CONFLICT, name+" already exists"); } newUser = new UserModel(v); tpGraph.setLabelToRootUser(newUser); diff -r fac4aa26ea04 -r 5d422941b702 app/models/TPGraph.java --- a/app/models/TPGraph.java Wed Oct 03 16:58:34 2012 +0900 +++ b/app/models/TPGraph.java Wed Oct 03 18:43:49 2012 +0900 @@ -81,21 +81,18 @@ public Edge setLabelToRootUser(UserModel user) { Vertex rootUser = getUserRootVertex(); - // rootUser ---child---> newUser return setLabel(rootUser, user.getVertex(), CHILD); } public Edge setLabelToRootClaim(ClaimModel claim) { Vertex rootClaim = getClaimRootVertex(); - // rootUser ---child---> newUser return setLabel(rootClaim, claim.getVertex(), CHILD); } public Edge setLabelToAuthor(ClaimModel claim, String author) { Vertex authorVertex = graph.getVertex(author); - // claim ---author---> authorVertex(userVertex) return setLabel(claim.getVertex(), authorVertex, NodeModel.L_AUTHOR); } @@ -125,14 +122,12 @@ public Object[] checkConsensus(HashSet set) { Iterator iter = set.iterator(); - while (iter.hasNext()) { Object childId = iter.next(); ArrayList array = getAllUpperVertex(childId); for (Object parentId: array.toArray()) { if (set.contains(parentId)) { if (set.contains(childId)) { - // This behavior is anxiety. set.remove(childId); iter = set.iterator(); @@ -150,13 +145,11 @@ GremlinPipeline pipe = new GremlinPipeline(); pipe.start(startV).in(NodeModel.L_QUESTION, NodeModel.L_REFUTATION, NodeModel.L_SUGGESTION); ArrayList vertexArray = new ArrayList(); - while (pipe.hasNext()) { Object e = pipe.next().getId(); vertexArray.add(e); pipe.start(graph.getVertex(e)).in(NodeModel.L_QUESTION, NodeModel.L_REFUTATION, NodeModel.L_SUGGESTION); } - return vertexArray; } diff -r fac4aa26ea04 -r 5d422941b702 target/scala-2.9.1/cache/compile/compile Binary file target/scala-2.9.1/cache/compile/compile has changed diff -r fac4aa26ea04 -r 5d422941b702 test/RequestTest.java --- a/test/RequestTest.java Wed Oct 03 16:58:34 2012 +0900 +++ b/test/RequestTest.java Wed Oct 03 18:43:49 2012 +0900 @@ -43,16 +43,25 @@ getUserInfo(user3,"consensus/"); for (int i=0; i