package dashboard;_x000D_
_x000D_
import java.util.*;_x000D_
_x000D_
import javax.persistence.Id;_x000D_
_x000D_
public class User {_x000D_
_x000D_
	public enum Role {_x000D_
		TUTOR, STUDENT;_x000D_
	}_x000D_
_x000D_
	@Id Long id;_x000D_
_x000D_
	private String userName;_x000D_
	private String password;_x000D_
	private String email;_x000D_
	private boolean timing;_x000D_
_x000D_
	private List<Course> courses;_x000D_
	private List<Activity> activities;_x000D_
	private List<String> favourites;_x000D_
	private List<Milestone> milestones;_x000D_
_x000D_
	private Role role = Role.STUDENT;_x000D_
_x000D_
	public User(String username, String password, String email, List<Course> courses, String role)_x000D_
	{_x000D_
		this.userName = username;_x000D_
		this.password = password;_x000D_
		this.email = email;_x000D_
		this.courses = courses;_x000D_
		if(role.equals("Tutor"))_x000D_
			this.role = Role.TUTOR;_x000D_
_x000D_
		this.activities = new ArrayList<Activity>();_x000D_
		this.milestones = new ArrayList<Milestone>();_x000D_
		this.favourites =  new ArrayList<String>();_x000D_
		this.timing = false;_x000D_
	}_x000D_
_x000D_
	// Getters and setters_x000D_
_x000D_
	public boolean setPassword(String password)_x000D_
	{_x000D_
		this.password = password;_x000D_
		return true;_x000D_
	}_x000D_
_x000D_
	public List<String> getFavourites() {_x000D_
		return favourites;_x000D_
	}_x000D_
_x000D_
_x000D_
_x000D_
	public List<Milestone> getMilestones() {_x000D_
		return milestones;_x000D_
	}_x000D_
_x000D_
_x000D_
	public boolean setEmail(String email)_x000D_
	{_x000D_
		this.email = email;_x000D_
		return true;_x000D_
	}_x000D_
_x000D_
	public String getUsername()_x000D_
	{_x000D_
		return userName;_x000D_
	}_x000D_
_x000D_
	public String getPassword()_x000D_
	{_x000D_
		return password;_x000D_
	}_x000D_
_x000D_
	public Role getRole()_x000D_
	{_x000D_
		return role;_x000D_
	}_x000D_
_x000D_
	public String getEmail()_x000D_
	{_x000D_
		return email;_x000D_
	}_x000D_
_x000D_
	public List<Course> getCourses()_x000D_
	{_x000D_
		return courses;_x000D_
	}_x000D_
_x000D_
	public List<Activity> getActivities()_x000D_
	{_x000D_
		return activities;_x000D_
	}_x000D_
_x000D_
	public long getId()_x000D_
	{_x000D_
		return id;_x000D_
	}_x000D_
_x000D_
	//adders and remover_x000D_
_x000D_
	public boolean addCourse(Course course)_x000D_
	{_x000D_
		courses.add(course);_x000D_
		return true;_x000D_
	}_x000D_
_x000D_
	public boolean removeCourse(String courseName)_x000D_
	{_x000D_
		if(courses.size() == 0) return false;_x000D_
		for(Course course: courses)_x000D_
		{_x000D_
			if(course.getCoursename().equals(courseName))_x000D_
			{_x000D_
				courses.remove(course);_x000D_
_x000D_
				return true;_x000D_
			}_x000D_
		}_x000D_
		return false;_x000D_
	}_x000D_
_x000D_
_x000D_
	public void addActivity(String type, Date start, int courseId)_x000D_
	{_x000D_
		Activity activity = new Activity(start, courseId, type);_x000D_
		activities.add(activity);_x000D_
		timing = true;_x000D_
	}_x000D_
	_x000D_
	public void stopTiming(){_x000D_
		timing=false;_x000D_
	}_x000D_
	public boolean isTiming(){_x000D_
	   return timing;_x000D_
	}_x000D_
	public void setTiming(boolean timing){_x000D_
		this.timing= timing;_x000D_
	}_x000D_
	public boolean removeActivity(int activityId)_x000D_
	{_x000D_
		if(activities.size() == 0) return false;_x000D_
		for(Activity activity: activities)_x000D_
		{_x000D_
			if(activity.getId() == activityId)_x000D_
			{_x000D_
				activities.remove(activity);_x000D_
				return true;_x000D_
			}_x000D_
_x000D_
		}_x000D_
		return false;_x000D_
	}_x000D_
_x000D_
	public void addFavourite(String userNumber) {_x000D_
		favourites.add(userNumber);_x000D_
	}_x000D_
_x000D_
	/**_x000D_
	 * Verwijdert bepaalde user uit favorieten_x000D_
	 * @param user : te verwijderen gebruiker uit favorieten_x000D_
	 * @return true als gelukt, false als mislukt_x000D_
	 */_x000D_
	public boolean removeFavourite(int activityId)_x000D_
	{_x000D_
		if(favourites.size() == 0) return false;_x000D_
		for(String userNumber: favourites)_x000D_
		{_x000D_
			if(favourites.contains(userNumber))_x000D_
			{_x000D_
				favourites.remove(userNumber);_x000D_
				return true;_x000D_
			}_x000D_
_x000D_
		}_x000D_
		return false;_x000D_
	}_x000D_
_x000D_
	public void addMilestone(Milestone milestone)_x000D_
	{_x000D_
		milestones.add(milestone);_x000D_
	}_x000D_
_x000D_
	public boolean removeMilestone(int milestoneId)_x000D_
	{_x000D_
		if(milestones.size() == 0) return false;_x000D_
		for(Milestone milestone: milestones)_x000D_
		{_x000D_
			if(milestone.getId() == milestoneId)_x000D_
			{_x000D_
				milestones.remove(milestone);_x000D_
				return true;_x000D_
			}_x000D_
_x000D_
		}_x000D_
		return false;_x000D_
	}_x000D_
_x000D_
	public void setUsername(String username) {_x000D_
_x000D_
		this.userName = username;_x000D_
_x000D_
	}_x000D_
_x000D_
}_x000D_

/**_x000D_
	 * Verwijdert bepaalde user uit favorieten_x000D_
	 * @param user : te verwijderen gebruiker uit favorieten_x000D_
	 * @return true als gelukt, false als mislukt_x000D_
	 */
package dashboard;_x000D_
_x000D_
import java.util.*;_x000D_
_x000D_
import javax.persistence.Id;_x000D_
_x000D_
public class User {_x000D_
_x000D_
	public enum Role {_x000D_
		TUTOR, STUDENT;_x000D_
	}_x000D_
_x000D_
	@Id Long id;_x000D_
_x000D_
	private String userName;_x000D_
	private String password;_x000D_
	private String email;_x000D_
	private boolean timing;_x000D_
_x000D_
	private List<Course> courses;_x000D_
	private List<Activity> activities;_x000D_
	private List<String> favourites;_x000D_
	private List<Milestone> milestones;_x000D_
_x000D_
	private Role role = Role.STUDENT;_x000D_
_x000D_
	public User(String username, String password, String email, List<Course> courses, String role)_x000D_
	{_x000D_
		this.userName = username;_x000D_
		this.password = password;_x000D_
		this.email = email;_x000D_
		this.courses = courses;_x000D_
		if(role.equals("Tutor"))_x000D_
			this.role = Role.TUTOR;_x000D_
_x000D_
		this.activities = new ArrayList<Activity>();_x000D_
		this.milestones = new ArrayList<Milestone>();_x000D_
		this.favourites =  new ArrayList<String>();_x000D_
		this.timing = false;_x000D_
	}_x000D_
_x000D_
	// Getters and setters_x000D_
_x000D_
	public boolean setPassword(String password)_x000D_
	{_x000D_
		this.password = password;_x000D_
		return true;_x000D_
	}_x000D_
_x000D_
	public List<String> getFavourites() {_x000D_
		return favourites;_x000D_
	}_x000D_
_x000D_
_x000D_
_x000D_
	public List<Milestone> getMilestones() {_x000D_
		return milestones;_x000D_
	}_x000D_
_x000D_
_x000D_
	public boolean setEmail(String email)_x000D_
	{_x000D_
		this.email = email;_x000D_
		return true;_x000D_
	}_x000D_
_x000D_
	public String getUsername()_x000D_
	{_x000D_
		return userName;_x000D_
	}_x000D_
_x000D_
	public String getPassword()_x000D_
	{_x000D_
		return password;_x000D_
	}_x000D_
_x000D_
	public Role getRole()_x000D_
	{_x000D_
		return role;_x000D_
	}_x000D_
_x000D_
	public String getEmail()_x000D_
	{_x000D_
		return email;_x000D_
	}_x000D_
_x000D_
	public List<Course> getCourses()_x000D_
	{_x000D_
		return courses;_x000D_
	}_x000D_
_x000D_
	public List<Activity> getActivities()_x000D_
	{_x000D_
		return activities;_x000D_
	}_x000D_
_x000D_
	public long getId()_x000D_
	{_x000D_
		return id;_x000D_
	}_x000D_
_x000D_
	//adders and remover_x000D_
_x000D_
	public boolean addCourse(Course course)_x000D_
	{_x000D_
		courses.add(course);_x000D_
		return true;_x000D_
	}_x000D_
_x000D_
	public boolean removeCourse(String courseName)_x000D_
	{_x000D_
		if(courses.size() == 0) return false;_x000D_
		for(Course course: courses)_x000D_
		{_x000D_
			if(course.getCoursename().equals(courseName))_x000D_
			{_x000D_
				courses.remove(course);_x000D_
_x000D_
				return true;_x000D_
			}_x000D_
		}_x000D_
		return false;_x000D_
	}_x000D_
_x000D_
_x000D_
	public void addActivity(String type, Date start, int courseId)_x000D_
	{_x000D_
		Activity activity = new Activity(start, courseId, type);_x000D_
		activities.add(activity);_x000D_
		timing = true;_x000D_
	}_x000D_
	_x000D_
	public void stopTiming(){_x000D_
		timing=false;_x000D_
	}_x000D_
	public boolean isTiming(){_x000D_
	   return timing;_x000D_
	}_x000D_
	public void setTiming(boolean timing){_x000D_
		this.timing= timing;_x000D_
	}_x000D_
	public boolean removeActivity(int activityId)_x000D_
	{_x000D_
		if(activities.size() == 0) return false;_x000D_
		for(Activity activity: activities)_x000D_
		{_x000D_
			if(activity.getId() == activityId)_x000D_
			{_x000D_
				activities.remove(activity);_x000D_
				return true;_x000D_
			}_x000D_
_x000D_
		}_x000D_
		return false;_x000D_
	}_x000D_
_x000D_
	public void addFavourite(String userNumber) {_x000D_
		favourites.add(userNumber);_x000D_
	}_x000D_
_x000D_
	/**_x000D_
	 * Verwijdert bepaalde user<SUF>*/_x000D_
	public boolean removeFavourite(int activityId)_x000D_
	{_x000D_
		if(favourites.size() == 0) return false;_x000D_
		for(String userNumber: favourites)_x000D_
		{_x000D_
			if(favourites.contains(userNumber))_x000D_
			{_x000D_
				favourites.remove(userNumber);_x000D_
				return true;_x000D_
			}_x000D_
_x000D_
		}_x000D_
		return false;_x000D_
	}_x000D_
_x000D_
	public void addMilestone(Milestone milestone)_x000D_
	{_x000D_
		milestones.add(milestone);_x000D_
	}_x000D_
_x000D_
	public boolean removeMilestone(int milestoneId)_x000D_
	{_x000D_
		if(milestones.size() == 0) return false;_x000D_
		for(Milestone milestone: milestones)_x000D_
		{_x000D_
			if(milestone.getId() == milestoneId)_x000D_
			{_x000D_
				milestones.remove(milestone);_x000D_
				return true;_x000D_
			}_x000D_
_x000D_
		}_x000D_
		return false;_x000D_
	}_x000D_
_x000D_
	public void setUsername(String username) {_x000D_
_x000D_
		this.userName = username;_x000D_
_x000D_
	}_x000D_
_x000D_
}_x000D_
