Rev 182 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 179 | 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.SequenceGenerator; |
||
| 11 | import javax.persistence.Table; |
||
| 12 | |||
| 13 | @Entity |
||
| 14 | @Table(name="sec_usuario", schema="sc_sec") |
||
| 15 | public class Usuario implements Serializable { |
||
| 16 | |||
| 17 | private static final long serialVersionUID = 1L; |
||
| 18 | |||
| 19 | private Long sequencial; |
||
| 20 | /* |
||
| 21 | private Pessoa pessoa; |
||
| 22 | private String nome; |
||
| 23 | private String login; |
||
| 24 | private String senha; |
||
| 25 | private Date ultimoAcesso; |
||
| 26 | private boolean ativo; |
||
| 27 | |||
| 28 | // private Set<Venda> listaVendas; |
||
| 29 | private Set<UsuarioPerfil> perfis; |
||
| 30 | private Set<UsuarioLoja> lojas; |
||
| 31 | |||
| 32 | private List<Parametro> parametros; |
||
| 33 | */ |
||
| 34 | |||
| 35 | @Id |
||
| 36 | @SequenceGenerator(name = "sq_usuario") |
||
| 37 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 38 | @Column(name="seq_usuario", nullable=false) |
||
| 39 | public Long getSequencial() { |
||
| 40 | return sequencial; |
||
| 41 | } |
||
| 42 | public void setSequencial(Long sequencial) { |
||
| 43 | this.sequencial = sequencial; |
||
| 44 | } |
||
| 45 | /* |
||
| 46 | @OneToOne |
||
| 47 | @ForeignKey(name="fk_usuario_pessoa") |
||
| 48 | @NotNull(message="Obrigatório informar a pessoa", groups={Cadastrar.class, Alterar.class}) |
||
| 49 | @JoinColumn(name="seq_pessoa", referencedColumnName="seq_pessoa", nullable=false) |
||
| 50 | public Pessoa getPessoa() { |
||
| 51 | return pessoa; |
||
| 52 | } |
||
| 53 | |||
| 54 | public void setPessoa(Pessoa pessoa) { |
||
| 55 | this.pessoa = pessoa; |
||
| 56 | } |
||
| 57 | |||
| 58 | @Column(name="dsc_nome") |
||
| 59 | @Size(max = 120, message = "Limite de caracteres ultrapassado: Nome") |
||
| 60 | public String getNome() { |
||
| 61 | return nome; |
||
| 62 | } |
||
| 63 | public void setNome(String nome) { |
||
| 64 | this.nome = StringUtil.setarUpperCaseComTrim(nome); |
||
| 65 | } |
||
| 66 | |||
| 67 | @Column(name="dsc_login", nullable=false) |
||
| 68 | @Size(max = 32, message = "Limite de caracteres ultrapassado: Login") |
||
| 69 | @NotEmpty(message="Obrigatório informar o login", groups={Cadastrar.class, Alterar.class}) |
||
| 70 | public String getLogin() { |
||
| 71 | return login; |
||
| 72 | } |
||
| 73 | public void setLogin(String login) { |
||
| 74 | this.login = login; |
||
| 75 | } |
||
| 76 | |||
| 77 | @Column(name="dsc_senha", nullable=false) |
||
| 78 | @Size(max = 32, message = "Limite de caracteres ultrapassado: Senha") |
||
| 79 | @NotEmpty(message="Obrigatório informar a senha", groups={Cadastrar.class, Alterar.class}) |
||
| 80 | public String getSenha() { |
||
| 81 | return senha; |
||
| 82 | } |
||
| 83 | public void setSenha(String senha) { |
||
| 84 | this.senha = senha; |
||
| 85 | } |
||
| 86 | |||
| 87 | @Column(name="dth_ultimo_acesso") |
||
| 88 | public Date getUltimoAcesso() { |
||
| 89 | return ultimoAcesso; |
||
| 90 | } |
||
| 91 | public void setUltimoAcesso(Date ultimoAcesso) { |
||
| 92 | this.ultimoAcesso = ultimoAcesso; |
||
| 93 | } |
||
| 94 | |||
| 95 | @Column(name="ind_ativo", nullable=false) |
||
| 96 | public Boolean getAtivo() { |
||
| 97 | return ativo; |
||
| 98 | } |
||
| 99 | public void setAtivo(Boolean ativo) { |
||
| 100 | this.ativo = ativo; |
||
| 101 | } |
||
| 102 | |||
| 103 | @OneToMany(mappedBy="usuario", cascade=CascadeType.ALL, orphanRemoval=true) |
||
| 104 | public Set<UsuarioPerfil> getPerfis() { |
||
| 105 | return perfis; |
||
| 106 | } |
||
| 107 | public void setPerfis(Set<UsuarioPerfil> perfis) { |
||
| 108 | this.perfis = perfis; |
||
| 109 | } |
||
| 110 | |||
| 111 | @OneToMany(mappedBy="usuario", cascade=CascadeType.ALL, orphanRemoval=true) |
||
| 112 | public Set<UsuarioLoja> getLojas() { |
||
| 113 | return lojas; |
||
| 114 | } |
||
| 115 | public void setLojas(Set<UsuarioLoja> lojas) { |
||
| 116 | this.lojas = lojas; |
||
| 117 | } |
||
| 118 | |||
| 119 | @Transient |
||
| 120 | public List<Parametro> getParametros() { |
||
| 121 | return parametros; |
||
| 122 | } |
||
| 123 | public void setParametros(List<Parametro> parametros) { |
||
| 124 | this.parametros = parametros; |
||
| 125 | } |
||
| 126 | |||
| 127 | @Transient |
||
| 128 | public String getNomeDaPessoa() { |
||
| 129 | return VerificadorUtil.naoEstaNulo(pessoa)? pessoa.getNome() : null; |
||
| 130 | } |
||
| 131 | |||
| 132 | @Transient |
||
| 133 | public Long getSequencialDaPessoa() { |
||
| 134 | return VerificadorUtil.naoEstaNulo(pessoa)? pessoa.getSequencial() : null; |
||
| 135 | } |
||
| 136 | |||
| 137 | @Transient |
||
| 138 | public Boolean verificarSeTemFoto() { |
||
| 139 | File foto = new File(getCaminhoPastaFotos() + "user" + getSequencial() + ".jpg"); |
||
| 140 | return foto.exists(); |
||
| 141 | } |
||
| 142 | |||
| 143 | @Transient |
||
| 144 | public String getCaminhoPastaFotos() { |
||
| 145 | ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext(); |
||
| 146 | return servletContext.getRealPath("") + File.separator + "imagens" + File.separator + "usuarios" + File.separator; |
||
| 147 | } |
||
| 148 | */ |
||
| 149 | } |