Mercurial > hg > Members > nobuyasu > Consensus
diff app/models/ClaimModel.java @ 32:be6bbd4967e4
create createMentions
author | one |
---|---|
date | Wed, 03 Oct 2012 16:47:44 +0900 |
parents | 995be14b30a2 |
children | 1ca28e3eb4e9 |
line wrap: on
line diff
--- a/app/models/ClaimModel.java Wed Oct 03 15:16:56 2012 +0900 +++ b/app/models/ClaimModel.java Wed Oct 03 16:47:44 2012 +0900 @@ -35,27 +35,30 @@ property.put(STATUS, Json.toJson(getProperty(STATUS))); property.put(TOULMIN, Json.toJson(getProperty(TOULMIN))); property.put(L_AUTHOR, Json.toJson(getAuthorId())); - property.put(MENTIONS, Json.toJson(getMentionsId())); + property.put(MENTIONS, Json.toJson(getClaimMentionsRecursive())); property.put(USERS, Json.toJson(getUsersIdAndStatus())); return property; } - public ObjectNode getClaimMentions() { + public Object[] getClaimMentionsRecursive() { GremlinPipeline<Vertex,Edge> pipe = new GremlinPipeline<Vertex,Edge>(); pipe.start(vertex).outE(L_QUESTION,L_REFUTATION,L_SUGGESTION); + ArrayList<Object> array = new ArrayList<Object>(); for (Edge e:pipe) { String label = e.getLabel(); - - + ObjectNode info = Json.newObject(); + info.put(TYPE, Json.toJson(label)); + info.put(STATUS, Json.toJson(e.getProperty(STATUS))); + GremlinPipeline<Edge,Vertex> pipeChildVertex = new GremlinPipeline<Edge,Vertex>(); + pipeChildVertex.start(e).inV(); + ClaimModel childClaim = new ClaimModel(pipeChildVertex.next()); + info.put(CLAIM, childClaim.getClaimInfoTraverse()); + info.put(MENTIONS, Json.toJson(childClaim.getClaimMentionsRecursive())); + array.add(info); } - return null; + return array.toArray(); } - - private JsonNode getClaimMention() { - - return null; - } - + public Object[] getInfoArray(String... labels) { GremlinPipeline<Vertex,Vertex> pipe = new GremlinPipeline<Vertex,Vertex>(); pipe.start(vertex).out(labels); @@ -80,7 +83,7 @@ for (Edge e : pipeEdge) { GremlinPipeline<Edge,Vertex> pipeChildVertex = new GremlinPipeline<Edge,Vertex>(); ObjectNode info = Json.newObject(); - pipeChildVertex.start(e).outV(); + pipeChildVertex.start(e).inV(); Vertex childVertex = pipeChildVertex.next(); info.put(ID, Json.toJson(childVertex.getId())); info.put(STATUS, Json.toJson(e.getProperty(STATUS))); @@ -97,14 +100,13 @@ public Object getAuthorId() { GremlinPipeline<Vertex,Vertex> pipe = new GremlinPipeline<Vertex,Vertex>(); pipe.start(vertex).out(L_AUTHOR); - if (pipe.hasNext()) return null; + if (!pipe.hasNext()) { + return null; + } Vertex authorV = pipe.next(); return authorV.getId(); } - - - public void setClaimProperties(JsonNode toulmin, String type) { String title = toulmin.findPath(TITLE).getTextValue(); String contents = toulmin.findPath(CONTENTS).getTextValue();