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; private String Pass = null;
//tests //tests
// private String server = "localhost"; // private String server = "evoserver";
// private int port = 5432; // private int port = 5432;
// private String db_name = "siprp"; // private String db_name = "siprp_20100813";
// private String User = "postgres"; // private String User = "postgres";
// private String Pass = null; // private String Pass = null;
private String connectionURL = "jdbc:postgresql://" + server + ":" + port + "/" + db_name; private String connectionURL = "jdbc:postgresql://" + server + ":" + port + "/" + db_name;

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

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

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

@ -15,7 +15,22 @@ import java.util.ArrayList;
* *
* @author lluis * @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 public Utilizador getUtilizador( Integer id ) throws Exception
{ {

@ -36,14 +36,20 @@ public class Global {
public static final String FASE_DNS_PARECER_TXT = "DNS(Parecer)"; 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://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 = "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 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 PLANOS_ACTUACAO_URL = "https://www.siprp.pt/PlanosActuacao/faces/";
public static final String LOGOS_FOLDER = "/resources/images"; public static final String LOGOS_FOLDER = "/resources/images";
public static final String PDF_FOLDER_URL = "/resources/pdf"; public static final String PDF_FOLDER_URL = "/resources/pdf";
} }

@ -393,85 +393,156 @@ public class ListaPlanos extends AbstractPageBean {
* this page.</p> * this page.</p>
*/ */
@Override @Override
public void prerender() { public void prerender()
{
//UIComponent emptyCol = tableRowGroup1.getEmptyDataText(); //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(); FacesContext fc = getFacesContext();
String user_id = JSFUtils.getRequestParameter(fc, "user"); String estab_gestor = JSFUtils.getRequestParameter( fc, "estab_gestor" );
String estab_gestor = JSFUtils.getRequestParameter(fc, "estab_gestor");
System.out.println("LISTA PLANOS - USER ID : " + user_id );
Utilizador u = null; // String user_id = JSFUtils.getRequestParameter( fc, "user" );
if ( user_id != null ) // System.out.println("LISTA PLANOS - USER ID : " + user_id + " : " + u );
// 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 ) ); try
{
UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); Integer estabelecimento_gestor = new Integer(Integer.parseInt(estab_gestor));
udp.checkConnection(); System.out.println("ESTABELECIMENTO GESTOR : " + estabelecimento_gestor.intValue());
u.setEstabelecimento_gestor(estabelecimento_gestor);
} catch (Exception ex2)
{
ErrorLogger.logException(ex2);
}
}
u = udp.getUtilizador( userId ); // getSessionBean1().setCurrentUser( u );
if ( u != null ) // u = getSessionBean1().getCurrentUser();
{
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 );
}
} 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 ); if (u.getTipo().intValue() != Global.DIRECTOR_SIPRP && u.getTipo().intValue() != Global.RH && u.getTipo().intValue() != Global.DIRECTOR_GERAL_RH) {
getSessionBean1().setDisableMenuUtilizadores(true);
u = getSessionBean1().getCurrentUser(); tableRowGroup1.setEmptyDataMsg("Sem registos");
if(u.getTipo().intValue() == Global.DIRECTOR_SIPRP || u.getTipo().intValue() == Global.RH || u.getTipo().intValue() == Global.DIRECTOR_GERAL_RH || u.getTipo().intValue() == Global.GESTOR) tableRowGroup2.setEmptyDataMsg("Sem registos");
{ tableRowGroup3.setEmptyDataMsg("Sem registos");
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 );
} }
//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.Button;
import com.sun.webui.jsf.component.PasswordField; import com.sun.webui.jsf.component.PasswordField;
import com.sun.webui.jsf.component.TextField; import com.sun.webui.jsf.component.TextField;
import db.entidades.Utilizador;
import db.providers.UtilizadoresDataProvider;
import java.sql.Connection; import java.sql.Connection;
import javax.faces.FacesException; import javax.faces.FacesException;
import utils.Utils;
/** /**
* <p>Page bean that corresponds to a similarly named JSP page. This * <p>Page bean that corresponds to a similarly named JSP page. This
@ -196,10 +199,71 @@ public class Login extends AbstractPageBean {
return null; return null;
} }
public String butLogin_action() { public String butLogin_action()
// TODO: Process the action. Return value is a navigation {
// case name where null will return to the same page. String sRet = null;
return "lista_planos";
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().getExpressionFactory().createValueExpression(facesContext.getELContext(), "#{requestScope}", Map.class).getValue(facesContext.getELContext());
//Map requestScope = (Map)facesContext.getApplication().createValueBinding(?#{requestScope}?).getValue(facesContext); //Map requestScope = (Map)facesContext.getApplication().createValueBinding(?#{requestScope}?).getValue(facesContext);
boolean ispostback = ((Boolean)requestScope.get("ispostback")).booleanValue(); boolean ispostback = ((Boolean)requestScope.get("ispostback")).booleanValue();
System.out.println("POSTBACK A : " + ispostback); System.out.println("JSFUtils . isPostback() : " + ispostback );
return ispostback; return ispostback;
} }

@ -6,6 +6,8 @@
package utils; package utils;
import com.evolute.utils.Singleton; 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() public static void doLogout()
{ {
Singleton.setInstance( Singleton.USERNAME, null ); Singleton.setInstance( Singleton.USERNAME, null );

Loading…
Cancel
Save