# HG changeset patch # User one # Date 1363072731 -32400 # Node ID 35eeb04a788dc05ee641722289f5751e08dcef8d # Parent 440b337b218298c146382d3d98602707dc86f54a create getLatestClaimTree action. modified createMention action and viewer.html. diff -r 440b337b2182 -r 35eeb04a788d app/controllers/Claim.java --- a/app/controllers/Claim.java Mon Mar 11 06:42:35 2013 +0900 +++ b/app/controllers/Claim.java Tue Mar 12 16:18:51 2013 +0900 @@ -144,14 +144,17 @@ String type = json.findPath(NodeModel.TYPE).getTextValue(); // Type (majority|unanimously) ClaimModel newClaim = new ClaimModel(tpGraph.addVertex(null)); tpGraph.setLabelToAuthor(newClaim, author); + String timestamp = Long.toString(System.currentTimeMillis()); newClaim.setClaimProperties(toulmin, type); String[] users = toStringArray(usersJson); tpGraph.setLabelStatusToUsers(newClaim, users, NodeModel.L_REQUEST, NodeModel.UNKNOWN); tpGraph.setLabelFromRootClaim(newClaim); ClaimModel targetClaim = new ClaimModel(tpGraph.getVertex(id)); - tpGraph.setLabelMention(targetClaim, newClaim, mentionType); + tpGraph.copyConsensusTree(targetClaim, timestamp); + ClaimModel latestTgtClaim = new ClaimModel(tpGraph.getVertex(tpGraph.getLatestVertexId(targetClaim.getId()))); + tpGraph.setLabelMention(latestTgtClaim, newClaim, mentionType); newClaim.computeAndUpdateStatus(); - targetClaim.computeAndUpdateStatus(); + latestTgtClaim.computeAndUpdateStatus(); return created(); } @@ -179,6 +182,12 @@ return ok(resultEntity); } + public static Result getLatestClaimTree(String id) { + TPGraph tpGraph = TPGraph.getInstance(); + String latestId = (tpGraph.getLatestVertexId(id)).toString(); + return getClaimTree(latestId); + } + public static Result getClaimRevision(String id) { TPGraph tpGraph = TPGraph.getInstance(); Object[] revision = tpGraph.getClaimRevision(id); diff -r 440b337b2182 -r 35eeb04a788d app/models/ClaimModel.java --- a/app/models/ClaimModel.java Mon Mar 11 06:42:35 2013 +0900 +++ b/app/models/ClaimModel.java Tue Mar 12 16:18:51 2013 +0900 @@ -21,6 +21,10 @@ } public void setClaimProperties(JsonNode toulmin, String type) { + setClaimProperties(toulmin, type, Long.toString(System.currentTimeMillis())); + } + + public void setClaimProperties(JsonNode toulmin, String type, String timestamp) { String title = toulmin.findPath(TITLE).getTextValue(); String contents = toulmin.findPath(CONTENTS).getTextValue(); String q = toulmin.findPath(QUALIFIER).getTextValue(); // Qualifier @@ -44,7 +48,7 @@ if (getProperty(STATUS) == null) { setProperty(STATUS, UNKNOWN); // Default Status is unknown. } - setProperty(TIMESTAMP, Long.toString(System.currentTimeMillis())); + setProperty(TIMESTAMP, timestamp); setProperty(TOULMIN, t); } diff -r 440b337b2182 -r 35eeb04a788d conf/routes --- a/conf/routes Mon Mar 11 06:42:35 2013 +0900 +++ b/conf/routes Tue Mar 12 16:18:51 2013 +0900 @@ -21,6 +21,7 @@ # latest GET /users/latest/consensus/:name controllers.User.getUserLatestConsensus(name: String) +GET /consensus/browse/latest/:id controllers.Claim.getLatestClaimTree(id: String) GET /users/latest/claims/:name controllers.User.getUserLatestClaims(name: String) # revision