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 | import java.util.List; |
||
| 5 | |||
| 6 | import javax.annotation.PostConstruct; |
||
| 7 | import javax.inject.Inject; |
||
| 8 | import javax.inject.Named; |
||
| 9 | |||
| 10 | import org.springframework.context.annotation.Scope; |
||
| 11 | |||
| 12 | import br.edu.cesmac.core.consulta.ParametrosConsulta; |
||
| 13 | import br.edu.cesmac.core.generic.GenericService; |
||
| 14 | import br.edu.cesmac.sic.controller.beans.consultademanda.QuestaoConsultaPorDemanda; |
||
| 15 | import br.edu.cesmac.sic.core.domain.model.Questao; |
||
| 16 | import br.edu.cesmac.sic.core.domain.model.tipo.TipoTopico; |
||
| 17 | import br.edu.cesmac.sic.core.domain.service.QuestaoService; |
||
| 18 | import br.edu.cesmac.web.generic.AbstractBean; |
||
| 19 | |||
| 20 | @Named |
||
| 21 | @Scope("view") |
||
| 22 | public class QuestaoBean extends AbstractBean<Questao> implements Serializable { |
||
| 23 | |||
| 24 | private static final long serialVersionUID = 1L; |
||
| 25 | |||
| 26 | private QuestaoConsultaPorDemanda lazy; |
||
| 27 | |||
| 28 | private QuestaoService questaoService; |
||
| 29 | |||
| 30 | @Inject |
||
| 31 | public QuestaoBean(QuestaoConsultaPorDemanda lazy, QuestaoService questaoService) { |
||
| 32 | this.lazy = lazy; |
||
| 33 | this.questaoService = questaoService; |
||
| 34 | } |
||
| 35 | |||
| 36 | @Override |
||
| 37 | public Questao getId() { |
||
| 38 | return getEntidade(); |
||
| 39 | } |
||
| 40 | |||
| 41 | @Override |
||
| 42 | public GenericService<Questao> getService() { |
||
| 43 | return questaoService; |
||
| 44 | } |
||
| 45 | |||
| 46 | @Override |
||
| 47 | public void limparEntidade() { |
||
| 48 | setEntidade(new Questao()); |
||
| 49 | } |
||
| 50 | |||
| 51 | @Override |
||
| 52 | public Questao getEntidade() { |
||
| 53 | return entidade; |
||
| 54 | } |
||
| 55 | |||
| 56 | public QuestaoConsultaPorDemanda getLazy() { |
||
| 57 | return lazy; |
||
| 58 | } |
||
| 59 | |||
| 60 | public void prepararConsultaDemanda() { |
||
| 61 | lazy.setarParametrosConsulta(getParametrosConsulta()); |
||
| 62 | } |
||
| 63 | |||
| 64 | public TipoTopico[] getTiposTopico() { |
||
| 65 | return TipoTopico.values(); |
||
| 66 | } |
||
| 67 | |||
| 68 | @PostConstruct |
||
| 69 | public void preCarregamento() { |
||
| 70 | parametrosConsulta = new ParametrosConsulta<Questao>(); |
||
| 71 | parametrosConsulta.setEntidade(new Questao()); |
||
| 72 | prepararConsultaDemanda(); |
||
| 73 | } |
||
| 74 | |||
| 75 | @Override |
||
| 76 | public void cadastrar() { |
||
| 77 | getEntidade().setAtivo(true); |
||
| 78 | super.cadastrar(); |
||
| 79 | } |
||
| 80 | |||
| 81 | public List<Questao> consultarQuestaosAtivas() { |
||
| 82 | return questaoService.consultarQuestoesAtivas(); |
||
| 83 | } |
||
| 84 | |||
| 85 | } |