Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 409 | espaco | 1 | package br.com.ec.domain.model; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.Date; |
||
| 5 | |||
| 6 | import javax.persistence.Column; |
||
| 7 | import javax.persistence.Entity; |
||
| 8 | import javax.persistence.GeneratedValue; |
||
| 9 | import javax.persistence.GenerationType; |
||
| 10 | import javax.persistence.Id; |
||
| 11 | import javax.persistence.JoinColumn; |
||
| 12 | import javax.persistence.OneToOne; |
||
| 13 | import javax.persistence.SequenceGenerator; |
||
| 14 | import javax.persistence.Table; |
||
| 15 | import javax.validation.constraints.NotNull; |
||
| 16 | import javax.validation.constraints.Size; |
||
| 17 | |||
| 18 | import org.hibernate.annotations.ForeignKey; |
||
| 19 | |||
| 20 | import br.com.ec.core.interfaces.Alterar; |
||
| 21 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 22 | import br.com.ec.core.util.StringUtil; |
||
| 23 | import br.com.ec.core.util.VerificadorUtil; |
||
| 24 | import br.com.ec.domain.dto.FuncionarioEventoDTO; |
||
| 25 | |||
| 26 | @Entity |
||
| 27 | @Table(name="sec_funcionario_evento", schema="sc_sec") |
||
| 28 | public class FuncionarioEvento implements Serializable { |
||
| 29 | |||
| 30 | private static final long serialVersionUID = 1L; |
||
| 31 | |||
| 32 | private Long sequencial; |
||
| 33 | private Funcionario funcionario; |
||
| 34 | private Usuario usuarioCadastro; |
||
| 35 | private Usuario usuarioAuditor; |
||
| 36 | private Date dataInicial; |
||
| 37 | private Date dataFinal; |
||
| 38 | private String descricao; |
||
| 39 | private String tipo; |
||
| 40 | |||
| 41 | public FuncionarioEvento() {} |
||
| 42 | |||
| 43 | public FuncionarioEvento(FuncionarioEventoDTO funcionarioEventoDTO) { |
||
| 44 | this.sequencial = funcionarioEventoDTO.getSequencial(); |
||
| 45 | this.funcionario = new Funcionario(funcionarioEventoDTO.getFuncionarioDTO()); |
||
| 46 | this.usuarioCadastro = new Usuario(funcionarioEventoDTO.getUsuarioDTOCadastro()); |
||
| 47 | if (VerificadorUtil.naoEstaNulo(funcionarioEventoDTO.getUsuarioDTOAuditor())) { |
||
| 48 | this.usuarioAuditor = new Usuario(funcionarioEventoDTO.getUsuarioDTOAuditor()); |
||
| 49 | } |
||
| 50 | this.dataInicial = funcionarioEventoDTO.getDataInicial(); |
||
| 51 | this.dataFinal = funcionarioEventoDTO.getDataFinal(); |
||
| 52 | this.descricao = funcionarioEventoDTO.getDescricao(); |
||
| 53 | this.tipo = funcionarioEventoDTO.getTipo(); |
||
| 54 | } |
||
| 55 | |||
| 56 | @Id |
||
| 57 | @SequenceGenerator(name = "sq_funcionarioevento") |
||
| 58 | @GeneratedValue(strategy=GenerationType.IDENTITY) |
||
| 59 | @Column(name="seq_funcionarioevento", nullable=false) |
||
| 60 | public Long getSequencial() { |
||
| 61 | return sequencial; |
||
| 62 | } |
||
| 63 | |||
| 64 | public void setSequencial(Long sequencial) { |
||
| 65 | this.sequencial = sequencial; |
||
| 66 | } |
||
| 67 | |||
| 68 | @OneToOne |
||
| 69 | @ForeignKey(name="fk_funcionarioevento_funcionario") |
||
| 70 | @NotNull(message="Obrigatório informar o funcionário", groups={Cadastrar.class, Alterar.class}) |
||
| 71 | @JoinColumn(name="seq_funcionario", referencedColumnName="seq_funcionario", nullable=false) |
||
| 72 | public Funcionario getFuncionario() { |
||
| 73 | return funcionario; |
||
| 74 | } |
||
| 75 | public void setFuncionario(Funcionario funcionario) { |
||
| 76 | this.funcionario = funcionario; |
||
| 77 | } |
||
| 78 | |||
| 79 | @OneToOne |
||
| 80 | @ForeignKey(name="fk_funcionarioevento_usuariocadastro") |
||
| 81 | @NotNull(message="Obrigatório informar o usuário de cadastro", groups={Cadastrar.class, Alterar.class}) |
||
| 82 | @JoinColumn(name="seq_usuario_cadastro", referencedColumnName="seq_usuario", nullable=false) |
||
| 83 | public Usuario getUsuarioCadastro() { |
||
| 84 | return usuarioCadastro; |
||
| 85 | } |
||
| 86 | public void setUsuarioCadastro(Usuario usuarioCadastro) { |
||
| 87 | this.usuarioCadastro = usuarioCadastro; |
||
| 88 | } |
||
| 89 | |||
| 90 | @OneToOne |
||
| 91 | @ForeignKey(name="fk_funcionarioevento_usuarioauditor") |
||
| 92 | @JoinColumn(name="seq_usuario_auditor", referencedColumnName="seq_usuario") |
||
| 93 | public Usuario getUsuarioAuditor() { |
||
| 94 | return usuarioAuditor; |
||
| 95 | } |
||
| 96 | public void setUsuarioAuditor(Usuario usuarioAuditor) { |
||
| 97 | this.usuarioAuditor = usuarioAuditor; |
||
| 98 | } |
||
| 99 | |||
| 100 | @Column(name="dat_inicial", nullable=false) |
||
| 101 | @NotNull(message = "Parâmetro obrigatório não preenchido: Data inicial do evento", groups = {Cadastrar.class, Alterar.class}) |
||
| 102 | public Date getDataInicial() { |
||
| 103 | return dataInicial; |
||
| 104 | } |
||
| 105 | public void setDataInicial(Date dataInicial) { |
||
| 106 | this.dataInicial = dataInicial; |
||
| 107 | } |
||
| 108 | |||
| 109 | @Column(name="dat_final", nullable=false) |
||
| 110 | @NotNull(message = "Parâmetro obrigatório não preenchido: Data final do evento", groups = {Cadastrar.class, Alterar.class}) |
||
| 111 | public Date getDataFinal() { |
||
| 112 | return dataFinal; |
||
| 113 | } |
||
| 114 | public void setDataFinal(Date dataFinal) { |
||
| 115 | this.dataFinal = dataFinal; |
||
| 116 | } |
||
| 117 | |||
| 118 | @Column(name="dsc_evento") |
||
| 119 | @Size(max = 240, message = "Limite de 240 caracteres ultrapassado: DESCRIÇÃO") |
||
| 120 | public String getDescricao() { |
||
| 121 | return descricao; |
||
| 122 | } |
||
| 123 | public void setDescricao(String descricao) { |
||
| 124 | this.descricao = StringUtil.setarUpperCaseComTrim(descricao); |
||
| 125 | } |
||
| 126 | |||
| 127 | @Column(name="tip_evento", nullable=false) |
||
| 128 | @NotNull(message = "Parâmetro obrigatório não preenchido: Tipo do evento", groups = {Cadastrar.class, Alterar.class}) |
||
| 129 | public String getTipo() { |
||
| 130 | return tipo; |
||
| 131 | } |
||
| 132 | public void setTipo(String tipo) { |
||
| 133 | this.tipo = tipo; |
||
| 134 | } |
||
| 135 | |||
| 136 | @Override |
||
| 137 | public int hashCode() { |
||
| 138 | final int prime = 31; |
||
| 139 | int result = 1; |
||
| 140 | result = prime * result + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 141 | return result; |
||
| 142 | } |
||
| 143 | |||
| 144 | @Override |
||
| 145 | public boolean equals(Object obj) { |
||
| 146 | if (this == obj) |
||
| 147 | return true; |
||
| 148 | if (obj == null) |
||
| 149 | return false; |
||
| 150 | if (getClass() != obj.getClass()) |
||
| 151 | return false; |
||
| 152 | FuncionarioEvento other = (FuncionarioEvento) obj; |
||
| 153 | if (sequencial == null) { |
||
| 154 | if (other.sequencial != null) |
||
| 155 | return false; |
||
| 156 | } else if (!sequencial.equals(other.sequencial)) |
||
| 157 | return false; |
||
| 158 | return true; |
||
| 159 | } |
||
| 160 | |||
| 161 | } |