From d8f56fbb772d40f2ea5c0f16bac99f050e9e70ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20Sim=C3=A3o?= Date: Tue, 24 Jun 2008 15:29:59 +0000 Subject: [PATCH] git-svn-id: https://svn.coded.pt/svn/SIPRP@725 bb69d46d-e84e-40c8-a05a-06db0d633741 --- trunk/SIPRPSoft/src/leaf/LeafWindow.java | 15 +- trunk/SIPRPSoft/src/siprp/SIPRPTracker.java | 22 ++- .../companydataloaders/SIPRPDataLoader.java | 20 +- .../cayenne/providers/MedicinaDAO.java | 12 ++ .../src/siprp/lembretes/Lembrete.java | 27 ++- .../lembretes/LembretesDataProvider.java | 64 ++++++- .../src/siprp/lembretes/LembretesWindow.java | 176 +++++++++++++++++- .../remarcacoes/LembretesRemarcacaoPanel.java | 9 +- .../remarcacoes/RemarcacoesDataProvider.java | 65 +++++-- .../TratarMarcacaoTrabalhadorAction.java | 81 ++++++-- .../src/siprp/medicina/MedicinaConstants.java | 4 + .../processo/logic/MedicinaProcessoLogic.java | 120 ++++++++++-- .../src/siprp/update/UpdateList.java | 3 +- .../siprp/update/updates/V8_7_To_V8_8.java | 65 +++++++ 14 files changed, 622 insertions(+), 61 deletions(-) create mode 100644 trunk/SIPRPSoft/src/siprp/update/updates/V8_7_To_V8_8.java diff --git a/trunk/SIPRPSoft/src/leaf/LeafWindow.java b/trunk/SIPRPSoft/src/leaf/LeafWindow.java index e363db9b..76cdfbf3 100755 --- a/trunk/SIPRPSoft/src/leaf/LeafWindow.java +++ b/trunk/SIPRPSoft/src/leaf/LeafWindow.java @@ -3,7 +3,6 @@ package leaf; import static info.clearthought.layout.TableLayoutConstants.FILL; import static leaf.LeafLogic.ACTION_CANCEL; import static leaf.LeafLogic.ACTION_STARTUP; - import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; @@ -146,7 +145,7 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection /** * Run later actions */ - private Queue listRunLater = new LinkedList(); + private Queue> listRunLater = new LinkedList>(); /** * Creates a new LeafWindow binded with given 'logicController' @@ -262,10 +261,15 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection } public void runActionLater( String action ) + { + runActionLater( action, null ); + } + + public void runActionLater( String action, Object argument ) { if( action != null && mapActionByName.containsKey( action ) ) { - listRunLater.add( action ); + listRunLater.add( new Pair( action, argument ) ); } } @@ -546,11 +550,12 @@ public class LeafWindow extends JFrame implements TrackableWindow, ListSelection return result; } - private void runPendingActions() + public void runPendingActions() { while( listRunLater.size() > 0 ) { - runAction( listRunLater.poll() ); + Pair p = listRunLater.poll(); + runAction( p.getCar(), p.getCdr() ); } } diff --git a/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java b/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java index 1e4deb26..bdfe07fd 100644 --- a/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java +++ b/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java @@ -53,6 +53,7 @@ public class SIPRPTracker extends WindowTracker private final AvisosPanel avisos; private ClientesWindow clientesWindow; private MedicinaWindow medicinaWindow; + private MedicinaProcessoWindow medicinaProcessoWindow; private MarcacoesHigieneWindow higieneWindow; /** Creates a new instance of SIPRPTracker */ @@ -152,7 +153,11 @@ public class SIPRPTracker extends WindowTracker public TrackableWindow create() throws Exception { - return new MedicinaProcessoWindow(); + if( medicinaProcessoWindow == null ) + { + medicinaProcessoWindow = new MedicinaProcessoWindow(); + } + return medicinaProcessoWindow; } } ); @@ -282,6 +287,21 @@ public class SIPRPTracker extends WindowTracker return medicinaWindow; } + public MedicinaProcessoWindow getMedicinaProcessoWindow() + { + if( medicinaProcessoWindow == null ) + { + try + { + medicinaProcessoWindow = new MedicinaProcessoWindow(); + } catch( Exception e ) + { + e.printStackTrace(); + } + } + return medicinaProcessoWindow; + } + public MarcacoesHigieneWindow getHigieneWindow() { return higieneWindow; diff --git a/trunk/SIPRPSoft/src/siprp/companydataloaders/SIPRPDataLoader.java b/trunk/SIPRPSoft/src/siprp/companydataloaders/SIPRPDataLoader.java index c26fe06a..8c426598 100644 --- a/trunk/SIPRPSoft/src/siprp/companydataloaders/SIPRPDataLoader.java +++ b/trunk/SIPRPSoft/src/siprp/companydataloaders/SIPRPDataLoader.java @@ -104,6 +104,14 @@ public class SIPRPDataLoader implements CompanyDataLoader // Singleton.setInstance( SingletonConstants.LOCAL_URL, "10.158.2.3:5432" ); // Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" ); // Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); + + Singleton.setInstance( SingletonConstants.LOCAL_USER, "postgres" ); + Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "Typein" ); + Singleton.setInstance( SingletonConstants.LOCAL_URL_PREFIX, "jdbc:postgresql://" ); + Singleton.setInstance( SingletonConstants.LOCAL_URL, "dbserver:5432" ); + Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" ); + Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); + // // Singleton.setInstance( SingletonConstants.LOCAL_USER, "postgres" ); // Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "Typein" ); @@ -112,12 +120,12 @@ public class SIPRPDataLoader implements CompanyDataLoader // Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" ); // Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); - Singleton.setInstance( SingletonConstants.LOCAL_USER, "postgres" ); - Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "Typein" ); - Singleton.setInstance( SingletonConstants.LOCAL_URL_PREFIX, "jdbc:postgresql://" ); - Singleton.setInstance( SingletonConstants.LOCAL_URL, "192.168.1.1:5432" ); - Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" ); - Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); +// Singleton.setInstance( SingletonConstants.LOCAL_USER, "postgres" ); +// Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "Typein" ); +// Singleton.setInstance( SingletonConstants.LOCAL_URL_PREFIX, "jdbc:postgresql://" ); +// Singleton.setInstance( SingletonConstants.LOCAL_URL, "192.168.1.1:5432" ); +// Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" ); +// Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); } } diff --git a/trunk/SIPRPSoft/src/siprp/database/cayenne/providers/MedicinaDAO.java b/trunk/SIPRPSoft/src/siprp/database/cayenne/providers/MedicinaDAO.java index b2cc5c82..573a428e 100644 --- a/trunk/SIPRPSoft/src/siprp/database/cayenne/providers/MedicinaDAO.java +++ b/trunk/SIPRPSoft/src/siprp/database/cayenne/providers/MedicinaDAO.java @@ -15,6 +15,7 @@ import siprp.database.cayenne.objects.Empresas; import siprp.database.cayenne.objects.Prestadores; import siprp.database.cayenne.objects.PrtGruposProtocolo; import siprp.database.cayenne.objects.Trabalhadores; +import siprp.database.cayenne.objects.TrabalhadoresConsultasDatas; import siprp.database.cayenne.objects.TrabalhadoresEcd; import siprp.database.cayenne.objects.TrabalhadoresEcdsDatas; import siprp.database.cayenne.objects.TrabalhadoresProcesso; @@ -30,6 +31,17 @@ public class MedicinaDAO extends MainDAO implements MedicinaConstants { return (Trabalhadores) DataObjectUtils.objectForPK( context, Trabalhadores.class, id ); } + + public TrabalhadoresConsultasDatas getConsultaMarcacaoByID( Integer id ) + { + return (TrabalhadoresConsultasDatas) DataObjectUtils.objectForPK( context, TrabalhadoresConsultasDatas.class, id ); + } + + public TrabalhadoresEcdsDatas getExameMarcacaoByID( Integer id ) + { + return (TrabalhadoresEcdsDatas) DataObjectUtils.objectForPK( context, TrabalhadoresEcdsDatas.class, id ); + } + public List getAllEmpresas() { diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/Lembrete.java b/trunk/SIPRPSoft/src/siprp/lembretes/Lembrete.java index 67d73eff..cfba5427 100644 --- a/trunk/SIPRPSoft/src/siprp/lembretes/Lembrete.java +++ b/trunk/SIPRPSoft/src/siprp/lembretes/Lembrete.java @@ -30,6 +30,8 @@ public class Lembrete protected boolean enviarEmail; protected Integer periodicidadeDias; protected Integer periodicidadeMeses; + protected Integer consultaDataID; + protected Integer exameDataID; /** Creates a new instance of Lembrete */ public Lembrete( Integer id, @@ -44,7 +46,9 @@ public class Lembrete Integer marcacaoTrabalhadorID, boolean enviarEmail, Integer periodicidadeDias, - Integer periodicidadeMeses ) + Integer periodicidadeMeses, + Integer consultaDataID, + Integer exameDataID ) { setId( id ); setTipoID( tipoID ); @@ -59,6 +63,8 @@ public class Lembrete setEnviarEmail( enviarEmail ); setPeriodicidadeDias( periodicidadeDias ); setPeriodicidadeMeses( periodicidadeMeses ); + setConsultaDataID( consultaDataID ); + setExameDataID( exameDataID ); } public Integer getTipoID() @@ -190,5 +196,24 @@ public class Lembrete { this.id = id; } + + public void setConsultaDataID( Integer consultaDataID ) + { + this.consultaDataID = consultaDataID; + } + + public void setExameDataID( Integer exameDataID ) + { + this.exameDataID = exameDataID; + } + public Integer getConsultaDataID() + { + return consultaDataID; + } + + public Integer getExameDataID() + { + return exameDataID; + } } diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/LembretesDataProvider.java b/trunk/SIPRPSoft/src/siprp/lembretes/LembretesDataProvider.java index 9a9d9701..2ff231cb 100644 --- a/trunk/SIPRPSoft/src/siprp/lembretes/LembretesDataProvider.java +++ b/trunk/SIPRPSoft/src/siprp/lembretes/LembretesDataProvider.java @@ -86,6 +86,24 @@ public class LembretesDataProvider return tiposLembrete; } + public Integer getTipoLembreteIDByCodigo( String codigo ) + { + Integer result = null; + TipoLembrete tipo; + try + { + tipo = getTipoLembreteByCodigo( codigo ); + if( tipo != null ) + { + result = tipo.getID(); + } + } catch( Exception e ) + { + e.printStackTrace(); + } + return result; + } + public TipoLembrete getTipoLembreteByCodigo( String codigo ) throws Exception { @@ -132,6 +150,39 @@ public class LembretesDataProvider EXECUTER.executeQuery( insert ); } + public void criarLembreteConsulta( Integer tipoID, Date date, String descricao, String texto, Integer empresaID, Integer estabelecimentoID, Integer trabalhadorID, Integer consultaMarcacaoID ) + { + criarLembreteNew( tipoID, date, descricao, texto, empresaID, estabelecimentoID, trabalhadorID, consultaMarcacaoID, true); + } + + public void criarLembreteExame( Integer tipoID, Date date, String descricao, String texto, Integer empresaID, Integer estabelecimentoID, Integer trabalhadorID, Integer consultaExameID ) + { + criarLembreteNew( tipoID, date, descricao, texto, empresaID, estabelecimentoID, trabalhadorID, consultaExameID, false ); + } + + private void criarLembreteNew( Integer tipoID, Date date, String descricao, String texto, Integer empresaID, Integer estabelecimentoID, Integer trabalhadorID, Integer marcacaoID, boolean isConsulta ) + { + try + { + Insert insert = + new Insert( "lembretes", + new Assignment[]{ + new Assignment( new Field( "tipo_id" ), tipoID ), + new Assignment( new Field( "data" ), date ), + new Assignment( new Field( "descricao" ), descricao ), + new Assignment( new Field( "texto" ), texto ), + new Assignment( new Field( "empresa_id" ), empresaID ), + new Assignment( new Field( "estabelecimento_id" ), estabelecimentoID ), + new Assignment( new Field( "trabalhador_id" ), trabalhadorID ), + new Assignment( new Field( isConsulta ? "trabalhadores_consultas_datas_id" : "trabalhadores_ecds_datas_id" ), marcacaoID ) } ); + EXECUTER.executeQuery( insert ); + } + catch( Exception e ) + { + e.printStackTrace(); + } + } + public void apagarLembreteByID( Integer id ) throws Exception { @@ -179,7 +230,7 @@ public class LembretesDataProvider "texto", "empresa_id", "estabelecimento_id", "trabalhador_id", "marcacao_estabelecimento_id", "marcacao_trabalhador_id", "enviar_email", - "periodicidade_dias", "periodicidade_meses" }, + "periodicidade_dias", "periodicidade_meses" , "trabalhadores_consultas_datas_id", "trabalhadores_ecds_datas_id" }, new Field( "tipo_id" ).isEqual( tipoID ).and( new Field( "data" ).isLessOrEqual( new Date() ) ) ); Virtual2DArray array = EXECUTER.executeQuery( select ); @@ -198,10 +249,12 @@ public class LembretesDataProvider boolean enviarEmail = "y".equals( array.get( n, 10 ) ); Integer periodicidadeDias = ( Integer ) array.get( n, 11 ); Integer periodicidadeMeses = ( Integer ) array.get( n, 12 ); + Integer consultaDataID = ( Integer ) array.get( 0, 13 ); + Integer exameDataID = ( Integer ) array.get( 0, 14 ); lembretes[ n ] = new Lembrete( id, tipoID, data, descricao, texto, empresaID, estabelecimentoID, trabalhadorID, marcacaoEstabelecimentoID, marcacaoTrabalhadorID, - enviarEmail, periodicidadeDias, periodicidadeMeses ); + enviarEmail, periodicidadeDias, periodicidadeMeses, consultaDataID, exameDataID ); } return lembretes; } @@ -215,7 +268,7 @@ public class LembretesDataProvider "texto", "empresa_id", "estabelecimento_id", "trabalhador_id", "marcacao_estabelecimento_id", "marcacao_trabalhador_id", "enviar_email", - "periodicidade_dias", "periodicidade_meses" }, + "periodicidade_dias", "periodicidade_meses", "trabalhadores_consultas_datas_id", "trabalhadores_ecds_datas_id" }, new Field( "id" ).isEqual( id ) ); Virtual2DArray array = EXECUTER.executeQuery( select ); if( array.columnLength() == 0 ) @@ -236,10 +289,13 @@ public class LembretesDataProvider boolean enviarEmail = "y".equals( array.get( 0, 10 ) ); Integer periodicidadeDias = ( Integer ) array.get( 0, 11 ); Integer periodicidadeMeses = ( Integer ) array.get( 0, 12 ); + Integer consultaDataID = ( Integer ) array.get( 0, 13 ); + Integer exameDataID = ( Integer ) array.get( 0, 14 ); return new Lembrete( id, tipoID, data, descricao, texto, empresaID, estabelecimentoID, trabalhadorID, marcacaoEstabelecimentoID, marcacaoTrabalhadorID, - enviarEmail, periodicidadeDias, periodicidadeMeses ); + enviarEmail, periodicidadeDias, periodicidadeMeses, consultaDataID, exameDataID ); } } + } diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/LembretesWindow.java b/trunk/SIPRPSoft/src/siprp/lembretes/LembretesWindow.java index dfd77b34..e4f757a7 100644 --- a/trunk/SIPRPSoft/src/siprp/lembretes/LembretesWindow.java +++ b/trunk/SIPRPSoft/src/siprp/lembretes/LembretesWindow.java @@ -9,19 +9,33 @@ package siprp.lembretes; +import info.clearthought.layout.TableLayout; +import info.clearthought.layout.TableLayoutConstraints; + import java.awt.*; import java.awt.event.ActionEvent; import javax.swing.*; import com.evolute.utils.tables.*; +import com.evolute.utils.tables.special.ComboBoxData; import com.evolute.utils.tracker.TrackableWindow; import com.evolute.utils.ui.DialogException; import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.util.List; import java.util.Vector; + +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; + +import siprp.database.cayenne.objects.Empresas; +import siprp.database.cayenne.objects.Estabelecimentos; +import siprp.database.cayenne.providers.MedicinaDAO; import siprp.lembretes.remarcacoes.LembretesRemarcacaoPanel; /** @@ -34,11 +48,21 @@ public class LembretesWindow extends JFrame { public static final String TITLE = "Lembretes"; + private static final int LEFT_COLUMN_WIDTH = 302; + protected VectorTableModel tiposModel; protected BaseTable tiposTable; protected JPanel lembretesPanel; protected JButton recarregarButton; + private final JPanel leftPanel = new JPanel(); + private final JCheckBox checkEmpresas = new JCheckBox(); + private final JComboBox comboEmpresas = new JComboBox( ); + private final JCheckBox checkEstabelecimentos = new JCheckBox(); + private final JComboBox comboEstabelecimentos = new JComboBox( ); + + private final MedicinaDAO medicinaDao = new MedicinaDAO(); + protected LembretesDataProvider provider; /** Creates a new instance of LembretesWindow */ @@ -61,16 +85,54 @@ public class LembretesWindow extends JFrame JScrollPane scp = new JScrollPane( tiposTable, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - scp.setPreferredSize( new Dimension( 300, 20 ) ); + scp.setPreferredSize( new Dimension( LEFT_COLUMN_WIDTH, 100 ) ); lembretesPanel = new JPanel(); lembretesPanel.setLayout( new GridLayout( 1, 1 ) ); recarregarButton = new JButton( "Recarregar" ); recarregarButton.addActionListener( this ); - getContentPane().setLayout( new BorderLayout() ); - getContentPane().add( scp, BorderLayout.WEST ); - getContentPane().add( lembretesPanel, BorderLayout.CENTER ); - getContentPane().add( recarregarButton, BorderLayout.SOUTH ); + loadEmpresas(); + loadEstabelecimentos(); + + double[] cols = new double[]{ TableLayout.MINIMUM, TableLayout.FILL }; + double[] rows = new double[]{ TableLayout.PREFERRED, TableLayout.PREFERRED, + TableLayout.MINIMUM, TableLayout.MINIMUM, + TableLayout.MINIMUM, TableLayout.MINIMUM, + TableLayout.MINIMUM + }; + TableLayout tableLayout = new TableLayout( cols, rows ); + tableLayout.setHGap( 5 ); + tableLayout.setVGap( 5 ); + leftPanel.setPreferredSize( new Dimension( LEFT_COLUMN_WIDTH, 0 ) ); + leftPanel.setLayout( tableLayout ); + + comboEmpresas.setPreferredSize( new Dimension( LEFT_COLUMN_WIDTH - 50, 0 ) ); + comboEstabelecimentos.setPreferredSize( new Dimension( LEFT_COLUMN_WIDTH - 50, 0 ) ); + checkEstabelecimentos.setEnabled( false ); + comboEstabelecimentos.setEnabled( false ); + + leftPanel.add( scp, new TableLayoutConstraints(0,0,1,0) ); + leftPanel.add( new JSeparator(), new TableLayoutConstraints(0,1,1,1) ); + leftPanel.add( new JLabel( "Filtrar por:"), new TableLayoutConstraints(0,2,1,2) ); + leftPanel.add( checkEmpresas, new TableLayoutConstraints(0,3) ); + leftPanel.add( new JLabel( "Empresa"), new TableLayoutConstraints(1,3) ); + leftPanel.add( comboEmpresas, new TableLayoutConstraints(1,4) ); + leftPanel.add( checkEstabelecimentos, new TableLayoutConstraints(0,5) ); + leftPanel.add( new JLabel( "Estabelecimento"), new TableLayoutConstraints(1,5) ); + leftPanel.add( comboEstabelecimentos, new TableLayoutConstraints(1,6) ); + + cols = new double[]{ TableLayout.PREFERRED, TableLayout.FILL }; + rows = new double[]{ TableLayout.FILL, TableLayout.MINIMUM }; + tableLayout = new TableLayout( cols, rows ); + tableLayout.setHGap( 5 ); + tableLayout.setVGap( 5 ); +// getContentPane().setPreferredSize( new Dimension( 300, 20 ) ); + getContentPane().setLayout( tableLayout ); + + getContentPane().setLayout( tableLayout ); + getContentPane().add( leftPanel, new TableLayoutConstraints( 0, 0 ) ); + getContentPane().add( lembretesPanel, new TableLayoutConstraints( 1, 0 ) ); + getContentPane().add( recarregarButton, new TableLayoutConstraints( 0, 1, 1, 1 ) ); addWindowListener( new WindowAdapter(){ public void windowClosing( WindowEvent e ) @@ -85,6 +147,74 @@ public class LembretesWindow extends JFrame reloadTotais(); } } ); + + + + setupComboListeners(); + setupCheckBoxListeners(); + + } + + private void setupComboListeners() + { + comboEmpresas.addItemListener( new ItemListener() + { + @Override + public void itemStateChanged( ItemEvent e ) + { + if( e.getStateChange() == ItemEvent.SELECTED ) + { + loadEstabelecimentos(); + if( checkEmpresas.isEnabled() && checkEmpresas.isEnabled() ) + { + reloadLembretes(); + } + } + } + } ); + comboEstabelecimentos.addItemListener( new ItemListener() + { + @Override + public void itemStateChanged( ItemEvent e ) + { + if( e.getStateChange() == ItemEvent.SELECTED && checkEstabelecimentos.isEnabled() ) + { + reloadLembretes(); + } + } + } ); + } + + private void setupCheckBoxListeners() + { + checkEmpresas.addChangeListener( new ChangeListener() + { + @Override + public void stateChanged( ChangeEvent e ) + { + empresasChecked(); + reloadLembretes(); + } + }); + checkEstabelecimentos.addChangeListener( new ChangeListener() + { + @Override + public void stateChanged( ChangeEvent e ) + { + reloadLembretes(); + } + }); + } + + private void empresasChecked() + { + boolean filtrarEmpresas = checkEmpresas.isSelected(); + checkEstabelecimentos.setEnabled( filtrarEmpresas ); + comboEstabelecimentos.setEnabled( filtrarEmpresas ); + if( !filtrarEmpresas ) + { + checkEstabelecimentos.setSelected( false ); + } } public void refresh() @@ -137,6 +267,10 @@ public class LembretesWindow extends JFrame { ColumnizedObjectArray line = ( ColumnizedObjectArray ) tiposModel.getRowAt( selected ); Integer tipoID = line.getID(); + Empresas empresa = (Empresas) comboEmpresas.getSelectedItem(); + Estabelecimentos estabelecimento = (Estabelecimentos) comboEstabelecimentos.getSelectedItem(); + Integer empresaID = ( empresa != null && checkEmpresas.isSelected() ) ? empresa.getId() : null; + Integer estabelecimentoID = ( estabelecimento != null && checkEstabelecimentos.isSelected() ) ? estabelecimento.getId() : null; try { TipoLembrete tipo = provider.getTipoLembreteByID( tipoID ); @@ -146,7 +280,7 @@ public class LembretesWindow extends JFrame } if( CODE_REMARCACOES.equals( tipo.getCodigo() ) ) { - lembretesPanel.add( new LembretesRemarcacaoPanel() ); + lembretesPanel.add( new LembretesRemarcacaoPanel( empresaID, estabelecimentoID ) ); } if( CODE_MARCACOES.equals( tipo.getCodigo() ) ) { @@ -164,6 +298,34 @@ public class LembretesWindow extends JFrame validate(); repaint(); } + + private void loadEmpresas() + { + comboEmpresas.removeAllItems(); + List allEmpresas = medicinaDao.getAllEmpresas(); + for( Empresas empresa : allEmpresas ) + { + comboEmpresas.addItem( empresa ); + } + + } + + private void loadEstabelecimentos() + { + comboEstabelecimentos.removeAllItems(); + Object selectedEmpresa = comboEmpresas.getSelectedItem(); + if( selectedEmpresa != null ) + { + if( selectedEmpresa instanceof Empresas ) + { + List allEstabelecimentos = ((Empresas) selectedEmpresa).getEstabelecimentosArray(); + for( Estabelecimentos estabelecimento : allEstabelecimentos ) + { + comboEstabelecimentos.addItem( estabelecimento ); + } + } + } + } public boolean closeIfPossible() { @@ -177,6 +339,8 @@ public class LembretesWindow extends JFrame if( source.equals( recarregarButton ) ) { reloadTotais(); + loadEmpresas(); + loadEstabelecimentos(); } } diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/LembretesRemarcacaoPanel.java b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/LembretesRemarcacaoPanel.java index 5638688a..4dfcfe90 100644 --- a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/LembretesRemarcacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/LembretesRemarcacaoPanel.java @@ -36,12 +36,17 @@ public class LembretesRemarcacaoPanel extends JPanel protected RemarcacoesDataProvider provider; + private final Integer empresaID; + private final Integer estabelecimentoID; + private JDOProvider JDO; /** Creates a new instance of LembretesRemarcacaoPanel */ - public LembretesRemarcacaoPanel() + public LembretesRemarcacaoPanel( Integer empresaID, Integer estabelecimentoID ) throws Exception { + this.empresaID = empresaID; + this.estabelecimentoID = estabelecimentoID; provider = RemarcacoesDataProvider.getProvider(); setupComponents(); } @@ -77,7 +82,7 @@ public class LembretesRemarcacaoPanel extends JPanel estabelecimentosPanel.add( new JLabel( "Higiene e Seguran\u00e7a", JLabel.CENTER ), BorderLayout.NORTH ); estabelecimentosPanel.add( listEstabelecimentosScroll, BorderLayout.CENTER ); - listTrabalhadoresPanel.showList( provider.getLembretesRemarcacaoTrabalhador() ); + listTrabalhadoresPanel.showList( provider.getLembretesRemarcacaoTrabalhador( empresaID, estabelecimentoID ) ); // listEstabelecimentosPanel.showList( estabelecimentos.toArray( new IDObject[ estabelecimentos.size() ] ) ); } diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/RemarcacoesDataProvider.java b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/RemarcacoesDataProvider.java index 209cccf1..627bb41d 100644 --- a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/RemarcacoesDataProvider.java +++ b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/RemarcacoesDataProvider.java @@ -23,8 +23,10 @@ import java.text.DateFormat; import java.util.Date; import java.util.Locale; import siprp.data.Marcacao; +import siprp.database.cayenne.providers.MedicinaDAO; import siprp.lembretes.LembretesConstants; import siprp.lembretes.LembretesDataProvider; +import siprp.medicina.processo.database.MedicinaProcessoDAO; /** * @@ -62,30 +64,56 @@ public class RemarcacoesDataProvider return instance; } - public IDObject[] getLembretesRemarcacaoTrabalhador() + private Expression whereExpressionLembretesRemarcacao( Integer empresaID, Integer estabelecimentoID ) throws Exception + { + Expression result = new Field( "lembretes.tipo_id" ).isEqual( + lembretesProvider.getTipoLembreteByCodigo( LembretesConstants.CODE_REMARCACOES ).getID() ).and( + new Field( "lembretes.data" ).isLessOrEqual( new Field( "current_date" ) ) ); + if( empresaID != null ) + { + result = result.and( new Field("empresas.id").isEqual( empresaID ) ); + if( estabelecimentoID != null ) + { + result = result.and( new Field("estabelecimentos.id").isEqual( estabelecimentoID ) ); + } + } + return result; + } + + public IDObject[] getLembretesRemarcacaoTrabalhador( Integer empresaID, Integer estabelecimentoID ) throws Exception { Select select = new Select2( new String[]{ "lembretes", "marcacoes_trabalhador", "trabalhadores", - "estabelecimentos", "empresas" }, - new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER }, + "estabelecimentos", "empresas", "trabalhadores_consultas_datas", "trabalhadores_ecds_datas"}, + new Integer [] { + Select2.JOIN_LEFT_OUTER, Select2.JOIN_LEFT_OUTER, + Select2.JOIN_LEFT_OUTER, Select2.JOIN_LEFT_OUTER, + Select2.JOIN_LEFT_OUTER, Select2.JOIN_LEFT_OUTER + }, new Expression[]{ - new Field( "lembretes.marcacao_trabalhador_id" ).isEqual( new Field( "marcacoes_trabalhador.id" ) ), - new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ), + new Field( "lembretes.marcacao_trabalhador_id" ).isEqual( new Field( "marcacoes_trabalhador.id" ) ),/*.or( + new Field( "lembretes.trabalhadores_consultas_datas_id" ).isEqual( new Field( "trabalhadores_consultas_datas.id" ) ) + ).or( + new Field( "lembretes.trabalhadores_ecds_datas_id" ).isEqual( new Field( "trabalhadores_ecds_datas.id" ) ) + ), + */ + new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).or( new Field( "lembretes.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ), new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ), new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ), + new Field( "lembretes.trabalhadores_consultas_datas_id" ).isEqual( new Field( "trabalhadores_consultas_datas.id" ) ), + new Field( "lembretes.trabalhadores_ecds_datas_id" ).isEqual( new Field( "trabalhadores_ecds_datas.id" ) ) }, new String[]{ "lembretes.id", "lembretes.descricao", "marcacoes_trabalhador.tipo", "marcacoes_trabalhador.data", "trabalhadores.nome", "estabelecimentos.nome", "empresas.designacao_social", - "trabalhadores.nome_plain" }, - new Field( "lembretes.tipo_id" ).isEqual( - lembretesProvider.getTipoLembreteByCodigo( LembretesConstants.CODE_REMARCACOES ).getID() ).and( - new Field( "lembretes.data" ).isLessOrEqual( new Field( "current_date" ) ) ), + "trabalhadores.nome_plain", "trabalhadores_consultas_datas.data", "trabalhadores_ecds_datas.data" }, + whereExpressionLembretesRemarcacao( empresaID, estabelecimentoID ), new String[]{ "trabalhadores.nome_plain" }, null, null, - null ); + null + ); Virtual2DArray array = EXECUTER.executeQuery( select ); IDObject lembretes[] = new IDObject[ array.columnLength() ]; for( int n = 0; n < lembretes.length; n++ ) @@ -93,6 +121,22 @@ public class RemarcacoesDataProvider Integer id = ( Integer ) array.get( n, 0 ); String descricao = ( String ) array.get( n, 1 ); Integer tipoMarcacao = ( Integer ) array.get( n, 2 ); + Date trabalhadorConsultaDataData = ( Date ) array.get( n, 8 ); + Date trabalhadorExameDataData = ( Date ) array.get( n, 9 ); + Date data = ( Date ) array.get( n, 3 ); + if( tipoMarcacao == null ) + { + if( trabalhadorConsultaDataData != null ) + { + tipoMarcacao = Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA; + data = trabalhadorConsultaDataData; + } + else if( trabalhadorExameDataData != null ) + { + tipoMarcacao = Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES; + data = trabalhadorExameDataData; + } + } String tipoMarcacaoStr = ""; switch( tipoMarcacao.intValue() ) { @@ -104,7 +148,6 @@ public class RemarcacoesDataProvider tipoMarcacaoStr = "Consulta"; break; } - Date data = ( Date ) array.get( n, 3 ); String trabalhador = ( String ) array.get( n, 4 ); String split[] = trabalhador.split( " " ); trabalhador = split[ 0 ] + " " + ( split.length > 2 ? split[ 1 ].charAt( 0 ) + ". " : " " ) + diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoTrabalhadorAction.java b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoTrabalhadorAction.java index 5de7330c..43246656 100644 --- a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoTrabalhadorAction.java +++ b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoTrabalhadorAction.java @@ -22,8 +22,20 @@ import siprp.data.EmpresaData; import siprp.data.EstabelecimentoData; import siprp.data.MarcacaoTrabalhadorData; import siprp.data.TrabalhadorData; +import siprp.database.cayenne.objects.Empresas; +import siprp.database.cayenne.objects.Estabelecimentos; +import siprp.database.cayenne.objects.Trabalhadores; +import siprp.database.cayenne.objects.TrabalhadoresConsultas; +import siprp.database.cayenne.objects.TrabalhadoresConsultasDatas; +import siprp.database.cayenne.objects.TrabalhadoresEcds; +import siprp.database.cayenne.objects.TrabalhadoresEcdsDatas; +import siprp.database.cayenne.objects.TrabalhadoresProcesso; +import siprp.database.cayenne.providers.MedicinaDAO; import siprp.lembretes.Lembrete; import siprp.lembretes.LembretesDataProvider; +import siprp.medicina.processo.data.TrabalhadoresConsultasData; +import siprp.medicina.processo.logic.MedicinaProcessoLogic; +import siprp.medicina.processo.ui.MedicinaProcessoWindow; /** * @@ -37,6 +49,8 @@ public class TratarMarcacaoTrabalhadorAction extends AbstractAction private Integer lembreteID; + private MedicinaDAO medicinaDAO = new MedicinaDAO(); + /** * Creates a new instance of TratarMarcacaoTrabalhadorAction */ @@ -67,17 +81,62 @@ public class TratarMarcacaoTrabalhadorAction extends AbstractAction JOptionPane.WARNING_MESSAGE ); return; } - MarcacaoTrabalhadorData marcacao = ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, lembrete.getMarcacaoTrabalhadorID() ); - TrabalhadorData trabalhador = ( TrabalhadorData ) marcacao.get( MarcacaoTrabalhadorData.TRABALHADOR ); - EstabelecimentoData estabelecimento = ( EstabelecimentoData ) trabalhador.get( TrabalhadorData.ESTABELECIMENTO ); - EmpresaData empresa = ( EmpresaData ) estabelecimento.get( EstabelecimentoData.EMPRESA ); - - lembretesProvider.apagarLembreteByID( lembreteID ); - setEnabled( false ); - tracker.getMedicinaWindow().setVisible( true ); - tracker.getMedicinaWindow().setEmpresaAndEstabelecimentoAndTrabalhador( (Integer) empresa.get( EmpresaData.ID ), - ( Integer ) estabelecimento.get( EstabelecimentoData.ID ), - ( Integer ) trabalhador.get( TrabalhadorData.ID ) ); + if( lembrete.getMarcacaoTrabalhadorID() != null ) + { + // old model + MarcacaoTrabalhadorData marcacao = ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, lembrete.getMarcacaoTrabalhadorID() ); + TrabalhadorData trabalhador = ( TrabalhadorData ) marcacao.get( MarcacaoTrabalhadorData.TRABALHADOR ); + EstabelecimentoData estabelecimento = ( EstabelecimentoData ) trabalhador.get( TrabalhadorData.ESTABELECIMENTO ); + EmpresaData empresa = ( EmpresaData ) estabelecimento.get( EstabelecimentoData.EMPRESA ); + + lembretesProvider.apagarLembreteByID( lembreteID ); + setEnabled( false ); + tracker.getMedicinaWindow().setVisible( true ); + tracker.getMedicinaWindow().setEmpresaAndEstabelecimentoAndTrabalhador( (Integer) empresa.get( EmpresaData.ID ), + ( Integer ) estabelecimento.get( EstabelecimentoData.ID ), + ( Integer ) trabalhador.get( TrabalhadorData.ID ) ); + } + else + { + // new model + Integer consultaID = lembrete.getConsultaDataID(); + Integer exameID = lembrete.getExameDataID(); + TrabalhadoresConsultasDatas consultaMarcacao = null; + TrabalhadoresConsultas consulta = null; + TrabalhadoresEcdsDatas exameMarcacao = null; + TrabalhadoresEcds exame = null; + TrabalhadoresProcesso processo = null; + Trabalhadores trabalhador = null; + Estabelecimentos estabelecimento = null; + Empresas empresa = null; + if( consultaID != null ) + { + consultaMarcacao = medicinaDAO.getConsultaMarcacaoByID( consultaID ); + consulta = consultaMarcacao.getToTrabalhadoresConsultas(); + processo = consulta.getToTrabalhadoresProcesso(); + } + else if( exameID != null ) + { + exameMarcacao = medicinaDAO.getExameMarcacaoByID( exameID ); + exame = exameMarcacao.getToTrabalhadoresEcds(); + processo = exame.getToTrabalhadoresProcesso(); + } + trabalhador = processo.getToTrabalhadores(); + estabelecimento = trabalhador.getToEstabelecimentos(); + empresa = estabelecimento.getToEmpresas(); + MedicinaProcessoWindow window = tracker.getMedicinaProcessoWindow(); + + window.runActionLater( MedicinaProcessoLogic.SELECT_EMPRESA, empresa ); + window.runActionLater( MedicinaProcessoLogic.SELECT_ESTABELECIMENTO, estabelecimento ); + window.runActionLater( MedicinaProcessoLogic.LOAD_TRABALHADOR, trabalhador ); + window.runActionLater( MedicinaProcessoLogic.SELECT_TRABALHADOR, trabalhador ); + window.runActionLater( MedicinaProcessoLogic.SELECT_PROCESSO, processo ); + window.runActionLater( consulta == null ? MedicinaProcessoLogic.SELECT_EXAME : MedicinaProcessoLogic.SELECT_CONSULTA, consulta == null ? exame : consulta ); + window.runActionLater( consulta == null ? MedicinaProcessoLogic.CREATE_EXAME_MARCACAO : MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO, null ); + window.runPendingActions(); + window.setVisible( true ); + lembretesProvider.apagarLembreteByID( lembreteID ); + } } catch( Exception ex ) { diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MedicinaConstants.java b/trunk/SIPRPSoft/src/siprp/medicina/MedicinaConstants.java index f999bfe7..fae9bbb4 100644 --- a/trunk/SIPRPSoft/src/siprp/medicina/MedicinaConstants.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/MedicinaConstants.java @@ -74,4 +74,8 @@ public interface MedicinaConstants public static final String ESTADOS_STR[][] = new String[][]{ ESTADOS_EXAME_STR, ESTADOS_CONSULTA_STR }; + + public static final String LEMBRETE_DESMARCOU_SIPRP_STRING = "SIPRP Desmarcou"; + public static final String LEMBRETE_DESMARCOU_TRABALHADOR_STRING = "Trabalhador Desmarcou"; + public static final String LEMBRETE_FALTOU_TRABALHADOR_STRING = "Trabalhador Faltou"; } diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/logic/MedicinaProcessoLogic.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/logic/MedicinaProcessoLogic.java index 449bc331..619747bf 100755 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/logic/MedicinaProcessoLogic.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/processo/logic/MedicinaProcessoLogic.java @@ -1,6 +1,5 @@ package siprp.medicina.processo.logic; -import java.awt.Dialog.ModalExclusionType; import java.util.Date; import java.util.List; @@ -24,8 +23,9 @@ import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasObservacoes; import siprp.database.cayenne.objects.TrabalhadoresFichasAptidao; import siprp.database.cayenne.objects.TrabalhadoresProcesso; import siprp.database.cayenne.providers.MedicinaDAO; -import siprp.ficha.FichaAptidaoCreator; import siprp.ficha.FichaWindow; +import siprp.lembretes.LembretesConstants; +import siprp.lembretes.LembretesDataProvider; import siprp.medicina.MedicinaConstants; import siprp.medicina.processo.ProcessoConstants; import siprp.medicina.processo.estrutura.FichaAptidaoMutableTreeNode; @@ -179,6 +179,8 @@ public class MedicinaProcessoLogic extends LeafLogic @Action(isSave = true) public static final String ANULAR_EXAME_MARCACAO = "ANULAR_EXAME_MARCACAO"; + private LembretesDataProvider lembretesDataProvider = null; + private MedicinaDAO provider = null; public Empresas currentEmpresa = null; @@ -227,6 +229,7 @@ public class MedicinaProcessoLogic extends LeafLogic try { provider = new MedicinaDAO(); + lembretesDataProvider = new LembretesDataProvider(); } catch( Exception e ) { e.printStackTrace( System.out ); @@ -294,12 +297,32 @@ public class MedicinaProcessoLogic extends LeafLogic } } + private void novoLembreteRemarcacao( String mensagem, boolean isConsulta) + { + Integer tipoID = lembretesDataProvider.getTipoLembreteIDByCodigo( LembretesConstants.CODE_REMARCACOES ); + try + { + if( isConsulta ) + { + lembretesDataProvider.criarLembreteConsulta( tipoID, new Date(), mensagem, null, currentEmpresa.getId(), currentEstabelecimento.getId(), currentTrabalhador.getId(), currentConsultaMarcacao.getId() ); + } + else + { + lembretesDataProvider.criarLembreteExame( tipoID, new Date(), mensagem, null, currentEmpresa.getId(), currentEstabelecimento.getId(), currentTrabalhador.getId(), currentExameMarcacao.getId() ); + } + } catch( Exception e ) + { + e.printStackTrace(); + } + } + @LeafLogicActionBinding(actions = DESMARCAR_SIPRP_CONSULTA_MARCACAO) public void desmarcarConsultaSiprp() { if( currentConsultaMarcacao != null ) { currentConsultaMarcacao.setEstado( MedicinaConstants.ESTADO_DESMARCADO_EMPRESA ); + novoLembreteRemarcacao( MedicinaConstants.LEMBRETE_DESMARCOU_SIPRP_STRING, true ); runActionLater( SAVE_CONSULTA_MARCACAO ); } } @@ -310,6 +333,7 @@ public class MedicinaProcessoLogic extends LeafLogic if( currentConsultaMarcacao != null ) { currentConsultaMarcacao.setEstado( MedicinaConstants.ESTADO_DESMARCADO_TRABALHADOR ); + novoLembreteRemarcacao( MedicinaConstants.LEMBRETE_DESMARCOU_TRABALHADOR_STRING, true ); runActionLater( SAVE_CONSULTA_MARCACAO ); } } @@ -320,6 +344,7 @@ public class MedicinaProcessoLogic extends LeafLogic if( currentConsultaMarcacao != null ) { currentConsultaMarcacao.setEstado( MedicinaConstants.ESTADO_FALTOU ); + novoLembreteRemarcacao( MedicinaConstants.LEMBRETE_FALTOU_TRABALHADOR_STRING, true ); runActionLater( SAVE_CONSULTA_MARCACAO ); } } @@ -340,6 +365,7 @@ public class MedicinaProcessoLogic extends LeafLogic if( currentExameMarcacao != null ) { currentExameMarcacao.desmarcarSIPRP(); + novoLembreteRemarcacao( MedicinaConstants.LEMBRETE_DESMARCOU_SIPRP_STRING, false ); runActionLater( SAVE_EXAME_MARCACAO ); } } @@ -350,6 +376,7 @@ public class MedicinaProcessoLogic extends LeafLogic if( currentExameMarcacao != null ) { currentExameMarcacao.desmarcarTrabalhador(); + novoLembreteRemarcacao( MedicinaConstants.LEMBRETE_DESMARCOU_TRABALHADOR_STRING, false ); runActionLater( SAVE_EXAME_MARCACAO ); } } @@ -360,6 +387,7 @@ public class MedicinaProcessoLogic extends LeafLogic if( currentExameMarcacao != null ) { currentExameMarcacao.faltou(); + novoLembreteRemarcacao( MedicinaConstants.LEMBRETE_FALTOU_TRABALHADOR_STRING, false ); runActionLater( SAVE_EXAME_MARCACAO ); } } @@ -392,6 +420,83 @@ public class MedicinaProcessoLogic extends LeafLogic runActionLater( SAVE_EXAME_MARCACAO ); } } + + @LeafLogicActionBinding(actions=SELECT_TRABALHADOR) + public Trabalhadores selectTrabalhador( Trabalhadores trabalhador ) + { + this.currentTrabalhador = trabalhador; + return this.currentTrabalhador; + } + + @LeafLogicActionBinding(actions=SELECT_PROCESSO) + public TrabalhadoresProcesso selectProcesso( TrabalhadoresProcesso processo ) + { + this.currentProcesso = processo; + return this.currentProcesso; + } + + @LeafLogicActionBinding(actions=SELECT_CONSULTA) + public TrabalhadoresConsultas selectConsulta( TrabalhadoresConsultas consulta ) + { + this.currentConsulta = consulta; + return this.currentConsulta; + } + + @LeafLogicActionBinding(actions=SELECT_CONSULTA_MARCACAO) + public TrabalhadoresConsultasDatas selectConsultaMarcacao( TrabalhadoresConsultasDatas consultaMarcacao ) + { + this.currentConsultaMarcacao = consultaMarcacao; + return this.currentConsultaMarcacao; + } + + @LeafLogicActionBinding(actions=SELECT_CONSULTA_MARCACAO_EMAIL) + public TrabalhadoresConsultasDatasEmails selectConsultaMarcacaoEmail( TrabalhadoresConsultasDatasEmails consultaMarcacaoEmail ) + { + this.currentConsultaMarcacaoEmail = consultaMarcacaoEmail; + return this.currentConsultaMarcacaoEmail; + } + + @LeafLogicActionBinding(actions=SELECT_CONSULTA_MARCACAO_OBSERVACAO) + public TrabalhadoresConsultasDatasObservacoes selectConsultaMarcacaoObservacoes( TrabalhadoresConsultasDatasObservacoes consultaMarcacaoObservacoes ) + { + this.currentConsultaMarcacaoObservacao = consultaMarcacaoObservacoes; + return this.currentConsultaMarcacaoObservacao; + } + + @LeafLogicActionBinding(actions=SELECT_EXAME) + public TrabalhadoresEcds selectExame( TrabalhadoresEcds exame ) + { + this.currentExame = exame; + return this.currentExame; + } + + @LeafLogicActionBinding(actions=SELECT_EXAME_MARCACAO) + public TrabalhadoresEcdsDatas selectExameMarcacao( TrabalhadoresEcdsDatas exameMarcacao ) + { + this.currentExameMarcacao = exameMarcacao; + return this.currentExameMarcacao; + } + + @LeafLogicActionBinding(actions=SELECT_EXAME_MARCACAO_EMAIL) + public TrabalhadoresEcdsDatasEmails selectExameMarcacaoEmail( TrabalhadoresEcdsDatasEmails exameMarcacaoEmail ) + { + this.currentExameMarcacaoEmail = exameMarcacaoEmail; + return this.currentExameMarcacaoEmail; + } + + @LeafLogicActionBinding(actions=SELECT_EXAME_MARCACAO_OBSERVACAO) + public TrabalhadoresEcdsDatasObservacoes selectExameMarcacaoObservacoes( TrabalhadoresEcdsDatasObservacoes exameMarcacaoObservacoes ) + { + this.currentExameMarcacaoObservacao = exameMarcacaoObservacoes; + return this.currentExameMarcacaoObservacao; + } + + @LeafLogicActionBinding(actions=SELECT_FICHA) + public TrabalhadoresFichasAptidao selectFichaAptidao( TrabalhadoresFichasAptidao ficha ) + { + this.currentFicha= ficha; + return this.currentFicha; + } @LeafLogicActionBinding(actions = { SELECT_TREE_NODE @@ -405,57 +510,46 @@ public class MedicinaProcessoLogic extends LeafLogic else if( node.getUserObject() instanceof Trabalhadores ) { action = SELECT_TRABALHADOR; - currentTrabalhador = (Trabalhadores) node.getUserObject(); } else if( node.getUserObject() instanceof TrabalhadoresProcesso ) { action = SELECT_PROCESSO; - currentProcesso = (TrabalhadoresProcesso) node.getUserObject(); } else if( node.getUserObject() instanceof TrabalhadoresConsultas ) { action = SELECT_CONSULTA; - currentConsulta = (TrabalhadoresConsultas) node.getUserObject(); } else if( node.getUserObject() instanceof TrabalhadoresConsultasDatas ) { action = SELECT_CONSULTA_MARCACAO; - currentConsultaMarcacao = (TrabalhadoresConsultasDatas) node.getUserObject(); } else if( node.getUserObject() instanceof TrabalhadoresConsultasDatasObservacoes ) { action = SELECT_CONSULTA_MARCACAO_OBSERVACAO; - currentConsultaMarcacaoObservacao = (TrabalhadoresConsultasDatasObservacoes) node.getUserObject(); } else if( node.getUserObject() instanceof TrabalhadoresConsultasDatasEmails ) { action = SELECT_CONSULTA_MARCACAO_EMAIL; - currentConsultaMarcacaoEmail = (TrabalhadoresConsultasDatasEmails) node.getUserObject(); } else if( node.getUserObject() instanceof TrabalhadoresEcds ) { action = SELECT_EXAME; - currentExame = (TrabalhadoresEcds) node.getUserObject(); } else if( node.getUserObject() instanceof TrabalhadoresEcdsDatas ) { action = SELECT_EXAME_MARCACAO; - currentExameMarcacao = (TrabalhadoresEcdsDatas) node.getUserObject(); } else if( node.getUserObject() instanceof TrabalhadoresEcdsDatasEmails ) { action = SELECT_EXAME_MARCACAO_EMAIL; - currentExameMarcacaoEmail = (TrabalhadoresEcdsDatasEmails) node.getUserObject(); } else if( node.getUserObject() instanceof TrabalhadoresEcdsDatasObservacoes ) { action = SELECT_EXAME_MARCACAO_OBSERVACAO; - currentExameMarcacaoObservacao = (TrabalhadoresEcdsDatasObservacoes) node.getUserObject(); } else if( node instanceof FichaAptidaoMutableTreeNode ) { action = SELECT_FICHA; - currentFicha = (TrabalhadoresFichasAptidao) node.getUserObject(); } runAction( action, node.getUserObject() ); return node; diff --git a/trunk/SIPRPSoft/src/siprp/update/UpdateList.java b/trunk/SIPRPSoft/src/siprp/update/UpdateList.java index 1f41206c..c8b34513 100644 --- a/trunk/SIPRPSoft/src/siprp/update/UpdateList.java +++ b/trunk/SIPRPSoft/src/siprp/update/UpdateList.java @@ -31,7 +31,8 @@ public class UpdateList new siprp.update.updates.V7_9_To_V8_0(), new siprp.update.updates.V8_0_To_V8_1(), new siprp.update.updates.V8_1_To_V8_2(), new siprp.update.updates.V8_2_To_V8_3(), new siprp.update.updates.V8_3_To_V8_4(), new siprp.update.updates.V8_4_To_V8_5(), - new siprp.update.updates.V8_5_To_V8_6(), new siprp.update.updates.V8_6_To_V8_7() }; + new siprp.update.updates.V8_5_To_V8_6(), new siprp.update.updates.V8_6_To_V8_7(), + new siprp.update.updates.V8_7_To_V8_8() }; protected static Executer EXECUTER; protected static double version = -1; diff --git a/trunk/SIPRPSoft/src/siprp/update/updates/V8_7_To_V8_8.java b/trunk/SIPRPSoft/src/siprp/update/updates/V8_7_To_V8_8.java new file mode 100644 index 00000000..5d2daab5 --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/update/updates/V8_7_To_V8_8.java @@ -0,0 +1,65 @@ +/* + * V8_1_To_V8_2.java + * + * Created on December 19, 2007, 3:12 PM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package siprp.update.updates; + +import com.evolute.utils.Singleton; +import com.evolute.utils.db.DBManager; +import com.evolute.utils.db.Executer; + +/** + * + * @author fpalma + */ +public class V8_7_To_V8_8 + implements siprp.update.Update +{ + + /** + * Creates a new instance of V8_6_To_V8_7 + */ + public V8_7_To_V8_8() + { + } + + public String []listChanges() + { + return new String[]{ "Adicionada coluna em 'lembretes' que referencia nova tabela das marcacoes (trabalhadores_consultas_datas)" }; + } + + public double getStartVersion() + { + return 8.7; + } + + public double getEndVersion() + { + return 8.8; + } + + public void doUpdate() + throws Exception + { + DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); + Executer executer = dbm.getSharedExecuter(); + com.evolute.utils.sql.Update update = + new com.evolute.utils.sql.Update( + "ALTER TABLE lembretes ADD COLUMN trabalhadores_consultas_datas_id int4 REFERENCES trabalhadores_consultas_datas(id);" ); + executer.executeQuery( update ); + update = + new com.evolute.utils.sql.Update( + "ALTER TABLE lembretes ADD COLUMN trabalhadores_ecds_datas_id int4 REFERENCES trabalhadores_ecds_datas(id);" ); + executer.executeQuery( update ); + } + + public String toString() + { + return "v" + getStartVersion() + " para v" + getEndVersion(); + } +}