Mercurial > hg > Members > nobuyasu > Consensus
diff app/models/UserModel.java @ 20:34ea98c5a18c
modified UserModel/getEdgeInUser
author | one |
---|---|
date | Tue, 02 Oct 2012 22:49:16 +0900 |
parents | c8ad59a52c7e |
children | e113f946c9c1 |
line wrap: on
line diff
--- a/app/models/UserModel.java Tue Oct 02 21:52:17 2012 +0900 +++ b/app/models/UserModel.java Tue Oct 02 22:49:16 2012 +0900 @@ -1,18 +1,7 @@ package models; -import java.util.HashMap; -import java.util.Iterator; - - +import java.util.ArrayList; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.node.ArrayNode; -import org.codehaus.jackson.node.JsonNodeFactory; - -import play.libs.Json; - -import com.tinkerpop.blueprints.Direction; -import com.tinkerpop.blueprints.Edge; import com.tinkerpop.blueprints.Vertex; import com.tinkerpop.gremlin.java.GremlinPipeline; @@ -26,15 +15,12 @@ private Object[] getEdgeInUser(String labels) { GremlinPipeline<Vertex,Vertex> pipe = new GremlinPipeline<Vertex,Vertex>(); pipe.start(this.vertex).in(labels); - long length = pipe.count(); - if (length == 0) return null; - Object[] requests = new Object[(int) length]; - int i = 0; - for (Vertex v :pipe) { - requests[i] = v.getId(); - i++; + ArrayList<Object> array = new ArrayList<Object>(); + for (Vertex v : pipe) { + array.add(v.getId()); } - return requests; + if (array.size() == 0) return null; + return array.toArray(); } public Object[] getUserRequests() { @@ -49,24 +35,6 @@ return null; } - public void appendRequests(Vertex claimVertex) { - Object[] requestsObj = getUserRequests(); - int length = requestsObj == null ? 0 : requestsObj.length; - Object[] newRequestsObj = new Object[length+1]; - for (int i=0; i<length; i++ ) { - newRequestsObj[i] = requestsObj[i]; - } - newRequestsObj[length] = claimVertex.getId(); -// vertex.setProperty(REQUESTS, newRequestsObj); - } - -/* - public Vertex setName(String name) { - this.vertex.setProperty(NAME, name); - return vertex; - } -*/ - - + }