Rev 195 | Details | Compare with Previous | 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 | |||
| 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.ManyToOne; |
||
| 13 | import javax.persistence.SequenceGenerator; |
||
| 14 | import javax.persistence.Table; |
||
| 15 | import javax.persistence.Transient; |
||
| 16 | import javax.validation.constraints.NotNull; |
||
| 17 | import javax.validation.constraints.Size; |
||
| 18 | |||
| 19 | import org.hibernate.annotations.ForeignKey; |
||
| 20 | import org.hibernate.validator.constraints.NotEmpty; |
||
| 21 | |||
| 195 | espaco | 22 | import br.com.ec.core.generic.identidade.Identidade; |
| 23 | import br.com.ec.core.interfaces.Alterar; |
||
| 24 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 25 | import br.com.ec.core.util.StringUtil; |
||
| 26 | import br.com.ec.core.util.VerificadorUtil; |
||
| 106 | espaco | 27 | |
| 28 | @Entity |
||
| 29 | @Table(name="sec_pagamento", schema="sc_sec") |
||
| 30 | public class Pagamento implements Serializable, Identidade { |
||
| 31 | |||
| 32 | private static final long serialVersionUID = 1L; |
||
| 33 | |||
| 34 | private Long sequencial; |
||
| 35 | private Loja loja; |
||
| 36 | private String descricao; |
||
| 37 | private Double valor; |
||
| 38 | private Date data; |
||
| 39 | private Boolean lancado; |
||
| 40 | private Usuario usuario; |
||
| 597 | blopes | 41 | |
| 42 | private Categoria categoriaGerarPagamento; |
||
| 43 | private Boolean gerarPagamento; |
||
| 106 | espaco | 44 | |
| 45 | @Override |
||
| 46 | @Transient |
||
| 47 | public Object getId() { |
||
| 48 | return this.getSequencial(); |
||
| 49 | } |
||
| 50 | @Override |
||
| 51 | public void setId(Object id) { |
||
| 52 | this.sequencial = (Long) id; |
||
| 53 | } |
||
| 54 | |||
| 55 | @Id |
||
| 56 | @SequenceGenerator(name = "sq_pagamento") |
||
| 57 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 58 | @Column(name="seq_pagamento", nullable=false) |
||
| 59 | public Long getSequencial() { |
||
| 60 | return sequencial; |
||
| 61 | } |
||
| 62 | public void setSequencial(Long sequencial) { |
||
| 63 | this.sequencial = sequencial; |
||
| 64 | } |
||
| 65 | |||
| 66 | @ManyToOne |
||
| 67 | @ForeignKey(name="fk_pagamento_loja") |
||
| 68 | @JoinColumn(name = "seq_loja", nullable = false) |
||
| 69 | public Loja getLoja() { |
||
| 70 | return loja; |
||
| 71 | } |
||
| 72 | public void setLoja(Loja loja) { |
||
| 73 | this.loja = loja; |
||
| 74 | } |
||
| 75 | |||
| 76 | @Column(name="dsc_pagamento") |
||
| 77 | @Size(max = 120, message = "Limite de caracteres ultrapassado: Descrição") |
||
| 78 | @NotEmpty(message = "Parâmetro obrigatório não preenchido: Descrição", groups = {Cadastrar.class, Alterar.class}) |
||
| 79 | @NotNull(message = "Parâmetro obrigatório não preenchido: Descrição", groups = {Cadastrar.class, Alterar.class}) |
||
| 80 | public String getDescricao() { |
||
| 81 | return descricao; |
||
| 82 | } |
||
| 83 | public void setDescricao(String descricao) { |
||
| 84 | this.descricao = StringUtil.setarUpperCaseComTrim(descricao); |
||
| 85 | } |
||
| 86 | |||
| 87 | @NotNull(message = "Parâmetro obrigatório não preenchido: Valor", groups = {Cadastrar.class, Alterar.class}) |
||
| 88 | @Column(name="val_pagamento") |
||
| 89 | public Double getValor() { |
||
| 90 | return valor; |
||
| 91 | } |
||
| 92 | public void setValor(Double valor) { |
||
| 93 | this.valor = valor; |
||
| 94 | } |
||
| 95 | |||
| 96 | @NotNull(message = "Parâmetro obrigatório não preenchido: Data", groups = {Cadastrar.class, Alterar.class}) |
||
| 97 | @Column(name="dat_pagamento", nullable=false) |
||
| 98 | public Date getData() { |
||
| 99 | return data; |
||
| 100 | } |
||
| 101 | public void setData(Date data) { |
||
| 102 | this.data = data; |
||
| 103 | } |
||
| 104 | |||
| 105 | @Column(name="ind_lancado", nullable=false) |
||
| 106 | public Boolean getLancado() { |
||
| 107 | return lancado; |
||
| 108 | } |
||
| 109 | public void setLancado(Boolean lancado) { |
||
| 110 | this.lancado = lancado; |
||
| 111 | } |
||
| 112 | |||
| 113 | @ManyToOne |
||
| 114 | @ForeignKey(name="fk_pagamento_usuario") |
||
| 115 | @JoinColumn(name = "seq_usuario", nullable=true) |
||
| 116 | public Usuario getUsuario() { |
||
| 117 | return usuario; |
||
| 118 | } |
||
| 119 | public void setUsuario(Usuario usuario) { |
||
| 120 | this.usuario = usuario; |
||
| 121 | } |
||
| 597 | blopes | 122 | |
| 123 | @Transient |
||
| 124 | public Categoria getCategoriaGerarPagamento() { |
||
| 125 | return categoriaGerarPagamento; |
||
| 126 | } |
||
| 127 | public void setCategoriaGerarPagamento(Categoria categoriaGerarPagamento) { |
||
| 128 | this.categoriaGerarPagamento = categoriaGerarPagamento; |
||
| 129 | } |
||
| 130 | |||
| 131 | @Transient |
||
| 132 | public Boolean getGerarPagamento() { |
||
| 133 | return gerarPagamento; |
||
| 134 | } |
||
| 135 | public void setGerarPagamento(Boolean gerarPagamento) { |
||
| 136 | this.gerarPagamento = gerarPagamento; |
||
| 137 | } |
||
| 106 | espaco | 138 | |
| 139 | @Transient |
||
| 140 | public Long getSequencialDaLoja() { |
||
| 141 | return VerificadorUtil.naoEstaNulo(getLoja()) ? getLoja().getSequencial() : null; |
||
| 142 | } |
||
| 143 | @Override |
||
| 144 | public int hashCode() { |
||
| 145 | final int prime = 31; |
||
| 146 | int result = 1; |
||
| 147 | result = prime * result + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 148 | return result; |
||
| 149 | } |
||
| 150 | @Override |
||
| 151 | public boolean equals(Object obj) { |
||
| 152 | if (this == obj) |
||
| 153 | return true; |
||
| 154 | if (obj == null) |
||
| 155 | return false; |
||
| 156 | if (getClass() != obj.getClass()) |
||
| 157 | return false; |
||
| 158 | Pagamento other = (Pagamento) obj; |
||
| 159 | if (sequencial == null) { |
||
| 160 | if (other.sequencial != null) |
||
| 161 | return false; |
||
| 162 | } else if (!sequencial.equals(other.sequencial)) |
||
| 163 | return false; |
||
| 164 | return true; |
||
| 165 | } |
||
| 166 | |||
| 167 | } |