Rev 195 | Rev 572 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 195 | Rev 571 | ||
|---|---|---|---|
| Line 2... | Line 2... | ||
| 2 | 2 | ||
| 3 | import java.io.Serializable; |
3 | import java.io.Serializable; |
| 4 | 4 | ||
| 5 | import javax.inject.Inject; |
5 | import javax.inject.Inject; |
| 6 | import javax.inject.Named; |
6 | import javax.inject.Named; |
| - | 7 | import javax.servlet.http.HttpServletRequest; |
|
| 7 | 8 | ||
| - | 9 | import org.springframework.beans.factory.annotation.Autowired; |
|
| 8 | import org.springframework.context.annotation.Scope; |
10 | import org.springframework.context.annotation.Scope; |
| 9 | 11 | ||
| - | 12 | import br.com.ec.controller.util.IpUtil; |
|
| 10 | import br.com.ec.core.generic.GenericService; |
13 | import br.com.ec.core.generic.GenericService; |
| 11 | import br.com.ec.core.util.DataUtils; |
14 | import br.com.ec.core.util.DataUtils; |
| 12 | import br.com.ec.domain.model.Ponto; |
15 | import br.com.ec.domain.model.Ponto; |
| 13 | import br.com.ec.domain.service.ponto.PontoService; |
16 | import br.com.ec.domain.service.ponto.PontoService; |
| 14 | import br.com.ec.web.exception.VerificadorLancamentoException; |
17 | import br.com.ec.web.exception.VerificadorLancamentoException; |
| Line 23... | Line 26... | ||
| 23 | private static final long serialVersionUID = 1L; |
26 | private static final long serialVersionUID = 1L; |
| 24 | 27 | ||
| 25 | private String senhaUsuario; |
28 | private String senhaUsuario; |
| 26 | 29 | ||
| 27 | private PontoService pontoService; |
30 | private PontoService pontoService; |
| - | 31 | ||
| - | 32 | // @Autowired
|
|
| - | 33 | // private HttpServletRequest request;
|
|
| 28 | 34 | ||
| 29 | @Inject |
35 | @Inject |
| 30 | public PontoBean(PontoService pontoService) { |
36 | public PontoBean(PontoService pontoService) { |
| 31 | this.pontoService = pontoService; |
37 | this.pontoService = pontoService; |
| 32 | }
|
38 | }
|
| Line 76... | Line 82... | ||
| 76 | 82 | ||
| 77 | public void baterPontoInicio() { |
83 | public void baterPontoInicio() { |
| 78 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
84 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
| 79 | public void execute() { |
85 | public void execute() { |
| 80 | getEntidade().setDataHoraPontoInicio(DataUtils.getDataAtual()); |
86 | getEntidade().setDataHoraPontoInicio(DataUtils.getDataAtual()); |
| - | 87 | getEntidade().setIpPontoInicio(recuperarIpUsuario()); |
|
| 81 | baterPonto(); |
88 | baterPonto(); |
| 82 | }
|
89 | }
|
| 83 | }); |
90 | }); |
| 84 | }
|
91 | }
|
| 85 | 92 | ||
| Line 94... | Line 101... | ||
| 94 | 101 | ||
| 95 | public void baterPontoFim() { |
102 | public void baterPontoFim() { |
| 96 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
103 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
| 97 | public void execute() { |
104 | public void execute() { |
| 98 | getEntidade().setDataHoraPontoFim(DataUtils.getDataAtual()); |
105 | getEntidade().setDataHoraPontoFim(DataUtils.getDataAtual()); |
| - | 106 | getEntidade().setIpPontoFim(recuperarIpUsuario()); |
|
| 99 | baterPonto(); |
107 | baterPonto(); |
| 100 | }
|
108 | }
|
| 101 | }); |
109 | }); |
| 102 | }
|
110 | }
|
| 103 | 111 | ||
| Line 112... | Line 120... | ||
| 112 | 120 | ||
| 113 | public void baterIntervaloInicio() { |
121 | public void baterIntervaloInicio() { |
| 114 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
122 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
| 115 | public void execute() { |
123 | public void execute() { |
| 116 | getEntidade().setDataHoraIntervaloInicio(DataUtils.getDataAtual()); |
124 | getEntidade().setDataHoraIntervaloInicio(DataUtils.getDataAtual()); |
| - | 125 | getEntidade().setIpPontoIntervaloInicio(recuperarIpUsuario()); |
|
| 117 | baterPonto(); |
126 | baterPonto(); |
| 118 | }
|
127 | }
|
| 119 | }); |
128 | }); |
| 120 | }
|
129 | }
|
| 121 | 130 | ||
| Line 130... | Line 139... | ||
| 130 | 139 | ||
| 131 | public void baterIntervaloFim() { |
140 | public void baterIntervaloFim() { |
| 132 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
141 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
| 133 | public void execute() { |
142 | public void execute() { |
| 134 | getEntidade().setDataHoraIntervaloFim(DataUtils.getDataAtual()); |
143 | getEntidade().setDataHoraIntervaloFim(DataUtils.getDataAtual()); |
| - | 144 | getEntidade().setIpPontoIntervaloFim(recuperarIpUsuario()); |
|
| 135 | baterPonto(); |
145 | baterPonto(); |
| 136 | }
|
146 | }
|
| 137 | }); |
147 | }); |
| 138 | }
|
148 | }
|
| 139 | 149 | ||
| Line 142... | Line 152... | ||
| 142 | public void execute() { |
152 | public void execute() { |
| 143 | getEntidade().setDataHoraIntervaloFim(null); |
153 | getEntidade().setDataHoraIntervaloFim(null); |
| 144 | baterPonto(); |
154 | baterPonto(); |
| 145 | }
|
155 | }
|
| 146 | }); |
156 | }); |
| - | 157 | }
|
|
| - | 158 | ||
| - | 159 | private String recuperarIpUsuario() { |
|
| - | 160 | HttpServletRequest request = (HttpServletRequest) getContext().getExternalContext().getRequest(); |
|
| - | 161 | return IpUtil.getClientIp(request); |
|
| 147 | }
|
162 | }
|
| 148 | 163 | ||
| 149 | private void baterPonto() { |
164 | private void baterPonto() { |
| 150 | pontoService.alterar(getEntidade()); |
165 | pontoService.alterar(getEntidade()); |
| 151 | limparEntidade(); |
166 | limparEntidade(); |