diff --git a/trunk/AnaliseAcidentesTrabalho/lib/evolute.jar b/trunk/AnaliseAcidentesTrabalho/lib/evolute.jar index c3bcf984..7fa2b007 100644 Binary files a/trunk/AnaliseAcidentesTrabalho/lib/evolute.jar and b/trunk/AnaliseAcidentesTrabalho/lib/evolute.jar differ diff --git a/trunk/AnaliseAcidentesTrabalho/lib/postgresql-8.2-506.jdbc4.jar b/trunk/AnaliseAcidentesTrabalho/lib/postgresql-8.2-506.jdbc4.jar deleted file mode 100644 index 260a95eb..00000000 Binary files a/trunk/AnaliseAcidentesTrabalho/lib/postgresql-8.2-506.jdbc4.jar and /dev/null differ diff --git a/trunk/AnaliseAcidentesTrabalho/lib/postgresql-8.4-701.jdbc4.jar b/trunk/AnaliseAcidentesTrabalho/lib/postgresql-8.4-701.jdbc4.jar new file mode 100644 index 00000000..e21beec5 Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib/postgresql-8.4-701.jdbc4.jar differ diff --git a/trunk/AnaliseAcidentesTrabalho/nbproject/build-impl.xml b/trunk/AnaliseAcidentesTrabalho/nbproject/build-impl.xml index 75ae9a5e..44cd4c89 100644 --- a/trunk/AnaliseAcidentesTrabalho/nbproject/build-impl.xml +++ b/trunk/AnaliseAcidentesTrabalho/nbproject/build-impl.xml @@ -532,8 +532,8 @@ exists or setup the property manually. For example like this: - + @@ -558,7 +558,7 @@ exists or setup the property manually. For example like this: - + @@ -578,8 +578,8 @@ exists or setup the property manually. For example like this: - + diff --git a/trunk/AnaliseAcidentesTrabalho/nbproject/faces-config.NavData b/trunk/AnaliseAcidentesTrabalho/nbproject/faces-config.NavData index 349d8867..c783bf39 100644 --- a/trunk/AnaliseAcidentesTrabalho/nbproject/faces-config.NavData +++ b/trunk/AnaliseAcidentesTrabalho/nbproject/faces-config.NavData @@ -19,10 +19,11 @@ + - + diff --git a/trunk/AnaliseAcidentesTrabalho/nbproject/genfiles.properties b/trunk/AnaliseAcidentesTrabalho/nbproject/genfiles.properties index 6c805e19..85a442cd 100644 --- a/trunk/AnaliseAcidentesTrabalho/nbproject/genfiles.properties +++ b/trunk/AnaliseAcidentesTrabalho/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=62908cce +build.xml.data.CRC32=430d21bb build.xml.script.CRC32=97b5d0ef build.xml.stylesheet.CRC32=c0ebde35@1.15.2.1 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=62908cce -nbproject/build-impl.xml.script.CRC32=866cdffa +nbproject/build-impl.xml.data.CRC32=430d21bb +nbproject/build-impl.xml.script.CRC32=ec8dc4f3 nbproject/build-impl.xml.stylesheet.CRC32=8ab4467e@1.15.2.1 diff --git a/trunk/AnaliseAcidentesTrabalho/nbproject/managed-beans.NavData b/trunk/AnaliseAcidentesTrabalho/nbproject/managed-beans.NavData index f65132b3..12aef59e 100644 --- a/trunk/AnaliseAcidentesTrabalho/nbproject/managed-beans.NavData +++ b/trunk/AnaliseAcidentesTrabalho/nbproject/managed-beans.NavData @@ -2,12 +2,12 @@ - + - + @@ -19,6 +19,7 @@ + diff --git a/trunk/AnaliseAcidentesTrabalho/nbproject/navigation.NavData b/trunk/AnaliseAcidentesTrabalho/nbproject/navigation.NavData index be634794..6d4aaf84 100644 --- a/trunk/AnaliseAcidentesTrabalho/nbproject/navigation.NavData +++ b/trunk/AnaliseAcidentesTrabalho/nbproject/navigation.NavData @@ -6,12 +6,12 @@ - + - + @@ -19,6 +19,7 @@ + diff --git a/trunk/AnaliseAcidentesTrabalho/nbproject/project.properties b/trunk/AnaliseAcidentesTrabalho/nbproject/project.properties index 94e2cc90..43a71a36 100644 --- a/trunk/AnaliseAcidentesTrabalho/nbproject/project.properties +++ b/trunk/AnaliseAcidentesTrabalho/nbproject/project.properties @@ -39,7 +39,7 @@ file.reference.log4j-1.2.15.jar=lib/log4j-1.2.15.jar file.reference.mail.jar=lib/mail.jar file.reference.poi-3.5-beta6-20090622.jar=lib/poi-3.5-beta6-20090622.jar file.reference.poi-ooxml-3.5-beta6-20090622.jar=lib/poi-ooxml-3.5-beta6-20090622.jar -file.reference.postgresql-8.2-506.jdbc4.jar=lib/postgresql-8.2-506.jdbc4.jar +file.reference.postgresql-8.4-701.jdbc4.jar=lib/postgresql-8.4-701.jdbc4.jar file.reference.serializer-2.7.0.jar=lib/serializer-2.7.0.jar file.reference.xalan-2.7.0.jar=lib/xalan-2.7.0.jar file.reference.xercesImpl-2.7.1.jar=lib/xercesImpl-2.7.1.jar @@ -68,8 +68,8 @@ javac.classpath=\ ${file.reference.jai_imageio.jar}:\ ${file.reference.jdom.jar}:\ ${file.reference.mail.jar}:\ - ${file.reference.postgresql-8.2-506.jdbc4.jar}:\ ${file.reference.evolute.jar}:\ + ${file.reference.postgresql-8.4-701.jdbc4.jar}:\ ${file.reference.evologger.jar}:\ ${file.reference.poi-3.5-beta6-20090622.jar}:\ ${file.reference.poi-ooxml-3.5-beta6-20090622.jar}:\ diff --git a/trunk/AnaliseAcidentesTrabalho/nbproject/project.xml b/trunk/AnaliseAcidentesTrabalho/nbproject/project.xml index dd48add6..b790a1d0 100644 --- a/trunk/AnaliseAcidentesTrabalho/nbproject/project.xml +++ b/trunk/AnaliseAcidentesTrabalho/nbproject/project.xml @@ -72,11 +72,11 @@ WEB-INF/lib - ${file.reference.postgresql-8.2-506.jdbc4.jar} + ${file.reference.evolute.jar} WEB-INF/lib - ${file.reference.evolute.jar} + ${file.reference.postgresql-8.4-701.jdbc4.jar} WEB-INF/lib diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/ConfirmarDesactivar.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/ConfirmarDesactivar.java new file mode 100644 index 00000000..70fcfe4f --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/ConfirmarDesactivar.java @@ -0,0 +1,313 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package analiseacidentestrabalho; + +import beans.AnaliseAcidente; +import beans.Utilizador; +import com.evolute.utils.error.ErrorLogger; +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.rave.web.ui.component.Hyperlink; +import com.sun.rave.web.ui.component.StaticText; +import com.sun.rave.web.ui.component.TextArea; +import db.AnalisesDataProvider; +import global.Global; +import java.util.Date; +import javax.faces.FacesException; +import javax.faces.context.FacesContext; +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.

+ * + * @version ConfirmarDesactivar.java + * @version Created on Oct 11, 2010, 3:38:04 PM + * @author dneves + */ + +public class ConfirmarDesactivar extends AbstractPageBean +{ + + private Hyperlink lnkPlanosActuacao = new Hyperlink(); + public Hyperlink getLnkPlanosActuacao() + { + return lnkPlanosActuacao; + } + public void setLnkPlanosActuacao( Hyperlink h ) + { + this.lnkPlanosActuacao = h; + } + + private StaticText lblUser = new StaticText(); + public StaticText getLblUser() + { + return lblUser; + } + public void setLblUser( StaticText st ) + { + this.lblUser = st; + } + + private StaticText txtMsg = new StaticText(); + public StaticText getTxtMsg() + { + return txtMsg; + } + public void setTxtMsg( StaticText st ) + { + this.txtMsg = st; + } + + private StaticText textAnalise = new StaticText(); + public StaticText getTextAnalise() + { + return textAnalise; + } + public void setTextAnalise( StaticText textAnalise ) + { + this.textAnalise = textAnalise; + } + + private TextArea textComentario = new TextArea(); + public TextArea getTextComentario() + { + return textComentario; + } + public void setTextComentario( TextArea textComentario ) + { + this.textComentario = textComentario; + } + + + private void _init() throws Exception + { + + } + + + public ConfirmarDesactivar() + { + + } + + + @Override + public void init() + { + super.init(); + + try + { + _init(); + } + catch ( Exception e ) + { + log( "ConfirmarDesactivar Initialization Failure", e ); + throw e instanceof FacesException ? (FacesException) e: new FacesException(e); + } + + if ( ! canAccess() ) + { + try + { + getExternalContext().redirect( "Login.jsp" ); + } + catch( Exception e ) + { + ErrorLogger.logException( e ); + } + } + } + + /** + *

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() + { + txtMsg.setText( getSessionBean1().getMsg() ); + getSessionBean1().setMsg( "" ); + } + + /** + *

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() + { + System.out.println( "=== CONFIRMAR_DESACTIVACAO ===" ); + + lblUser.setText( getSessionBean1().getCurrentUser().getLogin() ); + + AnaliseAcidente analise = getSessionBean1().getCurrentAnalise(); + if ( analise != null ) + { + textAnalise.setText( "Análise nº " + analise.getAnalise_nr() ); + } + else + { + textAnalise.setText( "Análise inválida." ); + } + } + + /** + *

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).

+ */ + @Override + public void destroy() + { + + } + + /** + *

Return a reference to the scoped data bean.

+ * + * @return reference to the scoped data bean + */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1) getBean("SessionBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ * + * @return reference to the scoped data bean + */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1) getBean("RequestBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ * + * @return reference to the scoped data bean + */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1) getBean("ApplicationBean1"); + } + + private boolean canAccess() + { + boolean canAccess = false; + + if ( getSessionBean1().isLoggedIn() ) + { + Utilizador u = getSessionBean1().getCurrentUser(); + if ( u != null && u.getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP ) + { + canAccess = true; + } + } + + return canAccess; + } + + public String lnkPlanosActuacao_action() + { + Utilizador u = getSessionBean1().getCurrentUser(); + FacesContext fc = getFacesContext().getCurrentInstance(); + Global.redirectToPlanos(fc, u); + return null; + } + + public String lnkNewUser_action() + { + getSessionBean1().setNavFrom( "EstatisticasProcesso" ); + return "gestao_utilizadores"; + } + + public String lnkEditUser_action() + { + getSessionBean1().setNavFrom( "EstatisticasProcesso" ); + getSessionBean1().setModoEdicaoUtilizador( "edit" ); + return "user"; + } + + public String lnkLogout_action() + { + try + { + javax.servlet.http.HttpSession session = ( javax.servlet.http.HttpSession ) getExternalContext().getSession( true ); + session.invalidate(); + Utils.doLogout(); + + getExternalContext().redirect( "Login.jsp" ); + } + catch( Exception ex ) + { + + } + return null; + } + + public String buttonCancelar_action() + { + getSessionBean1().setCurrentAnalise( null ); + return "formDirSiprp"; + } + + public String buttonConfirmar_action() + { + Utilizador currentUser = getSessionBean1().getCurrentUser(); + AnaliseAcidente analise = getSessionBean1().getCurrentAnalise(); + if ( userCanDesactivarAnalise( currentUser ) && analise != null ) + { + try + { + String comentario = null; + if ( textComentario.getText() != null ) + { + comentario = ( ( String ) textComentario.getText() ).trim(); + comentario = "".equals( comentario ) ? null : comentario; + } + + analise.setEstado( Global.ESTADO_CONCLUIDO ); + analise.setConcluido_por_desactivacao( Boolean.TRUE ); + analise.setData_desactivacao( new Date() ); + analise.setComentario_desactivacao( comentario ); + + AnalisesDataProvider adp = new AnalisesDataProvider(); + adp.updateAnalise( analise ); + } + catch ( Exception e ) + { + ErrorLogger.logException( e ); + getSessionBean1().setMsg( "Erro a desactivar análise.\n" + e.getMessage() ); + } + } + + return "formDirSiprp"; + } + + private boolean userCanDesactivarAnalise( Utilizador user ) + { + boolean canDesactivar = false; + if ( user != null ) + { + int userType = user.getTipo() == null ? -1 : user.getTipo().intValue(); + canDesactivar = userType == Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP; + } + return canDesactivar; + } +} + diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/EstatisticasProcesso.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/EstatisticasProcesso.java index 15efaa8b..7c52dbd3 100644 --- a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/EstatisticasProcesso.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/EstatisticasProcesso.java @@ -387,17 +387,13 @@ public class EstatisticasProcesso extends AbstractPageBean javax.servlet.http.HttpSession session = ( javax.servlet.http.HttpSession ) getExternalContext().getSession( true ); session.invalidate(); Utils.doLogout(); - } - catch( Exception ex ) - {} - try - { getExternalContext().redirect( "Login.jsp" ); } - catch( Exception e ) - {} + catch( Exception ex ) + { + } return null; } diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormDirSiprp.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormDirSiprp.java index 59a7b639..b8378f7e 100755 --- a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormDirSiprp.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FormDirSiprp.java @@ -842,6 +842,28 @@ public class FormDirSiprp extends AbstractPageBean { public void setLblUser(StaticText st) { this.lblUser = st; } + + public TableColumn tableColumnDesactivarAnalise = new TableColumn(); + + public TableColumn getTableColumnDesactivarAnalise() { + return tableColumnDesactivarAnalise; + } + + public void setTableColumnDesactivarAnalise(TableColumn tableColumnDesactivarAnalise) { + this.tableColumnDesactivarAnalise = tableColumnDesactivarAnalise; + } + + public Button buttonDesactivarAnalise = new Button(); + + public Button getButtonDesactivarAnalise() { + return buttonDesactivarAnalise; + } + + public void setButtonDesactivarAnalise(Button buttonDesactivarAnalise) { + this.buttonDesactivarAnalise = buttonDesactivarAnalise; + } + + // @@ -946,130 +968,111 @@ public class FormDirSiprp extends AbstractPageBean { } private static final DateFormat D_F = new SimpleDateFormat( "yyyy-MM-dd" ); - - /** - *

Construct a new Page bean instance.

- */ - public FormDirSiprp() { + + + public FormDirSiprp() + { + } - /** - *

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 + @Override + public void init() + { super.init(); - // Perform application initialization that must complete - // *before* managed components are initialized - // TODO - add your own initialiation code here - if (!getSessionBean1().isLoggedIn()) { - try { - getExternalContext().redirect("Login.jsp"); - } catch(Exception e) { - // . . . handle exception . . . - } - } - // - // Initialize automatically managed components - // *Note* - this logic should NOT be modified - try { + try + { _init(); - } catch (Exception e) { + } + catch ( Exception e ) + { log("FormDirSiprp 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 + + if ( ! getSessionBean1().isLoggedIn() ) + { + try + { + getExternalContext().redirect( "Login.jsp" ); + } + catch ( Exception e ) + { + // . . . handle exception . . . + } + } } - /** - *

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() { - txtMsg1.setText(getSessionBean1().getMsg()); - getSessionBean1().setMsg(""); + @Override + public void preprocess() + { + txtMsg1.setText( getSessionBean1().getMsg() ); + getSessionBean1().setMsg( "" ); } - - /** - *

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() { - System.out.println("=== FORM_DIR_SIPRP ==="); - lblUser.setText( getSessionBean1().getCurrentUser().getLogin() ); + + + @Override + public void prerender() + { + System.out.println("=== FORM_DIR_SIPRP ==="); + + Utilizador currentUser = getSessionBean1().getCurrentUser(); + lblUser.setText( currentUser == null ? "" : currentUser.getLogin() ); - HttpServletRequest request = (HttpServletRequest) getExternalContext().getRequest(); - String referer = request.getRequestURI(); - String pageFrom = Utils.getPageFrom(referer); - if((!pageFrom.matches("FormDirSiprp.jsp")) || getSessionBean1().isFromAnaliseDeletion()) - { - AnalisesDataProvider adp = new AnalisesDataProvider(); - - try - { + HttpServletRequest request = ( HttpServletRequest ) getExternalContext().getRequest(); + String referer = request.getRequestURI(); + String pageFrom = Utils.getPageFrom( referer ); + if ( ( ! pageFrom.matches( "FormDirSiprp.jsp" ) ) || getSessionBean1().isFromAnaliseDeletion() ) + { + AnalisesDataProvider adp = new AnalisesDataProvider(); + + try + { //lblActivos.setRendered(true); table2.setRendered( true ); ArrayList seguimentoList = adp.getAnalisesSeguimentoDirSiprpList(); getSessionBean1().getAnalisesSeguimentoDataProvider().setList( seguimentoList ); - } - catch(Exception ex) - { - //lblActivos.setRendered(false); - table2.setRendered( false ); - ErrorLogger.logException( ex ); - } - - try - { - //lblActivos.setRendered(true); - table3.setRendered(true); - - ArrayList concluidasList = adp.getAnalisesConcluidasList(null); - getSessionBean1().getAnalisesConcluidasDataProvider().setList(concluidasList); - } - catch(Exception ex) - { - //lblActivos.setRendered(false); - table3.setRendered(false); - ErrorLogger.logException( ex ); - } - fillAnoDropDown(); - } - } - - //} + } + catch ( Exception ex ) + { + //lblActivos.setRendered(false); + table2.setRendered( false ); + ErrorLogger.logException( ex ); + } + + try + { + //lblActivos.setRendered(true); + table3.setRendered( true ); + + ArrayList concluidasList = adp.getAnalisesConcluidasList( null ); + getSessionBean1().getAnalisesConcluidasDataProvider().setList( concluidasList ); + } + catch ( Exception ex ) + { + //lblActivos.setRendered(false); + table3.setRendered( false ); + ErrorLogger.logException( ex ); + } + fillAnoDropDown(); + } + + //Column para desactivar plano - mostra se o utilizador for DIRECTOR SIPRP +// System.out.println( "\n\nRendering 'desactivar' ... " + buttonDesactivarAnalise.isRendered() ); + int uType = currentUser == null ? -1 : currentUser.getTipo().intValue(); +// System.out.println( "\tuserType : " + uType ); + boolean renderOrNot = uType == Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP; +// System.out.println( "\trenderOrNot : " + renderOrNot + " ( " + Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP + " )" ); + tableColumnDesactivarAnalise.setRendered( renderOrNot ); + buttonDesactivarAnalise.setRendered( renderOrNot ); + } - /** - *

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() { + + @Override + public void destroy() + { + } /** @@ -1601,5 +1604,16 @@ public class FormDirSiprp extends AbstractPageBean { return null; } + public String buttonDesactivarAnalise_action() + { + System.out.println( "\nbuttonDesactivarAnalise_action() : " ); + AnaliseAcidente selectedAnalise = getTableSeguimentoRowData(); + + // TODO : call ConfirmarDesactivar.jsp with selectedAnalise + getSessionBean1().setCurrentAnalise( selectedAnalise ); + + return "confirmar_desactivar"; + } + } diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/ViewAnaliseAcidenteTrabalho.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/ViewAnaliseAcidenteTrabalho.java index 89ed70fd..a77c0c2d 100644 --- a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/ViewAnaliseAcidenteTrabalho.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/ViewAnaliseAcidenteTrabalho.java @@ -158,6 +158,28 @@ public class ViewAnaliseAcidenteTrabalho extends AbstractPageBean { this.txtMsg1 = st; } + private StaticText txtComentarioConclusaoTitle = new StaticText(); + + public StaticText getTxtComentarioConclusaoTitle() { + return txtComentarioConclusaoTitle; + } + + public void setTxtComentarioConclusaoTitle(StaticText txtComentarioConclusaoTitle) { + this.txtComentarioConclusaoTitle = txtComentarioConclusaoTitle; + } + + private StaticText txtComentarioConclusao = new StaticText(); + + public StaticText getTxtComentarioConclusao() { + return txtComentarioConclusao; + } + + public void setTxtComentarioConclusao(StaticText txtComentarioConclusao) { + this.txtComentarioConclusao = txtComentarioConclusao; + } + + + private HtmlPanelGrid gridCabecalho1 = new HtmlPanelGrid(); public HtmlPanelGrid getGridCabecalho1() { @@ -2141,7 +2163,9 @@ public class ViewAnaliseAcidenteTrabalho extends AbstractPageBean { * values submitted with this request. Instead, they represent the * property values that were saved for this view when it was rendered.

*/ - public void init() { + @Override + public void init() + { // Perform initializations inherited from our superclasssuperclass super.init(); // Perform application initialization that must complete @@ -2185,7 +2209,9 @@ public class ViewAnaliseAcidenteTrabalho extends AbstractPageBean { * is processing a form submit. Customize this method to allocate * resources that will be required in your event handlers.

*/ - public void preprocess() { + @Override + public void preprocess() + { } /** @@ -2196,7 +2222,9 @@ public class ViewAnaliseAcidenteTrabalho extends AbstractPageBean { * this method to allocate resources that will be required for rendering * this page.

*/ - public void prerender() { + @Override + public void prerender() + { getSessionBean1().setFromAnaliseDeletion(false); String confirmacao_analise = (String)getExternalContext().getRequestParameterMap().get("confirmacao_analise"); if(confirmacao_analise != null) @@ -2267,8 +2295,9 @@ public class ViewAnaliseAcidenteTrabalho extends AbstractPageBean { * preprocess(), or prerender() methods (or * acquired during execution of an event handler).

*/ - - public void destroy() { + @Override + public void destroy() + { } /** @@ -2334,18 +2363,47 @@ public class ViewAnaliseAcidenteTrabalho extends AbstractPageBean { private void initializePage() { Utilizador u = getSessionBean1().getCurrentUser(); + AnaliseAcidente a = getSessionBean1().getCurrentAnalise(); + if(! (u.getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP || u.getTipo().intValue() == Global.TIPO_UTILIZADOR_HS)) { butEliminar.setRendered(false); } else { - AnaliseAcidente a = getSessionBean1().getCurrentAnalise(); if(a.getEstado().intValue() == Global.ESTADO_CONCLUIDO) { butEliminar.setRendered(false); } } + + if ( a != null ) + { + if ( a.getConcluido_por_desactivacao() ) + { + txtComentarioConclusaoTitle.setRendered( true ); + txtComentarioConclusaoTitle.setText( "Análise concluída por falta de cumprimento do prazo." ); + + if ( a.getComentario_desactivacao() != null && ! "".equals( a.getComentario_desactivacao().trim() ) ) + { + txtComentarioConclusao.setRendered( true ); + txtComentarioConclusao.setText( "" + a.getComentario_desactivacao() ); + } + else + { + txtComentarioConclusao.setRendered( false ); + txtComentarioConclusao.setText( "" ); + } + } + else + { + txtComentarioConclusao.setRendered( false ); + txtComentarioConclusao.setText( "" ); + txtComentarioConclusao.setRendered( false ); + txtComentarioConclusao.setText( "" ); + } + } + fillPage(); //fillImages(); } diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/beans/AnaliseAcidente.java b/trunk/AnaliseAcidentesTrabalho/src/java/beans/AnaliseAcidente.java index 38e5cdf0..a15c55f5 100644 --- a/trunk/AnaliseAcidentesTrabalho/src/java/beans/AnaliseAcidente.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/beans/AnaliseAcidente.java @@ -142,6 +142,11 @@ public class AnaliseAcidente implements Serializable private Date data_inicio_processo; private Integer rh_fase4; + + private Boolean concluido_por_desactivacao; + private java.util.Date data_desactivacao; + private String comentario_desactivacao; + /** Creates a new instance of AnaliseAcidente */ public AnaliseAcidente() { @@ -1048,5 +1053,29 @@ public class AnaliseAcidente implements Serializable { this.rh_fase4 = rh_fase4; } - + + public Boolean getConcluido_por_desactivacao() { + return concluido_por_desactivacao; + } + + public void setConcluido_por_desactivacao(Boolean concluido_por_desactivacao) { + this.concluido_por_desactivacao = concluido_por_desactivacao; + } + + public java.util.Date getData_desactivacao() { + return data_desactivacao; + } + + public void setData_desactivacao( java.util.Date data_desactivacao) { + this.data_desactivacao = data_desactivacao; + } + + public String getComentario_desactivacao() { + return comentario_desactivacao; + } + + public void setComentario_desactivacao(String comentario_desactivacao) { + this.comentario_desactivacao = comentario_desactivacao; + } + } diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/db/AnalisesDataProvider.java b/trunk/AnaliseAcidentesTrabalho/src/java/db/AnalisesDataProvider.java index 1837cc60..e490d81a 100644 --- a/trunk/AnaliseAcidentesTrabalho/src/java/db/AnalisesDataProvider.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/db/AnalisesDataProvider.java @@ -1330,11 +1330,14 @@ public class AnalisesDataProvider { a.setNome_resp_consolidacao(rs.getString("nome_resp_consolidacao")); //System.out.println("ANALISE NR : " + a.getAnalise_nr()); a.setRh_fase4(new Integer( rs.getInt("rh_fase4") )); - list.add(a); - }while(rs.next()); + + a.setConcluido_por_desactivacao( rs.getBoolean( "concluido_por_desactivacao" ) ); + a.setData_desactivacao( rs.getDate( "data_desactivacao" ) ); + a.setComentario_desactivacao( rs.getString( "comentario_desactivacao" ) ); + list.add( a ); + } while ( rs.next() ); dblocal.close(); - return list; } @@ -1888,7 +1891,7 @@ public class AnalisesDataProvider { a.setAnalise_nr(analise_nr); a.setId(newId); - String sql = "INSERT INTO analises_acidentes (id, averiguador, data_acidente, acidentado_id, estado, empresa_id, estabelecimento_id, horas_turno, departamento_id, seccao_id, local_trabalho, tarefa, substancias, condicoes, testemunhas, causas, descricao, conclusoes, accoes, hora_acidente, medico_id, tecnico_saude_id, averiguacao_posterior, averiguacao_obs, data_inicio_processo, analise_nr, coef_incapacidade) VALUES ("; + String sql = "INSERT INTO analises_acidentes (id, averiguador, data_acidente, acidentado_id, estado, empresa_id, estabelecimento_id, horas_turno, departamento_id, seccao_id, local_trabalho, tarefa, substancias, condicoes, testemunhas, causas, descricao, conclusoes, accoes, hora_acidente, medico_id, tecnico_saude_id, averiguacao_posterior, averiguacao_obs, data_inicio_processo, analise_nr, coef_incapacidade, concluido_por_desactivacao, data_desactivacao, comentario_desactivacao) VALUES ("; sql += newId + ", '"; sql += a.getAveriguador() + "', '"; sql += a.getData_acidente() + "', "; @@ -1932,7 +1935,13 @@ public class AnalisesDataProvider { } sql += analise_nr + "', "; - sql += null + ")"; + sql += null + ", "; + + sql += false + ", " + null + ", " + null; //concluido_por_desactivacao, data_desactivacao, comentario_desactivacao + + sql += ")"; + +// sql += null + ")"; // sql += a.getFormacao_shst() + "', '"; // sql += a.getFormacao_shst_nao_porque() + "', '"; // sql += a.getOutros_acidentes_com_colaborador() + "', "; @@ -1987,8 +1996,24 @@ public class AnalisesDataProvider { { a.setFormacao_shst_nao_porque(""); } + if ( a.getConcluido_por_desactivacao() == null ) + { + a.setConcluido_por_desactivacao( Boolean.FALSE ); + a.setData_desactivacao( null ); + a.setComentario_desactivacao( null ); + } + if ( a.getConcluido_por_desactivacao() != null && a.getConcluido_por_desactivacao().equals( Boolean.TRUE ) && a.getData_desactivacao() == null ) + { + a.setData_desactivacao( new Date() ); + } + if ( a.getComentario_desactivacao() != null && "".equals( a.getComentario_desactivacao().trim() ) ) + { + a.setComentario_desactivacao( null ); + } + + Statement st = createStatement(); - String sql = "UPDATE analises_acidentes SET data_acidente = '" + a.getData_acidente() + "', "; + String sql = "UPDATE analises_acidentes SET data_acidente = '" + a.getData_acidente() + "', "; sql += "acidentado_id = " + a.getAcidentado_id() + ", "; sql += "estado = " + a.getEstado() + ", "; sql += "empresa_id = " + a.getEmpresa_id() + ", "; @@ -2149,17 +2174,20 @@ public class AnalisesDataProvider { { sql += "data_assinatura_superior = '" + a.getData_assinatura_superior() + "', "; } - sql += "rh_fase4 = " + a.getRh_fase4() + " "; - sql += "WHERE id = " + a.getId(); + sql += "rh_fase4 = " + a.getRh_fase4() + ", "; + sql += "concluido_por_desactivacao = " + a.getConcluido_por_desactivacao() + ", "; + sql += "comentario_desactivacao = " + ( a.getComentario_desactivacao() == null ? "null" : "'" + a.getComentario_desactivacao() + "'" ) + ", "; + sql += "data_desactivacao = " + ( a.getData_desactivacao() == null ? "null" : "'" + new java.sql.Date( a.getData_desactivacao().getTime() ) + "'" ); + sql += " WHERE id = " + a.getId(); System.out.println("SQL UPDATE : " + sql); - st.execute(sql); + st.execute( sql ); } public void changeEstado(Correcao c) throws Exception { Statement st = createStatement(); String sql = "UPDATE analises_acidentes SET correcao = '" + c.getCorrecao() + "', estado = " + c.getEstado_corr() + ", estado_antes_correcao = " + c.getEstado_actual() + ", observacoes_correcao = '" + c.getObservacoes() + "' WHERE id = " + c.getAnalise_id(); - st.execute(sql); + st.execute(sql); } public Integer getMaxRecomendacaoId() diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/db/Db.java b/trunk/AnaliseAcidentesTrabalho/src/java/db/Db.java index ce74a05d..553fd301 100644 --- a/trunk/AnaliseAcidentesTrabalho/src/java/db/Db.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/db/Db.java @@ -23,24 +23,34 @@ import javax.servlet.http.HttpSession; */ public class Db { -// String connectionURL = "jdbc:postgresql://evoserver:5432/siprp_20100813"; //testes - String connectionURL = "jdbc:postgresql://localhost:5436/siprp"; //real - - String User = "postgres"; - String Pass = null; + //production + private String host = "localhost"; + private int port = 5436; + private String db = "siprp"; + private String user = "postgres"; + private String pass = null; + + //tests +// private String host = "evoserver"; +// private int port = 5432; +// private String db = "siprp_20100813"; +// private String user = "postgres"; +// private String pass = null; - Connection connection = null; + private String connectionURL = "jdbc:postgresql://" + host + ":" + port + "/" + db; + private Connection connection = null; - /** Creates a new instance of Db */ - public Db() + + public Db() { + } public Connection connect() throws Exception { Class.forName("org.postgresql.Driver").newInstance(); - connection = DriverManager.getConnection(connectionURL, User, Pass); + connection = DriverManager.getConnection(connectionURL, user, pass); HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true); session.setAttribute("connection", connection); return connection; diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/db/Dblocal.java b/trunk/AnaliseAcidentesTrabalho/src/java/db/Dblocal.java index b3917a74..c5d6a215 100644 --- a/trunk/AnaliseAcidentesTrabalho/src/java/db/Dblocal.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/db/Dblocal.java @@ -23,24 +23,33 @@ import javax.servlet.http.HttpSession; */ public class Dblocal { -// String connectionURL = "jdbc:postgresql://evoserver:5432/siprp_local_3_20100813"; //testes - String connectionURL = "jdbc:postgresql://localhost:5436/siprp_local_3"; + //production + private String host = "localhost"; + private int port = 5436; + private String db = "siprp_local_3"; + private String user = "postgres"; + private String pass = null; - String User = "postgres"; - String Pass = null; + //tests +// private String host = "evoserver"; +// private int port = 5432; +// private String db = "siprp_local_3_20100813"; +// private String user = "postgres"; +// private String pass = null; + + private String connectionURL = "jdbc:postgresql://" + host + ":" + port + "/" + db; + private Connection connection = null; - Connection connection = null; - - /** Creates a new instance of Dblocal */ public Dblocal() { + } public Connection connect() throws Exception { Class.forName("org.postgresql.Driver").newInstance(); - connection = DriverManager.getConnection(connectionURL, User, Pass); + connection = DriverManager.getConnection(connectionURL, user, pass); HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true); session.setAttribute("connection_local", connection); return connection; diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/phaselistener/MainPhaseListener.java b/trunk/AnaliseAcidentesTrabalho/src/java/phaselistener/MainPhaseListener.java index da185266..9bcd4de9 100644 --- a/trunk/AnaliseAcidentesTrabalho/src/java/phaselistener/MainPhaseListener.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/phaselistener/MainPhaseListener.java @@ -5,14 +5,14 @@ package phaselistener; -import beans.Utilizador; import javax.faces.context.FacesContext; import javax.faces.event.PhaseEvent; import javax.faces.event.PhaseId; import javax.faces.event.PhaseListener; import analiseacidentestrabalho.SessionBean1; import com.evolute.utils.error.ErrorLogger; -import java.util.logging.Level; +import javax.faces.component.UIViewRoot; +import javax.servlet.http.HttpServletRequest; import utils.AnaliseAcidentesTrabalhoLogger; import utils.JSFUtils; import utils.Logos; @@ -43,35 +43,62 @@ public class MainPhaseListener implements PhaseListener } private boolean firstEntry = true; - + + @Override public void afterPhase(PhaseEvent pe) { } - public void beforePhase(PhaseEvent pe) { + @Override + public void beforePhase(PhaseEvent pe) + { if(pe.getPhaseId() == PhaseId.RENDER_RESPONSE) { - FacesContext fc = pe.getFacesContext(); - SessionBean1 session = JSFUtils.getSessionBean(fc); + FacesContext fc = pe.getFacesContext(); + SessionBean1 session = JSFUtils.getSessionBean( fc ); + + HttpServletRequest req = ( HttpServletRequest ) fc.getExternalContext().getRequest(); + boolean sessionValid = req.isRequestedSessionIdValid(); + System.out.println( "\tSessionValid : " + sessionValid ); - - Utilizador u = session.getCurrentUser(); + UIViewRoot view = fc.getViewRoot(); + System.out.println( "\tView : " + view ); + String viewID = view.getViewId(); + System.out.println( "\t\tView ID :" + viewID ); - - //insert logos - - //Integer empresaId = u.getEmpresa_id(); - Integer empresaId = new Integer(32); - //System.out.println("LOGO EMPRESA ID : " + empresaId.toString()); - Logos logos = new Logos(); - String logourl = logos.getLogo(fc, empresaId); - //System.out.println("LOGO URL : " + logourl); - session.setLogoEmpresaUrl(logourl); + boolean loggedIn = session.isLoggedIn(); + System.out.println( "\tLogged In : " + loggedIn ); + + if ( sessionValid && loggedIn ) + { + //insert logos + Integer empresaId = new Integer( 32 ); + Logos logos = new Logos(); + String logourl = logos.getLogo( fc, empresaId ); + session.setLogoEmpresaUrl( logourl ); + } + else + { + if ( ! viewID.endsWith( "/Login.jsp" ) ) + { + try + { + JSFUtils.redirect( fc.getCurrentInstance(), "faces/Login.jsp" ); + } + catch ( Exception e ) + { + ErrorLogger.logException( e ); + System.out.println( "\n\t\t\tERROR REDIRECTING TO LOGIN !" ); + } + } + } } } - public PhaseId getPhaseId() { + @Override + public PhaseId getPhaseId() + { return PhaseId.ANY_PHASE; } diff --git a/trunk/AnaliseAcidentesTrabalho/web/ConfirmarDesactivar.jsp b/trunk/AnaliseAcidentesTrabalho/web/ConfirmarDesactivar.jsp new file mode 100644 index 00000000..dc952163 --- /dev/null +++ b/trunk/AnaliseAcidentesTrabalho/web/ConfirmarDesactivar.jsp @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/trunk/AnaliseAcidentesTrabalho/web/FormDirSiprp.jsp b/trunk/AnaliseAcidentesTrabalho/web/FormDirSiprp.jsp index 1d8a4284..6f2c13c3 100755 --- a/trunk/AnaliseAcidentesTrabalho/web/FormDirSiprp.jsp +++ b/trunk/AnaliseAcidentesTrabalho/web/FormDirSiprp.jsp @@ -16,7 +16,7 @@ wOpen.focus(); wOpen.moveTo(0,0); wOpen.resizeTo( screen.availWidth, screen.availHeight ); - } + } @@ -136,6 +136,10 @@ + + + diff --git a/trunk/AnaliseAcidentesTrabalho/web/ViewAnaliseAcidenteTrabalho.jsp b/trunk/AnaliseAcidentesTrabalho/web/ViewAnaliseAcidenteTrabalho.jsp index 3baf64e0..4fab955d 100644 --- a/trunk/AnaliseAcidentesTrabalho/web/ViewAnaliseAcidenteTrabalho.jsp +++ b/trunk/AnaliseAcidentesTrabalho/web/ViewAnaliseAcidenteTrabalho.jsp @@ -94,6 +94,10 @@ style="height: 24px; width: 100%" width="96"> + + phaselistener.MainPhaseListener - - - Acesso - analiseacidentestrabalho.Acesso - request - + + + diff --git a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/managed-beans.xml b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/managed-beans.xml index 960b96d1..7d269e69 100644 --- a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/managed-beans.xml +++ b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/managed-beans.xml @@ -2,6 +2,11 @@ + + Acesso + analiseacidentestrabalho.Acesso + request + SessionBean1 analiseacidentestrabalho.SessionBean1 @@ -132,5 +137,9 @@ analiseacidentestrabalho.EstatisticasProcesso request - + + ConfirmarDesactivar + analiseacidentestrabalho.ConfirmarDesactivar + request + diff --git a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/navigation.xml b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/navigation.xml index 8cc6a020..b76ef483 100644 --- a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/navigation.xml +++ b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/navigation.xml @@ -2,6 +2,7 @@ + /Login.jsp @@ -53,6 +54,7 @@ /FormGestor.jsp + /RecuperarPassword.jsp @@ -60,6 +62,7 @@ /Login.jsp + /FormSeguranca.jsp @@ -79,6 +82,7 @@ /FichaUtilizador.jsp + /FormRH.jsp @@ -98,6 +102,7 @@ /FichaUtilizador.jsp + /FormHS.jsp @@ -117,6 +122,7 @@ /FichaUtilizador.jsp + /FormMedico.jsp @@ -136,6 +142,7 @@ /FichaUtilizador.jsp + /FormGestor.jsp @@ -150,7 +157,8 @@ user /FichaUtilizador.jsp - + + /FormDirGerRh.jsp @@ -170,6 +178,7 @@ /Login.jsp + /FormDirSiprp.jsp @@ -196,7 +205,12 @@ estatisticasProcesso /EstatisticasProcesso.jsp + + confirmar_desactivar + /ConfirmarDesactivar.jsp + + /AnaliseAcidenteTrabalho.jsp @@ -232,6 +246,7 @@ /Login.jsp + /LoadImage.jsp @@ -239,6 +254,7 @@ /AnaliseAcidenteTrabalho.jsp + /FichaUtilizador.jsp @@ -290,6 +306,7 @@ /Login.jsp + /ViewAnaliseAcidenteTrabalho.jsp @@ -329,6 +346,7 @@ /FormDirSiprp.jsp + /EnviarCorrecao.jsp @@ -344,6 +362,7 @@ /Login.jsp + /GestaoUtilizadores.jsp @@ -371,6 +390,7 @@ /Login.jsp + /NovoUtilizador.jsp @@ -398,6 +418,7 @@ /Login.jsp + /UtilizadorFields.jsp @@ -421,6 +442,7 @@ /Login.jsp + /Acesso.jsp @@ -470,4 +492,13 @@ + + + /ConfirmarDesactivar.jsp + + formDirSiprp + /FormDirSiprp.jsp + + +