view app/models/UserModel.java @ 10:a8ea4191fa99

modified User.java
author one
date Mon, 01 Oct 2012 20:51:36 +0900
parents d050b7fb4cda
children 9b677755cb93
line wrap: on
line source

package models;

import java.util.HashMap;

import com.tinkerpop.blueprints.Vertex;

public class UserModel extends NodeModel {

	protected final String CONSENSUS = "consensus";
	protected final String CLAIMS = "claims";
	protected final String REQUESTS = "requests";
	
	protected HashMap<Object,Object> properties = new HashMap<Object,Object>();
	
	public UserModel(Vertex vertex) {
		super(vertex);
	}
	

	public void setUserInfo() {
		this.vertex.setProperty(CONSENSUS, null);
		this.vertex.setProperty(CLAIMS, null);
		this.vertex.setProperty(REQUESTS, null);
	}
	

	public HashMap<Object,Object> getUserProperty() {
		for (String key : vertex.getPropertyKeys()) {
			properties.put(key, vertex.getProperty(key));
		}
		return properties;
	}

	public HashMap<Object, Object> getUserRequests() {
		HashMap<Object, Object> hash = getOneProperty(REQUESTS);
		return hash;
	}
	
	public HashMap<Object, Object> getUserConsensus() {
		HashMap<Object, Object> hash = getOneProperty(CONSENSUS);
		return hash;
	}
	
	public HashMap<Object, Object> getUserClaims() {
		HashMap<Object, Object> hash = getOneProperty(CLAIMS);
		return hash;
	}

	private HashMap<Object,Object> getOneProperty(String key) {
		HashMap<Object, Object> hash = new HashMap<Object,Object>(1);
		Object obj = vertex.getProperty(key);
		if (obj == null) return null;
		hash.put(key,obj);
		return hash;
	}

	
	
	
/*
	public Vertex setName(String name) {
		this.vertex.setProperty(NAME, name);
		return vertex;
	}
*/
	
	
	
}