/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package mx.edu.um.mateo.colportor.model; import java.io.Serializable; import java.util.Date; import java.util.Objects; import javax.persistence.*; import mx.edu.um.mateo.general.model.Organizacion; import mx.edu.um.mateo.general.utils.Constantes; import org.springframework.format.annotation.DateTimeFormat; /** * * @author gibrandemetrioo */ @Entity @Table(name="temporadas") public class Temporada implements Serializable{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Version private Integer version; @Column(length = 64) private String nombre; @DateTimeFormat(pattern = "dd/MM/yyyy") @Temporal(TemporalType.DATE) @Column(nullable = false, name = "fecha_inicio") private Date fechaInicio; @DateTimeFormat(pattern = "dd/MM/yyyy") @Temporal(TemporalType.DATE) @Column(nullable = false, name = "fecha_final") private Date fechaFinal; @Column(nullable = false) private String status; @ManyToOne(optional = false) private Organizacion organizacion; public Temporada(){ } public Temporada(String nombre){ this.nombre = nombre; Date fecha = new Date(); this.fechaInicio = fecha; this.fechaFinal = fecha; this.status = Constantes.STATUS_ACTIVO; } public Date getFechaFinal() { return fechaFinal; } public void setFechaFinal(Date fechaFinal) { this.fechaFinal = fechaFinal; } public Date getFechaInicio() { return fechaInicio; } public void setFechaInicio(Date fechaInicio) { this.fechaInicio = fechaInicio; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getNombre() { return nombre; } public void setNombre(String nombre) { this.nombre = nombre; } public Integer getVersion() { return version; } public void setVersion(Integer version) { this.version = version; } /** * @return the status */ public String getStatus() { return status; } /** * @param status the status to set */ public void setStatus(String status) { this.status = status; } /** * @return the organizacion */ public Organizacion getOrganizacion() { return organizacion; } /** * @param organizacion the organizacion to set */ public void setOrganizacion(Organizacion organizacion) { this.organizacion = organizacion; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Temporada other = (Temporada) obj; if (!Objects.equals(this.nombre, other.nombre)) { return false; } return true; } @Override public int hashCode() { int hash = 7; hash = 37 * hash + Objects.hashCode(this.nombre); return hash; } @Override public String toString() { return "Temporada{" + "id=" + id + ", version=" + version + ", nombre=" + nombre + ", fechaInicio=" + fechaInicio + ", fechaFinal=" + fechaFinal + '}'; } }