Mercurial > hg > Members > nobuyasu > Consensus
changeset 92:35eeb04a788d draft
create getLatestClaimTree action. modified createMention action and viewer.html.
author | one |
---|---|
date | Tue, 12 Mar 2013 16:18:51 +0900 |
parents | 440b337b2182 |
children | d66ac07e1c36 |
files | app/controllers/Claim.java app/models/ClaimModel.java conf/routes |
diffstat | 3 files changed, 17 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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);
--- 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); }
--- 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