Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
200 espaco 1
package br.com.ec.controller.managedbean;
2
 
3
import java.io.Serializable;
4
 
5
import javax.inject.Inject;
6
import javax.inject.Named;
7
 
8
import org.springframework.context.annotation.Scope;
9
 
10
import br.com.ec.core.generic.GenericService;
11
import br.com.ec.core.util.DataUtils;
12
import br.com.ec.domain.model.Ponto;
13
import br.com.ec.domain.service.ponto.PontoService;
14
import br.com.ec.web.exception.VerificadorLancamentoException;
15
import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean;
16
import br.com.ec.web.generic.AbstractBean;
17
import br.com.ec.web.message.LancadorMensagem;
18
 
19
@Named
20
@Scope("view")
21
public class PontoBean extends AbstractBean<Ponto> implements Serializable {
22
 
23
        private static final long serialVersionUID = 1L;
24
 
25
        private String senhaUsuario;
26
 
27
        private PontoService pontoService;
28
 
29
        @Inject
30
        public PontoBean(PontoService pontoService) {
31
                this.pontoService = pontoService;
32
        }
33
 
34
        @Override
35
        public void preCarregamento() {
36
                limparEntidade();
37
        }
38
 
39
        @Override
40
        public void limparEntidade() {
41
                entidade = new Ponto();
42
                setSenhaUsuario("");
43
        }
44
 
45
        @Override
46
        public GenericService<Ponto> getService() {
47
                return pontoService;
48
        }
49
 
50
        @Override
51
        public Ponto getEntidade() {
52
                return entidade;
53
        }
54
 
55
        @Override
56
        public Ponto getId() {
57
                return getEntidade();
58
        }
59
 
60
        public String getSenhaUsuario() {
61
                return senhaUsuario;
62
        }
63
        public void setSenhaUsuario(String senhaUsuario) {
64
                this.senhaUsuario = senhaUsuario;
65
        }
66
 
67
        /***************************************************************/
68
 
69
        public void iniciarPonto(final Long lojaSequencial) {
70
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
71
                        public void execute() {
72
                                setEntidade(pontoService.consultarPonto(DataUtils.getDataAtual(), senhaUsuario, lojaSequencial));
73
                        }
74
                });
75
        }
76
 
77
        public void baterPontoInicio() {
78
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
79
                        public void execute() {
80
                                getEntidade().setDataHoraPontoInicio(DataUtils.getDataAtual());
81
                                baterPonto();
82
                        }
83
                });
84
        }
85
 
86
        public void excluirPontoInicio() {
87
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
88
                        public void execute() {
89
                                getEntidade().setDataHoraPontoInicio(null);
90
                                baterPonto();
91
                        }
92
                });
93
        }
94
 
95
        public void baterPontoFim() {
96
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
97
                        public void execute() {
98
                                getEntidade().setDataHoraPontoFim(DataUtils.getDataAtual());
99
                                baterPonto();
100
                        }
101
                });
102
        }
103
 
104
        public void excluirPontoFim() {
105
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
106
                        public void execute() {
107
                                getEntidade().setDataHoraPontoFim(null);
108
                                baterPonto();
109
                        }
110
                });
111
        }
112
 
113
        public void baterIntervaloInicio() {
114
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
115
                        public void execute() {
116
                                getEntidade().setDataHoraIntervaloInicio(DataUtils.getDataAtual());
117
                                baterPonto();
118
                        }
119
                });
120
        }
121
 
122
        public void excluirIntervaloInicio() {
123
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
124
                        public void execute() {
125
                                getEntidade().setDataHoraIntervaloInicio(null);
126
                                baterPonto();
127
                        }
128
                });
129
        }
130
 
131
        public void baterIntervaloFim() {
132
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
133
                        public void execute() {
134
                                getEntidade().setDataHoraIntervaloFim(DataUtils.getDataAtual());
135
                                baterPonto();
136
                        }
137
                });
138
        }
139
 
140
        public void excluirIntervaloFim() {
141
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
142
                        public void execute() {
143
                                getEntidade().setDataHoraIntervaloFim(null);
144
                                baterPonto();
145
                        }
146
                });
147
        }
148
 
149
        private void baterPonto() {
150
                pontoService.alterar(getEntidade());
151
                limparEntidade();
152
                LancadorMensagem.lancarSucesso("PONTO ALTERADO COM SUCESSO!");
153
        }
154
 
155
}