view 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
line wrap: on
line source

package models;

import java.util.HashMap;
import java.util.Iterator;

import com.tinkerpop.blueprints.Vertex;

public class NodeModel {

	protected Vertex vertex;
	protected Object id;

	protected final String ID = "id";

	protected final String TOULMIN = "toulmin";
	protected final String TITLE = "title";
	protected final String CONTENTS = "contents";
	protected final String DATA = "d";
	protected final String WARRANT = "w";
	protected final String BACKING = "b";
	protected final String REBUTTLE = "r";
	protected final String AUTHOR = "author";
	protected final String USERS = "users";
	protected final String TYPE = "type";
	protected final String MENTIONS = "mentions";

	protected final String STATUS = "status";
	protected final String PASS = "pass";
	protected final String FAIL = "fail";
	protected final String AGREED = "agreed";
	protected final String DENIED = "denied"; 
	
	protected final String QUESTION = "question";
	protected final String REFUTATION = "refutation";

	protected final String MAJORITY = "majority";
	protected final String UNANIMOUSLY = "unanimously";
	
	
	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; 
	}
*/	
	
}