From e6d63271bcc9677b6b1c4e24429008d641793dc8 Mon Sep 17 00:00:00 2001 From: Frederico Palma Date: Wed, 26 Dec 2007 18:48:49 +0000 Subject: [PATCH] git-svn-id: https://svn.coded.pt/svn/SIPRP@626 bb69d46d-e84e-40c8-a05a-06db0d633741 --- trunk/SIPRPSoft/src/siprp/Main.java | 15 +- trunk/SIPRPSoft/src/siprp/SIPRPTracker.java | 11 + .../locais_analise/EnviarAnalisesWindow.java | 205 ++++++++++++++++++ .../LocaisRealizacaoConstants.java | 4 +- .../LocaisRealizacaoDataProvider.java | 36 ++- .../LocaisRealizacaoWindow.java | 22 +- .../src/siprp/update/UpdateList.java | 3 +- .../siprp/update/updates/V8_1_To_V8_2.java | 75 +++++++ 8 files changed, 349 insertions(+), 22 deletions(-) create mode 100644 trunk/SIPRPSoft/src/siprp/medicina/locais_analise/EnviarAnalisesWindow.java create mode 100644 trunk/SIPRPSoft/src/siprp/update/updates/V8_1_To_V8_2.java diff --git a/trunk/SIPRPSoft/src/siprp/Main.java b/trunk/SIPRPSoft/src/siprp/Main.java index 78ef3345..0d75c856 100644 --- a/trunk/SIPRPSoft/src/siprp/Main.java +++ b/trunk/SIPRPSoft/src/siprp/Main.java @@ -14,12 +14,10 @@ import java.util.Date; import java.util.Properties; import javax.swing.JPanel; +import javax.swing.SwingUtilities; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.MutableTreeNode; -import org.apache.cayenne.conf.Configuration; -import org.apache.cayenne.conf.DefaultConfiguration; - import siprp.clientes.AvisosPanel; import siprp.companydataloaders.SIPRPDataLoader; import siprp.data.ActualizacaoSaveHandler; @@ -58,6 +56,7 @@ public class Main implements com.evolute.utils.ui.window.Connector private static String dbase; private SIPRPTracker siprpTracker; + private static LoginWindow loginWindow; private static AvisosPanel avisos = null; @@ -131,7 +130,7 @@ public class Main implements com.evolute.utils.ui.window.Connector // window.show(); avisos = new AvisosPanel(); String logoFileName = ( String ) Singleton.getInstance( SingletonConstants.COMPANY_LOGO ); - LoginWindow loginWindow = new LoginWindow( new Main(), /*"logo"+File.separator +*/ logoFileName,//"logo"+File.separator + "logo_w400.jpg", + loginWindow = new LoginWindow( new Main(), /*"logo"+File.separator +*/ logoFileName,//"logo"+File.separator + "logo_w400.jpg", new String[] { (String) Singleton.getInstance( SingletonConstants.SOFTWARE_NAME ) }, new String[] { "Vers\u00E3o " + SHST_VERSION, "(EVOLUTE 2004-2006)" }, "", (String)Singleton.getInstance( SingletonConstants.LOCAL_USER ), @@ -142,7 +141,13 @@ public class Main implements com.evolute.utils.ui.window.Connector GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); loginWindow.setExtendedState(loginWindow.getExtendedState() | loginWindow.MAXIMIZED_BOTH); loginWindow.setVisible( true ); - loginWindow.expandAll(); + SwingUtilities.invokeLater( new Runnable(){ + public void run() + { + loginWindow.expandAll(); + } + } ); + new UpdateWindow().update(); } diff --git a/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java b/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java index 388a9b42..77cd4c5a 100644 --- a/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java +++ b/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java @@ -19,6 +19,7 @@ import siprp.higiene.marcacoes.MarcacoesHigieneWindow; import siprp.impressaofichas.ImpressaoFichasWindow; import siprp.lembretes.LembretesWindow; import siprp.medicina.MedicinaWindow; +import siprp.medicina.locais_analise.EnviarAnalisesWindow; import siprp.medicina.locais_realizacao.LocaisRealizacaoWindow; import siprp.medicina.presencas.RegistarPresencasWindow; import siprp.medicina.prestadores.PrestadoresWindow; @@ -41,6 +42,7 @@ public class SIPRPTracker extends WindowTracker public static final String MEDICINA = "Medicina"; public static final String MEDICINA_MARCACOES = "Marca\u00e7\u00f5es"; public static final String MEDICINA_LOCAIS = "Locais de Realiza\u00e7\u00e3o"; + public static final String MEDICINA_ENVIO_ANALISES= "Enviar Colheitas para An\u00e1lise"; public static final String MEDICINA_PRESENCAS = "Presen\u00e7as"; public static final String HIGIENE_SEGURANCA = "Higiene e Seguran\u00e7a"; public static final String RELATORIO_ANUAL = "Relat\u00f3rio Anual"; @@ -174,6 +176,15 @@ public class SIPRPTracker extends WindowTracker return new LocaisRealizacaoWindow(); } } ); + + medicinaNode.add( new DefaultMutableTreeNode( MEDICINA_ENVIO_ANALISES ) ); + creators.put( MEDICINA_ENVIO_ANALISES, new WindowCreator() { + public TrackableWindow create() + throws Exception + { + return new EnviarAnalisesWindow(); + } + } ); medicinaNode.add( new DefaultMutableTreeNode( MEDICINA_PRESENCAS ) ); creators.put( MEDICINA_PRESENCAS, new WindowCreator() { diff --git a/trunk/SIPRPSoft/src/siprp/medicina/locais_analise/EnviarAnalisesWindow.java b/trunk/SIPRPSoft/src/siprp/medicina/locais_analise/EnviarAnalisesWindow.java new file mode 100644 index 00000000..f35e5ef8 --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/medicina/locais_analise/EnviarAnalisesWindow.java @@ -0,0 +1,205 @@ +package siprp.medicina.locais_analise; + +import info.clearthought.layout.TableLayout; +import info.clearthought.layout.TableLayoutConstraints; + +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.text.DateFormat; +import java.util.Date; +import java.util.Locale; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.WindowConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +import com.evolute.utils.data.IDObject; +import com.evolute.utils.dataui.ControllableComponent; +import com.evolute.utils.tracker.TrackableWindow; +import com.evolute.utils.ui.DialogException; +import com.evolute.utils.ui.calendar.JCalendarPanel; +import com.evolute.utils.ui.panel.CheckBoxPanel; + +public class EnviarAnalisesWindow extends JFrame + implements TrackableWindow, ActionListener, ChangeListener, ControllableComponent +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + protected JCalendarPanel dataPanel; + protected JComboBox prestadorCombo; + protected JPanel ecdsOuterPanel; + protected CheckBoxPanel ecdsPanel; + protected JButton enviarButton; + + protected final EnviarAnalisesWindowLogic logic; + + public EnviarAnalisesWindow() + throws Exception + { + logic = new EnviarAnalisesWindowLogic( this ); + setupComponents(); + } + + private void setupComponents() + { + setTitle( "Enviar Colheitas para An\u00e1lise" ); + setSize( 500, 400 ); + + JLabel dataLabel = new JLabel( "Data" ); + dataPanel = new JCalendarPanel( this ); + dataPanel.addChangeListener( this ); + JLabel prestadorLabel = new JLabel( "Prestador" ); + prestadorCombo = new JComboBox(); + ecdsOuterPanel = new JPanel(); + ecdsOuterPanel.setLayout( new GridLayout( 1, 1 ) ); + enviarButton = new JButton( "Enviar" ); + enviarButton.addActionListener( this ); + + TableLayout layout = + new TableLayout( + new double[]{ TableLayoutConstraints.MINIMUM, TableLayoutConstraints.PREFERRED, + TableLayoutConstraints.MINIMUM, TableLayoutConstraints.PREFERRED }, + new double[]{ TableLayoutConstraints.MINIMUM, TableLayoutConstraints.FILL, + TableLayoutConstraints.MINIMUM } ); + layout.setHGap( 2 ); + layout.setVGap( 2 ); + getContentPane().setLayout( layout ); + + getContentPane().add( dataLabel, new TableLayoutConstraints( 0, 0 ) ); + getContentPane().add( dataPanel, new TableLayoutConstraints( 1, 0 ) ); + getContentPane().add( prestadorLabel, new TableLayoutConstraints( 2, 0 ) ); + getContentPane().add( prestadorCombo, new TableLayoutConstraints( 3, 0 ) ); + getContentPane().add( ecdsOuterPanel, new TableLayoutConstraints( 0, 1, 3, 1 ) ); + getContentPane().add( enviarButton, new TableLayoutConstraints( 1, 2, 2, 2 ) ); + + + setDefaultCloseOperation( WindowConstants.DO_NOTHING_ON_CLOSE ); + addWindowListener( new WindowAdapter(){ + public void windowClosing( WindowEvent e ) + { + close(); + } + + public void windowOpened( WindowEvent e ) + { +// setExtendedState( getExtendedState() | MAXIMIZED_BOTH ); + } + + } ); + dataPanel.setDate( new Date() ); + } + + public void refresh() + { + } + + public void open() + { + setVisible( true ); + } + + public void close() + { + SwingUtilities.invokeLater( new Runnable() { + public void run() + { + setVisible( false ); + dispose(); + } + } ); + } + + public boolean closeIfPossible() + { + close(); + return true; + } + + protected void setPrestadores( IDObject prestadores[] ) + { + prestadorCombo.removeAllItems(); + for( IDObject prestador : prestadores ) + { + prestadorCombo.addItem( prestador ); + } +// revalidate(); + } + + public void setEcds( IDObject ecds[] ) + { + ecdsPanel = new CheckBoxPanel( ecds ); + ecdsOuterPanel.removeAll(); + ecdsOuterPanel.add( ecdsPanel ); + revalidate(); + } + + @Override + public void actionPerformed( ActionEvent e ) + { + Object source = e.getSource(); + if( source.equals( enviarButton ) ) + { + Date data = dataPanel.getDate(); + try + { + logic.dateChanged( data ); + } + catch( Exception ex ) + { + if( data != null ) + { + DialogException.showExceptionMessage( ex, "Erro a carregar dados de " + DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) ).format( data ), true ); + } + else + { + DialogException.showExceptionMessage( ex, "Erro a carregar dados de null", true ); + } + } + } + } + + @Override + public void stateChanged( ChangeEvent e ) + { + // TODO Auto-generated method stub + + } + + @Override + public void clear() + { + // TODO Auto-generated method stub + + } + + @Override + public void fill( Object value ) + { + // TODO Auto-generated method stub + + } + + @Override + public Object save() + { + // TODO Auto-generated method stub + return null; + } + + private void revalidate() + { + ( ( JPanel ) getContentPane() ).revalidate(); + } +} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoConstants.java b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoConstants.java index 4534b31b..1911b738 100644 --- a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoConstants.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoConstants.java @@ -5,7 +5,7 @@ import com.evolute.utils.data.MappableObject; public class LocaisRealizacaoConstants { - protected static final Integer PRESTADOR_ID_SIPRP = new Integer( -1 ); + public static final Integer PRESTADOR_ID_SIPRP = new Integer( -1 ); - protected static final IDObject PRESTADOR_SIPRP = new MappableObject( PRESTADOR_ID_SIPRP, "SIPRP" ); + public static final IDObject PRESTADOR_SIPRP = new MappableObject( PRESTADOR_ID_SIPRP, "SIPRP" ); } diff --git a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoDataProvider.java b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoDataProvider.java index 1e3c91d1..0cca4cb8 100644 --- a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoDataProvider.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoDataProvider.java @@ -40,7 +40,7 @@ public class LocaisRealizacaoDataProvider private Executer EXECUTER; /** Creates a new instance of LocaisRealizacaoDataProvider */ - public LocaisRealizacaoDataProvider() + private LocaisRealizacaoDataProvider() throws Exception { DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); @@ -495,6 +495,36 @@ public class LocaisRealizacaoDataProvider return ( ( Number ) array.get( 0, 0 ) ).intValue(); } - - + public Integer []getMarcacoesEcdsIdsByDataAndPrestadorId( Date data, Integer prestadorId ) + throws Exception + { + if( LocaisRealizacaoConstants.PRESTADOR_ID_SIPRP.equals( prestadorId ) ) + { + prestadorId = null; + } + Select select = + new Select2( + new String[]{ "trabalhadoresEcdsDatas" }, + new Integer[]{}, + new Expression[]{}, + new String[]{ "id" }, + new Field( "data" ).isEqual( data ).and( + new Field("prestador_id" ).isEqual( prestadorId ) ).and( + new Field( "estado" ).in( + new Integer[]{ + new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ), + new Integer( MedicinaConstants.ESTADO_PARCIALMENTE_REALIZADO ), + new Integer( MedicinaConstants.ESTADO_REALIZADO ) } ) ), + null, + null, + null, + null ); + Virtual2DArray array = EXECUTER.executeQuery( select ); + Integer ids[] = new Integer[ array.columnLength() ]; + for( int n = 0; n < array.columnLength(); n++ ) + { + ids[ n ] = ( Integer ) array.get( n, 0 ); + } + return ids; + } } diff --git a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoWindow.java b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoWindow.java index 2c23f422..af9acce9 100644 --- a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoWindow.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoWindow.java @@ -63,7 +63,7 @@ public class LocaisRealizacaoWindow extends JFrame protected JCalendarPanel dataPanel; protected JButton carregarButton; - protected JButton recarregarPrestadoresButton; +// protected JButton recarregarPrestadoresButton; protected VectorTableModel empresasModel; protected BaseTable empresasTable; protected VectorTableModel estabelecimentosModel; @@ -72,16 +72,16 @@ public class LocaisRealizacaoWindow extends JFrame protected JComboBox prestadoresConsultasCombo; protected JButton enviarConsultasButton; protected JButton faxConsultasButton; + protected JButton enviarECDsButton; + protected JScrollPane listaEcdsScroll; + // protected JLabel numeroECDsLabel; protected Integer idsGruposEcds[]; protected JComboBox prestadoresECDsCombos[]; protected Integer idsEcdsOficiais[]; protected JComboBox prestadoresECDsOficiaisCombos[]; - protected JButton enviarECDsButton; - protected JScrollPane listaEcdsScroll; // protected JButton faxECDsButton; - protected LocaisRealizacaoDataProvider provider; protected PrestadoresDataProvider prestadoresProvider; @@ -105,8 +105,8 @@ public class LocaisRealizacaoWindow extends JFrame carregarButton = new JButton( "Carregar" ); carregarButton.addActionListener( this ); - recarregarPrestadoresButton = new JButton( "Recarregar Prestadores" ); - recarregarPrestadoresButton.addActionListener( this ); +// recarregarPrestadoresButton = new JButton( "Recarregar Prestadores" ); +// recarregarPrestadoresButton.addActionListener( this ); empresasModel = new VectorTableModel( new String[]{ "empresa" } ); empresasTable = new BaseTable( empresasModel ); empresasTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); @@ -179,7 +179,7 @@ public class LocaisRealizacaoWindow extends JFrame upperPanel.add( dataLabel ); upperPanel.add( dataPanel ); upperPanel.add( carregarButton ); - upperPanel.add( recarregarPrestadoresButton ); +// upperPanel.add( recarregarPrestadoresButton ); // centerPanel.setLayout( new GridLayout( 1, 3 ) ); // centerPanel.add( empresasScp ); @@ -273,10 +273,10 @@ public class LocaisRealizacaoWindow extends JFrame { carregar(); } - else if( source.equals( recarregarPrestadoresButton ) ) - { - recarregarPrestadores(); - } +//// else if( source.equals( recarregarPrestadoresButton ) ) +// { +// recarregarPrestadores(); +// } else if( source.equals( enviarConsultasButton ) ) { enviarConsultas(); diff --git a/trunk/SIPRPSoft/src/siprp/update/UpdateList.java b/trunk/SIPRPSoft/src/siprp/update/UpdateList.java index a43c1573..c4ae7f2c 100644 --- a/trunk/SIPRPSoft/src/siprp/update/UpdateList.java +++ b/trunk/SIPRPSoft/src/siprp/update/UpdateList.java @@ -28,7 +28,8 @@ public class UpdateList new siprp.update.updates.V7_2_To_V7_4(), new siprp.update.updates.V7_4_To_V7_5(), new siprp.update.updates.V7_5_To_V7_6(), new siprp.update.updates.V7_6_To_V7_7(), new siprp.update.updates.V7_7_To_V7_8(), new siprp.update.updates.V7_8_To_V7_9(), - new siprp.update.updates.V7_9_To_V8_0(), new siprp.update.updates.V8_0_To_V8_1() }; + 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() }; protected static Executer EXECUTER; protected static double version = -1; diff --git a/trunk/SIPRPSoft/src/siprp/update/updates/V8_1_To_V8_2.java b/trunk/SIPRPSoft/src/siprp/update/updates/V8_1_To_V8_2.java new file mode 100644 index 00000000..2dc78b95 --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/update/updates/V8_1_To_V8_2.java @@ -0,0 +1,75 @@ +/* + * 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; +import com.evolute.utils.sql.Assignment; +import com.evolute.utils.sql.Field; + +/** + * + * @author fpalma + */ +public class V8_1_To_V8_2 + implements siprp.update.Update +{ + + /** + * Creates a new instance of V8_1_To_V8_2 + */ + public V8_1_To_V8_2() + { + } + + public String []listChanges() + { + return new String[]{ "Alterar tabela dos ecds", "Alterar tabela de marca\u00e7\u00e3o dos ecds" }; + } + + public double getStartVersion() + { + return 8.1; + } + + public double getEndVersion() + { + return 8.2; + } + + 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 trabalhadores_ecd ADD enviado CHAR(1);" ); + executer.executeQuery( update ); + update = + new com.evolute.utils.sql.Update( + "ALTER TABLE trabalhadores_ecds_datas ADD analisador_id INT REFERENCES prestadores( id );" ); + executer.executeQuery( update ); + update = + new com.evolute.utils.sql.Update( + "ALTER TABLE trabalhadores_ecds_datas ADD data_envio DATE;" ); + executer.executeQuery( update ); + update = + new com.evolute.utils.sql.Update( + "ALTER TABLE trabalhadores_ecds_datas ADD data_recepcao DATE;" ); + executer.executeQuery( update ); + } + + public String toString() + { + return "v" + getStartVersion() + " para v" + getEndVersion(); + } +}