annotate app/models/NodeModel.java @ 8:7b314898fddd

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