@ -136,24 +136,28 @@ public class UtilizadoresDataProvider extends GenericDataProvider
throws Exception
throws Exception
{
{
List < Utilizador > list = new LinkedList < Utilizador > ( ) ;
List < Utilizador > list = new LinkedList < Utilizador > ( ) ;
int type = tipo . intValue ( ) ;
int type = tipo . intValue ( ) ;
Expression where = new Field ( UtilizadoresData . ACTIVO_FULL ) . isEqual ( "y" ) . and (
Expression where = new Field ( UtilizadoresData . ACTIVO_FULL ) . isEqual ( "y" ) ;
new Field ( UtilizadoresData . APAGADO_FULL ) . isEqual ( "n" ) ) . and (
where = where . and ( new Field ( UtilizadoresData . APAGADO_FULL ) . isEqual ( "n" ) ) ;
new Field ( UtilizadoresData . ESTABELECIMENTO_ID_FULL ) . isEqual ( estabelecimento_id )
where = where . and ( new Field ( UtilizadoresData . TIPO_FULL ) . isEqual ( type ) ) ;
) ;
if ( type = = Global . RESPONSAVEL_SEGURANCA | | type = = Global . DIRECTOR_LOJA )
{
where = where . and ( new Field ( UtilizadoresData . ESTABELECIMENTO_ID_FULL ) . isEqual ( estabelecimento_id ) ) ;
}
if ( type = = Global . RESPONSAVEL_SEGURANCA & & "y" . equals ( responsavel_loja ) )
if ( type = = Global . RESPONSAVEL_SEGURANCA & & "y" . equals ( responsavel_loja ) )
{
{
where = where . and ( new Field ( UtilizadoresData . RESPONSAVEL_LOJA_FULL ) . isEqual ( "y" ) ) ;
where = where . and ( new Field ( UtilizadoresData . RESPONSAVEL_LOJA_FULL ) . isEqual ( "y" ) ) ;
}
}
if ( type = = Global . DIRECTOR_LOJA | | type = = Global . RESPONSAVEL_SEGURANCA | | type = = Global . DIRECTOR_NACIONAL_SEGURANCA | | type = = Global . TECNICO_HS )
if ( type = = Global . DIRECTOR_LOJA | | type = = Global . TECNICO_HS | | type = = Global . DIRECTOR_NACIONAL_SEGURANCA
| | ( type = = Global . RESPONSAVEL_SEGURANCA & & "y" . equals ( responsavel_loja ) ) )
{
{
System . out . println ( "UtilizadoresDataProvider . getUtilizadoresListByTipo() : " + where . toString ( ) ) ;
System . out . println ( "\nUtilizadoresDataProvider . getUtilizadoresListByTipo( " + tipo + ", " + responsavel_loja + ", " + estabelecimento_id + " ) : " ) ;
System . out . println ( "\tSQL : SELECT * FROM utilizadores WHERE " + where . toString ( ) ) ;
List < UtilizadoresData > listData = getProvider ( ) . listLoad ( UtilizadoresData . class , where , new String [ ] { UtilizadoresData . NOME } , null ) ;
List < UtilizadoresData > listData = getProvider ( ) . listLoad (
UtilizadoresData . class , where , new String [ ] { UtilizadoresData . NOME } , null ) ;
for ( UtilizadoresData userData : listData )
for ( UtilizadoresData userData : listData )
{
{
list . add ( copyFrom ( userData ) ) ;
list . add ( copyFrom ( userData ) ) ;
@ -161,50 +165,50 @@ public class UtilizadoresDataProvider extends GenericDataProvider
}
}
// Statement st = createStatement();
// String sql = "";
// String sql = "";
// String estabelecimento_constraint = "";
// String estabelecimento_constraint = "";
// if (tipo.intValue() == Global.DIRECTOR_LOJA || tipo.intValue() == Global.RESPONSAVEL_SEGURANCA || tipo.intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA )
// if ( type == Global.DIRECTOR_LOJA || type == Global.RESPONSAVEL_SEGURANCA || type == Global.DIRECTOR_NACIONAL_SEGURANCA )
// {
// {
// estabelecimento_constraint = " AND estabelecimento_id = " + estabelecimento_id;
// estabelecimento_constraint = " AND estabelecimento_id = " + estabelecimento_id;
// }
// }
// if (tipo.intValue() == Global.RESPONSAVEL_SEGURANCA && responsavel_loja.matches("y"))
// if ( type == Global.RESPONSAVEL_SEGURANCA && responsavel_loja.matches( "y" ) )
// {
// {
// sql = "SELECT * FROM utilizadores WHERE activo = 'y' AND apagado = 'n' AND responsavel_loja = 'y' AND tipo = " + tipo + estabelecimento_constraint;
// sql = "SELECT * FROM utilizadores WHERE activo = 'y' AND apagado = 'n' AND tipo = " + tipo + estabelecimento_constraint + " AND responsavel_loja = 'y'" ;
// }
// }
// else if (tipo.intValue() == Global.DIRECTOR_LOJA || tipo.intValue() == Global.TECNICO_HS || tipo.intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA )
// else if ( type == Global.DIRECTOR_LOJA || type == Global.TECNICO_HS || type == Global.DIRECTOR_NACIONAL_SEGURANCA )
// {
// {
// sql = "SELECT * FROM utilizadores WHERE activo = 'y' AND apagado = 'n' AND tipo = " + tipo + estabelecimento_constraint;
// sql = "SELECT * FROM utilizadores WHERE activo = 'y' AND apagado = 'n' AND tipo = " + tipo + estabelecimento_constraint;
// }
// }
//
//
// System.out.println("UTILIZADORES LIST BY TIPO SQL : " + sql);
// System.out.println( "UTILIZADORES LIST BY TIPO SQL : " + sql );
// ResultSet rs = st.executeQuery(sql);
// Statement st = createStatement();
// if(rs.isBeforeFirst())
// ResultSet rs = st.executeQuery( sql );
// {
// if ( rs.isBeforeFirst() )
// rs.first();
// {
// do
// rs.first();
// {
// do
// Utilizador u = new Utilizador();
// {
// u.setId(new Integer(rs.getInt("id")));
// Utilizador u = new Utilizador();
// u.setLogin(rs.getString("login"));
// u.setId( new Integer( rs.getInt( "id" ) ) );
// u.setPassword(rs.getString("password"));
// u.setLogin( rs.getString( "login" ) );
// u.setData_password(rs.getDate("data_password"));
// u.setPassword( rs.getString( "password" ) );
// u.setEmail(rs.getString("email"));
// u.setData_password( rs.getDate( "data_password" ) );
// u.setEmpresa_id(new Integer(rs.getInt("empresa_id")));
// u.setEmail( rs.getString( "email" ) );
// u.setEstabelecimento_id(new Integer(rs.getInt("estabelecimento_id")));
// u.setEmpresa_id( new Integer( rs.getInt( "empresa_id" ) ) );
// u.setAdministrador(rs.getString("administrador"));
// u.setEstabelecimento_id( new Integer( rs.getInt( "estabelecimento_id" ) ) );
// u.setTipo(new Integer(rs.getInt("tipo")));
// u.setAdministrador( rs.getString( "administrador" ) );
// u.setNumero_cedula(rs.getString("numero_cedula"));
// u.setTipo( new Integer( rs.getInt( "tipo" ) ) );
// u.setCap(rs.getString("cap"));
// u.setNumero_cedula( rs.getString( "numero_cedula" ) );
// u.setNome(rs.getString("nome"));
// u.setCap( rs.getString( "cap" ) );
// u.setMedico_id(new Integer(rs.getInt("medico_id")));
// u.setNome( rs.getString( "nome" ) );
// u.setFuncionario_hst_id(new Integer(rs.getInt("funcionario_hst_id")));
// u.setMedico_id( new Integer( rs.getInt( "medico_id" ) ) );
// u.setActivo(rs.getString("activo"));
// u.setFuncionario_hst_id( new Integer( rs.getInt( "funcionario_hst_id" ) ) );
// u.setResponsavel_loja(rs.getString("responsavel_loja"));
// u.setActivo( rs.getString( "activo" ) );
// list.add(u);
// u.setResponsavel_loja( rs.getString( "responsavel_loja" ) );
// }while(rs.next());
// list.add( u );
// }
// }
// while ( rs.next() );
// }
return list ;
return list ;
}
}