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

lxbfYeaa
Diogo Neves 15 years ago
parent 3c82ac5de6
commit 9e7e18cb8b

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

Loading…
Cancel
Save