14
|
1 package models;
|
|
2
|
29
|
3 import java.util.ArrayList;
|
|
4
|
16
|
5 import org.codehaus.jackson.JsonNode;
|
14
|
6 import org.codehaus.jackson.node.ObjectNode;
|
|
7
|
|
8 import play.libs.Json;
|
|
9
|
|
10 import com.tinkerpop.blueprints.Vertex;
|
29
|
11 import com.tinkerpop.gremlin.java.GremlinPipeline;
|
14
|
12
|
|
13 public class ClaimModel extends NodeModel {
|
|
14
|
|
15
|
|
16 public ClaimModel(Vertex vertex) {
|
|
17 super(vertex);
|
|
18 }
|
|
19
|
29
|
20 public ObjectNode getClaimInfoFromGraph() {
|
|
21 ObjectNode property = Json.newObject();
|
|
22 property.put(TYPE, Json.toJson(getProperty(TYPE)));
|
|
23 property.put(STATUS, Json.toJson(getProperty(STATUS)));
|
|
24 property.put(TOULMIN, Json.toJson(getProperty(TOULMIN)));
|
28
|
25
|
30
|
26 property.put(L_AUTHOR, Json.toJson(getAuthorId()));
|
|
27 property.put(MENTIONS, Json.toJson(getMentionsId()));
|
29
|
28 property.put(USERS, Json.toJson(getUsers()));
|
|
29 return property;
|
|
30 }
|
|
31
|
30
|
32 public JsonNode getClaimMentions() {
|
|
33
|
|
34
|
|
35
|
|
36 return null;
|
|
37 }
|
|
38
|
|
39 private JsonNode getClaimMention() {
|
|
40
|
|
41 return null;
|
|
42 }
|
|
43
|
|
44 public Object[] getInfoArray(String... labels) {
|
|
45 GremlinPipeline<Vertex,Vertex> pipe = new GremlinPipeline<Vertex,Vertex>();
|
|
46 pipe.start(vertex).out(labels);
|
|
47 ArrayList<Object> array = new ArrayList<Object>();
|
|
48 for (Vertex v : pipe) array.add(v.getId());
|
|
49 if (array.size() == 0) return null;
|
|
50 return array.toArray();
|
|
51 }
|
|
52
|
|
53 public Object[] getMentionsId() {
|
|
54 return getInfoArray(L_QUESTION,L_REFUTATION,L_SUGGESTION);
|
|
55 }
|
|
56
|
|
57 public Object[] getUsers() {
|
|
58 return getInfoArray(L_REQUEST);
|
|
59 }
|
|
60
|
|
61
|
|
62 public Object[] getRequestUsersId() {
|
|
63 return getInfoArray(NodeModel.REQUESTS);
|
|
64 }
|
|
65
|
|
66 public Object getAuthorId() {
|
29
|
67 GremlinPipeline<Vertex,Vertex> pipe = new GremlinPipeline<Vertex,Vertex>();
|
|
68 pipe.start(vertex).out(L_AUTHOR);
|
|
69 if (pipe.hasNext()) return null;
|
|
70 Vertex authorV = pipe.next();
|
|
71 return authorV.getId();
|
|
72 }
|
|
73
|
28
|
74
|
14
|
75
|
29
|
76
|
18
|
77 public void setClaimProperties(JsonNode toulmin, String type) {
|
29
|
78 String title = toulmin.findPath(TITLE).getTextValue();
|
|
79 String contents = toulmin.findPath(CONTENTS).getTextValue();
|
|
80 String q = toulmin.findPath(QUALIFIER).getTextValue(); // Qualifier
|
|
81 String d = toulmin.findPath(DATA).getTextValue(); // Data
|
|
82 String w = toulmin.findPath(WARRANT).getTextValue(); // Warrant
|
|
83 String b = toulmin.findPath(BACKING).getTextValue(); // Backing
|
|
84 String r = toulmin.findPath(REBUTTLE).getTextValue(); // Rebuttle
|
14
|
85
|
16
|
86 ObjectNode t = Json.newObject();
|
|
87 t.put(TITLE, title);
|
|
88 t.put(CONTENTS, contents);
|
|
89 t.put(QUALIFIER, q);
|
|
90 t.put(DATA, d);
|
|
91 t.put(WARRANT, w);
|
|
92 t.put(BACKING, b);
|
|
93 t.put(REBUTTLE, r);
|
14
|
94
|
|
95 setProperty(TYPE, type);
|
18
|
96 setProperty(STATUS, FAIL); // Default Status is fail.
|
16
|
97 setProperty(TOULMIN, t);
|
25
|
98 }
|
|
99
|
|
100 public void setClaimMention(String label) {
|
|
101
|
18
|
102
|
14
|
103 }
|
18
|
104
|
14
|
105
|
|
106
|
|
107 }
|