package ub.scp2.entities;

// Generated Nov 4, 2011 3:38:03 PM by Hibernate Tools 3.4.0.CR1

import java.util.HashSet;
import java.util.Set;

/**
 * User.java -this class is an entity binded to the user table from the database
 */
public class User implements java.io.Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 7910845611766016626L;
	private String username;
	private Role role;
	private String firstName;
	private String lastName;
	private String password;
	private Set<Task> tasks = new HashSet<Task>(0);
	private Set<Submission> submissions = new HashSet<Submission>(0);
	private Set<Subject> subjects = new HashSet<Subject>(0);

	public User() {
	}

	public User(Role role, String firstName, String lastName) {
		this.role = role;
		this.firstName = firstName;
		this.lastName = lastName;
	}

	public User(String userId, Role role, String firstName, String lastName, String password,
			Set<Task> tasks, Set<Subject> subjects) {
		this.username = userId;
		this.role = role;
		this.firstName = firstName;
		this.lastName = lastName;
		this.password = password;
		this.tasks = tasks;
		this.subjects = subjects;
	}
	
	public void addSubject(Subject subject){
		subjects.add(subject);
	}
	
	public void removeSubject(Subject subject){
		subjects.remove(subject);
	}

	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public Role getRole() {
		return this.role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	public String getFirstName() {
		return this.firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return this.lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Set<Task> getTasks() {
		return this.tasks;
	}

	public void setTasks(Set<Task> tasks) {
		this.tasks = tasks;
	}

	public Set<Subject> getSubjects() {
		return subjects;
	}

	public void setSubjects(Set<Subject> subjects) {
		this.subjects = subjects;
	}
	
    public boolean equals(Object other) {
        return other instanceof User && (username != null) ? username.equals(((User) other).username) : (other == this);
    }

	public Set<Submission> getSubmissions() {
		return submissions;
	}

	public void setSubmissions(Set<Submission> submissions) {
		this.submissions = submissions;
	}
	

}
