view app/models/UserModel.java @ 21:e113f946c9c1

modified getUserClaims
author one
date Tue, 02 Oct 2012 22:55:16 +0900
parents 34ea98c5a18c
children 6506b8742343
line wrap: on
line source

package models;

import java.util.ArrayList;

import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.gremlin.java.GremlinPipeline;

public class UserModel extends NodeModel {
	
	
	public UserModel(Vertex vertex) {
		super(vertex);
	}
	
	private Object[] getEdgeInUser(String labels) {
		GremlinPipeline<Vertex,Vertex> pipe = new GremlinPipeline<Vertex,Vertex>();
		pipe.start(this.vertex).in(labels);
		ArrayList<Object> array = new ArrayList<Object>();
		for (Vertex v : pipe) {
			array.add(v.getId());
		}
		if (array.size() == 0) return null;
		return array.toArray();
	}
	
	public Object[] getUserRequests() {
		return getEdgeInUser(L_REQUEST);
	}
	
	public Object[] getUserClaims() {
		return getEdgeInUser(L_AUTHOR);
	}
	
	public Object[] getUserConsensus() {
		return null;
	}

		
	
}