Rev 630 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 625 | blopes | 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 | |||
| 21 | import br.com.ec.core.generic.identidade.Identidade; |
||
| 22 | import br.com.ec.core.interfaces.Alterar; |
||
| 23 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 24 | import br.com.ec.core.util.StringUtil; |
||
| 631 | blopes | 25 | import br.com.ec.domain.dto.NpsPosVendaDTO; |
| 625 | blopes | 26 | |
| 27 | @Entity |
||
| 28 | @Table(name="sec_nps_posvenda", schema="sc_sec") |
||
| 29 | public class NpsPosVenda implements Serializable, Identidade { |
||
| 30 | |||
| 31 | private static final long serialVersionUID = 1L; |
||
| 32 | |||
| 33 | private Long sequencial; |
||
| 34 | private PosVenda posVenda; |
||
| 35 | private String tipoNps; // A - ATENDIMENTO | P - PRODUTO |
||
| 36 | private Integer nota; |
||
| 37 | private String observacao; |
||
| 38 | private Date dataFinalizacao; |
||
| 39 | |||
| 40 | public NpsPosVenda() {} |
||
| 41 | |||
| 630 | blopes | 42 | public NpsPosVenda(Long sequencial) { |
| 43 | this.sequencial = sequencial; |
||
| 44 | } |
||
| 45 | |||
| 625 | blopes | 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_npsposvenda") |
||
| 58 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 629 | blopes | 59 | @Column(name="seq_npsposvenda", nullable=false) |
| 625 | blopes | 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_npsposvenda_posvenda") |
||
| 69 | @JoinColumn(name = "seq_posvenda", nullable = true) |
||
| 70 | public PosVenda getPosVenda() { |
||
| 71 | return posVenda; |
||
| 72 | } |
||
| 73 | public void setPosVenda(PosVenda posVenda) { |
||
| 74 | this.posVenda = posVenda; |
||
| 75 | } |
||
| 76 | |||
| 77 | @Column(name="tip_nps") |
||
| 78 | public String getTipoNps() { |
||
| 79 | return tipoNps; |
||
| 80 | } |
||
| 81 | public void setTipoNps(String tipoNps) { |
||
| 82 | this.tipoNps = tipoNps; |
||
| 83 | } |
||
| 84 | |||
| 85 | @NotNull(message = "Parâmetro obrigatório não preenchido: Nota do NPS", groups = {Cadastrar.class, Alterar.class}) |
||
| 86 | @Column(name="nota") |
||
| 87 | public Integer getNota() { |
||
| 88 | return nota; |
||
| 89 | } |
||
| 90 | public void setNota(Integer nota) { |
||
| 91 | this.nota = nota; |
||
| 92 | } |
||
| 93 | |||
| 94 | @NotNull(message = "Parâmetro obrigatório não preenchido: Data de finalização do NPS", groups = {Cadastrar.class, Alterar.class}) |
||
| 95 | @Column(name="dth_finalizacao") |
||
| 96 | public Date getDataFinalizacao() { |
||
| 97 | return dataFinalizacao; |
||
| 98 | } |
||
| 99 | public void setDataFinalizacao(Date dataFinalizacao) { |
||
| 100 | this.dataFinalizacao = dataFinalizacao; |
||
| 101 | } |
||
| 102 | |||
| 103 | @Column(name="dsc_observacao") |
||
| 104 | @Size(max = 1000, message = "Limite de caracteres ultrapassado: Comentário") |
||
| 105 | public String getObservacao() { |
||
| 106 | return observacao; |
||
| 107 | } |
||
| 108 | public void setObservacao(String observacao) { |
||
| 109 | this.observacao = StringUtil.setarUpperCaseComTrim(observacao); |
||
| 110 | } |
||
| 631 | blopes | 111 | |
| 112 | @Transient |
||
| 113 | public void preencherDados(NpsPosVendaDTO npsPosVendaDTO) { |
||
| 114 | this.sequencial = npsPosVendaDTO.getSequencial(); |
||
| 115 | this.tipoNps = npsPosVendaDTO.getTipoNps(); |
||
| 116 | this.nota = npsPosVendaDTO.getNota(); |
||
| 117 | this.observacao = npsPosVendaDTO.getObservacao(); |
||
| 118 | this.dataFinalizacao = npsPosVendaDTO.getDataFinalizacao(); |
||
| 119 | } |
||
| 625 | blopes | 120 | |
| 121 | } |