git-svn-id: https://svn.coded.pt/svn/SIPRP@1527 bb69d46d-e84e-40c8-a05a-06db0d633741

lxbfYeaa
Diogo Neves 15 years ago
parent c0c4aed110
commit c8707a8a21

@ -27,11 +27,11 @@ public class Db
private String Pass = null;
//tests
// private String server = "localhost";
// private String server = "evoserver";
// private int port = 5432;
// private String db_name = "siprp";
// private String db_name = "siprp_20100813";
// private String User = "postgres";
// private String Pass = null;
// private String Pass = null;
private String connectionURL = "jdbc:postgresql://" + server + ":" + port + "/" + db_name;

@ -25,9 +25,9 @@ public class DbRelatorios
private String Pass = null;
//tests
// private String server = "localhost";
// private String server = "evoserver";
// private int port = 5432;
// private String db_name = "siprp";
// private String db_name = "siprp_20100813";
// private String User = "postgres";
// private String Pass = null;

@ -9,11 +9,9 @@
package db;
import com.evolute.application.initializer.DefaultDatabaseInitializer;
import com.evolute.entity.ProviderRegistry;
import com.evolute.entity.evo.EvoDataProviderFactory;
import com.evolute.entity.utils.ConnectionIdentity;
import com.evolute.utils.Singleton;
import com.evolute.utils.db.DBManager;
import com.evolute.utils.db.JDBCManager;
import com.evolute.utils.db.keyretrievers.PostgresqlAutoKeyRetriever;
@ -35,15 +33,20 @@ import javax.servlet.http.HttpSession;
*/
public class Dblocal
{
String server = "localhost";
String port = "5436";
String database = "siprp_local_3";
String User = "postgres";
String Pass = null;
// String server = "localhost";
// String port = "5432";
// String database = "siprp_local";
//production
private String server = "localhost";
private String port = "5436";
private String database = "siprp_local_3";
private String User = "postgres";
private String Pass = null;
//tests
// private String server = "evoserver";
// private String port = "5432";
// private String database = "siprp_local_3_20100813";
// private String User = "postgres";
// private String Pass = null;
String connectionURL = "jdbc:postgresql://" + server + ":" + port + "/" + database;

@ -27,9 +27,9 @@ public class DblocalRelatorios
private String Pass = null;
//tests
// private String server = "localhost";
// private String server = "evoserver";
// private int port = 5432;
// private String db_name = "siprp_local";
// private String db_name = "siprp_local_3_20100813";
// private String User = "postgres";
// private String Pass = null;

@ -15,8 +15,23 @@ import java.util.ArrayList;
*
* @author lluis
*/
public class UtilizadoresDataProvider extends GenericDataProvider{
public class UtilizadoresDataProvider extends GenericDataProvider
{
public Utilizador getUtilizador( String login ) throws Exception
{
Utilizador u = null;
Statement st = createStatement();
String sql = "SELECT id FROM utilizadores WHERE LOWER(login) = '" + login.toLowerCase() + "' AND apagado = 'n'";
ResultSet rs = st.executeQuery(sql);
if ( rs.first() )
{
Integer userID = rs.getInt( "id" );
u = getUtilizador( userID );
}
return u;
}
public Utilizador getUtilizador( Integer id ) throws Exception
{
Utilizador u = null;

@ -13,18 +13,18 @@ public class Global {
//tipos utilizadores
public static final int RESPONSAVEL_SEGURANCA = 1;
public static final int RH = 2;
public static final int TECNICO_HS = 3;
public static final int GESTOR = 6;
public static final int DIRECTOR_GERAL_RH = 7;
public static final int DIRECTOR_SIPRP = 8;
public static final int DIRECTOR_LOJA = 9;
public static final int DIRECTOR_NACIONAL_SEGURANCA = 10;
public static final int RH = 2;
public static final int TECNICO_HS = 3;
public static final int GESTOR = 6;
public static final int DIRECTOR_GERAL_RH = 7;
public static final int DIRECTOR_SIPRP = 8;
public static final int DIRECTOR_LOJA = 9;
public static final int DIRECTOR_NACIONAL_SEGURANCA = 10;
//Fases do plano
public static final int FASE_SIPRP_EMISSAO = 1;
public static final int FASE_SEGURANCA_PREENCHIMENTO = 2;
public static final int FASE_DIR_LOJA_VALIDACAO = 3;
public static final int FASE_SEGURANCA_PREENCHIMENTO = 2;
public static final int FASE_DIR_LOJA_VALIDACAO = 3;
public static final int FASE_DNS_PARECER = 4;
public static final int FASE_SIPRP_CONCLUSAO = 5;
public static final int FASE_CONCLUIDO = 6;
@ -32,18 +32,24 @@ public class Global {
//Fases do plano - texto
public static final String FASE_SIPRP_EMISSAO_TXT = "SIPRP(Emissão)";
public static final String FASE_SEGURANCA_PREENCHIMENTO_TXT = "Segurança Auchan(Preenchimento)";
public static final String FASE_DIR_LOJA_VALIDACAO_TXT = "Director de loja(Validação)";
public static final String FASE_DIR_LOJA_VALIDACAO_TXT = "Director de loja(Validação)";
public static final String FASE_DNS_PARECER_TXT = "DNS(Parecer)";
public static final String FASE_SIPRP_CONCLUSAO_TXT = "SIPRP(Verificação/Conclusão)";
public static final String FASE_SIPRP_CONCLUSAO_TXT = "SIPRP(Verificação/Conclusão)";
public static final String[] FASES_TEXTO = new String[]{"SIPRP(Emissão)", "Segurança Auchan(Preenchimento)", "Director de loja(Validação)", "DNS(Parecer)", "SIPRP(Verificação/Conclusão)", "Concluído"};
public static final String[] FASES_TEXTO = new String[] {
"SIPRP(Emissão)",
"Segurança Auchan(Preenchimento)",
"Director de loja(Validação)",
"DNS(Parecer)",
"SIPRP(Verificação/Conclusão)",
"Concluído"
};
//public static final String ANALISE_ACIDENTES_URL = "http://localhost:8084/AnaliseAcidentesTrabalho/faces/"; //testes
//public static final String ANALISE_ACIDENTES_URL = "http://192.168.111.24:8084/AnaliseAcidentesTrabalho/faces/"; //testes portatil
public static final String ANALISE_ACIDENTES_URL = "https://www.siprp.pt/AnaliseAcidentesTrabalho/faces/"; //real
public static final String PLANOS_ACTUACAO_URL = "https://www.siprp.pt/PlanosActuacao/faces/";
public static final String LOGOS_FOLDER = "/resources/images";
public static final String PDF_FOLDER_URL = "/resources/pdf";
public static final String LOGOS_FOLDER = "/resources/images";
public static final String PDF_FOLDER_URL = "/resources/pdf";
}

@ -393,84 +393,155 @@ public class ListaPlanos extends AbstractPageBean {
* this page.</p>
*/
@Override
public void prerender() {
public void prerender()
{
//UIComponent emptyCol = tableRowGroup1.getEmptyDataText();
System.out.println("LISTA PLANOS - PRERENDER");
System.out.println("LISTA PLANOS - PRERENDER");
Utilizador u = getSessionBean1().getCurrentUser();
System.out.println( "\tUser Logged In : " + u );
FacesContext fc = getFacesContext();
String user_id = JSFUtils.getRequestParameter(fc, "user");
String estab_gestor = JSFUtils.getRequestParameter(fc, "estab_gestor");
System.out.println("LISTA PLANOS - USER ID : " + user_id );
String estab_gestor = JSFUtils.getRequestParameter( fc, "estab_gestor" );
// String user_id = JSFUtils.getRequestParameter( fc, "user" );
// System.out.println("LISTA PLANOS - USER ID : " + user_id + " : " + u );
Utilizador u = null;
if ( user_id != null )
// if ( u == null )
// {
// Integer userId = new Integer( Integer.parseInt( user_id ) );
// UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
// udp.checkConnection();
// u = udp.getUtilizador( userId );
// }
if ( u != null )
{
try
if ( u.getTipo() != null && u.getTipo().intValue() == Global.GESTOR )
{
Integer userId = new Integer( Integer.parseInt( user_id ) );
UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
udp.checkConnection();
try
{
Integer estabelecimento_gestor = new Integer(Integer.parseInt(estab_gestor));
System.out.println("ESTABELECIMENTO GESTOR : " + estabelecimento_gestor.intValue());
u.setEstabelecimento_gestor(estabelecimento_gestor);
} catch (Exception ex2)
{
ErrorLogger.logException(ex2);
}
}
u = udp.getUtilizador( userId );
if ( u != null )
{
if ( u.getTipo().intValue() == Global.GESTOR )
{
try
{
Integer estabelecimento_gestor = new Integer(Integer.parseInt(estab_gestor));
System.out.println("ESTABELECIMENTO GESTOR : " + estabelecimento_gestor.intValue());
u.setEstabelecimento_gestor(estabelecimento_gestor);
}
catch(Exception ex2)
{
ErrorLogger.logException( ex2 );
}
// getSessionBean1().setCurrentUser( u );
// u = getSessionBean1().getCurrentUser();
}
if (u.getTipo().intValue() == Global.DIRECTOR_SIPRP || u.getTipo().intValue() == Global.RH || u.getTipo().intValue() == Global.DIRECTOR_GERAL_RH || u.getTipo().intValue() == Global.GESTOR) {
gridActual.setRendered(false);
tableRowGroup2.setEmptyDataMsg("Sem registos");
tableRowGroup3.setEmptyDataMsg("Sem registos");
}
getSessionBean1().setCurrentUser( u );
u = getSessionBean1().getCurrentUser();
if(u.getTipo().intValue() == Global.DIRECTOR_SIPRP || u.getTipo().intValue() == Global.RH || u.getTipo().intValue() == Global.DIRECTOR_GERAL_RH || u.getTipo().intValue() == Global.GESTOR)
{
gridActual.setRendered(false);
tableRowGroup2.setEmptyDataMsg("Sem registos");
tableRowGroup3.setEmptyDataMsg("Sem registos");
}
if(u.getTipo().intValue() != Global.DIRECTOR_SIPRP && u.getTipo().intValue() != Global.RH && u.getTipo().intValue() != Global.DIRECTOR_GERAL_RH)
{
getSessionBean1().setDisableMenuUtilizadores(true);
tableRowGroup1.setEmptyDataMsg("Sem registos");
tableRowGroup2.setEmptyDataMsg("Sem registos");
tableRowGroup3.setEmptyDataMsg("Sem registos");
}
//Column para desactivar plano - mostra se o utilizador for DIRECTOR SIPRP
int uType = u.getTipo().intValue();
boolean renderOrNot = uType == Global.DIRECTOR_SIPRP || uType == Global.TECNICO_HS;
tableColumn55.setRendered( renderOrNot );
buttonDesactivar.setRendered( renderOrNot );
tableColumn56.setRendered( renderOrNot );
buttonDesactivarSeguimento.setRendered( renderOrNot );
initialize();
}
else
{
getSessionBean1().setMsg( "Utilizador inv&aacute;lido." );
}
}
catch(Exception ex)
{
ErrorLogger.logException( ex );
if (u.getTipo().intValue() != Global.DIRECTOR_SIPRP && u.getTipo().intValue() != Global.RH && u.getTipo().intValue() != Global.DIRECTOR_GERAL_RH) {
getSessionBean1().setDisableMenuUtilizadores(true);
tableRowGroup1.setEmptyDataMsg("Sem registos");
tableRowGroup2.setEmptyDataMsg("Sem registos");
tableRowGroup3.setEmptyDataMsg("Sem registos");
}
}
//Column para desactivar plano - mostra se o utilizador for DIRECTOR SIPRP
int uType = u.getTipo().intValue();
boolean renderOrNot = uType == Global.DIRECTOR_SIPRP || uType == Global.TECNICO_HS;
tableColumn55.setRendered(renderOrNot);
buttonDesactivar.setRendered(renderOrNot);
tableColumn56.setRendered(renderOrNot);
buttonDesactivarSeguimento.setRendered(renderOrNot);
initialize();
}
else
{
getSessionBean1().setMsg("Utilizador inv&aacute;lido.");
}
//UIComponent emptyCol = tableRowGroup1.getEmptyDataText();
// System.out.println("LISTA PLANOS - PRERENDER");
//
// System.out.println( "\n\tCURRENT USER : " + getSessionBean1().getCurrentUser() + " - " +
// ( getSessionBean1().getCurrentUser() == null ? "" :
// getSessionBean1().getCurrentUser().getId() + " : " + getSessionBean1().getCurrentUser().getLogin() ) );
//
// FacesContext fc = getFacesContext();
// String user_id = JSFUtils.getRequestParameter(fc, "user");
// String estab_gestor = JSFUtils.getRequestParameter(fc, "estab_gestor");
// System.out.println("LISTA PLANOS - USER ID ( From Request ) : " + user_id );
//
// Utilizador u = null;
// if ( user_id != null )
// {
// try
// {
// Integer userId = new Integer( Integer.parseInt( user_id ) );
//
// UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
// udp.checkConnection();
//
// u = udp.getUtilizador( userId );
// if ( u != null )
// {
// if ( u.getTipo().intValue() == Global.GESTOR )
// {
// try
// {
// Integer estabelecimento_gestor = new Integer(Integer.parseInt(estab_gestor));
// System.out.println("ESTABELECIMENTO GESTOR : " + estabelecimento_gestor.intValue());
// u.setEstabelecimento_gestor(estabelecimento_gestor);
// }
// catch(Exception ex2)
// {
// ErrorLogger.logException( ex2 );
// }
//
// }
//
// getSessionBean1().setCurrentUser( u );
//
// u = getSessionBean1().getCurrentUser();
// if(u.getTipo().intValue() == Global.DIRECTOR_SIPRP || u.getTipo().intValue() == Global.RH || u.getTipo().intValue() == Global.DIRECTOR_GERAL_RH || u.getTipo().intValue() == Global.GESTOR)
// {
// gridActual.setRendered(false);
// tableRowGroup2.setEmptyDataMsg("Sem registos");
// tableRowGroup3.setEmptyDataMsg("Sem registos");
// }
//
// if(u.getTipo().intValue() != Global.DIRECTOR_SIPRP && u.getTipo().intValue() != Global.RH && u.getTipo().intValue() != Global.DIRECTOR_GERAL_RH)
// {
// getSessionBean1().setDisableMenuUtilizadores(true);
// tableRowGroup1.setEmptyDataMsg("Sem registos");
// tableRowGroup2.setEmptyDataMsg("Sem registos");
// tableRowGroup3.setEmptyDataMsg("Sem registos");
// }
//
// //Column para desactivar plano - mostra se o utilizador for DIRECTOR SIPRP
// int uType = u.getTipo().intValue();
// boolean renderOrNot = uType == Global.DIRECTOR_SIPRP || uType == Global.TECNICO_HS;
// tableColumn55.setRendered( renderOrNot );
// buttonDesactivar.setRendered( renderOrNot );
// tableColumn56.setRendered( renderOrNot );
// buttonDesactivarSeguimento.setRendered( renderOrNot );
//
// initialize();
// }
// else
// {
// getSessionBean1().setMsg( "Utilizador inv&aacute;lido." );
// }
// }
// catch(Exception ex)
// {
// ErrorLogger.logException( ex );
// }
// }
}

@ -11,8 +11,11 @@ import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Button;
import com.sun.webui.jsf.component.PasswordField;
import com.sun.webui.jsf.component.TextField;
import db.entidades.Utilizador;
import db.providers.UtilizadoresDataProvider;
import java.sql.Connection;
import javax.faces.FacesException;
import utils.Utils;
/**
* <p>Page bean that corresponds to a similarly named JSP page. This
@ -196,10 +199,71 @@ public class Login extends AbstractPageBean {
return null;
}
public String butLogin_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
return "lista_planos";
public String butLogin_action()
{
String sRet = null;
UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
if(txtUtilizador.getText() != null)
{
String utilizador = (String) txtUtilizador.getText();
if(utilizador.trim().length() > 0)
{
if(txtPassword.getText() != null)
{
String password = (String) txtPassword.getText();
if( password.trim().length() > 0 )
{
try
{
Utilizador u = udp.getUtilizador( utilizador );
if( u != null && "y".equals( u.getActivo() ) )
{
if ( ! password.equals( u.getPassword() ) )
{
getSessionBean1().setMsg( "Palavra-chave inv&aacute;lida !" );
}
else
{
Utils.doLogin( u );
getSessionBean1().setCurrentUser( u );
getSessionBean1().setLoggedIn( true );
sRet = "lista_planos";
}
}
else
{
getSessionBean1().setMsg("Utilizador inv&aacute;lido ! ");
}
}
catch(Exception ex)
{
ErrorLogger.logException( ex );
getSessionBean1().setMsg("Utilizador inv&aacute;lido ! ");
}
}
else
{
getSessionBean1().setMsg("Falta palavra-chave !");
}
}
else
{
getSessionBean1().setMsg("Falta palavra-chave !");
}
}
else
{
getSessionBean1().setMsg("Falta utilizador !");
}
}
else
{
getSessionBean1().setMsg("Falta utilizador !");
}
return sRet;
}
}

@ -63,7 +63,7 @@ public class JSFUtils {
Map requestScope = (Map) facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), "#{requestScope}", Map.class).getValue(facesContext.getELContext());
//Map requestScope = (Map)facesContext.getApplication().createValueBinding(?#{requestScope}?).getValue(facesContext);
boolean ispostback = ((Boolean)requestScope.get("ispostback")).booleanValue();
System.out.println("POSTBACK A : " + ispostback);
System.out.println("JSFUtils . isPostback() : " + ispostback );
return ispostback;
}

@ -6,6 +6,8 @@
package utils;
import com.evolute.utils.Singleton;
import com.evolute.utils.error.ErrorLogger;
import db.entidades.Utilizador;
/**
*
@ -83,6 +85,18 @@ public class Utils {
}
public static void doLogin( Utilizador u )
{
if ( u != null )
{
Singleton.setInstance( Singleton.USERNAME, u.getLogin() );
}
else
{
ErrorLogger.logException( new Exception( "Utils.doLogin() : Utilizador is null !" ) );
}
}
public static void doLogout()
{
Singleton.setInstance( Singleton.USERNAME, null );

Loading…
Cancel
Save