|
|
|
@ -12,6 +12,8 @@ import com.evolute.utils.sql.Select2;
|
|
|
|
import db.data.siprp.outer.UtilizadoresData;
|
|
|
|
import db.data.siprp.outer.UtilizadoresData;
|
|
|
|
import db.entidades.Utilizador;
|
|
|
|
import db.entidades.Utilizador;
|
|
|
|
import global.Global;
|
|
|
|
import global.Global;
|
|
|
|
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
|
|
|
|
import java.sql.Statement;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
@ -134,72 +136,72 @@ 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();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
// int type = tipo.intValue();
|
|
|
|
// ResultSet rs = st.executeQuery(sql);
|
|
|
|
//
|
|
|
|
// if(rs.isBeforeFirst())
|
|
|
|
// Expression where = new Field( UtilizadoresData.ACTIVO_FULL ).isEqual( "y" ).and(
|
|
|
|
// {
|
|
|
|
// new Field( UtilizadoresData.APAGADO_FULL ).isEqual( "n" ) );
|
|
|
|
// rs.first();
|
|
|
|
//
|
|
|
|
// do
|
|
|
|
// if ( type == Global.DIRECTOR_LOJA || tipo == Global.RESPONSAVEL_SEGURANCA || tipo == Global.DIRECTOR_NACIONAL_SEGURANCA )
|
|
|
|
// {
|
|
|
|
// {
|
|
|
|
// Utilizador u = new Utilizador();
|
|
|
|
// where = where.and( new Field( UtilizadoresData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento_id ) );
|
|
|
|
// u.setId(new Integer(rs.getInt("id")));
|
|
|
|
// }
|
|
|
|
// u.setLogin(rs.getString("login"));
|
|
|
|
// if ( tipo == Global.RESPONSAVEL_SEGURANCA && "y".equals( responsavel_loja ) )
|
|
|
|
// u.setPassword(rs.getString("password"));
|
|
|
|
// {
|
|
|
|
// u.setData_password(rs.getDate("data_password"));
|
|
|
|
// where = where.and( new Field( UtilizadoresData.RESPONSAVEL_LOJA_FULL ).isEqual( "y" ) );
|
|
|
|
// u.setEmail(rs.getString("email"));
|
|
|
|
// }
|
|
|
|
// u.setEmpresa_id(new Integer(rs.getInt("empresa_id")));
|
|
|
|
//
|
|
|
|
// u.setEstabelecimento_id(new Integer(rs.getInt("estabelecimento_id")));
|
|
|
|
// System.out.println( "UtilizadoresDataProvider . getUtilizadoresListByTipo() : " + where.toString() );
|
|
|
|
// u.setAdministrador(rs.getString("administrador"));
|
|
|
|
//
|
|
|
|
// u.setTipo(new Integer(rs.getInt("tipo")));
|
|
|
|
// List< UtilizadoresData > listData = getProvider().listLoad( UtilizadoresData.class, where, new String[] { UtilizadoresData.NOME }, null );
|
|
|
|
// u.setNumero_cedula(rs.getString("numero_cedula"));
|
|
|
|
// for ( UtilizadoresData userData : listData )
|
|
|
|
// u.setCap(rs.getString("cap"));
|
|
|
|
// {
|
|
|
|
// u.setNome(rs.getString("nome"));
|
|
|
|
// list.add( copyFrom( userData ) );
|
|
|
|
// 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"));
|
|
|
|
Statement st = createStatement();
|
|
|
|
// u.setResponsavel_loja(rs.getString("responsavel_loja"));
|
|
|
|
String sql = "";
|
|
|
|
// list.add(u);
|
|
|
|
String estabelecimento_constraint = "";
|
|
|
|
// }while(rs.next());
|
|
|
|
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());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|