Rev 156 | Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 106 | espaco | 1 | package br.com.ec.domain.model; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.Date; |
||
| 5 | import java.util.List; |
||
| 6 | |||
| 7 | import javax.persistence.Column; |
||
| 8 | import javax.persistence.Entity; |
||
| 9 | import javax.persistence.GeneratedValue; |
||
| 10 | import javax.persistence.GenerationType; |
||
| 11 | import javax.persistence.Id; |
||
| 12 | import javax.persistence.JoinColumn; |
||
| 13 | import javax.persistence.ManyToOne; |
||
| 14 | import javax.persistence.SequenceGenerator; |
||
| 15 | import javax.persistence.Table; |
||
| 16 | import javax.persistence.Transient; |
||
| 17 | import javax.validation.constraints.NotNull; |
||
| 18 | import javax.validation.constraints.Size; |
||
| 19 | |||
| 20 | import org.hibernate.annotations.ForeignKey; |
||
| 21 | import org.hibernate.validator.constraints.NotEmpty; |
||
| 22 | |||
| 23 | import br.edu.cesmac.core.generic.identidade.Identidade; |
||
| 24 | import br.edu.cesmac.core.interfaces.Alterar; |
||
| 25 | import br.edu.cesmac.core.interfaces.Cadastrar; |
||
| 26 | import br.edu.cesmac.core.util.StringUtil; |
||
| 27 | |||
| 28 | @Entity |
||
| 29 | @Table(name="sec_pendencia", schema="sc_sec") |
||
| 30 | public class Pendencia implements Serializable, Identidade { |
||
| 31 | |||
| 32 | private static final long serialVersionUID = 1L; |
||
| 33 | |||
| 34 | private Long sequencial; |
||
| 35 | private Loja loja; |
||
| 36 | private Perfil perfil; |
||
| 37 | private Usuario usuario; |
||
| 38 | private String descricao; |
||
| 39 | private Date data; |
||
| 40 | private Date dataFinalizado; |
||
| 41 | private String resposta; |
||
| 42 | private Boolean indicadorFinalizado; |
||
| 43 | |||
| 44 | private List<Perfil> perfisConsulta; |
||
| 45 | |||
| 46 | @Override |
||
| 47 | @Transient |
||
| 48 | public Object getId() { |
||
| 49 | return this.getSequencial(); |
||
| 50 | } |
||
| 51 | @Override |
||
| 52 | public void setId(Object id) { |
||
| 53 | this.sequencial = (Long) id; |
||
| 54 | } |
||
| 55 | |||
| 56 | @Id |
||
| 57 | @SequenceGenerator(name = "sq_pendencia") |
||
| 58 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 59 | @Column(name="seq_pendencia", nullable=false) |
||
| 60 | public Long getSequencial() { |
||
| 61 | return sequencial; |
||
| 62 | } |
||
| 63 | public void setSequencial(Long sequencial) { |
||
| 64 | this.sequencial = sequencial; |
||
| 65 | } |
||
| 66 | |||
| 67 | @ManyToOne |
||
| 68 | @ForeignKey(name="fk_pendencia_loja") |
||
| 69 | @NotNull(message = "Parâmetro obrigatório não preenchido: Loja", groups = {Cadastrar.class, Alterar.class}) |
||
| 70 | @JoinColumn(name = "seq_loja", nullable = false) |
||
| 71 | public Loja getLoja() { |
||
| 72 | return loja; |
||
| 73 | } |
||
| 74 | public void setLoja(Loja loja) { |
||
| 75 | this.loja = loja; |
||
| 76 | } |
||
| 77 | |||
| 78 | @ManyToOne |
||
| 79 | @ForeignKey(name="fk_pendencia_perfil") |
||
| 80 | @NotNull(message = "Parâmetro obrigatório não preenchido: Setor", groups = {Cadastrar.class, Alterar.class}) |
||
| 81 | @JoinColumn(name = "cod_perfil", nullable = false) |
||
| 82 | public Perfil getPerfil() { |
||
| 83 | return perfil; |
||
| 84 | } |
||
| 85 | public void setPerfil(Perfil perfil) { |
||
| 86 | this.perfil = perfil; |
||
| 87 | } |
||
| 88 | |||
| 89 | @ManyToOne |
||
| 90 | @ForeignKey(name="fk_pendencia_usuario") |
||
| 91 | @NotNull(message = "Parâmetro obrigatório não preenchido: Solicitante", groups = {Cadastrar.class, Alterar.class}) |
||
| 92 | @JoinColumn(name = "seq_usuario", nullable = false) |
||
| 93 | public Usuario getUsuario() { |
||
| 94 | return usuario; |
||
| 95 | } |
||
| 96 | public void setUsuario(Usuario usuario) { |
||
| 97 | this.usuario = usuario; |
||
| 98 | } |
||
| 99 | |||
| 100 | @Column(name="dsc_pendencia") |
||
| 101 | @Size(max = 250, message = "Limite de caracteres ultrapassado: Descrição") |
||
| 102 | @NotEmpty(message = "Parâmetro obrigatório não preenchido: Descrição", groups = {Cadastrar.class, Alterar.class}) |
||
| 103 | public String getDescricao() { |
||
| 104 | return descricao; |
||
| 105 | } |
||
| 106 | public void setDescricao(String descricao) { |
||
| 107 | this.descricao = StringUtil.setarUpperCaseComTrim(descricao); |
||
| 108 | } |
||
| 109 | |||
| 110 | @Column(name="dat_pendencia", nullable=false) |
||
| 111 | public Date getData() { |
||
| 112 | return data; |
||
| 113 | } |
||
| 114 | public void setData(Date data) { |
||
| 115 | this.data = data; |
||
| 116 | } |
||
| 117 | |||
| 118 | @Column(name="dat_finalizado") |
||
| 119 | public Date getDataFinalizado() { |
||
| 120 | return dataFinalizado; |
||
| 121 | } |
||
| 122 | public void setDataFinalizado(Date dataFinalizado) { |
||
| 123 | this.dataFinalizado = dataFinalizado; |
||
| 124 | } |
||
| 125 | |||
| 126 | @Column(name="dsc_resposta") |
||
| 127 | public String getResposta() { |
||
| 128 | return resposta; |
||
| 129 | } |
||
| 130 | public void setResposta(String resposta) { |
||
| 131 | this.resposta = StringUtil.setarUpperCaseComTrim(resposta); |
||
| 132 | } |
||
| 133 | |||
| 134 | @Transient |
||
| 135 | public Boolean getIndicadorFinalizado() { |
||
| 136 | return indicadorFinalizado; |
||
| 137 | } |
||
| 138 | public void setIndicadorFinalizado(Boolean indicadorFinalizado) { |
||
| 139 | this.indicadorFinalizado = indicadorFinalizado; |
||
| 140 | } |
||
| 141 | |||
| 142 | @Transient |
||
| 143 | public List<Perfil> getPerfisConsulta() { |
||
| 144 | return perfisConsulta; |
||
| 145 | } |
||
| 146 | public void setPerfisConsulta(List<Perfil> perfisConsulta) { |
||
| 147 | this.perfisConsulta = perfisConsulta; |
||
| 148 | } |
||
| 149 | |||
| 150 | @Transient |
||
| 151 | public Long getSequencialDaLoja() { |
||
| 152 | return getLoja() != null ? getLoja().getSequencial() : null; |
||
| 153 | } |
||
| 154 | |||
| 155 | @Override |
||
| 156 | public int hashCode() { |
||
| 157 | final int prime = 31; |
||
| 158 | int result = 1; |
||
| 159 | result = prime * result + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 160 | return result; |
||
| 161 | } |
||
| 162 | |||
| 163 | @Override |
||
| 164 | public boolean equals(Object obj) { |
||
| 165 | if (this == obj) |
||
| 166 | return true; |
||
| 167 | if (obj == null) |
||
| 168 | return false; |
||
| 169 | if (getClass() != obj.getClass()) |
||
| 170 | return false; |
||
| 171 | Pendencia other = (Pendencia) obj; |
||
| 172 | if (sequencial == null) { |
||
| 173 | if (other.sequencial != null) |
||
| 174 | return false; |
||
| 175 | } else if (!sequencial.equals(other.sequencial)) |
||
| 176 | return false; |
||
| 177 | return true; |
||
| 178 | } |
||
| 179 | |||
| 180 | } |