From 4f719699e6ed7daece567643f2642f4f0434762e Mon Sep 17 00:00:00 2001
From: Diogo Neves
Date: Thu, 2 Sep 2010 13:29:05 +0000
Subject: [PATCH] git-svn-id: https://svn.coded.pt/svn/SIPRP@1459
bb69d46d-e84e-40c8-a05a-06db0d633741
---
.../AnaliseAcidenteTrabalho.java | 16 +-
.../FichaUtilizador.java | 338 +++++++++---------
.../UtilizadorFields.java | 8 +-
.../src/java/db/AnalisesDataProvider.java | 20 +-
.../src/java/db/UtilizadoresDataProvider.java | 2 +-
5 files changed, 192 insertions(+), 192 deletions(-)
diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/AnaliseAcidenteTrabalho.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/AnaliseAcidenteTrabalho.java
index ac3108b0..57ce4aa2 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/AnaliseAcidenteTrabalho.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/AnaliseAcidenteTrabalho.java
@@ -7653,12 +7653,12 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
//stDataNascimento.setText(a.getData_nascimento());
try
{
- java.util.Date ddate = new java.util.Date(a.getData_nascimento().getTime());
- stDataNascimento.setText(utils.Utils.dateToYYYYMMDD(ddate));
+ java.util.Date ddate = new java.util.Date( a.getData_nascimento().getTime() );
+ stDataNascimento.setText( utils.Utils.dateToYYYYMMDD( ddate ) );
}
catch(Exception ex)
{
- ErrorLogger.logException( ex );
+// ErrorLogger.logException( ex );
}
stBI.setText(a.getBilhete_identidade());
stMorada.setText(a.getMorada());
@@ -7691,15 +7691,17 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
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));
+ java.util.Date ddate = new java.util.Date( a.getData_admissao().getTime() );
+ stDataAdmissao1.setText( utils.Utils.dateToYYYYMMDD( ddate ) );
}
catch(Exception ex)
{
- ErrorLogger.logException( ex );
+// ErrorLogger.logException( ex );
}
+
stFuncao1.setText(a.getFuncao());
String turno_str = "";
if(a.getTurno() != null)
@@ -7744,7 +7746,7 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
if(a.getData_acidente() != null)
{
java.util.Date ddate = new java.util.Date(a.getData_acidente().getTime());
- calDataOcorrencia.setValue(ddate);
+ calDataOcorrencia.setValue( ddate );
}
Calendar cal = Calendar.getInstance();
diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FichaUtilizador.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FichaUtilizador.java
index db0efc1e..9ff89e93 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FichaUtilizador.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/FichaUtilizador.java
@@ -669,180 +669,174 @@ public class FichaUtilizador 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() {
- // 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("FichaUtilizador 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 . . .
- }
- }
- else
- {
-
- FacesContext fc = getFacesContext();
- System.out.println("REQUEST PARAMETERS : " + JSFUtils.requestHasParameters(fc));
- isFromPlanos = false;
- if(JSFUtils.requestHasParameters(fc))
- {
- isFromPlanos = true;
- String user_id = JSFUtils.getRequestParameter(fc, "user");
- String mode = JSFUtils.getRequestParameter(fc, "mode");
- if(mode != null)
- {
- if(mode.matches("edit"))
- {
- System.out.println("MODE PARAMETER : " + mode);
- getSessionBean1().setModoEdicaoUtilizador("edit");
- }
- }
-
- Utilizador u = null;
- try
- {
- Integer userId = new Integer(Integer.parseInt(user_id));
- System.out.println("USER ID FROM PLANOS : " + user_id);
- try
- {
- UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
- //udp.checkConnection();
- u = udp.getUtilizador(userId);
- getSessionBean1().setCurrentUser(u);
- }
- catch(Exception ex1)
- {
- ErrorLogger.logException( ex1 );
- }
- }
- catch(Exception ex)
- {
- ErrorLogger.logException( ex );
- }
- }
-
-
- if(
- getSessionBean1().getCurrentUser().getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_GERAL_RH
- || getSessionBean1().getCurrentUser().getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP )
- {
- lnkGerirUtilizadores.setDisabled(false);
- }
- else
- {
- lnkGerirUtilizadores.setDisabled(true);
- }
+ 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("FichaUtilizador Initialization Failure", e);
+ throw e instanceof FacesException ? (FacesException) e : new FacesException(e);
+ }
- HttpServletRequest request = (HttpServletRequest) getExternalContext().getRequest();
- String referer = request.getRequestURI();
- String pageFrom = Utils.getPageFrom(referer);
- if(isFromPlanos)
- {
- isPostData = false;
- }
- else
- {
- if(pageFrom.matches("FichaUtilizador.jsp"))
- {
- isPostData = true;
- System.out.println("IS POSTDATA : " + isPostData);
- }
- }
-
- if(!isPostData)
- {
-
-
- lblUser.setText( getSessionBean1().getCurrentUser().getLogin() );
- UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
-
- AnalisesDataProvider adp = new AnalisesDataProvider();
- try
- {
- Integer permissao = udp.getPermissionCode( getSessionBean1().getCurrentUser().getId() );
- getSessionBean1().setTiposOptions(adp.getTiposList(permissao));
- drpTipo.setSelected(new Integer(0));
- }
- catch(Exception ex)
- {
- ErrorLogger.logException( ex );
- }
-
- try
- {
- getSessionBean1().setEstabelecimentosOptions(adp.getEstabelecimentosList( getSessionBean1().getCurrentUser().getEmpresa_id(), new Boolean(false) ));
- System.out.println("ESTABELECIMENTOS OPTIONS : " + getSessionBean1().getEstabelecimentosOptions().length);
- drpEstabelecimentos.setSelected(new Integer(-1));
- }
- catch(Exception ex)
- {
- ErrorLogger.logException( ex );
- }
-
- }
- else //postData
- {
- String del_user = (String)getExternalContext().getRequestParameterMap().get("del_user");
- if(del_user != null)
- {
- if(del_user.matches("yes"))
- {
- hidConfDelUser.setValue("");
- try
- {
- deleteUser();
- }
- catch(Exception ex)
- {
- ErrorLogger.logException( ex );
- getSessionBean1().setMsg("Erro na eliminação do utilizador!");
- }
-
- //force a page reload
- // try
- // {
- // getExternalContext().redirect("FichaUtilizador.jsp");
- // System.out.println("REDIRECT");
- // }
- // catch(Exception ex)
- // {
- // ErrorLogger.logException( ex );
- // }
-
- }
- else if(del_user.matches("no"))
- {
- hidConfDelUser.setValue("");
- showUser();
- }
- }
-
- }
-
- }
-
+ //
+ // 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 . . .
+ }
+ }
+ else
+ {
+ FacesContext fc = getFacesContext();
+ System.out.println( "REQUEST PARAMETERS : " + JSFUtils.requestHasParameters( fc ) );
+ isFromPlanos = false;
+
+ if ( JSFUtils.requestHasParameters( fc ) )
+ {
+ isFromPlanos = true;
+ String user_id = JSFUtils.getRequestParameter(fc, "user");
+ String mode = JSFUtils.getRequestParameter(fc, "mode");
+ if (mode != null)
+ {
+ if (mode.matches("edit"))
+ {
+ System.out.println("MODE PARAMETER : " + mode);
+ getSessionBean1().setModoEdicaoUtilizador("edit");
+ }
+ }
+
+ Utilizador u = null;
+ if (user_id != null )
+ {
+ try
+ {
+ Integer userId = new Integer( Integer.parseInt( user_id ) );
+ System.out.println( "USER ID FROM PLANOS : " + user_id );
+
+ UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
+ //udp.checkConnection();
+ u = udp.getUtilizador( userId );
+ getSessionBean1().setCurrentUser( u );
+ }
+ catch ( Exception ex )
+ {
+ ErrorLogger.logException( ex );
+ }
+ }
+ }
+
+ if ( getSessionBean1().getCurrentUser().getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_GERAL_RH
+ || getSessionBean1().getCurrentUser().getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP )
+ {
+ lnkGerirUtilizadores.setDisabled( false );
+ }
+ else
+ {
+ lnkGerirUtilizadores.setDisabled( true );
+ }
+
+ HttpServletRequest request = (HttpServletRequest) getExternalContext().getRequest();
+ String referer = request.getRequestURI();
+ String pageFrom = Utils.getPageFrom(referer);
+ if ( isFromPlanos )
+ {
+ isPostData = false;
+ }
+ else
+ {
+ if ( pageFrom.matches( "FichaUtilizador.jsp" ) )
+ {
+ isPostData = true;
+ System.out.println( "IS POSTDATA : " + isPostData );
+ }
+ }
+
+ if ( ! isPostData )
+ {
+ lblUser.setText(getSessionBean1().getCurrentUser().getLogin());
+ UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
+
+ AnalisesDataProvider adp = new AnalisesDataProvider();
+ try
+ {
+ Integer permissao = udp.getPermissionCode( getSessionBean1().getCurrentUser().getId() );
+ getSessionBean1().setTiposOptions( adp.getTiposList( permissao ) );
+ drpTipo.setSelected( new Integer( 0 ) );
+ }
+ catch ( Exception ex )
+ {
+ ErrorLogger.logException( ex );
+ }
+
+ try
+ {
+ getSessionBean1().setEstabelecimentosOptions(adp.getEstabelecimentosList(getSessionBean1().getCurrentUser().getEmpresa_id(), new Boolean(false)));
+ System.out.println("ESTABELECIMENTOS OPTIONS : " + getSessionBean1().getEstabelecimentosOptions().length);
+ drpEstabelecimentos.setSelected(new Integer(-1));
+ }
+ catch (Exception ex)
+ {
+ ErrorLogger.logException(ex);
+ }
+ }
+ else //postData
+ {
+ String del_user = (String) getExternalContext().getRequestParameterMap().get("del_user");
+ if (del_user != null)
+ {
+ if (del_user.matches("yes"))
+ {
+ hidConfDelUser.setValue("");
+ try
+ {
+ deleteUser();
+ }
+ catch ( Exception ex )
+ {
+ ErrorLogger.logException( ex );
+ getSessionBean1().setMsg("Erro na eliminação do utilizador!");
+ }
+
+ //force a page reload
+ // try
+ // {
+ // getExternalContext().redirect("FichaUtilizador.jsp");
+ // System.out.println("REDIRECT");
+ // }
+ // catch(Exception ex)
+ // {
+ // ErrorLogger.logException( ex );
+ // }
+
+ }
+ else if ( del_user.matches( "no" ) )
+ {
+ hidConfDelUser.setValue("");
+ showUser();
+ }
+ }
+
+ }
-
- }
+ }
+ }
/**
* Callback method that is called after the component tree has been
diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/UtilizadorFields.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/UtilizadorFields.java
index fe81744c..583e87c3 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/UtilizadorFields.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/UtilizadorFields.java
@@ -1148,14 +1148,14 @@ public class UtilizadorFields extends AbstractPageBean {
}
else
{
- UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
try
{
- Utilizador u = udp.getUtilizador(login);
- if(u.getLogin().equals(login))
+ UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
+ Utilizador u = udp.getUtilizador( login );
+ if ( u != null && login.equals( u.getLogin() ) )
{
getSessionBean1().setMsg("O utilizador " + login + " já existe!");
- return false;
+ return false;
}
}
catch(Exception ex)
diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/db/AnalisesDataProvider.java b/trunk/AnaliseAcidentesTrabalho/src/java/db/AnalisesDataProvider.java
index f271d23f..1837cc60 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/java/db/AnalisesDataProvider.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/java/db/AnalisesDataProvider.java
@@ -1631,17 +1631,21 @@ public class AnalisesDataProvider {
- public String getEstabelecimentoNome(Integer estabelecimento_id) throws Exception
+ public String getEstabelecimentoNome( Integer estabelecimento_id ) throws Exception
{
Dblocal dblocal = new Dblocal();
dblocal.connect();
- Statement stlocal = dblocal.createStatement();
- String sql ="SELECT nome FROM estabelecimentos WHERE id = " + estabelecimento_id;
- ResultSet rslocal = stlocal.executeQuery(sql);
- rslocal.first();
- String nome = rslocal.getString("nome");
- dblocal.close();
- return Utils.unicodeToHTML(nome);
+ Statement stlocal = dblocal.createStatement();
+ String sql = "SELECT nome FROM estabelecimentos WHERE id = " + estabelecimento_id;
+ ResultSet rslocal = stlocal.executeQuery( sql );
+
+ String nome = "";
+ if ( rslocal.first() )
+ {
+ nome = rslocal.getString( "nome" );
+ dblocal.close();
+ }
+ return Utils.unicodeToHTML( nome );
}
public String getMedicoNome(Integer medico_id) throws Exception
diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/db/UtilizadoresDataProvider.java b/trunk/AnaliseAcidentesTrabalho/src/java/db/UtilizadoresDataProvider.java
index fc99268b..29998c17 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/java/db/UtilizadoresDataProvider.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/java/db/UtilizadoresDataProvider.java
@@ -117,7 +117,7 @@ public class UtilizadoresDataProvider {
public Utilizador getUtilizador(String login) throws Exception
{
- Utilizador u = new Utilizador();
+ Utilizador u = new Utilizador();
Statement st = createStatement();
String sql = "SELECT * FROM utilizadores WHERE LOWER(login) = '" + login.toLowerCase() + "' AND apagado = 'n'";
ResultSet rs = st.executeQuery(sql);