annotate app/models/ClaimModel.java @ 55:3295c9fe2b3a

modified public/viewer
author one
date Thu, 04 Oct 2012 18:22:10 +0900
parents a405991e39d8
children db075978fcb1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
792fdb0c10bf add ClaimModel.java
one
parents:
diff changeset
1 package models;
792fdb0c10bf add ClaimModel.java
one
parents:
diff changeset
2
29
fbb232e78422 create getClaimInfo
one
parents: 28
diff changeset
3 import java.util.ArrayList;
36
5f7fcdf98380 create editClaim
one
parents: 34
diff changeset
4 import java.util.HashSet;
29
fbb232e78422 create getClaimInfo
one
parents: 28
diff changeset
5
16
7cdc9d19834f modified createClaim
one
parents: 14
diff changeset
6 import org.codehaus.jackson.JsonNode;
14
792fdb0c10bf add ClaimModel.java
one
parents:
diff changeset
7 import org.codehaus.jackson.node.ObjectNode;
792fdb0c10bf add ClaimModel.java
one
parents:
diff changeset
8
792fdb0c10bf add ClaimModel.java
one
parents:
diff changeset
9 import play.libs.Json;
792fdb0c10bf add ClaimModel.java
one
parents:
diff changeset
10
44
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
11 import com.tinkerpop.blueprints.Direction;
31
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
12 import com.tinkerpop.blueprints.Edge;
36
5f7fcdf98380 create editClaim
one
parents: 34
diff changeset
13 import com.tinkerpop.blueprints.Graph;
14
792fdb0c10bf add ClaimModel.java
one
parents:
diff changeset
14 import com.tinkerpop.blueprints.Vertex;
29
fbb232e78422 create getClaimInfo
one
parents: 28
diff changeset
15 import com.tinkerpop.gremlin.java.GremlinPipeline;
14
792fdb0c10bf add ClaimModel.java
one
parents:
diff changeset
16
792fdb0c10bf add ClaimModel.java
one
parents:
diff changeset
17 public class ClaimModel extends NodeModel {
792fdb0c10bf add ClaimModel.java
one
parents:
diff changeset
18
792fdb0c10bf add ClaimModel.java
one
parents:
diff changeset
19 public ClaimModel(Vertex vertex) {
792fdb0c10bf add ClaimModel.java
one
parents:
diff changeset
20 super(vertex);
792fdb0c10bf add ClaimModel.java
one
parents:
diff changeset
21 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
22
47
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
23 public void setClaimProperties(JsonNode toulmin, String type) {
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
24 String title = toulmin.findPath(TITLE).getTextValue();
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
25 String contents = toulmin.findPath(CONTENTS).getTextValue();
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
26 String q = toulmin.findPath(QUALIFIER).getTextValue(); // Qualifier
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
27 String d = toulmin.findPath(DATA).getTextValue(); // Data
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
28 String w = toulmin.findPath(WARRANT).getTextValue(); // Warrant
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
29 String b = toulmin.findPath(BACKING).getTextValue(); // Backing
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
30 String r = toulmin.findPath(REBUTTLE).getTextValue(); // Rebuttle
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
31 ObjectNode t = Json.newObject();
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
32 t.put(TITLE, title);
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
33 t.put(CONTENTS, contents);
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
34 t.put(QUALIFIER, q);
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
35 t.put(DATA, d);
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
36 t.put(WARRANT, w);
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
37 t.put(BACKING, b);
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
38 t.put(REBUTTLE, r);
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
39 if (type == null) {
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
40 setProperty(TYPE, UNANIMOUSLY);
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
41 } else {
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
42 setProperty(TYPE, type);
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
43 }
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
44 if (getProperty(STATUS) == null) {
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
45 setProperty(STATUS, UNKNOWN); // Default Status is unknown.
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
46 }
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
47 setProperty(TOULMIN, t);
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
48 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
49
31
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
50 public ObjectNode getSimpleClaimInfo() {
29
fbb232e78422 create getClaimInfo
one
parents: 28
diff changeset
51 ObjectNode property = Json.newObject();
fbb232e78422 create getClaimInfo
one
parents: 28
diff changeset
52 property.put(TYPE, Json.toJson(getProperty(TYPE)));
fbb232e78422 create getClaimInfo
one
parents: 28
diff changeset
53 property.put(STATUS, Json.toJson(getProperty(STATUS)));
fbb232e78422 create getClaimInfo
one
parents: 28
diff changeset
54 property.put(TOULMIN, Json.toJson(getProperty(TOULMIN)));
30
80b5628f17d8 modified ClaimModel/getInfo action
one
parents: 29
diff changeset
55 property.put(L_AUTHOR, Json.toJson(getAuthorId()));
80b5628f17d8 modified ClaimModel/getInfo action
one
parents: 29
diff changeset
56 property.put(MENTIONS, Json.toJson(getMentionsId()));
31
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
57 property.put(USERS, Json.toJson(getUsersId()));
29
fbb232e78422 create getClaimInfo
one
parents: 28
diff changeset
58 return property;
fbb232e78422 create getClaimInfo
one
parents: 28
diff changeset
59 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
60
31
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
61 public ObjectNode getClaimInfoTraverse() {
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
62 ObjectNode property = Json.newObject();
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
63 property.put(TYPE, Json.toJson(getProperty(TYPE)));
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
64 property.put(STATUS, Json.toJson(getProperty(STATUS)));
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
65 property.put(TOULMIN, Json.toJson(getProperty(TOULMIN)));
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
66 property.put(L_AUTHOR, Json.toJson(getAuthorId()));
32
be6bbd4967e4 create createMentions
one
parents: 31
diff changeset
67 property.put(MENTIONS, Json.toJson(getClaimMentionsRecursive()));
31
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
68 property.put(USERS, Json.toJson(getUsersIdAndStatus()));
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
69 return property;
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
70 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
71
32
be6bbd4967e4 create createMentions
one
parents: 31
diff changeset
72 public Object[] getClaimMentionsRecursive() {
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
73 GremlinPipeline<Vertex, Edge> pipe = new GremlinPipeline<Vertex, Edge>();
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
74 pipe.start(vertex).outE(L_QUESTION, L_REFUTATION, L_SUGGESTION);
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
75 ArrayList<Object> array = new ArrayList<Object>();
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
76 for (Edge e : pipe) {
31
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
77 String label = e.getLabel();
32
be6bbd4967e4 create createMentions
one
parents: 31
diff changeset
78 ObjectNode info = Json.newObject();
be6bbd4967e4 create createMentions
one
parents: 31
diff changeset
79 info.put(TYPE, Json.toJson(label));
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
80 GremlinPipeline<Edge, Vertex> pipeChildVertex = new GremlinPipeline<Edge, Vertex>();
32
be6bbd4967e4 create createMentions
one
parents: 31
diff changeset
81 pipeChildVertex.start(e).inV();
be6bbd4967e4 create createMentions
one
parents: 31
diff changeset
82 ClaimModel childClaim = new ClaimModel(pipeChildVertex.next());
be6bbd4967e4 create createMentions
one
parents: 31
diff changeset
83 info.put(CLAIM, childClaim.getClaimInfoTraverse());
38
a2abe67d7c7a fix createMention action bug
one
parents: 37
diff changeset
84 info.put(ID, Json.toJson(childClaim.getId()));
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
85 array.add(info);
31
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
86 }
32
be6bbd4967e4 create createMentions
one
parents: 31
diff changeset
87 return array.toArray();
30
80b5628f17d8 modified ClaimModel/getInfo action
one
parents: 29
diff changeset
88 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
89
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
90 private Iterable<Vertex> getVertexIterable(Direction direction,
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
91 String... labels) {
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
92 GremlinPipeline<Vertex, Vertex> pipe = new GremlinPipeline<Vertex, Vertex>();
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
93 if (direction.equals(Direction.IN)) {
44
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
94 pipe.start(vertex).in(labels);
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
95 } else if (direction.equals(Direction.OUT)) {
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
96 pipe.start(vertex).out(labels);
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
97 } else {
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
98 pipe.start(vertex).both(labels);
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
99 }
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
100 ArrayList<Vertex> array = new ArrayList<Vertex>();
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
101 for (Vertex v : pipe) {
44
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
102 array.add(v);
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
103 }
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
104 if (array.size() == 0) {
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
105 return null;
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
106 }
44
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
107 return array;
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
108 }
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
109
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
110 private Object[] getVertexArray(Direction direction, String... labels) {
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
111 Iterable<Vertex> iter = getVertexIterable(direction, labels);
44
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
112 if (iter == null) {
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
113 return null;
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
114 }
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
115 ArrayList<Object> array = new ArrayList<Object>();
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
116 for (Vertex v : iter) {
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
117 array.add(v.getId());
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
118 }
30
80b5628f17d8 modified ClaimModel/getInfo action
one
parents: 29
diff changeset
119 return array.toArray();
80b5628f17d8 modified ClaimModel/getInfo action
one
parents: 29
diff changeset
120 }
80b5628f17d8 modified ClaimModel/getInfo action
one
parents: 29
diff changeset
121
80b5628f17d8 modified ClaimModel/getInfo action
one
parents: 29
diff changeset
122 public Object[] getMentionsId() {
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
123 return getVertexArray(Direction.OUT, L_QUESTION, L_REFUTATION,
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
124 L_SUGGESTION);
30
80b5628f17d8 modified ClaimModel/getInfo action
one
parents: 29
diff changeset
125 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
126
31
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
127 public Object[] getUsersId() {
44
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
128 return getVertexArray(Direction.OUT, L_REQUEST);
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
129 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
130
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
131 private Iterable<Edge> getEdgeIterable(Direction direction,
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
132 String... labels) {
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
133 GremlinPipeline<Vertex, Edge> pipe = new GremlinPipeline<Vertex, Edge>();
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
134 if (direction.equals(Direction.IN)) {
48
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
135 pipe.start(vertex).inE(labels);
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
136 } else if (direction.equals(Direction.OUT)) {
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
137 pipe.start(vertex).outE(labels);
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
138 } else {
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
139 pipe.start(vertex).bothE(labels);
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
140 }
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
141 ArrayList<Edge> array = new ArrayList<Edge>();
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
142 for (Edge v : pipe) {
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
143 array.add(v);
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
144 }
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
145 if (array.size() == 0) {
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
146 return null;
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
147 }
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
148 return array;
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
149 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
150
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
151 public Object[] getEdgeArray(Direction direction, String... labels) {
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
152 Iterable<Edge> iter = getEdgeIterable(direction, labels);
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
153 /*
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
154 * GremlinPipeline<Vertex,Edge> pipe = new
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
155 * GremlinPipeline<Vertex,Edge>(); pipe.start(vertex).outE(labels);
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
156 */
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
157 ArrayList<Object> array = new ArrayList<Object>();
48
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
158 for (Edge e : iter) {
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
159 array.add(e.getId());
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
160 }
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
161 if (array.size() == 0) {
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
162 return null;
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
163 }
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
164 return array.toArray();
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
165 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
166
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
167 public Object[] getRequestEdges() {
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
168 return getEdgeArray(Direction.OUT, L_REQUEST);
30
80b5628f17d8 modified ClaimModel/getInfo action
one
parents: 29
diff changeset
169 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
170
39
870553e92e3e create getUserConsensusStatus action
one
parents: 38
diff changeset
171 public ObjectNode getUserRequestStatus(UserModel user) {
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
172 GremlinPipeline<Vertex, Edge> pipeEdge = new GremlinPipeline<Vertex, Edge>();
39
870553e92e3e create getUserConsensusStatus action
one
parents: 38
diff changeset
173 pipeEdge.start(vertex).outE(L_REQUEST);
870553e92e3e create getUserConsensusStatus action
one
parents: 38
diff changeset
174 ObjectNode info = Json.newObject();
870553e92e3e create getUserConsensusStatus action
one
parents: 38
diff changeset
175 for (Edge e : pipeEdge) {
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
176 GremlinPipeline<Edge, Vertex> pipeChildVertex = new GremlinPipeline<Edge, Vertex>();
39
870553e92e3e create getUserConsensusStatus action
one
parents: 38
diff changeset
177 pipeChildVertex.start(e).inV();
870553e92e3e create getUserConsensusStatus action
one
parents: 38
diff changeset
178 Vertex childVertex = pipeChildVertex.next();
870553e92e3e create getUserConsensusStatus action
one
parents: 38
diff changeset
179 if (childVertex.getId() == user.getId()) {
870553e92e3e create getUserConsensusStatus action
one
parents: 38
diff changeset
180 info.put(STATUS, Json.toJson(e.getProperty(STATUS)));
870553e92e3e create getUserConsensusStatus action
one
parents: 38
diff changeset
181 break;
870553e92e3e create getUserConsensusStatus action
one
parents: 38
diff changeset
182 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
183 }
39
870553e92e3e create getUserConsensusStatus action
one
parents: 38
diff changeset
184 return info;
870553e92e3e create getUserConsensusStatus action
one
parents: 38
diff changeset
185 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
186
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
187 public Boolean updateUserRequestStatus(ClaimModel claim, UserModel user,
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
188 String status) {
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
189 GremlinPipeline<Vertex, Edge> pipeEdge = new GremlinPipeline<Vertex, Edge>();
41
f78442777849 create updateRequestStatus
one
parents: 39
diff changeset
190 pipeEdge.start(vertex).outE(L_REQUEST);
f78442777849 create updateRequestStatus
one
parents: 39
diff changeset
191 for (Edge e : pipeEdge) {
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
192 GremlinPipeline<Edge, Vertex> pipeChildVertex = new GremlinPipeline<Edge, Vertex>();
41
f78442777849 create updateRequestStatus
one
parents: 39
diff changeset
193 pipeChildVertex.start(e).inV();
f78442777849 create updateRequestStatus
one
parents: 39
diff changeset
194 Vertex childVertex = pipeChildVertex.next();
f78442777849 create updateRequestStatus
one
parents: 39
diff changeset
195 if (childVertex.getId() == user.getId()) {
f78442777849 create updateRequestStatus
one
parents: 39
diff changeset
196 e.setProperty(STATUS, status);
f78442777849 create updateRequestStatus
one
parents: 39
diff changeset
197 break;
f78442777849 create updateRequestStatus
one
parents: 39
diff changeset
198 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
199 }
41
f78442777849 create updateRequestStatus
one
parents: 39
diff changeset
200 return true;
f78442777849 create updateRequestStatus
one
parents: 39
diff changeset
201 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
202
31
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
203 public Object[] getUsersIdAndStatus() {
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
204 GremlinPipeline<Vertex, Edge> pipeEdge = new GremlinPipeline<Vertex, Edge>();
31
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
205 pipeEdge.start(vertex).outE(L_REQUEST);
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
206 ArrayList<Object> array = new ArrayList<Object>();
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
207 for (Edge e : pipeEdge) {
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
208 GremlinPipeline<Edge, Vertex> pipeChildVertex = new GremlinPipeline<Edge, Vertex>();
31
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
209 ObjectNode info = Json.newObject();
32
be6bbd4967e4 create createMentions
one
parents: 31
diff changeset
210 pipeChildVertex.start(e).inV();
31
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
211 Vertex childVertex = pipeChildVertex.next();
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
212 info.put(ID, Json.toJson(childVertex.getId()));
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
213 info.put(STATUS, Json.toJson(e.getProperty(STATUS)));
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
214 array.add(info);
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
215 }
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
216 return array.toArray();
995be14b30a2 create ClaimModel/getUsersIdAndStatus method
one
parents: 30
diff changeset
217 }
30
80b5628f17d8 modified ClaimModel/getInfo action
one
parents: 29
diff changeset
218
80b5628f17d8 modified ClaimModel/getInfo action
one
parents: 29
diff changeset
219 public Object[] getRequestUsersId() {
44
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
220 return getVertexArray(Direction.OUT, NodeModel.REQUESTS);
30
80b5628f17d8 modified ClaimModel/getInfo action
one
parents: 29
diff changeset
221 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
222
36
5f7fcdf98380 create editClaim
one
parents: 34
diff changeset
223 public void editRequestsEdgeUsers(Object[] updateUsers) {
5f7fcdf98380 create editClaim
one
parents: 34
diff changeset
224 TPGraph tpGraph = TPGraph.getInstance();
5f7fcdf98380 create editClaim
one
parents: 34
diff changeset
225 Object[] currentUsers = getUsersId();
5f7fcdf98380 create editClaim
one
parents: 34
diff changeset
226 HashSet<Object> currentUsersHashSet = new HashSet<Object>();
5f7fcdf98380 create editClaim
one
parents: 34
diff changeset
227 for (Object u : currentUsers) {
5f7fcdf98380 create editClaim
one
parents: 34
diff changeset
228 currentUsersHashSet.add(u);
5f7fcdf98380 create editClaim
one
parents: 34
diff changeset
229 }
5f7fcdf98380 create editClaim
one
parents: 34
diff changeset
230 for (Object updateUser : updateUsers) {
5f7fcdf98380 create editClaim
one
parents: 34
diff changeset
231 if (currentUsersHashSet.contains(updateUser)) {
5f7fcdf98380 create editClaim
one
parents: 34
diff changeset
232 currentUsersHashSet.remove(updateUser);
5f7fcdf98380 create editClaim
one
parents: 34
diff changeset
233 } else {
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
234 tpGraph.setLabelStatusToUser(this, updateUser.toString(),
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
235 L_REQUEST, UNKNOWN);
36
5f7fcdf98380 create editClaim
one
parents: 34
diff changeset
236 }
5f7fcdf98380 create editClaim
one
parents: 34
diff changeset
237 }
5f7fcdf98380 create editClaim
one
parents: 34
diff changeset
238 tpGraph.deleteRequestEdge(this, currentUsersHashSet);
5f7fcdf98380 create editClaim
one
parents: 34
diff changeset
239 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
240
30
80b5628f17d8 modified ClaimModel/getInfo action
one
parents: 29
diff changeset
241 public Object getAuthorId() {
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
242 GremlinPipeline<Vertex, Vertex> pipe = new GremlinPipeline<Vertex, Vertex>();
29
fbb232e78422 create getClaimInfo
one
parents: 28
diff changeset
243 pipe.start(vertex).out(L_AUTHOR);
32
be6bbd4967e4 create createMentions
one
parents: 31
diff changeset
244 if (!pipe.hasNext()) {
be6bbd4967e4 create createMentions
one
parents: 31
diff changeset
245 return null;
be6bbd4967e4 create createMentions
one
parents: 31
diff changeset
246 }
29
fbb232e78422 create getClaimInfo
one
parents: 28
diff changeset
247 Vertex authorV = pipe.next();
fbb232e78422 create getClaimInfo
one
parents: 28
diff changeset
248 return authorV.getId();
fbb232e78422 create getClaimInfo
one
parents: 28
diff changeset
249 }
47
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
250
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
251 public long getAgreedNumber(Object[] requestEdges) {
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
252 return getEdgeStatusNumber(requestEdges, AGREED);
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
253 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
254
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
255 public long getDeninedNumber(Object[] requestEdges) {
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
256 return getEdgeStatusNumber(requestEdges, DENIED);
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
257 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
258
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
259 public long getDeniedNumber(Object[] requestEdges) {
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
260 return getEdgeStatusNumber(requestEdges, DENIED);
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
261 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
262
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
263 private long getEdgeStatusNumber(Object[] requestEdges, String checkStatus) {
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
264 TPGraph tpGraph = TPGraph.getInstance();
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
265 Graph graph = tpGraph.getGraph();
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
266 long count = 0;
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
267 for (Object eId : requestEdges) {
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
268 Edge e = graph.getEdge(eId);
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
269 String status = e.getProperty(STATUS).toString();
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
270 if (status.equals(checkStatus)) {
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
271 count++;
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
272 }
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
273 }
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
274 return count;
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
275 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
276
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
277 private Boolean checkUnanimously(String inverseRefutationStatus,
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
278 String queAndSugStatus, long requestsNumber, long agreedNumber,
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
279 long deniedNumber) {
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
280 String preStatus = getProperty(STATUS).toString();
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
281 if (inverseRefutationStatus == null && queAndSugStatus == null) {
48
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
282 if (requestsNumber == agreedNumber) {
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
283 setProperty(STATUS, PASS);
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
284 } else if (requestsNumber == deniedNumber) {
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
285 setProperty(STATUS, FAILED);
49
36ddbd5e5d45 modified computeAndUpdateStatus
one
parents: 48
diff changeset
286 } else {
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
287 setProperty(STATUS, UNKNOWN);
50
d6c623e92837 modified routes
one
parents: 49
diff changeset
288 }
48
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
289 } else if (inverseRefutationStatus == null && queAndSugStatus != null) {
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
290 if (requestsNumber == agreedNumber && queAndSugStatus.equals(PASS)) {
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
291 setProperty(STATUS, PASS);
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
292 } else if (requestsNumber == deniedNumber
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
293 && queAndSugStatus.equals(FAILED)) {
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
294 setProperty(STATUS, FAILED);
53
a405991e39d8 modified ClaiMode/computeUnaimously method
one
parents: 52
diff changeset
295 } else {
a405991e39d8 modified ClaiMode/computeUnaimously method
one
parents: 52
diff changeset
296 setProperty(STATUS, UNKNOWN);
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
297 }
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
298 } else if (inverseRefutationStatus != null & queAndSugStatus == null) {
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
299 if (requestsNumber == agreedNumber && inverseRefutationStatus.equals(PASS)) {
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
300 setProperty(STATUS, PASS);
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
301 } else if (requestsNumber == deniedNumber
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
302 && inverseRefutationStatus.equals(FAILED)) {
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
303 setProperty(STATUS, FAILED);
53
a405991e39d8 modified ClaiMode/computeUnaimously method
one
parents: 52
diff changeset
304 } else {
a405991e39d8 modified ClaiMode/computeUnaimously method
one
parents: 52
diff changeset
305 setProperty(STATUS, UNKNOWN);
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
306 }
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
307 }else if (inverseRefutationStatus != null & queAndSugStatus != null) {
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
308 String childStatus = UNKNOWN;
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
309 if (inverseRefutationStatus.equals(queAndSugStatus)) {
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
310 childStatus = inverseRefutationStatus;
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
311 }
53
a405991e39d8 modified ClaiMode/computeUnaimously method
one
parents: 52
diff changeset
312 if ( requestsNumber == agreedNumber &&childStatus.equals(PASS) ){
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
313 setProperty(STATUS, PASS);
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
314 } else if ( requestsNumber == deniedNumber && childStatus.equals(DENIED)) {
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
315 setProperty(STATUS, FAILED);
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
316 } else {
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
317 setProperty(STATUS, UNKNOWN);
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
318 }
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
319 }
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
320 String nowStatus = getProperty(STATUS).toString();
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
321 return nowStatus.equals(preStatus);
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
322 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
323
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
324 private Boolean checkMajority(long requestsNumber, long agreedNumber,
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
325 long deniedNumber) {
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
326 // TODO
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
327 return false;
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
328 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
329
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
330 public void computeAndUpdateStatus() {
47
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
331 /* Check child claim */
48
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
332 String inverseRefutationStatus = checkRefutationClaims();
47
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
333 String queAndSugStatus = checkQuestionAndSuggestionClaims();
9645bfb49603 modified computeAndUpdateStatus
one
parents: 46
diff changeset
334 /* Check user request status */
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
335 Object[] requestEdges = getRequestEdges();
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
336 String type = getProperty(TYPE).toString();
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
337 long requestsNumber = requestEdges.length;
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
338 long agreedNumber = getAgreedNumber(requestEdges);
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
339 long deniedNumber = getDeninedNumber(requestEdges);
48
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
340 Boolean notChanged = false;
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
341 if (type.equals(UNANIMOUSLY)) {
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
342 notChanged = checkUnanimously(inverseRefutationStatus,
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
343 queAndSugStatus, requestsNumber, agreedNumber, deniedNumber);
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
344 } else if (type.equals(MAJORITY)) {
55
3295c9fe2b3a modified public/viewer
one
parents: 53
diff changeset
345 /* !!! !!! */
3295c9fe2b3a modified public/viewer
one
parents: 53
diff changeset
346 notChanged = checkUnanimously(inverseRefutationStatus,
3295c9fe2b3a modified public/viewer
one
parents: 53
diff changeset
347 queAndSugStatus, requestsNumber, agreedNumber, deniedNumber);
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
348 } else {
48
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
349 notChanged = false;
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
350 }
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
351 if (notChanged) {
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
352 return;
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
353 }
48
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
354 ClaimModel parentClaim = new ClaimModel(getParentVertex());
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
355 if (parentClaim.getVertex() == null) { // If parentClaim is Root.
48
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
356 return;
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
357 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
358 parentClaim.computeAndUpdateStatus();
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
359 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
360
46
49aa4ad3008f modified ClaimModel/checkRefutationClaim method
one
parents: 45
diff changeset
361 private String checkQuestionAndSuggestionClaims() {
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
362 Iterable<Vertex> iter = getVertexIterable(Direction.OUT, L_QUESTION,
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
363 L_SUGGESTION);
44
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
364 if (iter == null) {
48
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
365 return null;
44
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
366 }
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
367 String status = null;
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
368 for (Vertex v : iter) {
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
369 String nextChildStatus = v.getProperty(STATUS).toString();
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
370 if (status == null) {
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
371 status = nextChildStatus;
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
372 }
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
373 if (!nextChildStatus.equals(status)) {
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
374 return UNKNOWN;
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
375 }
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
376 }
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
377 return status;
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
378 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
379
46
49aa4ad3008f modified ClaimModel/checkRefutationClaim method
one
parents: 45
diff changeset
380 private String checkRefutationClaims() {
48
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
381 Iterable<Vertex> iter = getVertexIterable(Direction.OUT, L_REFUTATION);
46
49aa4ad3008f modified ClaimModel/checkRefutationClaim method
one
parents: 45
diff changeset
382 if (iter == null) {
48
bc35c27966f5 modified checkUnanimously method
one
parents: 47
diff changeset
383 return null;
44
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
384 }
46
49aa4ad3008f modified ClaimModel/checkRefutationClaim method
one
parents: 45
diff changeset
385 String status = null;
49aa4ad3008f modified ClaimModel/checkRefutationClaim method
one
parents: 45
diff changeset
386 for (Vertex v : iter) {
49aa4ad3008f modified ClaimModel/checkRefutationClaim method
one
parents: 45
diff changeset
387 String childStatus = v.getProperty(STATUS).toString();
49aa4ad3008f modified ClaimModel/checkRefutationClaim method
one
parents: 45
diff changeset
388 if (status == null) {
49aa4ad3008f modified ClaimModel/checkRefutationClaim method
one
parents: 45
diff changeset
389 status = childStatus;
49aa4ad3008f modified ClaimModel/checkRefutationClaim method
one
parents: 45
diff changeset
390 }
49aa4ad3008f modified ClaimModel/checkRefutationClaim method
one
parents: 45
diff changeset
391 if (status.equals(PASS)) {
49aa4ad3008f modified ClaimModel/checkRefutationClaim method
one
parents: 45
diff changeset
392 return FAILED;
49aa4ad3008f modified ClaimModel/checkRefutationClaim method
one
parents: 45
diff changeset
393 } else if (!status.equals(childStatus)) {
49aa4ad3008f modified ClaimModel/checkRefutationClaim method
one
parents: 45
diff changeset
394 status = UNKNOWN;
49aa4ad3008f modified ClaimModel/checkRefutationClaim method
one
parents: 45
diff changeset
395 }
49aa4ad3008f modified ClaimModel/checkRefutationClaim method
one
parents: 45
diff changeset
396 }
49aa4ad3008f modified ClaimModel/checkRefutationClaim method
one
parents: 45
diff changeset
397 if (status.equals(FAILED)) {
44
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
398 return PASS;
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
399 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
400 return UNKNOWN;
44
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
401 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
402
44
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
403 private String checkAllChildsStatus() {
45
one
parents: 44
diff changeset
404 String queAndSugStatus = checkQuestionAndSuggestionClaims();
one
parents: 44
diff changeset
405 String refutationStatus = checkRefutationClaims();
one
parents: 44
diff changeset
406 if (refutationStatus.equals(FAILED)) {
one
parents: 44
diff changeset
407 return FAILED;
46
49aa4ad3008f modified ClaimModel/checkRefutationClaim method
one
parents: 45
diff changeset
408 } else if (refutationStatus.equals(queAndSugStatus)) {
45
one
parents: 44
diff changeset
409 return queAndSugStatus;
44
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
410 } else {
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
411 return UNKNOWN;
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
412 }
853bc291a3bb modified ClaimModel/computeAndUpdateStatus method
one
parents: 43
diff changeset
413 }
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
414
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
415 private Vertex getParentVertex() {
52
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
416 GremlinPipeline<Vertex, Vertex> pipe = new GremlinPipeline<Vertex, Vertex>();
f3db6edc61ad modify checkUnanimously
one
parents: 50
diff changeset
417 pipe.start(vertex).in(L_QUESTION, L_REFUTATION, L_SUGGESTION);
42
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
418 if (pipe.hasNext()) {
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
419 return pipe.next();
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
420 }
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
421 return null;
4321d97da830 modified updateUserConsensusStatus
one
parents: 41
diff changeset
422 }
14
792fdb0c10bf add ClaimModel.java
one
parents:
diff changeset
423 }