fixed various bugs

git-svn-id: https://svn.coded.pt/svn/SIPRP@1730 bb69d46d-e84e-40c8-a05a-06db0d633741
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Diogo Neves 14 years ago
parent b8cfa8bf7b
commit bcaaa1dd54

@ -11187,49 +11187,51 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
public String butGravar_action() public String butGravar_action()
{ {
// TODO: Process the button click action. Return value is a navigation
// case name where null will return to the same page.
System.out.println( "BUT GRAVAR" ); System.out.println( "BUT GRAVAR" );
if ( getSessionBean1().getCurrentAnalise() == null ) //new analise if ( getSessionBean1().getCurrentAnalise() == null ) //new analise
{ {
//if(validationOk()) if ( validateDataOcorrencia() )
//{
if ( validationDepartmentSectionOk() )
{ {
AnaliseAcidente a = fillAnaliseFields(); if ( validationDepartmentSectionOk() )
Acidentado ac = fillAcidentadoFields();
if ( fieldsLenOk() )
{ {
try AnaliseAcidente a = fillAnaliseFields();
Acidentado ac = fillAcidentadoFields();
if ( fieldsLenOk() )
{ {
if ( !getSessionBean1().isGravado() ) try
{
getSessionBean1().setGravado( true );
AnaliseAcidente aa = create( a, ac );
createImagesFolder( aa );
getSessionBean1().setMsg( "A Ficha de Análise de Acidente nº " + aa.getAnalise_nr() + " foi gravada na sua área de trabalho." );
}
else
{ {
getSessionBean1().setMsg( "A Ficha de Análise de Acidente foi gravada na sua área de trabalho." ); if ( !getSessionBean1().isGravado() )
{
getSessionBean1().setGravado( true );
AnaliseAcidente aa = create( a, ac );
createImagesFolder( aa );
getSessionBean1().setMsg( "A Ficha de Análise de Acidente nº " + aa.getAnalise_nr() + " foi gravada na sua área de trabalho." );
}
else
{
getSessionBean1().setMsg( "A Ficha de Análise de Acidente foi gravada na sua área de trabalho." );
}
String navFrom = getSessionBean1().getNavFrom();
if ( navFrom.matches( "FormSeguranca" ) )
{
return "form_seguranca";
}
} }
String navFrom = getSessionBean1().getNavFrom(); catch ( Exception ex )
if ( navFrom.matches( "FormSeguranca" ) )
{ {
return "form_seguranca"; getSessionBean1().setMsg( "Erro na inserção da análise !" );
getSessionBean1().setGravado( false );
ErrorLogger.logException( ex );
} }
}
catch ( Exception ex )
{
getSessionBean1().setMsg( "Erro na inserção da análise !" );
getSessionBean1().setGravado( false );
ErrorLogger.logException( ex );
} }
}
}
else
{
getSessionBean1().setGravado( false );
}
} }
else else
{ {
@ -11238,77 +11240,80 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
} }
else // edit analise else // edit analise
{ {
if ( fieldsLenOk() ) if ( validateDataOcorrencia() )
{ {
if ( fieldsLenOk() )
AnaliseAcidente a = fillAnaliseFields();
Acidentado ac = null;
ArrayList recs = null;
ArrayList meds = null;
int estado = a.getEstado().intValue();
//if(estado == ESTADO_SEG || estado == ESTADO_RH1)
if ( estado == Global.ESTADO_RH1 )
{
ac = fillAcidentadoFields();
}
else if ( estado == Global.ESTADO_HS )
{
a.setTecnico_saude_id( getSessionBean1().getCurrentUser().getId() );
recs = fillAnaliseRecomendacoesHs( a );
}
else if ( estado == Global.ESTADO_RH2 )
{
meds = fillAnaliseMedidasRh( a );
a.setRh_fase4( getSessionBean1().getCurrentUser().getId() );
}
try
{ {
if ( !getSessionBean1().isGravado() )
AnaliseAcidente a = fillAnaliseFields();
Acidentado ac = null;
ArrayList recs = null;
ArrayList meds = null;
int estado = a.getEstado().intValue();
//if(estado == ESTADO_SEG || estado == ESTADO_RH1)
if ( estado == Global.ESTADO_RH1 )
{ {
getSessionBean1().setGravado( true ); ac = fillAcidentadoFields();
update( a, ac, recs, meds );
//createImagesFolder(analiseId.toString());
updateImagesFolder( a );
getSessionBean1().setMsg( "A Ficha de Análise de Acidente nº " + a.getAnalise_nr() + " foi gravada na sua área de trabalho." );
} }
else else if ( estado == Global.ESTADO_HS )
{ {
getSessionBean1().setMsg( "A Ficha de Análise de Acidente nº " + a.getAnalise_nr() + " foi gravada na sua área de trabalho." ); a.setTecnico_saude_id( getSessionBean1().getCurrentUser().getId() );
recs = fillAnaliseRecomendacoesHs( a );
} }
else if ( estado == Global.ESTADO_RH2 )
if ( estado != Global.ESTADO_ASSINATURA_RH ) {
meds = fillAnaliseMedidasRh( a );
a.setRh_fase4( getSessionBean1().getCurrentUser().getId() );
}
try
{ {
String navFrom = getSessionBean1().getNavFrom(); if ( !getSessionBean1().isGravado() )
if ( navFrom.matches( "FormSeguranca" ) )
{ {
return "form_seguranca"; getSessionBean1().setGravado( true );
update( a, ac, recs, meds );
//createImagesFolder(analiseId.toString());
updateImagesFolder( a );
getSessionBean1().setMsg( "A Ficha de Análise de Acidente nº " + a.getAnalise_nr() + " foi gravada na sua área de trabalho." );
} }
else if ( navFrom.matches( "FormRH" ) ) else
{ {
return "form_rh"; getSessionBean1().setMsg( "A Ficha de Análise de Acidente nº " + a.getAnalise_nr() + " foi gravada na sua área de trabalho." );
} }
else if ( navFrom.matches( "FormHS" ) )
if ( estado != Global.ESTADO_ASSINATURA_RH )
{ {
return "form_hs"; String navFrom = getSessionBean1().getNavFrom();
if ( navFrom.matches( "FormSeguranca" ) )
{
return "form_seguranca";
}
else if ( navFrom.matches( "FormRH" ) )
{
return "form_rh";
}
else if ( navFrom.matches( "FormHS" ) )
{
return "form_hs";
}
else if ( navFrom.matches( "FormMedico" ) )
{
return "form_medico";
}
} }
else if ( navFrom.matches( "FormMedico" ) ) else
{ {
return "form_medico"; chkVerRespRh.setDisabled( true );
// IMPRIMIR HERE
} }
} }
else catch ( Exception ex )
{ {
chkVerRespRh.setDisabled( true ); getSessionBean1().setMsg( "Erro na actualização da análise !" );
// IMPRIMIR HERE getSessionBean1().setGravado( false );
ErrorLogger.logException( ex );
} }
}
catch ( Exception ex )
{
getSessionBean1().setMsg( "Erro na actualização da análise !" );
getSessionBean1().setGravado( false );
ErrorLogger.logException( ex );
} }
} }
} }
@ -11512,7 +11517,6 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
a.setAcidentado_id( acidentado_id ); a.setAcidentado_id( acidentado_id );
AnaliseAcidente aa = adp.createAnalise( a ); AnaliseAcidente aa = adp.createAnalise( a );
return aa; return aa;
} }
@ -11672,7 +11676,7 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
int estado = 0; int estado = 0;
AnaliseAcidente a = null; AnaliseAcidente a = null;
//fill analise fields //fill analise fields
if ( getSessionBean1().getCurrentAnalise() == null ) //null if ( getSessionBean1().getCurrentAnalise() == null )
{ {
a = new AnaliseAcidente(); a = new AnaliseAcidente();
a.setEspecif1( "" ); a.setEspecif1( "" );
@ -11826,14 +11830,17 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
} }
Integer horas_turno = null; Integer horas_turno = null;
try String horas_turno_str = ( String ) txtHorasTurno.getText();
if ( horas_turno_str != null && ! "".equals( horas_turno_str.trim() ) )
{ {
String horas_turno_str = ( String ) txtHorasTurno.getText(); try
horas_turno = new Integer( Integer.parseInt( horas_turno_str ) ); {
} horas_turno = Integer.parseInt( horas_turno_str );
catch ( Exception ex ) }
{ catch ( Exception e )
ErrorLogger.logException( ex ); {
ErrorLogger.logException( e );
}
} }
a.setHoras_turno( horas_turno ); a.setHoras_turno( horas_turno );
@ -12819,6 +12826,17 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
return a; return a;
} }
private boolean validateDataOcorrencia()
{
Date d = getCalDataOcorrencia();
if ( d == null )
{
getSessionBean1().setMsg( "Falta data da ocorrência!" );
return false;
}
return true;
}
private boolean validationDepartmentSectionOk() private boolean validationDepartmentSectionOk()
{ {
Integer departmentId = ( Integer ) drpDepartamento.getSelected(); Integer departmentId = ( Integer ) drpDepartamento.getSelected();
@ -12833,7 +12851,6 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
getSessionBean1().setMsg( "Falta secção!" ); getSessionBean1().setMsg( "Falta secção!" );
return false; return false;
} }
return true; return true;
} }
@ -13198,7 +13215,7 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
int estado = 0; int estado = 0;
int estado_assinatura = 0; int estado_assinatura = 0;
if ( getSessionBean1().getCurrentAnalise() == null ) //null if ( getSessionBean1().getCurrentAnalise() == null )
{ {
estado = Global.ESTADO_SEG; estado = Global.ESTADO_SEG;
} }
@ -13211,6 +13228,11 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
if ( estado == Global.ESTADO_SEG ) if ( estado == Global.ESTADO_SEG )
{ {
if ( ! validateDataOcorrencia() )
{
return false;
}
if ( txtAveriguador.getText() == null ) if ( txtAveriguador.getText() == null )
{ {
getSessionBean1().setMsg( "Falta averiguador!" ); getSessionBean1().setMsg( "Falta averiguador!" );
@ -14377,14 +14399,7 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
// calDataOcorrencia.setValue( dtAcidente ); // calDataOcorrencia.setValue( dtAcidente );
setCalDataOcorrencia( dtAcidente ); setCalDataOcorrencia( dtAcidente );
try txtHorasTurno.setText( a.getHoras_turno() == null ? "" : a.getHoras_turno().toString() );
{
txtHorasTurno.setText( a.getHoras_turno().toString() );
}
catch ( Exception ex )
{
ErrorLogger.logException( ex );
}
stBI.setText( a.getBi() ); stBI.setText( a.getBi() );
stMorada.setText( a.getMorada() ); stMorada.setText( a.getMorada() );

@ -23,8 +23,10 @@ import beans.TecnicoSaude;
import beans.TipoUtilizador; import beans.TipoUtilizador;
import beans.Trabalhador; import beans.Trabalhador;
import com.evolute.utils.arrays.Virtual2DArray; import com.evolute.utils.arrays.Virtual2DArray;
import com.evolute.utils.sql.Assignment;
import com.evolute.utils.sql.Expression; import com.evolute.utils.sql.Expression;
import com.evolute.utils.sql.Field; import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Insert;
import com.evolute.utils.sql.Select2; import com.evolute.utils.sql.Select2;
import com.evolute.utils.strings.StringPlainer; import com.evolute.utils.strings.StringPlainer;
import com.sun.rave.web.ui.model.Option; import com.sun.rave.web.ui.model.Option;
@ -2017,15 +2019,11 @@ public class AnalisesDataProvider extends GenericDataProvider
public AnaliseAcidente createAnalise( AnaliseAcidente a ) throws Exception public AnaliseAcidente createAnalise( AnaliseAcidente a ) throws Exception
{ {
//Controle c = getControle(); // Integer newId = getMaxAnaliseId();
Statement st = createStatement();
Integer newId = getMaxAnaliseId();
//calc analise_nr //calc analise_nr
java.util.Date data_acidente = new java.util.Date( a.getData_acidente().getTime() ); java.util.Date data_acidente = new java.util.Date( a.getData_acidente().getTime() );
//java.util.Date now = new java.util.Date();
Calendar cal = new GregorianCalendar(); Calendar cal = new GregorianCalendar();
//cal.setTime(now);
cal.setTime( data_acidente ); cal.setTime( data_acidente );
int ano = cal.get( Calendar.YEAR ); int ano = cal.get( Calendar.YEAR );
Controle c = getControloByAno( new Integer( ano ) ); Controle c = getControloByAno( new Integer( ano ) );
@ -2046,75 +2044,116 @@ public class AnalisesDataProvider extends GenericDataProvider
String ano_str = new Integer( ano ).toString(); String ano_str = new Integer( ano ).toString();
String analise_nr = ano_str.substring( 2 ) + "/" + seq_str.substring( 1 ); String analise_nr = ano_str.substring( 2 ) + "/" + seq_str.substring( 1 );
a.setAnalise_nr( analise_nr ); a.setAnalise_nr( analise_nr );
a.setId( newId ); // a.setId( newId );
String sql = "INSERT INTO analises_acidentes (id, averiguador, data_acidente, acidentado_id, estado, empresa_id, estabelecimento_id, horas_turno, departamento_id, seccao_id, local_trabalho, tarefa, substancias, condicoes, testemunhas, causas, descricao, conclusoes, accoes, hora_acidente, medico_id, tecnico_saude_id, averiguacao_posterior, averiguacao_obs, data_inicio_processo, analise_nr, coef_incapacidade, concluido_por_desactivacao, data_desactivacao, comentario_desactivacao) VALUES ("; Insert insert = new Insert( "analises_acidentes", new Assignment[] {
sql += newId + ", '"; // new Assignment( new Field( "id" ), newId ),
sql += a.getAveriguador() + "', '"; new Assignment( new Field( "averiguador" ), a.getAveriguador() ),
sql += a.getData_acidente() + "', "; new Assignment( new Field( "data_acidente" ), a.getData_acidente() ),
sql += a.getAcidentado_id() + ", "; new Assignment( new Field( "acidentado_id" ), a.getAcidentado_id() ),
sql += a.getEstado() + ", "; new Assignment( new Field( "estado" ), a.getEstado() ),
sql += a.getEmpresa_id() + ", "; new Assignment( new Field( "empresa_id" ), a.getEmpresa_id() ),
sql += a.getEstabelecimento_id() + ", "; new Assignment( new Field( "estabelecimento_id" ), a.getEstabelecimento_id() ),
sql += a.getHoras_turno() + ", "; new Assignment( new Field( "horas_turno" ), a.getHoras_turno() ),
sql += a.getDepartamento_id() + ", "; new Assignment( new Field( "departamento_id" ), a.getDepartamento_id() ),
sql += a.getSeccao_id() + ", '"; new Assignment( new Field( "seccao_id" ), a.getSeccao_id() ),
sql += a.getLocal_trabalho() + "', '"; new Assignment( new Field( "local_trabalho" ), a.getLocal_trabalho() ),
sql += a.getTarefa() + "', '"; new Assignment( new Field( "tarefa" ), a.getTarefa() ),
sql += a.getSubstancias() + "', '"; new Assignment( new Field( "substancias" ), a.getSubstancias() ),
// sql += a.getSuperior_hierarquico() + "', '"; new Assignment( new Field( "condicoes" ), a.getCondicoes() ),
sql += a.getCondicoes() + "', '"; new Assignment( new Field( "testemunhas" ), a.getTestemunhas() ),
sql += a.getTestemunhas() + "', "; new Assignment( new Field( "causas" ), a.getCausas() ),
sql += a.getCausas() + ", '"; new Assignment( new Field( "descricao" ), a.getDescricao() ),
sql += a.getDescricao() + "', '"; new Assignment( new Field( "conclusoes" ), a.getConclusoes() ),
sql += a.getConclusoes() + "', '"; new Assignment( new Field( "accoes" ), a.getAccoes() ),
sql += a.getAccoes() + "', "; new Assignment( new Field( "hora_acidente" ), a.getHora_acidente() ),
if ( a.getHora_acidente() == null ) new Assignment( new Field( "medico_id" ), a.getMedico_id() ),
{ new Assignment( new Field( "tecnico_saude_id" ), a.getTecnico_saude_id() ),
sql += null + ", "; new Assignment( new Field( "averiguacao_posterior" ), a.getAveriguacao_posterior() ),
} new Assignment( new Field( "averiguacao_obs" ), a.getAveriguacao_obs() ),
else new Assignment( new Field( "data_inicio_processo" ), a.getData_inicio_processo() ),
{ new Assignment( new Field( "analise_nr" ), analise_nr ),
sql += "'" + a.getHora_acidente() + "', "; new Assignment( new Field( "coef_incapacidade" ), null ),
} new Assignment( new Field( "concluido_por_desactivacao" ), Boolean.FALSE ),
new Assignment( new Field( "data_desactivacao" ), null ),
sql += a.getMedico_id() + ", "; new Assignment( new Field( "comentario_desactivacao" ), null ),
sql += a.getTecnico_saude_id() + ", '"; } );
sql += a.getAveriguacao_posterior() + "', '"; Virtual2DArray array = getExecuter().executeQuery( insert );
sql += a.getAveriguacao_obs() + "', "; Integer insertedID = getInsertedID( array );
if ( a.getData_inicio_processo() == null ) System.out.println( "SQL : " + insert.toString() );
{ System.out.println( "\nINSERTED ANALISE ID : " + insertedID );
sql += null + ", "; a.setId( insertedID );
}
else // String sql = "INSERT INTO analises_acidentes (id, averiguador, data_acidente, acidentado_id, estado, empresa_id, estabelecimento_id, horas_turno, departamento_id, seccao_id, local_trabalho, tarefa, substancias, condicoes, testemunhas, causas, descricao, conclusoes, accoes, hora_acidente, medico_id, tecnico_saude_id, averiguacao_posterior, averiguacao_obs, data_inicio_processo, analise_nr, coef_incapacidade, concluido_por_desactivacao, data_desactivacao, comentario_desactivacao) VALUES (";
{ // sql += newId + ", '";
sql += "'" + a.getData_inicio_processo() + "', '"; // sql += a.getAveriguador() + "', '";
} // sql += a.getData_acidente() + "', ";
// sql += a.getAcidentado_id() + ", ";
sql += analise_nr + "', "; // sql += a.getEstado() + ", ";
sql += null + ", "; // sql += a.getEmpresa_id() + ", ";
// sql += a.getEstabelecimento_id() + ", ";
sql += false + ", " + null + ", " + null; //concluido_por_desactivacao, data_desactivacao, comentario_desactivacao // sql += a.getHoras_turno() + ", ";
// sql += a.getDepartamento_id() + ", ";
sql += ")"; // sql += a.getSeccao_id() + ", '";
// sql += a.getLocal_trabalho() + "', '";
// sql += a.getTarefa() + "', '";
// sql += a.getSubstancias() + "', '";
//// sql += a.getSuperior_hierarquico() + "', '";
// sql += a.getCondicoes() + "', '";
// sql += a.getTestemunhas() + "', ";
// sql += a.getCausas() + ", '";
// sql += a.getDescricao() + "', '";
// sql += a.getConclusoes() + "', '";
// sql += a.getAccoes() + "', ";
// if ( a.getHora_acidente() == null )
// {
// sql += null + ", ";
// }
// else
// {
// sql += "'" + a.getHora_acidente() + "', ";
// }
//
// sql += a.getMedico_id() + ", ";
// sql += a.getTecnico_saude_id() + ", '";
// sql += a.getAveriguacao_posterior() + "', '";
// sql += a.getAveriguacao_obs() + "', ";
// if ( a.getData_inicio_processo() == null )
// {
// sql += null + ", ";
// }
// else
// {
// sql += "'" + a.getData_inicio_processo() + "', '";
// }
//
// sql += analise_nr + "', ";
// sql += null + ", ";
//
// sql += false + ", " + null + ", " + null; //concluido_por_desactivacao, data_desactivacao, comentario_desactivacao
//
// sql += ")";
//
//// sql += null + ")";
//// sql += a.getFormacao_shst() + "', '";
//// sql += a.getFormacao_shst_nao_porque() + "', '";
//// sql += a.getOutros_acidentes_com_colaborador() + "', ";
//// sql += a.getNr_acidentes_com_colaborador() + ", ";
//// sql += a.getNr_relatorio_acidente_colaborador1() + ", ";
//// sql += a.getNr_relatorio_acidente_colaborador2() + ", ";
//// sql += a.getNr_relatorio_acidente_colaborador3() + ", ";
//// sql += a.getNr_relatorio_acidente_colaborador4() + ", '";
//// sql += a.getAcidentes_outros_colaboradores()+ "', ";
//// sql += a.getNr_acidentes_outros_colaboradores()+ ", ";
//// sql += a.getNr_relatorio_acidente_outros_colaboradores1() + ", ";
//// sql += a.getNr_relatorio_acidente_outros_colaboradores2() + ", ";
//// sql += a.getNr_relatorio_acidente_outros_colaboradores3() + ", ";
//// sql += a.getNr_relatorio_acidente_outros_colaboradores4() + ")";
// System.out.println( "SQL : " + sql );
//
// Statement st = createStatement();
// st.execute( sql );
// sql += null + ")";
// sql += a.getFormacao_shst() + "', '";
// sql += a.getFormacao_shst_nao_porque() + "', '";
// sql += a.getOutros_acidentes_com_colaborador() + "', ";
// sql += a.getNr_acidentes_com_colaborador() + ", ";
// sql += a.getNr_relatorio_acidente_colaborador1() + ", ";
// sql += a.getNr_relatorio_acidente_colaborador2() + ", ";
// sql += a.getNr_relatorio_acidente_colaborador3() + ", ";
// sql += a.getNr_relatorio_acidente_colaborador4() + ", '";
// sql += a.getAcidentes_outros_colaboradores()+ "', ";
// sql += a.getNr_acidentes_outros_colaboradores()+ ", ";
// sql += a.getNr_relatorio_acidente_outros_colaboradores1() + ", ";
// sql += a.getNr_relatorio_acidente_outros_colaboradores2() + ", ";
// sql += a.getNr_relatorio_acidente_outros_colaboradores3() + ", ";
// sql += a.getNr_relatorio_acidente_outros_colaboradores4() + ")";
System.out.println( "SQL : " + sql );
st.execute( sql );
updateControle( c ); updateControle( c );
return a; return a;
} }

@ -17,12 +17,11 @@ import com.evolute.utils.db.DBException;
import com.evolute.utils.db.DBManager; import com.evolute.utils.db.DBManager;
import com.evolute.utils.db.Executer; import com.evolute.utils.db.Executer;
import com.evolute.utils.db.JDBCManager; import com.evolute.utils.db.JDBCManager;
import com.evolute.utils.db.keyretrievers.PostgresqlAutoKeyRetriever;
import com.evolute.utils.error.ErrorLogger; import com.evolute.utils.error.ErrorLogger;
import com.evolute.utils.jdbc.DBStatementExecuter; import com.evolute.utils.jdbc.DBStatementExecuter;
import com.evolute.utils.jdbc.StatementExecuterFactory; import com.evolute.utils.jdbc.StatementExecuterFactory;
import com.evolute.utils.sql.Insert;
import com.evolute.utils.sql.SQLQuery; import com.evolute.utils.sql.SQLQuery;
import com.evolute.utils.sql.backend.BackendProvider;
import com.evolute.utils.strings.UnicodeChecker; import com.evolute.utils.strings.UnicodeChecker;
import db.DBConstants; import db.DBConstants;
import db.DBPropertiesLoader; import db.DBPropertiesLoader;
@ -143,6 +142,7 @@ public class EvoBaseProvider
{ {
String dbUrl = ( String ) Singleton.getInstance( DBConstants.CONNECTION_URL ); String dbUrl = ( String ) Singleton.getInstance( DBConstants.CONNECTION_URL );
providerInterface = createInstance( db, dbUrl, username, password ); providerInterface = createInstance( db, dbUrl, username, password );
BackendProvider.getBackend( dbUrl ).setEscapeUnicode( false );
} }
else if ( DBConstants.DB.SIPRP_LOCAL.equals( db ) ) else if ( DBConstants.DB.SIPRP_LOCAL.equals( db ) )
{ {

@ -8,6 +8,7 @@ package db.providers;
import com.evolute.entity.ProviderInterface; import com.evolute.entity.ProviderInterface;
import com.evolute.entity.evo.EvoDataException; import com.evolute.entity.evo.EvoDataException;
import com.evolute.entity.evo.EvoDataObject; import com.evolute.entity.evo.EvoDataObject;
import com.evolute.utils.arrays.Virtual2DArray;
import com.evolute.utils.db.DBException; import com.evolute.utils.db.DBException;
import com.evolute.utils.db.Executer; import com.evolute.utils.db.Executer;
import com.evolute.utils.error.ErrorLogger; import com.evolute.utils.error.ErrorLogger;
@ -70,6 +71,15 @@ public abstract class GenericDataProvider
// } // }
// } // }
protected Integer getInsertedID( Virtual2DArray array )
{
Integer id = null;
if ( array != null && array.columnLength() > 0 )
{
id = array.get( 0, 0 );
}
return id;
}
protected Integer getMaxTableId(String table) protected Integer getMaxTableId(String table)
{ {
Statement st = createStatement(); Statement st = createStatement();
@ -119,4 +129,5 @@ public abstract class GenericDataProvider
} }
return null; return null;
} }
} }

@ -17,6 +17,7 @@ import com.evolute.utils.arrays.Virtual2DArray;
import com.evolute.utils.error.ErrorLogger; import com.evolute.utils.error.ErrorLogger;
import com.evolute.utils.sql.Expression; import com.evolute.utils.sql.Expression;
import com.evolute.utils.sql.Field; import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Select;
import com.evolute.utils.sql.Select2; import com.evolute.utils.sql.Select2;
import com.evolute.utils.sql.expression.Par; import com.evolute.utils.sql.expression.Par;
import com.evolute.utils.strings.StringPlainer; import com.evolute.utils.strings.StringPlainer;
@ -573,27 +574,63 @@ public class UtilizadoresDataProvider extends GenericDataProvider
} }
} }
public Medico getMedico(Integer estabelecimento_id) public Medico getMedico( Integer estabelecimentoID )
{ {
Medico m = null; Medico result = null;
Statement st = createStatement(); try
String sql ="SELECT * FROM utilizadores WHERE activo = 'y' AND tipo = " + Global.TIPO_UTILIZADOR_MEDICO + " AND apagado = 'n' AND estabelecimento_id = " + estabelecimento_id; {
try Select2 query = new Select2(
{ new String[] { UtilizadoresData.TABLENAME },
ResultSet rs = st.executeQuery(sql); new Integer[] {},
rs.first(); new Expression[] {},
m = new Medico(); new String[] { UtilizadoresData.ID_FULL, UtilizadoresData.NOME_FULL, UtilizadoresData.NUMERO_CEDULA_FULL },
m.setId(new Integer(rs.getInt("id"))); new Field( UtilizadoresData.ACTIVO_FULL ).isEqual( "y" )
m.setNome(rs.getString("nome")); .and( new Field( UtilizadoresData.APAGADO_FULL ).isEqual( "n" ) )
m.setNumero_cedula(rs.getString("numero_cedula")); .and( new Field( UtilizadoresData.TIPO_FULL ).isEqual( Global.TIPO_UTILIZADOR_MEDICO ) )
return m; .and( new Field( UtilizadoresData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) ),
} null, null, null, null
catch(Exception ex) );
{ Virtual2DArray array = getExecuter().executeQuery( query );
ErrorLogger.logException( ex ); if ( array.columnLength() > 0 )
return null; {
} Integer medicoID = array.get( 0, 0 );
} String nome = array.get( 0, 1 );
String numeroCedula = array.get( 0, 2 );
result = new Medico();
result.setId( medicoID );
result.setNome( nome );
result.setNumero_cedula( numeroCedula );
}
}
catch ( Exception e )
{
ErrorLogger.logException( e );
}
return result;
}
// public Medico getMedico(Integer estabelecimento_id)
// {
// Medico m = null;
// Statement st = createStatement();
// String sql ="SELECT * FROM utilizadores WHERE activo = 'y' AND tipo = " + Global.TIPO_UTILIZADOR_MEDICO + " AND apagado = 'n' AND estabelecimento_id = " + estabelecimento_id;
// try
// {
// ResultSet rs = st.executeQuery(sql);
// rs.first();
// m = new Medico();
// m.setId(new Integer(rs.getInt("id")));
// m.setNome(rs.getString("nome"));
// m.setNumero_cedula(rs.getString("numero_cedula"));
// return m;
// }
// catch(Exception ex)
// {
// ErrorLogger.logException( ex );
// return null;
// }
// }
public com.sun.rave.web.ui.model.Option[] getMedicosList() throws Exception public com.sun.rave.web.ui.model.Option[] getMedicosList() throws Exception

Loading…
Cancel
Save