diff --git a/trunk/PlanosActuacao/.classpath b/trunk/PlanosActuacao/.classpath index a564ab7b..1e95162f 100644 --- a/trunk/PlanosActuacao/.classpath +++ b/trunk/PlanosActuacao/.classpath @@ -3,76 +3,15 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - - - diff --git a/trunk/PlanosActuacao/.settings/org.eclipse.wst.common.project.facet.core.xml b/trunk/PlanosActuacao/.settings/org.eclipse.wst.common.project.facet.core.xml index daa6c333..a51df16b 100644 --- a/trunk/PlanosActuacao/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/trunk/PlanosActuacao/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,6 +1,6 @@ - + diff --git a/trunk/PlanosActuacao/ant/common/evo-app-build-common.xml b/trunk/PlanosActuacao/ant/common/evo-app-build-common.xml index 87fca9f3..ab030ae8 100644 --- a/trunk/PlanosActuacao/ant/common/evo-app-build-common.xml +++ b/trunk/PlanosActuacao/ant/common/evo-app-build-common.xml @@ -7,7 +7,7 @@ - + diff --git a/trunk/PlanosActuacao/ant/common/evo-app-compile-common.xml b/trunk/PlanosActuacao/ant/common/evo-app-compile-common.xml index 2997c34b..747dfbcd 100644 --- a/trunk/PlanosActuacao/ant/common/evo-app-compile-common.xml +++ b/trunk/PlanosActuacao/ant/common/evo-app-compile-common.xml @@ -75,6 +75,9 @@ + + + diff --git a/trunk/PlanosActuacao/ant/common/evo-app-deploy-common.xml b/trunk/PlanosActuacao/ant/common/evo-app-deploy-common.xml index a787f921..4f583da5 100644 --- a/trunk/PlanosActuacao/ant/common/evo-app-deploy-common.xml +++ b/trunk/PlanosActuacao/ant/common/evo-app-deploy-common.xml @@ -245,7 +245,8 @@ - + + @@ -272,8 +273,10 @@ + - + + @@ -286,7 +289,7 @@ - + @@ -294,16 +297,17 @@ + - + - + @@ -321,6 +325,7 @@ + @@ -353,6 +358,8 @@ + + @@ -362,8 +369,9 @@ + - + @@ -432,9 +440,11 @@ - + + + @@ -539,12 +549,20 @@ - - - - - - + + + + + + + + + + + + + + @@ -552,9 +570,22 @@ + + + + + + + + + + + + + - + @@ -632,6 +663,7 @@ + @@ -648,7 +680,7 @@ - + @@ -658,7 +690,7 @@ - + @@ -681,9 +713,9 @@ - + - + @@ -714,7 +746,7 @@ - + @@ -722,9 +754,27 @@ - + + + + + + + + + + + + + + + + + + + - + diff --git a/trunk/PlanosActuacao/ant/common/evo-app-load-properties.xml b/trunk/PlanosActuacao/ant/common/evo-app-load-properties.xml index 71186559..dc69ec77 100644 --- a/trunk/PlanosActuacao/ant/common/evo-app-load-properties.xml +++ b/trunk/PlanosActuacao/ant/common/evo-app-load-properties.xml @@ -17,7 +17,7 @@ - + @@ -36,7 +36,6 @@ - diff --git a/trunk/PlanosActuacao/ant/common/evo-web-build-common.xml b/trunk/PlanosActuacao/ant/common/evo-web-build-common.xml new file mode 100644 index 00000000..0a70a5b7 --- /dev/null +++ b/trunk/PlanosActuacao/ant/common/evo-web-build-common.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/trunk/PlanosActuacao/ant/common/evo-web-compile-common.xml b/trunk/PlanosActuacao/ant/common/evo-web-compile-common.xml new file mode 100644 index 00000000..0089b2ec --- /dev/null +++ b/trunk/PlanosActuacao/ant/common/evo-web-compile-common.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/trunk/PlanosActuacao/ant/common/evo-web-load-properties.xml b/trunk/PlanosActuacao/ant/common/evo-web-load-properties.xml new file mode 100644 index 00000000..0a94a7bd --- /dev/null +++ b/trunk/PlanosActuacao/ant/common/evo-web-load-properties.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/trunk/PlanosActuacao/ant/evo-web-build.xml b/trunk/PlanosActuacao/ant/evo-web-build.xml new file mode 100644 index 00000000..a1a26490 --- /dev/null +++ b/trunk/PlanosActuacao/ant/evo-web-build.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/trunk/PlanosActuacao/lib/evolute.jar b/trunk/PlanosActuacao/lib/evolute.jar index 180ccc93..ec566036 100644 Binary files a/trunk/PlanosActuacao/lib/evolute.jar and b/trunk/PlanosActuacao/lib/evolute.jar differ diff --git a/trunk/PlanosActuacao/lib/postgresql-9.2-1002.jdbc4.jar b/trunk/PlanosActuacao/lib/postgresql-9.3-1100-jdbc4.jar similarity index 62% rename from trunk/PlanosActuacao/lib/postgresql-9.2-1002.jdbc4.jar rename to trunk/PlanosActuacao/lib/postgresql-9.3-1100-jdbc4.jar index abd06ba3..f00ee16a 100644 Binary files a/trunk/PlanosActuacao/lib/postgresql-9.2-1002.jdbc4.jar and b/trunk/PlanosActuacao/lib/postgresql-9.3-1100-jdbc4.jar differ diff --git a/trunk/PlanosActuacao/lib/shst.jar b/trunk/PlanosActuacao/lib/shst.jar index 5523d79e..21931d58 100644 Binary files a/trunk/PlanosActuacao/lib/shst.jar and b/trunk/PlanosActuacao/lib/shst.jar differ diff --git a/trunk/PlanosActuacao/src/db/entidades/Area.java b/trunk/PlanosActuacao/src/db/entidades/Area.java index d5d24be9..fdc462e9 100644 --- a/trunk/PlanosActuacao/src/db/entidades/Area.java +++ b/trunk/PlanosActuacao/src/db/entidades/Area.java @@ -22,7 +22,49 @@ public class Area implements Serializable, Comparable< Area > private Integer ordem; private List riscos; - public Integer getId() { + public Area withId( final Integer id ) + { + this.id = id; + return this; + } + + public Area withArea_id( final Integer area_id ) + { + this.area_id = area_id; + return this; + } + + public Area withPlano_id( final Integer plano_id ) + { + this.plano_id = plano_id; + return this; + } + + public Area withDescricao( final String descricao ) + { + this.descricao = descricao; + return this; + } + + public Area withIs_principal( final Boolean is_principal ) + { + this.is_principal = is_principal; + return this; + } + + public Area withOrdem( final Integer ordem ) + { + this.ordem = ordem; + return this; + } + + public Area withRiscos( final List< Risco > riscos ) + { + this.riscos = riscos; + return this; + } + + public Integer getId() { return id; } diff --git a/trunk/PlanosActuacao/src/db/providers/GenericDataProvider.java b/trunk/PlanosActuacao/src/db/providers/GenericDataProvider.java index 0da93335..0d8418ef 100644 --- a/trunk/PlanosActuacao/src/db/providers/GenericDataProvider.java +++ b/trunk/PlanosActuacao/src/db/providers/GenericDataProvider.java @@ -8,13 +8,8 @@ package db.providers; import com.evolute.entity.ProviderInterface; import com.evolute.entity.evo.EvoDataException; import com.evolute.entity.evo.EvoDataObject; -import com.evolute.utils.db.DBException; import com.evolute.utils.db.Executer; -import com.evolute.utils.error.ErrorLogger; import db.DBConstants; -import java.sql.ResultSet; -import java.sql.Statement; - public abstract class GenericDataProvider { @@ -52,71 +47,4 @@ public abstract class GenericDataProvider { return localProvider; } - - -// public void checkConnection() -// { -// Db db = Db.getInstance(); -// if ( db.getConnection() == null ) -// { -// try -// { -// db.connect(); -// } -// catch ( Exception ex ) -// { -// ErrorLogger.logException( ex ); -// } -// } -// } - - protected Integer getMaxTableId(String table) - { - Statement st = createStatement(); - String id = table + ".id"; - String sql = "SELECT max(" + id + ")+1 AS MAXID FROM " + table; - try - { - ResultSet rs = st.executeQuery(sql); - rs.first(); - Integer newId = new Integer(rs.getInt("MAXID")); - if(newId.intValue() == 0) - { - newId = new Integer(1); - } - return newId; - } - catch(Exception ex) - { - return new Integer(1); - } - } - - protected Statement createStatement() - { - try - { -// Db db = Db.getInstance(); -// return db.createStatement(); - return EvoBaseProvider.getInstance().createStatement(); - } - catch ( DBException ex ) - { - ErrorLogger.logException( ex ); - } - return null; - } - - protected Statement createLocalStatement() - { - try - { - return EvoBaseProvider.getInstance().createLocalStatement(); - } - catch ( DBException ex ) - { - ErrorLogger.logException( ex ); - } - return null; - } } diff --git a/trunk/PlanosActuacao/src/db/providers/PlanosDataProvider.java b/trunk/PlanosActuacao/src/db/providers/PlanosDataProvider.java index b3956060..0cc0439b 100644 --- a/trunk/PlanosActuacao/src/db/providers/PlanosDataProvider.java +++ b/trunk/PlanosActuacao/src/db/providers/PlanosDataProvider.java @@ -17,7 +17,6 @@ import com.evolute.utils.sql.Select2; import com.evolute.utils.sql.Update; import com.evolute.utils.sql.expression.Par; import com.evolute.utils.strings.StringPlainer; -import db.data.siprp.outer.EstabelecimentosData; import db.data.siprp.outer.EstadoMedidasData; import db.data.siprp.outer.PlanoAreasData; import db.data.siprp.outer.PlanoMedidasData; @@ -33,7 +32,6 @@ import db.entidades.PlanoActuacao; import db.entidades.PostoTrabalho; import db.entidades.Risco; import db.entidades.Utilizador; -import java.sql.Timestamp; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -51,8 +49,6 @@ public class PlanosDataProvider extends GenericDataProvider protected static final String UNCONTROLLED = "Incontrolado"; protected static final String CONTROLLED = "Controlado"; protected static final String INDETERMINATE = "Indeterminado"; - protected static final String NAO_VALORAVEL = "N\u00E3o Valor\u00E1vel"; - protected static final String NAO_VALORAVEL_SHORT = "N/V"; protected static final String MUITO_ALTO = "Muito Alto"; protected static final String ALTO = "Alto"; protected static final String MEDIO = "M\u00e9dio"; @@ -92,19 +88,19 @@ public class PlanosDataProvider extends GenericDataProvider { p.setObservacoes_dns( "" ); } - if ( p.getUser_dir_loja() != null && p.getUser_dir_loja().intValue() == 0 ) + if ( p.getUser_dir_loja() != null && p.getUser_dir_loja() == 0 ) { p.setUser_dir_loja( null ); } - if ( p.getUser_dns() != null && p.getUser_dns().intValue() == 0 ) + if ( p.getUser_dns() != null && p.getUser_dns() == 0 ) { p.setUser_dns( null ); } - if ( p.getUser_hs() != null && p.getUser_hs().intValue() == 0 ) + if ( p.getUser_hs() != null && p.getUser_hs() == 0 ) { p.setUser_hs( null ); } - if ( p.getUser_seg() != null && p.getUser_seg().intValue() == 0 ) + if ( p.getUser_seg() != null && p.getUser_seg() == 0 ) { p.setUser_seg( null ); } @@ -122,7 +118,7 @@ public class PlanosDataProvider extends GenericDataProvider new Assignment( new Field( "obs_correcao" ), p.getObs_correcao() ), new Assignment( new Field( "correcao" ), p.getCorrecao() ), new Assignment( new Field( "fase_antes_correcao" ), p.getFase_antes_correcao() ), - new Assignment( new Field( "concluido_por_desactivacao" ), ( p.getConcluidoPorDesactivacao() == null ? new Boolean( false ) : p.getConcluidoPorDesactivacao() ) ), + new Assignment( new Field( "concluido_por_desactivacao" ), ( p.getConcluidoPorDesactivacao() == null ? Boolean.FALSE : p.getConcluidoPorDesactivacao() ) ), new Assignment( new Field( "data_desactivacao" ), p.getDataDesactivacao() ), new Assignment( new Field( "data_validacao_dir_loja" ), p.getData_validacao_dir_loja() ), new Assignment( new Field( "user_dir_loja" ), p.getUser_dir_loja() ), @@ -193,7 +189,7 @@ public class PlanosDataProvider extends GenericDataProvider for ( Medida m : medidas ) { Integer emID = null; - if ( m.getValidarMedidaId() != null && m.getValidarMedidaId().intValue() != 0 ) + if ( m.getValidarMedidaId() != null && m.getValidarMedidaId() != 0 ) { emID = m.getValidarMedidaId(); } @@ -210,38 +206,7 @@ public class PlanosDataProvider extends GenericDataProvider } } - - - -// private String getExpression( String nome, String estabelecimento, String dataVisita ) -// { -// String tables = "planos_actuacao"; -// String whereExpression = "planos_actuacao.deleted_date IS NULL "; -// -// if ( nome != null ) -// { -// nome = StringPlainer.convertString( nome.trim() ); -// nome = nome.replaceAll( " ", "%" ); -// whereExpression += "AND ( " + -// "plain_utf8( planos_actuacao.tecnico_hs_nome ) LIKE '%" + nome + "%' " + -// "OR plain_utf8( planos_actuacao.tecnico_superior_hs_nome ) LIKE '%" + nome + "%' " + -// ") "; -// } -// if ( estabelecimento != null ) -// { -// estabelecimento = StringPlainer.convertString( estabelecimento.trim() ); -// estabelecimento = estabelecimento.replaceAll( " ", "%" ); -// whereExpression += "AND plain_utf8( planos_actuacao.nome_estabelecimento ) LIKE '%" + estabelecimento + "%' "; -// } -// if ( dataVisita != null ) -// { -// whereExpression += "AND planos_actuacao.data_visita = '" + dataVisita + "' "; -// } -// -// return "SELECT * FROM " + tables + " WHERE " + whereExpression; -// } - - private enum SECTION { ACTIVOS, SEGUIMENTO, CONCLUIDOS; }; + private enum SECTION { ACTIVOS, SEGUIMENTO, CONCLUIDOS } private Select2 getExpression( SECTION section, Utilizador u, String nome, String estabelecimento, String dataVisita, Integer ano ) { @@ -263,7 +228,7 @@ public class PlanosDataProvider extends GenericDataProvider { where = where.and( faseExpression ); } - if( ano != null && ano.intValue() > 0 && dataVisita == null ) + if( ano != null && ano > 0 && dataVisita == null ) { where = where.and( new Field( "EXTRACT( year FROM " + PlanosActuacaoData.DATA_VISITA_FULL + " )" ).isEqual( ano) ); } @@ -361,11 +326,6 @@ public class PlanosDataProvider extends GenericDataProvider Virtual2DArray array = getExecuter().executeQuery( query ); return getFullPlanos( array ); -// String sql = getExpression( nome, estabelecimento, dataVisita ); -// sql += " AND " + getFaseActivos( u ); -// Statement st = createStatement(); -// ResultSet rs = st.executeQuery( query ); -// return getFullPlanos( rs ); } public List< PlanoActuacao > searchPlanosSeguimento( Utilizador u, String nome, String estabelecimento, String dataVisita, Integer ano ) @@ -378,12 +338,6 @@ public class PlanosDataProvider extends GenericDataProvider Virtual2DArray array = getExecuter().executeQuery( query ); return getFullPlanos( array ); - -// String sql = getExpression( nome, estabelecimento, dataVisita ); -// sql += " AND " + getFaseSeguimento( u ); -// Statement st = createStatement(); -// ResultSet rs = st.executeQuery( sql ); -// return getFullPlanos( rs ); } public List< PlanoActuacao > searchPlanosConcluidos( Utilizador u, String nome, String estabelecimento, String dataVisita, Integer ano ) @@ -396,12 +350,6 @@ public class PlanosDataProvider extends GenericDataProvider Virtual2DArray array = getExecuter().executeQuery( query ); return getFullPlanos( array ); - -// String sql = getExpression( nome, estabelecimento, dataVisita ); -// sql += " AND " + getFaseConcluidos( u ); -// Statement st = createStatement(); -// ResultSet rs = st.executeQuery( sql ); -// return getFullPlanos( rs ); } @@ -409,135 +357,62 @@ public class PlanosDataProvider extends GenericDataProvider private Expression getFaseActivos( Utilizador u ) { Expression result = null; - int userType = u.getTipo().intValue(); + int userType = u.getTipo(); switch ( userType ) { case Global.TECNICO_HS : result = new Par( - new Field( "fase" ).isEqual( new Integer( 1 ) ) - .or( new Field( "fase" ).isEqual( new Integer( 5 ) ) ) + new Field( "fase" ).isEqual( 1 ) + .or( new Field( "fase" ).isEqual( 5 ) ) ); break; case Global.RESPONSAVEL_SEGURANCA : - result = new Field( "fase" ).isEqual( new Integer( 2 ) ); + result = new Field( "fase" ).isEqual( 2 ); break; case Global.DIRECTOR_LOJA : - result = new Field( "fase" ).isEqual( new Integer( 3 ) ); + result = new Field( "fase" ).isEqual( 3 ); break; case Global.DIRECTOR_NACIONAL_SEGURANCA : - result = new Field( "fase" ).isEqual( new Integer( 4 ) ); + result = new Field( "fase" ).isEqual( 4 ); break; } if ( userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS && userType != Global.DIRECTOR_NACIONAL_SEGURANCA ) { - Expression expr = new Field( "estabelecimento_id" ).isEqual( new Integer( u.getEstabelecimento_id() ) ); + Expression expr = new Field( "estabelecimento_id" ).isEqual( u.getEstabelecimento_id() ); result = result == null ? expr : result.and( expr ); } return result; } -// private String getFaseActivos( Utilizador u ) -// { -// String sql = ""; -// int userType = u.getTipo().intValue(); -// switch ( userType ) -// { -// case Global.TECNICO_HS: -// sql += " AND (fase = 1 OR fase = 5)"; -// break; -// -// case Global.RESPONSAVEL_SEGURANCA: -// sql += " AND fase = 2"; -// break; -// -// case Global.DIRECTOR_LOJA: -// sql += " AND fase = 3"; -// break; -// -// case Global.DIRECTOR_NACIONAL_SEGURANCA: -// sql += " AND fase = 4"; -// break; -// } -// if ( userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS && userType != Global.DIRECTOR_NACIONAL_SEGURANCA ) -// { -// sql += " AND estabelecimento_id = " + u.getEstabelecimento_id(); -// } -// -// return sql; -// } - -// private String getFaseSeguimento( Utilizador u ) -// { -// int userType = u.getTipo(); -// String sql = ""; -// switch( userType ) -// { -// case Global.TECNICO_HS: -// sql = " AND (fase <> 1 AND fase <> 5 AND fase <> 6) "; -// break; -// case Global.RESPONSAVEL_SEGURANCA: -// sql = " AND (fase <> 2 AND fase <> 6) "; -// break; -// case Global.DIRECTOR_LOJA: -// sql = " AND (fase <> 3 AND fase <> 6) "; -// break; -// case Global.DIRECTOR_NACIONAL_SEGURANCA: -// sql = " AND (fase <> 4 AND fase <> 6) "; -// break; -// case Global.DIRECTOR_SIPRP: -// case Global.RH: -// case Global.DIRECTOR_GERAL_RH: -// case Global.GESTOR: -// sql = " AND (fase > 1 AND fase < 6) "; -// break; -// default: -// break; -// } -// -// if ( userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS -// && userType != Global.DIRECTOR_NACIONAL_SEGURANCA && userType != Global.DIRECTOR_GERAL_RH -// && userType != Global.GESTOR ) -// { -// sql += " AND estabelecimento_id = " + u.getEstabelecimento_id(); -// } -// if ( userType == Global.GESTOR ) -// { -// if ( u.getEstabelecimento_gestor().intValue() > 0 ) -// { -// sql += " AND estabelecimento_id = " + u.getEstabelecimento_gestor(); -// } -// } -// return sql; -// } private Expression getFaseSeguimento( Utilizador u ) { Expression result = null; - int userType = u.getTipo().intValue(); + int userType = u.getTipo(); switch ( userType ) { case Global.TECNICO_HS : result = new Par( - new Field( "fase" ).isDifferent( new Integer( 1 ) ) - .and( new Field( "fase" ).isDifferent( new Integer( 5 ) ) ) - .and( new Field( "fase" ).isDifferent( new Integer( 6 ) ) ) + new Field( "fase" ).isDifferent( 1 ) + .and( new Field( "fase" ).isDifferent( 5 ) ) + .and( new Field( "fase" ).isDifferent( 6 ) ) ); break; case Global.RESPONSAVEL_SEGURANCA : result = new Par( - new Field( "fase" ).isDifferent( new Integer( 2 ) ) - .and( new Field( "fase" ).isDifferent( new Integer( 6 ) ) ) + new Field( "fase" ).isDifferent( 2 ) + .and( new Field( "fase" ).isDifferent( 6 ) ) ); break; case Global.DIRECTOR_LOJA : result = new Par( - new Field( "fase" ).isDifferent( new Integer( 3 ) ) - .and( new Field( "fase" ).isDifferent( new Integer( 6 ) ) ) + new Field( "fase" ).isDifferent( 3 ) + .and( new Field( "fase" ).isDifferent( 6 ) ) ); break; case Global.DIRECTOR_NACIONAL_SEGURANCA : result = new Par( - new Field( "fase" ).isDifferent( new Integer( 4 ) ) - .and( new Field( "fase" ).isDifferent( new Integer( 6 ) ) ) + new Field( "fase" ).isDifferent( 4 ) + .and( new Field( "fase" ).isDifferent( 6 ) ) ); break; case Global.DIRECTOR_SIPRP : @@ -545,8 +420,8 @@ public class PlanosDataProvider extends GenericDataProvider case Global.DIRECTOR_GERAL_RH : case Global.GESTOR : result = new Par( - new Field( "fase" ).isGreater( new Integer( 1 ) ) - .and( new Field( "fase" ).isLess( new Integer( 6 ) ) ) + new Field( "fase" ).isGreater( 1 ) + .and( new Field( "fase" ).isLess( 6 ) ) ); break; } @@ -560,32 +435,19 @@ public class PlanosDataProvider extends GenericDataProvider } if ( userType == Global.GESTOR ) { - if ( u.getEstabelecimento_gestor().intValue() > 0 ) + if ( u.getEstabelecimento_gestor() > 0 ) { Expression expr = new Field( "estabelecimento_id" ).isEqual( u.getEstabelecimento_gestor() ); - result = result == null ? expr : result.and( expr ); + result = result.and( expr ); } } return result; } -// private String getFaseConcluidos( Utilizador u ) -// { -// int userType = u.getTipo().intValue(); -// String sql = " AND fase = 6 "; -// -// if ( userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS -// && userType != Global.DIRECTOR_NACIONAL_SEGURANCA && userType != Global.DIRECTOR_GERAL_RH ) -// { -// sql += " AND estabelecimento_id = " + u.getEstabelecimento_id(); -// } -// -// return sql; -// } private Expression getFaseConcluidos( Utilizador u ) { - Expression result = new Field( "fase" ).isEqual( new Integer( 6 ) ); - int userType = u.getTipo().intValue(); + Expression result = new Field( "fase" ).isEqual( 6 ); + int userType = u.getTipo(); if ( userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS && userType != Global.DIRECTOR_NACIONAL_SEGURANCA && userType != Global.DIRECTOR_GERAL_RH && userType != Global.GESTOR ) @@ -595,14 +457,12 @@ public class PlanosDataProvider extends GenericDataProvider return result; } - - private List< PlanoActuacao > getFullPlanos( Virtual2DArray array ) { List< PlanoActuacao > result = new LinkedList< PlanoActuacao >(); if ( array != null ) { - for ( int i = 0; i < array.columnLength(); i++ ) + for ( int i = 0; i < array.rowCount(); i++ ) { Integer estabelecimentoID = array.get( i, 0 ); Integer fase = array.get( i, 1 ); @@ -611,7 +471,6 @@ public class PlanosDataProvider extends GenericDataProvider Boolean validacaoDirectorLoja = array.get( i, 4 ); Boolean validacaoDNS = array.get( i, 5 ); Boolean validacaoHS = array.get( i, 6 ); - String parecerDNS = array.get( i, 7 ); String observacaoCorreccao = array.get( i, 8 ); Date dataValidacaoDirectorLoja = array.get( i, 9 ); Integer userDirectorLoja = array.get( i, 10 ); @@ -623,16 +482,10 @@ public class PlanosDataProvider extends GenericDataProvider String correccao = array.get( i, 16 ); String observacoesDL = array.get( i, 17 ); String observacoesDNS = array.get( i, 18 ); - String verificacaoSIPRP = array.get( i, 19 ); - Date dataControlo = array.get( i, 20 ); - Date dataEmailControlo = array.get( i, 21 ); - Integer empresaID = array.get( i, 22 ); String nomeEmpresa = array.get( i, 23 ); Integer tecnicoHSID = array.get( i, 24 ); String tecnicoHSNome = array.get( i, 25 ); Integer id = array.get( i, 26 ); - Date dataRelatorio = array.get( i, 27 ); - Timestamp deletedStamp = array.get( i, 28 ); Boolean concluidoPorDesactivacao = array.get( i, 29 ); Integer tecnicoSuperiorHSID = array.get( i, 30 ); String tecnicoSuperiorHSNome = array.get( i, 31 ); @@ -678,68 +531,13 @@ public class PlanosDataProvider extends GenericDataProvider pa.setHs_relatorio_id( hsRelatorioID ); pa.setTem_patrimoniais( temPatrimoniais ); -// pa.setData_controlo( dataControlo ); -// pa.setData_email_controlo( dataEmailControlo ); -// pa.setEmpresa_id( empresaID ); -// pa.setData_relatorio( dataRelatorio ); - result.add( pa ); } } return result; } -// private List< PlanoActuacao > getFullPlanos( ResultSet rs ) throws Exception -// { -// List< PlanoActuacao > list = new LinkedList< PlanoActuacao >(); -// if ( rs.isBeforeFirst() ) -// { -// rs.first(); -// do -// { -// PlanoActuacao pa = new PlanoActuacao(); -// pa.setId( new Integer( rs.getInt("id") ) ); -// pa.setEstabelecimento_id( new Integer( rs.getInt( "estabelecimento_id" ) ) ); -// pa.setNome_estabelecimento( Utils.unicodeToHTML( rs.getString( "nome_estabelecimento" ) ) ); -// pa.setNome_empresa( Utils.unicodeToHTML( rs.getString( "nome_empresa" ) ) ); -// pa.setFase( new Integer( rs.getInt( "fase" ) ) ); -// java.sql.Date sqlDate = rs.getDate( "data_visita" ); -// pa.setData_visita( new java.util.Date( sqlDate.getTime() ) ); -// pa.setValidacao_director_loja( new Boolean( rs.getBoolean( "validacao_director_loja" ) ) ); -// pa.setValidacao_dns( new Boolean( rs.getBoolean("validacao_dns") ) ); -// pa.setValidacao_hs( new Boolean( rs.getBoolean("validacao_hs") ) ); -// pa.setObservacoes_dl( Utils.unicodeToHTML( rs.getString("observacoes_dl") ) ); -// pa.setObservacoes_dns( Utils.unicodeToHTML( rs.getString("observacoes_dns") ) ); -// pa.setObs_correcao( Utils.unicodeToHTML( rs.getString("obs_correcao") ) ); -// pa.setAreas( getAreasByPlano( pa ) ); -// pa.setTotal_riscos( getTotalRiscosByPlano( pa.getId() ) ); -// pa.setCorrecao( Utils.unicodeToHTML( rs.getString( "correcao") ) ); -// pa.setFase_antes_correcao( new Integer( rs.getInt( "fase_antes_correcao" ) ) ); -// pa.setData_validacao_dir_loja( rs.getDate( "data_validacao_dir_loja" ) ); -// pa.setUser_dir_loja( new Integer( rs.getInt( "user_dir_loja" ) ) ); -// pa.setData_validacao_dns( rs.getDate( "data_validacao_dns" ) ); -// pa.setUser_dns( new Integer( rs.getInt( "user_dns" ) ) ); -// pa.setData_validacao_hs( rs.getDate( "data_validacao_hs" ) ); -// pa.setUser_hs( new Integer( rs.getInt( "user_hs" ) ) ); -// pa.setTecnico_hs_id( new Integer( rs.getInt( "tecnico_hs_id" ) ) ); -// pa.setTecnico_hs_nome( Utils.unicodeToHTML( rs.getString("tecnico_hs_nome") ) ); -// pa.setConcluidoPorDesactivacao( new Boolean( rs.getBoolean( "concluido_por_desactivacao" ) ) ); -// pa.setDataDesactivacao( rs.getDate( "data_desactivacao" ) ); -// pa.setTecnico_superior_hs_id( new Integer( rs.getInt( "tecnico_superior_hs_id" ) ) ); -// pa.setTecnico_superior_hs_nome( Utils.unicodeToHTML( rs.getString( "tecnico_superior_hs_nome" ) ) ); -// pa.setData_disponibilizacao( rs.getDate( "data_disponibilizacao" ) ); -// pa.setData_validacao_seg( rs.getDate( "data_validacao_seg" ) ); -// pa.setUser_seg( rs.getInt( "user_seg" ) ); -// pa.setHs_relatorio_id( rs.getInt( "hs_relatorio_id" ) ); -// -// list.add( pa ); -// } -// while ( rs.next() ); -// } -// return list; -// } - - private List< Area > getAreasByPlanoID( final Integer planoID ) + private List< Area > getAreasByPlanoID( final Integer planoID ) { List< Area > list = new LinkedList< Area >(); try @@ -751,9 +549,9 @@ public class PlanosDataProvider extends GenericDataProvider new String[] { PlanoAreasData.DESCRICAO_FULL } ); Virtual2DArray array = getExecuter().executeQuery( query ); - if ( array != null && array.columnLength() > 0 ) + if ( array != null && array.rowCount() > 0 ) { - for ( int i = 0; i < array.columnLength(); i++ ) + for ( int i = 0; i < array.rowCount(); i++ ) { Integer areaID = array.get( i, 0 ); Integer pID = array.get( i, 1 ); @@ -782,10 +580,6 @@ public class PlanosDataProvider extends GenericDataProvider /** * FIXME : ORDER BY patrimonial em ultimo ! - * - * @param a - * @return - * @throws Exception */ private List< Risco > getRiscosByArea( Area a ) throws Exception { @@ -805,9 +599,9 @@ public class PlanosDataProvider extends GenericDataProvider query.disableOrderFieldsVerification(); Virtual2DArray array = getExecuter().executeQuery( query ); - if ( array != null && array.columnLength() > 0 ) + if ( array != null && array.rowCount() > 0 ) { - for ( int i = 0; i < array.columnLength(); i++ ) + for ( int i = 0; i < array.rowCount(); i++ ) { Integer riscoID = array.get( i, 0 ); Integer areaID = array.get( i, 1 ); @@ -924,7 +718,7 @@ public class PlanosDataProvider extends GenericDataProvider Virtual2DArray array = getExecuter().executeQuery( query ); if ( array != null ) { - for ( int i = 0; i < array.columnLength(); i++ ) + for ( int i = 0; i < array.rowCount(); i++ ) { Integer planoMedidaID = array.get( i, 0 ); String descricao = array.get( i, 1 ); @@ -956,7 +750,7 @@ public class PlanosDataProvider extends GenericDataProvider Virtual2DArray array = getExecuter().executeQuery( query ); if ( array != null ) { - for ( int i = 0; i < array.columnLength(); i++ ) + for ( int i = 0; i < array.rowCount(); i++ ) { Integer planoPostoTrabalhoID = array.get( i, 0 ); Integer medidaID = array.get( i, 1 ); @@ -999,7 +793,7 @@ public class PlanosDataProvider extends GenericDataProvider null ); Virtual2DArray array = getExecuter().executeQuery( query ); - if ( array != null && array.columnLength() > 0 ) + if ( array != null && array.rowCount() > 0 ) { Long countL = array.get( 0, 0 ); count = countL == null ? 0 : countL.intValue(); @@ -1027,12 +821,10 @@ public class PlanosDataProvider extends GenericDataProvider Virtual2DArray array = getExecuter().executeQuery( query ); if ( array != null ) { - for ( int i = 0; i < array.columnLength(); i++ ) + for ( int i = 0; i < array.rowCount(); i++ ) { Integer estadoID = array.get( i, 0 ); String descricao = array.get( i, 1 ); - Integer ordem = array.get( i, 2 ); - String activo = array.get( i, 3 ); EstadoMedida estado = new EstadoMedida(); estado.setId( estadoID ); @@ -1043,11 +835,6 @@ public class PlanosDataProvider extends GenericDataProvider return list; } -// public HsRelatorioRiscoValorQualitativoData loadValorQualitativoByID( Integer valorID ) throws Exception -// { -// return getLocalProvider().load( HsRelatorioRiscoValorQualitativoData.class, valorID, HsRelatorioRiscoValorQualitativoData.ID ); -// } - public void loadValoresQualitativos() throws Exception { VALORES_QUALITATIVOS_BY_ID.clear(); @@ -1065,7 +852,6 @@ public class PlanosDataProvider extends GenericDataProvider public PlanoValoresQualitativosData loadValorQualitativoByID( Integer valorID ) throws Exception { -// return getProvider().load( PlanoValoresQualitativosData.class, valorID, PlanoValoresQualitativosData.ID ); if( !VALORES_QUALITATIVOS_BY_ID.containsKey( valorID) ) { loadValoresQualitativos(); @@ -1092,7 +878,7 @@ public class PlanosDataProvider extends GenericDataProvider null, null, null ); query.disableOrderFieldsVerification(); Virtual2DArray array = getExecuter().executeQuery( query ); - for ( int i = 0; i < array.columnLength(); i++ ) + for ( int i = 0; i < array.rowCount(); i++ ) { Integer ano = array.get( i, 0 ); result.add( ano ); @@ -1129,7 +915,7 @@ public class PlanosDataProvider extends GenericDataProvider int total = 0; String last = null; int totalEstado = 0; - for( int n = 0; n < array.columnLength(); n++ ) + for( int n = 0; n < array.rowCount(); n++ ) { String estado = array.get( n, 0 ); if( last == null ? estado != null : !last.equals( estado ) ) @@ -1219,7 +1005,7 @@ public class PlanosDataProvider extends GenericDataProvider int total = 0; String last = null; int totalEstado = 0; - for( int n = 0; n < array.columnLength(); n++ ) + for( int n = 0; n < array.rowCount(); n++ ) { String estado = array.get( n, 0 ); if( last == null ? estado != null : !last.equals( estado ) ) @@ -1250,13 +1036,12 @@ public class PlanosDataProvider extends GenericDataProvider return linhas; } -// public List getEstabelecimentosForEstatistica( Utilizador u ) public List getEstabelecimentosForEstatistica( Utilizador u ) throws Exception { Expression exp = new Field( db.data.siprp_local.outer.EstabelecimentosData.EMPRESA_ID_FULL ).isEqual( 32 ).and( new Field( db.data.siprp_local.outer.EstabelecimentosData.INACTIVO_FULL ).isDifferent( "y" ) ); - int userType = u.getTipo().intValue(); + int userType = u.getTipo(); if ( userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS && userType != Global.DIRECTOR_NACIONAL_SEGURANCA && userType != Global.DIRECTOR_GERAL_RH && userType != Global.GESTOR ) @@ -1275,22 +1060,10 @@ public class PlanosDataProvider extends GenericDataProvider null); Virtual2DArray array = getLocalExecuter().executeQuery( select ); List estabelecimentos = new ArrayList(); - for( int n = 0; n < array.columnLength(); n++ ) + for( int n = 0; n < array.rowCount(); n++ ) { - estabelecimentos.add( new MappableObject( ( Integer ) array.get( n, 0), ( String ) array.get( n, 1 ) ) ); + estabelecimentos.add( new MappableObject( ( Integer ) array.get( n, 0), array.get( n, 1 ) ) ); } return estabelecimentos; -// int userType = u.getTipo().intValue(); -// if ( userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS -// && userType != Global.DIRECTOR_NACIONAL_SEGURANCA && userType != Global.DIRECTOR_GERAL_RH -// && userType != Global.GESTOR ) -// { -// return getProvider().listLoad( EstabelecimentosData.class, new Object[]{ u.getEstabelecimento_id() }, -// new String[]{ EstabelecimentosData.ID_FULL }, new String[]{ EstabelecimentosData.NOME_FULL } ); -// } -// else -// { -// return getProvider().listLoad( EstabelecimentosData.class, EstabelecimentosData.NOME_FULL); -// } } } diff --git a/trunk/PlanosActuacao/src/db/providers/RelatoriosDataProvider.java b/trunk/PlanosActuacao/src/db/providers/RelatoriosDataProvider.java index 68af45e1..106692f9 100644 --- a/trunk/PlanosActuacao/src/db/providers/RelatoriosDataProvider.java +++ b/trunk/PlanosActuacao/src/db/providers/RelatoriosDataProvider.java @@ -5,8 +5,20 @@ package db.providers; +import com.evolute.utils.arrays.Virtual2DArray; import com.evolute.utils.error.ErrorLogger; +import com.evolute.utils.sql.Expression; +import com.evolute.utils.sql.Field; +import com.evolute.utils.sql.Select; +import com.evolute.utils.sql.Select2; import db.data.siprp_local.outer.EmpresasData; +import db.data.siprp_local.outer.HsRelatorioAreaData; +import db.data.siprp_local.outer.HsRelatorioData; +import db.data.siprp_local.outer.HsRelatorioMedidaData; +import db.data.siprp_local.outer.HsRelatorioPostoData; +import db.data.siprp_local.outer.HsRelatorioPostoMedidaData; +import db.data.siprp_local.outer.HsRelatorioPostoRiscoData; +import db.data.siprp_local.outer.HsRelatorioRiscoData; import db.data.siprp_local.outer.ImageData; import db.entidades.Area; import db.entidades.Medida; @@ -14,8 +26,8 @@ import db.entidades.PlanoActuacao; import db.entidades.PostoTrabalho; import db.entidades.Risco; import db.entidades.Valor; -import java.sql.ResultSet; -import java.sql.Statement; + +import java.text.MessageFormat; import java.util.LinkedList; import java.util.List; import utils.Utils; @@ -26,14 +38,11 @@ import utils.Utils; */ public class RelatoriosDataProvider extends GenericDataProvider { -// private DbLocal dblocal = DbLocal.getInstance(); - private static RelatoriosDataProvider INSTANCE = null; private RelatoriosDataProvider() throws Exception { super(); -// dblocal.connect(); } public static synchronized RelatoriosDataProvider getInstance() throws Exception @@ -45,9 +54,12 @@ public class RelatoriosDataProvider extends GenericDataProvider return INSTANCE; } - + + @SuppressWarnings( "UnusedDeclaration" ) public PlanoActuacao getFullPlano(PlanoActuacao plano, Integer relatorioId) { + //TODO: Check method (file) usage + try { plano = getAreasByPlano(plano, relatorioId); @@ -56,302 +68,266 @@ public class RelatoriosDataProvider extends GenericDataProvider { ErrorLogger.logException( ex ); } - + return plano; } private PlanoActuacao getAreasByPlano( PlanoActuacao plano, Integer relatorioID ) throws Exception { - Statement st = createLocalStatement(); - - String sql = "select distinct area_id, hs_relatorio_area.description as descricao from hs_relatorio_posto "; - sql += "inner join hs_relatorio_posto_medida on hs_relatorio_posto_medida.posto_id = hs_relatorio_posto.id "; - sql += "inner join hs_relatorio_medida on hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id "; - sql += "inner join hs_relatorio_risco on hs_relatorio_risco.id = hs_relatorio_medida.risco_id "; - sql += "inner join hs_relatorio on hs_relatorio.id = hs_relatorio_risco.relatorio_id "; - sql += "inner join hs_relatorio_area on hs_relatorio_area.id = area_id "; - sql += "where hs_relatorio.id = " + relatorioID + " "; - sql += "order by area_id "; - System.out.println("AREAS BY PLANO SQL : " + sql); - ResultSet rs = st.executeQuery(sql); + Select select = new Select2( + new String[] { HsRelatorioPostoData.TABLENAME, HsRelatorioPostoMedidaData.TABLENAME, + HsRelatorioMedidaData.TABLENAME, HsRelatorioRiscoData.TABLENAME, + HsRelatorioData.TABLENAME, HsRelatorioAreaData.TABLENAME }, + new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER }, + new Expression[]{ + new Field( HsRelatorioPostoMedidaData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ), + new Field( HsRelatorioMedidaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoMedidaData.MEDIDA_ID_FULL ) ), + new Field( HsRelatorioRiscoData.ID_FULL ).isEqual( new Field( HsRelatorioMedidaData.RISCO_ID_FULL ) ), + new Field( HsRelatorioData.ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.RELATORIO_ID_FULL ) ), + new Field( HsRelatorioAreaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoData.AREA_ID_FULL ) ) + }, + new String[]{ "distinct " + HsRelatorioPostoData.AREA_ID_FULL, HsRelatorioAreaData.DESCRIPTION_FULL }, + new Field( HsRelatorioData.ID_FULL ).isEqual( relatorioID ), + new String[]{ HsRelatorioPostoData.AREA_ID_FULL }, null, null, null + ); + + Virtual2DArray res = getLocalExecuter().executeQuery( select ); List< Area > areas = new LinkedList< Area >(); - if ( rs.isBeforeFirst() ) - { - rs.first(); - do + + for( int i = 0; i < res.rowCount(); i++ ) + { + Integer rId = res.get( i, 0 ); + String rDescription = res.get( i, 1 ); + List< Risco > rRiscos = null; + + if(existemMedidasByArea(rId)) { - Area a = new Area(); - a.setId(new Integer( rs.getInt("area_id") )); - a.setArea_id(a.getId()); - if(existemMedidasByArea(a.getId())) + Area a = new Area().withArea_id( rId ).withId( rId ); + + rDescription = Utils.unicodeToHTML( rDescription ); + try { - a.setDescricao(Utils.unicodeToHTML(rs.getString("descricao"))); - try - { - a.setRiscos(getRiscosByArea(a)); - } - catch(Exception ex) - { - System.out.println("ERRO RISCOS BY AREA !!!!"); - ErrorLogger.logException( ex ); - a.setRiscos(null); - } - - areas.add(a); + rRiscos = getRiscosByArea( a ); } + catch( Exception ex ) + { + System.out.println( "ERRO RISCOS BY AREA !!!!" ); + ErrorLogger.logException( ex ); + } + areas.add( a.withDescricao( rDescription ).withRiscos( rRiscos ) ); + } + } + + if( !areas.isEmpty() ) + { + plano.setAreas( areas ); + } - }while(rs.next()); - plano.setAreas(areas); - } return plano; } - + private List getRiscosByArea(Area a) throws Exception { -// Statement st = dblocal.createStatement(); - Statement st = createLocalStatement(); - - String sql = "select distinct hs_relatorio_risco.id, hs_relatorio_risco.description as descricao from hs_relatorio_posto "; - sql += "inner join hs_relatorio_posto_medida on hs_relatorio_posto_medida.posto_id = hs_relatorio_posto.id "; - sql += "inner join hs_relatorio_medida on hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id "; - sql += "inner join hs_relatorio_risco on hs_relatorio_risco.id = hs_relatorio_medida.risco_id "; - sql += "inner join hs_relatorio on hs_relatorio.id = hs_relatorio_risco.relatorio_id "; - sql += "inner join hs_relatorio_area on hs_relatorio_area.id = area_id "; - sql += "where area_id = " + a.getId() + " "; - sql += "order by hs_relatorio_risco.id "; - System.out.println("RISCOS BY AREA SQL : " + sql); - ResultSet rs = st.executeQuery(sql); + Select select = new Select2( + new String[] { HsRelatorioPostoData.TABLENAME, HsRelatorioPostoMedidaData.TABLENAME, + HsRelatorioMedidaData.TABLENAME, HsRelatorioRiscoData.TABLENAME, + HsRelatorioData.TABLENAME, HsRelatorioAreaData.TABLENAME }, + new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER }, + new Expression[]{ + new Field( HsRelatorioPostoMedidaData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ), + new Field( HsRelatorioMedidaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoMedidaData.MEDIDA_ID_FULL ) ), + new Field( HsRelatorioRiscoData.ID_FULL ).isEqual( new Field( HsRelatorioMedidaData.RISCO_ID_FULL ) ), + new Field( HsRelatorioData.ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.RELATORIO_ID_FULL ) ), + new Field( HsRelatorioAreaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoData.AREA_ID_FULL ) ) + }, + new String[]{ "distinct " + HsRelatorioRiscoData.ID_FULL, HsRelatorioRiscoData.DESCRIPTION_FULL }, + new Field( HsRelatorioPostoData.AREA_ID ).isEqual( a.getId() ), + new String[]{ HsRelatorioRiscoData.ID_FULL }, null, null, null + ); + + Virtual2DArray res = getLocalExecuter().executeQuery( select ); + List< Risco > riscos = new LinkedList< Risco >(); - if(rs.isBeforeFirst()) - { - rs.first(); - do - { - Risco r = new Risco(); - r.setId(new Integer( rs.getInt("id") )); - if(existemMedidasByRisco(r.getId())) - { - r.setDescricao(Utils.unicodeToHTML(rs.getString("descricao"))); - r.setValores(getValoresByRisco(r, a)); - //Integer valor = getValorByRisco(r, a); - //r.setValorQuantitativo(valor); - r.setRisco_id(new Integer( rs.getInt("id") )); - r.setMedidas(getMedidasByRisco( r, a)); - riscos.add(r); - } - }while(rs.next()); - } + for( int i = 0; i < res.rowCount(); i++ ) + { + Integer rId = res.get( i, 0 ); + String rDescricao = res.get( i, 1 ); + if(existemMedidasByRisco(rId)) + { + Risco r = new Risco(); + r.setDescricao( Utils.unicodeToHTML( rDescricao ) ); + r.setValores( getValoresByRisco( r, a ) ); + r.setRisco_id( rId ); + r.setMedidas( getMedidasByRisco( r, a ) ); + riscos.add( r ); + } + } + return riscos; - } private List getValoresByRisco(Risco r, Area a) throws Exception - //private Integer getValorByRisco(Risco r, Area a) throws Exception { -// Statement st = dblocal.createStatement(); - Statement st = createLocalStatement(); - - String sql = "select valor from "; - sql += "(select distinct hs_relatorio_posto_risco.risco_id, "; - sql += "case when hs_relatorio_posto_risco.valor_qualitativo_id isnull and hs_relatorio_posto_risco.probabilidade isnull and hs_relatorio_posto_risco.severidade isnull then null "; - sql += "when hs_relatorio_posto_risco.valor_qualitativo_id isnull then hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade "; - sql += "else hs_relatorio_posto_risco.valor_qualitativo_id "; - sql += "end as valor "; - sql += "from hs_relatorio_posto "; - sql += "inner join hs_relatorio_posto_medida on hs_relatorio_posto_medida.posto_id = hs_relatorio_posto.id "; - sql += "inner join hs_relatorio_medida on hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id "; - sql += "inner join hs_relatorio_risco on hs_relatorio_risco.id = hs_relatorio_medida.risco_id "; - sql += "inner join hs_relatorio_posto_risco on (hs_relatorio_posto_risco.posto_id = hs_relatorio_posto.id and hs_relatorio_posto_risco.risco_id = hs_relatorio_risco.id) "; - sql += "inner join hs_relatorio on hs_relatorio.id = hs_relatorio_risco.relatorio_id "; - sql += "inner join hs_relatorio_area on hs_relatorio_area.id = area_id "; - sql += "where hs_relatorio_posto_risco.risco_id = " + r.getId() + " and area_id = " + a.getId() + ") subquery "; - sql += "order by subquery.valor"; - System.out.println("VALORES BY RISCO : " + sql); - ResultSet rs = st.executeQuery(sql); + Select innerSelect = new Select2( + new String[] { HsRelatorioPostoData.TABLENAME, HsRelatorioPostoMedidaData.TABLENAME, + HsRelatorioMedidaData.TABLENAME, HsRelatorioRiscoData.TABLENAME, HsRelatorioPostoRiscoData.TABLENAME, + HsRelatorioData.TABLENAME, HsRelatorioAreaData.TABLENAME }, + new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, + Select2.JOIN_INNER, Select2.JOIN_INNER }, + new Expression[]{ + new Field( HsRelatorioPostoMedidaData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ), + new Field( HsRelatorioMedidaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoMedidaData.MEDIDA_ID_FULL ) ), + new Field( HsRelatorioRiscoData.ID_FULL ).isEqual( new Field( HsRelatorioMedidaData.RISCO_ID_FULL ) ), + new Field( HsRelatorioPostoRiscoData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ) + .and( new Field( HsRelatorioPostoRiscoData.RISCO_ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.ID_FULL ) ) ), + new Field( HsRelatorioData.ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.RELATORIO_ID_FULL ) ), + new Field( HsRelatorioAreaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoData.AREA_ID_FULL ) ) + }, + new String[]{ "DISTINCT " + HsRelatorioPostoRiscoData.RISCO_ID_FULL, + "CASE WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + .and( new Field( HsRelatorioPostoRiscoData.PROBABILIDADE_FULL ).isEqual( null ) ) + .and( new Field( HsRelatorioPostoRiscoData.SEVERIDADE_FULL ).isEqual( null ) ).toString() + + " THEN null WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + + " THEN " + HsRelatorioPostoRiscoData.PROBABILIDADE_FULL + "*" + HsRelatorioPostoRiscoData.SEVERIDADE_FULL + + " ELSE " + HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL + + " END AS valor " }, + new Field( HsRelatorioPostoRiscoData.RISCO_ID ).isEqual( r.getId() ).and( new Field( HsRelatorioPostoData.AREA_ID_FULL ).isEqual( a.getId() ) ), + new String[]{ HsRelatorioRiscoData.ID_FULL }, null, null, null + ); + + Select select = new Select( MessageFormat.format( "SELECT valor FROM ( {0} ) subquery ORDER BY subquery.valor ", innerSelect.toString() ) ); + + System.out.println("VALORES BY RISCO : " + select.toString()); + + Virtual2DArray res = getLocalExecuter().executeQuery( select ); + List< Valor > valores = new LinkedList< Valor >(); - Integer valor = null; - if(rs.isBeforeFirst()) - { - rs.first(); - do - { - Valor v = new Valor(); - Object oValor = rs.getObject("valor"); - if(oValor == null) - { - v.setValorQuantitativo(null); - //r.setValorQuantitativo(null); - valor = null; - } - else - { - v.setValorQuantitativo((Integer) oValor); - //r.setValorQuantitativo((Integer) oValor); - valor = (Integer) oValor; - } -// System.out.println("RISCO : " + r.getId().toString() + "VALOR : " + oValor.toString()); - //int valor = rs.getInt("valor"); - //v.setValorQuantitativo(new Integer(valor)); - //v.setMedidas(getMedidasByValor(v, r, a)); - valores.add(v); - }while(rs.next()); - } + for( int i = 0; i < res.rowCount(); i++ ) + { + Valor v = new Valor(); + Object oValor = res.get( i, 0 ); + + if(oValor == null) + { + v.setValorQuantitativo(null); + } + else + { + v.setValorQuantitativo((Integer) oValor); + } + valores.add(v); + } + return valores; - //return valor; } - -// private List getMedidasByValor(Valor v, Risco r, Area a) throws Exception -// { -// Statement st = dblocal.createStatement(); -// String sql = "select distinct medida_id, valor, descricao from "; -// sql += "( select distinct hs_relatorio_posto_medida.medida_id, hs_relatorio_posto_risco.risco_id, hs_relatorio_medida.description as descricao, "; -// sql += "case when hs_relatorio_posto_risco.valor_qualitativo_id isnull and hs_relatorio_posto_risco.probabilidade isnull and hs_relatorio_posto_risco.severidade isnull then null "; -// sql += "when hs_relatorio_posto_risco.valor_qualitativo_id isnull then hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade "; -// sql += "else hs_relatorio_posto_risco.valor_qualitativo_id "; -// sql += "end as valor "; -// sql += "from hs_relatorio_posto "; -// sql += "inner join hs_relatorio_posto_medida on hs_relatorio_posto_medida.posto_id = hs_relatorio_posto.id "; -// sql += "inner join hs_relatorio_medida on hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id "; -// sql += "inner join hs_relatorio_risco on hs_relatorio_risco.id = hs_relatorio_medida.risco_id "; -// sql += "inner join hs_relatorio_posto_risco on (hs_relatorio_posto_risco.posto_id = hs_relatorio_posto.id and hs_relatorio_posto_risco.risco_id = hs_relatorio_risco.id) "; -// sql += "inner join hs_relatorio on hs_relatorio.id = hs_relatorio_risco.relatorio_id "; -// sql += "inner join hs_relatorio_area on hs_relatorio_area.id = area_id "; -// sql += "where hs_relatorio_posto_risco.risco_id = " + r.getId() + " and area_id = " + a.getId() + " and hs_relatorio_posto_medida.is_plano_actuacao = true" + ") subquery "; -// //sql += "where hs_relatorio_posto_risco.risco_id = " + r.getId() + " and area_id = " + a.getId() + ") subquery "; -// //sql += "where valor = " + v.getValorQuantitativo() + " "; -// sql += "order by subquery.medida_id, valor"; -// System.out.println("MEDIDAS BY VALOR SQL : " + sql); -// ResultSet rs = st.executeQuery(sql); -// List medidas = new ArrayList(); -// if(rs.isBeforeFirst()) -// { -// rs.first(); -// do -// { -// Medida m = new Medida(); -// //int valor = rs.getInt("valor"); -// //m.setValorQuantitativo(new Integer(valor)); -// m.setId(new Integer( rs.getInt("medida_id") )); -// m.setDescricao(Utils.unicodeToHTML(rs.getString("descricao"))); -// m.setPostos(getPostosByMedidaAndValor(m, v, a)); -// medidas.add(m); -// }while(rs.next()); -// } -// return medidas; -// } - + private List getMedidasByRisco(Risco r, Area a) throws Exception { -// Statement st = dblocal.createStatement(); - Statement st = createLocalStatement(); - - String sql = "select distinct medida_id, valor, descricao from "; - sql += "( select distinct hs_relatorio_posto_medida.medida_id, hs_relatorio_posto_risco.risco_id, hs_relatorio_medida.description as descricao, "; - sql += "case when hs_relatorio_posto_risco.valor_qualitativo_id isnull and hs_relatorio_posto_risco.probabilidade isnull and hs_relatorio_posto_risco.severidade isnull then null "; - sql += "when hs_relatorio_posto_risco.valor_qualitativo_id isnull then hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade "; - sql += "else hs_relatorio_posto_risco.valor_qualitativo_id "; - sql += "end as valor "; - sql += "from hs_relatorio_posto "; - sql += "inner join hs_relatorio_posto_medida on hs_relatorio_posto_medida.posto_id = hs_relatorio_posto.id "; - sql += "inner join hs_relatorio_medida on hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id "; - sql += "inner join hs_relatorio_risco on hs_relatorio_risco.id = hs_relatorio_medida.risco_id "; - sql += "inner join hs_relatorio_posto_risco on (hs_relatorio_posto_risco.posto_id = hs_relatorio_posto.id and hs_relatorio_posto_risco.risco_id = hs_relatorio_risco.id) "; - sql += "inner join hs_relatorio on hs_relatorio.id = hs_relatorio_risco.relatorio_id "; - sql += "inner join hs_relatorio_area on hs_relatorio_area.id = area_id "; - sql += "where hs_relatorio_posto_risco.risco_id = " + r.getId() + " and area_id = " + a.getId() + " and hs_relatorio_posto_medida.is_plano_actuacao = true" + ") subquery "; - //sql += "where hs_relatorio_posto_risco.risco_id = " + r.getId() + " and area_id = " + a.getId() + ") subquery "; - //sql += "where valor = " + v.getValorQuantitativo() + " "; - sql += "order by subquery.medida_id, valor"; - System.out.println("MEDIDAS BY RISCO SQL : " + sql); - ResultSet rs = st.executeQuery(sql); - List< Medida > medidas = new LinkedList< Medida >(); - if ( rs.isBeforeFirst() ) - { - rs.first(); - do - { - Medida m = new Medida(); - //int valor = rs.getInt("valor"); - //m.setValorQuantitativo(new Integer(valor)); - m.setId(new Integer( rs.getInt("medida_id") )); - m.setMedida_id(m.getId()); - m.setDescricao(Utils.unicodeToHTML(rs.getString("descricao"))); - //m.setPostos(getPostosByMedidaAndValor(m, v, a)); - m.setPostos(getPostosByMedida(r, m, a)); - medidas.add(m); - }while(rs.next()); - } - return medidas; + Select innerSelect = new Select2( + new String[] { HsRelatorioPostoData.TABLENAME, HsRelatorioPostoMedidaData.TABLENAME, + HsRelatorioMedidaData.TABLENAME, HsRelatorioRiscoData.TABLENAME, HsRelatorioPostoRiscoData.TABLENAME, + HsRelatorioData.TABLENAME, HsRelatorioAreaData.TABLENAME }, + new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, + Select2.JOIN_INNER, Select2.JOIN_INNER }, + new Expression[]{ + new Field( HsRelatorioPostoMedidaData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ), + new Field( HsRelatorioMedidaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoMedidaData.MEDIDA_ID_FULL ) ), + new Field( HsRelatorioRiscoData.ID_FULL ).isEqual( new Field( HsRelatorioMedidaData.RISCO_ID_FULL ) ), + new Field( HsRelatorioPostoRiscoData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ) + .and( new Field( HsRelatorioPostoRiscoData.RISCO_ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.ID_FULL ) ) ), + new Field( HsRelatorioData.ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.RELATORIO_ID_FULL ) ), + new Field( HsRelatorioAreaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoData.AREA_ID_FULL ) ) + }, + new String[]{ "DISTINCT " + HsRelatorioPostoMedidaData.MEDIDA_ID_FULL, + HsRelatorioPostoRiscoData.RISCO_ID_FULL, + HsRelatorioMedidaData.DESCRIPTION_FULL, + "CASE WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + .and( new Field( HsRelatorioPostoRiscoData.PROBABILIDADE_FULL ).isEqual( null ) ) + .and( new Field( HsRelatorioPostoRiscoData.SEVERIDADE_FULL ).isEqual( null ) ).toString() + + " THEN null WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + + " THEN " + HsRelatorioPostoRiscoData.PROBABILIDADE_FULL + "*" + HsRelatorioPostoRiscoData.SEVERIDADE_FULL + + " ELSE " + HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL + + " END AS valor " }, + new Field( HsRelatorioPostoRiscoData.RISCO_ID_FULL ).isEqual( r.getId() ) + .and( new Field( HsRelatorioPostoData.AREA_ID_FULL ).isEqual( a.getId() ) ) + .and( new Field( HsRelatorioPostoMedidaData.IS_PLANO_ACTUACAO_FULL ).isEqual( Boolean.TRUE ) ), + new String[]{ HsRelatorioRiscoData.ID_FULL }, null, null, null + ); + + Select select = new Select( MessageFormat.format( "SELECT distinct medida_id, valor, descricao FROM ( {0} ) subquery ORDER BY subquery.medida_id, valor ", innerSelect.toString() ) ); + + System.out.println( "MEDIDAS BY RISCO SQL : " + select.toString() ); + + Virtual2DArray res = getLocalExecuter( ).executeQuery( select ); + + List< Medida > medidas = new LinkedList< Medida >( ); + + for( int i = 0; i < res.rowCount( ); i++ ) + { + Medida m = new Medida( ); + m.setId( (Integer) res.get( i, 0 ) ); + m.setMedida_id( m.getId( ) ); + m.setDescricao( Utils.unicodeToHTML( ( String ) res.get(i, 1) ) ); + m.setPostos( getPostosByMedida( r, m, a ) ); + medidas.add( m ); + } + + return medidas; } -// private List getPostosByMedidaAndValor(Medida m, Valor v, Area a) throws Exception -// { -// Statement st = dblocal.createStatement(); -// String sql = "select subquery.posto_id, valor, descricao from "; -// sql += "(select hs_relatorio_posto_medida.posto_id, hs_relatorio_posto.description as descricao, "; -// sql += "case when hs_relatorio_posto_risco.valor_qualitativo_id isnull and hs_relatorio_posto_risco.probabilidade isnull and hs_relatorio_posto_risco.severidade isnull then null "; -// sql += "when hs_relatorio_posto_risco.valor_qualitativo_id isnull then hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade "; -// sql += "else hs_relatorio_posto_risco.valor_qualitativo_id "; -// sql += "end as valor "; -// sql += "from hs_relatorio_posto_medida "; -// sql += "inner join hs_relatorio_posto_risco on hs_relatorio_posto_risco.posto_id = hs_relatorio_posto_medida.posto_id "; -// sql += "inner join hs_relatorio_posto on hs_relatorio_posto.id = hs_relatorio_posto_medida.posto_id "; -// sql += "inner join hs_relatorio_area on hs_relatorio_area.id = area_id "; -// sql += "where medida_id = " + m.getId() + " and area_id = " + a.getId() + ") subquery "; -// //sql += "where valor = " + v.getValorQuantitativo(); -// System.out.println("POSTOS BY MEDIDA SQL : " + sql); -// ResultSet rs = st.executeQuery(sql); -// List postos = new ArrayList(); -// if(rs.isBeforeFirst()) -// { -// rs.first(); -// do -// { -// PostoTrabalho p = new PostoTrabalho(); -// p.setId(new Integer( rs.getInt("posto_id") )); -// p.setDescricao(Utils.unicodeToHTML(rs.getString("descricao"))); -// postos.add(p); -// }while(rs.next()); -// } -// return postos; -// } - private List getPostosByMedida(Risco r, Medida m, Area a) throws Exception { -// Statement st = dblocal.createStatement(); - Statement st = createLocalStatement(); - - String sql = "select subquery.posto_id, valor, descricao from "; - sql += "(select hs_relatorio_posto_medida.posto_id, hs_relatorio_posto.description as descricao, "; - sql += "case when hs_relatorio_posto_risco.valor_qualitativo_id isnull and hs_relatorio_posto_risco.probabilidade isnull and hs_relatorio_posto_risco.severidade isnull then null "; - sql += "when hs_relatorio_posto_risco.valor_qualitativo_id isnull then hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade "; - sql += "else hs_relatorio_posto_risco.valor_qualitativo_id "; - sql += "end as valor "; - sql += "from hs_relatorio_posto_medida "; - sql += "inner join hs_relatorio_posto_risco on hs_relatorio_posto_risco.posto_id = hs_relatorio_posto_medida.posto_id "; - sql += "inner join hs_relatorio_posto on hs_relatorio_posto.id = hs_relatorio_posto_medida.posto_id "; - sql += "inner join hs_relatorio_area on hs_relatorio_area.id = area_id "; - sql += "where medida_id = " + m.getId() + " and area_id = " + a.getId() + " and risco_id = " + r.getId() + ") subquery "; - //sql += "where valor = " + v.getValorQuantitativo(); - System.out.println("POSTOS BY MEDIDA SQL : " + sql); - ResultSet rs = st.executeQuery(sql); + Select innerSelect = new Select2( + new String[] { HsRelatorioPostoMedidaData.TABLENAME, HsRelatorioPostoRiscoData.TABLENAME, + HsRelatorioPostoData.TABLENAME, HsRelatorioAreaData.TABLENAME }, + new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER }, + new Expression[]{ + new Field( HsRelatorioPostoRiscoData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoMedidaData.POSTO_ID_FULL ) ), + new Field( HsRelatorioPostoData.ID_FULL ).isEqual( new Field( HsRelatorioPostoMedidaData.POSTO_ID_FULL ) ), + new Field( HsRelatorioAreaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoData.AREA_ID ) ) + }, + new String[]{ HsRelatorioPostoMedidaData.POSTO_ID_FULL, + HsRelatorioPostoData.DESCRIPTION_FULL, + "CASE WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + .and( new Field( HsRelatorioPostoRiscoData.PROBABILIDADE_FULL ).isEqual( null ) ) + .and( new Field( HsRelatorioPostoRiscoData.SEVERIDADE_FULL ).isEqual( null ) ).toString() + + " THEN null WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + + " THEN " + HsRelatorioPostoRiscoData.PROBABILIDADE_FULL + "*" + HsRelatorioPostoRiscoData.SEVERIDADE_FULL + + " ELSE " + HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL + + " END AS valor " }, + new Field( HsRelatorioPostoRiscoData.RISCO_ID ).isEqual( r.getId() ) + .and( new Field( HsRelatorioPostoData.AREA_ID ).isEqual( a.getId() ) ) + .and( new Field( HsRelatorioPostoMedidaData.MEDIDA_ID ).isEqual( m.getId() ) ), + new String[]{ HsRelatorioRiscoData.ID_FULL }, null, null, null + ); + + Select select = new Select( MessageFormat.format( "SELECT subquery.posto_id, valor, descricao FROM ( {0} ) subquery ", innerSelect.toString() ) ); + + System.out.println("POSTOS BY MEDIDA SQL : " + select.toString()); + + Virtual2DArray res = getLocalExecuter( ).executeQuery( select ); + List< PostoTrabalho > postos = new LinkedList< PostoTrabalho >(); - if(rs.isBeforeFirst()) - { - rs.first(); - do - { - PostoTrabalho p = new PostoTrabalho(); - p.setId(new Integer( rs.getInt("posto_id") )); - p.setPosto_id(p.getId()); - p.setDescricao(Utils.unicodeToHTML(rs.getString("descricao"))); - postos.add(p); - }while(rs.next()); - } + + for( int i = 0; i < res.rowCount( ); i++ ) + { + PostoTrabalho p = new PostoTrabalho(); + p.setId( (Integer) res.get( i, 0 ) ); + p.setPosto_id( p.getId() ); + p.setDescricao( Utils.unicodeToHTML( (String) res.get( i, 1 ) ) ); + postos.add( p ); + } + return postos; } @@ -359,113 +335,107 @@ public class RelatoriosDataProvider extends GenericDataProvider private boolean existemMedidasByArea(Integer area_id) throws Exception { -// Statement st = dblocal.createStatement(); - Statement st = createLocalStatement(); - - String sql = "select distinct medida_id, valor, descricao "; - sql += "from ( select distinct hs_relatorio_posto_medida.medida_id, hs_relatorio_posto_risco.risco_id, hs_relatorio_medida.description as descricao, "; - sql += "case when hs_relatorio_posto_risco.valor_qualitativo_id isnull and hs_relatorio_posto_risco.probabilidade isnull and hs_relatorio_posto_risco.severidade isnull then null "; - sql += "when hs_relatorio_posto_risco.valor_qualitativo_id isnull then hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade else hs_relatorio_posto_risco.valor_qualitativo_id end as valor from hs_relatorio_posto "; - sql += "inner join hs_relatorio_posto_medida on hs_relatorio_posto_medida.posto_id = hs_relatorio_posto.id "; - sql += "inner join hs_relatorio_medida on hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id "; - sql += "inner join hs_relatorio_risco on hs_relatorio_risco.id = hs_relatorio_medida.risco_id "; - sql += "inner join hs_relatorio_posto_risco on (hs_relatorio_posto_risco.posto_id = hs_relatorio_posto.id and hs_relatorio_posto_risco.risco_id = hs_relatorio_risco.id) "; - sql += "inner join hs_relatorio on hs_relatorio.id = hs_relatorio_risco.relatorio_id "; - sql += "inner join hs_relatorio_area on hs_relatorio_area.id = area_id "; - sql += "where area_id = " + area_id + " and hs_relatorio_posto_medida.is_plano_actuacao = true) subquery order by subquery.medida_id, valor"; - System.out.println("EXISTEM MEDIDAS BY AREA SQL : " + sql); - ResultSet rs = st.executeQuery(sql); - if(rs.isBeforeFirst()) - { - return true; - } - else - { - return false; - } + Select innerSelect = new Select2( + new String[] { HsRelatorioPostoData.TABLENAME, HsRelatorioPostoMedidaData.TABLENAME, + HsRelatorioMedidaData.TABLENAME, HsRelatorioRiscoData.TABLENAME, HsRelatorioPostoRiscoData.TABLENAME, + HsRelatorioData.TABLENAME, HsRelatorioAreaData.TABLENAME }, + new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, + Select2.JOIN_INNER, Select2.JOIN_INNER }, + new Expression[]{ + new Field( HsRelatorioPostoMedidaData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ), + new Field( HsRelatorioMedidaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoMedidaData.MEDIDA_ID_FULL ) ), + new Field( HsRelatorioRiscoData.ID_FULL ).isEqual( new Field( HsRelatorioMedidaData.RISCO_ID_FULL ) ), + new Field( HsRelatorioPostoRiscoData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ) + .and( new Field( HsRelatorioPostoRiscoData.RISCO_ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.ID_FULL ) ) ), + new Field( HsRelatorioData.ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.RELATORIO_ID_FULL ) ), + new Field( HsRelatorioAreaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoData.AREA_ID_FULL ) ) + }, + new String[]{ "DISTINCT " + HsRelatorioPostoMedidaData.MEDIDA_ID_FULL, + HsRelatorioPostoRiscoData.RISCO_ID_FULL, + HsRelatorioMedidaData.DESCRIPTION_FULL, + "CASE WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + .and( new Field( HsRelatorioPostoRiscoData.PROBABILIDADE_FULL ).isEqual( null ) ) + .and( new Field( HsRelatorioPostoRiscoData.SEVERIDADE_FULL ).isEqual( null ) ).toString() + + " THEN null WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + + " THEN " + HsRelatorioPostoRiscoData.PROBABILIDADE_FULL + "*" + HsRelatorioPostoRiscoData.SEVERIDADE_FULL + + " ELSE " + HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL + + " END AS valor " }, + new Field( HsRelatorioPostoData.AREA_ID_FULL ).isEqual( area_id ) + .and( new Field( HsRelatorioPostoMedidaData.IS_PLANO_ACTUACAO_FULL ).isEqual( Boolean.TRUE ) ), + new String[]{ HsRelatorioRiscoData.ID_FULL }, null, null, null + ); + + Select select = new Select( MessageFormat.format( "SELECT distinct medida_id, valor, descricao FROM ( {0} ) subquery ORDER BY subquery.medida_id, valor ", innerSelect.toString() ) ); + + System.out.println("EXISTEM MEDIDAS BY AREA SQL : " + select.toString()); + + Virtual2DArray res = getLocalExecuter( ).executeQuery( select ); + return res.rowCount() > 0; } private boolean existemMedidasByRisco(Integer risco_id) throws Exception { -// Statement st = dblocal.createStatement(); - Statement st = createLocalStatement(); - - String sql = "select distinct medida_id "; - sql += "from ( select distinct hs_relatorio_posto_medida.medida_id, hs_relatorio_posto_risco.risco_id, hs_relatorio_medida.description as descricao, "; - sql += "case when hs_relatorio_posto_risco.valor_qualitativo_id isnull and hs_relatorio_posto_risco.probabilidade isnull and hs_relatorio_posto_risco.severidade isnull then null "; - sql += "when hs_relatorio_posto_risco.valor_qualitativo_id isnull then hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade else hs_relatorio_posto_risco.valor_qualitativo_id end as valor from hs_relatorio_posto "; - sql += "inner join hs_relatorio_posto_medida on hs_relatorio_posto_medida.posto_id = hs_relatorio_posto.id "; - sql += "inner join hs_relatorio_medida on hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id "; - sql += "inner join hs_relatorio_risco on hs_relatorio_risco.id = hs_relatorio_medida.risco_id "; - sql += "inner join hs_relatorio_posto_risco on (hs_relatorio_posto_risco.posto_id = hs_relatorio_posto.id and hs_relatorio_posto_risco.risco_id = hs_relatorio_risco.id) "; - sql += "inner join hs_relatorio on hs_relatorio.id = hs_relatorio_risco.relatorio_id "; - sql += "inner join hs_relatorio_area on hs_relatorio_area.id = area_id "; - sql += "where hs_relatorio_posto_risco.risco_id = " + risco_id + " and hs_relatorio_posto_medida.is_plano_actuacao = true) subquery order by medida_id"; - System.out.println("EXISTEM MEDIDAS BY RISCO SQL : " + sql); - ResultSet rs = st.executeQuery(sql); - if(rs.isBeforeFirst()) - { - return true; - } - else - { - return false; - } - + Select innerSelect = new Select2( + new String[] { HsRelatorioPostoData.TABLENAME, HsRelatorioPostoMedidaData.TABLENAME, + HsRelatorioMedidaData.TABLENAME, HsRelatorioRiscoData.TABLENAME, HsRelatorioPostoRiscoData.TABLENAME, + HsRelatorioData.TABLENAME, HsRelatorioAreaData.TABLENAME }, + new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, + Select2.JOIN_INNER, Select2.JOIN_INNER }, + new Expression[]{ + new Field( HsRelatorioPostoMedidaData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ), + new Field( HsRelatorioMedidaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoMedidaData.MEDIDA_ID_FULL ) ), + new Field( HsRelatorioRiscoData.ID_FULL ).isEqual( new Field( HsRelatorioMedidaData.RISCO_ID_FULL ) ), + new Field( HsRelatorioPostoRiscoData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ) + .and( new Field( HsRelatorioPostoRiscoData.RISCO_ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.ID_FULL ) ) ), + new Field( HsRelatorioData.ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.RELATORIO_ID_FULL ) ), + new Field( HsRelatorioAreaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoData.AREA_ID_FULL ) ) + }, + new String[]{ "DISTINCT " + HsRelatorioPostoMedidaData.MEDIDA_ID_FULL, + HsRelatorioPostoRiscoData.RISCO_ID_FULL, + HsRelatorioMedidaData.DESCRIPTION_FULL, + "CASE WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + .and( new Field( HsRelatorioPostoRiscoData.PROBABILIDADE_FULL ).isEqual( null ) ) + .and( new Field( HsRelatorioPostoRiscoData.SEVERIDADE_FULL ).isEqual( null ) ).toString() + + " THEN null WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + + " THEN " + HsRelatorioPostoRiscoData.PROBABILIDADE_FULL + "*" + HsRelatorioPostoRiscoData.SEVERIDADE_FULL + + " ELSE " + HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL + + " END AS valor " }, + new Field( HsRelatorioPostoRiscoData.RISCO_ID_FULL ).isEqual( risco_id ) + .and( new Field( HsRelatorioPostoMedidaData.IS_PLANO_ACTUACAO_FULL ).isEqual( Boolean.TRUE ) ), + new String[]{ HsRelatorioRiscoData.ID_FULL }, null, null, null + ); + + Select select = new Select( MessageFormat.format( "SELECT distinct medida_id FROM ( {0} ) subquery ORDER BY medida_id ", innerSelect.toString() ) ); + + System.out.println("EXISTEM MEDIDAS BY RISCO SQL : " + select.toString()); + + Virtual2DArray res = getLocalExecuter( ).executeQuery( select ); + return res.rowCount() > 0; } - public String getEmpresaNome(Integer empresa_id) throws Exception - { - String nome = ""; - EmpresasData empresaData = getLocalProvider().load( EmpresasData.class, empresa_id, EmpresasData.ID ); - if ( empresaData != null ) - { - nome = Utils.unicodeToHTML( empresaData.getDesignacao_social() ); - } - return nome; - -// Statement st = createLocalStatement(); -// -// String sql ="SELECT designacao_social FROM empresas WHERE id = " + empresa_id; -// ResultSet rslocal = st.executeQuery(sql); -// rslocal.first(); -// String nome = Utils.unicodeToHTML(rslocal.getString("designacao_social")); -// return nome; - } - public byte[] getLogoByEmpresa( Integer empresaId ) throws Exception { byte[] logo = null; - EmpresasData empresaData = getLocalProvider().load( EmpresasData.class, empresaId, EmpresasData.ID ); + EmpresasData empresaData = getLocalProvider().load( EmpresasData.class, empresaId, EmpresasData.ID, null ); if ( empresaData != null ) { Integer logoID = empresaData.getEmpresa_logo_id(); logo = getLogo( logoID ); } return logo; - -// Statement st = createLocalStatement(); -// -// String sql = "select empresa_logo_id from empresas where id = " + empresaId; -// ResultSet rslocal = st.executeQuery(sql); -// if ( rslocal.isBeforeFirst() ) -// { -// rslocal.first(); -// Integer logoId = new Integer( rslocal.getInt("empresa_logo_id") ); -// byte[] logo = getLogo( logoId ); -// return logo; -// } -// -// return null; } public byte[] getLogo( Integer logoID ) throws Exception { byte[] logo = null; - ImageData imageData = getLocalProvider().load( ImageData.class, logoID, ImageData.ID ); + ImageData imageData = getLocalProvider().load( ImageData.class, logoID, ImageData.ID, null ); if ( imageData != null ) { logo = imageData.getImage_data(); @@ -473,16 +443,4 @@ public class RelatoriosDataProvider extends GenericDataProvider System.out.println( "\nRelatoriosDataProvider . getLogo( " + logoID + " ) : " + ( logo == null ? "null" : "size = " + logo.length ) ); return logo; } - -// public byte[] getLogo(Integer logoId) throws Exception -// { -// Statement st = createLocalStatement(); -// -// String sql = "select image_data from image where id = " + logoId; -// ResultSet rslocal = st.executeQuery(sql); -// rslocal.first(); -// byte[] logo = rslocal.getBytes("image_data"); -// System.out.println("LOGO SIZE : " + logo.length); -// return logo; -// } -} \ No newline at end of file +} diff --git a/trunk/PlanosActuacao/src/db/providers/UtilizadoresDataProvider.java b/trunk/PlanosActuacao/src/db/providers/UtilizadoresDataProvider.java index be190c5e..ad171db6 100644 --- a/trunk/PlanosActuacao/src/db/providers/UtilizadoresDataProvider.java +++ b/trunk/PlanosActuacao/src/db/providers/UtilizadoresDataProvider.java @@ -6,14 +6,15 @@ package db.providers; import com.evolute.utils.arrays.Virtual2DArray; +import com.evolute.utils.db.DBException; import com.evolute.utils.sql.Expression; import com.evolute.utils.sql.Field; +import com.evolute.utils.sql.Select; import com.evolute.utils.sql.Select2; +import db.data.siprp.outer.EmpresasData; import db.data.siprp.outer.UtilizadoresData; import db.entidades.Utilizador; import utils.Global; -import java.sql.ResultSet; -import java.sql.Statement; import java.util.LinkedList; import java.util.List; @@ -57,7 +58,7 @@ public class UtilizadoresDataProvider extends GenericDataProvider null, null, null ); Virtual2DArray result = getExecuter().executeQuery( query ); - if ( result != null && result.columnLength() > 0 ) + if ( result != null && result.rowCount( ) > 0 ) { Integer userID = result.get( 0, 0 ); user = getUtilizador( userID ); @@ -100,43 +101,12 @@ public class UtilizadoresDataProvider extends GenericDataProvider } return user; } - -// public Utilizador getUtilizador( Integer id ) throws Exception -// { -// Utilizador u = null; -// Statement st = createStatement(); -// String sql = "SELECT * FROM utilizadores WHERE id = " + id; -// ResultSet rs = st.executeQuery( sql ); -// if ( rs.first() ) -// { -// 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")); -// u.setGestor_geral(rs.getString("gestor_geral")); -// u.setApagado(rs.getString("apagado")); -// } -// return u; -// } public List< Utilizador > getUtilizadoresListByTipo( Integer tipo, String responsavel_loja, Integer estabelecimento_id ) throws Exception { List< Utilizador > list = new LinkedList< Utilizador >(); - int type = tipo.intValue(); + int type = tipo; Expression where = new Field( UtilizadoresData.ACTIVO_FULL ).isEqual( "y" ); where = where.and( new Field( UtilizadoresData.APAGADO_FULL ).isEqual( "n" ) ); @@ -164,52 +134,6 @@ public class UtilizadoresDataProvider extends GenericDataProvider } } - -// String sql = ""; -// String estabelecimento_constraint = ""; -// if ( type == Global.DIRECTOR_LOJA || type == Global.RESPONSAVEL_SEGURANCA || type == Global.DIRECTOR_NACIONAL_SEGURANCA ) -// { -// estabelecimento_constraint = " AND estabelecimento_id = " + estabelecimento_id; -// } -// if ( type == Global.RESPONSAVEL_SEGURANCA && responsavel_loja.matches( "y" ) ) -// { -// sql = "SELECT * FROM utilizadores WHERE activo = 'y' AND apagado = 'n' AND tipo = " + tipo + estabelecimento_constraint + " AND responsavel_loja = 'y'"; -// } -// else if ( type == Global.DIRECTOR_LOJA || type == Global.TECNICO_HS || type == 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 ); -// Statement st = createStatement(); -// 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; } @@ -227,36 +151,17 @@ public class UtilizadoresDataProvider extends GenericDataProvider } return list; } - -// public ArrayList getUtilizadoresList() throws Exception -// { -// ArrayList list = new ArrayList(); -// Statement st = createStatement(); -// String sql = "select * from utilizadores where activo = 'y' and apagado = 'n'"; -// -// ResultSet rs = st.executeQuery(sql); -// 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; -// } + + public Boolean isSiprp( Utilizador utilizador ) throws DBException + { + Select select = new Select2( EmpresasData.TABLENAME, new Field( EmpresasData.DESIGNACAO_SOCIAL_FULL ).isILike( "siprp%" ) + .and( new Field( EmpresasData.ID_FULL ).isEqual( utilizador.getEmpresa_id() ) ), "1" ); + + Select outer = new Select( "select exists( " + select.toString() + " )" ); + + Virtual2DArray array = getExecuter().executeQuery( outer ); + + return array.rowCount() > 0 ? ( Boolean ) array.get( 0, 1 ) : Boolean.FALSE; + } + } diff --git a/trunk/PlanosActuacao/src/importer/PlanosActuacaoImporterProvider.java b/trunk/PlanosActuacao/src/importer/PlanosActuacaoImporterProvider.java index 9617d2f9..91337fb6 100644 --- a/trunk/PlanosActuacao/src/importer/PlanosActuacaoImporterProvider.java +++ b/trunk/PlanosActuacao/src/importer/PlanosActuacaoImporterProvider.java @@ -1,5 +1,14 @@ package importer; +import com.evolute.utils.sql.Select; +import db.data.siprp_local.outer.HsRelatorioAreaData; +import db.data.siprp_local.outer.HsRelatorioData; +import db.data.siprp_local.outer.HsRelatorioMedidaData; +import db.data.siprp_local.outer.HsRelatorioPostoData; +import db.data.siprp_local.outer.HsRelatorioPostoMedidaData; +import db.data.siprp_local.outer.HsRelatorioPostoRiscoData; +import db.data.siprp_local.outer.HsRelatorioRiscoData; +import db.data.siprp_local.outer.HsRelatorioRiscoValorQualitativoData; import db.providers.*; import com.evolute.utils.arrays.Virtual2DArray; import com.evolute.utils.error.ErrorLogger; @@ -21,11 +30,11 @@ import db.entidades.PostoTrabalho; import db.entidades.Risco; import db.entidades.Valor; import db.entidades.ValorQualitativo; -import java.sql.ResultSet; -import java.sql.Statement; +import java.text.MessageFormat; import java.util.Date; import java.util.LinkedList; import java.util.List; + import utils.Utils; @@ -64,7 +73,7 @@ public class PlanosActuacaoImporterProvider extends GenericDataProvider new String[] { PlanosActuacaoData.DATA_VISITA_FULL }, new String[] {} ); Virtual2DArray array = getExecuter().executeQuery( query ); - for ( int i = 0; i < array.columnLength(); i++ ) + for ( int i = 0; i < array.rowCount(); i++ ) { Date date = array.get( i, 0 ); System.out.println( "\n\t\t\tData-Visita Plano : " + date ); @@ -84,7 +93,7 @@ public class PlanosActuacaoImporterProvider extends GenericDataProvider new String[] {} ); Virtual2DArray array = getExecuter().executeQuery( query ); - for ( int i = 0; i < array.columnLength(); i++ ) + for ( int i = 0; i < array.rowCount(); i++ ) { Integer estabelecimentoID = array.get( i, 0 ); result.add( estabelecimentoID ); @@ -109,325 +118,332 @@ public class PlanosActuacaoImporterProvider extends GenericDataProvider private PlanoActuacao getAreasByPlano( PlanoActuacao plano, Integer relatorioID ) throws Exception { - String sql = "select hs_relatorio_posto.area_id as area, hs_relatorio_area.description as descricao, hs_relatorio_area.ordem as ordem, bool_or( coalesce( hs_relatorio_posto.is_principal, false ) ) as is_principal " - + " from hs_relatorio_posto " - + " inner join hs_relatorio_posto_medida on hs_relatorio_posto_medida.posto_id = hs_relatorio_posto.id " - + " inner join hs_relatorio_medida on hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id " - + " inner join hs_relatorio_risco on hs_relatorio_risco.id = hs_relatorio_medida.risco_id " - + " inner join hs_relatorio on hs_relatorio.id = hs_relatorio_risco.relatorio_id " - + " inner join hs_relatorio_area on hs_relatorio_area.id = hs_relatorio_posto.area_id " - + " where hs_relatorio.id = " + relatorioID + " and hs_relatorio_posto_medida.is_plano_actuacao " - + " and hs_relatorio_posto.deleted_date is null and hs_relatorio_area.deleted_date is null " - + " group by area, descricao, ordem" - + " order by area "; + Select select = new Select2( + new String[] { HsRelatorioPostoData.TABLENAME, HsRelatorioPostoMedidaData.TABLENAME, + HsRelatorioMedidaData.TABLENAME, HsRelatorioRiscoData.TABLENAME, + HsRelatorioData.TABLENAME, HsRelatorioAreaData.TABLENAME }, + new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER }, + new Expression[]{ + new Field( HsRelatorioPostoMedidaData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ), + new Field( HsRelatorioMedidaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoMedidaData.MEDIDA_ID_FULL ) ), + new Field( HsRelatorioRiscoData.ID_FULL ).isEqual( new Field( HsRelatorioMedidaData.RISCO_ID_FULL ) ), + new Field( HsRelatorioData.ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.RELATORIO_ID_FULL ) ), + new Field( HsRelatorioAreaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoData.AREA_ID_FULL ) ) + }, + new String[]{ HsRelatorioPostoData.AREA_ID_FULL, HsRelatorioAreaData.DESCRIPTION_FULL, HsRelatorioAreaData.ORDEM_FULL, + "bool_or(coalesce(" + HsRelatorioPostoData.IS_PRINCIPAL_FULL + ", false))" + }, + new Field( HsRelatorioData.ID_FULL ).isEqual( relatorioID ) + .and( new Field( HsRelatorioPostoMedidaData.IS_PLANO_ACTUACAO_FULL ).isEqual( Boolean.TRUE ) ) + .and( new Field( HsRelatorioPostoData.DELETED_DATE_FULL ).isEqual( null ) ) + .and( new Field( HsRelatorioAreaData.DELETED_DATE_FULL ).isEqual( null ) ), + new String[]{ HsRelatorioPostoData.AREA_ID_FULL }, + new String[]{ HsRelatorioPostoData.AREA_ID_FULL, HsRelatorioAreaData.DESCRIPTION_FULL, HsRelatorioAreaData.ORDEM_FULL }, + null, null + ); + System.out.println( "\n\t\t\t\t\t\tprovider . getAreasByPlano( " + plano.getId() + ", " + relatorioID + " ) : " ); - System.out.println( "\n\t\t\t\t\t\t\t\tSQL : " + sql ); + System.out.println( "\n\t\t\t\t\t\t\t\tSQL : " + select.toString() ); + + Virtual2DArray res = getLocalExecuter().executeQuery( select ); - Statement st = createLocalStatement(); - ResultSet rs = st.executeQuery( sql ); List< Area > areas = new LinkedList< Area >(); - if ( rs.isBeforeFirst() ) - { - rs.first(); - do - { - Area a = new Area(); - a.setId( new Integer( rs.getInt( "area" ) ) ); - a.setArea_id( a.getId() ); - a.setIs_principal( new Boolean( rs.getBoolean( "is_principal" ) ) ); - Integer ordem = ( Integer ) rs.getObject( "ordem" ); - if( ordem != null ) - { - a.setOrdem( ordem ); - } - if ( existemMedidasByArea( a.getId() ) ) - { - a.setDescricao( Utils.unicodeToHTML( rs.getString( "descricao") ) ); - try - { - a.setRiscos( getRiscosByArea( a ) ); - } - catch ( Exception ex ) - { - System.out.println( "\nERRO RISCOS BY AREA !!!!" ); - ErrorLogger.logException( ex ); - a.setRiscos( null ); - } - if( a.getRiscos().size() > 0 ) - { - areas.add( a ); - } - } - } - while ( rs.next() ); - plano.setAreas( areas ); - } + + for( int i = 0; i < res.rowCount(); i++ ) + { + Integer rId = res.get( i, 0 ); + String rDescription = res.get( i, 1 ); + Integer rOrdem = res.get( i, 2 ); + Boolean rIsPrincipal = res.get( i, 3 ); + + Area a = new Area().withId( rId ).withArea_id( rId ).withIs_principal( rIsPrincipal ); + if( rOrdem != null ) + { + a.setOrdem( rOrdem ); + } + if ( existemMedidasByArea( rId ) ) + { + a.setDescricao( Utils.unicodeToHTML( rDescription ) ); + try + { + a.setRiscos( getRiscosByArea( a ) ); + } + catch ( Exception ex ) + { + System.out.println( "\nERRO RISCOS BY AREA !!!!" ); + ErrorLogger.logException( ex ); + a.setRiscos( null ); + } + if( a.getRiscos().size() > 0 ) + { + areas.add( a ); + } + } + } + + plano.setAreas( areas ); return plano; } private List< Risco > getRiscosByArea( Area a ) throws Exception { - String sql = "select distinct hs_relatorio_risco.id, hs_relatorio_risco.description as descricao, hs_relatorio_risco.is_patrimonial as is_patrimonial " - + " from hs_relatorio_posto " - + " inner join hs_relatorio_posto_medida on hs_relatorio_posto_medida.posto_id = hs_relatorio_posto.id " - + " inner join hs_relatorio_medida on hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id " - + " inner join hs_relatorio_risco on hs_relatorio_risco.id = hs_relatorio_medida.risco_id " - + " inner join hs_relatorio on hs_relatorio.id = hs_relatorio_risco.relatorio_id " - + " inner join hs_relatorio_area on hs_relatorio_area.id = area_id " - + " where area_id = " + a.getId() + " and hs_relatorio_posto_medida.is_plano_actuacao and hs_relatorio_posto.deleted_date is null " - + " order by hs_relatorio_risco.id "; + Select select = new Select2( + new String[] { HsRelatorioPostoData.TABLENAME, HsRelatorioPostoMedidaData.TABLENAME, + HsRelatorioMedidaData.TABLENAME, HsRelatorioRiscoData.TABLENAME, + HsRelatorioData.TABLENAME, HsRelatorioAreaData.TABLENAME }, + new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER }, + new Expression[]{ + new Field( HsRelatorioPostoMedidaData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ), + new Field( HsRelatorioMedidaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoMedidaData.MEDIDA_ID_FULL ) ), + new Field( HsRelatorioRiscoData.ID_FULL ).isEqual( new Field( HsRelatorioMedidaData.RISCO_ID_FULL ) ), + new Field( HsRelatorioData.ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.RELATORIO_ID_FULL ) ), + new Field( HsRelatorioAreaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoData.AREA_ID_FULL ) ) + }, + new String[]{ "DISTINCT " + HsRelatorioRiscoData.ID_FULL, HsRelatorioRiscoData.DESCRIPTION_FULL, + HsRelatorioRiscoData.IS_PATRIMONIAL_FULL }, + new Field( HsRelatorioPostoData.AREA_ID_FULL ).isEqual( a.getId() ) + .and( new Field( HsRelatorioPostoMedidaData.IS_PLANO_ACTUACAO_FULL ).isEqual( Boolean.TRUE ) ) + .and( new Field( HsRelatorioPostoData.DELETED_DATE_FULL ).isEqual( null ) ), + new String[]{ HsRelatorioRiscoData.ID_FULL }, null, null, null + ); + System.out.println( "\t\t\t\t\t\t\tprovider . getRiscosByArea( " + a.getId() + " ) : " ); - System.out.println( "\t\t\t\t\t\t\t\t\tSQL : " + sql ); + System.out.println( "\t\t\t\t\t\t\t\t\tSQL : " + select.toString() ); + + Virtual2DArray res = getLocalExecuter().executeQuery( select ); - Statement st = createLocalStatement(); - ResultSet rs = st.executeQuery( sql ); List< Risco > riscos = new LinkedList< Risco >(); - if ( rs.isBeforeFirst() ) - { - rs.first(); - do - { - Risco r = new Risco(); - r.setId( new Integer( rs.getInt( "id" ) ) ); - if ( existemMedidasByRisco( r.getId() ) ) - { - r.setDescricao( Utils.unicodeToHTML( rs.getString( "descricao" ) ) ); - r.setIsPatrimonial( rs.getBoolean( "is_patrimonial" ) ); - - r.setValores( getValoresByRisco( r, a ) ); - r.setRisco_id( new Integer( rs.getInt( "id" ) ) ); - r.setMedidas( getMedidasByRisco( r, a ) ); - if( r.getMedidas().size() > 0 ) - { - riscos.add( r ); - } - } - } - while ( rs.next() ); - } - return riscos; + + for( int i = 0; i < res.rowCount(); i++ ) + { + Integer rId = res.get( i, 0 ); + String rDescription = res.get( i, 1 ); + Boolean rIsPatrimonial = res.get( i , 2 ); + + Risco r = new Risco(); + r.setId( rId ); + + if ( existemMedidasByRisco( rId ) ) + { + r.setDescricao( Utils.unicodeToHTML( rDescription ) ); + r.setIsPatrimonial( rIsPatrimonial ); + + r.setValores( getValoresByRisco( r, a ) ); + r.setRisco_id( rId ); + r.setMedidas( getMedidasByRisco( r, a ) ); + if( r.getMedidas().size() > 0 ) + { + riscos.add( r ); + } + } + } + + return riscos; } private List< Valor > getValoresByRisco( Risco r, Area a ) throws Exception { - String sql = "select subquery.valor, subquery.valor_qualitativo_id from " - + " (select distinct hs_relatorio_posto_risco.risco_id, hs_relatorio_posto_risco.valor_qualitativo_id, hs_relatorio_risco_valor_qualitativo.description, " - + " case when hs_relatorio_posto_risco.valor_qualitativo_id isnull and hs_relatorio_posto_risco.probabilidade isnull and hs_relatorio_posto_risco.severidade isnull then null " - + " when hs_relatorio_posto_risco.valor_qualitativo_id isnull then hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade " - + " else null " - + " end as valor " - + " from hs_relatorio_posto " - + " inner join hs_relatorio_posto_medida on hs_relatorio_posto_medida.posto_id = hs_relatorio_posto.id " - + " inner join hs_relatorio_medida on hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id " - + " inner join hs_relatorio_risco on hs_relatorio_risco.id = hs_relatorio_medida.risco_id " - + " inner join hs_relatorio_posto_risco on (hs_relatorio_posto_risco.posto_id = hs_relatorio_posto.id and hs_relatorio_posto_risco.risco_id = hs_relatorio_risco.id) " - + " inner join hs_relatorio on hs_relatorio.id = hs_relatorio_risco.relatorio_id " - + " inner join hs_relatorio_area on hs_relatorio_area.id = area_id " - + " left outer join hs_relatorio_risco_valor_qualitativo on ( hs_relatorio_risco_valor_qualitativo.id = hs_relatorio_posto_risco.valor_qualitativo_id ) " - + " where hs_relatorio_posto_risco.risco_id = " + r.getId() + " and area_id = " + a.getId() + " and hs_relatorio_posto.deleted_date is null) subquery " - + " order by subquery.valor"; + + Select innerSelect = new Select2( + new String[] { HsRelatorioPostoData.TABLENAME, HsRelatorioPostoMedidaData.TABLENAME, + HsRelatorioMedidaData.TABLENAME, HsRelatorioRiscoData.TABLENAME, HsRelatorioPostoRiscoData.TABLENAME, + HsRelatorioData.TABLENAME, HsRelatorioAreaData.TABLENAME, HsRelatorioRiscoValorQualitativoData.TABLENAME }, + new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, + Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_LEFT_OUTER }, + new Expression[]{ + new Field( HsRelatorioPostoMedidaData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ), + new Field( HsRelatorioMedidaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoMedidaData.MEDIDA_ID_FULL ) ), + new Field( HsRelatorioRiscoData.ID_FULL ).isEqual( new Field( HsRelatorioMedidaData.RISCO_ID_FULL ) ), + new Field( HsRelatorioPostoRiscoData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ) + .and( new Field( HsRelatorioPostoRiscoData.RISCO_ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.ID_FULL ) ) ), + new Field( HsRelatorioData.ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.RELATORIO_ID_FULL ) ), + new Field( HsRelatorioAreaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoData.AREA_ID_FULL ) ), + new Field( HsRelatorioRiscoValorQualitativoData.ID_FULL ).isEqual( new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ) ) + }, + new String[]{ "DISTINCT " + HsRelatorioPostoRiscoData.RISCO_ID_FULL, + HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL, + HsRelatorioRiscoValorQualitativoData.DESCRIPTION_FULL, + "CASE WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + .and( new Field( HsRelatorioPostoRiscoData.PROBABILIDADE_FULL ).isEqual( null ) ) + .and( new Field( HsRelatorioPostoRiscoData.SEVERIDADE_FULL ).isEqual( null ) ).toString() + + " THEN null WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + + " THEN " + HsRelatorioPostoRiscoData.PROBABILIDADE_FULL + "*" + HsRelatorioPostoRiscoData.SEVERIDADE_FULL + + " ELSE null END AS valor " }, + new Field( HsRelatorioPostoRiscoData.RISCO_ID_FULL ).isEqual( r.getId() ) + .and( new Field( HsRelatorioPostoData.AREA_ID_FULL ).isEqual( a.getId() ) ) + .and( new Field( HsRelatorioPostoData.DELETED_DATE_FULL ).isEqual( null ) ), + new String[]{ HsRelatorioRiscoData.ID_FULL }, null, null, null + ); + + Select select = new Select( MessageFormat.format( "SELECT subquery.valor, subquery.valor_qualitativo_id FROM ( {0} ) subquery ORDER BY subquery.valor ", innerSelect.toString() ) ); System.out.println( "\t\t\t\t\t\t\t\tprovider . getValoresByRisco( " + r.getId() + ", " + a.getId() + " ) : " ); - System.out.println( "\t\t\t\t\t\t\t\t\t\tSQL : " + sql ); + System.out.println( "\t\t\t\t\t\t\t\t\t\tSQL : " + select.toString() ); + + Virtual2DArray res = getLocalExecuter().executeQuery( select ); - Statement st = createLocalStatement(); - ResultSet rs = st.executeQuery( sql ); List< Valor > valores = new LinkedList< Valor >(); - if ( rs.isBeforeFirst() ) - { - rs.first(); - do - { - Object oValor = rs.getObject( "valor" ); - Object valorQualitativoID = rs.getObject( "valor_qualitativo_id" ); - - Valor v = new Valor(); - v.setValorQuantitativo( oValor == null ? null : ( Integer ) oValor ); - v.setValorQualitativoID( valorQualitativoID == null ? null : ( Integer ) valorQualitativoID ); - valores.add( v ); - } - while ( rs.next() ); - } - return valores; - } -// private List getMedidasByValor(Valor v, Risco r, Area a) throws Exception -// { -// Statement st = dblocal.createStatement(); -// String sql = "select distinct medida_id, valor, descricao from "; -// sql += "( select distinct hs_relatorio_posto_medida.medida_id, hs_relatorio_posto_risco.risco_id, hs_relatorio_medida.description as descricao, "; -// sql += "case when hs_relatorio_posto_risco.valor_qualitativo_id isnull and hs_relatorio_posto_risco.probabilidade isnull and hs_relatorio_posto_risco.severidade isnull then null "; -// sql += "when hs_relatorio_posto_risco.valor_qualitativo_id isnull then hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade "; -// sql += "else hs_relatorio_posto_risco.valor_qualitativo_id "; -// sql += "end as valor "; -// sql += "from hs_relatorio_posto "; -// sql += "inner join hs_relatorio_posto_medida on hs_relatorio_posto_medida.posto_id = hs_relatorio_posto.id "; -// sql += "inner join hs_relatorio_medida on hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id "; -// sql += "inner join hs_relatorio_risco on hs_relatorio_risco.id = hs_relatorio_medida.risco_id "; -// sql += "inner join hs_relatorio_posto_risco on (hs_relatorio_posto_risco.posto_id = hs_relatorio_posto.id and hs_relatorio_posto_risco.risco_id = hs_relatorio_risco.id) "; -// sql += "inner join hs_relatorio on hs_relatorio.id = hs_relatorio_risco.relatorio_id "; -// sql += "inner join hs_relatorio_area on hs_relatorio_area.id = area_id "; -// sql += "where hs_relatorio_posto_risco.risco_id = " + r.getId() + " and area_id = " + a.getId() + " and hs_relatorio_posto_medida.is_plano_actuacao = true" + ") subquery "; -// //sql += "where hs_relatorio_posto_risco.risco_id = " + r.getId() + " and area_id = " + a.getId() + ") subquery "; -// //sql += "where valor = " + v.getValorQuantitativo() + " "; -// sql += "order by subquery.medida_id, valor"; -// System.out.println("MEDIDAS BY VALOR SQL : " + sql); -// ResultSet rs = st.executeQuery(sql); -// List medidas = new ArrayList(); -// if(rs.isBeforeFirst()) -// { -// rs.first(); -// do -// { -// Medida m = new Medida(); -// //int valor = rs.getInt("valor"); -// //m.setValorQuantitativo(new Integer(valor)); -// m.setId(new Integer( rs.getInt("medida_id") )); -// m.setDescricao(Utils.unicodeToHTML(rs.getString("descricao"))); -// m.setPostos(getPostosByMedidaAndValor(m, v, a)); -// medidas.add(m); -// }while(rs.next()); -// } -// return medidas; -// } + for( int i = 0; i < res.rowCount(); i++ ) + { + Integer oValor = res.get( i, 0 ); + Integer valorQualitativoID = res.get( i, 1 ); + + Valor v = new Valor(); + v.setValorQuantitativo( oValor == null ? null : oValor ); + v.setValorQualitativoID( valorQualitativoID == null ? null : valorQualitativoID ); + valores.add( v ); + } + + return valores; + } private List getMedidasByRisco( Risco r, Area a ) throws Exception { - String sql = "select distinct medida_id, valor, descricao from " - + " ( select distinct hs_relatorio_posto_medida.medida_id, hs_relatorio_posto_risco.risco_id, hs_relatorio_medida.description as descricao, " - + " case when hs_relatorio_posto_risco.valor_qualitativo_id isnull and hs_relatorio_posto_risco.probabilidade isnull and hs_relatorio_posto_risco.severidade isnull then null " - + " when hs_relatorio_posto_risco.valor_qualitativo_id isnull then hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade " - + " else hs_relatorio_posto_risco.valor_qualitativo_id " - + " end as valor " - + " from hs_relatorio_posto " - + " inner join hs_relatorio_posto_medida on hs_relatorio_posto_medida.posto_id = hs_relatorio_posto.id " - + " inner join hs_relatorio_medida on hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id " - + " inner join hs_relatorio_risco on hs_relatorio_risco.id = hs_relatorio_medida.risco_id " - + " inner join hs_relatorio_posto_risco on (hs_relatorio_posto_risco.posto_id = hs_relatorio_posto.id and hs_relatorio_posto_risco.risco_id = hs_relatorio_risco.id) " - + " inner join hs_relatorio on hs_relatorio.id = hs_relatorio_risco.relatorio_id " - + " inner join hs_relatorio_area on hs_relatorio_area.id = area_id " - + " where hs_relatorio_medida.description is not null and length( hs_relatorio_medida.description ) > 0 " - + " and hs_relatorio_posto_risco.risco_id = " + r.getId() + " and area_id = " + a.getId() + " and hs_relatorio_posto_medida.is_plano_actuacao " - + " and hs_relatorio_posto.deleted_date is null and hs_relatorio_medida.deleted_date is null ) subquery " - //+ " where hs_relatorio_posto_risco.risco_id = " + r.getId() + " and area_id = " + a.getId() + ") subquery " - //+ " where valor = " + v.getValorQuantitativo() + " " - + " order by subquery.medida_id, valor"; + Select innerSelect = new Select2( + new String[] { HsRelatorioPostoData.TABLENAME, HsRelatorioPostoMedidaData.TABLENAME, + HsRelatorioMedidaData.TABLENAME, HsRelatorioRiscoData.TABLENAME, HsRelatorioPostoRiscoData.TABLENAME, + HsRelatorioData.TABLENAME, HsRelatorioAreaData.TABLENAME, HsRelatorioRiscoValorQualitativoData.TABLENAME }, + new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, + Select2.JOIN_INNER, Select2.JOIN_INNER }, + new Expression[]{ + new Field( HsRelatorioPostoMedidaData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ), + new Field( HsRelatorioMedidaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoMedidaData.MEDIDA_ID_FULL ) ), + new Field( HsRelatorioRiscoData.ID_FULL ).isEqual( new Field( HsRelatorioMedidaData.RISCO_ID_FULL ) ), + new Field( HsRelatorioPostoRiscoData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ) + .and( new Field( HsRelatorioPostoRiscoData.RISCO_ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.ID_FULL ) ) ), + new Field( HsRelatorioData.ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.RELATORIO_ID_FULL ) ), + new Field( HsRelatorioAreaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoData.AREA_ID_FULL ) ) + }, + new String[]{ "DISTINCT " + HsRelatorioPostoMedidaData.MEDIDA_ID_FULL, + HsRelatorioPostoRiscoData.RISCO_ID_FULL, + HsRelatorioMedidaData.DESCRIPTION_FULL, + "CASE WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + .and( new Field( HsRelatorioPostoRiscoData.PROBABILIDADE_FULL ).isEqual( null ) ) + .and( new Field( HsRelatorioPostoRiscoData.SEVERIDADE_FULL ).isEqual( null ) ).toString() + + " THEN null WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + + " THEN " + HsRelatorioPostoRiscoData.PROBABILIDADE_FULL + "*" + HsRelatorioPostoRiscoData.SEVERIDADE_FULL + + " ELSE " + HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL + + " END AS valor " }, + new Field( HsRelatorioMedidaData.DESCRIPTION_FULL ).isDifferent( null ) + .and( new Field( "length( " + HsRelatorioMedidaData.DESCRIPTION_FULL + " )" ).isGreater( 0 ) ) + .and( new Field( HsRelatorioPostoRiscoData.RISCO_ID_FULL ).isEqual( r.getId() ) ) + .and( new Field( HsRelatorioPostoData.AREA_ID_FULL ).isEqual( a.getId() ) ) + .and( new Field( HsRelatorioPostoMedidaData.IS_PLANO_ACTUACAO_FULL ).isEqual( Boolean.TRUE ) ) + .and( new Field( HsRelatorioPostoData.DELETED_DATE_FULL ).isEqual( null ) ) + .and( new Field( HsRelatorioMedidaData.DELETED_DATE_FULL ).isEqual( null ) ), + new String[]{ HsRelatorioRiscoData.ID_FULL }, null, null, null + ); + + Select select = new Select( MessageFormat.format( "SELECT DISTINCT medida_id, valor, descricao FROM ( {0} ) subquery ORDER BY subquery.medida_id, valor ", innerSelect.toString() ) ); + System.out.println( "\t\t\t\t\t\t\t\t\tprovider . getMedidasByRisco( " + r.getId() + ", " + a.getId() + " ) : " ); - System.out.println( "\t\t\t\t\t\t\t\t\t\t\tSQL : " + sql ); + System.out.println( "\t\t\t\t\t\t\t\t\t\t\tSQL : " + select.toString() ); + + Virtual2DArray res = getLocalExecuter( ).executeQuery( select ); - Statement st = createLocalStatement(); - ResultSet rs = st.executeQuery( sql ); List< Medida > medidas = new LinkedList< Medida >(); - if ( rs.isBeforeFirst() ) - { - rs.first(); - do - { - Medida m = new Medida(); - m.setId( new Integer( rs.getInt("medida_id") ) ); - m.setMedida_id( m.getId() ); - String descricao = rs.getString( "descricao" ); - if( descricao != null && descricao.trim().length() > 8) - { - m.setDescricao( Utils.unicodeToHTML( descricao ) ); - //m.setPostos(getPostosByMedidaAndValor(m, v, a)); - m.setPostos( getPostosByMedida( r, m, a ) ); - medidas.add( m ); - } - } - while ( rs.next() ); - } - return medidas; - } -// private List getPostosByMedidaAndValor(Medida m, Valor v, Area a) throws Exception -// { -// Statement st = dblocal.createStatement(); -// String sql = "select subquery.posto_id, valor, descricao from "; -// sql += "(select hs_relatorio_posto_medida.posto_id, hs_relatorio_posto.description as descricao, "; -// sql += "case when hs_relatorio_posto_risco.valor_qualitativo_id isnull and hs_relatorio_posto_risco.probabilidade isnull and hs_relatorio_posto_risco.severidade isnull then null "; -// sql += "when hs_relatorio_posto_risco.valor_qualitativo_id isnull then hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade "; -// sql += "else hs_relatorio_posto_risco.valor_qualitativo_id "; -// sql += "end as valor "; -// sql += "from hs_relatorio_posto_medida "; -// sql += "inner join hs_relatorio_posto_risco on hs_relatorio_posto_risco.posto_id = hs_relatorio_posto_medida.posto_id "; -// sql += "inner join hs_relatorio_posto on hs_relatorio_posto.id = hs_relatorio_posto_medida.posto_id "; -// sql += "inner join hs_relatorio_area on hs_relatorio_area.id = area_id "; -// sql += "where medida_id = " + m.getId() + " and area_id = " + a.getId() + ") subquery "; -// //sql += "where valor = " + v.getValorQuantitativo(); -// System.out.println("POSTOS BY MEDIDA SQL : " + sql); -// ResultSet rs = st.executeQuery(sql); -// List postos = new ArrayList(); -// if(rs.isBeforeFirst()) -// { -// rs.first(); -// do -// { -// PostoTrabalho p = new PostoTrabalho(); -// p.setId(new Integer( rs.getInt("posto_id") )); -// p.setDescricao(Utils.unicodeToHTML(rs.getString("descricao"))); -// postos.add(p); -// }while(rs.next()); -// } -// return postos; -// } + for( int i = 0; i < res.rowCount(); i++ ) + { + Integer rId = res.get( i, 0 ); + String rDescricao = res.get( i, 2 ); + + Medida m = new Medida(); + m.setId( rId ); + m.setMedida_id( rId ); + if( rDescricao != null && rDescricao.trim().length() > 8) + { + m.setDescricao( Utils.unicodeToHTML( rDescricao ) ); + m.setPostos( getPostosByMedida( r, m, a ) ); + medidas.add( m ); + } + } + + return medidas; + } private List getPostosByMedida(Risco r, Medida m, Area a) throws Exception { - String sql = "select subquery.posto_id, valor, descricao, is_principal from "; - sql += "(select hs_relatorio_posto_medida.posto_id, hs_relatorio_posto.description as descricao, "; - sql += "case when hs_relatorio_posto_risco.valor_qualitativo_id isnull and hs_relatorio_posto_risco.probabilidade isnull and hs_relatorio_posto_risco.severidade isnull then null "; - sql += "when hs_relatorio_posto_risco.valor_qualitativo_id isnull then hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade "; - sql += "else hs_relatorio_posto_risco.valor_qualitativo_id "; - sql += "end as valor, coalesce( hs_relatorio_posto.is_principal, false ) as is_principal "; - sql += "from hs_relatorio_posto_medida "; - sql += "inner join hs_relatorio_posto_risco on hs_relatorio_posto_risco.posto_id = hs_relatorio_posto_medida.posto_id "; - sql += "inner join hs_relatorio_posto on hs_relatorio_posto.id = hs_relatorio_posto_medida.posto_id "; - sql += "inner join hs_relatorio_area on hs_relatorio_area.id = area_id "; - sql += "where medida_id = " + m.getId() + " and area_id = " + a.getId() + " and risco_id = " + r.getId() + ") subquery "; - //sql += "where valor = " + v.getValorQuantitativo(); - System.out.println("POSTOS BY MEDIDA SQL : " + sql); - Statement st = createLocalStatement(); - ResultSet rs = st.executeQuery( sql ); + Select innerSelect = new Select2( + new String[] { HsRelatorioPostoMedidaData.TABLENAME, HsRelatorioPostoRiscoData.TABLENAME, + HsRelatorioPostoData.TABLENAME, HsRelatorioAreaData.TABLENAME }, + new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER }, + new Expression[]{ + new Field( HsRelatorioPostoRiscoData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoMedidaData.POSTO_ID_FULL ) ), + new Field( HsRelatorioPostoData.ID_FULL ).isEqual( new Field( HsRelatorioPostoMedidaData.POSTO_ID_FULL ) ), + new Field( HsRelatorioAreaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoData.AREA_ID_FULL ) ) + }, + new String[]{ HsRelatorioPostoMedidaData.POSTO_ID_FULL, + HsRelatorioPostoData.DESCRIPTION_FULL, + "CASE WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + .and( new Field( HsRelatorioPostoRiscoData.PROBABILIDADE_FULL ).isEqual( null ) ) + .and( new Field( HsRelatorioPostoRiscoData.SEVERIDADE_FULL ).isEqual( null ) ).toString() + + " THEN null WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + + " THEN " + HsRelatorioPostoRiscoData.PROBABILIDADE_FULL + "*" + HsRelatorioPostoRiscoData.SEVERIDADE_FULL + + " ELSE " + HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL + + " END AS valor ", + "coalesce( " + HsRelatorioPostoData.IS_PRINCIPAL_FULL + ", false )" }, + new Field( HsRelatorioPostoMedidaData.MEDIDA_ID ).isEqual( m.getId() ) + .and( new Field( HsRelatorioPostoRiscoData.RISCO_ID_FULL ).isEqual( r.getId() ) ) + .and( new Field( HsRelatorioPostoData.AREA_ID_FULL ).isEqual( a.getId() ) ), + new String[]{ HsRelatorioRiscoData.ID_FULL }, null, null, null + ); + + Select select = new Select( MessageFormat.format( "SELECT subquery.posto_id, valor, descricao, is_principal FROM ( {0} ) subquery ", innerSelect.toString() ) ); + + System.out.println("POSTOS BY MEDIDA SQL : " + select.toString() ); + + Virtual2DArray res = getLocalExecuter( ).executeQuery( select ); + List< PostoTrabalho > postos = new LinkedList< PostoTrabalho >(); - if ( rs.isBeforeFirst() ) - { - rs.first(); - do - { - PostoTrabalho p = new PostoTrabalho(); - p.setId( new Integer( rs.getInt("posto_id") ) ); - p.setPosto_id( p.getId() ); - p.setDescricao( Utils.unicodeToHTML( rs.getString( "descricao" ) ) ); - p.setIs_principal( new Boolean( rs.getBoolean( "is_principal" ) ) ); - postos.add( p ); - } - while ( rs.next() ); - } - return postos; + + for( int i = 0; i < res.rowCount(); i++ ) + { + Integer rPostoId = res.get( i, 0 ); + String rDescricao = res.get( i, 2 ); + Boolean rIsPrincipal = res.get( i, 3 ); + + PostoTrabalho p = new PostoTrabalho(); + p.setId( rPostoId ); + p.setPosto_id( rPostoId ); + p.setDescricao( Utils.unicodeToHTML( rDescricao ) ); + p.setIs_principal( rIsPrincipal ); + postos.add( p ); + } + + return postos; } public List getValoresQualitativos() throws Exception { - String sql = "select id, description from hs_relatorio_risco_valor_qualitativo;"; - System.out.println("VALORES QUALITATIVOS SQL : " + sql); - Statement st = createLocalStatement(); - ResultSet rs = st.executeQuery( sql ); - List< ValorQualitativo > valores = new LinkedList< ValorQualitativo >(); - if ( rs.isBeforeFirst() ) - { - rs.first(); - do - { - ValorQualitativo v = new ValorQualitativo(); - v.setId( new Integer( rs.getInt("id") ) ); - v.setDescricao( Utils.unicodeToHTML( rs.getString( "description" ) ) ); - valores.add( v ); - } - while ( rs.next() ); - } - return valores; + Select select = new Select2( HsRelatorioRiscoValorQualitativoData.TABLENAME, null, HsRelatorioRiscoValorQualitativoData.ID_FULL, HsRelatorioRiscoValorQualitativoData.DESCRIPTION_FULL ); + + System.out.println("VALORES QUALITATIVOS SQL : " + select.toString()); + + Virtual2DArray res = getLocalExecuter( ).executeQuery( select ); + + List< ValorQualitativo > valores = new LinkedList< ValorQualitativo >(); + + for( int i = 0; i < res.rowCount(); i++ ) + { + Integer rId = res.get( i, 0 ); + String rDescricao = res.get( i, 1 ); + + ValorQualitativo v = new ValorQualitativo(); + v.setId( rId ); + v.setDescricao( Utils.unicodeToHTML( rDescricao ) ); + valores.add( v ); + } + + return valores; } public List getValoresQualitativosOnline() throws Exception @@ -437,52 +453,95 @@ public class PlanosActuacaoImporterProvider extends GenericDataProvider private boolean existemMedidasByArea( Integer areaID ) throws Exception { - String sql = "select distinct medida_id, valor, descricao " - + " from ( select distinct hs_relatorio_posto_medida.medida_id, hs_relatorio_posto_risco.risco_id, hs_relatorio_medida.description as descricao, " - + " case when hs_relatorio_posto_risco.valor_qualitativo_id isnull and hs_relatorio_posto_risco.probabilidade isnull and hs_relatorio_posto_risco.severidade isnull then null " - + " when hs_relatorio_posto_risco.valor_qualitativo_id isnull then hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade else hs_relatorio_posto_risco.valor_qualitativo_id end as valor from hs_relatorio_posto " - + " inner join hs_relatorio_posto_medida on hs_relatorio_posto_medida.posto_id = hs_relatorio_posto.id " - + " inner join hs_relatorio_medida on hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id " - + " inner join hs_relatorio_risco on hs_relatorio_risco.id = hs_relatorio_medida.risco_id " - + " inner join hs_relatorio_posto_risco on (hs_relatorio_posto_risco.posto_id = hs_relatorio_posto.id and hs_relatorio_posto_risco.risco_id = hs_relatorio_risco.id) " - + " inner join hs_relatorio on hs_relatorio.id = hs_relatorio_risco.relatorio_id " - + " inner join hs_relatorio_area on hs_relatorio_area.id = area_id " - + " where area_id = " + areaID + " and hs_relatorio_posto_medida.is_plano_actuacao = true) subquery " - + " order by subquery.medida_id, valor"; + Select innerSelect = new Select2( + new String[] { HsRelatorioPostoData.TABLENAME, HsRelatorioPostoMedidaData.TABLENAME, + HsRelatorioMedidaData.TABLENAME, HsRelatorioRiscoData.TABLENAME, HsRelatorioPostoRiscoData.TABLENAME, + HsRelatorioData.TABLENAME, HsRelatorioAreaData.TABLENAME }, + new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, + Select2.JOIN_INNER, Select2.JOIN_INNER }, + new Expression[]{ + new Field( HsRelatorioPostoMedidaData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ), + new Field( HsRelatorioMedidaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoMedidaData.MEDIDA_ID_FULL ) ), + new Field( HsRelatorioRiscoData.ID_FULL ).isEqual( new Field( HsRelatorioMedidaData.RISCO_ID_FULL ) ), + new Field( HsRelatorioPostoRiscoData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ) + .and( new Field( HsRelatorioPostoRiscoData.RISCO_ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.ID_FULL ) ) ), + new Field( HsRelatorioData.ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.RELATORIO_ID_FULL ) ), + new Field( HsRelatorioAreaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoData.AREA_ID_FULL ) ) + }, + new String[]{ "DISTINCT " + HsRelatorioPostoMedidaData.MEDIDA_ID_FULL, + HsRelatorioPostoRiscoData.RISCO_ID_FULL, + HsRelatorioMedidaData.DESCRIPTION_FULL, + "CASE WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + .and( new Field( HsRelatorioPostoRiscoData.PROBABILIDADE_FULL ).isEqual( null ) ) + .and( new Field( HsRelatorioPostoRiscoData.SEVERIDADE_FULL ).isEqual( null ) ).toString() + + " THEN null WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + + " THEN " + HsRelatorioPostoRiscoData.PROBABILIDADE_FULL + "*" + HsRelatorioPostoRiscoData.SEVERIDADE_FULL + + " ELSE " + HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL + + " END AS valor " }, + new Field( HsRelatorioPostoData.AREA_ID_FULL ).isEqual( areaID ) + .and( new Field( HsRelatorioPostoMedidaData.IS_PLANO_ACTUACAO_FULL ).isEqual( Boolean.TRUE ) ), + new String[]{ HsRelatorioRiscoData.ID_FULL }, null, null, null + ); + + Select select = new Select( MessageFormat.format( "SELECT distinct medida_id, valor, descricao FROM ( {0} ) subquery ORDER BY subquery.medida_id, valor ", innerSelect.toString() ) ); System.out.println( "\t\t\t\t\t\t\t\t\tprovider . existemMedidasByArea( " + areaID + " ) : " ); - System.out.println( "\t\t\t\t\t\t\t\t\t\t\tSQL : " + sql ); + System.out.println( "\t\t\t\t\t\t\t\t\t\t\tSQL : " + select.toString() ); + + Virtual2DArray res = getLocalExecuter( ).executeQuery( select ); - Statement st = createLocalStatement(); - ResultSet rs = st.executeQuery( sql ); - return rs.isBeforeFirst(); + return res.rowCount() > 0; } private boolean existemMedidasByRisco(Integer risco_id) throws Exception { - String sql = "select distinct medida_id " - + " from ( select distinct hs_relatorio_posto_medida.medida_id, hs_relatorio_posto_risco.risco_id, hs_relatorio_medida.description as descricao, " - + " case when hs_relatorio_posto_risco.valor_qualitativo_id isnull and hs_relatorio_posto_risco.probabilidade isnull and hs_relatorio_posto_risco.severidade isnull then null " - + " when hs_relatorio_posto_risco.valor_qualitativo_id isnull then hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade else hs_relatorio_posto_risco.valor_qualitativo_id end as valor from hs_relatorio_posto " - + " inner join hs_relatorio_posto_medida on hs_relatorio_posto_medida.posto_id = hs_relatorio_posto.id " - + " inner join hs_relatorio_medida on hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id " - + " inner join hs_relatorio_risco on hs_relatorio_risco.id = hs_relatorio_medida.risco_id " - + " inner join hs_relatorio_posto_risco on (hs_relatorio_posto_risco.posto_id = hs_relatorio_posto.id and hs_relatorio_posto_risco.risco_id = hs_relatorio_risco.id) " - + " inner join hs_relatorio on hs_relatorio.id = hs_relatorio_risco.relatorio_id " - + " inner join hs_relatorio_area on hs_relatorio_area.id = area_id " - + " where hs_relatorio_posto_risco.risco_id = " + risco_id + " and hs_relatorio_posto_medida.is_plano_actuacao = true) subquery " - + " order by medida_id"; - - System.out.println("EXISTEM MEDIDAS BY RISCO SQL : " + sql); - Statement st = createLocalStatement(); - ResultSet rs = st.executeQuery( sql ); - return rs.isBeforeFirst(); + Select innerSelect = new Select2( + new String[] { HsRelatorioPostoData.TABLENAME, HsRelatorioPostoMedidaData.TABLENAME, + HsRelatorioMedidaData.TABLENAME, HsRelatorioRiscoData.TABLENAME, HsRelatorioPostoRiscoData.TABLENAME, + HsRelatorioData.TABLENAME, HsRelatorioAreaData.TABLENAME }, + new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, + Select2.JOIN_INNER, Select2.JOIN_INNER }, + new Expression[]{ + new Field( HsRelatorioPostoMedidaData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ), + new Field( HsRelatorioMedidaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoMedidaData.MEDIDA_ID_FULL ) ), + new Field( HsRelatorioRiscoData.ID_FULL ).isEqual( new Field( HsRelatorioMedidaData.RISCO_ID_FULL ) ), + new Field( HsRelatorioPostoRiscoData.POSTO_ID_FULL ).isEqual( new Field( HsRelatorioPostoData.ID_FULL ) ) + .and( new Field( HsRelatorioPostoRiscoData.RISCO_ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.ID_FULL ) ) ), + new Field( HsRelatorioData.ID_FULL ).isEqual( new Field( HsRelatorioRiscoData.RELATORIO_ID_FULL ) ), + new Field( HsRelatorioAreaData.ID_FULL ).isEqual( new Field( HsRelatorioPostoData.AREA_ID_FULL ) ) + }, + new String[]{ "DISTINCT " + HsRelatorioPostoMedidaData.MEDIDA_ID_FULL, + HsRelatorioPostoRiscoData.RISCO_ID_FULL, + HsRelatorioMedidaData.DESCRIPTION_FULL, + "CASE WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + .and( new Field( HsRelatorioPostoRiscoData.PROBABILIDADE_FULL ).isEqual( null ) ) + .and( new Field( HsRelatorioPostoRiscoData.SEVERIDADE_FULL ).isEqual( null ) ).toString() + + " THEN null WHEN " + + new Field( HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL ).isEqual( null ) + + " THEN " + HsRelatorioPostoRiscoData.PROBABILIDADE_FULL + "*" + HsRelatorioPostoRiscoData.SEVERIDADE_FULL + + " ELSE " + HsRelatorioPostoRiscoData.VALOR_QUALITATIVO_ID_FULL + + " END AS valor " }, + new Field( HsRelatorioPostoRiscoData.RISCO_ID_FULL ).isEqual( risco_id ) + .and( new Field( HsRelatorioPostoMedidaData.IS_PLANO_ACTUACAO_FULL ).isEqual( Boolean.TRUE ) ), + new String[]{ HsRelatorioRiscoData.ID_FULL }, null, null, null + ); + + Select select = new Select( MessageFormat.format( "SELECT distinct medida_id FROM ( {0} ) subquery ORDER BY medida_id ", innerSelect.toString() ) ); + + System.out.println("EXISTEM MEDIDAS BY RISCO SQL : " + select.toString()); + + Virtual2DArray res = getLocalExecuter( ).executeQuery( select ); + + return res.rowCount() > 0; } public Integer createPlano( PlanoActuacao p ) throws Exception { - Integer newPlanoID = null; + Integer newPlanoID; Date todayDate = new Date(); boolean concluidoPorDesactivacao = p.getConcluidoPorDesactivacao() == null ? Boolean.FALSE : p.getConcluidoPorDesactivacao(); @@ -535,7 +594,6 @@ public class PlanosActuacaoImporterProvider extends GenericDataProvider planoData.setTecnico_superior_hs_nome( p.getTecnico_superior_hs_nome() ); planoData.setData_desactivacao( dataDesactivacao ); -// planoData.setData_disponibilizacao( p.getData_disponibilizacao() ); planoData.setData_validacao_seg( null ); planoData.setUser_seg( null ); @@ -552,7 +610,7 @@ public class PlanosActuacaoImporterProvider extends GenericDataProvider public Integer createArea( Area a ) throws Exception { - Integer newAreaID = null; + Integer newAreaID; PlanoAreasData areaData = new PlanoAreasData(); areaData.setArea_id( a.getArea_id() ); @@ -571,7 +629,7 @@ public class PlanosActuacaoImporterProvider extends GenericDataProvider public Integer createRisco( Risco r ) throws Exception { - Integer newRiscoID = null; + Integer newRiscoID; PlanoRiscosData riscoData = new PlanoRiscosData(); riscoData.setDescricao( Utils.parseToInsert( r.getDescricao() ) ); @@ -593,7 +651,7 @@ public class PlanosActuacaoImporterProvider extends GenericDataProvider public Integer createMedida( Medida m ) throws Exception { - Integer newMedidaID = null; + Integer newMedidaID; PlanoMedidasData medidaData = new PlanoMedidasData(); medidaData.setMedida_id( m.getMedida_id() ); @@ -650,20 +708,18 @@ public class PlanosActuacaoImporterProvider extends GenericDataProvider valor.save(); } - //==================== public String getEmpresaNome( Integer empresaID ) throws Exception { String nome = null; - EmpresasData empresaData = getLocalProvider().load( EmpresasData.class, empresaID, EmpresasData.ID ); + EmpresasData empresaData = getLocalProvider().load( EmpresasData.class, empresaID, EmpresasData.ID, null ); if ( empresaData != null ) { nome = Utils.unicodeToHTML( empresaData.getDesignacao_social() ); } else { - ErrorLogger.logException( new Exception( "CreatePlanosDataProvider . getEmpresaNome( " + empresaID + " ) : is Null !" + - "\n\tempresaData = " + (empresaData == null ? "null" : "not null") + ", nome = " + nome ) ); + ErrorLogger.logException( new Exception( "CreatePlanosDataProvider . getEmpresaNome( " + empresaID + " ) : is Null !" + "\n\tempresaData = " + ( "null" ) + ", nome = " + nome ) ); } return nome; } diff --git a/trunk/PlanosActuacao/web/WEB-INF/lib/evolute.jar b/trunk/PlanosActuacao/web/WEB-INF/lib/evolute.jar index 180ccc93..ec566036 100644 Binary files a/trunk/PlanosActuacao/web/WEB-INF/lib/evolute.jar and b/trunk/PlanosActuacao/web/WEB-INF/lib/evolute.jar differ diff --git a/trunk/PlanosActuacao/web/WEB-INF/lib/postgresql-9.2-1002.jdbc4.jar b/trunk/PlanosActuacao/web/WEB-INF/lib/postgresql-9.3-1100-jdbc4.jar similarity index 62% rename from trunk/PlanosActuacao/web/WEB-INF/lib/postgresql-9.2-1002.jdbc4.jar rename to trunk/PlanosActuacao/web/WEB-INF/lib/postgresql-9.3-1100-jdbc4.jar index abd06ba3..f00ee16a 100644 Binary files a/trunk/PlanosActuacao/web/WEB-INF/lib/postgresql-9.2-1002.jdbc4.jar and b/trunk/PlanosActuacao/web/WEB-INF/lib/postgresql-9.3-1100-jdbc4.jar differ diff --git a/trunk/PlanosActuacao/web/WEB-INF/lib/shst.jar b/trunk/PlanosActuacao/web/WEB-INF/lib/shst.jar index 5523d79e..21931d58 100644 Binary files a/trunk/PlanosActuacao/web/WEB-INF/lib/shst.jar and b/trunk/PlanosActuacao/web/WEB-INF/lib/shst.jar differ