/* * This file is part of SGEA - Sistema de Gestão de Eventos Acadêmicos - TADS IFNMG Campus Januária. * * SGEA 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. * * SGEA 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 SGEA. If not, see <http://www.gnu.org/licenses/>. */ package br.edu.ifnmg.GerenciamentoEventos.DomainModel; import br.edu.ifnmg.DomainModel.Pessoa; import br.edu.ifnmg.DomainModel.Entidade; import java.io.Serializable; import java.util.Date; import java.util.Objects; import javax.persistence.Cacheable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Lob; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Version; /** * * @author petronio */ //@Cacheable(true) @Entity @Table(name = "questoes") public class Questao implements Serializable, Entidade { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @ManyToOne(targetEntity = Questionario.class) private Questionario questionario; @ManyToOne(targetEntity = QuestionarioSecao.class) private QuestionarioSecao secao; @Enumerated(EnumType.ORDINAL) private QuestaoTipo tipo; @Column(name = "ordem") private int ordem; @Lob @Column(name = "enunciado") private String enunciado; @Lob @Column(name = "opcoes") private String opcoes; @Column(name = "minimo") private int minimo; @Column(name = "maximo") private int maximo; public Questao() { this.id = 0L; this.enunciado = ""; this.maximo = 0; this.minimo = 0; this.ordem = 0; } @Override public Long getId() { return id; } @Override public void setId(Long id) { this.id = id; } public Questionario getQuestionario() { return questionario; } public void setQuestionario(Questionario questionario) { this.questionario = questionario; } public QuestaoTipo getTipo() { return tipo; } public void setTipo(QuestaoTipo tipo) { this.tipo = tipo; } public int getOrdem() { return ordem; } public void setOrdem(int ordem) { this.ordem = ordem; } public String getEnunciado() { return enunciado; } public void setEnunciado(String enunciado) { this.enunciado = enunciado; } public int getMinimo() { return minimo; } public void setMinimo(int minimo) { this.minimo = minimo; } public int getMaximo() { return maximo; } public void setMaximo(int maximo) { this.maximo = maximo; } public QuestionarioSecao getSecao() { return secao; } public void setSecao(QuestionarioSecao secao) { this.secao = secao; } public String getOpcoes() { return opcoes; } public void setOpcoes(String opcoes) { this.opcoes = opcoes; } public String[] getOpcoesLista() { return opcoes.split(";"); } @Override public String toString() { return id.toString() ; } @Override public int hashCode() { int hash = 7; hash = 23 * hash + Objects.hashCode(this.id); hash = 23 * hash + Objects.hashCode(this.questionario); hash = 23 * hash + Objects.hashCode(this.secao); hash = 23 * hash + Objects.hashCode(this.tipo); hash = 23 * hash + this.ordem; hash = 23 * hash + Objects.hashCode(this.enunciado); return hash; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Questao other = (Questao) obj; if (!Objects.equals(this.id, other.id)) { return false; } if (!Objects.equals(this.questionario, other.questionario)) { return false; } if (!Objects.equals(this.secao, other.secao)) { return false; } if (this.tipo != other.tipo) { return false; } if (this.ordem != other.ordem) { return false; } if (!Objects.equals(this.enunciado, other.enunciado)) { return false; } return true; } @ManyToOne(fetch = FetchType.LAZY) private Pessoa criador; @Temporal(TemporalType.TIMESTAMP) private Date dataCriacao; @ManyToOne(fetch = FetchType.LAZY) private Pessoa ultimoAlterador; @Temporal(TemporalType.TIMESTAMP) private Date dataUltimaAlteracao; @Version private Long versao; @Override public Pessoa getCriador() { return criador; } @Override public void setCriador(Pessoa criador) { this.criador = criador; } @Override public Date getDataCriacao() { return dataCriacao; } @Override public void setDataCriacao(Date dataCriacao) { this.dataCriacao = dataCriacao; } @Override public Pessoa getUltimoAlterador() { return ultimoAlterador; } @Override public void setUltimoAlterador(Pessoa ultimoAlterador) { this.ultimoAlterador = ultimoAlterador; } @Override public Date getDataUltimaAlteracao() { return dataUltimaAlteracao; } @Override public void setDataUltimaAlteracao(Date dataUltimaAlteracao) { this.dataUltimaAlteracao = dataUltimaAlteracao; } @Override public Long getVersao() { return versao; } public void setVersao(Long versao) { this.versao = versao; } }