Subversion Repositories Integrator Subversion

Rev

Rev 369 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
353 espaco 1
package br.com.ec.controller;
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.controller.consultademanda.NotaFiscalConsultaPorDemanda;
11
import br.com.ec.core.generic.GenericService;
12
import br.com.ec.domain.dto.consulta.ParametrosConsultaNotaFiscal;
13
import br.com.ec.domain.model.NotaFiscal;
14
import br.com.ec.domain.model.Papel;
15
import br.com.ec.domain.model.nfe.TipoNotaFiscal;
16
import br.com.ec.domain.service.NotaFiscalService;
17
import br.com.ec.web.exception.VerificadorLancamentoException;
18
import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean;
19
import br.com.ec.web.generic.AbstractBean;
20
import br.com.ec.web.message.LancadorMensagem;
21
import br.com.ec.web.util.TipoOperacao;
22
 
23
@Named
24
@Scope("view")
25
public class NotaFiscalBean extends AbstractBean<NotaFiscal> implements Serializable {
26
 
27
        private static final long serialVersionUID = 1L;
28
 
29
        private NotaFiscalService notaFiscalService;
30
 
31
        private ParametrosConsultaNotaFiscal parametrosConsultaNotaFiscal;
32
        private NotaFiscalConsultaPorDemanda lazy;
33
 
34
        private Long sequencialVendaParaVinculo;
35
 
36
        @Inject
37
        public NotaFiscalBean(NotaFiscalConsultaPorDemanda lazy, NotaFiscalService notaFiscalService) {
38
                this.lazy = lazy;
39
                this.notaFiscalService = notaFiscalService;
40
        }
41
 
42
        @Override
43
        public void preCarregamento() {
44
                parametrosConsultaNotaFiscal = new ParametrosConsultaNotaFiscal();
45
                prepararConsultaDemanda();
46
                limparEntidade();
47
        }
48
 
49
        @Override
50
        public void limparEntidade() {
51
                setEntidade(new NotaFiscal());
52
        }
53
 
54
        @Override
55
        public GenericService<NotaFiscal> getService() {
56
                return notaFiscalService;
57
        }
58
 
59
        @Override
60
        public NotaFiscal getEntidade() {
61
                return entidade;
62
        }
63
 
64
        @Override
65
        public void preConsultar() {
66
                setTipoOperacao(TipoOperacao.CONSULTAR);
67
        }
68
 
69
        @Override
70
        public NotaFiscal getId() {
71
                return getEntidade();
72
        }
73
 
74
        public ParametrosConsultaNotaFiscal getParametrosConsultaNotaFiscal() {
75
                return parametrosConsultaNotaFiscal;
76
        }
77
        public void setParametrosConsultaNotaFiscal(ParametrosConsultaNotaFiscal parametrosConsultaNotaFiscal) {
78
                this.parametrosConsultaNotaFiscal = parametrosConsultaNotaFiscal;
79
        }
80
 
81
        public NotaFiscalConsultaPorDemanda getLazy() {
82
                return lazy;
83
        }
84
        public void setLazy(NotaFiscalConsultaPorDemanda lazy) {
85
                this.lazy = lazy;
86
        }
87
        public void prepararConsultaDemanda() {
88
                lazy.setarParametrosConsulta(getParametrosConsultaNotaFiscal());
89
        }
90
 
91
        public TipoNotaFiscal[] getTiposNotaFiscal() {
92
                return TipoNotaFiscal.values();
93
        }
94
 
95
        public Long getSequencialVendaParaVinculo() {
96
                return sequencialVendaParaVinculo;
97
        }
98
        public void setSequencialVendaParaVinculo(Long sequencialVendaParaVinculo) {
99
                this.sequencialVendaParaVinculo = sequencialVendaParaVinculo;
100
        }
101
 
102
        /**************************************************/
103
 
104
        public void desvincularVenda() {
105
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
106
                        public void execute() {
107
//                              pessoaPapelService.adicionarPapel(getEntidade().getPessoa(), new Papel(getPessoaPapelDTO().getCodigoPapel()));
108
//                              getEntidadeDTO().setPapeisDTO(pessoaPapelService.consultarPapeisDaPessoa(getPessoaPapelDTO().getSequencialPessoa()));
109
                                LancadorMensagem.lancarSucesso("VENDA DESVINCULADA COM SUCESSO");
110
                        }
111
                });
112
        }
113
 
114
        public void vincularVenda() {
115
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
116
                        public void execute() {
117
//                              pessoaPapelService.adicionarPapel(getEntidade().getPessoa(), new Papel(getPessoaPapelDTO().getCodigoPapel()));
118
//                              getEntidadeDTO().setPapeisDTO(pessoaPapelService.consultarPapeisDaPessoa(getPessoaPapelDTO().getSequencialPessoa()));
119
                                LancadorMensagem.lancarSucesso("VENDA VINCULADA COM SUCESSO");
120
                        }
121
                });
122
        }
123
 
124
}