3
|
1 package models;
|
|
2
|
|
3 import java.util.HashMap;
|
|
4 import java.util.Iterator;
|
|
5
|
|
6 import com.tinkerpop.blueprints.Vertex;
|
|
7
|
|
8 public class NodeModel {
|
|
9
|
7
|
10 protected Vertex vertex;
|
|
11 protected Object id;
|
3
|
12
|
7
|
13 protected final String ID = "id";
|
3
|
14
|
7
|
15 protected final String TOULMIN = "toulmin";
|
|
16 protected final String TITLE = "title";
|
|
17 protected final String CONTENTS = "contents";
|
|
18 protected final String DATA = "d";
|
|
19 protected final String WARRANT = "w";
|
|
20 protected final String BACKING = "b";
|
|
21 protected final String REBUTTLE = "r";
|
|
22 protected final String AUTHOR = "author";
|
|
23 protected final String USERS = "users";
|
|
24 protected final String TYPE = "type";
|
|
25 protected final String MENTIONS = "mentions";
|
3
|
26
|
7
|
27 protected final String STATUS = "status";
|
|
28 protected final String PASS = "pass";
|
|
29 protected final String FAIL = "fail";
|
|
30 protected final String AGREED = "agreed";
|
|
31 protected final String DENIED = "denied";
|
3
|
32
|
7
|
33 protected final String QUESTION = "question";
|
|
34 protected final String REFUTATION = "refutation";
|
3
|
35
|
7
|
36 protected final String MAJORITY = "majority";
|
|
37 protected final String UNANIMOUSLY = "unanimously";
|
3
|
38
|
|
39
|
|
40 public NodeModel(Vertex vertex) {
|
|
41 this.vertex = vertex;
|
|
42 this.id = vertex.getId();
|
|
43 }
|
7
|
44
|
4
|
45 /*
|
3
|
46 public JSONObject getProperties() throws JSONException {
|
|
47 for (String key: vertex.getPropertyKeys() ) {
|
|
48 properties.put(key, vertex.getProperty(key));
|
|
49 }
|
|
50 return properties;
|
|
51 }
|
7
|
52 */
|
|
53
|
3
|
54 public void setId(Object id) {
|
|
55 this.id = id;
|
|
56 }
|
|
57
|
|
58 public Object getId() {
|
|
59 return this.id;
|
|
60 }
|
|
61
|
|
62 public Vertex getVertex() {
|
|
63 return this.vertex;
|
|
64 }
|
7
|
65
|
|
66 /*
|
3
|
67 public void setJsonProperty(String key, Object value) throws JSONException {
|
|
68 properties.put(key, value);
|
|
69 }
|
|
70
|
|
71 public void setPropetiesFromJson(JSONObject jobj) throws JSONException {
|
|
72 for (Iterator<String> iter=jobj.keys(); iter.hasNext();) {
|
|
73 String key = iter.next();
|
|
74 this.setJsonProperty(key, jobj.get(key));
|
|
75 }
|
|
76 }
|
|
77
|
|
78 public void writeProperties() throws JSONException {
|
|
79 for (Iterator<String> iter=properties.keys(); iter.hasNext(); ) {
|
|
80 String key = iter.next();
|
|
81 vertex.setProperty(key, properties.get(key));
|
|
82 }
|
|
83 }
|
|
84
|
|
85 public JSONObject getNodeJson() throws JSONException {
|
|
86 JSONObject jobj = new JSONObject();
|
|
87 jobj.put("id",this.id);
|
|
88 jobj.put("data", this.properties);
|
|
89 return jobj;
|
|
90 }
|
4
|
91 */
|
3
|
92
|
|
93 }
|