package task.timer.model;

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

import javax.persistence.*;

import javafx.beans.property.StringProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;


@Entity
@Table(name = "PROJECTS")
public class Project extends AbstractEntity {
	@Id @GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id")
	private int id;
	
	@Column(name = "name")
	private String name;
	
	@ManyToMany()
	@JoinTable(name = "PROJECT_USER", 
			joinColumns = { @JoinColumn(name = "PROJECT_ID") }, 
			inverseJoinColumns = { @JoinColumn(name = "USER_ID") })	
	private Set<User> users = new HashSet<User>();

	
	public Project(String name){
		this.name = name;
	}
	
	public Project(){
		
	}
	

	public int getId() {
		return id;
	}
	
	public void setId(int id) {
		this.id = id;
	}
	
	public IntegerProperty getIdProjectProperty(){
		SimpleIntegerProperty idProperty = new SimpleIntegerProperty(id);
		return idProperty;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public StringProperty getNameProjectProperty(){
		SimpleStringProperty nameProjectProperty = new SimpleStringProperty(name);
		return nameProjectProperty;
	}
		
	public Set<User> getUsers() {
		return this.users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}

}

@@ -732,16 +732,211 @@
 er%3E();%0A%0A
+%09public Project(int id, String name, Set%3CUser%3E users)%7B%0A%09%09this.id = id;%0A%09%09this.name = name;%0A%09%09this.users = users;%0A%09%7D%0A%09%0A%09public Project(int id, String name)%7B%0A%09%09this.id = id;%0A%09%09this.name = name;%0A%09%7D%0A
 %09%0A%09publi

add new constructor - with Set of users