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