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