Course.java

/**
 * TFG 75.678 - TFG Desarrollo web 2020 e-Learning for Schools
 * Copyright (C) 2020  Eduardo Rodriguez Carro
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.uoc.tfg.sel.repository.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Size;

import org.springframework.lang.NonNull;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

/**
 * Modelo de Cursos.
 *
 * @author Eduardo Rodriguez carro
 */
@JsonInclude(value = Include.NON_NULL)
@Table(name="course")
@Entity
public class Course {

	/** The id. */
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name = "id")
	@Min(0)
	private Integer id;
	
	/** The teacher tutor. */
	@ManyToOne(optional=false,fetch = FetchType.EAGER)
	@NonNull
	@JoinColumn(name="teachertutor_id")
	private User teacherTutor;
	
	/** The year. */
	@NonNull
	@Max(value = 3000)
	@Min(value = 2000)
	private Short year;
	
	/** The name. */
	@NonNull
	@Size(min = 1,max = 200)
	private String name;
	
	/** The open. */
	@NonNull
	private Boolean open;

	/**
	 * Gets the id.
	 *
	 * @return the id
	 */
	public Integer getId() {
		return id;
	}

	/**
	 * Sets the id.
	 *
	 * @param id the new id
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * Gets the teacher tutor.
	 *
	 * @return the teacher tutor
	 */
	public User getTeacherTutor() {
		return teacherTutor;
	}

	/**
	 * Sets the teacher tutor.
	 *
	 * @param teacherTutor the new teacher tutor
	 */
	public void setTeacherTutor(User teacherTutor) {
		this.teacherTutor = teacherTutor;
	}

	/**
	 * Gets the year.
	 *
	 * @return the year
	 */
	public Short getYear() {
		return year;
	}

	/**
	 * Sets the year.
	 *
	 * @param year the new year
	 */
	public void setYear(Short year) {
		this.year = year;
	}

	/**
	 * Gets the name.
	 *
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * Sets the name.
	 *
	 * @param name the new name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Gets the open.
	 *
	 * @return the open
	 */
	public Boolean getOpen() {
		return open;
	}

	/**
	 * Sets the open.
	 *
	 * @param open the new open
	 */
	public void setOpen(Boolean open) {
		this.open = open;
	}
	
	/**
	 * To string.
	 *
	 * @return the string
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Course [id=").append(id).append(", teacherTutor=").append(teacherTutor).append(", year=")
				.append(year).append(", name=").append(name).append(", open=").append(open).append("]");
		return builder.toString();
	}
	
	
	
}