From b7664ab4ae8b25679c0fa01ea76483ec0f506d0d Mon Sep 17 00:00:00 2001 From: Frederico Palma Date: Tue, 17 Mar 2015 12:03:44 +0000 Subject: [PATCH] git-svn-id: https://svn.coded.pt/svn/SIPRP@2053 bb69d46d-e84e-40c8-a05a-06db0d633741 --- .../db/providers/AnalisesDataProvider.java | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/trunk/AnaliseAcidentesTrabalho/src/db/providers/AnalisesDataProvider.java b/trunk/AnaliseAcidentesTrabalho/src/db/providers/AnalisesDataProvider.java index f49cb343..09f307b2 100644 --- a/trunk/AnaliseAcidentesTrabalho/src/db/providers/AnalisesDataProvider.java +++ b/trunk/AnaliseAcidentesTrabalho/src/db/providers/AnalisesDataProvider.java @@ -206,7 +206,11 @@ public class AnalisesDataProvider extends GenericDataProvider throws Exception { Expression where = new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" ); - where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) ); + if( estabelecimentoID != null && estabelecimentoID > 0 ) + { + where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) ); + } +// where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) ); if( fromYear != null ) { where = where.and( @@ -300,7 +304,11 @@ public class AnalisesDataProvider extends GenericDataProvider throws Exception { Expression where = new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" ); - where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) ); + if( estabelecimentoID != null && estabelecimentoID > 0 ) + { + where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) ); + } +// where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) ); if( fromYear != null ) { @@ -392,6 +400,10 @@ public class AnalisesDataProvider extends GenericDataProvider where = where.and( new Field( "EXTRACT( year FROM " + AnalisesAcidentesData.DATA_ACIDENTE_FULL + " )" ).isEqual( fromYear ) ); } + if( estabelecimentoID != null && estabelecimentoID > 0 ) + { + where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) ); + } if( empresa_id != null ) { @@ -485,7 +497,7 @@ public class AnalisesDataProvider extends GenericDataProvider { String tables[] = new String[]{ AnalisesAcidentesData.TABLENAME }; Expression where = new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento_id ) - .or( new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" ) ); + .and( new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" ) ); String[] order = new String[]{ AnalisesAcidentesData.ANALISE_NR_FULL }; if( responsavel_loja.matches( "y" ) ) @@ -585,6 +597,10 @@ public class AnalisesDataProvider extends GenericDataProvider where = where.and( new Field( "EXTRACT( year FROM " + AnalisesAcidentesData.DATA_ACIDENTE_FULL + " )" ).isEqual( fromYear ) ); } + if( estabelecimentoID != null && estabelecimentoID > 0 ) + { + where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) ); + } where = where.and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_HS ) .or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isGreater( Global.ESTADO_HS ) @@ -676,7 +692,10 @@ public class AnalisesDataProvider extends GenericDataProvider throws Exception { Expression where = new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" ); - where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) ); + if( estabelecimentoID != null && estabelecimentoID > 0 ) + { + where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) ); + } if( fromYear != null ) { where = where.and( @@ -768,8 +787,10 @@ public class AnalisesDataProvider extends GenericDataProvider throws Exception { Expression where = new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" ); - where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) ); - + if( estabelecimentoID != null && estabelecimentoID > 0 ) + { + where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) ); + } if( fromYear != null ) { where = where.and( @@ -937,7 +958,7 @@ public class AnalisesDataProvider extends GenericDataProvider { Expression where = new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" ); where = where.and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_CONCLUIDO ) ); - if( estabelecimentoID != null ) + if( estabelecimentoID != null && estabelecimentoID > 0 ) { where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) ); } @@ -979,7 +1000,7 @@ public class AnalisesDataProvider extends GenericDataProvider { Expression where = new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_CONCLUIDO ); where = where.and( new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" ) ); - if( estabelecimentoID != null ) + if( estabelecimentoID != null && estabelecimentoID > 0 ) { where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) ); }