diff --git a/branches/SIPRP/build.xml b/branches/SIPRP/build.xml index 6db0126e..2b42ba72 100644 --- a/branches/SIPRP/build.xml +++ b/branches/SIPRP/build.xml @@ -97,7 +97,7 @@ - + @@ -257,6 +257,7 @@ + @@ -265,7 +266,7 @@ - + diff --git a/branches/SIPRP/web/contents/user.html b/branches/SIPRP/web/contents/user.html index dd574756..37d25d06 100644 --- a/branches/SIPRP/web/contents/user.html +++ b/branches/SIPRP/web/contents/user.html @@ -174,20 +174,20 @@ #end #elseif( $query == "trabalhadores_tudo" ) - - - - - - #foreach( $element in $v1 ) - #set ( $counter = $velocityCount - 1 ) - #set ( $dados_trabalhador = $v2.get($counter) ) +
NomeData da Ficha de Aptidão
+ + + + + #foreach ( $trabalhador in $v1 ) - - + + #end -
NomeData da Ficha de Aptidão
$dados_trabalhador.Nome$dados_trabalhador.Data $trabalhador.trabalhador_nome$trabalhador.ficha_aptidao_data
+ + + #elseif( $query == "trabalhadores_pendentes" )
- Por Agendar diff --git a/branches/SIPRP/web/contents/user_print.html b/branches/SIPRP/web/contents/user_print.html index 589fd16c..6ee7b1d2 100644 --- a/branches/SIPRP/web/contents/user_print.html +++ b/branches/SIPRP/web/contents/user_print.html @@ -46,20 +46,19 @@ #elseif( $query == "trabalhadores_tudo" ) - - - - - - #foreach( $element in $v1 ) - #set ( $counter = $velocityCount - 1 ) - #set ( $dados_trabalhador = $v2.get($counter) ) - - - + +
  NomeData da Ficha de Aptidão
  $dados_trabalhador.Nome$dados_trabalhador.Data  
+ + + - #end -
NomeData da Ficha de Aptidão
+ #foreach ( $trabalhador in $v1 ) + + $trabalhador.trabalhador_nome + $trabalhador.ficha_aptidao_data + + #end + #elseif( $query == "trabalhadores_pendentes" ) @@ -77,26 +76,6 @@ #end - - #* -
(*)ECD - Exames Complementares de Diagnóstico
- - - - - - - #foreach( $element in $v1 ) - #set ( $counter = $velocityCount - 1 ) - #set ( $dados_trabalhador = $v2.get($counter) ) - - - - - - #end -
  NomeECD(*)Consulta
  $dados_trabalhador.Nome$dados_trabalhador.Exame_estado$dados_trabalhador.Consulta_estado
- *# #end
diff --git a/branches/SIPRP/web/lib/ashwood-2.0.jar b/branches/SIPRP/web/lib/ashwood-2.0.jar new file mode 100644 index 00000000..55fcc9b1 Binary files /dev/null and b/branches/SIPRP/web/lib/ashwood-2.0.jar differ diff --git a/branches/SIPRP/web/lib/commons-collections-3.1.jar b/branches/SIPRP/web/lib/commons-collections-3.1.jar new file mode 100644 index 00000000..41e230fe Binary files /dev/null and b/branches/SIPRP/web/lib/commons-collections-3.1.jar differ diff --git a/branches/SIPRP/web/lib/commons-lang-2.1.jar b/branches/SIPRP/web/lib/commons-lang-2.1.jar new file mode 100644 index 00000000..87b80ab5 Binary files /dev/null and b/branches/SIPRP/web/lib/commons-lang-2.1.jar differ diff --git a/branches/SIPRP/web/lib/commons-logging-1.1.jar b/branches/SIPRP/web/lib/commons-logging-1.1.jar new file mode 100644 index 00000000..2ff9bbd9 Binary files /dev/null and b/branches/SIPRP/web/lib/commons-logging-1.1.jar differ diff --git a/branches/SIPRP/web/lib/evologger.jar b/branches/SIPRP/web/lib/evologger.jar new file mode 100644 index 00000000..498b5d10 Binary files /dev/null and b/branches/SIPRP/web/lib/evologger.jar differ diff --git a/branches/SIPRP/web/lib/evolute.jar b/branches/SIPRP/web/lib/evolute.jar new file mode 100644 index 00000000..759e7a7d Binary files /dev/null and b/branches/SIPRP/web/lib/evolute.jar differ diff --git a/branches/SIPRP/web/lib/log4j-1.2.8.jar b/branches/SIPRP/web/lib/log4j-1.2.8.jar new file mode 100644 index 00000000..493a3ccc Binary files /dev/null and b/branches/SIPRP/web/lib/log4j-1.2.8.jar differ diff --git a/branches/SIPRP/web/lib/mail.jar b/branches/SIPRP/web/lib/mail.jar new file mode 100644 index 00000000..59543774 Binary files /dev/null and b/branches/SIPRP/web/lib/mail.jar differ diff --git a/branches/SIPRP/web/lib/postgresql-8.2-504.jdbc3.jar b/branches/SIPRP/web/lib/postgresql-8.2-504.jdbc3.jar deleted file mode 100644 index b450671d..00000000 Binary files a/branches/SIPRP/web/lib/postgresql-8.2-504.jdbc3.jar and /dev/null differ diff --git a/branches/SIPRP/web/lib/postgresql-9.0-801.jdbc4.jar b/branches/SIPRP/web/lib/postgresql-9.0-801.jdbc4.jar new file mode 100644 index 00000000..63e54165 Binary files /dev/null and b/branches/SIPRP/web/lib/postgresql-9.0-801.jdbc4.jar differ diff --git a/branches/SIPRP/web/src/siprp/pagina/NewsServlet.java b/branches/SIPRP/web/src/siprp/pagina/NewsServlet.java index 5122d6b2..f11c21eb 100644 --- a/branches/SIPRP/web/src/siprp/pagina/NewsServlet.java +++ b/branches/SIPRP/web/src/siprp/pagina/NewsServlet.java @@ -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(); diff --git a/branches/SIPRP/web/src/siprp/pagina/doGetListaTrabalhadoresTudo.java b/branches/SIPRP/web/src/siprp/pagina/doGetListaTrabalhadoresTudo.java index dc5166b5..2eddcd66 100644 --- a/branches/SIPRP/web/src/siprp/pagina/doGetListaTrabalhadoresTudo.java +++ b/branches/SIPRP/web/src/siprp/pagina/doGetListaTrabalhadoresTudo.java @@ -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(""+super.nomeEmpresa(con,empresaId)+"

" - +super.nomeEstabelecimento(con, estabelecimentoId)+"" ); - 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, "" + empresaNome + "

" + estabelecimentoNome + "" ); + 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( "" + super.nomeEmpresa( con, empresaId ) + "

" + super.nomeEstabelecimento( con, estabelecimentoId ) +// + "" ); +// +// 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; +// } } - diff --git a/branches/SIPRP/web/src/siprp/pagina/siprpServlet.java b/branches/SIPRP/web/src/siprp/pagina/siprpServlet.java index e7809e74..b8ae20fc 100644 --- a/branches/SIPRP/web/src/siprp/pagina/siprpServlet.java +++ b/branches/SIPRP/web/src/siprp/pagina/siprpServlet.java @@ -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 ); } }