From 6302a1a4257cbe7195ef58bef4eb861781febae9 Mon Sep 17 00:00:00 2001 From: Frederico Palma Date: Thu, 17 May 2007 23:30:27 +0000 Subject: [PATCH] no message git-svn-id: https://svn.coded.pt/svn/SIPRP@407 bb69d46d-e84e-40c8-a05a-06db0d633741 --- .../processo/ProcessoDataProvider.java | 148 ++++++++++++++++++ .../processo/detalhes/ConsultaPanel.java | 32 +++- 2 files changed, 178 insertions(+), 2 deletions(-) diff --git a/trunk/siprp/medicina/processo/ProcessoDataProvider.java b/trunk/siprp/medicina/processo/ProcessoDataProvider.java index f64e31da..217387f8 100644 --- a/trunk/siprp/medicina/processo/ProcessoDataProvider.java +++ b/trunk/siprp/medicina/processo/ProcessoDataProvider.java @@ -29,6 +29,8 @@ import java.util.Date; import java.util.HashMap; import java.util.Vector; import siprp.medicina.MedicinaConstants; +import siprp.medicina.processo.data.TrabalhadoresConsultasData; +import siprp.medicina.processo.data.TrabalhadoresConsultasDatasData; import siprp.medicina.processo.data.TrabalhadoresProcessoData; /** @@ -347,4 +349,150 @@ public class ProcessoDataProvider return ( Integer ) array.get( 0, 0 ); } } + + public boolean getProcessoTemConsultasPorRealizar( Integer processoID ) + throws Exception + { + Select select = + new Select2( new String[]{ "trabalhadores_consultas" }, + new Integer[]{}, + new Expression[]{}, + new String[]{ "id", "estado" }, + new Field( "processo_id" ).isEqual( processoID ), + new String[]{ "estado" }, + null, + null, + null ); + Virtual2DArray array = EXECUTER.executeQuery( select ); + return ( array.columnLength() > 0 ) && ( new Integer( ESTADO_POR_REALIZAR ).equals( array.get( 0, 1 ) ) ); + } + + public boolean getProcessoTemECDsPorRealizar( Integer processoID ) + throws Exception + { + Select select = + new Select2( new String[]{ "trabalhadores_ecds" }, + new Integer[]{}, + new Expression[]{}, + new String[]{ "id", "estado" }, + new Field( "processo_id" ).isEqual( processoID ), + new String[]{ "estado" }, + null, + null, + null ); + Virtual2DArray array = EXECUTER.executeQuery( select ); + return ( array.columnLength() > 0 ) && ( new Integer( ESTADO_POR_REALIZAR ).equals( array.get( 0, 1 ) ) ); + } + + public Integer getConsultaEmAbertoForProcesso( Integer processoID ) + throws Exception + { + Select select = + new Select2( new String[]{ "trabalhadores_consultas" }, + new Integer[]{}, + new Expression[]{}, + new String[]{ "id" }, + new Field( "processo_id" ).isEqual( processoID ).and( + new Field( "estado" ).isEqual( new Integer( ESTADO_POR_REALIZAR ) ) ), + null, + null, + null, + null ); + Virtual2DArray array = EXECUTER.executeQuery( select ); + if( array.columnLength() == 0 ) + { + return null; + } + else + { + return ( Integer ) array.get( 0, 0 ); + } + } + + public Integer getECDsEmAbertoForProcesso( Integer processoID ) + throws Exception + { + Select select = + new Select2( new String[]{ "trabalhadores_ecds" }, + new Integer[]{}, + new Expression[]{}, + new String[]{ "id" }, + new Field( "processo_id" ).isEqual( processoID ).and( + new Field( "estado" ).isDifferent( new Integer( ESTADO_POR_REALIZAR ) ) ), + null, + null, + null, + null ); + Virtual2DArray array = EXECUTER.executeQuery( select ); + if( array.columnLength() == 0 ) + { + return null; + } + else + { + return ( Integer ) array.get( 0, 0 ); + } + } + + public TrabalhadoresConsultasData getConsultaByID( Integer id ) + throws Exception + { + return ( TrabalhadoresConsultasData ) JDO.load( TrabalhadoresConsultasData.class, id ); + } + + public void saveConsulta( TrabalhadoresConsultasData consulta ) + throws Exception + { + consulta.save(); + } + + public TrabalhadoresConsultasDatasData getConsultaDataByID( Integer id ) + throws Exception + { + return ( TrabalhadoresConsultasDatasData ) JDO.load( TrabalhadoresConsultasDatasData.class, id ); + } + + public void saveConsultaData( TrabalhadoresConsultasDatasData consultaData ) + throws Exception + { + consultaData.save(); + } + + public boolean verificarDataValidaForConsulta( Integer consultaID, Date data ) + throws Exception + { + Select select = + new Select2( new String[]{ "trabalhadores_consultas_datas" }, + new Integer[]{}, + new Expression[]{}, + new String[]{ "id" }, + new Field( "trabalhadores_consultas_id" ).isEqual( consultaID ).and( + new Field( "estado" ).isDifferent( new Integer( ESTADO_POR_REALIZAR ) ) ).and( + new Field( "data" ).isGreater( data ) ), + null, + null, + null, + null ); + Virtual2DArray array = EXECUTER.executeQuery( select ); + return array.columnLength() == 0; + } + + public boolean verificarDataValidaForECDs( Integer ecdsID, Date data ) + throws Exception + { + Select select = + new Select2( new String[]{ "trabalhadores_ecds_datas" }, + new Integer[]{}, + new Expression[]{}, + new String[]{ "id" }, + new Field( "trabalhadores_ecdss_id" ).isEqual( ecdsID ).and( + new Field( "estado" ).isDifferent( new Integer( ESTADO_POR_REALIZAR ) ) ).and( + new Field( "data" ).isGreater( data ) ), + null, + null, + null, + null ); + Virtual2DArray array = EXECUTER.executeQuery( select ); + return array.columnLength() == 0; + } } diff --git a/trunk/siprp/medicina/processo/detalhes/ConsultaPanel.java b/trunk/siprp/medicina/processo/detalhes/ConsultaPanel.java index 5ae2883e..c0eb25cb 100644 --- a/trunk/siprp/medicina/processo/detalhes/ConsultaPanel.java +++ b/trunk/siprp/medicina/processo/detalhes/ConsultaPanel.java @@ -97,11 +97,11 @@ public class ConsultaPanel extends JPanel } else if( source.equals( emailButton ) ) { - + enviarEmail(); } else if( source.equals( estadoButton ) ) { - + mudarEstado(); } } @@ -142,6 +142,14 @@ public class ConsultaPanel extends JPanel } } + protected void enviarEmail() + { + } + + protected void mudarEstado() + { + } + public void addProcessoListener( ProcessoListener listener ) { PROCESSO_LISTENERS.add( listener ); @@ -183,6 +191,26 @@ public class ConsultaPanel extends JPanel DialogException.showExceptionMessage( ex, "Erro a carregar dados da consulta", true ); } } + enableButtons(); + } + + protected void enableButtons() + { + if( consulta != null ) + { + Integer estado = ( Integer ) consulta.get( TrabalhadoresConsultasData.ESTADO ); + dataConsultaPanel.setEnabled( estado == null || estado.intValue() == ESTADO_POR_REALIZAR ); + estadoButton.setEnabled( consulta.get( TrabalhadoresConsultasData.DATA ) != null ); + emailButton.setEnabled( consulta.get( TrabalhadoresConsultasData.DATA ) != null ); + observacoesButton.setEnabled( consulta.get( TrabalhadoresConsultasData.DATA ) != null ); + } + else + { + dataConsultaPanel.setEnabled( true ); + estadoButton.setEnabled( false ); + emailButton.setEnabled( false ); + observacoesButton.setEnabled( false ); + } } public void setTrabalhadorID( Integer trabalhadorID )