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

lxbfYeaa
Diogo Neves 15 years ago
parent 73c7fe5c3b
commit 948a331494

@ -97,7 +97,7 @@
<!-- WEB CLASSPATHS -->
<path id="web.jar.classpath">
<fileset dir="${common.lib.dir}" />
<!-- <fileset dir="${common.lib.dir}" /> -->
<fileset dir="${web.lib.dir}" />
<fileset dir="${common.lib.tools.dir}">
<include name="servlet-api.jar" />
@ -257,6 +257,7 @@
<fileset dir="${web.build.dir}" />
</delete>
<delete dir="${web.build.dir}" failonerror="false" />
<delete file="${web.dist.dir}/${web.warfile}" failonerror="false" />
</target>
<target name="web-makeWar" depends="web-build" description="Creates the web war">
@ -265,7 +266,7 @@
<fileset dir="${web.build.dir}">
<include name="html/**/*" />
</fileset>
<lib dir="${common.lib.dir}" />
<!-- <lib dir="${common.lib.dir}" /> -->
<lib dir="${web.lib.dir}" />
<classes dir="${web.build.classes.dir}" />
</war>

@ -174,20 +174,20 @@
#end
</table>
#elseif( $query == "trabalhadores_tudo" )
<table width='98%' cellspacing='0' cellpadding='0' border="0">
<tr class='tableheader'>
<td width='75%'>Nome</td>
<td class='box6' width='25%'>Data da Ficha de Aptid&atilde;o</td>
</tr>
#foreach( $element in $v1 )
#set ( $counter = $velocityCount - 1 )
#set ( $dados_trabalhador = $v2.get($counter) )
<table width='100%' cellspacing='0' cellpadding='0' border="0">
<tr class='tableheader'>
<td width='75%'>Nome</td>
<td class='box6' width='25%'>Data da Ficha de Aptid&atilde;o</td>
</tr>
#foreach ( $trabalhador in $v1 )
<tr class='elements'>
<td class='box5' ><a class='text' href="$v1.get($counter)">$dados_trabalhador.Nome</a></td>
<td class='box6' >$dados_trabalhador.Data </td>
<td class='box5'><a class='text' href="$trabalhador.trabalhador_link">$trabalhador.trabalhador_nome</a></td>
<td class='box6'>$trabalhador.ficha_aptidao_data</td>
</tr>
#end
</table>
</table>
#elseif( $query == "trabalhadores_pendentes" )
<div class="icons_info">
<span><img SRC="/siprpWeb/html/images/red.png"> - Por Agendar</span>

@ -46,20 +46,19 @@
</table>
#elseif( $query == "trabalhadores_tudo" )
<table width='100%'>
<tr class="tableheader">
<td width='75%' align='left' >&nbsp;&nbsp;Nome</td>
<td width='25%' align='center' >Data da Ficha de Aptid&atilde;o</td>
</tr>
#foreach( $element in $v1 )
#set ( $counter = $velocityCount - 1 )
#set ( $dados_trabalhador = $v2.get($counter) )
<tr class="elements">
<td align='left' >&nbsp;&nbsp;$dados_trabalhador.Nome</td>
<td align='center' >$dados_trabalhador.Data &nbsp;</td>
<table width='100%' cellspacing='0' cellpadding='0' border="0">
<tr class='tableheader'>
<td width='75%' align='left'>Nome</td>
<td class='box6' width='25%' align='center'>Data da Ficha de Aptid&atilde;o</td>
</tr>
#end
</table>
#foreach ( $trabalhador in $v1 )
<tr class='elements'>
<td align='left'><a class='text' href="$trabalhador.trabalhador_link">$trabalhador.trabalhador_nome</a></td>
<td align='center'>$trabalhador.ficha_aptidao_data</td>
</tr>
#end
</table>
#elseif( $query == "trabalhadores_pendentes" )
@ -77,26 +76,6 @@
</tr>
#end
</table>
#*
<div class="info">(*)ECD - Exames Complementares de Diagn&oacute;stico</div>
<table width='100%' >
<tr class="tableheader">
<td width='75%' align='left' >&nbsp;&nbsp;Nome</td>
<td width='12%' align='center' >ECD(*)</td>
<td width='12%' align='center'>Consulta</td>
</tr>
#foreach( $element in $v1 )
#set ( $counter = $velocityCount - 1 )
#set ( $dados_trabalhador = $v2.get($counter) )
<tr class="elements">
<td align='left' ><a class='text' href="$v1.get($counter)">&nbsp;&nbsp;$dados_trabalhador.Nome</a></td>
<td align='center' >$dados_trabalhador.Exame_estado</td>
<td align='center' >$dados_trabalhador.Consulta_estado</td>
</tr>
#end
</table>
*#
#end
</div>

Binary file not shown.

@ -93,7 +93,7 @@ public class NewsServlet extends HttpServlet
{
if( executer == null )
{
executer = ( SQLExecuter )DBM.getSharedExecuter();
executer = ( SQLExecuter )DBM.getSharedExecuter( this );
}
Virtual2DArray array = executer.executeQuery( SELECT );
Object o[][] = array.getObjects();

@ -9,6 +9,7 @@ package siprp.pagina;
import java.io.*;
import java.util.*;
import java.sql.*;
import java.util.Date;
import java.lang.reflect.Array;
import javax.servlet.*;
import javax.servlet.http.*;
@ -16,241 +17,340 @@ import javax.servlet.http.*;
import org.apache.velocity.*;
import org.apache.velocity.app.*;
import com.evolute.utils.arrays.*;
import com.evolute.utils.db.*;
import com.evolute.utils.sql.*;
import com.evolute.utils.strings.*;
/**
*
* @author fpalma
*/
public class doGetListaTrabalhadoresTudo
extends siprpServlet
implements GlobalConstants
public class doGetListaTrabalhadoresTudo extends siprpServlet implements GlobalConstants
{
protected java.util.Date today;
protected long todayMillis;
/** Creates a new instance of doGetListaTrabalhadores */
public doGetListaTrabalhadoresTudo(HttpServletRequest req, HttpServletResponse res, boolean print) throws IOException
{
ServletOutputStream out = res.getOutputStream();
Connection con = null ;
Statement stmt = null ;
ResultSet2DArray rs;
StringBuffer dbQuery, sBuffer;
String userRole, empresaId, estabelecimentoId, temp;
HttpSession session = req.getSession(false);
Vector links = new Vector();
Vector desc = new Vector();
Vector descAdicional = new Vector();
today = new java.util.Date();
todayMillis = today.getTime();
try
{
userRole = (String)session.getAttribute(super.sessionUserRole);
empresaId = (String)session.getAttribute(super.sessionEmpresaId);
estabelecimentoId = (String)session.getAttribute(super.sessionEstabelecimentoId);
if ( userRole.equals ( super.superUserRole ) || userRole.equals ( empresaId ) )
{
Class.forName(super.bdDriver);
con = DriverManager.getConnection( bdLocalUrl, bdLocalUsername, bdLocalPassword );
if ( super.verificaEstabelecimento(con, empresaId, estabelecimentoId) ) // estabelecimento pertence 'a empresa ??
{
//Class.forName(super.bdDriver);
//con = DriverManager.getConnection( super.bdUrl, super.bdUsername, super.bdPassword );
dbQuery = new StringBuffer();
// dbQuery.append( "SELECT id, nome, data_ficha FROM trabalhadores "
// + "WHERE estabelecimento_id = '"+estabelecimentoId+"'"
// + " AND ultima_consulta IS NOT NULL AND realizada = 'y' AND"
// + " ( proxima_consulta IS NULL OR proxima_consulta - current_date > 14 )"
// + " AND ( proximo_exame IS NULL OR proximo_exame - current_date > 14 )"
// + " ORDER BY nome" );
dbQuery.append( "SELECT trabalhadores.id, trabalhadores.nome, "
+ "marcacoes_trabalhador.tipo, marcacoes_trabalhador.data, "
// + "marcacoes_trabalhador.estado, "
+ " trabalhadores.nome_plain "
+ "FROM trabalhadores, marcacoes_trabalhador "
+ "WHERE estabelecimento_id = " + estabelecimentoId
+ " AND marcacoes_trabalhador.trabalhador_id = trabalhadores.id "
+ " AND trabalhadores.inactivo <> 'y' AND data_demissao IS NULL "
+ "ORDER BY 5, 3, 4 DESC " );
stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
rs = new ResultSet2DArray( stmt.executeQuery( dbQuery.toString()) );
int index=0;
int max = rs.columnLength();
Integer trabalhadorID = new Integer( -1 );
String nomeTrabalhador = "";
Vector consultas = new Vector();
Vector exames = new Vector();
for ( index = 0; index <= max; index++ )
{
Integer id = index < max ? ( Integer ) rs.get( index, 0 ) : new Integer( -1 );
if( !id.equals( trabalhadorID ) )
{
Object listaConsultas[][] = ( Object[][] ) consultas.toArray( new Object[consultas.size()][2] );
Object listaExames[][] = ( Object[][] ) exames.toArray( new Object[exames.size()][2] );
if( trabalhadorID.intValue() > -1 &&
verificarTrabalhador( listaConsultas, listaExames ) )
{
temp=""+rs.get(index - 1,0); // converter de int para String
java.util.Date dataUltimaConsulta = null;
for( int c = 0; c < listaConsultas.length; c++ )
{
if( new Integer( 2 ).equals( listaConsultas[ c ][ 1 ] ) )
{
dataUltimaConsulta = ( java.util.Date ) listaConsultas[ c ][ 0 ];
break;
}
}
HashMap dadosTrabalhador = criarDadosTrabalhador( trabalhadorID, nomeTrabalhador, dataUltimaConsulta );
if( dadosTrabalhador != null )
{
dbQuery = new StringBuffer();
dbQuery.append("/"+super.servletName+"/?"+empresaId+"/"+estabelecimentoId+"/"+temp); // construir url
links.add(dbQuery.toString());
desc.add( dadosTrabalhador );
}
}
exames.clear();
consultas.clear();
}
if( index == max )
{
break;
}
Integer tipo = ( Integer ) rs.get( index, 2 );
String nome = ( String ) rs.get( index, 1 );
java.util.Date data = ( java.util.Date ) rs.get( index, 3 );
// Integer estado = ( Integer ) rs.get( index, 4 );
trabalhadorID = id;
nomeTrabalhador = nome;
// Object marcacao[] = new Object[]{ data, estado };
// switch( tipo.intValue() )
// {
// case TIPO_MARCACAO_EXAMES:
// exames.add( marcacao );
// break;
//
// case TIPO_MARCACAO_CONSULTA:
// consultas.add( marcacao );
// break;
// }
}
stmt.close();
sBuffer = new StringBuffer();
sBuffer.append("<b>"+super.nomeEmpresa(con,empresaId)+"</b><br><br><i>"
+super.nomeEstabelecimento(con, estabelecimentoId)+"</i>" );
HashMap hmValues = new HashMap();
hmValues.put( "empresa_nome", session.getAttribute( sessionCompanyName ) );
hmValues.put( "empresa_id", session.getAttribute( sessionEmpresaId ) );
hmValues.put( "estabelecimento_nome", super.nomeEstabelecimento( con, estabelecimentoId ) );
hmValues.put( "estabelecimento_id", estabelecimentoId );
hmValues.put( "userRole", userRole );
hmValues.put( "userName", session.getAttribute( sessionUser ) );
hmValues.put( msgTemplate , sBuffer.toString() ) ;
hmValues.put( templateUserRole, userRole);
hmValues.put( templateQuery, "trabalhadores_tudo" );
hmValues.put( templateVector1,links);
hmValues.put( templateVector2,desc);
hmValues.put( templateVector3,null);
if( !print )
{
out.println( mergeTemplate( hmValues, super.authenticatedUserTemplate));
}
else
{
out.println( mergeTemplate( hmValues, super.authenticatedUserPrintTemplate));
}
// out.println( mergeTemplate( sBuffer.toString(), userRole, super.queryStringTrabalhadores, links, desc, null, super.authenticatedUserTemplate) );
}
else // est nao pertence 'a empresa
{
out.println( mergeTemplate( super.msgLinkFormatError , userRole, super.errorTemplate) );
}
con.close();
}
else // Role nao permite ver esta informacao
{
out.println( mergeTemplate( super.msgAcessoNegado , userRole, super.errorTemplate) );
}
}
catch ( SQLException e )
{
e.printStackTrace();
out.println( mergeTemplate( super.msgErroBd , super.errorTemplate) );
}
catch ( Exception e )
{
e.printStackTrace();
out.println( mergeTemplate( super.msgGenericError , super.errorTemplate) );
}
}
protected boolean verificarTrabalhador( Object consultas[][], Object exames[][] )
public doGetListaTrabalhadoresTudo( HttpServletRequest req, HttpServletResponse res, boolean print )
throws Exception
{
boolean estadoConsultas = false;
boolean estadoExames = ( exames.length == 0 ) || ( ( java.util.Date )exames[ 0 ][ 0 ] ).before(today) ||
( ( ( ( java.util.Date )exames[ 0 ][ 0 ] ).getTime() - todayMillis ) / 86400000 > 14 );
if( consultas.length > 0 )
ServletOutputStream out = res.getOutputStream();
HttpSession session = req.getSession( false );
String userRole = ( String ) session.getAttribute( sessionUserRole );
String empresaID = ( String ) session.getAttribute( sessionEmpresaId );
String userName = ( String ) session.getAttribute( sessionUser );
String estabelecimentoID = ( String ) session.getAttribute( sessionEstabelecimentoId );
try
{
int anterior;
int proxima;
if( ( (java.util.Date) consultas[ 0 ][ 0 ] ).after( today ) )
if ( superUserRole.equals( userRole ) || userRole.equals( empresaID ) )
{
proxima = 0;
if( consultas.length >= 2 )
Class.forName( bdDriver );
Connection con = DriverManager.getConnection( bdLocalUrl, bdLocalUsername, bdLocalPassword );
if ( verificaEstabelecimento( con, empresaID, estabelecimentoID ) )
{
anterior = 1;
List< Map< String, Object > > data = new LinkedList< Map< String, Object > >();
String query = "select e.trabalhador_id, t.nome, max( e.data ) " +
"from exames e " +
"inner join trabalhadores t on ( t.id = e.trabalhador_id ) " +
"where " +
" e.inactivo != 'y' " +
" and t.inactivo != 'y' " +
" and t.data_demissao is null " +
" and t.estabelecimento_id = " + estabelecimentoID + " " +
"group by e.trabalhador_id, t.nome";
Statement stmt = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY );
Virtual2DArray array = new ResultSet2DArray( stmt.executeQuery( query ) );
for ( int i = 0; i < array.columnLength(); i++ )
{
Integer trabalhadorID = ( Integer ) array.get( i, 0 );
String trabalhadorNome = ( String ) array.get( i, 1 );
Date dataFicha = ( Date ) array.get( i, 2 );
String trabalhadorLink = "/" + servletName + "/?" + empresaID + "/" + estabelecimentoID + "/" + trabalhadorID;
Map< String, Object > worker = new HashMap< String, Object >();
worker.put( "trabalhador_id", trabalhadorID );
worker.put( "trabalhador_nome", trabalhadorNome );
worker.put( "trabalhador_link", trabalhadorLink );
worker.put( "ficha_aptidao_data", dataFicha );
data.add( worker );
}
String empresaNome = nomeEmpresa( con, empresaID );
String estabelecimentoNome = nomeEstabelecimento( con, estabelecimentoID );
Map< String, Object > hmValues = new HashMap< String, Object >();
hmValues.put( "empresa_nome", empresaNome /*session.getAttribute( sessionCompanyName )*/ );
hmValues.put( "empresa_id", empresaID );
hmValues.put( "estabelecimento_nome", estabelecimentoNome );
hmValues.put( "estabelecimento_id", estabelecimentoID );
hmValues.put( "userRole", userRole );
hmValues.put( "userName", userName );
hmValues.put( msgTemplate, "<b>" + empresaNome + "</b><br><br><i>" + estabelecimentoNome + "</i>" );
hmValues.put( templateUserRole, userRole );
hmValues.put( templateQuery, "trabalhadores_tudo" );
hmValues.put( templateVector1, data );
hmValues.put( templateVector2, null );
hmValues.put( templateVector3, null );
out.println( mergeTemplate( hmValues, ! print ? super.authenticatedUserTemplate : super.authenticatedUserPrintTemplate ) );
}
else
{
anterior = -1;
out.println( mergeTemplate( super.msgLinkFormatError, userRole, super.errorTemplate ) );
}
con.close();
}
else
{
proxima = -1;
anterior = 0;
out.println( mergeTemplate( super.msgAcessoNegado, userRole, super.errorTemplate ) );
}
estadoConsultas = anterior >= 0 && new Integer( 2 ).equals( consultas[ anterior ][ 1 ] ) &&
( proxima == -1 || ( ( ( java.util.Date )consultas[ proxima ][ 0 ] ).getTime() - todayMillis ) / 86400000 > 14 );
}
return estadoConsultas && estadoExames;
}
protected HashMap criarDadosTrabalhador( Integer id, String nome, java.util.Date ultimaConsulta )
throws Exception
{
Executer executer = getExecuter();
HashMap trabalhador = new HashMap();
trabalhador.put( "Nome", nome );
Select select =
new Select( new String[]{ "exames" }, new String[]{ "data" },
new Field( "trabalhador_id" ).isEqual( id ).and(
new Field( "data" ).isGreaterOrEqual( ultimaConsulta ) ),
new String[]{ "data" }, null );
// Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
// ResultSet2DArray rs = new ResultSet2DArray( stmt.executeQuery( select.toString() ) );
Virtual2DArray rs = executer.executeQuery( select );
Object data_ficha = rs.columnLength() > 0 ? rs.get( 0, 0 ) : null;
// stmt.close();
if( data_ficha == null )
catch ( SQLException e )
{
e.printStackTrace();
out.println( mergeTemplate( super.msgErroBd, super.errorTemplate ) );
}
catch ( Exception e )
{
return null;
// data_ficha = "";
e.printStackTrace();
out.println( mergeTemplate( super.msgGenericError, super.errorTemplate ) );
}
trabalhador.put( "Data", data_ficha );
return trabalhador;
}
// public doGetListaTrabalhadoresTudo( HttpServletRequest req, HttpServletResponse res, boolean print )
// throws IOException
// {
// ServletOutputStream out = res.getOutputStream();
// Connection con = null;
// Statement stmt = null;
// ResultSet2DArray rs;
// StringBuffer dbQuery, sBuffer;
// String userRole, empresaId, estabelecimentoId, temp;
// HttpSession session = req.getSession( false );
// Vector links = new Vector();
// Vector desc = new Vector();
// Vector descAdicional = new Vector();
// Date today = new Date();
// long todayMillis = today.getTime();
//
// try
// {
// userRole = ( String ) session.getAttribute( super.sessionUserRole );
// empresaId = ( String ) session.getAttribute( super.sessionEmpresaId );
// estabelecimentoId = ( String ) session.getAttribute( super.sessionEstabelecimentoId );
//
// if ( userRole.equals( super.superUserRole ) || userRole.equals( empresaId ) )
// {
// Class.forName( super.bdDriver );
// con = DriverManager.getConnection( bdLocalUrl, bdLocalUsername, bdLocalPassword );
// if ( verificaEstabelecimento( con, empresaId, estabelecimentoId ) )
// {
// // Class.forName(super.bdDriver);
// // con = DriverManager.getConnection( super.bdUrl,
// // super.bdUsername, super.bdPassword );
// dbQuery = new StringBuffer();
// // dbQuery.append(
// // "SELECT id, nome, data_ficha FROM trabalhadores "
// // + "WHERE estabelecimento_id = '"+estabelecimentoId+"'"
// // +
// // " AND ultima_consulta IS NOT NULL AND realizada = 'y' AND"
// // +
// // " ( proxima_consulta IS NULL OR proxima_consulta - current_date > 14 )"
// // +
// // " AND ( proximo_exame IS NULL OR proximo_exame - current_date > 14 )"
// // + " ORDER BY nome" );
// dbQuery.append( "SELECT trabalhadores.id, trabalhadores.nome, "
// + "marcacoes_trabalhador.tipo, marcacoes_trabalhador.data, "
// // + "marcacoes_trabalhador.estado, "
// + " trabalhadores.nome_plain " + "FROM trabalhadores, marcacoes_trabalhador " + "WHERE estabelecimento_id = " + estabelecimentoId
// + " AND marcacoes_trabalhador.trabalhador_id = trabalhadores.id " + " AND trabalhadores.inactivo <> 'y' AND data_demissao IS NULL "
// + "ORDER BY 5, 3, 4 DESC " );
// stmt = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY );
// rs = new ResultSet2DArray( stmt.executeQuery( dbQuery.toString() ) );
//
// int index = 0;
// int max = rs.columnLength();
//
// Integer trabalhadorID = new Integer( -1 );
// String nomeTrabalhador = "";
// Vector consultas = new Vector();
// Vector exames = new Vector();
//
// for ( index = 0; index <= max; index++ )
// {
// Integer id = index < max ? ( Integer ) rs.get( index, 0 ) : new Integer( -1 );
// if ( !id.equals( trabalhadorID ) )
// {
// Object listaConsultas[][] = ( Object[][] ) consultas.toArray( new Object[ consultas.size() ][ 2 ] );
// Object listaExames[][] = ( Object[][] ) exames.toArray( new Object[ exames.size() ][ 2 ] );
// if ( trabalhadorID.intValue() > -1 && verificarTrabalhador( listaConsultas, listaExames ) )
// {
// temp = "" + rs.get( index - 1, 0 ); // converter
// // de int
// // para
// // String
// java.util.Date dataUltimaConsulta = null;
// for ( int c = 0; c < listaConsultas.length; c++ )
// {
// if ( new Integer( 2 ).equals( listaConsultas[ c ][ 1 ] ) )
// {
// dataUltimaConsulta = ( java.util.Date ) listaConsultas[ c ][ 0 ];
// break;
// }
// }
// HashMap dadosTrabalhador = criarDadosTrabalhador( trabalhadorID, nomeTrabalhador, dataUltimaConsulta );
// if ( dadosTrabalhador != null )
// {
// dbQuery = new StringBuffer();
// dbQuery.append( "/" + super.servletName + "/?" + empresaId + "/" + estabelecimentoId + "/" + temp ); // construir
// // url
// links.add( dbQuery.toString() );
// desc.add( dadosTrabalhador );
// }
// }
// exames.clear();
// consultas.clear();
// }
// if ( index == max )
// {
// break;
// }
// Integer tipo = ( Integer ) rs.get( index, 2 );
// String nome = ( String ) rs.get( index, 1 );
// java.util.Date data = ( java.util.Date ) rs.get( index, 3 );
// // Integer estado = ( Integer ) rs.get( index, 4 );
// trabalhadorID = id;
// nomeTrabalhador = nome;
// // Object marcacao[] = new Object[]{ data, estado };
// // switch( tipo.intValue() )
// // {
// // case TIPO_MARCACAO_EXAMES:
// // exames.add( marcacao );
// // break;
// //
// // case TIPO_MARCACAO_CONSULTA:
// // consultas.add( marcacao );
// // break;
// // }
// }
// stmt.close();
//
// sBuffer = new StringBuffer();
// sBuffer.append( "<b>" + super.nomeEmpresa( con, empresaId ) + "</b><br><br><i>" + super.nomeEstabelecimento( con, estabelecimentoId )
// + "</i>" );
//
// HashMap hmValues = new HashMap();
// hmValues.put( "empresa_nome", session.getAttribute( sessionCompanyName ) );
// hmValues.put( "empresa_id", session.getAttribute( sessionEmpresaId ) );
// hmValues.put( "estabelecimento_nome", super.nomeEstabelecimento( con, estabelecimentoId ) );
// hmValues.put( "estabelecimento_id", estabelecimentoId );
// hmValues.put( "userRole", userRole );
// hmValues.put( "userName", session.getAttribute( sessionUser ) );
// hmValues.put( msgTemplate, sBuffer.toString() );
// hmValues.put( templateUserRole, userRole );
// hmValues.put( templateQuery, "trabalhadores_tudo" );
// hmValues.put( templateVector1, links );
// hmValues.put( templateVector2, desc );
// hmValues.put( templateVector3, null );
// if ( !print )
// {
// out.println( mergeTemplate( hmValues, super.authenticatedUserTemplate ) );
// }
// else
// {
// out.println( mergeTemplate( hmValues, super.authenticatedUserPrintTemplate ) );
// }
// // out.println( mergeTemplate( sBuffer.toString(), userRole,
// // super.queryStringTrabalhadores, links, desc, null,
// // super.authenticatedUserTemplate) );
// }
// else
// // est nao pertence 'a empresa
// {
// out.println( mergeTemplate( super.msgLinkFormatError, userRole, super.errorTemplate ) );
// }
// con.close();
// }
// else
// // Role nao permite ver esta informacao
// {
// out.println( mergeTemplate( super.msgAcessoNegado, userRole, super.errorTemplate ) );
// }
// }
// catch ( SQLException e )
// {
// e.printStackTrace();
// out.println( mergeTemplate( super.msgErroBd, super.errorTemplate ) );
// }
// catch ( Exception e )
// {
// e.printStackTrace();
// out.println( mergeTemplate( super.msgGenericError, super.errorTemplate ) );
// }
// }
//
// protected boolean verificarTrabalhador( Object consultas[][], Object exames[][] )
// {
// boolean estadoConsultas = false;
// boolean estadoExames = ( exames.length == 0 ) || ( ( java.util.Date ) exames[ 0 ][ 0 ] ).before( today )
// || ( ( ( ( java.util.Date ) exames[ 0 ][ 0 ] ).getTime() - todayMillis ) / 86400000 > 14 );
// if ( consultas.length > 0 )
// {
// int anterior;
// int proxima;
// if ( ( ( java.util.Date ) consultas[ 0 ][ 0 ] ).after( today ) )
// {
// proxima = 0;
// if ( consultas.length >= 2 )
// {
// anterior = 1;
// }
// else
// {
// anterior = -1;
// }
// }
// else
// {
// proxima = -1;
// anterior = 0;
// }
// estadoConsultas = anterior >= 0 && new Integer( 2 ).equals( consultas[ anterior ][ 1 ] )
// && ( proxima == -1 || ( ( ( java.util.Date ) consultas[ proxima ][ 0 ] ).getTime() - todayMillis ) / 86400000 > 14 );
// }
// return estadoConsultas && estadoExames;
// }
//
// protected HashMap criarDadosTrabalhador( Integer id, String nome, java.util.Date ultimaConsulta ) throws Exception
// {
// Executer executer = getExecuter();
// HashMap trabalhador = new HashMap();
// trabalhador.put( "Nome", nome );
// Select select = new Select( new String[] {
// "exames"
// }, new String[] {
// "data"
// }, new Field( "trabalhador_id" ).isEqual( id ).and( new Field( "data" ).isGreaterOrEqual( ultimaConsulta ) ), new String[] {
// "data"
// }, null );
//
// // Statement stmt =
// // con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
// // ResultSet.CONCUR_READ_ONLY);
// // ResultSet2DArray rs = new ResultSet2DArray( stmt.executeQuery(
// // select.toString() ) );
// Virtual2DArray rs = executer.executeQuery( select );
// Object data_ficha = rs.columnLength() > 0 ? rs.get( 0, 0 ) : null;
// // stmt.close();
// if ( data_ficha == null )
// {
// return null;
// // data_ficha = "";
// }
// trabalhador.put( "Data", data_ficha );
// return trabalhador;
// }
}

@ -6,6 +6,7 @@ import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;
import java.util.Iterator;
import java.util.Properties;
import java.util.StringTokenizer;
@ -298,7 +299,7 @@ System.out.println( "query: " + queryString );
}
public String mergeTemplate( HashMap values, String template )
public String mergeTemplate( Map values, String template )
{
VelocityContext context = new VelocityContext();
StringWriter output = new StringWriter();
@ -665,7 +666,7 @@ System.out.println( "query: " + queryString );
dbm = new JDBCManager( bdLocalUrl, bdLocalUsername, bdLocalPassword , 500, 499, 1, null );
context.setAttribute( Singleton.DEFAULT_DBMANAGER, dbm );
}
return dbm.getSharedExecuter();
return dbm.getSharedExecuter( this );
}
}

Loading…
Cancel
Save