Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | package br.gov.al.saude.srv.web.managebean.relatorio; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.Collection; |
||
| 5 | import java.util.List; |
||
| 6 | |||
| 7 | import javax.faces.bean.ManagedBean; |
||
| 8 | |||
| 9 | import net.sf.jasperreports.engine.JasperPrint; |
||
| 10 | |||
| 11 | import org.primefaces.model.StreamedContent; |
||
| 12 | import org.springframework.beans.factory.annotation.Autowired; |
||
| 13 | import org.springframework.context.annotation.Scope; |
||
| 14 | import org.springframework.security.core.GrantedAuthority; |
||
| 15 | import org.springframework.stereotype.Component; |
||
| 16 | |||
| 17 | import br.gov.al.saude.framework.core.util.RelatorioUtils; |
||
| 18 | import br.gov.al.saude.framework.core.util.VerificadorUtil; |
||
| 19 | import br.gov.al.saude.framework.security.authentication.authorities.IndraGrantedAuthority; |
||
| 20 | import br.gov.al.saude.framework.security.authentication.entity.UserIndra; |
||
| 21 | import br.gov.al.saude.framework.security.context.ContextoSeguranca; |
||
| 22 | import br.gov.al.saude.framework.web.generic.VerificadorPermissao; |
||
| 23 | import br.gov.al.saude.framework.web.message.LancadorMensagem; |
||
| 24 | import br.gov.al.saude.srv.core.application.cargo.CargoFacade; |
||
| 25 | import br.gov.al.saude.srv.core.application.emissorrelatorio.EmissorRelatorioFacade; |
||
| 26 | import br.gov.al.saude.srv.core.application.especialidade.EspecialidadeFacade; |
||
| 27 | import br.gov.al.saude.srv.core.application.formaingresso.FormaIngressoFacade; |
||
| 28 | import br.gov.al.saude.srv.core.application.funcao.FuncaoFacade; |
||
| 29 | import br.gov.al.saude.srv.core.application.grauinstrucao.GrauInstrucaoFacade; |
||
| 30 | import br.gov.al.saude.srv.core.application.orgao.OrgaoFacade; |
||
| 31 | import br.gov.al.saude.srv.core.application.situacaoservidor.SituacaoServidorFacade; |
||
| 32 | import br.gov.al.saude.srv.core.application.unidade.UnidadeFacade; |
||
| 33 | import br.gov.al.saude.srv.model.Cargo; |
||
| 34 | import br.gov.al.saude.srv.model.Especialidade; |
||
| 35 | import br.gov.al.saude.srv.model.FormaIngresso; |
||
| 36 | import br.gov.al.saude.srv.model.Funcao; |
||
| 37 | import br.gov.al.saude.srv.model.GrauInstrucao; |
||
| 38 | import br.gov.al.saude.srv.model.Orgao; |
||
| 39 | import br.gov.al.saude.srv.model.SituacaoServidor; |
||
| 40 | import br.gov.al.saude.srv.model.Unidade; |
||
| 41 | import br.gov.al.saude.srv.model.dto.ParametrosRelatorioAcompanhamentoServidorDTO; |
||
| 42 | import br.gov.al.saude.srv.model.enums.TipoRelatorioAcompanhamento; |
||
| 43 | import br.gov.al.saude.srv.model.enums.TipoRelatorioQuantitativo; |
||
| 44 | |||
| 45 | @Component |
||
| 46 | @ManagedBean |
||
| 47 | @Scope("view") |
||
| 48 | public class RelatorioBean implements Serializable, VerificadorPermissao { |
||
| 49 | |||
| 50 | private static final long serialVersionUID = 1L; |
||
| 51 | |||
| 52 | private ParametrosRelatorioAcompanhamentoServidorDTO parametrosRelatorioAcompanhamentoServidor = new ParametrosRelatorioAcompanhamentoServidorDTO(); |
||
| 53 | |||
| 54 | private List<GrauInstrucao> listaGrausInstrucao; |
||
| 55 | private List<SituacaoServidor> listaSituacoesServidor; |
||
| 56 | private List<Cargo> listaCargosServidor; |
||
| 57 | private List<Funcao> listaFuncoesServidor; |
||
| 58 | private List<Especialidade> listaEspecialidadesServidor; |
||
| 59 | private List<Orgao> listaOrgaos; |
||
| 60 | private List<Unidade> listaUnidades; |
||
| 61 | private List<FormaIngresso> listaFormaIngresso; |
||
| 62 | |||
| 63 | private EmissorRelatorioFacade emissorRelatorioFacade; |
||
| 64 | private GrauInstrucaoFacade grauInstrucaoFacade; |
||
| 65 | private SituacaoServidorFacade situacaoServidorFacade; |
||
| 66 | private CargoFacade cargoFacade; |
||
| 67 | private FuncaoFacade funcaoFacade; |
||
| 68 | private EspecialidadeFacade especialidadeFacade; |
||
| 69 | private OrgaoFacade orgaoFacade; |
||
| 70 | private UnidadeFacade unidadeFacade; |
||
| 71 | private FormaIngressoFacade formaIngressoFacade; |
||
| 72 | |||
| 73 | @Autowired |
||
| 74 | private ContextoSeguranca contextoSeguranca; |
||
| 75 | |||
| 76 | @Autowired |
||
| 77 | public RelatorioBean(EmissorRelatorioFacade emissorRelatorioFacade, GrauInstrucaoFacade grauInstrucaoFacade, |
||
| 78 | SituacaoServidorFacade situacaoServidorFacade, |
||
| 79 | CargoFacade cargoFacade, FuncaoFacade funcaoFacade, EspecialidadeFacade especialidadeFacade, |
||
| 80 | OrgaoFacade orgaoFacade, UnidadeFacade unidadeFacade, FormaIngressoFacade formaIngressoFacade) { |
||
| 81 | this.emissorRelatorioFacade = emissorRelatorioFacade; |
||
| 82 | this.grauInstrucaoFacade = grauInstrucaoFacade; |
||
| 83 | this.situacaoServidorFacade = situacaoServidorFacade; |
||
| 84 | this.cargoFacade = cargoFacade; |
||
| 85 | this.funcaoFacade = funcaoFacade; |
||
| 86 | this.especialidadeFacade = especialidadeFacade; |
||
| 87 | this.orgaoFacade = orgaoFacade; |
||
| 88 | this.unidadeFacade = unidadeFacade; |
||
| 89 | this.formaIngressoFacade = formaIngressoFacade; |
||
| 90 | parametrosRelatorioAcompanhamentoServidor.setTipoRelatorioAcompanhamento(TipoRelatorioAcompanhamento.ACOMPANHAMENTO); |
||
| 91 | } |
||
| 92 | |||
| 93 | public StreamedContent emitirRelatorioAcompanhamento() { |
||
| 94 | try { |
||
| 95 | JasperPrint relatorio = emissorRelatorioFacade.emitirRelatorioAcompanhamentoServidor(parametrosRelatorioAcompanhamentoServidor); |
||
| 96 | return RelatorioUtils.gerarPdf(relatorio, relatorio.getName()); |
||
| 97 | } catch (Exception e) { |
||
| 98 | LancadorMensagem.lancarAlerta(e.getMessage()); |
||
| 99 | return null; |
||
| 100 | } |
||
| 101 | } |
||
| 102 | |||
| 103 | public ParametrosRelatorioAcompanhamentoServidorDTO.ColunaAgrupamentoEnumeration[] getColunasAgrupamentoRelatorioAcompanhamentoServidor() { |
||
| 104 | return ParametrosRelatorioAcompanhamentoServidorDTO.ColunaAgrupamentoEnumeration.values(); |
||
| 105 | } |
||
| 106 | |||
| 107 | public StreamedContent emitirRelatorioQuantitativoCargo() { |
||
| 108 | return emitirRelatorioQuantitativo(TipoRelatorioQuantitativo.ACOMPANHAMENTO_CARGO); |
||
| 109 | } |
||
| 110 | |||
| 111 | public StreamedContent emitirRelatorioQuantitativoFuncao() { |
||
| 112 | return emitirRelatorioQuantitativo(TipoRelatorioQuantitativo.ACOMPANHAMENTO_FUNCAO); |
||
| 113 | } |
||
| 114 | |||
| 115 | private StreamedContent emitirRelatorioQuantitativo(final TipoRelatorioQuantitativo tipo) { |
||
| 116 | try { |
||
| 117 | JasperPrint relatorio = emissorRelatorioFacade.emitirRelatorioQuantitativoDeCargoOuFuncao(tipo); |
||
| 118 | return RelatorioUtils.gerarPdf(relatorio, relatorio.getName()); |
||
| 119 | } catch (Exception e) { |
||
| 120 | LancadorMensagem.lancarAlerta(e.getMessage()); |
||
| 121 | return null; |
||
| 122 | } |
||
| 123 | } |
||
| 124 | |||
| 125 | public TipoRelatorioAcompanhamento[] getTiposRelatoriosAcompanhamentos() { |
||
| 126 | return TipoRelatorioAcompanhamento.values(); |
||
| 127 | } |
||
| 128 | |||
| 129 | public ParametrosRelatorioAcompanhamentoServidorDTO getParametrosRelatorioAcompanhamentoServidor() { |
||
| 130 | return parametrosRelatorioAcompanhamentoServidor; |
||
| 131 | } |
||
| 132 | |||
| 133 | public void setParametrosRelatorioAcompanhamentoServidor( |
||
| 134 | ParametrosRelatorioAcompanhamentoServidorDTO parametrosRelatorioAcompanhamentoServidor) { |
||
| 135 | this.parametrosRelatorioAcompanhamentoServidor = parametrosRelatorioAcompanhamentoServidor; |
||
| 136 | } |
||
| 137 | |||
| 138 | public List<GrauInstrucao> getListaGrausInstrucao() { |
||
| 139 | if(VerificadorUtil.estaNulo(listaGrausInstrucao)) { |
||
| 140 | listaGrausInstrucao = grauInstrucaoFacade.consultarTodos(new GrauInstrucao()); |
||
| 141 | } |
||
| 142 | return listaGrausInstrucao; |
||
| 143 | } |
||
| 144 | |||
| 145 | public void setListaGrausInstrucao(List<GrauInstrucao> listaGrausInstrucao) { |
||
| 146 | this.listaGrausInstrucao = listaGrausInstrucao; |
||
| 147 | } |
||
| 148 | |||
| 149 | public List<SituacaoServidor> getListaSituacoesServidor() { |
||
| 150 | if(VerificadorUtil.estaNulo(listaSituacoesServidor)) { |
||
| 151 | listaSituacoesServidor = situacaoServidorFacade.consultarTodos(new SituacaoServidor()); |
||
| 152 | } |
||
| 153 | return listaSituacoesServidor; |
||
| 154 | } |
||
| 155 | |||
| 156 | public void setListaSituacoesServidor(List<SituacaoServidor> listaSituacoesServidor) { |
||
| 157 | this.listaSituacoesServidor = listaSituacoesServidor; |
||
| 158 | } |
||
| 159 | |||
| 160 | public List<Cargo> getListaCargosServidor() { |
||
| 161 | if(VerificadorUtil.estaNulo(listaCargosServidor)) { |
||
| 162 | listaCargosServidor = cargoFacade.consultarTodos(new Cargo()); |
||
| 163 | } |
||
| 164 | return listaCargosServidor; |
||
| 165 | } |
||
| 166 | |||
| 167 | public void setListaCargosServidor(List<Cargo> listaCargosServidor) { |
||
| 168 | this.listaCargosServidor = listaCargosServidor; |
||
| 169 | } |
||
| 170 | |||
| 171 | public List<Funcao> getListaFuncoesServidor() { |
||
| 172 | if(VerificadorUtil.estaNulo(listaFuncoesServidor)) { |
||
| 173 | listaFuncoesServidor = funcaoFacade.consultarTodos(new Funcao()); |
||
| 174 | } |
||
| 175 | return listaFuncoesServidor; |
||
| 176 | } |
||
| 177 | |||
| 178 | public void setListaFuncoesServidor(List<Funcao> listaFuncoesServidor) { |
||
| 179 | this.listaFuncoesServidor = listaFuncoesServidor; |
||
| 180 | } |
||
| 181 | |||
| 182 | public List<Especialidade> getListaEspecialidadesServidor() { |
||
| 183 | if(VerificadorUtil.estaNulo(listaEspecialidadesServidor)) { |
||
| 184 | listaEspecialidadesServidor = especialidadeFacade.consultarTodos(new Especialidade()); |
||
| 185 | } |
||
| 186 | return listaEspecialidadesServidor; |
||
| 187 | } |
||
| 188 | |||
| 189 | public void setListaEspecialidadesServidor(List<Especialidade> listaEspecialidadesServidor) { |
||
| 190 | this.listaEspecialidadesServidor = listaEspecialidadesServidor; |
||
| 191 | } |
||
| 192 | |||
| 193 | public List<Orgao> getListaOrgaos() { |
||
| 194 | if(VerificadorUtil.estaNulo(listaOrgaos)) { |
||
| 195 | listaOrgaos = orgaoFacade.consultarTodos(new Orgao()); |
||
| 196 | } |
||
| 197 | return listaOrgaos; |
||
| 198 | } |
||
| 199 | |||
| 200 | public void setListaOrgaos(List<Orgao> listaOrgaos) { |
||
| 201 | this.listaOrgaos = listaOrgaos; |
||
| 202 | } |
||
| 203 | |||
| 204 | public List<Unidade> getListaUnidades() { |
||
| 205 | if(VerificadorUtil.estaNulo(listaUnidades)) { |
||
| 206 | listaUnidades = unidadeFacade.consultarTodos(new Unidade()); |
||
| 207 | } |
||
| 208 | return listaUnidades; |
||
| 209 | } |
||
| 210 | |||
| 211 | public void setListaUnidades(List<Unidade> listaUnidades) { |
||
| 212 | this.listaUnidades = listaUnidades; |
||
| 213 | } |
||
| 214 | |||
| 215 | public UserIndra getUsuario() { |
||
| 216 | return contextoSeguranca.obterUserIndra(); |
||
| 217 | } |
||
| 218 | |||
| 219 | @Override |
||
| 220 | public Boolean verificarPermissao(String permissao) { |
||
| 221 | GrantedAuthority authority = new IndraGrantedAuthority(permissao); |
||
| 222 | Collection<? extends GrantedAuthority> authorities = getUsuario().getAuthorities(); |
||
| 223 | return authorities.contains(authority); |
||
| 224 | } |
||
| 225 | |||
| 226 | public List<FormaIngresso> getListaFormaIngresso() { |
||
| 227 | if(VerificadorUtil.estaNulo(listaFormaIngresso)){ |
||
| 228 | listaFormaIngresso = formaIngressoFacade.consultarTodos(new FormaIngresso()); |
||
| 229 | } |
||
| 230 | return listaFormaIngresso; |
||
| 231 | } |
||
| 232 | |||
| 233 | public void setListaFormaIngresso(List<FormaIngresso> listaFormaIngresso) { |
||
| 234 | this.listaFormaIngresso = listaFormaIngresso; |
||
| 235 | } |
||
| 236 | |||
| 237 | public void limparParametrosDeConsultaDosRelatoriosDeAcompanhamentoDoServidor() { |
||
| 238 | parametrosRelatorioAcompanhamentoServidor = new ParametrosRelatorioAcompanhamentoServidorDTO(); |
||
| 239 | parametrosRelatorioAcompanhamentoServidor.setTipoRelatorioAcompanhamento(TipoRelatorioAcompanhamento.ACOMPANHAMENTO); |
||
| 240 | } |
||
| 241 | } |