Mercurial > hg > Members > nobuyasu > Consensus
changeset 3:d0ee9edfff28
add libs, models/NodeModel.java
line wrap: on
line diff
--- a/.classpath Mon Oct 01 16:13:44 2012 +0900 +++ b/.classpath Mon Oct 01 16:39:19 2012 +0900 @@ -2,7 +2,10 @@ <classpath> <classpathentry kind="src" output=".target" path="app"/> <classpathentry kind="src" output=".target" path="test"/> - <classpathentry kind="lib" path="/Users/aotokage/testProgram/play/Consensus/target/scala-2.9.1/classes_managed"/> + <classpathentry kind="lib" path="lib/jackson-annotations-2.0.2.jar"/> + <classpathentry kind="lib" path="lib/jackson-core-2.0.2.jar"/> + <classpathentry kind="lib" path="lib/jackson-databind-2.0.2.jar"/> + <classpathentry kind="lib" path="/Users/aotokage/workspace/Consensus/target/scala-2.9.1/classes_managed"/> <classpathentry kind="lib" path="/Users/aotokage/opt/play/repository/local/play/play_2.9.1/2.0.3/jars/play_2.9.1.jar"/> <classpathentry kind="lib" path="/Users/aotokage/opt/play/repository/local/play/templates_2.9.1/2.0.3/jars/templates_2.9.1.jar"/> <classpathentry kind="lib" path="/Users/aotokage/opt/play/repository/local/com.github.scala-incubator.io/scala-io-file_2.9.1/0.4.0/jars/scala-io-file_2.9.1.jar"/> @@ -89,8 +92,8 @@ <classpathentry kind="lib" path="/Users/aotokage/opt/play/repository/local/org.easytesting/fest-util/1.1.6/jars/fest-util.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="lib" path="/Users/aotokage/opt/play/framework/sbt/boot/scala-2.9.1/lib/scala-library.jar"/> - <classpathentry kind="lib" path="lib/jackson-annotations-2.0.2.jar"/> - <classpathentry kind="lib" path="lib/jackson-core-2.0.2.jar"/> - <classpathentry kind="lib" path="lib/jackson-databind-2.0.2.jar"/> + <classpathentry kind="lib" path="lib/blueprints-core-2.2.0-SNAPSHOT.jar"/> + <classpathentry kind="lib" path="lib/gremlin-java-2.2.0-SNAPSHOT.jar"/> + <classpathentry kind="lib" path="lib/pipes-2.2.0-SNAPSHOT.jar"/> <classpathentry kind="output" path="bin"/> </classpath>
--- a/.settings/org.scala-ide.sdt.core.prefs Mon Oct 01 16:13:44 2012 +0900 +++ b/.settings/org.scala-ide.sdt.core.prefs Mon Oct 01 16:39:19 2012 +0900 @@ -1,5 +1,5 @@ #Generated by sbteclipse -#Mon Oct 01 06:39:25 JST 2012 +#Mon Oct 01 16:31:59 JST 2012 Xcheckinit=true deprecation=true encoding=utf8
--- a/app/controllers/Application.java Mon Oct 01 16:13:44 2012 +0900 +++ b/app/controllers/Application.java Mon Oct 01 16:39:19 2012 +0900 @@ -26,7 +26,7 @@ @BodyParser.Of(BodyParser.Json.class) public static Result hello() { -/* + JsonNode json = request().body().asJson(); ObjectNode result = Json.newObject(); String name = json.findPath("name").getTextValue(); @@ -40,12 +40,7 @@ return ok(result); } - */ - System.out.println(request().body().asText()); - RequestBody body = request().body(); - return ok("Got Json:" + body.asJson()); - - + }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/controllers/User.java Mon Oct 01 16:39:19 2012 +0900 @@ -0,0 +1,21 @@ +package controllers; + +import play.mvc.Controller; +import play.mvc.Result; + +public class User extends Controller { + + public static Result create() { + + + + return ok(); + } + + + + + + + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/models/NodeModel.java Mon Oct 01 16:39:19 2012 +0900 @@ -0,0 +1,94 @@ +package models; + +import java.util.HashMap; +import java.util.Iterator; + +import org.json.JSONException; +import org.json.JSONObject; + +import com.tinkerpop.blueprints.Vertex; + +public class NodeModel { + + private Vertex vertex; + private Object id; + + final String ID = "id"; + + final String TOULMIN = "toulmin"; + final String TITLE = "title"; + final String CONTENTS = "contents"; + final String DATA = "d"; + final String WARRANT = "w"; + final String BACKING = "b"; + final String REBUTTLE = "r"; + final String AUTHOR = "author"; + final String USERS = "users"; + final String TYPE = "type"; + final String MENTIONS = "mentions"; + + final String STATUS = "status"; + final String PASS = "pass"; + final String FAIL = "fail"; + final String AGREED = "agreed"; + final String DENIED = "denied"; + + final String QUESTION = "question"; + final String REFUTATION = "refutation"; + + final String MAJORITY = "majority"; + final String UNANIMOUSLY = "unanimously"; + + JSONObject properties = new JSONObject(); + + public NodeModel(Vertex vertex) { + this.vertex = vertex; + this.id = vertex.getId(); + } + + public JSONObject getProperties() throws JSONException { + for (String key: vertex.getPropertyKeys() ) { + properties.put(key, vertex.getProperty(key)); + } + return properties; + } + + public void setId(Object id) { + this.id = id; + } + + public Object getId() { + return this.id; + } + + public Vertex getVertex() { + return this.vertex; + } + + public void setJsonProperty(String key, Object value) throws JSONException { + properties.put(key, value); + } + + public void setPropetiesFromJson(JSONObject jobj) throws JSONException { + for (Iterator<String> iter=jobj.keys(); iter.hasNext();) { + String key = iter.next(); + this.setJsonProperty(key, jobj.get(key)); + } + } + + public void writeProperties() throws JSONException { + for (Iterator<String> iter=properties.keys(); iter.hasNext(); ) { + String key = iter.next(); + vertex.setProperty(key, properties.get(key)); + } + } + + public JSONObject getNodeJson() throws JSONException { + JSONObject jobj = new JSONObject(); + jobj.put("id",this.id); + jobj.put("data", this.properties); + return jobj; + } + + +}
--- a/logs/application.log Mon Oct 01 16:13:44 2012 +0900 +++ b/logs/application.log Mon Oct 01 16:39:19 2012 +0900 @@ -1,3 +1,6 @@ -2012-10-01 15:59:25,575 - [INFO] - from play in main +2012-10-01 16:33:22,607 - [INFO] - from play in main Listening for HTTP on port 9000... +2012-10-01 16:33:29,036 - [INFO] - from play in play-akka.actor.default-dispatcher-3 +Application started (Dev) +
Binary file project/project/target/config-classes/$60248ea5edf127a3d4b7$$anonfun$$sbtdef$1.class has changed
Binary file project/project/target/config-classes/$f6c5bcb932278671af90$$anonfun$$sbtdef$1.class has changed