/* * AnaliseAcidenteTrabalho.java * * Created on September 28, 2007, 3:56 PM * Copyright lluis */ package analiseacidentestrabalho; import beans.Estabelecimento; import beans.Recomendacao; import beans.Seccao; import beans.Causa; import beans.Medico; import beans.Medida; import beans.Trabalhador; import beans.Utilizador; import beans.Acidentado; import beans.AnaliseAcidente; import com.evolute.utils.error.ErrorLogger; import com.evolute.utils.strings.StringPlainer; 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.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.ImageHyperlink; 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.RadioButton; 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.TextArea; import com.sun.rave.web.ui.component.TextField; import com.sun.rave.web.ui.model.DefaultTableDataProvider; import com.sun.rave.web.ui.model.SingleSelectOptionsList; import db.providers.AnalisesDataProvider; import db.providers.TrabalhadoresListDataProvider; import db.providers.UtilizadoresDataProvider; import global.Global; import java.io.File; import java.sql.Time; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.ListIterator; import java.util.Properties; import javax.activation.DataHandler; import javax.faces.FacesException; import javax.faces.FactoryFinder; import javax.faces.application.ApplicationFactory; import javax.faces.component.html.HtmlPanelGrid; import javax.faces.el.MethodBinding; import javax.faces.event.ActionEvent; import javax.faces.event.ValueChangeEvent; import javax.mail.*; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMultipart; import javax.mail.util.ByteArrayDataSource; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import org.apache.commons.validator.EmailValidator; import pagestate.AnaliseAcidenteTrabalhoState; import pdf.PdfGenerator; import shst.companydataloaders.SIPRPPropertiesLoader; 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 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.
*/ @Override 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.
*/ @Override 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.
*/ @Override 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() { getSessionBean1().setIeBug( true ); Utils.doLogout( getExternalContext(), true ); 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 ); gridParticipacao.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 { AnalisesDataProvider adp = AnalisesDataProvider.getInstance(); String nome_empresa = adp.getEmpresaNome( getSessionBean1().getCurrentUser().getEmpresa_id() ); txtEmpresa.setText( utils.Utils.unicodeToHTML( nome_empresa ) ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } try { AnalisesDataProvider adp = AnalisesDataProvider.getInstance(); txtEstabelecimento.setText( adp.getEstabelecimentoNome( getSessionBean1().getCurrentUser().getEstabelecimento_id() ) ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } drpDepartamento.setSelected( new Integer( 0 ) ); try { AnalisesDataProvider adp = AnalisesDataProvider.getInstance(); getSessionBean1().setSeccaoOptions( adp.getSeccoesList( null ) ); drpSeccao.setSelected( new Integer( 0 ) ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } // 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 ); setCalDataOcorrencia( today ); //drpMedicos.setSelected(new Integer(0)); // UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); try { UtilizadoresDataProvider udp = UtilizadoresDataProvider.getInstance(); Medico m = udp.getMedico( getSessionBean1().getCurrentUser().getEstabelecimento_id() ); getSessionBean1().setMedico( m ); if ( m != null ) { stMedico.setText( m.getNome() + " " ); txtCedula.setText( m.getNumero_cedula() ); } } catch ( Exception e ) { ErrorLogger.logException( e ); } 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); // ErrorLogger.logException( ex ); // } // } 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 ) { ErrorLogger.logException( ex ); } // AnalisesDataProvider adp = new AnalisesDataProvider(); try { AnalisesDataProvider adp = AnalisesDataProvider.getInstance(); String nome_empresa = adp.getEmpresaNome( a.getEmpresa_id() ); txtEmpresa.setText( utils.Utils.unicodeToHTML( nome_empresa ) ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } try { AnalisesDataProvider adp = AnalisesDataProvider.getInstance(); txtEstabelecimento.setText( adp.getEstabelecimentoNome( a.getEstabelecimento_id() ) ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } Acidentado ac = null; try { AnalisesDataProvider adp = AnalisesDataProvider.getInstance(); //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 ) { ErrorLogger.logException( ex ); } 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() == Global.TIPO_UTILIZADOR_SEGURANCA && 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 ); gridParticipacao.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 ); gridParticipacao.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 ); gridParticipacao.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 ); //gridParticipacao.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); gridParticipacao.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 ) ); gridParticipacao.setRendered( false ); 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_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: } chkParticipacao.setSelected( a.getParticipado() != null ? a.getParticipado() : Boolean.FALSE ); return null; } private void fillSiprp( AnaliseAcidente a ) { //drpTecnicos.setSelected(a.getTecnico_saude_id()); //drpMedicos.setSelected(a.getMedico_id()); // UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); try { UtilizadoresDataProvider udp = UtilizadoresDataProvider.getInstance(); Utilizador u = udp.getUtilizador( a.getTecnico_saude_id() ); txtCap.setText( u.getCap() ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } try { UtilizadoresDataProvider udp = UtilizadoresDataProvider.getInstance(); Utilizador u = udp.getUtilizador( a.getMedico_id() ); stMedico.setText( u.getNome() + " " ); txtCedula.setText( u.getNumero_cedula() ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } private void fillSiprpView( AnaliseAcidente a ) { if ( a.getEstado().intValue() == Global.ESTADO_HS ) { if ( a.getTecnico_saude_id() == null || a.getTecnico_saude_id().equals( new Integer( 0 ) ) ) { a.setTecnico_saude_id( getSessionBean1().getCurrentUser().getId() ); } } try { UtilizadoresDataProvider udp = UtilizadoresDataProvider.getInstance(); Utilizador u = udp.getUtilizador( a.getTecnico_saude_id() ); stTecnicoNome.setText( Utils.unicodeToHTML( u.getNome() ) ); txtCap1.setText( u.getCap() ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } try { UtilizadoresDataProvider udp = UtilizadoresDataProvider.getInstance(); Utilizador u = udp.getUtilizador( a.getMedico_id() ); stMedicoNome.setText( Utils.unicodeToHTML( u.getNome() ) ); txtCedula1.setText( u.getNumero_cedula() ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } 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 ) { // ErrorLogger.logException( ex ); } try { cod_postal2 = a.getCod_postal().substring( 5, 8 ); } catch ( Exception ex ) { // ErrorLogger.logException( 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 ) { // ErrorLogger.logException( ex ); } stFuncao.setText( a.getFuncao() ); rbTurnoManha.setSelected( null ); rbTurnoTarde.setSelected( null ); rbTurnoNoite.setSelected( null ); rbTurnoOutro.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 ) ); } else if ( a.getTurno().matches( "o" ) ) { rbTurnoOutro.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 ) { // ErrorLogger.logException( 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 ) { // ErrorLogger.logException( 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 ); setCalDataOcorrencia( 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 ) { // ErrorLogger.logException( ex ); } 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 { AnalisesDataProvider adp = AnalisesDataProvider.getInstance(); 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 ) { // ErrorLogger.logException( ex ); } 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; i < images.length; i++ ) { if ( images[i].isFile() ) { String imageName = images[i].getName(); ImageComponent newImg = new ImageComponent(); newImg.setId( "img_comp" + imageName ); File apacheImage = new File( theApplicationsServletContext.getRealPath( Global.RESOURCES_IMAGE_FOLDER ) + "/analises/" + folderName + "/" + imageName ); Global global = new Global(); global.copyImage( images[i], apacheImage ); newImg.setUrl( Global.RESOURCES_IMAGE_FOLDER + "/analises/" + folderName + "/" + imageName ); newImg.setRendered( true ); gridImages.getChildren().add( newImg ); Hyperlink ln = new Hyperlink(); ln.setId( "img" + imageName ); ln.setText( "Apagar" ); //ln.setValue(imageName); Class args[] = { javax.faces.event.ActionEvent.class }; ApplicationFactory factory = ( ApplicationFactory ) FactoryFinder.getFactory( FactoryFinder.APPLICATION_FACTORY ); //mb = factory.getApplication().createMethodBinding( "#{EditarQuestionario.lnkGrupo_onClick}", args); MethodBinding mbAction = ( MethodBinding ) factory.getApplication().createMethodBinding( "#{AnaliseAcidenteTrabalho.lnkDelImageReal_actionListener}", args ); ln.setActionListener( mbAction ); gridImages.getChildren().add( ln ); } } } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } private void fillDadosAcidenteSegView( AnaliseAcidente a ) { // AnalisesDataProvider adp = new AnalisesDataProvider(); 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 ) { ErrorLogger.logException( 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 ) { ErrorLogger.logException( ex ); } } boolean booTurnoSeccaoLocal = false; if ( a.getHoras_turno() == null ) { lblHorasTurno.setRendered( false ); txtHorasTurno2.setRendered( false ); } else if ( a.getHoras_turno().intValue() == 0 ) { lblHorasTurno.setRendered( false ); txtHorasTurno2.setRendered( false ); } else { txtHorasTurno2.setText( a.getHoras_turno().toString() ); booTurnoSeccaoLocal = true; } // if(a.getSeccao() == null) // { // lblSeccao.setRendered(false); // txtSeccao1.setRendered(false); // } // else if(a.getSeccao().trim().length() == 0) // { // lblSeccao.setRendered(false); // txtSeccao1.setRendered(false); // } // else // { // txtSeccao1.setText(a.getSeccao()); // booTurnoSeccaoLocal = true; // } try { AnalisesDataProvider adp = AnalisesDataProvider.getInstance(); Seccao s = adp.getSeccao( a.getSeccao_id() ); txtSeccao1.setText( s.getDescricao() ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); lblSeccao.setRendered( false ); txtSeccao1.setRendered( false ); } if ( a.getLocal_trabalho() == null ) { lblLocal.setRendered( false ); txtLocal1.setRendered( false ); } else if ( a.getLocal_trabalho().trim().length() == 0 ) { lblLocal.setRendered( false ); txtLocal1.setRendered( false ); } else { txtLocal1.setText( a.getLocal_trabalho() ); booTurnoSeccaoLocal = true; } if ( !booTurnoSeccaoLocal ) { gridTurnoSeccaoLocal.setRendered( false ); } if ( a.getTarefa() == null ) { gridTarefa.setRendered( false ); lblTarefa.setRendered( false ); txtTarefa1.setRendered( false ); } else if ( a.getTarefa().trim().length() == 0 ) { gridTarefa.setRendered( false ); lblTarefa.setRendered( false ); txtTarefa1.setRendered( false ); } else { txtTarefa1.setText( a.getTarefa() ); } if ( a.getSubstancias() == null ) { gridSubstancias.setRendered( false ); lblSubstancias.setRendered( false ); txtSubstancias1.setRendered( false ); } else if ( a.getSubstancias().trim().length() == 0 ) { gridSubstancias.setRendered( false ); lblSubstancias.setRendered( false ); txtSubstancias1.setRendered( false ); } else { txtSubstancias1.setText( a.getSubstancias() ); } // if(a.getSuperior_hierarquico() == null) // { // gridSuperior.setRendered(false); // lblSuperior.setRendered(false); // txtSuperior1.setRendered(false); // } // else if(a.getSuperior_hierarquico().trim().length() == 0) // { // gridSuperior.setRendered(false); // lblSuperior.setRendered(false); // txtSuperior1.setRendered(false); // } // else // { // txtSuperior1.setText(a.getSuperior_hierarquico()); // } if ( a.getCondicoes() == null ) { gridCondicoes.setRendered( false ); lblCondicoes.setRendered( false ); txtCondicoes1.setRendered( false ); } else if ( a.getCondicoes().trim().length() == 0 ) { gridCondicoes.setRendered( false ); lblCondicoes.setRendered( false ); txtCondicoes1.setRendered( false ); } else { txtCondicoes1.setText( a.getCondicoes() ); } if ( a.getTestemunhas() == null ) { gridTestemunhas.setRendered( false ); lblTestemunhas.setRendered( false ); txtTestemunhas1.setRendered( false ); } else if ( a.getTestemunhas().trim().length() == 0 ) { gridTestemunhas.setRendered( false ); lblTestemunhas.setRendered( false ); txtTestemunhas1.setRendered( false ); } else { txtTestemunhas1.setText( a.getTestemunhas() ); } // txtCausas1.setText(a.getCausas()); try { AnalisesDataProvider adp = AnalisesDataProvider.getInstance(); Causa c = adp.getCausa( a.getCausas() ); txtCausas1.setText( c.getCausa() ); } catch ( Exception ex ) { // ErrorLogger.logException( ex ); gridCausas.setRendered( false ); } if ( a.getDescricao() == null ) { gridDescricao.setRendered( false ); lblDescricao.setRendered( false ); txtDescricao1.setRendered( false ); } else if ( a.getDescricao().trim().length() == 0 ) { gridDescricao.setRendered( false ); lblDescricao.setRendered( false ); txtDescricao1.setRendered( false ); } else { txtDescricao1.setText( a.getDescricao() ); } if ( a.getConclusoes() == null ) { gridConclusoes.setRendered( false ); lblConclusoes.setRendered( false ); txtConclusoes1.setRendered( false ); } else if ( a.getConclusoes().trim().length() == 0 ) { gridConclusoes.setRendered( false ); lblConclusoes.setRendered( false ); txtConclusoes1.setRendered( false ); } else { txtConclusoes1.setText( a.getConclusoes() ); } if ( a.getAccoes() == null ) { gridAccoes.setRendered( false ); lblAccoes.setRendered( false ); txtAccoes1.setRendered( false ); } else if ( a.getAccoes().trim().length() == 0 ) { gridAccoes.setRendered( false ); lblAccoes.setRendered( false ); txtAccoes1.setRendered( false ); } else { txtAccoes1.setText( a.getAccoes() ); } if ( a.getAveriguacao_posterior().matches( "y" ) ) { if ( a.getAveriguacao_obs().trim().length() == 0 ) // must edit { if ( getSessionBean1().getCurrentUser().getTipo().intValue() == Global.TIPO_UTILIZADOR_SEGURANCA ) // seguranca { gridAveriguacaoPosterior.setRendered( false ); } else { gridAveriguacaoPosterior.setRendered( false ); gridAveriguacaoPosterior1.setRendered( false ); } } else { gridAveriguacaoPosterior1.setRendered( false ); txtAveriguacaoPosterior.setText( "Averiguação posterior: " + a.getAveriguacao_obs() ); } } else { gridAveriguacaoPosterior.setRendered( false ); gridAveriguacaoPosterior1.setRendered( false ); } //fill images if ( gridImages.getChildren().size() > 0 ) { gridImages.getChildren().clear(); } String folderName = a.getAnalise_nr().substring( 0, 2 ) + a.getAnalise_nr().substring( 3 ); 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 ); System.out.println( "FILES DELETED" ); } 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 < images.length; i++ ) { if ( images[i].isFile() ) { String imageName = images[i].getName(); ImageComponent newImg = new ImageComponent(); File apacheImage = new File( theApplicationsServletContext.getRealPath( Global.RESOURCES_IMAGE_FOLDER ) + "/analises/" + folderName + "/" + imageName ); Global global = new Global(); global.copyImage( images[i], apacheImage ); newImg.setUrl( Global.RESOURCES_IMAGE_FOLDER + "/analises/" + folderName + "/" + imageName ); //newImg.setUrl("/resources/images/" + getSessionBean1().getCurrentAnalise().getId() + "/" + imageName); //newImg.setUrl(Global.IMAGE_FOLDER + "/" + folderName + "/" + imageName); newImg.setRendered( true ); gridImages1.getChildren().add( newImg ); } } } else { gridFotografias.setRendered( false ); lblFotografias.setRendered( false ); gridImages1.setRendered( false ); } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } private void fillDadosAcidenteRh( AnaliseAcidente a ) { if ( a.getFormacao_shst().matches( "y" ) ) { rbFormacaoSHSTY.setSelected( new Boolean( true ) ); } else if ( a.getFormacao_shst().matches( "n" ) ) { rbFormacaoSHSTN.setSelected( new Boolean( true ) ); txtFormacaoSHSTNWhy.setText( a.getFormacao_shst_nao_porque() ); } else //t { rbFormacaoSHSTY.setSelected( null ); rbFormacaoSHSTN.setSelected( null ); } if ( a.getOutros_acidentes_com_colaborador().matches( "y" ) ) { rbAcidentesColaboradorY.setSelected( new Boolean( true ) ); try { txtNrAcidentesColaborador.setText( a.getNr_acidentes_com_colaborador().toString() ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } try { txtNrRelatorioAcidentesColaborador1.setText( a.getNr_relatorio_acidente_colaborador1().toString() ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } try { txtNrRelatorioAcidentesColaborador2.setText( a.getNr_relatorio_acidente_colaborador2().toString() ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } try { txtNrRelatorioAcidentesColaborador3.setText( a.getNr_relatorio_acidente_colaborador3().toString() ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } try { txtNrRelatorioAcidentesColaborador4.setText( a.getNr_relatorio_acidente_colaborador4().toString() ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } else if ( a.getOutros_acidentes_com_colaborador().matches( "n" ) ) { rbAcidentesColaboradorN.setSelected( new Boolean( true ) ); } else //t { rbAcidentesColaboradorY.setSelected( null ); rbAcidentesColaboradorN.setSelected( null ); } if ( a.getAcidentes_outros_colaboradores().matches( "y" ) ) { rbAcidentesColaboradoresY.setSelected( new Boolean( true ) ); try { txtNrAcidentesColaboradores.setText( a.getNr_acidentes_outros_colaboradores().toString() ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } try { txtNrRelatorioAcidentesColaboradores1.setText( a.getNr_relatorio_acidente_outros_colaboradores1().toString() ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } try { txtNrRelatorioAcidentesColaboradores2.setText( a.getNr_relatorio_acidente_outros_colaboradores2().toString() ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } try { txtNrRelatorioAcidentesColaboradores3.setText( a.getNr_relatorio_acidente_outros_colaboradores3().toString() ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } try { txtNrRelatorioAcidentesColaboradores4.setText( a.getNr_relatorio_acidente_outros_colaboradores4().toString() ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } else if ( a.getAcidentes_outros_colaboradores().matches( "n" ) ) { rbAcidentesColaboradoresN.setSelected( new Boolean( true ) ); } else //t { rbAcidentesColaboradoresY.setSelected( null ); rbAcidentesColaboradoresN.setSelected( null ); } } private void fillDadosAcidenteRhView( AnaliseAcidente a ) { StaticText st = new StaticText(); st.setId( "stSHST" ); st.setEscape( false ); StaticText st1 = new StaticText(); st1.setId( "stColaborador" ); st1.setEscape( false ); StaticText st2 = new StaticText(); st2.setId( "stColaboradores" ); st2.setEscape( false ); if ( a.getFormacao_shst().matches( "y" ) ) { st.setText( "O colaborador teve formação em SHST." ); gridSHST.getChildren().add( st ); } else if ( a.getFormacao_shst().matches( "n" ) ) { st.setText( "O colaborador não teve formação em SHST." ); gridSHST.getChildren().add( st ); HtmlPanelGrid grd = new HtmlPanelGrid(); grd.setId( "grdMotivo" ); grd.setColumns( 2 ); grd.setColumnClasses( "gridColLeft5, gridColLeft95" ); StaticText s = new StaticText(); s.setId( "stMotivo" ); s.setEscape( false ); s.setText( "Motivo: " ); grd.getChildren().add( s ); s = new StaticText(); s.setId( "stMotivo1" ); s.setEscape( false ); s.setText( a.getFormacao_shst_nao_porque() ); grd.getChildren().add( s ); gridSHST.getChildren().add( grd ); } else { gridSHST.setRendered( false ); } if ( a.getOutros_acidentes_com_colaborador().matches( "y" ) ) { st1.setText( "Verificaram-se outras ocorrências/inicidências no mesmo posto de trabalho com o colaborador acidentado." ); gridColaborador.getChildren().add( st1 ); boolean booShow = false; boolean booShow1 = false; boolean booShow2 = false; if ( a.getNr_acidentes_com_colaborador() != null ) { booShow = true; booShow1 = true; } if ( a.getNr_relatorio_acidente_colaborador1() != null || a.getNr_relatorio_acidente_colaborador2() != null || a.getNr_relatorio_acidente_colaborador3() != null || a.getNr_relatorio_acidente_colaborador4() != null ) { booShow = true; booShow2 = true; } if ( booShow ) { HtmlPanelGrid grd = new HtmlPanelGrid(); grd.setId( "grdColaboradorS" ); grd.setColumns( 2 ); grd.setColumnClasses( "gridColLeft15, gridColLeft85" ); if ( booShow1 ) { PanelGroup pg = new PanelGroup(); StaticText s = new StaticText(); s.setId( "s100" ); s.setEscape( false ); s.setText( "Total: " ); pg.getChildren().add( s ); s = new StaticText(); s.setId( "s101" ); s.setEscape( false ); s.setText( a.getNr_acidentes_com_colaborador().toString() ); pg.getChildren().add( s ); grd.getChildren().add( pg ); } if ( booShow2 ) { PanelGroup pg = new PanelGroup(); StaticText s = new StaticText(); s.setId( "s102" ); s.setEscape( false ); s.setText( "Relatórios de acidente nº: " ); pg.getChildren().add( s ); if ( a.getNr_relatorio_acidente_colaborador1() != null ) { if ( a.getNr_relatorio_acidente_colaborador1().intValue() > 0 ) { s = new StaticText(); s.setId( "s103" ); s.setEscape( false ); s.setText( a.getNr_relatorio_acidente_colaborador1() ); pg.getChildren().add( s ); } } if ( a.getNr_relatorio_acidente_colaborador2() != null ) { if ( a.getNr_relatorio_acidente_colaborador2().intValue() > 0 ) { s = new StaticText(); s.setId( "s104" ); s.setEscape( false ); s.setText( " " + a.getNr_relatorio_acidente_colaborador2() ); pg.getChildren().add( s ); } } if ( a.getNr_relatorio_acidente_colaborador3() != null ) { if ( a.getNr_relatorio_acidente_colaborador3().intValue() > 0 ) { s = new StaticText(); s.setId( "s105" ); s.setEscape( false ); s.setText( " " + a.getNr_relatorio_acidente_colaborador3() ); pg.getChildren().add( s ); } } if ( a.getNr_relatorio_acidente_colaborador4() != null ) { if ( a.getNr_relatorio_acidente_colaborador4().intValue() > 0 ) { s = new StaticText(); s.setId( "s106" ); s.setEscape( false ); s.setText( " " + a.getNr_relatorio_acidente_colaborador4() ); pg.getChildren().add( s ); } } grd.getChildren().add( pg ); } gridColaborador.getChildren().add( grd ); } } else if ( a.getOutros_acidentes_com_colaborador().matches( "n" ) ) { st1.setText( "Não se verificaram outras ocorrências/incidências no mesmo posto de trabalho com o colaborador acidentado." ); gridColaborador.getChildren().add( st1 ); } else //t { gridColaborador.setRendered( false ); } if ( a.getAcidentes_outros_colaboradores().matches( "y" ) ) { st2.setText( "Verificaram-se ocorrências/incidentes semelhantes com outros colaboradores." ); gridColaboradores.getChildren().add( st2 ); boolean booShow = false; boolean booShow1 = false; boolean booShow2 = false; if ( a.getNr_acidentes_outros_colaboradores() != null ) { booShow = true; booShow1 = true; } if ( a.getNr_relatorio_acidente_outros_colaboradores1() != null || a.getNr_relatorio_acidente_outros_colaboradores2() != null || a.getNr_relatorio_acidente_outros_colaboradores3() != null || a.getNr_relatorio_acidente_outros_colaboradores4() != null ) { booShow = true; booShow2 = true; } if ( booShow ) { HtmlPanelGrid grd = new HtmlPanelGrid(); grd.setId( "grdColaboradoresS" ); grd.setColumns( 2 ); grd.setColumnClasses( "gridColLeft15, gridColLeft85" ); if ( booShow1 ) { PanelGroup pg = new PanelGroup(); StaticText s = new StaticText(); s.setId( "s200" ); s.setEscape( false ); s.setText( "Total: " ); pg.getChildren().add( s ); s = new StaticText(); s.setId( "s201" ); s.setEscape( false ); s.setText( a.getNr_acidentes_outros_colaboradores() ); pg.getChildren().add( s ); grd.getChildren().add( pg ); } if ( booShow2 ) { PanelGroup pg = new PanelGroup(); StaticText s = new StaticText(); s.setId( "s202" ); s.setEscape( false ); s.setText( "Relatórios de acidente nº: " ); pg.getChildren().add( s ); if ( a.getNr_relatorio_acidente_outros_colaboradores1() != null ) { if ( a.getNr_relatorio_acidente_outros_colaboradores1().intValue() > 0 ) { s = new StaticText(); s.setId( "s203" ); s.setEscape( false ); s.setText( a.getNr_relatorio_acidente_outros_colaboradores1() ); pg.getChildren().add( s ); } } if ( a.getNr_relatorio_acidente_outros_colaboradores2() != null ) { if ( a.getNr_relatorio_acidente_outros_colaboradores2().intValue() > 0 ) { s = new StaticText(); s.setId( "s204" ); s.setEscape( false ); s.setText( " " + a.getNr_relatorio_acidente_outros_colaboradores2() ); pg.getChildren().add( s ); } } if ( a.getNr_relatorio_acidente_outros_colaboradores3() != null ) { if ( a.getNr_relatorio_acidente_outros_colaboradores3().intValue() > 0 ) { s = new StaticText(); s.setId( "s205" ); s.setEscape( false ); s.setText( " " + a.getNr_relatorio_acidente_outros_colaboradores3() ); pg.getChildren().add( s ); } } if ( a.getNr_relatorio_acidente_outros_colaboradores4() != null ) { if ( a.getNr_relatorio_acidente_outros_colaboradores4().intValue() > 0 ) { s = new StaticText(); s.setId( "s206" ); s.setEscape( false ); s.setText( " " + a.getNr_relatorio_acidente_outros_colaboradores4() ); pg.getChildren().add( s ); } } grd.getChildren().add( pg ); } gridColaboradores.getChildren().add( grd ); } } else if ( a.getAcidentes_outros_colaboradores().matches( "n" ) ) { st2.setText( "Não se verificaram ocorrências/incidentes com outros colaboradores." ); gridColaboradores.getChildren().add( st2 ); } else //t { gridColaboradores.setRendered( false ); } } private void fillRecomendacoesHs( AnaliseAcidente a ) { // AnalisesDataProvider adp = new AnalisesDataProvider(); try { AnalisesDataProvider adp = AnalisesDataProvider.getInstance(); ArrayList list = adp.getRecomendacoesByAnalise( a.getId() ); ListIterator iter = list.listIterator(); int seq = 1; while ( iter.hasNext() ) { Recomendacao r = ( Recomendacao ) iter.next(); if ( seq == 1 ) { txtRecomendacao1.setText( r.getRecomendacao() ); } else { //int seq = gridRecomendacoes.getChildren().size(); //seq++; HtmlPanelGrid grd = new HtmlPanelGrid(); grd.setId( "grd" + seq ); grd.setColumns( 3 ); grd.setColumnClasses( "gridColLeft5, gridColLeft90,gridColLeft5" ); grd.setStyle( "width: 100%" ); StaticText st = new StaticText(); st.setId( "st" + seq ); st.setText( seq + " ." ); st.setStyle( "width: 24px" ); grd.getChildren().add( st ); TextArea ta = new TextArea(); ta.setId( "ta" + seq ); ta.setStyle( "height: 24px; width: 98%" ); ta.setText( r.getRecomendacao() ); grd.getChildren().add( ta ); ImageHyperlink ln = new ImageHyperlink(); ln.setId( "ln" + seq ); ln.setWidth( 9 ); ln.setHeight( 9 ); ln.setImageURL( "/resources/plus_more.gif" ); MethodBinding mbAction = this.getApplication().createMethodBinding( "#{AnaliseAcidenteTrabalho.lnkMoreRec1_action}", null ); ln.setAction( mbAction ); grd.getChildren().add( ln ); gridRecomendacoes.getChildren().add( grd ); } seq++; } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } private void fillRecomendacoesViewHs( AnaliseAcidente a ) { // AnalisesDataProvider adp = new AnalisesDataProvider(); try { AnalisesDataProvider adp = AnalisesDataProvider.getInstance(); ArrayList list = adp.getRecomendacoesByAnalise( a.getId() ); ListIterator iter = list.listIterator(); int seq = 1; while ( iter.hasNext() ) { Recomendacao r = ( Recomendacao ) iter.next(); HtmlPanelGrid grd = new HtmlPanelGrid(); grd.setId( "grdRecomendacaoView" + seq ); grd.setColumns( 2 ); grd.setColumnClasses( "gridColLeft5, gridColLeft95" ); grd.setStyle( "width: 100%" ); StaticText st = new StaticText(); st.setId( "stNrRecomendacaoView" + seq ); st.setText( seq + " ." ); st.setStyle( "width: 24px" ); grd.getChildren().add( st ); st = new StaticText(); st.setId( "stRecomendacaoView" + seq ); st.setText( r.getRecomendacao() ); //st.setStyle("width: 24px"); grd.getChildren().add( st ); gridRecomendacoesView.getChildren().add( grd ); seq++; } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } private void fillMedidasRh( AnaliseAcidente a ) { // AnalisesDataProvider adp = new AnalisesDataProvider(); try { AnalisesDataProvider adp = AnalisesDataProvider.getInstance(); ArrayList list = adp.getMedidasByAnalise( a.getId() ); ListIterator iter = list.listIterator(); int seq = 1; while ( iter.hasNext() ) { Medida m = ( Medida ) iter.next(); if ( seq == 1 ) { txtMedida1.setText( m.getMedida() ); } else { HtmlPanelGrid grd = new HtmlPanelGrid(); grd.setId( "grdMedida" + seq ); grd.setColumns( 3 ); grd.setColumnClasses( "gridColLeft5, gridColLeft90,gridColLeft5" ); grd.setStyle( "width: 100%" ); StaticText st = new StaticText(); st.setId( "stNrMedida" + seq ); st.setText( seq + " ." ); st.setStyle( "width: 24px" ); grd.getChildren().add( st ); TextArea ta = new TextArea(); ta.setId( "taMedida" + seq ); ta.setStyle( "height: 24px; width: 98%" ); ta.setText( m.getMedida() ); grd.getChildren().add( ta ); ImageHyperlink ln = new ImageHyperlink(); ln.setId( "lnMedidaMore" + seq ); ln.setWidth( 9 ); ln.setHeight( 9 ); ln.setImageURL( "/resources/plus_more.gif" ); MethodBinding mbAction = this.getApplication().createMethodBinding( "#{AnaliseAcidenteTrabalho.lnkMoreMed_action}", null ); ln.setAction( mbAction ); grd.getChildren().add( ln ); gridMedidas.getChildren().add( grd ); } seq++; } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } private void fillMedidasViewRh( AnaliseAcidente a ) { try { AnalisesDataProvider adp = AnalisesDataProvider.getInstance(); ArrayList list = adp.getMedidasByAnalise( a.getId() ); ListIterator iter = list.listIterator(); int seq = 1; while ( iter.hasNext() ) { Medida m = ( Medida ) iter.next(); HtmlPanelGrid grd = new HtmlPanelGrid(); grd.setId( "grdMedidaView" + seq ); grd.setColumns( 2 ); grd.setColumnClasses( "gridColLeft5, gridColLeft95" ); grd.setStyle( "width: 100%" ); StaticText st = new StaticText(); st.setId( "stNrMedidaView" + seq ); st.setText( seq + " ." ); st.setStyle( "width: 24px" ); grd.getChildren().add( st ); st = new StaticText(); st.setId( "stMedidaView" + seq ); st.setText( m.getMedida() ); //st.setStyle("width: 24px"); grd.getChildren().add( st ); gridMedidasView.getChildren().add( grd ); seq++; } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } private void fillMedico( AnaliseAcidente a ) { if ( a.getLesao_cabeca().matches( "y" ) ) { chkCabeca.setSelected( new Boolean( true ) ); } if ( a.getLesao_pescoco().matches( "y" ) ) { chkPescoco.setSelected( new Boolean( true ) ); } if ( a.getLesao_tronco().matches( "y" ) ) { chkTronco.setSelected( new Boolean( true ) ); } if ( a.getLesao_membro_sup_dir().matches( "y" ) ) { chkMembroSupDir.setSelected( new Boolean( true ) ); //lblEspecif1.setRendered(true); //txtEspecif1.setRendered(true); lblEspecif1.setVisible( true ); txtEspecif1.setVisible( true ); txtEspecif1.setText( a.getEspecif1() ); } else { //lblEspecif1.setRendered(false); //txtEspecif1.setRendered(false); lblEspecif1.setVisible( false ); txtEspecif1.setVisible( false ); } if ( a.getLesao_membro_sup_esq().matches( "y" ) ) { chkMembroSupEsq.setSelected( new Boolean( true ) ); // lblEspecif2.setRendered(true); // txtEspecif2.setRendered(true); lblEspecif2.setVisible( true ); txtEspecif2.setVisible( true ); txtEspecif2.setText( a.getEspecif2() ); } else { lblEspecif2.setVisible( false ); txtEspecif2.setVisible( false ); } if ( a.getLesao_membro_inf_dir().matches( "y" ) ) { chkMembroInfDir.setSelected( new Boolean( true ) ); lblEspecif3.setVisible( true ); txtEspecif3.setVisible( true ); txtEspecif3.setText( a.getEspecif3() ); } else { lblEspecif3.setVisible( false ); txtEspecif3.setVisible( false ); } if ( a.getLesao_membro_inf_esq().matches( "y" ) ) { chkMembroInfEsq.setSelected( new Boolean( true ) ); lblEspecif4.setVisible( true ); txtEspecif4.setVisible( true ); txtEspecif4.setText( a.getEspecif4() ); } else { lblEspecif4.setVisible( false ); txtEspecif4.setVisible( false ); } txtTipoLesao.setText( a.getTipo_lesao() ); if ( a.getTipo_incapacidade().matches( "n" ) ) { rbIncapacidadeNone.setSelected( new Boolean( true ) ); } else if ( a.getTipo_incapacidade().matches( "t" ) ) { rbIncapacidadeTemp.setSelected( new Boolean( true ) ); } else if ( a.getTipo_incapacidade().matches( "p" ) ) { rbIncapacidadePerm.setSelected( new Boolean( true ) ); } else { rbIncapacidadeNone.setSelected( null ); rbIncapacidadeTemp.setSelected( null ); rbIncapacidadePerm.setSelected( null ); } if ( a.getCoef_incapacidade() == null ) { txtCoefIncapacidade.setText( "" ); } else { txtCoefIncapacidade.setText( a.getCoef_incapacidade() ); } if ( a.getData_aval_incapacidade() != null ) { java.util.Date ddate = new java.util.Date( a.getData_aval_incapacidade().getTime() ); // calAvaliacaoIncap.setValue( ddate ); setCalAvaliacaoIncap( ddate ); } if ( a.getData_rev_incapacidade() != null ) { java.util.Date ddate = new java.util.Date( a.getData_rev_incapacidade().getTime() ); // calRevisaoIncap.setValue( ddate ); setCalRevisaoIncap( ddate ); } if ( a.getPeriodo_incapacidade_de() != null ) { java.util.Date ddate = new java.util.Date( a.getPeriodo_incapacidade_de().getTime() ); // calPeridoIncapDe.setValue( ddate ); setCalPeriodoIncapDe( ddate ); } if ( a.getPeriodo_incapacidade_a() != null ) { java.util.Date ddate = new java.util.Date( a.getPeriodo_incapacidade_a().getTime() ); // calPeriodoIncapA.setValue( ddate ); setCalPeriodoIncapA( ddate ); } if ( a.getImg_flexao().matches( "y" ) ) { chkImgFlexao.setSelected( new Boolean( true ) ); } if ( a.getImg_rot1().matches( "y" ) ) { chkImgRot1.setSelected( new Boolean( true ) ); } if ( a.getImg_rot2().matches( "y" ) ) { chkImgRot2.setSelected( new Boolean( true ) ); } if ( a.getImg_ext1().matches( "y" ) ) { chkImgExt1.setSelected( new Boolean( true ) ); } if ( a.getImg_ext2().matches( "y" ) ) { chkImgExt2.setSelected( new Boolean( true ) ); } if ( a.getImg_cab1().matches( "y" ) ) { chkImgCab1.setSelected( new Boolean( true ) ); } if ( a.getImg_cab2().matches( "y" ) ) { chkImgCab2.setSelected( new Boolean( true ) ); } if ( a.getImg_cab3().matches( "y" ) ) { chkImgCab3.setSelected( new Boolean( true ) ); } if ( a.getImg_cab4().matches( "y" ) ) { chkImgCab4.setSelected( new Boolean( true ) ); } if ( a.getImg_ma1().matches( "y" ) ) { chkImgMa1.setSelected( new Boolean( true ) ); } if ( a.getImg_ma2().matches( "y" ) ) { chkImgMa2.setSelected( new Boolean( true ) ); } if ( a.getImg_ma3().matches( "y" ) ) { chkImgMa3.setSelected( new Boolean( true ) ); } if ( a.getImg_ma4().matches( "y" ) ) { chkImgMa4.setSelected( new Boolean( true ) ); } if ( a.getImg_ma5().matches( "y" ) ) { chkImgMa5.setSelected( new Boolean( true ) ); } if ( a.getImg_ma6().matches( "y" ) ) { chkImgMa6.setSelected( new Boolean( true ) ); } if ( a.getImg_ma7().matches( "y" ) ) { chkImgMa7.setSelected( new Boolean( true ) ); } if ( a.getImg_ma8().matches( "y" ) ) { chkImgMa8.setSelected( new Boolean( true ) ); } if ( a.getImg_ma9().matches( "y" ) ) { chkImgMa9.setSelected( new Boolean( true ) ); } if ( a.getImg_ma10().matches( "y" ) ) { chkImgMa10.setSelected( new Boolean( true ) ); } if ( a.getRestricao_carga() != null ) { if ( a.getRestricao_carga().intValue() > 0 ) { chkRestricaoCargas.setSelected( new Boolean( true ) ); rbKgs2.setRendered( true ); rbKgs5.setRendered( true ); rbKgs10.setRendered( true ); rbKgs15.setRendered( true ); rbKgsOutro.setRendered( true ); txtKgs.setRendered( true ); stKgs2.setRendered( true ); stKgs5.setRendered( true ); stKgs10.setRendered( true ); stKgs15.setRendered( true ); stKgsOutro.setRendered( true ); stKg.setRendered( true ); int carga = a.getRestricao_carga().intValue(); switch ( carga ) { case 2: rbKgs2.setSelected( new Boolean( true ) ); break; case 5: rbKgs5.setSelected( new Boolean( true ) ); break; case 10: rbKgs10.setSelected( new Boolean( true ) ); break; case 15: rbKgs15.setSelected( new Boolean( true ) ); break; default: rbKgsOutro.setSelected( new Boolean( true ) ); txtKgs.setText( a.getRestricao_carga().toString() ); break; } } else { chkRestricaoCargas.setSelected( new Boolean( false ) ); rbKgs2.setRendered( false ); rbKgs5.setRendered( false ); rbKgs10.setRendered( false ); rbKgs15.setRendered( false ); rbKgsOutro.setRendered( false ); txtKgs.setRendered( false ); stKgs2.setRendered( false ); stKgs5.setRendered( false ); stKgs10.setRendered( false ); stKgs15.setRendered( false ); stKgsOutro.setRendered( false ); stKg.setRendered( false ); } } else { chkRestricaoCargas.setSelected( new Boolean( false ) ); rbKgs2.setRendered( false ); rbKgs5.setRendered( false ); rbKgs10.setRendered( false ); rbKgs15.setRendered( false ); rbKgsOutro.setRendered( false ); txtKgs.setRendered( false ); stKgs2.setRendered( false ); stKgs5.setRendered( false ); stKgs10.setRendered( false ); stKgs15.setRendered( false ); stKgsOutro.setRendered( false ); stKg.setRendered( false ); } if ( a.getRestricao_motricidade().matches( "y" ) ) { chkRestricaoMotricidade.setSelected( new Boolean( true ) ); } if ( a.getRestricao_conducao().matches( "y" ) ) { chkRestricaoConducao.setSelected( new Boolean( true ) ); } if ( a.getRestricao_vibracoes().matches( "y" ) ) { chkRestricaoVibracoes.setSelected( new Boolean( true ) ); } if ( a.getRestricao_outras() != null ) { if ( a.getRestricao_outras().trim().length() > 0 ) { chkRestricaoOutras.setSelected( new Boolean( true ) ); txtRestricaoOutras.setText( a.getRestricao_outras() ); } } txtObservacoes.setText( a.getMed_observ() ); } private void fillMedicoView( AnaliseAcidente a ) { PanelGroup pg = null; StaticText st = null; HtmlPanelGrid grd = null; ImageComponent img = null; //LESAO : if ( a.getLesao_cabeca().matches( "y" ) ) { st = new StaticText(); st.setId( "stLesaoCabeca" ); st.setEscape( false ); st.setText( "Cabeça" ); gridLesao.getChildren().add( st ); } if ( a.getLesao_pescoco().matches( "y" ) ) { st = new StaticText(); st.setId( "stLesaoPescoco" ); st.setEscape( false ); st.setText( "Pescoço" ); gridLesao.getChildren().add( st ); } if ( a.getLesao_tronco().matches( "y" ) ) { st = new StaticText(); st.setId( "stLesaoTronco" ); st.setEscape( false ); st.setText( "Tronco" ); gridLesao.getChildren().add( st ); } grd = new HtmlPanelGrid(); grd.setId( "gridLesaoMembros" ); grd.setColumns( 2 ); grd.setColumnClasses( "gridColLeft" ); if ( a.getLesao_membro_sup_dir().matches( "y" ) ) { st = new StaticText(); st.setId( "stLesaoMembroSupDir" ); st.setEscape( false ); st.setText( "Membro Superior Direito" ); grd.getChildren().add( st ); if ( a.getEspecif1() != null ) { if ( a.getEspecif1().trim().length() > 0 ) { st = new StaticText(); st.setId( "stEspecif1" ); st.setEscape( false ); st.setText( " - " + a.getEspecif1() ); grd.getChildren().add( st ); } } } if ( a.getLesao_membro_sup_esq().matches( "y" ) ) { st = new StaticText(); st.setId( "stLesaoMembroSupEsq" ); st.setEscape( false ); st.setText( "Membro Superior Esquerdo" ); grd.getChildren().add( st ); if ( a.getEspecif2() != null ) { if ( a.getEspecif2().trim().length() > 0 ) { st = new StaticText(); st.setId( "stEspecif2" ); st.setEscape( false ); st.setText( " - " + a.getEspecif2() ); grd.getChildren().add( st ); } } } if ( a.getLesao_membro_inf_dir().matches( "y" ) ) { st = new StaticText(); st.setId( "stLesaoMembroInfDir" ); st.setEscape( false ); st.setText( "Membro Inferior Direito" ); grd.getChildren().add( st ); if ( a.getEspecif3() != null ) { if ( a.getEspecif3().trim().length() > 0 ) { st = new StaticText(); st.setId( "stEspecif3" ); st.setEscape( false ); st.setText( a.getEspecif3() ); grd.getChildren().add( st ); } } } if ( a.getLesao_membro_inf_esq().matches( "y" ) ) { st = new StaticText(); st.setId( "stLesaoMembroInfEsq" ); st.setEscape( false ); st.setText( "Membro Inferior Esquerdo" ); grd.getChildren().add( st ); if ( a.getEspecif4() != null ) { if ( a.getEspecif4().trim().length() > 0 ) { st = new StaticText(); st.setId( "stEspecif4" ); st.setEscape( false ); st.setText( a.getEspecif4() ); grd.getChildren().add( st ); } } } if ( grd.getChildren().size() > 0 ) { gridLesao.getChildren().add( grd ); } if ( a.getTipo_lesao().trim().length() > 0 ) { pg = new PanelGroup(); pg.setId( "pgTipoLesao" ); st = new StaticText(); st.setId( "stTipoLesaoLbl" ); st.setEscape( false ); st.setText( "Tipo de lesão: " ); pg.getChildren().add( st ); st = new StaticText(); st.setId( "stTipoLesao" ); st.setEscape( false ); st.setText( a.getTipo_lesao() ); pg.getChildren().add( st ); gridLesao.getChildren().add( pg ); } //INCAPACIDADE : pg = new PanelGroup(); pg.setId( "pgTipoIncapacidade" ); st = new StaticText(); st.setId( "stTipoIncapacidadeLbl1" ); st.setStyle( "font-weight: bold" ); st.setEscape( false ); st.setText( "Tipo de incapacidade: " ); if ( a.getTipo_incapacidade().matches( "t" ) ) { pg.getChildren().add( st ); st = new StaticText(); st.setId( "stTipoIncapacidade" ); st.setEscape( false ); st.setText( "Temporária " ); pg.getChildren().add( st ); st = new StaticText(); st.setId( "stTipoIncapacidadeLbl2" ); st.setStyle( "font-weight: bold" ); st.setEscape( false ); st.setText( "Coeficiente de incapacidade: " ); pg.getChildren().add( st ); st = new StaticText(); st.setId( "stCoefIncapacidade" ); st.setEscape( false ); st.setText( a.getCoef_incapacidade().toString() + "%" ); pg.getChildren().add( st ); } else if ( a.getTipo_incapacidade().matches( "p" ) ) { pg.getChildren().add( st ); st = new StaticText(); st.setId( "stTipoIncapacidade" ); st.setEscape( false ); st.setText( "Permanente " ); pg.getChildren().add( st ); st = new StaticText(); st.setId( "stTipoIncapacidadeLbl2" ); st.setStyle( "font-weight: bold" ); st.setEscape( false ); st.setText( "Coeficiente de incapacidade: " ); pg.getChildren().add( st ); st = new StaticText(); st.setId( "stCoefIncapacidade" ); st.setEscape( false ); st.setText( a.getCoef_incapacidade().toString() + "%" ); pg.getChildren().add( st ); } if ( pg.getChildren().size() > 0 ) { gridIncapacidade2.getChildren().add( pg ); } pg = new PanelGroup(); if ( a.getData_aval_incapacidade() != null ) { pg.setId( "pgAvaliacaoIncapacidade" ); st = new StaticText(); st.setId( "stDataAvalIncapacidadeLbl1" ); st.setEscape( false ); st.setText( "Avaliação de incapacidade realizada em " ); pg.getChildren().add( st ); st = new StaticText(); st.setId( "stDataAvalIncapacidade" ); st.setEscape( false ); //st.setText(a.getData_aval_incapacidade()); try { java.util.Date ddate = new java.util.Date( a.getData_aval_incapacidade().getTime() ); st.setText( utils.Utils.dateToYYYYMMDD( ddate ) ); } catch ( Exception ex ) { // ErrorLogger.logException( ex ); } pg.getChildren().add( st ); } if ( a.getData_rev_incapacidade() != null ) { st = new StaticText(); st.setId( "stDataRevIncapacidadeLbl1" ); st.setEscape( false ); st.setText( "Revisão de incapacidade em " ); pg.getChildren().add( st ); st = new StaticText(); st.setId( "stDataRevIncapacidade" ); st.setEscape( false ); //st.setText(a.getData_rev_incapacidade()); try { java.util.Date ddate = new java.util.Date( a.getData_rev_incapacidade().getTime() ); st.setText( utils.Utils.dateToYYYYMMDD( ddate ) ); } catch ( Exception ex ) { // ErrorLogger.logException( ex ); } pg.getChildren().add( st ); } if ( pg.getChildren().size() > 0 ) { gridIncapacidade2.getChildren().add( pg ); } pg = new PanelGroup(); if ( a.getPeriodo_incapacidade_de() != null || a.getPeriodo_incapacidade_a() != null ) { pg.setId( "pgPeriodoIncapacidade" ); st = new StaticText(); st.setId( "stPeriodoIncapacidadeLbl1" ); st.setEscape( false ); st.setText( "Período de incapacidade temporária de " ); pg.getChildren().add( st ); st = new StaticText(); st.setId( "stPeriodoIncapacidadeDe" ); st.setEscape( false ); //st.setText(a.getPeriodo_incapacidade_de()); try { java.util.Date ddate = new java.util.Date( a.getPeriodo_incapacidade_de().getTime() ); st.setText( utils.Utils.dateToYYYYMMDD( ddate ) ); } catch ( Exception ex ) { // ErrorLogger.logException( ex ); } pg.getChildren().add( st ); st = new StaticText(); st.setId( "stPeriodoIncapacidadeLbl2" ); st.setEscape( false ); st.setText( " a " ); pg.getChildren().add( st ); st = new StaticText(); st.setId( "stPeriodoIncapacidadeA" ); st.setEscape( false ); //st.setText(a.getPeriodo_incapacidade_a()); try { java.util.Date ddate = new java.util.Date( a.getPeriodo_incapacidade_a().getTime() ); st.setText( utils.Utils.dateToYYYYMMDD( ddate ) ); } catch ( Exception ex ) { // ErrorLogger.logException( ex ); } pg.getChildren().add( st ); } if ( pg.getChildren().size() > 0 ) { gridIncapacidade2.getChildren().add( pg ); } //RESTRICOES // if(a.getImg_flexao().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgFlexao"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // pg = new PanelGroup(); // pg.setId("pgImgFlexao"); // img = new ImageComponent(); // img.setId("imgRestricoes1000"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/fle1.gif"); // pg.getChildren().add(img); // img = new ImageComponent(); // img.setId("imgRestricoes1001"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/fle2.gif"); // pg.getChildren().add(img); // img = new ImageComponent(); // img.setId("imgRestricoes1002"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/fle3.gif"); // pg.getChildren().add(img); // img = new ImageComponent(); // img.setId("imgRestricoes1003"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/fle4.gif"); // pg.getChildren().add(img); // grd.getChildren().add(pg); // st = new StaticText(); // st.setId("stImgRestricaoLbl1"); // st.setEscape(false); // st.setText("Flexão"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getImg_rot1().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgRot1"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // img = new ImageComponent(); // img.setId("imgRestricoes1005"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/rot1.gif"); // grd.getChildren().add(img); // st = new StaticText(); // st.setId("stImgRestricaoLbl2"); // st.setEscape(false); // st.setText("Flexão Lateral"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getImg_rot2().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgRot2"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // img = new ImageComponent(); // img.setId("imgRestricoes1006"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/rot2.gif"); // grd.getChildren().add(img); // st = new StaticText(); // st.setId("stImgRestricaoLbl3"); // st.setEscape(false); // st.setText("Rotação"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getImg_ext1().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgExt1"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // img = new ImageComponent(); // img.setId("imgRestricoes1007"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/ext1.gif"); // grd.getChildren().add(img); // st = new StaticText(); // st.setId("stImgRestricaoLbl4"); // st.setEscape(false); // st.setText("Extensão"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getImg_ext2().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgExt2"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // pg = new PanelGroup(); // pg.setId("pgImgExt2"); // img = new ImageComponent(); // img.setId("imgRestricoes1008"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/ext2.gif"); // pg.getChildren().add(img); // img = new ImageComponent(); // img.setId("imgRestricoes1009"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/ext3.gif"); // pg.getChildren().add(img); // img = new ImageComponent(); // img.setId("imgRestricoes1010"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/ext4.gif"); // pg.getChildren().add(img); // grd.getChildren().add(pg); // st = new StaticText(); // st.setId("stImgRestricaoLbl5"); // st.setEscape(false); // st.setText("Flexão/Extensão Lateral + Rotação"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getImg_cab1().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgCab1"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // img = new ImageComponent(); // img.setId("imgRestricoes10011"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/ca1.gif"); // grd.getChildren().add(img); // st = new StaticText(); // st.setId("stImgRestricaoLbl6"); // st.setEscape(false); // st.setText("Flexão"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getImg_cab2().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgCab2"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // img = new ImageComponent(); // img.setId("imgRestricoes10012"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/ca2.gif"); // grd.getChildren().add(img); // st = new StaticText(); // st.setId("stImgRestricaoLbl7"); // st.setEscape(false); // st.setText("Extensão"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getImg_cab3().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgCab3"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // img = new ImageComponent(); // img.setId("imgRestricoes10013"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/ca3.gif"); // grd.getChildren().add(img); // st = new StaticText(); // st.setId("stImgRestricaoLbl8"); // st.setEscape(false); // st.setText("Flexão Lateral"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getImg_cab4().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgCab4"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // img = new ImageComponent(); // img.setId("imgRestricoes10014"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/ca4.gif"); // grd.getChildren().add(img); // st = new StaticText(); // st.setId("stImgRestricaoLbl9"); // st.setEscape(false); // st.setText("Rotação"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getImg_ma1().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgMa1"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // img = new ImageComponent(); // img.setId("imgRestricoes10015"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/ma1.gif"); // grd.getChildren().add(img); // st = new StaticText(); // st.setId("stImgRestricaoLbl10"); // st.setEscape(false); // st.setText("Poronação"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getImg_ma2().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgMa2"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // img = new ImageComponent(); // img.setId("imgRestricoes10016"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/ma2.gif"); // grd.getChildren().add(img); // st = new StaticText(); // st.setId("stImgRestricaoLbl11"); // st.setEscape(false); // st.setText("Supinação"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getImg_ma3().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgMa3"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // img = new ImageComponent(); // img.setId("imgRestricoes10017"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/ma3.gif"); // grd.getChildren().add(img); // st = new StaticText(); // st.setId("stImgRestricaoLbl12"); // st.setEscape(false); // st.setText("Flexão"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getImg_ma4().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgMa4"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // img = new ImageComponent(); // img.setId("imgRestricoes10018"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/ma4.gif"); // grd.getChildren().add(img); // st = new StaticText(); // st.setId("stImgRestricaoLbl13"); // st.setEscape(false); // st.setText("Extensão"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getImg_ma5().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgMa5"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // img = new ImageComponent(); // img.setId("imgRestricoes10019"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/ma5.gif"); // grd.getChildren().add(img); // st = new StaticText(); // st.setId("stImgRestricaoLbl14"); // st.setEscape(false); // st.setText("Desvio Ulnar"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getImg_ma6().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgMa6"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // img = new ImageComponent(); // img.setId("imgRestricoes10020"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/ma6.gif"); // grd.getChildren().add(img); // st = new StaticText(); // st.setId("stImgRestricaoLbl15"); // st.setEscape(false); // st.setText("Desvio Radial"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getImg_ma7().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgMa7"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // img = new ImageComponent(); // img.setId("imgRestricoes10021"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/ma7.gif"); // grd.getChildren().add(img); // st = new StaticText(); // st.setId("stImgRestricaoLbl16"); // st.setEscape(false); // st.setText("Pinça Digital"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getImg_ma8().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgMa8"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // img = new ImageComponent(); // img.setId("imgRestricoes10022"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/ma8.gif"); // grd.getChildren().add(img); // st = new StaticText(); // st.setId("stImgRestricaoLbl17"); // st.setEscape(false); // st.setText("Segurar objectos entre os dedos"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getImg_ma9().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgMa9"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // img = new ImageComponent(); // img.setId("imgRestricoes10023"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/ma9.gif"); // grd.getChildren().add(img); // st = new StaticText(); // st.setId("stImgRestricaoLbl18"); // st.setEscape(false); // st.setText("Dedos em extensão"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getImg_ma10().matches("y")) // { // grd = new HtmlPanelGrid(); // grd.setId("grdImgMa10"); // grd.setColumns(1); // grd.setColumnClasses("gridColCenter"); // grd.setStyleClass("centerBlock"); // // img = new ImageComponent(); // img.setId("imgRestricoes10024"); // img.setWidth(IMAGE_WIDTH); // img.setHeight(IMAGE_HEIGHT); // img.setUrl("/resources/images/medico/ma10.gif"); // grd.getChildren().add(img); // st = new StaticText(); // st.setId("stImgRestricaoLbl19"); // st.setEscape(false); // st.setText("Pega palmar"); // grd.getChildren().add(st); // gridImagesRestricoes.getChildren().add(grd); // } // // if(a.getRestricao_carga() != null) // { // if(a.getRestricao_carga().intValue() > 0) // { // pg = new PanelGroup(); // st = new StaticText(); // st.setId("stRestricaoCargaLbl"); // st.setEscape(false); // st.setText("Movimentação e manipulação de cargas com mais de "); // pg.getChildren().add(st); // st = new StaticText(); // st.setId("stRestricaoCargaKgs"); // st.setEscape(false); // st.setText(a.getRestricao_carga().toString()); // pg.getChildren().add(st); // st = new StaticText(); // st.setId("stRestricaoCargaLbl1"); // st.setEscape(false); // st.setText("Kg"); // pg.getChildren().add(st); // gridOutrasRestricoes.getChildren().add(pg); // } // // if(a.getRestricao_motricidade().matches("y")) // { // st = new StaticText(); // st.setId("stRestricaoMotricidadeLbl"); // st.setEscape(false); // st.setText("Operações que requeiram motricidade fina."); // gridOutrasRestricoes.getChildren().add(st); // } // // if(a.getRestricao_conducao().matches("y")) // { // st = new StaticText(); // st.setId("stRestricaoConducaoLbl"); // st.setEscape(false); // st.setText("Condução/interacção com veículos ou outros equipamentos."); // gridOutrasRestricoes.getChildren().add(st); // } // // if(a.getRestricao_vibracoes().matches("y")) // { // st = new StaticText(); // st.setId("stRestricaoVibracoesLbl"); // st.setEscape(false); // st.setText("Utilizaçõo de equipamentos/ferramentas que impliquem exposição a vibrações ou impactos."); // gridOutrasRestricoes.getChildren().add(st); // } // // if(a.getRestricao_outras().trim().length() > 0) // { // st = new StaticText(); // st.setId("stRestricaoOutras"); // st.setEscape(false); // st.setText(a.getRestricao_outras()); // gridOutrasRestricoes.getChildren().add(st); // } // // if(a.getMed_observ().trim().length() > 0) // { // stObservacoes.setText(a.getMed_observ()); // } // } } // private String getPageFrom(String referer) // { // String pageFrom = referer.substring(referer.lastIndexOf("/")+1); // return pageFrom; // } // public String lnkNome_action() { // // TODO: Replace with your code // RowKey rk = tableRowGroup1.getRowKey(); // int k = Integer.parseInt(rk.getRowId()); // TrabalhadoresListDataProvider provider = (TrabalhadoresListDataProvider) tableRowGroup1.getSourceData(); // ArrayList list = (ArrayList) provider.getList(); // Trabalhador t = (Trabalhador)list.get(k); // txtTrabalhador.setText(t.getNome()); // txtNomeAcidentado.setText(t.getNome()); // txtDataNascimento.setText(t.getData_nascimento()); // Acidentado a = new Acidentado(); // a.setTrabalhador_id(t.getId()); // a.setData_nascimento(t.getData_nascimento()); // a.setNome(t.getNome()); // a.setFuncao(utils.Utils.unicodeToHTML(t.getFuncao())); // a.setData_admissao(t.getData_admissao()); // getSessionBean1().setAcidentado(a); // if(getSessionBean1().getCurrentAnalise() != null) // new analise) // { // gridTrabalhadores.setRendered(false); // } // // return null; // } // public String lnkDataNascimento_action() { // // TODO: Replace with your code // RowKey rk = tableRowGroup1.getRowKey(); // int k = Integer.parseInt(rk.getRowId()); // TrabalhadoresListDataProvider provider = (TrabalhadoresListDataProvider) tableRowGroup1.getSourceData(); // ArrayList list = (ArrayList) provider.getList(); // Trabalhador t = (Trabalhador)list.get(k); // txtTrabalhador.setText(t.getNome()); // txtNomeAcidentado.setText(t.getNome()); // txtDataNascimento.setText(t.getData_nascimento()); // Acidentado a = new Acidentado(); // a.setTrabalhador_id(t.getId()); // a.setData_nascimento(t.getData_nascimento()); // a.setNome(t.getNome()); // a.setFuncao(t.getFuncao()); // a.setData_admissao(t.getData_admissao()); // getSessionBean1().setAcidentado(a); // if(getSessionBean1().getCurrentAnalise() != null) // new analise) // { // gridTrabalhadores.setRendered(false); // } // return null; // } private void fillVerificacao( AnaliseAcidente a ) { int estado = a.getEstado().intValue(); switch ( estado ) { case Global.ESTADO_ASSINATURA_SEG: if ( a.getAss_resp_seg().matches( "y" ) ) { chkVerRespSeg.setSelected( new Boolean( true ) ); chkVerRespSeg.setDisabled( true ); java.util.Date ddate = new java.util.Date( a.getData_assinatura_seg().getTime() ); stVerRespSeg.setText( "Tomei conhecimento a " + utils.Utils.dateToYYYYMMDD( ddate ) ); } break; case Global.ESTADO_ASSINATURA_RH: if ( a.getAss_resp_rh().matches( "y" ) ) { chkVerRespRh.setSelected( new Boolean( true ) ); chkVerRespRh.setDisabled( true ); java.util.Date ddate = new java.util.Date( a.getData_assinatura_rh().getTime() ); stVerRespRh.setText( "Tomei conhecimento a " + utils.Utils.dateToYYYYMMDD( ddate ) ); } break; } } private void fillVerificacaoView( AnaliseAcidente a ) { StaticText st = null; String txtVer = null; if ( a.getAveriguador() != null ) { if ( a.getAveriguador().trim().length() > 0 ) { st = new StaticText(); st.setId( "stVerificacao1" ); st.setEscape( false ); txtVer = "Averiguado por " + a.getAveriguador() + " (Departamento de Segurança) a "; //txtVer += a.getData_assinatura_seg(); try { java.util.Date ddate = new java.util.Date( a.getData_inicio_processo().getTime() ); txtVer += utils.Utils.dateToYYYYMMDD( ddate ) + "."; } catch ( Exception ex ) { ErrorLogger.logException( ex ); } st.setText( txtVer ); gridAssinaturasView.getChildren().add( st ); } } if ( a.getAss_consolidacao().matches( "y" ) ) { st = new StaticText(); st.setId( "stVerificacao2" ); st.setEscape( false ); txtVer = "Verificado por " + a.getNome_resp_consolidacao() + " (Técnico de SHST) a "; //txtVer += a.getData_assinatura_rh(); try { java.util.Date ddate = new java.util.Date( a.getData_consolidacao().getTime() ); txtVer += utils.Utils.dateToYYYYMMDD( ddate ) + "."; } catch ( Exception ex ) { ErrorLogger.logException( ex ); } st.setText( txtVer ); gridAssinaturasView.getChildren().add( st ); } if ( a.getAss_resp_seg().matches( "y" ) ) { st = new StaticText(); st.setId( "stVerificacao3" ); st.setEscape( false ); txtVer = "Verificado por " + a.getNome_resp_seg() + " (Responsável de Segurança) a "; //txtVer += a.getData_assinatura_rh(); try { java.util.Date ddate = new java.util.Date( a.getData_assinatura_seg().getTime() ); txtVer += utils.Utils.dateToYYYYMMDD( ddate ) + "."; } catch ( Exception ex ) { ErrorLogger.logException( ex ); } st.setText( txtVer ); gridAssinaturasView.getChildren().add( st ); } if ( a.getAss_resp_rh().matches( "y" ) ) { st = new StaticText(); st.setId( "stVerificacao4" ); st.setEscape( false ); txtVer = "Verificado por " + a.getNome_resp_rh() + " (Responsável de RH) a "; //txtVer += a.getData_assinatura_rh(); try { java.util.Date ddate = new java.util.Date( a.getData_assinatura_rh().getTime() ); txtVer += utils.Utils.dateToYYYYMMDD( ddate ) + "."; } catch ( Exception ex ) { ErrorLogger.logException( ex ); } st.setText( txtVer ); gridAssinaturasView.getChildren().add( st ); } // AnalisesDataProvider adp = new AnalisesDataProvider(); try { AnalisesDataProvider adp = AnalisesDataProvider.getInstance(); Acidentado ac = adp.getAcidentado( a.getAcidentado_id() ); if ( ac.getNome_superior_hierarquico() != null ) { if ( ac.getNome_superior_hierarquico().trim().length() > 0 ) { st = new StaticText(); st.setId( "stVerificacao5" ); st.setEscape( false ); txtVer = "Com conhecimento de " + ac.getNome_superior_hierarquico() + " (Responsável hierárquico)"; if ( ac.getEmail_superior_hierarquico() != null ) { if ( ac.getEmail_superior_hierarquico().trim().length() > 0 ) { try { java.util.Date ddate = new java.util.Date( ac.getData_email_superior_hierarquico().getTime() ); txtVer += " a " + utils.Utils.dateToYYYYMMDD( ddate ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } } txtVer += "."; st.setText( txtVer ); gridAssinaturasView.getChildren().add( st ); } } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } HtmlPanelGrid grid = new HtmlPanelGrid(); grid.setId( "rodape1" ); grid.setColumns( 1 ); grid.setStyle( "width: 100%" ); grid.setColumnClasses( "gridColCenter" ); st = new StaticText(); st.setId( "stRodape1" ); st.setEscape( false ); st.setText( "- processamento informático - acesso autenticado -" ); grid.getChildren().add( st ); gridAssinaturasView.getChildren().add( grid ); } private AnaliseAcidente fillAnaliseFieldsImpressao( AnaliseAcidente a ) { a.setAss_superior( "n" ); if ( chkAssSup.getSelected() != null ) { if ( chkAssSup.getSelected().equals( new Boolean( true ) ) ) { a.setAss_superior( "y" ); } } if ( a.getAss_superior().matches( "y" ) ) { a.setNome_superior( "" ); if ( txtAssSup.getText() != null ) { a.setNome_superior( ( String ) txtAssSup.getText() ); } java.util.Date today = new java.util.Date(); java.sql.Date sqlToday = new java.sql.Date( today.getTime() ); a.setData_assinatura_superior( sqlToday ); } else { a.setNome_superior( "" ); a.setData_assinatura_superior( null ); } return a; } private void fillImpressao( AnaliseAcidente a ) { if ( a.getAss_superior().matches( "y" ) ) { chkAssSup.setSelected( new Boolean( true ) ); txtAssSup.setText( a.getNome_superior() ); String txt = ( String ) stAssSup2.getText(); String nome_acidentado = getSessionBean1().getAcidentado().getNome(); String stData = ""; try { java.util.Date ddate = new java.util.Date( a.getData_assinatura_superior().getTime() ); stData += utils.Utils.dateToYYYYMMDD( ddate ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } stAssSup2.setText( txt + nome_acidentado + ", a " + stData ); } } private void fillImpressaoView( AnaliseAcidente a ) { StaticText st = new StaticText(); st.setId( "stImpressaoView1" ); st.setEscape( false ); String stData = ""; try { java.util.Date ddate = new java.util.Date( a.getData_assinatura_superior().getTime() ); stData += utils.Utils.dateToYYYYMMDD( ddate ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } String txt = "Assinado na Ficha de Análise de Acidente em papel por " + a.getNome_superior() + ", superior hierárquico / superior de "; txt += getSessionBean1().getAcidentado().getNome() + ", a " + stData; gridAssSupView.getChildren().add( st ); } 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. getSessionBean1().setIeBug( true ); savePageState(); return "load_image"; } private void fillImages() { // String imageName = getSessionBean1().getImageName(); // if(imageName != null) // { // ImageComponent newImg = new ImageComponent(); // newImg.setUrl("/resources/imagens/" + imageName); // System.out.println("IMAGE URL : " + "/resources/imagens/" + imageName); // newImg.setRendered(true); // gridImages.getChildren().add(newImg); // System.out.println("HERE"); // } // if(gridImages.getChildren().size() > 0) // { // gridImages.getChildren().clear(); // } ServletContext theApplicationsServletContext = ( ServletContext ) this.getExternalContext().getContext(); File apacheTmpFolder = new File( theApplicationsServletContext.getRealPath( Global.RESOURCES_IMAGE_FOLDER ) + "/tmp" + getSessionBean1().getCurrentUser().getLogin() ); if ( apacheTmpFolder.exists() ) { Global global = new Global(); global.deleteFolderFiles( apacheTmpFolder ); } else { apacheTmpFolder.mkdir(); } // String imageFileFolder = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin()); String imageFileFolder = Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin(); try { File f = new File( imageFileFolder ); if ( f.exists() ) { File files[] = f.listFiles(); //List list = Arrays.asList(files); Arrays.sort( files ); for ( int i = 0; i < files.length; i++ ) { if ( files[i].isFile() ) { String imageName = files[i].getName(); File apacheImage = new File( theApplicationsServletContext.getRealPath( Global.RESOURCES_IMAGE_FOLDER ) + "/tmp" + getSessionBean1().getCurrentUser().getLogin() + "/" + imageName ); Global global = new Global(); global.copyImage( files[i], apacheImage ); ImageComponent newImg = new ImageComponent(); newImg.setId( "img_comp" + imageName ); //newImg.setUrl(Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin() + "/" + imageName); newImg.setUrl( Global.RESOURCES_IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin() + "/" + imageName ); //System.out.println("IMAGE URL : " + newImg.getUrl()); newImg.setRendered( true ); gridImages.getChildren().add( newImg ); Hyperlink ln = new Hyperlink(); ln.setId( "img" + imageName ); ln.setText( "Apagar" ); //ln.setValue(imageName); Class args[] = { javax.faces.event.ActionEvent.class }; ApplicationFactory factory = ( ApplicationFactory ) FactoryFinder.getFactory( FactoryFinder.APPLICATION_FACTORY ); //mb = factory.getApplication().createMethodBinding( "#{EditarQuestionario.lnkGrupo_onClick}", args); MethodBinding mbAction = ( MethodBinding ) factory.getApplication().createMethodBinding( "#{AnaliseAcidenteTrabalho.lnkDelImageTmp_actionListener}", args ); ln.setActionListener( mbAction ); gridImages.getChildren().add( ln ); } } } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } 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. getSessionBean1().setIeBug( true ); ServletContext theApplicationsServletContext = ( ServletContext ) this.getExternalContext().getContext(); // String imageFileFolderTmp = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin()); String imageFileFolderTmp = Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin(); File ftmp = new File( imageFileFolderTmp ); if ( ftmp.exists() ) { File files[] = ftmp.listFiles(); for ( int i = 0; i < files.length; i++ ) { if ( files[i].isFile() ) { files[i].delete(); } } ftmp.delete(); } 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"; } return null; } public String butGravar_action() { System.out.println( "BUT GRAVAR" ); AnaliseAcidente analise = getSessionBean1().getCurrentAnalise(); if ( analise == null ) //new analise { if ( validateDataOcorrencia( analise ) ) { if ( validationDepartmentSectionOk() ) { AnaliseAcidente a = fillAnaliseFields(); Acidentado ac = fillAcidentadoFields(); if ( fieldsLenOk() ) { try { if ( !getSessionBean1().isGravado() ) { getSessionBean1().setGravado( true ); AnaliseAcidente aa = create( a, ac ); createImagesFolder( aa ); getSessionBean1().setMsg( "A Ficha de Análise de Acidente nº " + aa.getAnalise_nr() + " foi gravada na sua área de trabalho." ); } else { getSessionBean1().setMsg( "A Ficha de Análise de Acidente foi gravada na sua área de trabalho." ); } String navFrom = getSessionBean1().getNavFrom(); if ( navFrom.matches( "FormSeguranca" ) ) { return "form_seguranca"; } } catch ( Exception ex ) { getSessionBean1().setMsg( "Erro na inserção da análise !" ); getSessionBean1().setGravado( false ); ErrorLogger.logException( ex ); } } } else { getSessionBean1().setGravado( false ); } } else { getSessionBean1().setGravado( false ); } } else // edit analise { if ( validateDataOcorrencia( analise ) ) { if ( fieldsLenOk() ) { 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 ); a.setRh_fase4( getSessionBean1().getCurrentUser().getId() ); } try { if ( !getSessionBean1().isGravado() ) { getSessionBean1().setGravado( true ); update( a, ac, recs, meds ); //createImagesFolder(analiseId.toString()); updateImagesFolder( a ); getSessionBean1().setMsg( "A Ficha de Análise de Acidente nº " + a.getAnalise_nr() + " foi gravada na sua área de trabalho." ); } else { getSessionBean1().setMsg( "A Ficha de Análise de Acidente nº " + a.getAnalise_nr() + " foi gravada na sua área de trabalho." ); } if ( estado != Global.ESTADO_ASSINATURA_RH ) { 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"; } } else { chkVerRespRh.setDisabled( true ); // IMPRIMIR HERE } } catch ( Exception ex ) { getSessionBean1().setMsg( "Erro na actualização da análise !" ); getSessionBean1().setGravado( false ); ErrorLogger.logException( ex ); } } } } return null; } public String butEnviar_action() { System.out.println( "BUT ENVIAR 1" ); //IE bugs if ( getSessionBean1().isIeBug() ) { return null; } if ( getSessionBean1().isGravado() ) { getSessionBean1().setSubmetido( true ); } if ( getSessionBean1().getCurrentAnalise() == null ) //new analise { if ( validationOk() ) { AnaliseAcidente a = fillAnaliseFields(); Acidentado ac = fillAcidentadoFields(); //int novo_estado = a.getEstado().intValue(); a.setEstado( new Integer( Global.ESTADO_RH1 ) ); try { if ( !getSessionBean1().isSubmetido() ) { getSessionBean1().setSubmetido( true ); AnaliseAcidente aa = create( a, ac ); createImagesFolder( aa ); String errorMessage = ""; errorMessage += sendMailToNextUser( a, new Integer( Global.ESTADO_RH1 ) ); if ( "".equals( errorMessage.trim() ) ) { getSessionBean1().setMsg( "A Ficha de Análise de Acidente nº " + aa.getAnalise_nr() + " foi enviada para a fase seguinte." ); } else { getSessionBean1().setMsg( errorMessage ); } } else { getSessionBean1().setMsg( "A Ficha de Análise de Acidente foi enviada para a fase seguinte." ); } String navFrom = getSessionBean1().getNavFrom(); if ( navFrom.matches( "FormSeguranca" ) ) { return "form_seguranca"; } } catch ( Exception ex ) { getSessionBean1().setMsg( "Erro no envio da análise !" ); getSessionBean1().setSubmetido( false ); ErrorLogger.logException( ex ); } } else { getSessionBean1().setSubmetido( false ); } } else // edit analise { 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 ); a.setRh_fase4( getSessionBean1().getCurrentUser().getId() ); } int novo_estado = a.getEstado().intValue(); if ( a.getCorrecao().matches( "y" ) ) { a.setCorrecao( "n" ); a.setEstado( a.getEstado_antes_correcao() ); novo_estado = a.getEstado_antes_correcao().intValue(); a.setEstado_antes_correcao( null ); a.setObservacoes_correcao( "" ); //sendMailToNextUser(a, new Integer(novo_estado)); } else { if ( novo_estado < Global.ESTADO_CONCLUIDO ) { if ( !getSessionBean1().isSubmetido() ) { novo_estado++; } // if(novo_estado == ESTADO_MEDICO) // { // novo_estado++; //skip medico // } // if(novo_estado == Global.ESTADO_ASSINATURA_SEG || novo_estado == Global.ESTADO_ASSINATURA_RH) // { // //a.setEstado_assinatura(new Integer(ESTADO_ASSINATURA_1)); // notifyNextSignature(new Integer(novo_estado)); // } } a.setEstado( new Integer( novo_estado ) ); } try { if ( !getSessionBean1().isSubmetido() ) { getSessionBean1().setSubmetido( true ); update( a, ac, recs, meds ); //createImagesFolder(analiseId.toString()); updateImagesFolder( a ); String errorMessage = ""; errorMessage += sendMailToNextUser( a, new Integer( novo_estado ) ); //envia email para responsavel hierarquico ao passar da Consolidacao para a Verificacao if ( a.getEstado().intValue() == Global.ESTADO_ASSINATURA_SEG ) { errorMessage += sendEmailResponsavelHierarquico( a ); } else if ( a.getEstado().intValue() == Global.ESTADO_CONCLUIDO ) { errorMessage += sendEmailFimProcesso( a ); errorMessage += sendEmailToRhFase4( a ); } if ( "".equals( errorMessage.trim() ) ) { getSessionBean1().setMsg( "A Ficha de Análise de Acidente nº " + a.getAnalise_nr() + " foi enviada para a fase seguinte." ); } else { getSessionBean1().setMsg( errorMessage ); } } else { getSessionBean1().setMsg( "A Ficha de Análise de Acidente nº " + a.getAnalise_nr() + " foi enviada para a fase seguinte." ); } 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 !" ); getSessionBean1().setSubmetido( false ); ErrorLogger.logException( ex ); } } else { getSessionBean1().setSubmetido( false ); } } return null; } private AnaliseAcidente create( AnaliseAcidente a, Acidentado ac ) throws Exception { // AnalisesDataProvider adp = new AnalisesDataProvider(); AnalisesDataProvider adp = AnalisesDataProvider.getInstance(); Integer acidentado_id = adp.createAcidentado( ac ); a.setAcidentado_id( acidentado_id ); AnaliseAcidente aa = adp.createAnalise( a ); return aa; } private void update( AnaliseAcidente a, Acidentado ac, ArrayList recs, ArrayList meds ) throws Exception { // AnalisesDataProvider adp = new AnalisesDataProvider(); AnalisesDataProvider adp = AnalisesDataProvider.getInstance(); if ( ac != null ) { adp.updateAcidentado( ac ); } if ( recs != null ) { //remove recs form analise try { adp.deleteRecomendacoesByAnalise( a.getId() ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } ListIterator iter = recs.listIterator(); while ( iter.hasNext() ) { Recomendacao r = ( Recomendacao ) iter.next(); adp.createRecomendacao( r ); } } else if ( meds != null ) { //remove meds form analise try { adp.deleteMedidasByAnalise( a.getId() ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } ListIterator iter = meds.listIterator(); while ( iter.hasNext() ) { Medida m = ( Medida ) iter.next(); adp.createMedida( m ); } } adp.updateAnalise( a ); } private Acidentado fillAcidentadoFields() { Acidentado a = getSessionBean1().getAcidentado(); a.setBilhete_identidade( "" ); if ( txtBI.getText() != null ) { String bi = ( String ) txtBI.getText(); if ( bi.trim().length() > 0 ) { a.setBilhete_identidade( bi ); } } a.setMorada( "" ); if ( txtMorada.getText() != null ) { String morada = ( String ) txtMorada.getText(); if ( morada.trim().length() > 0 ) { a.setMorada( morada ); } } a.setCod_postal( "" ); String cod_postal = ""; if ( txtCodPostal1.getText() != null ) { String cod_postal1 = ( String ) txtCodPostal1.getText(); String cod_postal2 = ""; if ( txtCodPostal2.getText() != null ) { cod_postal2 = ( String ) txtCodPostal2.getText(); } if ( cod_postal1.trim().length() > 0 ) { cod_postal = ( String ) txtCodPostal1.getText() + "-" + ( String ) txtCodPostal2.getText(); a.setCod_postal( cod_postal ); } } a.setLocalidade( "" ); if ( txtLocalidade.getText() != null ) { String localidade = ( String ) txtLocalidade.getText(); if ( localidade.trim().length() > 0 ) { a.setLocalidade( localidade ); } } a.setContacto_telefonico( "" ); if ( txtContactoTelefonico.getText() != null ) { String contacto_telefonico = ( String ) txtContactoTelefonico.getText(); if ( contacto_telefonico.trim().length() > 0 ) { a.setContacto_telefonico( contacto_telefonico ); } } a.setTurno( "v" ); // null if ( rbTurnoManha.getValue() != null ) { if ( rbTurnoManha.getValue().equals( new Boolean( true ) ) ) { a.setTurno( "m" ); } } if ( rbTurnoTarde.getValue() != null ) { if ( rbTurnoTarde.getValue().equals( new Boolean( true ) ) ) { a.setTurno( "t" ); } } if ( rbTurnoNoite.getValue() != null ) { if ( rbTurnoNoite.getValue().equals( new Boolean( true ) ) ) { a.setTurno( "n" ); } } if ( rbTurnoOutro.getValue() != null ) { if ( rbTurnoOutro.getValue().equals( new Boolean( true ) ) ) { a.setTurno( "o" ); } } if ( txtNomeSuperior.getText() != null ) { a.setNome_superior_hierarquico( ( String ) txtNomeSuperior.getText() ); } if ( txtEmailSuperior.getText() != null ) { a.setEmail_superior_hierarquico( ( String ) txtEmailSuperior.getText() ); java.util.Date today = new java.util.Date(); java.sql.Date sqlToday = new java.sql.Date( today.getTime() ); a.setData_email_superior_hierarquico( sqlToday ); } return a; } private AnaliseAcidente fillAnaliseFields() { int estado = 0; AnaliseAcidente a = null; //fill analise fields if ( getSessionBean1().getCurrentAnalise() == null ) { a = new AnaliseAcidente(); a.setEspecif1( "" ); a.setEspecif2( "" ); a.setEspecif3( "" ); a.setEspecif4( "" ); a.setRestricao_outras( "" ); a.setTipo_lesao( "" ); a.setMed_observ( "" ); estado = Global.ESTADO_SEG; a.setEstado( new Integer( estado ) ); } else { a = getSessionBean1().getCurrentAnalise(); estado = a.getEstado().intValue(); } //averiguacao posterior // if(estado < Global.ESTADO_ASSINATURAS) if ( estado <= Global.ESTADO_ASSINATURA_SEG ) { if ( getSessionBean1().getCurrentUser().getTipo().intValue() == 1 ) //seguranca { if ( a.getAveriguacao_posterior().matches( "y" ) ) { if ( txtAveriguacaoObs1.getText() != null ) { a.setAveriguacao_obs( ( String ) txtAveriguacaoObs1.getText() ); } } } } switch ( estado ) { case Global.ESTADO_SEG: a = fillAnaliseFieldsSeg( a ); break; case Global.ESTADO_RH1: //a = fillAnaliseFieldsSeg(a); a = fillAnaliseFieldsRH1( a ); break; case Global.ESTADO_HS: //a = fillAnaliseFieldsHS(a); break; case Global.ESTADO_RH2: a = fillAnaliseFieldsMedico( a ); //a = fillAnaliseFieldsRH2(a); break; // case Global.ESTADO_MEDICINA: // a = fillAnaliseFieldsMedico(a); // break; case Global.ESTADO_CONSOLIDACAO: a = fillAnaliseFieldsConsolidacao( a ); break; // case Global.ESTADO_ASSINATURAS: case Global.ESTADO_ASSINATURA_SEG: a = fillAnaliseAssinaturas( a ); break; case Global.ESTADO_ASSINATURA_RH: a = fillAnaliseAssinaturas( a ); break; } if( chkParticipacao.isChecked() ) { a = fillAnaliseFieldsParticipacao( a ); } else { a = clearAnaliseFieldsParticipacao( a ); } return a; } private AnaliseAcidente fillAnaliseFieldsSeg( AnaliseAcidente a ) { if ( txtAveriguador.getText() != null ) { a.setAveriguador( ( String ) txtAveriguador.getText() ); } java.util.Date today = new java.util.Date(); java.sql.Date sqlToday = new java.sql.Date( today.getTime() ); //if(a.getData_acidente() == null) //{ // a.setData_acidente(sqlToday); //} //else //{ DateFormat formatador = new SimpleDateFormat( "yyyy-MM-dd" ); // java.util.Date ddate = ( java.util.Date ) calDataOcorrencia.getValue(); Date ddate = getCalDataOcorrencia(); try { String ddate_str = formatador.format( ddate ); java.sql.Date ddate_sql = new java.sql.Date( formatador.parse( ddate_str ).getTime() ); a.setData_acidente( ddate_sql ); } catch ( Exception ex ) { a.setData_acidente( null ); } //} if ( a.getData_inicio_processo() == null ) { a.setData_inicio_processo( sqlToday ); } Integer hhInt = ( Integer ) drpHours.getSelected(); Integer mmInt = ( Integer ) drpMinutes.getSelected(); if ( hhInt.intValue() == -1 || mmInt.intValue() == -1 ) { a.setHora_acidente( null ); } else { // String hh = drpHours.getSelected().toString(); // String mm = drpMinutes.getSelected().toString(); String hh = hhInt.toString(); String mm = mmInt.toString(); SimpleDateFormat formatter = new SimpleDateFormat( "HH:mm" ); try { Time horaAcidente = new Time( formatter.parse( hh + ":" + mm ).getTime() ); a.setHora_acidente( horaAcidente ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } if ( getSessionBean1().getCurrentAnalise() == null ) // new { a.setEmpresa_id( getSessionBean1().getCurrentUser().getEmpresa_id() ); a.setEstabelecimento_id( getSessionBean1().getCurrentUser().getEstabelecimento_id() ); } // Integer medico_id = (Integer) drpMedicos.getSelected(); Medico m = getSessionBean1().getMedico(); if ( m != null ) { Integer medico_id = m.getId(); if ( medico_id.intValue() > 0 ) { a.setMedico_id( medico_id ); } } Integer horas_turno = null; String horas_turno_str = ( String ) txtHorasTurno.getText(); if ( horas_turno_str != null && ! "".equals( horas_turno_str.trim() ) ) { try { horas_turno = Integer.parseInt( horas_turno_str ); } catch ( Exception e ) { ErrorLogger.logException( e ); } } a.setHoras_turno( horas_turno ); a.setDepartamento_id( ( Integer ) drpDepartamento.getSelected() ); a.setSeccao_id( ( Integer ) drpSeccao.getSelected() ); try { if ( txtLocal.getText() != null ) { a.setLocal_trabalho( ( String ) txtLocal.getText() ); } else { a.setLocal_trabalho( "" ); } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } try { if ( txtTarefa.getText() != null ) { a.setTarefa( ( String ) txtTarefa.getText() ); } else { a.setTarefa( "" ); } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } try { if ( txtSubstancias.getText() != null ) { a.setSubstancias( ( String ) txtSubstancias.getText() ); } else { a.setSubstancias( "" ); } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } // try // { // if(txtSuperior.getText() != null) // { // a.setSuperior_hierarquico( (String) txtSuperior.getText() ); // } // else // { // a.setSuperior_hierarquico(""); // } // } // catch(Exception ex) // { // ErrorLogger.logException( ex ); // } try { if ( txtCondicoes.getText() != null ) { a.setCondicoes( ( String ) txtCondicoes.getText() ); } else { a.setCondicoes( "" ); } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } try { if ( txtTestemunhas.getText() != null ) { a.setTestemunhas( ( String ) txtTestemunhas.getText() ); } else { a.setTestemunhas( "" ); } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } // try // { // if(txtCausas.getText() != null) // { // a.setCausas( (String) txtCausas.getText() ); // } // else // { // a.setCausas(""); // } // } // catch(Exception ex) // { // ErrorLogger.logException( ex ); // } a.setCausas( ( Integer ) drpCausas.getSelected() ); try { if ( txtDescricao.getText() != null ) { a.setDescricao( ( String ) txtDescricao.getText() ); } else { a.setDescricao( "" ); } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } try { if ( txtConclusoes.getText() != null ) { a.setConclusoes( ( String ) txtConclusoes.getText() ); } else { a.setConclusoes( "" ); } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } try { if ( txtAccoes.getText() != null ) { a.setAccoes( ( String ) txtAccoes.getText() ); } else { a.setAccoes( "" ); } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } a.setAveriguacao_posterior( "n" ); if ( chkAveriguacaoPosterior.getSelected() != null ) { if ( chkAveriguacaoPosterior.getSelected().equals( new Boolean( true ) ) ) { a.setAveriguacao_posterior( "y" ); } } if ( txtAveriguacaoObs.getText() != null ) { a.setAveriguacao_obs( ( String ) txtAveriguacaoObs.getText() ); } return a; } private AnaliseAcidente fillAnaliseFieldsRH1( AnaliseAcidente a ) { boolean booFormacaoSHST = false; if ( rbFormacaoSHSTY.getSelected() != null ) { Boolean f = ( Boolean ) rbFormacaoSHSTY.getSelected(); if ( f.equals( new Boolean( true ) ) ) { a.setFormacao_shst( "y" ); booFormacaoSHST = true; } } if ( !booFormacaoSHST ) { if ( rbFormacaoSHSTN.getSelected() != null ) { Boolean f = ( Boolean ) rbFormacaoSHSTN.getSelected(); if ( f.equals( new Boolean( true ) ) ) { a.setFormacao_shst( "n" ); a.setFormacao_shst_nao_porque( "" ); if ( txtFormacaoSHSTNWhy.getText() != null ) { String s = ( String ) txtFormacaoSHSTNWhy.getText(); if ( s.trim().length() > 0 ) { a.setFormacao_shst_nao_porque( s ); } } } } else { a.setFormacao_shst( "t" ); } } boolean booAcidentesColaborador = false; a.setOutros_acidentes_com_colaborador( "n" ); if ( rbAcidentesColaboradorY.getSelected() != null ) { Boolean f = ( Boolean ) rbAcidentesColaboradorY.getSelected(); if ( f.equals( new Boolean( true ) ) ) { a.setOutros_acidentes_com_colaborador( "y" ); booAcidentesColaborador = true; if ( txtNrAcidentesColaborador.getText() != null ) { String nr_str = ( String ) txtNrAcidentesColaborador.getText(); if ( nr_str.trim().length() > 0 ) { try { Integer nr = new Integer( Integer.parseInt( nr_str ) ); a.setNr_acidentes_com_colaborador( nr ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } } if ( txtNrRelatorioAcidentesColaborador1.getText() != null ) { String nr_str = ( String ) txtNrRelatorioAcidentesColaborador1.getText(); if ( nr_str.trim().length() > 0 ) { try { Integer nr = new Integer( Integer.parseInt( nr_str ) ); a.setNr_relatorio_acidente_colaborador1( nr ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } } if ( txtNrRelatorioAcidentesColaborador2.getText() != null ) { String nr_str = ( String ) txtNrRelatorioAcidentesColaborador2.getText(); if ( nr_str.trim().length() > 0 ) { try { Integer nr = new Integer( Integer.parseInt( nr_str ) ); a.setNr_relatorio_acidente_colaborador2( nr ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } } if ( txtNrRelatorioAcidentesColaborador3.getText() != null ) { String nr_str = ( String ) txtNrRelatorioAcidentesColaborador3.getText(); if ( nr_str.trim().length() > 0 ) { try { Integer nr = new Integer( Integer.parseInt( nr_str ) ); a.setNr_relatorio_acidente_colaborador3( nr ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } } if ( txtNrRelatorioAcidentesColaborador4.getText() != null ) { String nr_str = ( String ) txtNrRelatorioAcidentesColaborador4.getText(); if ( nr_str.trim().length() > 0 ) { try { Integer nr = new Integer( Integer.parseInt( nr_str ) ); a.setNr_relatorio_acidente_colaborador4( nr ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } } } } if ( !booAcidentesColaborador ) { if ( rbAcidentesColaboradorN.getSelected() != null ) { Boolean f = ( Boolean ) rbAcidentesColaboradorN.getSelected(); if ( f.equals( new Boolean( true ) ) ) { a.setOutros_acidentes_com_colaborador( "n" ); } } else { a.setOutros_acidentes_com_colaborador( "t" ); } } boolean booAcidentesColaboradores = false; if ( rbAcidentesColaboradoresY.getSelected() != null ) { Boolean f = ( Boolean ) rbAcidentesColaboradoresY.getSelected(); if ( f.equals( new Boolean( true ) ) ) { a.setAcidentes_outros_colaboradores( "y" ); booAcidentesColaboradores = true; if ( txtNrAcidentesColaboradores.getText() != null ) { String nr_str = ( String ) txtNrAcidentesColaboradores.getText(); if ( nr_str.trim().length() > 0 ) { try { Integer nr = new Integer( Integer.parseInt( nr_str ) ); a.setNr_acidentes_outros_colaboradores( nr ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } } if ( txtNrRelatorioAcidentesColaboradores1.getText() != null ) { String nr_str = ( String ) txtNrRelatorioAcidentesColaboradores1.getText(); if ( nr_str.trim().length() > 0 ) { try { Integer nr = new Integer( Integer.parseInt( nr_str ) ); a.setNr_relatorio_acidente_outros_colaboradores1( nr ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } } if ( txtNrRelatorioAcidentesColaboradores2.getText() != null ) { String nr_str = ( String ) txtNrRelatorioAcidentesColaboradores2.getText(); if ( nr_str.trim().length() > 0 ) { try { Integer nr = new Integer( Integer.parseInt( nr_str ) ); a.setNr_relatorio_acidente_outros_colaboradores2( nr ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } } if ( txtNrRelatorioAcidentesColaboradores3.getText() != null ) { String nr_str = ( String ) txtNrRelatorioAcidentesColaboradores3.getText(); if ( nr_str.trim().length() > 0 ) { try { Integer nr = new Integer( Integer.parseInt( nr_str ) ); a.setNr_relatorio_acidente_outros_colaboradores3( nr ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } } if ( txtNrRelatorioAcidentesColaboradores4.getText() != null ) { String nr_str = ( String ) txtNrRelatorioAcidentesColaboradores4.getText(); if ( nr_str.trim().length() > 0 ) { try { Integer nr = new Integer( Integer.parseInt( nr_str ) ); a.setNr_relatorio_acidente_outros_colaboradores4( nr ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } } } } if ( !booAcidentesColaboradores ) { if ( rbAcidentesColaboradoresN.getSelected() != null ) { Boolean f = ( Boolean ) rbAcidentesColaboradoresN.getSelected(); if ( f.equals( new Boolean( true ) ) ) { a.setAcidentes_outros_colaboradores( "n" ); } } else { a.setAcidentes_outros_colaboradores( "t" ); } } return a; } private ArrayList fillAnaliseRecomendacoesHs( AnaliseAcidente a ) { System.out.println( "FILL RECOMENDACOES" ); ArrayList list = new ArrayList(); ListIterator iter = gridRecomendacoes.getChildren().listIterator(); while ( iter.hasNext() ) { HtmlPanelGrid grd = ( HtmlPanelGrid ) iter.next(); TextArea ta = ( TextArea ) grd.getChildren().get( 1 ); if ( ta.getText() != null ) { String txt = ( String ) ta.getText(); if ( txt.trim().length() > 0 ) { Recomendacao r = new Recomendacao(); r.setAnalise_id( a.getId() ); r.setRecomendacao( txt ); list.add( r ); } } } return list; } private ArrayList fillAnaliseMedidasRh( AnaliseAcidente a ) { ArrayList list = new ArrayList(); ListIterator iter = gridMedidas.getChildren().listIterator(); while ( iter.hasNext() ) { HtmlPanelGrid grd = ( HtmlPanelGrid ) iter.next(); TextArea ta = ( TextArea ) grd.getChildren().get( 1 ); if ( ta.getText() != null ) { String txt = ( String ) ta.getText(); if ( txt.trim().length() > 0 ) { Medida m = new Medida(); m.setAnalise_id( a.getId() ); m.setMedida( txt ); list.add( m ); } } } return list; } private AnaliseAcidente fillAnaliseFieldsRH2( AnaliseAcidente a ) { return a; } private AnaliseAcidente fillAnaliseFieldsMedico( AnaliseAcidente a ) { a.setLesao_cabeca( "n" ); if ( chkCabeca.getSelected() != null ) { if ( chkCabeca.getSelected().equals( new Boolean( true ) ) ) { a.setLesao_cabeca( "y" ); } } a.setLesao_pescoco( "n" ); if ( chkPescoco.getSelected() != null ) { if ( chkPescoco.getSelected().equals( new Boolean( true ) ) ) { a.setLesao_pescoco( "y" ); } } a.setLesao_tronco( "n" ); if ( chkTronco.getSelected() != null ) { if ( chkTronco.getSelected().equals( new Boolean( true ) ) ) { a.setLesao_tronco( "y" ); } } a.setEspecif1( "" ); a.setEspecif2( "" ); a.setEspecif3( "" ); a.setEspecif4( "" ); a.setLesao_membro_sup_dir( "n" ); if ( chkMembroSupDir.getSelected() != null ) { if ( chkMembroSupDir.getSelected().equals( new Boolean( true ) ) ) { a.setLesao_membro_sup_dir( "y" ); if ( txtEspecif1.getText() != null ) { a.setEspecif1( ( String ) txtEspecif1.getText() ); } } } a.setLesao_membro_sup_esq( "n" ); if ( chkMembroSupEsq.getSelected() != null ) { if ( chkMembroSupEsq.getSelected().equals( new Boolean( true ) ) ) { a.setLesao_membro_sup_esq( "y" ); if ( txtEspecif2.getText() != null ) { a.setEspecif2( ( String ) txtEspecif2.getText() ); } } } a.setLesao_membro_inf_dir( "n" ); if ( chkMembroInfDir.getSelected() != null ) { if ( chkMembroInfDir.getSelected().equals( new Boolean( true ) ) ) { a.setLesao_membro_inf_dir( "y" ); if ( txtEspecif3.getText() != null ) { a.setEspecif3( ( String ) txtEspecif3.getText() ); } } } a.setLesao_membro_inf_esq( "n" ); if ( chkMembroInfEsq.getSelected() != null ) { if ( chkMembroInfEsq.getSelected().equals( new Boolean( true ) ) ) { a.setLesao_membro_inf_esq( "y" ); if ( txtEspecif4.getText() != null ) { a.setEspecif4( ( String ) txtEspecif4.getText() ); } } } a.setTipo_lesao( "" ); if ( txtTipoLesao.getText() != null ) { a.setTipo_lesao( ( String ) txtTipoLesao.getText() ); } a.setTipo_incapacidade( "v" ); if ( rbIncapacidadeNone.getSelected() != null ) { if ( rbIncapacidadeNone.getSelected().equals( new Boolean( true ) ) ) { a.setTipo_incapacidade( "n" ); } } if ( rbIncapacidadeTemp.getSelected() != null ) { if ( rbIncapacidadeTemp.getSelected().equals( new Boolean( true ) ) ) { a.setTipo_incapacidade( "t" ); } } if ( rbIncapacidadePerm.getSelected() != null ) { if ( rbIncapacidadePerm.getSelected().equals( new Boolean( true ) ) ) { a.setTipo_incapacidade( "p" ); } } if ( txtCoefIncapacidade.getText() != null ) { String coef_str = txtCoefIncapacidade.getText().toString(); if ( coef_str != null && !"".equals( coef_str.trim() ) ) { try { int coef = Integer.parseInt( coef_str ); a.setCoef_incapacidade( new Integer( coef ) ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } } DateFormat formatador = new SimpleDateFormat( "yyyy-MM-dd" ); // java.util.Date ddate = ( java.util.Date ) calAvaliacaoIncap.getValue(); Date ddate = getCalAvaliacaoIncap(); try { String ddate_str = formatador.format( ddate ); java.sql.Date ddate_sql = new java.sql.Date( formatador.parse( ddate_str ).getTime() ); a.setData_aval_incapacidade( ddate_sql ); } catch ( Exception ex ) { a.setData_aval_incapacidade( null ); } // ddate = ( java.util.Date ) calRevisaoIncap.getValue(); ddate = getCalRevisaoIncap(); try { String ddate_str = formatador.format( ddate ); java.sql.Date ddate_sql = new java.sql.Date( formatador.parse( ddate_str ).getTime() ); a.setData_rev_incapacidade( ddate_sql ); } catch ( Exception ex ) { a.setData_rev_incapacidade( null ); } // ddate = ( java.util.Date ) calPeridoIncapDe.getValue(); ddate = getCalPeriodoIncapDe(); try { String ddate_str = formatador.format( ddate ); java.sql.Date ddate_sql = new java.sql.Date( formatador.parse( ddate_str ).getTime() ); a.setPeriodo_incapacidade_de( ddate_sql ); } catch ( Exception ex ) { a.setPeriodo_incapacidade_de( null ); } // ddate = ( java.util.Date ) calPeriodoIncapA.getValue(); ddate = getCalPeriodoIncapA(); try { String ddate_str = formatador.format( ddate ); java.sql.Date ddate_sql = new java.sql.Date( formatador.parse( ddate_str ).getTime() ); a.setPeriodo_incapacidade_a( ddate_sql ); } catch ( Exception ex ) { a.setPeriodo_incapacidade_a( null ); } return a; } private AnaliseAcidente fillAnaliseFieldsConsolidacao( AnaliseAcidente a ) { String nome_resp_consolidacao = getSessionBean1().getCurrentUser().getNome(); a.setNome_resp_consolidacao( nome_resp_consolidacao ); java.util.Date today = new java.util.Date(); java.sql.Date sqlToday = new java.sql.Date( today.getTime() ); a.setData_consolidacao( sqlToday ); a.setAss_consolidacao( "y" ); return a; } private AnaliseAcidente fillAnaliseFieldsParticipacao( AnaliseAcidente a ) { if( a.getParticipado() == null || !a.getParticipado() ) { a.setParticipado( Boolean.TRUE ); String nome = getSessionBean1().getCurrentUser().getNome(); a.setNomeResponsavelParticipacao( nome ); java.util.Date today = new java.util.Date(); java.sql.Date sqlToday = new java.sql.Date( today.getTime() ); a.setDataParticipacao( sqlToday ); } return a; } private AnaliseAcidente clearAnaliseFieldsParticipacao( AnaliseAcidente a ) { a.setParticipado( Boolean.FALSE ); a.setNomeResponsavelParticipacao( null ); a.setDataParticipacao( null ); return a; } private AnaliseAcidente fillAnaliseAssinaturas( AnaliseAcidente a ) { // UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); java.util.Date today = new java.util.Date(); java.sql.Date sqlToday = new java.sql.Date( today.getTime() ); int estado = a.getEstado().intValue(); switch ( estado ) { case Global.ESTADO_ASSINATURA_SEG: //notifyNextSignature(new Integer(Global.ESTADO_ASSINATURA_RH)); a.setData_assinatura_seg( sqlToday ); a.setAss_resp_seg( "y" ); a.setNome_resp_seg( getSessionBean1().getCurrentUser().getNome() ); break; case Global.ESTADO_ASSINATURA_RH: a.setData_assinatura_rh( sqlToday ); a.setAss_resp_rh( "y" ); a.setNome_resp_rh( getSessionBean1().getCurrentUser().getNome() ); break; } return a; } private boolean validateDataOcorrencia( AnaliseAcidente analise ) { Date d = analise == null ? getCalDataOcorrencia() : analise.getData_acidente(); if ( d == null ) { getSessionBean1().setMsg( "Falta data da ocorrência!" ); return false; } return true; } private boolean validationDepartmentSectionOk() { Integer departmentId = ( Integer ) drpDepartamento.getSelected(); if ( departmentId.intValue() == 0 ) { getSessionBean1().setMsg( "Falta departamento!" ); return false; } Integer seccaoId = ( Integer ) drpSeccao.getSelected(); if ( seccaoId.intValue() == 0 ) { getSessionBean1().setMsg( "Falta secção!" ); return false; } return true; } private boolean fieldsLenOk() { //System.out.println("VALIDATION GRAVAR OK"); // AnalisesDataProvider adp = new AnalisesDataProvider(); HashMap meta = new HashMap(); HashMap meta_ac = new HashMap(); try { AnalisesDataProvider adp = AnalisesDataProvider.getInstance(); meta = adp.getMetaData( "analises_acidentes" ); meta_ac = adp.getMetaData( "acidentados" ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); meta = null; meta_ac = null; } if ( meta == null || meta_ac == null ) { getSessionBean1().setMsg( "Erro na aquisição da metadata!" ); return false; } int estado = 0; if ( getSessionBean1().getCurrentAnalise() == null ) //null { estado = Global.ESTADO_SEG; } else { AnaliseAcidente a = getSessionBean1().getCurrentAnalise(); estado = a.getEstado().intValue(); } if ( estado == Global.ESTADO_SEG ) { if ( txtAveriguador.getText() != null ) { String averiguador = txtAveriguador.getText().toString(); int len = ( ( Integer ) meta.get( "averiguador" ) ).intValue(); System.out.println( "Averiguador : " + len ); if ( averiguador.length() > len ) { getSessionBean1().setMsg( "O campo Averiguador não pode exceder " + len + " caracteres!" ); return false; } } if ( txtLocal.getText() != null ) { String local = txtLocal.getText().toString(); int len = ( ( Integer ) meta.get( "local_trabalho" ) ).intValue(); System.out.println( "Local : " + len ); if ( local.length() > len ) { getSessionBean1().setMsg( "O campo Local não pode exceder " + len + " caracteres!" ); return false; } } if ( txtTarefa.getText() != null ) { String tarefa = txtTarefa.getText().toString(); int len = ( ( Integer ) meta.get( "tarefa" ) ).intValue(); System.out.println( "Tarefa : " + len ); if ( tarefa.length() > len ) { getSessionBean1().setMsg( "O campo Tarefa não pode exceder " + len + " caracteres!" ); return false; } } if ( txtSubstancias.getText() != null ) { String substancias = txtSubstancias.getText().toString(); int len = ( ( Integer ) meta.get( "substancias" ) ).intValue(); System.out.println( "Substancias : " + len ); if ( substancias.length() > len ) { getSessionBean1().setMsg( "O campo Substancias não pode exceder " + len + " caracteres!" ); return false; } } if ( txtTestemunhas.getText() != null ) { String testemunhas = txtTestemunhas.getText().toString(); int len = ( ( Integer ) meta.get( "testemunhas" ) ).intValue(); System.out.println( "Testemunhas : " + len ); if ( testemunhas.length() > len ) { getSessionBean1().setMsg( "O campo Testemunhas não pode exceder " + len + " caracteres!" ); return false; } } if ( txtDescricao.getText() != null ) { String descricao = txtDescricao.getText().toString(); int len = ( ( Integer ) meta.get( "descricao" ) ).intValue(); System.out.println( "Descricao : " + len ); if ( descricao.length() > len ) { getSessionBean1().setMsg( "O campo Descrição não pode exceder " + len + " caracteres!" ); return false; } } if ( txtConclusoes.getText() != null ) { String conclusoes = txtConclusoes.getText().toString(); int len = ( ( Integer ) meta.get( "conclusoes" ) ).intValue(); System.out.println( "Conclusoes : " + len ); if ( conclusoes.length() > len ) { getSessionBean1().setMsg( "O campo Conclusões não pode exceder " + len + " caracteres!" ); return false; } } if ( txtAccoes.getText() != null ) { String accoes = txtAccoes.getText().toString(); int len = ( ( Integer ) meta.get( "accoes" ) ).intValue(); System.out.println( "Accoes : " + len ); if ( accoes.length() > len ) { getSessionBean1().setMsg( "O campo Accões não pode exceder " + len + " caracteres!" ); return false; } } if ( txtCondicoes.getText() != null ) { String condicoes = txtCondicoes.getText().toString(); int len = ( ( Integer ) meta.get( "condicoes" ) ).intValue(); System.out.println( "Condicoes : " + len ); if ( condicoes.length() > len ) { getSessionBean1().setMsg( "O campo Condições não pode exceder " + len + " caracteres!" ); return false; } } if ( txtAveriguacaoObs.getText() != null ) { String averiguacao_obs = txtAveriguacaoObs.getText().toString(); int len = ( ( Integer ) meta.get( "averiguacao_obs" ) ).intValue(); System.out.println( "Observacoes : " + len ); if ( averiguacao_obs.length() > len ) { getSessionBean1().setMsg( "O campo Observações não pode exceder " + len + " caracteres!" ); return false; } } } else if ( estado == Global.ESTADO_RH1 ) { if ( txtBI.getText() != null ) { String bi = ( String ) txtBI.getText(); int len = ( ( Integer ) meta_ac.get( "bilhete_identidade" ) ).intValue(); System.out.println( "BI : " + len ); if ( bi.length() > len ) { getSessionBean1().setMsg( "Campo Bilhete Identidade não pode exceder " + len + " caracteres!" ); return false; } // try // { // int bi_nr = Integer.parseInt(bi); // } // catch(Exception ex) // { // getSessionBean1().setMsg("Nº do Bilhete de Identidade tem de ser numérico!"); // return false; // } } if ( txtMorada.getText() != null ) { String morada = txtMorada.getText().toString(); int len = ( ( Integer ) meta_ac.get( "morada" ) ).intValue(); System.out.println( "Morada : " + len ); if ( morada.length() > len ) { getSessionBean1().setMsg( "O campo Morada não pode exceder " + len + " caracteres!" ); return false; } } if ( txtLocalidade.getText() != null ) { String localidade = txtLocalidade.getText().toString(); int len = ( ( Integer ) meta_ac.get( "localidade" ) ).intValue(); System.out.println( "Localidade : " + len ); if ( localidade.length() > len ) { getSessionBean1().setMsg( "O campo Localidade não pode exceder " + len + " caracteres!" ); return false; } } if ( txtContactoTelefonico.getText() != null ) { String contacto_telefonico = txtContactoTelefonico.getText().toString(); int len = ( ( Integer ) meta_ac.get( "contacto_telefonico" ) ).intValue(); System.out.println( "Contacto Telefonico : " + len ); if ( contacto_telefonico.length() > len ) { getSessionBean1().setMsg( "O campo Contacto Telefónico não pode exceder " + len + " caracteres!" ); return false; } } if ( txtNomeSuperior.getText() != null ) { String nome_superior = txtNomeSuperior.getText().toString(); int len = ( ( Integer ) meta_ac.get( "nome_superior_hierarquico" ) ).intValue(); System.out.println( "Nome Superior : " + len ); if ( nome_superior.length() > len ) { getSessionBean1().setMsg( "O campo Nome do Superior Hierárquico não pode exceder " + len + " caracteres!" ); return false; } } if ( txtEmailSuperior.getText() != null ) { String email_superior = txtEmailSuperior.getText().toString(); int len = ( ( Integer ) meta_ac.get( "email_superior_hierarquico" ) ).intValue(); System.out.println( "Email Superior : " + len ); if ( email_superior.length() > len ) { getSessionBean1().setMsg( "O campo Email do Superior Hierárquico não pode exceder " + len + " caracteres!" ); return false; } } if ( txtEmailSuperior.getText() != null ) { String email_superior = ( String ) txtEmailSuperior.getText(); if ( email_superior.trim().length() > 0 ) { if ( !utils.Utils.isValidEmail( email_superior ) ) { getSessionBean1().setMsg( "Email do superior hierárquico inválido!" ); return false; } } } if ( txtFormacaoSHSTNWhy.getText() != null ) { String why = txtFormacaoSHSTNWhy.getText().toString(); int len = ( ( Integer ) meta.get( "formacao_shst_nao_porque" ) ).intValue(); System.out.println( "Porque Nao Teve Formacao : " + len ); if ( why.length() > len ) { getSessionBean1().setMsg( "O campo Porquê o Colaborador Não Teve Formação não pode exceder " + len + " caracteres!" ); return false; } } } else if ( estado == Global.ESTADO_HS ) { if ( !checkRecomendacoesLen() ) { return false; } } else if ( estado == Global.ESTADO_RH2 ) { if ( !checkMedidasLen() ) { return false; } if ( txtEspecif1.getText() != null ) { String especif = txtEspecif1.getText().toString(); int len = ( ( Integer ) meta.get( "especif1" ) ).intValue(); if ( especif.length() > len ) { getSessionBean1().setMsg( "O campo Especifíque não pode exceder " + len + " caracteres!" ); return false; } } if ( txtEspecif2.getText() != null ) { String especif = txtEspecif2.getText().toString(); int len = ( ( Integer ) meta.get( "especif2" ) ).intValue(); if ( especif.length() > len ) { getSessionBean1().setMsg( "O campo Especifíque não pode exceder " + len + " caracteres!" ); return false; } } if ( txtEspecif3.getText() != null ) { String especif = txtEspecif3.getText().toString(); int len = ( ( Integer ) meta.get( "especif3" ) ).intValue(); if ( especif.length() > len ) { getSessionBean1().setMsg( "O campo Especifíque não pode exceder " + len + " caracteres!" ); return false; } } if ( txtEspecif4.getText() != null ) { String especif = txtEspecif4.getText().toString(); int len = ( ( Integer ) meta.get( "especif4" ) ).intValue(); if ( especif.length() > len ) { getSessionBean1().setMsg( "O campo Especifíque não pode exceder " + len + " caracteres!" ); return false; } } if ( txtTipoLesao.getText() != null ) { String tipo_lesao = txtTipoLesao.getText().toString(); int len = ( ( Integer ) meta.get( "tipo_lesao" ) ).intValue(); System.out.println( "Tipo Lesao : " + len ); if ( tipo_lesao.length() > len ) { getSessionBean1().setMsg( "O campo Tipo Lesão não pode exceder " + len + " caracteres!" ); return false; } } } return true; } private boolean validationOk() { if ( getSessionBean1().isSubmetido() || getSessionBean1().isGravado() ) { return true; } if ( getSessionBean1().getAcidentado() == null ) { getSessionBean1().setMsg( "Não seleccionou trabalhador acidentado!" ); return false; } if ( !fieldsLenOk() ) { return false; } AnaliseAcidente analise = getSessionBean1().getCurrentAnalise(); int estado = 0; int estado_assinatura = 0; if ( analise == null ) { estado = Global.ESTADO_SEG; } else { estado = analise.getEstado().intValue(); estado_assinatura = analise.getEstado_assinatura().intValue(); } if ( estado == Global.ESTADO_SEG ) { if ( ! validateDataOcorrencia( analise ) ) { return false; } if ( txtAveriguador.getText() == null ) { getSessionBean1().setMsg( "Falta averiguador!" ); return false; } else { String averiguador = ( String ) txtAveriguador.getText(); if ( averiguador.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta averiguador!" ); return false; } } if ( drpHours.getSelected() == null || drpMinutes.getSelected() == null ) { getSessionBean1().setMsg( "Falta hora acidente!" ); return false; } else { Integer h = ( Integer ) drpHours.getSelected(); Integer m = ( Integer ) drpMinutes.getSelected(); if ( h.intValue() == -1 || m.intValue() == -1 ) { getSessionBean1().setMsg( "Falta hora acidente!" ); return false; } } if ( txtHorasTurno.getText() != null ) { String horas_turno = txtHorasTurno.getText().toString(); if ( horas_turno.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta nº horas trabalhadas no turno!" ); return false; } else { try { int nr = Integer.parseInt( horas_turno ); if ( nr > 9 ) { getSessionBean1().setMsg( "As horas turno devem ser entre 0 e 9!" ); return false; } } catch ( Exception ex ) { getSessionBean1().setMsg( "As horas turno devem ser um valor numérico!" ); return false; } } } else { getSessionBean1().setMsg( "Falta nº horas trabalhadas no turno!" ); return false; } if ( drpDepartamento.getSelected() == null ) { getSessionBean1().setMsg( "Falta departamento!" ); return false; } else { Integer d = ( Integer ) drpDepartamento.getSelected(); if ( d.intValue() == 0 ) { getSessionBean1().setMsg( "Falta departamento!" ); return false; } } if ( drpSeccao.getSelected() == null ) { getSessionBean1().setMsg( "Falta secção!" ); return false; } else { Integer s = ( Integer ) drpSeccao.getSelected(); if ( s.intValue() == 0 ) { getSessionBean1().setMsg( "Falta secção!" ); return false; } } if ( txtLocal.getText() == null ) { getSessionBean1().setMsg( "Falta local específico!" ); return false; } else { String local = ( String ) txtLocal.getText(); if ( local.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta local específico!" ); return false; } } if ( txtTarefa.getText() == null ) { getSessionBean1().setMsg( "Falta tarefa!" ); return false; } else { String tarefa = ( String ) txtTarefa.getText(); if ( tarefa.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta tarefa!" ); return false; } } if ( txtSubstancias.getText() == null ) { getSessionBean1().setMsg( "Falta substâncias!" ); return false; } else { String substancias = ( String ) txtSubstancias.getText(); if ( substancias.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta substâncias!" ); return false; } } if ( txtCondicoes.getText() == null ) { getSessionBean1().setMsg( "Falta condições!" ); return false; } else { String condicoes = ( String ) txtCondicoes.getText(); if ( condicoes.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta condições!" ); return false; } } if ( txtTestemunhas.getText() == null ) { getSessionBean1().setMsg( "Falta testemunhas!" ); return false; } else { String testemunhas = ( String ) txtTestemunhas.getText(); if ( testemunhas.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta testemunhas!" ); return false; } } if ( drpCausas.getSelected() == null ) { getSessionBean1().setMsg( "Falta causa do acidente!" ); return false; } else { Integer c = ( Integer ) drpCausas.getSelected(); if ( c.intValue() == 0 ) { getSessionBean1().setMsg( "Falta causa do acidente!" ); return false; } } if ( txtDescricao.getText() == null ) { getSessionBean1().setMsg( "Falta descrição do acidente!" ); return false; } else { String descricao = ( String ) txtDescricao.getText(); if ( descricao.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta descrição do acidente!" ); return false; } } if ( txtConclusoes.getText() == null ) { getSessionBean1().setMsg( "Falta conclusões!" ); return false; } else { String conclusoes = ( String ) txtConclusoes.getText(); if ( conclusoes.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta conclusões!" ); return false; } } if ( txtAccoes.getText() == null ) { getSessionBean1().setMsg( "Falta acções!" ); return false; } else { String accoes = ( String ) txtAccoes.getText(); if ( accoes.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta acções!" ); return false; } } } if ( estado == Global.ESTADO_RH1 ) { if ( txtBI.getText() == null ) { getSessionBean1().setMsg( "Falta Nº Bilhete de Identidade!" ); return false; } else { String bi = ( String ) txtBI.getText(); if ( bi.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta Nº Bilhete de Identidade!" ); return false; } // else // { // try // { // int bi_nr = Integer.parseInt(bi); // } // catch(Exception ex) // { // getSessionBean1().setMsg("Nº do Bilhete de Identidade tem de ser numérico!"); // return false; // } // } } if ( txtMorada.getText() == null ) { getSessionBean1().setMsg( "Falta morada!" ); return false; } else { String morada = ( String ) txtMorada.getText(); if ( morada.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta morada!" ); return false; } } String cod_postal1 = ""; String cod_postal2 = ""; if ( txtCodPostal1.getText() == null || txtCodPostal2.getText() == null ) { getSessionBean1().setMsg( "Falta código postal!" ); return false; } else { cod_postal1 = ( String ) txtCodPostal1.getText(); cod_postal2 = ( String ) txtCodPostal2.getText(); if ( cod_postal1.trim().length() == 0 || cod_postal2.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta código postal!" ); return false; } } if ( txtCodPostal1.getText() != null ) { if ( cod_postal1.trim().length() > 0 ) { try { int nr = Integer.parseInt( cod_postal1 ); if ( nr < 1000 || nr > 9999 ) { getSessionBean1().setMsg( "O formato do código postal é : '9999-999'" ); return false; } } catch ( Exception ex ) { getSessionBean1().setMsg( "O código postal tem de ser um valor numérico!" ); return false; } } } if ( txtCodPostal2.getText() != null ) { if ( cod_postal2.trim().length() > 0 ) { if ( cod_postal1.trim().length() == 0 ) { getSessionBean1().setMsg( "O formato do código postal é : '9999-999'" ); return false; } try { int nr = Integer.parseInt( cod_postal2 ); if ( cod_postal2.length() > 3 ) { getSessionBean1().setMsg( "O formato do código postal é : '9999-999'" ); return false; } } catch ( Exception ex ) { getSessionBean1().setMsg( "O código postal de ser um valor numérico!" ); return false; } } if ( txtLocalidade.getText() == null ) { getSessionBean1().setMsg( "Falta localidade!" ); return false; } else { String localidade = ( String ) txtLocalidade.getText(); if ( localidade.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta localidade!" ); return false; } } if ( txtContactoTelefonico.getText() == null ) { getSessionBean1().setMsg( "Falta contacto telefónico!" ); return false; } else { String contacto_telefonico = ( String ) txtContactoTelefonico.getText(); if ( contacto_telefonico.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta contacto telefónico!" ); return false; } } if ( rbTurnoManha.getSelected() == null && rbTurnoTarde.getSelected() == null && rbTurnoNoite.getSelected() == null && rbTurnoOutro.getSelected() == null ) { getSessionBean1().setMsg( "Falta turno de trabalho!" ); return false; } if ( txtNomeSuperior.getText() == null ) { getSessionBean1().setMsg( "Falta nome do superior hierárquico!" ); return false; } else { String nome_superior = ( String ) txtNomeSuperior.getText(); if ( nome_superior.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta nome do superior hierárquico!" ); return false; } } if ( txtEmailSuperior.getText() != null ) { String email_superior = ( String ) txtEmailSuperior.getText(); if ( email_superior.trim().length() > 0 ) { if ( !utils.Utils.isValidEmail( email_superior ) ) { getSessionBean1().setMsg( "Email do superior hierárquico inválido!" ); return false; } } else { getSessionBean1().setMsg( "Falta email do superior hierárquico!" ); return false; } } else { getSessionBean1().setMsg( "Falta email do superior hierárquico!" ); return false; } } if ( estado == Global.ESTADO_RH1 ) { if ( rbFormacaoSHSTY.getSelected() == null && rbFormacaoSHSTN.getSelected() == null ) { getSessionBean1().setMsg( "Falta indicar se o colaborador teve formação em SHST!" ); return false; } else { if ( rbFormacaoSHSTY.getSelected() != null ) { if ( rbFormacaoSHSTY.getSelected().equals( new Boolean( false ) ) ) { if ( rbFormacaoSHSTN.getSelected() != null ) { if ( rbFormacaoSHSTN.getSelected().equals( new Boolean( false ) ) ) { getSessionBean1().setMsg( "Falta indicar se o colaborador teve formação em SHST!" ); return false; } } } } } if ( rbFormacaoSHSTN.getSelected() != null ) { if ( rbFormacaoSHSTN.getSelected().equals( new Boolean( true ) ) ) { if ( txtFormacaoSHSTNWhy.getText() == null ) { getSessionBean1().setMsg( "Falta indicar a razão porque o colaborador não teve formação em SHST!" ); return false; } else { String why = ( String ) txtFormacaoSHSTNWhy.getText(); if ( why.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta indicar a razão porque o colaborador não teve formação em SHST!" ); return false; } } } } if ( rbAcidentesColaboradorY.getSelected() == null && rbAcidentesColaboradorN.getSelected() == null ) { getSessionBean1().setMsg( "Falta indicar se o colaborador teve outras ocorrências, ou não!" ); return false; } else { if ( rbAcidentesColaboradorY.getSelected() != null ) { if ( rbAcidentesColaboradorY.getSelected().equals( new Boolean( false ) ) ) { if ( rbAcidentesColaboradorN.getSelected() != null ) { if ( rbAcidentesColaboradorN.getSelected().equals( new Boolean( false ) ) ) { getSessionBean1().setMsg( "Falta indicar se o colaborador teve outras ocorrências, ou não!" ); return false; } } } } } if ( rbAcidentesColaboradorY.getSelected() != null ) { if ( rbAcidentesColaboradorY.getSelected().equals( new Boolean( true ) ) ) { if ( txtNrAcidentesColaborador.getText() != null ) { String nr_str = txtNrAcidentesColaborador.getText().toString(); if ( nr_str.trim().length() > 0 ) { try { int nr = Integer.parseInt( nr_str ); } catch ( Exception ex ) { getSessionBean1().setMsg( "O º de acidentes do colaborador deve ser um valor numérico!" ); return false; } } else { getSessionBean1().setMsg( "Falta indicar o º de ocorrências do colaborador!" ); return false; } } else { getSessionBean1().setMsg( "Falta indicar o º de ocorrências do colaborador!" ); return false; } if ( txtNrRelatorioAcidentesColaborador1.getText() == null && txtNrRelatorioAcidentesColaborador2.getText() == null && txtNrRelatorioAcidentesColaborador3.getText() == null && txtNrRelatorioAcidentesColaborador1.getText() == null ) { getSessionBean1().setMsg( "Falta indicar o(s) º(s) do(s) relatório(s) de acidente do colaborador!" ); return false; } else { String nr_relatorio1 = ""; String nr_relatorio2 = ""; String nr_relatorio3 = ""; String nr_relatorio4 = ""; if ( txtNrRelatorioAcidentesColaborador1.getText() != null ) { nr_relatorio1 = ( String ) txtNrRelatorioAcidentesColaborador1.getText(); } if ( txtNrRelatorioAcidentesColaborador2.getText() != null ) { nr_relatorio2 = ( String ) txtNrRelatorioAcidentesColaborador2.getText(); } if ( txtNrRelatorioAcidentesColaborador3.getText() != null ) { nr_relatorio3 = ( String ) txtNrRelatorioAcidentesColaborador3.getText(); } if ( txtNrRelatorioAcidentesColaborador4.getText() != null ) { nr_relatorio4 = ( String ) txtNrRelatorioAcidentesColaborador4.getText(); } if ( nr_relatorio1.trim().length() == 0 && nr_relatorio2.trim().length() == 0 && nr_relatorio3.trim().length() == 0 && nr_relatorio4.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta indicar o(s) º(s) do(s) relatório(s) de acidente do colaborador!" ); return false; } } }// } if ( rbAcidentesColaboradoresY.getSelected() == null && rbAcidentesColaboradoresN.getSelected() == null ) { getSessionBean1().setMsg( "Falta indicar se houve outras ocorrências com outros colaboradores!" ); return false; } else { if ( rbAcidentesColaboradoresY.getSelected() != null ) { if ( rbAcidentesColaboradoresY.getSelected().equals( new Boolean( false ) ) ) { if ( rbAcidentesColaboradoresN.getSelected() != null ) { if ( rbAcidentesColaboradoresN.getSelected().equals( new Boolean( false ) ) ) { getSessionBean1().setMsg( "Falta indicar se houve outras ocorrências com outros colaboradores!" ); return false; } } } } } if ( rbAcidentesColaboradoresY.getSelected() != null ) { if ( rbAcidentesColaboradoresY.getSelected().equals( new Boolean( true ) ) ) { if ( txtNrAcidentesColaboradores.getText() != null ) { String nr_str = txtNrAcidentesColaboradores.getText().toString(); if ( nr_str.trim().length() > 0 ) { try { int nr = Integer.parseInt( nr_str ); } catch ( Exception ex ) { getSessionBean1().setMsg( "O º de acidentes dos colaboradores deve ser um valor numérico!" ); return false; } } else { getSessionBean1().setMsg( "Falta indicar o º de ocorrências com outros colaboradores!" ); return false; } } else { getSessionBean1().setMsg( "Falta indicar o º de ocorrências com outros colaboradores!" ); return false; } if ( txtNrRelatorioAcidentesColaboradores1.getText() == null && txtNrRelatorioAcidentesColaboradores2.getText() == null && txtNrRelatorioAcidentesColaboradores3.getText() == null && txtNrRelatorioAcidentesColaboradores1.getText() == null ) { getSessionBean1().setMsg( "Falta indicar o(s) º(s) do(s) relatório(s) de acidente com outros colaboradores!" ); return false; } else { String nr_relatorio1 = ""; String nr_relatorio2 = ""; String nr_relatorio3 = ""; String nr_relatorio4 = ""; if ( txtNrRelatorioAcidentesColaboradores1.getText() != null ) { nr_relatorio1 = ( String ) txtNrRelatorioAcidentesColaboradores1.getText(); } if ( txtNrRelatorioAcidentesColaboradores2.getText() != null ) { nr_relatorio2 = ( String ) txtNrRelatorioAcidentesColaboradores2.getText(); } if ( txtNrRelatorioAcidentesColaboradores3.getText() != null ) { nr_relatorio3 = ( String ) txtNrRelatorioAcidentesColaboradores3.getText(); } if ( txtNrRelatorioAcidentesColaboradores4.getText() != null ) { nr_relatorio4 = ( String ) txtNrRelatorioAcidentesColaboradores4.getText(); } if ( nr_relatorio1.trim().length() == 0 && nr_relatorio2.trim().length() == 0 && nr_relatorio3.trim().length() == 0 && nr_relatorio4.trim().length() == 0 ) { getSessionBean1().setMsg( "Falta indicar o(s) º(s) do(s) relatório(s) de acidente com outros colaboradores!" ); return false; } } }// } } } else if ( estado == Global.ESTADO_HS ) //recomendacoes { if ( isRecomendacoesEmpty() ) { getSessionBean1().setMsg( "Tem de preencher pelo menos uma recomendação!" ); return false; } } else if ( estado == Global.ESTADO_RH2 ) //medidas { if ( isMedidasEmpty() ) { getSessionBean1().setMsg( "Tem de preencher pelo menos uma medida!" ); return false; } // } // //else if(estado == Global.ESTADO_MEDICINA) // else if(estado == Global.ESTADO_RH2) // { if ( rbIncapacidadeNone.getSelected() == null && rbIncapacidadeTemp.getSelected() == null && rbIncapacidadePerm.getSelected() == null ) { getSessionBean1().setMsg( "Falta indicar o tipo de incapacidade!" ); return false; } else { if ( rbIncapacidadeNone.getSelected() != null ) { if ( rbIncapacidadeNone.getSelected().equals( new Boolean( false ) ) ) { if ( rbIncapacidadeTemp.getSelected() != null ) { if ( rbIncapacidadeTemp.getSelected().equals( new Boolean( false ) ) ) { if ( rbIncapacidadePerm.getSelected() != null ) { if ( rbIncapacidadePerm.getSelected().equals( new Boolean( false ) ) ) { getSessionBean1().setMsg( "Falta indicar o tipo de incapacidade!" ); return false; } } } } } } } if ( txtCoefIncapacidade.getText() != null ) { String coef_str = txtCoefIncapacidade.getText().toString(); if ( coef_str.trim().length() > 0 ) { try { int nr = Integer.parseInt( coef_str ); } catch ( Exception ex ) { getSessionBean1().setMsg( "O coeficiente de incapacidade deve ser um valor numérico!" ); return false; } } else { getSessionBean1().setMsg( "Falta coeficiente de incapacidade!" ); return false; } } else { getSessionBean1().setMsg( "Falta coeficiente de incapacidade!" ); return false; } if ( chkRestricaoCargas.getSelected() != null ) { Boolean b = ( Boolean ) chkRestricaoCargas.getSelected(); if ( b.equals( new Boolean( true ) ) ) { if ( txtKgs.getText() != null ) { String kgs_str = txtKgs.getText().toString(); try { int nr = Integer.parseInt( kgs_str ); } catch ( Exception ex ) { getSessionBean1().setMsg( "O valor de kgs deve ser um valor numérico!" ); return false; } } } } } else if ( estado == Global.ESTADO_CONSOLIDACAO ) { if ( chkVerHs.getSelected() == null ) { getSessionBean1().setMsg( "Falta assinatura!" ); return false; } else if ( chkVerHs.getSelected().equals( new Boolean( false ) ) ) { getSessionBean1().setMsg( "Falta assinatura!" ); return false; } } else if ( estado == Global.ESTADO_ASSINATURA_SEG ) { if ( chkVerRespSeg.getSelected() == null ) { getSessionBean1().setMsg( "Falta assinatura!" ); return false; } else if ( chkVerRespSeg.getSelected().equals( new Boolean( false ) ) ) { getSessionBean1().setMsg( "Falta assinatura!" ); return false; } } else if ( estado == Global.ESTADO_ASSINATURA_RH ) { if ( chkVerRespRh.getSelected() == null ) { getSessionBean1().setMsg( "Falta assinatura!" ); return false; } else if ( chkVerRespRh.getSelected().equals( new Boolean( false ) ) ) { getSessionBean1().setMsg( "Falta assinatura!" ); return false; } } return true; } private void createImagesFolder( AnaliseAcidente a ) //private void createImagesFolder(String folderName) { String folderName = a.getAnalise_nr().substring( 0, 2 ) + a.getAnalise_nr().substring( 3 ); ServletContext theApplicationsServletContext = ( ServletContext ) this.getExternalContext().getContext(); // String imageFileFolder = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/" + folderName); String imageFileFolder = Global.IMAGE_FOLDER + "/" + folderName; try { // String imageFileFolderTmp = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin()); String imageFileFolderTmp = Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin(); File f = new File( imageFileFolderTmp ); if ( f.exists() ) { File folder = new File( imageFileFolder ); folder.mkdir(); File files[] = f.listFiles(); for ( int i = 0; i < files.length; i++ ) { if ( files[i].isFile() ) { // Move file to new directory boolean success = files[i].renameTo( new File( folder, files[i].getName() ) ); } } //delete tmp folder f.delete(); } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } //private void updateImagesFolder(String folderName) private void updateImagesFolder( AnaliseAcidente a ) { String folderName = a.getAnalise_nr().substring( 0, 2 ) + a.getAnalise_nr().substring( 3 ); ServletContext theApplicationsServletContext = ( ServletContext ) this.getExternalContext().getContext(); try { //checks if there are images in tmp // String imageFileFolderTmp = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin()); String imageFileFolderTmp = Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin(); File ftmp = new File( imageFileFolderTmp ); if ( ftmp.exists() ) { //if so, checks if there is already a image folder // String imageFileFolder = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/" + folderName); String imageFileFolder = Global.IMAGE_FOLDER + "/" + folderName; File fimages = new File( imageFileFolder ); if ( !fimages.exists() ) { // create image folder fimages.mkdir(); } //copy images onto it File files[] = ftmp.listFiles(); for ( int i = 0; i < files.length; i++ ) { if ( files[i].isFile() ) { // Move file to new directory boolean success = files[i].renameTo( new File( fimages, files[i].getName() ) ); } } //delete tmp folder ftmp.delete(); } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } private void savePageState() { AnaliseAcidenteTrabalhoState a = new AnaliseAcidenteTrabalhoState(); a.setHeader_nr( stHeaderNr.getText() ); a.setHeader_date( stHeaderDate.getText() ); if ( getSessionBean1().getCurrentAnalise() == null ) { a.setEstado( Global.ESTADO_SEG ); } else { a.setEstado( getSessionBean1().getCurrentAnalise().getEstado().intValue() ); } a.setEmpresa( txtEmpresa.getText() ); a.setHoras_turno( txtHorasTurno.getText() ); a.setAveriguador( txtAveriguador.getText() ); a.setData_nascimento( stDataNascimento.getText() ); a.setData_admissao( stDataAdmissao1.getText() ); // a.setData_acidente( calDataOcorrencia.getValue() ); a.setData_acidente( getCalDataOcorrencia() ); a.setBi( stBI.getText() ); a.setMorada( stMorada.getText() ); a.setContacto_telefonico( stContactoTelefonico.getText() ); a.setFuncao( stFuncao1.getText() ); a.setTurno( stTurno.getText() ); //////a.setData_acidente(stDataAcidente.getText()); // a.setBi(txtBI.getText()); // a.setMorada(txtMorada.getText()); // a.setCod_postal1(txtCodPostal1.getText()); // a.setCod_postal2(txtCodPostal2.getText()); // a.setLocalidade(txtLocalidade.getText()); // a.setContacto_telefonico(txtContactoTelefonico.getText()); // a.setTurno("m"); // if(rbTurnoManha.getSelected() != null) // { // Boolean b = (Boolean) rbTurnoManha.getSelected(); // if(b.equals(new Boolean(true))) // { // a.setTurno("m"); // } // } // // if(rbTurnoTarde.getSelected() != null) // { // Boolean b = (Boolean) rbTurnoTarde.getSelected(); // if(b.equals(new Boolean(true))) // { // a.setTurno("t"); // } // } // // if(rbTurnoNoite.getSelected() != null) // { // Boolean b = (Boolean) rbTurnoNoite.getSelected(); // if(b.equals(new Boolean(true))) // { // a.setTurno("n"); // } // } Integer hours = ( Integer ) drpHours.getSelected(); Integer minutes = ( Integer ) drpMinutes.getSelected(); a.setHours( hours ); a.setMinutes( minutes ); a.setLocal_trabalho( txtLocal.getText() ); ////a.setSeccao(txtSeccao.getText()); a.setSubstancias( txtSubstancias.getText() ); a.setTarefa( txtTarefa.getText() ); a.setEstabelecimento( txtEstabelecimento.getText() ); a.setTrabalhador( txtTrabalhador.getText() ); a.setData_nascimento( txtDataNascimento.getText() ); // a.setSuperior_hierarquico(txtSuperior.getText()); a.setCondicoes( txtCondicoes.getText() ); a.setTestemunhas( txtTestemunhas.getText() ); // a.setCausas(txtCausas.getText()); a.setCausas( drpCausas.getSelected() ); a.setDescricao( txtDescricao.getText() ); a.setConclusoes( txtConclusoes.getText() ); a.setAccoes( txtAccoes.getText() ); a.setAveriguacao_posterior( "n" ); if ( chkAveriguacaoPosterior.getSelected() != null ) { if ( chkAveriguacaoPosterior.getSelected().equals( new Boolean( true ) ) ) { a.setAveriguacao_posterior( "y" ); } } a.setAveriguacao_obs( txtAveriguacaoObs.getText() ); if ( getSessionBean1().getCurrentAnalise() != null ) { if ( getSessionBean1().getCurrentAnalise().getEstado().intValue() == Global.ESTADO_RH1 ) { a.setFormacao_shst( "n" ); if ( rbFormacaoSHSTY.getSelected() != null ) { Boolean b = ( Boolean ) rbFormacaoSHSTY.getSelected(); if ( b.equals( new Boolean( true ) ) ) { a.setFormacao_shst( "y" ); } } if ( rbFormacaoSHSTN.getSelected() != null ) { Boolean b = ( Boolean ) rbFormacaoSHSTN.getSelected(); if ( b.equals( new Boolean( true ) ) ) { a.setFormacao_shst( "n" ); } } a.setFormacao_shsht_n_why( txtFormacaoSHSTNWhy.getText() ); a.setAcidentes_colaborador( "n" ); if ( rbAcidentesColaboradorY.getSelected() != null ) { Boolean b = ( Boolean ) rbAcidentesColaboradorY.getSelected(); if ( b.equals( new Boolean( true ) ) ) { a.setAcidentes_colaborador( "y" ); } } if ( rbAcidentesColaboradorN.getSelected() != null ) { Boolean b = ( Boolean ) rbAcidentesColaboradorN.getSelected(); if ( b.equals( new Boolean( true ) ) ) { a.setAcidentes_colaborador( "n" ); } } a.setNr_acidentes_colaborador( txtNrAcidentesColaborador.getText() ); a.setNr_relatorio_acidentes_colaborador_1( txtNrRelatorioAcidentesColaborador1.getText() ); a.setNr_relatorio_acidentes_colaborador_2( txtNrRelatorioAcidentesColaborador2.getText() ); a.setNr_relatorio_acidentes_colaborador_3( txtNrRelatorioAcidentesColaborador3.getText() ); a.setNr_relatorio_acidentes_colaborador_4( txtNrRelatorioAcidentesColaborador4.getText() ); a.setAcidentes_colaboradores( "n" ); if ( rbAcidentesColaboradoresY.getSelected() != null ) { Boolean b = ( Boolean ) rbAcidentesColaboradoresY.getSelected(); if ( b.equals( new Boolean( true ) ) ) { a.setAcidentes_colaboradores( "y" ); } } if ( rbAcidentesColaboradoresN.getSelected() != null ) { Boolean b = ( Boolean ) rbAcidentesColaboradoresN.getSelected(); if ( b.equals( new Boolean( true ) ) ) { a.setAcidentes_colaboradores( "n" ); } } a.setNr_acidentes_colaboradores( txtNrAcidentesColaboradores.getText() ); a.setNr_relatorio_acidentes_colaboradores_1( txtNrRelatorioAcidentesColaboradores1.getText() ); a.setNr_relatorio_acidentes_colaboradores_2( txtNrRelatorioAcidentesColaboradores2.getText() ); a.setNr_relatorio_acidentes_colaboradores_3( txtNrRelatorioAcidentesColaboradores3.getText() ); a.setNr_relatorio_acidentes_colaboradores_4( txtNrRelatorioAcidentesColaboradores4.getText() ); } } getSessionBean1().setAnalise_acidente_trabalho_state( a ); } private void restorePageState() { AnaliseAcidenteTrabalhoState a = getSessionBean1().getAnalise_acidente_trabalho_state(); butCorrecao.setRendered( false ); butGravar.setText( "Gravar" ); butImprimir.setRendered( false ); getSessionBean1().setIeBug( false ); //THIS MUST BE SEEN !!!!! if ( a.getEstado() == Global.ESTADO_SEG ) { butEnviar.setText( "Enviar a RH" ); gridSiprpView.setRendered( false ); gridTrabalhadores.setRendered( false ); gridAcidentado.setRendered( false ); gridDadosAcidenteSegView.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 ); } else if ( a.getEstado() == Global.ESTADO_RH1 ) { butEnviar.setText( "Enviar a HS" ); gridSiprpView.setRendered( false ); gridAcidentadoView.setRendered( false ); //gridDadosAcidenteSeg.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 ); if ( a.getFormacao_shst().matches( "y" ) ) { rbFormacaoSHSTY.setSelected( new Boolean( true ) ); } else { rbFormacaoSHSTN.setSelected( new Boolean( true ) ); } txtFormacaoSHSTNWhy.setText( a.getFormacao_shsht_n_why() ); if ( a.getAcidentes_colaborador().matches( "y" ) ) { rbAcidentesColaboradorY.setSelected( new Boolean( true ) ); } else { rbAcidentesColaboradorN.setSelected( new Boolean( true ) ); } txtNrAcidentesColaborador.setText( a.getNr_acidentes_colaborador() ); txtNrRelatorioAcidentesColaborador1.setText( a.getNr_relatorio_acidentes_colaborador_1() ); txtNrRelatorioAcidentesColaborador2.setText( a.getNr_relatorio_acidentes_colaborador_2() ); txtNrRelatorioAcidentesColaborador3.setText( a.getNr_relatorio_acidentes_colaborador_3() ); txtNrRelatorioAcidentesColaborador4.setText( a.getNr_relatorio_acidentes_colaborador_4() ); if ( a.getAcidentes_colaboradores().matches( "y" ) ) { rbAcidentesColaboradoresY.setSelected( new Boolean( true ) ); } else { rbAcidentesColaboradoresN.setSelected( new Boolean( true ) ); } txtNrAcidentesColaboradores.setText( a.getNr_acidentes_colaboradores() ); txtNrRelatorioAcidentesColaboradores1.setText( a.getNr_relatorio_acidentes_colaboradores_1() ); txtNrRelatorioAcidentesColaboradores2.setText( a.getNr_relatorio_acidentes_colaboradores_2() ); txtNrRelatorioAcidentesColaboradores3.setText( a.getNr_relatorio_acidentes_colaboradores_3() ); txtNrRelatorioAcidentesColaboradores4.setText( a.getNr_relatorio_acidentes_colaboradores_4() ); } stHeaderNr.setText( a.getHeader_nr() ); stHeaderDate.setText( a.getHeader_date() ); txtEmpresa.setText( a.getEmpresa() ); txtEstabelecimento.setText( a.getEstabelecimento() ); txtTrabalhador.setText( a.getTrabalhador() ); stNomeAcidentado.setText( a.getTrabalhador() ); stDataNascimento.setText( a.getData_nascimento() ); stDataAdmissao1.setText( a.getData_admissao() ); //////stDataAcidente.setText(a.getData_acidente()); txtAveriguador.setText( a.getAveriguador() ); java.util.Date dtAcidente = ( java.util.Date ) a.getData_acidente(); // calDataOcorrencia.setValue( dtAcidente ); setCalDataOcorrencia( dtAcidente ); txtHorasTurno.setText( a.getHoras_turno() == null ? "" : a.getHoras_turno().toString() ); stBI.setText( a.getBi() ); stMorada.setText( a.getMorada() ); txtCodPostal1.setText( a.getCod_postal1() ); txtCodPostal2.setText( a.getCod_postal2() ); txtLocalidade.setText( a.getLocalidade() ); stContactoTelefonico.setText( a.getContacto_telefonico() ); // if(a.getTurno().matches("m")) // { // rbTurnoManha.setSelected(new Boolean(true)); // } // if(a.getTurno().matches("t")) // { // rbTurnoTarde.setSelected(new Boolean(true)); // } // if(a.getTurno().matches("n")) // { // rbTurnoNoite.setSelected(new Boolean(true)); // } // stTurno.setText( a.getTurno() ); stFuncao1.setText( a.getFuncao() ); drpHours.setSelected( a.getHours() ); drpMinutes.setSelected( a.getMinutes() ); txtLocal.setText( a.getLocal_trabalho() ); ////txtSeccao.setText(a.getSeccao()); txtSubstancias.setText( a.getSubstancias() ); txtTarefa.setText( a.getTarefa() ); // 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() ); chkAveriguacaoPosterior.setSelected( new Boolean( false ) ); if ( a.getAveriguacao_posterior().matches( "y" ) ) { chkAveriguacaoPosterior.setSelected( new Boolean( true ) ); } txtAveriguacaoObs.setText( a.getAveriguacao_obs() ); if ( getSessionBean1().getCurrentAnalise() != null ) { String folderName = getSessionBean1().getCurrentAnalise().getAnalise_nr().substring( 0, 2 ) + getSessionBean1().getCurrentAnalise().getAnalise_nr().substring( 3 ); //fill images if ( gridImages.getChildren().size() > 0 ) { gridImages.getChildren().clear(); } 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 ); System.out.println( "FILES DELETED" ); } 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 < images.length; i++ ) { if ( images[i].isFile() ) { String imageName = images[i].getName(); ImageComponent newImg = new ImageComponent(); newImg.setId( "img_comp" + imageName ); File apacheImage = new File( theApplicationsServletContext.getRealPath( Global.RESOURCES_IMAGE_FOLDER ) + "/analises/" + folderName + "/" + imageName ); Global global = new Global(); global.copyImage( images[i], apacheImage ); newImg.setUrl( Global.RESOURCES_IMAGE_FOLDER + "/analises/" + folderName + "/" + imageName ); //newImg.setUrl("/resources/images/" + folderName + "/" + imageName); newImg.setRendered( true ); gridImages.getChildren().add( newImg ); Hyperlink ln = new Hyperlink(); ln.setId( "img" + imageName ); ln.setText( "Apagar" ); //ln.setValue(imageName); Class args[] = { javax.faces.event.ActionEvent.class }; ApplicationFactory factory = ( ApplicationFactory ) FactoryFinder.getFactory( FactoryFinder.APPLICATION_FACTORY ); //mb = factory.getApplication().createMethodBinding( "#{EditarQuestionario.lnkGrupo_onClick}", args); MethodBinding mbAction = ( MethodBinding ) factory.getApplication().createMethodBinding( "#{AnaliseAcidenteTrabalho.lnkDelImageReal_actionListener}", args ); ln.setActionListener( mbAction ); gridImages.getChildren().add( ln ); } } } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } } public String lnkLblTrabalhador_action() { // TODO: Replace with your code gridTrabalhadores.setRendered( true ); //fillTrabalhadoresTable(); return null; } public String lnkAnalisesAcidente_action() { getSessionBean1().setIeBug( true ); ServletContext theApplicationsServletContext = ( ServletContext ) this.getExternalContext().getContext(); String imageFileFolderTmp = Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin(); File ftmp = new File( imageFileFolderTmp ); if ( ftmp.exists() ) { File files[] = ftmp.listFiles(); for ( int i = 0; i < files.length; i++ ) { if ( files[i].isFile() ) { files[i].delete(); } } ftmp.delete(); } 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"; } return null; } public String lnkMoreRec1_action() { // TODO: Replace with your code getSessionBean1().setIeBug( true ); int seq = gridRecomendacoes.getChildren().size(); seq++; HtmlPanelGrid grd = new HtmlPanelGrid(); grd.setId( "grd" + seq ); grd.setColumns( 3 ); grd.setColumnClasses( "gridColLeft5, gridColLeft90,gridColLeft5" ); grd.setStyle( "width: 100%" ); StaticText st = new StaticText(); st.setId( "st" + seq ); st.setText( seq + " ." ); st.setStyle( "width: 24px" ); grd.getChildren().add( st ); TextArea ta = new TextArea(); ta.setId( "ta" + seq ); ta.setStyle( "height: 24px; width: 98%" ); grd.getChildren().add( ta ); ImageHyperlink ln = new ImageHyperlink(); ln.setId( "ln" + seq ); ln.setWidth( 9 ); ln.setHeight( 9 ); ln.setImageURL( "/resources/plus_more.gif" ); MethodBinding mbAction = this.getApplication().createMethodBinding( "#{AnaliseAcidenteTrabalho.lnkMoreRec1_action}", null ); ln.setAction( mbAction ); grd.getChildren().add( ln ); gridRecomendacoes.getChildren().add( grd ); return null; } public String lnkMoreMed_action() { // TODO: Replace with your code getSessionBean1().setIeBug( true ); int seq = gridMedidas.getChildren().size(); seq++; HtmlPanelGrid grd = new HtmlPanelGrid(); grd.setId( "grdMedida" + seq ); grd.setColumns( 3 ); grd.setColumnClasses( "gridColLeft5, gridColLeft90,gridColLeft5" ); grd.setStyle( "width: 100%" ); StaticText st = new StaticText(); st.setId( "stNrMedida" + seq ); st.setText( seq + " ." ); st.setStyle( "width: 24px" ); grd.getChildren().add( st ); TextArea ta = new TextArea(); ta.setId( "taMedida" + seq ); ta.setStyle( "height: 24px; width: 98%" ); grd.getChildren().add( ta ); ImageHyperlink ln = new ImageHyperlink(); ln.setId( "lnMedidaMore" + seq ); ln.setWidth( 9 ); ln.setHeight( 9 ); ln.setImageURL( "/resources/plus_more.gif" ); MethodBinding mbAction = this.getApplication().createMethodBinding( "#{AnaliseAcidenteTrabalho.lnkMoreMed_action}", null ); ln.setAction( mbAction ); grd.getChildren().add( ln ); gridMedidas.getChildren().add( grd ); return null; } public void lnkDelImageTmp_actionListener( ActionEvent ae ) { String imageFilePath = ""; //UIComponent eventSrc = ae.getComponent(); Hyperlink lnk = ( Hyperlink ) ae.getComponent(); String imageName = ( String ) lnk.getId(); imageName = imageName.substring( 3 ); ServletContext theApplicationsServletContext = ( ServletContext ) this.getExternalContext().getContext(); // imageFilePath = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER); imageFilePath = Global.IMAGE_FOLDER; imageFilePath += "/tmp" + getSessionBean1().getCurrentUser().getLogin() + "/" + imageName; try { File f = new File( imageFilePath ); if ( f.exists() ) { f.delete(); ImageComponent img = ( ImageComponent ) gridImages.findComponent( "img_comp" + imageName ); gridImages.getChildren().remove( img ); gridImages.getChildren().remove( lnk ); } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } public void lnkDelImageReal_actionListener( ActionEvent ae ) { String imageFilePath = ""; //UIComponent eventSrc = ae.getComponent(); String folderName = getSessionBean1().getCurrentAnalise().getAnalise_nr().substring( 0, 2 ) + getSessionBean1().getCurrentAnalise().getAnalise_nr().substring( 3 ); Hyperlink lnk = ( Hyperlink ) ae.getComponent(); String imageName = ( String ) lnk.getId(); imageName = imageName.substring( 3 ); ServletContext theApplicationsServletContext = ( ServletContext ) this.getExternalContext().getContext(); // imageFilePath = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/" + folderName); imageFilePath = Global.IMAGE_FOLDER + "/" + folderName; //imageFilePath = theApplicationsServletContext.getRealPath(IMAGE_URL); imageFilePath += "/" + imageName; try { File f = new File( imageFilePath ); if ( f.exists() ) { f.delete(); ImageComponent img = ( ImageComponent ) gridImages.findComponent( "img_comp" + imageName ); gridImages.getChildren().remove( img ); gridImages.getChildren().remove( lnk ); } } catch ( Exception ex ) { ErrorLogger.logException( ex ); } } private void initCalendars() { // java.util.GregorianCalendar gcalendar = new java.util.GregorianCalendar(); // gcalendar.set( 1900, 1, 1 ); // // calAvaliacaoIncap.setMinDate( gcalendar.getTime() ); // java.util.GregorianCalendar gcalendar1 = new java.util.GregorianCalendar(); // gcalendar1.set( 2099, 1, 1 ); // calAvaliacaoIncap.setMaxDate( gcalendar1.getTime() ); // // calRevisaoIncap.setMinDate( gcalendar.getTime() ); // calRevisaoIncap.setMaxDate( gcalendar1.getTime() ); // // calPeridoIncapDe.setMinDate( gcalendar.getTime() ); // calPeridoIncapDe.setMaxDate( gcalendar1.getTime() ); // // calPeriodoIncapA.setMinDate( gcalendar.getTime() ); // calPeriodoIncapA.setMaxDate( gcalendar1.getTime() ); // // calDataOcorrencia.setMinDate( gcalendar.getTime() ); // calDataOcorrencia.setMaxDate( gcalendar1.getTime() ); } public void chkMembroSupDir_processValueChange( ValueChangeEvent event ) { // TODO: Replace with your code Boolean b = ( Boolean ) event.getNewValue(); if ( b.equals( new Boolean( true ) ) ) { lblEspecif1.setRendered( true ); txtEspecif1.setRendered( true ); } else { lblEspecif1.setRendered( false ); txtEspecif1.setRendered( false ); } } public void chkMembroSupEsq_processValueChange( ValueChangeEvent event ) { // TODO: Replace with your code Boolean b = ( Boolean ) event.getNewValue(); if ( b.equals( new Boolean( true ) ) ) { lblEspecif2.setRendered( true ); txtEspecif2.setRendered( true ); } else { lblEspecif2.setRendered( false ); txtEspecif2.setRendered( false ); } } public void chkMembroInfDir_processValueChange( ValueChangeEvent event ) { // TODO: Replace with your code Boolean b = ( Boolean ) event.getNewValue(); if ( b.equals( new Boolean( true ) ) ) { lblEspecif3.setRendered( true ); txtEspecif3.setRendered( true ); } else { lblEspecif3.setRendered( false ); txtEspecif3.setRendered( false ); } } public void chkMembroInfEsq_processValueChange( ValueChangeEvent event ) { // TODO: Replace with your code Boolean b = ( Boolean ) event.getNewValue(); if ( b.equals( new Boolean( true ) ) ) { lblEspecif4.setRendered( true ); txtEspecif4.setRendered( true ); } else { lblEspecif4.setRendered( false ); txtEspecif4.setRendered( false ); } } // public void drpTecnicos_processValueChange(ValueChangeEvent event) { // // TODO: Replace with your code // Integer selected = (Integer) drpTecnicos.getSelected(); // if(selected.intValue() != 0) // { // UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); // try // { // Utilizador u = udp.getUtilizador(selected); // txtCap.setText(u.getCap()); // } // catch(Exception ex) // { // ErrorLogger.logException( ex ); // } // // } // } // public void drpMedicos_processValueChange(ValueChangeEvent event) { // // TODO: Replace with your code // Integer selected = (Integer) drpMedicos.getSelected(); // if(selected.intValue() != 0) // { // UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); // try // { // Utilizador u = udp.getUtilizador(selected); // txtCedula.setText(u.getNumero_cedula()); // } // catch(Exception ex) // { // ErrorLogger.logException( ex ); // } // } // // } public void chkRestricaoCargas_processValueChange( ValueChangeEvent event ) { // TODO: Replace with your code Boolean b = ( Boolean ) event.getNewValue(); if ( b.equals( new Boolean( true ) ) ) { rbKgs2.setRendered( true ); rbKgs5.setRendered( true ); rbKgs10.setRendered( true ); rbKgs15.setRendered( true ); rbKgsOutro.setRendered( true ); txtKgs.setRendered( true ); stKgs2.setRendered( true ); stKgs5.setRendered( true ); stKgs10.setRendered( true ); stKgs15.setRendered( true ); stKgsOutro.setRendered( true ); stKg.setRendered( true ); } else { rbKgs2.setRendered( false ); rbKgs5.setRendered( false ); rbKgs10.setRendered( false ); rbKgs15.setRendered( false ); rbKgsOutro.setRendered( false ); txtKgs.setRendered( false ); stKgs2.setRendered( false ); stKgs5.setRendered( false ); stKgs10.setRendered( false ); stKgs15.setRendered( false ); stKgsOutro.setRendered( false ); stKg.setRendered( false ); } } // private void notifyNextSignature(Integer estado) // { // Integer tipo = null; // ArrayList list = null; // UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); // switch(estado.intValue()) // { // case Global.ESTADO_ASSINATURA_SEG: // tipo = new Integer(Global.TIPO_UTILIZADOR_SEGURANCA); // seguranca // try // { // list = udp.getUtilizadoresListByTipo(tipo); // ListIterator iter = list.listIterator(); // while(iter.hasNext()) // { // Utilizador u = (Utilizador) iter.next(); // //sendEmail(u.getEmail(), getSessionBean1().getCurrentUser().getEmail()); // } // } // catch(Exception ex) // { // ErrorLogger.logException( ex ); // } // // break; // // case Global.ESTADO_ASSINATURA_RH: // tipo = new Integer(Global.TIPO_UTILIZADOR_RH); // recursos humanos // try // { // list = udp.getUtilizadoresListByTipo(tipo); // ListIterator iter = list.listIterator(); // while(iter.hasNext()) // { // Utilizador u = (Utilizador) iter.next(); // //sendEmail(u.getEmail(), "", texto); // } // } // catch(Exception ex) // { // ErrorLogger.logException( ex ); // } // break; // } // } private String sendMailToNextUser( AnaliseAcidente a, Integer estado ) { String errorMessage = ""; Integer tipo = null; String estabelecimentoNome = null; try { estabelecimentoNome = AnalisesDataProvider.getInstance().getEstabelecimentoNome( a.getEstabelecimento_id() ); } catch( Exception ex ) { ex.printStackTrace(); } Acidentado ac = getSessionBean1().getAcidentado(); if( estabelecimentoNome == null ) { if( ac == null ) { Integer acidentadoId = a.getAcidentado_id(); try { ac = AnalisesDataProvider.getInstance().getAcidentado( acidentadoId ); } catch( Exception ex ) { ex.printStackTrace(); } } if( ac != null ) { estabelecimentoNome = ac.getEstabelecimento_origem(); } else { estabelecimentoNome = ""; } } String assunto = "Comunicacao de Analise de Acidentes de Trabalho" + ( ac != null ? " de " + ac.getNome() : "" ) + " - " + estabelecimentoNome; String texto_email = "Esta é uma mensagem automática da equipa da SIPRP:
"; texto_email += "Recebeu um novo processo de análise de acidente de trabalho para tratar.
"; texto_email += "Por 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() + ".
"; System.out.println( "Sending mail to next user." ); 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 { UtilizadoresDataProvider udp = UtilizadoresDataProvider.getInstance(); ArrayList list = udp.getUtilizadoresListByTipo( tipo, responsavel_loja, a.getEstabelecimento_id() ); ListIterator iter = list.listIterator(); while ( iter.hasNext() ) { Utilizador u = ( Utilizador ) iter.next(); System.out.println( "USER MAIL NEXT FASE : " + u.getLogin() + " ; " + u.getEmail() ); try { //sendEmail(u.getEmail(), Global.ENDERECO_ENVIO, assunto, texto_email); sendEmailWithPdf( a, u.getEmail(), Global.ENDERECO_ENVIO, assunto, texto_email ); } catch ( Exception ex1 ) { errorMessage += "Erro a enviar email para " + u.getEmail(); boolean isValid = EmailValidator.getInstance().isValid( u.getEmail() ); if ( !isValid ) { errorMessage += " : email inválido."; } errorMessage += "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 { sendEmailWithPdf( a, ac.getEmail_superior_hierarquico(), Global.ENDERECO_ENVIO, assunto, texto_email ); //sendEmail(ac.getEmail_superior_hierarquico(), Global.ENDERECO_ENVIO, assunto, texto_email); } catch ( Exception ex ) { errorMessage += "Error a enviar email para " + ac.getEmail_superior_hierarquico(); boolean isValid = EmailValidator.getInstance().isValid( ac.getEmail_superior_hierarquico() ); if ( !isValid ) { errorMessage += " : email inválido."; } errorMessage += "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); sendEmailWithPdf( a, u.getEmail(), Global.ENDERECO_ENVIO, assunto, texto_email ); } catch ( Exception ex ) { errorMessage += "Erro a enviar email para " + u.getEmail(); boolean isValid = EmailValidator.getInstance().isValid( u.getEmail() ); if ( !isValid ) { errorMessage += " : email inválido."; } errorMessage += "Exmo. (a) Senhor(a),
"; texto_email += "Confirmamos que o processo de Análise de Acidente de Trabalho nº " + a.getAnalise_nr() + " se encontra encerrado após o preenchimento e validação de todos os intervenientes.
"; texto_email += "Sugerimos que imprima o ficheiro que enviamos em anexo e o junte à Participação de Sinistro à Seguradora para dar conhecimento ao Médico do Trabalho do seu estabelecimento. Após o seu conhecimento, aconselhamos que entregue uma cópia da Ficha de Análise de Acidente de Trabalho à equipa de Saúde Ocupacional, para que esta a arquive no processo clínico do trabalhador antes de juntar toda a documentação no processo individual do colaborador nos Recursos Humanos.
"; texto_email += "Agradecemos a sua colaboração e ficamos ao dispor para qualquer esclarecimento através dos telefones 213 504 544 (Catarina Leonardo) ou 213 504 542 (Sónia Campos).
"; texto_email += "Os melhores cumprimentos,
"; texto_email += "A equipa da SIPRP
"; try { sendEmailWithPdf( a, urh.getEmail(), Global.ENDERECO_ENVIO, assunto, texto_email ); } catch ( Exception ex ) { errorMessage += "Erro a enviar email para " + urh.getEmail(); boolean isValid = EmailValidator.getInstance().isValid( urh.getEmail() ); if ( !isValid ) { errorMessage += " : email inválido."; } errorMessage += "