diff app/controllers/Claim.java @ 34:fac4aa26ea04

fix
author one
date Wed, 03 Oct 2012 16:58:34 +0900
parents 1ca28e3eb4e9
children 5d422941b702
line wrap: on
line diff
--- a/app/controllers/Claim.java	Wed Oct 03 16:55:16 2012 +0900
+++ b/app/controllers/Claim.java	Wed Oct 03 16:58:34 2012 +0900
@@ -16,33 +16,28 @@
 import play.mvc.Result;
 
 public class Claim extends Controller {
-
 	
 	@BodyParser.Of(BodyParser.Json.class)
 	public static Result crateClaim() {
 		JsonNode json = request().body().asJson();
 		String author = json.findPath(NodeModel.L_AUTHOR).getTextValue(); // Author
-
 		TPGraph tpGraph = TPGraph.getInstance();
 		Graph graph = tpGraph.getGraph();
-		if ( graph.getVertex(author) == null) 
+		if ( graph.getVertex(author) == null) { 
 			return badRequest("Author "+ author + "is not exist.");
-		
+		}
 		JsonNode toulmin = json.findPath(NodeModel.TOULMIN);
-		if (toulmin.findPath(NodeModel.TITLE) == null) 
+		if (toulmin.findPath(NodeModel.TITLE) == null) { 
 			return badRequest("Please set title");
-
+		}
 		JsonNode usersJson = json.get(NodeModel.USERS); // Users (class JsonNode) 
 		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.setLabelToRootClaim(newClaim);
-		
 		return created();
 	}
 	
@@ -57,11 +52,13 @@
 		String author = json.findPath(NodeModel.L_AUTHOR).getTextValue(); // Author
 		TPGraph tpGraph = TPGraph.getInstance();
 		Graph graph = tpGraph.getGraph();
-		if ( graph.getVertex(author) == null) 
+		if ( graph.getVertex(author) == null) { 
 			return badRequest("Author "+ author + "is not exist.");
+		}
 		JsonNode toulmin = json.findPath(NodeModel.TOULMIN);
-		if (toulmin.findPath(NodeModel.TITLE) == null) 
+		if (toulmin.findPath(NodeModel.TITLE) == null) { 
 			return badRequest("Please set title");
+		}
 		JsonNode usersJson = json.get(NodeModel.USERS); // Users (class JsonNode) 
 		String type = json.findPath(NodeModel.TYPE).getTextValue(); // Type (majority|unanimously)		
 		ClaimModel newClaim = new ClaimModel(graph.addVertex(null));
@@ -79,7 +76,9 @@
 		TPGraph tpGraph = TPGraph.getInstance();
 		Graph graph = tpGraph.getGraph();
 		Vertex claimV = graph.getVertex(id); 
-		if (claimV == null) badRequest("Claim id "+id+" is not found.");
+		if (claimV == null) {
+			badRequest("Claim id "+id+" is not found.");
+		}
 		ClaimModel claim = new ClaimModel(claimV);
 		ObjectNode claimInfo = claim.getSimpleClaimInfo();
 		ObjectNode result = Json.newObject();
@@ -104,7 +103,9 @@
 	
 	private static String[] toStringArray(JsonNode jsonNode) {
 		int length = jsonNode.size();
-		if (length == 0) return null;
+		if (length == 0) {
+			return null;
+		}
 		String[] userArray = new String[length];
 		for (int i=0; i<length; i++ ) {
 			userArray[i] = jsonNode.get(i).getTextValue();