package it.enea.cruise.model.user;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;

import lombok.Getter;
import lombok.Setter;

@Entity(name = "role")
@Table(name = "t_roles")
@Getter
@Setter
public class Role {

	@Id
	private Long id;

	private String description;

	@Column(name = "rolename")
	private String rolename;

	@OneToMany(mappedBy = "role", cascade = CascadeType.ALL, orphanRemoval = true)
	@JsonIgnore
	private List<UserRole> userRoles = new ArrayList<>();
	
	
//	public Long getId() {
//		return id;
//	}
//
//	public void setId(Long id) {
//		this.id = id;
//	}
//
//	public String getDescription() {
//		return description;
//	}
//
//	public void setDescription(String description) {
//		this.description = description;
//	}
//
//	public String getRolename() {
//		return rolename;
//	}
//
//	public void setRolename(String roleName) {
//		this.rolename = roleName;
//	}
//
//	public List<UserRole> getUserRoles() {
//		return userRoles;
//	}
//
//	public void setUserRoles(List<UserRole> userRoles) {
//		this.userRoles = userRoles;
//	}
	
	@Override
	public String toString() {
		String result = "{\"id\":" + this.id + ","
				+ "\"rolename\":\"" + this.rolename + "\","
				+ "\"description\":\"" + this.description + "\""
				+ "}";
		return result;
	}

}
