Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 espaco 1
package br.edu.cesmac.sic.controller.beans;
2
 
3
import java.io.Serializable;
4
 
5
import javax.annotation.PostConstruct;
6
import javax.inject.Inject;
7
import javax.inject.Named;
8
 
9
import org.springframework.context.annotation.Scope;
10
 
11
import br.edu.cesmac.core.consulta.ParametrosConsulta;
12
import br.edu.cesmac.core.generic.GenericService;
13
import br.edu.cesmac.sic.controller.beans.consultademanda.ProjetoPesquisaConsultaPorDemanda;
14
import br.edu.cesmac.sic.core.domain.model.ProjetoPesquisa;
15
import br.edu.cesmac.sic.core.domain.service.ProjetoPesquisaService;
16
import br.edu.cesmac.web.exception.VerificadorLancamentoException;
17
import br.edu.cesmac.web.exception.VerificadorLancamentoException.CommandBean;
18
import br.edu.cesmac.web.generic.AbstractBean;
19
import br.edu.cesmac.web.message.LancadorMensagem;
20
 
21
@Named
22
@Scope("view")
23
public class RecursoBean extends AbstractBean<ProjetoPesquisa> implements Serializable {
24
 
25
        private static final long serialVersionUID = 1L;
26
 
27
        private ProjetoPesquisaConsultaPorDemanda lazy;
28
        private ProjetoPesquisaService projetoPesquisaService;
29
 
30
        @Inject
31
        public RecursoBean(ProjetoPesquisaConsultaPorDemanda lazy, ProjetoPesquisaService projetoPesquisaService) {
32
                this.lazy = lazy;
33
                this.projetoPesquisaService = projetoPesquisaService;
34
        }
35
 
36
        @Override
37
        public ProjetoPesquisa getId() {
38
                return getEntidade();
39
        }
40
 
41
        @Override
42
        public GenericService<ProjetoPesquisa> getService() {
43
                return projetoPesquisaService;
44
        }
45
 
46
        @Override
47
        public void limparEntidade() {
48
                setEntidade(new ProjetoPesquisa());
49
        }
50
 
51
        @Override
52
        public ProjetoPesquisa getEntidade() {
53
                return entidade;
54
        }
55
 
56
        public ProjetoPesquisaConsultaPorDemanda getLazy() {
57
                return lazy;
58
        }
59
 
60
        public void prepararConsultaDemanda() {
61
                lazy.setarParametrosConsulta(getParametrosConsulta());
62
        }
63
 
64
        @PostConstruct
65
        public void preCarregamento() {
66
                parametrosConsulta = new ParametrosConsulta<ProjetoPesquisa>();
67
                parametrosConsulta.setEntidade(new ProjetoPesquisa());
68
                prepararConsultaDemanda();
69
        }
70
 
71
        @Override
72
        public void preDetalhar(ProjetoPesquisa projetoPesquisa) {
73
                detalharProjetoPesquisa(projetoPesquisa);
74
                super.preDetalhar(entidade);
75
        }
76
 
77
        public void detalharProjetoPesquisa(ProjetoPesquisa projetoPesquisa) {
78
                setEntidade(projetoPesquisaService.detalharProjetoPesquisa(projetoPesquisa));
79
        }
80
 
81
        public void prepararSolicitacaoRecurso(ProjetoPesquisa projetoPesquisa) {
82
                /*
83
                projetoPesquisa.setProjetoPesquisaRecurso(new ProjetoPesquisaRecurso());
84
                */
85
                setEntidade(projetoPesquisa);
86
        }
87
 
88
        public void solicitarRecurso() {
89
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
90
                        public void execute() {
91
                                projetoPesquisaService.solicitarRecurso(getEntidade());
92
                                LancadorMensagem.lancarSucesso("Recurso solicitado com sucesso");
93
                        }
94
                });
95
        }
96
 
97
        public void atenderRecurso() {
98
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
99
                        public void execute() {
100
                                projetoPesquisaService.atenderRecurso(getEntidade());
101
                                LancadorMensagem.lancarSucesso("Recurso atendido com sucesso");
102
                        }
103
                });
104
        }
105
 
106
        public void excluirRecurso(final ProjetoPesquisa projetoPesquisa) {
107
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
108
                        public void execute() {
109
                                projetoPesquisaService.excluirRecurso(projetoPesquisa);
110
                                LancadorMensagem.lancarSucesso("Dados excluĂ­dos com sucesso");
111
                        }
112
                });
113
        }
114
 
115
}