package com.example.beer.model;

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

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "task", uniqueConstraints = @UniqueConstraint(columnNames = {
		"name", "project_id" }))
public class Task {

	public enum TaskStatus {
		BEGIN, INPROGRESS, FINISHED
	}

	public Task() {
		
	}

	public Task(String name, String description, Date finalDate,
			double estimatedHours, Project project, User assignee) {
		super();
		this.name = name;
		this.description = description;
		this.finalDate = finalDate;
		this.estimatedHours = estimatedHours;
		status = TaskStatus.BEGIN;
		this.project = project;
		this.assignee = assignee;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;

	String name;
	String description;

	@Temporal(TemporalType.DATE)
	Date finalDate;

	double estimatedHours;
	double workedHours;

	@Enumerated(EnumType.STRING)
	TaskStatus status;

	@ManyToOne
	Project project;
	
	@ManyToOne
	User assignee;

	@OneToMany
	Set<Comment> comments = new HashSet<Comment>();
	
	public User getAssignee() {
		return assignee;
	}

	void setId(int id) {
		this.id = id;
	}

	public int getId() {
		return id;
	}

	void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	void setDescription(String description) {
		this.description = description;
	}

	String getDescription() {
		return description;
	}

	void setFinalData(Date finalDate) {
		this.finalDate = finalDate;
	}

	Date getFinalDate() {
		return finalDate;
	}

	void setHoursWorked(double hours) {
		this.workedHours = hours;
	}

	double getHoursWorked() {
		return workedHours;
	}

	void setHoursEstimated(double hours) {
		this.estimatedHours = hours;
	}

	double getHoursEstimated() {
		return estimatedHours;
	}

	public void setTaskStatus(TaskStatus status) {
		this.status = status;
	}

	TaskStatus getTaskStatus() {
		return status;
	}

	public void setProject(Project project) {
		this.project = project;
	}

	Project getProject() {
		return project;
	}

	public void assignUser(User user) {
		assignee = user;
	}
	
	public Set<Comment> getComments() {
		return comments;
	}
	
	public void addComment(Comment comment) {
		comments.add(comment);
	}
};

@@ -1603,24 +1603,31 @@
 rn id;%0A%09%7D%0A%0A%09
+public 
 void setName
@@ -1705,32 +1705,39 @@
 turn name;%0A%09%7D%0A%0A%09
+public 
 void setDescript
@@ -1801,16 +1801,23 @@
 n;%0A%09%7D%0A%0A%09
+public 
 String g
@@ -1857,24 +1857,31 @@
 ption;%0A%09%7D%0A%0A%09
+public 
 void setFina
@@ -1939,16 +1939,23 @@
 e;%0A%09%7D%0A%0A%09
+public 
 Date get
@@ -1985,32 +1985,39 @@
 finalDate;%0A%09%7D%0A%0A%09
+public 
 void setHoursWor
@@ -2061,32 +2061,39 @@
 s = hours;%0A%09%7D%0A%0A%09
+public 
 double getHoursW
@@ -2125,24 +2125,31 @@
 Hours;%0A%09%7D%0A%0A%09
+public 
 void setHour
@@ -2211,16 +2211,23 @@
 s;%0A%09%7D%0A%0A%09
+public 
 double g
@@ -2353,16 +2353,23 @@
 s;%0A%09%7D%0A%0A%09
+public 
 TaskStat
@@ -2484,16 +2484,23 @@
 t;%0A%09%7D%0A%0A%09
+public 
 Project 

Fix visibility for getters and setters