Mercurial > hg > Members > nobuyasu > Consensus
diff app/models/ClaimModel.java @ 36:5f7fcdf98380
create editClaim
author | one |
---|---|
date | Thu, 04 Oct 2012 00:01:40 +0900 |
parents | fac4aa26ea04 |
children | bc3ac73320f9 |
line wrap: on
line diff
--- a/app/models/ClaimModel.java Wed Oct 03 18:43:49 2012 +0900 +++ b/app/models/ClaimModel.java Thu Oct 04 00:01:40 2012 +0900 @@ -1,6 +1,8 @@ package models; import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.node.ObjectNode; @@ -8,6 +10,7 @@ import play.libs.Json; import com.tinkerpop.blueprints.Edge; +import com.tinkerpop.blueprints.Graph; import com.tinkerpop.blueprints.Vertex; import com.tinkerpop.gremlin.java.GremlinPipeline; @@ -91,11 +94,27 @@ return array.toArray(); } - public Object[] getRequestUsersId() { return getInfoArray(NodeModel.REQUESTS); } + public void editRequestsEdgeUsers(Object[] updateUsers) { + TPGraph tpGraph = TPGraph.getInstance(); + Object[] currentUsers = getUsersId(); + HashSet<Object> currentUsersHashSet = new HashSet<Object>(); + for (Object u : currentUsers) { + currentUsersHashSet.add(u); + } + for (Object updateUser : updateUsers) { + if (currentUsersHashSet.contains(updateUser)) { + currentUsersHashSet.remove(updateUser); + } else { + tpGraph.setLabelStatusToUser(this, updateUser.toString(), L_REQUEST, UNKNOWN); + } + } + tpGraph.deleteRequestEdge(this, currentUsersHashSet); + } + public Object getAuthorId() { GremlinPipeline<Vertex,Vertex> pipe = new GremlinPipeline<Vertex,Vertex>(); pipe.start(vertex).out(L_AUTHOR);