Rev 259 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 259 | Rev 326 | ||
|---|---|---|---|
| Line 4... | Line 4... | ||
| 4 | 4 | ||
| - | 5 | import javax.persistence.CascadeType; |
|
| 5 | import javax.persistence.Column; |
6 | import javax.persistence.Column; |
| 6 | import javax.persistence.Entity; |
7 | import javax.persistence.Entity; |
| - | 8 | import javax.persistence.FetchType; |
|
| 7 | import javax.persistence.GeneratedValue; |
9 | import javax.persistence.GeneratedValue; |
| 8 | import javax.persistence.GenerationType; |
10 | import javax.persistence.GenerationType; |
| 9 | import javax.persistence.Id; |
11 | import javax.persistence.Id; |
| 10 | import javax.persistence.JoinColumn; |
12 | import javax.persistence.JoinColumn; |
| - | 13 | import javax.persistence.ManyToOne; |
|
| - | 14 | import javax.persistence.OneToMany; |
|
| 11 | import javax.persistence.OneToOne; |
15 | import javax.persistence.OneToOne; |
| 12 | import javax.persistence.SequenceGenerator; |
16 | import javax.persistence.SequenceGenerator; |
| 13 | import javax.persistence.Table; |
17 | import javax.persistence.Table; |
| 14 | import javax.persistence.Transient; |
18 | import javax.persistence.Transient; |
| 15 | import javax.validation.constraints.Size; |
19 | import javax.validation.constraints.Size; |
| 16 | 20 | ||
| 17 | import org.hibernate.annotations.ForeignKey; |
21 | import org.hibernate.annotations.ForeignKey; |
| 18 | 22 | ||
| 19 | import br.com.ec.core.util.StringUtil; |
23 | import br.com.ec.core.util.StringUtil; |
| 20 | import br.com.ec.core.util.VerificadorUtil; |
24 | import br.com.ec.core.util.VerificadorUtil; |
| - | 25 | import br.com.ec.domain.dto.UsuarioDTO; |
|
| - | 26 | import br.com.ec.domain.dto.VendedorDTO; |
|
| 21 | 27 | ||
| 22 | @Entity |
28 | @Entity |
| 23 | @Table(name="sec_vendedor", schema="sc_sec") |
29 | @Table(name="sec_vendedor", schema="sc_sec") |
| 24 | public class Vendedor implements Serializable { |
30 | public class Vendedor implements Serializable { |
| 25 | 31 | ||
| Line 29... | Line 35... | ||
| 29 | private Pessoa pessoa; |
35 | private Pessoa pessoa; |
| 30 | private Loja loja; |
36 | private Loja loja; |
| 31 | private String nome; |
37 | private String nome; |
| 32 | private Boolean ativo; |
38 | private Boolean ativo; |
| 33 | private Boolean indicadorColaborador; |
39 | private Boolean indicadorColaborador; |
| - | 40 | ||
| - | 41 | public Vendedor() {} |
|
| - | 42 | ||
| - | 43 | public Vendedor(Long sequencial) { |
|
| - | 44 | this.sequencial = sequencial; |
|
| - | 45 | }
|
|
| 34 | 46 | ||
| 35 | @Id |
47 | @Id |
| 36 | @SequenceGenerator(name = "sq_vendedor") |
48 | @SequenceGenerator(name = "sq_vendedor") |
| 37 | @GeneratedValue(strategy=GenerationType.IDENTITY) |
49 | @GeneratedValue(strategy=GenerationType.IDENTITY) |
| 38 | @Column(name="seq_vendedor", nullable=false) |
50 | @Column(name="seq_vendedor", nullable=false) |
| Line 52... | Line 64... | ||
| 52 | }
|
64 | }
|
| 53 | public void setPessoa(Pessoa pessoa) { |
65 | public void setPessoa(Pessoa pessoa) { |
| 54 | this.pessoa = pessoa; |
66 | this.pessoa = pessoa; |
| 55 | }
|
67 | }
|
| 56 | 68 | ||
| 57 | @OneToOne |
- | |
| - | 69 | // @OneToOne
|
|
| - | 70 | @ManyToOne |
|
| 58 | @ForeignKey(name="fk_vendedor_loja") |
71 | @ForeignKey(name="fk_vendedor_loja") |
| 59 | @JoinColumn(name="seq_loja", referencedColumnName="seq_loja", nullable=true) |
72 | @JoinColumn(name="seq_loja", referencedColumnName="seq_loja", nullable=true) |
| 60 | public Loja getLoja() { |
73 | public Loja getLoja() { |
| 61 | return loja; |
74 | return loja; |
| 62 | }
|
75 | }
|
| Line 116... | Line 129... | ||
| 116 | if (other.sequencial != null) |
129 | if (other.sequencial != null) |
| 117 | return false; |
130 | return false; |
| 118 | } else if (!sequencial.equals(other.sequencial)) |
131 | } else if (!sequencial.equals(other.sequencial)) |
| 119 | return false; |
132 | return false; |
| 120 | return true; |
133 | return true; |
| - | 134 | }
|
|
| - | 135 | ||
| - | 136 | public void atualizarDados(VendedorDTO vendedorDTO) { |
|
| - | 137 | this.loja = null; |
|
| - | 138 | if (VerificadorUtil.naoEstaNulo(vendedorDTO.getLojaDTO().getSequencial())) { |
|
| - | 139 | this.loja = new Loja(vendedorDTO.getLojaDTO().getSequencial()); |
|
| - | 140 | }
|
|
| - | 141 | this.nome = vendedorDTO.getNome(); |
|
| - | 142 | this.ativo = vendedorDTO.getAtivo(); |
|
| - | 143 | this.indicadorColaborador = vendedorDTO.getIndicadorColaborador(); |
|
| 121 | }
|
144 | }
|
| 122 | 145 | ||
| 123 | }
|
146 | }
|