/* * EnviarCorrecao.java * * Created on November 28, 2007, 5:27 PM * Copyright lluis */ package analiseacidentestrabalho; import beans.Correcao; import com.evolute.utils.error.ErrorLogger; 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.Form; import com.sun.rave.web.ui.component.Head; import com.sun.rave.web.ui.component.Html; import com.sun.rave.web.ui.component.Hyperlink; import com.sun.rave.web.ui.component.ImageComponent; import com.sun.rave.web.ui.component.Link; import com.sun.rave.web.ui.component.Page; import com.sun.rave.web.ui.component.PanelGroup; import com.sun.rave.web.ui.component.StaticText; import com.sun.rave.web.ui.component.Table; import com.sun.rave.web.ui.component.TableColumn; import com.sun.rave.web.ui.component.TableRowGroup; import com.sun.rave.web.ui.component.TextArea; import db.providers.AnalisesDataProvider; import db.providers.EstadosCorrecaoDataProvider; import global.Global; import java.util.ArrayList; import javax.faces.FacesException; import javax.faces.component.html.HtmlPanelGrid; import javax.faces.event.ValueChangeEvent; 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 EnviarCorrecao extends AbstractPageBean { // private int __placeholder; /** *

Automatically managed component initialization. WARNING: * This method is automatically generated, so any user-specified code inserted * here is subject to being replaced.

*/ private void _init() throws Exception { } private Page page1 = new Page(); public Page getPage1() { return page1; } public void setPage1(Page p) { this.page1 = p; } private Html html1 = new Html(); public Html getHtml1() { return html1; } public void setHtml1(Html h) { this.html1 = h; } private Head head1 = new Head(); public Head getHead1() { return head1; } public void setHead1(Head h) { this.head1 = h; } private Link link1 = new Link(); public Link getLink1() { return link1; } public void setLink1(Link l) { this.link1 = l; } private Body body1 = new Body(); public Body getBody1() { return body1; } public void setBody1(Body b) { this.body1 = b; } private Form form1 = new Form(); public Form getForm1() { return form1; } public void setForm1(Form f) { this.form1 = f; } private HtmlPanelGrid gridBase1 = new HtmlPanelGrid(); public HtmlPanelGrid getGridBase1() { return gridBase1; } public void setGridBase1(HtmlPanelGrid hpg) { this.gridBase1 = hpg; } private HtmlPanelGrid gridLayout1 = new HtmlPanelGrid(); public HtmlPanelGrid getGridLayout1() { return gridLayout1; } public void setGridLayout1(HtmlPanelGrid hpg) { this.gridLayout1 = hpg; } private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid(); public HtmlPanelGrid getGridPanel1() { return gridPanel1; } public void setGridPanel1(HtmlPanelGrid hpg) { this.gridPanel1 = hpg; } private PanelGroup groupPanel1 = new PanelGroup(); public PanelGroup getGroupPanel1() { return groupPanel1; } public void setGroupPanel1(PanelGroup pg) { this.groupPanel1 = pg; } private ImageComponent image1 = new ImageComponent(); public ImageComponent getImage1() { return image1; } public void setImage1(ImageComponent ic) { this.image1 = ic; } private ImageComponent image2 = new ImageComponent(); public ImageComponent getImage2() { return image2; } public void setImage2(ImageComponent ic) { this.image2 = ic; } private HtmlPanelGrid gridLayoutTop1 = new HtmlPanelGrid(); public HtmlPanelGrid getGridLayoutTop1() { return gridLayoutTop1; } public void setGridLayoutTop1(HtmlPanelGrid hpg) { this.gridLayoutTop1 = hpg; } private HtmlPanelGrid gridPanel9 = new HtmlPanelGrid(); public HtmlPanelGrid getGridPanel9() { return gridPanel9; } public void setGridPanel9(HtmlPanelGrid hpg) { this.gridPanel9 = hpg; } private PanelGroup groupPanel8 = new PanelGroup(); public PanelGroup getGroupPanel8() { return groupPanel8; } public void setGroupPanel8(PanelGroup pg) { this.groupPanel8 = pg; } private StaticText staticText10 = new StaticText(); public StaticText getStaticText10() { return staticText10; } public void setStaticText10(StaticText st) { this.staticText10 = st; } private ImageComponent image3 = new ImageComponent(); public ImageComponent getImage3() { return image3; } public void setImage3(ImageComponent ic) { this.image3 = ic; } private StaticText staticText11 = new StaticText(); public StaticText getStaticText11() { return staticText11; } public void setStaticText11(StaticText st) { this.staticText11 = st; } private HtmlPanelGrid gridMain1 = new HtmlPanelGrid(); public HtmlPanelGrid getGridMain1() { return gridMain1; } public void setGridMain1(HtmlPanelGrid hpg) { this.gridMain1 = hpg; } private Table table1 = new Table(); public Table getTable1() { return table1; } public void setTable1(Table t) { this.table1 = t; } private TableRowGroup tableRowGroup1 = new TableRowGroup(); public TableRowGroup getTableRowGroup1() { return tableRowGroup1; } public void setTableRowGroup1(TableRowGroup trg) { this.tableRowGroup1 = trg; } private StaticText staticText6 = new StaticText(); public StaticText getStaticText6() { return staticText6; } public void setStaticText6(StaticText st) { this.staticText6 = st; } private TextArea txtObservacoes = new TextArea(); public TextArea getTxtObservacoes() { return txtObservacoes; } public void setTxtObservacoes(TextArea ta) { this.txtObservacoes = ta; } private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid(); public HtmlPanelGrid getGridPanel2() { return gridPanel2; } public void setGridPanel2(HtmlPanelGrid hpg) { this.gridPanel2 = hpg; } private Button butCancelar = new Button(); public Button getButCancelar() { return butCancelar; } public void setButCancelar(Button b) { this.butCancelar = b; } private TableColumn tableColumn1 = new TableColumn(); public TableColumn getTableColumn1() { return tableColumn1; } public void setTableColumn1(TableColumn tc) { this.tableColumn1 = tc; } private Hyperlink lnkEstadoCorr = new Hyperlink(); public Hyperlink getLnkEstadoCorr() { return lnkEstadoCorr; } public void setLnkEstadoCorr(Hyperlink h) { this.lnkEstadoCorr = h; } private StaticText staticText5 = new StaticText(); public StaticText getStaticText5() { return staticText5; } public void setStaticText5(StaticText st) { this.staticText5 = st; } private Button butConfirmar = new Button(); public Button getButConfirmar() { return butConfirmar; } public void setButConfirmar(Button b) { this.butConfirmar = b; } private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid(); public HtmlPanelGrid getGridPanel3() { return gridPanel3; } public void setGridPanel3(HtmlPanelGrid hpg) { this.gridPanel3 = hpg; } private StaticText txtMsg = new StaticText(); public StaticText getTxtMsg() { return txtMsg; } public void setTxtMsg(StaticText st) { this.txtMsg = st; } private StaticText lblUser = new StaticText(); public StaticText getLblUser() { return lblUser; } public void setLblUser(StaticText st) { this.lblUser = st; } //
/** *

Construct a new Page bean instance.

*/ public EnviarCorrecao() { } /** *

Callback method that is called whenever a page is navigated to, * either directly via a URL, or indirectly via page navigation. * Customize this method to acquire resources that will be needed * for event handlers and lifecycle methods, whether or not this * page is performing post back processing.

* *

Note that, if the current request is a postback, the property * values of the components do not represent any * values submitted with this request. Instead, they represent the * property values that were saved for this view when it was rendered.

*/ public void init() { // Perform initializations inherited from our superclass super.init(); // Perform application initialization that must complete // *before* managed components are initialized // TODO - add your own initialiation code here // // Initialize automatically managed components // *Note* - this logic should NOT be modified try { _init(); } catch (Exception e) { log("EnviarCorrecao Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e: new FacesException(e); } // // Perform application initialization that must complete // *after* managed components are initialized // TODO - add your own initialization code here } /** *

Callback method that is called after the component tree has been * restored, but before any event processing takes place. This method * will only be called on a postback request that * is processing a form submit. Customize this method to allocate * resources that will be required in your event handlers.

*/ public void preprocess() { } /** *

Callback method that is called just before rendering takes place. * This method will only be called for the page that * will actually be rendered (and not, for example, on a page that * handled a postback and then navigated to a different page). Customize * this method to allocate resources that will be required for rendering * this page.

*/ public void prerender() { lblUser.setText( getSessionBean1().getCurrentUser().getLogin()); fillTabelaEstados(); 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).

*/ public void destroy() { } /** *

Return a reference to the scoped data bean.

*/ protected SessionBean1 getSessionBean1() { return (SessionBean1)getBean("SessionBean1"); } /** *

Return a reference to the scoped data bean.

*/ protected RequestBean1 getRequestBean1() { return (RequestBean1)getBean("RequestBean1"); } /** *

Return a reference to the scoped data bean.

*/ protected ApplicationBean1 getApplicationBean1() { return (ApplicationBean1)getBean("ApplicationBean1"); } public String lnkEditUser_action() { // TODO: Replace with your code return null; } public String lnkLogout_action() { Utils.doLogout( getExternalContext(), true ); return null; } public String lnkDataAcidente_action() { // TODO: Replace with your code return null; } public String lnkNr_action() { // TODO: Replace with your code return null; } public String lnkPor_action() { // TODO: Replace with your code return null; } public String lnkNomeAcidentado_action() { // TODO: Replace with your code return null; } public String lnkFase_action() { // TODO: Replace with your code return null; } public String lnkDataAcidenteSeg_action() { // TODO: Replace with your code return null; } public String lnkNrSeg_action() { // TODO: Replace with your code return null; } public String lnkPorSeg_action() { // TODO: Replace with your code return null; } public String lnkNomeAcidentadoSeg_action() { // TODO: Replace with your code return null; } public String lnkFaseSeg_action() { // TODO: Replace with your code return null; } public void drpAno_processValueChange(ValueChangeEvent event) { // TODO: Replace with your code } public void drpMes_processValueChange(ValueChangeEvent event) { // TODO: Replace with your code } public void drpDia_processValueChange(ValueChangeEvent event) { // TODO: Replace with your code } public String butPesquisar_action() { // TODO: Process the button click action. Return value is a navigation // case name where null will return to the same page. return null; } public String lnkDataConcluida_action() { // TODO: Replace with your code return null; } public String lnkNrConcluida_action() { // TODO: Replace with your code return null; } public String lnkPorConcluida_action() { // TODO: Replace with your code return null; } public String lnkNomeConcluida_action() { // TODO: Replace with your code return null; } public String lnkEstabConcluida_action() { // TODO: Replace with your code return null; } private void fillTabelaEstados() { ArrayList list = new ArrayList(); Correcao c = null; int estado = getSessionBean1().getCurrentAnalise().getEstado().intValue(); switch(estado) { case Global.ESTADO_HS: c = new Correcao(); c.setCorrecao("y"); c.setAnalise_id(getSessionBean1().getCurrentAnalise().getId()); c.setEstado_actual(getSessionBean1().getCurrentAnalise().getEstado()); c.setEstado_corr(new Integer(Global.ESTADO_SEG)); c.setDescricao("FASE 1 - SEG - ABERTURA"); list.add(c); c = new Correcao(); c.setCorrecao("y"); c.setAnalise_id(getSessionBean1().getCurrentAnalise().getId()); c.setEstado_actual(getSessionBean1().getCurrentAnalise().getEstado()); c.setEstado_corr(new Integer(Global.ESTADO_RH1)); c.setDescricao("FASE 2 - RH - ACOMPANHAMENTO"); list.add(c); getSessionBean1().getEstadosCorrecaoDataProvider().setList(list); break; case Global.ESTADO_CONSOLIDACAO: c = new Correcao(); c.setCorrecao("y"); c.setAnalise_id(getSessionBean1().getCurrentAnalise().getId()); c.setEstado_actual(getSessionBean1().getCurrentAnalise().getEstado()); c.setEstado_corr(new Integer(Global.ESTADO_RH2)); c.setDescricao("FASE 4 - RH - MEDIDAS + LESÃO"); list.add(c); // c = new Correcao(); // c.setCorrecao("y"); // c.setAnalise_id(getSessionBean1().getCurrentAnalise().getId()); // c.setEstado_actual(getSessionBean1().getCurrentAnalise().getEstado()); // c.setEstado_corr(new Integer(Global.ESTADO_MEDICINA)); // c.setDescricao("Medicina"); // list.add(c); getSessionBean1().getEstadosCorrecaoDataProvider().setList(list); break; } } public String lnkEstadoCorr_action() { // TODO: Replace with your code RowKey rk = tableRowGroup1.getRowKey(); int k = Integer.parseInt(rk.getRowId()); EstadosCorrecaoDataProvider provider = (EstadosCorrecaoDataProvider) tableRowGroup1.getSourceData(); ArrayList list = (ArrayList) provider.getList(); Correcao c = (Correcao)list.get(k); getSessionBean1().setCorrecao(c); // c.setObservacoes(""); // if(txtObservacoes.getText() != null) // { // String obs = (String) txtObservacoes.getText(); // c.setObservacoes(obs); // } // AnalisesDataProvider adp = new AnalisesDataProvider(); // try // { // adp.changeEstado(c); // // } // catch(Exception ex) // { // ErrorLogger.logException( ex ); // } // return "form_hs"; return null; } public String lnkNewUser_action() { // TODO: Replace with your code return null; } public String butCancelar_action() { // TODO: Process the button click action. Return value is a navigation // case name where null will return to the same page. //return "form_hs"; return "analise_acidente"; } public String lnkAjuda_action() { // TODO: Replace with your code // ServletContext theApplicationsServletContext = // (ServletContext) this.getExternalContext().getContext(); // String pdfFolderPath = theApplicationsServletContext.getRealPath(Global.PDF_FOLDER_URL); // String pdfFilePath = pdfFolderPath + "/Ajuda.pdf"; // // Global global = new Global(); // try // { // global.showPdf(pdfFilePath); // } // catch(Exception ex) // { // ErrorLogger.logException( ex ); // } return null; } public String butConfirmar_action() { // TODO: Process the button click action. Return value is a navigation // case name where null will return to the same page. Correcao c = getSessionBean1().getCorrecao(); if(c != null) { c.setObservacoes(""); if(txtObservacoes.getText() != null) { String obs = (String) txtObservacoes.getText(); c.setObservacoes(obs); } try { AnalisesDataProvider adp = AnalisesDataProvider.getInstance(); adp.changeEstado( c ); } catch ( Exception ex ) { ErrorLogger.logException( ex ); } return "form_hs"; } else { getSessionBean1().setMsg("Tem de indicar para onde enviar a correcção"); return null; } } public String lnkAnalisesAcidente_action() { // TODO: Replace with your code return null; } public String lnkPlanosActuacao_action() { // TODO: Replace with your code return null; } }