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 | |||
| 5 | import javax.persistence.Column; |
||
| 6 | import javax.persistence.Entity; |
||
| 7 | import javax.persistence.GeneratedValue; |
||
| 8 | import javax.persistence.GenerationType; |
||
| 9 | import javax.persistence.Id; |
||
| 10 | import javax.persistence.JoinColumn; |
||
| 11 | import javax.persistence.ManyToOne; |
||
| 12 | import javax.persistence.SequenceGenerator; |
||
| 13 | import javax.persistence.Table; |
||
| 14 | import javax.validation.constraints.NotNull; |
||
| 15 | import javax.validation.constraints.Size; |
||
| 16 | |||
| 17 | import org.hibernate.annotations.ForeignKey; |
||
| 18 | import org.hibernate.validator.constraints.NotEmpty; |
||
| 19 | |||
| 20 | import br.com.ec.core.interfaces.Alterar; |
||
| 21 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 22 | import br.com.ec.core.util.StringUtil; |
||
| 23 | |||
| 24 | @Entity |
||
| 25 | @Table(name="sec_maquineta", schema="sc_sec") |
||
| 26 | public class Maquineta implements Serializable { |
||
| 27 | |||
| 28 | private static final long serialVersionUID = 1L; |
||
| 29 | |||
| 30 | private Long sequencial; |
||
| 31 | private String descricao; |
||
| 32 | private String senha; |
||
| 33 | private Double valorAluguel; |
||
| 34 | private String observacao; |
||
| 35 | private EmpresaAdquirente empresaAdquirente; |
||
| 36 | private Pessoa pessoa; |
||
| 37 | private Boolean ativo; |
||
| 38 | |||
| 39 | @Id |
||
| 40 | @SequenceGenerator(name = "sq_maquineta") |
||
| 41 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 42 | @Column(name="seq_maquineta", nullable=false) |
||
| 43 | public Long getSequencial() { |
||
| 44 | return sequencial; |
||
| 45 | } |
||
| 46 | public void setSequencial(Long sequencial) { |
||
| 47 | this.sequencial = sequencial; |
||
| 48 | } |
||
| 49 | |||
| 50 | @Column(name="dsc_maquineta") |
||
| 51 | @Size(max = 120, message = "Limite de caracteres ultrapassado: Descrição") |
||
| 52 | @NotEmpty(message="Obrigatório informar a descrição", groups={Cadastrar.class, Alterar.class}) |
||
| 53 | public String getDescricao() { |
||
| 54 | return descricao; |
||
| 55 | } |
||
| 56 | public void setDescricao(String descricao) { |
||
| 57 | this.descricao = StringUtil.setarUpperCaseComTrim(descricao); |
||
| 58 | } |
||
| 59 | |||
| 60 | @Column(name="dsc_senha") |
||
| 61 | @Size(max = 20, message = "Limite de caracteres ultrapassado: Senha") |
||
| 62 | public String getSenha() { |
||
| 63 | return senha; |
||
| 64 | } |
||
| 65 | public void setSenha(String senha) { |
||
| 66 | this.senha = senha; |
||
| 67 | } |
||
| 68 | |||
| 69 | @Column(name="val_aluguel") |
||
| 70 | public Double getValorAluguel() { |
||
| 71 | return valorAluguel; |
||
| 72 | } |
||
| 73 | public void setValorAluguel(Double valorAluguel) { |
||
| 74 | this.valorAluguel = valorAluguel; |
||
| 75 | } |
||
| 76 | |||
| 77 | @Column(name="dsc_observacao") |
||
| 78 | @Size(max = 400, message = "Limite de caracteres ultrapassado: Observação") |
||
| 79 | public String getObservacao() { |
||
| 80 | return observacao; |
||
| 81 | } |
||
| 82 | public void setObservacao(String observacao) { |
||
| 83 | this.observacao = StringUtil.setarUpperCaseComTrim(observacao); |
||
| 84 | } |
||
| 85 | |||
| 86 | @ManyToOne |
||
| 87 | @ForeignKey(name="fk_maquineta_empresaadquirente") |
||
| 88 | @JoinColumn(name = "seq_empresa_adquirente", nullable=true) |
||
| 89 | @NotNull(message="Obrigatório informar a empresa adquirente", groups={Cadastrar.class, Alterar.class}) |
||
| 90 | public EmpresaAdquirente getEmpresaAdquirente() { |
||
| 91 | return empresaAdquirente; |
||
| 92 | } |
||
| 93 | public void setEmpresaAdquirente(EmpresaAdquirente empresaAdquirente) { |
||
| 94 | this.empresaAdquirente = empresaAdquirente; |
||
| 95 | } |
||
| 96 | |||
| 97 | @ManyToOne |
||
| 98 | @ForeignKey(name="fk_maquineta_pessoa") |
||
| 99 | @JoinColumn(name = "seq_pessoa", nullable=true) |
||
| 100 | @NotNull(message="Obrigatório informar a pessoa", groups={Cadastrar.class, Alterar.class}) |
||
| 101 | public Pessoa getPessoa() { |
||
| 102 | return pessoa; |
||
| 103 | } |
||
| 104 | public void setPessoa(Pessoa pessoa) { |
||
| 105 | this.pessoa = pessoa; |
||
| 106 | } |
||
| 107 | |||
| 108 | @Column(name="ind_ativo", nullable=false) |
||
| 109 | public Boolean getAtivo() { |
||
| 110 | return ativo; |
||
| 111 | } |
||
| 112 | public void setAtivo(Boolean ativo) { |
||
| 113 | this.ativo = ativo; |
||
| 114 | } |
||
| 115 | |||
| 116 | public String descricaoCompleta() { |
||
| 117 | return getEmpresaAdquirente().getDescricao() + ": " + getDescricao(); |
||
| 118 | } |
||
| 119 | |||
| 120 | @Override |
||
| 121 | public int hashCode() { |
||
| 122 | final int prime = 31; |
||
| 123 | int result = 1; |
||
| 124 | result = prime * result |
||
| 125 | + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 126 | return result; |
||
| 127 | } |
||
| 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 | Maquineta other = (Maquineta) 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 | } |