diff --git a/trunk/AnaliseAcidentesTrabalho/build.xml b/trunk/AnaliseAcidentesTrabalho/build.xml
new file mode 100644
index 00000000..749e498d
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/build.xml
@@ -0,0 +1,66 @@
+
+
+
+
+
Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.
+ */ +public class AnaliseAcidenteTrabalho extends AbstractPageBean { + //Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.
+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridBase1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridBase1() { + return gridBase1; + } + + public void setGridBase1(HtmlPanelGrid hpg) { + this.gridBase1 = hpg; + } + + private HtmlPanelGrid gridLayout1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayout1() { + return gridLayout1; + } + + public void setGridLayout1(HtmlPanelGrid hpg) { + this.gridLayout1 = hpg; + } + + private HtmlPanelGrid gridMsg = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridMsg() { + return gridMsg; + } + + public void setGridMsg(HtmlPanelGrid hpg) { + this.gridMsg = hpg; + } + + private StaticText txtMsg = new StaticText(); + + public StaticText getTxtMsg() { + return txtMsg; + } + + public void setTxtMsg(StaticText st) { + this.txtMsg = st; + } + + private HtmlPanelGrid gridCabecalho = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridCabecalho() { + return gridCabecalho; + } + + public void setGridCabecalho(HtmlPanelGrid hpg) { + this.gridCabecalho = hpg; + } + + private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel2() { + return gridPanel2; + } + + public void setGridPanel2(HtmlPanelGrid hpg) { + this.gridPanel2 = hpg; + } + + private StaticText lblEmpresa1 = new StaticText(); + + public StaticText getLblEmpresa1() { + return lblEmpresa1; + } + + public void setLblEmpresa1(StaticText st) { + this.lblEmpresa1 = st; + } + + private StaticText txtEmpresa = new StaticText(); + + public StaticText getTxtEmpresa() { + return txtEmpresa; + } + + public void setTxtEmpresa(StaticText st) { + this.txtEmpresa = st; + } + + private StaticText staticText4 = new StaticText(); + + public StaticText getStaticText4() { + return staticText4; + } + + public void setStaticText4(StaticText st) { + this.staticText4 = st; + } + + private StaticText txtEstabelecimento = new StaticText(); + + public StaticText getTxtEstabelecimento() { + return txtEstabelecimento; + } + + public void setTxtEstabelecimento(StaticText st) { + this.txtEstabelecimento = st; + } + + private StaticText txtTrabalhador = new StaticText(); + + public StaticText getTxtTrabalhador() { + return txtTrabalhador; + } + + public void setTxtTrabalhador(StaticText st) { + this.txtTrabalhador = st; + } + + private HtmlPanelGrid gridTrabalhadores = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridTrabalhadores() { + return gridTrabalhadores; + } + + public void setGridTrabalhadores(HtmlPanelGrid hpg) { + this.gridTrabalhadores = hpg; + } + + private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel3() { + return gridPanel3; + } + + public void setGridPanel3(HtmlPanelGrid hpg) { + this.gridPanel3 = hpg; + } + + private StaticText staticText5 = new StaticText(); + + public StaticText getStaticText5() { + return staticText5; + } + + public void setStaticText5(StaticText st) { + this.staticText5 = st; + } + + private HtmlPanelGrid gridPanel4 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel4() { + return gridPanel4; + } + + public void setGridPanel4(HtmlPanelGrid hpg) { + this.gridPanel4 = hpg; + } + + private StaticText txtSearchMsg = new StaticText(); + + public StaticText getTxtSearchMsg() { + return txtSearchMsg; + } + + public void setTxtSearchMsg(StaticText st) { + this.txtSearchMsg = st; + } + + private HtmlPanelGrid gridSiprp = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridSiprp() { + return gridSiprp; + } + + public void setGridSiprp(HtmlPanelGrid hpg) { + this.gridSiprp = hpg; + } + + private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel5() { + return gridPanel5; + } + + public void setGridPanel5(HtmlPanelGrid hpg) { + this.gridPanel5 = hpg; + } + + private StaticText staticText6 = new StaticText(); + + public StaticText getStaticText6() { + return staticText6; + } + + public void setStaticText6(StaticText st) { + this.staticText6 = st; + } + + private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel6() { + return gridPanel6; + } + + public void setGridPanel6(HtmlPanelGrid hpg) { + this.gridPanel6 = hpg; + } + + private HtmlPanelGrid gridPanel7 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel7() { + return gridPanel7; + } + + public void setGridPanel7(HtmlPanelGrid hpg) { + this.gridPanel7 = hpg; + } + + private StaticText staticText9 = new StaticText(); + + public StaticText getStaticText9() { + return staticText9; + } + + public void setStaticText9(StaticText st) { + this.staticText9 = st; + } + + private PanelGroup groupPanel3 = new PanelGroup(); + + public PanelGroup getGroupPanel3() { + return groupPanel3; + } + + public void setGroupPanel3(PanelGroup pg) { + this.groupPanel3 = pg; + } + + private StaticText staticText10 = new StaticText(); + + public StaticText getStaticText10() { + return staticText10; + } + + public void setStaticText10(StaticText st) { + this.staticText10 = st; + } + + private StaticText txtCap = new StaticText(); + + public StaticText getTxtCap() { + return txtCap; + } + + public void setTxtCap(StaticText st) { + this.txtCap = st; + } + + //Construct a new Page bean instance.
+ */ + public AnaliseAcidenteTrabalho() { + } + + /** + *Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.
+ * + *Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.
+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + //Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.
+ */ + public void preprocess() { + } + + /** + *Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.
+ */ + public void prerender() { + txtMsg.setText(getSessionBean1().getMsg()); + getSessionBean1().setMsg(""); + + } + + /** + *Callback method that is called after rendering is completed for
+ * this request, if init() was called (regardless of whether
+ * or not this was the page that was actually rendered). Customize this
+ * method to release resources acquired in the init(),
+ * preprocess(), or prerender() methods (or
+ * acquired during execution of an event handler).
Return a reference to the scoped data bean.
+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + public String lnkLogout_action() { + // TODO: Replace with your code + + try + { + javax.servlet.http.HttpSession session = + (javax.servlet.http.HttpSession) getExternalContext().getSession(true); + session.invalidate(); + } + catch(Exception ex){} + + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) {} + //return "login"; + return null; + } + + + private void initializePage() + { + hidAnchor.setValue("none"); + butCorrecao.setRendered(false); + butGravar.setText("Gravar"); + butEnviar.setText("Enviar a RH"); + gridSiprp.setRendered(false); + //gridAcidentadoView.setRendered(false); + gridSiprpView.setRendered(false); + gridAcidentadoView.setRendered(false); + gridDadosAcidenteRh.setRendered(false); + gridDadosAcidenteRhView.setRendered(false); + gridRecomendacoesHS.setRendered(false); + gridRecomendacoesViewHS.setRendered(false); + gridMedidasRH.setRendered(false); + gridMedidasViewRH.setRendered(false); + gridMedico.setRendered(false); + gridMedicoView.setRendered(false); + gridVerificacao.setRendered(false); + gridVerificacaoView.setRendered(false); + gridImpressao.setRendered(false); + gridImpressaoView.setRendered(false); + + tblTrabalhadores.setRendered(false); + gridAcidentado.setRendered(false); + gridDadosAcidenteSeg.setRendered(false); + gridDadosAcidenteSegView.setRendered(false); + + butImprimir.setRendered(false); + + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + String nome_empresa = adp.getEmpresaNome(getSessionBean1().getCurrentUser().getEmpresa_id()); + txtEmpresa.setText(utils.Utils.unicodeToHTML(nome_empresa)); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + try + { + txtEstabelecimento.setText(adp.getEstabelecimentoNome(getSessionBean1().getCurrentUser().getEstabelecimento_id())); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + + drpDepartamento.setSelected(new Integer(0)); + try + { + getSessionBean1().setSeccaoOptions(adp.getSeccoesList(null)); + drpSeccao.setSelected(new Integer(0)); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + +// fillTrabalhadoresTable(); + +// Calendar c = Calendar.getInstance(); +// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); +// stDataAcidente.setText(dateFormat.format(c.getTime())); + txtAveriguador.setText( getSessionBean1().getCurrentUser().getNome() ); + java.util.Date today = + new java.util.Date(); + calDataOcorrencia.setValue(today); + + //drpMedicos.setSelected(new Integer(0)); + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + Medico m = udp.getMedico( getSessionBean1().getCurrentUser().getEstabelecimento_id() ); + getSessionBean1().setMedico( m ); + if(m != null) + { + stMedico.setText(m.getNome() + " "); + txtCedula.setText(m.getNumero_cedula()); + } + drpHours.setSelected(new Integer(-1)); + drpMinutes.setSelected(new Integer(-1)); + drpDepartamento.setSelected(new Integer(0)); + drpSeccao.setSelected(new Integer(0)); + drpCausas.setSelected(new Integer(0)); + } + +// private void fillTrabalhadoresTable() +// { +// AnalisesDataProvider adp = new AnalisesDataProvider(); +// try +// { +// //lblActivos.setRendered(true); +// table1.setRendered(true); +// +// ArrayList trabalhadoresList = adp.getTrabalhadoresListByEstabelecimento(getSessionBean1().getCurrentUser().getEstabelecimento_id()); +// getSessionBean1().getTrabalhadoresListDataProvider().setList(trabalhadoresList); +// } +// catch(Exception ex) +// { +// //lblActivos.setRendered(false); +// table1.setRendered(false); +// ex.printStackTrace(); +// } +// } + + private String fillPage() + { + AnaliseAcidente a = getSessionBean1().getCurrentAnalise(); + + //correcao + if(a.getCorrecao().matches("y")) + { + stObservacoesCorr.setText(a.getObservacoes_correcao()); + } + else + { + stObservacoesCorr.setRendered(false); + } + + + stHeaderNr.setText(a.getAnalise_nr()); + try + { + java.util.Date ddate = new java.util.Date(a.getData_acidente().getTime()); + stHeaderDate.setText(utils.Utils.dateToYYYYMMDD(ddate)); + } + catch(Exception ex){}; + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + String nome_empresa = adp.getEmpresaNome(a.getEmpresa_id()); + txtEmpresa.setText(utils.Utils.unicodeToHTML(nome_empresa)); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + try + { + txtEstabelecimento.setText(adp.getEstabelecimentoNome(a.getEstabelecimento_id())); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + Acidentado ac = null; + try + { + //Trabalhador t = adp.getTrabalhador(a.getTrabalhador_id()); + //txtDataNascimento.setText(t.getData_nascimento()); + ac = adp.getAcidentado(a.getAcidentado_id()); + txtTrabalhador.setText(ac.getNome()); + getSessionBean1().setAcidentado(ac); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + + int estado_documento = a.getEstado().intValue(); +// if(estado_documento != Global.ESTADO_IMPRESSAO) +//// if(estado_documento != Global.ESTADO_ASSINATURAS || (estado_documento == Global.ESTADO_ASSINATURAS && getSessionBean1().getCurrentUser().getTipo().intValue() != Global.TIPO_UTILIZADOR_RH)) +//// { +//// butImprimir.setRendered(false); +//// } +//// else +//// { +//// butGravar.setRendered(false); +//// } + butImprimir.setRendered(false); + + if(estado_documento > Global.ESTADO_SEG && getSessionBean1().getCurrentUser().getTipo().intValue() == 1 && a.getAveriguacao_posterior().matches("y")) + { + boolean booAveriguacao = false; + if(a.getAveriguacao_obs() == null) + { + booAveriguacao = true; + } + else if(a.getAveriguacao_obs().trim().length() == 0) + { + booAveriguacao = true; + } + if(booAveriguacao) + { + butCorrecao.setRendered(false); + butGravar.setText("Gravar"); + butEnviar.setRendered(false); + gridSiprp.setRendered(false); + //gridSiprpView.setRendered(false); + gridAcidentado.setRendered(false); //19/11/2007 + gridAcidentadoView.setRendered(false); //19/11/2007 + gridDadosAcidenteSeg.setRendered(false); //19/11/2007 + //gridDadosAcidenteSegView.setRendered(false); //19/11/2007 + gridDadosAcidenteRh.setRendered(false); + gridDadosAcidenteRhView.setRendered(false); + gridRecomendacoesHS.setRendered(false); + gridRecomendacoesViewHS.setRendered(false); + gridMedidasRH.setRendered(false); + gridMedidasViewRH.setRendered(false); + gridMedico.setRendered(false); + gridMedicoView.setRendered(false); + gridVerificacao.setRendered(false); + gridVerificacaoView.setRendered(false); + gridImpressao.setRendered(false); + gridImpressaoView.setRendered(false); + + // fillSiprp(a); + // fillDadosAcidenteSegView(a); + fillSiprpView(a); + if(ac != null) + { + fillAcidentadoView(ac); + } + fillDadosAcidenteSegView(a); + + return null; + } + + } + + + switch(estado_documento) + { + case Global.ESTADO_SEG: + butCorrecao.setRendered(false); + butGravar.setText("Gravar"); + if(a.getCorrecao().matches("y")) + { + butEnviar.setText("Enviar a Recomendações SHST"); + } + else + { + butEnviar.setText("Enviar a Acompanhamento RH"); + } + gridSiprpView.setRendered(false); + gridAcidentado.setRendered(false); //19/11/2007 + //gridAcidentadoView.setRendered(false); //19/11/2007 + gridDadosAcidenteSegView.setRendered(false); //19/11/2007 + gridDadosAcidenteRh.setRendered(false); + gridDadosAcidenteRhView.setRendered(false); + gridRecomendacoesHS.setRendered(false); + gridRecomendacoesViewHS.setRendered(false); + gridMedidasRH.setRendered(false); + gridMedidasViewRH.setRendered(false); + gridMedico.setRendered(false); + gridMedicoView.setRendered(false); + gridVerificacao.setRendered(false); + gridVerificacaoView.setRendered(false); + gridImpressao.setRendered(false); + gridImpressaoView.setRendered(false); + + fillSiprp(a); + fillAcidentadoView(ac); + fillDadosAcidenteSeg(a); + break; + case Global.ESTADO_RH1: + butCorrecao.setRendered(false); + butGravar.setText("Gravar"); + butEnviar.setText("Enviar a Recomendações SHST"); + gridSiprpView.setRendered(false); + gridAcidentadoView.setRendered(false); + gridDadosAcidenteSeg.setRendered(false); //19/11/2007 + gridDadosAcidenteRhView.setRendered(false); + gridRecomendacoesHS.setRendered(false); + gridRecomendacoesViewHS.setRendered(false); + gridMedidasRH.setRendered(false); + gridMedidasViewRH.setRendered(false); + gridMedico.setRendered(false); + gridMedicoView.setRendered(false); + gridVerificacao.setRendered(false); + gridVerificacaoView.setRendered(false); + gridImpressao.setRendered(false); + gridImpressaoView.setRendered(false); + + if(ac != null) + { + fillAcidentado(ac); + } + fillSiprp(a); + fillDadosAcidenteSegView(a); + fillDadosAcidenteRh(a); + break; + case Global.ESTADO_HS: + butGravar.setText("Gravar"); + butEnviar.setText("Enviar a Medidas RH"); + //gridSiprpView.setRendered(false); + gridSiprp.setRendered(false); + gridAcidentado.setRendered(false); + //gridAcidentadoView.setRendered(false); + gridDadosAcidenteSeg.setRendered(false); + gridDadosAcidenteRh.setRendered(false); + gridRecomendacoesViewHS.setRendered(false); + gridMedidasRH.setRendered(false); + gridMedidasViewRH.setRendered(false); + gridMedico.setRendered(false); + gridMedicoView.setRendered(false); + gridVerificacao.setRendered(false); + gridVerificacaoView.setRendered(false); + gridImpressao.setRendered(false); + gridImpressaoView.setRendered(false); + + fillSiprpView(a); + if(ac != null) + { + fillAcidentadoView(ac); + } + fillDadosAcidenteSegView(a); + fillDadosAcidenteRhView(a); + fillRecomendacoesHs(a); + //gridDadosAcidenteRhView.setRendered(false); + //gridRecomendacoesHS.setRendered(false); + break; + case Global.ESTADO_RH2: + butCorrecao.setRendered(false); + butGravar.setText("Gravar"); + //butEnviar.setText("Enviar a Médico"); +// if(a.getCorrecao().matches("y")) +// { +// butEnviar.setText("Enviar a Consolidação"); +// } +// else +// { +// butEnviar.setText("Enviar a Medicina"); +// } + butEnviar.setText("Enviar a Consolidação"); + + //butEnviar.setText("Enviar a Medicina"); + //gridSiprpView.setRendered(false); + gridSiprp.setRendered(false); + gridAcidentado.setRendered(false); + //gridAcidentadoView.setRendered(false); + gridDadosAcidenteSeg.setRendered(false); + gridDadosAcidenteRh.setRendered(false); + gridRecomendacoesHS.setRendered(false); + //gridRecomendacoesViewHS.setRendered(false); + gridMedidasViewRH.setRendered(false); + //gridMedico.setRendered(false); + gridMedicoView.setRendered(false); + gridVerificacao.setRendered(false); + gridVerificacaoView.setRendered(false); + gridImpressao.setRendered(false); + gridImpressaoView.setRendered(false); + + fillSiprpView(a); + if(ac != null) + { + fillAcidentadoView(ac); + } + fillDadosAcidenteSegView(a); + fillDadosAcidenteRhView(a); + fillRecomendacoesViewHs(a); + //fillMedico(a); //19/11/2007 + fillMedidasRh(a); + fillMedico(a); //23/11/2007 + break; +// case Global.ESTADO_MEDICINA: +// butCorrecao.setRendered(false); +// butGravar.setText("Gravar"); +// butEnviar.setText("Enviar a Consolidação"); +// //gridSiprpView.setRendered(false); +// gridSiprp.setRendered(false); +// gridAcidentado.setRendered(false); +// //gridAcidentadoView.setRendered(false); +// gridDadosAcidenteSeg.setRendered(false); +// gridDadosAcidenteRh.setRendered(false); +// gridRecomendacoesHS.setRendered(false); +// //gridRecomendacoesViewHS.setRendered(false); +// gridMedidasRH.setRendered(false); +// //gridMedidasViewRH.setRendered(false); +// //gridMedico.setRendered(false); +// gridMedicoView.setRendered(false); +// gridVerificacao.setRendered(false); +// gridVerificacaoView.setRendered(false); +// gridImpressao.setRendered(false); +// gridImpressaoView.setRendered(false); +// +// fillSiprpView(a); +// if(ac != null) +// { +// fillAcidentadoView(ac); +// } +// fillDadosAcidenteSegView(a); +// fillDadosAcidenteRhView(a); +// fillRecomendacoesViewHs(a); +// fillMedidasViewRh(a); +// fillMedico(a); //23/11/2007 +// break; + case Global.ESTADO_CONSOLIDACAO: + //butGravar.setText("Gravar"); + butGravar.setRendered(false); + butEnviar.setText("Enviar a Verificação"); + hidDisableEnviar.setValue("n"); + boolean booAveriguacao = false; + if(a.getAveriguacao_posterior().matches("y")) + { + if(a.getAveriguacao_obs() == null) + { + booAveriguacao = true; + } + else if(a.getAveriguacao_obs().trim().length() == 0) + { + booAveriguacao = true; + } + if(booAveriguacao) + { + hidDisableEnviar.setValue("y"); + } + + } + gridSiprp.setRendered(false); + gridAcidentado.setRendered(false); + //gridAcidentadoView.setRendered(false); + gridDadosAcidenteSeg.setRendered(false); + gridDadosAcidenteRh.setRendered(false); + gridRecomendacoesHS.setRendered(false); + //gridRecomendacoesViewHS.setRendered(false); + gridMedidasRH.setRendered(false); + //gridMedidasViewRH.setRendered(false); + gridMedico.setRendered(false); + //gridMedicoView.setRendered(false); + //gridVerificacao.setRendered(false); + java.util.Date ddate = new java.util.Date(); + stVerHs.setText("Tomei conhecimento a " + utils.Utils.dateToYYYYMMDD(ddate)); + grpVerRespSeg.setRendered(false); + grpVerRespRh.setRendered(false); + butGravar.setDisabled(true); + butEnviar.setDisabled(true); + gridVerificacaoView.setRendered(false); + gridImpressao.setRendered(false); + gridImpressaoView.setRendered(false); + + fillSiprpView(a); + if(ac != null) + { + fillAcidentadoView(ac); + } + fillDadosAcidenteSegView(a); + fillDadosAcidenteRhView(a); + fillRecomendacoesViewHs(a); + fillMedidasViewRh(a); + fillMedicoView(a); //23/11/2007 + break; + case Global.ESTADO_ASSINATURA_SEG: + butImprimir.setRendered(false); + butCorrecao.setRendered(false); + butEnviar.setText("Enviar a RH"); + //butGravar.setText("Enviar"); + butGravar.setRendered(false); + gridSiprp.setRendered(false); + gridAcidentado.setRendered(false); + gridDadosAcidenteSeg.setRendered(false); + gridDadosAcidenteRh.setRendered(false); + gridRecomendacoesHS.setRendered(false); + gridRecomendacoesViewHS.setRendered(false); + gridMedidasRH.setRendered(false); + //gridMedidasViewRH.setRendered(false); + gridMedico.setRendered(false); + //gridMedicoView.setRendered(false); + //gridVerificacaoView.setRendered(false); + gridImpressao.setRendered(false); + gridImpressaoView.setRendered(false); + grpVerRespSeg.setRendered(true); + grpVerHs.setRendered(false); + grpVerRespRh.setRendered(false); + //chkVerRespRh.setDisabled(true); + ddate = new java.util.Date(); + stVerRespSeg.setText("Tomei conhecimento a " + utils.Utils.dateToYYYYMMDD(ddate)); + + fillSiprpView(a); + if(ac != null) + { + fillAcidentadoView(ac); + } + fillDadosAcidenteSegView(a); + fillDadosAcidenteRhView(a); + fillMedidasViewRh(a); + fillMedicoView(a); + fillVerificacaoView(a); + fillVerificacao(a); + + break; + case Global.ESTADO_ASSINATURA_RH: + //butGravar.setRendered(false); + butGravar.setText("Imprimir"); + butCorrecao.setRendered(false); + butImprimir.setRendered(false); + butEnviar.setText("Enviar a Conclusão"); + gridSiprp.setRendered(false); + gridAcidentado.setRendered(false); + gridDadosAcidenteSeg.setRendered(false); + gridDadosAcidenteRh.setRendered(false); + gridRecomendacoesHS.setRendered(false); + gridMedidasRH.setRendered(false); + gridMedico.setRendered(false); + //gridMedicoView.setRendered(false); + //gridVerificacaoView.setRendered(false); + gridImpressao.setRendered(false); + gridImpressaoView.setRendered(false); + grpVerRespRh.setRendered(true); + grpVerHs.setRendered(false); + grpVerRespSeg.setRendered(false); + //chkVerRespSeg.setDisabled(true); + ddate = new java.util.Date(); + stVerRespRh.setText("Tomei conhecimento a " + utils.Utils.dateToYYYYMMDD(ddate)); + + fillSiprpView(a); + if(ac != null) + { + fillAcidentadoView(ac); + } + fillDadosAcidenteSegView(a); + fillDadosAcidenteRhView(a); + fillRecomendacoesViewHs(a); + fillMedidasViewRh(a); + fillMedicoView(a); + fillVerificacaoView(a); + fillVerificacao(a); + break; +//// case Global.ESTADO_ASSINATURAS: +//// butImprimir.setDisabled(true); +//// butCorrecao.setRendered(false); +//// butGravar.setText("Gravar"); +//// butEnviar.setText("Enviar a Impressão"); +//// if(a.getEstado_assinatura().intValue() == ESTADO_ASSINATURA_1) +//// { +//// butEnviar.setDisabled(true); +//// } +//// else +//// { +//// butEnviar.setDisabled(false); +//// } +//// +//// +//// int tipo_utilizador = getSessionBean1().getCurrentUser().getTipo().intValue(); +//// +//// switch(tipo_utilizador) +//// { +//// case 1: //seguranca +//// if(a.getEstado_assinatura().intValue() == 1) +//// { +//// //txtAssRespSeg.setDisabled(false); +//// } +//// else +//// { +//// //txtAssSeg.setDisabled(false); +//// } +//// butGravar.setText("Enviar"); +//// gridSiprp.setRendered(false); +//// gridAcidentado.setRendered(false); +//// gridDadosAcidenteSeg.setRendered(false); +//// gridDadosAcidenteRh.setRendered(false); +//// gridRecomendacoesHS.setRendered(false); +//// gridRecomendacoesViewHS.setRendered(false); +//// gridMedidasRH.setRendered(false); +//// //gridMedidasViewRH.setRendered(false); +//// gridMedico.setRendered(false); +//// //gridMedicoView.setRendered(false); +//// gridVerificacaoView.setRendered(false); +//// gridImpressao.setRendered(false); +//// gridImpressaoView.setRendered(false); +//// grpVerRespSeg.setRendered(true); +//// grpVerHs.setRendered(false); +//// grpVerRespRh.setRendered(false); +//// //chkVerRespRh.setDisabled(true); +//// ddate = new java.util.Date(); +//// stVerRespSeg.setText("Tomei conhecimento a " + utils.Utils.dateToYYYYMMDD(ddate)); +//// +//// fillSiprpView(a); +//// if(ac != null) +//// { +//// fillAcidentadoView(ac); +//// } +//// fillDadosAcidenteSegView(a); +//// fillDadosAcidenteRhView(a); +//// fillMedidasViewRh(a); +//// fillMedicoView(a); +//// //fillAssinaturaSeg(a); +//// break; +//// +//// case 2: //rh +//// //txtAssRespRh.setDisabled(false); +//// butGravar.setRendered(false); +//// gridSiprp.setRendered(false); +//// gridAcidentado.setRendered(false); +//// gridDadosAcidenteSeg.setRendered(false); +//// gridDadosAcidenteRh.setRendered(false); +//// gridRecomendacoesHS.setRendered(false); +//// gridMedidasRH.setRendered(false); +//// gridMedico.setRendered(false); +//// //gridMedicoView.setRendered(false); +//// gridVerificacaoView.setRendered(false); +//// gridImpressao.setRendered(false); +//// gridImpressaoView.setRendered(false); +//// grpVerRespRh.setRendered(true); +//// grpVerHs.setRendered(false); +//// grpVerRespSeg.setRendered(false); +//// //chkVerRespSeg.setDisabled(true); +//// ddate = new java.util.Date(); +//// stVerRespRh.setText("Tomei conhecimento a " + utils.Utils.dateToYYYYMMDD(ddate)); +//// +//// fillSiprpView(a); +//// if(ac != null) +//// { +//// fillAcidentadoView(ac); +//// } +//// fillDadosAcidenteSegView(a); +//// fillDadosAcidenteRhView(a); +//// fillRecomendacoesViewHs(a); +//// fillMedidasViewRh(a); +//// fillMedicoView(a); +//// break; + +// case 3: //hs +// //txtAssHS.setDisabled(false); +// gridSiprp.setRendered(false); +// gridAcidentado.setRendered(false); +// gridDadosAcidenteSeg.setRendered(false); +// gridDadosAcidenteRh.setRendered(false); +// gridRecomendacoesHS.setRendered(false); +// gridMedidasRH.setRendered(false); +// gridMedidasViewRH.setRendered(false); +// gridMedico.setRendered(false); +// gridMedicoView.setRendered(false); +// fillSiprpView(a); +// if(ac != null) +// { +// fillAcidentadoView(ac); +// } +// fillDadosAcidenteSegView(a); +// fillDadosAcidenteRhView(a); +// fillRecomendacoesViewHs(a); +// break; +// +// case 5: //med +// //txtAssMed.setDisabled(false); +// gridSiprp.setRendered(false); +// gridAcidentado.setRendered(false); +// gridDadosAcidenteSeg.setRendered(false); +// gridDadosAcidenteRh.setRendered(false); +// gridRecomendacoesHS.setRendered(false); +// gridMedidasRH.setRendered(false); +// gridMedico.setRendered(false); +// fillSiprpView(a); +// if(ac != null) +// { +// fillAcidentadoView(ac); +// } +// fillDadosAcidenteSegView(a); +// fillDadosAcidenteRhView(a); +// fillRecomendacoesViewHs(a); +// fillMedidasViewRh(a); +// //fillMedico(a); +// fillMedicoView(a); +// break; +//// } +//// break; +// case Global.ESTADO_IMPRESSAO: +// butCorrecao.setRendered(false); +// butImprimir.setRendered(false); +// butGravar.setText("Gravar"); +// butEnviar.setText("Enviar para Fecho"); +// gridSiprp.setRendered(false); +// gridAcidentado.setRendered(false); +// gridDadosAcidenteSeg.setRendered(false); +// gridDadosAcidenteRh.setRendered(false); +// gridRecomendacoesHS.setRendered(false); +// gridMedidasRH.setRendered(false); +// gridMedico.setRendered(false); +// gridVerificacao.setRendered(false); +// gridImpressao.setRendered(false); +// gridImpressaoView.setRendered(false); +// fillSiprpView(a); +// if(ac != null) +// { +// fillAcidentadoView(ac); +// } +// fillDadosAcidenteSegView(a); +// fillDadosAcidenteRhView(a); +// fillRecomendacoesViewHs(a); +// fillMedidasViewRh(a); +// //fillMedico(a); +// fillMedicoView(a); +// fillVerificacaoView(a); +// //fillImpressao(a); +// //buildPdf(a); +// +// break; + case Global.ESTADO_FECHAR: + butCorrecao.setRendered(false); + butGravar.setRendered(false); + butGravar.setText("Gravar"); + butEnviar.setText("Fechar"); + gridSiprp.setRendered(false); + gridAcidentado.setRendered(false); + gridDadosAcidenteSeg.setRendered(false); + gridDadosAcidenteRh.setRendered(false); + gridRecomendacoesHS.setRendered(false); + gridMedidasRH.setRendered(false); + gridMedico.setRendered(false); + gridVerificacao.setRendered(false); + gridImpressao.setRendered(false); + gridImpressaoView.setRendered(false); + fillSiprpView(a); + if(ac != null) + { + fillAcidentadoView(ac); + } + fillDadosAcidenteSegView(a); + fillDadosAcidenteRhView(a); + fillRecomendacoesViewHs(a); + fillMedidasViewRh(a); + //fillMedico(a); + fillMedicoView(a); + fillVerificacaoView(a); + //fillImpressaoView(a); + break; + case Global.ESTADO_CONCLUIDO: + } + + return null; + } + + private void fillSiprp(AnaliseAcidente a) + { + //drpTecnicos.setSelected(a.getTecnico_saude_id()); + //drpMedicos.setSelected(a.getMedico_id()); + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + try + { + Utilizador u = udp.getUtilizador(a.getTecnico_saude_id()); + txtCap.setText(u.getCap()); + } + catch(Exception ex) + { + //ex.printStackTrace(); + } + try + { + Utilizador u = udp.getUtilizador(a.getMedico_id()); + stMedico.setText(u.getNome() + " "); + txtCedula.setText(u.getNumero_cedula()); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + } + + private void fillSiprpView(AnaliseAcidente a) + { + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + + if(a.getEstado().intValue() == Global.ESTADO_HS) + { + if(a.getTecnico_saude_id().equals(new Integer(0))) + { + a.setTecnico_saude_id( getSessionBean1().getCurrentUser().getId()); + } + } + + try + { + Utilizador u = udp.getUtilizador(a.getTecnico_saude_id()); + stTecnicoNome.setText(Utils.unicodeToHTML(u.getNome())); + txtCap1.setText(u.getCap()); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + try + { + Utilizador u = udp.getUtilizador(a.getMedico_id()); + stMedicoNome.setText(Utils.unicodeToHTML(u.getNome())); + txtCedula1.setText(u.getNumero_cedula()); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + } + + private void fillAcidentado(Acidentado a) + { + txtNomeAcidentado.setText(a.getNome()); + stEstabelecimentoOrigem.setText(a.getEstabelecimento_origem()); + //txtDataNascimento.setText(a.getData_nascimento()); + try + { + java.util.Date ddate = new java.util.Date(a.getData_nascimento().getTime()); + txtDataNascimento.setText(utils.Utils.dateToYYYYMMDD(ddate)); + } + catch(Exception ex){}; + txtBI.setText(a.getBilhete_identidade()); + txtMorada.setText(a.getMorada()); + String cod_postal1 = ""; + String cod_postal2 = ""; + try + { + cod_postal1 = a.getCod_postal().substring(0, 4); + } + catch(Exception ex){} + try + { + cod_postal2 = a.getCod_postal().substring(5, 8); + } + catch(Exception ex){} + + + txtCodPostal1.setText(cod_postal1); + txtCodPostal2.setText(cod_postal2); + txtLocalidade.setText(a.getLocalidade()); + txtContactoTelefonico.setText(a.getContacto_telefonico()); + try + { + java.util.Date ddate = new java.util.Date(a.getData_admissao().getTime()); + stDataAdmissao.setText(utils.Utils.dateToYYYYMMDD(ddate)); + } + catch(Exception ex){}; + + stFuncao.setText(a.getFuncao()); + rbTurnoManha.setSelected(null); + rbTurnoTarde.setSelected(null); + rbTurnoNoite.setSelected(null); + if(a.getTurno().matches("m")) + { + rbTurnoManha.setSelected(new Boolean(true)); + } + else if(a.getTurno().matches("t")) + { + rbTurnoTarde.setSelected(new Boolean(true)); + } + else if(a.getTurno().matches("n")) + { + rbTurnoNoite.setSelected(new Boolean(true)); + } + + txtNomeSuperior.setText(a.getNome_superior_hierarquico()); + txtEmailSuperior.setText(a.getEmail_superior_hierarquico()); + + } + + private void fillAcidentadoView(Acidentado a) + { + stNomeAcidentado.setText(a.getNome()); + stEstabelecimentoOrigem1.setText(a.getEstabelecimento_origem()); + //stDataNascimento.setText(a.getData_nascimento()); + try + { + java.util.Date ddate = new java.util.Date(a.getData_nascimento().getTime()); + stDataNascimento.setText(utils.Utils.dateToYYYYMMDD(ddate)); + } + catch(Exception ex){}; + stBI.setText(a.getBilhete_identidade()); + stMorada.setText(a.getMorada()); + String cod_postal1 = ""; + String cod_postal2 = ""; + try + { + cod_postal1 = a.getCod_postal().substring(0, 4); + } + catch(Exception ex) + { + cod_postal1 = ""; + } + try + { + cod_postal2 = a.getCod_postal().substring(5, 8); + } + catch(Exception ex) + { + cod_postal2 = ""; + } + + //String cod_postal1 = a.getCod_postal().substring(0, 4); + //String cod_postal2 = a.getCod_postal().substring(5, 8); + if(a.getLocalidade() == null) + { + a.setLocalidade(""); + } + String cod_postal = cod_postal1 + "-" + cod_postal2 + " " + a.getLocalidade(); + stCodPostal.setText(cod_postal); + stContactoTelefonico.setText(a.getContacto_telefonico()); + //stDataAdmissao1.setText(a.getData_admissao()); + try + { + java.util.Date ddate = new java.util.Date(a.getData_admissao().getTime()); + stDataAdmissao1.setText(utils.Utils.dateToYYYYMMDD(ddate)); + } + catch(Exception ex){}; + stFuncao1.setText(a.getFuncao()); + String turno_str = ""; + if(a.getTurno() != null) + { + if(a.getTurno().matches("m")) + { + turno_str = "manhã"; + } + else if(a.getTurno().matches("t")) + { + turno_str += "tarde "; + } + else if(a.getTurno().matches("n")) + { + turno_str += "noite"; + } + } + + stTurno.setText(turno_str); + stNomeSuperior.setText(a.getNome_superior_hierarquico()); + stEmailSuperior.setText(a.getEmail_superior_hierarquico()); + } + + private void fillDadosAcidenteSeg(AnaliseAcidente a) + { + //stDataAcidente.setText(a.getData_acidente()); +// try +// { +// java.util.Date ddate = new java.util.Date(a.getData_acidente().getTime()); +// stDataAcidente.setText(utils.Utils.dateToYYYYMMDD(ddate)); +// } +// catch(Exception ex){}; + if(a.getAveriguador() == null) + { + txtAveriguador.setText(getSessionBean1().getCurrentUser().getNome()); + } + else + { + txtAveriguador.setText(a.getAveriguador()); + } + + if(a.getData_acidente() != null) + { + java.util.Date ddate = new java.util.Date(a.getData_acidente().getTime()); + calDataOcorrencia.setValue(ddate); + } + + Calendar cal = Calendar.getInstance(); + + // set the calendar to have your time + try + { + cal.setTimeInMillis(a.getHora_acidente().getTime()); + + int hour = cal.get(Calendar.HOUR_OF_DAY); + int minutes = cal.get(Calendar.MINUTE); + drpHours.setSelected(new Integer(hour)); + drpMinutes.setSelected(new Integer(minutes)); + } + catch(Exception ex) + { + //ex.printStackTrace(); + } + + if(a.getHoras_turno() != null) + { + txtHorasTurno.setText(a.getHoras_turno().toString()); + } + + ////txtSeccao.setText(a.getSeccao()); + + AnalisesDataProvider adp = new AnalisesDataProvider(); + drpDepartamento.setSelected(a.getDepartamento_id()); + try + { + if(a.getDepartamento_id().intValue() == 0) + { + getSessionBean1().setSeccaoOptions(adp.getSeccoesList(null)); + drpSeccao.setSelected(new Integer(0)); + } + else + { + getSessionBean1().setSeccaoOptions(adp.getSeccoesList(a.getDepartamento_id())); + drpSeccao.setSelected(a.getSeccao_id()); + } + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + txtLocal.setText(a.getLocal_trabalho()); + txtTarefa.setText(a.getTarefa()); + txtSubstancias.setText(a.getSubstancias()); +// txtSuperior.setText(a.getSuperior_hierarquico()); + txtCondicoes.setText(a.getCondicoes()); + txtTestemunhas.setText(a.getTestemunhas()); +// txtCausas.setText(a.getCausas()); + + drpCausas.setSelected(a.getCausas()); + txtDescricao.setText(a.getDescricao()); + txtConclusoes.setText(a.getConclusoes()); + txtAccoes.setText(a.getAccoes()); + + if(a.getAveriguacao_posterior().matches("y")) + { + chkAveriguacaoPosterior.setSelected(new Boolean(true)); + } + + txtAveriguacaoObs.setText(a.getAveriguacao_obs()); + + //fill images + if(gridImages.getChildren().size() > 0) + { + gridImages.getChildren().clear(); + } + String folderName = getSessionBean1().getCurrentAnalise().getAnalise_nr().substring(0,2) + getSessionBean1().getCurrentAnalise().getAnalise_nr().substring(3); + ServletContext theApplicationsServletContext = + (ServletContext) this.getExternalContext().getContext(); + + File apacheAnaliseFolder = new File(theApplicationsServletContext.getRealPath( Global.RESOURCES_IMAGE_FOLDER ) + "/analises/" + folderName); + if(apacheAnaliseFolder.exists()) + { + Global global = new Global(); + global.deleteFolderFiles(apacheAnaliseFolder); + } + else + { + apacheAnaliseFolder.mkdir(); + } + + +// String imageFileFolder = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/" + folderName); + String imageFileFolder = Global.IMAGE_FOLDER + "/" + folderName; + try + { + File f = new File(imageFileFolder); + + if(f.exists()) + { + File images[] = f.listFiles(); + Arrays.sort(images); + for(int i=0;iPor favor, aceda a www.siprp.pt, separador colaboradores em 'Acesso à Gestão de Análises de Acidentes de Trabalho' e prossiga com a gestão do processo " + a.getAnalise_nr() + ".
"; + + String responsavel_loja = "n"; + switch (estado.intValue()) + { + case Global.ESTADO_RH1: + tipo = new Integer(Global.TIPO_UTILIZADOR_RH); + break; + case Global.ESTADO_HS: + tipo = new Integer(Global.TIPO_UTILIZADOR_HS); + break; + case Global.ESTADO_RH2: + tipo = new Integer(Global.TIPO_UTILIZADOR_RH); + break; + case Global.ESTADO_CONSOLIDACAO: + tipo = new Integer(Global.TIPO_UTILIZADOR_HS); + break; + case Global.ESTADO_ASSINATURA_SEG: + tipo =new Integer(Global.TIPO_UTILIZADOR_SEGURANCA); + responsavel_loja = "y"; + break; + case Global.ESTADO_ASSINATURA_RH: + tipo = new Integer(Global.TIPO_UTILIZADOR_RH); + responsavel_loja = "y"; + break; + case Global.ESTADO_FECHAR: + tipo = new Integer(Global.TIPO_UTILIZADOR_HS); + break; + } + +// if(estado.intValue() == Global.ESTADO_FECHAR) +// { +// tipo = new Integer(Global.TIPO_UTILIZADOR_HS); // hs +// } +// else +// { +// tipo = estado; +// } + + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + try + { + ArrayList list = udp.getUtilizadoresListByTipo(tipo, responsavel_loja); + ListIterator iter = list.listIterator(); + while(iter.hasNext()) + { + Utilizador u = (Utilizador) iter.next(); + System.out.println("USER MAIL : " + u.getLogin() + " ; " + u.getEmail()); + try + { + sendEmail(u.getEmail(), Global.ENDERECO_ENVIO, assunto, texto_email); + } + catch(Exception ex1) + { + ex1.printStackTrace(); + System.out.println("MAIL ERROR : " + ex1.getMessage()); + } + + } + } + catch(Exception ex) + { + //ex.printStackTrace(); + } + + } + + private void sendEmailResponsavelHierarquico(AnaliseAcidente a) + { + Acidentado ac = getSessionBean1().getAcidentado(); + String assunto = "Comunicação de Análise de Acidentes de Trabalho de " + ac.getNome(); + + String data_acidente = ""; + try + { + java.util.Date ddate = new java.util.Date(a.getData_acidente().getTime()); + data_acidente = utils.Utils.dateToYYYYMMDD(ddate); + } + catch(Exception ex){} + + String texto_email = "Caro(a) Colega,
"; + texto_email += "Na sequência do acidente de trabalho do colaborador "; + texto_email += ac.getNome(); + texto_email += " no dia " + data_acidente; + texto_email += ", vimos pelo presente remeter cópia da análise do acidente " + a.getAnalise_nr() + " que se encontra em processo de averiguação pelo departamento de Segurança, Recursos Humanos e pela SIPRP para seu conhecimento. Caso tenha qualquer informação importante sobre o processo ou pretenda esclarecimentos adicionais contacte, por favor, a secção de Recursos Humanos.
"; + texto_email += "Cumprimentos.
"; + try + { + sendEmail(ac.getEmail_superior_hierarquico(), Global.ENDERECO_ENVIO, assunto, texto_email); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + } + + private void sendEmailFimProcesso(AnaliseAcidente a) + { + Acidentado ac = getSessionBean1().getAcidentado(); + String assunto = "Fecho do Processo de Análise de Acidente de Trabalho de " + ac.getNome(); + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + ArrayList responsavelRh_list = udp.getResponsavelRhList( a.getEstabelecimento_id() ); + if(responsavelRh_list != null) + { + ListIterator iter = responsavelRh_list.listIterator(); + while(iter.hasNext()) + { + Utilizador u = (Utilizador) iter.next(); + String texto_email = "Exmo. (a) Senhor(a), " + u.getNome() + "
"; + texto_email += "Informamos que o processo de análise de acidente de trabalho nº " + a.getAnalise_nr() + " se encontra finalizado, "; + texto_email += "pelo que solicitamos a sua impressão e arquivamento em pasta própria, juntamente com a participação de sinistro à seguradora.
"; + texto_email += "Caso pretenda qualquer esclarecimento, contacte-nos, por favor, através de acidentes.auchan@siprp.pt ou pelo telefone 213 504 540.
"; + texto_email += "Os melhores cumprimentos.
"; + texto_email += "SIPRP
"; + try + { + sendEmail(u.getEmail(), Global.ENDERECO_ENVIO, assunto, texto_email); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + } + } + } + +// private void sendEmail(String emailTo, String emailFrom, String assunto, String texto_email) throws Exception +// { +// Properties props = new Properties(); +// //props.put("mail.transport.protocol", "smtp"); +// props.put("mail.smtp.host", "smtp.netcabo.pt"); +// props.put("mail.from", emailFrom); +// Session session1 = Session.getInstance(props); +// Message msg = new MimeMessage(session1); +// +//// try +//// { +// //Address Email_TO = new InternetAddress("myemail@bol.com.br"); +// msg.setFrom(new InternetAddress(emailFrom)); +// InternetAddress[] address = {new InternetAddress(emailTo)}; +// msg.setRecipients(Message.RecipientType.TO, address); +// msg.setSubject(assunto); +// msg.setSentDate(new Date()); +// Multipart multipart = new MimeMultipart(); +// BodyPart msgBodyPart = new MimeBodyPart(); +// String html; +// html=" "; +// html+=""; +// html+= texto_email; +// html+=""; +// msgBodyPart.setContent(html, "text/html"); +// multipart.addBodyPart(msgBodyPart); +// msg.setContent(multipart); +// Transport.send(msg); +// System.out.println("Email Enviado !!!! "); +//// } +//// catch (Exception ex) +//// { +//// System.out.println("MAIL ERROR : " + ex.getMessage()); +//// ex.printStackTrace(); +//// } +// +// } + + public class SMTPAuthenticator extends Authenticator { + public PasswordAuthentication getPasswordAuthentication() { + String username = "lluis"; + String password = "654321"; + return new PasswordAuthentication(username, password); + } + } + private void sendEmail(String emailTo, String emailFrom, String assunto, String texto_email) throws Exception + { + Properties props = new Properties(); + //props.put("mail.transport.protocol", "smtp"); + props.put("mail.smtp.host", "mail2.evolute.pt"); + props.put("mail.from", emailFrom); + props.put("mail.smtp.auth", "true"); + props.put("mail.smtp.user", "lluis"); + props.put("mail.smtp.password", "654321"); +// Session session1 = Session.getInstance(props); + Authenticator auth = new SMTPAuthenticator(); + Session session = Session.getDefaultInstance(props, auth); + + Message msg = new MimeMessage(session); + msg.setFrom(new InternetAddress(emailFrom)); + InternetAddress[] address = {new InternetAddress(emailTo)}; + msg.setRecipients(Message.RecipientType.TO, address); + msg.setSubject(assunto); + msg.setSentDate(new Date()); + Multipart multipart = new MimeMultipart(); + BodyPart msgBodyPart = new MimeBodyPart(); + String html; + html=" "; + html+=""; + html+= texto_email; + html+=""; + msgBodyPart.setContent(html, "text/html"); + multipart.addBodyPart(msgBodyPart); + msg.setContent(multipart); + ////////Transport.send(msg); + ////////System.out.println("Email Enviado !!!! "); + + } + + public String butImprimir_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. +// AnaliseAcidente a = getSessionBean1().getCurrentAnalise(); +// if(a.getEstado().intValue() == ESTADO_IMPRESSAO) +// { +// Pdf pdf = new Pdf(); +// pdf.generatePdf(a); +// } + + if(validationOk()) + { + AnaliseAcidente a = fillAnaliseFields(); + Acidentado ac = null; + ArrayList recs = null; + ArrayList meds = null; + int estado = a.getEstado().intValue(); + //if(estado == ESTADO_SEG || estado == ESTADO_RH1) +// if(estado == Global.ESTADO_RH1) +// { +// ac = fillAcidentadoFields(); +// } +// else if(estado == Global.ESTADO_HS) +// { +// a.setTecnico_saude_id(getSessionBean1().getCurrentUser().getId()); +// recs = fillAnaliseRecomendacoesHs(a); +// } +// else if(estado == Global.ESTADO_RH2) +// { +// meds = fillAnaliseMedidasRh(a); +// } +// int novo_estado = a.getEstado().intValue(); +// +// if(a.getCorrecao().matches("y")) +// { +// a.setCorrecao("n"); +// a.setEstado(a.getEstado_antes_correcao()); +// a.setEstado_antes_correcao(null); +// a.setObservacoes_correcao(""); +// } +// else +// { +// if(novo_estado < Global.ESTADO_CONCLUIDO) +// { +// novo_estado++; +// // if(novo_estado == ESTADO_MEDICO) +// // { +// // novo_estado++; //skip medico +// // } +// if(novo_estado == Global.ESTADO_ASSINATURAS) +// { +// a.setEstado_assinatura(new Integer(ESTADO_ASSINATURA_1)); +// notifyNextSignature(new Integer(ESTADO_ASSINATURA_1)); +// } +// } +// a.setEstado(new Integer(novo_estado)); +// } + + try + { + update(a, ac, recs, meds); + chkVerRespRh.setDisabled(true); + //createImagesFolder(analiseId.toString()); +// updateImagesFolder(a.getId().toString()); +// sendMailToNextUser(new Integer(novo_estado)); +// String navFrom = getSessionBean1().getNavFrom(); +// if(navFrom.matches("FormSeguranca")) +// { +// return "form_seguranca"; +// } +// else if(navFrom.matches("FormRH")) +// { +// return "form_rh"; +// } +// else if(navFrom.matches("FormHS")) +// { +// return "form_hs"; +// } +// else if(navFrom.matches("FormMedico")) +// { +// return "form_medico"; +// } + } + catch(Exception ex) + { + getSessionBean1().setMsg("Erro na actualização da análise !"); + ex.printStackTrace(); + } + } + + return null; + } + + private void buildPdf(AnaliseAcidente a) + { + + // create pdf folder + String pdf_folder = createPdfFolder(a.getId().toString()); + if(pdf_folder != null) + { + hidDisableEnviar.setValue(a.getId().toString()); + Pdf pdf = new Pdf(); + pdf.generatePdf(pdf_folder, a); + } + } + + + private String createPdfFolder(String folderName) + { + ServletContext theApplicationsServletContext = + (ServletContext) this.getExternalContext().getContext(); + String pdfFileFolder = theApplicationsServletContext.getRealPath(PDFS_FOLDER_URL + "/" + folderName); + try + { + //String imageFileFolderTmp = theApplicationsServletContext.getRealPath(IMAGE_URL + "/tmp" + getSessionBean1().getCurrentUser().getLogin()); + File folder = new File(pdfFileFolder); + if(! folder.exists()) + { + folder.mkdir(); + } + else + { + //remove all existing files + File files[] = folder.listFiles(); + + for(int i=0;iApplication scope data bean for your application. Create properties + * here to represent cached data that should be made available to all users + * and pages in the application.
+ * + *An instance of this class will be created for you automatically, + * the first time your application evaluates a value binding expression + * or method binding expression that references a managed bean using + * this class.
+ */ +public class ApplicationBean1 extends AbstractApplicationBean { + //Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.
+ */ + private void _init() throws Exception { + } + //Construct a new application data bean instance.
+ */ + public ApplicationBean1() { + } + + /** + *This method is called when this bean is initially added to + * application scope. Typically, this occurs as a result of evaluating + * a value binding or method binding expression, which utilizes the + * managed bean facility to instantiate this bean and store it into + * application scope.
+ * + *You may customize this method to initialize and cache application wide + * data values (such as the lists of valid options for dropdown list + * components), or to allocate resources that are required for the + * lifetime of the application.
+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + //This method is called when this bean is removed from + * application scope. Typically, this occurs as a result of + * the application being shut down by its owning container.
+ * + *You may customize this method to clean up resources allocated
+ * during the execution of the init() method, or
+ * at any later time during the lifetime of the application.
Return an appropriate character encoding based on the
+ * Locale defined for the current JavaServer Faces
+ * view. If no more suitable encoding can be found, return
+ * "UTF-8" as a general purpose default.
The default implementation uses the implementation from
+ * our superclass, AbstractApplicationBean.
Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.
+ */ +public class Dummy extends AbstractPageBean { + //Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.
+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridHeader = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridHeader() { + return gridHeader; + } + + public void setGridHeader(HtmlPanelGrid hpg) { + this.gridHeader = hpg; + } + + private PanelGroup groupPanel5 = new PanelGroup(); + + public PanelGroup getGroupPanel5() { + return groupPanel5; + } + + public void setGroupPanel5(PanelGroup pg) { + this.groupPanel5 = pg; + } + + private StaticText lblUser2 = new StaticText(); + + public StaticText getLblUser2() { + return lblUser2; + } + + public void setLblUser2(StaticText st) { + this.lblUser2 = st; + } + + private StaticText staticText7 = new StaticText(); + + public StaticText getStaticText7() { + return staticText7; + } + + public void setStaticText7(StaticText st) { + this.staticText7 = st; + } + + private Hyperlink lnkEditUser2 = new Hyperlink(); + + public Hyperlink getLnkEditUser2() { + return lnkEditUser2; + } + + public void setLnkEditUser2(Hyperlink h) { + this.lnkEditUser2 = h; + } + + private StaticText staticText8 = new StaticText(); + + public StaticText getStaticText8() { + return staticText8; + } + + public void setStaticText8(StaticText st) { + this.staticText8 = st; + } + + private Hyperlink lnkLogout2 = new Hyperlink(); + + public Hyperlink getLnkLogout2() { + return lnkLogout2; + } + + public void setLnkLogout2(Hyperlink h) { + this.lnkLogout2 = h; + } + + private StaticText staticText9 = new StaticText(); + + public StaticText getStaticText9() { + return staticText9; + } + + public void setStaticText9(StaticText st) { + this.staticText9 = st; + } + + private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel2() { + return gridPanel2; + } + + public void setGridPanel2(HtmlPanelGrid hpg) { + this.gridPanel2 = hpg; + } + + private PanelGroup groupPanel3 = new PanelGroup(); + + public PanelGroup getGroupPanel3() { + return groupPanel3; + } + + public void setGroupPanel3(PanelGroup pg) { + this.groupPanel3 = pg; + } + + private ImageComponent image3 = new ImageComponent(); + + public ImageComponent getImage3() { + return image3; + } + + public void setImage3(ImageComponent ic) { + this.image3 = ic; + } + + private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel5() { + return gridPanel5; + } + + public void setGridPanel5(HtmlPanelGrid hpg) { + this.gridPanel5 = hpg; + } + + private StaticText staticText4 = new StaticText(); + + public StaticText getStaticText4() { + return staticText4; + } + + public void setStaticText4(StaticText st) { + this.staticText4 = st; + } + + private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel6() { + return gridPanel6; + } + + public void setGridPanel6(HtmlPanelGrid hpg) { + this.gridPanel6 = hpg; + } + + private PanelGroup groupPanel4 = new PanelGroup(); + + public PanelGroup getGroupPanel4() { + return groupPanel4; + } + + public void setGroupPanel4(PanelGroup pg) { + this.groupPanel4 = pg; + } + + private StaticText staticText5 = new StaticText(); + + public StaticText getStaticText5() { + return staticText5; + } + + public void setStaticText5(StaticText st) { + this.staticText5 = st; + } + + private StaticText stHeaderNr1 = new StaticText(); + + public StaticText getStHeaderNr1() { + return stHeaderNr1; + } + + public void setStHeaderNr1(StaticText st) { + this.stHeaderNr1 = st; + } + + private PanelGroup groupPanel6 = new PanelGroup(); + + public PanelGroup getGroupPanel6() { + return groupPanel6; + } + + public void setGroupPanel6(PanelGroup pg) { + this.groupPanel6 = pg; + } + + private StaticText staticText6 = new StaticText(); + + public StaticText getStaticText6() { + return staticText6; + } + + public void setStaticText6(StaticText st) { + this.staticText6 = st; + } + + private StaticText stHeaderDate1 = new StaticText(); + + public StaticText getStHeaderDate1() { + return stHeaderDate1; + } + + public void setStHeaderDate1(StaticText st) { + this.stHeaderDate1 = st; + } + + private ImageComponent image4 = new ImageComponent(); + + public ImageComponent getImage4() { + return image4; + } + + public void setImage4(ImageComponent ic) { + this.image4 = ic; + } + + private HiddenField hiddenField1 = new HiddenField(); + + public HiddenField getHiddenField1() { + return hiddenField1; + } + + public void setHiddenField1(HiddenField hf) { + this.hiddenField1 = hf; + } + + private Button button2 = new Button(); + + public Button getButton2() { + return button2; + } + + public void setButton2(Button b) { + this.button2 = b; + } + + private StaticText stMsg = new StaticText(); + + public StaticText getStMsg() { + return stMsg; + } + + public void setStMsg(StaticText st) { + this.stMsg = st; + } + + private ImageComponent image1 = new ImageComponent(); + + public ImageComponent getImage1() { + return image1; + } + + public void setImage1(ImageComponent ic) { + this.image1 = ic; + } + + //Construct a new Page bean instance.
+ */ + public Dummy() { + } + + /** + *Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.
+ * + *Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.
+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + //Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.
+ */ + public void preprocess() { + } + + /** + *Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.
+ */ + public void prerender() { + //txtIn.setText("OLA"); + } + + /** + *Callback method that is called after rendering is completed for
+ * this request, if init() was called (regardless of whether
+ * or not this was the page that was actually rendered). Customize this
+ * method to release resources acquired in the init(),
+ * preprocess(), or prerender() methods (or
+ * acquired during execution of an event handler).
Return a reference to the scoped data bean.
+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + public String button1_action() { + + java.util.Date now = new java.util.Date(); + Calendar cal = new GregorianCalendar(); + cal.setTime(now); + int ano = cal.get(Calendar.YEAR); + int mes = cal.MONTH; + int dia = cal.DAY_OF_MONTH; + + Calendar today = new GregorianCalendar(ano, mes, dia); + Calendar firstJan = new GregorianCalendar(ano, Calendar.JANUARY, 1); + Calendar firstJul = new GregorianCalendar(ano, Calendar.JULY, 1); + + if(today.compareTo(firstJan) == 0) + { + System.out.println("IGUAL !!!!!!!!!"); + } + +// GregorianCalendar backDate = new GregorianCalendar(ano, Calendar.MAY, 1); +// backDate.add(GregorianCalendar.DATE, 180); +// Date d = worldTour.getTime(); + + + return null; + } + + public String butCancelar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + return null; + } + + public String butGravar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + return null; + } + + public String butEnviar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + return null; + } + + public String butImagem_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + return null; + } + + public String lnkMoreMed1_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkNome_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkDataNascimento_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkEditUser_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkLogout_action() { + // TODO: Replace with your code + + return null; + } + + public String butProcurarTrab_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + return null; + } + + public String lnkPOR_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkNomeTrabalhador_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkEstabelecimentoTrabalhador_action() { + // TODO: Replace with your code + + return null; + } + + public void drpTipo_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + + } + + public void drpNome_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + + } + + public String hyperlink1_action() { + // TODO: Replace with your code + + return null; + } + + public void lnk_actionListener(ActionEvent e) + { + System.out.println("LINK"); + } + + public String button2_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + //File f = new File(Global.IMAGE_FOLDER); + //stMsg.setText(f.getAbsolutePath() + " ; " + f.exists() + " ; " + f.canRead() + " ; " + f.canWrite()); + String foldername = Global.IMAGE_FOLDER + "/AAA"; + File folder = new File(foldername); + boolean res = folder.mkdir(); + stMsg.setText(res + " ; " + folder.getAbsolutePath()); + return null; + } +} + diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Erro.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Erro.java new file mode 100644 index 00000000..66aa2dc1 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Erro.java @@ -0,0 +1,239 @@ +/* + * Error.java + * + * Created on September 19, 2007, 5:21 PM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.rave.web.ui.component.Body; +import com.sun.rave.web.ui.component.Form; +import com.sun.rave.web.ui.component.Head; +import com.sun.rave.web.ui.component.Html; +import com.sun.rave.web.ui.component.Link; +import com.sun.rave.web.ui.component.Page; +import com.sun.rave.web.ui.component.StaticText; +import com.sun.rave.web.ui.component.TextField; +import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; + +/** + *Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.
+ */ +public class Erro extends AbstractPageBean { + //Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.
+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel1() { + return gridPanel1; + } + + public void setGridPanel1(HtmlPanelGrid hpg) { + this.gridPanel1 = hpg; + } + + private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel2() { + return gridPanel2; + } + + public void setGridPanel2(HtmlPanelGrid hpg) { + this.gridPanel2 = hpg; + } + + private StaticText txtCab = new StaticText(); + + public StaticText getTxtCab() { + return txtCab; + } + + public void setTxtCab(StaticText st) { + this.txtCab = st; + } + + private StaticText txtMsg = new StaticText(); + + public StaticText getTxtMsg() { + return txtMsg; + } + + public void setTxtMsg(StaticText st) { + this.txtMsg = st; + } + + //Construct a new Page bean instance.
+ */ + public Erro() { + } + + /** + *Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.
+ * + *Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.
+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + //Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.
+ */ + public void preprocess() { + } + + /** + *Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.
+ */ + public void prerender() { + txtMsg.setText( getSessionBean1().getMsg() ); + getSessionBean1().setMsg(""); + System.out.println("ERROR PAGE"); + } + + /** + *Callback method that is called after rendering is completed for
+ * this request, if init() was called (regardless of whether
+ * or not this was the page that was actually rendered). Customize this
+ * method to release resources acquired in the init(),
+ * preprocess(), or prerender() methods (or
+ * acquired during execution of an event handler).
Return a reference to the scoped data bean.
+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } +} + diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Estabelecimento.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Estabelecimento.java new file mode 100644 index 00000000..afdcaecf --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Estabelecimento.java @@ -0,0 +1,49 @@ +/* + * Empresa.java + * + * Created on October 11, 2007, 5:19 PM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package analiseacidentestrabalho; + +/** + * + * @author lluis + */ +public class Estabelecimento { + private Integer id; + private String nome_plain; + private String nome; + + /** Creates a new instance of Empresa */ + public Estabelecimento() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getNome_plain() { + return nome_plain; + } + + public void setNome_plain(String nome_plain) { + this.nome_plain = nome_plain; + } + + public String getNome() { + return nome; + } + + public void setNome(String nome) { + this.nome = nome; + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FichaUtilizador.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FichaUtilizador.java new file mode 100644 index 00000000..72d1cef1 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FichaUtilizador.java @@ -0,0 +1,1568 @@ +/* + * FichaUtilizador.java + * + * Created on October 11, 2007, 9:49 AM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.rave.web.ui.component.Body; +import com.sun.rave.web.ui.component.Button; +import com.sun.rave.web.ui.component.Checkbox; +import com.sun.rave.web.ui.component.DropDown; +import com.sun.rave.web.ui.component.Form; +import com.sun.rave.web.ui.component.Head; +import com.sun.rave.web.ui.component.HiddenField; +import com.sun.rave.web.ui.component.Html; +import com.sun.rave.web.ui.component.Hyperlink; +import com.sun.rave.web.ui.component.ImageComponent; +import com.sun.rave.web.ui.component.Link; +import com.sun.rave.web.ui.component.Page; +import com.sun.rave.web.ui.component.PanelGroup; +import com.sun.rave.web.ui.component.PasswordField; +import com.sun.rave.web.ui.component.StaticText; +import com.sun.rave.web.ui.component.TextField; +import com.sun.rave.web.ui.model.SingleSelectOptionsList; +import db.AnalisesDataProvider; +import db.UtilizadoresDataProvider; +import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; +import javax.faces.event.ValueChangeEvent; +import javax.servlet.http.HttpServletRequest; +import utils.Utils; +import global.Global; + +/** + *Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.
+ */ +public class FichaUtilizador extends AbstractPageBean { + //Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.
+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridBase1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridBase1() { + return gridBase1; + } + + public void setGridBase1(HtmlPanelGrid hpg) { + this.gridBase1 = hpg; + } + + private HtmlPanelGrid gridLayout1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayout1() { + return gridLayout1; + } + + public void setGridLayout1(HtmlPanelGrid hpg) { + this.gridLayout1 = hpg; + } + + private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel1() { + return gridPanel1; + } + + public void setGridPanel1(HtmlPanelGrid hpg) { + this.gridPanel1 = hpg; + } + + private PanelGroup groupPanel1 = new PanelGroup(); + + public PanelGroup getGroupPanel1() { + return groupPanel1; + } + + public void setGroupPanel1(PanelGroup pg) { + this.groupPanel1 = pg; + } + + private ImageComponent image1 = new ImageComponent(); + + public ImageComponent getImage1() { + return image1; + } + + public void setImage1(ImageComponent ic) { + this.image1 = ic; + } + + private ImageComponent image2 = new ImageComponent(); + + public ImageComponent getImage2() { + return image2; + } + + public void setImage2(ImageComponent ic) { + this.image2 = ic; + } + + private PanelGroup groupPanel2 = new PanelGroup(); + + public PanelGroup getGroupPanel2() { + return groupPanel2; + } + + public void setGroupPanel2(PanelGroup pg) { + this.groupPanel2 = pg; + } + + private StaticText lblUser = new StaticText(); + + public StaticText getLblUser() { + return lblUser; + } + + public void setLblUser(StaticText st) { + this.lblUser = st; + } + + private StaticText staticText1 = new StaticText(); + + public StaticText getStaticText1() { + return staticText1; + } + + public void setStaticText1(StaticText st) { + this.staticText1 = st; + } + + private Hyperlink lnkEditUser = new Hyperlink(); + + public Hyperlink getLnkEditUser() { + return lnkEditUser; + } + + public void setLnkEditUser(Hyperlink h) { + this.lnkEditUser = h; + } + + private StaticText staticText2 = new StaticText(); + + public StaticText getStaticText2() { + return staticText2; + } + + public void setStaticText2(StaticText st) { + this.staticText2 = st; + } + + private Hyperlink lnkLogout = new Hyperlink(); + + public Hyperlink getLnkLogout() { + return lnkLogout; + } + + public void setLnkLogout(Hyperlink h) { + this.lnkLogout = h; + } + + private HtmlPanelGrid gridMsg1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridMsg1() { + return gridMsg1; + } + + public void setGridMsg1(HtmlPanelGrid hpg) { + this.gridMsg1 = hpg; + } + + private StaticText txtMsg = new StaticText(); + + public StaticText getTxtMsg() { + return txtMsg; + } + + public void setTxtMsg(StaticText st) { + this.txtMsg = st; + } + + private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel2() { + return gridPanel2; + } + + public void setGridPanel2(HtmlPanelGrid hpg) { + this.gridPanel2 = hpg; + } + + private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel3() { + return gridPanel3; + } + + public void setGridPanel3(HtmlPanelGrid hpg) { + this.gridPanel3 = hpg; + } + + private PanelGroup groupPanel3 = new PanelGroup(); + + public PanelGroup getGroupPanel3() { + return groupPanel3; + } + + public void setGroupPanel3(PanelGroup pg) { + this.groupPanel3 = pg; + } + + private StaticText stCriarEditar = new StaticText(); + + public StaticText getStCriarEditar() { + return stCriarEditar; + } + + public void setStCriarEditar(StaticText st) { + this.stCriarEditar = st; + } + + private StaticText staticText4 = new StaticText(); + + public StaticText getStaticText4() { + return staticText4; + } + + public void setStaticText4(StaticText st) { + this.staticText4 = st; + } + + private HtmlPanelGrid gridPanel4 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel4() { + return gridPanel4; + } + + public void setGridPanel4(HtmlPanelGrid hpg) { + this.gridPanel4 = hpg; + } + + private StaticText staticText5 = new StaticText(); + + public StaticText getStaticText5() { + return staticText5; + } + + public void setStaticText5(StaticText st) { + this.staticText5 = st; + } + + private DropDown drpTipo = new DropDown(); + + public DropDown getDrpTipo() { + return drpTipo; + } + + public void setDrpTipo(DropDown dd) { + this.drpTipo = dd; + } + + private StaticText staticText6 = new StaticText(); + + public StaticText getStaticText6() { + return staticText6; + } + + public void setStaticText6(StaticText st) { + this.staticText6 = st; + } + + private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel5() { + return gridPanel5; + } + + public void setGridPanel5(HtmlPanelGrid hpg) { + this.gridPanel5 = hpg; + } + + private DropDown drpNome = new DropDown(); + + public DropDown getDrpNome() { + return drpNome; + } + + public void setDrpNome(DropDown dd) { + this.drpNome = dd; + } + + private TextField txtNome = new TextField(); + + public TextField getTxtNome() { + return txtNome; + } + + public void setTxtNome(TextField tf) { + this.txtNome = tf; + } + + private StaticText staticText7 = new StaticText(); + + public StaticText getStaticText7() { + return staticText7; + } + + public void setStaticText7(StaticText st) { + this.staticText7 = st; + } + + private TextField txtLogin = new TextField(); + + public TextField getTxtLogin() { + return txtLogin; + } + + public void setTxtLogin(TextField tf) { + this.txtLogin = tf; + } + + private StaticText staticText8 = new StaticText(); + + public StaticText getStaticText8() { + return staticText8; + } + + public void setStaticText8(StaticText st) { + this.staticText8 = st; + } + + private PasswordField txtPassword = new PasswordField(); + + public PasswordField getTxtPassword() { + return txtPassword; + } + + public void setTxtPassword(PasswordField pf) { + this.txtPassword = pf; + } + + private StaticText staticText9 = new StaticText(); + + public StaticText getStaticText9() { + return staticText9; + } + + public void setStaticText9(StaticText st) { + this.staticText9 = st; + } + + private TextField txtEmail = new TextField(); + + public TextField getTxtEmail() { + return txtEmail; + } + + public void setTxtEmail(TextField tf) { + this.txtEmail = tf; + } + + private StaticText lblCap = new StaticText(); + + public StaticText getLblCap() { + return lblCap; + } + + public void setLblCap(StaticText st) { + this.lblCap = st; + } + + private TextField txtCap = new TextField(); + + public TextField getTxtCap() { + return txtCap; + } + + public void setTxtCap(TextField tf) { + this.txtCap = tf; + } + + private StaticText lblCedula = new StaticText(); + + public StaticText getLblCedula() { + return lblCedula; + } + + public void setLblCedula(StaticText st) { + this.lblCedula = st; + } + + private StaticText stCedula = new StaticText(); + + public StaticText getStCedula() { + return stCedula; + } + + public void setStCedula(StaticText st) { + this.stCedula = st; + } + + private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel6() { + return gridPanel6; + } + + public void setGridPanel6(HtmlPanelGrid hpg) { + this.gridPanel6 = hpg; + } + + private PanelGroup groupPanel4 = new PanelGroup(); + + public PanelGroup getGroupPanel4() { + return groupPanel4; + } + + public void setGroupPanel4(PanelGroup pg) { + this.groupPanel4 = pg; + } + + private StaticText staticText13 = new StaticText(); + + public StaticText getStaticText13() { + return staticText13; + } + + public void setStaticText13(StaticText st) { + this.staticText13 = st; + } + + private HtmlPanelGrid gridPanel7 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel7() { + return gridPanel7; + } + + public void setGridPanel7(HtmlPanelGrid hpg) { + this.gridPanel7 = hpg; + } + + private Button butCancelar = new Button(); + + public Button getButCancelar() { + return butCancelar; + } + + public void setButCancelar(Button b) { + this.butCancelar = b; + } + + private PanelGroup groupPanel5 = new PanelGroup(); + + public PanelGroup getGroupPanel5() { + return groupPanel5; + } + + public void setGroupPanel5(PanelGroup pg) { + this.groupPanel5 = pg; + } + + private Button butApagar = new Button(); + + public Button getButApagar() { + return butApagar; + } + + public void setButApagar(Button b) { + this.butApagar = b; + } + + private Button butGravar = new Button(); + + public Button getButGravar() { + return butGravar; + } + + public void setButGravar(Button b) { + this.butGravar = b; + } + + private HiddenField hidConfDelUser = new HiddenField(); + + public HiddenField getHidConfDelUser() { + return hidConfDelUser; + } + + public void setHidConfDelUser(HiddenField hf) { + this.hidConfDelUser = hf; + } + + //Construct a new Page bean instance.
+ */ + public FichaUtilizador() { + } + + /** + *Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.
+ * + *Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.
+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + //Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.
+ */ + public void preprocess() { + } + + /** + *Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.
+ */ + public void prerender() { + stCriarEditar.setText("EDITAR"); + butApagar.setRendered(true); + if(getSessionBean1().getModoEdicaoUtilizador().matches("new")) + { + if(!isPostData) + { + txtNome.setStyleClass("hide"); + stCriarEditar.setText("CRIAR"); + lblCap.setRendered(false); + txtCap.setRendered(false); + lblCedula.setRendered(false); + stCedula.setRendered(false); + } + butApagar.setRendered(false); + } + if(getSessionBean1().getModoEdicaoUtilizador().matches("edit")) + { + //drpNome.setRendered(true); + butApagar.setRendered(false); + if(!isPostData) + { + showUser(); + } + } + + txtMsg.setText(getSessionBean1().getMsg()); + getSessionBean1().setMsg(""); + + if(getSessionBean1().isMudarPassword()) + { + //txtMsg.setStyle("color: #000000; font-weight: bold"); + if(!isPostData) + { + txtMsg.setText("Por favor confirme os seus dados e altere a password para uma apenas do seu conhecimento."); + } + //getSessionBean1().setMudarPassword(false); + } + } + + /** + *Callback method that is called after rendering is completed for
+ * this request, if init() was called (regardless of whether
+ * or not this was the page that was actually rendered). Customize this
+ * method to release resources acquired in the init(),
+ * preprocess(), or prerender() methods (or
+ * acquired during execution of an event handler).
Return a reference to the scoped data bean.
+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + public String lnkAnalisesAcidente_action() { + //return navigate(); + int tipo = getSessionBean1().getCurrentUser().getTipo().intValue(); + if(tipo == Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP) + { + return "form_dir_siprp"; + } + else if(tipo == Global.TIPO_UTILIZADOR_DIRECTOR_GERAL_RH) + { + return "form_dir_ger_rh"; + } + else if(tipo == Global.TIPO_UTILIZADOR_SEGURANCA) + { + return "form_seguranca"; + } + else if(tipo == Global.TIPO_UTILIZADOR_RH) + { + return "form_rh"; + } + else if(tipo == Global.TIPO_UTILIZADOR_RH) + { + return "form_rh"; + } + else if(tipo == Global.TIPO_UTILIZADOR_HS) + { + return "form_hs"; + } + else if(tipo == Global.TIPO_UTILIZADOR_GESTOR) + { + return "form_gestor"; + } + + return null; + } + + public String lnkLogout_action() { + // TODO: Replace with your code + try + { + javax.servlet.http.HttpSession session = + (javax.servlet.http.HttpSession) getExternalContext().getSession(true); + session.invalidate(); + } + catch(Exception ex){} + + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) {} + //return "login"; + return null; + } + + + public String butCancelar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + return navigate(); + } + + public String butGravar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + if(validationOk()) + { + if(getSessionBean1().getModoEdicaoUtilizador().matches("new")) + { + try + { + Utilizador u = addUser(); + addPermissao(u); + getSessionBean1().setMsg("Utilizador criado"); + } + catch(Exception ex) + { + getSessionBean1().setMsg("Erro na criação do utilizador!"); + ex.printStackTrace(); + } + } + else //edit + { + try + { + updateUser(); + //getSessionBean1().setMsg("Dados actualizados"); + return navigate(); + } + catch(Exception ex) + { + getSessionBean1().setMsg("Erro na actualização do utilizador"); + ex.printStackTrace(); + } + } + + if(getSessionBean1().isMudarPassword()) + { + getSessionBean1().setMudarPassword(false); + } + + } + + return null; + } + + public void drpTipo_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + drpNome.setVisible(true); + Integer tipo = (Integer) drpTipo.getSelected(); + boolean booGestor = false; + if(tipo.intValue() == GESTOR) + { + booGestor = true; + } + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + getSessionBean1().setEstabelecimentosOptions(adp.getEstabelecimentosList( getSessionBean1().getCurrentUser().getEmpresa_id(), new Boolean(booGestor) )); + drpEstabelecimentos.setSelected(new Integer(-1)); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + if(tipo.intValue() == SEG || tipo.intValue() == RH || tipo.intValue() == GESTOR || tipo.intValue() == DIRECTOR_RH || tipo.intValue() == DIRECTOR_SIPRP) + { + drpNome.setRendered(false); + txtNome.setStyleClass("show"); + lblCap.setRendered(false); + txtCap.setRendered(false); + lblCedula.setRendered(false); + stCedula.setRendered(false); + } + else if(tipo.intValue() == HS || tipo.intValue() == MEDICO) + { + drpNome.setRendered(true); + txtNome.setStyleClass("hide"); + if(tipo.intValue() == HS) + { + lblCap.setRendered(true); + txtCap.setRendered(true); + lblCedula.setRendered(false); + stCedula.setRendered(false); + try + { + getSessionBean1().setMedicosOptions(adp.getTecnicosSaudeList()); + drpNome.setSelected(new Integer(0)); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + } + else // medicos + { + lblCedula.setRendered(true); + stCedula.setRendered(true); + lblCap.setRendered(false); + txtCap.setRendered(false); + try + { + getSessionBean1().setMedicosOptions(adp.getMedicosList()); + drpNome.setSelected(new Integer(0)); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + } + } + } + + private boolean validationOk() + { + Integer tipo = (Integer) drpTipo.getSelected(); +// if(tipo.intValue() == 0) +// { +// getSessionBean1().setMsg("Tem de escolher um tipo!"); +// return false; +// } +// Integer estabelecimento = (Integer) drpEstabelecimentos.getSelected(); +// if(estabelecimento.intValue() == -1) +// { +// getSessionBean1().setMsg("Tem de escolher um estabelecimento!"); +// return false; +// } + +// if(tipo.intValue() == SEG || tipo.intValue() == RH || tipo.intValue() == GESTOR || tipo.intValue() == DIRECTOR_RH || tipo.intValue() == DIRECTOR_SIPRP) +// { +// if(txtNome.getText() == null) +// { +// getSessionBean1().setMsg("Tem de indicar o nome!"); +// return false; +// } +// else +// { +// String nome = (String) txtNome.getText(); +// if(nome.trim().length() == 0) +// { +// getSessionBean1().setMsg("Tem de indicar o nome!"); +// return false; +// } +// } +// } +// else if(tipo.intValue() == HS || tipo.intValue() == MEDICO) +// { +// Integer nome = (Integer) drpNome.getSelected(); +// if(nome.intValue() == 0) +// { +// getSessionBean1().setMsg("Tem de indicar o nome!"); +// return false; +// } +// } + +// if(txtLogin.getText() == null) +// { +// getSessionBean1().setMsg("Tem de indicar o login!"); +// return false; +// } +// else +// { +// String login = (String) txtLogin.getText(); +// if(login.trim().length() == 0) +// { +// getSessionBean1().setMsg("Tem de indicar o login!"); +// return false; +// } +// } + + if(txtPassword.getText() == null) + { + getSessionBean1().setMsg("Tem de indicar a password!"); + return false; + } + else + { + String password = (String) txtPassword.getText(); + if(password.trim().length() == 0) + { + getSessionBean1().setMsg("Tem de indicar a password!"); + return false; + } + else + { + if(txtConfPassword.getText() == null) + { + getSessionBean1().setMsg("Tem de confirmar a password!"); + return false; + } + else + { + String conf_password = (String) txtConfPassword.getText(); + if(conf_password.trim().length() == 0) + { + getSessionBean1().setMsg("Tem de confirmar a password!"); + return false; + } + else + { + if(!password.equals(conf_password)) + { + getSessionBean1().setMsg("A confirmação tem de ser igual à a password!"); + return false; + } + } + } + } // + } + + if(getSessionBean1().isMudarPassword()) + { + String password = (String) txtPassword.getText(); + if(password.matches(getSessionBean1().getCurrentUser().getPassword())) + { + getSessionBean1().setMsg("A nova password tem de ser diferente da password actual!"); + return false; + } + + } + +// if(tipo.intValue() == HS) +// { +// if(txtCap.getText() == null ) +// { +// getSessionBean1().setMsg("Tem de indicar o c.a.p.!"); +// return false; +// } +// else +// { +// String cap = (String) txtCap.getText(); +// if(cap.trim().length() == 0) +// { +// getSessionBean1().setMsg("Tem de indicar o c.a.p.!"); +// return false; +// } +// } +// } + + return true; + } + + public void drpNome_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + Integer tipo = (Integer) drpTipo.getSelected(); + if(tipo.intValue() == MEDICO) + { + AnalisesDataProvider adp = new AnalisesDataProvider(); + Integer medico_id = (Integer) drpNome.getSelected(); + try + { + String numero_cedula = adp.getNumeroCedula(medico_id); + stCedula.setText(numero_cedula); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + } + } + + private Utilizador addUser() throws Exception + { + Utilizador u = fillUser(); + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + Integer id = udp.createNewUtilizador(u); + u.setId(id); + return u; + } + + private void addPermissao(Utilizador u) throws Exception + { + Permissao p = new Permissao(); + p.setUser_id(u.getId()); + p.setCodigo_permissao(u.getTipo()); + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + udp.createPermissao(p); + } + + private void updateUser() throws Exception + { + Utilizador u = fillUser(); + u.setId(getSessionBean1().getCurrentUser().getId()); + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + udp.updateUtilizador(u); + } + + private void deleteUser() throws Exception + { + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + udp.deleteUser(getSessionBean1().getCurrentUser().getId()); + } + + private void showUser() + { + AnalisesDataProvider adp = new AnalisesDataProvider(); + Utilizador u = getSessionBean1().getCurrentUser(); + drpTipo.setSelected(u.getTipo()); + if(u.getTipo().intValue() == SEG || u.getTipo().intValue() == RH || u.getTipo().intValue() == HS || u.getTipo().intValue() == MEDICO || u.getTipo().intValue() == GESTOR || u.getTipo().intValue() == DIRECTOR_RH || u.getTipo().intValue() == DIRECTOR_SIPRP) + { + drpNome.setRendered(false); + txtNome.setStyleClass("show"); + lblCap.setRendered(false); + txtCap.setRendered(false); + lblCedula.setRendered(false); + stCedula.setRendered(false); + txtNome.setText(utils.Utils.unicodeToHTML(u.getNome())); + } + else if(u.getTipo().intValue() == HS) + { + //txtNome.setRendered(false); + try + { + getSessionBean1().setMedicosOptions(adp.getTecnicosSaudeList()); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + drpNome.setSelected(u.getFuncionario_hst_id()); + drpNome.setStyleClass("show"); + lblCap.setRendered(true); + txtCap.setRendered(true); + lblCedula.setRendered(false); + stCedula.setRendered(false); + txtCap.setText(u.getCap()); + } + else if(u.getTipo().intValue() == MEDICO) //medico + { + drpNome.setRendered(true); + try + { + getSessionBean1().setMedicosOptions(adp.getMedicosList()); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + drpNome.setSelected(u.getMedico_id()); + txtNome.setStyleClass("hide"); + lblCap.setRendered(false); + txtCap.setRendered(false); + lblCedula.setRendered(true); + stCedula.setRendered(true); + stCedula.setText(u.getNumero_cedula()); + + } + if(u.getEstabelecimento_id() != null) + { + drpEstabelecimentos.setSelected(u.getEstabelecimento_id()); + } + + txtLogin.setText(u.getLogin()); + //txtPassword.setText(u.getPassword()); + txtEmail.setText(u.getEmail()); + } + + private Utilizador fillUser() + { + //Utilizador u = new Utilizador(); + Utilizador u = getSessionBean1().getCurrentUser(); +// u.setActivo("y"); +// u.setAdministrador("n"); +// u.setTipo((Integer) drpTipo.getSelected()); +// u.setEmpresa_id(getSessionBean1().getCurrentUser().getEmpresa_id()); +// u.setEstabelecimento_id( (Integer) drpEstabelecimentos.getSelected() ); +// u.setLogin( (String) txtLogin.getText() ); + String password = (String) txtPassword.getText(); + u.setPassword( password ); + java.util.Date today = + new java.util.Date(); + java.sql.Date sqlToday = + new java.sql.Date(today.getTime()); + u.setData_password(sqlToday); + + + u.setEmail(""); + if(txtEmail.getText() != null) + { + u.setEmail( (String) txtEmail.getText() ); + } + + Integer tipo = (Integer) drpTipo.getSelected(); + +// u.setNumero_cedula(""); +// u.setCap(""); +// if(tipo.intValue() == HS || tipo.intValue() == MEDICO) +// { +// AnalisesDataProvider adp = new AnalisesDataProvider(); +// if(tipo.intValue() == HS) +// { +// try +// { +// Integer tecnico_id = (Integer) drpNome.getSelected(); +// u.setFuncionario_hst_id(tecnico_id); +// u.setNome( adp.getTecnicoSaudeNome(tecnico_id) ); +// } +// catch(Exception ex) +// { +// ex.printStackTrace(); +// } +// u.setCap( (String) txtCap.getText()); +// } +// else // medico +// { +// try +// { +// Integer medico_id = (Integer) drpNome.getSelected(); +// u.setMedico_id(medico_id); +// u.setNome( adp.getMedicoNome(medico_id) ); +// } +// catch(Exception ex) +// { +// ex.printStackTrace(); +// } +// u.setNumero_cedula( (String) stCedula.getText()); +// } +// } +// else +// { +// u.setNome( (String) txtNome.getText() ); +// } + +// u.setResponsavel_loja("n"); +// if(chkResponsavelLoja.getSelected() != null) +// { +// if(chkResponsavelLoja.getSelected().equals(new Boolean(true))) +// { +// u.setResponsavel_loja("y"); +// } +// } +// +// if(u.getGestor_geral() == null) +// { +// u.setGestor_geral("n"); +// } + + u.setPrimeiro_login("n"); + return u; + } + + public String lnkEditUser_action() { + // TODO: Replace with your code + + getSessionBean1().setModoEdicaoUtilizador("edit"); + return "user"; + } + + public String butApagar_action() { + // TODO: Replace with your code + hidConfDelUser.setValue("apagar"); + return null; + } + + private String navigate() + { + String nav_from = getSessionBean1().getNavFrom(); + if(nav_from.matches("FormSeguranca")) + { + return "form_seguranca"; + } + else if(nav_from.matches("FormRH")) + { + return "form_rh"; + } + else if(nav_from.matches("FormHS")) + { + return "form_hs"; + } + else if(nav_from.matches("FormMedico")) + { + return "form_medico"; + } + else if(nav_from.matches("AnaliseAcidenteTrabalho")) + { + return "analise_acidente"; + } + else if(nav_from.matches("ViewAnaliseAcidenteTrabalho")) + { + return "view_analise"; + } + else if(nav_from.matches("FormGestor")) + { + return "form_gestor"; + } + else if(nav_from.matches("FormDirGerRh")) + { + return "form_dir_ger_rh"; + } + else if(nav_from.matches("FormDirSiprp")) + { + return "form_dir_siprp"; + } + else if(nav_from.matches("GestaoUtilizadores")) + { + return "gestao_utilizadores"; + } + else if(nav_from.matches("NovoUtilizador")) + { + return "novo_utilizador"; + } + else if(nav_from.matches("Login")) // first login + { + int tipo = getSessionBean1().getCurrentUser().getTipo().intValue(); + switch(tipo) + { + case Global.TIPO_UTILIZADOR_SEGURANCA: + return "form_seguranca"; + case Global.TIPO_UTILIZADOR_RH: + return "form_rh"; + case Global.TIPO_UTILIZADOR_HS: + return "form_hs"; + case Global.TIPO_UTILIZADOR_MEDICO: + return "form_medico"; + case Global.TIPO_UTILIZADOR_GESTOR: + return "form_gestor"; + case Global.TIPO_UTILIZADOR_DIRECTOR_GERAL_RH: + return "form_dir_ger_rh"; + case Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP: + return "form_dir_siprp"; + } + } + return null; + } + + public String lnkNewUser_action() { + // TODO: Replace with your code + + if(getSessionBean1().getCurrentUser().getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_GERAL_RH) + { + getSessionBean1().setNavFrom("FormDirGerRh"); + } + else if(getSessionBean1().getCurrentUser().getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP) + { + getSessionBean1().setNavFrom("FormDirSiprp"); + } + + + return "gestao_utilizadores"; + + } +} + diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Footer.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Footer.java new file mode 100644 index 00000000..52f9e49d --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Footer.java @@ -0,0 +1,152 @@ +/* + * Footer.java + * + * Created on September 19, 2007, 10:57 AM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.rave.web.ui.appbase.AbstractFragmentBean; +import com.sun.rave.web.ui.component.ImageComponent; +import com.sun.rave.web.ui.component.PanelGroup; +import com.sun.rave.web.ui.component.StaticText; +import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; + +/** + *Fragment bean that corresponds to a similarly named JSP page + * fragment. This class contains component definitions (and initialization + * code) for all components that you have defined on this fragment, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.
+ */ +public class Footer extends AbstractFragmentBean { + //Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.
+ */ + private void _init() throws Exception { + } + + private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel1() { + return gridPanel1; + } + + public void setGridPanel1(HtmlPanelGrid hpg) { + this.gridPanel1 = hpg; + } + + private PanelGroup groupPanel1 = new PanelGroup(); + + public PanelGroup getGroupPanel1() { + return groupPanel1; + } + + public void setGroupPanel1(PanelGroup pg) { + this.groupPanel1 = pg; + } + + private StaticText staticText1 = new StaticText(); + + public StaticText getStaticText1() { + return staticText1; + } + + public void setStaticText1(StaticText st) { + this.staticText1 = st; + } + + private StaticText staticText2 = new StaticText(); + + public StaticText getStaticText2() { + return staticText2; + } + + public void setStaticText2(StaticText st) { + this.staticText2 = st; + } + + private ImageComponent image1 = new ImageComponent(); + + public ImageComponent getImage1() { + return image1; + } + + public void setImage1(ImageComponent ic) { + this.image1 = ic; + } + //Callback method that is called whenever a page containing + * this page fragment is navigated to, either directly via a URL, + * or indirectly via page navigation. Override this method to acquire + * resources that will be needed for event handlers and lifecycle methods.
+ * + *The default implementation does nothing.
+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + + //Callback method that is called after rendering is completed for
+ * this request, if init() was called. Override this
+ * method to release resources acquired in the init()
+ * resources that will be needed for event handlers and lifecycle methods.
The default implementation does nothing.
+ */ + public void destroy() { + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormHS.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormHS.java new file mode 100644 index 00000000..3b30f435 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormHS.java @@ -0,0 +1,1603 @@ +/* + * FormHS.java + * + * Created on October 1, 2007, 1:43 PM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.data.provider.RowKey; +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.rave.web.ui.component.Body; +import com.sun.rave.web.ui.component.Button; +import com.sun.rave.web.ui.component.DropDown; +import com.sun.rave.web.ui.component.Form; +import com.sun.rave.web.ui.component.Head; +import com.sun.rave.web.ui.component.Html; +import com.sun.rave.web.ui.component.Hyperlink; +import com.sun.rave.web.ui.component.ImageComponent; +import com.sun.rave.web.ui.component.Link; +import com.sun.rave.web.ui.component.Page; +import com.sun.rave.web.ui.component.PanelGroup; +import com.sun.rave.web.ui.component.StaticText; +import com.sun.rave.web.ui.component.Table; +import com.sun.rave.web.ui.component.TableColumn; +import com.sun.rave.web.ui.component.TableRowGroup; +import com.sun.rave.web.ui.component.TextField; +import com.sun.rave.web.ui.model.Option; +import db.AnalisesActualDataProvider; +import db.AnalisesConcluidasDataProvider; +import db.AnalisesDataProvider; +import db.AnalisesSeguimentoDataProvider; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.ListIterator; +import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; +import javax.faces.event.ValueChangeEvent; +import javax.servlet.http.HttpServletRequest; +import utils.Utils; + +/** + *Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.
+ */ +public class FormHS extends AbstractPageBean { + //Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.
+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridBase1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridBase1() { + return gridBase1; + } + + public void setGridBase1(HtmlPanelGrid hpg) { + this.gridBase1 = hpg; + } + + private HtmlPanelGrid gridLayout1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayout1() { + return gridLayout1; + } + + public void setGridLayout1(HtmlPanelGrid hpg) { + this.gridLayout1 = hpg; + } + + private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel1() { + return gridPanel1; + } + + public void setGridPanel1(HtmlPanelGrid hpg) { + this.gridPanel1 = hpg; + } + + private PanelGroup groupPanel1 = new PanelGroup(); + + public PanelGroup getGroupPanel1() { + return groupPanel1; + } + + public void setGroupPanel1(PanelGroup pg) { + this.groupPanel1 = pg; + } + + private ImageComponent image1 = new ImageComponent(); + + public ImageComponent getImage1() { + return image1; + } + + public void setImage1(ImageComponent ic) { + this.image1 = ic; + } + + private ImageComponent image2 = new ImageComponent(); + + public ImageComponent getImage2() { + return image2; + } + + public void setImage2(ImageComponent ic) { + this.image2 = ic; + } + + private PanelGroup groupPanel2 = new PanelGroup(); + + public PanelGroup getGroupPanel2() { + return groupPanel2; + } + + public void setGroupPanel2(PanelGroup pg) { + this.groupPanel2 = pg; + } + + private StaticText lblUser = new StaticText(); + + public StaticText getLblUser() { + return lblUser; + } + + public void setLblUser(StaticText st) { + this.lblUser = st; + } + + private StaticText staticText1 = new StaticText(); + + public StaticText getStaticText1() { + return staticText1; + } + + public void setStaticText1(StaticText st) { + this.staticText1 = st; + } + + private Hyperlink lnkEditUser = new Hyperlink(); + + public Hyperlink getLnkEditUser() { + return lnkEditUser; + } + + public void setLnkEditUser(Hyperlink h) { + this.lnkEditUser = h; + } + + private StaticText staticText2 = new StaticText(); + + public StaticText getStaticText2() { + return staticText2; + } + + public void setStaticText2(StaticText st) { + this.staticText2 = st; + } + + private Hyperlink lnkLogout = new Hyperlink(); + + public Hyperlink getLnkLogout() { + return lnkLogout; + } + + public void setLnkLogout(Hyperlink h) { + this.lnkLogout = h; + } + + private HtmlPanelGrid gridLayoutTop1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayoutTop1() { + return gridLayoutTop1; + } + + public void setGridLayoutTop1(HtmlPanelGrid hpg) { + this.gridLayoutTop1 = hpg; + } + + private HtmlPanelGrid gridActual1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridActual1() { + return gridActual1; + } + + public void setGridActual1(HtmlPanelGrid hpg) { + this.gridActual1 = hpg; + } + + private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel2() { + return gridPanel2; + } + + public void setGridPanel2(HtmlPanelGrid hpg) { + this.gridPanel2 = hpg; + } + + private StaticText staticText4 = new StaticText(); + + public StaticText getStaticText4() { + return staticText4; + } + + public void setStaticText4(StaticText st) { + this.staticText4 = st; + } + + private StaticText staticText5 = new StaticText(); + + public StaticText getStaticText5() { + return staticText5; + } + + public void setStaticText5(StaticText st) { + this.staticText5 = st; + } + + private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel3() { + return gridPanel3; + } + + public void setGridPanel3(HtmlPanelGrid hpg) { + this.gridPanel3 = hpg; + } + + private Table table1 = new Table(); + + public Table getTable1() { + return table1; + } + + public void setTable1(Table t) { + this.table1 = t; + } + + private TableRowGroup tableRowGroup1 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup1() { + return tableRowGroup1; + } + + public void setTableRowGroup1(TableRowGroup trg) { + this.tableRowGroup1 = trg; + } + + private TableColumn tableColumn1 = new TableColumn(); + + public TableColumn getTableColumn1() { + return tableColumn1; + } + + public void setTableColumn1(TableColumn tc) { + this.tableColumn1 = tc; + } + + private Hyperlink lnkDataAcidente = new Hyperlink(); + + public Hyperlink getLnkDataAcidente() { + return lnkDataAcidente; + } + + public void setLnkDataAcidente(Hyperlink h) { + this.lnkDataAcidente = h; + } + + private TableColumn tableColumn2 = new TableColumn(); + + public TableColumn getTableColumn2() { + return tableColumn2; + } + + public void setTableColumn2(TableColumn tc) { + this.tableColumn2 = tc; + } + + private Hyperlink lnkNr = new Hyperlink(); + + public Hyperlink getLnkNr() { + return lnkNr; + } + + public void setLnkNr(Hyperlink h) { + this.lnkNr = h; + } + + private TableColumn tableColumn3 = new TableColumn(); + + public TableColumn getTableColumn3() { + return tableColumn3; + } + + public void setTableColumn3(TableColumn tc) { + this.tableColumn3 = tc; + } + + private Hyperlink lnkNomeAcidentado = new Hyperlink(); + + public Hyperlink getLnkNomeAcidentado() { + return lnkNomeAcidentado; + } + + public void setLnkNomeAcidentado(Hyperlink h) { + this.lnkNomeAcidentado = h; + } + + private HtmlPanelGrid gridSeguimento1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridSeguimento1() { + return gridSeguimento1; + } + + public void setGridSeguimento1(HtmlPanelGrid hpg) { + this.gridSeguimento1 = hpg; + } + + private HtmlPanelGrid gridPanel4 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel4() { + return gridPanel4; + } + + public void setGridPanel4(HtmlPanelGrid hpg) { + this.gridPanel4 = hpg; + } + + private StaticText staticText6 = new StaticText(); + + public StaticText getStaticText6() { + return staticText6; + } + + public void setStaticText6(StaticText st) { + this.staticText6 = st; + } + + private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel5() { + return gridPanel5; + } + + public void setGridPanel5(HtmlPanelGrid hpg) { + this.gridPanel5 = hpg; + } + + private Table table2 = new Table(); + + public Table getTable2() { + return table2; + } + + public void setTable2(Table t) { + this.table2 = t; + } + + private TableRowGroup tableRowGroup2 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup2() { + return tableRowGroup2; + } + + public void setTableRowGroup2(TableRowGroup trg) { + this.tableRowGroup2 = trg; + } + + private TableColumn tableColumn4 = new TableColumn(); + + public TableColumn getTableColumn4() { + return tableColumn4; + } + + public void setTableColumn4(TableColumn tc) { + this.tableColumn4 = tc; + } + + private Hyperlink lnkDataAcidenteSeg = new Hyperlink(); + + public Hyperlink getLnkDataAcidenteSeg() { + return lnkDataAcidenteSeg; + } + + public void setLnkDataAcidenteSeg(Hyperlink h) { + this.lnkDataAcidenteSeg = h; + } + + private TableColumn tableColumn5 = new TableColumn(); + + public TableColumn getTableColumn5() { + return tableColumn5; + } + + public void setTableColumn5(TableColumn tc) { + this.tableColumn5 = tc; + } + + private Hyperlink lnkNrSeg = new Hyperlink(); + + public Hyperlink getLnkNrSeg() { + return lnkNrSeg; + } + + public void setLnkNrSeg(Hyperlink h) { + this.lnkNrSeg = h; + } + + private TableColumn tableColumn6 = new TableColumn(); + + public TableColumn getTableColumn6() { + return tableColumn6; + } + + public void setTableColumn6(TableColumn tc) { + this.tableColumn6 = tc; + } + + private Hyperlink lnkNomeAcidentadoSeg = new Hyperlink(); + + public Hyperlink getLnkNomeAcidentadoSeg() { + return lnkNomeAcidentadoSeg; + } + + public void setLnkNomeAcidentadoSeg(Hyperlink h) { + this.lnkNomeAcidentadoSeg = h; + } + + private HtmlPanelGrid gridConcluidos1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridConcluidos1() { + return gridConcluidos1; + } + + public void setGridConcluidos1(HtmlPanelGrid hpg) { + this.gridConcluidos1 = hpg; + } + + private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel6() { + return gridPanel6; + } + + public void setGridPanel6(HtmlPanelGrid hpg) { + this.gridPanel6 = hpg; + } + + private StaticText staticText7 = new StaticText(); + + public StaticText getStaticText7() { + return staticText7; + } + + public void setStaticText7(StaticText st) { + this.staticText7 = st; + } + + private HtmlPanelGrid gridPanel7 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel7() { + return gridPanel7; + } + + public void setGridPanel7(HtmlPanelGrid hpg) { + this.gridPanel7 = hpg; + } + + private PanelGroup groupPanel3 = new PanelGroup(); + + public PanelGroup getGroupPanel3() { + return groupPanel3; + } + + public void setGroupPanel3(PanelGroup pg) { + this.groupPanel3 = pg; + } + + private StaticText staticText8 = new StaticText(); + + public StaticText getStaticText8() { + return staticText8; + } + + public void setStaticText8(StaticText st) { + this.staticText8 = st; + } + + private DropDown drpAno = new DropDown(); + + public DropDown getDrpAno() { + return drpAno; + } + + public void setDrpAno(DropDown dd) { + this.drpAno = dd; + } + + private PanelGroup groupPanel4 = new PanelGroup(); + + public PanelGroup getGroupPanel4() { + return groupPanel4; + } + + public void setGroupPanel4(PanelGroup pg) { + this.groupPanel4 = pg; + } + + private StaticText lblMes = new StaticText(); + + public StaticText getLblMes() { + return lblMes; + } + + public void setLblMes(StaticText st) { + this.lblMes = st; + } + + private DropDown drpMes = new DropDown(); + + public DropDown getDrpMes() { + return drpMes; + } + + public void setDrpMes(DropDown dd) { + this.drpMes = dd; + } + + private PanelGroup groupPanel5 = new PanelGroup(); + + public PanelGroup getGroupPanel5() { + return groupPanel5; + } + + public void setGroupPanel5(PanelGroup pg) { + this.groupPanel5 = pg; + } + + private StaticText lblDia = new StaticText(); + + public StaticText getLblDia() { + return lblDia; + } + + public void setLblDia(StaticText st) { + this.lblDia = st; + } + + private DropDown drpDia = new DropDown(); + + public DropDown getDrpDia() { + return drpDia; + } + + public void setDrpDia(DropDown dd) { + this.drpDia = dd; + } + + private PanelGroup groupPanel6 = new PanelGroup(); + + public PanelGroup getGroupPanel6() { + return groupPanel6; + } + + public void setGroupPanel6(PanelGroup pg) { + this.groupPanel6 = pg; + } + + private StaticText staticText9 = new StaticText(); + + public StaticText getStaticText9() { + return staticText9; + } + + public void setStaticText9(StaticText st) { + this.staticText9 = st; + } + + private TextField txtNome = new TextField(); + + public TextField getTxtNome() { + return txtNome; + } + + public void setTxtNome(TextField tf) { + this.txtNome = tf; + } + + private Button butPesquisar = new Button(); + + public Button getButPesquisar() { + return butPesquisar; + } + + public void setButPesquisar(Button b) { + this.butPesquisar = b; + } + + private HtmlPanelGrid gridPanel8 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel8() { + return gridPanel8; + } + + public void setGridPanel8(HtmlPanelGrid hpg) { + this.gridPanel8 = hpg; + } + + private Table table3 = new Table(); + + public Table getTable3() { + return table3; + } + + public void setTable3(Table t) { + this.table3 = t; + } + + private TableRowGroup tableRowGroup3 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup3() { + return tableRowGroup3; + } + + public void setTableRowGroup3(TableRowGroup trg) { + this.tableRowGroup3 = trg; + } + + private TableColumn tableColumn7 = new TableColumn(); + + public TableColumn getTableColumn7() { + return tableColumn7; + } + + public void setTableColumn7(TableColumn tc) { + this.tableColumn7 = tc; + } + + private Hyperlink lnkDataConcluida = new Hyperlink(); + + public Hyperlink getLnkDataConcluida() { + return lnkDataConcluida; + } + + public void setLnkDataConcluida(Hyperlink h) { + this.lnkDataConcluida = h; + } + + private TableColumn tableColumn8 = new TableColumn(); + + public TableColumn getTableColumn8() { + return tableColumn8; + } + + public void setTableColumn8(TableColumn tc) { + this.tableColumn8 = tc; + } + + private Hyperlink lnkNrConcluida = new Hyperlink(); + + public Hyperlink getLnkNrConcluida() { + return lnkNrConcluida; + } + + public void setLnkNrConcluida(Hyperlink h) { + this.lnkNrConcluida = h; + } + + private TableColumn tableColumn9 = new TableColumn(); + + public TableColumn getTableColumn9() { + return tableColumn9; + } + + public void setTableColumn9(TableColumn tc) { + this.tableColumn9 = tc; + } + + private Hyperlink lnkNomeConcluida = new Hyperlink(); + + public Hyperlink getLnkNomeConcluida() { + return lnkNomeConcluida; + } + + public void setLnkNomeConcluida(Hyperlink h) { + this.lnkNomeConcluida = h; + } + + private StaticText txtSearchMsg = new StaticText(); + + public StaticText getTxtSearchMsg() { + return txtSearchMsg; + } + + public void setTxtSearchMsg(StaticText st) { + this.txtSearchMsg = st; + } + + private TableColumn tableColumn10 = new TableColumn(); + + public TableColumn getTableColumn10() { + return tableColumn10; + } + + public void setTableColumn10(TableColumn tc) { + this.tableColumn10 = tc; + } + + private Hyperlink lnkFase = new Hyperlink(); + + public Hyperlink getLnkFase() { + return lnkFase; + } + + public void setLnkFase(Hyperlink h) { + this.lnkFase = h; + } + + private TableColumn tableColumn11 = new TableColumn(); + + public TableColumn getTableColumn11() { + return tableColumn11; + } + + public void setTableColumn11(TableColumn tc) { + this.tableColumn11 = tc; + } + + private Hyperlink lnkFaseSeg = new Hyperlink(); + + public Hyperlink getLnkFaseSeg() { + return lnkFaseSeg; + } + + public void setLnkFaseSeg(Hyperlink h) { + this.lnkFaseSeg = h; + } + + private TableColumn tableColumn12 = new TableColumn(); + + public TableColumn getTableColumn12() { + return tableColumn12; + } + + public void setTableColumn12(TableColumn tc) { + this.tableColumn12 = tc; + } + + private TableColumn tableColumn13 = new TableColumn(); + + public TableColumn getTableColumn13() { + return tableColumn13; + } + + public void setTableColumn13(TableColumn tc) { + this.tableColumn13 = tc; + } + + private TableColumn tableColumn14 = new TableColumn(); + + public TableColumn getTableColumn14() { + return tableColumn14; + } + + public void setTableColumn14(TableColumn tc) { + this.tableColumn14 = tc; + } + + private TableColumn tableColumn15 = new TableColumn(); + + public TableColumn getTableColumn15() { + return tableColumn15; + } + + public void setTableColumn15(TableColumn tc) { + this.tableColumn15 = tc; + } + + private Hyperlink lnkPor = new Hyperlink(); + + public Hyperlink getLnkPor() { + return lnkPor; + } + + public void setLnkPor(Hyperlink h) { + this.lnkPor = h; + } + + private Hyperlink lnkPorSeg = new Hyperlink(); + + public Hyperlink getLnkPorSeg() { + return lnkPorSeg; + } + + public void setLnkPorSeg(Hyperlink h) { + this.lnkPorSeg = h; + } + + private Hyperlink lnkPorConcluida = new Hyperlink(); + + public Hyperlink getLnkPorConcluida() { + return lnkPorConcluida; + } + + public void setLnkPorConcluida(Hyperlink h) { + this.lnkPorConcluida = h; + } + + private Hyperlink lnkEstabConcluida = new Hyperlink(); + + public Hyperlink getLnkEstabConcluida() { + return lnkEstabConcluida; + } + + public void setLnkEstabConcluida(Hyperlink h) { + this.lnkEstabConcluida = h; + } + + private PanelGroup groupPanel7 = new PanelGroup(); + + public PanelGroup getGroupPanel7() { + return groupPanel7; + } + + public void setGroupPanel7(PanelGroup pg) { + this.groupPanel7 = pg; + } + + private StaticText staticText3 = new StaticText(); + + public StaticText getStaticText3() { + return staticText3; + } + + public void setStaticText3(StaticText st) { + this.staticText3 = st; + } + + private TextField txtPor = new TextField(); + + public TextField getTxtPor() { + return txtPor; + } + + public void setTxtPor(TextField tf) { + this.txtPor = tf; + } + + private HtmlPanelGrid gridPanel9 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel9() { + return gridPanel9; + } + + public void setGridPanel9(HtmlPanelGrid hpg) { + this.gridPanel9 = hpg; + } + + private PanelGroup groupPanel8 = new PanelGroup(); + + public PanelGroup getGroupPanel8() { + return groupPanel8; + } + + public void setGroupPanel8(PanelGroup pg) { + this.groupPanel8 = pg; + } + + private StaticText staticText10 = new StaticText(); + + public StaticText getStaticText10() { + return staticText10; + } + + public void setStaticText10(StaticText st) { + this.staticText10 = st; + } + + private ImageComponent image3 = new ImageComponent(); + + public ImageComponent getImage3() { + return image3; + } + + public void setImage3(ImageComponent ic) { + this.image3 = ic; + } + + private StaticText staticText11 = new StaticText(); + + public StaticText getStaticText11() { + return staticText11; + } + + public void setStaticText11(StaticText st) { + this.staticText11 = st; + } + + private Hyperlink lnkNewUser1 = new Hyperlink(); + + public Hyperlink getLnkNewUser1() { + return lnkNewUser1; + } + + public void setLnkNewUser1(Hyperlink h) { + this.lnkNewUser1 = h; + } + + private StaticText staticText12 = new StaticText(); + + public StaticText getStaticText12() { + return staticText12; + } + + public void setStaticText12(StaticText st) { + this.staticText12 = st; + } + + private Hyperlink lnkAnalisesAcidente = new Hyperlink(); + + public Hyperlink getLnkAnalisesAcidente() { + return lnkAnalisesAcidente; + } + + public void setLnkAnalisesAcidente(Hyperlink h) { + this.lnkAnalisesAcidente = h; + } + + private StaticText staticText13 = new StaticText(); + + public StaticText getStaticText13() { + return staticText13; + } + + public void setStaticText13(StaticText st) { + this.staticText13 = st; + } + + //Construct a new Page bean instance.
+ */ + public FormHS() { + } + + /** + *Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.
+ * + *Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.
+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + //Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.
+ */ + public void preprocess() { + } + + /** + *Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.
+ */ + public void prerender() { + lblUser.setText( getSessionBean1().getCurrentUser().getLogin() ); + + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + //lblActivos.setRendered(true); + table1.setRendered(true); + + //ArrayList actuaisList = adp.getAnalisesActuaisList(getSessionBean1().getCurrentUser().getEstabelecimento_id(), new Integer(3)); + ArrayList actuaisList = adp.getAnalisesActuaisHsList( getSessionBean1().getCurrentUser().getEstabelecimento_id() ); + getSessionBean1().getAnalisesActualDataProvider().setList(actuaisList); + } + catch(Exception ex) + { + //lblActivos.setRendered(false); + table1.setRendered(false); + //ex.printStackTrace(); + } + + try + { + //lblActivos.setRendered(true); + table2.setRendered(true); + + ArrayList seguimentoList = adp.getAnalisesSeguimentoHsList(getSessionBean1().getCurrentUser().getEstabelecimento_id()); + getSessionBean1().getAnalisesSeguimentoDataProvider().setList(seguimentoList); + } + catch(Exception ex) + { + //lblActivos.setRendered(false); + table2.setRendered(false); + //ex.printStackTrace(); + } + + HttpServletRequest request = (HttpServletRequest) getExternalContext().getRequest(); + String referer = request.getRequestURI(); + String pageFrom = Utils.getPageFrom(referer); + if(!pageFrom.matches("FormHS.jsp")) + { + + try + { + //lblActivos.setRendered(true); + table3.setRendered(true); + ArrayList concluidasList = adp.getAnalisesConcluidasHsList(); + getSessionBean1().getAnalisesConcluidasDataProvider().setList(concluidasList); + } + catch(Exception ex) + { + //lblActivos.setRendered(false); + table3.setRendered(false); + //ex.printStackTrace(); + } + fillAnoDropDown(); + } + } + + /** + *Callback method that is called after rendering is completed for
+ * this request, if init() was called (regardless of whether
+ * or not this was the page that was actually rendered). Customize this
+ * method to release resources acquired in the init(),
+ * preprocess(), or prerender() methods (or
+ * acquired during execution of an event handler).
Return a reference to the scoped data bean.
+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + public String lnkLogout_action() { + // TODO: Replace with your code + + try + { + javax.servlet.http.HttpSession session = + (javax.servlet.http.HttpSession) getExternalContext().getSession(true); + session.invalidate(); + } + catch(Exception ex){} + + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) {} + //return "login"; + return null; + } + + public String lnkDataAcidente_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableActivosRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormHS"); + return "analise_acidente"; + } + + public String lnkNr_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableActivosRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormHS"); + return "analise_acidente"; + } + + public String lnkNomeAcidentado_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableActivosRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormHS"); + return "analise_acidente"; + } + + private AnaliseAcidente getTableActivosRowData() + { + RowKey rk = tableRowGroup1.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + AnalisesActualDataProvider provider = (AnalisesActualDataProvider) tableRowGroup1.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + AnaliseAcidente a = (AnaliseAcidente)list.get(k); + return a; + } + + public String lnkDataAcidenteSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormHS"); + return "view_analise"; + } + + public String lnkNrSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormHS"); + return "view_analise"; + } + + public String lnkNomeAcidentadoSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormHS"); + return "view_analise"; + } + + private AnaliseAcidente getTableSeguimentoRowData() + { + RowKey rk = tableRowGroup2.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + AnalisesSeguimentoDataProvider provider = (AnalisesSeguimentoDataProvider) tableRowGroup2.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + AnaliseAcidente a = (AnaliseAcidente)list.get(k); + return a; + } + + private AnaliseAcidente getTableConcluidasRowData() + { + RowKey rk = tableRowGroup3.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + AnalisesConcluidasDataProvider provider = (AnalisesConcluidasDataProvider) tableRowGroup3.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + AnaliseAcidente a = (AnaliseAcidente)list.get(k); + return a; + } + + public void drpAno_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + Object ano = event.getNewValue(); + if(ano == null) + { + lblMes.setVisible(false); + drpMes.setVisible(false); + lblDia.setVisible(false); + drpDia.setVisible(false); + } + else + { + lblMes.setVisible(true); + drpMes.setVisible(true); + fillMesDropDown(); + } + } + + public void drpMes_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + Object mes = event.getNewValue(); + if(mes == null) + { + lblDia.setVisible(false); + drpDia.setVisible(false); + } + else + { + lblDia.setVisible(true); + drpDia.setVisible(true); + //fillDiaDropDown(); + } + } + + public void drpDia_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + + } + + public String butPesquisar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + Object obAno = null; + Object obMes = null; + Object obDia = null; + try + { + obAno = drpAno.getSelected(); + obMes = drpMes.getSelected(); + obDia = drpDia.getSelected(); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + Integer ano = null; + Integer mes = null; + Integer dia = null; + + if(obAno != null) + { + ano = (Integer) obAno; + } + + if(obMes != null) + { + mes = (Integer) obMes; + } + + if(obDia != null) + { + dia = (Integer) obDia; + } + + String por = null; + if(txtPor.getText() != null) + { + por = (String) txtPor.getText(); + if(por.trim().length() == 0) + { + por = null; + } + } + + String nome = null; + if(txtNome.getText() != null) + { + nome = (String) txtNome.getText(); + if(nome.trim().length() == 0) + { + nome = null; + } + } + + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + + //getSessionBean1().getAnalisesConcluidasDataProvider().setList(new ArrayList()); + ArrayList concluidasList = adp.searchAanalisesConcluidasList(getSessionBean1().getCurrentUser().getEstabelecimento_id(), ano, mes, dia, por, nome); + + table3.setRendered(true); + txtSearchMsg.setRendered(false); + getSessionBean1().getAnalisesConcluidasDataProvider().setList(concluidasList); + + + } + catch(Exception ex) + { + table3.setRendered(false); + txtSearchMsg.setRendered(true); + txtSearchMsg.setText("Não foram encontrados registos para a sua pesquisa !"); + //ex.printStackTrace(); + } + + return null; + } + +// private String getPageFrom(String referer) +// { +// String pageFrom = referer.substring(referer.lastIndexOf("/")+1); +// return pageFrom; +// } + + private void fillAnoDropDown() + { +// ArrayList anosList = new ArrayList(); +// for(int ano=2007; ano<2051; ano++) +// { +// anosList.add(new Integer(ano)); +// } + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + ArrayList anosList = adp.getAnosListFromAnalises(); + com.sun.rave.web.ui.model.Option[] anoOptions = new com.sun.rave.web.ui.model.Option[anosList.size()+1]; + anoOptions[0] = new Option("", ""); + ListIterator iter = anosList.listIterator(); + int i = 1; + while(iter.hasNext()) + { + Integer ano = (Integer) iter.next(); + + anoOptions[i] = new Option(ano, ano.toString()); + i++; + } + getSessionBean1().setAnoOptions(anoOptions); + Calendar cal = new GregorianCalendar(); + int year = cal.get(Calendar.YEAR); + //drpAno.setSelected( new Integer(year) ); + + } + catch(Exception ex) + { + //ex.printStackTrace(); + } + + } + + + private void fillMesDropDown() + { + com.sun.rave.web.ui.model.Option[] mesOptions = new com.sun.rave.web.ui.model.Option[13]; + mesOptions[0] = new Option("", ""); + mesOptions[1] = new Option(new Integer(1), "Janeiro"); + mesOptions[2] = new Option(new Integer(2), "Fevereiro"); + mesOptions[3] = new Option(new Integer(3), "Março"); + mesOptions[4] = new Option(new Integer(4), "Abril"); + mesOptions[5] = new Option(new Integer(5), "Maio"); + mesOptions[6] = new Option(new Integer(6), "Junho"); + mesOptions[7] = new Option(new Integer(7), "Julho"); + mesOptions[8] = new Option(new Integer(8), "Agosto"); + mesOptions[9] = new Option(new Integer(9), "Setembro"); + mesOptions[10] = new Option(new Integer(10), "Outubro"); + mesOptions[11] = new Option(new Integer(11), "Novembro"); + mesOptions[12] = new Option(new Integer(12), "Dezembro"); + getSessionBean1().setMesOptions(mesOptions); + Calendar cal = new GregorianCalendar(); + int month = cal.get(Calendar.MONTH); // 0=Jan, 1=Feb, ... + //drpMes.setSelected( new Integer(month+1) ); + } + + private void fillDiaDropDown() + { +// int ano = ( (Integer)drpAno.getSelected() ).intValue(); +// int mes = ( (Integer)drpMes.getSelected() ).intValue(); +// int dias = 0; +// switch (mes) { +// case 1: dias=31; break; +// case 2: +// GregorianCalendar cal = new GregorianCalendar(); +// if(cal.isLeapYear(ano)) +// { +// dias = 29; +// } +// else +// { +// dias = 28; +// } +// break; +// case 3: dias=31; break; +// case 4: dias=30; break; +// case 5: dias=31; break; +// case 6: dias=30; break; +// case 7: dias=31; break; +// case 8: dias=31; break; +// case 9: dias=30; break; +// case 10: dias=31; break; +// case 11: dias=30; break; +// case 12: dias=31; break; +// default: System.out.println("Invalid month.");break; +// } +// +// ArrayList diasList = new ArrayList(); +// for(int dia=1; diaAutomatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.
+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridBase1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridBase1() { + return gridBase1; + } + + public void setGridBase1(HtmlPanelGrid hpg) { + this.gridBase1 = hpg; + } + + private HtmlPanelGrid gridLayout1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayout1() { + return gridLayout1; + } + + public void setGridLayout1(HtmlPanelGrid hpg) { + this.gridLayout1 = hpg; + } + + private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel1() { + return gridPanel1; + } + + public void setGridPanel1(HtmlPanelGrid hpg) { + this.gridPanel1 = hpg; + } + + private PanelGroup groupPanel1 = new PanelGroup(); + + public PanelGroup getGroupPanel1() { + return groupPanel1; + } + + public void setGroupPanel1(PanelGroup pg) { + this.groupPanel1 = pg; + } + + private ImageComponent image1 = new ImageComponent(); + + public ImageComponent getImage1() { + return image1; + } + + public void setImage1(ImageComponent ic) { + this.image1 = ic; + } + + private ImageComponent image2 = new ImageComponent(); + + public ImageComponent getImage2() { + return image2; + } + + public void setImage2(ImageComponent ic) { + this.image2 = ic; + } + + private PanelGroup groupPanel2 = new PanelGroup(); + + public PanelGroup getGroupPanel2() { + return groupPanel2; + } + + public void setGroupPanel2(PanelGroup pg) { + this.groupPanel2 = pg; + } + + private StaticText lblUser = new StaticText(); + + public StaticText getLblUser() { + return lblUser; + } + + public void setLblUser(StaticText st) { + this.lblUser = st; + } + + private StaticText staticText1 = new StaticText(); + + public StaticText getStaticText1() { + return staticText1; + } + + public void setStaticText1(StaticText st) { + this.staticText1 = st; + } + + private Hyperlink lnkEditUser = new Hyperlink(); + + public Hyperlink getLnkEditUser() { + return lnkEditUser; + } + + public void setLnkEditUser(Hyperlink h) { + this.lnkEditUser = h; + } + + private StaticText staticText2 = new StaticText(); + + public StaticText getStaticText2() { + return staticText2; + } + + public void setStaticText2(StaticText st) { + this.staticText2 = st; + } + + private Hyperlink lnkLogout = new Hyperlink(); + + public Hyperlink getLnkLogout() { + return lnkLogout; + } + + public void setLnkLogout(Hyperlink h) { + this.lnkLogout = h; + } + + private HtmlPanelGrid gridLayoutTop1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayoutTop1() { + return gridLayoutTop1; + } + + public void setGridLayoutTop1(HtmlPanelGrid hpg) { + this.gridLayoutTop1 = hpg; + } + + private HtmlPanelGrid gridActual = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridActual() { + return gridActual; + } + + public void setGridActual(HtmlPanelGrid hpg) { + this.gridActual = hpg; + } + + private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel2() { + return gridPanel2; + } + + public void setGridPanel2(HtmlPanelGrid hpg) { + this.gridPanel2 = hpg; + } + + private StaticText staticText4 = new StaticText(); + + public StaticText getStaticText4() { + return staticText4; + } + + public void setStaticText4(StaticText st) { + this.staticText4 = st; + } + + private StaticText staticText5 = new StaticText(); + + public StaticText getStaticText5() { + return staticText5; + } + + public void setStaticText5(StaticText st) { + this.staticText5 = st; + } + + private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel3() { + return gridPanel3; + } + + public void setGridPanel3(HtmlPanelGrid hpg) { + this.gridPanel3 = hpg; + } + + private Table table1 = new Table(); + + public Table getTable1() { + return table1; + } + + public void setTable1(Table t) { + this.table1 = t; + } + + private TableRowGroup tableRowGroup1 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup1() { + return tableRowGroup1; + } + + public void setTableRowGroup1(TableRowGroup trg) { + this.tableRowGroup1 = trg; + } + + private TableColumn tableColumn1 = new TableColumn(); + + public TableColumn getTableColumn1() { + return tableColumn1; + } + + public void setTableColumn1(TableColumn tc) { + this.tableColumn1 = tc; + } + + private Hyperlink lnkDataAcidente = new Hyperlink(); + + public Hyperlink getLnkDataAcidente() { + return lnkDataAcidente; + } + + public void setLnkDataAcidente(Hyperlink h) { + this.lnkDataAcidente = h; + } + + private TableColumn tableColumn2 = new TableColumn(); + + public TableColumn getTableColumn2() { + return tableColumn2; + } + + public void setTableColumn2(TableColumn tc) { + this.tableColumn2 = tc; + } + + private Hyperlink lnkNr = new Hyperlink(); + + public Hyperlink getLnkNr() { + return lnkNr; + } + + public void setLnkNr(Hyperlink h) { + this.lnkNr = h; + } + + private TableColumn tableColumn3 = new TableColumn(); + + public TableColumn getTableColumn3() { + return tableColumn3; + } + + public void setTableColumn3(TableColumn tc) { + this.tableColumn3 = tc; + } + + private Hyperlink lnkNomeAcidentado = new Hyperlink(); + + public Hyperlink getLnkNomeAcidentado() { + return lnkNomeAcidentado; + } + + public void setLnkNomeAcidentado(Hyperlink h) { + this.lnkNomeAcidentado = h; + } + + private HtmlPanelGrid gridSeguimento = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridSeguimento() { + return gridSeguimento; + } + + public void setGridSeguimento(HtmlPanelGrid hpg) { + this.gridSeguimento = hpg; + } + + private HtmlPanelGrid gridPanel4 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel4() { + return gridPanel4; + } + + public void setGridPanel4(HtmlPanelGrid hpg) { + this.gridPanel4 = hpg; + } + + private StaticText staticText6 = new StaticText(); + + public StaticText getStaticText6() { + return staticText6; + } + + public void setStaticText6(StaticText st) { + this.staticText6 = st; + } + + private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel5() { + return gridPanel5; + } + + public void setGridPanel5(HtmlPanelGrid hpg) { + this.gridPanel5 = hpg; + } + + private Table table2 = new Table(); + + public Table getTable2() { + return table2; + } + + public void setTable2(Table t) { + this.table2 = t; + } + + private TableRowGroup tableRowGroup2 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup2() { + return tableRowGroup2; + } + + public void setTableRowGroup2(TableRowGroup trg) { + this.tableRowGroup2 = trg; + } + + private TableColumn tableColumn4 = new TableColumn(); + + public TableColumn getTableColumn4() { + return tableColumn4; + } + + public void setTableColumn4(TableColumn tc) { + this.tableColumn4 = tc; + } + + private Hyperlink lnkDataAcidenteSeg = new Hyperlink(); + + public Hyperlink getLnkDataAcidenteSeg() { + return lnkDataAcidenteSeg; + } + + public void setLnkDataAcidenteSeg(Hyperlink h) { + this.lnkDataAcidenteSeg = h; + } + + private TableColumn tableColumn5 = new TableColumn(); + + public TableColumn getTableColumn5() { + return tableColumn5; + } + + public void setTableColumn5(TableColumn tc) { + this.tableColumn5 = tc; + } + + private Hyperlink lnkNrSeg = new Hyperlink(); + + public Hyperlink getLnkNrSeg() { + return lnkNrSeg; + } + + public void setLnkNrSeg(Hyperlink h) { + this.lnkNrSeg = h; + } + + private TableColumn tableColumn6 = new TableColumn(); + + public TableColumn getTableColumn6() { + return tableColumn6; + } + + public void setTableColumn6(TableColumn tc) { + this.tableColumn6 = tc; + } + + private Hyperlink lnkNomeAcidentadoSeg = new Hyperlink(); + + public Hyperlink getLnkNomeAcidentadoSeg() { + return lnkNomeAcidentadoSeg; + } + + public void setLnkNomeAcidentadoSeg(Hyperlink h) { + this.lnkNomeAcidentadoSeg = h; + } + + private HtmlPanelGrid gridConcluidos = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridConcluidos() { + return gridConcluidos; + } + + public void setGridConcluidos(HtmlPanelGrid hpg) { + this.gridConcluidos = hpg; + } + + private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel6() { + return gridPanel6; + } + + public void setGridPanel6(HtmlPanelGrid hpg) { + this.gridPanel6 = hpg; + } + + private StaticText staticText7 = new StaticText(); + + public StaticText getStaticText7() { + return staticText7; + } + + public void setStaticText7(StaticText st) { + this.staticText7 = st; + } + + private HtmlPanelGrid gridPanel7 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel7() { + return gridPanel7; + } + + public void setGridPanel7(HtmlPanelGrid hpg) { + this.gridPanel7 = hpg; + } + + private PanelGroup groupPanel3 = new PanelGroup(); + + public PanelGroup getGroupPanel3() { + return groupPanel3; + } + + public void setGroupPanel3(PanelGroup pg) { + this.groupPanel3 = pg; + } + + private StaticText staticText8 = new StaticText(); + + public StaticText getStaticText8() { + return staticText8; + } + + public void setStaticText8(StaticText st) { + this.staticText8 = st; + } + + private DropDown drpAno = new DropDown(); + + public DropDown getDrpAno() { + return drpAno; + } + + public void setDrpAno(DropDown dd) { + this.drpAno = dd; + } + + private PanelGroup groupPanel4 = new PanelGroup(); + + public PanelGroup getGroupPanel4() { + return groupPanel4; + } + + public void setGroupPanel4(PanelGroup pg) { + this.groupPanel4 = pg; + } + + private StaticText lblMes = new StaticText(); + + public StaticText getLblMes() { + return lblMes; + } + + public void setLblMes(StaticText st) { + this.lblMes = st; + } + + private DropDown drpMes = new DropDown(); + + public DropDown getDrpMes() { + return drpMes; + } + + public void setDrpMes(DropDown dd) { + this.drpMes = dd; + } + + private PanelGroup groupPanel5 = new PanelGroup(); + + public PanelGroup getGroupPanel5() { + return groupPanel5; + } + + public void setGroupPanel5(PanelGroup pg) { + this.groupPanel5 = pg; + } + + private StaticText lblDia = new StaticText(); + + public StaticText getLblDia() { + return lblDia; + } + + public void setLblDia(StaticText st) { + this.lblDia = st; + } + + private DropDown drpDia = new DropDown(); + + public DropDown getDrpDia() { + return drpDia; + } + + public void setDrpDia(DropDown dd) { + this.drpDia = dd; + } + + private PanelGroup groupPanel6 = new PanelGroup(); + + public PanelGroup getGroupPanel6() { + return groupPanel6; + } + + public void setGroupPanel6(PanelGroup pg) { + this.groupPanel6 = pg; + } + + private StaticText staticText9 = new StaticText(); + + public StaticText getStaticText9() { + return staticText9; + } + + public void setStaticText9(StaticText st) { + this.staticText9 = st; + } + + private TextField txtNome = new TextField(); + + public TextField getTxtNome() { + return txtNome; + } + + public void setTxtNome(TextField tf) { + this.txtNome = tf; + } + + private Button butPesquisar = new Button(); + + public Button getButPesquisar() { + return butPesquisar; + } + + public void setButPesquisar(Button b) { + this.butPesquisar = b; + } + + private HtmlPanelGrid gridPanel8 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel8() { + return gridPanel8; + } + + public void setGridPanel8(HtmlPanelGrid hpg) { + this.gridPanel8 = hpg; + } + + private Table table3 = new Table(); + + public Table getTable3() { + return table3; + } + + public void setTable3(Table t) { + this.table3 = t; + } + + private TableRowGroup tableRowGroup3 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup3() { + return tableRowGroup3; + } + + public void setTableRowGroup3(TableRowGroup trg) { + this.tableRowGroup3 = trg; + } + + private TableColumn tableColumn7 = new TableColumn(); + + public TableColumn getTableColumn7() { + return tableColumn7; + } + + public void setTableColumn7(TableColumn tc) { + this.tableColumn7 = tc; + } + + private Hyperlink lnkDataConcluida = new Hyperlink(); + + public Hyperlink getLnkDataConcluida() { + return lnkDataConcluida; + } + + public void setLnkDataConcluida(Hyperlink h) { + this.lnkDataConcluida = h; + } + + private TableColumn tableColumn8 = new TableColumn(); + + public TableColumn getTableColumn8() { + return tableColumn8; + } + + public void setTableColumn8(TableColumn tc) { + this.tableColumn8 = tc; + } + + private Hyperlink lnkNrConcluida = new Hyperlink(); + + public Hyperlink getLnkNrConcluida() { + return lnkNrConcluida; + } + + public void setLnkNrConcluida(Hyperlink h) { + this.lnkNrConcluida = h; + } + + private TableColumn tableColumn9 = new TableColumn(); + + public TableColumn getTableColumn9() { + return tableColumn9; + } + + public void setTableColumn9(TableColumn tc) { + this.tableColumn9 = tc; + } + + private Hyperlink lnkNomeConcluida = new Hyperlink(); + + public Hyperlink getLnkNomeConcluida() { + return lnkNomeConcluida; + } + + public void setLnkNomeConcluida(Hyperlink h) { + this.lnkNomeConcluida = h; + } + + private StaticText txtSearchMsg = new StaticText(); + + public StaticText getTxtSearchMsg() { + return txtSearchMsg; + } + + public void setTxtSearchMsg(StaticText st) { + this.txtSearchMsg = st; + } + + private TableColumn tableColumn10 = new TableColumn(); + + public TableColumn getTableColumn10() { + return tableColumn10; + } + + public void setTableColumn10(TableColumn tc) { + this.tableColumn10 = tc; + } + + private Hyperlink lnkFase = new Hyperlink(); + + public Hyperlink getLnkFase() { + return lnkFase; + } + + public void setLnkFase(Hyperlink h) { + this.lnkFase = h; + } + + private TableColumn tableColumn11 = new TableColumn(); + + public TableColumn getTableColumn11() { + return tableColumn11; + } + + public void setTableColumn11(TableColumn tc) { + this.tableColumn11 = tc; + } + + private Hyperlink lnkFaseSeg = new Hyperlink(); + + public Hyperlink getLnkFaseSeg() { + return lnkFaseSeg; + } + + public void setLnkFaseSeg(Hyperlink h) { + this.lnkFaseSeg = h; + } + + private TableColumn tableColumn12 = new TableColumn(); + + public TableColumn getTableColumn12() { + return tableColumn12; + } + + public void setTableColumn12(TableColumn tc) { + this.tableColumn12 = tc; + } + + private TableColumn tableColumn13 = new TableColumn(); + + public TableColumn getTableColumn13() { + return tableColumn13; + } + + public void setTableColumn13(TableColumn tc) { + this.tableColumn13 = tc; + } + + private TableColumn tableColumn14 = new TableColumn(); + + public TableColumn getTableColumn14() { + return tableColumn14; + } + + public void setTableColumn14(TableColumn tc) { + this.tableColumn14 = tc; + } + + private TableColumn tableColumn15 = new TableColumn(); + + public TableColumn getTableColumn15() { + return tableColumn15; + } + + public void setTableColumn15(TableColumn tc) { + this.tableColumn15 = tc; + } + + private Hyperlink lnkPor = new Hyperlink(); + + public Hyperlink getLnkPor() { + return lnkPor; + } + + public void setLnkPor(Hyperlink h) { + this.lnkPor = h; + } + + private Hyperlink lnkPorSeg = new Hyperlink(); + + public Hyperlink getLnkPorSeg() { + return lnkPorSeg; + } + + public void setLnkPorSeg(Hyperlink h) { + this.lnkPorSeg = h; + } + + private Hyperlink lnkPorConcluida = new Hyperlink(); + + public Hyperlink getLnkPorConcluida() { + return lnkPorConcluida; + } + + public void setLnkPorConcluida(Hyperlink h) { + this.lnkPorConcluida = h; + } + + private Hyperlink lnkEstabConcluida = new Hyperlink(); + + public Hyperlink getLnkEstabConcluida() { + return lnkEstabConcluida; + } + + public void setLnkEstabConcluida(Hyperlink h) { + this.lnkEstabConcluida = h; + } + + private PanelGroup groupPanel7 = new PanelGroup(); + + public PanelGroup getGroupPanel7() { + return groupPanel7; + } + + public void setGroupPanel7(PanelGroup pg) { + this.groupPanel7 = pg; + } + + private StaticText staticText3 = new StaticText(); + + public StaticText getStaticText3() { + return staticText3; + } + + public void setStaticText3(StaticText st) { + this.staticText3 = st; + } + + private TextField txtPor = new TextField(); + + public TextField getTxtPor() { + return txtPor; + } + + public void setTxtPor(TextField tf) { + this.txtPor = tf; + } + + private HtmlPanelGrid gridPanel9 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel9() { + return gridPanel9; + } + + public void setGridPanel9(HtmlPanelGrid hpg) { + this.gridPanel9 = hpg; + } + + private PanelGroup groupPanel8 = new PanelGroup(); + + public PanelGroup getGroupPanel8() { + return groupPanel8; + } + + public void setGroupPanel8(PanelGroup pg) { + this.groupPanel8 = pg; + } + + private StaticText staticText10 = new StaticText(); + + public StaticText getStaticText10() { + return staticText10; + } + + public void setStaticText10(StaticText st) { + this.staticText10 = st; + } + + private ImageComponent image3 = new ImageComponent(); + + public ImageComponent getImage3() { + return image3; + } + + public void setImage3(ImageComponent ic) { + this.image3 = ic; + } + + private StaticText staticText11 = new StaticText(); + + public StaticText getStaticText11() { + return staticText11; + } + + public void setStaticText11(StaticText st) { + this.staticText11 = st; + } + + //Construct a new Page bean instance.
+ */ + public FormMedico() { + } + + /** + *Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.
+ * + *Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.
+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + //Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.
+ */ + public void preprocess() { + } + + /** + *Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.
+ */ + public void prerender() { + lblUser.setText( getSessionBean1().getCurrentUser().getLogin() ); + + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + //lblActivos.setRendered(true); + table1.setRendered(true); + + //ArrayList actuaisList = adp.getAnalisesActuaisList(getSessionBean1().getCurrentUser().getEstabelecimento_id(), new Integer(5)); +// ArrayList actuaisList = adp.getAnalisesActuaisMedicoList( getSessionBean1().getCurrentUser().getEstabelecimento_id() ); +// getSessionBean1().getAnalisesActualDataProvider().setList(actuaisList); + } + catch(Exception ex) + { + //lblActivos.setRendered(false); + table1.setRendered(false); + ex.printStackTrace(); + } + + table2.setRendered(false); + + try + { + //lblActivos.setRendered(true); + table2.setRendered(true); + + ArrayList seguimentoList = adp.getAnalisesSeguimentoMedList(getSessionBean1().getCurrentUser().getEstabelecimento_id()); + getSessionBean1().getAnalisesSeguimentoDataProvider().setList(seguimentoList); + } + catch(Exception ex) + { + //lblActivos.setRendered(false); + table2.setRendered(false); + ex.printStackTrace(); + } + + HttpServletRequest request = (HttpServletRequest) getExternalContext().getRequest(); + String referer = request.getRequestURI(); + String pageFrom = Utils.getPageFrom(referer); + if(!pageFrom.matches("FormMedico.jsp")) + { + + try + { + //lblActivos.setRendered(true); + table3.setRendered(true); + + ArrayList concluidasList = adp.getAnalisesConcluidasList(getSessionBean1().getCurrentUser().getEstabelecimento_id()); + getSessionBean1().getAnalisesConcluidasDataProvider().setList(concluidasList); + } + catch(Exception ex) + { + //lblActivos.setRendered(false); + table3.setRendered(false); + ex.printStackTrace(); + } + fillAnoDropDown(); + } + } + + /** + *Callback method that is called after rendering is completed for
+ * this request, if init() was called (regardless of whether
+ * or not this was the page that was actually rendered). Customize this
+ * method to release resources acquired in the init(),
+ * preprocess(), or prerender() methods (or
+ * acquired during execution of an event handler).
Return a reference to the scoped data bean.
+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + public String lnkEditUser_action() { + // TODO: Replace with your code + + getSessionBean1().setNavFrom("FormMedico"); + getSessionBean1().setModoEdicaoUtilizador("edit"); + return "user"; + } + + public String lnkLogout_action() { + // TODO: Replace with your code + + try + { + javax.servlet.http.HttpSession session = + (javax.servlet.http.HttpSession) getExternalContext().getSession(true); + session.invalidate(); + } + catch(Exception ex){} + + return "login"; + } + + public String lnkDataAcidente_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableActivosRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormMedico"); + return "analise_acidente"; + } + + public String lnkNr_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableActivosRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormMedico"); + return "analise_acidente"; + } + + public String lnkNomeAcidentado_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableActivosRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormMedico"); + return "analise_acidente"; + } + + private AnaliseAcidente getTableActivosRowData() + { + RowKey rk = tableRowGroup1.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + AnalisesActualDataProvider provider = (AnalisesActualDataProvider) tableRowGroup1.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + AnaliseAcidente a = (AnaliseAcidente)list.get(k); + return a; + } + + private AnaliseAcidente getTableConcluidasRowData() + { + RowKey rk = tableRowGroup3.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + AnalisesConcluidasDataProvider provider = (AnalisesConcluidasDataProvider) tableRowGroup3.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + AnaliseAcidente a = (AnaliseAcidente)list.get(k); + return a; + } + + public String lnkDataAcidenteSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormMedico"); + return "view_analise"; + } + + public String lnkNrSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormMedico"); + return "view_analise"; + } + + public String lnkNomeAcidentadoSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormMedico"); + return "view_analise"; + } + + private AnaliseAcidente getTableSeguimentoRowData() + { + RowKey rk = tableRowGroup2.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + AnalisesSeguimentoDataProvider provider = (AnalisesSeguimentoDataProvider) tableRowGroup2.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + AnaliseAcidente a = (AnaliseAcidente)list.get(k); + return a; + } + + public void drpAno_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + Object ano = event.getNewValue(); + if(ano == null) + { + lblMes.setVisible(false); + drpMes.setVisible(false); + lblDia.setVisible(false); + drpDia.setVisible(false); + } + else + { + lblMes.setVisible(true); + drpMes.setVisible(true); + fillMesDropDown(); + } + } + + public void drpMes_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + Object mes = event.getNewValue(); + if(mes == null) + { + lblDia.setVisible(false); + drpDia.setVisible(false); + } + else + { + lblDia.setVisible(true); + drpDia.setVisible(true); + fillDiaDropDown(); + } + } + + public void drpDia_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + + } + + public String butPesquisar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + Object obAno = null; + Object obMes = null; + Object obDia = null; + try + { + obAno = drpAno.getSelected(); + obMes = drpMes.getSelected(); + obDia = drpDia.getSelected(); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + Integer ano = null; + Integer mes = null; + Integer dia = null; + + if(obAno != null) + { + ano = (Integer) obAno; + } + + if(obMes != null) + { + mes = (Integer) obMes; + } + + if(obDia != null) + { + dia = (Integer) obDia; + } + + String por = null; + if(txtPor.getText() != null) + { + por = (String) txtPor.getText(); + if(por.trim().length() == 0) + { + por = null; + } + } + + String nome = null; + if(txtNome.getText() != null) + { + nome = (String) txtNome.getText(); + if(nome.trim().length() == 0) + { + nome = null; + } + } + + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + + //getSessionBean1().getAnalisesConcluidasDataProvider().setList(new ArrayList()); + ArrayList concluidasList = adp.searchAanalisesConcluidasList(getSessionBean1().getCurrentUser().getEstabelecimento_id(), ano, mes, dia, por, nome); + + table3.setRendered(true); + txtSearchMsg.setRendered(false); + getSessionBean1().getAnalisesConcluidasDataProvider().setList(concluidasList); + + + } + catch(Exception ex) + { + table3.setRendered(false); + txtSearchMsg.setRendered(true); + txtSearchMsg.setText("Não foram encontrados registos para a sua pesquisa !"); + ex.printStackTrace(); + } + return null; + } + + private void fillAnoDropDown() + { +// ArrayList anosList = new ArrayList(); +// for(int ano=2007; ano<2051; ano++) +// { +// anosList.add(new Integer(ano)); +// } + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + ArrayList anosList = adp.getAnosListFromAnalises(); + com.sun.rave.web.ui.model.Option[] anoOptions = new com.sun.rave.web.ui.model.Option[anosList.size()+1]; + anoOptions[0] = new Option("", ""); + ListIterator iter = anosList.listIterator(); + int i = 1; + while(iter.hasNext()) + { + Integer ano = (Integer) iter.next(); + + anoOptions[i] = new Option(ano, ano.toString()); + i++; + } + getSessionBean1().setAnoOptions(anoOptions); + Calendar cal = new GregorianCalendar(); + int year = cal.get(Calendar.YEAR); + //drpAno.setSelected( new Integer(year) ); + + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + } + + + private void fillMesDropDown() + { + com.sun.rave.web.ui.model.Option[] mesOptions = new com.sun.rave.web.ui.model.Option[13]; + mesOptions[0] = new Option("", ""); + mesOptions[1] = new Option(new Integer(1), "Janeiro"); + mesOptions[2] = new Option(new Integer(2), "Fevereiro"); + mesOptions[3] = new Option(new Integer(3), "Março"); + mesOptions[4] = new Option(new Integer(4), "Abril"); + mesOptions[5] = new Option(new Integer(5), "Maio"); + mesOptions[6] = new Option(new Integer(6), "Junho"); + mesOptions[7] = new Option(new Integer(7), "Julho"); + mesOptions[8] = new Option(new Integer(8), "Agosto"); + mesOptions[9] = new Option(new Integer(9), "Setembro"); + mesOptions[10] = new Option(new Integer(10), "Outubro"); + mesOptions[11] = new Option(new Integer(11), "Novembro"); + mesOptions[12] = new Option(new Integer(12), "Dezembro"); + getSessionBean1().setMesOptions(mesOptions); + Calendar cal = new GregorianCalendar(); + int month = cal.get(Calendar.MONTH); // 0=Jan, 1=Feb, ... + //drpMes.setSelected( new Integer(month+1) ); + } + + private void fillDiaDropDown() + { + + } + + public String lnkDataConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormMedico"); + return "view_analise"; + } + + public String lnkNrConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormMedico"); + return "view_analise"; + } + + public String lnkNomeConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormMedico"); + return "view_analise"; + } + + public String lnkFase_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableActivosRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormMedico"); + return "analise_acidente"; + } + + public String lnkFaseSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormMedico"); + return "view_analise"; + } + + public String lnkPor_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableActivosRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormMedico"); + return "analise_acidente"; + } + + public String lnkPorSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormMedico"); + return "view_analise"; + } + + public String lnkPorConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormMedico"); + return "view_analise"; + } + + public String lnkEstabConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormMedico"); + return "view_analise"; + } + +} + diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormRH.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormRH.java new file mode 100644 index 00000000..0d2dfd5d --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormRH.java @@ -0,0 +1,1628 @@ +/* + * FormRH.java + * + * Created on October 1, 2007, 11:43 AM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.data.provider.RowKey; +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.rave.web.ui.component.Body; +import com.sun.rave.web.ui.component.Button; +import com.sun.rave.web.ui.component.DropDown; +import com.sun.rave.web.ui.component.Form; +import com.sun.rave.web.ui.component.Head; +import com.sun.rave.web.ui.component.Html; +import com.sun.rave.web.ui.component.Hyperlink; +import com.sun.rave.web.ui.component.ImageComponent; +import com.sun.rave.web.ui.component.Link; +import com.sun.rave.web.ui.component.Page; +import com.sun.rave.web.ui.component.PanelGroup; +import com.sun.rave.web.ui.component.StaticText; +import com.sun.rave.web.ui.component.Table; +import com.sun.rave.web.ui.component.TableColumn; +import com.sun.rave.web.ui.component.TableRowGroup; +import com.sun.rave.web.ui.component.TextField; +import com.sun.rave.web.ui.model.Option; +import db.AnalisesActualDataProvider; +import db.AnalisesConcluidasDataProvider; +import db.AnalisesDataProvider; +import db.AnalisesSeguimentoDataProvider; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.ListIterator; +import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; +import javax.faces.event.ValueChangeEvent; +import javax.servlet.http.HttpServletRequest; +import utils.Utils; + +/** + *Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.
+ */ +public class FormRH extends AbstractPageBean { + //Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.
+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridBase1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridBase1() { + return gridBase1; + } + + public void setGridBase1(HtmlPanelGrid hpg) { + this.gridBase1 = hpg; + } + + private HtmlPanelGrid gridLayout1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayout1() { + return gridLayout1; + } + + public void setGridLayout1(HtmlPanelGrid hpg) { + this.gridLayout1 = hpg; + } + + private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel1() { + return gridPanel1; + } + + public void setGridPanel1(HtmlPanelGrid hpg) { + this.gridPanel1 = hpg; + } + + private PanelGroup groupPanel1 = new PanelGroup(); + + public PanelGroup getGroupPanel1() { + return groupPanel1; + } + + public void setGroupPanel1(PanelGroup pg) { + this.groupPanel1 = pg; + } + + private ImageComponent image1 = new ImageComponent(); + + public ImageComponent getImage1() { + return image1; + } + + public void setImage1(ImageComponent ic) { + this.image1 = ic; + } + + private ImageComponent image2 = new ImageComponent(); + + public ImageComponent getImage2() { + return image2; + } + + public void setImage2(ImageComponent ic) { + this.image2 = ic; + } + + private PanelGroup groupPanel2 = new PanelGroup(); + + public PanelGroup getGroupPanel2() { + return groupPanel2; + } + + public void setGroupPanel2(PanelGroup pg) { + this.groupPanel2 = pg; + } + + private StaticText lblUser = new StaticText(); + + public StaticText getLblUser() { + return lblUser; + } + + public void setLblUser(StaticText st) { + this.lblUser = st; + } + + private Hyperlink lnkEditUser = new Hyperlink(); + + public Hyperlink getLnkEditUser() { + return lnkEditUser; + } + + public void setLnkEditUser(Hyperlink h) { + this.lnkEditUser = h; + } + + private StaticText staticText2 = new StaticText(); + + public StaticText getStaticText2() { + return staticText2; + } + + public void setStaticText2(StaticText st) { + this.staticText2 = st; + } + + private Hyperlink lnkLogout = new Hyperlink(); + + public Hyperlink getLnkLogout() { + return lnkLogout; + } + + public void setLnkLogout(Hyperlink h) { + this.lnkLogout = h; + } + + private HtmlPanelGrid gridLayoutTop1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayoutTop1() { + return gridLayoutTop1; + } + + public void setGridLayoutTop1(HtmlPanelGrid hpg) { + this.gridLayoutTop1 = hpg; + } + + private HtmlPanelGrid gridActual1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridActual1() { + return gridActual1; + } + + public void setGridActual1(HtmlPanelGrid hpg) { + this.gridActual1 = hpg; + } + + private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel2() { + return gridPanel2; + } + + public void setGridPanel2(HtmlPanelGrid hpg) { + this.gridPanel2 = hpg; + } + + private StaticText staticText4 = new StaticText(); + + public StaticText getStaticText4() { + return staticText4; + } + + public void setStaticText4(StaticText st) { + this.staticText4 = st; + } + + private StaticText staticText5 = new StaticText(); + + public StaticText getStaticText5() { + return staticText5; + } + + public void setStaticText5(StaticText st) { + this.staticText5 = st; + } + + private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel3() { + return gridPanel3; + } + + public void setGridPanel3(HtmlPanelGrid hpg) { + this.gridPanel3 = hpg; + } + + private Table table1 = new Table(); + + public Table getTable1() { + return table1; + } + + public void setTable1(Table t) { + this.table1 = t; + } + + private TableRowGroup tableRowGroup1 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup1() { + return tableRowGroup1; + } + + public void setTableRowGroup1(TableRowGroup trg) { + this.tableRowGroup1 = trg; + } + + private TableColumn tableColumn1 = new TableColumn(); + + public TableColumn getTableColumn1() { + return tableColumn1; + } + + public void setTableColumn1(TableColumn tc) { + this.tableColumn1 = tc; + } + + private Hyperlink lnkDataAcidente = new Hyperlink(); + + public Hyperlink getLnkDataAcidente() { + return lnkDataAcidente; + } + + public void setLnkDataAcidente(Hyperlink h) { + this.lnkDataAcidente = h; + } + + private TableColumn tableColumn2 = new TableColumn(); + + public TableColumn getTableColumn2() { + return tableColumn2; + } + + public void setTableColumn2(TableColumn tc) { + this.tableColumn2 = tc; + } + + private Hyperlink lnkNr = new Hyperlink(); + + public Hyperlink getLnkNr() { + return lnkNr; + } + + public void setLnkNr(Hyperlink h) { + this.lnkNr = h; + } + + private TableColumn tableColumn3 = new TableColumn(); + + public TableColumn getTableColumn3() { + return tableColumn3; + } + + public void setTableColumn3(TableColumn tc) { + this.tableColumn3 = tc; + } + + private Hyperlink lnkNomeAcidentado = new Hyperlink(); + + public Hyperlink getLnkNomeAcidentado() { + return lnkNomeAcidentado; + } + + public void setLnkNomeAcidentado(Hyperlink h) { + this.lnkNomeAcidentado = h; + } + + private HtmlPanelGrid gridSeguimento1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridSeguimento1() { + return gridSeguimento1; + } + + public void setGridSeguimento1(HtmlPanelGrid hpg) { + this.gridSeguimento1 = hpg; + } + + private HtmlPanelGrid gridPanel4 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel4() { + return gridPanel4; + } + + public void setGridPanel4(HtmlPanelGrid hpg) { + this.gridPanel4 = hpg; + } + + private StaticText staticText6 = new StaticText(); + + public StaticText getStaticText6() { + return staticText6; + } + + public void setStaticText6(StaticText st) { + this.staticText6 = st; + } + + private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel5() { + return gridPanel5; + } + + public void setGridPanel5(HtmlPanelGrid hpg) { + this.gridPanel5 = hpg; + } + + private Table table2 = new Table(); + + public Table getTable2() { + return table2; + } + + public void setTable2(Table t) { + this.table2 = t; + } + + private TableRowGroup tableRowGroup2 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup2() { + return tableRowGroup2; + } + + public void setTableRowGroup2(TableRowGroup trg) { + this.tableRowGroup2 = trg; + } + + private TableColumn tableColumn4 = new TableColumn(); + + public TableColumn getTableColumn4() { + return tableColumn4; + } + + public void setTableColumn4(TableColumn tc) { + this.tableColumn4 = tc; + } + + private Hyperlink lnkDataAcidenteSeg = new Hyperlink(); + + public Hyperlink getLnkDataAcidenteSeg() { + return lnkDataAcidenteSeg; + } + + public void setLnkDataAcidenteSeg(Hyperlink h) { + this.lnkDataAcidenteSeg = h; + } + + private TableColumn tableColumn5 = new TableColumn(); + + public TableColumn getTableColumn5() { + return tableColumn5; + } + + public void setTableColumn5(TableColumn tc) { + this.tableColumn5 = tc; + } + + private Hyperlink lnkNrSeg = new Hyperlink(); + + public Hyperlink getLnkNrSeg() { + return lnkNrSeg; + } + + public void setLnkNrSeg(Hyperlink h) { + this.lnkNrSeg = h; + } + + private TableColumn tableColumn6 = new TableColumn(); + + public TableColumn getTableColumn6() { + return tableColumn6; + } + + public void setTableColumn6(TableColumn tc) { + this.tableColumn6 = tc; + } + + private Hyperlink lnkNomeAcidentadoSeg = new Hyperlink(); + + public Hyperlink getLnkNomeAcidentadoSeg() { + return lnkNomeAcidentadoSeg; + } + + public void setLnkNomeAcidentadoSeg(Hyperlink h) { + this.lnkNomeAcidentadoSeg = h; + } + + private HtmlPanelGrid gridConcluidos1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridConcluidos1() { + return gridConcluidos1; + } + + public void setGridConcluidos1(HtmlPanelGrid hpg) { + this.gridConcluidos1 = hpg; + } + + private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel6() { + return gridPanel6; + } + + public void setGridPanel6(HtmlPanelGrid hpg) { + this.gridPanel6 = hpg; + } + + private StaticText staticText7 = new StaticText(); + + public StaticText getStaticText7() { + return staticText7; + } + + public void setStaticText7(StaticText st) { + this.staticText7 = st; + } + + private HtmlPanelGrid gridPanel7 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel7() { + return gridPanel7; + } + + public void setGridPanel7(HtmlPanelGrid hpg) { + this.gridPanel7 = hpg; + } + + private PanelGroup groupPanel3 = new PanelGroup(); + + public PanelGroup getGroupPanel3() { + return groupPanel3; + } + + public void setGroupPanel3(PanelGroup pg) { + this.groupPanel3 = pg; + } + + private StaticText staticText8 = new StaticText(); + + public StaticText getStaticText8() { + return staticText8; + } + + public void setStaticText8(StaticText st) { + this.staticText8 = st; + } + + private DropDown drpAno = new DropDown(); + + public DropDown getDrpAno() { + return drpAno; + } + + public void setDrpAno(DropDown dd) { + this.drpAno = dd; + } + + private PanelGroup groupPanel4 = new PanelGroup(); + + public PanelGroup getGroupPanel4() { + return groupPanel4; + } + + public void setGroupPanel4(PanelGroup pg) { + this.groupPanel4 = pg; + } + + private StaticText lblMes = new StaticText(); + + public StaticText getLblMes() { + return lblMes; + } + + public void setLblMes(StaticText st) { + this.lblMes = st; + } + + private DropDown drpMes = new DropDown(); + + public DropDown getDrpMes() { + return drpMes; + } + + public void setDrpMes(DropDown dd) { + this.drpMes = dd; + } + + private PanelGroup groupPanel5 = new PanelGroup(); + + public PanelGroup getGroupPanel5() { + return groupPanel5; + } + + public void setGroupPanel5(PanelGroup pg) { + this.groupPanel5 = pg; + } + + private StaticText lblDia = new StaticText(); + + public StaticText getLblDia() { + return lblDia; + } + + public void setLblDia(StaticText st) { + this.lblDia = st; + } + + private DropDown drpDia = new DropDown(); + + public DropDown getDrpDia() { + return drpDia; + } + + public void setDrpDia(DropDown dd) { + this.drpDia = dd; + } + + private PanelGroup groupPanel6 = new PanelGroup(); + + public PanelGroup getGroupPanel6() { + return groupPanel6; + } + + public void setGroupPanel6(PanelGroup pg) { + this.groupPanel6 = pg; + } + + private StaticText staticText9 = new StaticText(); + + public StaticText getStaticText9() { + return staticText9; + } + + public void setStaticText9(StaticText st) { + this.staticText9 = st; + } + + private TextField txtNome = new TextField(); + + public TextField getTxtNome() { + return txtNome; + } + + public void setTxtNome(TextField tf) { + this.txtNome = tf; + } + + private Button butPesquisar = new Button(); + + public Button getButPesquisar() { + return butPesquisar; + } + + public void setButPesquisar(Button b) { + this.butPesquisar = b; + } + + private HtmlPanelGrid gridPanel8 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel8() { + return gridPanel8; + } + + public void setGridPanel8(HtmlPanelGrid hpg) { + this.gridPanel8 = hpg; + } + + private Table table3 = new Table(); + + public Table getTable3() { + return table3; + } + + public void setTable3(Table t) { + this.table3 = t; + } + + private TableRowGroup tableRowGroup3 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup3() { + return tableRowGroup3; + } + + public void setTableRowGroup3(TableRowGroup trg) { + this.tableRowGroup3 = trg; + } + + private TableColumn tableColumn7 = new TableColumn(); + + public TableColumn getTableColumn7() { + return tableColumn7; + } + + public void setTableColumn7(TableColumn tc) { + this.tableColumn7 = tc; + } + + private Hyperlink lnkDataConcluida = new Hyperlink(); + + public Hyperlink getLnkDataConcluida() { + return lnkDataConcluida; + } + + public void setLnkDataConcluida(Hyperlink h) { + this.lnkDataConcluida = h; + } + + private TableColumn tableColumn8 = new TableColumn(); + + public TableColumn getTableColumn8() { + return tableColumn8; + } + + public void setTableColumn8(TableColumn tc) { + this.tableColumn8 = tc; + } + + private Hyperlink lnkNrConcluida = new Hyperlink(); + + public Hyperlink getLnkNrConcluida() { + return lnkNrConcluida; + } + + public void setLnkNrConcluida(Hyperlink h) { + this.lnkNrConcluida = h; + } + + private TableColumn tableColumn9 = new TableColumn(); + + public TableColumn getTableColumn9() { + return tableColumn9; + } + + public void setTableColumn9(TableColumn tc) { + this.tableColumn9 = tc; + } + + private Hyperlink lnkNomeConcluida = new Hyperlink(); + + public Hyperlink getLnkNomeConcluida() { + return lnkNomeConcluida; + } + + public void setLnkNomeConcluida(Hyperlink h) { + this.lnkNomeConcluida = h; + } + + private StaticText txtSearchMsg = new StaticText(); + + public StaticText getTxtSearchMsg() { + return txtSearchMsg; + } + + public void setTxtSearchMsg(StaticText st) { + this.txtSearchMsg = st; + } + + private TableColumn tableColumn10 = new TableColumn(); + + public TableColumn getTableColumn10() { + return tableColumn10; + } + + public void setTableColumn10(TableColumn tc) { + this.tableColumn10 = tc; + } + + private Hyperlink lnkFase = new Hyperlink(); + + public Hyperlink getLnkFase() { + return lnkFase; + } + + public void setLnkFase(Hyperlink h) { + this.lnkFase = h; + } + + private TableColumn tableColumn11 = new TableColumn(); + + public TableColumn getTableColumn11() { + return tableColumn11; + } + + public void setTableColumn11(TableColumn tc) { + this.tableColumn11 = tc; + } + + private Hyperlink lnkFaseSeg = new Hyperlink(); + + public Hyperlink getLnkFaseSeg() { + return lnkFaseSeg; + } + + public void setLnkFaseSeg(Hyperlink h) { + this.lnkFaseSeg = h; + } + + private TableColumn tableColumn12 = new TableColumn(); + + public TableColumn getTableColumn12() { + return tableColumn12; + } + + public void setTableColumn12(TableColumn tc) { + this.tableColumn12 = tc; + } + + private TableColumn tableColumn13 = new TableColumn(); + + public TableColumn getTableColumn13() { + return tableColumn13; + } + + public void setTableColumn13(TableColumn tc) { + this.tableColumn13 = tc; + } + + private TableColumn tableColumn14 = new TableColumn(); + + public TableColumn getTableColumn14() { + return tableColumn14; + } + + public void setTableColumn14(TableColumn tc) { + this.tableColumn14 = tc; + } + + private TableColumn tableColumn15 = new TableColumn(); + + public TableColumn getTableColumn15() { + return tableColumn15; + } + + public void setTableColumn15(TableColumn tc) { + this.tableColumn15 = tc; + } + + private Hyperlink lnkPor = new Hyperlink(); + + public Hyperlink getLnkPor() { + return lnkPor; + } + + public void setLnkPor(Hyperlink h) { + this.lnkPor = h; + } + + private Hyperlink lnkPorSeg = new Hyperlink(); + + public Hyperlink getLnkPorSeg() { + return lnkPorSeg; + } + + public void setLnkPorSeg(Hyperlink h) { + this.lnkPorSeg = h; + } + + private Hyperlink lnkPorConcluida = new Hyperlink(); + + public Hyperlink getLnkPorConcluida() { + return lnkPorConcluida; + } + + public void setLnkPorConcluida(Hyperlink h) { + this.lnkPorConcluida = h; + } + + private Hyperlink lnkEstabConcluida = new Hyperlink(); + + public Hyperlink getLnkEstabConcluida() { + return lnkEstabConcluida; + } + + public void setLnkEstabConcluida(Hyperlink h) { + this.lnkEstabConcluida = h; + } + + private PanelGroup groupPanel7 = new PanelGroup(); + + public PanelGroup getGroupPanel7() { + return groupPanel7; + } + + public void setGroupPanel7(PanelGroup pg) { + this.groupPanel7 = pg; + } + + private StaticText staticText3 = new StaticText(); + + public StaticText getStaticText3() { + return staticText3; + } + + public void setStaticText3(StaticText st) { + this.staticText3 = st; + } + + private TextField txtPor = new TextField(); + + public TextField getTxtPor() { + return txtPor; + } + + public void setTxtPor(TextField tf) { + this.txtPor = tf; + } + + private StaticText stSep1 = new StaticText(); + + public StaticText getStSep1() { + return stSep1; + } + + public void setStSep1(StaticText st) { + this.stSep1 = st; + } + + private HtmlPanelGrid gridPanel9 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel9() { + return gridPanel9; + } + + public void setGridPanel9(HtmlPanelGrid hpg) { + this.gridPanel9 = hpg; + } + + private PanelGroup groupPanel8 = new PanelGroup(); + + public PanelGroup getGroupPanel8() { + return groupPanel8; + } + + public void setGroupPanel8(PanelGroup pg) { + this.groupPanel8 = pg; + } + + private StaticText staticText1 = new StaticText(); + + public StaticText getStaticText1() { + return staticText1; + } + + public void setStaticText1(StaticText st) { + this.staticText1 = st; + } + + private ImageComponent image3 = new ImageComponent(); + + public ImageComponent getImage3() { + return image3; + } + + public void setImage3(ImageComponent ic) { + this.image3 = ic; + } + + private StaticText staticText10 = new StaticText(); + + public StaticText getStaticText10() { + return staticText10; + } + + public void setStaticText10(StaticText st) { + this.staticText10 = st; + } + + private Hyperlink lnkNewUser1 = new Hyperlink(); + + public Hyperlink getLnkNewUser1() { + return lnkNewUser1; + } + + public void setLnkNewUser1(Hyperlink h) { + this.lnkNewUser1 = h; + } + + private StaticText staticText11 = new StaticText(); + + public StaticText getStaticText11() { + return staticText11; + } + + public void setStaticText11(StaticText st) { + this.staticText11 = st; + } + + private StaticText staticText12 = new StaticText(); + + public StaticText getStaticText12() { + return staticText12; + } + + public void setStaticText12(StaticText st) { + this.staticText12 = st; + } + + private Hyperlink lnkAnalisesAcidente = new Hyperlink(); + + public Hyperlink getLnkAnalisesAcidente() { + return lnkAnalisesAcidente; + } + + public void setLnkAnalisesAcidente(Hyperlink h) { + this.lnkAnalisesAcidente = h; + } + + //Construct a new Page bean instance.
+ */ + public FormRH() { + } + + /** + *Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.
+ * + *Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.
+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + //Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.
+ */ + public void preprocess() { + } + + /** + *Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.
+ */ + public void prerender() { + lblUser.setText( getSessionBean1().getCurrentUser().getLogin() ); + + String responsavel_loja = getSessionBean1().getCurrentUser().getResponsavel_loja(); +// if(getSessionBean1().getCurrentUser().getTipo().intValue() == 7) // director rh +// { +// //////stSep.setText("|"); +// } +// else //rh +// { +// //////stSep.setText(" "); +// //////lnkNewUser.setRendered(false); +// stSep1.setRendered(false); +// } + + + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + //lblActivos.setRendered(true); + table1.setRendered(true); + + //ArrayList actuaisList = adp.getAnalisesActuaisList(getSessionBean1().getCurrentUser().getEstabelecimento_id()); + ArrayList actuaisList = adp.getAnalisesActuaisRhList(getSessionBean1().getCurrentUser().getEstabelecimento_id(), responsavel_loja); + getSessionBean1().getAnalisesActualDataProvider().setList(actuaisList); + } + catch(Exception ex) + { + //lblActivos.setRendered(false); + table1.setRendered(false); + //ex.printStackTrace(); + } + + try + { + //lblActivos.setRendered(true); + table2.setRendered(true); + + ArrayList seguimentoList = adp.getAnalisesSeguimentoRhList(getSessionBean1().getCurrentUser().getEstabelecimento_id(), responsavel_loja); + getSessionBean1().getAnalisesSeguimentoDataProvider().setList(seguimentoList); + } + catch(Exception ex) + { + //lblActivos.setRendered(false); + table2.setRendered(false); + //ex.printStackTrace(); + } + + HttpServletRequest request = (HttpServletRequest) getExternalContext().getRequest(); + String referer = request.getRequestURI(); + String pageFrom = Utils.getPageFrom(referer); + if(!pageFrom.matches("FormRH.jsp")) + { + + try + { + //lblActivos.setRendered(true); + table3.setRendered(true); + + ArrayList concluidasList = adp.getAnalisesConcluidasList(getSessionBean1().getCurrentUser().getEstabelecimento_id()); + getSessionBean1().getAnalisesConcluidasDataProvider().setList(concluidasList); + } + catch(Exception ex) + { + //lblActivos.setRendered(false); + table3.setRendered(false); + //ex.printStackTrace(); + } + fillAnoDropDown(); + } + } + + /** + *Callback method that is called after rendering is completed for
+ * this request, if init() was called (regardless of whether
+ * or not this was the page that was actually rendered). Customize this
+ * method to release resources acquired in the init(),
+ * preprocess(), or prerender() methods (or
+ * acquired during execution of an event handler).
Return a reference to the scoped data bean.
+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + public String lnkLogout_action() { + // TODO: Replace with your code + + try + { + javax.servlet.http.HttpSession session = + (javax.servlet.http.HttpSession) getExternalContext().getSession(true); + session.invalidate(); + } + catch(Exception ex){} + + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) {} + //return "login"; + return null; + } + + public String butNovaAnalise_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + return null; + } + + public String lnkDataAcidente_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableActivosRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormRH"); + return "analise_acidente"; + } + + public String lnkNr_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableActivosRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormRH"); + return "analise_acidente"; + } + + public String lnkNomeAcidentado_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableActivosRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormRH"); + return "analise_acidente"; + } + + private AnaliseAcidente getTableActivosRowData() + { + RowKey rk = tableRowGroup1.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + AnalisesActualDataProvider provider = (AnalisesActualDataProvider) tableRowGroup1.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + AnaliseAcidente a = (AnaliseAcidente)list.get(k); + return a; + } + + public String lnkDataAcidenteSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormRh"); + return "view_analise"; + } + + public String lnkNrSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormRh"); + return "view_analise"; + } + + + public String lnkNomeAcidentadoSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormRh"); + return "view_analise"; + } + + private AnaliseAcidente getTableSeguimentoRowData() + { + RowKey rk = tableRowGroup2.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + AnalisesSeguimentoDataProvider provider = (AnalisesSeguimentoDataProvider) tableRowGroup2.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + AnaliseAcidente a = (AnaliseAcidente)list.get(k); + return a; + } + + private AnaliseAcidente getTableConcluidasRowData() + { + RowKey rk = tableRowGroup3.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + AnalisesConcluidasDataProvider provider = (AnalisesConcluidasDataProvider) tableRowGroup3.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + AnaliseAcidente a = (AnaliseAcidente)list.get(k); + return a; + } + + public void drpAno_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + Object ano = event.getNewValue(); + if(ano == null) + { + lblMes.setVisible(false); + drpMes.setVisible(false); + lblDia.setVisible(false); + drpDia.setVisible(false); + } + else + { + lblMes.setVisible(true); + drpMes.setVisible(true); + fillMesDropDown(); + } + } + + public void drpMes_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + Object mes = event.getNewValue(); + if(mes == null) + { + lblDia.setVisible(false); + drpDia.setVisible(false); + } + else + { + lblDia.setVisible(true); + drpDia.setVisible(true); + //fillDiaDropDown(); + } + } + + public void drpDia_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + + } + + public String butPesquisar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + Object obAno = null; + Object obMes = null; + Object obDia = null; + try + { + obAno = drpAno.getSelected(); + obMes = drpMes.getSelected(); + obDia = drpDia.getSelected(); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + Integer ano = null; + Integer mes = null; + Integer dia = null; + + if(obAno != null) + { + ano = (Integer) obAno; + } + + if(obMes != null) + { + mes = (Integer) obMes; + } + + if(obDia != null) + { + dia = (Integer) obDia; + } + + String por = null; + if(txtPor.getText() != null) + { + por = (String) txtPor.getText(); + if(por.trim().length() == 0) + { + por = null; + } + } + + String nome = null; + if(txtNome.getText() != null) + { + nome = (String) txtNome.getText(); + if(nome.trim().length() == 0) + { + nome = null; + } + } + + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + + //getSessionBean1().getAnalisesConcluidasDataProvider().setList(new ArrayList()); + ArrayList concluidasList = adp.searchAanalisesConcluidasList(getSessionBean1().getCurrentUser().getEstabelecimento_id(), ano, mes, dia, por, nome); + + table3.setRendered(true); + txtSearchMsg.setRendered(false); + getSessionBean1().getAnalisesConcluidasDataProvider().setList(concluidasList); + + + } + catch(Exception ex) + { + table3.setRendered(false); + txtSearchMsg.setRendered(true); + txtSearchMsg.setText("Não foram encontrados registos para a sua pesquisa !"); + //ex.printStackTrace(); + } + + return null; + } + +// private String getPageFrom(String referer) +// { +// String pageFrom = referer.substring(referer.lastIndexOf("/")+1); +// return pageFrom; +// } + + private void fillAnoDropDown() + { +// ArrayList anosList = new ArrayList(); +// for(int ano=2007; ano<2051; ano++) +// { +// anosList.add(new Integer(ano)); +// } + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + ArrayList anosList = adp.getAnosListFromAnalises(); + com.sun.rave.web.ui.model.Option[] anoOptions = new com.sun.rave.web.ui.model.Option[anosList.size()+1]; + anoOptions[0] = new Option("", ""); + ListIterator iter = anosList.listIterator(); + int i = 1; + while(iter.hasNext()) + { + Integer ano = (Integer) iter.next(); + + anoOptions[i] = new Option(ano, ano.toString()); + i++; + } + getSessionBean1().setAnoOptions(anoOptions); + Calendar cal = new GregorianCalendar(); + int year = cal.get(Calendar.YEAR); + //drpAno.setSelected( new Integer(year) ); + + } + catch(Exception ex) + { + //ex.printStackTrace(); + } + + } + + + private void fillMesDropDown() + { + com.sun.rave.web.ui.model.Option[] mesOptions = new com.sun.rave.web.ui.model.Option[13]; + mesOptions[0] = new Option("", ""); + mesOptions[1] = new Option(new Integer(1), "Janeiro"); + mesOptions[2] = new Option(new Integer(2), "Fevereiro"); + mesOptions[3] = new Option(new Integer(3), "Março"); + mesOptions[4] = new Option(new Integer(4), "Abril"); + mesOptions[5] = new Option(new Integer(5), "Maio"); + mesOptions[6] = new Option(new Integer(6), "Junho"); + mesOptions[7] = new Option(new Integer(7), "Julho"); + mesOptions[8] = new Option(new Integer(8), "Agosto"); + mesOptions[9] = new Option(new Integer(9), "Setembro"); + mesOptions[10] = new Option(new Integer(10), "Outubro"); + mesOptions[11] = new Option(new Integer(11), "Novembro"); + mesOptions[12] = new Option(new Integer(12), "Dezembro"); + getSessionBean1().setMesOptions(mesOptions); + Calendar cal = new GregorianCalendar(); + int month = cal.get(Calendar.MONTH); // 0=Jan, 1=Feb, ... + //drpMes.setSelected( new Integer(month+1) ); + } + + private void fillDiaDropDown() + { +// int ano = ( (Integer)drpAno.getSelected() ).intValue(); +// int mes = ( (Integer)drpMes.getSelected() ).intValue(); +// int dias = 0; +// switch (mes) { +// case 1: dias=31; break; +// case 2: +// GregorianCalendar cal = new GregorianCalendar(); +// if(cal.isLeapYear(ano)) +// { +// dias = 29; +// } +// else +// { +// dias = 28; +// } +// break; +// case 3: dias=31; break; +// case 4: dias=30; break; +// case 5: dias=31; break; +// case 6: dias=30; break; +// case 7: dias=31; break; +// case 8: dias=31; break; +// case 9: dias=30; break; +// case 10: dias=31; break; +// case 11: dias=30; break; +// case 12: dias=31; break; +// default: System.out.println("Invalid month.");break; +// } +// +// ArrayList diasList = new ArrayList(); +// for(int dia=1; diaAutomatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.
+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridBase = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridBase() { + return gridBase; + } + + public void setGridBase(HtmlPanelGrid hpg) { + this.gridBase = hpg; + } + + private HtmlPanelGrid gridLayout = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayout() { + return gridLayout; + } + + public void setGridLayout(HtmlPanelGrid hpg) { + this.gridLayout = hpg; + } + + private HtmlPanelGrid gridLayoutTop = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayoutTop() { + return gridLayoutTop; + } + + public void setGridLayoutTop(HtmlPanelGrid hpg) { + this.gridLayoutTop = hpg; + } + + private HtmlPanelGrid gridActual = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridActual() { + return gridActual; + } + + public void setGridActual(HtmlPanelGrid hpg) { + this.gridActual = hpg; + } + + private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel1() { + return gridPanel1; + } + + public void setGridPanel1(HtmlPanelGrid hpg) { + this.gridPanel1 = hpg; + } + + private StaticText staticText1 = new StaticText(); + + public StaticText getStaticText1() { + return staticText1; + } + + public void setStaticText1(StaticText st) { + this.staticText1 = st; + } + + private HtmlPanelGrid gridSeguimento = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridSeguimento() { + return gridSeguimento; + } + + public void setGridSeguimento(HtmlPanelGrid hpg) { + this.gridSeguimento = hpg; + } + + private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel2() { + return gridPanel2; + } + + public void setGridPanel2(HtmlPanelGrid hpg) { + this.gridPanel2 = hpg; + } + + private StaticText staticText2 = new StaticText(); + + public StaticText getStaticText2() { + return staticText2; + } + + public void setStaticText2(StaticText st) { + this.staticText2 = st; + } + + private HtmlPanelGrid gridConcluidos = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridConcluidos() { + return gridConcluidos; + } + + public void setGridConcluidos(HtmlPanelGrid hpg) { + this.gridConcluidos = hpg; + } + + private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel3() { + return gridPanel3; + } + + public void setGridPanel3(HtmlPanelGrid hpg) { + this.gridPanel3 = hpg; + } + + private StaticText staticText3 = new StaticText(); + + public StaticText getStaticText3() { + return staticText3; + } + + public void setStaticText3(StaticText st) { + this.staticText3 = st; + } + + private Link link2 = new Link(); + + public Link getLink2() { + return link2; + } + + public void setLink2(Link l) { + this.link2 = l; + } + + private Button butNovaAnalise = new Button(); + + public Button getButNovaAnalise() { + return butNovaAnalise; + } + + public void setButNovaAnalise(Button b) { + this.butNovaAnalise = b; + } + + private StaticText staticText4 = new StaticText(); + + public StaticText getStaticText4() { + return staticText4; + } + + public void setStaticText4(StaticText st) { + this.staticText4 = st; + } + + private HtmlPanelGrid gridPanel4 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel4() { + return gridPanel4; + } + + public void setGridPanel4(HtmlPanelGrid hpg) { + this.gridPanel4 = hpg; + } + + private Table table1 = new Table(); + + public Table getTable1() { + return table1; + } + + public void setTable1(Table t) { + this.table1 = t; + } + + private TableRowGroup tableRowGroup1 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup1() { + return tableRowGroup1; + } + + public void setTableRowGroup1(TableRowGroup trg) { + this.tableRowGroup1 = trg; + } + + private TableColumn tableColumn1 = new TableColumn(); + + public TableColumn getTableColumn1() { + return tableColumn1; + } + + public void setTableColumn1(TableColumn tc) { + this.tableColumn1 = tc; + } + + private TableColumn tableColumn2 = new TableColumn(); + + public TableColumn getTableColumn2() { + return tableColumn2; + } + + public void setTableColumn2(TableColumn tc) { + this.tableColumn2 = tc; + } + + private TableColumn tableColumn3 = new TableColumn(); + + public TableColumn getTableColumn3() { + return tableColumn3; + } + + public void setTableColumn3(TableColumn tc) { + this.tableColumn3 = tc; + } + + private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel5() { + return gridPanel5; + } + + public void setGridPanel5(HtmlPanelGrid hpg) { + this.gridPanel5 = hpg; + } + + private Table table2 = new Table(); + + public Table getTable2() { + return table2; + } + + public void setTable2(Table t) { + this.table2 = t; + } + + private TableRowGroup tableRowGroup2 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup2() { + return tableRowGroup2; + } + + public void setTableRowGroup2(TableRowGroup trg) { + this.tableRowGroup2 = trg; + } + + private TableColumn tableColumn4 = new TableColumn(); + + public TableColumn getTableColumn4() { + return tableColumn4; + } + + public void setTableColumn4(TableColumn tc) { + this.tableColumn4 = tc; + } + + private TableColumn tableColumn5 = new TableColumn(); + + public TableColumn getTableColumn5() { + return tableColumn5; + } + + public void setTableColumn5(TableColumn tc) { + this.tableColumn5 = tc; + } + + private TableColumn tableColumn6 = new TableColumn(); + + public TableColumn getTableColumn6() { + return tableColumn6; + } + + public void setTableColumn6(TableColumn tc) { + this.tableColumn6 = tc; + } + + private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel6() { + return gridPanel6; + } + + public void setGridPanel6(HtmlPanelGrid hpg) { + this.gridPanel6 = hpg; + } + + private PanelGroup groupPanel1 = new PanelGroup(); + + public PanelGroup getGroupPanel1() { + return groupPanel1; + } + + public void setGroupPanel1(PanelGroup pg) { + this.groupPanel1 = pg; + } + + private StaticText staticText11 = new StaticText(); + + public StaticText getStaticText11() { + return staticText11; + } + + public void setStaticText11(StaticText st) { + this.staticText11 = st; + } + + private DropDown drpAno = new DropDown(); + + public DropDown getDrpAno() { + return drpAno; + } + + public void setDrpAno(DropDown dd) { + this.drpAno = dd; + } + + private PanelGroup groupPanel2 = new PanelGroup(); + + public PanelGroup getGroupPanel2() { + return groupPanel2; + } + + public void setGroupPanel2(PanelGroup pg) { + this.groupPanel2 = pg; + } + + private StaticText lblMes = new StaticText(); + + public StaticText getLblMes() { + return lblMes; + } + + public void setLblMes(StaticText st) { + this.lblMes = st; + } + + private DropDown drpMes = new DropDown(); + + public DropDown getDrpMes() { + return drpMes; + } + + public void setDrpMes(DropDown dd) { + this.drpMes = dd; + } + + private PanelGroup groupPanel3 = new PanelGroup(); + + public PanelGroup getGroupPanel3() { + return groupPanel3; + } + + public void setGroupPanel3(PanelGroup pg) { + this.groupPanel3 = pg; + } + + private StaticText lblDia = new StaticText(); + + public StaticText getLblDia() { + return lblDia; + } + + public void setLblDia(StaticText st) { + this.lblDia = st; + } + + private DropDown drpDia = new DropDown(); + + public DropDown getDrpDia() { + return drpDia; + } + + public void setDrpDia(DropDown dd) { + this.drpDia = dd; + } + + private PanelGroup groupPanel4 = new PanelGroup(); + + public PanelGroup getGroupPanel4() { + return groupPanel4; + } + + public void setGroupPanel4(PanelGroup pg) { + this.groupPanel4 = pg; + } + + private StaticText staticText14 = new StaticText(); + + public StaticText getStaticText14() { + return staticText14; + } + + public void setStaticText14(StaticText st) { + this.staticText14 = st; + } + + private TextField txtNome = new TextField(); + + public TextField getTxtNome() { + return txtNome; + } + + public void setTxtNome(TextField tf) { + this.txtNome = tf; + } + + private Button butPesquisar = new Button(); + + public Button getButPesquisar() { + return butPesquisar; + } + + public void setButPesquisar(Button b) { + this.butPesquisar = b; + } + + private HtmlPanelGrid gridPanel7 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel7() { + return gridPanel7; + } + + public void setGridPanel7(HtmlPanelGrid hpg) { + this.gridPanel7 = hpg; + } + + private Table table3 = new Table(); + + public Table getTable3() { + return table3; + } + + public void setTable3(Table t) { + this.table3 = t; + } + + private TableRowGroup tableRowGroup3 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup3() { + return tableRowGroup3; + } + + public void setTableRowGroup3(TableRowGroup trg) { + this.tableRowGroup3 = trg; + } + + private TableColumn tableColumn7 = new TableColumn(); + + public TableColumn getTableColumn7() { + return tableColumn7; + } + + public void setTableColumn7(TableColumn tc) { + this.tableColumn7 = tc; + } + + private TableColumn tableColumn8 = new TableColumn(); + + public TableColumn getTableColumn8() { + return tableColumn8; + } + + public void setTableColumn8(TableColumn tc) { + this.tableColumn8 = tc; + } + + private TableColumn tableColumn9 = new TableColumn(); + + public TableColumn getTableColumn9() { + return tableColumn9; + } + + public void setTableColumn9(TableColumn tc) { + this.tableColumn9 = tc; + } + + private HtmlPanelGrid gridPanel8 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel8() { + return gridPanel8; + } + + public void setGridPanel8(HtmlPanelGrid hpg) { + this.gridPanel8 = hpg; + } + + private PanelGroup groupPanel5 = new PanelGroup(); + + public PanelGroup getGroupPanel5() { + return groupPanel5; + } + + public void setGroupPanel5(PanelGroup pg) { + this.groupPanel5 = pg; + } + + private ImageComponent image1 = new ImageComponent(); + + public ImageComponent getImage1() { + return image1; + } + + public void setImage1(ImageComponent ic) { + this.image1 = ic; + } + + private ImageComponent image2 = new ImageComponent(); + + public ImageComponent getImage2() { + return image2; + } + + public void setImage2(ImageComponent ic) { + this.image2 = ic; + } + + private PanelGroup groupPanel6 = new PanelGroup(); + + public PanelGroup getGroupPanel6() { + return groupPanel6; + } + + public void setGroupPanel6(PanelGroup pg) { + this.groupPanel6 = pg; + } + + private StaticText lblUser = new StaticText(); + + public StaticText getLblUser() { + return lblUser; + } + + public void setLblUser(StaticText st) { + this.lblUser = st; + } + + private StaticText staticText18 = new StaticText(); + + public StaticText getStaticText18() { + return staticText18; + } + + public void setStaticText18(StaticText st) { + this.staticText18 = st; + } + + private Hyperlink lnkEditUser = new Hyperlink(); + + public Hyperlink getLnkEditUser() { + return lnkEditUser; + } + + public void setLnkEditUser(Hyperlink h) { + this.lnkEditUser = h; + } + + private StaticText staticText19 = new StaticText(); + + public StaticText getStaticText19() { + return staticText19; + } + + public void setStaticText19(StaticText st) { + this.staticText19 = st; + } + + private Hyperlink lnkLogout = new Hyperlink(); + + public Hyperlink getLnkLogout() { + return lnkLogout; + } + + public void setLnkLogout(Hyperlink h) { + this.lnkLogout = h; + } + + private Hyperlink lnkDataAcidente = new Hyperlink(); + + public Hyperlink getLnkDataAcidente() { + return lnkDataAcidente; + } + + public void setLnkDataAcidente(Hyperlink h) { + this.lnkDataAcidente = h; + } + + private Hyperlink lnkNr = new Hyperlink(); + + public Hyperlink getLnkNr() { + return lnkNr; + } + + public void setLnkNr(Hyperlink h) { + this.lnkNr = h; + } + + private Hyperlink lnkNomeAcidentado = new Hyperlink(); + + public Hyperlink getLnkNomeAcidentado() { + return lnkNomeAcidentado; + } + + public void setLnkNomeAcidentado(Hyperlink h) { + this.lnkNomeAcidentado = h; + } + + private Hyperlink lnkDataAcidenteSeg = new Hyperlink(); + + public Hyperlink getLnkDataAcidenteSeg() { + return lnkDataAcidenteSeg; + } + + public void setLnkDataAcidenteSeg(Hyperlink h) { + this.lnkDataAcidenteSeg = h; + } + + private Hyperlink lnkNrSeg = new Hyperlink(); + + public Hyperlink getLnkNrSeg() { + return lnkNrSeg; + } + + public void setLnkNrSeg(Hyperlink h) { + this.lnkNrSeg = h; + } + + private Hyperlink lnkNomeAcidentadoSeg = new Hyperlink(); + + public Hyperlink getLnkNomeAcidentadoSeg() { + return lnkNomeAcidentadoSeg; + } + + public void setLnkNomeAcidentadoSeg(Hyperlink h) { + this.lnkNomeAcidentadoSeg = h; + } + + private Hyperlink lnkDataConcluida = new Hyperlink(); + + public Hyperlink getLnkDataConcluida() { + return lnkDataConcluida; + } + + public void setLnkDataConcluida(Hyperlink h) { + this.lnkDataConcluida = h; + } + + private Hyperlink lnkNrConcluida = new Hyperlink(); + + public Hyperlink getLnkNrConcluida() { + return lnkNrConcluida; + } + + public void setLnkNrConcluida(Hyperlink h) { + this.lnkNrConcluida = h; + } + + private Hyperlink lnkNomeConcluida = new Hyperlink(); + + public Hyperlink getLnkNomeConcluida() { + return lnkNomeConcluida; + } + + public void setLnkNomeConcluida(Hyperlink h) { + this.lnkNomeConcluida = h; + } + + private StaticText txtSearchMsg = new StaticText(); + + public StaticText getTxtSearchMsg() { + return txtSearchMsg; + } + + public void setTxtSearchMsg(StaticText st) { + this.txtSearchMsg = st; + } + + private TableColumn tableColumn10 = new TableColumn(); + + public TableColumn getTableColumn10() { + return tableColumn10; + } + + public void setTableColumn10(TableColumn tc) { + this.tableColumn10 = tc; + } + + private TableColumn tableColumn11 = new TableColumn(); + + public TableColumn getTableColumn11() { + return tableColumn11; + } + + public void setTableColumn11(TableColumn tc) { + this.tableColumn11 = tc; + } + + private Hyperlink lnkFase = new Hyperlink(); + + public Hyperlink getLnkFase() { + return lnkFase; + } + + public void setLnkFase(Hyperlink h) { + this.lnkFase = h; + } + + private Hyperlink lnkFaseSeg = new Hyperlink(); + + public Hyperlink getLnkFaseSeg() { + return lnkFaseSeg; + } + + public void setLnkFaseSeg(Hyperlink h) { + this.lnkFaseSeg = h; + } + + private TableColumn tableColumn12 = new TableColumn(); + + public TableColumn getTableColumn12() { + return tableColumn12; + } + + public void setTableColumn12(TableColumn tc) { + this.tableColumn12 = tc; + } + + private TableColumn tableColumn13 = new TableColumn(); + + public TableColumn getTableColumn13() { + return tableColumn13; + } + + public void setTableColumn13(TableColumn tc) { + this.tableColumn13 = tc; + } + + private TableColumn tableColumn14 = new TableColumn(); + + public TableColumn getTableColumn14() { + return tableColumn14; + } + + public void setTableColumn14(TableColumn tc) { + this.tableColumn14 = tc; + } + + private TableColumn tableColumn15 = new TableColumn(); + + public TableColumn getTableColumn15() { + return tableColumn15; + } + + public void setTableColumn15(TableColumn tc) { + this.tableColumn15 = tc; + } + + private Hyperlink lnkPor = new Hyperlink(); + + public Hyperlink getLnkPor() { + return lnkPor; + } + + public void setLnkPor(Hyperlink h) { + this.lnkPor = h; + } + + private Hyperlink lnkPorSeg = new Hyperlink(); + + public Hyperlink getLnkPorSeg() { + return lnkPorSeg; + } + + public void setLnkPorSeg(Hyperlink h) { + this.lnkPorSeg = h; + } + + private Hyperlink lnkPorConcluida = new Hyperlink(); + + public Hyperlink getLnkPorConcluida() { + return lnkPorConcluida; + } + + public void setLnkPorConcluida(Hyperlink h) { + this.lnkPorConcluida = h; + } + + private Hyperlink lnkEstabConcluida = new Hyperlink(); + + public Hyperlink getLnkEstabConcluida() { + return lnkEstabConcluida; + } + + public void setLnkEstabConcluida(Hyperlink h) { + this.lnkEstabConcluida = h; + } + + private PanelGroup groupPanel7 = new PanelGroup(); + + public PanelGroup getGroupPanel7() { + return groupPanel7; + } + + public void setGroupPanel7(PanelGroup pg) { + this.groupPanel7 = pg; + } + + private StaticText staticText5 = new StaticText(); + + public StaticText getStaticText5() { + return staticText5; + } + + public void setStaticText5(StaticText st) { + this.staticText5 = st; + } + + private TextField txtPor = new TextField(); + + public TextField getTxtPor() { + return txtPor; + } + + public void setTxtPor(TextField tf) { + this.txtPor = tf; + } + + private HtmlPanelGrid gridPanel9 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel9() { + return gridPanel9; + } + + public void setGridPanel9(HtmlPanelGrid hpg) { + this.gridPanel9 = hpg; + } + + private PanelGroup groupPanel8 = new PanelGroup(); + + public PanelGroup getGroupPanel8() { + return groupPanel8; + } + + public void setGroupPanel8(PanelGroup pg) { + this.groupPanel8 = pg; + } + + private StaticText staticText6 = new StaticText(); + + public StaticText getStaticText6() { + return staticText6; + } + + public void setStaticText6(StaticText st) { + this.staticText6 = st; + } + + private ImageComponent image3 = new ImageComponent(); + + public ImageComponent getImage3() { + return image3; + } + + public void setImage3(ImageComponent ic) { + this.image3 = ic; + } + + private StaticText staticText7 = new StaticText(); + + public StaticText getStaticText7() { + return staticText7; + } + + public void setStaticText7(StaticText st) { + this.staticText7 = st; + } + + private StaticText staticText8 = new StaticText(); + + public StaticText getStaticText8() { + return staticText8; + } + + public void setStaticText8(StaticText st) { + this.staticText8 = st; + } + + private Hyperlink lnkNewUser1 = new Hyperlink(); + + public Hyperlink getLnkNewUser1() { + return lnkNewUser1; + } + + public void setLnkNewUser1(Hyperlink h) { + this.lnkNewUser1 = h; + } + + private StaticText staticText9 = new StaticText(); + + public StaticText getStaticText9() { + return staticText9; + } + + public void setStaticText9(StaticText st) { + this.staticText9 = st; + } + + private StaticText staticText10 = new StaticText(); + + public StaticText getStaticText10() { + return staticText10; + } + + public void setStaticText10(StaticText st) { + this.staticText10 = st; + } + + private Hyperlink lnkAnalisesAcidente = new Hyperlink(); + + public Hyperlink getLnkAnalisesAcidente() { + return lnkAnalisesAcidente; + } + + public void setLnkAnalisesAcidente(Hyperlink h) { + this.lnkAnalisesAcidente = h; + } + + //Construct a new Page bean instance.
+ */ + public FormSeguranca() { + } + + /** + *Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.
+ * + *Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.
+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + //Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.
+ */ + public void preprocess() { + + } + + /** + *Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.
+ */ + public void prerender() { + lblUser.setText( getSessionBean1().getCurrentUser().getLogin() ); + String responsavel_loja = getSessionBean1().getCurrentUser().getResponsavel_loja(); + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + //lblActivos.setRendered(true); + table1.setRendered(true); + + //ArrayList actuaisList = adp.getAnalisesActuaisList(getSessionBean1().getCurrentUser().getEstabelecimento_id(), new Integer(1)); + ArrayList actuaisList = adp.getAnalisesActuaisSegList( getSessionBean1().getCurrentUser().getEstabelecimento_id(), responsavel_loja ); + getSessionBean1().getAnalisesActualDataProvider().setList(actuaisList); + } + catch(Exception ex) + { + //lblActivos.setRendered(false); + table1.setRendered(false); + //ex.printStackTrace(); + } + + try + { + //lblActivos.setRendered(true); + table2.setRendered(true); + + ArrayList seguimentoList = adp.getAnalisesSeguimentoSegList(getSessionBean1().getCurrentUser().getEstabelecimento_id(), responsavel_loja); + getSessionBean1().getAnalisesSeguimentoDataProvider().setList(seguimentoList); + } + catch(Exception ex) + { + //lblActivos.setRendered(false); + table2.setRendered(false); + //ex.printStackTrace(); + } + + HttpServletRequest request = (HttpServletRequest) getExternalContext().getRequest(); + String referer = request.getRequestURI(); + String pageFrom = Utils.getPageFrom(referer); + if(!pageFrom.matches("FormSeguranca.jsp")) + { + + try + { + //lblActivos.setRendered(true); + table3.setRendered(true); + + ArrayList concluidasList = adp.getAnalisesConcluidasList(getSessionBean1().getCurrentUser().getEstabelecimento_id()); + getSessionBean1().getAnalisesConcluidasDataProvider().setList(concluidasList); + } + catch(Exception ex) + { + //lblActivos.setRendered(false); + table3.setRendered(false); + //ex.printStackTrace(); + } + fillAnoDropDown(); + } + + } + + /** + *Callback method that is called after rendering is completed for
+ * this request, if init() was called (regardless of whether
+ * or not this was the page that was actually rendered). Customize this
+ * method to release resources acquired in the init(),
+ * preprocess(), or prerender() methods (or
+ * acquired during execution of an event handler).
Return a reference to the scoped data bean.
+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + public String lnkLogout_action() { + // TODO: Replace with your code + // Invalidate the current session + try + { + javax.servlet.http.HttpSession session = + (javax.servlet.http.HttpSession) getExternalContext().getSession(true); + session.invalidate(); + } + catch(Exception ex){} + + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) {} + //return "login"; + return null; + } + + public void drpAno_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + Object ano = event.getNewValue(); + if(ano == null) + { + lblMes.setVisible(false); + drpMes.setVisible(false); + lblDia.setVisible(false); + drpDia.setVisible(false); + } + else + { + lblMes.setVisible(true); + drpMes.setVisible(true); + fillMesDropDown(); + } + } + + public void drpMes_processValueChange(ValueChangeEvent event) { + // TODO: Replace with your code + Object mes = event.getNewValue(); + if(mes == null) + { + lblDia.setVisible(false); + drpDia.setVisible(false); + } + else + { + lblDia.setVisible(true); + drpDia.setVisible(true); + fillDiaDropDown(); + } + } + + public String butPesquisar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + Object obAno = null; + Object obMes = null; + Object obDia = null; + try + { + obAno = drpAno.getSelected(); + obMes = drpMes.getSelected(); + obDia = drpDia.getSelected(); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + Integer ano = null; + Integer mes = null; + Integer dia = null; + + if(obAno != null) + { + ano = (Integer) obAno; + } + + if(obMes != null) + { + mes = (Integer) obMes; + } + + if(obDia != null) + { + dia = (Integer) obDia; + } + + String por = null; + if(txtPor.getText() != null) + { + por = (String) txtPor.getText(); + if(por.trim().length() == 0) + { + por = null; + } + } + + + String nome = null; + if(txtNome.getText() != null) + { + nome = (String) txtNome.getText(); + if(nome.trim().length() == 0) + { + nome = null; + } + } + + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + + //getSessionBean1().getAnalisesConcluidasDataProvider().setList(new ArrayList()); + ArrayList concluidasList = adp.searchAanalisesConcluidasList(getSessionBean1().getCurrentUser().getEstabelecimento_id(), ano, mes, dia, por, nome); + + table3.setRendered(true); + txtSearchMsg.setRendered(false); + getSessionBean1().getAnalisesConcluidasDataProvider().setList(concluidasList); + + + } + catch(Exception ex) + { + table3.setRendered(false); + txtSearchMsg.setRendered(true); + txtSearchMsg.setText("Não foram encontrados registos para a sua pesquisa !"); + //ex.printStackTrace(); + } + + return null; + } + + public void drpDia_processValueChange(ValueChangeEvent vce) { + // TODO: Replace with your code + + } + +// private String getPageFrom(String referer) +// { +// String pageFrom = referer.substring(referer.lastIndexOf("/")+1); +// return pageFrom; +// } + + public String butNovaAnalise_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + getSessionBean1().setNavFrom("FormSeguranca"); + getSessionBean1().setCurrentAnalise(null); + return "analise_acidente"; + } + + public String lnkDataAcidente_action() { + // TODO: Replace with your code + AnaliseAcidente a = getTableActivosRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormSeguranca"); + return "analise_acidente"; + } + + public String lnkNr_action() { + // TODO: Replace with your code + AnaliseAcidente a = getTableActivosRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormSeguranca"); + return "analise_acidente"; + } + + public String lnkNomeAcidentado_action() { + // TODO: Replace with your code + AnaliseAcidente a = getTableActivosRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormSeguranca"); + return "analise_acidente"; + } + + private AnaliseAcidente getTableActivosRowData() + { + RowKey rk = tableRowGroup1.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + AnalisesActualDataProvider provider = (AnalisesActualDataProvider) tableRowGroup1.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + AnaliseAcidente a = (AnaliseAcidente)list.get(k); + return a; + } + + public String lnkDataAcidenteSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormSeguranca"); + return "view_analise"; + + } + + public String lnkNrSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormSeguranca"); + return "view_analise"; + } + + public String lnkNomeAcidentadoSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormSeguranca"); + return "view_analise"; + } + + private AnaliseAcidente getTableSeguimentoRowData() + { + RowKey rk = tableRowGroup2.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + AnalisesSeguimentoDataProvider provider = (AnalisesSeguimentoDataProvider) tableRowGroup2.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + AnaliseAcidente a = (AnaliseAcidente)list.get(k); + return a; + } + + private AnaliseAcidente getTableConcluidasRowData() + { + RowKey rk = tableRowGroup3.getRowKey(); + int k = Integer.parseInt(rk.getRowId()); + AnalisesConcluidasDataProvider provider = (AnalisesConcluidasDataProvider) tableRowGroup3.getSourceData(); + ArrayList list = (ArrayList) provider.getList(); + AnaliseAcidente a = (AnaliseAcidente)list.get(k); + return a; + } + + public String lnkEditUser_action() { + // TODO: Replace with your code + getSessionBean1().setNavFrom("FormSeguranca"); + getSessionBean1().setModoEdicaoUtilizador("edit"); + return "user"; + } + + public String lnkDataConcluida_action() { + // TODO: Replace with your code + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormSeguranca"); + return "view_analise"; + } + + public String lnkNrConcluida_action() { + // TODO: Replace with your code + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormSeguranca"); + return "view_analise"; + } + + public String lnkNomeConcluida_action() { + // TODO: Replace with your code + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormSeguranca"); + return "view_analise"; + } + + public String lnkFase_action() { + // TODO: Replace with your code + AnaliseAcidente a = getTableActivosRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormSeguranca"); + return "analise_acidente"; + } + + public String lnkFaseSeg_action() { + // TODO: Replace with your code + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormSeguranca"); + return "view_analise"; + } + + public String lnkPor_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableActivosRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormSeguranca"); + return "analise_acidente"; } + + public String lnkPorSeg_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableSeguimentoRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormSeguranca"); + return "view_analise"; + } + + public String lnkPorConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormSeguranca"); + return "view_analise"; + } + + public String lnkEstabConcluida_action() { + // TODO: Replace with your code + + AnaliseAcidente a = getTableConcluidasRowData(); + getSessionBean1().setCurrentAnalise(a); + getSessionBean1().setNavFrom("FormSeguranca"); + return "view_analise"; + } + + public String lnkNewUser_action() { + // TODO: Replace with your code + + return null; + } +} + diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Header.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Header.java new file mode 100644 index 00000000..7bcdb7dc --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Header.java @@ -0,0 +1,120 @@ +/* + * Header.java + * + * Created on September 19, 2007, 10:14 AM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.rave.web.ui.appbase.AbstractFragmentBean; +import com.sun.rave.web.ui.component.StaticText; +import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; + +/** + *Fragment bean that corresponds to a similarly named JSP page + * fragment. This class contains component definitions (and initialization + * code) for all components that you have defined on this fragment, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.
+ */ +public class Header extends AbstractFragmentBean { + //Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.
+ */ + private void _init() throws Exception { + } + + private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel1() { + return gridPanel1; + } + + public void setGridPanel1(HtmlPanelGrid hpg) { + this.gridPanel1 = hpg; + } + + private StaticText staticText1 = new StaticText(); + + public StaticText getStaticText1() { + return staticText1; + } + + public void setStaticText1(StaticText st) { + this.staticText1 = st; + } + //Callback method that is called whenever a page containing + * this page fragment is navigated to, either directly via a URL, + * or indirectly via page navigation. Override this method to acquire + * resources that will be needed for event handlers and lifecycle methods.
+ * + *The default implementation does nothing.
+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + + //Callback method that is called after rendering is completed for
+ * this request, if init() was called. Override this
+ * method to release resources acquired in the init()
+ * resources that will be needed for event handlers and lifecycle methods.
The default implementation does nothing.
+ */ + public void destroy() { + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/LoadImage.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/LoadImage.java new file mode 100644 index 00000000..0c6e4108 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/LoadImage.java @@ -0,0 +1,467 @@ +/* + * LoadImage.java + * + * Created on September 26, 2007, 5:36 PM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.rave.web.ui.component.Body; +import com.sun.rave.web.ui.component.Button; +import com.sun.rave.web.ui.component.Form; +import com.sun.rave.web.ui.component.Head; +import com.sun.rave.web.ui.component.Html; +import com.sun.rave.web.ui.component.Link; +import com.sun.rave.web.ui.component.Page; +import com.sun.rave.web.ui.component.PanelGroup; +import com.sun.rave.web.ui.component.StaticText; +import com.sun.rave.web.ui.component.Upload; +import com.sun.rave.web.ui.model.UploadedFile; +import global.Global; +import java.io.File; +import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; +import javax.servlet.ServletContext; + +/** + *Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.
+ */ +public class LoadImage extends AbstractPageBean { + //Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.
+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridBase1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridBase1() { + return gridBase1; + } + + public void setGridBase1(HtmlPanelGrid hpg) { + this.gridBase1 = hpg; + } + + private HtmlPanelGrid gridLayout = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayout() { + return gridLayout; + } + + public void setGridLayout(HtmlPanelGrid hpg) { + this.gridLayout = hpg; + } + + private StaticText staticText1 = new StaticText(); + + public StaticText getStaticText1() { + return staticText1; + } + + public void setStaticText1(StaticText st) { + this.staticText1 = st; + } + + private Upload fileUpload1 = new Upload(); + + public Upload getFileUpload1() { + return fileUpload1; + } + + public void setFileUpload1(Upload u) { + this.fileUpload1 = u; + } + + //Construct a new Page bean instance.
+ */ + + private String realImageFilePath; + //private static final String IMAGE_URL = "/resources/image-file"; + //private String IMAGE_URL = "/resources/images"; + + private StaticText staticText2 = new StaticText(); + + public StaticText getStaticText2() { + return staticText2; + } + + public void setStaticText2(StaticText st) { + this.staticText2 = st; + } + + private StaticText txtMsg = new StaticText(); + + public StaticText getTxtMsg() { + return txtMsg; + } + + public void setTxtMsg(StaticText st) { + this.txtMsg = st; + } + + private PanelGroup groupPanel4 = new PanelGroup(); + + public PanelGroup getGroupPanel4() { + return groupPanel4; + } + + public void setGroupPanel4(PanelGroup pg) { + this.groupPanel4 = pg; + } + + private Button butUpload = new Button(); + + public Button getButUpload() { + return butUpload; + } + + public void setButUpload(Button b) { + this.butUpload = b; + } + + private Button butCancelar = new Button(); + + public Button getButCancelar() { + return butCancelar; + } + + public void setButCancelar(Button b) { + this.butCancelar = b; + } + public LoadImage() { + } + + /** + *Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.
+ * + *Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.
+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + //Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.
+ */ + public void preprocess() { + } + + /** + *Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.
+ */ + public void prerender() { + //String uploadedFileName = (String) this.txtFileName.getValue(); + //if ( uploadedFileName != null ) { +// IMAGE_URL += getSessionBean1().getImageName(); +// System.out.println("IMAGE URL : " + IMAGE_URL); + //image1.setUrl(IMAGE_URL); +// } + txtMsg.setText(getSessionBean1().getMsg()); + getSessionBean1().setMsg(""); + + } + + /** + *Callback method that is called after rendering is completed for
+ * this request, if init() was called (regardless of whether
+ * or not this was the page that was actually rendered). Customize this
+ * method to release resources acquired in the init(),
+ * preprocess(), or prerender() methods (or
+ * acquired during execution of an event handler).
Return a reference to the scoped data bean.
+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + public String lnkLogout_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkNome_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkDataNascimento_action() { + // TODO: Replace with your code + + return null; + } + + public String butCancelar_action() { + getSessionBean1().setImageName(null); + return "analise_acidente"; + } + + public String butUpload_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + //realImageFilePath += "/tmp" + getSessionBean1().getCurrentUser().getLogin(); + System.out.println("REAL IMAGE FILE PATH : " + realImageFilePath); + File fdir = new File(realImageFilePath); + System.out.println("FDIR : " + fdir); + + + UploadedFile uploadedFile = fileUpload1.getUploadedFile(); + if(uploadedFile != null) + { + + String uploadedFileName = uploadedFile.getOriginalName(); + + // Some browsers return complete path name, some don't + // Make sure we only have the file name + // First, try forward slash + int index = uploadedFileName.lastIndexOf('/'); + String justFileName; + if ( index >= 0) { + justFileName = uploadedFileName.substring( index + 1 ); + } else { + // Try backslash + index = uploadedFileName.lastIndexOf('\\'); + if (index >= 0) { + justFileName = uploadedFileName.substring( index + 1 ); + } else { + // No forward or back slashes + justFileName = uploadedFileName; + } + } + //justFileName = justFileName.substring(0, justFileName.lastIndexOf('.')); + int firstImageNr = getFirstImageNr().intValue(); + File files[] = fdir.listFiles(); + // realImageFilePath += "/" + justFileName; + System.out.println("FILES : " + files); + + justFileName = new Integer(firstImageNr + files.length + 1).toString(); + //this.txtFileName.setValue(justFileName); + Long uploadedFileSize = new Long(uploadedFile.getSize()); + //this.txtFileSize.setValue(uploadedFileSize); + String uploadedFileType = uploadedFile.getContentType(); + //this.txtFileType.setValue(uploadedFileType); + if ( uploadedFileType.equals("image/jpeg") + || uploadedFileType.equals("image/pjpeg") + || uploadedFileType.equals("image/gif") + || uploadedFileType.equals("image/png") + || uploadedFileType.equals("image/x-png")) { + try { + + realImageFilePath += "/" + justFileName; + File file = new File(this.realImageFilePath); + uploadedFile.write(file); + getSessionBean1().setImageName(justFileName); + //getSessionBean1().setMsg("Ficheiro carregado !"); + } catch (Exception ex) { + ex.printStackTrace(); + getSessionBean1().setMsg("Não foi possivel carregar o ficheiro !"); + return null; + } + } else { + getSessionBean1().setMsg("Tem de seleccionar um ficheiro do tipo JPEG, PJPEG, GIF, PNG, ou X-PNG !"); + new File(this.realImageFilePath).delete(); + return null; + } + } + else + { + getSessionBean1().setImageName(null); + } + + return "analise_acidente"; + } + + private Integer getFirstImageNr() + { + if(getSessionBean1().getCurrentAnalise() == null) + { + return new Integer(0); + } + else + { + String folderName = getSessionBean1().getCurrentAnalise().getAnalise_nr().substring(0,2) + getSessionBean1().getCurrentAnalise().getAnalise_nr().substring(3); + ServletContext theApplicationsServletContext = + (ServletContext) this.getExternalContext().getContext(); +// String imageFileFolder = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/" + folderName); + String imageFileFolder = Global.IMAGE_FOLDER + "/" + folderName; + File fdir = new File(imageFileFolder); + int nr = 0; + if(fdir.exists()) + { + File files[] = fdir.listFiles(); + for(int i=0; i < files.length; i++) + { + String nr_str = files[i].getName(); + int i_nr = Integer.parseInt(nr_str); + if(i_nr > nr) + { + nr = i_nr; + } + } + return new Integer(nr); + } + + return new Integer(0); + } + } +} + diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Login.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Login.java new file mode 100644 index 00000000..8964d9bc --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Login.java @@ -0,0 +1,626 @@ +/* + * Page1.java + * + * Created on September 18, 2007, 3:14 PM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.rave.web.ui.component.Body; +import com.sun.rave.web.ui.component.Button; +import com.sun.rave.web.ui.component.Form; +import com.sun.rave.web.ui.component.Head; +import com.sun.rave.web.ui.component.Html; +import com.sun.rave.web.ui.component.Hyperlink; +import com.sun.rave.web.ui.component.Link; +import com.sun.rave.web.ui.component.Page; +import com.sun.rave.web.ui.component.PasswordField; +import com.sun.rave.web.ui.component.StaticText; +import com.sun.rave.web.ui.component.TextField; +import com.sun.rave.web.ui.model.Option; +import db.AnalisesDataProvider; +import db.UtilizadoresDataProvider; +import java.sql.Connection; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.GregorianCalendar; +import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; + +/** + *Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.
+ */ +public class Login extends AbstractPageBean { + //Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.
+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel6() { + return gridPanel6; + } + + public void setGridPanel6(HtmlPanelGrid hpg) { + this.gridPanel6 = hpg; + } + + private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel1() { + return gridPanel1; + } + + public void setGridPanel1(HtmlPanelGrid hpg) { + this.gridPanel1 = hpg; + } + + private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel2() { + return gridPanel2; + } + + public void setGridPanel2(HtmlPanelGrid hpg) { + this.gridPanel2 = hpg; + } + + private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel3() { + return gridPanel3; + } + + public void setGridPanel3(HtmlPanelGrid hpg) { + this.gridPanel3 = hpg; + } + + private HtmlPanelGrid gridPanel4 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel4() { + return gridPanel4; + } + + public void setGridPanel4(HtmlPanelGrid hpg) { + this.gridPanel4 = hpg; + } + + private StaticText staticText1 = new StaticText(); + + public StaticText getStaticText1() { + return staticText1; + } + + public void setStaticText1(StaticText st) { + this.staticText1 = st; + } + + private TextField txtUtilizador = new TextField(); + + public TextField getTxtUtilizador() { + return txtUtilizador; + } + + public void setTxtUtilizador(TextField tf) { + this.txtUtilizador = tf; + } + + private StaticText staticText2 = new StaticText(); + + public StaticText getStaticText2() { + return staticText2; + } + + public void setStaticText2(StaticText st) { + this.staticText2 = st; + } + + private PasswordField txtPassword = new PasswordField(); + + public PasswordField getTxtPassword() { + return txtPassword; + } + + public void setTxtPassword(PasswordField pf) { + this.txtPassword = pf; + } + + private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel5() { + return gridPanel5; + } + + public void setGridPanel5(HtmlPanelGrid hpg) { + this.gridPanel5 = hpg; + } + + private Hyperlink lnkPassRecovery = new Hyperlink(); + + public Hyperlink getLnkPassRecovery() { + return lnkPassRecovery; + } + + public void setLnkPassRecovery(Hyperlink h) { + this.lnkPassRecovery = h; + } + + private Button butLogin = new Button(); + + public Button getButLogin() { + return butLogin; + } + + public void setButLogin(Button b) { + this.butLogin = b; + } + + private StaticText txtMsg = new StaticText(); + + public StaticText getTxtMsg() { + return txtMsg; + } + + public void setTxtMsg(StaticText st) { + this.txtMsg = st; + } + + //Construct a new Page bean instance.
+ */ + public Login() { + connect(); + } + + /** + *Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.
+ * + *Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.
+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + //Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.
+ */ + public void preprocess() { + } + + /** + *Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.
+ */ + public void prerender() { + + txtMsg.setText(getSessionBean1().getMsg()); + getSessionBean1().setMsg(""); + } + + /** + *Callback method that is called after rendering is completed for
+ * this request, if init() was called (regardless of whether
+ * or not this was the page that was actually rendered). Customize this
+ * method to release resources acquired in the init(),
+ * preprocess(), or prerender() methods (or
+ * acquired during execution of an event handler).
Return a reference to the scoped data bean.
+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + public String butLogin_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + String sRet = null; + + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + if(txtUtilizador.getText() != null) + { + String utilizador = (String) txtUtilizador.getText(); + if(utilizador.trim().length() > 0) + { + if(txtPassword.getText() != null) + { + String password = (String) txtPassword.getText(); + if(password.trim().length() > 0) + { + try + { + Utilizador u = udp.getUtilizador(utilizador); + if(u.getActivo().matches("y")) + { + if(!password.equals(u.getPassword())) + { + getSessionBean1().setMsg("Palavra-chave inválida !"); + } + else + { + //if(u.getOwner_id().intValue() == 0 ) + + //Login Ok ! +// if(u.getPrimeiro_login().matches("y") || mustChangePassword(u)) + if(u.getPrimeiro_login().matches("y") ) + { + getSessionBean1().setMudarPassword(true); + getSessionBean1().setCurrentUser( u ); + getSessionBean1().setNavFrom("Login"); + getSessionBean1().setModoEdicaoUtilizador("edit"); + getSessionBean1().setLoggedIn(true); + initializeClock(); + initializeDropDownOptions(); + return "user"; + } + try + { + Integer permissao = udp.getPermissionCode(u.getId()); + if(permissao.intValue() == 1) //seguranca + { + sRet = "form_seguranca"; + } + else if(permissao.intValue() == 2) // rh + { + sRet = "form_rh"; + } + else if(permissao.intValue() == 3) // hs + { + sRet = "form_hs"; + } + else if(permissao.intValue() == 5) // medico + { + sRet = "form_medico"; + } + else if(permissao.intValue() == 6) // gestor + { + sRet = "form_gestor"; + } + else if(permissao.intValue() == 7) // director geral rh + { + //sRet = "form_rh"; + sRet = "form_dir_ger_rh"; + } + else if(permissao.intValue() == 8) // director siprp + { + sRet = "form_dir_siprp"; + } + u.setCodigo_permissao(permissao); + getSessionBean1().setCurrentUser( u ); + getSessionBean1().setLoggedIn(true); + initializeClock(); + initializeDropDownOptions(); + + // só para testes. retirar depois : + ///getSessionBean1().setModoEdicaoUtilizador("new"); + ///sRet = "create_user"; + } + catch(Exception e1) + { + e1.printStackTrace(); + getSessionBean1().setMsg("Não tem permissão para entrar na aplicação !"); + } + } + + } + else + { + getSessionBean1().setMsg("Utilizador inválido ! "); + } + } + catch(Exception ex) + { + getSessionBean1().setMsg("Utilizador inválido ! "); + } + } + else + { + getSessionBean1().setMsg("Falta palavra-chave !"); + } + } + else + { + getSessionBean1().setMsg("Falta palavra-chave !"); + } + } + else + { + getSessionBean1().setMsg("Falta utilizador !"); + } + } + else + { + getSessionBean1().setMsg("Falta utilizador !"); + } + return sRet; + } + + public String lnkPassRecovery_action() { + // TODO: Replace with your code + + return "recuperar_password"; + } + + private void connect() + { + db.Db db = new db.Db(); + try + { + Connection connection = db.connect(); + } + catch(Exception ex) + { + getSessionBean1().setMsg("Erro na ligação à Base de Dados"); + //***** terminate session + try { + getExternalContext().redirect("faces/Erro.jsp"); + } catch(Exception e) { + // . . . handle exception . . . + e.printStackTrace(); + } + ex.printStackTrace(); + } + } + + private void initializeClock() + { + com.sun.rave.web.ui.model.Option[] horasOptions = new com.sun.rave.web.ui.model.Option[25]; + horasOptions[0] = new Option(new Integer(-1), "-"); + int j = 0; + String str_j = ""; + for(int i=1; i < 25; i++) + { + if(j < 10) + { + str_j = "0" + new Integer(j).toString(); + } + else + { + str_j = new Integer(j).toString(); + } + horasOptions[i] = new Option(new Integer(j), str_j); + j++; + } + getSessionBean1().setHorasOptions(horasOptions); + + com.sun.rave.web.ui.model.Option[] minutosOptions = new com.sun.rave.web.ui.model.Option[13]; + minutosOptions[0] = new Option(new Integer(-1), "-"); + j = 0; + for(int i=1; i < 13; i++) + { + if(j < 10) + { + str_j = "0" + new Integer(j).toString(); + } + else + { + str_j = new Integer(j).toString(); + } + minutosOptions[i] = new Option(new Integer(j), str_j); + j += 5; + } + getSessionBean1().setMinutosOptions(minutosOptions); + } + + private void initializeDropDownOptions() + { + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); +// try +// { +// getSessionBean1().setTecnicosOptions(udp.getTecnicosSaudeList()); +// //drpTipo.setSelected(new Integer(0)); +// } +// catch(Exception ex) +// { +// ex.printStackTrace(); +// } + +// try +// { +// getSessionBean1().setMedicosOptions(udp.getMedicosList()); +// //drpTipo.setSelected(new Integer(0)); +// } +// catch(Exception ex) +// { +// ex.printStackTrace(); +// } + + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + getSessionBean1().setCausasOptions(adp.getCausasList()); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + try + { + getSessionBean1().setDepartamentoOptions(adp.getDepartamentosList()); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + } + + private boolean mustChangePassword(Utilizador u) + { + java.util.Date now = new java.util.Date(); + Calendar cal = new GregorianCalendar(); + cal.setTime(now); + int ano = cal.get(Calendar.YEAR); + int mes = cal.get(Calendar.MONTH); + int dia = cal.get(Calendar.DAY_OF_MONTH); + + Calendar today = new GregorianCalendar(ano, mes, dia); + Calendar firstJan = new GregorianCalendar(ano, Calendar.JANUARY, 1); +// Calendar firstJan = new GregorianCalendar(ano, Calendar.DECEMBER, 27); + Calendar firstJul = new GregorianCalendar(ano, Calendar.JULY, 1); + + if(today.compareTo(firstJan) == 0 || today.compareTo(firstJul) == 0) + { + return true; + } + + if(u.getData_password() == null) + { + return true; + } + else + { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + try + { + java.util.Date dt_password = sdf.parse(u.getData_password().toString()); + Calendar cal_dt_password = new GregorianCalendar(); + cal_dt_password.setTime(dt_password); + cal_dt_password.add(GregorianCalendar.MONTH, 6); + if(cal.compareTo(cal_dt_password) > 0) + { + return true; + } + else + { + return false; + } + + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + } + return false; + } +} + diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Medico.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Medico.java new file mode 100644 index 00000000..257089e6 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Medico.java @@ -0,0 +1,53 @@ +/* + * Medico.java + * + * Created on October 12, 2007, 11:00 AM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package analiseacidentestrabalho; + +/** + * + * @author lluis + */ +public class Medico { + private Integer id; + private String nome; + private String numero_cedula; + + /** Creates a new instance of Medico */ + public Medico() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getNome() { + return nome; + } + + public void setNome(String nome) { + this.nome = nome; + } + + public String getNumero_cedula() { + return numero_cedula; + } + + public void setNumero_cedula(String numero_cedula) { + this.numero_cedula = numero_cedula; + } + + public String toString() { + return utils.Utils.unicodeToHTML(nome); + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Medida.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Medida.java new file mode 100644 index 00000000..5fe9c763 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Medida.java @@ -0,0 +1,49 @@ +/* + * Medida.java + * + * Created on October 19, 2007, 4:59 PM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package analiseacidentestrabalho; + +/** + * + * @author lluis + */ +public class Medida { + private Integer id; + private Integer analise_id; + private String medida; + + /** Creates a new instance of Medida */ + public Medida() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getAnalise_id() { + return analise_id; + } + + public void setAnalise_id(Integer analise_id) { + this.analise_id = analise_id; + } + + public String getMedida() { + return medida; + } + + public void setMedida(String medida) { + this.medida = medida; + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Permissao.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Permissao.java new file mode 100644 index 00000000..31b0be5b --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Permissao.java @@ -0,0 +1,49 @@ +/* + * Permissao.java + * + * Created on October 25, 2007, 4:40 PM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package analiseacidentestrabalho; + +/** + * + * @author lluis + */ +public class Permissao { + private Integer id; + private Integer user_id; + private Integer codigo_permissao; + + /** Creates a new instance of Permissao */ + public Permissao() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getUser_id() { + return user_id; + } + + public void setUser_id(Integer user_id) { + this.user_id = user_id; + } + + public Integer getCodigo_permissao() { + return codigo_permissao; + } + + public void setCodigo_permissao(Integer codigo_permissao) { + this.codigo_permissao = codigo_permissao; + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Recomendacao.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Recomendacao.java new file mode 100644 index 00000000..85aea13e --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Recomendacao.java @@ -0,0 +1,49 @@ +/* + * Recomendacao.java + * + * Created on October 16, 2007, 3:13 PM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package analiseacidentestrabalho; + +/** + * + * @author lluis + */ +public class Recomendacao { + private Integer id; + private Integer analise_id; + private String recomendacao; + + /** Creates a new instance of Recomendacao */ + public Recomendacao() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getAnalise_id() { + return analise_id; + } + + public void setAnalise_id(Integer analise_id) { + this.analise_id = analise_id; + } + + public String getRecomendacao() { + return recomendacao; + } + + public void setRecomendacao(String recomendacao) { + this.recomendacao = recomendacao; + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/RecuperarPassword.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/RecuperarPassword.java new file mode 100644 index 00000000..deb5b682 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/RecuperarPassword.java @@ -0,0 +1,525 @@ +/* + * RecuperarPassword.java + * + * Created on September 19, 2007, 9:57 AM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.rave.web.ui.component.Body; +import com.sun.rave.web.ui.component.Button; +import com.sun.rave.web.ui.component.Form; +import com.sun.rave.web.ui.component.Head; +import com.sun.rave.web.ui.component.Html; +import com.sun.rave.web.ui.component.Link; +import com.sun.rave.web.ui.component.Page; +import com.sun.rave.web.ui.component.PanelGroup; +import com.sun.rave.web.ui.component.StaticText; +import com.sun.rave.web.ui.component.TextField; +import db.UtilizadoresDataProvider; +import java.util.Date; +import java.util.Properties; +import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; +import javax.mail.BodyPart; +import javax.mail.Message; +import javax.mail.Multipart; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeBodyPart; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMultipart; +import utils.Utils; + +/** + *Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.
+ */ +public class RecuperarPassword extends AbstractPageBean { + //Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.
+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel1() { + return gridPanel1; + } + + public void setGridPanel1(HtmlPanelGrid hpg) { + this.gridPanel1 = hpg; + } + + private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel2() { + return gridPanel2; + } + + public void setGridPanel2(HtmlPanelGrid hpg) { + this.gridPanel2 = hpg; + } + + private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel3() { + return gridPanel3; + } + + public void setGridPanel3(HtmlPanelGrid hpg) { + this.gridPanel3 = hpg; + } + + private StaticText txtMsg = new StaticText(); + + public StaticText getTxtMsg() { + return txtMsg; + } + + public void setTxtMsg(StaticText st) { + this.txtMsg = st; + } + + private StaticText staticText3 = new StaticText(); + + public StaticText getStaticText3() { + return staticText3; + } + + public void setStaticText3(StaticText st) { + this.staticText3 = st; + } + + private HtmlPanelGrid gridPanel4 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel4() { + return gridPanel4; + } + + public void setGridPanel4(HtmlPanelGrid hpg) { + this.gridPanel4 = hpg; + } + + private StaticText staticText1 = new StaticText(); + + public StaticText getStaticText1() { + return staticText1; + } + + public void setStaticText1(StaticText st) { + this.staticText1 = st; + } + + private TextField txtUtilizador = new TextField(); + + public TextField getTxtUtilizador() { + return txtUtilizador; + } + + public void setTxtUtilizador(TextField tf) { + this.txtUtilizador = tf; + } + + private StaticText staticText2 = new StaticText(); + + public StaticText getStaticText2() { + return staticText2; + } + + public void setStaticText2(StaticText st) { + this.staticText2 = st; + } + + private TextField txtEmail = new TextField(); + + public TextField getTxtEmail() { + return txtEmail; + } + + public void setTxtEmail(TextField tf) { + this.txtEmail = tf; + } + + private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel5() { + return gridPanel5; + } + + public void setGridPanel5(HtmlPanelGrid hpg) { + this.gridPanel5 = hpg; + } + + private PanelGroup groupPanel1 = new PanelGroup(); + + public PanelGroup getGroupPanel1() { + return groupPanel1; + } + + public void setGroupPanel1(PanelGroup pg) { + this.groupPanel1 = pg; + } + + private Button butCancelar = new Button(); + + public Button getButCancelar() { + return butCancelar; + } + + public void setButCancelar(Button b) { + this.butCancelar = b; + } + + private Button butOk = new Button(); + + public Button getButOk() { + return butOk; + } + + public void setButOk(Button b) { + this.butOk = b; + } + + //Construct a new Page bean instance.
+ */ + public RecuperarPassword() { + } + + /** + *Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.
+ * + *Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.
+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + //Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.
+ */ + public void preprocess() { + } + + /** + *Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.
+ */ + public void prerender() { + txtMsg.setText(getSessionBean1().getMsg()); + getSessionBean1().setMsg(""); + } + + /** + *Callback method that is called after rendering is completed for
+ * this request, if init() was called (regardless of whether
+ * or not this was the page that was actually rendered). Customize this
+ * method to release resources acquired in the init(),
+ * preprocess(), or prerender() methods (or
+ * acquired during execution of an event handler).
Return a reference to the scoped data bean.
+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + public String butLogin_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + return null; + } + + public String butCancelar_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + return "login"; + } + + public String butOk_action() { + // TODO: Process the button click action. Return value is a navigation + // case name where null will return to the same page. + + + if(fieldsValidationOk()) + { + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + try + { + String utilizador = (String) txtUtilizador.getText(); + Utilizador u = udp.getUtilizador(utilizador); + String email = (String) txtEmail.getText(); + if(u.getEmail().equals(email)) + { + //send mail : + try + { + sendEmail(u.getEmail(), u.getLogin(), u.getPassword(), "linojose@mail.com"); + getSessionBean1().setMsg("A sua password foi enviada para o seu email"); + return "login"; + } + catch(Exception ex) + { + getSessionBean1().setMsg("Erro no envio da password !"); + } + + } + else + { + getSessionBean1().setMsg("Os dados não coincidem com os registos !"); + } + } + catch(Exception ex) + { + getSessionBean1().setMsg("Utilizador inválido !"); + } + } + + + return null; + } + + private void sendEmail(String emailTo, String login, String password, String admin_email) throws Exception + { + Properties props = new Properties(); + //props.put("mail.transport.protocol", "smtp"); + props.put("mail.smtp.host", "smtp.netcabo.pt"); + props.put("mail.from", admin_email); + Session session1 = Session.getInstance(props); + Message msg = new MimeMessage(session1); + +// try +// { + //Address Email_TO = new InternetAddress("myemail@bol.com.br"); + msg.setFrom(new InternetAddress(admin_email)); + InternetAddress[] address = {new InternetAddress(emailTo)}; + msg.setRecipients(Message.RecipientType.TO, address); + msg.setSubject("Envio da password"); + msg.setSentDate(new Date()); + Multipart multipart = new MimeMultipart(); + BodyPart msgBodyPart = new MimeBodyPart(); + String html; + html=" "; + html+=""; + html+="Password: " + password + "
"; + html+=""; + msgBodyPart.setContent(html, "text/html"); + multipart.addBodyPart(msgBodyPart); + msg.setContent(multipart); + Transport.send(msg); + System.out.println("Email Enviado !!!! " + emailTo + ", " + login); +// } +// catch (Exception ex) +// { +// System.out.println("MAIL ERROR : " + ex.getMessage()); +// ex.printStackTrace(); +// } + + } + + private boolean fieldsValidationOk() + { + if(txtUtilizador.getText() != null) + { + String utilizador = (String) txtUtilizador.getText(); + if(utilizador.trim().length() == 0) + { + getSessionBean1().setMsg("Falta utilizador !"); + return false; + } + } + else + { + getSessionBean1().setMsg("Falta utilizador !"); + return false; + } + + if(txtEmail.getText() != null) + { + String email = (String) txtEmail.getText(); + if(email.trim().length() == 0) + { + getSessionBean1().setMsg("Falta email !"); + return false; + } + else + { + if(! Utils.isValidEmail(email)) + { + getSessionBean1().setMsg("Email inválido !"); + return false; + } + } + } + else + { + getSessionBean1().setMsg("Falta email !"); + return false; + } + + return true; + } + +// private boolean isValidEmail(String email){ +// boolean res = true; +// +// int indexOfAtChar=email.indexOf("@"); +// +// if(indexOfAtChar > 0) +// { +// int indexOfDotChar = +// email.indexOf(".",indexOfAtChar); +// if(indexOfDotChar > 0) +// { +// res = true; +// } +// else +// { +// res = false; +// } +// } +// else{ +// res = false; +// } +// return res; +// } + + +} + diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/RequestBean1.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/RequestBean1.java new file mode 100644 index 00000000..66ece1e4 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/RequestBean1.java @@ -0,0 +1,100 @@ +/* + * RequestBean1.java + * + * Created on September 18, 2007, 3:14 PM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.rave.web.ui.appbase.AbstractRequestBean; +import javax.faces.FacesException; + +/** + *Request scope data bean for your application. Create properties + * here to represent data that should be made available across different + * pages in the same HTTP request, so that the page bean classes do not + * have to be directly linked to each other.
+ * + *An instance of this class will be created for you automatically, + * the first time your application evaluates a value binding expression + * or method binding expression that references a managed bean using + * this class.
+ */ +public class RequestBean1 extends AbstractRequestBean { + //Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.
+ */ + private void _init() throws Exception { + } + //Construct a new request data bean instance.
+ */ + public RequestBean1() { + } + + /** + *This method is called when this bean is initially added to + * request scope. Typically, this occurs as a result of evaluating + * a value binding or method binding expression, which utilizes the + * managed bean facility to instantiate this bean and store it into + * request scope.
+ * + *You may customize this method to allocate resources that are required + * for the lifetime of the current request.
+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + //This method is called when this bean is removed from + * request scope. This occurs automatically when the corresponding + * HTTP response has been completed and sent to the client.
+ * + *You may customize this method to clean up resources allocated
+ * during the execution of the init() method, or
+ * at any later time during the lifetime of the request.
Return a reference to the scoped data bean.
+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/SessionBean1.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/SessionBean1.java new file mode 100644 index 00000000..64bdcbec --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/SessionBean1.java @@ -0,0 +1,645 @@ +/* + * SessionBean1.java + * + * Created on September 18, 2007, 3:14 PM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.rave.web.ui.appbase.AbstractSessionBean; +import javax.faces.FacesException; +import pagestate.AnaliseAcidenteTrabalhoState; + +/** + *Session scope data bean for your application. Create properties + * here to represent cached data that should be made available across + * multiple HTTP requests for an individual user.
+ * + *An instance of this class will be created for you automatically, + * the first time your application evaluates a value binding expression + * or method binding expression that references a managed bean using + * this class.
+ */ +public class SessionBean1 extends AbstractSessionBean { + //Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.
+ */ + private void _init() throws Exception { + } + //Construct a new session data bean instance.
+ */ + public SessionBean1() { + msg = new String(""); + currentUser = new Utilizador(); + analisesActualDataProvider = new db.AnalisesActualDataProvider(); + analisesSeguimentoDataProvider = new db.AnalisesSeguimentoDataProvider(); + analisesConcluidasDataProvider = new db.AnalisesConcluidasDataProvider(); + trabalhadoresListDataProvider = new db.TrabalhadoresListDataProvider(); + setEstadosCorrecaoDataProvider(new db.EstadosCorrecaoDataProvider()); + utilizadoresActivosListDataProvider = new db.UtilizadoresActivosListDataProvider(); + utilizadoresInactivosListDataProvider = new db.UtilizadoresInactivosListDataProvider(); + + setNavFrom(""); + setAcidentado(null); + setCurrentAnalise(null); + setLoggedIn(false); + + modoEdicaoUtilizador = ""; + setIdSequence(1); + setNewUser(null); + setEditUser(null); + setUserDeleted(false); + setMudarPassword(false); + } + + /** + *This method is called when this bean is initially added to + * session scope. Typically, this occurs as a result of evaluating + * a value binding or method binding expression, which utilizes the + * managed bean facility to instantiate this bean and store it into + * session scope.
+ * + *You may customize this method to initialize and cache data values + * or resources that are required for the lifetime of a particular + * user session.
+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + //This method is called when the session containing it is about to be
+ * passivated. Typically, this occurs in a distributed servlet container
+ * when the session is about to be transferred to a different
+ * container instance, after which the activate() method
+ * will be called to indicate that the transfer is complete.
You may customize this method to release references to session data + * or resources that can not be serialized with the session itself.
+ */ + public void passivate() { + } + + /** + *This method is called when the session containing it was + * reactivated.
+ * + *You may customize this method to reacquire references to session + * data or resources that could not be serialized with the + * session itself.
+ */ + public void activate() { + } + + /** + *This method is called when this bean is removed from + * session scope. Typically, this occurs as a result of + * the session timing out or being terminated by the application.
+ * + *You may customize this method to clean up resources allocated
+ * during the execution of the init() method, or
+ * at any later time during the lifetime of the application.
Return a reference to the scoped data bean.
+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + private String msg; + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + private Utilizador currentUser; + + public Utilizador getCurrentUser() { + return currentUser; + } + + public void setCurrentUser(Utilizador currentUser) { + this.currentUser = currentUser; + } + + private db.AnalisesActualDataProvider analisesActualDataProvider; + private db.AnalisesSeguimentoDataProvider analisesSeguimentoDataProvider; + private db.AnalisesConcluidasDataProvider analisesConcluidasDataProvider; + private db.TrabalhadoresListDataProvider trabalhadoresListDataProvider; + private db.EstadosCorrecaoDataProvider estadosCorrecaoDataProvider; + private db.UtilizadoresActivosListDataProvider utilizadoresActivosListDataProvider; + private db.UtilizadoresInactivosListDataProvider utilizadoresInactivosListDataProvider; + + public db.AnalisesActualDataProvider getAnalisesActualDataProvider() { + return analisesActualDataProvider; + } + + public void setAnalisesActualDataProvider(db.AnalisesActualDataProvider analisesActualDataProvider) { + this.analisesActualDataProvider = analisesActualDataProvider; + } + + public db.AnalisesSeguimentoDataProvider getAnalisesSeguimentoDataProvider() { + return analisesSeguimentoDataProvider; + } + + public void setAnalisesSeguimentoDataProvider(db.AnalisesSeguimentoDataProvider analisesSeguimentoDataProvider) { + this.analisesSeguimentoDataProvider = analisesSeguimentoDataProvider; + } + + public db.AnalisesConcluidasDataProvider getAnalisesConcluidasDataProvider() { + return analisesConcluidasDataProvider; + } + + public void setAnalisesConcluidasDataProvider(db.AnalisesConcluidasDataProvider analisesConcluidasDataProvider) { + this.analisesConcluidasDataProvider = analisesConcluidasDataProvider; + } + + public db.TrabalhadoresListDataProvider getTrabalhadoresListDataProvider() { + return trabalhadoresListDataProvider; + } + + public void setTrabalhadoresListDataProvider(db.TrabalhadoresListDataProvider trabalhadoresListDataProvider) { + this.trabalhadoresListDataProvider = trabalhadoresListDataProvider; + } + + public db.EstadosCorrecaoDataProvider getEstadosCorrecaoDataProvider() { + return estadosCorrecaoDataProvider; + } + + public void setEstadosCorrecaoDataProvider(db.EstadosCorrecaoDataProvider estadosCorrecaoDataProvider) { + this.estadosCorrecaoDataProvider = estadosCorrecaoDataProvider; + } + + public db.UtilizadoresActivosListDataProvider getUtilizadoresActivosListDataProvider() { + return utilizadoresActivosListDataProvider; + } + + public void setUtilizadoresActivosListDataProvider(db.UtilizadoresActivosListDataProvider utilizadoresActivosListDataProvider) { + this.utilizadoresActivosListDataProvider = utilizadoresActivosListDataProvider; + } + + public db.UtilizadoresInactivosListDataProvider getUtilizadoresInactivosListDataProvider() { + return utilizadoresInactivosListDataProvider; + } + + public void setUtilizadoresInactivosListDataProvider(db.UtilizadoresInactivosListDataProvider utilizadoresInactivosListDataProvider) { + this.utilizadoresInactivosListDataProvider = utilizadoresInactivosListDataProvider; + } + + private com.sun.rave.web.ui.model.Option[] anoOptions; + + private Integer anoChoice; + + public Integer getAnoChoice() { + return anoChoice; + } + + public void setAnoChoice(Integer anoChoice) { + this.anoChoice = anoChoice; + } + + public com.sun.rave.web.ui.model.Option[] getAnoOptions() { + return anoOptions; + } + + public void setAnoOptions(com.sun.rave.web.ui.model.Option[] anoOptions) { + this.anoOptions = anoOptions; + } + + private com.sun.rave.web.ui.model.Option[] mesOptions; + + private Integer mesChoice; + + public Integer getMesChoice() { + return mesChoice; + } + + public void setMesChoice(Integer mesChoice) { + this.mesChoice = mesChoice; + } + + public com.sun.rave.web.ui.model.Option[] getMesOptions() { + return mesOptions; + } + + public void setMesOptions(com.sun.rave.web.ui.model.Option[] mesOptions) { + this.mesOptions = mesOptions; + } + + private com.sun.rave.web.ui.model.Option[] diaOptions; + + private Integer diaChoice; + + public Integer getDiaChoice() { + return diaChoice; + } + + public void setDiaChoice(Integer diaChoice) { + this.diaChoice = diaChoice; + } + + public com.sun.rave.web.ui.model.Option[] getDiaOptions() { + return diaOptions; + } + + public void setDiaOptions(com.sun.rave.web.ui.model.Option[] diaOptions) { + this.diaOptions = diaOptions; + } + + private com.sun.rave.web.ui.model.Option[] departamentoOptions; + + private Integer departamentoChoice; + + public Integer getDepartamentoChoice() { + return departamentoChoice; + } + + public void setDepartamentoChoice(Integer departamentoChoice) { + this.departamentoChoice = departamentoChoice; + } + + public com.sun.rave.web.ui.model.Option[] getDepartamentoOptions() { + return departamentoOptions; + } + + public void setDepartamentoOptions(com.sun.rave.web.ui.model.Option[] departamentoOptions) { + this.departamentoOptions = departamentoOptions; + } + + private com.sun.rave.web.ui.model.Option[] seccaoOptions; + + private Integer seccaoChoice; + + public Integer getSeccaoChoice() { + return seccaoChoice; + } + + public void setSeccaoChoice(Integer seccaoChoice) { + this.seccaoChoice = seccaoChoice; + } + + public com.sun.rave.web.ui.model.Option[] getSeccaoOptions() { + return seccaoOptions; + } + + public void setSeccaoOptions(com.sun.rave.web.ui.model.Option[] seccaoOptions) { + this.seccaoOptions = seccaoOptions; + } + + private String imageName; + + public String getImageName() { + return imageName; + } + + public void setImageName(String imageName) { + this.imageName = imageName; + } + + private String navFrom; + + public String getNavFrom() { + return navFrom; + } + + public void setNavFrom(String navFrom) { + this.navFrom = navFrom; + } + + private Acidentado acidentado; + + public Acidentado getAcidentado() { + return acidentado; + } + + public void setAcidentado(Acidentado acidentado) { + this.acidentado = acidentado; + } + + private AnaliseAcidenteTrabalhoState analise_acidente_trabalho_state; + + public AnaliseAcidenteTrabalhoState getAnalise_acidente_trabalho_state() { + return analise_acidente_trabalho_state; + } + + public void setAnalise_acidente_trabalho_state(AnaliseAcidenteTrabalhoState analise_acidente_trabalho_state) { + this.analise_acidente_trabalho_state = analise_acidente_trabalho_state; + } + + private AnaliseAcidente currentAnalise; + + public AnaliseAcidente getCurrentAnalise() { + return currentAnalise; + } + + public void setCurrentAnalise(AnaliseAcidente currentAnalise) { + this.currentAnalise = currentAnalise; + } + + private boolean loggedIn; + + public boolean isLoggedIn() + { + return loggedIn; + } + + public void setLoggedIn(boolean loggedIn) + { + this.loggedIn = loggedIn; + } + + private String modoEdicaoUtilizador; + + public String getModoEdicaoUtilizador() { + return modoEdicaoUtilizador; + } + + public void setModoEdicaoUtilizador(String modoEdicaoUtilizador) { + this.modoEdicaoUtilizador = modoEdicaoUtilizador; + } + + private Integer tipoChoice; + + public Integer getTipoChoice() { + return tipoChoice; + } + + public void setTipoChoice(Integer tipoChoice) { + this.tipoChoice = tipoChoice; + } + + private com.sun.rave.web.ui.model.Option[] tiposOptions; + + public com.sun.rave.web.ui.model.Option[] getTiposOptions() { + return tiposOptions; + } + + public void setTiposOptions(com.sun.rave.web.ui.model.Option[] tiposOptions) { + this.tiposOptions = tiposOptions; + } + + + private Integer estabelecimentoChoice; + + public Integer getEstabelecimentoChoice() { + return estabelecimentoChoice; + } + + public void setEstabelecimentoChoice(Integer estabelecimentoChoice) { + this.estabelecimentoChoice = estabelecimentoChoice; + } + + private com.sun.rave.web.ui.model.Option[] estabelecimentosOptions; + + public com.sun.rave.web.ui.model.Option[] getEstabelecimentosOptions() { + return estabelecimentosOptions; + } + + public void setEstabelecimentosOptions(com.sun.rave.web.ui.model.Option[] estabelecimentosOptions) { + this.estabelecimentosOptions = estabelecimentosOptions; + } + + + // + private Integer estabelecimentoOutroChoice; + + public Integer getEstabelecimentoOutroChoice() { + return estabelecimentoOutroChoice; + } + + public void setEstabelecimentoOutroChoice(Integer estabelecimentoOutroChoice) { + this.estabelecimentoOutroChoice = estabelecimentoOutroChoice; + } + + private com.sun.rave.web.ui.model.Option[] estabelecimentosOutroOptions; + + public com.sun.rave.web.ui.model.Option[] getEstabelecimentosOutroOptions() { + return estabelecimentosOutroOptions; + } + + public void setEstabelecimentosOutroOptions(com.sun.rave.web.ui.model.Option[] estabelecimentosOutroOptions) { + this.estabelecimentosOutroOptions = estabelecimentosOutroOptions; + } + + + private Integer estabelecimentoMedChoice; + + public Integer getEstabelecimentoMedChoice() { + return estabelecimentoMedChoice; + } + + public void setEstabelecimentoMedChoice(Integer estabelecimentoMedChoice) { + this.estabelecimentoMedChoice = estabelecimentoMedChoice; + } + + private com.sun.rave.web.ui.model.Option[] estabelecimentosMedOptions; + + public com.sun.rave.web.ui.model.Option[] getEstabelecimentosMedOptions() { + return estabelecimentosMedOptions; + } + + public void setEstabelecimentosMedOptions(com.sun.rave.web.ui.model.Option[] estabelecimentosMedOptions) { + this.estabelecimentosMedOptions = estabelecimentosMedOptions; + } + + private Integer tecnicoChoice; + + public Integer getTecnicoChoice() { + return tecnicoChoice; + } + + public void setTecnicoChoice(Integer tecnicoChoice) { + this.tecnicoChoice = tecnicoChoice; + } + + private com.sun.rave.web.ui.model.Option[] tecnicosOptions; + + public com.sun.rave.web.ui.model.Option[] getTecnicosOptions() { + return tecnicosOptions; + } + + public void setTecnicosOptions(com.sun.rave.web.ui.model.Option[] tecnicosOptions) { + this.tecnicosOptions = tecnicosOptions; + } + + + private Integer medicoChoice; + + public Integer getMedicoChoice() { + return medicoChoice; + } + + public void setMedicoChoice(Integer medicoChoice) { + this.medicoChoice = medicoChoice; + } + + private com.sun.rave.web.ui.model.Option[] medicosOptions; + + public com.sun.rave.web.ui.model.Option[] getMedicosOptions() { + return medicosOptions; + } + + public void setMedicosOptions(com.sun.rave.web.ui.model.Option[] medicosOptions) { + this.medicosOptions = medicosOptions; + } + + + // Clock : + private Integer horaChoice; + + public Integer getHoraChoice() { + return horaChoice; + } + + public void setHoraChoice(Integer horaChoice) { + this.horaChoice = horaChoice; + } + + private com.sun.rave.web.ui.model.Option[] horasOptions; + + public com.sun.rave.web.ui.model.Option[] getHorasOptions() { + return horasOptions; + } + + public void setHorasOptions(com.sun.rave.web.ui.model.Option[] horasOptions) { + this.horasOptions = horasOptions; + } + + + private Integer minutoChoice; + + public Integer getMinutoChoice() { + return minutoChoice; + } + + public void setMinutoChoice(Integer minutoChoice) { + this.minutoChoice = minutoChoice; + } + + private com.sun.rave.web.ui.model.Option[] minutosOptions; + + public com.sun.rave.web.ui.model.Option[] getMinutosOptions() { + return minutosOptions; + } + + public void setMinutosOptions(com.sun.rave.web.ui.model.Option[] minutosOptions) { + this.minutosOptions = minutosOptions; + } + + + private Integer causaChoice; + + public Integer getCausaChoice() { + return causaChoice; + } + + public void setCausaChoice(Integer causaChoice) { + this.causaChoice = causaChoice; + } + + private com.sun.rave.web.ui.model.Option[] causasOptions; + + public com.sun.rave.web.ui.model.Option[] getCausasOptions() { + return causasOptions; + } + + public void setCausasOptions(com.sun.rave.web.ui.model.Option[] causasOptions) { + this.causasOptions = causasOptions; + } + + private int idSequence; + + public int getIdSequence() { + return idSequence; + } + + public void setIdSequence(int idSequence) { + this.idSequence = idSequence; + } + + private NewUser newUser; + + public NewUser getNewUser() { + return newUser; + } + + public void setNewUser(NewUser newUser) { + this.newUser = newUser; + } + + private Utilizador editUser; + + public Utilizador getEditUser() { + return editUser; + } + + public void setEditUser(Utilizador editUser) { + this.editUser = editUser; + } + + private boolean userDeleted; + + public boolean isUserDeleted() { + return userDeleted; + } + + public void setUserDeleted(boolean userDeleted) { + this.userDeleted = userDeleted; + } + + private boolean mudarPassword; + + public boolean isMudarPassword() { + return mudarPassword; + } + + public void setMudarPassword(boolean mudarPassword) { + this.mudarPassword = mudarPassword; + } + + private Medico medico; + + public Medico getMedico() { + return medico; + } + + public void setMedico(Medico medico) { + this.medico = medico; + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/TecnicoSaude.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/TecnicoSaude.java new file mode 100644 index 00000000..7980ae83 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/TecnicoSaude.java @@ -0,0 +1,44 @@ +/* + * TecnicoSaude.java + * + * Created on October 12, 2007, 11:00 AM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package analiseacidentestrabalho; + +/** + * + * @author lluis + */ +public class TecnicoSaude { + private Integer id; + private String nome; + + /** Creates a new instance of TecnicoSaude */ + public TecnicoSaude() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getNome() { + return nome; + } + + public void setNome(String nome) { + this.nome = nome; + } + + public String toString() { + return utils.Utils.unicodeToHTML(nome); + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/TipoUtilizador.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/TipoUtilizador.java new file mode 100644 index 00000000..749160c9 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/TipoUtilizador.java @@ -0,0 +1,67 @@ +/* + * TipoUtilizador.java + * + * Created on October 11, 2007, 4:32 PM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package analiseacidentestrabalho; + +/** + * + * @author lluis + */ +public class TipoUtilizador { + private Integer id; + private Integer tipo; + private String descricao; + private String activo; + private Integer ordem; + + /** Creates a new instance of TipoUtilizador */ + public TipoUtilizador() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getTipo() { + return tipo; + } + + public void setTipo(Integer tipo) { + this.tipo = tipo; + } + + public String getDescricao() { + return descricao; + } + + public void setDescricao(String descricao) { + this.descricao = descricao; + } + + public String getActivo() { + return activo; + } + + public void setActivo(String activo) { + this.activo = activo; + } + + public Integer getOrdem() { + return ordem; + } + + public void setOrdem(Integer ordem) { + this.ordem = ordem; + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Top.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Top.java new file mode 100644 index 00000000..d183ddf6 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Top.java @@ -0,0 +1,203 @@ +/* + * Top.java + * + * Created on September 20, 2007, 11:04 AM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.rave.web.ui.appbase.AbstractFragmentBean; +import com.sun.rave.web.ui.component.Hyperlink; +import com.sun.rave.web.ui.component.ImageComponent; +import com.sun.rave.web.ui.component.PanelGroup; +import com.sun.rave.web.ui.component.StaticText; +import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; + +/** + *Fragment bean that corresponds to a similarly named JSP page + * fragment. This class contains component definitions (and initialization + * code) for all components that you have defined on this fragment, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.
+ */ +public class Top extends AbstractFragmentBean { + //Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.
+ */ + private void _init() throws Exception { + } + + private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel1() { + return gridPanel1; + } + + public void setGridPanel1(HtmlPanelGrid hpg) { + this.gridPanel1 = hpg; + } + + private PanelGroup groupPanel1 = new PanelGroup(); + + public PanelGroup getGroupPanel1() { + return groupPanel1; + } + + public void setGroupPanel1(PanelGroup pg) { + this.groupPanel1 = pg; + } + + private ImageComponent image1 = new ImageComponent(); + + public ImageComponent getImage1() { + return image1; + } + + public void setImage1(ImageComponent ic) { + this.image1 = ic; + } + + private ImageComponent image2 = new ImageComponent(); + + public ImageComponent getImage2() { + return image2; + } + + public void setImage2(ImageComponent ic) { + this.image2 = ic; + } + + private PanelGroup groupPanel2 = new PanelGroup(); + + public PanelGroup getGroupPanel2() { + return groupPanel2; + } + + public void setGroupPanel2(PanelGroup pg) { + this.groupPanel2 = pg; + } + + private StaticText lblUser = new StaticText(); + + public StaticText getLblUser() { + return lblUser; + } + + public void setLblUser(StaticText st) { + this.lblUser = st; + } + + private StaticText staticText2 = new StaticText(); + + public StaticText getStaticText2() { + return staticText2; + } + + public void setStaticText2(StaticText st) { + this.staticText2 = st; + } + + private Hyperlink lnkChangePassword = new Hyperlink(); + + public Hyperlink getLnkChangePassword() { + return lnkChangePassword; + } + + public void setLnkChangePassword(Hyperlink h) { + this.lnkChangePassword = h; + } + + private StaticText staticText3 = new StaticText(); + + public StaticText getStaticText3() { + return staticText3; + } + + public void setStaticText3(StaticText st) { + this.staticText3 = st; + } + + private Hyperlink lnkLogout = new Hyperlink(); + + public Hyperlink getLnkLogout() { + return lnkLogout; + } + + public void setLnkLogout(Hyperlink h) { + this.lnkLogout = h; + } + //Callback method that is called whenever a page containing + * this page fragment is navigated to, either directly via a URL, + * or indirectly via page navigation. Override this method to acquire + * resources that will be needed for event handlers and lifecycle methods.
+ * + *The default implementation does nothing.
+ */ + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + + //Callback method that is called after rendering is completed for
+ * this request, if init() was called. Override this
+ * method to release resources acquired in the init()
+ * resources that will be needed for event handlers and lifecycle methods.
The default implementation does nothing.
+ */ + public void destroy() { + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Trabalhador.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Trabalhador.java new file mode 100644 index 00000000..446c026e --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Trabalhador.java @@ -0,0 +1,95 @@ +/* + * Trabalhador.java + * + * Created on September 26, 2007, 4:23 PM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package analiseacidentestrabalho; + +/** + * + * @author lluis + */ +public class Trabalhador { + private Integer id; + private String nome; + private java.sql.Date data_nascimento; + private String funcao; + private java.sql.Date data_admissao; + private String numero_mecanografico; + private Integer estabelecimento_id; + private String estabelecimento; + + + /** Creates a new instance of Trabalhador */ + public Trabalhador() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getNome() { + return nome; + } + + public void setNome(String nome) { + this.nome = nome; + } + + public java.sql.Date getData_nascimento() { + return data_nascimento; + } + + public void setData_nascimento(java.sql.Date data_nascimento) { + this.data_nascimento = data_nascimento; + } + + public String getFuncao() { + return funcao; + } + + public void setFuncao(String funcao) { + this.funcao = funcao; + } + + public java.sql.Date getData_admissao() { + return data_admissao; + } + + public void setData_admissao(java.sql.Date data_admissao) { + this.data_admissao = data_admissao; + } + + public String getNumero_mecanografico() { + return numero_mecanografico; + } + + public void setNumero_mecanografico(String numero_mecanografico) { + this.numero_mecanografico = numero_mecanografico; + } + + public String getEstabelecimento() { + return estabelecimento; + } + + public void setEstabelecimento(String estabelecimento) { + this.estabelecimento = estabelecimento; + } + + public Integer getEstabelecimento_id() { + return estabelecimento_id; + } + + public void setEstabelecimento_id(Integer estabelecimento_id) { + this.estabelecimento_id = estabelecimento_id; + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Utilizador.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Utilizador.java new file mode 100644 index 00000000..6e375480 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/Utilizador.java @@ -0,0 +1,249 @@ +/* + * Utilizador.java + * + * Created on September 20, 2007, 9:58 AM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package analiseacidentestrabalho; + +import java.sql.Date; + +/** + * + * @author lluis + */ +public class Utilizador { + private Integer id; + private String login; + private String password; + private String email; + private Integer empresa_id; + private Integer estabelecimento_id; + private String administrador; + private Integer tipo; + private String numero_cedula; + private String cap; + + private Integer codigo_permissao; + + private String nome; + + private Integer medico_id; + private Integer funcionario_hst_id; + + private String activo; + + private Integer acesso; + private String responsavel_loja; + private String gestor_geral; + + private String numero_mecanografico; + private String categoria; //descricao do 'tipo'' + private String nome_estabelecimento; + + private String primeiro_login; + + private String apagado; + + private Date data_password; + + /** Creates a new instance of Utilizador */ + public Utilizador() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getLogin() { + return login; + } + + public void setLogin(String login) { + this.login = login; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public Integer getEmpresa_id() { + return empresa_id; + } + + public void setEmpresa_id(Integer empresa_id) { + this.empresa_id = empresa_id; + } + + public Integer getEstabelecimento_id() { + return estabelecimento_id; + } + + public void setEstabelecimento_id(Integer estabelecimento_id) { + this.estabelecimento_id = estabelecimento_id; + } + + public String getAdministrador() { + return administrador; + } + + public void setAdministrador(String administrador) { + this.administrador = administrador; + } + + public Integer getCodigo_permissao() { + return codigo_permissao; + } + + public void setCodigo_permissao(Integer codigo_permissao) { + this.codigo_permissao = codigo_permissao; + } + + public Integer getTipo() { + return tipo; + } + + public void setTipo(Integer tipo) { + this.tipo = tipo; + } + + public String getNumero_cedula() { + return numero_cedula; + } + + public void setNumero_cedula(String numero_cedula) { + this.numero_cedula = numero_cedula; + } + + public String getCap() { + return cap; + } + + public void setCap(String cap) { + this.cap = cap; + } + + public String getNome() { + return nome; + } + + public void setNome(String nome) { + this.nome = nome; + } + + public Integer getMedico_id() { + return medico_id; + } + + public void setMedico_id(Integer medico_id) { + this.medico_id = medico_id; + } + + public Integer getFuncionario_hst_id() { + return funcionario_hst_id; + } + + public void setFuncionario_hst_id(Integer funcionario_hst_id) { + this.funcionario_hst_id = funcionario_hst_id; + } + + public String getActivo() { + return activo; + } + + public void setActivo(String activo) { + this.activo = activo; + } + + public Integer getAcesso() { + return acesso; + } + + public void setAcesso(Integer acesso) { + this.acesso = acesso; + } + + public String getResponsavel_loja() { + return responsavel_loja; + } + + public void setResponsavel_loja(String responsavel_loja) { + this.responsavel_loja = responsavel_loja; + } + + public String getNumero_mecanografico() { + return numero_mecanografico; + } + + public void setNumero_mecanografico(String numero_mecanografico) { + this.numero_mecanografico = numero_mecanografico; + } + + public String getCategoria() { + return categoria; + } + + public void setCategoria(String categoria) { + this.categoria = categoria; + } + + public String getNome_estabelecimento() { + return nome_estabelecimento; + } + + public void setNome_estabelecimento(String nome_estabelecimento) { + this.nome_estabelecimento = nome_estabelecimento; + } + + public String getGestor_geral() { + return gestor_geral; + } + + public void setGestor_geral(String gestor_geral) { + this.gestor_geral = gestor_geral; + } + + public String getPrimeiro_login() { + return primeiro_login; + } + + public void setPrimeiro_login(String primeiro_login) { + this.primeiro_login = primeiro_login; + } + + public String getApagado() { + return apagado; + } + + public void setApagado(String apagado) { + this.apagado = apagado; + } + + public Date getData_password() { + return data_password; + } + + public void setData_password(Date data_password) { + this.data_password = data_password; + } + +} diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/ViewAnaliseAcidenteTrabalho.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/ViewAnaliseAcidenteTrabalho.java new file mode 100644 index 00000000..92ebac19 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/ViewAnaliseAcidenteTrabalho.java @@ -0,0 +1,4440 @@ +/* + * ViewAnaliseAcidenteTrabalho.java + * + * Created on October 1, 2007, 10:48 AM + * Copyright lluis + */ +package analiseacidentestrabalho; + +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.rave.web.ui.component.Body; +import com.sun.rave.web.ui.component.Button; +import com.sun.rave.web.ui.component.Form; +import com.sun.rave.web.ui.component.Head; +import com.sun.rave.web.ui.component.Html; +import com.sun.rave.web.ui.component.Hyperlink; +import com.sun.rave.web.ui.component.ImageComponent; +import com.sun.rave.web.ui.component.Link; +import com.sun.rave.web.ui.component.Page; +import com.sun.rave.web.ui.component.PanelGroup; +import com.sun.rave.web.ui.component.StaticText; +import db.AnalisesDataProvider; +import db.UtilizadoresDataProvider; +import global.Global; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.ListIterator; +import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; +import javax.servlet.ServletContext; +import utils.Utils; + +/** + *Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.
+ */ +public class ViewAnaliseAcidenteTrabalho extends AbstractPageBean { + //Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.
+ */ + private void _init() throws Exception { + } + + private Page page1 = new Page(); + + public Page getPage1() { + return page1; + } + + public void setPage1(Page p) { + this.page1 = p; + } + + private Html html1 = new Html(); + + public Html getHtml1() { + return html1; + } + + public void setHtml1(Html h) { + this.html1 = h; + } + + private Head head1 = new Head(); + + public Head getHead1() { + return head1; + } + + public void setHead1(Head h) { + this.head1 = h; + } + + private Link link1 = new Link(); + + public Link getLink1() { + return link1; + } + + public void setLink1(Link l) { + this.link1 = l; + } + + private Body body1 = new Body(); + + public Body getBody1() { + return body1; + } + + public void setBody1(Body b) { + this.body1 = b; + } + + private Form form1 = new Form(); + + public Form getForm1() { + return form1; + } + + public void setForm1(Form f) { + this.form1 = f; + } + + private HtmlPanelGrid gridBase1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridBase1() { + return gridBase1; + } + + public void setGridBase1(HtmlPanelGrid hpg) { + this.gridBase1 = hpg; + } + + private HtmlPanelGrid gridLayout1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridLayout1() { + return gridLayout1; + } + + public void setGridLayout1(HtmlPanelGrid hpg) { + this.gridLayout1 = hpg; + } + + private HtmlPanelGrid gridMsg1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridMsg1() { + return gridMsg1; + } + + public void setGridMsg1(HtmlPanelGrid hpg) { + this.gridMsg1 = hpg; + } + + private StaticText txtMsg1 = new StaticText(); + + public StaticText getTxtMsg1() { + return txtMsg1; + } + + public void setTxtMsg1(StaticText st) { + this.txtMsg1 = st; + } + + private HtmlPanelGrid gridCabecalho1 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridCabecalho1() { + return gridCabecalho1; + } + + public void setGridCabecalho1(HtmlPanelGrid hpg) { + this.gridCabecalho1 = hpg; + } + + private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel2() { + return gridPanel2; + } + + public void setGridPanel2(HtmlPanelGrid hpg) { + this.gridPanel2 = hpg; + } + + private StaticText lblEmpresa1 = new StaticText(); + + public StaticText getLblEmpresa1() { + return lblEmpresa1; + } + + public void setLblEmpresa1(StaticText st) { + this.lblEmpresa1 = st; + } + + private StaticText txtEmpresa = new StaticText(); + + public StaticText getTxtEmpresa() { + return txtEmpresa; + } + + public void setTxtEmpresa(StaticText st) { + this.txtEmpresa = st; + } + + private StaticText staticText4 = new StaticText(); + + public StaticText getStaticText4() { + return staticText4; + } + + public void setStaticText4(StaticText st) { + this.staticText4 = st; + } + + private StaticText txtEstabelecimento = new StaticText(); + + public StaticText getTxtEstabelecimento() { + return txtEstabelecimento; + } + + public void setTxtEstabelecimento(StaticText st) { + this.txtEstabelecimento = st; + } + + private StaticText lblTrabalhador1 = new StaticText(); + + public StaticText getLblTrabalhador1() { + return lblTrabalhador1; + } + + public void setLblTrabalhador1(StaticText st) { + this.lblTrabalhador1 = st; + } + + private StaticText txtTrabalhador = new StaticText(); + + public StaticText getTxtTrabalhador() { + return txtTrabalhador; + } + + public void setTxtTrabalhador(StaticText st) { + this.txtTrabalhador = st; + } + + private HtmlPanelGrid gridDadosAcidenteSegView = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridDadosAcidenteSegView() { + return gridDadosAcidenteSegView; + } + + public void setGridDadosAcidenteSegView(HtmlPanelGrid hpg) { + this.gridDadosAcidenteSegView = hpg; + } + + private HtmlPanelGrid gridPanel8 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel8() { + return gridPanel8; + } + + public void setGridPanel8(HtmlPanelGrid hpg) { + this.gridPanel8 = hpg; + } + + private StaticText staticText13 = new StaticText(); + + public StaticText getStaticText13() { + return staticText13; + } + + public void setStaticText13(StaticText st) { + this.staticText13 = st; + } + + private HtmlPanelGrid gridPanel9 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel9() { + return gridPanel9; + } + + public void setGridPanel9(HtmlPanelGrid hpg) { + this.gridPanel9 = hpg; + } + + private HtmlPanelGrid gridTurnoSeccaoLocal = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridTurnoSeccaoLocal() { + return gridTurnoSeccaoLocal; + } + + public void setGridTurnoSeccaoLocal(HtmlPanelGrid hpg) { + this.gridTurnoSeccaoLocal = hpg; + } + + private HtmlPanelGrid gridTarefa = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridTarefa() { + return gridTarefa; + } + + public void setGridTarefa(HtmlPanelGrid hpg) { + this.gridTarefa = hpg; + } + + private StaticText lblTarefa = new StaticText(); + + public StaticText getLblTarefa() { + return lblTarefa; + } + + public void setLblTarefa(StaticText st) { + this.lblTarefa = st; + } + + private HtmlPanelGrid gridSubstancias = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridSubstancias() { + return gridSubstancias; + } + + public void setGridSubstancias(HtmlPanelGrid hpg) { + this.gridSubstancias = hpg; + } + + private StaticText lblSubstancias = new StaticText(); + + public StaticText getLblSubstancias() { + return lblSubstancias; + } + + public void setLblSubstancias(StaticText st) { + this.lblSubstancias = st; + } + + private HtmlPanelGrid gridCondicoes = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridCondicoes() { + return gridCondicoes; + } + + public void setGridCondicoes(HtmlPanelGrid hpg) { + this.gridCondicoes = hpg; + } + + private StaticText lblCondicoes = new StaticText(); + + public StaticText getLblCondicoes() { + return lblCondicoes; + } + + public void setLblCondicoes(StaticText st) { + this.lblCondicoes = st; + } + + private HtmlPanelGrid gridTestemunhas = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridTestemunhas() { + return gridTestemunhas; + } + + public void setGridTestemunhas(HtmlPanelGrid hpg) { + this.gridTestemunhas = hpg; + } + + private StaticText lblTestemunhas = new StaticText(); + + public StaticText getLblTestemunhas() { + return lblTestemunhas; + } + + public void setLblTestemunhas(StaticText st) { + this.lblTestemunhas = st; + } + + private HtmlPanelGrid gridCausas = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridCausas() { + return gridCausas; + } + + public void setGridCausas(HtmlPanelGrid hpg) { + this.gridCausas = hpg; + } + + private StaticText lblCausas = new StaticText(); + + public StaticText getLblCausas() { + return lblCausas; + } + + public void setLblCausas(StaticText st) { + this.lblCausas = st; + } + + private HtmlPanelGrid gridDescricao = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridDescricao() { + return gridDescricao; + } + + public void setGridDescricao(HtmlPanelGrid hpg) { + this.gridDescricao = hpg; + } + + private StaticText lblDescricao = new StaticText(); + + public StaticText getLblDescricao() { + return lblDescricao; + } + + public void setLblDescricao(StaticText st) { + this.lblDescricao = st; + } + + private HtmlPanelGrid gridFotografias = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridFotografias() { + return gridFotografias; + } + + public void setGridFotografias(HtmlPanelGrid hpg) { + this.gridFotografias = hpg; + } + + private HtmlPanelGrid gridPanel19 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPanel19() { + return gridPanel19; + } + + public void setGridPanel19(HtmlPanelGrid hpg) { + this.gridPanel19 = hpg; + } + + private StaticText lblFotografias = new StaticText(); + + public StaticText getLblFotografias() { + return lblFotografias; + } + + public void setLblFotografias(StaticText st) { + this.lblFotografias = st; + } + + private HtmlPanelGrid gridImages = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridImages() { + return gridImages; + } + + public void setGridImages(HtmlPanelGrid hpg) { + this.gridImages = hpg; + } + + private HtmlPanelGrid gridConclusoes = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridConclusoes() { + return gridConclusoes; + } + + public void setGridConclusoes(HtmlPanelGrid hpg) { + this.gridConclusoes = hpg; + } + + private StaticText lblConclusoes = new StaticText(); + + public StaticText getLblConclusoes() { + return lblConclusoes; + } + + public void setLblConclusoes(StaticText st) { + this.lblConclusoes = st; + } + + private HtmlPanelGrid gridAccoes = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridAccoes() { + return gridAccoes; + } + + public void setGridAccoes(HtmlPanelGrid hpg) { + this.gridAccoes = hpg; + } + + private StaticText lblAccoes = new StaticText(); + + public StaticText getLblAccoes() { + return lblAccoes; + } + + public void setLblAccoes(StaticText st) { + this.lblAccoes = st; + } + + private StaticText txtAccoes = new StaticText(); + + public StaticText getTxtAccoes() { + return txtAccoes; + } + + public void setTxtAccoes(StaticText st) { + this.txtAccoes = st; + } + + private StaticText txtConclusoes = new StaticText(); + + public StaticText getTxtConclusoes() { + return txtConclusoes; + } + + public void setTxtConclusoes(StaticText st) { + this.txtConclusoes = st; + } + + private StaticText txtDescricao = new StaticText(); + + public StaticText getTxtDescricao() { + return txtDescricao; + } + + public void setTxtDescricao(StaticText st) { + this.txtDescricao = st; + } + + private StaticText txtCausas = new StaticText(); + + public StaticText getTxtCausas() { + return txtCausas; + } + + public void setTxtCausas(StaticText st) { + this.txtCausas = st; + } + + private StaticText txtTestemunhas = new StaticText(); + + public StaticText getTxtTestemunhas() { + return txtTestemunhas; + } + + public void setTxtTestemunhas(StaticText st) { + this.txtTestemunhas = st; + } + + private StaticText txtCondicoes = new StaticText(); + + public StaticText getTxtCondicoes() { + return txtCondicoes; + } + + public void setTxtCondicoes(StaticText st) { + this.txtCondicoes = st; + } + + private StaticText txtSubstancias = new StaticText(); + + public StaticText getTxtSubstancias() { + return txtSubstancias; + } + + public void setTxtSubstancias(StaticText st) { + this.txtSubstancias = st; + } + + private StaticText txtTarefa = new StaticText(); + + public StaticText getTxtTarefa() { + return txtTarefa; + } + + public void setTxtTarefa(StaticText st) { + this.txtTarefa = st; + } + + //Construct a new Page bean instance.
+ */ + public ViewAnaliseAcidenteTrabalho() { + } + + /** + *Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.
+ * + *Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.
+ */ + public void init() { + // Perform initializations inherited from our superclasssuperclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + //Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.
+ */ + public void preprocess() { + } + + /** + *Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.
+ */ + public void prerender() { + } + + /** + *Callback method that is called after rendering is completed for
+ * this request, if init() was called (regardless of whether
+ * or not this was the page that was actually rendered). Customize this
+ * method to release resources acquired in the init(),
+ * preprocess(), or prerender() methods (or
+ * acquired during execution of an event handler).
Return a reference to the scoped data bean.
+ */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1)getBean("SessionBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1)getBean("RequestBean1"); + } + + /** + *Return a reference to the scoped data bean.
+ */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1)getBean("ApplicationBean1"); + } + + public String lnkLogout_action() { + // TODO: Replace with your code + + if (getSessionBean1().isLoggedIn()) { +// try { +// getExternalContext().redirect("Login.jsp"); +// } catch(Exception e) {} + + try + { + javax.servlet.http.HttpSession session = + (javax.servlet.http.HttpSession) getExternalContext().getSession(true); + session.invalidate(); + } + catch(Exception ex){} + + } + + try { + getExternalContext().redirect("Login.jsp"); + } catch(Exception e) {} + //return "login"; + return null; + } + + public String lnkNome_action() { + // TODO: Replace with your code + + return null; + } + + public String lnkDataNascimento_action() { + // TODO: Replace with your code + + return null; + } + + private void initializePage() + { + fillPage(); + //fillImages(); + } + + private void fillPage() + { + AnaliseAcidente a = getSessionBean1().getCurrentAnalise(); + fillHeader(a); + fillSIPRP(a); + + AnalisesDataProvider adp = new AnalisesDataProvider(); + Acidentado ac = null; + try + { + ac = adp.getAcidentado(a.getAcidentado_id()); + //txtTrabalhador.setText(ac.getNome()); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + + int estado = a.getEstado().intValue(); + switch(estado) + { + case Global.ESTADO_SEG: + gridDadosAcidenteRhView.setRendered(false); + gridRecomendacoesViewHS.setRendered(false); + gridMedidasViewRH.setRendered(false); + gridMedicoView.setRendered(false); + gridVerificacaoView.setRendered(false); + gridImpressaoView.setRendered(false); + + fillAcidentado(ac); + fillDadosAcidenteSeg(a); + break; + case Global.ESTADO_RH1: + gridDadosAcidenteRhView.setRendered(false); + gridRecomendacoesViewHS.setRendered(false); + gridMedidasViewRH.setRendered(false); + gridMedicoView.setRendered(false); + gridVerificacaoView.setRendered(false); + gridImpressaoView.setRendered(false); + + fillAcidentado(ac); + fillDadosAcidenteSeg(a); + break; + case Global.ESTADO_HS: + gridRecomendacoesViewHS.setRendered(false); + gridMedidasViewRH.setRendered(false); + gridMedicoView.setRendered(false); + gridVerificacaoView.setRendered(false); + gridImpressaoView.setRendered(false); + + fillAcidentado(ac); + fillDadosAcidenteSeg(a); + fillDadosAcidenteRh(a); + break; + case Global.ESTADO_RH2: //medidas + gridMedidasViewRH.setRendered(false); + gridMedicoView.setRendered(false); + gridVerificacaoView.setRendered(false); + gridImpressaoView.setRendered(false); + + fillAcidentado(ac); + fillDadosAcidenteSeg(a); + fillDadosAcidenteRh(a); + fillRecomendacoesHs(a); + + break; +// case Global.ESTADO_MEDICINA: +// gridMedicoView.setRendered(false); +// gridVerificacaoView.setRendered(false); +// gridImpressaoView.setRendered(false); +// +// fillAcidentado(ac); +// fillDadosAcidenteSeg(a); +// fillDadosAcidenteRh(a); +// fillRecomendacoesHs(a); +// fillMedidasRh(a); +// break; + case Global.ESTADO_CONSOLIDACAO: + gridVerificacaoView.setRendered(false); + gridImpressaoView.setRendered(false); + + fillAcidentado(ac); + fillDadosAcidenteSeg(a); + fillDadosAcidenteRh(a); + fillRecomendacoesHs(a); + fillMedidasRh(a); + fillMedico(a); + break; + case Global.ESTADO_ASSINATURA_SEG: + //gridMedidasViewRH.setRendered(false); + //gridMedicoView.setRendered(false); + //gridVerificacaoView.setRendered(false); + gridImpressaoView.setRendered(false); + + fillAcidentado(ac); + fillDadosAcidenteSeg(a); + fillDadosAcidenteRh(a); + fillRecomendacoesHs(a); + fillMedidasRh(a); + fillMedico(a); + fillVerificacao(a); + break; + + case Global.ESTADO_ASSINATURA_RH: + //gridMedidasViewRH.setRendered(false); + //gridMedicoView.setRendered(false); + //gridVerificacaoView.setRendered(false); + gridImpressaoView.setRendered(false); + + fillAcidentado(ac); + fillDadosAcidenteSeg(a); + fillDadosAcidenteRh(a); + fillRecomendacoesHs(a); + fillMedidasRh(a); + fillMedico(a); + fillVerificacao(a); + break; + + +// case Global.ESTADO_IMPRESSAO: +// gridImpressaoView.setRendered(false); +// +// fillAcidentado(ac); +// fillDadosAcidenteSeg(a); +// fillDadosAcidenteRh(a); +// fillRecomendacoesHs(a); +// fillMedidasRh(a); +// fillMedico(a); +// fillVerificacao(a); +// break; + + case Global.ESTADO_FECHAR: + gridImpressaoView.setRendered(false); + + fillAcidentado(ac); + fillDadosAcidenteSeg(a); + fillDadosAcidenteRh(a); + fillRecomendacoesHs(a); + fillMedidasRh(a); + fillMedico(a); + fillVerificacao(a); + //fillImpressao(a); + break; + case Global.ESTADO_CONCLUIDO: + gridImpressaoView.setRendered(false); + + fillAcidentado(ac); + fillDadosAcidenteSeg(a); + fillDadosAcidenteRh(a); + fillRecomendacoesHs(a); + fillMedidasRh(a); + fillMedico(a); + fillVerificacao(a); + + break; + } + } + + private void fillHeader(AnaliseAcidente a) + { + stHeaderNr.setText(a.getAnalise_nr()); + try + { + java.util.Date ddate = new java.util.Date(a.getData_acidente().getTime()); + stHeaderDate.setText(utils.Utils.dateToYYYYMMDD(ddate)); + } + catch(Exception ex){}; + } + + private void fillSIPRP(AnaliseAcidente a) + { + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + try + { + Utilizador u = udp.getUtilizador(a.getTecnico_saude_id()); + txtTecnicoSuperior.setText(Utils.unicodeToHTML(u.getNome())); + txtCap1.setText(u.getCap()); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + try + { + Utilizador u = udp.getUtilizador(a.getMedico_id()); + txtMedicoTrabalho.setText(Utils.unicodeToHTML(u.getNome())); + txtCedula1.setText(u.getNumero_cedula()); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + } + + private void fillAcidentado(Acidentado a) + { + stNomeAcidentado.setText(a.getNome()); + //stDataNascimento.setText(a.getData_nascimento()); + try + { + java.util.Date ddate = new java.util.Date(a.getData_nascimento().getTime()); + stDataNascimento.setText(utils.Utils.dateToYYYYMMDD(ddate)); + } + catch(Exception ex){}; + stBI.setText(a.getBilhete_identidade()); + stMorada.setText(a.getMorada()); + String cod_postal1 = ""; + String cod_postal2 = ""; + try + { + cod_postal1 = a.getCod_postal().substring(0, 4); + } + catch(Exception ex){} + try + { + cod_postal2 = a.getCod_postal().substring(5, 8); + } + catch(Exception ex){} + + //String cod_postal1 = a.getCod_postal().substring(0, 4); + //String cod_postal2 = a.getCod_postal().substring(5, 8); + String cod_postal = cod_postal1 + "-" + cod_postal2 + " " + a.getLocalidade(); + stCodPostal.setText(cod_postal); + stContactoTelefonico.setText(a.getContacto_telefonico()); + //stDataAdmissao1.setText(a.getData_admissao()); + try + { + java.util.Date ddate = new java.util.Date(a.getData_admissao().getTime()); + stDataAdmissao.setText(utils.Utils.dateToYYYYMMDD(ddate)); + } + catch(Exception ex){}; + stFuncao.setText(a.getFuncao()); + String turno_str = ""; + if(a.getTurno().matches("m")) + { + turno_str = "manhã"; + } + else if(a.getTurno().matches("t")) + { + turno_str += "tarde "; + } + if(a.getTurno().matches("n")) + { + turno_str += "noite"; + } + stTurno.setText(turno_str); + stNomeSuperior.setText(a.getNome_superior_hierarquico()); + stEmailSuperior.setText(a.getEmail_superior_hierarquico()); + stEstabelecimentoOrigem.setText(a.getEstabelecimento_origem()); + } + + private void fillDadosAcidenteSeg(AnaliseAcidente a) + { + AnalisesDataProvider adp = new AnalisesDataProvider(); + try + { + String nome_empresa = adp.getEmpresaNome(a.getEmpresa_id()); + txtEmpresa.setText(utils.Utils.unicodeToHTML(nome_empresa)); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + try + { + txtEstabelecimento.setText(adp.getEstabelecimentoNome(a.getEstabelecimento_id())); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + +// try +// { +// //Trabalhador t = adp.getTrabalhador(a.getTrabalhador_id()); +// Acidentado ac = adp.getAcidentado(a.getAcidentado_id()); +// //txtDataNascimento.setText(ac.getData_nascimento()); +// try +// { +// java.util.Date ddate = new java.util.Date(ac.getData_nascimento().getTime()); +// txtDataNascimento.setText(utils.Utils.dateToYYYYMMDD(ddate)); +// } +// catch(Exception ex){}; +// getSessionBean1().setAcidentado(ac); +// } +// catch(Exception ex) +// { +// ex.printStackTrace(); +// } + + txtTrabalhador.setText(a.getNome_acidentado()); +// txtNomeAcidentado.setText(a.getNome_acidentado()); + + stAveriguador.setText(a.getAveriguador()); + + if(a.getData_acidente() == null) + { + lblDataAcidente.setRendered(false); + stDataAcidente1.setRendered(false); + } + else + { + try + { + java.util.Date ddate = new java.util.Date(a.getData_acidente().getTime()); + stDataAcidente1.setText(utils.Utils.dateToYYYYMMDD(ddate)); + } + catch(Exception ex){}; + } + + if(a.getHora_acidente() == null) + { + lblHoraAcidente.setRendered(false); + stHoraAcidente1.setRendered(false); + } + else + { + Calendar cal = Calendar.getInstance(); + + // set the calendar to have your time + cal.setTimeInMillis(a.getHora_acidente().getTime()); + + int hour = cal.get(Calendar.HOUR_OF_DAY); + int minutes = cal.get(Calendar.MINUTE); + try + { + stHoraAcidente1.setText(utils.Utils.timeToHHMM(hour + ":" + minutes)); + } + catch(Exception ex){} + } + + boolean booTurnoSeccaoLocal = false; + if(a.getHoras_turno() == null) + { + lblHorasTurno.setRendered(false); + txtHorasTurno.setRendered(false); + } + else if(a.getHoras_turno().intValue() == 0) + { + lblHorasTurno.setRendered(false); + txtHorasTurno.setRendered(false); + } + else + { + txtHorasTurno.setText(a.getHoras_turno().toString()); + booTurnoSeccaoLocal = true; + } + +// if(a.getSeccao() == null) +// { +// lblSeccao.setRendered(false); +// txtSeccao.setRendered(false); +// } +// else if(a.getSeccao().trim().length() == 0) +// { +// lblSeccao.setRendered(false); +// txtSeccao.setRendered(false); +// } +// else +// { +// txtSeccao.setText(a.getSeccao()); +// booTurnoSeccaoLocal = true; +// } + + try + { + Seccao s = adp.getSeccao(a.getSeccao_id()); + txtSeccao.setText(s.getDescricao()); + booTurnoSeccaoLocal = true; + } + catch(Exception ex) + { + ex.printStackTrace(); + lblSeccao.setRendered(false); + txtSeccao.setRendered(false); + } + + + if(a.getLocal_trabalho() == null) + { + lblLocal.setRendered(false); + txtLocal.setRendered(false); + } + else if(a.getLocal_trabalho().trim().length() == 0) + { + lblLocal.setRendered(false); + txtLocal.setRendered(false); + } + else + { + txtLocal.setText(a.getLocal_trabalho()); + booTurnoSeccaoLocal = true; + } + + if(!booTurnoSeccaoLocal) + { + gridTurnoSeccaoLocal.setRendered(false); + } + + if(a.getTarefa() == null) + { + gridTarefa.setRendered(false); + lblTarefa.setRendered(false); + txtTarefa.setRendered(false); + } + else if(a.getTarefa().trim().length() == 0) + { + gridTarefa.setRendered(false); + lblTarefa.setRendered(false); + txtTarefa.setRendered(false); + } + else + { + txtTarefa.setText(a.getTarefa()); + } + + if(a.getSubstancias() == null) + { + gridSubstancias.setRendered(false); + lblSubstancias.setRendered(false); + txtSubstancias.setRendered(false); + } + else if(a.getSubstancias().trim().length() == 0) + { + gridSubstancias.setRendered(false); + lblSubstancias.setRendered(false); + txtSubstancias.setRendered(false); + } + else + { + txtSubstancias.setText(a.getSubstancias()); + } + +// if(a.getSuperior_hierarquico() == null) +// { +// gridSuperior.setRendered(false); +// lblSuperior.setRendered(false); +// txtSuperior.setRendered(false); +// } +// else if(a.getSuperior_hierarquico().trim().length() == 0) +// { +// gridSuperior.setRendered(false); +// lblSuperior.setRendered(false); +// txtSuperior.setRendered(false); +// } +// else +// { +// txtSuperior.setText(a.getSuperior_hierarquico()); +// } + + if(a.getCondicoes() == null) + { + gridCondicoes.setRendered(false); + lblCondicoes.setRendered(false); + txtCondicoes.setRendered(false); + } + else if(a.getCondicoes().trim().length() == 0) + { + gridCondicoes.setRendered(false); + lblCondicoes.setRendered(false); + txtCondicoes.setRendered(false); + } + else + { + txtCondicoes.setText(a.getCondicoes()); + } + + + if(a.getTestemunhas() == null) + { + gridTestemunhas.setRendered(false); + lblTestemunhas.setRendered(false); + txtTestemunhas.setRendered(false); + } + else if(a.getTestemunhas().trim().length() == 0) + { + gridTestemunhas.setRendered(false); + lblTestemunhas.setRendered(false); + txtTestemunhas.setRendered(false); + + } + else + { + txtTestemunhas.setText(a.getTestemunhas()); + } + +// txtCausas.setText(a.getCausas()); + try + { + Causa c = adp.getCausa(a.getCausas()); + txtCausas.setText(c.getCausa()); + } + catch(Exception ex) + { + ex.printStackTrace(); + gridCausas.setRendered(false); + } + + if(a.getDescricao() == null) + { + gridDescricao.setRendered(false); + lblDescricao.setRendered(false); + txtDescricao.setRendered(false); + } + else if(a.getTestemunhas().trim().length() == 0) + { + gridDescricao.setRendered(false); + lblDescricao.setRendered(false); + txtDescricao.setRendered(false); + } + else + { + txtDescricao.setText(a.getDescricao()); + } + + if(a.getConclusoes() == null) + { + gridConclusoes.setRendered(false); + lblConclusoes.setRendered(false); + txtConclusoes.setRendered(false); + } + else if(a.getConclusoes().trim().length() == 0) + { + gridConclusoes.setRendered(false); + lblConclusoes.setRendered(false); + txtConclusoes.setRendered(false); + } + else + { + txtConclusoes.setText(a.getConclusoes()); + } + + if(a.getAccoes() == null) + { + gridAccoes.setRendered(false); + lblAccoes.setRendered(false); + txtAccoes.setRendered(false); + } + else if(a.getAccoes().trim().length() == 0) + { + gridAccoes.setRendered(false); + lblAccoes.setRendered(false); + txtAccoes.setRendered(false); + } + else + { + txtAccoes.setText(a.getAccoes()); + } + + if(a.getAveriguacao_posterior().matches("n")) + { + gridAveriguacaoPosterior.setRendered(false); + } + else + { + if(a.getAveriguacao_obs().trim().length() > 0) + { + txtAveriguacaoPosterior.setText("Averiguação posterior: " + a.getAveriguacao_obs()); + } + } + + + + //fill images + String folderName = a.getAnalise_nr().substring(0,2) + a.getAnalise_nr().substring(3); + System.out.println("FOLDER NAME : " + folderName); + ServletContext theApplicationsServletContext = + (ServletContext) this.getExternalContext().getContext(); +// String imageFileFolder = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/" + folderName); + + + File apacheAnaliseFolder = new File(theApplicationsServletContext.getRealPath( Global.RESOURCES_IMAGE_FOLDER ) + "/analises/" + folderName); + if(apacheAnaliseFolder.exists()) + { + Global global = new Global(); + global.deleteFolderFiles(apacheAnaliseFolder); + } + else + { + apacheAnaliseFolder.mkdir(); + } + + + String imageFileFolder = Global.IMAGE_FOLDER + "/" + folderName; + try + { + File f = new File(imageFileFolder); + + if(f.exists()) + { + File images[] = f.listFiles(); + Arrays.sort(images); + for(int i=0;i