" );
+ }
+ }
+ passwordText.getDocument().addDocumentListener( this );
+ }
+
+ public void setEmpresaID( Integer empresaID )
+ {
+ try
+ {
+ userNameText.setText( "" );
+ passwordText.setText( "" );
+ passwordEdited = false;
+ hasPassword = false;
+ this.empresaID = empresaID;
+// if( empresaID == null )
+// {
+// return;
+// }
+ reload();
+ refresh();
+ error = false;
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro na liga\u00e7\u00e3o \u00e0 Base de Dados WEB", true );
+ userNameText.setText( "Erro na liga\u00e7\u00e3o" );
+ setEnabled( false );
+ error = true;
+ }
+ }
+
+ private boolean save()
+ throws Exception
+ {
+ if( !provider.checkNewName( userNameText.getText(), empresaID ) )
+ {
+ JOptionPane.showMessageDialog( null, "O Utilizador " + userNameText.getText() + " j\u00e1 est\u00e1 em uso por outra entidade." );
+ return false;
+ }
+ provider.saveUser( userNameText.getText(), passwordText.getText(), empresaID, !hasPassword );
+ passwordEdited = false;
+ return true;
+ }
+
+ private boolean reload()
+ throws Exception
+ {
+ String userName = provider.getUserName( empresaID );
+ if( userName != null )
+ {
+ userNameText.setText( userName );
+ hasPassword = true;
+ }
+ passwordEdited = false;
+ return true;
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ userNameText.setEnabled( enable && !error );
+ passwordText.setEnabled( enable && !error );
+ applyButton.setEnabled( enable && !error );
+ cancelButton.setEnabled( enable && !error );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/clientes/UserWindow.java b/trunk/SIPRPSoft/src/siprp/clientes/UserWindow.java
new file mode 100644
index 00000000..8ba90d39
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/clientes/UserWindow.java
@@ -0,0 +1,66 @@
+/*
+ * UserWindow.java
+ *
+ * Created on 15 de Marco de 2005, 11:35
+ */
+
+package siprp.clientes;
+
+import java.awt.*;
+import javax.swing.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.jdo.*;
+import com.evolute.utils.ui.*;
+
+import siprp.data.*;
+/**
+ *
+ * @author fpalma
+ */
+public class UserWindow extends CustomJDialog
+{
+ protected JDOProvider JDO;
+// protected JTextField empresaText;
+ protected UserPanel userPanel;
+ protected Integer empresaID;
+
+ /** Creates a new instance of UserWindow */
+ public UserWindow( JFrame owner, Integer empresaID )
+ throws Exception
+ {
+ super( owner, true );
+ this.empresaID = empresaID;
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ setupComponents();
+ centerSuper();
+ }
+
+ private void setupComponents()
+ throws Exception
+ {
+ setSize( 500, 200 );
+ userPanel = new UserPanel();
+// empresaText = new JTextField();
+ getContentPane().setLayout( new BorderLayout() );
+// getContentPane().add( empresaText, BorderLayout.NORTH );
+ getContentPane().add( userPanel, BorderLayout.CENTER );
+
+ if( empresaID == null )
+ {
+// empresaText.setText( "SIPRP" );
+ setTitle( "SIPRP" );
+ }
+ else
+ {
+ EmpresaData empresa = ( EmpresaData )JDO.load( EmpresaData.class, empresaID );
+ if( empresa == null )
+ {
+ return;
+ }
+// empresaText.setText( (String)empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) );
+ setTitle( (String)empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) );
+ }
+ userPanel.setEmpresaID( empresaID );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/clientes/etiqueta.xsl b/trunk/SIPRPSoft/src/siprp/clientes/etiqueta.xsl
new file mode 100644
index 00000000..4603a50b
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/clientes/etiqueta.xsl
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Cuidado Prestado
+
+
+
+
+ Código
+
+
+
+
+ Valor
+
+
+
+
+ Benef.
+
+
+
+
+ Entidade
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/trunk/SIPRPSoft/src/siprp/clientes/etiquetas.dtd b/trunk/SIPRPSoft/src/siprp/clientes/etiquetas.dtd
new file mode 100644
index 00000000..69d2b4f1
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/clientes/etiquetas.dtd
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/trunk/SIPRPSoft/src/siprp/companydataloaders/ClinicaAvenidaDataLoader.java b/trunk/SIPRPSoft/src/siprp/companydataloaders/ClinicaAvenidaDataLoader.java
new file mode 100644
index 00000000..89dbdca8
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/companydataloaders/ClinicaAvenidaDataLoader.java
@@ -0,0 +1,91 @@
+/*
+ * ClinicaAvenidaDtaLoader.java
+ *
+ * Created on 25 de Janeiro de 2005, 13:27
+ */
+
+package siprp.companydataloaders;
+
+import com.evolute.utils.*;
+
+import siprp.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class ClinicaAvenidaDataLoader implements CompanyDataLoader
+{
+
+ /** Creates a new instance of ClinicaAvenidaDtaLoader */
+ public ClinicaAvenidaDataLoader()
+ {
+ }
+
+ public void load()
+ {
+ Singleton.setInstance( SingletonConstants.SOFTWARE_NAME, "SHSTSoft" );
+ Singleton.setInstance( SingletonConstants.COMPANY_NAME, "Centro Cl\u00ednico Avenida" );
+ Singleton.setInstance( SingletonConstants.COMPANY_LOGO, "logo_evo.jpg" );
+ Singleton.setInstance( SingletonConstants.COMPANY_ACRONYM, "CCA" );
+ Singleton.setInstance( SingletonConstants.SUBJECT_CONSULTA, "Centro Cl\u00ednico da Avenida - Marca\u00e7\u00e3o de consulta m\u00e9dica" );
+ Singleton.setInstance( SingletonConstants.LETTER_CONSULTA, "Vimos por este meio informar que " + NOME + " "
+ + "dever\u00e1 comparecer no Centro Cl\u00ednico da Avenida para a realiza\u00e7\u00e3o da "
+ + "consulta de Medicina do Trabalho, no dia " + DATA + ".\n"
+ + "Caso n\u00e3o seja poss\u00edvel a compar\u00eancia do referido colaborador na "
+ + "data indicada, agradecemos que nos informem atrav\u00e9s do telefone 214928612 "
+ + "ou respondendo a esta mensagem.\n\n"
+ + "Departamento de Seguran\u00e7a e Higiene do Trabalho\n"
+ + "Centro Cl\u00ednico da Avenida\n"
+ + "Av. General Humberto Delgado 128 R/C D\n"
+ + "2700-419 Amadora" );
+ Singleton.setInstance( SingletonConstants.SUBJECT_EXAMES, "Centro Cl\u00ednico da Avenida - Marca\u00e7\u00e3o de exames de Medicina do Trabalho" );
+ Singleton.setInstance( SingletonConstants.LETTER_EXAMES, "Vimos por este meio informar que " + NOME + " "
+ + "dever\u00e1 comparecer no Centro Cl\u00ednico da Avenida para a realiza\u00e7\u00e3o "
+ + "de exames relativos \u00e0 Medicina do Trabalho, no dia " + DATA + ".\n"
+ + "Caso n\u00e3o seja poss\u00edvel a compar\u00eancia do referido colaborador na "
+ + "data indicada, agradecemos que nos informem atrav\u00e9s do telefone 214928612 "
+ + "ou respondendo a esta mensagem.\n\n"
+ + "Departamento de Seguran\u00e7a e Higiene do Trabalho\n"
+ + "Centro Cl\u00ednico da Avenida\n"
+ + "Av. General Humberto Delgado 128 R/C D\n"
+ + "2700-419 Amadora" );
+ Singleton.setInstance( SingletonConstants.SUBJECT_VISITA, "Centro Cl\u00ednico da Avenida - Marca\u00e7\u00e3�o da Auditoria de Seguran\u00e7a e Higiene do Trabalho" );
+ Singleton.setInstance( SingletonConstants.LETTER_VISITA, "Vimos por este meio informar que pretendemos "
+ + "realizar a auditoria de Seguran\u00e7a e Higiene do Trabalho \u00e0s vossas "
+ + "instala��es em " + MORADA + ", no dia " + DATA + ".\n"
+ + "Agradecemos que confirmem a vossa disponibilidade para a realiza\u00e7\u00e3o "
+ + "da visita na data indicada, atrav\u00e9s do telefone 214928612 ou "
+ + "respondendo a esta mensagem.\n\n"
+ + "Departamento de Seguran\u00e7a e Higiene do Trabalho\n"
+ + "Centro Cl\u00ednico da Avenida\n"
+ + "Av. General Humberto Delgado 128 R/C D\n"
+ + "2700-419 Amadora\n"
+ + "Tel.: 214928612" );
+ Singleton.setInstance( SingletonConstants.USES_HOUR, Boolean.TRUE );
+ Singleton.setInstance( SingletonConstants.CODIGO_EMPRESA_FORMAT, "15" );
+ Singleton.setInstance( SingletonConstants.FICHA_MARCA_EXAMES, Boolean.FALSE );
+ Singleton.setInstance( SingletonConstants.EXCEL_FORMAT, new int[]{ 0, 2, 3, 1, 4, 5, 6, 9, 7, 8 } );
+
+ Singleton.setInstance( SingletonConstants.MODULE_FICHA, Boolean.TRUE );
+ Singleton.setInstance( SingletonConstants.MODULE_CLIENTES, Boolean.TRUE );
+ Singleton.setInstance( SingletonConstants.WEB_AWARE, Boolean.FALSE );
+ Singleton.setInstance( SingletonConstants.MODULE_RELATORIO, Boolean.TRUE );
+ Singleton.setInstance( SingletonConstants.MODULE_LISTAGENS, Boolean.FALSE );
+
+ Singleton.setInstance( SingletonConstants.WEB_USER, "" );
+ Singleton.setInstance( SingletonConstants.WEB_PASSWORD, "" );
+ Singleton.setInstance( SingletonConstants.WEB_URL_PREFIX, "" );
+ Singleton.setInstance( SingletonConstants.WEB_URL, "" );
+ Singleton.setInstance( SingletonConstants.WEB_DB_NAME, "" );
+ Singleton.setInstance( SingletonConstants.WEB_DRIVER_NAME, "" );
+
+ 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, "localhost" );
+ Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "shst" );
+ Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" );
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/companydataloaders/IBookDataLoader.java b/trunk/SIPRPSoft/src/siprp/companydataloaders/IBookDataLoader.java
new file mode 100644
index 00000000..1f1d3e4b
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/companydataloaders/IBookDataLoader.java
@@ -0,0 +1,105 @@
+/*
+ * SIPRPDataLoader.java
+ *
+ * Created on 25 de Janeiro de 2005, 13:19
+ */
+
+package siprp.companydataloaders;
+
+import com.evolute.utils.*;
+
+import siprp.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class IBookDataLoader implements CompanyDataLoader
+{
+
+ /** Creates a new instance of SIPRPDataLoader */
+ public IBookDataLoader()
+ {
+ }
+
+ public void load()
+ {
+ Singleton.setInstance( SingletonConstants.SOFTWARE_NAME, "SHSTSoft" );
+ Singleton.setInstance( SingletonConstants.COMPANY_NAME, "SHST" );
+ Singleton.setInstance( SingletonConstants.COMPANY_LOGO, "logo_evo.jpg" );
+ Singleton.setInstance( SingletonConstants.COMPANY_ACRONYM, "SHST" );
+ Singleton.setInstance( SingletonConstants.SUBJECT_CONSULTA, "SHST - Marca\u00E7\u00E3o de consulta");
+ Singleton.setInstance( SingletonConstants.LETTER_CONSULTA, "Vimos pelo presente informar que '" + NOME + "' dever\u00E1 comparecer "
+ + "nas nossas instala\u00E7\u00F5es para a realiza\u00E7\u00E3o da consulta de Medicina "
+ + "do Trabalho, no dia '" + DATA + "', pelas 08H30."
+ + "%0A%0A"
+ + "%0A%0A"
+ + "Solicitamos, tamb\u00E9m, que o colaborador seja portador do Boletim de Vacinas e "
+ + "dos \u00FAltimos exames complementares realizados."
+ + "%0A%0A"
+ + "%0A%0A"
+ + "Caso n\u00E3o seja poss\u00EDvel a compar\u00EAncia deste colaborador na data "
+ + "indicada, contacte-nos, por favor, atrav\u00E9s do telefone 21 212 12 12 "
+ + "ou respondendo ao remetente desta mensagem."
+ + "%0A%0A%0A"
+ + "Cumprimentos,"
+ + "%0A%0ASHST" );
+ Singleton.setInstance( SingletonConstants.SUBJECT_EXAMES, "SHST - Marca\u00E7\u00E3o de exame");
+ Singleton.setInstance( SingletonConstants.LETTER_EXAMES, "Vimos pelo presente informar que '" + NOME + "' dever\u00E1 comparecer "
+ + "nas nossas instala\u00E7\u00F5es para a realiza\u00E7\u00E3o dos exames de Medicina "
+ + "do Trabalho, no dia '" + DATA + "', pelas 08H30."
+ + "%0A%0A"
+ + "Relembramos que o colaborador dever\u00E1 comparecer em jejum."
+ + "%0A%0A"
+ + "Caso n\u00E3o seja poss\u00EDvel a compar\u00EAncia deste colaborador na data "
+ + "indicada, contacte-nos, por favor, atrav\u00E9s do telefone 21 212 12 12 "
+ + "ou respondendo ao remetente desta mensagem."
+ + "%0A%0A%0A"
+ + "Cumprimentos,%0A%0ASHST" );
+ Singleton.setInstance( SingletonConstants.SUBJECT_VISITA, "SHST - Marca\u00E7\u00E3o de visita de higiene e seguran\u00E7a");
+ Singleton.setInstance( SingletonConstants.LETTER_VISITA, "Vimos pelo presente informar que iremos efectuar a auditoria de Higiene e "
+ + "Seguran\u00E7a \u00E0s vossas instala\u00E7\u00F5es de '" + NOME + "', no dia '" + DATA + "'."
+ + "%0A%0A"
+ + "Agradecemos que nos confirme, pela mesma via, o nome do representante "
+ + "da empresa que nos ir\u00E1 acompanhar e a vossa disponibilidade para a "
+ + "realiza\u00E7\u00E3o da visita na data indicada."
+ + "%0A%0A"
+ + "Caso necessite de qualquer esclarecimento, contacte-nos, por favor, "
+ + "atrav\u00E9s do telefone 21 212 12 12 "
+ + "ou responda ao remetente desta mensagem."
+ + "%0A%0A%0A"
+ + "Cumprimentos,%0A%0ASHST" );
+ Singleton.setInstance( SingletonConstants.USES_HOUR, Boolean.FALSE );
+ Singleton.setInstance( SingletonConstants.CODIGO_EMPRESA_FORMAT, "2 6 / 2" );
+ Singleton.setInstance( SingletonConstants.FICHA_MARCA_EXAMES, Boolean.TRUE );
+ Singleton.setInstance( SingletonConstants.EXCEL_FORMAT, new int[]{ 0, 2, 3, 1, -1, 4, 5, 7, 6, -1 } );
+
+ Singleton.setInstance( SingletonConstants.MODULE_FICHA, Boolean.TRUE );
+ Singleton.setInstance( SingletonConstants.MODULE_CLIENTES, Boolean.TRUE );
+ Singleton.setInstance( SingletonConstants.WEB_AWARE, Boolean.FALSE );
+ Singleton.setInstance( SingletonConstants.MODULE_RELATORIO, Boolean.TRUE );
+ Singleton.setInstance( SingletonConstants.MODULE_LISTAGENS, Boolean.TRUE );
+
+ Singleton.setInstance( SingletonConstants.WEB_USER, "" );
+ Singleton.setInstance( SingletonConstants.WEB_PASSWORD, "" );
+ Singleton.setInstance( SingletonConstants.WEB_URL_PREFIX, "" );
+ Singleton.setInstance( SingletonConstants.WEB_URL, "" );
+ Singleton.setInstance( SingletonConstants.WEB_DB_NAME, "" );
+ Singleton.setInstance( SingletonConstants.WEB_DRIVER_NAME, "" );
+
+// 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, "localhost: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/companydataloaders/SIPRPDataLoader.java b/trunk/SIPRPSoft/src/siprp/companydataloaders/SIPRPDataLoader.java
new file mode 100644
index 00000000..497bb5d6
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/companydataloaders/SIPRPDataLoader.java
@@ -0,0 +1,123 @@
+/*
+ * SIPRPDataLoader.java
+ *
+ * Created on 25 de Janeiro de 2005, 13:19
+ */
+
+package siprp.companydataloaders;
+
+import com.evolute.utils.*;
+
+import siprp.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class SIPRPDataLoader implements CompanyDataLoader
+{
+
+ /** Creates a new instance of SIPRPDataLoader */
+ public SIPRPDataLoader()
+ {
+ }
+
+ public void load()
+ {
+ Singleton.setInstance( SingletonConstants.SOFTWARE_NAME, "SIPRPSoft" );
+ Singleton.setInstance( SingletonConstants.COMPANY_NAME, "SIPRP - Sociedade Ib\u00e9rica de Preven\u00e7\u00e3o de Riscos Profissionais" );
+ Singleton.setInstance( SingletonConstants.COMPANY_LOGO, "logo_combo.jpg" );
+ Singleton.setInstance( SingletonConstants.COMPANY_ACRONYM, "SIPRP" );
+ Singleton.setInstance( SingletonConstants.SUBJECT_CONSULTA, "SIPRP - Marca\u00E7\u00E3o de consulta de '" + NOME + "'");
+ Singleton.setInstance( SingletonConstants.LETTER_CONSULTA, "Vimos pelo presente informar que '" + NOME + "' dever\u00E1 comparecer "
+ + "nas nossas instala\u00E7\u00F5es para a realiza\u00E7\u00E3o da consulta de Medicina "
+ + "do Trabalho, no dia '" + DATA + "', pelas 08H30."
+ + "%0A%0A"
+ + "%0A%0A"
+ + "Solicitamos, tamb\u00E9m, que o colaborador seja portador do Boletim de Vacinas e "
+ + "dos \u00FAltimos exames complementares realizados."
+ + "%0A%0A"
+ + "%0A%0A"
+ + "Caso n\u00E3o seja poss\u00EDvel a compar\u00EAncia deste colaborador na data "
+ + "indicada, contacte-nos, por favor, atrav\u00E9s do telefone 21 350 45 40 "
+ + "ou respondendo ao remetente desta mensagem."
+ + "%0A%0A%0A"
+ + "Cumprimentos,"
+ + "%0A%0ASIPRP"
+ + "%0A%0AATRIUM SALDANHA"
+ + "%0A%0APra\u00e7a Duque de Saldanha, 1 - 9\u00BAG"
+ + "%0A%0A1050-094 Lisboa" );
+ Singleton.setInstance( SingletonConstants.SUBJECT_EXAMES, "SIPRP - Marca\u00E7\u00E3o de exame de '" + NOME + "'");
+ Singleton.setInstance( SingletonConstants.LETTER_EXAMES, "Vimos pelo presente informar que '" + NOME + "' dever\u00E1 comparecer "
+ + "nas nossas instala\u00E7\u00F5es para a realiza\u00E7\u00E3o dos exames de Medicina "
+ + "do Trabalho, no dia '" + DATA + "', pelas 08H30."
+ + "%0A%0A"
+ + "Relembramos que o colaborador dever\u00E1 comparecer em jejum."
+ + "%0A%0A"
+ + "Caso n\u00E3o seja poss\u00EDvel a compar\u00EAncia deste colaborador na data "
+ + "indicada, contacte-nos, por favor, atrav\u00E9s do telefone 21 350 45 40 "
+ + "ou respondendo ao remetente desta mensagem."
+ + "%0A%0A%0A"
+ + "Cumprimentos,%0A%0ASIPRP" );
+ Singleton.setInstance( SingletonConstants.SUBJECT_VISITA, "SIPRP - Marca\u00E7\u00E3o de visita de higiene e seguran\u00E7a a '" + NOME + "'" );
+ Singleton.setInstance( SingletonConstants.LETTER_VISITA, "Vimos pelo presente informar que iremos efectuar a auditoria de Higiene e "
+ + "Seguran\u00E7a \u00E0s vossas instala\u00E7\u00F5es de '" + NOME + "', no dia '" + DATA + "'."
+ + "%0A%0A"
+ + "Agradecemos que nos confirme, pela mesma via, o nome do representante "
+ + "da empresa que nos ir\u00E1 acompanhar e a vossa disponibilidade para a "
+ + "realiza\u00E7\u00E3o da visita na data indicada."
+ + "%0A%0A"
+ + "Caso necessite de qualquer esclarecimento, contacte-nos, por favor, "
+ + "atrav\u00E9s dos telefones 21 350 45 43 (Pedro Vieira), 21 350 45 44 "
+ + "(Catarina Leonardo) ou responda ao remetente desta mensagem."
+ + "%0A%0A%0A"
+ + "Cumprimentos,%0A%0ASIPRP" );
+ Singleton.setInstance( SingletonConstants.USES_HOUR, Boolean.FALSE );
+ Singleton.setInstance( SingletonConstants.CODIGO_EMPRESA_FORMAT, "2 6 / 2" );
+ Singleton.setInstance( SingletonConstants.FICHA_MARCA_EXAMES, Boolean.TRUE );
+ Singleton.setInstance( SingletonConstants.EXCEL_FORMAT, new int[]{ 0, 2, 3, 1, -1, 4, 5, 7, 6, -1 } );
+ Singleton.setInstance( SingletonConstants.EXCEL_FORMAT_DEMISSAO, new int[]{ 0, 1 } );
+
+ Singleton.setInstance( SingletonConstants.MODULE_FICHA, Boolean.TRUE );
+ Singleton.setInstance( SingletonConstants.MODULE_CLIENTES, Boolean.TRUE );
+ Singleton.setInstance( SingletonConstants.WEB_AWARE, Boolean.TRUE );
+ Singleton.setInstance( SingletonConstants.MODULE_RELATORIO, Boolean.TRUE );
+ Singleton.setInstance( SingletonConstants.MODULE_LISTAGENS, Boolean.TRUE );
+
+ Singleton.setInstance( SingletonConstants.WEB_USER, "siprp" );
+ Singleton.setInstance( SingletonConstants.WEB_PASSWORD, "rg2h-opksiprp" );
+ Singleton.setInstance( SingletonConstants.WEB_URL_PREFIX, "jdbc:postgresql://" );
+ Singleton.setInstance( SingletonConstants.WEB_URL, "www.evolute.pt:5436" );
+ Singleton.setInstance( SingletonConstants.WEB_DB_NAME, "siprp" );
+ Singleton.setInstance( SingletonConstants.WEB_DRIVER_NAME, "org.postgresql.Driver" );
+
+// Singleton.setInstance( SingletonConstants.LOCAL_USER, "slony" );
+// Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "-rg2hevoevo" );
+// Singleton.setInstance( SingletonConstants.LOCAL_URL_PREFIX, "jdbc:postgresql://" );
+// Singleton.setInstance( SingletonConstants.LOCAL_URL, "www.evolute.pt:5436" );
+// Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local_3" );
+// 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, "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, "localhost: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/data/ActualizacaoSaveHandler.java b/trunk/SIPRPSoft/src/siprp/data/ActualizacaoSaveHandler.java
new file mode 100644
index 00000000..a951e86a
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/ActualizacaoSaveHandler.java
@@ -0,0 +1,51 @@
+/*
+ * StampSaveHandler.java
+ *
+ * Created on 15 de Marco de 2005, 15:00
+ */
+
+package siprp.data;
+
+import java.util.*;
+
+import com.evolute.utils.jdo.*;
+/**
+ *
+ * @author fpalma
+ */
+public class ActualizacaoSaveHandler implements JDOOperationHandlerInterface
+{
+ public static final ActualizacaoSaveHandler INSTANCE = new ActualizacaoSaveHandler();
+
+ /** Creates a new instance of StampSaveHandler */
+ public ActualizacaoSaveHandler()
+ {
+ }
+
+ public boolean handle(JDOObject object, int operation, int moment) throws Exception
+ {
+ if( !( object instanceof ActualizacaoSaveable ) )
+ {
+ return false;
+ }
+ switch( operation )
+ {
+ case OP_SAVE:
+ return save( object, moment );
+
+ case OP_DELETE:
+ return false;
+ }
+ return false;
+ }
+
+ protected boolean save( JDOObject object, int moment )
+ {
+ if( moment != MOMENT_BEFORE )
+ {
+ return false;
+ }
+ object.set( ActualizacaoSaveable.ACTUALIZACAO, new Date() );
+ return true;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/ActualizacaoSaveable.java b/trunk/SIPRPSoft/src/siprp/data/ActualizacaoSaveable.java
new file mode 100644
index 00000000..87d79372
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/ActualizacaoSaveable.java
@@ -0,0 +1,16 @@
+/*
+ * ActualizacaoSaveable.java
+ *
+ * Created on 15 de Marco de 2005, 15:32
+ */
+
+package siprp.data;
+
+/**
+ *
+ * @author fpalma
+ */
+public interface ActualizacaoSaveable
+{
+ public static final String ACTUALIZACAO = "actualizacao";
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/Aviso.java b/trunk/SIPRPSoft/src/siprp/data/Aviso.java
new file mode 100644
index 00000000..791fad87
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/Aviso.java
@@ -0,0 +1,186 @@
+/*
+* Aviso.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 13/Out/2004
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.Date;
+import com.evolute.utils.jdo.*;
+
+public final class Aviso implements JDOInnerObject
+{
+ private Integer id;
+ private Integer tipo;
+ private Empresa empresa;
+ private Estabelecimento estabelecimento;
+ private Trabalhador trabalhador;
+ private Integer evento_id;
+ private Date data_aviso;
+ private Date data_evento;
+ private String descricao;
+
+ public Aviso()
+ {
+ }
+
+ public Object getField( String fieldName )
+ {
+ if( fieldName == AvisoData.ID )
+ {
+ return id;
+ }
+ else if( fieldName == AvisoData.TIPO )
+ {
+ return tipo;
+ }
+ else if( fieldName == AvisoData.EMPRESA )
+ {
+ return empresa;
+ }
+ else if( fieldName == AvisoData.ESTABELECIMENTO )
+ {
+ return estabelecimento;
+ }
+ else if( fieldName == AvisoData.TRABALHADOR )
+ {
+ return trabalhador;
+ }
+ else if( fieldName == AvisoData.EVENTO_ID )
+ {
+ return evento_id;
+ }
+ else if( fieldName == AvisoData.DATA_AVISO )
+ {
+ return data_aviso;
+ }
+ else if( fieldName == AvisoData.DATA_EVENTO )
+ {
+ return data_evento;
+ }
+ else if( fieldName == AvisoData.DESCRICAO )
+ {
+ return descricao;
+ }
+ else if( fieldName.equals( AvisoData.ID ) )
+ {
+ return id;
+ }
+ else if( fieldName.equals( AvisoData.TIPO ) )
+ {
+ return tipo;
+ }
+ else if( fieldName.equals( AvisoData.EMPRESA ) )
+ {
+ return empresa;
+ }
+ else if( fieldName.equals( AvisoData.ESTABELECIMENTO ) )
+ {
+ return estabelecimento;
+ }
+ else if( fieldName.equals( AvisoData.TRABALHADOR ) )
+ {
+ return trabalhador;
+ }
+ else if( fieldName.equals( AvisoData.EVENTO_ID ) )
+ {
+ return evento_id;
+ }
+ else if( fieldName.equals( AvisoData.DATA_AVISO ) )
+ {
+ return data_aviso;
+ }
+ else if( fieldName.equals( AvisoData.DATA_EVENTO ) )
+ {
+ return data_evento;
+ }
+ else if( fieldName.equals( AvisoData.DESCRICAO ) )
+ {
+ return descricao;
+ }
+ return null;
+ }
+
+ public void setField( String fieldName, Object value )
+ {
+ if( fieldName == AvisoData.ID )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName == AvisoData.TIPO )
+ {
+ tipo = ( Integer ) value;
+ }
+ else if( fieldName == AvisoData.EMPRESA )
+ {
+ empresa = ( Empresa ) value;
+ }
+ else if( fieldName == AvisoData.ESTABELECIMENTO )
+ {
+ estabelecimento = ( Estabelecimento ) value;
+ }
+ else if( fieldName == AvisoData.TRABALHADOR )
+ {
+ trabalhador = ( Trabalhador ) value;
+ }
+ else if( fieldName == AvisoData.EVENTO_ID )
+ {
+ evento_id = ( Integer ) value;
+ }
+ else if( fieldName == AvisoData.DATA_AVISO )
+ {
+ data_aviso = ( Date ) value;
+ }
+ else if( fieldName == AvisoData.DATA_EVENTO )
+ {
+ data_evento = ( Date ) value;
+ }
+ else if( fieldName == AvisoData.DESCRICAO )
+ {
+ descricao = ( String ) value;
+ }
+ else if( fieldName.equals( AvisoData.ID ) )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName.equals( AvisoData.TIPO ) )
+ {
+ tipo = ( Integer ) value;
+ }
+ else if( fieldName.equals( AvisoData.EMPRESA ) )
+ {
+ empresa = ( Empresa ) value;
+ }
+ else if( fieldName.equals( AvisoData.ESTABELECIMENTO ) )
+ {
+ estabelecimento = ( Estabelecimento ) value;
+ }
+ else if( fieldName.equals( AvisoData.TRABALHADOR ) )
+ {
+ trabalhador = ( Trabalhador ) value;
+ }
+ else if( fieldName.equals( AvisoData.EVENTO_ID ) )
+ {
+ evento_id = ( Integer ) value;
+ }
+ else if( fieldName.equals( AvisoData.DATA_AVISO ) )
+ {
+ data_aviso = ( Date ) value;
+ }
+ else if( fieldName.equals( AvisoData.DATA_EVENTO ) )
+ {
+ data_evento = ( Date ) value;
+ }
+ else if( fieldName.equals( AvisoData.DESCRICAO ) )
+ {
+ descricao = ( String ) value;
+ }
+ }
+
+ public Class getOuterClass()
+ {
+ return AvisoData.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/AvisoConstants.java b/trunk/SIPRPSoft/src/siprp/data/AvisoConstants.java
new file mode 100644
index 00000000..1f8ca61f
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/AvisoConstants.java
@@ -0,0 +1,18 @@
+/*
+ * AvisoConstants.java
+ *
+ * Created on 11 de Outubro de 2004, 13:03
+ */
+
+package siprp.data;
+
+/**
+ *
+ * @author fpalma
+ */
+public interface AvisoConstants
+{
+ public static final int TIPO_TRABALHADOR = 0;
+ public static final int TIPO_ESTABELECIMENTO = 1;
+ public static final int TIPO_EMPRESA = 2;
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/AvisoData.java b/trunk/SIPRPSoft/src/siprp/data/AvisoData.java
new file mode 100644
index 00000000..dace2057
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/AvisoData.java
@@ -0,0 +1,68 @@
+/*
+* AvisoData.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 13/Out/2004
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.HashMap;
+import com.evolute.utils.jdo.*;
+
+public final class AvisoData extends JDOObject
+ implements AvisoConstants
+{
+ public static final String ID = "id";
+ public static final String TIPO = "tipo";
+ public static final String EMPRESA = "empresa";
+ public static final String ESTABELECIMENTO = "estabelecimento";
+ public static final String TRABALHADOR = "trabalhador";
+ public static final String EVENTO_ID = "evento_id";
+ public static final String DATA_AVISO = "data_aviso";
+ public static final String DATA_EVENTO = "data_evento";
+ public static final String DESCRICAO = "descricao";
+
+ public static final String FIELD_NAMES[] = new String[]{
+ TIPO, EMPRESA, ESTABELECIMENTO, TRABALHADOR, EVENTO_ID, DATA_AVISO, DATA_EVENTO,
+ DESCRICAO, };
+
+
+ protected static final String ALL_FIELD_NAMES[] = new String[]{
+ ID, TIPO, EMPRESA, ESTABELECIMENTO, TRABALHADOR, EVENTO_ID, DATA_AVISO, DATA_EVENTO,
+ DESCRICAO, };
+
+ private HashMap dataHash;
+
+ public AvisoData()
+ {
+ dataHash = new HashMap();
+ }
+
+ protected Object innerGet( String fieldName )
+ throws Exception
+ {
+ return dataHash.get( fieldName );
+ }
+
+ protected void innerSet( String fieldName, Object value )
+ throws Exception
+ {
+ dataHash.put( fieldName, value );
+ }
+
+ public String []getFieldNames()
+ {
+ return FIELD_NAMES;
+ }
+
+ protected String []getAllFieldNames()
+ {
+ return ALL_FIELD_NAMES;
+ }
+
+ public Class getInnerClass()
+ {
+ return Aviso.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/AvisoID.java b/trunk/SIPRPSoft/src/siprp/data/AvisoID.java
new file mode 100644
index 00000000..9a7cfb3f
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/AvisoID.java
@@ -0,0 +1,22 @@
+/*
+* AvisoID.java
+*
+* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 13/Out/2004
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import com.evolute.utils.jdo.jpox.*;
+
+public final class AvisoID extends IntegerID
+{
+ public AvisoID()
+ {
+ }
+
+ public AvisoID( String str )
+ {
+ super( str );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/Contacto.java b/trunk/SIPRPSoft/src/siprp/data/Contacto.java
new file mode 100644
index 00000000..38941701
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/Contacto.java
@@ -0,0 +1,152 @@
+/*
+* Contacto.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 13/Out/2004
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.Date;
+import com.evolute.utils.jdo.*;
+
+public final class Contacto implements JDOInnerObject
+{
+ private Integer id;
+ private String nome;
+ private String cargo;
+ private String telefone;
+ private String telemovel;
+ private String fax;
+ private String email;
+
+ public Contacto()
+ {
+ }
+
+ public Object getField( String fieldName )
+ {
+ if( fieldName == ContactoData.ID )
+ {
+ return id;
+ }
+ else if( fieldName == ContactoData.NOME )
+ {
+ return nome;
+ }
+ else if( fieldName == ContactoData.CARGO )
+ {
+ return cargo;
+ }
+ else if( fieldName == ContactoData.TELEFONE )
+ {
+ return telefone;
+ }
+ else if( fieldName == ContactoData.TELEMOVEL )
+ {
+ return telemovel;
+ }
+ else if( fieldName == ContactoData.FAX )
+ {
+ return fax;
+ }
+ else if( fieldName == ContactoData.EMAIL )
+ {
+ return email;
+ }
+ else if( fieldName.equals( ContactoData.ID ) )
+ {
+ return id;
+ }
+ else if( fieldName.equals( ContactoData.NOME ) )
+ {
+ return nome;
+ }
+ else if( fieldName.equals( ContactoData.CARGO ) )
+ {
+ return cargo;
+ }
+ else if( fieldName.equals( ContactoData.TELEFONE ) )
+ {
+ return telefone;
+ }
+ else if( fieldName.equals( ContactoData.TELEMOVEL ) )
+ {
+ return telemovel;
+ }
+ else if( fieldName.equals( ContactoData.FAX ) )
+ {
+ return fax;
+ }
+ else if( fieldName.equals( ContactoData.EMAIL ) )
+ {
+ return email;
+ }
+ return null;
+ }
+
+ public void setField( String fieldName, Object value )
+ {
+ if( fieldName == ContactoData.ID )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName == ContactoData.NOME )
+ {
+ nome = ( String ) value;
+ }
+ else if( fieldName == ContactoData.CARGO )
+ {
+ cargo = ( String ) value;
+ }
+ else if( fieldName == ContactoData.TELEFONE )
+ {
+ telefone = ( String ) value;
+ }
+ else if( fieldName == ContactoData.TELEMOVEL )
+ {
+ telemovel = ( String ) value;
+ }
+ else if( fieldName == ContactoData.FAX )
+ {
+ fax = ( String ) value;
+ }
+ else if( fieldName == ContactoData.EMAIL )
+ {
+ email = ( String ) value;
+ }
+ else if( fieldName.equals( ContactoData.ID ) )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName.equals( ContactoData.NOME ) )
+ {
+ nome = ( String ) value;
+ }
+ else if( fieldName.equals( ContactoData.CARGO ) )
+ {
+ cargo = ( String ) value;
+ }
+ else if( fieldName.equals( ContactoData.TELEFONE ) )
+ {
+ telefone = ( String ) value;
+ }
+ else if( fieldName.equals( ContactoData.TELEMOVEL ) )
+ {
+ telemovel = ( String ) value;
+ }
+ else if( fieldName.equals( ContactoData.FAX ) )
+ {
+ fax = ( String ) value;
+ }
+ else if( fieldName.equals( ContactoData.EMAIL ) )
+ {
+ email = ( String ) value;
+ }
+ }
+
+ public Class getOuterClass()
+ {
+ return ContactoData.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/ContactoData.java b/trunk/SIPRPSoft/src/siprp/data/ContactoData.java
new file mode 100644
index 00000000..a3fd1829
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/ContactoData.java
@@ -0,0 +1,63 @@
+/*
+* ContactoData.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 13/Out/2004
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.HashMap;
+import com.evolute.utils.jdo.*;
+
+public final class ContactoData extends JDOObject
+{
+ public static final String ID = "id";
+ public static final String NOME = "nome";
+ public static final String CARGO = "cargo";
+ public static final String TELEFONE = "telefone";
+ public static final String TELEMOVEL = "telemovel";
+ public static final String FAX = "fax";
+ public static final String EMAIL = "email";
+
+ public static final String FIELD_NAMES[] = new String[]{
+ NOME, CARGO, TELEFONE, TELEMOVEL, FAX, EMAIL, };
+
+
+ protected static final String ALL_FIELD_NAMES[] = new String[]{
+ ID, NOME, CARGO, TELEFONE, TELEMOVEL, FAX, EMAIL, };
+
+ private HashMap dataHash;
+
+ public ContactoData()
+ {
+ dataHash = new HashMap();
+ }
+
+ protected Object innerGet( String fieldName )
+ throws Exception
+ {
+ return dataHash.get( fieldName );
+ }
+
+ protected void innerSet( String fieldName, Object value )
+ throws Exception
+ {
+ dataHash.put( fieldName, value );
+ }
+
+ public String []getFieldNames()
+ {
+ return FIELD_NAMES;
+ }
+
+ protected String []getAllFieldNames()
+ {
+ return ALL_FIELD_NAMES;
+ }
+
+ public Class getInnerClass()
+ {
+ return Contacto.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/ContactoID.java b/trunk/SIPRPSoft/src/siprp/data/ContactoID.java
new file mode 100644
index 00000000..a142d5ef
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/ContactoID.java
@@ -0,0 +1,22 @@
+/*
+* ContactoID.java
+*
+* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 13/Out/2004
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import com.evolute.utils.jdo.jpox.*;
+
+public final class ContactoID extends IntegerID
+{
+ public ContactoID()
+ {
+ }
+
+ public ContactoID( String str )
+ {
+ super( str );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/DisableDeleteHandler.java b/trunk/SIPRPSoft/src/siprp/data/DisableDeleteHandler.java
new file mode 100644
index 00000000..d6f2650e
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/DisableDeleteHandler.java
@@ -0,0 +1,70 @@
+/*
+ * DeleteHandler.java
+ *
+ * Created on 11 de Outubro de 2004, 16:04
+ */
+
+package siprp.data;
+
+import com.evolute.utils.jdo.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class DisableDeleteHandler implements JDOOperationHandlerInterface
+{
+ public static final DisableDeleteHandler INSTANCE = new DisableDeleteHandler();
+
+ /** Creates a new instance of DeleteHandler */
+ public DisableDeleteHandler()
+ {
+ }
+
+ public boolean handle( JDOObject object, int operation, int moment )
+ throws Exception
+ {
+ if( !( object instanceof DisableDeleteable ) )
+ {
+ return false;
+ }
+ switch( operation )
+ {
+ case OP_SAVE:
+ return save( object, moment );
+
+ case OP_DELETE:
+ return delete( object, moment );
+
+ }
+ return false;
+ }
+
+ protected boolean save( JDOObject object, int moment )
+ throws Exception
+ {
+ if( moment != MOMENT_BEFORE )
+ {
+ return false;
+ }
+ String old = (String) object.get( DisableDeleteable.INACTIVO );
+ if( old == null )
+ {
+ object.set( DisableDeleteable.INACTIVO, "n" );
+ }
+ return true;
+ }
+
+ protected boolean delete( JDOObject object, int moment )
+ throws Exception
+ {
+ if( moment != MOMENT_INSTEAD )
+ {
+ return false;
+ }
+ object.set( DisableDeleteable.INACTIVO, "y" );
+ object.save();
+ return true;
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/DisableDeleteable.java b/trunk/SIPRPSoft/src/siprp/data/DisableDeleteable.java
new file mode 100644
index 00000000..b3ba4e52
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/DisableDeleteable.java
@@ -0,0 +1,16 @@
+/*
+ * DisableDeleteable.java
+ *
+ * Created on 11 de Outubro de 2004, 16:09
+ */
+
+package siprp.data;
+
+/**
+ *
+ * @author fpalma
+ */
+public interface DisableDeleteable
+{
+ public static final String INACTIVO = "inactivo";
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/Empresa.java b/trunk/SIPRPSoft/src/siprp/data/Empresa.java
new file mode 100644
index 00000000..7a64f2dc
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/Empresa.java
@@ -0,0 +1,747 @@
+/*
+* Empresa.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 17/Mai/2006
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.Date;
+import com.evolute.utils.jdo.*;
+
+public final class Empresa implements JDOInnerObject
+{
+ private Integer id;
+ private String designacao_social;
+ private String designacao_social_plain;
+ private Integer servico_saude_tipo;
+ private String servico_saude_designacao;
+ private Integer servico_higiene_tipo;
+ private String servico_higiene_designacao;
+ private String morada;
+ private String codigo_postal;
+ private String localidade;
+ private String distrito;
+ private String concelho;
+ private Date data_proposta;
+ private Date data_aceitacao;
+ private Date inicio_contrato;
+ private Integer duracao;
+ private Date data_cancelamento;
+ private String perfil_1;
+ private String perfil_2;
+ private Date data_envio_contrato;
+ private Date data_recepcao_contrato;
+ private Date data_envio_idict;
+ private Date data_relatorio_anual;
+ private String codigo_1;
+ private String codigo_2;
+ private String codigo_3;
+ private String cae;
+ private String actividade;
+ private String contribuinte;
+ private String seguranca_social;
+ private Double preco_higiene;
+ private Double preco_medicina;
+ private String periodicidade;
+ private Contacto contacto_1;
+ private Contacto contacto_2;
+ private Integer servicos;
+ private String inactivo;
+ private Date actualizacao;
+ private String a_consultas;
+ private String a_exames;
+ private String b_consultas;
+ private String b_exames;
+
+ public Empresa()
+ {
+ }
+
+ public Object getField( String fieldName )
+ {
+ if( fieldName == EmpresaData.ID )
+ {
+ return id;
+ }
+ else if( fieldName == EmpresaData.DESIGNACAO_SOCIAL )
+ {
+ return designacao_social;
+ }
+ else if( fieldName == EmpresaData.DESIGNACAO_SOCIAL_PLAIN )
+ {
+ return designacao_social_plain;
+ }
+ else if( fieldName == EmpresaData.SERVICO_SAUDE_TIPO )
+ {
+ return servico_saude_tipo;
+ }
+ else if( fieldName == EmpresaData.SERVICO_SAUDE_DESIGNACAO )
+ {
+ return servico_saude_designacao;
+ }
+ else if( fieldName == EmpresaData.SERVICO_HIGIENE_TIPO )
+ {
+ return servico_higiene_tipo;
+ }
+ else if( fieldName == EmpresaData.SERVICO_HIGIENE_DESIGNACAO )
+ {
+ return servico_higiene_designacao;
+ }
+ else if( fieldName == EmpresaData.MORADA )
+ {
+ return morada;
+ }
+ else if( fieldName == EmpresaData.CODIGO_POSTAL )
+ {
+ return codigo_postal;
+ }
+ else if( fieldName == EmpresaData.LOCALIDADE )
+ {
+ return localidade;
+ }
+ else if( fieldName == EmpresaData.DISTRITO )
+ {
+ return distrito;
+ }
+ else if( fieldName == EmpresaData.CONCELHO )
+ {
+ return concelho;
+ }
+ else if( fieldName == EmpresaData.DATA_PROPOSTA )
+ {
+ return data_proposta;
+ }
+ else if( fieldName == EmpresaData.DATA_ACEITACAO )
+ {
+ return data_aceitacao;
+ }
+ else if( fieldName == EmpresaData.INICIO_CONTRATO )
+ {
+ return inicio_contrato;
+ }
+ else if( fieldName == EmpresaData.DURACAO )
+ {
+ return duracao;
+ }
+ else if( fieldName == EmpresaData.DATA_CANCELAMENTO )
+ {
+ return data_cancelamento;
+ }
+ else if( fieldName == EmpresaData.PERFIL_1 )
+ {
+ return perfil_1;
+ }
+ else if( fieldName == EmpresaData.PERFIL_2 )
+ {
+ return perfil_2;
+ }
+ else if( fieldName == EmpresaData.DATA_ENVIO_CONTRATO )
+ {
+ return data_envio_contrato;
+ }
+ else if( fieldName == EmpresaData.DATA_RECEPCAO_CONTRATO )
+ {
+ return data_recepcao_contrato;
+ }
+ else if( fieldName == EmpresaData.DATA_ENVIO_IDICT )
+ {
+ return data_envio_idict;
+ }
+ else if( fieldName == EmpresaData.DATA_RELATORIO_ANUAL )
+ {
+ return data_relatorio_anual;
+ }
+ else if( fieldName == EmpresaData.CODIGO_1 )
+ {
+ return codigo_1;
+ }
+ else if( fieldName == EmpresaData.CODIGO_2 )
+ {
+ return codigo_2;
+ }
+ else if( fieldName == EmpresaData.CODIGO_3 )
+ {
+ return codigo_3;
+ }
+ else if( fieldName == EmpresaData.CAE )
+ {
+ return cae;
+ }
+ else if( fieldName == EmpresaData.ACTIVIDADE )
+ {
+ return actividade;
+ }
+ else if( fieldName == EmpresaData.CONTRIBUINTE )
+ {
+ return contribuinte;
+ }
+ else if( fieldName == EmpresaData.SEGURANCA_SOCIAL )
+ {
+ return seguranca_social;
+ }
+ else if( fieldName == EmpresaData.PRECO_HIGIENE )
+ {
+ return preco_higiene;
+ }
+ else if( fieldName == EmpresaData.PRECO_MEDICINA )
+ {
+ return preco_medicina;
+ }
+ else if( fieldName == EmpresaData.PERIODICIDADE )
+ {
+ return periodicidade;
+ }
+ else if( fieldName == EmpresaData.CONTACTO_1 )
+ {
+ return contacto_1;
+ }
+ else if( fieldName == EmpresaData.CONTACTO_2 )
+ {
+ return contacto_2;
+ }
+ else if( fieldName == EmpresaData.SERVICOS )
+ {
+ return servicos;
+ }
+ else if( fieldName == EmpresaData.INACTIVO )
+ {
+ return inactivo;
+ }
+ else if( fieldName == EmpresaData.ACTUALIZACAO )
+ {
+ return actualizacao;
+ }
+ else if( fieldName == EmpresaData.A_CONSULTAS )
+ {
+ return a_consultas;
+ }
+ else if( fieldName == EmpresaData.A_EXAMES )
+ {
+ return a_exames;
+ }
+ else if( fieldName == EmpresaData.B_CONSULTAS )
+ {
+ return b_consultas;
+ }
+ else if( fieldName == EmpresaData.B_EXAMES )
+ {
+ return b_exames;
+ }
+ else if( fieldName.equals( EmpresaData.ID ) )
+ {
+ return id;
+ }
+ else if( fieldName.equals( EmpresaData.DESIGNACAO_SOCIAL ) )
+ {
+ return designacao_social;
+ }
+ else if( fieldName.equals( EmpresaData.DESIGNACAO_SOCIAL_PLAIN ) )
+ {
+ return designacao_social_plain;
+ }
+ else if( fieldName.equals( EmpresaData.SERVICO_SAUDE_TIPO ) )
+ {
+ return servico_saude_tipo;
+ }
+ else if( fieldName.equals( EmpresaData.SERVICO_SAUDE_DESIGNACAO ) )
+ {
+ return servico_saude_designacao;
+ }
+ else if( fieldName.equals( EmpresaData.SERVICO_HIGIENE_TIPO ) )
+ {
+ return servico_higiene_tipo;
+ }
+ else if( fieldName.equals( EmpresaData.SERVICO_HIGIENE_DESIGNACAO ) )
+ {
+ return servico_higiene_designacao;
+ }
+ else if( fieldName.equals( EmpresaData.MORADA ) )
+ {
+ return morada;
+ }
+ else if( fieldName.equals( EmpresaData.CODIGO_POSTAL ) )
+ {
+ return codigo_postal;
+ }
+ else if( fieldName.equals( EmpresaData.LOCALIDADE ) )
+ {
+ return localidade;
+ }
+ else if( fieldName.equals( EmpresaData.DISTRITO ) )
+ {
+ return distrito;
+ }
+ else if( fieldName.equals( EmpresaData.CONCELHO ) )
+ {
+ return concelho;
+ }
+ else if( fieldName.equals( EmpresaData.DATA_PROPOSTA ) )
+ {
+ return data_proposta;
+ }
+ else if( fieldName.equals( EmpresaData.DATA_ACEITACAO ) )
+ {
+ return data_aceitacao;
+ }
+ else if( fieldName.equals( EmpresaData.INICIO_CONTRATO ) )
+ {
+ return inicio_contrato;
+ }
+ else if( fieldName.equals( EmpresaData.DURACAO ) )
+ {
+ return duracao;
+ }
+ else if( fieldName.equals( EmpresaData.DATA_CANCELAMENTO ) )
+ {
+ return data_cancelamento;
+ }
+ else if( fieldName.equals( EmpresaData.PERFIL_1 ) )
+ {
+ return perfil_1;
+ }
+ else if( fieldName.equals( EmpresaData.PERFIL_2 ) )
+ {
+ return perfil_2;
+ }
+ else if( fieldName.equals( EmpresaData.DATA_ENVIO_CONTRATO ) )
+ {
+ return data_envio_contrato;
+ }
+ else if( fieldName.equals( EmpresaData.DATA_RECEPCAO_CONTRATO ) )
+ {
+ return data_recepcao_contrato;
+ }
+ else if( fieldName.equals( EmpresaData.DATA_ENVIO_IDICT ) )
+ {
+ return data_envio_idict;
+ }
+ else if( fieldName.equals( EmpresaData.DATA_RELATORIO_ANUAL ) )
+ {
+ return data_relatorio_anual;
+ }
+ else if( fieldName.equals( EmpresaData.CODIGO_1 ) )
+ {
+ return codigo_1;
+ }
+ else if( fieldName.equals( EmpresaData.CODIGO_2 ) )
+ {
+ return codigo_2;
+ }
+ else if( fieldName.equals( EmpresaData.CODIGO_3 ) )
+ {
+ return codigo_3;
+ }
+ else if( fieldName.equals( EmpresaData.CAE ) )
+ {
+ return cae;
+ }
+ else if( fieldName.equals( EmpresaData.ACTIVIDADE ) )
+ {
+ return actividade;
+ }
+ else if( fieldName.equals( EmpresaData.CONTRIBUINTE ) )
+ {
+ return contribuinte;
+ }
+ else if( fieldName.equals( EmpresaData.SEGURANCA_SOCIAL ) )
+ {
+ return seguranca_social;
+ }
+ else if( fieldName.equals( EmpresaData.PRECO_HIGIENE ) )
+ {
+ return preco_higiene;
+ }
+ else if( fieldName.equals( EmpresaData.PRECO_MEDICINA ) )
+ {
+ return preco_medicina;
+ }
+ else if( fieldName.equals( EmpresaData.PERIODICIDADE ) )
+ {
+ return periodicidade;
+ }
+ else if( fieldName.equals( EmpresaData.CONTACTO_1 ) )
+ {
+ return contacto_1;
+ }
+ else if( fieldName.equals( EmpresaData.CONTACTO_2 ) )
+ {
+ return contacto_2;
+ }
+ else if( fieldName.equals( EmpresaData.SERVICOS ) )
+ {
+ return servicos;
+ }
+ else if( fieldName.equals( EmpresaData.INACTIVO ) )
+ {
+ return inactivo;
+ }
+ else if( fieldName.equals( EmpresaData.ACTUALIZACAO ) )
+ {
+ return actualizacao;
+ }
+ else if( fieldName.equals( EmpresaData.A_CONSULTAS ) )
+ {
+ return a_consultas;
+ }
+ else if( fieldName.equals( EmpresaData.A_EXAMES ) )
+ {
+ return a_exames;
+ }
+ else if( fieldName.equals( EmpresaData.B_CONSULTAS ) )
+ {
+ return b_consultas;
+ }
+ else if( fieldName.equals( EmpresaData.B_EXAMES ) )
+ {
+ return b_exames;
+ }
+ return null;
+ }
+
+ public void setField( String fieldName, Object value )
+ {
+ if( fieldName == EmpresaData.ID )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName == EmpresaData.DESIGNACAO_SOCIAL )
+ {
+ designacao_social = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.DESIGNACAO_SOCIAL_PLAIN )
+ {
+ designacao_social_plain = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.SERVICO_SAUDE_TIPO )
+ {
+ servico_saude_tipo = ( Integer ) value;
+ }
+ else if( fieldName == EmpresaData.SERVICO_SAUDE_DESIGNACAO )
+ {
+ servico_saude_designacao = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.SERVICO_HIGIENE_TIPO )
+ {
+ servico_higiene_tipo = ( Integer ) value;
+ }
+ else if( fieldName == EmpresaData.SERVICO_HIGIENE_DESIGNACAO )
+ {
+ servico_higiene_designacao = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.MORADA )
+ {
+ morada = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.CODIGO_POSTAL )
+ {
+ codigo_postal = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.LOCALIDADE )
+ {
+ localidade = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.DISTRITO )
+ {
+ distrito = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.CONCELHO )
+ {
+ concelho = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.DATA_PROPOSTA )
+ {
+ data_proposta = ( Date ) value;
+ }
+ else if( fieldName == EmpresaData.DATA_ACEITACAO )
+ {
+ data_aceitacao = ( Date ) value;
+ }
+ else if( fieldName == EmpresaData.INICIO_CONTRATO )
+ {
+ inicio_contrato = ( Date ) value;
+ }
+ else if( fieldName == EmpresaData.DURACAO )
+ {
+ duracao = ( Integer ) value;
+ }
+ else if( fieldName == EmpresaData.DATA_CANCELAMENTO )
+ {
+ data_cancelamento = ( Date ) value;
+ }
+ else if( fieldName == EmpresaData.PERFIL_1 )
+ {
+ perfil_1 = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.PERFIL_2 )
+ {
+ perfil_2 = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.DATA_ENVIO_CONTRATO )
+ {
+ data_envio_contrato = ( Date ) value;
+ }
+ else if( fieldName == EmpresaData.DATA_RECEPCAO_CONTRATO )
+ {
+ data_recepcao_contrato = ( Date ) value;
+ }
+ else if( fieldName == EmpresaData.DATA_ENVIO_IDICT )
+ {
+ data_envio_idict = ( Date ) value;
+ }
+ else if( fieldName == EmpresaData.DATA_RELATORIO_ANUAL )
+ {
+ data_relatorio_anual = ( Date ) value;
+ }
+ else if( fieldName == EmpresaData.CODIGO_1 )
+ {
+ codigo_1 = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.CODIGO_2 )
+ {
+ codigo_2 = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.CODIGO_3 )
+ {
+ codigo_3 = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.CAE )
+ {
+ cae = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.ACTIVIDADE )
+ {
+ actividade = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.CONTRIBUINTE )
+ {
+ contribuinte = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.SEGURANCA_SOCIAL )
+ {
+ seguranca_social = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.PRECO_HIGIENE )
+ {
+ preco_higiene = ( Double ) value;
+ }
+ else if( fieldName == EmpresaData.PRECO_MEDICINA )
+ {
+ preco_medicina = ( Double ) value;
+ }
+ else if( fieldName == EmpresaData.PERIODICIDADE )
+ {
+ periodicidade = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.CONTACTO_1 )
+ {
+ contacto_1 = ( Contacto ) value;
+ }
+ else if( fieldName == EmpresaData.CONTACTO_2 )
+ {
+ contacto_2 = ( Contacto ) value;
+ }
+ else if( fieldName == EmpresaData.SERVICOS )
+ {
+ servicos = ( Integer ) value;
+ }
+ else if( fieldName == EmpresaData.INACTIVO )
+ {
+ inactivo = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.ACTUALIZACAO )
+ {
+ actualizacao = ( Date ) value;
+ }
+ else if( fieldName == EmpresaData.A_CONSULTAS )
+ {
+ a_consultas = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.A_EXAMES )
+ {
+ a_exames = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.B_CONSULTAS )
+ {
+ b_consultas = ( String ) value;
+ }
+ else if( fieldName == EmpresaData.B_EXAMES )
+ {
+ b_exames = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.ID ) )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName.equals( EmpresaData.DESIGNACAO_SOCIAL ) )
+ {
+ designacao_social = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.DESIGNACAO_SOCIAL_PLAIN ) )
+ {
+ designacao_social_plain = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.SERVICO_SAUDE_TIPO ) )
+ {
+ servico_saude_tipo = ( Integer ) value;
+ }
+ else if( fieldName.equals( EmpresaData.SERVICO_SAUDE_DESIGNACAO ) )
+ {
+ servico_saude_designacao = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.SERVICO_HIGIENE_TIPO ) )
+ {
+ servico_higiene_tipo = ( Integer ) value;
+ }
+ else if( fieldName.equals( EmpresaData.SERVICO_HIGIENE_DESIGNACAO ) )
+ {
+ servico_higiene_designacao = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.MORADA ) )
+ {
+ morada = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.CODIGO_POSTAL ) )
+ {
+ codigo_postal = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.LOCALIDADE ) )
+ {
+ localidade = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.DISTRITO ) )
+ {
+ distrito = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.CONCELHO ) )
+ {
+ concelho = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.DATA_PROPOSTA ) )
+ {
+ data_proposta = ( Date ) value;
+ }
+ else if( fieldName.equals( EmpresaData.DATA_ACEITACAO ) )
+ {
+ data_aceitacao = ( Date ) value;
+ }
+ else if( fieldName.equals( EmpresaData.INICIO_CONTRATO ) )
+ {
+ inicio_contrato = ( Date ) value;
+ }
+ else if( fieldName.equals( EmpresaData.DURACAO ) )
+ {
+ duracao = ( Integer ) value;
+ }
+ else if( fieldName.equals( EmpresaData.DATA_CANCELAMENTO ) )
+ {
+ data_cancelamento = ( Date ) value;
+ }
+ else if( fieldName.equals( EmpresaData.PERFIL_1 ) )
+ {
+ perfil_1 = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.PERFIL_2 ) )
+ {
+ perfil_2 = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.DATA_ENVIO_CONTRATO ) )
+ {
+ data_envio_contrato = ( Date ) value;
+ }
+ else if( fieldName.equals( EmpresaData.DATA_RECEPCAO_CONTRATO ) )
+ {
+ data_recepcao_contrato = ( Date ) value;
+ }
+ else if( fieldName.equals( EmpresaData.DATA_ENVIO_IDICT ) )
+ {
+ data_envio_idict = ( Date ) value;
+ }
+ else if( fieldName.equals( EmpresaData.DATA_RELATORIO_ANUAL ) )
+ {
+ data_relatorio_anual = ( Date ) value;
+ }
+ else if( fieldName.equals( EmpresaData.CODIGO_1 ) )
+ {
+ codigo_1 = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.CODIGO_2 ) )
+ {
+ codigo_2 = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.CODIGO_3 ) )
+ {
+ codigo_3 = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.CAE ) )
+ {
+ cae = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.ACTIVIDADE ) )
+ {
+ actividade = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.CONTRIBUINTE ) )
+ {
+ contribuinte = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.SEGURANCA_SOCIAL ) )
+ {
+ seguranca_social = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.PRECO_HIGIENE ) )
+ {
+ preco_higiene = ( Double ) value;
+ }
+ else if( fieldName.equals( EmpresaData.PRECO_MEDICINA ) )
+ {
+ preco_medicina = ( Double ) value;
+ }
+ else if( fieldName.equals( EmpresaData.PERIODICIDADE ) )
+ {
+ periodicidade = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.CONTACTO_1 ) )
+ {
+ contacto_1 = ( Contacto ) value;
+ }
+ else if( fieldName.equals( EmpresaData.CONTACTO_2 ) )
+ {
+ contacto_2 = ( Contacto ) value;
+ }
+ else if( fieldName.equals( EmpresaData.SERVICOS ) )
+ {
+ servicos = ( Integer ) value;
+ }
+ else if( fieldName.equals( EmpresaData.INACTIVO ) )
+ {
+ inactivo = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.ACTUALIZACAO ) )
+ {
+ actualizacao = ( Date ) value;
+ }
+ else if( fieldName.equals( EmpresaData.A_CONSULTAS ) )
+ {
+ a_consultas = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.A_EXAMES ) )
+ {
+ a_exames = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.B_CONSULTAS ) )
+ {
+ b_consultas = ( String ) value;
+ }
+ else if( fieldName.equals( EmpresaData.B_EXAMES ) )
+ {
+ b_exames = ( String ) value;
+ }
+ }
+
+ public Class getOuterClass()
+ {
+ return EmpresaData.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/EmpresaData.java b/trunk/SIPRPSoft/src/siprp/data/EmpresaData.java
new file mode 100644
index 00000000..437a7f72
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/EmpresaData.java
@@ -0,0 +1,114 @@
+/*
+* EmpresaData.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 17/Mai/2006
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.HashMap;
+import com.evolute.utils.jdo.*;
+
+public final class EmpresaData extends JDOObject
+ implements DisableDeleteable, ActualizacaoSaveable
+{
+ public static final String ID = "id";
+ public static final String DESIGNACAO_SOCIAL = "designacao_social";
+ public static final String DESIGNACAO_SOCIAL_PLAIN = "designacao_social_plain";
+ public static final String SERVICO_SAUDE_TIPO = "servico_saude_tipo";
+ public static final String SERVICO_SAUDE_DESIGNACAO = "servico_saude_designacao";
+ public static final String SERVICO_HIGIENE_TIPO = "servico_higiene_tipo";
+ public static final String SERVICO_HIGIENE_DESIGNACAO = "servico_higiene_designacao";
+ public static final String MORADA = "morada";
+ public static final String CODIGO_POSTAL = "codigo_postal";
+ public static final String LOCALIDADE = "localidade";
+ public static final String DISTRITO = "distrito";
+ public static final String CONCELHO = "concelho";
+ public static final String DATA_PROPOSTA = "data_proposta";
+ public static final String DATA_ACEITACAO = "data_aceitacao";
+ public static final String INICIO_CONTRATO = "inicio_contrato";
+ public static final String DURACAO = "duracao";
+ public static final String DATA_CANCELAMENTO = "data_cancelamento";
+ public static final String PERFIL_1 = "perfil_1";
+ public static final String PERFIL_2 = "perfil_2";
+ public static final String DATA_ENVIO_CONTRATO = "data_envio_contrato";
+ public static final String DATA_RECEPCAO_CONTRATO = "data_recepcao_contrato";
+ public static final String DATA_ENVIO_IDICT = "data_envio_idict";
+ public static final String DATA_RELATORIO_ANUAL = "data_relatorio_anual";
+ public static final String CODIGO_1 = "codigo_1";
+ public static final String CODIGO_2 = "codigo_2";
+ public static final String CODIGO_3 = "codigo_3";
+ public static final String CAE = "cae";
+ public static final String ACTIVIDADE = "actividade";
+ public static final String CONTRIBUINTE = "contribuinte";
+ public static final String SEGURANCA_SOCIAL = "seguranca_social";
+ public static final String PRECO_HIGIENE = "preco_higiene";
+ public static final String PRECO_MEDICINA = "preco_medicina";
+ public static final String PERIODICIDADE = "periodicidade";
+ public static final String CONTACTO_1 = "contacto_1";
+ public static final String CONTACTO_2 = "contacto_2";
+ public static final String SERVICOS = "servicos";
+ public static final String INACTIVO = "inactivo";
+ public static final String ACTUALIZACAO = "actualizacao";
+ public static final String A_CONSULTAS = "a_consultas";
+ public static final String A_EXAMES = "a_exames";
+ public static final String B_CONSULTAS = "b_consultas";
+ public static final String B_EXAMES = "b_exames";
+
+ public static final String FIELD_NAMES[] = new String[]{
+ DESIGNACAO_SOCIAL, DESIGNACAO_SOCIAL_PLAIN, SERVICO_SAUDE_TIPO,
+ SERVICO_SAUDE_DESIGNACAO, SERVICO_HIGIENE_TIPO, SERVICO_HIGIENE_DESIGNACAO,
+ MORADA, CODIGO_POSTAL, LOCALIDADE, DISTRITO, CONCELHO, DATA_PROPOSTA,
+ DATA_ACEITACAO, INICIO_CONTRATO, DURACAO, DATA_CANCELAMENTO, PERFIL_1, PERFIL_2,
+ DATA_ENVIO_CONTRATO, DATA_RECEPCAO_CONTRATO, DATA_ENVIO_IDICT,
+ DATA_RELATORIO_ANUAL, CODIGO_1, CODIGO_2, CODIGO_3, CAE, ACTIVIDADE, CONTRIBUINTE,
+ SEGURANCA_SOCIAL, PRECO_HIGIENE, PRECO_MEDICINA, PERIODICIDADE, CONTACTO_1,
+ CONTACTO_2, SERVICOS, A_CONSULTAS, A_EXAMES, B_CONSULTAS, B_EXAMES, };
+
+
+ protected static final String ALL_FIELD_NAMES[] = new String[]{
+ ID, DESIGNACAO_SOCIAL, DESIGNACAO_SOCIAL_PLAIN, SERVICO_SAUDE_TIPO,
+ SERVICO_SAUDE_DESIGNACAO, SERVICO_HIGIENE_TIPO, SERVICO_HIGIENE_DESIGNACAO,
+ MORADA, CODIGO_POSTAL, LOCALIDADE, DISTRITO, CONCELHO, DATA_PROPOSTA,
+ DATA_ACEITACAO, INICIO_CONTRATO, DURACAO, DATA_CANCELAMENTO, PERFIL_1, PERFIL_2,
+ DATA_ENVIO_CONTRATO, DATA_RECEPCAO_CONTRATO, DATA_ENVIO_IDICT,
+ DATA_RELATORIO_ANUAL, CODIGO_1, CODIGO_2, CODIGO_3, CAE, ACTIVIDADE, CONTRIBUINTE,
+ SEGURANCA_SOCIAL, PRECO_HIGIENE, PRECO_MEDICINA, PERIODICIDADE, CONTACTO_1,
+ CONTACTO_2, SERVICOS, INACTIVO, ACTUALIZACAO, A_CONSULTAS, A_EXAMES, B_CONSULTAS,
+ B_EXAMES, };
+
+ private HashMap dataHash;
+
+ public EmpresaData()
+ {
+ dataHash = new HashMap();
+ }
+
+ protected Object innerGet( String fieldName )
+ throws Exception
+ {
+ return dataHash.get( fieldName );
+ }
+
+ protected void innerSet( String fieldName, Object value )
+ throws Exception
+ {
+ dataHash.put( fieldName, value );
+ }
+
+ public String []getFieldNames()
+ {
+ return FIELD_NAMES;
+ }
+
+ protected String []getAllFieldNames()
+ {
+ return ALL_FIELD_NAMES;
+ }
+
+ public Class getInnerClass()
+ {
+ return Empresa.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/EmpresaID.java b/trunk/SIPRPSoft/src/siprp/data/EmpresaID.java
new file mode 100644
index 00000000..ddee27c0
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/EmpresaID.java
@@ -0,0 +1,25 @@
+/*
+* EmpresaID.java
+*
+* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 17/Mai/2006
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.io.*;
+
+import com.evolute.utils.jdo.jpox.*;
+
+public final class EmpresaID extends IntegerID
+ implements Serializable
+{
+ public EmpresaID()
+ {
+ }
+
+ public EmpresaID( String str )
+ {
+ super( str );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/Estabelecimento.java b/trunk/SIPRPSoft/src/siprp/data/Estabelecimento.java
new file mode 100644
index 00000000..e14be8da
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/Estabelecimento.java
@@ -0,0 +1,220 @@
+/*
+* Estabelecimento.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 24/Nov/2005
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.Date;
+import com.evolute.utils.jdo.*;
+
+public final class Estabelecimento implements JDOInnerObject
+{
+ private Integer id;
+ private String nome;
+ private String nome_plain;
+ private String morada;
+ private String codigo_postal;
+ private String localidade;
+ private String historico;
+ private Empresa empresa;
+ private Contacto contacto;
+ private String inactivo;
+ private Date actualizacao;
+
+ public Estabelecimento()
+ {
+ }
+
+ public Object getField( String fieldName )
+ {
+ if( fieldName == EstabelecimentoData.ID )
+ {
+ return id;
+ }
+ else if( fieldName == EstabelecimentoData.NOME )
+ {
+ return nome;
+ }
+ else if( fieldName == EstabelecimentoData.NOME_PLAIN )
+ {
+ return nome_plain;
+ }
+ else if( fieldName == EstabelecimentoData.MORADA )
+ {
+ return morada;
+ }
+ else if( fieldName == EstabelecimentoData.CODIGO_POSTAL )
+ {
+ return codigo_postal;
+ }
+ else if( fieldName == EstabelecimentoData.LOCALIDADE )
+ {
+ return localidade;
+ }
+ else if( fieldName == EstabelecimentoData.HISTORICO )
+ {
+ return historico;
+ }
+ else if( fieldName == EstabelecimentoData.EMPRESA )
+ {
+ return empresa;
+ }
+ else if( fieldName == EstabelecimentoData.CONTACTO )
+ {
+ return contacto;
+ }
+ else if( fieldName == EstabelecimentoData.INACTIVO )
+ {
+ return inactivo;
+ }
+ else if( fieldName == EstabelecimentoData.ACTUALIZACAO )
+ {
+ return actualizacao;
+ }
+ else if( fieldName.equals( EstabelecimentoData.ID ) )
+ {
+ return id;
+ }
+ else if( fieldName.equals( EstabelecimentoData.NOME ) )
+ {
+ return nome;
+ }
+ else if( fieldName.equals( EstabelecimentoData.NOME_PLAIN ) )
+ {
+ return nome_plain;
+ }
+ else if( fieldName.equals( EstabelecimentoData.MORADA ) )
+ {
+ return morada;
+ }
+ else if( fieldName.equals( EstabelecimentoData.CODIGO_POSTAL ) )
+ {
+ return codigo_postal;
+ }
+ else if( fieldName.equals( EstabelecimentoData.LOCALIDADE ) )
+ {
+ return localidade;
+ }
+ else if( fieldName.equals( EstabelecimentoData.HISTORICO ) )
+ {
+ return historico;
+ }
+ else if( fieldName.equals( EstabelecimentoData.EMPRESA ) )
+ {
+ return empresa;
+ }
+ else if( fieldName.equals( EstabelecimentoData.CONTACTO ) )
+ {
+ return contacto;
+ }
+ else if( fieldName.equals( EstabelecimentoData.INACTIVO ) )
+ {
+ return inactivo;
+ }
+ else if( fieldName.equals( EstabelecimentoData.ACTUALIZACAO ) )
+ {
+ return actualizacao;
+ }
+ return null;
+ }
+
+ public void setField( String fieldName, Object value )
+ {
+ if( fieldName == EstabelecimentoData.ID )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName == EstabelecimentoData.NOME )
+ {
+ nome = ( String ) value;
+ }
+ else if( fieldName == EstabelecimentoData.NOME_PLAIN )
+ {
+ nome_plain = ( String ) value;
+ }
+ else if( fieldName == EstabelecimentoData.MORADA )
+ {
+ morada = ( String ) value;
+ }
+ else if( fieldName == EstabelecimentoData.CODIGO_POSTAL )
+ {
+ codigo_postal = ( String ) value;
+ }
+ else if( fieldName == EstabelecimentoData.LOCALIDADE )
+ {
+ localidade = ( String ) value;
+ }
+ else if( fieldName == EstabelecimentoData.HISTORICO )
+ {
+ historico = ( String ) value;
+ }
+ else if( fieldName == EstabelecimentoData.EMPRESA )
+ {
+ empresa = ( Empresa ) value;
+ }
+ else if( fieldName == EstabelecimentoData.CONTACTO )
+ {
+ contacto = ( Contacto ) value;
+ }
+ else if( fieldName == EstabelecimentoData.INACTIVO )
+ {
+ inactivo = ( String ) value;
+ }
+ else if( fieldName == EstabelecimentoData.ACTUALIZACAO )
+ {
+ actualizacao = ( Date ) value;
+ }
+ else if( fieldName.equals( EstabelecimentoData.ID ) )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName.equals( EstabelecimentoData.NOME ) )
+ {
+ nome = ( String ) value;
+ }
+ else if( fieldName.equals( EstabelecimentoData.NOME_PLAIN ) )
+ {
+ nome_plain = ( String ) value;
+ }
+ else if( fieldName.equals( EstabelecimentoData.MORADA ) )
+ {
+ morada = ( String ) value;
+ }
+ else if( fieldName.equals( EstabelecimentoData.CODIGO_POSTAL ) )
+ {
+ codigo_postal = ( String ) value;
+ }
+ else if( fieldName.equals( EstabelecimentoData.LOCALIDADE ) )
+ {
+ localidade = ( String ) value;
+ }
+ else if( fieldName.equals( EstabelecimentoData.HISTORICO ) )
+ {
+ historico = ( String ) value;
+ }
+ else if( fieldName.equals( EstabelecimentoData.EMPRESA ) )
+ {
+ empresa = ( Empresa ) value;
+ }
+ else if( fieldName.equals( EstabelecimentoData.CONTACTO ) )
+ {
+ contacto = ( Contacto ) value;
+ }
+ else if( fieldName.equals( EstabelecimentoData.INACTIVO ) )
+ {
+ inactivo = ( String ) value;
+ }
+ else if( fieldName.equals( EstabelecimentoData.ACTUALIZACAO ) )
+ {
+ actualizacao = ( Date ) value;
+ }
+ }
+
+ public Class getOuterClass()
+ {
+ return EstabelecimentoData.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/EstabelecimentoData.java b/trunk/SIPRPSoft/src/siprp/data/EstabelecimentoData.java
new file mode 100644
index 00000000..e11cfb6b
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/EstabelecimentoData.java
@@ -0,0 +1,69 @@
+/*
+* EstabelecimentoData.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 24/Nov/2005
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.HashMap;
+import com.evolute.utils.jdo.*;
+
+public final class EstabelecimentoData extends JDOObject
+ implements DisableDeleteable, ActualizacaoSaveable
+{
+ public static final String ID = "id";
+ public static final String NOME = "nome";
+ public static final String NOME_PLAIN = "nome_plain";
+ public static final String MORADA = "morada";
+ public static final String CODIGO_POSTAL = "codigo_postal";
+ public static final String LOCALIDADE = "localidade";
+ public static final String HISTORICO = "historico";
+ public static final String EMPRESA = "empresa";
+ public static final String CONTACTO = "contacto";
+ public static final String INACTIVO = "inactivo";
+ public static final String ACTUALIZACAO = "actualizacao";
+
+ public static final String FIELD_NAMES[] = new String[]{
+ NOME, NOME_PLAIN, MORADA, CODIGO_POSTAL, LOCALIDADE, HISTORICO, EMPRESA, CONTACTO, };
+
+
+ protected static final String ALL_FIELD_NAMES[] = new String[]{
+ ID, NOME, NOME_PLAIN, MORADA, CODIGO_POSTAL, LOCALIDADE, HISTORICO, EMPRESA, CONTACTO,
+ INACTIVO, ACTUALIZACAO, };
+
+ private HashMap dataHash;
+
+ public EstabelecimentoData()
+ {
+ dataHash = new HashMap();
+ }
+
+ protected Object innerGet( String fieldName )
+ throws Exception
+ {
+ return dataHash.get( fieldName );
+ }
+
+ protected void innerSet( String fieldName, Object value )
+ throws Exception
+ {
+ dataHash.put( fieldName, value );
+ }
+
+ public String []getFieldNames()
+ {
+ return FIELD_NAMES;
+ }
+
+ protected String []getAllFieldNames()
+ {
+ return ALL_FIELD_NAMES;
+ }
+
+ public Class getInnerClass()
+ {
+ return Estabelecimento.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/EstabelecimentoID.java b/trunk/SIPRPSoft/src/siprp/data/EstabelecimentoID.java
new file mode 100644
index 00000000..3824759b
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/EstabelecimentoID.java
@@ -0,0 +1,25 @@
+/*
+* EstabelecimentoID.java
+*
+* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 24/Nov/2005
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.io.*;
+
+import com.evolute.utils.jdo.jpox.*;
+
+public final class EstabelecimentoID extends IntegerID
+ implements Serializable
+{
+ public EstabelecimentoID()
+ {
+ }
+
+ public EstabelecimentoID( String str )
+ {
+ super( str );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/Etiqueta.java b/trunk/SIPRPSoft/src/siprp/data/Etiqueta.java
new file mode 100644
index 00000000..7a35bb38
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/Etiqueta.java
@@ -0,0 +1,270 @@
+/*
+* Etiqueta.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 27/Fev/2006
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import com.evolute.utils.jdo.*;
+
+public final class Etiqueta implements JDOInnerObject
+{
+ private Integer id;
+ private String descricao;
+ private String descricao_plain;
+ private Double altura;
+ private Double largura;
+ private Double margem_esquerda;
+ private Double margem_cima;
+ private Integer colunas;
+ private Integer linhas;
+ private String continua;
+ private Double altura_folha;
+ private Double largura_folha;
+ private Double margem_vertical_folha;
+ private Double margem_horizontal_folha;
+
+ public Etiqueta()
+ {
+ }
+
+ public Object getField( String fieldName )
+ {
+ if( fieldName == EtiquetaData.ID )
+ {
+ return id;
+ }
+ else if( fieldName == EtiquetaData.DESCRICAO )
+ {
+ return descricao;
+ }
+ else if( fieldName == EtiquetaData.DESCRICAO_PLAIN )
+ {
+ return descricao_plain;
+ }
+ else if( fieldName == EtiquetaData.ALTURA )
+ {
+ return altura;
+ }
+ else if( fieldName == EtiquetaData.LARGURA )
+ {
+ return largura;
+ }
+ else if( fieldName == EtiquetaData.MARGEM_ESQUERDA )
+ {
+ return margem_esquerda;
+ }
+ else if( fieldName == EtiquetaData.MARGEM_CIMA )
+ {
+ return margem_cima;
+ }
+ else if( fieldName == EtiquetaData.COLUNAS )
+ {
+ return colunas;
+ }
+ else if( fieldName == EtiquetaData.LINHAS )
+ {
+ return linhas;
+ }
+ else if( fieldName == EtiquetaData.CONTINUA )
+ {
+ return continua;
+ }
+ else if( fieldName == EtiquetaData.ALTURA_FOLHA )
+ {
+ return altura_folha;
+ }
+ else if( fieldName == EtiquetaData.LARGURA_FOLHA )
+ {
+ return largura_folha;
+ }
+ else if( fieldName == EtiquetaData.MARGEM_VERTICAL_FOLHA )
+ {
+ return margem_vertical_folha;
+ }
+ else if( fieldName == EtiquetaData.MARGEM_HORIZONTAL_FOLHA )
+ {
+ return margem_horizontal_folha;
+ }
+ else if( fieldName.equals( EtiquetaData.ID ) )
+ {
+ return id;
+ }
+ else if( fieldName.equals( EtiquetaData.DESCRICAO ) )
+ {
+ return descricao;
+ }
+ else if( fieldName.equals( EtiquetaData.DESCRICAO_PLAIN ) )
+ {
+ return descricao_plain;
+ }
+ else if( fieldName.equals( EtiquetaData.ALTURA ) )
+ {
+ return altura;
+ }
+ else if( fieldName.equals( EtiquetaData.LARGURA ) )
+ {
+ return largura;
+ }
+ else if( fieldName.equals( EtiquetaData.MARGEM_ESQUERDA ) )
+ {
+ return margem_esquerda;
+ }
+ else if( fieldName.equals( EtiquetaData.MARGEM_CIMA ) )
+ {
+ return margem_cima;
+ }
+ else if( fieldName.equals( EtiquetaData.COLUNAS ) )
+ {
+ return colunas;
+ }
+ else if( fieldName.equals( EtiquetaData.LINHAS ) )
+ {
+ return linhas;
+ }
+ else if( fieldName.equals( EtiquetaData.CONTINUA ) )
+ {
+ return continua;
+ }
+ else if( fieldName.equals( EtiquetaData.ALTURA_FOLHA ) )
+ {
+ return altura_folha;
+ }
+ else if( fieldName.equals( EtiquetaData.LARGURA_FOLHA ) )
+ {
+ return largura_folha;
+ }
+ else if( fieldName.equals( EtiquetaData.MARGEM_VERTICAL_FOLHA ) )
+ {
+ return margem_vertical_folha;
+ }
+ else if( fieldName.equals( EtiquetaData.MARGEM_HORIZONTAL_FOLHA ) )
+ {
+ return margem_horizontal_folha;
+ }
+ return null;
+ }
+
+ public void setField( String fieldName, Object value )
+ {
+ if( fieldName == EtiquetaData.ID )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName == EtiquetaData.DESCRICAO )
+ {
+ descricao = ( String ) value;
+ }
+ else if( fieldName == EtiquetaData.DESCRICAO_PLAIN )
+ {
+ descricao_plain = ( String ) value;
+ }
+ else if( fieldName == EtiquetaData.ALTURA )
+ {
+ altura = ( Double ) value;
+ }
+ else if( fieldName == EtiquetaData.LARGURA )
+ {
+ largura = ( Double ) value;
+ }
+ else if( fieldName == EtiquetaData.MARGEM_ESQUERDA )
+ {
+ margem_esquerda = ( Double ) value;
+ }
+ else if( fieldName == EtiquetaData.MARGEM_CIMA )
+ {
+ margem_cima = ( Double ) value;
+ }
+ else if( fieldName == EtiquetaData.COLUNAS )
+ {
+ colunas = ( Integer ) value;
+ }
+ else if( fieldName == EtiquetaData.LINHAS )
+ {
+ linhas = ( Integer ) value;
+ }
+ else if( fieldName == EtiquetaData.CONTINUA )
+ {
+ continua = ( String ) value;
+ }
+ else if( fieldName == EtiquetaData.ALTURA_FOLHA )
+ {
+ altura_folha = ( Double ) value;
+ }
+ else if( fieldName == EtiquetaData.LARGURA_FOLHA )
+ {
+ largura_folha = ( Double ) value;
+ }
+ else if( fieldName == EtiquetaData.MARGEM_VERTICAL_FOLHA )
+ {
+ margem_vertical_folha = ( Double ) value;
+ }
+ else if( fieldName == EtiquetaData.MARGEM_HORIZONTAL_FOLHA )
+ {
+ margem_horizontal_folha = ( Double ) value;
+ }
+ else if( fieldName.equals( EtiquetaData.ID ) )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName.equals( EtiquetaData.DESCRICAO ) )
+ {
+ descricao = ( String ) value;
+ }
+ else if( fieldName.equals( EtiquetaData.DESCRICAO_PLAIN ) )
+ {
+ descricao_plain = ( String ) value;
+ }
+ else if( fieldName.equals( EtiquetaData.ALTURA ) )
+ {
+ altura = ( Double ) value;
+ }
+ else if( fieldName.equals( EtiquetaData.LARGURA ) )
+ {
+ largura = ( Double ) value;
+ }
+ else if( fieldName.equals( EtiquetaData.MARGEM_ESQUERDA ) )
+ {
+ margem_esquerda = ( Double ) value;
+ }
+ else if( fieldName.equals( EtiquetaData.MARGEM_CIMA ) )
+ {
+ margem_cima = ( Double ) value;
+ }
+ else if( fieldName.equals( EtiquetaData.COLUNAS ) )
+ {
+ colunas = ( Integer ) value;
+ }
+ else if( fieldName.equals( EtiquetaData.LINHAS ) )
+ {
+ linhas = ( Integer ) value;
+ }
+ else if( fieldName.equals( EtiquetaData.CONTINUA ) )
+ {
+ continua = ( String ) value;
+ }
+ else if( fieldName.equals( EtiquetaData.ALTURA_FOLHA ) )
+ {
+ altura_folha = ( Double ) value;
+ }
+ else if( fieldName.equals( EtiquetaData.LARGURA_FOLHA ) )
+ {
+ largura_folha = ( Double ) value;
+ }
+ else if( fieldName.equals( EtiquetaData.MARGEM_VERTICAL_FOLHA ) )
+ {
+ margem_vertical_folha = ( Double ) value;
+ }
+ else if( fieldName.equals( EtiquetaData.MARGEM_HORIZONTAL_FOLHA ) )
+ {
+ margem_horizontal_folha = ( Double ) value;
+ }
+ }
+
+ public Class getOuterClass()
+ {
+ return EtiquetaData.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/EtiquetaData.java b/trunk/SIPRPSoft/src/siprp/data/EtiquetaData.java
new file mode 100644
index 00000000..8d244d95
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/EtiquetaData.java
@@ -0,0 +1,74 @@
+/*
+* EtiquetaData.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 27/Fev/2006
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.HashMap;
+import com.evolute.utils.jdo.*;
+
+public final class EtiquetaData extends JDOObject
+{
+ public static final String ID = "id";
+ public static final String DESCRICAO = "descricao";
+ public static final String DESCRICAO_PLAIN = "descricao_plain";
+ public static final String ALTURA = "altura";
+ public static final String LARGURA = "largura";
+ public static final String MARGEM_ESQUERDA = "margem_esquerda";
+ public static final String MARGEM_CIMA = "margem_cima";
+ public static final String COLUNAS = "colunas";
+ public static final String LINHAS = "linhas";
+ public static final String CONTINUA = "continua";
+ public static final String ALTURA_FOLHA = "altura_folha";
+ public static final String LARGURA_FOLHA = "largura_folha";
+ public static final String MARGEM_VERTICAL_FOLHA = "margem_vertical_folha";
+ public static final String MARGEM_HORIZONTAL_FOLHA = "margem_horizontal_folha";
+
+ public static final String FIELD_NAMES[] = new String[]{
+ DESCRICAO, DESCRICAO_PLAIN, ALTURA, LARGURA, MARGEM_ESQUERDA, MARGEM_CIMA, COLUNAS,
+ LINHAS, CONTINUA, ALTURA_FOLHA, LARGURA_FOLHA, MARGEM_VERTICAL_FOLHA,
+ MARGEM_HORIZONTAL_FOLHA, };
+
+
+ protected static final String ALL_FIELD_NAMES[] = new String[]{
+ ID, DESCRICAO, DESCRICAO_PLAIN, ALTURA, LARGURA, MARGEM_ESQUERDA, MARGEM_CIMA,
+ COLUNAS, LINHAS, CONTINUA, ALTURA_FOLHA, LARGURA_FOLHA, MARGEM_VERTICAL_FOLHA,
+ MARGEM_HORIZONTAL_FOLHA, };
+
+ private HashMap dataHash;
+
+ public EtiquetaData()
+ {
+ dataHash = new HashMap();
+ }
+
+ protected Object innerGet( String fieldName )
+ throws Exception
+ {
+ return dataHash.get( fieldName );
+ }
+
+ protected void innerSet( String fieldName, Object value )
+ throws Exception
+ {
+ dataHash.put( fieldName, value );
+ }
+
+ public String []getFieldNames()
+ {
+ return FIELD_NAMES;
+ }
+
+ protected String []getAllFieldNames()
+ {
+ return ALL_FIELD_NAMES;
+ }
+
+ public Class getInnerClass()
+ {
+ return Etiqueta.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/EtiquetaID.java b/trunk/SIPRPSoft/src/siprp/data/EtiquetaID.java
new file mode 100644
index 00000000..d014ef55
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/EtiquetaID.java
@@ -0,0 +1,25 @@
+/*
+* EtiquetaID.java
+*
+* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 27/Fev/2006
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.io.*;
+
+import com.evolute.utils.jdo.jpox.*;
+
+public final class EtiquetaID extends IntegerID
+ implements Serializable
+{
+ public EtiquetaID()
+ {
+ }
+
+ public EtiquetaID( String str )
+ {
+ super( str );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/Exame.java b/trunk/SIPRPSoft/src/siprp/data/Exame.java
new file mode 100644
index 00000000..58ade49b
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/Exame.java
@@ -0,0 +1,322 @@
+/*
+* Exame.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 28/Jan/2005
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.Date;
+import com.evolute.utils.jdo.*;
+
+public final class Exame implements JDOInnerObject
+{
+ private Integer id;
+ private Date data;
+ private Integer tipo;
+ private Integer ocasional;
+ private String outro_tipo;
+ private Integer resultado;
+ private String outra_funcao_1;
+ private String outra_funcao_2;
+ private String outra_funcao_3;
+ private String outra_funcao_4;
+ private Date proximo_exame;
+ private String outras_recomendacoes;
+ private Trabalhador trabalhador;
+ private Medico medico;
+ private byte[] pdf;
+ private byte[] fo;
+ private String inactivo;
+
+ public Exame()
+ {
+ }
+
+ public Object getField( String fieldName )
+ {
+ if( fieldName == ExameData.ID )
+ {
+ return id;
+ }
+ else if( fieldName == ExameData.DATA )
+ {
+ return data;
+ }
+ else if( fieldName == ExameData.TIPO )
+ {
+ return tipo;
+ }
+ else if( fieldName == ExameData.OCASIONAL )
+ {
+ return ocasional;
+ }
+ else if( fieldName == ExameData.OUTRO_TIPO )
+ {
+ return outro_tipo;
+ }
+ else if( fieldName == ExameData.RESULTADO )
+ {
+ return resultado;
+ }
+ else if( fieldName == ExameData.OUTRA_FUNCAO_1 )
+ {
+ return outra_funcao_1;
+ }
+ else if( fieldName == ExameData.OUTRA_FUNCAO_2 )
+ {
+ return outra_funcao_2;
+ }
+ else if( fieldName == ExameData.OUTRA_FUNCAO_3 )
+ {
+ return outra_funcao_3;
+ }
+ else if( fieldName == ExameData.OUTRA_FUNCAO_4 )
+ {
+ return outra_funcao_4;
+ }
+ else if( fieldName == ExameData.PROXIMO_EXAME )
+ {
+ return proximo_exame;
+ }
+ else if( fieldName == ExameData.OUTRAS_RECOMENDACOES )
+ {
+ return outras_recomendacoes;
+ }
+ else if( fieldName == ExameData.TRABALHADOR )
+ {
+ return trabalhador;
+ }
+ else if( fieldName == ExameData.MEDICO )
+ {
+ return medico;
+ }
+ else if( fieldName == ExameData.PDF )
+ {
+ return pdf;
+ }
+ else if( fieldName == ExameData.FO )
+ {
+ return fo;
+ }
+ else if( fieldName == ExameData.INACTIVO )
+ {
+ return inactivo;
+ }
+ else if( fieldName.equals( ExameData.ID ) )
+ {
+ return id;
+ }
+ else if( fieldName.equals( ExameData.DATA ) )
+ {
+ return data;
+ }
+ else if( fieldName.equals( ExameData.TIPO ) )
+ {
+ return tipo;
+ }
+ else if( fieldName.equals( ExameData.OCASIONAL ) )
+ {
+ return ocasional;
+ }
+ else if( fieldName.equals( ExameData.OUTRO_TIPO ) )
+ {
+ return outro_tipo;
+ }
+ else if( fieldName.equals( ExameData.RESULTADO ) )
+ {
+ return resultado;
+ }
+ else if( fieldName.equals( ExameData.OUTRA_FUNCAO_1 ) )
+ {
+ return outra_funcao_1;
+ }
+ else if( fieldName.equals( ExameData.OUTRA_FUNCAO_2 ) )
+ {
+ return outra_funcao_2;
+ }
+ else if( fieldName.equals( ExameData.OUTRA_FUNCAO_3 ) )
+ {
+ return outra_funcao_3;
+ }
+ else if( fieldName.equals( ExameData.OUTRA_FUNCAO_4 ) )
+ {
+ return outra_funcao_4;
+ }
+ else if( fieldName.equals( ExameData.PROXIMO_EXAME ) )
+ {
+ return proximo_exame;
+ }
+ else if( fieldName.equals( ExameData.OUTRAS_RECOMENDACOES ) )
+ {
+ return outras_recomendacoes;
+ }
+ else if( fieldName.equals( ExameData.TRABALHADOR ) )
+ {
+ return trabalhador;
+ }
+ else if( fieldName.equals( ExameData.MEDICO ) )
+ {
+ return medico;
+ }
+ else if( fieldName.equals( ExameData.PDF ) )
+ {
+ return pdf;
+ }
+ else if( fieldName.equals( ExameData.FO ) )
+ {
+ return fo;
+ }
+ else if( fieldName.equals( ExameData.INACTIVO ) )
+ {
+ return inactivo;
+ }
+ return null;
+ }
+
+ public void setField( String fieldName, Object value )
+ {
+ if( fieldName == ExameData.ID )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName == ExameData.DATA )
+ {
+ data = ( Date ) value;
+ }
+ else if( fieldName == ExameData.TIPO )
+ {
+ tipo = ( Integer ) value;
+ }
+ else if( fieldName == ExameData.OCASIONAL )
+ {
+ ocasional = ( Integer ) value;
+ }
+ else if( fieldName == ExameData.OUTRO_TIPO )
+ {
+ outro_tipo = ( String ) value;
+ }
+ else if( fieldName == ExameData.RESULTADO )
+ {
+ resultado = ( Integer ) value;
+ }
+ else if( fieldName == ExameData.OUTRA_FUNCAO_1 )
+ {
+ outra_funcao_1 = ( String ) value;
+ }
+ else if( fieldName == ExameData.OUTRA_FUNCAO_2 )
+ {
+ outra_funcao_2 = ( String ) value;
+ }
+ else if( fieldName == ExameData.OUTRA_FUNCAO_3 )
+ {
+ outra_funcao_3 = ( String ) value;
+ }
+ else if( fieldName == ExameData.OUTRA_FUNCAO_4 )
+ {
+ outra_funcao_4 = ( String ) value;
+ }
+ else if( fieldName == ExameData.PROXIMO_EXAME )
+ {
+ proximo_exame = ( Date ) value;
+ }
+ else if( fieldName == ExameData.OUTRAS_RECOMENDACOES )
+ {
+ outras_recomendacoes = ( String ) value;
+ }
+ else if( fieldName == ExameData.TRABALHADOR )
+ {
+ trabalhador = ( Trabalhador ) value;
+ }
+ else if( fieldName == ExameData.MEDICO )
+ {
+ medico = ( Medico ) value;
+ }
+ else if( fieldName == ExameData.PDF )
+ {
+ pdf = ( byte[] ) value;
+ }
+ else if( fieldName == ExameData.FO )
+ {
+ fo = ( byte[] ) value;
+ }
+ else if( fieldName == ExameData.INACTIVO )
+ {
+ inactivo = ( String ) value;
+ }
+ else if( fieldName.equals( ExameData.ID ) )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName.equals( ExameData.DATA ) )
+ {
+ data = ( Date ) value;
+ }
+ else if( fieldName.equals( ExameData.TIPO ) )
+ {
+ tipo = ( Integer ) value;
+ }
+ else if( fieldName.equals( ExameData.OCASIONAL ) )
+ {
+ ocasional = ( Integer ) value;
+ }
+ else if( fieldName.equals( ExameData.OUTRO_TIPO ) )
+ {
+ outro_tipo = ( String ) value;
+ }
+ else if( fieldName.equals( ExameData.RESULTADO ) )
+ {
+ resultado = ( Integer ) value;
+ }
+ else if( fieldName.equals( ExameData.OUTRA_FUNCAO_1 ) )
+ {
+ outra_funcao_1 = ( String ) value;
+ }
+ else if( fieldName.equals( ExameData.OUTRA_FUNCAO_2 ) )
+ {
+ outra_funcao_2 = ( String ) value;
+ }
+ else if( fieldName.equals( ExameData.OUTRA_FUNCAO_3 ) )
+ {
+ outra_funcao_3 = ( String ) value;
+ }
+ else if( fieldName.equals( ExameData.OUTRA_FUNCAO_4 ) )
+ {
+ outra_funcao_4 = ( String ) value;
+ }
+ else if( fieldName.equals( ExameData.PROXIMO_EXAME ) )
+ {
+ proximo_exame = ( Date ) value;
+ }
+ else if( fieldName.equals( ExameData.OUTRAS_RECOMENDACOES ) )
+ {
+ outras_recomendacoes = ( String ) value;
+ }
+ else if( fieldName.equals( ExameData.TRABALHADOR ) )
+ {
+ trabalhador = ( Trabalhador ) value;
+ }
+ else if( fieldName.equals( ExameData.MEDICO ) )
+ {
+ medico = ( Medico ) value;
+ }
+ else if( fieldName.equals( ExameData.PDF ) )
+ {
+ pdf = ( byte[] ) value;
+ }
+ else if( fieldName.equals( ExameData.FO ) )
+ {
+ fo = ( byte[] ) value;
+ }
+ else if( fieldName.equals( ExameData.INACTIVO ) )
+ {
+ inactivo = ( String ) value;
+ }
+ }
+
+ public Class getOuterClass()
+ {
+ return ExameData.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/ExameData.java b/trunk/SIPRPSoft/src/siprp/data/ExameData.java
new file mode 100644
index 00000000..ffc17877
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/ExameData.java
@@ -0,0 +1,78 @@
+/*
+* ExameData.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 28/Jan/2005
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.HashMap;
+import com.evolute.utils.jdo.*;
+
+public final class ExameData extends JDOObject
+ implements DisableDeleteable
+{
+ public static final String ID = "id";
+ public static final String DATA = "data";
+ public static final String TIPO = "tipo";
+ public static final String OCASIONAL = "ocasional";
+ public static final String OUTRO_TIPO = "outro_tipo";
+ public static final String RESULTADO = "resultado";
+ public static final String OUTRA_FUNCAO_1 = "outra_funcao_1";
+ public static final String OUTRA_FUNCAO_2 = "outra_funcao_2";
+ public static final String OUTRA_FUNCAO_3 = "outra_funcao_3";
+ public static final String OUTRA_FUNCAO_4 = "outra_funcao_4";
+ public static final String PROXIMO_EXAME = "proximo_exame";
+ public static final String OUTRAS_RECOMENDACOES = "outras_recomendacoes";
+ public static final String TRABALHADOR = "trabalhador";
+ public static final String MEDICO = "medico";
+ public static final String PDF = "pdf";
+ public static final String FO = "fo";
+ public static final String INACTIVO = "inactivo";
+
+ public static final String FIELD_NAMES[] = new String[]{
+ DATA, TIPO, OCASIONAL, OUTRO_TIPO, RESULTADO, OUTRA_FUNCAO_1, OUTRA_FUNCAO_2,
+ OUTRA_FUNCAO_3, OUTRA_FUNCAO_4, PROXIMO_EXAME, OUTRAS_RECOMENDACOES,
+ TRABALHADOR, MEDICO, PDF, FO, };
+
+
+ protected static final String ALL_FIELD_NAMES[] = new String[]{
+ ID, DATA, TIPO, OCASIONAL, OUTRO_TIPO, RESULTADO, OUTRA_FUNCAO_1, OUTRA_FUNCAO_2,
+ OUTRA_FUNCAO_3, OUTRA_FUNCAO_4, PROXIMO_EXAME, OUTRAS_RECOMENDACOES,
+ TRABALHADOR, MEDICO, PDF, FO, INACTIVO, };
+
+ private HashMap dataHash;
+
+ public ExameData()
+ {
+ dataHash = new HashMap();
+ }
+
+ protected Object innerGet( String fieldName )
+ throws Exception
+ {
+ return dataHash.get( fieldName );
+ }
+
+ protected void innerSet( String fieldName, Object value )
+ throws Exception
+ {
+ dataHash.put( fieldName, value );
+ }
+
+ public String []getFieldNames()
+ {
+ return FIELD_NAMES;
+ }
+
+ protected String []getAllFieldNames()
+ {
+ return ALL_FIELD_NAMES;
+ }
+
+ public Class getInnerClass()
+ {
+ return Exame.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/ExameID.java b/trunk/SIPRPSoft/src/siprp/data/ExameID.java
new file mode 100644
index 00000000..3fc144de
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/ExameID.java
@@ -0,0 +1,22 @@
+/*
+* ExameID.java
+*
+* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 28/Jan/2005
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import com.evolute.utils.jdo.jpox.*;
+
+public final class ExameID extends IntegerID
+{
+ public ExameID()
+ {
+ }
+
+ public ExameID( String str )
+ {
+ super( str );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/Historico.java b/trunk/SIPRPSoft/src/siprp/data/Historico.java
new file mode 100644
index 00000000..3a641ee1
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/Historico.java
@@ -0,0 +1,58 @@
+/*
+ * Historico.java
+ *
+ * Created on 7 de Dezembro de 2004, 16:50
+ */
+
+package siprp.data;
+
+import java.text.*;
+import java.util.*;
+
+import com.evolute.utils.jdo.*;
+import com.evolute.utils.tables.*;
+
+import siprp.*;
+/**
+ *
+ * @author fpalma
+ */
+public abstract class Historico extends JDOObject
+ implements ColumnizedObject
+{
+ protected static final DateFormat DATE_FORMAT = DateFormat.getDateInstance( DateFormat.SHORT );
+
+ public static final String DATA = "data";
+ public static final String TEXTO = "texto";
+
+ /** Creates a new instance of Historico */
+ public Historico()
+ {
+ }
+
+ public Object getValue(int col)
+ {
+ switch( col )
+ {
+ case 0:
+ Date data = (Date) get( DATA );
+ String dataStr = DATE_FORMAT.format( data );
+ return dataStr;
+
+ case 1:
+ String textoStr = (String ) get( TEXTO );
+ if( textoStr == null )
+ {
+ textoStr = "";
+ }
+ textoStr = textoStr.trim();
+ int index = textoStr.indexOf( "\n" );
+ if( index != -1 )
+ {
+ textoStr = textoStr.substring( 0, index );
+ }
+ return textoStr;
+ }
+ return null;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/HistoricoEstabelecimento.java b/trunk/SIPRPSoft/src/siprp/data/HistoricoEstabelecimento.java
new file mode 100644
index 00000000..0bd186b8
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/HistoricoEstabelecimento.java
@@ -0,0 +1,101 @@
+/*
+* HistoricoEstabelecimento.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 7/Dez/2004
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.Date;
+import com.evolute.utils.jdo.*;
+
+public final class HistoricoEstabelecimento implements JDOInnerObject
+{
+ private Integer id;
+ private Date data;
+ private String texto;
+ private Estabelecimento estabelecimento;
+
+ public HistoricoEstabelecimento()
+ {
+ }
+
+ public Object getField( String fieldName )
+ {
+ if( fieldName == HistoricoEstabelecimentoData.ID )
+ {
+ return id;
+ }
+ else if( fieldName == HistoricoEstabelecimentoData.DATA )
+ {
+ return data;
+ }
+ else if( fieldName == HistoricoEstabelecimentoData.TEXTO )
+ {
+ return texto;
+ }
+ else if( fieldName == HistoricoEstabelecimentoData.ESTABELECIMENTO )
+ {
+ return estabelecimento;
+ }
+ else if( fieldName.equals( HistoricoEstabelecimentoData.ID ) )
+ {
+ return id;
+ }
+ else if( fieldName.equals( HistoricoEstabelecimentoData.DATA ) )
+ {
+ return data;
+ }
+ else if( fieldName.equals( HistoricoEstabelecimentoData.TEXTO ) )
+ {
+ return texto;
+ }
+ else if( fieldName.equals( HistoricoEstabelecimentoData.ESTABELECIMENTO ) )
+ {
+ return estabelecimento;
+ }
+ return null;
+ }
+
+ public void setField( String fieldName, Object value )
+ {
+ if( fieldName == HistoricoEstabelecimentoData.ID )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName == HistoricoEstabelecimentoData.DATA )
+ {
+ data = ( Date ) value;
+ }
+ else if( fieldName == HistoricoEstabelecimentoData.TEXTO )
+ {
+ texto = ( String ) value;
+ }
+ else if( fieldName == HistoricoEstabelecimentoData.ESTABELECIMENTO )
+ {
+ estabelecimento = ( Estabelecimento ) value;
+ }
+ else if( fieldName.equals( HistoricoEstabelecimentoData.ID ) )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName.equals( HistoricoEstabelecimentoData.DATA ) )
+ {
+ data = ( Date ) value;
+ }
+ else if( fieldName.equals( HistoricoEstabelecimentoData.TEXTO ) )
+ {
+ texto = ( String ) value;
+ }
+ else if( fieldName.equals( HistoricoEstabelecimentoData.ESTABELECIMENTO ) )
+ {
+ estabelecimento = ( Estabelecimento ) value;
+ }
+ }
+
+ public Class getOuterClass()
+ {
+ return HistoricoEstabelecimentoData.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/HistoricoEstabelecimentoData.java b/trunk/SIPRPSoft/src/siprp/data/HistoricoEstabelecimentoData.java
new file mode 100644
index 00000000..38f82221
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/HistoricoEstabelecimentoData.java
@@ -0,0 +1,60 @@
+/*
+* HistoricoEstabelecimentoData.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 7/Dez/2004
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.HashMap;
+import com.evolute.utils.jdo.*;
+
+public final class HistoricoEstabelecimentoData extends Historico
+{
+ public static final String ID = "id";
+ public static final String DATA = "data";
+ public static final String TEXTO = "texto";
+ public static final String ESTABELECIMENTO = "estabelecimento";
+
+ public static final String FIELD_NAMES[] = new String[]{
+ DATA, TEXTO, ESTABELECIMENTO, };
+
+
+ protected static final String ALL_FIELD_NAMES[] = new String[]{
+ ID, DATA, TEXTO, ESTABELECIMENTO, };
+
+ private HashMap dataHash;
+
+ public HistoricoEstabelecimentoData()
+ {
+ dataHash = new HashMap();
+ }
+
+ protected Object innerGet( String fieldName )
+ throws Exception
+ {
+ return dataHash.get( fieldName );
+ }
+
+ protected void innerSet( String fieldName, Object value )
+ throws Exception
+ {
+ dataHash.put( fieldName, value );
+ }
+
+ public String []getFieldNames()
+ {
+ return FIELD_NAMES;
+ }
+
+ protected String []getAllFieldNames()
+ {
+ return ALL_FIELD_NAMES;
+ }
+
+ public Class getInnerClass()
+ {
+ return HistoricoEstabelecimento.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/HistoricoEstabelecimentoID.java b/trunk/SIPRPSoft/src/siprp/data/HistoricoEstabelecimentoID.java
new file mode 100644
index 00000000..1513d1bc
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/HistoricoEstabelecimentoID.java
@@ -0,0 +1,22 @@
+/*
+* HistoricoEstabelecimentoID.java
+*
+* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 7/Dez/2004
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import com.evolute.utils.jdo.jpox.*;
+
+public final class HistoricoEstabelecimentoID extends IntegerID
+{
+ public HistoricoEstabelecimentoID()
+ {
+ }
+
+ public HistoricoEstabelecimentoID( String str )
+ {
+ super( str );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/Marcacao.java b/trunk/SIPRPSoft/src/siprp/data/Marcacao.java
new file mode 100644
index 00000000..5302e965
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/Marcacao.java
@@ -0,0 +1,352 @@
+/*
+ * Marcacao.java
+ *
+ * Created on 21 de Maio de 2004, 16:59
+ */
+
+package siprp.data;
+
+import java.text.*;
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.jdo.*;
+import com.evolute.utils.tables.*;
+
+import siprp.*;
+/**
+ *
+ * @author fpalma
+ */
+public abstract class Marcacao extends JDOObject
+ implements ColumnizedObject
+ //, JDOOperationHandlerInterface
+{
+ public static final int TIPO_MARCACAO_TRABALHADOR_EXAMES = 0;
+ public static final int TIPO_MARCACAO_TRABALHADOR_CONSULTA = 1;
+ public static final int TIPO_MARCACAO_ESTABELECIMENTO = 2;
+ public static final int TIPO_MARCACAO_EMPRESA = 3;
+
+ public static final int ESTADO_POR_REALIZAR = 0;
+ public static final int ESTADO_PARCIALMENTE_REALIZADA = 1;
+ public static final int ESTADO_REALIZADA = 2;
+ public static final int ESTADO_DESMARCADA_TRABALHADOR = 3;
+ public static final int ESTADO_DESMARCADA_SHST = 4;
+ public static final int ESTADO_FALTOU = 5;
+
+ public static final String DATA = "data";
+ public static final String REALIZADA = "realizada";
+ public static final String DATA_EMAIL = "data_email";
+ public static final String DATA_RELATORIO = "data_relatorio";
+ public static final String ANTECEDENCIA_AVISO = "antecedencia_aviso";
+
+ protected static final DateFormat DATE_FORMAT = DateFormat.getDateInstance( DateFormat.SHORT );
+ protected static JDOProvider JDO;
+
+
+ public static Marcacao getMarcacao( int tipo )
+ {
+ switch( tipo )
+ {
+ case TIPO_MARCACAO_TRABALHADOR_EXAMES: case TIPO_MARCACAO_TRABALHADOR_CONSULTA:
+ return new MarcacaoTrabalhadorData();
+
+ case TIPO_MARCACAO_ESTABELECIMENTO:
+ return new MarcacaoEstabelecimentoData();
+
+ case TIPO_MARCACAO_EMPRESA:
+ return new MarcacaoEmpresaData();
+ }
+ return null;
+ }
+
+ public Object getValue( int col )
+ {
+ switch( col )
+ {
+ case 0:
+ Date data = (Date) get( DATA );
+ String dataStr = DATE_FORMAT.format( data );
+ return dataStr;
+
+ case 1:
+ String realizada = (String) get( REALIZADA );
+// if( this instanceof MarcacaoEmpresaData )
+// {
+// return new Boolean( "y".equals( realizada ) );
+// }
+// else
+// {
+
+ realizada = "y".equals( realizada ) ? "Sim" : "N\u00e3o";
+ return realizada;
+// }
+
+ case 2:
+ if( this instanceof MarcacaoEmpresaData )
+ {
+ String textoStr = (String ) get( MarcacaoEmpresaData.TEXTO );
+ if( textoStr == null )
+ {
+ textoStr = "";
+ }
+ textoStr = textoStr.trim();
+ int index = textoStr.indexOf( "\n" );
+ if( index != -1 )
+ {
+ textoStr = textoStr.substring( 0, index );
+ }
+ return textoStr;
+ }
+ else
+ {
+ Date dataRelatorio = (Date) get( DATA_RELATORIO );
+ String dataRelatorioStr = ( dataRelatorio != null ? DATE_FORMAT.format( dataRelatorio ) : "" );
+ return dataRelatorioStr;
+ }
+
+ default:
+ return null;
+ }
+ }
+
+ public static void saveMarcacaoConsultaForTrabalhadorID( Integer trabalhadorID, Date date )
+ throws Exception
+ {
+ if( date != null )
+ {
+ date = (Date)date.clone();
+ }
+ FichaDataProvider provider = (FichaDataProvider) FichaDataProvider.getProvider();
+ if( trabalhadorID == null )
+ {
+ return;
+ }
+ Integer marcacaoID = provider.getMarcacaoIDByTrabalhador( trabalhadorID );
+ MarcacaoTrabalhadorData marcacao;
+ if( marcacaoID == null )
+ {
+ marcacao = null;
+ }
+ else
+ {
+ if( JDO == null )
+ {
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ }
+ marcacao = ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, marcacaoID );
+ }
+ if( date == null && marcacao != null )
+ {
+ marcacao.delete();
+ }
+ else if( date != null && marcacao != null )
+ {
+ marcacao.set( Marcacao.DATA, date );
+ marcacao.save();
+ }
+ else if( date != null && marcacao == null )
+ {
+ marcacao = new MarcacaoTrabalhadorData();
+ if( JDO == null )
+ {
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ }
+ TrabalhadorData trab = (TrabalhadorData)JDO.load( TrabalhadorData.class, trabalhadorID );
+ marcacao.set( MarcacaoTrabalhadorData.TRABALHADOR, trab );
+ marcacao.set( MarcacaoTrabalhadorData.TIPO, new Integer( MarcacaoTrabalhadorData.TIPO_CONSULTA ) );
+ marcacao.set( Marcacao.DATA, date );
+ marcacao.set( Marcacao.REALIZADA, "n" );
+ marcacao.set( MarcacaoTrabalhadorData.ESTADO, new Integer( siprp.medicina.MedicinaDataProvider.ESTADO_POR_REALIZAR ) );
+ marcacao.set( MarcacaoTrabalhadorData.MOTIVO, new Integer( 2 ) );
+ marcacao.save();
+ }
+ }
+//
+// public boolean handle( JDOObject object, int operation, int moment )
+// throws Exception
+// {
+// switch( operation )
+// {
+// case JDOOperationHandlerInterface.OP_SAVE:
+// switch( moment )
+// {
+// case JDOOperationHandlerInterface.MOMENT_BEFORE:
+// return preSave( (Marcacao) object );
+//
+// case JDOOperationHandlerInterface.MOMENT_AFTER:
+// return postSave( (Marcacao) object );
+// }
+// return false;
+//
+// case JDOOperationHandlerInterface.OP_DELETE:
+// switch( moment )
+// {
+// case JDOOperationHandlerInterface.MOMENT_BEFORE:
+// return preDelete( (Marcacao) object );
+//
+// case JDOOperationHandlerInterface.MOMENT_AFTER:
+// return postDelete( (Marcacao) object );
+// }
+// return false;
+// }
+// return false;
+// }
+//
+// protected boolean preSave( Marcacao object )
+// throws Exception
+// {
+// return false;
+// }
+//
+// protected boolean postSave( Marcacao object )
+// throws Exception
+// {
+// if( object instanceof MarcacaoEmpresaData )
+// {
+// AvisoData aviso = (AvisoData) load( AvisoData.class, new Object[]{ get( MarcacaoEmpresaData.ID ), new Integer( AvisoData.TIPO_EMPRESA ) }, new String[]{ AvisoData.EVENTO_ID, AvisoData.TIPO } );
+// if( aviso == null )
+// {
+// aviso = new AvisoData();
+// }
+// aviso.set( AvisoData.TIPO, new Integer( AvisoData.TIPO_EMPRESA ) );
+// EmpresaData empresa = ( EmpresaData ) object.get( MarcacaoEmpresaData.EMPRESA );
+// aviso.set( AvisoData.EMPRESA, empresa );
+// aviso.set( AvisoData.EVENTO_ID, object.get( MarcacaoEmpresaData.ID ) );
+// Date dataEvento = (Date) object.get( DATA );
+// aviso.set( AvisoData.DATA_EVENTO, dataEvento );
+// aviso.set( AvisoData.DATA_AVISO, dataEvento );
+// String descricao = "Tarefa ";
+// aviso.set( AvisoData.DESCRICAO, descricao );
+// aviso.save();
+// }
+// else if( object instanceof MarcacaoEstabelecimentoData )
+// {
+// AvisoData aviso = (AvisoData) load( AvisoData.class, new Object[]{ get( MarcacaoEstabelecimentoData.ID ), new Integer( AvisoData.TIPO_ESTABELECIMENTO ) }, new String[]{ AvisoData.EVENTO_ID, AvisoData.TIPO } );
+// if( aviso == null )
+// {
+// aviso = new AvisoData();
+// }
+// aviso.set( AvisoData.TIPO, new Integer( AvisoData.TIPO_ESTABELECIMENTO ) );
+// EstabelecimentoData estabelecimento = ( EstabelecimentoData ) object.get( MarcacaoEstabelecimentoData.ESTABELECIMENTO );
+// aviso.set( AvisoData.ESTABELECIMENTO, estabelecimento );
+// EmpresaData empresa = ( EmpresaData )estabelecimento.get( EstabelecimentoData.EMPRESA );
+// aviso.set( AvisoData.EMPRESA, empresa );
+// aviso.set( AvisoData.EVENTO_ID, object.get( MarcacaoEstabelecimentoData.ID ) );
+// Date dataEvento = (Date) object.get( DATA );
+// Date dataAviso = new Date( dataEvento.getTime() );
+// Calendar cal = Calendar.getInstance();
+// cal.setTime( dataAviso );
+// cal.add( Calendar.DAY_OF_MONTH, -14 );
+// dataAviso = cal.getTime();
+// aviso.set( AvisoData.DATA_AVISO, dataAviso );
+// aviso.set( AvisoData.DATA_EVENTO, dataEvento );
+// String descricao = "Visita ";
+// aviso.set( AvisoData.DESCRICAO, descricao );
+// cal = Calendar.getInstance();
+// cal.setTime( dataEvento );
+// cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 0, 0, 0 );
+// cal.set( Calendar.MILLISECOND, 0 );
+// dataEvento = cal.getTime();
+//
+// cal = Calendar.getInstance();
+// cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 10, 0, 0 );
+// cal.set( Calendar.MILLISECOND, 0 );
+// Date hoje = cal.getTime();
+// if( hoje.before( dataEvento ) )
+// {
+// aviso.save();
+// }
+// }
+// if( object instanceof MarcacaoTrabalhadorData )
+// {
+// AvisoData aviso = (AvisoData) load( AvisoData.class, new Object[]{ object.get( MarcacaoTrabalhadorData.ID ), new Integer( AvisoData.TIPO_TRABALHADOR ) }, new String[]{ AvisoData.EVENTO_ID, AvisoData.TIPO } );
+// if( aviso == null )
+// {
+// aviso = new AvisoData();
+// }
+// aviso.set( AvisoData.TIPO, new Integer( AvisoData.TIPO_TRABALHADOR ) );
+// TrabalhadorData trab = ( TrabalhadorData ) object.get( MarcacaoTrabalhadorData.TRABALHADOR );
+// aviso.set( AvisoData.TRABALHADOR, trab );
+// EstabelecimentoData estabelecimento = ( EstabelecimentoData ) trab.get( TrabalhadorData.ESTABELECIMENTO );
+// aviso.set( AvisoData.ESTABELECIMENTO, estabelecimento );
+// EmpresaData empresa = ( EmpresaData ) estabelecimento.get( EstabelecimentoData.EMPRESA );
+// aviso.set( AvisoData.EMPRESA, empresa );
+// aviso.set( AvisoData.EVENTO_ID, object.get( MarcacaoTrabalhadorData.ID ) );
+// Date dataEvento = (Date) object.get( DATA );
+// Date dataAviso = new Date( dataEvento.getTime() );
+// Calendar cal = Calendar.getInstance();
+// cal.setTime( dataAviso );
+// cal.add( Calendar.DAY_OF_MONTH, -14 );
+// dataAviso = cal.getTime();
+// aviso.set( AvisoData.DATA_AVISO, dataAviso );
+// aviso.set( AvisoData.DATA_EVENTO, dataEvento );
+// String descricao = "";
+// switch( ( ( Integer ) object.get( MarcacaoTrabalhadorData.TIPO ) ).intValue() )
+// {
+// case MarcacaoTrabalhadorData.TIPO_EXAMES:
+// descricao = "Exames ";
+// break;
+//
+// case MarcacaoTrabalhadorData.TIPO_CONSULTA:
+// descricao = "Consulta ";
+// break;
+// }
+// aviso.set( AvisoData.DESCRICAO, descricao );
+// cal = Calendar.getInstance();
+// cal.setTime( dataEvento );
+// cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 0, 0, 0 );
+// cal.set( Calendar.MILLISECOND, 0 );
+// dataEvento = cal.getTime();
+//
+// cal = Calendar.getInstance();
+// cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 10, 0, 0 );
+// cal.set( Calendar.MILLISECOND, 0 );
+// Date hoje = cal.getTime();
+// if( hoje.before( dataEvento ) )
+// {
+// aviso.save();
+// }
+// }
+// else
+// {
+// return false;
+// }
+// return true;
+// }
+//
+// protected boolean preDelete( Marcacao object )
+// throws Exception
+// {
+// return false;
+// }
+//
+// protected boolean postDelete( Marcacao object )
+// throws Exception
+// {
+// Integer tipo;
+// if( object instanceof MarcacaoEmpresaData )
+// {
+// tipo = new Integer( AvisoData.TIPO_EMPRESA );
+// }
+// else if( object instanceof MarcacaoEstabelecimentoData )
+// {
+// tipo = new Integer( AvisoData.TIPO_ESTABELECIMENTO );
+// }
+// if( object instanceof MarcacaoTrabalhadorData )
+// {
+// tipo = new Integer( AvisoData.TIPO_TRABALHADOR );
+// }
+// else
+// {
+// return false;
+// }
+// AvisoData aviso = (AvisoData) load( AvisoData.class, new Object[]{ object.get( "id" ), tipo }, new String[]{ AvisoData.EVENTO_ID, AvisoData.TIPO } );
+// if( aviso != null )
+// {
+// aviso.delete();
+// }
+//
+// return true;
+// }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoEmpresa.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoEmpresa.java
new file mode 100644
index 00000000..1f32cac8
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/MarcacaoEmpresa.java
@@ -0,0 +1,118 @@
+/*
+* MarcacaoEmpresa.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 7/Dez/2004
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.Date;
+import com.evolute.utils.jdo.*;
+
+public final class MarcacaoEmpresa implements JDOInnerObject
+{
+ private Integer id;
+ private Date data;
+ private String texto;
+ private String realizada;
+ private Empresa empresa;
+
+ public MarcacaoEmpresa()
+ {
+ }
+
+ public Object getField( String fieldName )
+ {
+ if( fieldName == MarcacaoEmpresaData.ID )
+ {
+ return id;
+ }
+ else if( fieldName == MarcacaoEmpresaData.DATA )
+ {
+ return data;
+ }
+ else if( fieldName == MarcacaoEmpresaData.TEXTO )
+ {
+ return texto;
+ }
+ else if( fieldName == MarcacaoEmpresaData.REALIZADA )
+ {
+ return realizada;
+ }
+ else if( fieldName == MarcacaoEmpresaData.EMPRESA )
+ {
+ return empresa;
+ }
+ else if( fieldName.equals( MarcacaoEmpresaData.ID ) )
+ {
+ return id;
+ }
+ else if( fieldName.equals( MarcacaoEmpresaData.DATA ) )
+ {
+ return data;
+ }
+ else if( fieldName.equals( MarcacaoEmpresaData.TEXTO ) )
+ {
+ return texto;
+ }
+ else if( fieldName.equals( MarcacaoEmpresaData.REALIZADA ) )
+ {
+ return realizada;
+ }
+ else if( fieldName.equals( MarcacaoEmpresaData.EMPRESA ) )
+ {
+ return empresa;
+ }
+ return null;
+ }
+
+ public void setField( String fieldName, Object value )
+ {
+ if( fieldName == MarcacaoEmpresaData.ID )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName == MarcacaoEmpresaData.DATA )
+ {
+ data = ( Date ) value;
+ }
+ else if( fieldName == MarcacaoEmpresaData.TEXTO )
+ {
+ texto = ( String ) value;
+ }
+ else if( fieldName == MarcacaoEmpresaData.REALIZADA )
+ {
+ realizada = ( String ) value;
+ }
+ else if( fieldName == MarcacaoEmpresaData.EMPRESA )
+ {
+ empresa = ( Empresa ) value;
+ }
+ else if( fieldName.equals( MarcacaoEmpresaData.ID ) )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName.equals( MarcacaoEmpresaData.DATA ) )
+ {
+ data = ( Date ) value;
+ }
+ else if( fieldName.equals( MarcacaoEmpresaData.TEXTO ) )
+ {
+ texto = ( String ) value;
+ }
+ else if( fieldName.equals( MarcacaoEmpresaData.REALIZADA ) )
+ {
+ realizada = ( String ) value;
+ }
+ else if( fieldName.equals( MarcacaoEmpresaData.EMPRESA ) )
+ {
+ empresa = ( Empresa ) value;
+ }
+ }
+
+ public Class getOuterClass()
+ {
+ return MarcacaoEmpresaData.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoEmpresaData.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoEmpresaData.java
new file mode 100644
index 00000000..54921f1f
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/MarcacaoEmpresaData.java
@@ -0,0 +1,61 @@
+/*
+* MarcacaoEmpresaData.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 7/Dez/2004
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.HashMap;
+import com.evolute.utils.jdo.*;
+
+public final class MarcacaoEmpresaData extends Marcacao
+{
+ public static final String ID = "id";
+ public static final String DATA = "data";
+ public static final String TEXTO = "texto";
+ public static final String REALIZADA = "realizada";
+ public static final String EMPRESA = "empresa";
+
+ public static final String FIELD_NAMES[] = new String[]{
+ DATA, TEXTO, REALIZADA, EMPRESA, };
+
+
+ protected static final String ALL_FIELD_NAMES[] = new String[]{
+ ID, DATA, TEXTO, REALIZADA, EMPRESA, };
+
+ private HashMap dataHash;
+
+ public MarcacaoEmpresaData()
+ {
+ dataHash = new HashMap();
+ }
+
+ protected Object innerGet( String fieldName )
+ throws Exception
+ {
+ return dataHash.get( fieldName );
+ }
+
+ protected void innerSet( String fieldName, Object value )
+ throws Exception
+ {
+ dataHash.put( fieldName, value );
+ }
+
+ public String []getFieldNames()
+ {
+ return FIELD_NAMES;
+ }
+
+ protected String []getAllFieldNames()
+ {
+ return ALL_FIELD_NAMES;
+ }
+
+ public Class getInnerClass()
+ {
+ return MarcacaoEmpresa.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoEmpresaID.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoEmpresaID.java
new file mode 100644
index 00000000..8b074d13
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/MarcacaoEmpresaID.java
@@ -0,0 +1,22 @@
+/*
+* MarcacaoEmpresaID.java
+*
+* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 7/Dez/2004
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import com.evolute.utils.jdo.jpox.*;
+
+public final class MarcacaoEmpresaID extends IntegerID
+{
+ public MarcacaoEmpresaID()
+ {
+ }
+
+ public MarcacaoEmpresaID( String str )
+ {
+ super( str );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoEstabelecimento.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoEstabelecimento.java
new file mode 100644
index 00000000..16f5fca4
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/MarcacaoEstabelecimento.java
@@ -0,0 +1,186 @@
+/*
+* MarcacaoEstabelecimento.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on Feb 1, 2006
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.Date;
+import com.evolute.utils.jdo.*;
+
+public final class MarcacaoEstabelecimento implements JDOInnerObject
+{
+ private Integer id;
+ private Date data;
+ private String realizada;
+ private Integer estado;
+ private Integer tecnico_hst;
+ private Date data_email;
+ private Date data_relatorio;
+ private Estabelecimento estabelecimento;
+ private String observacoes;
+
+ public MarcacaoEstabelecimento()
+ {
+ }
+
+ public Object getField( String fieldName )
+ {
+ if( fieldName == MarcacaoEstabelecimentoData.ID )
+ {
+ return id;
+ }
+ else if( fieldName == MarcacaoEstabelecimentoData.DATA )
+ {
+ return data;
+ }
+ else if( fieldName == MarcacaoEstabelecimentoData.REALIZADA )
+ {
+ return realizada;
+ }
+ else if( fieldName == MarcacaoEstabelecimentoData.ESTADO )
+ {
+ return estado;
+ }
+ else if( fieldName == MarcacaoEstabelecimentoData.TECNICO_HST )
+ {
+ return tecnico_hst;
+ }
+ else if( fieldName == MarcacaoEstabelecimentoData.DATA_EMAIL )
+ {
+ return data_email;
+ }
+ else if( fieldName == MarcacaoEstabelecimentoData.DATA_RELATORIO )
+ {
+ return data_relatorio;
+ }
+ else if( fieldName == MarcacaoEstabelecimentoData.ESTABELECIMENTO )
+ {
+ return estabelecimento;
+ }
+ else if( fieldName == MarcacaoEstabelecimentoData.OBSERVACOES )
+ {
+ return observacoes;
+ }
+ else if( fieldName.equals( MarcacaoEstabelecimentoData.ID ) )
+ {
+ return id;
+ }
+ else if( fieldName.equals( MarcacaoEstabelecimentoData.DATA ) )
+ {
+ return data;
+ }
+ else if( fieldName.equals( MarcacaoEstabelecimentoData.REALIZADA ) )
+ {
+ return realizada;
+ }
+ else if( fieldName.equals( MarcacaoEstabelecimentoData.ESTADO ) )
+ {
+ return estado;
+ }
+ else if( fieldName.equals( MarcacaoEstabelecimentoData.TECNICO_HST ) )
+ {
+ return tecnico_hst;
+ }
+ else if( fieldName.equals( MarcacaoEstabelecimentoData.DATA_EMAIL ) )
+ {
+ return data_email;
+ }
+ else if( fieldName.equals( MarcacaoEstabelecimentoData.DATA_RELATORIO ) )
+ {
+ return data_relatorio;
+ }
+ else if( fieldName.equals( MarcacaoEstabelecimentoData.ESTABELECIMENTO ) )
+ {
+ return estabelecimento;
+ }
+ else if( fieldName.equals( MarcacaoEstabelecimentoData.OBSERVACOES ) )
+ {
+ return observacoes;
+ }
+ return null;
+ }
+
+ public void setField( String fieldName, Object value )
+ {
+ if( fieldName == MarcacaoEstabelecimentoData.ID )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName == MarcacaoEstabelecimentoData.DATA )
+ {
+ data = ( Date ) value;
+ }
+ else if( fieldName == MarcacaoEstabelecimentoData.REALIZADA )
+ {
+ realizada = ( String ) value;
+ }
+ else if( fieldName == MarcacaoEstabelecimentoData.ESTADO )
+ {
+ estado = ( Integer ) value;
+ }
+ else if( fieldName == MarcacaoEstabelecimentoData.TECNICO_HST )
+ {
+ tecnico_hst = ( Integer ) value;
+ }
+ else if( fieldName == MarcacaoEstabelecimentoData.DATA_EMAIL )
+ {
+ data_email = ( Date ) value;
+ }
+ else if( fieldName == MarcacaoEstabelecimentoData.DATA_RELATORIO )
+ {
+ data_relatorio = ( Date ) value;
+ }
+ else if( fieldName == MarcacaoEstabelecimentoData.ESTABELECIMENTO )
+ {
+ estabelecimento = ( Estabelecimento ) value;
+ }
+ else if( fieldName == MarcacaoEstabelecimentoData.OBSERVACOES )
+ {
+ observacoes = ( String ) value;
+ }
+ else if( fieldName.equals( MarcacaoEstabelecimentoData.ID ) )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName.equals( MarcacaoEstabelecimentoData.DATA ) )
+ {
+ data = ( Date ) value;
+ }
+ else if( fieldName.equals( MarcacaoEstabelecimentoData.REALIZADA ) )
+ {
+ realizada = ( String ) value;
+ }
+ else if( fieldName.equals( MarcacaoEstabelecimentoData.ESTADO ) )
+ {
+ estado = ( Integer ) value;
+ }
+ else if( fieldName.equals( MarcacaoEstabelecimentoData.TECNICO_HST ) )
+ {
+ tecnico_hst = ( Integer ) value;
+ }
+ else if( fieldName.equals( MarcacaoEstabelecimentoData.DATA_EMAIL ) )
+ {
+ data_email = ( Date ) value;
+ }
+ else if( fieldName.equals( MarcacaoEstabelecimentoData.DATA_RELATORIO ) )
+ {
+ data_relatorio = ( Date ) value;
+ }
+ else if( fieldName.equals( MarcacaoEstabelecimentoData.ESTABELECIMENTO ) )
+ {
+ estabelecimento = ( Estabelecimento ) value;
+ }
+ else if( fieldName.equals( MarcacaoEstabelecimentoData.OBSERVACOES ) )
+ {
+ observacoes = ( String ) value;
+ }
+ }
+
+ public Class getOuterClass()
+ {
+ return MarcacaoEstabelecimentoData.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoEstabelecimentoData.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoEstabelecimentoData.java
new file mode 100644
index 00000000..4c8551ca
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/MarcacaoEstabelecimentoData.java
@@ -0,0 +1,67 @@
+/*
+* MarcacaoEstabelecimentoData.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on Feb 1, 2006
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.HashMap;
+import com.evolute.utils.jdo.*;
+
+public final class MarcacaoEstabelecimentoData extends Marcacao
+{
+ public static final String ID = "id";
+ public static final String DATA = "data";
+ public static final String REALIZADA = "realizada";
+ public static final String ESTADO = "estado";
+ public static final String TECNICO_HST = "tecnico_hst";
+ public static final String DATA_EMAIL = "data_email";
+ public static final String DATA_RELATORIO = "data_relatorio";
+ public static final String ESTABELECIMENTO = "estabelecimento";
+ public static final String OBSERVACOES = "observacoes";
+
+ public static final String FIELD_NAMES[] = new String[]{
+ DATA, REALIZADA, ESTADO, TECNICO_HST, DATA_EMAIL, DATA_RELATORIO, ESTABELECIMENTO,
+ OBSERVACOES, };
+
+
+ protected static final String ALL_FIELD_NAMES[] = new String[]{
+ ID, DATA, REALIZADA, ESTADO, TECNICO_HST, DATA_EMAIL, DATA_RELATORIO,
+ ESTABELECIMENTO, OBSERVACOES, };
+
+ private HashMap dataHash;
+
+ public MarcacaoEstabelecimentoData()
+ {
+ dataHash = new HashMap();
+ }
+
+ protected Object innerGet( String fieldName )
+ throws Exception
+ {
+ return dataHash.get( fieldName );
+ }
+
+ protected void innerSet( String fieldName, Object value )
+ throws Exception
+ {
+ dataHash.put( fieldName, value );
+ }
+
+ public String []getFieldNames()
+ {
+ return FIELD_NAMES;
+ }
+
+ protected String []getAllFieldNames()
+ {
+ return ALL_FIELD_NAMES;
+ }
+
+ public Class getInnerClass()
+ {
+ return MarcacaoEstabelecimento.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoEstabelecimentoID.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoEstabelecimentoID.java
new file mode 100644
index 00000000..36240581
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/MarcacaoEstabelecimentoID.java
@@ -0,0 +1,25 @@
+/*
+* MarcacaoEstabelecimentoID.java
+*
+* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on Feb 1, 2006
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.io.*;
+
+import com.evolute.utils.jdo.jpox.*;
+
+public final class MarcacaoEstabelecimentoID extends IntegerID
+ implements Serializable
+{
+ public MarcacaoEstabelecimentoID()
+ {
+ }
+
+ public MarcacaoEstabelecimentoID( String str )
+ {
+ super( str );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoListLoader.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoListLoader.java
new file mode 100644
index 00000000..c966c222
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/MarcacaoListLoader.java
@@ -0,0 +1,80 @@
+/*
+ * MarcacaoListLoader.java
+ *
+ * Created on 27 de Maio de 2004, 16:18
+ */
+
+package siprp.data;
+
+import javax.jdo.*;
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.jdo.*;
+
+import siprp.*;
+/**
+ *
+ * @author fpalma
+ */
+public class MarcacaoListLoader
+{
+// private static PersistenceManager MANAGER = null;
+ private JDOProvider JDO;
+
+ /** Creates a new instance of MarcacaoListLoader */
+ public MarcacaoListLoader()
+ {
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ }
+
+ public Marcacao[] load( int tipo, Integer targetID )
+ throws Exception
+ {
+ Class theClass;
+ String filterString;
+ switch( tipo )
+ {
+ case Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES: case Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA:
+ theClass = MarcacaoTrabalhador.class;
+ filterString = "(trabalhador.id == " + targetID + ") && (tipo == " + tipo + ")";
+ break;
+
+ case Marcacao.TIPO_MARCACAO_ESTABELECIMENTO:
+ theClass = MarcacaoEstabelecimento.class;
+ filterString = "estabelecimento.id == " + targetID;
+ break;
+
+ default:
+ return new Marcacao[ 0 ];
+ }
+// if( MANAGER == null )
+// {
+// MANAGER = (PersistenceManager) Singleton.getInstance( SingletonConstants.PERSISTENCE_MANAGER );
+// }
+// Transaction tx = MANAGER.currentTransaction();
+ Object sessionID = null;
+ try
+ {
+ sessionID = JDO.begin();
+ Query q = JDO.getManager().newQuery( theClass, filterString );
+ q.setOrdering( Marcacao.DATA + " descending" );
+ Collection c = ( Collection )q.execute();
+ JDOInnerObject innerObjects[] = ( JDOInnerObject [] ) c.toArray( new JDOInnerObject[0] );
+ JDO.commit( sessionID );
+ Marcacao marcacoes[] = new Marcacao[ innerObjects.length ];
+ for( int n = 0; n < marcacoes.length; n++ )
+ {
+ marcacoes[ n ] = ( Marcacao ) innerObjects[ n ].getOuterClass().newInstance();
+ marcacoes[ n ].setInnerObject( innerObjects[ n ] );
+ }
+ return marcacoes;
+ }
+ catch( RuntimeException ex )
+ {
+ JDO.rollback( sessionID );
+// Main.reconnectJDO();
+ throw ex;
+ }
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoSaveAndDeleteHandler.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoSaveAndDeleteHandler.java
new file mode 100644
index 00000000..c8df3dc6
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/MarcacaoSaveAndDeleteHandler.java
@@ -0,0 +1,258 @@
+/*
+* MarcacaoSaveAndDeleteHandler.java
+ *
+ * Created on 13 de Outubro de 2004, 18:31
+ */
+
+package siprp.data;
+
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.jdo.*;
+
+import siprp.medicina.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class MarcacaoSaveAndDeleteHandler
+ implements JDOOperationHandlerInterface
+{
+ public static final MarcacaoSaveAndDeleteHandler INSTANCE = new MarcacaoSaveAndDeleteHandler();
+
+ public JDOProvider JDO;
+ protected MedicinaDataProvider medicinaProvider;
+
+ /** Creates a new instance of MarcacaoSaveAndDeleteHandler */
+ public MarcacaoSaveAndDeleteHandler()
+ {
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ }
+
+ public boolean handle( JDOObject object, int operation, int moment )
+ throws Exception
+ {
+ if( JDO == null )
+ {
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ }
+ switch( operation )
+ {
+ case JDOOperationHandlerInterface.OP_SAVE:
+ switch( moment )
+ {
+ case JDOOperationHandlerInterface.MOMENT_BEFORE:
+ return preSave( (Marcacao) object );
+
+ case JDOOperationHandlerInterface.MOMENT_AFTER:
+ return postSave( (Marcacao) object );
+ }
+ return false;
+
+ case JDOOperationHandlerInterface.OP_DELETE:
+ switch( moment )
+ {
+ case JDOOperationHandlerInterface.MOMENT_BEFORE:
+ return preDelete( (Marcacao) object );
+
+ case JDOOperationHandlerInterface.MOMENT_AFTER:
+ return postDelete( (Marcacao) object );
+ }
+ return false;
+ }
+ return false;
+ }
+
+ protected boolean preSave( Marcacao object )
+ throws Exception
+ {
+ return false;
+ }
+
+ protected boolean postSave( Marcacao object )
+ throws Exception
+ {
+ if( object instanceof MarcacaoEmpresaData )
+ {
+ AvisoData aviso = (AvisoData) JDO.load( AvisoData.class,
+ new Object[]{ object.get( MarcacaoEmpresaData.ID ), new Integer( AvisoData.TIPO_EMPRESA ) },
+ new String[]{ AvisoData.EVENTO_ID, AvisoData.TIPO } );
+ if( aviso == null )
+ {
+ aviso = new AvisoData();
+ }
+ aviso.set( AvisoData.TIPO, new Integer( AvisoData.TIPO_EMPRESA ) );
+ EmpresaData empresa = ( EmpresaData ) object.get( MarcacaoEmpresaData.EMPRESA );
+ aviso.set( AvisoData.EMPRESA, empresa );
+ aviso.set( AvisoData.EVENTO_ID, object.get( MarcacaoEmpresaData.ID ) );
+ Date dataEvento = (Date) object.get( Marcacao.DATA );
+ aviso.set( AvisoData.DATA_EVENTO, dataEvento );
+ aviso.set( AvisoData.DATA_AVISO, dataEvento );
+ String descricao = "Tarefa ";
+ aviso.set( AvisoData.DESCRICAO, descricao );
+ aviso.save();
+
+ empresa.save();
+ }
+ else if( object instanceof MarcacaoEstabelecimentoData )
+ {
+ AvisoData aviso = (AvisoData) JDO.load( AvisoData.class,
+ new Object[]{ object.get( MarcacaoEstabelecimentoData.ID ), new Integer( AvisoData.TIPO_ESTABELECIMENTO ) },
+ new String[]{ AvisoData.EVENTO_ID, AvisoData.TIPO } );
+ if( aviso == null )
+ {
+ aviso = new AvisoData();
+ }
+ aviso.set( AvisoData.TIPO, new Integer( AvisoData.TIPO_ESTABELECIMENTO ) );
+ EstabelecimentoData estabelecimento = ( EstabelecimentoData ) object.get( MarcacaoEstabelecimentoData.ESTABELECIMENTO );
+ aviso.set( AvisoData.ESTABELECIMENTO, estabelecimento );
+ EmpresaData empresa = ( EmpresaData )estabelecimento.get( EstabelecimentoData.EMPRESA );
+ aviso.set( AvisoData.EMPRESA, empresa );
+ aviso.set( AvisoData.EVENTO_ID, object.get( MarcacaoEstabelecimentoData.ID ) );
+ Date dataEvento = (Date) object.get( Marcacao.DATA );
+ Date dataAviso = new Date( dataEvento.getTime() );
+ Calendar cal = Calendar.getInstance();
+ cal.setTime( dataAviso );
+ cal.add( Calendar.DAY_OF_MONTH, -14 );
+ dataAviso = cal.getTime();
+ aviso.set( AvisoData.DATA_AVISO, dataAviso );
+ aviso.set( AvisoData.DATA_EVENTO, dataEvento );
+ String descricao = "Visita ";
+ aviso.set( AvisoData.DESCRICAO, descricao );
+ cal = Calendar.getInstance();
+ cal.setTime( dataEvento );
+ cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 0, 0, 0 );
+ cal.set( Calendar.MILLISECOND, 0 );
+ dataEvento = cal.getTime();
+
+ cal = Calendar.getInstance();
+ cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 10, 0, 0 );
+ cal.set( Calendar.MILLISECOND, 0 );
+ Date hoje = cal.getTime();
+ if( hoje.before( dataEvento ) )
+ {
+ aviso.save();
+ }
+
+ estabelecimento.save();
+ }
+ if( object instanceof MarcacaoTrabalhadorData )
+ {
+ AvisoData aviso = (AvisoData) JDO.load( AvisoData.class,
+ new Object[]{ object.get( MarcacaoTrabalhadorData.ID ), new Integer( AvisoData.TIPO_TRABALHADOR ) },
+ new String[]{ AvisoData.EVENTO_ID, AvisoData.TIPO } );
+ System.out.println( "AVISO LOADED: " + aviso + " id: " + ( aviso != null ? aviso.get( AvisoData.ID ) : "n/a" )
+ + " MT.ID: " + object.get( MarcacaoTrabalhadorData.ID )
+ + " AD.TIPO: " + new Integer( AvisoData.TIPO_TRABALHADOR ) );
+ if( aviso == null )
+ {
+ System.out.println( "novo aviso" );
+ aviso = new AvisoData();
+ }
+ aviso.set( AvisoData.TIPO, new Integer( AvisoData.TIPO_TRABALHADOR ) );
+ TrabalhadorData trab = ( TrabalhadorData ) object.get( MarcacaoTrabalhadorData.TRABALHADOR );
+ aviso.set( AvisoData.TRABALHADOR, trab );
+ EstabelecimentoData estabelecimento = ( EstabelecimentoData ) trab.get( TrabalhadorData.ESTABELECIMENTO );
+ aviso.set( AvisoData.ESTABELECIMENTO, estabelecimento );
+ EmpresaData empresa = ( EmpresaData ) estabelecimento.get( EstabelecimentoData.EMPRESA );
+ aviso.set( AvisoData.EMPRESA, empresa );
+ aviso.set( AvisoData.EVENTO_ID, object.get( MarcacaoTrabalhadorData.ID ) );
+ Date dataEvento = (Date) object.get( Marcacao.DATA );
+ Date dataAviso = new Date( dataEvento.getTime() );
+ Calendar cal = Calendar.getInstance();
+ cal.setTime( dataAviso );
+ cal.add( Calendar.DAY_OF_MONTH, -14 );
+ dataAviso = cal.getTime();
+ aviso.set( AvisoData.DATA_AVISO, dataAviso );
+ aviso.set( AvisoData.DATA_EVENTO, dataEvento.clone() );
+ String descricao = "";
+ switch( ( ( Integer ) object.get( MarcacaoTrabalhadorData.TIPO ) ).intValue() )
+ {
+ case MarcacaoTrabalhadorData.TIPO_EXAMES:
+ descricao = "Exames";
+ break;
+
+ case MarcacaoTrabalhadorData.TIPO_CONSULTA:
+ Integer motivo = ( ( Integer ) object.get( MarcacaoTrabalhadorData.MOTIVO ) );
+ descricao = "Consulta " + ( motivo == null ? "" : ("(" + MedicinaDataProvider.TIPOS_CONSULTAS[ motivo.intValue() ] + ")" ) );
+ break;
+ }
+ aviso.set( AvisoData.DESCRICAO, descricao );
+ cal = Calendar.getInstance();
+ cal.setTime( dataEvento );
+ cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 0, 0, 0 );
+ cal.set( Calendar.MILLISECOND, 0 );
+ dataEvento = cal.getTime();
+
+ cal = Calendar.getInstance();
+ cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 10, 0, 0 );
+ cal.set( Calendar.MILLISECOND, 0 );
+ Date hoje = cal.getTime();
+ if( hoje.before( dataEvento ) )
+ {
+ if( !hoje.before( dataAviso ) )
+ {
+ aviso.set( AvisoData.DATA_AVISO, dataEvento.clone() );
+ }
+ aviso.save();
+ }
+
+ trab.save();
+ }
+ else
+ {
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean preDelete( Marcacao object )
+ throws Exception
+ {
+ if( object instanceof MarcacaoTrabalhadorData &&
+ ( ( Integer ) object.get( MarcacaoTrabalhadorData.TIPO ) ).intValue() == MarcacaoTrabalhadorData.TIPO_EXAMES )
+ {
+ if( medicinaProvider == null )
+ {
+ medicinaProvider = (MedicinaDataProvider)MedicinaDataProvider.getProvider();
+ }
+ medicinaProvider.deleteDetalhesRealizadosForMarcacao( ( Integer ) object.get( MarcacaoTrabalhadorData.ID ) );
+ return true;
+ }
+ return false;
+ }
+
+ protected boolean postDelete( Marcacao object )
+ throws Exception
+ {
+System.out.println( "!delete!" );
+ Integer tipo;
+ if( object instanceof MarcacaoEmpresaData )
+ {
+ tipo = new Integer( AvisoData.TIPO_EMPRESA );
+ }
+ else if( object instanceof MarcacaoEstabelecimentoData )
+ {
+ tipo = new Integer( AvisoData.TIPO_ESTABELECIMENTO );
+ }
+ if( object instanceof MarcacaoTrabalhadorData )
+ {
+ tipo = new Integer( AvisoData.TIPO_TRABALHADOR );
+ }
+ else
+ {
+ return false;
+ }
+ AvisoData aviso = (AvisoData) JDO.load( AvisoData.class,
+ new Object[]{ object.get( "id" ), tipo },
+ new String[]{ AvisoData.EVENTO_ID, AvisoData.TIPO } );
+ if( aviso != null )
+ {
+ aviso.delete();
+ }
+
+ return true;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhador.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhador.java
new file mode 100644
index 00000000..a4af4d07
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhador.java
@@ -0,0 +1,203 @@
+/*
+* MarcacaoTrabalhador.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on Jan 28, 2006
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.Date;
+import com.evolute.utils.jdo.*;
+
+public final class MarcacaoTrabalhador implements JDOInnerObject
+{
+ private Integer id;
+ private Date data;
+ private String realizada;
+ private Integer estado;
+ private Integer motivo;
+ private Date data_email;
+ private Date data_relatorio;
+ private Integer tipo;
+ private Trabalhador trabalhador;
+ private String observacoes;
+
+ public MarcacaoTrabalhador()
+ {
+ }
+
+ public Object getField( String fieldName )
+ {
+ if( fieldName == MarcacaoTrabalhadorData.ID )
+ {
+ return id;
+ }
+ else if( fieldName == MarcacaoTrabalhadorData.DATA )
+ {
+ return data;
+ }
+ else if( fieldName == MarcacaoTrabalhadorData.REALIZADA )
+ {
+ return realizada;
+ }
+ else if( fieldName == MarcacaoTrabalhadorData.ESTADO )
+ {
+ return estado;
+ }
+ else if( fieldName == MarcacaoTrabalhadorData.MOTIVO )
+ {
+ return motivo;
+ }
+ else if( fieldName == MarcacaoTrabalhadorData.DATA_EMAIL )
+ {
+ return data_email;
+ }
+ else if( fieldName == MarcacaoTrabalhadorData.DATA_RELATORIO )
+ {
+ return data_relatorio;
+ }
+ else if( fieldName == MarcacaoTrabalhadorData.TIPO )
+ {
+ return tipo;
+ }
+ else if( fieldName == MarcacaoTrabalhadorData.TRABALHADOR )
+ {
+ return trabalhador;
+ }
+ else if( fieldName == MarcacaoTrabalhadorData.OBSERVACOES )
+ {
+ return observacoes;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.ID ) )
+ {
+ return id;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.DATA ) )
+ {
+ return data;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.REALIZADA ) )
+ {
+ return realizada;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.ESTADO ) )
+ {
+ return estado;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.MOTIVO ) )
+ {
+ return motivo;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.DATA_EMAIL ) )
+ {
+ return data_email;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.DATA_RELATORIO ) )
+ {
+ return data_relatorio;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.TIPO ) )
+ {
+ return tipo;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.TRABALHADOR ) )
+ {
+ return trabalhador;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.OBSERVACOES ) )
+ {
+ return observacoes;
+ }
+ return null;
+ }
+
+ public void setField( String fieldName, Object value )
+ {
+ if( fieldName == MarcacaoTrabalhadorData.ID )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName == MarcacaoTrabalhadorData.DATA )
+ {
+ data = ( Date ) value;
+ }
+ else if( fieldName == MarcacaoTrabalhadorData.REALIZADA )
+ {
+ realizada = ( String ) value;
+ }
+ else if( fieldName == MarcacaoTrabalhadorData.ESTADO )
+ {
+ estado = ( Integer ) value;
+ }
+ else if( fieldName == MarcacaoTrabalhadorData.MOTIVO )
+ {
+ motivo = ( Integer ) value;
+ }
+ else if( fieldName == MarcacaoTrabalhadorData.DATA_EMAIL )
+ {
+ data_email = ( Date ) value;
+ }
+ else if( fieldName == MarcacaoTrabalhadorData.DATA_RELATORIO )
+ {
+ data_relatorio = ( Date ) value;
+ }
+ else if( fieldName == MarcacaoTrabalhadorData.TIPO )
+ {
+ tipo = ( Integer ) value;
+ }
+ else if( fieldName == MarcacaoTrabalhadorData.TRABALHADOR )
+ {
+ trabalhador = ( Trabalhador ) value;
+ }
+ else if( fieldName == MarcacaoTrabalhadorData.OBSERVACOES )
+ {
+ observacoes = ( String ) value;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.ID ) )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.DATA ) )
+ {
+ data = ( Date ) value;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.REALIZADA ) )
+ {
+ realizada = ( String ) value;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.ESTADO ) )
+ {
+ estado = ( Integer ) value;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.MOTIVO ) )
+ {
+ motivo = ( Integer ) value;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.DATA_EMAIL ) )
+ {
+ data_email = ( Date ) value;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.DATA_RELATORIO ) )
+ {
+ data_relatorio = ( Date ) value;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.TIPO ) )
+ {
+ tipo = ( Integer ) value;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.TRABALHADOR ) )
+ {
+ trabalhador = ( Trabalhador ) value;
+ }
+ else if( fieldName.equals( MarcacaoTrabalhadorData.OBSERVACOES ) )
+ {
+ observacoes = ( String ) value;
+ }
+ }
+
+ public Class getOuterClass()
+ {
+ return MarcacaoTrabalhadorData.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhadorConstants.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhadorConstants.java
new file mode 100644
index 00000000..e0096a87
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhadorConstants.java
@@ -0,0 +1,17 @@
+/*
+ * MarcacaoTrabalhadorConstants.java
+ *
+ * Created on 11 de Outubro de 2004, 13:18
+ */
+
+package siprp.data;
+
+/**
+ *
+ * @author fpalma
+ */
+public interface MarcacaoTrabalhadorConstants
+{
+ public static final int TIPO_EXAMES = 0;
+ public static final int TIPO_CONSULTA = 1;
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhadorData.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhadorData.java
new file mode 100644
index 00000000..67273b67
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhadorData.java
@@ -0,0 +1,69 @@
+/*
+* MarcacaoTrabalhadorData.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on Jan 28, 2006
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.HashMap;
+import com.evolute.utils.jdo.*;
+
+public final class MarcacaoTrabalhadorData extends Marcacao
+ implements MarcacaoTrabalhadorConstants
+{
+ public static final String ID = "id";
+ public static final String DATA = "data";
+ public static final String REALIZADA = "realizada";
+ public static final String ESTADO = "estado";
+ public static final String MOTIVO = "motivo";
+ public static final String DATA_EMAIL = "data_email";
+ public static final String DATA_RELATORIO = "data_relatorio";
+ public static final String TIPO = "tipo";
+ public static final String TRABALHADOR = "trabalhador";
+ public static final String OBSERVACOES = "observacoes";
+
+ public static final String FIELD_NAMES[] = new String[]{
+ DATA, REALIZADA, ESTADO, MOTIVO, DATA_EMAIL, DATA_RELATORIO, TIPO, TRABALHADOR,
+ OBSERVACOES, };
+
+
+ protected static final String ALL_FIELD_NAMES[] = new String[]{
+ ID, DATA, REALIZADA, ESTADO, MOTIVO, DATA_EMAIL, DATA_RELATORIO, TIPO, TRABALHADOR,
+ OBSERVACOES, };
+
+ private HashMap dataHash;
+
+ public MarcacaoTrabalhadorData()
+ {
+ dataHash = new HashMap();
+ }
+
+ protected Object innerGet( String fieldName )
+ throws Exception
+ {
+ return dataHash.get( fieldName );
+ }
+
+ protected void innerSet( String fieldName, Object value )
+ throws Exception
+ {
+ dataHash.put( fieldName, value );
+ }
+
+ public String []getFieldNames()
+ {
+ return FIELD_NAMES;
+ }
+
+ protected String []getAllFieldNames()
+ {
+ return ALL_FIELD_NAMES;
+ }
+
+ public Class getInnerClass()
+ {
+ return MarcacaoTrabalhador.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhadorID.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhadorID.java
new file mode 100644
index 00000000..7dc15955
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhadorID.java
@@ -0,0 +1,25 @@
+/*
+* MarcacaoTrabalhadorID.java
+*
+* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on Jan 28, 2006
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.io.*;
+
+import com.evolute.utils.jdo.jpox.*;
+
+public final class MarcacaoTrabalhadorID extends IntegerID
+ implements Serializable
+{
+ public MarcacaoTrabalhadorID()
+ {
+ }
+
+ public MarcacaoTrabalhadorID( String str )
+ {
+ super( str );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/Medico.java b/trunk/SIPRPSoft/src/siprp/data/Medico.java
new file mode 100644
index 00000000..a9c4785e
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/Medico.java
@@ -0,0 +1,100 @@
+/*
+* Medico.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 27/Jan/2005
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import com.evolute.utils.jdo.*;
+
+public final class Medico implements JDOInnerObject
+{
+ private Integer id;
+ private String nome;
+ private String numero_cedula;
+ private String inactivo;
+
+ public Medico()
+ {
+ }
+
+ public Object getField( String fieldName )
+ {
+ if( fieldName == MedicoData.ID )
+ {
+ return id;
+ }
+ else if( fieldName == MedicoData.NOME )
+ {
+ return nome;
+ }
+ else if( fieldName == MedicoData.NUMERO_CEDULA )
+ {
+ return numero_cedula;
+ }
+ else if( fieldName == MedicoData.INACTIVO )
+ {
+ return inactivo;
+ }
+ else if( fieldName.equals( MedicoData.ID ) )
+ {
+ return id;
+ }
+ else if( fieldName.equals( MedicoData.NOME ) )
+ {
+ return nome;
+ }
+ else if( fieldName.equals( MedicoData.NUMERO_CEDULA ) )
+ {
+ return numero_cedula;
+ }
+ else if( fieldName.equals( MedicoData.INACTIVO ) )
+ {
+ return inactivo;
+ }
+ return null;
+ }
+
+ public void setField( String fieldName, Object value )
+ {
+ if( fieldName == MedicoData.ID )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName == MedicoData.NOME )
+ {
+ nome = ( String ) value;
+ }
+ else if( fieldName == MedicoData.NUMERO_CEDULA )
+ {
+ numero_cedula = ( String ) value;
+ }
+ else if( fieldName == MedicoData.INACTIVO )
+ {
+ inactivo = ( String ) value;
+ }
+ else if( fieldName.equals( MedicoData.ID ) )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName.equals( MedicoData.NOME ) )
+ {
+ nome = ( String ) value;
+ }
+ else if( fieldName.equals( MedicoData.NUMERO_CEDULA ) )
+ {
+ numero_cedula = ( String ) value;
+ }
+ else if( fieldName.equals( MedicoData.INACTIVO ) )
+ {
+ inactivo = ( String ) value;
+ }
+ }
+
+ public Class getOuterClass()
+ {
+ return MedicoData.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/MedicoData.java b/trunk/SIPRPSoft/src/siprp/data/MedicoData.java
new file mode 100644
index 00000000..6e385ce8
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/MedicoData.java
@@ -0,0 +1,61 @@
+/*
+* MedicoData.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 27/Jan/2005
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.HashMap;
+import com.evolute.utils.jdo.*;
+
+public final class MedicoData extends JDOObject
+ implements DisableDeleteable
+{
+ public static final String ID = "id";
+ public static final String NOME = "nome";
+ public static final String NUMERO_CEDULA = "numero_cedula";
+ public static final String INACTIVO = "inactivo";
+
+ public static final String FIELD_NAMES[] = new String[]{
+ NOME, NUMERO_CEDULA, };
+
+
+ protected static final String ALL_FIELD_NAMES[] = new String[]{
+ ID, NOME, NUMERO_CEDULA, INACTIVO, };
+
+ private HashMap dataHash;
+
+ public MedicoData()
+ {
+ dataHash = new HashMap();
+ }
+
+ protected Object innerGet( String fieldName )
+ throws Exception
+ {
+ return dataHash.get( fieldName );
+ }
+
+ protected void innerSet( String fieldName, Object value )
+ throws Exception
+ {
+ dataHash.put( fieldName, value );
+ }
+
+ public String []getFieldNames()
+ {
+ return FIELD_NAMES;
+ }
+
+ protected String []getAllFieldNames()
+ {
+ return ALL_FIELD_NAMES;
+ }
+
+ public Class getInnerClass()
+ {
+ return Medico.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/MedicoID.java b/trunk/SIPRPSoft/src/siprp/data/MedicoID.java
new file mode 100644
index 00000000..8c13efb7
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/MedicoID.java
@@ -0,0 +1,22 @@
+/*
+* MedicoID.java
+*
+* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 27/Jan/2005
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import com.evolute.utils.jdo.jpox.*;
+
+public final class MedicoID extends IntegerID
+{
+ public MedicoID()
+ {
+ }
+
+ public MedicoID( String str )
+ {
+ super( str );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/SearchExecuterFactory.java b/trunk/SIPRPSoft/src/siprp/data/SearchExecuterFactory.java
new file mode 100644
index 00000000..e011144d
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/SearchExecuterFactory.java
@@ -0,0 +1,180 @@
+/*
+ * SearchExecuterFactory.java
+ *
+ * Created on 24 de Maio de 2004, 19:30
+ */
+
+package siprp.data;
+
+import com.evolute.utils.*;
+import com.evolute.utils.arrays.*;
+import com.evolute.utils.db.*;
+import com.evolute.utils.sql.*;
+import com.evolute.utils.ui.search.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class SearchExecuterFactory
+{
+ private static SearchExecuter empresaExecuter;
+ private static SearchExecuter estabelecimentoExecuter;
+ private static SearchExecuter trabalhadorExecuter;
+
+
+
+ /** Creates a new instance of SearchExecuterFactory */
+ private SearchExecuterFactory()
+ {
+ }
+
+ public static SearchExecuter getSearchExecuter( Class objectClass )
+ {
+ if( objectClass.equals( EmpresaData.class ) )
+ {
+System.out.println( "Empresa" );
+ return getEmpresaSearchExecuter();
+ }
+ else if( objectClass == EstabelecimentoData.class )
+ {
+ return getEstabelecimentoSearchExecuter();
+ }
+ else if( objectClass == TrabalhadorData.class )
+ {
+ return getTrabalhadorSearchExecuter();
+ }
+ return null;
+ }
+
+ private static SearchExecuter getEmpresaSearchExecuter()
+ {
+ if( empresaExecuter == null )
+ {
+ empresaExecuter = new SearchExecuter(){
+
+ private final DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ );
+
+ public Virtual2DArray search( String pattern )
+ throws Exception
+ {
+
+ Executer executer = dbm.getSharedExecuter( this );
+ Select select = new Select( new String[]{ "empresas" },
+ new String[]{ EmpresaData.ID, EmpresaData.DESIGNACAO_SOCIAL, EmpresaData.DESIGNACAO_SOCIAL_PLAIN },
+ new Field( EmpresaData.DESIGNACAO_SOCIAL_PLAIN ).isLike( "%" + com.evolute.utils.strings.StringPlainer.convertString( pattern, false, false ) + "%" ).and(
+ new Field( EmpresaData.INACTIVO ).isDifferent( "y" ) ),
+ new String[]{ EmpresaData.DESIGNACAO_SOCIAL_PLAIN }, null );
+System.out.println( "SELECT : " + select );
+ return executer.executeQuery( select );
+ }
+
+ public boolean hasDetails()
+ {
+ return false;
+ }
+
+ public void showDetails( SearchDialog dialog, Object o )
+ throws Exception
+ {
+ }
+
+ public String getSearchTitle()
+ {
+ return "Procurar Empresa";
+ }
+
+ public String[] getColumnNames()
+ {
+ return new String[]{ "Designa\u00e7\u00e3o Social" };
+ }
+ };
+ }
+ return empresaExecuter;
+ }
+
+ private static SearchExecuter getEstabelecimentoSearchExecuter()
+ {
+ if( estabelecimentoExecuter == null )
+ {
+ estabelecimentoExecuter = new SearchExecuter(){
+ private final DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ );
+
+ public Virtual2DArray search( String pattern )
+ throws Exception
+ {
+ Executer executer = dbm.getSharedExecuter( this );
+ Select select = new Select( new String[]{ "estabelecimentos" },
+ new String[]{ EstabelecimentoData.ID, EstabelecimentoData.NOME, EstabelecimentoData.NOME_PLAIN },
+ new Field( EstabelecimentoData.NOME_PLAIN ).isLike( "%" + com.evolute.utils.strings.StringPlainer.convertString( pattern, false, false ) + "%" ),
+ new String[]{ EstabelecimentoData.NOME_PLAIN }, null );
+ return executer.executeQuery( select );
+ }
+
+ public boolean hasDetails()
+ {
+ return false;
+ }
+
+ public void showDetails( SearchDialog dialog, Object o )
+ throws Exception
+ {
+ }
+
+ public String getSearchTitle()
+ {
+ return "Procurar Estabelecimento";
+ }
+
+ public String[] getColumnNames()
+ {
+ return new String[]{ "Designa\u00e7\u00e3o" };
+ }
+ };
+ }
+ return estabelecimentoExecuter;
+ }
+
+
+ private static SearchExecuter getTrabalhadorSearchExecuter()
+ {
+ if( trabalhadorExecuter == null )
+ {
+ trabalhadorExecuter = new SearchExecuter(){
+ private final DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ );
+
+ public Virtual2DArray search( String pattern )
+ throws Exception
+ {
+ Executer executer = dbm.getSharedExecuter( this );
+ Select select = new Select( new String[]{ "trabalhadores" },
+ new String[]{ TrabalhadorData.ID, TrabalhadorData.NOME, TrabalhadorData.NOME_PLAIN },
+ new Field( TrabalhadorData.NOME_PLAIN ).isLike( "%" + com.evolute.utils.strings.StringPlainer.convertString( pattern, false, false ) + "%" ),
+ new String[]{ TrabalhadorData.NOME_PLAIN }, null );
+ return executer.executeQuery( select );
+ }
+
+ public boolean hasDetails()
+ {
+ return false;
+ }
+
+ public void showDetails( SearchDialog dialog, Object o )
+ throws Exception
+ {
+ }
+
+ public String getSearchTitle()
+ {
+ return "Procurar Trablhador";
+ }
+
+ public String[] getColumnNames()
+ {
+ return new String[]{ "Nome" };
+ }
+ };
+ }
+ return trabalhadorExecuter;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/TecnicoHST.java b/trunk/SIPRPSoft/src/siprp/data/TecnicoHST.java
new file mode 100644
index 00000000..352d6096
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/TecnicoHST.java
@@ -0,0 +1,134 @@
+/*
+* TecnicoHST.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on Feb 1, 2006
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import com.evolute.utils.jdo.*;
+
+public final class TecnicoHST implements JDOInnerObject
+{
+ private Integer id;
+ private String nome;
+ private String nome_plain;
+ private String iniciais;
+ private Integer identificador;
+ private String inactivo;
+
+ public TecnicoHST()
+ {
+ }
+
+ public Object getField( String fieldName )
+ {
+ if( fieldName == TecnicoHSTData.ID )
+ {
+ return id;
+ }
+ else if( fieldName == TecnicoHSTData.NOME )
+ {
+ return nome;
+ }
+ else if( fieldName == TecnicoHSTData.NOME_PLAIN )
+ {
+ return nome_plain;
+ }
+ else if( fieldName == TecnicoHSTData.INICIAIS )
+ {
+ return iniciais;
+ }
+ else if( fieldName == TecnicoHSTData.IDENTIFICADOR )
+ {
+ return identificador;
+ }
+ else if( fieldName == TecnicoHSTData.INACTIVO )
+ {
+ return inactivo;
+ }
+ else if( fieldName.equals( TecnicoHSTData.ID ) )
+ {
+ return id;
+ }
+ else if( fieldName.equals( TecnicoHSTData.NOME ) )
+ {
+ return nome;
+ }
+ else if( fieldName.equals( TecnicoHSTData.NOME_PLAIN ) )
+ {
+ return nome_plain;
+ }
+ else if( fieldName.equals( TecnicoHSTData.INICIAIS ) )
+ {
+ return iniciais;
+ }
+ else if( fieldName.equals( TecnicoHSTData.IDENTIFICADOR ) )
+ {
+ return identificador;
+ }
+ else if( fieldName.equals( TecnicoHSTData.INACTIVO ) )
+ {
+ return inactivo;
+ }
+ return null;
+ }
+
+ public void setField( String fieldName, Object value )
+ {
+ if( fieldName == TecnicoHSTData.ID )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName == TecnicoHSTData.NOME )
+ {
+ nome = ( String ) value;
+ }
+ else if( fieldName == TecnicoHSTData.NOME_PLAIN )
+ {
+ nome_plain = ( String ) value;
+ }
+ else if( fieldName == TecnicoHSTData.INICIAIS )
+ {
+ iniciais = ( String ) value;
+ }
+ else if( fieldName == TecnicoHSTData.IDENTIFICADOR )
+ {
+ identificador = ( Integer ) value;
+ }
+ else if( fieldName == TecnicoHSTData.INACTIVO )
+ {
+ inactivo = ( String ) value;
+ }
+ else if( fieldName.equals( TecnicoHSTData.ID ) )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName.equals( TecnicoHSTData.NOME ) )
+ {
+ nome = ( String ) value;
+ }
+ else if( fieldName.equals( TecnicoHSTData.NOME_PLAIN ) )
+ {
+ nome_plain = ( String ) value;
+ }
+ else if( fieldName.equals( TecnicoHSTData.INICIAIS ) )
+ {
+ iniciais = ( String ) value;
+ }
+ else if( fieldName.equals( TecnicoHSTData.IDENTIFICADOR ) )
+ {
+ identificador = ( Integer ) value;
+ }
+ else if( fieldName.equals( TecnicoHSTData.INACTIVO ) )
+ {
+ inactivo = ( String ) value;
+ }
+ }
+
+ public Class getOuterClass()
+ {
+ return TecnicoHSTData.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/TecnicoHSTData.java b/trunk/SIPRPSoft/src/siprp/data/TecnicoHSTData.java
new file mode 100644
index 00000000..1d70e935
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/TecnicoHSTData.java
@@ -0,0 +1,63 @@
+/*
+* TecnicoHSTData.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on Feb 1, 2006
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.HashMap;
+import com.evolute.utils.jdo.*;
+
+public final class TecnicoHSTData extends JDOObject
+ implements DisableDeleteable
+{
+ public static final String ID = "id";
+ public static final String NOME = "nome";
+ public static final String NOME_PLAIN = "nome_plain";
+ public static final String INICIAIS = "iniciais";
+ public static final String IDENTIFICADOR = "identificador";
+ public static final String INACTIVO = "inactivo";
+
+ public static final String FIELD_NAMES[] = new String[]{
+ NOME, NOME_PLAIN, INICIAIS, IDENTIFICADOR, };
+
+
+ protected static final String ALL_FIELD_NAMES[] = new String[]{
+ ID, NOME, NOME_PLAIN, INICIAIS, IDENTIFICADOR, INACTIVO, };
+
+ private HashMap dataHash;
+
+ public TecnicoHSTData()
+ {
+ dataHash = new HashMap();
+ }
+
+ protected Object innerGet( String fieldName )
+ throws Exception
+ {
+ return dataHash.get( fieldName );
+ }
+
+ protected void innerSet( String fieldName, Object value )
+ throws Exception
+ {
+ dataHash.put( fieldName, value );
+ }
+
+ public String []getFieldNames()
+ {
+ return FIELD_NAMES;
+ }
+
+ protected String []getAllFieldNames()
+ {
+ return ALL_FIELD_NAMES;
+ }
+
+ public Class getInnerClass()
+ {
+ return TecnicoHST.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/TecnicoHSTID.java b/trunk/SIPRPSoft/src/siprp/data/TecnicoHSTID.java
new file mode 100644
index 00000000..f7f90bd4
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/TecnicoHSTID.java
@@ -0,0 +1,25 @@
+/*
+* TecnicoHSTID.java
+*
+* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on Feb 1, 2006
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.io.*;
+
+import com.evolute.utils.jdo.jpox.*;
+
+public final class TecnicoHSTID extends IntegerID
+ implements Serializable
+{
+ public TecnicoHSTID()
+ {
+ }
+
+ public TecnicoHSTID( String str )
+ {
+ super( str );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/Trabalhador.java b/trunk/SIPRPSoft/src/siprp/data/Trabalhador.java
new file mode 100644
index 00000000..e7da2172
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/Trabalhador.java
@@ -0,0 +1,356 @@
+/*
+* Trabalhador.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 24/Nov/2005
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.Date;
+import com.evolute.utils.jdo.*;
+
+public final class Trabalhador implements JDOInnerObject
+{
+ private Integer id;
+ private String nome;
+ private String nome_plain;
+ private String sexo;
+ private Date data_nascimento;
+ private String nacionalidade;
+ private String numero_mecanografico;
+ private Date data_admissao;
+ private String categoria;
+ private String local_trabalho;
+ private String funcao_proposta;
+ private Date data_admissao_funcao;
+ private String observacoes;
+ private Estabelecimento estabelecimento;
+ private Date data_demissao;
+ private String observacoes_gestao;
+ private Integer perfil;
+ private String inactivo;
+ private Date actualizacao;
+
+ public Trabalhador()
+ {
+ }
+
+ public Object getField( String fieldName )
+ {
+ if( fieldName == TrabalhadorData.ID )
+ {
+ return id;
+ }
+ else if( fieldName == TrabalhadorData.NOME )
+ {
+ return nome;
+ }
+ else if( fieldName == TrabalhadorData.NOME_PLAIN )
+ {
+ return nome_plain;
+ }
+ else if( fieldName == TrabalhadorData.SEXO )
+ {
+ return sexo;
+ }
+ else if( fieldName == TrabalhadorData.DATA_NASCIMENTO )
+ {
+ return data_nascimento;
+ }
+ else if( fieldName == TrabalhadorData.NACIONALIDADE )
+ {
+ return nacionalidade;
+ }
+ else if( fieldName == TrabalhadorData.NUMERO_MECANOGRAFICO )
+ {
+ return numero_mecanografico;
+ }
+ else if( fieldName == TrabalhadorData.DATA_ADMISSAO )
+ {
+ return data_admissao;
+ }
+ else if( fieldName == TrabalhadorData.CATEGORIA )
+ {
+ return categoria;
+ }
+ else if( fieldName == TrabalhadorData.LOCAL_TRABALHO )
+ {
+ return local_trabalho;
+ }
+ else if( fieldName == TrabalhadorData.FUNCAO_PROPOSTA )
+ {
+ return funcao_proposta;
+ }
+ else if( fieldName == TrabalhadorData.DATA_ADMISSAO_FUNCAO )
+ {
+ return data_admissao_funcao;
+ }
+ else if( fieldName == TrabalhadorData.OBSERVACOES )
+ {
+ return observacoes;
+ }
+ else if( fieldName == TrabalhadorData.ESTABELECIMENTO )
+ {
+ return estabelecimento;
+ }
+ else if( fieldName == TrabalhadorData.DATA_DEMISSAO )
+ {
+ return data_demissao;
+ }
+ else if( fieldName == TrabalhadorData.OBSERVACOES_GESTAO )
+ {
+ return observacoes_gestao;
+ }
+ else if( fieldName == TrabalhadorData.PERFIL )
+ {
+ return perfil;
+ }
+ else if( fieldName == TrabalhadorData.INACTIVO )
+ {
+ return inactivo;
+ }
+ else if( fieldName == TrabalhadorData.ACTUALIZACAO )
+ {
+ return actualizacao;
+ }
+ else if( fieldName.equals( TrabalhadorData.ID ) )
+ {
+ return id;
+ }
+ else if( fieldName.equals( TrabalhadorData.NOME ) )
+ {
+ return nome;
+ }
+ else if( fieldName.equals( TrabalhadorData.NOME_PLAIN ) )
+ {
+ return nome_plain;
+ }
+ else if( fieldName.equals( TrabalhadorData.SEXO ) )
+ {
+ return sexo;
+ }
+ else if( fieldName.equals( TrabalhadorData.DATA_NASCIMENTO ) )
+ {
+ return data_nascimento;
+ }
+ else if( fieldName.equals( TrabalhadorData.NACIONALIDADE ) )
+ {
+ return nacionalidade;
+ }
+ else if( fieldName.equals( TrabalhadorData.NUMERO_MECANOGRAFICO ) )
+ {
+ return numero_mecanografico;
+ }
+ else if( fieldName.equals( TrabalhadorData.DATA_ADMISSAO ) )
+ {
+ return data_admissao;
+ }
+ else if( fieldName.equals( TrabalhadorData.CATEGORIA ) )
+ {
+ return categoria;
+ }
+ else if( fieldName.equals( TrabalhadorData.LOCAL_TRABALHO ) )
+ {
+ return local_trabalho;
+ }
+ else if( fieldName.equals( TrabalhadorData.FUNCAO_PROPOSTA ) )
+ {
+ return funcao_proposta;
+ }
+ else if( fieldName.equals( TrabalhadorData.DATA_ADMISSAO_FUNCAO ) )
+ {
+ return data_admissao_funcao;
+ }
+ else if( fieldName.equals( TrabalhadorData.OBSERVACOES ) )
+ {
+ return observacoes;
+ }
+ else if( fieldName.equals( TrabalhadorData.ESTABELECIMENTO ) )
+ {
+ return estabelecimento;
+ }
+ else if( fieldName.equals( TrabalhadorData.DATA_DEMISSAO ) )
+ {
+ return data_demissao;
+ }
+ else if( fieldName.equals( TrabalhadorData.OBSERVACOES_GESTAO ) )
+ {
+ return observacoes_gestao;
+ }
+ else if( fieldName.equals( TrabalhadorData.PERFIL ) )
+ {
+ return perfil;
+ }
+ else if( fieldName.equals( TrabalhadorData.INACTIVO ) )
+ {
+ return inactivo;
+ }
+ else if( fieldName.equals( TrabalhadorData.ACTUALIZACAO ) )
+ {
+ return actualizacao;
+ }
+ return null;
+ }
+
+ public void setField( String fieldName, Object value )
+ {
+ if( fieldName == TrabalhadorData.ID )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName == TrabalhadorData.NOME )
+ {
+ nome = ( String ) value;
+ }
+ else if( fieldName == TrabalhadorData.NOME_PLAIN )
+ {
+ nome_plain = ( String ) value;
+ }
+ else if( fieldName == TrabalhadorData.SEXO )
+ {
+ sexo = ( String ) value;
+ }
+ else if( fieldName == TrabalhadorData.DATA_NASCIMENTO )
+ {
+ data_nascimento = ( Date ) value;
+ }
+ else if( fieldName == TrabalhadorData.NACIONALIDADE )
+ {
+ nacionalidade = ( String ) value;
+ }
+ else if( fieldName == TrabalhadorData.NUMERO_MECANOGRAFICO )
+ {
+ numero_mecanografico = ( String ) value;
+ }
+ else if( fieldName == TrabalhadorData.DATA_ADMISSAO )
+ {
+ data_admissao = ( Date ) value;
+ }
+ else if( fieldName == TrabalhadorData.CATEGORIA )
+ {
+ categoria = ( String ) value;
+ }
+ else if( fieldName == TrabalhadorData.LOCAL_TRABALHO )
+ {
+ local_trabalho = ( String ) value;
+ }
+ else if( fieldName == TrabalhadorData.FUNCAO_PROPOSTA )
+ {
+ funcao_proposta = ( String ) value;
+ }
+ else if( fieldName == TrabalhadorData.DATA_ADMISSAO_FUNCAO )
+ {
+ data_admissao_funcao = ( Date ) value;
+ }
+ else if( fieldName == TrabalhadorData.OBSERVACOES )
+ {
+ observacoes = ( String ) value;
+ }
+ else if( fieldName == TrabalhadorData.ESTABELECIMENTO )
+ {
+ estabelecimento = ( Estabelecimento ) value;
+ }
+ else if( fieldName == TrabalhadorData.DATA_DEMISSAO )
+ {
+ data_demissao = ( Date ) value;
+ }
+ else if( fieldName == TrabalhadorData.OBSERVACOES_GESTAO )
+ {
+ observacoes_gestao = ( String ) value;
+ }
+ else if( fieldName == TrabalhadorData.PERFIL )
+ {
+ perfil = ( Integer ) value;
+ }
+ else if( fieldName == TrabalhadorData.INACTIVO )
+ {
+ inactivo = ( String ) value;
+ }
+ else if( fieldName == TrabalhadorData.ACTUALIZACAO )
+ {
+ actualizacao = ( Date ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.ID ) )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.NOME ) )
+ {
+ nome = ( String ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.NOME_PLAIN ) )
+ {
+ nome_plain = ( String ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.SEXO ) )
+ {
+ sexo = ( String ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.DATA_NASCIMENTO ) )
+ {
+ data_nascimento = ( Date ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.NACIONALIDADE ) )
+ {
+ nacionalidade = ( String ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.NUMERO_MECANOGRAFICO ) )
+ {
+ numero_mecanografico = ( String ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.DATA_ADMISSAO ) )
+ {
+ data_admissao = ( Date ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.CATEGORIA ) )
+ {
+ categoria = ( String ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.LOCAL_TRABALHO ) )
+ {
+ local_trabalho = ( String ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.FUNCAO_PROPOSTA ) )
+ {
+ funcao_proposta = ( String ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.DATA_ADMISSAO_FUNCAO ) )
+ {
+ data_admissao_funcao = ( Date ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.OBSERVACOES ) )
+ {
+ observacoes = ( String ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.ESTABELECIMENTO ) )
+ {
+ estabelecimento = ( Estabelecimento ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.DATA_DEMISSAO ) )
+ {
+ data_demissao = ( Date ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.OBSERVACOES_GESTAO ) )
+ {
+ observacoes_gestao = ( String ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.PERFIL ) )
+ {
+ perfil = ( Integer ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.INACTIVO ) )
+ {
+ inactivo = ( String ) value;
+ }
+ else if( fieldName.equals( TrabalhadorData.ACTUALIZACAO ) )
+ {
+ actualizacao = ( Date ) value;
+ }
+ }
+
+ public Class getOuterClass()
+ {
+ return TrabalhadorData.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/TrabalhadorData.java b/trunk/SIPRPSoft/src/siprp/data/TrabalhadorData.java
new file mode 100644
index 00000000..396b512f
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/TrabalhadorData.java
@@ -0,0 +1,82 @@
+/*
+* TrabalhadorData.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on 24/Nov/2005
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.util.HashMap;
+import com.evolute.utils.jdo.*;
+
+public final class TrabalhadorData extends JDOObject
+ implements DisableDeleteable, ActualizacaoSaveable
+{
+ public static final String ID = "id";
+ public static final String NOME = "nome";
+ public static final String NOME_PLAIN = "nome_plain";
+ public static final String SEXO = "sexo";
+ public static final String DATA_NASCIMENTO = "data_nascimento";
+ public static final String NACIONALIDADE = "nacionalidade";
+ public static final String NUMERO_MECANOGRAFICO = "numero_mecanografico";
+ public static final String DATA_ADMISSAO = "data_admissao";
+ public static final String CATEGORIA = "categoria";
+ public static final String LOCAL_TRABALHO = "local_trabalho";
+ public static final String FUNCAO_PROPOSTA = "funcao_proposta";
+ public static final String DATA_ADMISSAO_FUNCAO = "data_admissao_funcao";
+ public static final String OBSERVACOES = "observacoes";
+ public static final String ESTABELECIMENTO = "estabelecimento";
+ public static final String DATA_DEMISSAO = "data_demissao";
+ public static final String OBSERVACOES_GESTAO = "observacoes_gestao";
+ public static final String PERFIL = "perfil";
+ public static final String INACTIVO = "inactivo";
+ public static final String ACTUALIZACAO = "actualizacao";
+
+ public static final String FIELD_NAMES[] = new String[]{
+ NOME, NOME_PLAIN, SEXO, DATA_NASCIMENTO, NACIONALIDADE, NUMERO_MECANOGRAFICO,
+ DATA_ADMISSAO, CATEGORIA, LOCAL_TRABALHO, FUNCAO_PROPOSTA,
+ DATA_ADMISSAO_FUNCAO, OBSERVACOES, ESTABELECIMENTO, DATA_DEMISSAO,
+ OBSERVACOES_GESTAO, PERFIL, };
+
+
+ protected static final String ALL_FIELD_NAMES[] = new String[]{
+ ID, NOME, NOME_PLAIN, SEXO, DATA_NASCIMENTO, NACIONALIDADE, NUMERO_MECANOGRAFICO,
+ DATA_ADMISSAO, CATEGORIA, LOCAL_TRABALHO, FUNCAO_PROPOSTA,
+ DATA_ADMISSAO_FUNCAO, OBSERVACOES, ESTABELECIMENTO, DATA_DEMISSAO,
+ OBSERVACOES_GESTAO, PERFIL, INACTIVO, ACTUALIZACAO, };
+
+ private HashMap dataHash;
+
+ public TrabalhadorData()
+ {
+ dataHash = new HashMap();
+ }
+
+ protected Object innerGet( String fieldName )
+ throws Exception
+ {
+ return dataHash.get( fieldName );
+ }
+
+ protected void innerSet( String fieldName, Object value )
+ throws Exception
+ {
+ dataHash.put( fieldName, value );
+ }
+
+ public String []getFieldNames()
+ {
+ return FIELD_NAMES;
+ }
+
+ protected String []getAllFieldNames()
+ {
+ return ALL_FIELD_NAMES;
+ }
+
+ public Class getInnerClass()
+ {
+ return Trabalhador.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/TrabalhadorID.java b/trunk/SIPRPSoft/src/siprp/data/TrabalhadorID.java
new file mode 100644
index 00000000..6f37784d
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/TrabalhadorID.java
@@ -0,0 +1,25 @@
+/*
+* TrabalhadorID.java
+*
+* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 24/Nov/2005
+*
+* Use but DON'T TOUCH
+*/
+package siprp.data;
+
+import java.io.*;
+
+import com.evolute.utils.jdo.jpox.*;
+
+public final class TrabalhadorID extends IntegerID
+ implements Serializable
+{
+ public TrabalhadorID()
+ {
+ }
+
+ public TrabalhadorID( String str )
+ {
+ super( str );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/data/package.jdo b/trunk/SIPRPSoft/src/siprp/data/package.jdo
new file mode 100644
index 00000000..6911c812
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/data/package.jdo
@@ -0,0 +1,1122 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaDataProvider.java b/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaDataProvider.java
new file mode 100644
index 00000000..935afc49
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaDataProvider.java
@@ -0,0 +1,777 @@
+/*
+ * EstatisticaDataProvider.java
+ *
+ * Created on 16 de Dezembro de 2004, 12:50
+ */
+
+package siprp.estatistica;
+
+import java.text.*;
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.arrays.*;
+import com.evolute.utils.data.*;
+import com.evolute.utils.db.*;
+import com.evolute.utils.db.keyretrievers.*;
+import com.evolute.utils.metadb.*;
+import com.evolute.utils.sql.*;
+import com.evolute.utils.sql.expression.*;
+
+import siprp.data.*;
+/**
+ *
+ * @author fpalma
+ */
+public class EstatisticaDataProvider extends MetaProvider
+{
+ private static final Object LOCK = new Object();
+ private static EstatisticaDataProvider instance = null;
+ private final Executer executer;
+
+ public static final DateFormat DF = DateFormat.getDateInstance( DateFormat.SHORT );
+
+ /** Creates a new instance of EstatisticaDataProvider */
+ public EstatisticaDataProvider()
+ throws Exception
+ {
+ DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ );
+ executer = dbm.getSharedExecuter( this );
+ }
+
+ public static MetaProvider getProvider()
+ throws Exception
+ {
+ synchronized( LOCK )
+ {
+ if( instance == null )
+ {
+ instance = new EstatisticaDataProvider();
+ }
+ }
+ return instance;
+ }
+
+ public String[][] getMarcacoesPeriodo( Date dataInicio, Date dataFim )
+ throws Exception
+ {
+ String [][]result = null;
+ Select select =
+ new Select( new String[]{ "marcacoes_trabalhador" },
+ new String[]{ MarcacaoTrabalhadorData.DATA,
+ "trabalhador_id",
+ MarcacaoTrabalhadorData.REALIZADA,
+ MarcacaoTrabalhadorData.TIPO },
+ new Field( "data" ).isGreaterOrEqual( dataInicio ).and(
+ new Field( "data" ).isLessOrEqual( dataFim ) ),
+ new String[]{ "data" }, null );
+ Virtual2DArray array = executer.executeQuery( select );
+ result = new String[ array.columnLength() ][ 5 ];
+ for( int n = 0; n < result.length; n++ )
+ {
+ Date data = ( Date ) array.get( n, 0 );
+ int trabalhadorID = ( ( Number ) array.get( n, 1 ) ).intValue();
+ boolean realizada = "y".equals( array.get( n, 2 ) );
+ int tipo = ( ( Number ) array.get( n, 3 ) ).intValue();
+ String nomeEstabEmp[] = getNomeEstabelecimentoEmpresaForTrabalhador( trabalhadorID );
+ result[ n ][ 0 ] = nomeEstabEmp[ 2 ];
+ result[ n ][ 1 ] = nomeEstabEmp[ 0 ];
+ result[ n ][ 2 ] = nomeEstabEmp[ 1 ];
+ result[ n ][ 3 ] = DF.format( data );
+ result[ n ][ 4 ] = ( tipo == Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ? "(Exame)" : "(Consulta)" );
+
+ }
+ return result;
+ }
+
+ public String[] getNomeEstabelecimentoEmpresaForTrabalhador( int trabalhadorID )
+ throws Exception
+ {
+ String data[] = new String[ 3 ];
+ Select select =
+ new Select( new String[]{ "trabalhadores", "estabelecimentos", "empresas"},
+ new String[]{ "trabalhadores.nome", "estabelecimentos.nome", "empresas.designacao_social" },
+ new Field( "trabalhadores.id" ).isEqual( new Integer( trabalhadorID ) ).and(
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
+ new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ if( array.columnLength() == 1 )
+ {
+ data[ 0 ] = ( String ) array.get( 0, 0 );
+ data[ 1 ] = ( String ) array.get( 0, 1 );
+ data[ 2 ] = ( String ) array.get( 0, 2 );
+ }
+ return data;
+ }
+
+ public int countExamesPeriodo( Date dataInicio, Date dataFim )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "marcacoes_trabalhador" },
+ new String[]{ "count(*)" },
+ new Field( "data" ).isGreaterOrEqual( dataInicio ).and(
+ new Field( "data" ).isLessOrEqual( dataFim ) ).and(
+ new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
+ {
+ return 0;
+ }
+ return ( ( Number ) array.get( 0, 0 ) ).intValue();
+ }
+
+ public int countConsultasPeriodo( Date dataInicio, Date dataFim )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "marcacoes_trabalhador" },
+ new String[]{ "count(*)" },
+ new Field( "data" ).isGreaterOrEqual( dataInicio ).and(
+ new Field( "data" ).isLessOrEqual( dataFim ) ).and(
+ new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
+ {
+ return 0;
+ }
+ return ( ( Number ) array.get( 0, 0 ) ).intValue();
+ }
+
+ public int countExamesPeriodoForEmpresa( Date dataInicio, Date dataFim, Integer empresaID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos" },
+ new String[]{ "count(*)" },
+ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
+ new Field( "estabelecimentos.empresa_id" ).isEqual( empresaID ) ).and(
+ new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
+ new Field( "data" ).isLessOrEqual( dataFim ) ).and(
+ new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
+ {
+ return 0;
+ }
+ return ( ( Number ) array.get( 0, 0 ) ).intValue();
+ }
+
+ public int countConsultasPeriodoForEmpresa( Date dataInicio, Date dataFim, Integer empresaID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos" },
+ new String[]{ "count(*)" },
+ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
+ new Field( "estabelecimentos.empresa_id" ).isEqual( empresaID ) ).and(
+ new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
+ new Field( "data" ).isLessOrEqual( dataFim ) ).and(
+ new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
+ {
+ return 0;
+ }
+ return ( ( Number ) array.get( 0, 0 ) ).intValue();
+ }
+
+ public String[][] getMarcacoesPeriodoForEstabelecimento( Date dataInicio, Date dataFim, Integer estabelecimentoID )
+ throws Exception
+ {
+ String [][]result = null;
+ Select select =
+ new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores" },
+ new String[]{ MarcacaoTrabalhadorData.DATA,
+ "trabalhador_id",
+ MarcacaoTrabalhadorData.REALIZADA,
+ MarcacaoTrabalhadorData.TIPO },
+ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
+ new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
+ new Field( "data" ).isLessOrEqual( dataFim ) ),
+ new String[]{ "data" }, null );
+ Virtual2DArray array = executer.executeQuery( select );
+ result = new String[ array.columnLength() ][ 5 ];
+ for( int n = 0; n < result.length; n++ )
+ {
+ Date data = ( Date ) array.get( n, 0 );
+ int trabalhadorID = ( ( Number ) array.get( n, 1 ) ).intValue();
+ boolean realizada = "y".equals( array.get( n, 2 ) );
+ int tipo = ( ( Number ) array.get( n, 3 ) ).intValue();
+ String nomeEstabEmp[] = getNomeEstabelecimentoEmpresaForTrabalhador( trabalhadorID );
+ result[ n ][ 0 ] = nomeEstabEmp[ 2 ];
+ result[ n ][ 1 ] = nomeEstabEmp[ 0 ];
+ result[ n ][ 2 ] = nomeEstabEmp[ 1 ];
+ result[ n ][ 3 ] = DF.format( data );
+ result[ n ][ 4 ] = ( tipo == Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ? "(Exame)" : "(Consulta)" );
+
+ }
+ return result;
+ }
+
+ public int countExamesPeriodoForEstabelecimento( Date dataInicio, Date dataFim, Integer estabelecimentoID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores" },
+ new String[]{ "count(*)" },
+ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
+ new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
+ new Field( "data" ).isLessOrEqual( dataFim ) ).and(
+ new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
+ {
+ return 0;
+ }
+ return ( ( Number ) array.get( 0, 0 ) ).intValue();
+ }
+
+ public int countConsultasPeriodoForEstabelecimento( Date dataInicio, Date dataFim, Integer estabelecimentoID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores" },
+ new String[]{ "count(*)" },
+ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
+ new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
+ new Field( "data" ).isLessOrEqual( dataFim ) ).and(
+ new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
+ {
+ return 0;
+ }
+ return ( ( Number ) array.get( 0, 0 ) ).intValue();
+ }
+
+ public String[][] getTrabalhadoresSemExamesOuConsultas( Date dataInicio, Date dataFim, boolean exames )
+ throws Exception
+ {
+// Select subSelect =
+// new Select( new String[]{ "marcacoes_trabalhador" },
+// new String[]{ "trabalhador_id" },
+// new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ).and(
+// new Field( "realizada" ).isEqual( "y" ) ) );
+ Select select =
+ new Select( new String[]{ "empresas", "estabelecimentos",
+ "trabalhadores LEFT OUTER JOIN marcacoes_trabalhador ON "
+ + "( trabalhadores.id = marcacoes_trabalhador.trabalhador_id AND marcacoes_trabalhador.tipo = "
+ + (exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA) + " AND marcacoes_trabalhador.realizada = 'y' )" },
+ new String[]{ "empresas.designacao_social", "estabelecimentos.nome", "trabalhadores.nome",
+ "empresas.designacao_social_plain", "estabelecimentos.nome_plain", "trabalhadores.nome_plain" },
+ new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ).and(
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
+ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( null ) ).and(
+ new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
+ new Field( "trabalhadores.inactivo" ).isDifferent( "y" ).or(
+ new Field( "marcacoes_trabalhador.realizada" ).isDifferent( "y" ) ) ).and(
+ new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
+ new Field( "data" ).isLessOrEqual( dataFim ) ),
+ new String[]{ "empresas.designacao_social_plain", "estabelecimentos.nome_plain", "trabalhadores.nome_plain" }, null );
+ Virtual2DArray array = executer.executeQuery( select );
+ String data[][] = new String[ array.columnLength() ][ 3 ];
+ for( int r = 0; r < array.columnLength(); r++ )
+ {
+ for( int c = 0; c < 3; c++ )
+ {
+ data[ r ][ c ] = (String) array.get( r, c );
+ }
+ }
+ return data;
+ }
+
+
+
+ public int countTrabalhadoresSemExamesOuConsultas( Date dataInicio, Date dataFim, boolean exames )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "trabalhadores" }, new String[]{ "COUNT(*)" },
+ new Field( "inactivo" ).isDifferent( "y" ) );
+ int totalCount = 0;
+ Virtual2DArray array = executer.executeQuery( select );
+ if( array.columnLength() > 0 && array.rowLength() > 0 )
+ {
+ Number n = (Number) array.get( 0, 0 );
+ if( n != null )
+ {
+ totalCount = n.intValue();
+ }
+ }
+
+// select =
+// new Select( new String[]{ "marcacoes_trabalhador" },
+// new String[]{ "COUNT(*)" },
+// new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ).and(
+// new Field( "realizada" ).isEqual( "y" ) ).and(
+// new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
+// int subCount = 0;
+// array = executer.executeQuery( select );
+// if( array.columnLength() > 0 && array.rowLength() > 0 )
+// {
+// Number n = (Number) array.get( 0, 0 );
+// if( n != null )
+// {
+// subCount = n.intValue();
+// }
+// }
+
+ return totalCount - countTrabalhadoresComExamesOuConsultasPeriodo( dataInicio, dataFim, exames );
+ }
+
+ public String[][] getTrabalhadoresSemExamesOuConsultasEstabelecimento( Integer estabelecimentoID, Date dataInicio, Date dataFim, boolean exames )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "marcacoes_trabalhador" },
+ new String[]{ "trabalhador_id" },
+ new Field( "tipo" ).isEqual( new Integer( exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ).and(
+ new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
+ new Field( "data" ).isLessOrEqual( dataFim ) ).and(
+ new Field( "realizada" ).isEqual( "y" ) ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ Integer ids[] = new Integer[ array.columnLength() ];
+ for( int n = 0; n < ids.length; n++ )
+ {
+ ids[ n ] = ( Integer ) array.get( n, 0 );
+ }
+ if( ids.length == 0 )
+ {
+ ids = new Integer[]{ new Integer( -1 ) };
+ }
+ select =
+ new Select( new String[]{ "estabelecimentos",
+ "trabalhadores" },
+ new String[]{ "estabelecimentos.nome", "trabalhadores.nome" },
+ new Field( "estabelecimentos.id" ).isEqual( estabelecimentoID ).and(
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
+ new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
+ new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ).and(
+ new Field( "trabalhadores.id" ).notIn( ids ) ),
+ new String[]{ "trabalhadores.nome" }, null );
+// Select select =
+// new Select( new String[]{ "estabelecimentos",
+// "trabalhadores LEFT OUTER JOIN marcacoes_trabalhador ON "
+// + "( trabalhadores.id = marcacoes_trabalhador.trabalhador_id AND marcacoes_trabalhador.tipo = "
+// + (exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA) + " AND marcacoes_trabalhador.realizada = 'y' )" },
+// new String[]{ "estabelecimentos.nome", "trabalhadores.nome" },
+// new Field( "estabelecimentos.id" ).isEqual( estabelecimentoID ).and(
+// new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
+// new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
+// new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( null ).or(
+// new Field( "marcacoes_trabalhador.realizada" ).isDifferent( "y" ) ) ).and(
+// new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
+// new Field( "data" ).isLessOrEqual( dataFim ) ).and(
+// new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ),
+// new String[]{ "trabalhadores.nome" }, null );
+ array = executer.executeQuery( select );
+ String data[][] = new String[ array.columnLength() ][ 2 ];
+ for( int r = 0; r < array.columnLength(); r++ )
+ {
+ for( int c = 0; c < 2; c++ )
+ {
+ data[ r ][ c ] = (String) array.get( r, c );
+ }
+ }
+ return data;
+ }
+
+ public Object[][] getCountTrabalhadoresSemExamesOuConsultasPeriodoForAllEmpresas( Date dataInicio, Date dataFim, boolean exames )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "empresas" },
+ new String[]{ "id", "designacao_social", "designacao_social_plain" },
+ new Field( "inactivo" ).isDifferent( "y" ),
+ new String[]{ "designacao_social_plain" }, null );
+ Virtual2DArray array = executer.executeQuery( select );
+ Object data[][] = new Object[ array.columnLength() ][ 3 ];
+ for( int n = 0; n < data.length; n++ )
+ {
+ data[ n ][ 0 ] = array.get( n, 1 );
+ Integer empresaID = (Integer)array.get( n, 0 );
+ data[ n ][ 1 ] = new Integer( countTrabalhadoresSemExamesOuConsultasEmpresa( empresaID, dataInicio, dataFim, exames ) );
+ data[ n ][ 2 ] = empresaID;
+ }
+ return data;
+ }
+
+ public int countTrabalhadoresSemExamesOuConsultasEmpresa( Integer empresaID, Date dataInicio, Date dataFim, boolean exames )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "trabalhadores", "estabelecimentos" }, new String[]{ "COUNT(*)" },
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ).and(
+ new Field( "estabelecimentos.empresa_id" ).isEqual( empresaID ) ).and(
+ new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
+ new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
+ int totalCount = 0;
+ Virtual2DArray array = executer.executeQuery( select );
+ if( array.columnLength() > 0 && array.rowLength() > 0 )
+ {
+ Number n = (Number) array.get( 0, 0 );
+ if( n != null )
+ {
+ totalCount = n.intValue();
+ }
+ }
+
+// select =
+// new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos" },
+// new String[]{ "COUNT(*)" },
+// new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
+// new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
+// new Field( "estabelecimentos.empresa_id" ).isEqual( empresaID ) ).and(
+// new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ).and(
+// new Field( "realizada" ).isEqual( "y" ) ).and(
+// new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
+// int subCount = 0;
+// array = executer.executeQuery( select );
+// if( array.columnLength() > 0 && array.rowLength() > 0 )
+// {
+// Number n = (Number) array.get( 0, 0 );
+// if( n != null )
+// {
+// subCount = n.intValue();
+// }
+// }
+ return totalCount - countTrabalhadoresComExamesOuConsultasPeriodoForEmpresa( dataInicio, dataFim, empresaID, exames );
+ }
+
+ public int countTrabalhadoresSemExamesOuConsultasEstabelecimento( Integer estabelecimentoID, Date dataInicio, Date dataFim, boolean exames )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "trabalhadores" }, new String[]{ "COUNT(*)" },
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ).and(
+ new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
+ int totalCount = 0;
+ Virtual2DArray array = executer.executeQuery( select );
+ if( array.columnLength() > 0 && array.rowLength() > 0 )
+ {
+ Number n = (Number) array.get( 0, 0 );
+ if( n != null )
+ {
+ totalCount = n.intValue();
+ }
+ }
+
+// select =
+// new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores" },
+// new String[]{ "COUNT(*)" },
+// new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
+// new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
+// new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ).and(
+// new Field( "realizada" ).isEqual( "y" ) ).and(
+// new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
+// int subCount = 0;
+// array = executer.executeQuery( select );
+// if( array.columnLength() > 0 && array.rowLength() > 0 )
+// {
+// Number n = (Number) array.get( 0, 0 );
+// if( n != null )
+// {
+// subCount = n.intValue();
+// }
+// }
+ return totalCount - countTrabalhadoresComExamesOuConsultasPeriodoForEstabelecimento( dataInicio, dataFim, estabelecimentoID, exames );
+ }
+
+ public String[][]getTrabalhadoresComExamesOuConsultasPeriodo( Date dataInicio, Date dataFim, boolean exames )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "empresas", "estabelecimentos",
+ "trabalhadores", "marcacoes_trabalhador" },
+ new String[]{ "empresas.designacao_social", "estabelecimentos.nome", "trabalhadores.nome",
+ "empresas.designacao_social_plain", "estabelecimentos.nome_plain", "trabalhadores.nome_plain" },
+ new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ).and(
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
+ new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
+ new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ).and(
+ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ).and(
+ new Field( "marcacoes_trabalhador.tipo" ).isEqual( new Integer( exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
+ new Field( "marcacoes_trabalhador.realizada" ).isEqual( "y" ) ).and(
+ new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
+ new Field( "data" ).isLessOrEqual( dataFim ) ),
+ new String[]{ "empresas.designacao_social_plain", "estabelecimentos.nome_plain", "trabalhadores.nome_plain" }, null );
+ Virtual2DArray array = executer.executeQuery( select );
+ String data[][] = new String[ array.columnLength() ][ 3 ];
+ for( int r = 0; r < array.columnLength(); r++ )
+ {
+ for( int c = 0; c < 3; c++ )
+ {
+ data[ r ][ c ] = (String) array.get( r, c );
+ }
+ }
+ return data;
+ }
+
+ public int countTrabalhadoresComExamesOuConsultasPeriodo( Date dataInicio, Date dataFim, boolean exames )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores" },
+ new String[]{ "COUNT(*)" },
+ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
+ new Field( "tipo" ).isEqual( new Integer( exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
+ new Field( "realizada" ).isEqual( "y" ) ).and(
+ new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ).and(
+ new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
+ new Field( "data" ).isLessOrEqual( dataFim ) ) );
+ int count = 0;
+ Virtual2DArray array = executer.executeQuery( select );
+ if( array.columnLength() > 0 && array.rowLength() > 0 )
+ {
+ Number n = (Number) array.get( 0, 0 );
+ if( n != null )
+ {
+ count = n.intValue();
+ }
+ }
+ return count;
+ }
+
+ public String[][]getTrabalhadoresComExamesOuConsultasPeriodoForEstabelecimento( Date dataInicio, Date dataFim, Integer estabelecimentoID, boolean exames )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "estabelecimentos",
+ "trabalhadores", "marcacoes_trabalhador" },
+ new String[]{ "estabelecimentos.nome", "trabalhadores.nome" },
+ new Field( "estabelecimentos.id" ).isEqual( estabelecimentoID ).and(
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
+ new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
+ new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ).and(
+ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ).and(
+ new Field( "marcacoes_trabalhador.tipo" ).isEqual( new Integer( exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
+ new Field( "marcacoes_trabalhador.realizada" ).isEqual( "y" ) ).and(
+ new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
+ new Field( "data" ).isLessOrEqual( dataFim ) ),
+ new String[]{ "estabelecimentos.nome", "trabalhadores.nome" }, null );
+ Virtual2DArray array = executer.executeQuery( select );
+ String data[][] = new String[ array.columnLength() ][ 2 ];
+ for( int r = 0; r < array.columnLength(); r++ )
+ {
+ for( int c = 0; c < 2; c++ )
+ {
+ data[ r ][ c ] = (String) array.get( r, c );
+ }
+ }
+ return data;
+ }
+
+ public Object[][] getCountTrabalhadoresComExamesOuConsultasPeriodoForAllEmpresas( Date dataInicio, Date dataFim, boolean exames )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "empresas" },
+ new String[]{ "id", "designacao_social", "designacao_social_plain" },
+ new Field( "inactivo" ).isDifferent( "y" ),
+ new String[]{ "designacao_social_plain" }, null );
+ Virtual2DArray array = executer.executeQuery( select );
+ Object data[][] = new Object[ array.columnLength() ][ 3 ];
+ for( int n = 0; n < data.length; n++ )
+ {
+ data[ n ][ 0 ] = array.get( n, 1 );
+ Integer empresaID = (Integer)array.get( n, 0 );
+ data[ n ][ 1 ] = new Integer( countTrabalhadoresComExamesOuConsultasPeriodoForEmpresa( dataInicio, dataFim, empresaID, exames ) );
+ data[ n ][ 2 ] = empresaID;
+ }
+ return data;
+ }
+
+ public int countTrabalhadoresComExamesOuConsultasPeriodoForEmpresa( Date dataInicio, Date dataFim, Integer empresaID, boolean exames )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos" },
+ new String[]{ "COUNT(*)" },
+ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
+ new Field( "estabelecimentos.empresa_id" ).isEqual( empresaID ) ).and(
+ new Field( "tipo" ).isEqual( new Integer( exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
+ new Field( "realizada" ).isEqual( "y" ) ).and(
+ new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ).and(
+ new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
+ new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
+ new Field( "data" ).isLessOrEqual( dataFim ) ) );
+ int count = 0;
+ Virtual2DArray array = executer.executeQuery( select );
+ if( array.columnLength() > 0 && array.rowLength() > 0 )
+ {
+ Number n = (Number) array.get( 0, 0 );
+ if( n != null )
+ {
+ count = n.intValue();
+ }
+ }
+ return count;
+ }
+
+ public int countTrabalhadoresComExamesOuConsultasPeriodoForEstabelecimento( Date dataInicio, Date dataFim, Integer estabelecimentoID, boolean exames )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores" },
+ new String[]{ "COUNT(*)" },
+ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
+ new Field( "tipo" ).isEqual( new Integer( exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
+ new Field( "realizada" ).isEqual( "y" ) ).and(
+ new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ).and(
+ new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
+ new Field( "data" ).isLessOrEqual( dataFim ) ) );
+ int count = 0;
+ Virtual2DArray array = executer.executeQuery( select );
+ if( array.columnLength() > 0 && array.rowLength() > 0 )
+ {
+ Number n = (Number) array.get( 0, 0 );
+ if( n != null )
+ {
+ count = n.intValue();
+ }
+ }
+ return count;
+ }
+
+ public String [][]getDadosTrabalhadoresPeriodo( Date dataInicio, Date dataFim )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "empresas", "estabelecimentos", "trabalhadores" },
+ new String[]{ "empresas.designacao_social", "estabelecimentos.nome", "trabalhadores.nome", "trabalhadores.id",
+ "empresas.designacao_social_plain", "estabelecimentos.nome_plain", "trabalhadores.nome_plain" },
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ).and(
+ new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) ).and(
+ new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
+ new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ),
+ new String[]{ "empresas.designacao_social_plain", "estabelecimentos.nome_plain", "trabalhadores.nome_plain" }, null );
+
+ Virtual2DArray array = executer.executeQuery( select );
+ String data[][] = new String[ array.columnLength() ][ 7 ];
+ for( int n = 0; n < array.columnLength(); n++ )
+ {
+ data[ n ][ 0 ] = ( String ) array.get( n, 0 );
+ data[ n ][ 1 ] = ( String ) array.get( n, 1 );
+ data[ n ][ 2 ] = ( String ) array.get( n, 2 );
+ Integer id = new Integer( ( (Number) array.get( n, 3 ) ).intValue() );
+ Select exameSelect =
+ new Select( new String[]{ "trabalhadores", "marcacoes_trabalhador" },
+ new String[]{ "data", "realizada" },
+ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
+ new Field( "trabalhadores.id" ).isEqual( id ) ).and(
+ new Field( "marcacoes_trabalhador.data" ).isLessOrEqual( dataFim ) ).and(
+ new Field( "marcacoes_trabalhador.tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ),
+ new String[]{ "data desc" }, null );
+ Virtual2DArray exameArray = executer.executeQuery( exameSelect );
+ if( exameArray.columnLength() > 0 )
+ {
+ Date dataExame = ( Date ) exameArray.get( 0, 0 );
+ String estado = ( String ) exameArray.get( 0, 1 );
+ data[ n ][ 3 ] = DF.format( dataExame );
+ data[ n ][ 4 ] = "y".equals( estado ) ? "Realizado" : "Faltou";
+ }
+ else
+ {
+ data[ n ][ 3 ] = "--";
+ data[ n ][ 4 ] = "--";
+ }
+
+ Select consultaSelect =
+ new Select( new String[]{ "trabalhadores", "marcacoes_trabalhador" },
+ new String[]{ "data", "realizada" },
+ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
+ new Field( "trabalhadores.id" ).isEqual( id ) ).and(
+ new Field( "marcacoes_trabalhador.data" ).isLessOrEqual( dataFim ) ).and(
+ new Field( "marcacoes_trabalhador.tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ),
+ new String[]{ "data desc" }, null );
+ Virtual2DArray consultaArray = executer.executeQuery( consultaSelect );
+ if( consultaArray.columnLength() > 0 )
+ {
+ Date dataConsulta = ( Date ) consultaArray.get( 0, 0 );
+ String estado = ( String ) consultaArray.get( 0, 1 );
+ data[ n ][ 5 ] = DF.format( dataConsulta );
+ data[ n ][ 6 ] = "y".equals( estado ) ? "Realizada" : "Faltou";
+ }
+ else
+ {
+ data[ n ][ 5 ] = "--";
+ data[ n ][ 6 ] = "--";
+ }
+ }
+ return data;
+ }
+
+ public String[][]getDadosHigieneSeguranca()
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "empresas", "estabelecimentos" },
+ new String[]{ "empresas.designacao_social", "estabelecimentos.nome", "estabelecimentos.id",
+ "empresas.designacao_social_plain", "estabelecimentos.nome_plain" },
+ new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ).and(
+ new Field( "empresas.inactivo" ).isDifferent( "y" ) ).and(
+ new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ),
+ new String[]{ "empresas.designacao_social_plain", "estabelecimentos.nome_plain" }, null );
+
+ Virtual2DArray array = executer.executeQuery( select );
+ String data[][] = new String[ array.columnLength() ][ 6 ];
+ for( int n = 0; n < array.columnLength(); n++ )
+ {
+ data[ n ][ 0 ] = ( String ) array.get( n, 0 );
+ data[ n ][ 1 ] = ( String ) array.get( n, 1 );
+ Integer id = new Integer( ( (Number) array.get( n, 2 ) ).intValue() );
+ Select ultimaSelect =
+ new Select( new String[]{ "marcacoes_estabelecimento" },
+ new String[]{ "data", "realizada", "data_relatorio" },
+ new Field( "marcacoes_estabelecimento.estabelecimento_id" ).isEqual( id ).and(
+ new Field( "marcacoes_estabelecimento.data" ).isLessOrEqual( new Date() ) ),
+ new String[]{ "data desc" }, null );
+ Virtual2DArray ultimaArray = executer.executeQuery( ultimaSelect );
+ if( ultimaArray.columnLength() > 0 )
+ {
+ Date dataAud = ( Date ) ultimaArray.get( 0, 0 );
+ String estado = ( String ) ultimaArray.get( 0, 1 );
+ Date dataRel = ( Date ) ultimaArray.get( 0, 2 );
+ data[ n ][ 2 ] = DF.format( dataAud );
+ data[ n ][ 3 ] = "y".equals( estado ) ? "Realizada" : "Não Realizada";
+ data[ n ][ 4 ] = dataRel != null ? DF.format( dataRel ) : "--";
+ }
+ else
+ {
+ data[ n ][ 2 ] = "--";
+ data[ n ][ 3 ] = "--";
+ data[ n ][ 4 ] = "--";
+ }
+
+ Select proximaSelect =
+ new Select( new String[]{ "marcacoes_estabelecimento" },
+ new String[]{ "data" },
+ new Field( "marcacoes_estabelecimento.estabelecimento_id" ).isEqual( id ).and(
+ new Field( "marcacoes_estabelecimento.data" ).isGreaterOrEqual( new Date() ) ),
+ new String[]{ "data desc" }, null );
+ Virtual2DArray proximaArray = executer.executeQuery( proximaSelect );
+ if( proximaArray.columnLength() > 0 )
+ {
+ Date dataProx = ( Date ) proximaArray.get( 0, 0 );
+ data[ n ][ 5 ] = DF.format( dataProx );
+ }
+ else
+ {
+ data[ n ][ 5 ] = "--";
+ }
+ }
+ return data;
+ }
+
+
+
+}
+
diff --git a/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaWindow.java b/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaWindow.java
new file mode 100644
index 00000000..eb4fed2f
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaWindow.java
@@ -0,0 +1,1324 @@
+/*
+ * EstatisticaWindow.java
+ *
+ * Created on 16 de Dezembro de 2004, 13:50
+ */
+
+package siprp.estatistica;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.io.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.text.*;
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.data.*;
+import com.evolute.utils.documents.*;
+import com.evolute.utils.jdo.*;
+import com.evolute.utils.tables.*;
+import com.evolute.utils.tracker.*;
+import com.evolute.utils.ui.*;
+import com.evolute.utils.ui.calendar.*;
+import com.evolute.utils.ui.text.*;
+
+import siprp.data.*;
+import siprp.pesquisas.*;
+/**
+ *
+ * @author fpalma
+ */
+public class EstatisticaWindow extends JFrame
+ implements TrackableWindow, ListSelectionListener, ActionListener, ItemListener
+{
+ public static final DateFormat DF = DateFormat.getDateInstance( DateFormat.SHORT );
+
+ public static final int NONE = 0;
+ public static final int LISTAGEM_GERAL_MARCACOES_PERIODO = 1;
+ public static final int LISTAGEM_MARCACOES_PERIODO_EMPRESA_ESTABELECIMENTO = 2;
+ public static final int LISTAGEM_GLOBAL_TRABALHADORES_SEM_EXAMES = 3;
+ public static final int LISTAGEM_TRABALHADORES_SEM_EXAMES_EMPRESA_ESTABELECIMENTO = 4;
+ public static final int LISTAGEM_GLOBAL_TRABALHADORES_COM_EXAMES_PERIODO = 5;
+ public static final int LISTAGEM_TRABALHADORES_COM_EXAMES_PERIODO_EMPRESA_ESTABELECIMENTO = 6;
+ public static final int LISTAGEM_GLOBAL_TRABALHADORES_SEM_CONSULTA = 7;
+ public static final int LISTAGEM_TRABALHADORES_SEM_CONSULTA_EMPRESA_ESTABELECIMENTO = 8;
+ public static final int LISTAGEM_GLOBAL_TRABALHADORES_COM_CONSULTA_PERIODO = 9;
+ public static final int LISTAGEM_TRABALHADORES_COM_CONSULTA_PERIODO_EMPRESA_ESTABELECIMENTO = 10;
+ public static final int LISTAGEM_GLOBAL_TRABALHADORES_PERIODO = -1;
+ public static final int LISTAGEM_GLOBAL_HIGIENE_SEGURANCA = 11;
+
+ public static final String ESTATISTICAS[] =
+ new String[]{ "",
+ "Marca\u00e7\u00f5es efectuadas e pendentes (geral)",
+ "Marca\u00e7\u00f5es efectuadas e pendentes (por Empresa e Estabelecimento)",
+ "Contagem global de trabalhadores que ainda n\u00e3o realizaram exames (por per\u00edodo)",
+ "Listagem de trabalhadores que ainda n\u00e3o realizaram exames (por per\u00edodo, Empresa e Estabelecimento)",
+ "Contagem global de trabalhadores que j\u00e1 realizaram exames (por per\u00edodo)",
+ "Listagem de trabalhadores que j\u00e1 realizaram exames (por per\u00edodo, Empresa e Estabelecimento)",
+ "Contagem global de trabalhadores que ainda n\u00e3o realizaram consultas (por per\u00edodo)",
+ "Listagem de trabalhadores que ainda n\u00e3o realizaram consultas (por per\u00edodo, Empresa e Estabelecimento)",
+ "Contagem global de trabalhadores que j\u00e1 realizaram consultas (por per\u00edodo)",
+ "Listagem de trabalhadores que j\u00e1 realizaram consultas (por per\u00edodo, Empresa e Estabelecimento)",
+ //"Listagem global de trabalhadores (por per\u00edodo)",
+ "Listagem global com os dados de higiene e seguran\u00e7a" };
+
+
+ public static final int OPTION_INTERVALO = 0;
+ public static final int OPTION_ANO = 1;
+ public static final int OPTION_EMPRESA = 2;
+ public static final int OPTION_ESTABELECIMENTO = 0;
+
+ public static final boolean ESTATISTICAS_OPTIONS[][] =
+ // intervalo, ano, empresa, estabelecimento
+ new boolean[][]{ { false, false, false, false },
+ { true, false, false, false },
+ { true, false, true, true },
+ { true, false, false, false },
+ { true, false, true, true },
+ { true, false, false, false },
+ { true, false, true, true },
+ { true, false, false, false },
+ { true, false, true, true },
+ { true, false, false, false },
+ { true, false, true, true },
+// { true, false, false, false },
+ { false, false, false, false } };
+
+ private JDOProvider JDO;
+ private EstatisticaDataProvider provider;
+ private PesquisasProvider pesquisasProvider;
+
+ private JComboBox estatisticaCombo;
+ private JCalendarPanel dataInicioPanel;
+ private JCalendarPanel dataFimPanel;
+ private JTextField anoText;
+ private BaseTable empresasTable;
+ private VectorTableModel empresasModel;
+ private BaseTable estabelecimentosTable;
+ private VectorTableModel estabelecimentosModel;
+ private JButton pesquisarButton;
+ private JButton excelButton;
+ private JEditorPane resultadoText;
+
+ /** Creates a new instance of EstatisticaWindow */
+ public EstatisticaWindow()
+ throws Exception
+ {
+ provider = (EstatisticaDataProvider)EstatisticaDataProvider.getProvider();
+ pesquisasProvider = (PesquisasProvider)PesquisasProvider.getProvider();
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ setupComponents();
+ }
+
+ private void setupComponents()
+ {
+ setSize( 1000, 700 );
+ setTitle( "Listagens" );
+
+ JLabel estatisticaLabel = new JLabel( "Listagem" );
+ estatisticaCombo = new JComboBox();
+ for( int n = 0; n < ESTATISTICAS.length; n++ )
+ {
+ estatisticaCombo.addItem( ESTATISTICAS[ n ] );
+ }
+ estatisticaCombo.setSelectedIndex( 0 );
+ estatisticaCombo.addItemListener( this );
+ estatisticaCombo.setPreferredSize( new Dimension( 700, 20 ) );
+ JLabel intervalo1Label = new JLabel( "De" );
+ JLabel intervalo2Label = new JLabel( "a" );
+ dataInicioPanel = new JCalendarPanel( null );
+ dataInicioPanel.setPreferredSize( new Dimension( 200, 20 ) );
+ dataFimPanel = new JCalendarPanel( null );
+ dataFimPanel.setPreferredSize( new Dimension( 200, 20 ) );
+
+ JLabel anoLabel = new JLabel( "Ano" );
+ anoText = new JTextField();
+ anoText.setDocument( new YearDocument() );
+ anoText.setPreferredSize( new Dimension( 50, 20 ) );
+ new CopyPasteHandler( anoText );
+
+ empresasModel = new VectorTableModel( new String[]{ "Designa\u00e7\u00e3o Social" } );
+ empresasTable = new BaseTable( empresasModel );
+ empresasTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ empresasTable.setNonResizableNorReordable();
+ empresasTable.getSelectionModel().addListSelectionListener( this );
+ JScrollPane empresasScroll = new JScrollPane();
+ empresasScroll.setBorder( BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(), "Empresa" ) );
+ empresasScroll.setViewportView( empresasTable );
+ empresasScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ empresasScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
+ empresasScroll.getVerticalScrollBar().setBlockIncrement(20);
+
+ estabelecimentosModel = new VectorTableModel( new String[]{ "Nome" } );
+ estabelecimentosTable = new BaseTable( estabelecimentosModel );
+ estabelecimentosTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ estabelecimentosTable.setNonResizableNorReordable();
+ estabelecimentosTable.getSelectionModel().addListSelectionListener( this );
+ JScrollPane estabelecimentosScroll = new JScrollPane();
+ estabelecimentosScroll.setBorder( BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(), "Estabelecimento" ) );
+ estabelecimentosScroll.setViewportView( estabelecimentosTable );
+ estabelecimentosScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ estabelecimentosScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
+
+ pesquisarButton = new JButton( "Pesquisar" );
+ pesquisarButton.addActionListener( this );
+ excelButton = new JButton( "Exportar" );
+ excelButton.addActionListener( this );
+
+ resultadoText = new JEditorPane( "text/html", "" );
+ resultadoText.setEditable( false );
+// resultadoText.setLineWrap( true );
+// resultadoText.setWrapStyleWord( true );
+ new CopyPasteHandler( resultadoText );
+ JScrollPane resultadoScroll = new JScrollPane();
+ resultadoScroll.setViewportView( resultadoText );
+ resultadoScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS );
+ resultadoScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
+
+ JPanel pad;
+
+ GridBagLayout gridbag = new GridBagLayout();
+ getContentPane().setLayout( gridbag );
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.insets = new Insets( 5, 5, 5, 5 );
+
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ constraints.weighty = 0;
+ constraints.gridheight = 1;
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+
+ JPanel escolhaEstatisticaPanel = new JPanel();
+ escolhaEstatisticaPanel.setLayout( new FlowLayout( FlowLayout.LEFT ) );
+ escolhaEstatisticaPanel.add( estatisticaLabel );
+ escolhaEstatisticaPanel.add( estatisticaCombo );
+ gridbag.setConstraints( escolhaEstatisticaPanel, constraints );
+ getContentPane().add( escolhaEstatisticaPanel );
+
+ JPanel periodoPanel = new JPanel();
+ periodoPanel.setLayout( new FlowLayout( FlowLayout.LEFT ) );
+ periodoPanel.add( intervalo1Label );
+ periodoPanel.add( dataInicioPanel );
+ periodoPanel.add( intervalo2Label );
+ periodoPanel.add( dataFimPanel );
+ gridbag.setConstraints( periodoPanel, constraints );
+ getContentPane().add( periodoPanel );
+
+ JPanel anoPanel = new JPanel();
+ anoPanel.setLayout( new FlowLayout( FlowLayout.LEFT ) );
+ anoPanel.add( anoLabel );
+ anoPanel.add( anoText );
+ gridbag.setConstraints( anoPanel, constraints );
+ getContentPane().add( anoPanel );
+
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.weighty = 0.2;
+ constraints.gridheight = 2;
+ constraints.weightx = 0.3;
+ constraints.gridwidth = 3;
+ gridbag.setConstraints( empresasScroll, constraints );
+ getContentPane().add( empresasScroll );
+
+ gridbag.setConstraints( estabelecimentosScroll, constraints );
+ getContentPane().add( estabelecimentosScroll );
+
+ constraints.weighty = 0;
+ constraints.gridheight = 1;
+ constraints.weightx = 0.4;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ pad = new JPanel();
+ gridbag.setConstraints( pad, constraints );
+ getContentPane().add( pad );
+
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ constraints.weighty = 0;
+ constraints.gridheight = 1;
+ constraints.weightx = 0;
+ constraints.gridwidth = 1;
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setLayout( new GridLayout( 1, 1 ) );
+ buttonPanel.add( pesquisarButton );
+ buttonPanel.add( excelButton );
+ gridbag.setConstraints( buttonPanel, constraints );
+ getContentPane().add( buttonPanel );
+
+ constraints.weighty = 0;
+ constraints.gridheight = 1;
+ constraints.weightx = 0.4;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ pad = new JPanel();
+ gridbag.setConstraints( pad, constraints );
+ getContentPane().add( pad );
+
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.weighty = 0.8;
+ constraints.gridheight = GridBagConstraints.REMAINDER;
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( resultadoScroll, constraints );
+ getContentPane().add( resultadoScroll );
+
+ processarEscolha();
+ }
+
+ public void actionPerformed(java.awt.event.ActionEvent e)
+ {
+ Object source = e.getSource();
+ if( source.equals( pesquisarButton ) )
+ {
+ int index = estatisticaCombo.getSelectedIndex();
+ switch( index )
+ {
+ case LISTAGEM_GERAL_MARCACOES_PERIODO:
+ listagemGeralMarcacoesPeriodo();
+ break;
+
+ case LISTAGEM_MARCACOES_PERIODO_EMPRESA_ESTABELECIMENTO:
+ listagemMarcacoesPeriodoEmpresaEstabelecimento();
+ break;
+
+ case LISTAGEM_GLOBAL_TRABALHADORES_SEM_EXAMES:
+ listagemGeralTrabalhadoresSemExamesOuConsultas( true );
+ break;
+
+ case LISTAGEM_TRABALHADORES_SEM_EXAMES_EMPRESA_ESTABELECIMENTO:
+ listagemTrabalhadoresSemExamesOuConsultasEmpresaEstabelecimento( true );
+ break;
+
+ case LISTAGEM_GLOBAL_TRABALHADORES_COM_EXAMES_PERIODO:
+ listagemGeralTrabalhadoresComExamesOuConsultasPeriodo( true );
+ break;
+
+ case LISTAGEM_TRABALHADORES_COM_EXAMES_PERIODO_EMPRESA_ESTABELECIMENTO:
+ listagemGeralTrabalhadoresComExamesOuConsultasPeriodoEmpresaEstabelecimento( true );
+ break;
+
+ case LISTAGEM_GLOBAL_TRABALHADORES_SEM_CONSULTA:
+ listagemGeralTrabalhadoresSemExamesOuConsultas( false );
+ break;
+
+ case LISTAGEM_TRABALHADORES_SEM_CONSULTA_EMPRESA_ESTABELECIMENTO:
+ listagemTrabalhadoresSemExamesOuConsultasEmpresaEstabelecimento( false );
+ break;
+
+ case LISTAGEM_GLOBAL_TRABALHADORES_COM_CONSULTA_PERIODO:
+ listagemGeralTrabalhadoresComExamesOuConsultasPeriodo( false );
+ break;
+
+ case LISTAGEM_TRABALHADORES_COM_CONSULTA_PERIODO_EMPRESA_ESTABELECIMENTO:
+ listagemGeralTrabalhadoresComExamesOuConsultasPeriodoEmpresaEstabelecimento( false );
+ break;
+
+ case LISTAGEM_GLOBAL_TRABALHADORES_PERIODO:
+ listagemGeralTrabalhadoresPeriodo();
+ break;
+
+ case LISTAGEM_GLOBAL_HIGIENE_SEGURANCA:
+ listagemGlobalHigieneSeguranca();
+ break;
+ }
+ }
+ else if( source.equals( excelButton ) )
+ {
+ exportar();
+ }
+ }
+
+ private boolean close()
+ {
+ setVisible( false );
+ dispose();
+ return true;
+ }
+
+ public boolean closeIfPossible()
+ {
+ return close();
+ }
+
+ public void open()
+ {
+ empresasTable.clearSelection();
+ estatisticaCombo.setSelectedIndex( 0 );
+ try
+ {
+ IDObject empresas[] = pesquisasProvider.getAllEmpresas();
+ empresasModel.setValues( new Vector( Arrays.asList( empresas ) ) );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
+ }
+ setVisible( true );
+ }
+
+ public void refresh()
+ {
+ setVisible( true );
+ }
+
+ public void valueChanged(javax.swing.event.ListSelectionEvent e)
+ {
+ Object source = e.getSource();
+ if( source.equals( empresasTable.getSelectionModel() ) )
+ {
+ estabelecimentosTable.clearSelection();
+ int selected = empresasTable.getSelectedRow();
+ if( selected == -1 )
+ {
+ return;
+ }
+ IDObject empresa = (IDObject) empresasModel.getRowAt( selected );
+ estabelecimentosModel.clearAll();
+ IDObject estabelecimentos[];
+ try
+ {
+ estabelecimentos = pesquisasProvider.getAllEstabelecimentosForEmpresa( empresa.getID() );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar os estabelecimentos", true );
+ return;
+ }
+ Vector v = new Vector( Arrays.asList( estabelecimentos ) );
+ v.add( new MappableObject( new Integer( -1 ), "TODOS" ) );
+ estabelecimentosModel.setValues( v );
+ }
+ }
+
+ public void itemStateChanged(java.awt.event.ItemEvent itemEvent)
+ {
+ processarEscolha();
+ }
+
+ protected void processarEscolha()
+ {
+ int index = estatisticaCombo.getSelectedIndex();
+ boolean optionLine[] = ESTATISTICAS_OPTIONS[ index ];
+ dataInicioPanel.setEnabled( optionLine[ OPTION_INTERVALO ] );
+ dataFimPanel.setEnabled( optionLine[ OPTION_INTERVALO ] );
+ anoText.setEnabled( optionLine[ OPTION_ANO ] );
+ empresasTable.setEnabled( optionLine[ OPTION_EMPRESA ] );
+ estabelecimentosTable.setEnabled( optionLine[ OPTION_ESTABELECIMENTO ] );
+ pesquisarButton.setEnabled( index != NONE );
+ }
+
+ protected void listagemGeralMarcacoesPeriodo()
+ {
+ try
+ {
+ Date inicio = dataInicioPanel.getDate();
+ Date fim = dataFimPanel.getDate();
+ if( inicio == null || fim == null )
+ {
+ JOptionPane.showMessageDialog( this, "Tem de escolher o intervalo de datas.", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ resultadoText.setText( "ERRO!" );
+ return;
+ }
+ if( inicio.after( fim ) )
+ {
+ JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ resultadoText.setText( "ERRO!" );
+ return;
+ }
+ StringBuffer buffer = new StringBuffer();
+ int exames = provider.countExamesPeriodo( inicio, fim );
+ int consultas = provider.countConsultasPeriodo( inicio, fim );
+ int total = exames + consultas;
+ buffer.append( "" );
+ buffer.append( "" + ESTATISTICAS[ LISTAGEM_GERAL_MARCACOES_PERIODO ] + "" );
+ buffer.append( "
" );
+ buffer.append( "
" );
+ buffer.append( "" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "PER\u00cdODO:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + DF.format( dataInicioPanel.getDate() ) + " a "
+ + DF.format( dataFimPanel.getDate() ) + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "EXAMES:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + exames + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "CONSULTAS:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + consultas + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "TOTAL:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + ( exames + consultas ) + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "EMPRESA" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "NOME" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "ESTABELECIMENTO" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "DATA" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( " " );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ String data[][] = provider.getMarcacoesPeriodo( inicio, fim );
+ for( int l = 0; l < data.length; l++ )
+ {
+ buffer.append( "" );
+ for( int c = 0; c < data[ l ].length; c++ )
+ {
+ buffer.append( "| " );
+ buffer.append( "" + data[ l ][ c ] + "" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ }
+ buffer.append( "
" );
+ }
+ buffer.append( "
" );
+ resultadoText.setText( buffer.toString() );
+ }
+ catch( Exception ex )
+ {
+ resultadoText.setText( "ERRO a carregar dados!" );
+ ex.printStackTrace();
+ }
+ }
+
+ protected void listagemMarcacoesPeriodoEmpresaEstabelecimento()
+ {
+ try
+ {
+ Date inicio = dataInicioPanel.getDate();
+ Date fim = dataFimPanel.getDate();
+ int sEmpresa = empresasTable.getSelectedRow();
+ int sEstabelecimento = estabelecimentosTable.getSelectedRow();
+ if( inicio == null || fim == null || sEmpresa == -1 )
+ {
+ JOptionPane.showMessageDialog( this, "Tem de escolher Empresa e intervalo de datas.", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ resultadoText.setText( "ERRO!" );
+ return;
+ }
+ if( inicio.after( fim ) )
+ {
+ JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ resultadoText.setText( "ERRO!" );
+ return;
+ }
+ StringBuffer buffer = new StringBuffer();
+ Integer idEmpresa = ( (IDObject)empresasModel.getRowAt( sEmpresa ) ).getID();
+ EmpresaData empresa = (EmpresaData)JDO.load( EmpresaData.class, idEmpresa );
+ String designacao = (String)empresa.get( EmpresaData.DESIGNACAO_SOCIAL );
+ IDObject estabelecimentos[];
+ if( sEstabelecimento == -1 || ( ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento ) ).getID().equals( new Integer( -1 ) ) )
+ {
+ estabelecimentos = pesquisasProvider.getAllEstabelecimentosForEmpresa( idEmpresa );
+ }
+ else
+ {
+ estabelecimentos = new IDObject[ 1 ];
+ estabelecimentos[ 0 ] = ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento );
+ }
+ int examesEmpresa = provider.countExamesPeriodoForEmpresa( inicio, fim, idEmpresa );
+ int consultasEmpresa = provider.countConsultasPeriodoForEmpresa( inicio, fim, idEmpresa );
+ buffer.append( "" );
+ buffer.append( "" + ESTATISTICAS[ LISTAGEM_MARCACOES_PERIODO_EMPRESA_ESTABELECIMENTO ] + "" );
+ buffer.append( "
" );
+ buffer.append( "
" );
+ buffer.append( "" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "EMPRESA:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + designacao + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "PER\u00cdODO:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + DF.format( dataInicioPanel.getDate() ) + " a "
+ + DF.format( dataFimPanel.getDate() ) + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "EXAMES:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + examesEmpresa + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "CONSULTAS:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + consultasEmpresa + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "TOTAL:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + ( examesEmpresa + consultasEmpresa ) + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ buffer.append( "
" );
+ for( int e = 0; e < estabelecimentos.length; e++ )
+ {
+ EstabelecimentoData estabelecimento = (EstabelecimentoData)JDO.load( EstabelecimentoData.class, estabelecimentos[ e ].getID() );
+ String nome = (String)estabelecimento.get( EstabelecimentoData.NOME );
+ int exames = provider.countExamesPeriodoForEstabelecimento( inicio, fim, estabelecimentos[ e ].getID() );
+ int consultas = provider.countConsultasPeriodoForEstabelecimento( inicio, fim, estabelecimentos[ e ].getID() );
+ int total = exames + consultas;
+ buffer.append( "
" );
+ buffer.append( "" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "ESTABELECIMENTO:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + nome + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "EXAMES:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + exames + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "CONSULTAS:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + consultas + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "TOTAL:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + ( exames + consultas ) + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "NOME" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "ESTABELECIMENTO" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "DATA" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( " " );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ String data[][] = provider.getMarcacoesPeriodoForEstabelecimento( inicio, fim, estabelecimentos[ e ].getID() );
+ for( int l = 0; l < data.length; l++ )
+ {
+ buffer.append( "" );
+ for( int c = 1; c < data[ l ].length; c++ )
+ {
+ buffer.append( "| " );
+ buffer.append( "" + data[ l ][ c ] + "" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ }
+ buffer.append( "
" );
+ }
+ buffer.append( "
" );
+ }
+ resultadoText.setText( buffer.toString() );
+ }
+ catch( Exception ex )
+ {
+ resultadoText.setText( "ERRO a carregar dados!" );
+ ex.printStackTrace();
+ }
+ }
+
+ protected void listagemGeralTrabalhadoresSemExamesOuConsultas( boolean exames )
+ {
+ try
+ {
+ Date inicio = dataInicioPanel.getDate();
+ Date fim = dataFimPanel.getDate();
+ if( inicio == null || fim == null )
+ {
+ JOptionPane.showMessageDialog( this, "Tem de escolher o intervalo de datas.", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ resultadoText.setText( "ERRO!" );
+ return;
+ }
+ if( inicio.after( fim ) )
+ {
+ JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ resultadoText.setText( "ERRO!" );
+ return;
+ }
+ int count = provider.countTrabalhadoresSemExamesOuConsultas( inicio, fim, exames );
+ //String data[][] = provider.getTrabalhadoresComExamesOuConsultasPeriodo( inicio, fim, exames );
+ Object data[][] = provider.getCountTrabalhadoresSemExamesOuConsultasPeriodoForAllEmpresas( inicio, fim, exames );
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "" );
+ buffer.append( "" + ESTATISTICAS[ exames ? LISTAGEM_GLOBAL_TRABALHADORES_SEM_EXAMES : LISTAGEM_GLOBAL_TRABALHADORES_SEM_CONSULTA ] + "" );
+ buffer.append( "
" );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "PER\u00cdODO:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + DF.format( dataInicioPanel.getDate() ) + " a "
+ + DF.format( dataFimPanel.getDate() ) + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "TOTAL:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + count + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "EMPRESA" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "N\u00ba" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ for( int l = 0; l < data.length; l++ )
+ {
+ buffer.append( "
" );
+ buffer.append( "| " );
+ buffer.append( "" + data[ l ][ 0 ] + "" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+
+ buffer.append( "" );
+ buffer.append( "" + data[ l ][ 1 ] + "" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ }
+ buffer.append( "
" );
+ resultadoText.setText( buffer.toString() );
+ }
+ catch( Exception ex )
+ {
+ resultadoText.setText( "ERRO a carregar dados!" );
+ ex.printStackTrace();
+ }
+ }
+
+ protected void listagemTrabalhadoresSemExamesOuConsultasEmpresaEstabelecimento( boolean exames )
+ {
+ try
+ {
+ Date inicio = dataInicioPanel.getDate();
+ Date fim = dataFimPanel.getDate();
+ if( inicio == null || fim == null )
+ {
+ JOptionPane.showMessageDialog( this, "Tem de escolher o intervalo de datas.", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ resultadoText.setText( "ERRO!" );
+ return;
+ }
+ if( inicio.after( fim ) )
+ {
+ JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ resultadoText.setText( "ERRO!" );
+ return;
+ }
+ int sEmpresa = empresasTable.getSelectedRow();
+ int sEstabelecimento = estabelecimentosTable.getSelectedRow();
+ if( sEmpresa == -1 )
+ {
+ JOptionPane.showMessageDialog( this, "Tem de escolher Empresa.", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ resultadoText.setText( "ERRO!" );
+ return;
+ }
+ StringBuffer buffer = new StringBuffer();
+ Integer idEmpresa = ( (IDObject)empresasModel.getRowAt( sEmpresa ) ).getID();
+ EmpresaData empresa = (EmpresaData)JDO.load( EmpresaData.class, idEmpresa );
+ String designacao = (String)empresa.get( EmpresaData.DESIGNACAO_SOCIAL );
+ IDObject estabelecimentos[];
+ if( sEstabelecimento == -1 || ( ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento ) ).getID().equals( new Integer( -1 ) ) )
+ {
+ estabelecimentos = pesquisasProvider.getAllEstabelecimentosForEmpresa( idEmpresa );
+ }
+ else
+ {
+ estabelecimentos = new IDObject[ 1 ];
+ estabelecimentos[ 0 ] = ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento );
+ }
+ int countEmpresa = provider.countTrabalhadoresSemExamesOuConsultasEmpresa( idEmpresa, inicio, fim, exames );
+ buffer.append( "" );
+ buffer.append( "" + ESTATISTICAS[ exames ? LISTAGEM_TRABALHADORES_SEM_EXAMES_EMPRESA_ESTABELECIMENTO : LISTAGEM_TRABALHADORES_SEM_CONSULTA_EMPRESA_ESTABELECIMENTO ] + "" );
+ buffer.append( "
" );
+ buffer.append( "
" );
+ buffer.append( "" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "EMPRESA:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + designacao + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "Nº DE TRABALHADORES:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + countEmpresa + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ buffer.append( "
" );
+ for( int e = 0; e < estabelecimentos.length; e++ )
+ {
+ EstabelecimentoData estabelecimento = (EstabelecimentoData)JDO.load( EstabelecimentoData.class, estabelecimentos[ e ].getID() );
+ String nome = (String)estabelecimento.get( EstabelecimentoData.NOME );
+ int countEstabelecimento = provider.countTrabalhadoresSemExamesOuConsultasEstabelecimento( estabelecimentos[ e ].getID(), inicio, fim, exames );
+ buffer.append( "
" );
+ buffer.append( "" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "ESTABELECIMENTO:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + nome + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "Nº DE TRABALHADORES:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + countEstabelecimento + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "ESTABELECIMENTO" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "NOME" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ String data[][] = provider.getTrabalhadoresSemExamesOuConsultasEstabelecimento( estabelecimentos[ e ].getID(), inicio, fim, exames );
+ for( int l = 0; l < data.length; l++ )
+ {
+ buffer.append( "" );
+ for( int c = 0; c < data[ l ].length; c++ )
+ {
+ buffer.append( "| " );
+ buffer.append( "" + data[ l ][ c ] + "" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ }
+ buffer.append( "
" );
+ }
+ buffer.append( "
" );
+ }
+ resultadoText.setText( buffer.toString() );
+ }
+ catch( Exception ex )
+ {
+ resultadoText.setText( "ERRO a carregar dados!" );
+ ex.printStackTrace();
+ }
+ }
+
+ protected void listagemGeralTrabalhadoresComExamesOuConsultasPeriodo( boolean exames )
+ {
+ try
+ {
+ Date inicio = dataInicioPanel.getDate();
+ Date fim = dataFimPanel.getDate();
+ if( inicio == null || fim == null )
+ {
+ JOptionPane.showMessageDialog( this, "Tem de escolher o intervalo de datas.", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ resultadoText.setText( "ERRO!" );
+ return;
+ }
+ if( inicio.after( fim ) )
+ {
+ JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ resultadoText.setText( "ERRO!" );
+ return;
+ }
+ int count = provider.countTrabalhadoresComExamesOuConsultasPeriodo( inicio, fim, exames );
+ //String data[][] = provider.getTrabalhadoresComExamesOuConsultasPeriodo( inicio, fim, exames );
+ Object data[][] = provider.getCountTrabalhadoresComExamesOuConsultasPeriodoForAllEmpresas( inicio, fim, exames );
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "" );
+ buffer.append( "" + ESTATISTICAS[ exames ? LISTAGEM_GLOBAL_TRABALHADORES_COM_EXAMES_PERIODO : LISTAGEM_GLOBAL_TRABALHADORES_COM_CONSULTA_PERIODO ] + "" );
+ buffer.append( "
" );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "PER\u00cdODO:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + DF.format( dataInicioPanel.getDate() ) + " a "
+ + DF.format( dataFimPanel.getDate() ) + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "TOTAL:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + count + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "EMPRESA" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "N\u00ba" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ for( int l = 0; l < data.length; l++ )
+ {
+ buffer.append( "
" );
+ buffer.append( "| " );
+ buffer.append( "" + data[ l ][ 0 ] + "" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+
+ buffer.append( "" );
+ buffer.append( "" + data[ l ][ 1 ] + "" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ }
+ buffer.append( "
" );
+ resultadoText.setText( buffer.toString() );
+ }
+ catch( Exception ex )
+ {
+ resultadoText.setText( "ERRO a carregar dados!" );
+ ex.printStackTrace();
+ }
+ }
+
+ protected void listagemGeralTrabalhadoresComExamesOuConsultasPeriodoEmpresaEstabelecimento( boolean exames )
+ {
+ try
+ {
+ Date inicio = dataInicioPanel.getDate();
+ Date fim = dataFimPanel.getDate();
+ int sEmpresa = empresasTable.getSelectedRow();
+ int sEstabelecimento = estabelecimentosTable.getSelectedRow();
+ if( inicio == null || fim == null || sEmpresa == -1 )
+ {
+ JOptionPane.showMessageDialog( this, "Tem de escolher Empresa e intervalo de datas.", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ resultadoText.setText( "ERRO!" );
+ return;
+ }
+ if( inicio.after( fim ) )
+ {
+ JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ resultadoText.setText( "ERRO!" );
+ return;
+ }
+ StringBuffer buffer = new StringBuffer();
+ Integer idEmpresa = ( (IDObject)empresasModel.getRowAt( sEmpresa ) ).getID();
+ EmpresaData empresa = (EmpresaData)JDO.load( EmpresaData.class, idEmpresa );
+ String designacao = (String)empresa.get( EmpresaData.DESIGNACAO_SOCIAL );
+ IDObject estabelecimentos[];
+ if( sEstabelecimento == -1 || ( ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento ) ).getID().equals( new Integer( -1 ) ) )
+ {
+ estabelecimentos = pesquisasProvider.getAllEstabelecimentosForEmpresa( idEmpresa );
+ }
+ else
+ {
+ estabelecimentos = new IDObject[ 1 ];
+ estabelecimentos[ 0 ] = ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento );
+ }
+ int countEmpresa = provider.countTrabalhadoresComExamesOuConsultasPeriodoForEmpresa( inicio, fim, idEmpresa, exames );
+ buffer.append( "" );
+ buffer.append( "" + ESTATISTICAS[ exames ? LISTAGEM_TRABALHADORES_COM_EXAMES_PERIODO_EMPRESA_ESTABELECIMENTO : LISTAGEM_TRABALHADORES_COM_CONSULTA_PERIODO_EMPRESA_ESTABELECIMENTO ] + "" );
+ buffer.append( "
" );
+ buffer.append( "
" );
+ buffer.append( "" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "EMPRESA:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + designacao + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "PER\u00cdODO:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + DF.format( dataInicioPanel.getDate() ) + " a "
+ + DF.format( dataFimPanel.getDate() ) + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "Nº:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + countEmpresa + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+
+ buffer.append( "
" );
+ for( int e = 0; e < estabelecimentos.length; e++ )
+ {
+ EstabelecimentoData estabelecimento = (EstabelecimentoData)JDO.load( EstabelecimentoData.class, estabelecimentos[ e ].getID() );
+ String nome = (String)estabelecimento.get( EstabelecimentoData.NOME );
+ int countEstabelecimento = provider.countTrabalhadoresComExamesOuConsultasPeriodoForEstabelecimento( inicio, fim, estabelecimentos[ e ].getID(), exames );
+ buffer.append( "
" );
+ buffer.append( "" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "ESTABELECIMENTO:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + nome + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "Nº:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + countEstabelecimento + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "ESTABELECIMENTO" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "NOME" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ String data[][] = provider.getTrabalhadoresComExamesOuConsultasPeriodoForEstabelecimento( inicio, fim, estabelecimentos[ e ].getID(), exames );
+ for( int l = 0; l < data.length; l++ )
+ {
+ buffer.append( "" );
+ for( int c = 0; c < data[ l ].length; c++ )
+ {
+ buffer.append( "| " );
+ buffer.append( "" + data[ l ][ c ] + "" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ }
+ buffer.append( "
" );
+ }
+ buffer.append( "
" );
+ }
+ resultadoText.setText( buffer.toString() );
+ }
+ catch( Exception ex )
+ {
+ resultadoText.setText( "ERRO a carregar dados!" );
+ ex.printStackTrace();
+ }
+ }
+
+ protected void listagemGeralTrabalhadoresPeriodo()
+ {
+ try
+ {
+ Date inicio = dataInicioPanel.getDate();
+ Date fim = dataFimPanel.getDate();
+ if( inicio == null || fim == null )
+ {
+ JOptionPane.showMessageDialog( this, "Tem de escolher o intervalo de datas.", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ resultadoText.setText( "ERRO!" );
+ return;
+ }
+ if( inicio.after( fim ) )
+ {
+ JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ resultadoText.setText( "ERRO!" );
+ return;
+ }
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "" );
+ buffer.append( "" + ESTATISTICAS[ LISTAGEM_GLOBAL_TRABALHADORES_PERIODO ] + "" );
+ buffer.append( "
" );
+ buffer.append( "
" );
+ buffer.append( "" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "PER\u00cdODO:" );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "" + DF.format( dataInicioPanel.getDate() ) + " a "
+ + DF.format( dataFimPanel.getDate() ) + "" );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "EMPRESA" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "ESTABELECIMENTO" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "NOME" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "ÚLTIMO EXAME" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "ESTADO" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "ÚLTIMA CONSULTA" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "ESTADO" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ String data[][] = provider.getDadosTrabalhadoresPeriodo( inicio, fim );
+ for( int l = 0; l < data.length; l++ )
+ {
+ buffer.append( "" );
+ for( int c = 0; c < data[ l ].length; c++ )
+ {
+ buffer.append( "| " );
+ buffer.append( "" + data[ l ][ c ] + "" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ }
+ buffer.append( "
" );
+ }
+ buffer.append( "
" );
+ resultadoText.setText( buffer.toString() );
+ }
+ catch( Exception ex )
+ {
+ resultadoText.setText( "ERRO a carregar dados!" );
+ ex.printStackTrace();
+ }
+ }
+
+ protected void listagemGlobalHigieneSeguranca()
+ {
+ try
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "" );
+ buffer.append( "" + ESTATISTICAS[ LISTAGEM_GLOBAL_HIGIENE_SEGURANCA ] + "" );
+ buffer.append( "
" );
+ buffer.append( "
" );
+
+ buffer.append( "" );
+ buffer.append( "" );
+ buffer.append( "| " );
+ buffer.append( "EMPRESA" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "ESTABELECIMENTO" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "ÚLTIMA AUDITORIA" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "ESTADO" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "RELATÓRIO" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "" );
+ buffer.append( "PRÓXIMA AUDITORIA" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ buffer.append( "
" );
+ String data[][] = provider.getDadosHigieneSeguranca();
+ for( int l = 0; l < data.length; l++ )
+ {
+ buffer.append( "" );
+ for( int c = 0; c < data[ l ].length; c++ )
+ {
+ buffer.append( "| " );
+ buffer.append( "" + data[ l ][ c ] + "" );
+ buffer.append( " | " );
+ buffer.append( " | " );
+ }
+ buffer.append( "
" );
+ }
+ buffer.append( "
" );
+ resultadoText.setText( buffer.toString() );
+ }
+ catch( Exception ex )
+ {
+ resultadoText.setText( "ERRO a carregar dados!" );
+ ex.printStackTrace();
+ }
+ }
+
+ public void exportar()
+ {
+ FileDialog dialog = new FileDialog( this, "Ficheiro de destino", FileDialog.SAVE );
+ dialog.setDirectory( System.getProperty( "user.home" ) );
+ dialog.setVisible( true );
+ String fileName;
+ String dirName;
+ fileName = dialog.getFile();
+ dirName = dialog.getDirectory();
+ if( fileName != null )
+ {
+ int index = fileName.indexOf( '.' );
+ if( index == -1 )
+ {
+ fileName += ".html";
+ }
+ if( index == fileName.length() - 1 )
+ {
+ fileName += "html";
+ }
+ String fullName = dirName + fileName;
+ String text = resultadoText.getText();
+ String title = "S.I.P.R.P. - Sociedade Ibérica de Prevenção de Riscos Profissionais";
+ String style = "";
+ text = text.replace( "", "\n\t\t" + title + "\n" + style );
+ text = text.replace( "", "" );
+ text = text.replace( "", "
" );
+// System.out.println( text );
+ try
+ {
+ FileWriter writer = new FileWriter( new File( fullName ) );
+ writer.write( text );
+ writer.close();
+ }
+ catch( IOException ex )
+ {
+ DialogException.showException( ex );
+ return;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/trunk/SIPRPSoft/src/siprp/estatisticas/EstatisticasWindow.java b/trunk/SIPRPSoft/src/siprp/estatisticas/EstatisticasWindow.java
new file mode 100644
index 00000000..71e4e844
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/estatisticas/EstatisticasWindow.java
@@ -0,0 +1,36 @@
+/*
+ * EstatisticasWindow.java
+ *
+ * Created on 11 de Maio de 2004, 17:57
+ */
+
+package siprp.estatisticas;
+
+import javax.swing.*;
+
+import com.evolute.utils.ui.window.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class EstatisticasWindow
+ extends CustomJFrame
+{
+ private JPanel filtrosPanel;
+ private JPanel agrupamentosPanel;
+ private JPanel buttonPanel;
+
+ private JComboBox filtroEmpresa;
+
+ /** Creates a new instance of EstatisticasWindow */
+ public EstatisticasWindow()
+ {
+ setupComponents();
+ }
+
+ private void setupComponents()
+ {
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/EmpresaPanel.java b/trunk/SIPRPSoft/src/siprp/ficha/EmpresaPanel.java
new file mode 100644
index 00000000..bede830c
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/EmpresaPanel.java
@@ -0,0 +1,492 @@
+/*
+ * EmpresaPanel.java
+ *
+ * Created on 29 de Marco de 2004, 11:53
+ */
+
+package siprp.ficha;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.data.*;
+import com.evolute.utils.dataui.*;
+import com.evolute.utils.jdo.*;
+import com.evolute.utils.metadb.*;
+import com.evolute.utils.ui.*;
+import com.evolute.utils.ui.button.*;
+import com.evolute.utils.ui.panel.*;
+import com.evolute.utils.ui.text.*;
+
+import siprp.*;
+import siprp.data.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class EmpresaPanel extends JPanel
+ implements ControllableComponent
+{
+ private JDOProvider JDO;
+ private JTextField designacaoSocialText;
+ private JTextField estabelecimentoText;
+ private JTextField localidadeText;
+ private RadioButtonFixedPanel servicoSaudeTipoPanel;
+ private JTextField designacaoServicoSaudeText;
+ private JButton defaultServicoSaudeButton;
+ private RadioButtonFixedPanel servicoHigieneTipoPanel;
+ private JTextField designacaoText;
+ private JButton defaultServicoHigieneButton;
+
+ private FichaDataProvider provider;
+ private ComponentsHashtable empresaComponents;
+ private ComponentsHashtable estabelecimentoComponents;
+
+ private EstabelecimentoData estabelecimento;
+ private EmpresaData empresa;
+
+
+ /** Creates a new instance of EmpresaPanel */
+ public EmpresaPanel()
+ throws Exception
+ {
+ provider = (FichaDataProvider)FichaDataProvider.getProvider();
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ setupComponents();
+ setupComponentsHashtable();
+ }
+
+ private void setupComponents()
+ {
+ setBorder( BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(),
+ "Empresa/Entidade" ) );
+
+ JLabel designacaoSocialLabel = new JLabel( "Designa\u00e7\u00e3o Social" );
+ designacaoSocialText = new JTextField();
+// JPanel servicoSaudePanel = new JPanel();
+ JLabel estabelecimentoLabel = new JLabel( "Estabelecimento" );
+ estabelecimentoText = new JTextField();
+ JLabel localidadeLabel = new JLabel( "Localidade" );
+ localidadeText = new JTextField();
+ JLabel servicoSaudeLabel = new JLabel( "Servi\u00e7o de Sa\u00fade: Tipo" );
+ servicoSaudeTipoPanel =
+ new RadioButtonFixedPanel( new IDObject[]{ new MappableObject( new Integer(1), "Interno" ),
+ new MappableObject( new Integer(2), "Interempresas" ),
+ new MappableObject( new Integer(3), "Externo" ),
+ new MappableObject( new Integer(4), "Servi\u00e7o Nacional de Sa\u00fade" ) },
+ 1, 4, RadioButtonPanel.ORIENTATION_HORIZONTAL, false );
+ JLabel designacaoServicoSaudeLabel = new JLabel( "Designa\u00e7\u00e3o" );
+ designacaoServicoSaudeText = new JTextField();
+ defaultServicoSaudeButton = new JButton("-");
+ defaultServicoSaudeButton.addActionListener( new ActionListener(){
+ public void actionPerformed( ActionEvent e )
+ {
+ designacaoServicoSaudeText.setText( (String) Singleton.getInstance( SingletonConstants.COMPANY_NAME ) );
+ }
+ } );
+
+ JLabel servicoHigieneLabel = new JLabel( "Servi\u00e7o de Higiene e Seguran\u00e7a: Tipo" );
+ servicoHigieneTipoPanel =
+ new RadioButtonFixedPanel( new IDObject[]{ new MappableObject( new Integer(1), "Interno" ),
+ new MappableObject( new Integer(2), "Interempresas" ),
+ new MappableObject( new Integer(3), "Externo" ),
+ new MappableObject( new Integer(4), "Outro" ) },
+ 1, 4, RadioButtonPanel.ORIENTATION_HORIZONTAL, false );
+ JLabel designacaoLabel = new JLabel( "Designa\u00e7\u00e3o" );
+ designacaoText = new JTextField();
+ defaultServicoHigieneButton = new JButton("-");
+ defaultServicoHigieneButton.addActionListener( new ActionListener(){
+ public void actionPerformed( ActionEvent e )
+ {
+ designacaoText.setText( (String) Singleton.getInstance( SingletonConstants.COMPANY_NAME ) );
+ }
+ } );
+
+ GridBagLayout gridbag = new GridBagLayout();
+ setLayout( gridbag );
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.insets = new Insets( 0, 1, 0, 1 );
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ constraints.gridwidth = 1;
+ constraints.weightx = 0;
+ constraints.gridheight = 1;
+ constraints.weighty = 0;
+
+ gridbag.setConstraints( designacaoSocialLabel, constraints );
+ add( designacaoSocialLabel );
+
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( designacaoSocialText, constraints );
+ add( designacaoSocialText );
+
+ constraints.weightx = 0;
+ constraints.gridwidth = 1;
+ gridbag.setConstraints( estabelecimentoLabel, constraints );
+ add( estabelecimentoLabel );
+
+ constraints.weightx = 0.6;
+ constraints.gridwidth = 3;
+ gridbag.setConstraints( estabelecimentoText, constraints );
+ add( estabelecimentoText );
+
+ constraints.weightx = 0;
+ constraints.gridwidth = 1;
+ gridbag.setConstraints( localidadeLabel, constraints );
+ add( localidadeLabel );
+
+ constraints.weightx = 0.4;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( localidadeText, constraints );
+ add( localidadeText );
+
+ constraints.weightx = 0;
+ constraints.gridwidth = 2;
+ gridbag.setConstraints( servicoSaudeLabel, constraints );
+ add( servicoSaudeLabel );
+
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( servicoSaudeTipoPanel, constraints );
+ add( servicoSaudeTipoPanel );
+
+ constraints.weightx = 0;
+ constraints.gridwidth = 1;
+ gridbag.setConstraints( designacaoServicoSaudeLabel, constraints );
+ add( designacaoServicoSaudeLabel );
+
+ JPanel designacaoServicoSaudePanel = new JPanel();
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( designacaoServicoSaudePanel, constraints );
+ add( designacaoServicoSaudePanel );
+
+ constraints.weightx = 0;
+ constraints.gridwidth = 3;
+ gridbag.setConstraints( servicoHigieneLabel, constraints );
+ add( servicoHigieneLabel );
+
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( servicoHigieneTipoPanel, constraints );
+ add( servicoHigieneTipoPanel );
+
+ constraints.gridwidth = 1;
+ constraints.weightx = 0;
+ constraints.weighty = 1;
+ constraints.gridheight = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( designacaoLabel, constraints );
+ add( designacaoLabel );
+
+ JPanel designacaoServicoHigienePanel = new JPanel();
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( designacaoServicoHigienePanel, constraints );
+ add( designacaoServicoHigienePanel );
+
+ gridbag = new GridBagLayout();
+ designacaoServicoSaudePanel.setLayout( gridbag );
+ constraints.insets = new Insets( 0, 0, 0, 0 );
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ constraints.gridwidth = 1;
+ constraints.weightx = 1;
+ constraints.weighty = 1;
+ constraints.gridheight = GridBagConstraints.REMAINDER;
+
+ gridbag.setConstraints( designacaoServicoSaudeText, constraints );
+ designacaoServicoSaudePanel.add( designacaoServicoSaudeText );
+
+ constraints.weightx = 0;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( defaultServicoSaudeButton, constraints );
+ designacaoServicoSaudePanel.add( defaultServicoSaudeButton );
+
+
+ gridbag = new GridBagLayout();
+ designacaoServicoHigienePanel.setLayout( gridbag );
+ constraints.insets = new Insets( 0, 0, 0, 0 );
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ constraints.gridwidth = 1;
+ constraints.weightx = 1;
+ constraints.weighty = 1;
+ constraints.gridheight = GridBagConstraints.REMAINDER;
+
+ gridbag.setConstraints( designacaoText, constraints );
+ designacaoServicoHigienePanel.add( designacaoText );
+
+ constraints.weightx = 0;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( defaultServicoHigieneButton, constraints );
+ designacaoServicoHigienePanel.add( defaultServicoHigieneButton );
+
+ new CopyPasteHandler( designacaoSocialText );
+ new CopyPasteHandler( estabelecimentoText );
+ new CopyPasteHandler( localidadeText );
+ new CopyPasteHandler( designacaoServicoSaudeText );
+ new CopyPasteHandler( designacaoText );
+ }
+
+ private void setupComponentsHashtable()
+ {
+ empresaComponents = new ComponentsHashtable();
+ empresaComponents.putComponent( EmpresaData.DESIGNACAO_SOCIAL, designacaoSocialText );
+ empresaComponents.putComponent( EmpresaData.SERVICO_SAUDE_TIPO, servicoSaudeTipoPanel );
+ empresaComponents.putComponent( EmpresaData.SERVICO_SAUDE_DESIGNACAO, designacaoServicoSaudeText );
+ empresaComponents.putComponent( EmpresaData.SERVICO_HIGIENE_TIPO, servicoHigieneTipoPanel );
+ empresaComponents.putComponent( EmpresaData.SERVICO_HIGIENE_DESIGNACAO, designacaoText );
+
+ empresaComponents.putDummy( EmpresaData.MORADA );
+ empresaComponents.putDummy( EmpresaData.CODIGO_POSTAL );
+ empresaComponents.putDummy( EmpresaData.LOCALIDADE );
+ empresaComponents.putDummy( EmpresaData.DISTRITO );
+ empresaComponents.putDummy( EmpresaData.CONCELHO );
+ empresaComponents.putDummy( EmpresaData.DATA_PROPOSTA );
+ empresaComponents.putDummy( EmpresaData.DATA_ACEITACAO );
+ empresaComponents.putDummy( EmpresaData.PERFIL_1 );
+ empresaComponents.putDummy( EmpresaData.PERFIL_2 );
+ empresaComponents.putDummy( EmpresaData.DATA_ENVIO_CONTRATO );
+ empresaComponents.putDummy( EmpresaData.DATA_RECEPCAO_CONTRATO );
+ empresaComponents.putDummy( EmpresaData.DATA_ENVIO_IDICT );
+ empresaComponents.putDummy( EmpresaData.DATA_RELATORIO_ANUAL );
+ empresaComponents.putDummy( EmpresaData.CODIGO_1 );
+ empresaComponents.putDummy( EmpresaData.CODIGO_2 );
+ empresaComponents.putDummy( EmpresaData.CODIGO_3 );
+ empresaComponents.putDummy( EmpresaData.CAE );
+ empresaComponents.putDummy( EmpresaData.ACTIVIDADE );
+ empresaComponents.putDummy( EmpresaData.CONTRIBUINTE );
+ empresaComponents.putDummy( EmpresaData.SEGURANCA_SOCIAL );
+ empresaComponents.putDummy( EmpresaData.CONTACTO_1 );
+ empresaComponents.putDummy( EmpresaData.CONTACTO_2 );
+ empresaComponents.putDummy( EmpresaData.SERVICOS );
+ empresaComponents.putDummy( EmpresaData.PRECO_HIGIENE );
+ empresaComponents.putDummy( EmpresaData.PRECO_MEDICINA );
+ empresaComponents.putDummy( EmpresaData.PERIODICIDADE );
+ empresaComponents.putDummy( EmpresaData.DESIGNACAO_SOCIAL_PLAIN );
+ empresaComponents.putDummy( EmpresaData.DATA_CANCELAMENTO );
+ empresaComponents.putDummy( EmpresaData.A_CONSULTAS );
+ empresaComponents.putDummy( EmpresaData.A_EXAMES );
+ empresaComponents.putDummy( EmpresaData.B_CONSULTAS );
+ empresaComponents.putDummy( EmpresaData.B_EXAMES );
+ empresaComponents.putDummy( EmpresaData.INICIO_CONTRATO );
+ empresaComponents.putDummy( EmpresaData.DURACAO );
+
+ estabelecimentoComponents = new ComponentsHashtable();
+ estabelecimentoComponents.putComponent( EstabelecimentoData.NOME, estabelecimentoText );
+ estabelecimentoComponents.putComponent( EstabelecimentoData.LOCALIDADE, localidadeText );
+ estabelecimentoComponents.putDummy( EstabelecimentoData.MORADA );
+ estabelecimentoComponents.putDummy( EstabelecimentoData.CODIGO_POSTAL );
+ estabelecimentoComponents.putDummy( EstabelecimentoData.CONTACTO );
+ estabelecimentoComponents.putDummy( EstabelecimentoData.HISTORICO );
+ estabelecimentoComponents.putDummy( EstabelecimentoData.EMPRESA );
+ estabelecimentoComponents.putDummy( EstabelecimentoData.NOME_PLAIN );
+
+// components.putComponent( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.DESIGNACAO_SOCIAL, designacaoSocialText );
+// components.put( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_SAUDE_TIPO, servicoSaudeTipoPanel );
+// components.putComponent( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_SAUDE_DESIGNACAO, designacaoServicoSaudeText );
+// components.put( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_HIGIENE_TIPO, servicoHigieneTipoPanel );
+// components.putComponent( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_HIGIENE_DESIGNACAO, designacaoText );
+//
+// components.putComponent( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.NOME, estabelecimentoText );
+// components.putComponent( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.LOCALIDADE, localidadeText );
+//
+// components.putDummy( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.INACTIVO );
+// components.putDummy( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.EMPRESA_ID );
+// components.putDummy( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.INACTIVO );
+ }
+
+ public void fill(Object value)
+ {
+ clear();
+ empresa = null;
+ estabelecimento = null;
+ if( value != null )
+ {
+ Integer empresaID = (Integer)((Object[])value)[0];
+ Integer estabelecimentoID = (Integer)((Object[])value)[1];
+ if( empresaID != null )
+ {
+ try
+ {
+ empresa = (EmpresaData)JDO.load( EmpresaData.class, empresaID );
+ String names[] = (String[])empresaComponents.keySet().toArray( new String[0] );
+ ComponentController.fill( names, empresa.getHashData(), empresaComponents );
+
+ if( estabelecimentoID != null )
+ {
+ estabelecimento = (EstabelecimentoData)JDO.load( EstabelecimentoData.class, estabelecimentoID );
+ names = estabelecimento.getFieldNames();
+ ComponentController.fill( names, estabelecimento.getHashData(), estabelecimentoComponents );
+ }
+
+// DBField fields[] = provider.EMPRESAS.getInsertFields();
+// String empresaFields[] = new String[ fields.length ];
+// Hashtable data = new Hashtable();
+// for( int i = 0; i < empresaFields.length; ++i )
+// {
+// empresaFields[ i ] = fields[ i ].FULL_NAME;
+// Object fieldValue = empresa.getProperty( empresaFields[ i ] );
+// if( fieldValue != null )
+// {
+// data.put( empresaFields[ i ], fieldValue );
+// }
+// }
+// ComponentController.fill( empresaFields, data, components );
+// if( estabelecimentoID != null )
+// {
+// estabelecimento = provider.load( provider.ESTABELECIMENTOS, new DBKey( estabelecimentoID ) );
+// fields = provider.ESTABELECIMENTOS.getInsertFields();
+// String estabelecimentoFields[] = new String[ fields.length ];
+// for( int i = 0; i < estabelecimentoFields.length; ++i )
+// {
+// estabelecimentoFields[ i ] = fields[ i ].FULL_NAME;
+// Object fieldValue = estabelecimento.getProperty( estabelecimentoFields[ i ] );
+// if( fieldValue != null )
+// {
+// data.put( estabelecimentoFields[ i ], fieldValue );
+// }
+// }
+// ComponentController.fill( estabelecimentoFields, data, components );
+// }
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar os dados da Empresa", true );
+ }
+ }
+ }
+ else
+ {
+ estabelecimentoText.setText( "Sede" );
+ }
+ }
+
+ public Object save()
+ {
+ StringBuffer msg = new StringBuffer();
+ boolean hasMsg = false;
+ try
+ {
+ if( estabelecimento == null )
+ {
+// estabelecimento = provider.createObject( provider.ESTABELECIMENTOS );
+ estabelecimento = new EstabelecimentoData();
+ }
+ if( empresa == null )
+ {
+// empresa = provider.createObject( provider.EMPRESAS );
+ empresa = new EmpresaData();
+ }
+// DBField fields[] = provider.EMPRESAS.getInsertFields();
+// String empresaFields[] = new String[ fields.length ];
+// for( int i = 0; i < empresaFields.length; ++i )
+// {
+// empresaFields[ i ] = fields[ i ].FULL_NAME;
+// }
+// Hashtable hash = new Hashtable();
+// ComponentController.save( empresaFields, hash, components );
+// Enumeration enum = hash.keys();
+// while( enum.hasMoreElements() )
+// {
+// String name = ( String )enum.nextElement();
+// empresa.setProperty( name, hash.get( name ) );
+// }
+// fields = provider.ESTABELECIMENTOS.getInsertFields();
+// String estabelecimentoFields[] = new String[ fields.length ];
+// for( int i = 0; i < estabelecimentoFields.length; ++i )
+// {
+// estabelecimentoFields[ i ] = fields[ i ].FULL_NAME;
+// }
+// hash = new Hashtable();
+// ComponentController.save( estabelecimentoFields, hash, components );
+// enum = hash.keys();
+// while( enum.hasMoreElements() )
+// {
+// String name = ( String )enum.nextElement();
+// estabelecimento.setProperty( name, hash.get( name ) );
+// }
+
+ String names[] = (String[])empresaComponents.keySet().toArray( new String[0] );
+// String names[] = new String[]{ EmpresaData.DESIGNACAO_SOCIAL, EmpresaData.SERVICO_SAUDE_TIPO,
+// EmpresaData.SERVICO_SAUDE_DESIGNACAO, EmpresaData.SERVICO_HIGIENE_TIPO,
+// EmpresaData.SERVICO_HIGIENE_DESIGNACAO };
+ Hashtable hash = empresa.getHashData();
+ ComponentController.save( names, hash, empresaComponents );
+ empresa.setHashData( hash );
+
+ names = estabelecimento.getFieldNames();
+ hash = estabelecimento.getHashData();
+ ComponentController.save( names, hash, estabelecimentoComponents );
+ estabelecimento.setHashData( hash );
+ estabelecimento.set( EstabelecimentoData.EMPRESA, empresa );
+
+// estabelecimento.setProperty( provider.R_ESTABELECIMENTO_EMPRESA, empresa );
+
+// if( ((String)empresa.getProperty( provider.DESIGNACAO_SOCIAL )).trim().length() == 0 )
+ if( ((String)empresa.get( EmpresaData.DESIGNACAO_SOCIAL )).trim().length() == 0 )
+ {
+ msg.append( "A empresa tem de ter uma design\u00e7\u00e3o social\n" );
+ hasMsg = true;
+ }
+ else
+ {
+ empresa.set( EmpresaData.DESIGNACAO_SOCIAL_PLAIN,
+ com.evolute.utils.strings.StringPlainer.convertString( ( String )
+ empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) ) );
+ }
+// if( empresa.getProperty( provider.SERVICO_SAUDE_TIPO ) == null )
+ if( empresa.get( EmpresaData.SERVICO_SAUDE_TIPO ) == null )
+ {
+ msg.append( "A empresa tem de ter um tipo de seri\00e7o de sa\u00fade\n" );
+ hasMsg = true;
+ }
+// if( empresa.getProperty( provider.SERVICO_HIGIENE_TIPO ) == null )
+ if( empresa.get( EmpresaData.SERVICO_HIGIENE_TIPO ) == null )
+ {
+ msg.append( "A empresa tem de ter um tipo de seri\00e7o de higiene\n" );
+ hasMsg = true;
+ }
+// if( ((String)estabelecimento.getProperty( provider.NOME )).trim().length() == 0 )
+ if( ((String)estabelecimento.get( EstabelecimentoData.NOME )).trim().length() == 0 )
+ {
+ msg.append( "O estabelecimento tem de ter nome\n" );
+ hasMsg = true;
+ }
+
+ }
+ catch( Exception ex )
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ if( hasMsg )
+ {
+ throw new ValuesException( msg.toString() );
+ }
+ return estabelecimento;
+
+ }
+
+ public void clear()
+ {
+ String names[] = (String[])empresaComponents.keySet().toArray( new String[0] );
+ ComponentController.clear( names, empresaComponents );
+ names = (String[])estabelecimentoComponents.keySet().toArray( new String[0] );
+ ComponentController.clear( names, estabelecimentoComponents );
+ estabelecimentoText.setText( "Sede" );
+ empresa = null;
+ estabelecimento = null;
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ String names[] = (String[])empresaComponents.keySet().toArray( new String[0] );
+ ComponentController.setEnabled( names, enable, empresaComponents );
+ names = (String[])estabelecimentoComponents.keySet().toArray( new String[0] );
+ ComponentController.setEnabled( names, enable, estabelecimentoComponents );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/ExamePDF.java b/trunk/SIPRPSoft/src/siprp/ficha/ExamePDF.java
new file mode 100644
index 00000000..32b7702e
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/ExamePDF.java
@@ -0,0 +1,461 @@
+package siprp.ficha;
+
+import java.awt.Color;
+import java.io.*;
+import java.util.*;
+
+import com.lowagie.text.*;
+import com.lowagie.text.pdf.*;
+
+import com.evolute.utils.*;
+import siprp.*;
+
+public class ExamePDF implements FichaAptidaoConstants
+{
+ private final Font FONT_BOLD = FontFactory.getFont( "Arial", 8, Font.BOLD );
+ private final Font FONT_NORMAL = FontFactory.getFont( "Arial", 8, Font.NORMAL );
+ private final Font FONT_ZAPFDINGBATS = new Font( Font.ZAPFDINGBATS , 12, Font.NORMAL, new Color( 0, 0, 0 ) );
+
+ private BaseFont BASE_WINGDINGS;
+ private Font FONT_WINGDINGS;
+
+// static
+// {
+// try
+// {
+// //BASE_WINGDINGS = BaseFont.createFont("C:\\WINNT\\Fonts\\WINGDING.TTF", BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
+// BASE_WINGDINGS = BaseFont.createFont("WingDings", BaseFont.CP1252, BaseFont.EMBEDDED);
+// InputStream stream = BaseFont.getResourceStream( "WING", ClassLoader loader)
+// BASE_WINGDINGS = BaseFont.createFont("WingDings", BaseFont.CP1252, BaseFont.EMBEDDED,
+// true, byte[] ttfAfm, null );
+// FONT_WINGDINGS = new Font(BASE_WINGDINGS, 12);
+// }
+// catch( Exception ex )
+// {
+// FONT_WINGDINGS = FONT_NORMAL;
+// System.out.println( "NO FONT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" );
+// }
+// }
+
+ public ExamePDF()
+ {
+ FontFactory.registerDirectories();
+ String possibleNames[] = new String[]{ "Wingdings", "WingDings", "wingdings", "WINGDINGS" };
+
+ for( int n = 0; n < 4; n++ )
+ {
+ FONT_WINGDINGS = FontFactory.getFont( possibleNames[ n ] );
+ if( FONT_WINGDINGS.getFamilyname().toLowerCase().equals( "wingdings" ) )
+ {
+ break;
+ }
+ }
+
+ }
+
+ public static void main( String[] args )
+ {
+ try
+ {
+ HashMap ht = new HashMap();
+ // designacao_social
+ // estabelecimentos.nome
+ // estabelecimentos.localidade
+ // servico_saude_tipo_interno
+ // servico_saude_tipo_interempresas
+ // servico_saude_tipo_externo
+ // servico_saude_tipo_sns
+ // servico_saude_designacao
+ // servico_higiene_tipo_interno
+ // servico_higiene_tipo_interempresas
+ // servico_higiene_tipo_externo
+ // servico_higiene_outro
+ // servico_higiene_designacao
+ // trabalhadores.nome
+ // sexo
+ // data_nascimento
+ // nacionalidade
+ // numero_mecanografico
+ // data_admissao
+ // categoria
+ // local_trabalho
+ // funcao_proposta
+ // data_admissao_funcao
+ // observacoes
+ // exames.data
+ // tipo_admissao
+ // tipo_periodico
+ // tipo_ocasional
+ // tipo_apos_doenca
+ // tipo_apos_acidente
+ // tipo_pedido_trabalhador
+ // tipo_pedido_empresa
+ // tipo_mudanca_funcao
+ // tipo_trabalho
+ // tipo_outro
+ // resultado_apto
+ // resultado_apto_condicionalmente
+ // resultado_inapto_temp
+ // resultado_inapto_def
+ // outra_funcao_1
+ // outra_funcao_2
+ // outra_funcao_3
+ // outra_funcao_4
+ // proximo_exame
+ // outras_recomendacoes
+ // medicos.nome
+ // numero_cedula
+
+ ht.put( TRABALHADORES_NOME, "Trabalhador do com\u00e9rcio" );
+ ht.put( SERVICO_SAUDE_DESIGNACAO, "Designacao servico saude" );
+ ht.put( SERVICO_SAUDE_TIPO_EXTERNO, "" + Boolean.TRUE );
+ ht.put( TIPO_PERIODICO, "" + Boolean.TRUE );
+ ht.put( RESULTADO_INAPTO_TEMP, "" + Boolean.TRUE );
+ FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + "\\report.pdf" );
+ fos.write( new ExamePDF().createPDF( ht ) );
+ fos.close();
+ System.out.println( "File saved." );
+ Process proc = Runtime.getRuntime().exec( "cmd.exe /c \"" + System.getProperty( "user.home" ) + "\\report.pdf\"" );
+ proc.waitFor();
+ new File( System.getProperty( "user.home" ) + "\\report.pdf" ).delete();
+ System.out.println( "Done." );
+ }
+ catch( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void print( byte []pdf, String nome )
+ throws Exception
+ {
+ long time = System.currentTimeMillis();
+// FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha" + time + ".pdf" );
+ FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf" );
+ fos.write( pdf );
+ fos.close();
+ System.out.println( "File saved ( " + nome + "_" + time + " )." );
+ Process proc;
+ if( System.getProperty( "os.name" ).startsWith( "Windows" ) )
+ {
+//System.out.println( "cmd.exe /c \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf\"" );
+ proc = Runtime.getRuntime().exec( "cmd.exe /c \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf\"" );
+ proc.waitFor();
+ if( !new File( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf" ).delete() )
+ {
+ System.err.println( "File: report_ficha" + time + ".pdf - NOT DELETED" );
+ }
+ }
+ else
+ {
+//System.out.println( "/usr/bin/open \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf\"" );
+ try{
+ proc = Runtime.getRuntime().exec( new String[]{"/usr/bin/open", "" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf" } );
+ }
+ catch( Exception ex )
+ {
+ ex.printStackTrace();
+ }
+// proc = Runtime.getRuntime().exec( "/usr/bin/open \"/Users/Shared/teste.pdf.pdf\"" );
+ }
+ }
+
+ public void printSilent( byte []pdf, String nome, String printerName )
+ throws Exception
+ {
+ long time = System.currentTimeMillis();
+// FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha" + time + ".pdf" );
+
+ if( System.getProperty( "os.name" ).startsWith( "Windows" ) )
+ {
+ Process proc;
+
+// FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + "\\print_fichas_temp\\" + nome + "_" + time + ".pdf" );
+ FileOutputStream fos = new FileOutputStream( "c:\\temp\\" + nome + "_" + time + ".pdf" );
+ fos.write( pdf );
+ fos.close();
+
+ System.out.println( "File saved ( " + nome + "_" + time + " )." );
+//System.out.println("cmd /c \"c:\\temp\\acrord32.lnk /t \"c:" + System.getProperty( "file.separator" ) + "temp" + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf\" \"" + printerName + "\"\"");
+// proc = Runtime.getRuntime().exec( new String[]{ System.getProperty( "user.home" ) + "\\print.bat",
+// System.getProperty( "user.home" ) + "\\print_fichas_temp\\" + nome + "_" + time + ".pdf",
+// printerName });
+ proc = Runtime.getRuntime().exec( new String[]{ System.getProperty( "user.home" ) + "\\print.bat",
+ "c:\\temp\\" + nome + "_" + time + ".pdf",
+ printerName });
+ proc.waitFor();
+// if( !new File( "c:\\temp\\" + nome + "_" + time + ".pdf" ).delete() )
+// {
+// System.err.println( "File: " + nome + "_" + ".pdf - NOT DELETED" );
+// }
+ }
+
+ }
+
+ public void cleanSilentPrint()
+ throws Exception
+ {
+ Process proc;
+ proc = Runtime.getRuntime().exec( "cmd /c \"del c:\\temp\\*.pdf\"" );
+ proc.waitFor();
+ }
+
+ public byte[] createPDF( HashMap values )
+ {
+ Document document = new Document();
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+
+ document.setPageSize( PageSize.A4 );
+
+ try {
+ PdfWriter pdfw = PdfWriter.getInstance( document, bos );
+
+ document.addTitle( "Ficha de Aptid\u00e3o" );
+ String acronym = (String) Singleton.getInstance( SingletonConstants.COMPANY_ACRONYM );
+ document.addAuthor( acronym != null ? acronym: "n/a" );
+ document.addCreator( "Evolute" );
+
+ document.open();
+
+ Paragraph conteudo = new Paragraph();
+
+ conteudo.add( new Chunk( "\n\nFICHA DE APTID\u00c3O\n",
+ FontFactory.getFont( "Arial", 10, Font.BOLD ) ) );
+ conteudo.add( new Chunk( "(Portaria n.\u00ba 299/2007, de 16 de Mar\u00e7o)",
+// conteudo.add( new Chunk( "(Portaria n\u00ba1031/2002, de 10 de Agosto)",
+ FontFactory.getFont( "Arial", 7, Font.BOLD ) ) );
+
+ conteudo.setAlignment( Element.ALIGN_CENTER );
+
+ document.add( conteudo );
+
+ Table table = new Table( 1 );
+ table.setBorderWidth( 1 );
+ table.setPadding( 5 );
+ table.setOffset( 0 );
+ table.setWidth( 100 );
+
+ table.addCell( new Phrase( "Empresa/Entidade", FONT_BOLD ) );
+
+ StringBuilder texto = new StringBuilder();
+ Phrase ph = new Phrase( 12f );
+
+ Cell cell = new Cell();
+ texto.append( "DESIGNA\u00c7\u00c3O SOCIAL: " + values.get( DESIGNACAO_SOCIAL ) + "\n" );
+ texto.append( "ESTABELECIMENTO: " + values.get( ESTABELECIMENTOS_NOME )
+ + " LOCALIDADE: " + values.get( ESTABELECIMENTOS_LOCALIDADE ) + "\n" );
+ texto.append( "SERVI\u00c7O DE SA\u00DaDE: Tipo " );
+ ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
+
+ texto = new StringBuilder( "Interno" );
+ ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_SAUDE_TIPO_INTERNO ) ) );
+
+ texto = new StringBuilder( "Interempresas" );
+ ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_SAUDE_TIPO_INTEREMPRESAS ), true ) );
+
+ texto = new StringBuilder( "Externo" );
+ ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_SAUDE_TIPO_EXTERNO ), true ) );
+
+ texto = new StringBuilder( "Servi\u00e7o Nacional de Sa\u00fade\n" );
+ ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_SAUDE_TIPO_SNS ), true ) );
+
+ texto = new StringBuilder();
+
+ texto.append( "DESIGNA\u00c7\u00c3O: " + values.get( SERVICO_SAUDE_DESIGNACAO ) + "\n" );
+ texto.append( "SERVI\u00c7O DE HIGIENE E SEGURAN\u00c7A: Tipo " );
+ ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
+
+ texto = new StringBuilder( "Interno" );
+ ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_HIGIENE_TIPO_INTERNO ) ) );
+
+ texto = new StringBuilder( "Interempresas" );
+ ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_HIGIENE_TIPO_INTEREMPRESAS ), true ) );
+
+ texto = new StringBuilder( "Externo" );
+ ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_HIGIENE_TIPO_EXTERNO ), true ) );
+
+ texto = new StringBuilder( "Outro\n" );
+ ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_HIGIENE_TIPO_OUTRO ), true ) );
+
+ texto = new StringBuilder();
+
+ texto.append( "DESIGNA\u00c7\u00c3O: " + values.get( SERVICO_HIGIENE_DESIGNACAO ) + "" );
+
+ ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
+
+ cell.addElement( ph );
+ table.addCell( cell );
+ document.add( table );
+
+ table = new Table( 1 );
+ table.setBorderWidth( 1 );
+ table.setPadding( 5 );
+ table.setOffset( 0 );
+ table.setWidth( 100 );
+
+ table.addCell( new Phrase( "Trabalhador",
+ FONT_BOLD ) );
+
+ texto = new StringBuilder();
+
+ texto.append( "NOME: " + values.get( TRABALHADORES_NOME ) + "\n" );
+ texto.append( "SEXO: " + values.get( SEXO ) + " DATA DE NASCIMENTO: "
+ + values.get( DATA_NASCIMENTO ) + " NACIONALIDADE: "
+ + values.get( NACIONALIDADE ) + "\n" );
+ texto.append( "N\u00daMERO MECANOGR\u00c1FICO/OUTRO: " + values.get( NUMERO_MECANOGRAFICO )
+ + " DATA DE ADMISS\u00c3O: " + values.get( DATA_ADMISSAO ) + "\n" );
+ texto.append( "CATEGORIA PROFISSIONAL: " + values.get( CATEGORIA )
+ + " LOCAL DE TRABALHO: " + values.get( LOCAL_TRABALHO ) + "\n" );
+ texto.append( "FUN\u00c7\u00c3O PROPOSTA: " + values.get( FUNCAO_PROPOSTA )
+ + " DATA DE ADMISS\u00c3O NA FUN\u00c7\u00c3O: "
+ + values.get( DATA_ADMISSAO_FUNCAO ) + "" );
+
+ table.addCell( new Phrase( 12f, texto.toString(), FONT_NORMAL ) );
+ document.add( table );
+
+ table = new Table( 1 );
+ table.setBorderWidth( 1 );
+ table.setOffset( 0 );
+ table.setPadding( 5 );
+ table.setWidth( 100 );
+
+ table.addCell( new Phrase( "Observa\u00e7\u00f5es",
+ FONT_BOLD ) );
+
+ texto = new StringBuilder();
+ texto.append( values.get( OBSERVACOES ) );
+
+ table.addCell( new Phrase( 12f, texto.toString(), FONT_NORMAL ) );
+ document.add( table );
+
+ table = new Table( 2 );
+ table.setBorderWidth( 1 );
+ table.setOffset( 0 );
+ table.setPadding( 5 );
+ table.setWidth( 100 );
+
+ cell = new Cell( new Phrase( "Exame M\u00e9dico",
+ FONT_BOLD ) );
+
+ cell.setColspan( 2 );
+ table.addCell( cell );
+
+ texto = new StringBuilder();
+ ph = new Phrase( 12f );
+ texto.append( "DATA DO EXAME: " + values.get( EXAMES_DATA ) + "\n" );
+ texto.append( "TIPO\n" );
+ ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
+
+ ph.add( doCheckedPhrase( "ADMISS\u00c3O\n", values.get( TIPO_ADMISSAO ) ) );
+
+ ph.add( doCheckedPhrase( "PERI\u00d3DICO\n", values.get( TIPO_PERIODICO ) ) );
+
+ ph.add( doCheckedPhrase( "OCASIONAL\n", values.get( TIPO_OCASIONAL ) ) );
+
+ ph.add( doCheckedPhrase( "AP\u00d3S DOEN\u00c7A\n", values.get( TIPO_APOS_DOENCA ), true ) );
+
+ ph.add( doCheckedPhrase( "AP\u00d3S ACIDENTE\n", values.get( TIPO_APOS_ACIDENTE ), true ) );
+
+ ph.add( doCheckedPhrase( "A PEDIDO DO TRABALHADOR\n", values.get( TIPO_PEDIDO_TRABALHADOR ), true ) );
+
+ ph.add( doCheckedPhrase( "A PEDIDO DO SERVI\u00c7O\n", values.get( TIPO_PEDIDO_EMPRESA ), true ) );
+
+ ph.add( doCheckedPhrase( "POR MUDAN\u00c7A DE FUN\u00c7\u00c3O\n", values.get( TIPO_MUDANCA_FUNCAO ), true ) );
+
+ ph.add( doCheckedPhrase( "POR ALTERA\u00c7\u00c3O DAS CONDI\u00c7\u00d5ES DE TRABALHO\n", values.get( TIPO_TRABALHO ), true ) );
+
+ ph.add( doCheckedPhrase( "OUTRO\n", values.get( TIPO_OUTRO ), true ) );
+
+ texto = new StringBuilder();
+ texto.append( " ESPECIFIQUE: " + values.get( TIPO_OUTRO_TEXTO ) );
+
+ ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
+
+ table.addCell( ph );
+
+ ph = new Phrase( 12f );
+ ph.add( new Chunk( "RESULTADO\n", FONT_NORMAL ) );
+ ph.add( doCheckedPhrase( "APTO\n", values.get( RESULTADO_APTO ) ) );
+
+ ph.add( doCheckedPhrase( "APTO CONDICIONALMENTE\n\n", values.get( RESULTADO_APTO_CONDICIONALMENTE ) ) );
+
+ ph.add( doCheckedPhrase( "INAPTO TEMPORARIAMENTE\n", values.get( RESULTADO_INAPTO_TEMP ) ) );
+
+ ph.add( doCheckedPhrase( "INAPTO DEFINITIVAMENTE\n\n", values.get( RESULTADO_INAPTO_DEF ) ) );
+
+ texto = new StringBuilder();
+ texto.append( "OUTRAS FUN\u00c7\u00d5ES QUE PODE DESEMPENHAR\n" );
+ texto.append( " 1 " + values.get( OUTRA_FUNCAO_1 ) + "\n" );
+ texto.append( " 2 " + values.get( OUTRA_FUNCAO_2 ) + "\n" );
+ texto.append( " 3 " + values.get( OUTRA_FUNCAO_3 ) + "\n" );
+ texto.append( " 4 " + values.get( OUTRA_FUNCAO_4 ) + "\n" );
+ ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
+ table.addCell( ph );
+
+ document.add( table );
+
+ table = new Table( 1 );
+ table.setBorderWidth( 1 );
+ table.setOffset( 0 );
+ table.setPadding( 5 );
+ table.setWidth( 100 );
+
+ table.addCell( new Phrase( "Outras Recomenda\u00e7\u00f5es",
+ FONT_BOLD ) );
+
+ texto = new StringBuilder();
+ if( ( (Boolean) Singleton.getInstance( SingletonConstants.FICHA_MARCA_EXAMES ) ).booleanValue() )
+ {
+ System.out.println( "ficha marca exames" );
+ texto.append( "PR\u00d3XIMO EXAME: " + values.get( PROXIMO_EXAME ) + "\n" );
+ }
+ texto.append( "" + values.get( OUTRAS_RECOMENDACOES ) + "" );
+
+ table.addCell( new Phrase( 12f, texto.toString(), FONT_NORMAL ) );
+ document.add( table );
+
+
+ table = new Table( 1 );
+ table.setBorderWidth( 1 );
+ table.setOffset( 0 );
+ table.setPadding( 5 );
+ table.setWidth( 100 );
+
+ texto = new StringBuilder();
+
+ texto.append( "M\u00c9DICO DO TRABALHO: "
+ + values.get( MEDICOS_NOME ) + " C.P. " + values.get( NUMERO_CEDULA ) + "\n" );
+ texto.append( "ASSINATURA _____________________________________________________________________________________\n\n" );
+ texto.append( "TOMEI CONHECIMENTO ___________________________________________________________ DATA:____/____/________\n" );
+ texto.append( " O RESPONS\u00c1VEL DOS RECURSOS HUMANOS" );
+
+ table.addCell( new Phrase( 18f, texto.toString(), FONT_NORMAL ) );
+ document.add( table );
+
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ return null;
+ }
+
+ document.close();
+ return bos.toByteArray();
+ }
+
+ private Phrase doCheckedPhrase( String text, String phrase, boolean indent )
+ {
+ boolean checked = CHECKED.equals( phrase );
+ Phrase p = new Phrase( 12f );
+ //p.add( new Chunk( ( indent ? " " : "" ) + ( char )( checked? 110: 111) + " ", FONT_ZAPFDINGBATS ) );
+ //System.out.println( "FAMILY: " + FONT_WINGDINGS.getFamilyname() );
+ p.add( new Chunk( ( indent ? " " : "" ) + ( char )( checked? 0xfe: 0xa8), FONT_WINGDINGS ) );
+// p.add( new Chunk( ( indent ? " " : "" ) + ( char )( checked? 'X': '_'), FONT_WINGDINGS ) );
+ p.add( new Chunk( text, FONT_NORMAL ) );
+ return p;
+ }
+
+ private Phrase doCheckedPhrase( String text, String phrase )
+ {
+ return doCheckedPhrase( text, phrase, false );
+ }
+}
\ No newline at end of file
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/ExamePanel.java b/trunk/SIPRPSoft/src/siprp/ficha/ExamePanel.java
new file mode 100644
index 00000000..36853696
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/ExamePanel.java
@@ -0,0 +1,527 @@
+/*
+ * ExamePanel.java
+ *
+ * Created on 29 de Marco de 2004, 11:57
+ */
+
+package siprp.ficha;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.io.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.documents.*;
+import com.evolute.utils.data.*;
+import com.evolute.utils.dataui.*;
+import com.evolute.utils.jdo.*;
+//import com.evolute.utils.metadb.*;
+import com.evolute.utils.ui.*;
+import com.evolute.utils.ui.button.*;
+import com.evolute.utils.ui.calendar.*;
+import com.evolute.utils.ui.panel.*;
+import com.evolute.utils.ui.text.*;
+
+import siprp.*;
+import siprp.data.*;
+/**
+ *
+ * @author fpalma
+ */
+public class ExamePanel extends JPanel
+ implements ChangeListener, ControllableComponent, ListSelectionListener
+{
+ static
+ {
+ ExameData.registerOperationHandlerForClass( DisableDeleteHandler.INSTANCE, ExameData.class );
+ }
+ private JDOProvider JDO;
+
+ private JCalendarPanel dataExamePanel;
+ private BetterButtonGroup tipoGroup;
+ private JRadioButton admissaoRadio;
+ private JRadioButton periodicoRadio;
+ private JRadioButton ocasionalRadio;
+// private JRadioButton outroRadio;
+ private RadioButtonFixedPanel ocasionalPanel;
+ private JTextField especificarText;
+ private RadioButtonFixedPanel tipoProximoPanel;
+ private JCalendarPanel proximoExamePanel;
+ private RadioButtonFixedPanel resultadoPanel;
+ private JTextField outrasFuncoesTexts[];
+ private JTextArea recomendacoesText;
+
+ private FichaDataProvider provider;
+ private ComponentsHashtable components;
+
+ private Integer trabalhadorID;
+ private MarcacaoTrabalhadorData marcacao;
+
+ /** Creates a new instance of ExamePanel */
+ public ExamePanel()
+ throws Exception
+ {
+ provider = (FichaDataProvider)FichaDataProvider.getProvider();
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ setupComponents();
+ setupComponentsHashtable();
+ }
+
+ private void setupComponents()
+ {
+ setBorder( BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(),
+ "Exame M\u00e9dico" ) );
+
+ JPanel leftPanel = new JPanel();
+ JPanel rightPanel = new JPanel();
+ JPanel dataExameOuterPanel = new JPanel();
+ JLabel dataExameLabel = new JLabel( "Data do Exame" );
+ dataExamePanel = new JCalendarPanel( null );
+ JPanel tipoPanel = new JPanel();
+ tipoPanel.setBorder( BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(), "Tipo" ) );
+ tipoGroup = new BetterButtonGroup( false );
+ admissaoRadio = new JRadioButton( "Admiss\u00e3o" );
+ tipoGroup.add( admissaoRadio );
+ periodicoRadio = new JRadioButton( "Peri\u00f3dico" );
+ tipoGroup.add( periodicoRadio );
+ ocasionalRadio = new JRadioButton( "Ocasional" );
+ tipoGroup.add( ocasionalRadio );
+ ocasionalRadio.addChangeListener( this );
+// outroRadio = new JRadioButton( "Outro" );
+// tipoGroup.add( outroRadio );
+// outroRadio.addChangeListener( this );
+ ocasionalPanel = new RadioButtonFixedPanel(
+ new IDObject[]{ new MappableObject( new Integer( 1 ), "Ap\u00f3s doen\u00e7a" ),
+ new MappableObject( new Integer( 2 ), "Ap\u00f3s acidente" ),
+ new MappableObject( new Integer( 3 ), "A pedido do trabalhador" ),
+ new MappableObject( new Integer( 4 ), "A pedido do servi\u00e7o" ),
+ new MappableObject( new Integer( 5 ), "Por mudan\u00e7a de fun\u00e7\u00e3o" ),
+ new MappableObject( new Integer( 6 ), "Por altera\u00e7\u00e3o das condi\u00e7\u00f5es de trabalho" ),
+ new MappableObject( new Integer( 10 ), "Outro" ) },
+ false );
+ ocasionalPanel.addListSelectionListener( this );
+ ocasionalPanel.setEnabled( false );
+ especificarText = new JTextField();
+ especificarText.setEnabled( false );
+ JPanel proximoExameOuterPanel = new JPanel();
+ proximoExameOuterPanel.setBorder( BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(), "Pr\u00f3ximo Exame" ) );
+ proximoExamePanel = new JCalendarPanel( null );
+ tipoProximoPanel = new RadioButtonFixedPanel(
+ new IDObject[]{ new MappableObject( new Integer( 2 ), "Peri\u00f3dico" ),
+ new MappableObject( new Integer( 3 ), "Ocasional" ) },
+ RadioButtonFixedPanel.ORIENTATION_HORIZONTAL, 1, 2, false );
+// JLabel proximoExameLabel = new JLabel( "Pr\u00f3ximo Exame" );
+
+ JPanel resultadoOuterPanel = new JPanel();
+ resultadoOuterPanel.setBorder( BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(), "Resultado" ) );
+ resultadoPanel = new RadioButtonFixedPanel(
+ new IDObject[]{ new MappableObject( new Integer( 1 ), "Apto" ),
+ new MappableObject( new Integer( 2 ), "Apto condicionalmente" ),
+ new MappableObject( new Integer( 3 ), "Inapto temporariamente" ),
+ new MappableObject( new Integer( 4 ), "Inapto definitivamente" ) },
+ false );
+ JLabel outrasFuncoesLabel = new JLabel( "Outras fun\u00e7\u00f5es que pode desempenhar", JLabel.CENTER );
+ JPanel outrasFuncoesPanel = new JPanel();
+ JLabel outrasFuncoesLabels[] = new JLabel[ 4 ];
+ outrasFuncoesTexts = new JTextField[ 4 ];
+ for( int n = 0; n < 4; n++ )
+ {
+ outrasFuncoesLabels[ n ] = new JLabel( "" + ( n + 1 ) );
+ outrasFuncoesTexts[ n ] = new JTextField();
+ }
+ JScrollPane recomendacoesScp = new JScrollPane();
+ recomendacoesScp.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ recomendacoesScp.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
+ recomendacoesText = new JTextArea();
+ recomendacoesText.setLineWrap( true );
+ recomendacoesText.setWrapStyleWord( true );
+ recomendacoesText.setDocument( new MaximumLengthDocument( 300 ) );
+ recomendacoesScp.setViewportView( recomendacoesText );
+ recomendacoesScp.setBorder( BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(),
+ "Outras recomenda\u00e7\u00f5es" ) );
+
+ setLayout( new GridLayout( 1, 2 ) );
+ add( leftPanel );
+ add( rightPanel );
+
+ leftPanel.setLayout( new BorderLayout() );
+
+ dataExameOuterPanel.setLayout( new BorderLayout() );
+ dataExameOuterPanel.add( dataExameLabel, BorderLayout.WEST );
+ dataExameOuterPanel.add( dataExamePanel, BorderLayout.CENTER );
+ leftPanel.add( dataExameOuterPanel, BorderLayout.NORTH );
+ leftPanel.add( tipoPanel, BorderLayout.CENTER );
+ proximoExameOuterPanel.setLayout( new BorderLayout() );
+// proximoExameOuterPanel.add( proximoExameLabel, BorderLayout.WEST );
+ proximoExameOuterPanel.add( proximoExamePanel, BorderLayout.CENTER );
+ proximoExameOuterPanel.add( tipoProximoPanel, BorderLayout.SOUTH );
+ if( ( ( Boolean ) Singleton.getInstance( SingletonConstants.FICHA_MARCA_EXAMES ) ).booleanValue() )
+ {
+ leftPanel.add( proximoExameOuterPanel, BorderLayout.SOUTH );
+ }
+
+ GridBagLayout gridbag = new GridBagLayout();
+ tipoPanel.setLayout( gridbag );
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.insets = new Insets( 0, 1, 0, 1 );
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ constraints.weighty = 0;
+ constraints.gridheight = 1;
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+
+ gridbag.setConstraints( admissaoRadio, constraints );
+ tipoPanel.add( admissaoRadio );
+
+ gridbag.setConstraints( periodicoRadio, constraints );
+ tipoPanel.add( periodicoRadio );
+
+ gridbag.setConstraints( ocasionalRadio, constraints );
+ tipoPanel.add( ocasionalRadio );
+
+ constraints.weightx = 0.1;
+ constraints.gridwidth = 1;
+ JPanel pad = new JPanel();
+ gridbag.setConstraints( pad, constraints );
+ tipoPanel.add( pad );
+
+ constraints.weightx = 0.9;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( ocasionalPanel, constraints );
+ tipoPanel.add( ocasionalPanel );
+
+// constraints.weightx = 0;
+// constraints.gridwidth = 1;
+// gridbag.setConstraints( outroRadio, constraints );
+// tipoPanel.add( outroRadio );
+
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( especificarText, constraints );
+ tipoPanel.add( especificarText );
+
+
+ gridbag = new GridBagLayout();
+ rightPanel.setLayout( gridbag );
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ constraints.gridheight = 1;
+ constraints.weighty = 0;
+
+ gridbag.setConstraints( resultadoOuterPanel, constraints );
+ rightPanel.add( resultadoOuterPanel );
+
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ //constraints.gridheight = GridBagConstraints.REMAINDER;
+ constraints.weighty = 1;
+// JPanel recomendacoesOuterPanel = new JPanel();
+// recomendacoesOuterPanel.setLayout( new GridLayout( 1, 1 ) );
+// recomendacoesOuterPanel.add( recomendacoesScp );
+ gridbag.setConstraints( recomendacoesScp, constraints );
+ rightPanel.add( recomendacoesScp );
+
+ gridbag = new GridBagLayout();
+ resultadoOuterPanel.setLayout( gridbag );
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ constraints.gridheight = 1;
+ constraints.weighty = 0;
+
+ gridbag.setConstraints( resultadoPanel, constraints );
+ resultadoOuterPanel.add( resultadoPanel );
+
+ gridbag.setConstraints( outrasFuncoesLabel, constraints );
+ resultadoOuterPanel.add( outrasFuncoesLabel );
+
+ gridbag.setConstraints( outrasFuncoesPanel, constraints );
+ resultadoOuterPanel.add( outrasFuncoesPanel );
+
+ for( int n = 0; n < outrasFuncoesTexts.length; n++ )
+ {
+ constraints.weightx = 0.1;
+ constraints.gridwidth = 1;
+ pad = new JPanel();
+ gridbag.setConstraints( pad, constraints );
+ resultadoOuterPanel.add( pad );
+
+ constraints.weightx = 0;
+ gridbag.setConstraints( outrasFuncoesLabels[ n ], constraints );
+ resultadoOuterPanel.add( outrasFuncoesLabels[ n ] );
+
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( outrasFuncoesTexts[ n ], constraints );
+ resultadoOuterPanel.add( outrasFuncoesTexts[ n ] );
+ new CopyPasteHandler( outrasFuncoesTexts[ n ] );
+ }
+
+ new CopyPasteHandler( especificarText );
+ new CopyPasteHandler( recomendacoesText );
+ }
+
+ private void setupComponentsHashtable()
+ {
+ components = new ComponentsHashtable();
+ components.putDummy( ExameData.TIPO );
+ components.putComponent( ExameData.DATA, dataExamePanel );
+ components.putComponent( ExameData.OCASIONAL, ocasionalPanel );
+ components.putComponent( ExameData.OUTRO_TIPO, especificarText );
+ components.putComponent( ExameData.PROXIMO_EXAME, proximoExamePanel );
+ components.putComponent( ExameData.RESULTADO, resultadoPanel );
+ components.putComponent( ExameData.OUTRA_FUNCAO_1, outrasFuncoesTexts[ 0 ] );
+ components.putComponent( ExameData.OUTRA_FUNCAO_2, outrasFuncoesTexts[ 1 ] );
+ components.putComponent( ExameData.OUTRA_FUNCAO_3, outrasFuncoesTexts[ 2 ] );
+ components.putComponent( ExameData.OUTRA_FUNCAO_4, outrasFuncoesTexts[ 3 ] );
+ components.putComponent( ExameData.OUTRAS_RECOMENDACOES, recomendacoesText );
+ components.putDummy( ExameData.INACTIVO );
+ components.putDummy( ExameData.TRABALHADOR );
+ components.putDummy( ExameData.MEDICO );
+ components.putDummy( ExameData.PDF );
+ components.putDummy( ExameData.FO );
+ }
+
+ public void stateChanged( ChangeEvent e )
+ {
+ if( e.getSource().equals( ocasionalRadio ) )
+ {
+ ocasionalPanel.setEnabled( ocasionalRadio.isSelected() && ocasionalRadio.isEnabled() ) ;
+ }
+// else if( e.getSource().equals( outroRadio ) )
+// {
+// especificarText.setEnabled( outroRadio.isSelected() && outroRadio.isEnabled() );
+// }
+ }
+
+
+ public void fill( Object value )
+ {
+ clear();
+ trabalhadorID = ( Integer ) value;
+ if( trabalhadorID == null )
+ {
+ return;
+ }
+ try
+ {
+ Integer marcacaoID = provider.getMarcacaoIDByTrabalhador( trabalhadorID );
+
+ if( marcacaoID != null )
+ {
+ marcacao = ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, marcacaoID );
+ proximoExamePanel.setDate( (Date) marcacao.get( Marcacao.DATA ) );
+ }
+ Object dadosMarcacao[] = provider.getDadosUltimaMarcacao( trabalhadorID );
+ if( dadosMarcacao != null )
+ {
+ dataExamePanel.setDate( ( Date ) dadosMarcacao[ 0 ] );
+ Integer tipo = ( Integer ) dadosMarcacao[ 1 ];
+ int tipoValue = tipo != null ? tipo.intValue() : 0;
+ tipoGroup.setIntSelected( tipoValue > 0 ? tipoValue - 1 : 0 );
+ }
+
+ }
+ catch( Exception ex )
+ {
+ ex.printStackTrace();
+ return;
+ }
+
+// Integer trabID = (Integer) value;
+// if( trabID == null )
+// {
+// return;
+// }
+// try
+// {
+// Integer id = provider.getLastExameIDForTrabalhador( trabID );
+// if( id == null )
+// {
+// return;
+// }
+// MetaObject exame = provider.load( provider.EXAMES, new DBKey( id ) );
+// byte pdf[] = (byte []) exame.getProperty( provider.PDF );
+// if( pdf != null )
+// {
+// FileOutputStream fos = new FileOutputStream( "C:\\teste.pdf" );
+// fos.write( pdf );
+// fos.close();
+// }
+// }
+// catch( Exception ex )
+// {
+// ex.printStackTrace();
+// return;
+// }
+ }
+
+ public Object save()
+ {
+ StringBuffer msg = new StringBuffer();
+ boolean hasMsg = false;
+ boolean hasData = false;
+ ExameData exame;
+ Date dataExame = dataExamePanel.getDate();
+ if( dataExame == null )
+ {
+ dataExame = new Date();
+ }
+ Calendar cal = Calendar.getInstance();
+ cal.add( Calendar.DAY_OF_MONTH, 1 );
+ if( !cal.getTime().after( dataExame ) )
+ {
+ throw new ValuesException( "N\u00E3o \u00E9 poss\u00EDvel gravar exames com datas futuras." );
+ }
+ try
+ {
+ String recomendacoes = recomendacoesText.getText();
+ String linhas[] = recomendacoes.split( "\\n" );
+ Vector linhasV = new Vector();
+ for( int n = 0; n < linhas.length; n++ )
+ {
+ if( linhas[ n ].trim().length() > 0 )
+ {
+ linhasV.add( linhas[ n ] );
+ }
+ }
+ if( linhasV.size() > 0 )
+ {
+ linhas = ( String[] ) linhasV.toArray( new String[0] );
+ boolean compress = false;
+ if( linhas.length == 2 )
+ {
+ linhas[ 0 ] += " ";
+ }
+ recomendacoes = "";
+ for( int n = 0; n < linhas.length; n++ )
+ {
+ recomendacoes += linhas[ n ];
+ }
+ }
+ recomendacoesText.setText( recomendacoes.trim() );
+
+// exame = provider.createObject( FichaDataProvider.EXAMES );
+ exame = new ExameData();
+// DBField fields[] = FichaDataProvider.EXAMES.getInsertFields();
+// String exameFields[] = new String[ fields.length ];
+// for( int i = 0; i < exameFields.length; ++i )
+// {
+// exameFields[ i ] = fields[ i ].FULL_NAME;
+// }
+// Hashtable hash = new Hashtable();
+// ComponentController.save( exameFields, hash, components );
+// hash.put( FichaDataProvider.T_EXAMES + "." + FichaDataProvider.INACTIVO, "n" );
+// Enumeration enum = hash.keys();
+// while( enum.hasMoreElements() )
+// {
+// String name = ( String )enum.nextElement();
+// exame.setProperty( name, hash.get( name ) );
+// }
+ String names[] = exame.getFieldNames();
+ Hashtable hash = new Hashtable();
+ ComponentController.save( names, hash, components );
+ exame.setHashData( hash );
+
+ int tipo = 0;
+ if( admissaoRadio.isSelected() )
+ {
+ tipo = 1;
+ }
+ else if( periodicoRadio.isSelected() )
+ {
+ tipo = 2;
+ }
+ else if( ocasionalRadio.isSelected() )
+ {
+ tipo = 3;
+ }
+// else if( outroRadio.isSelected() )
+// {
+// tipo = 4;
+// }
+// exame.setProperty( FichaDataProvider.TIPO, new Integer( tipo ) );
+ exame.set( ExameData.TIPO, new Integer( tipo ) );
+ if( tipo != 3 )
+ {
+// exame.setProperty( FichaDataProvider.EXAMES.getFieldByName( FichaDataProvider.OCASIONAL ).FULL_NAME, null );
+ exame.set( ExameData.OCASIONAL, null );
+// exame.setProperty( FichaDataProvider.EXAMES.getFieldByName( FichaDataProvider.OUTRO_TIPO ).FULL_NAME, "" );
+ exame.set( ExameData.OUTRO_TIPO, "" );
+ }
+ else
+ {
+ Integer ocasionalID = ( Integer )ocasionalPanel.save();
+ if( ocasionalID == null || ocasionalID.intValue() != 10 )
+ {
+// exame.setProperty( FichaDataProvider.EXAMES.getFieldByName( FichaDataProvider.OUTRO_TIPO ).FULL_NAME, "" );
+ exame.set( ExameData.OUTRO_TIPO, "" );
+ }
+ }
+ }
+ catch( Exception ex )
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ if( hasMsg )
+ {
+ throw new ValuesException( msg.toString() );
+ }
+ return exame;
+ }
+
+ public void clear()
+ {
+ String names[] = (String[])components.keySet().toArray( new String[0] );
+ ComponentController.clear( names, components );
+ tipoGroup.setIntSelected( 0 );
+ dataExamePanel.setDate( new Date() );
+ tipoProximoPanel.setSelected( new Integer( 2 ) );
+ marcacao = null;
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ String names[] = (String[])components.keySet().toArray( new String[0] );
+ ComponentController.setEnabled( names, enable, components );
+ admissaoRadio.setEnabled( enable );
+ periodicoRadio.setEnabled( enable );
+ ocasionalRadio.setEnabled( enable );
+// outroRadio.setEnabled( enable );
+ ocasionalPanel.setEnabled( ocasionalRadio.isSelected() && ocasionalRadio.isEnabled() ) ;
+// especificarText.setEnabled( outroRadio.isSelected() && outroRadio.isEnabled() );
+ setEspecificarState();
+ }
+
+ public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent)
+ {
+ setEspecificarState();
+ }
+
+ public void setEspecificarState()
+ {
+ Integer id = ( Integer )ocasionalPanel.save();
+ if( id != null && id.intValue() == 10 )
+ {
+ especificarText.setEnabled( ocasionalRadio.isSelected() && ocasionalRadio.isEnabled() );
+ }
+ else
+ {
+ especificarText.setEnabled( false );
+ }
+ }
+
+ public Integer getMotivoProximoExame()
+ {
+ return tipoProximoPanel.getSelected();
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoConstants.java b/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoConstants.java
new file mode 100644
index 00000000..6fb08f27
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoConstants.java
@@ -0,0 +1,74 @@
+/*
+ * FichaAptidaoConstants.java
+ *
+ * Created on May 14, 2007, 5:12 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.ficha;
+
+/**
+ *
+ * @author lflores
+ */
+public interface FichaAptidaoConstants
+{
+ /* unicode
+ private final String SQUARE = "☐";
+ private final String CHECKED = "☑";*/
+/* windows arial circle (full circle) */
+ public static final String SQUARE = "○";
+ public static final String CHECKED = "●";
+
+ public static final String PORTARIA = "portaria";
+ public static final String DESIGNACAO_SOCIAL = "designacao_social";
+ public static final String ESTABELECIMENTOS_NOME = "estabelecimentos.nome";
+ public static final String ESTABELECIMENTOS_LOCALIDADE = "estabelecimentos.localidade";
+ public static final String SERVICO_SAUDE_TIPO_INTERNO = "servico_saude_tipo_interno";
+ public static final String SERVICO_SAUDE_TIPO_INTEREMPRESAS = "servico_saude_tipo_interempresas";
+ public static final String SERVICO_SAUDE_TIPO_EXTERNO = "servico_saude_tipo_externo";
+ public static final String SERVICO_SAUDE_TIPO_SNS = "servico_saude_tipo_sns";
+ public static final String SERVICO_SAUDE_DESIGNACAO = "servico_saude_designacao";
+ public static final String SERVICO_HIGIENE_TIPO_INTERNO = "servico_higiene_tipo_interno";
+ public static final String SERVICO_HIGIENE_TIPO_INTEREMPRESAS = "servico_higiene_tipo_interempresas";
+ public static final String SERVICO_HIGIENE_TIPO_EXTERNO = "servico_higiene_tipo_externo";
+ public static final String SERVICO_HIGIENE_TIPO_OUTRO = "servico_higiene_tipo_outro";
+ public static final String SERVICO_HIGIENE_DESIGNACAO = "servico_higiene_designacao";
+ public static final String TRABALHADORES_NOME = "trabalhadores.nome";
+ public static final String SEXO = "sexo";
+ public static final String DATA_NASCIMENTO = "data_nascimento";
+ public static final String NACIONALIDADE = "nacionalidade";
+ public static final String NUMERO_MECANOGRAFICO = "numero_mecanografico";
+ public static final String DATA_ADMISSAO = "data_admissao";
+ public static final String CATEGORIA = "categoria";
+ public static final String LOCAL_TRABALHO = "local_trabalho";
+ public static final String FUNCAO_PROPOSTA = "funcao_proposta";
+ public static final String DATA_ADMISSAO_FUNCAO = "data_admissao_funcao";
+ public static final String OBSERVACOES = "observacoes";
+ public static final String EXAMES_DATA = "exames.data";
+ public static final String TIPO_ADMISSAO = "tipo_admissao";
+ public static final String TIPO_PERIODICO = "tipo_periodico";
+ public static final String TIPO_OCASIONAL = "tipo_ocasional";
+ public static final String TIPO_APOS_DOENCA = "tipo_apos_doenca";
+ public static final String TIPO_APOS_ACIDENTE = "tipo_apos_acidente";
+ public static final String TIPO_PEDIDO_TRABALHADOR = "tipo_pedido_trabalhador";
+ public static final String TIPO_PEDIDO_EMPRESA = "tipo_pedido_empresa";
+ public static final String TIPO_MUDANCA_FUNCAO = "tipo_mudanca_funcao";
+ public static final String TIPO_TRABALHO = "tipo_trabalho";
+ public static final String TIPO_OUTRO = "tipo_outro";
+ public static final String TIPO_OUTRO_TEXTO = "tipo_outro_texto";
+ public static final String RESULTADO_APTO = "resultado_apto";
+ public static final String RESULTADO_APTO_CONDICIONALMENTE = "resultado_apto_condicionalmente";
+ public static final String RESULTADO_INAPTO_TEMP = "resultado_inapto_temp";
+ public static final String RESULTADO_INAPTO_DEF = "resultado_inapto_def";
+ public static final String OUTRA_FUNCAO_1 = "outra_funcao_1";
+ public static final String OUTRA_FUNCAO_2 = "outra_funcao_2";
+ public static final String OUTRA_FUNCAO_3 = "outra_funcao_3";
+ public static final String OUTRA_FUNCAO_4 = "outra_funcao_4";
+ public static final String OUTRAS_RECOMENDACOES = "outras_recomendacoes";
+ public static final String PROXIMO_EXAME = "proximo_exame";
+ public static final String MEDICOS_NOME = "medicos.nome";
+ public static final String NUMERO_CEDULA = "numero_cedula";
+}
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoCreator.java b/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoCreator.java
new file mode 100644
index 00000000..36e0e272
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoCreator.java
@@ -0,0 +1,102 @@
+/*
+ * FichaAptidaoCreator.java
+ *
+ * Created on May 14, 2007, 4:50 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.ficha;
+
+import com.evolute.utils.fop.FOPCreator;
+import com.evolute.utils.fop.FOPPrinter;
+import com.evolute.utils.fop.PDFCreator;
+import com.evolute.utils.strings.UnicodeChecker;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.HashMap;
+
+/**
+ *
+ * @author lflores
+ */
+public class FichaAptidaoCreator implements FichaAptidaoConstants
+{
+ private final FOPCreator fopCreator;
+ private final PDFCreator pdfCreator;
+ private final FOPPrinter fopPrinter;
+
+ private static FichaAptidaoCreator creator = null;
+
+ /** Creates a new instance of FichaAptidaoCreator */
+ private FichaAptidaoCreator()
+ {
+ fopCreator = FOPCreator.getFOPCreator();
+ pdfCreator = PDFCreator.getPDFCreator();
+ fopPrinter = FOPPrinter.getFOPPrinter();
+ }
+
+ public static FichaAptidaoCreator getCreator()
+ {
+ if( creator == null )
+ {
+ creator = new FichaAptidaoCreator();
+ }
+ return creator;
+ }
+
+ public void print( byte fo[] )
+ throws Exception
+ {
+ ByteArrayInputStream in = new ByteArrayInputStream( fo );
+ fopPrinter.printFO( in, true, true, null );
+// System.out.println( "DONE" );
+ }
+
+ public void printSilent( byte fo[], String printerName )
+ throws Exception
+ {
+ ByteArrayInputStream in = new ByteArrayInputStream( fo );
+ fopPrinter.printFO( in, true, false, null );
+ }
+
+ public byte[] createFO( HashMap values )
+ throws Exception
+ {
+ StringBuilder buff = new StringBuilder( "\n\n" );
+
+ values.put( PORTARIA, "Portaria n. 299/2007, de 16 de Março" );
+
+// ☐ square
+// ☑ checked square
+
+ for( String key: values.keySet() )
+ {
+ buff.append( "\t<" + key + ">" );
+ String val = values.get( key );
+ buff.append( UnicodeChecker.parseToUnicode( "", ";", val, true ) );
+ buff.append( "" + key + ">\n" );
+ }
+ buff.append( "" );
+ String xml = buff.toString();
+
+ System.out.println( "XML: " + xml );
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ InputStream xmlIn = new ByteArrayInputStream( xml.getBytes() );
+
+ InputStream xslStream = getClass().getClassLoader().getResourceAsStream( "siprp/ficha/ficha_aptidao.xsl" );
+ fopCreator.createFOfromXML( xmlIn, xslStream, out );
+ // System.out.println( "FO created" );
+
+ return out.toByteArray();
+ }
+
+ public byte[] createPDF( byte[] fo )
+ throws Exception
+ {
+ return pdfCreator.createPdfFromFo( fo );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoEditorManager.java b/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoEditorManager.java
new file mode 100644
index 00000000..ce664623
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoEditorManager.java
@@ -0,0 +1,204 @@
+/*
+ * FichaAptidaoEditorManager.java
+ *
+ * Created on 30 de Marco de 2004, 19:23
+ */
+
+package siprp.ficha;
+
+import com.evolute.utils.editormanager.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class FichaAptidaoEditorManager extends EditorManager
+{
+ private static final EditorManagerFactory FACTORY = new FichaAptidaoEditorManagerFactory();
+
+ public static EditorManagerFactory getEditorManagerFactory()
+ {
+ return FACTORY;
+ }
+
+ /** Creates a new instance of FichaAptidaoEditorManager */
+ public FichaAptidaoEditorManager( Editor ed, int i )
+ {
+ super( ed, i );
+ }
+
+ /** Creates a new instance of FichaAptidaoEditorManager */
+ public FichaAptidaoEditorManager( Editor ed, int i, EditorManagerInterface subMan )
+ {
+ super( ed, i, subMan );
+ throw new RuntimeException( "FichaAptidaoEditorManager cannot have subManagers" );
+ }
+
+ /** Creates a new instance of FichaAptidaoEditorManager */
+ public FichaAptidaoEditorManager( Editor ed, int i, EditorManagerInterface subMan[] )
+ {
+ super( ed, i, subMan );
+ throw new RuntimeException( "FichaAptidaoEditorManager cannot have subManagers" );
+ }
+
+ public boolean isEditing()
+ {
+ if( state != STATE_UNSELECT )
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public void enable()
+ {
+// System.out.println( "EditorManager: enable " + this );
+ editor.enableComponents( index, false );
+ // new, edit, cancel, save, delete, select
+ editor.actions( index, true, false, false, false, false, true );
+ enabled = true;
+ }
+
+ public void disable()
+ {
+// System.out.println( "EditorManager: disable " + this );
+ editor.clear( index );
+ editor.enableComponents( index, false );
+ // new, edit, cancel, save, delete, select
+ editor.actions( index, false, false, false, false, false, false );
+ enabled = false;
+ state = STATE_UNSELECT;
+ }
+
+ public void unlock(boolean direction)
+ {
+ editor.enableComponents( index, false );
+ if( enabled )
+ {
+ if( state == STATE_UNSELECT )
+ {
+ // new, edit, cancel, save, delete, select
+ editor.actions( index, true, false, false, false, false, true );
+ }
+ else
+ {
+ // new, edit, cancel, save, delete, select
+ editor.actions( index, true, true, false, false, true, true );
+ }
+ }
+ }
+
+ public void select()
+ {
+// System.out.println( "EditorManager: select " + this );
+ // new, edit, cancel, save, delete, select
+ editor.actions( index, true, true, true, true, true, true );
+ state = STATE_EDIT;
+ }
+
+ public void unselect()
+ {
+// System.out.println( "EditorManager: select " + this );
+ // new, edit, cancel, save, delete, select
+ editor.actions( index, true, false, false, false, false, true );
+ state = STATE_UNSELECT;
+ }
+
+ public void newItem()
+ {
+// System.out.println( "EditorManager: new " + this );
+ editor.enableComponents( index, true );
+ // new, edit, cancel, save, delete, select
+ editor.actions( index, false, false, true, true, true, false );
+ state = STATE_NEW;
+ }
+
+ public void cancelItem()
+ {
+// System.out.println( "EditorManager: cancel " + this );
+ if( state == STATE_NEW )
+ {
+ editor.clear( index );
+ editor.enableComponents( index, false );
+ // new, edit, cancel, save, delete, select
+ editor.actions( index, true, false, false, false, false, true );
+ state = STATE_UNSELECT;
+ }
+ else if( state == STATE_EDIT )
+ {
+ editor.reload( index );
+ editor.enableComponents( index, true );
+ // new, edit, cancel, save, delete, select
+ editor.actions( index, true, true, true, true, true, true );
+ state = STATE_EDIT;
+ }
+ }
+
+ public void saveItem()
+ {
+// System.out.println( "EditorManager: save " + this );
+ if( ! editor.save( index ) )
+ {
+ return;
+ }
+ editor.enableComponents( index, false );
+ // new, edit, cancel, save, delete, select
+ editor.actions( index, true, true, false, false, true, true );
+ state = STATE_EDIT;
+ }
+
+ public void deleteItem()
+ {
+// System.out.println( "EditorManager: delete " + this );
+ if( editor.delete( index ) )
+ {
+ editor.clear( index );
+ editor.enableComponents( index, false );
+ // new, edit, cancel, save, delete, select
+ editor.actions( index, true, false, false, false, false, true );
+ state = STATE_UNSELECT;
+ }
+ }
+
+ public void refresh()
+ {
+// System.out.println( "EditorManager: refresh " + this );
+ if( !enabled )
+ {
+ disable();
+ return;
+ }
+ switch( state )
+ {
+ case STATE_NEW:
+ editItem();
+ state = STATE_NEW;
+ break;
+ case STATE_EDIT:
+ editItem();
+ break;
+ case STATE_SELECT:
+ throw new RuntimeException( "FichaAptidaoEditorManager cannot be in STATE_SELECT" );
+ case STATE_UNSELECT:
+ enable();
+ break;
+ }
+ }
+
+ public void editItem()
+ {
+ state = STATE_EDIT;
+ editor.actions( index, false, false, true, true, true, false );
+ }
+
+ public void lock(boolean direction)
+ {
+ throw new RuntimeException( "lock cannot be called on FichaAptidaoEditorManager" );
+ }
+
+ public void registerMain(EditorManagerInterface mainMan)
+ {
+ throw new RuntimeException( "registerMain cannot be called on FichaAptidaoEditorManager" );
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoEditorManagerFactory.java b/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoEditorManagerFactory.java
new file mode 100644
index 00000000..e7d4196f
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoEditorManagerFactory.java
@@ -0,0 +1,38 @@
+/*
+ * FichaAptidaoEditorManagerFactory.java
+ *
+ * Created on 30 de Marco de 2004, 20:48
+ */
+
+package siprp.ficha;
+
+import com.evolute.utils.editormanager.*;
+/**
+ *
+ * @author fpalma
+ */
+public class FichaAptidaoEditorManagerFactory
+ implements EditorManagerFactory
+{
+
+ /** Creates a new instance of FichaAptidaoEditorManagerFactory */
+ public FichaAptidaoEditorManagerFactory()
+ {
+ }
+
+ public EditorManagerInterface createEditorManager(Editor ed, int i)
+ {
+ return new FichaAptidaoEditorManager( ed, i );
+ }
+
+ public EditorManagerInterface createEditorManager(Editor ed, int i, EditorManagerInterface[] subMan)
+ {
+ return new FichaAptidaoEditorManager( ed, i, subMan );
+ }
+
+ public EditorManagerInterface createEditorManager(Editor ed, int i, EditorManagerInterface subMan)
+ {
+ return new FichaAptidaoEditorManager( ed, i, subMan );
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java b/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java
new file mode 100644
index 00000000..27e45569
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java
@@ -0,0 +1,860 @@
+/*
+ * FichaWindow.java
+ *
+ * Created on 29 de Marco de 2004, 11:50
+ */
+
+package siprp.ficha;
+
+import siprp.*;
+import siprp.data.*;
+import siprp.importer.*;
+import siprp.medicina.*;
+
+import java.awt.*;
+import java.io.*;
+import java.util.*;
+import javax.swing.*;
+import java.text.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.data.*;
+import com.evolute.utils.jdo.*;
+import com.evolute.utils.metadb.*;
+import com.evolute.utils.strings.*;
+import com.evolute.utils.tracker.*;
+import com.evolute.utils.ui.*;
+import com.evolute.utils.ui.panel.*;
+import com.evolute.utils.ui.search.*;
+import com.evolute.utils.ui.window.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class FichaWindow extends TabbedWindow
+ implements ListAction, FichaAptidaoConstants
+{
+ private JDOProvider JDO;
+
+ private UpperPanel upperPanel;
+ private EmpresaPanel empresaPanel;
+ private TrabalhadorPanel trabalhadorPanel;
+ private ObservacoesPanel observacoesPanel;
+ private ExamePanel examePanel;
+
+ private FichaDataProvider fdpProvider;
+ private MarcacoesMedicinaHandler marcacoesHandler;
+ private Integer empresaID;
+ private Integer estabelecimentoID;
+ private Integer trabalhadorID;
+
+ private final ExamePDF ePDF = new ExamePDF();
+
+ private static int permissions[][] =
+ new int[][]{ { NEW_INDEX, CANCEL_INDEX, SAVE_INDEX } };
+
+ private static FichaWindow window = null;
+
+ private Integer imposedTrabalhadorID = null;
+ private SaveExameListener exameListener = null;
+
+ /** Creates a new instance of FichaWindow */
+ private FichaWindow()
+ throws Exception
+ {
+ super( new UpperPanel(), new String[]{ "Empresa/Trabalhador", "Exame" },
+ createPermissions( permissions ) );
+ setEditorManagerFactory( FichaAptidaoEditorManager.getEditorManagerFactory() );
+ upperPanel = (UpperPanel) getUpperPanel();
+ upperPanel.owner = this;
+ fdpProvider = ( FichaDataProvider ) FichaDataProvider.getProvider();
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ marcacoesHandler = new MarcacoesMedicinaHandler();
+ setupComponents();
+ }
+
+ public static FichaWindow getWindow()
+ throws Exception
+ {
+ if( window == null )
+ {
+ window = new FichaWindow();
+ }
+ return window;
+ }
+
+ private void setupComponents()
+ throws Exception
+ {
+ setSize( 700, 640 );
+ setResizable( false );
+ setTitle( "Ficha de Aptid\u00e3o" );
+
+ JPanel empresaTrabalhadorPanel = getTab( 0 );
+ JPanel exameRecomendacoesPanel = getTab( 1 );
+
+ GridBagLayout gridbag = new GridBagLayout();
+ empresaTrabalhadorPanel.setLayout( gridbag );
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.insets = new Insets( 0, 1, 0, 1 );
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ constraints.gridheight = 1;
+ constraints.weighty = 0;
+
+ empresaPanel = new EmpresaPanel();
+ empresaPanel.setEnabled( false );
+ gridbag.setConstraints( empresaPanel, constraints );
+ empresaTrabalhadorPanel.add( empresaPanel );
+
+ constraints.weighty = 0;
+ trabalhadorPanel = new TrabalhadorPanel();
+ gridbag.setConstraints( trabalhadorPanel, constraints );
+ empresaTrabalhadorPanel.add( trabalhadorPanel );
+
+ constraints.weighty = 1;
+ observacoesPanel = new ObservacoesPanel();
+ gridbag.setConstraints( observacoesPanel, constraints );
+ empresaTrabalhadorPanel.add( observacoesPanel );
+
+
+ gridbag = new GridBagLayout();
+ exameRecomendacoesPanel.setLayout( gridbag );
+ constraints = new GridBagConstraints();
+ constraints.insets = new Insets( 0, 1, 0, 1 );
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ constraints.gridheight = 1;
+ constraints.weighty = 0;
+
+ constraints.weighty = 1;
+ examePanel = new ExamePanel();
+ gridbag.setConstraints( examePanel, constraints );
+ exameRecomendacoesPanel.add( examePanel );
+
+ registerAction( new ActionHandler(){
+ public void execute()
+ {
+ print();
+ }
+
+ public boolean activate( boolean newAction, boolean editAction,
+ boolean cancelAction, boolean saveAction,
+ boolean deleteAction, boolean selectAction )
+ {
+ return saveAction || editAction;
+ }
+ }, "Imprimir",
+ "Imprimir Ficha", "print",
+ 0, true );
+
+ registerAction( new ActionHandler(){
+ public void execute()
+ {
+ printOld();
+ }
+
+ public boolean activate( boolean newAction, boolean editAction,
+ boolean cancelAction, boolean saveAction,
+ boolean deleteAction, boolean selectAction )
+ {
+ return saveAction || editAction;
+ }
+ }, "Imprimir Fichas Anteriores",
+ "Imprimir Fichas Anteriores", null,
+ 0, false );
+
+ registerAction( new ActionHandler(){
+ public void execute()
+ {
+ deleteOld();
+ }
+
+ public boolean activate( boolean newAction, boolean editAction,
+ boolean cancelAction, boolean saveAction,
+ boolean deleteAction, boolean selectAction )
+ {
+ return saveAction || editAction;
+ }
+ }, "Apagar Fichas Anteriores",
+ "Apagar Fichas Anteriores", null,
+ 0, false );
+
+// registerAction( new ActionHandler(){
+// public void execute()
+// {
+// excel();
+// }
+//
+// public boolean activate( boolean newAction, boolean editAction,
+// boolean cancelAction, boolean saveAction,
+// boolean deleteAction, boolean selectAction )
+// {
+// return saveAction;
+// }
+// }, "Importar",
+// "Importar de Excel", "excel",
+// 0, true );
+ }
+
+ public boolean save( int index )
+ {
+ new ProgressDialog( this, "A gravar...",
+ new Runnable(){
+ public void run()
+ {
+
+ }
+ });
+ StringBuilder msg = new StringBuilder();
+ MedicoData medico;
+ try
+ {
+ medico = (MedicoData)upperPanel.save();
+ }
+ catch( ValuesException vex )
+ {
+ msg.append( vex.getMessage() );
+ medico = null;
+ }
+ EstabelecimentoData estabelecimento;
+ try
+ {
+ estabelecimento = (EstabelecimentoData)empresaPanel.save();
+ }
+ catch( ValuesException vex )
+ {
+ msg.append( vex.getMessage() );
+ estabelecimento = null;
+ }
+ TrabalhadorData trabalhador;
+ try
+ {
+ trabalhador = (TrabalhadorData)trabalhadorPanel.save();
+ }
+ catch( ValuesException vex )
+ {
+ msg.append( vex.getMessage() );
+ trabalhador = null;
+ }
+ ExameData exame;
+ try
+ {
+ exame = (ExameData)examePanel.save();
+ }
+ catch( ValuesException vex )
+ {
+ msg.append( vex.getMessage() );
+ exame = null;
+ }
+ if( estabelecimento == null || trabalhador == null || exame == null || medico == null )
+ {
+ JOptionPane.showMessageDialog( this, msg.toString(), "Erro...", JOptionPane.ERROR_MESSAGE );
+ return false;
+ }
+ estabelecimento.set( EstabelecimentoData.NOME_PLAIN,
+ com.evolute.utils.strings.StringPlainer.convertString( ( String )
+ estabelecimento.get( EstabelecimentoData.NOME ) ) );
+
+// trabalhador.setProperty( FichaDataProvider.R_TRABALHADOR_ESTABELECIMENTO, estabelecimento );
+// trabalhador.setProperty( FichaDataProvider.OBSERVACOES, observacoesPanel.save() );
+ trabalhador.set( TrabalhadorData.ESTABELECIMENTO, estabelecimento );
+ trabalhador.set( TrabalhadorData.OBSERVACOES, observacoesPanel.save() );
+ trabalhador.set( TrabalhadorData.NOME_PLAIN,
+ com.evolute.utils.strings.StringPlainer.convertString( ( String )
+ trabalhador.get( TrabalhadorData.NOME ) ) );
+
+
+// exame.setProperty( FichaDataProvider.R_EXAME_MEDICO, medico );
+// exame.setProperty( FichaDataProvider.R_EXAME_TRABALHADOR, trabalhador );
+ exame.set( ExameData.MEDICO, medico );
+ exame.set( ExameData.TRABALHADOR, trabalhador );
+ try
+ {
+ // lflores - disable FO for now
+ byte fo[] = null; //createFO( exame );
+
+// System.out.println( "FO sz: " + fo.length );
+ exame.set( ExameData.FO, fo );
+ exame.set( ExameData.PDF, createPDF( exame ) );
+
+// empresa.save();
+// estabelecimento.save();
+
+ exame.save();
+ trabalhador.save();
+ try
+ {
+ if( medico != null )
+ {
+ fdpProvider.setMedicoForEstabelecimento( ( Integer ) estabelecimento.get( EstabelecimentoData.ID ),
+ ( Integer ) medico.get( MedicoData.ID ) );
+ }
+ }
+ catch( Exception mex )
+ {
+ }
+// fdpProvider.savePDF( exame );
+
+// DBKey key = trabalhador.getPrimaryKeyValue();
+// DBField fields[] = FichaDataProvider.TRABALHADORES.getPrimaryKey();
+// trabalhadorID = new Integer( ((Number)key.getFieldValue( fields[ 0 ] )).intValue() );
+ trabalhadorID = ( Integer ) trabalhador.get( TrabalhadorData.ID );
+ try
+ {
+ //Marcacao.saveMarcacaoConsultaForTrabalhadorID( trabalhadorID, (Date)exame.get( ExameData.PROXIMO_EXAME ) );
+ marcacoesHandler.ajustarMarcacoes(
+ trabalhadorID, (Integer)exame.get( ExameData.TIPO ),
+ (Date)exame.get( ExameData.DATA ),
+ examePanel.getMotivoProximoExame(), (Date)exame.get( ExameData.PROXIMO_EXAME ) );
+ }
+ catch( Exception iex )
+ {
+ iex.printStackTrace();
+ }
+// createPDF( exame );
+// print();
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a guardar", true );
+ return false;
+ }
+ if( exameListener != null )
+ {
+ exameListener.exameSaved( trabalhadorID, ( Integer )exame.get( ExameData.ID ) );
+ exameListener = null;
+ }
+ return true;
+ }
+
+ public boolean newItem( int index )
+ {
+ exameListener = null;
+ if( imposedTrabalhadorID == null )
+ {
+ fdpProvider.setSearch( FichaDataProvider.SEARCH_EMPRESAS );
+ SearchDialog search;
+ Integer oldID = empresaID;
+
+ search = new SearchDialog( fdpProvider, null, false, null, true );
+ empresaID = ( Integer )search.getSelected();
+
+ if( empresaID == null )
+ {
+ if( search.getIsNew() )
+ {
+ estabelecimentoID = null;
+ trabalhadorID = null;
+ clear( 0 );
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ fdpProvider.setSearch( FichaDataProvider.SEARCH_ESTABELECIMENTOS );
+ fdpProvider.setSearchID( FichaDataProvider.SEARCH_EMPRESAS, empresaID.intValue() );
+
+ search = new SearchDialog( fdpProvider, null, false, null, true );
+ estabelecimentoID = ( Integer )search.getSelected();
+
+ if( estabelecimentoID == null )
+ {
+ if( search.getIsNew() )
+ {
+ trabalhadorID = null;
+ reload(0);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ fdpProvider.setSearch( FichaDataProvider.SEARCH_TRABALHADORES );
+ fdpProvider.setSearchID( FichaDataProvider.SEARCH_ESTABELECIMENTOS, estabelecimentoID.intValue() );
+ search = new SearchDialog( fdpProvider, null, false, null, true );
+ trabalhadorID = ( Integer )search.getSelected();
+ if( trabalhadorID == null && search.getIsNew() )
+ {
+ reload(0);
+ return true;
+ }
+ }
+ else
+ {
+ trabalhadorID = imposedTrabalhadorID;
+ imposedTrabalhadorID = null;
+ try
+ {
+ estabelecimentoID = fdpProvider.getEstabelecimentoIDForTrabalhador( trabalhadorID );
+ empresaID = fdpProvider.getEmpresaIDForEstabelecimento( estabelecimentoID );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar dados.", true );
+ return false;
+ }
+ }
+ if( trabalhadorID == null )
+ {
+ return false;
+ }
+ reload(0);
+ return true;
+ }
+
+ public boolean delete( int index )
+ {
+ return true;
+ }
+
+ public void deleteOld()
+ {
+ if( trabalhadorID == null )
+ {
+ return;
+ }
+ Vector linhas;
+ try
+ {
+ IDObject fichas[] = fdpProvider.getAllFichasForTrabalhador( trabalhadorID );
+ linhas = new Vector( Arrays.asList( fichas ) );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a criar lista de Fichas anteriores", true );
+ return;
+ }
+ ListActionDialog dialog =
+ new ListActionDialog( this, "Apagar Fichas Anteriores", new String[]{ "Data" }, linhas,
+ new ListAction(){
+ public String getListActionName()
+ {
+ return "Apagar";
+ }
+
+ public boolean executeListAction( int line, Object value )
+ {
+ if( value == null )
+ {
+ return true;
+ }
+ try
+ {
+ delete( ( ( IDObject )value ).getID() );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a Apagar Ficha", true );
+ return false;
+ }
+ return true;
+ }
+ } );
+ dialog.setSize( 250, 200 );
+ dialog.setVisible( true );
+ }
+
+ public void reload( int index )
+ {
+ Integer upperData[] = new Integer[]{ empresaID, estabelecimentoID, trabalhadorID };
+ upperPanel.fill( upperData );
+ Object empresaData[] = new Object[]{ empresaID, estabelecimentoID };
+ empresaPanel.fill( empresaData );
+ trabalhadorPanel.fill( trabalhadorID );
+ observacoesPanel.fill( trabalhadorID );
+ examePanel.fill( trabalhadorID );
+ }
+
+ public void enableComponents( int index, boolean enable )
+ {
+ upperPanel.setEnabled( enable );
+ empresaPanel.setEnabled( enable );
+ trabalhadorPanel.setEnabled( enable );
+ observacoesPanel.setEnabled( enable );
+ examePanel.setEnabled( enable );
+ }
+
+ public void clear( int index )
+ {
+ upperPanel.clear();
+ empresaPanel.clear();
+ trabalhadorPanel.clear();
+ observacoesPanel.clear();
+ examePanel.clear();
+ }
+
+ public void print()
+ {
+ try
+ {
+ if( trabalhadorID == null )
+ {
+ System.out.println( "no trab" );
+ return;
+ }
+
+ Integer id = fdpProvider.getLastExameIDForTrabalhador( trabalhadorID );
+ if( id == null )
+ {
+ System.out.println( "no id" );
+ return;
+ }
+ print( id );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "N\u00e3o foi poss\u00edvel imprimir", true );
+ }
+ }
+
+ private void print( Integer exameID )
+ throws Exception
+ {
+// MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) );
+ ExameData exame = (ExameData) JDO.load( ExameData.class, exameID );
+ if( exame == null )
+ {
+ throw new Exception( "N\u00e3o existe exame" );
+ }
+
+ // lflores - ignore FO (for now)
+ byte fo[] = null; //(byte []) exame.get( ExameData.FO );
+ byte pdf[] = (byte []) exame.get( ExameData.PDF );
+
+ if( fo != null )
+ {
+ FichaAptidaoCreator.getCreator().print( fo );
+ }
+ else
+ {
+ TrabalhadorData trabalhadorExame = ( TrabalhadorData ) exame.get( ExameData.TRABALHADOR );
+ String nomeFicheiro = StringPlainer.convertString( ( String ) trabalhadorExame.get( TrabalhadorData.NOME ) );
+ nomeFicheiro = nomeFicheiro.replaceAll( " ", "_" );
+ ePDF.print( pdf, nomeFicheiro );
+ }
+ }
+
+ public byte[] createFO( ExameData exame )
+ throws Exception
+ {
+ HashMap ht = createMapFromExame(exame);
+// ExamePDF ePDF = new ExamePDF();
+// return ePDF.createPDF( ht );
+
+ return FichaAptidaoCreator.getCreator().createFO( ht );
+ }
+
+ public byte[] createPDF( ExameData exame )
+ throws Exception
+ {
+ // byte fo[] = exame.get( ExameData.FO, fo );
+ HashMap ht = createMapFromExame( exame );
+ return ePDF.createPDF( ht );
+// return FichaAptidaoCreator.getCreator().createPDF( fo );
+ }
+
+ private HashMap createMapFromExame(final ExameData exame)
+ {
+ MedicoData medico = (MedicoData)exame.get( ExameData.MEDICO );
+ TrabalhadorData trabalhador = (TrabalhadorData) exame.get( ExameData.TRABALHADOR );
+ EstabelecimentoData estabelecimento = (EstabelecimentoData) trabalhador.get( TrabalhadorData.ESTABELECIMENTO );
+ EmpresaData empresa = (EmpresaData) estabelecimento.get( EstabelecimentoData.EMPRESA );
+// empresa.load( empresa.getPrimaryKeyValue() );
+ HashMap ht = new HashMap();
+ ht.put( DESIGNACAO_SOCIAL, ( String )empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) );
+ ht.put( ESTABELECIMENTOS_NOME, ( String )estabelecimento.get( EstabelecimentoData.NOME ) );
+ String aux = (String)estabelecimento.get( EstabelecimentoData.LOCALIDADE );
+ ht.put( ESTABELECIMENTOS_LOCALIDADE, aux != null ? aux : "" );
+ Integer tipo = (Integer)empresa.get( EmpresaData.SERVICO_SAUDE_TIPO );
+ ht.put( SERVICO_SAUDE_TIPO_INTERNO, SQUARE );
+ ht.put( SERVICO_SAUDE_TIPO_INTEREMPRESAS, SQUARE );
+ ht.put( SERVICO_SAUDE_TIPO_EXTERNO, SQUARE );
+ ht.put( SERVICO_SAUDE_TIPO_SNS, SQUARE );
+ switch( tipo.intValue() )
+ {
+ case 1:
+ ht.put( SERVICO_SAUDE_TIPO_INTERNO, CHECKED );
+ break;
+ case 2:
+ ht.put( SERVICO_SAUDE_TIPO_INTEREMPRESAS, CHECKED );
+ break;
+ case 3:
+ ht.put( SERVICO_SAUDE_TIPO_EXTERNO, CHECKED );
+ break;
+ case 4:
+ ht.put( SERVICO_SAUDE_TIPO_SNS, CHECKED );
+ break;
+ }
+ ht.put( SERVICO_SAUDE_DESIGNACAO, ( String )empresa.get( EmpresaData.SERVICO_SAUDE_DESIGNACAO ) );
+ tipo = (Integer)empresa.get( EmpresaData.SERVICO_HIGIENE_TIPO );
+ ht.put( SERVICO_HIGIENE_TIPO_INTERNO, SQUARE );
+ ht.put( SERVICO_HIGIENE_TIPO_INTEREMPRESAS, SQUARE );
+ ht.put( SERVICO_HIGIENE_TIPO_EXTERNO, SQUARE );
+ ht.put( SERVICO_HIGIENE_TIPO_OUTRO, SQUARE );
+ switch( tipo.intValue() )
+ {
+ case 1:
+ ht.put( SERVICO_HIGIENE_TIPO_INTERNO, CHECKED );
+ break;
+ case 2:
+ ht.put( SERVICO_HIGIENE_TIPO_INTEREMPRESAS, CHECKED );
+ break;
+ case 3:
+ ht.put( SERVICO_HIGIENE_TIPO_EXTERNO, CHECKED );
+ break;
+ case 4:
+ ht.put( SERVICO_HIGIENE_TIPO_OUTRO, CHECKED );
+ break;
+ }
+ ht.put( SERVICO_HIGIENE_DESIGNACAO, ( String )empresa.get( EmpresaData.SERVICO_HIGIENE_DESIGNACAO ) );
+ ht.put( TRABALHADORES_NOME, ( String )trabalhador.get( TrabalhadorData.NOME ) );
+ aux = (String)trabalhador.get( TrabalhadorData.SEXO );
+ switch( aux.charAt( 0 ) )
+ {
+ case 'm':
+ ht.put( SEXO, "Masculino" );
+ break;
+ case 'f':
+ ht.put( SEXO, "Feminino" );
+ break;
+ }
+ DateFormat df = DateFormat.getDateInstance( DateFormat.SHORT );
+ Date data = ( Date )trabalhador.get( TrabalhadorData.DATA_NASCIMENTO );
+ ht.put( DATA_NASCIMENTO, data != null ? df.format( data ) : "" );
+ aux = (String)trabalhador.get( TrabalhadorData.NACIONALIDADE );
+ ht.put( NACIONALIDADE, aux != null ? aux : "" );
+ aux = (String)trabalhador.get( TrabalhadorData.NUMERO_MECANOGRAFICO );
+ ht.put( NUMERO_MECANOGRAFICO, aux != null ? aux : "" );
+ data = ( Date )trabalhador.get( TrabalhadorData.DATA_ADMISSAO );
+ ht.put( DATA_ADMISSAO, data != null ? df.format( data ) : "" );
+ aux = (String)trabalhador.get( TrabalhadorData.CATEGORIA );
+ ht.put( CATEGORIA, aux != null ? aux : "" );
+ aux = (String)trabalhador.get( TrabalhadorData.LOCAL_TRABALHO );
+ ht.put( LOCAL_TRABALHO, aux != null ? aux : "" );
+ aux = (String)trabalhador.get( TrabalhadorData.FUNCAO_PROPOSTA );
+ ht.put( FUNCAO_PROPOSTA, aux != null ? aux : "" );
+ data = ( Date )trabalhador.get( TrabalhadorData.DATA_ADMISSAO_FUNCAO );
+ ht.put( DATA_ADMISSAO_FUNCAO, data != null ? df.format( data ) : "" );
+ aux = (String)trabalhador.get( TrabalhadorData.OBSERVACOES );
+ ht.put( OBSERVACOES, aux != null ? aux : "" );
+ data = ( Date )exame.get( ExameData.DATA );
+ ht.put( EXAMES_DATA, data != null ? df.format( data ) : "" );
+ tipo = (Integer)exame.get( ExameData.TIPO );
+ ht.put( TIPO_ADMISSAO, SQUARE );
+ ht.put( TIPO_PERIODICO, SQUARE );
+ ht.put( TIPO_OCASIONAL, SQUARE );
+
+ ht.put( TIPO_APOS_DOENCA, SQUARE );
+ ht.put( TIPO_APOS_ACIDENTE, SQUARE );
+ ht.put( TIPO_PEDIDO_TRABALHADOR, SQUARE );
+ ht.put( TIPO_PEDIDO_EMPRESA, SQUARE );
+ ht.put( TIPO_MUDANCA_FUNCAO, SQUARE );
+ ht.put( TIPO_TRABALHO, SQUARE );
+ ht.put( TIPO_OUTRO, SQUARE );
+
+ switch( tipo.intValue() )
+ {
+ case 1:
+ ht.put( TIPO_ADMISSAO, CHECKED );
+ break;
+ case 2:
+ ht.put( TIPO_PERIODICO, CHECKED );
+ break;
+ case 3:
+ ht.put( TIPO_OCASIONAL, CHECKED );
+ tipo = (Integer)exame.get( ExameData.OCASIONAL );
+
+ switch( tipo.intValue() )
+ {
+ case 1:
+ ht.put( TIPO_APOS_DOENCA, CHECKED );
+ break;
+ case 2:
+ ht.put( TIPO_APOS_ACIDENTE, CHECKED );
+ break;
+ case 3:
+ ht.put( TIPO_PEDIDO_TRABALHADOR, CHECKED );
+ break;
+ case 4:
+ ht.put( TIPO_PEDIDO_EMPRESA, CHECKED );
+ break;
+ case 5:
+ ht.put( TIPO_MUDANCA_FUNCAO, CHECKED );
+ break;
+ case 6:
+ ht.put( TIPO_TRABALHO, CHECKED );
+ break;
+ case 10:
+ ht.put( TIPO_OUTRO, CHECKED );
+ break;
+ }
+ break;
+// case 4:
+// aux = (String)exame.get( ExameData.OUTRO_TIPO );
+// ht.put( "tipo_outro", aux != null ? aux : "" );
+// break;
+ }
+ aux = (String)exame.get( ExameData.OUTRO_TIPO );
+ ht.put( TIPO_OUTRO_TEXTO, aux != null ? aux : "" );
+ tipo = (Integer)exame.get( ExameData.RESULTADO );
+ ht.put( RESULTADO_APTO, SQUARE );
+ ht.put( RESULTADO_APTO_CONDICIONALMENTE, SQUARE );
+ ht.put( RESULTADO_INAPTO_TEMP, SQUARE );
+ ht.put( RESULTADO_INAPTO_DEF, SQUARE );
+ switch( tipo.intValue() )
+ {
+ case 1:
+ ht.put( RESULTADO_APTO, CHECKED );
+ break;
+ case 2:
+ ht.put( RESULTADO_APTO_CONDICIONALMENTE, CHECKED );
+ break;
+ case 3:
+ ht.put( RESULTADO_INAPTO_TEMP, CHECKED );
+ break;
+ case 4:
+ ht.put( RESULTADO_INAPTO_DEF, CHECKED );
+ break;
+ }
+ aux = (String)exame.get( ExameData.OUTRA_FUNCAO_1 );
+ ht.put( OUTRA_FUNCAO_1, aux != null ? aux : "" );
+ aux = (String)exame.get( ExameData.OUTRA_FUNCAO_2 );
+ ht.put( OUTRA_FUNCAO_2, aux != null ? aux : "" );
+ aux = (String)exame.get( ExameData.OUTRA_FUNCAO_3 );
+ ht.put( OUTRA_FUNCAO_3, aux != null ? aux : "" );
+ aux = (String)exame.get( ExameData.OUTRA_FUNCAO_4 );
+ ht.put( OUTRA_FUNCAO_4, aux != null ? aux : "" );
+ aux = (String)exame.get( ExameData.OUTRAS_RECOMENDACOES );
+ ht.put( OUTRAS_RECOMENDACOES, aux != null ? aux : "" );
+ data = ( Date )exame.get( ExameData.PROXIMO_EXAME );
+ ht.put( PROXIMO_EXAME, data != null ? df.format( data ) : "n/d" );
+ aux = (String)medico.get( MedicoData.NOME );
+ ht.put( MEDICOS_NOME, aux != null ? aux : "" );
+ aux = (String)medico.get( MedicoData.NUMERO_CEDULA );
+ ht.put( NUMERO_CEDULA, aux != null ? aux : "" );
+ return ht;
+ }
+
+ private void excel()
+ {
+ FileDialog fd = new FileDialog( this, "Escolha um ficheiro Excel:", FileDialog.LOAD );
+ fd.setDirectory( System.getProperty( "user.home" ) );
+ fd.setFilenameFilter( new FilenameFilter() {
+ public boolean accept( File dir, String name )
+ {
+ return (name!=null) && (name.indexOf( ".xls" ) != -1);
+ }
+ } );
+ fd.setVisible( true );
+ //String filename = "c:\\test.xls";
+ String filename = fd.getFile();
+ if( filename != null )
+ {
+ filename = fd.getDirectory() + File.separator + filename;
+ try
+ {
+ Importer importer = new Importer( this, filename, false, Importer.TYPE_ADMISSAO );
+ Hashtable hash = importer.getData();
+ if( hash != null )
+ {
+ trabalhadorPanel.setData( hash );
+ }
+ }
+ catch( Exception ex )
+ {
+ ex.printStackTrace();
+ JOptionPane.showMessageDialog( this, "Erro a importar", "Erro...", JOptionPane.ERROR_MESSAGE );
+ }
+ }
+
+ }
+
+ private void printOld()
+ {
+ if( trabalhadorID != null )
+ {
+ Vector linhas;
+ try
+ {
+ IDObject fichas[] = fdpProvider.getAllFichasForTrabalhador( trabalhadorID );
+ linhas = new Vector( Arrays.asList( fichas ) );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a criar lista de Fichas anteriores", true );
+ return;
+ }
+ ListActionDialog dialog = new ListActionDialog( this, "Imprimir Fichas Anteriores", new String[]{ "Data" },
+ linhas, this );
+ dialog.setSize( 250, 200 );
+ dialog.setVisible( true );
+ }
+ }
+
+ public boolean executeListAction( int line, Object value )
+ {
+ if( value != null )
+ {
+ try
+ {
+ print( ( ( IDObject )value ).getID() );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a imprimir Ficha", true );
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public String getListActionName()
+ {
+ return "Imprimir";
+ }
+
+ private void delete( Integer exameID )
+ throws Exception
+ {
+// MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) );
+ ExameData exame = (ExameData) JDO.load( ExameData.class, exameID );
+ if( exame == null )
+ {
+ throw new Exception( "N\u00e3o existe exame" );
+ }
+ if( JOptionPane.showConfirmDialog( this,
+ "Tem a certeza que quer apagar o exame de " + exame.get( ExameData.DATA ) + "?",
+ "...", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null ) == 0 )
+ {
+// exame.set( ExameData.INACTIVO, "y" );
+// exame.save();
+ exame.delete();
+ }
+ }
+
+ public void editTrabalhador( Integer trabalhadorID, SaveExameListener listener )
+ {
+System.out.println( "edit trabalhador: " + trabalhadorID );
+
+ if( isVisible() )
+ {
+ toFront();
+ }
+ else
+ {
+ setVisible( true );
+ }
+ imposedTrabalhadorID = trabalhadorID;
+ executeAction( NEW_INDEX );
+ exameListener = listener;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/MedicoColumnizedObject.java b/trunk/SIPRPSoft/src/siprp/ficha/MedicoColumnizedObject.java
new file mode 100644
index 00000000..4253604d
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/MedicoColumnizedObject.java
@@ -0,0 +1,46 @@
+/*
+ * MedicoColumnizedObject.java
+ *
+ * Created on 12 de Abril de 2004, 11:53
+ */
+
+package siprp.ficha;
+
+import com.evolute.utils.tables.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class MedicoColumnizedObject implements ColumnizedObject
+{
+ private Integer id;
+ private String nome;
+ private String numero;
+
+ /** Creates a new instance of MedicoColumnizedObject */
+ public MedicoColumnizedObject( Integer id, String nome, String numero )
+ {
+ this.id = id;
+ this.nome = nome;
+ this.numero = numero;
+ }
+
+ public Object getValue( int col )
+ {
+ switch( col )
+ {
+ case 0:
+ return nome;
+
+ case 1:
+ return numero;
+ }
+ return null;
+ }
+
+ public Integer getID()
+ {
+ return id;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/MedicoEditor.java b/trunk/SIPRPSoft/src/siprp/ficha/MedicoEditor.java
new file mode 100644
index 00000000..a6268c29
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/MedicoEditor.java
@@ -0,0 +1,270 @@
+/*
+ * MedicoEditor.java
+ *
+ * Created on 10 de Abril de 2004, 20:50
+ */
+
+package siprp.ficha;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.jdo.*;
+import com.evolute.utils.metadb.*;
+import com.evolute.utils.tables.*;
+import com.evolute.utils.ui.*;
+import com.evolute.utils.ui.text.*;
+
+import siprp.*;
+import siprp.data.*;
+
+/**
+ *
+ * @author Administrator
+ */
+public class MedicoEditor extends CustomJDialog
+ implements ActionListener, ListSelectionListener
+{
+ static
+ {
+ MedicoData.registerOperationHandlerForClass( DisableDeleteHandler.INSTANCE, MedicoData.class );
+ }
+ private JDOProvider JDO;
+ private FichaDataProvider provider;
+ private BaseTable table;
+ private VectorTableModel model;
+ private JButton okButton;
+ private JButton cancelarButton;
+ private JButton novoButton;
+ private JTextField nomeText;
+ private JTextField numeroText;
+ private Integer id;
+ private boolean isNew = false;
+
+ /** Creates a new instance of MedicoEditor */
+ public MedicoEditor( JFrame owner )
+ throws Exception
+ {
+ super( owner, true );
+ provider = (FichaDataProvider)FichaDataProvider.getProvider();
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ setupComponents();
+ }
+
+ private void setupComponents()
+ throws Exception
+ {
+ setSize( 600, 300 );
+ setResizable( false );
+ setTitle( "Criar/Editar M\u00e9dico" );
+ centerSuper();
+
+ model = new VectorTableModel( new String[]{ "Nome", "NC" } );
+ table = new BaseTable( model );
+ table.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ JScrollPane scp = new JScrollPane();
+ scp.setMinimumSize( new Dimension( 300, 200 ) );
+ scp.setMaximumSize( new Dimension( 300, 200 ) );
+ scp.setPreferredSize( new Dimension( 300, 200 ) );
+ scp.setSize( new Dimension( 300, 200 ) );
+ scp.setViewportView( table );
+ scp.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ scp.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
+ table.fixColumnWidth( 0, 200 );
+ table.setNonResizableNorReordable();
+ table.getSelectionModel().addListSelectionListener( this );
+ Object obj[][] = provider.getAllMedicos();
+ Vector medicos = new Vector();
+ for( int n = 0; n < obj.length; n++ )
+ {
+ medicos.add( new MedicoColumnizedObject( (Integer)obj[n][0],
+ (String)obj[n][1],
+ (String)obj[n][2] ) );
+ }
+ model.setValues( medicos );
+
+ okButton = new JButton( "OK" );
+ cancelarButton = new JButton( "Cancelar" );
+ novoButton = new JButton( "Novo" );
+ okButton.addActionListener( this );
+ cancelarButton.addActionListener( this );
+ novoButton.addActionListener( this );
+
+ nomeText = new JTextField();
+ nomeText.setEnabled( false );
+ numeroText = new JTextField();
+ numeroText.setEnabled( false );
+
+ GridBagLayout gridbag = new GridBagLayout();
+ getContentPane().setLayout( gridbag );
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.insets = new Insets( 1, 1, 1, 1 );
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.weighty = 1;
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ constraints.gridheight = 1;
+
+ JPanel upperPanel = new JPanel();
+ upperPanel.setLayout( new GridLayout( 1, 2 ) );
+ upperPanel.add( scp );
+ JPanel textPanel = new JPanel();
+ upperPanel.add( textPanel );
+ gridbag.setConstraints( upperPanel, constraints );
+ getContentPane().add( upperPanel );
+
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ constraints.weighty = 0;
+ constraints.weightx = 0.3;
+ constraints.gridwidth = 1;
+ constraints.gridheight = GridBagConstraints.REMAINDER;;
+
+ gridbag.setConstraints( novoButton, constraints );
+ getContentPane().add( novoButton );
+
+ gridbag.setConstraints( okButton, constraints );
+ getContentPane().add( okButton );
+
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( cancelarButton, constraints );
+ getContentPane().add( cancelarButton );
+
+ gridbag = new GridBagLayout();
+ textPanel.setLayout( gridbag );
+ constraints.weighty = 0;
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ constraints.gridheight = 1;
+
+ JLabel nomeLabel = new JLabel( "Nome" );
+ gridbag.setConstraints( nomeLabel, constraints );
+ textPanel.add( nomeLabel );
+
+ gridbag.setConstraints( nomeText, constraints );
+ textPanel.add( nomeText );
+
+ JLabel numeroLabel = new JLabel( "N\u00famero" );
+ gridbag.setConstraints( numeroLabel, constraints );
+ textPanel.add( numeroLabel );
+
+ gridbag.setConstraints( numeroText, constraints );
+ textPanel.add( numeroText );
+
+ constraints.weighty = 1;
+ constraints.gridheight = GridBagConstraints.REMAINDER;;
+ JPanel pad = new JPanel();
+ gridbag.setConstraints( pad, constraints );
+ textPanel.add( pad );
+
+ new CopyPasteHandler( nomeText );
+ new CopyPasteHandler( numeroText );
+ }
+
+ public void actionPerformed( ActionEvent e )
+ {
+ if( e.getSource().equals( okButton ) )
+ {
+ if( save() )
+ {
+ close();
+ }
+ }
+ else if( e.getSource().equals( cancelarButton ) )
+ {
+ close();
+ }
+ if( e.getSource().equals( novoButton ) )
+ {
+ table.getSelectionModel().removeListSelectionListener( this );
+ nomeText.setText( "" );
+ numeroText.setText( "" );
+ nomeText.setEnabled( true );
+ numeroText.setEnabled( true );
+ id = null;
+ isNew = true;
+ }
+ }
+
+ public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent)
+ {
+ int selected = table.getSelectedRow();
+ if( selected == -1 )
+ {
+ return;
+ }
+ MedicoColumnizedObject row = (MedicoColumnizedObject)model.getRowAt( selected );
+ id = row.getID();
+ String nome = (String) row.getValue( 0 );
+ String numero = (String) row.getValue( 1 );
+ nomeText.setText( nome );
+ numeroText.setText( numero );
+ nomeText.setEnabled( true );
+ numeroText.setEnabled( true );
+ }
+
+ private void close()
+ {
+ setVisible( false );
+ dispose();
+ }
+
+ public boolean getIsNew()
+ {
+ return isNew;
+ }
+
+ public Integer getID()
+ {
+ return id;
+ }
+
+ private boolean save()
+ {
+ String nome = nomeText.getText().trim();
+ String numero = numeroText.getText().trim();
+ if( nome.length() == 0 )
+ {
+ JOptionPane.showMessageDialog( this, "O Nome n\u00e3o pode ser vazio.", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ return false;
+ }
+ try
+ {
+ MedicoData medico;
+ if( id != null )
+ {
+ medico = ( MedicoData ) JDO.load( MedicoData.class, id );
+// medico = provider.load( provider.MEDICOS, new DBKey( id ) );
+ }
+ else
+ {
+ medico = new MedicoData();
+// medico = provider.createObject( provider.MEDICOS );
+ }
+// medico.setProperty( provider.NOME, nome );
+// medico.setProperty( provider.NUMERO_CEDULA, numero );
+ medico.set( MedicoData.NOME, nome );
+ medico.set( MedicoData.NUMERO_CEDULA, numero );
+ medico.save();
+ if( id == null )
+ {
+// DBKey key = medico.getPrimaryKeyValue();
+// DBField fields[] = provider.MEDICOS.getPrimaryKey();
+// id = new Integer( ((Number)key.getFieldValue( fields[ 0 ] )).intValue() );
+ id = (Integer)medico.get( MedicoData.ID );
+ }
+ }
+ catch( Exception ex )
+ {
+// JOptionPane.showMessageDialog( this, "Erro a gravar...", "Erro...",
+// JOptionPane.ERROR_MESSAGE );
+ DialogException.showExceptionMessage( ex, "Erro a gravar...", false );
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/ObservacoesPanel.java b/trunk/SIPRPSoft/src/siprp/ficha/ObservacoesPanel.java
new file mode 100644
index 00000000..68edd548
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/ObservacoesPanel.java
@@ -0,0 +1,101 @@
+/*
+ * ObservacoesPanel.java
+ *
+ * Created on 29 de Marco de 2004, 11:56
+ */
+
+package siprp.ficha;
+
+import java.awt.*;
+import javax.swing.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.dataui.*;
+import com.evolute.utils.documents.*;
+import com.evolute.utils.jdo.*;
+import com.evolute.utils.metadb.*;
+import com.evolute.utils.ui.text.*;
+
+import siprp.*;
+import siprp.data.*;
+/**
+ *
+ * @author fpalma
+ */
+public class ObservacoesPanel extends JPanel
+ implements ControllableComponent
+{
+ private JDOProvider JDO;
+
+ private JTextField observacoesText;
+
+ private FichaDataProvider provider;
+
+ /** Creates a new instance of ObservacoesPanel */
+ public ObservacoesPanel()
+ throws Exception
+ {
+ provider = (FichaDataProvider)FichaDataProvider.getProvider();
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ setupComponents();
+ }
+
+ private void setupComponents()
+ {
+ setBorder( BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(),
+ "Observa\u00e7\u00f5es" ) );
+
+// JScrollPane scp = new JScrollPane();
+// scp.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+// scp.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
+ observacoesText = new JTextField();
+ observacoesText.setDocument( new MaximumLengthDocument( 150 ) );
+// observacoesText.setLineWrap( true );
+// observacoesText.setWrapStyleWord( true );
+// scp.setViewportView( observacoesText );
+
+ setLayout( new GridLayout( 1, 1, 0, 0 ) );
+ add( observacoesText );
+
+ new CopyPasteHandler( observacoesText );
+ }
+
+ public void fill(Object value)
+ {
+ clear();
+ Integer trabalhadorID = (Integer)value;
+ if( trabalhadorID != null )
+ {
+
+ try
+ {
+ TrabalhadorData trabalhador = (TrabalhadorData)JDO.load( TrabalhadorData.class, trabalhadorID );
+ String observacoes = (String) trabalhador.get( TrabalhadorData.OBSERVACOES );
+ if( observacoes != null )
+ {
+ observacoesText.setText( observacoes );
+ }
+ }
+ catch( Exception ex )
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ public Object save()
+ {
+ return observacoesText.getText();
+ }
+
+ public void clear()
+ {
+ observacoesText.setText( "" );
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ observacoesText.setEnabled( enable );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/RecomendacoesPanel.java b/trunk/SIPRPSoft/src/siprp/ficha/RecomendacoesPanel.java
new file mode 100644
index 00000000..7d74be41
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/RecomendacoesPanel.java
@@ -0,0 +1,59 @@
+/*
+ * RecomendacoesPanel.java
+ *
+ * Created on 29 de Marco de 2004, 11:58
+ */
+
+package siprp.ficha;
+
+import java.awt.*;
+import javax.swing.*;
+
+import com.evolute.utils.documents.*;
+import com.evolute.utils.ui.*;
+import com.evolute.utils.ui.calendar.*;
+import com.evolute.utils.ui.text.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class RecomendacoesPanel extends JPanel
+{
+ private JTextArea recomendacoesText;
+ private JCalendarPanel proximoExamePanel;
+ /** Creates a new instance of RecomendacoesPanel */
+ public RecomendacoesPanel()
+ {
+ setupComponents();
+ }
+
+ private void setupComponents()
+ {
+ setBorder( BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(),
+ "Outras Recomenda\u00e7\u00f5es" ) );
+
+ JScrollPane scp = new JScrollPane();
+ scp.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ scp.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
+ recomendacoesText = new JTextArea();
+ recomendacoesText.setLineWrap( true );
+ recomendacoesText.setWrapStyleWord( true );
+ recomendacoesText.setDocument( new MaximumLengthDocument( 150 ) );
+ scp.setViewportView( recomendacoesText );
+ JPanel rightPanel = new JPanel();
+ JLabel proximoExameLabel = new JLabel( "Pr\u00f3ximo Exame" );
+ proximoExamePanel = new JCalendarPanel( null );
+
+ setLayout( new GridLayout( 1, 2, 0, 0 ) );
+ add( scp );
+ add( rightPanel );
+
+ rightPanel.setLayout( new BorderLayout() );
+ rightPanel.add( proximoExameLabel, BorderLayout.WEST );
+ rightPanel.add( proximoExamePanel, BorderLayout.CENTER );
+
+ new CopyPasteHandler( recomendacoesText );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/SaveExameListener.java b/trunk/SIPRPSoft/src/siprp/ficha/SaveExameListener.java
new file mode 100644
index 00000000..ccb16da8
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/SaveExameListener.java
@@ -0,0 +1,19 @@
+/*
+ * SaveExameListener.java
+ *
+ * Created on May 17, 2007, 12:33 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.ficha;
+
+/**
+ *
+ * @author lflores
+ */
+public interface SaveExameListener
+{
+ public void exameSaved( Integer trabalhadorID, Integer exameID );
+}
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/TrabalhadorPanel.java b/trunk/SIPRPSoft/src/siprp/ficha/TrabalhadorPanel.java
new file mode 100644
index 00000000..c44cbc9d
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/TrabalhadorPanel.java
@@ -0,0 +1,477 @@
+/*
+ * TrabalhadorPanel.java
+ *
+ * Created on 29 de Marco de 2004, 11:55
+ */
+
+package siprp.ficha;
+
+import java.awt.*;
+import javax.swing.*;
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.data.*;
+import com.evolute.utils.dataui.*;
+import com.evolute.utils.date.*;
+import com.evolute.utils.jdo.*;
+import com.evolute.utils.metadb.*;
+import com.evolute.utils.ui.*;
+import com.evolute.utils.ui.calendar.*;
+import com.evolute.utils.ui.panel.*;
+import com.evolute.utils.ui.text.*;
+
+import siprp.*;
+import siprp.data.*;
+import siprp.importer.*;
+/**
+ *
+ * @author fpalma
+ */
+public class TrabalhadorPanel extends JPanel
+ implements ControllableComponent
+{
+ private JDOProvider JDO;
+ private JTextField nomeText;
+ private RadioButtonFixedPanel sexoPanel;
+ private JCalendarPanel dataNascimentoPanel;
+ private JTextField nacionalidadeText;
+ private JTextField numeroMecanograficoText;
+ private JCalendarPanel dataAdmissaoPanel;
+ private JTextField categoriaText;
+ private JTextField localText;
+ private JTextField funcaoText;
+ private JCalendarPanel dataAdmissaoFuncaoPanel;
+
+ private ComponentsHashtable components;
+ private FichaDataProvider provider;
+ private TrabalhadorData trabalhador;
+
+ /** Creates a new instance of TrabalhadorPanel */
+
+ public TrabalhadorPanel()
+ throws Exception
+ {
+ provider = (FichaDataProvider)FichaDataProvider.getProvider();
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ setupComponents();
+ setupComponentsHashtable();
+ }
+
+
+ private void setupComponents()
+ {
+ setBorder( BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(),
+ "Trabalhador" ) );
+ JLabel nomeLabel = new JLabel( "Nome" );
+ nomeText = new JTextField();
+ JLabel sexoLabel = new JLabel( "Sexo" );
+ sexoPanel =
+ new RadioButtonFixedPanel(
+ new IDObject[]{ new MappableObject( new Integer( 1 ), "M" ),
+ new MappableObject( new Integer( 2 ), "F" ) },
+ 1, 2, RadioButtonPanel.ORIENTATION_HORIZONTAL, false );
+ JLabel dataNascimentoLabel = new JLabel( "Data de Nascimento" );
+ dataNascimentoPanel = new JCalendarPanel( null );
+ JLabel nacionalidadeLabel = new JLabel( "Nacionalidade" );
+ nacionalidadeText = new JTextField();
+ JLabel numeroMecanograficoLabel = new JLabel( "N\u00famero Mecanogr\u00e1fico/outro" );
+ numeroMecanograficoText = new JTextField();
+ JLabel dataAdmissaoLabel = new JLabel( "Data de Admiss\u00e3o" );
+ dataAdmissaoPanel = new JCalendarPanel( null );
+ JLabel categoriaLabel = new JLabel( "Categoria Profissional" );
+ categoriaText = new JTextField();
+ JLabel localLabel = new JLabel( "Local de Trabalho" );
+ localText = new JTextField();
+ JLabel funcaoLabel = new JLabel( "Fun\u00e7\u00e3o proposta" );
+ funcaoText = new JTextField();
+ JLabel dataAdmissaoFuncaoLabel = new JLabel( "Data de Admiss\u00e3o na Fun\u00e7\u00e3o" );
+ dataAdmissaoFuncaoPanel = new JCalendarPanel( null );
+
+ GridBagLayout gridbag = new GridBagLayout();
+ setLayout( gridbag );
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.insets = new Insets( 0, 1, 0, 1 );
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ constraints.weighty = 0;
+ constraints.gridheight = 1;
+ constraints.gridwidth = 1;
+ constraints.weightx = 0;
+
+ gridbag.setConstraints( nomeLabel, constraints );
+ add( nomeLabel );
+
+ constraints.weightx = 1;
+ constraints.gridwidth = 3;
+ gridbag.setConstraints( nomeText, constraints );
+ add( nomeText );
+
+ constraints.gridwidth = 1;
+ constraints.weightx = 0;
+ gridbag.setConstraints( sexoLabel, constraints );
+ add( sexoLabel );
+
+ constraints.weightx = 0;
+ //constraints.gridwidth = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( sexoPanel, constraints );
+ add( sexoPanel );
+
+ constraints.weightx = 0;
+ constraints.gridwidth = 2;
+ gridbag.setConstraints( nacionalidadeLabel, constraints );
+ add( nacionalidadeLabel );
+
+ constraints.weightx = 0.5;
+ constraints.gridwidth = 1;
+ gridbag.setConstraints( nacionalidadeText, constraints );
+ add( nacionalidadeText );
+
+ constraints.weightx = 0;
+ constraints.gridwidth = 1;
+ gridbag.setConstraints( dataNascimentoLabel, constraints );
+ add( dataNascimentoLabel );
+
+ constraints.weightx = 0.5;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( dataNascimentoPanel, constraints );
+ add( dataNascimentoPanel );
+
+ constraints.weightx = 0;
+ constraints.gridwidth = 2;
+ gridbag.setConstraints( numeroMecanograficoLabel, constraints );
+ add( numeroMecanograficoLabel );
+
+ constraints.weightx = 0.5;
+ constraints.gridwidth = 1;
+ gridbag.setConstraints( numeroMecanograficoText, constraints );
+ add( numeroMecanograficoText );
+
+ constraints.weightx = 0;
+ constraints.gridwidth = 1;
+ gridbag.setConstraints( dataAdmissaoLabel, constraints );
+ add( dataAdmissaoLabel );
+
+ constraints.weightx = 0.5;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( dataAdmissaoPanel, constraints );
+ add( dataAdmissaoPanel );
+
+ constraints.weightx = 0;
+ constraints.gridwidth = 2;
+ gridbag.setConstraints( categoriaLabel, constraints );
+ add( categoriaLabel );
+
+ constraints.weightx = 0.5;
+ constraints.gridwidth = 1;
+ gridbag.setConstraints( categoriaText, constraints );
+ add( categoriaText );
+
+ constraints.weightx = 0;
+ gridbag.setConstraints( localLabel, constraints );
+ add( localLabel );
+
+ constraints.weightx = 0.5;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( localText, constraints );
+ add( localText );
+
+ constraints.weightx = 0;
+ constraints.gridwidth = 2;
+ gridbag.setConstraints( funcaoLabel, constraints );
+ add( funcaoLabel );
+
+ constraints.weightx = 0.5;
+ constraints.gridwidth = 1;
+ gridbag.setConstraints( funcaoText, constraints );
+ add( funcaoText );
+
+ constraints.weightx = 0;
+ constraints.gridwidth = 1;
+ gridbag.setConstraints( dataAdmissaoFuncaoLabel, constraints );
+ add( dataAdmissaoFuncaoLabel );
+
+ constraints.weightx = 0.5;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( dataAdmissaoFuncaoPanel, constraints );
+ add( dataAdmissaoFuncaoPanel );
+
+ new CopyPasteHandler( nomeText );
+ new CopyPasteHandler( nacionalidadeText );
+ new CopyPasteHandler( numeroMecanograficoText );
+ new CopyPasteHandler( categoriaText );
+ new CopyPasteHandler( localText );
+ new CopyPasteHandler( funcaoText );
+ }
+
+ private void setupComponentsHashtable()
+ {
+ components = new ComponentsHashtable();
+ components.putComponent( TrabalhadorData.NOME, nomeText );
+ components.putComponent( TrabalhadorData.SEXO, new ControllableComponent()
+ {
+ public void fill( Object value )
+ {
+ if( value != null && value.equals( "f" ) )
+ {
+ sexoPanel.fill( new Integer(2) );
+ }
+ else
+ {
+ sexoPanel.fill( new Integer(1) );
+ }
+ }
+
+ public Object save()
+ {
+ Integer id = (Integer)sexoPanel.save();
+ if( id != null && id.intValue() == 1 )
+ {
+ return "m";
+ }
+ return "f";
+ }
+
+ public void clear()
+ {
+ sexoPanel.clear();
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ sexoPanel.setEnabled( enable );
+ }
+ } );
+ components.putComponent( TrabalhadorData.DATA_NASCIMENTO, dataNascimentoPanel );
+ components.putComponent( TrabalhadorData.NACIONALIDADE, nacionalidadeText );
+ components.putComponent( TrabalhadorData.NUMERO_MECANOGRAFICO, numeroMecanograficoText );
+ components.putComponent( TrabalhadorData.DATA_ADMISSAO, dataAdmissaoPanel );
+ components.putComponent( TrabalhadorData.CATEGORIA, categoriaText );
+ components.putComponent( TrabalhadorData.LOCAL_TRABALHO, localText );
+ components.putComponent( TrabalhadorData.FUNCAO_PROPOSTA, funcaoText );
+ components.putComponent( TrabalhadorData.DATA_ADMISSAO_FUNCAO, dataAdmissaoFuncaoPanel );
+ components.putDummy( TrabalhadorData.DATA_DEMISSAO );
+ components.putDummy( TrabalhadorData.OBSERVACOES );
+ components.putDummy( TrabalhadorData.OBSERVACOES_GESTAO );
+ components.putDummy( TrabalhadorData.PERFIL );
+ components.putDummy( TrabalhadorData.ESTABELECIMENTO );
+ components.putDummy( TrabalhadorData.NOME_PLAIN );
+
+// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.NOME, nomeText );
+// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.DATA_NASCIMENTO, dataNascimentoPanel );
+// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.NACIONALIDADE, nacionalidadeText );
+// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.NUMERO_MECANOGRAFICO, numeroMecanograficoText );
+// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.DATA_ADMISSAO, dataAdmissaoPanel );
+// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.CATEGORIA, categoriaText );
+// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.LOCAL_TRABALHO, localText );
+// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.FUNCAO_PROPOSTA, funcaoText );
+// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.DATA_ADMISSAO_FUNCAO, dataAdmissaoFuncaoPanel );
+// components.putDummy( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.ESTABELECIMENTO_ID );
+// components.putDummy( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.OBSERVACOES );
+// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.SEXO,
+// new ControllableComponent()
+// {
+// public void fill( Object value )
+// {
+// if( value != null && value.equals( "f" ) )
+// {
+// sexoPanel.fill( new Integer(2) );
+// }
+// else
+// {
+// sexoPanel.fill( new Integer(1) );
+// }
+// }
+//
+// public Object save()
+// {
+// Integer id = (Integer)sexoPanel.save();
+// if( id != null && id.intValue() == 1 )
+// {
+// return "m";
+// }
+// return "f";
+// }
+//
+// public void clear()
+// {
+// sexoPanel.clear();
+// }
+//
+// public void setEnabled( boolean enable )
+// {
+// sexoPanel.setEnabled( enable );
+// }
+// } );
+ }
+
+ public void fill(Object value)
+ {
+ clear();
+ trabalhador = null;
+ if( value != null )
+ {
+ Integer trabalhadorID = (Integer)value;
+ if( trabalhadorID != null )
+ {
+ try
+ {
+ trabalhador = ( TrabalhadorData ) JDO.load( TrabalhadorData.class, trabalhadorID );
+ String names[] = trabalhador.getFieldNames();
+ ComponentController.fill( names, trabalhador.getHashData(), components );
+// trabalhador = provider.load( FichaDataProvider.TRABALHADORES, new DBKey( trabalhadorID ) );
+// DBField fields[] = FichaDataProvider.TRABALHADORES.getInsertFields();
+// String trabalhadorFields[] = new String[ fields.length ];
+// Hashtable data = new Hashtable();
+// for( int i = 0; i < trabalhadorFields.length; ++i )
+// {
+// trabalhadorFields[ i ] = fields[ i ].FULL_NAME;
+// Object fieldValue = trabalhador.getProperty( trabalhadorFields[ i ] );
+// if( fieldValue != null )
+// {
+// data.put( trabalhadorFields[ i ], fieldValue );
+// }
+// }
+// ComponentController.fill( trabalhadorFields, data, components );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar os dados do trabalhador", true );
+ }
+ }
+ }
+
+ }
+
+ public Object save()
+ {
+ StringBuffer msg = new StringBuffer();
+ boolean hasMsg = false;
+ try
+ {
+ if( trabalhador == null )
+ {
+// trabalhador = provider.createObject( FichaDataProvider.TRABALHADORES );
+ trabalhador = new TrabalhadorData();
+ trabalhador.set( TrabalhadorData.PERFIL, new Integer( 1 ) );
+ }
+// DBField fields[] = FichaDataProvider.TRABALHADORES.getInsertFields();
+// String trabalhadorFields[] = new String[ fields.length ];
+// for( int i = 0; i < trabalhadorFields.length; ++i )
+// {
+// trabalhadorFields[ i ] = fields[ i ].FULL_NAME;
+// }
+// Hashtable hash = new Hashtable();
+// ComponentController.save( trabalhadorFields, hash, components );
+// Enumeration enum = hash.keys();
+// while( enum.hasMoreElements() )
+// {
+// String name = ( String )enum.nextElement();
+// trabalhador.setProperty( name, hash.get( name ) );
+// }
+ String names[] = trabalhador.getFieldNames();
+ Hashtable hash = trabalhador.getHashData();
+ ComponentController.save( names, hash, components );
+ trabalhador.setHashData( hash );
+// if( ((String)trabalhador.getProperty( FichaDataProvider.NOME )).trim().length() == 0 )
+ if( ((String)trabalhador.get( TrabalhadorData.NOME )).trim().length() == 0 )
+ {
+ msg.append( "O trabalhador tem de ter nome\n" );
+ hasMsg = true;
+ }
+// if( trabalhador.getProperty( FichaDataProvider.SEXO ) == null )
+ if( trabalhador.get( TrabalhadorData.SEXO ) == null )
+ {
+ msg.append( "O trabalhador tem de ter um sexo definido\n" );
+ hasMsg = true;
+ }
+ }
+ catch( Exception ex )
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ if( hasMsg )
+ {
+ throw new ValuesException( msg.toString() );
+ }
+ return trabalhador;
+ }
+
+ public void clear()
+ {
+ String names[] = (String[])components.keySet().toArray( new String[0] );
+ ComponentController.clear( names, components );
+ trabalhador = null;
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ String names[] = (String[])components.keySet().toArray( new String[0] );
+ ComponentController.setEnabled( names, enable, components );
+ }
+
+ public void setData( Hashtable data )
+ {
+ String nome = (String)data.get( Importer.NOME );
+ if( nome != null && nome.trim().length() > 0 )
+ {
+ nomeText.setText( nome );
+ }
+ String sexo = (String)data.get( Importer.SEXO );
+ if( sexo != null && sexo.trim().length() > 0 )
+ {
+ Integer sexoInt;
+ if( sexo.trim().toLowerCase().charAt(0) == 'f' )
+ {
+ sexoInt = new Integer( 2 );
+ }
+ else
+ {
+ sexoInt = new Integer( 1 );
+ }
+ sexoPanel.fill( sexoInt );
+ }
+ String nacionalidade = (String)data.get( Importer.NACIONALIDADE );
+ if( nacionalidade != null && nacionalidade.trim().length() > 0 )
+ {
+ nacionalidadeText.setText( nacionalidade );
+ }
+ String dataNascimento = (String)data.get( Importer.DATA_NASCIMENTO );
+ if( dataNascimento != null )
+ {
+ dataNascimentoPanel.setDate( DateUtils.guessDate( dataNascimento ) );
+ }
+ String numeroMecanografico = (String)data.get( Importer.NUMERO_MECANOGRAFICO );
+ if( numeroMecanografico != null && numeroMecanografico.trim().length() > 0 )
+ {
+ numeroMecanograficoText.setText( numeroMecanografico );
+ }
+ String dataAdmissao = (String)data.get( Importer.DATA_ADMISSAO );
+ if( dataAdmissao != null )
+ {
+ dataAdmissaoPanel.setDate( DateUtils.guessDate( dataAdmissao ) );
+ }
+ String categoria = (String)data.get( Importer.CATEGORIA );
+ if( categoria != null && categoria.trim().length() > 0 )
+ {
+ categoriaText.setText( categoria );
+ }
+ String localTrabalho = (String)data.get( Importer.LOCAL_TRABALHO );
+ if( localTrabalho != null && localTrabalho.trim().length() > 0 )
+ {
+ localText.setText( localTrabalho );
+ }
+ String funcao = (String)data.get( Importer.FUNCAO );
+ if( funcao != null && funcao.trim().length() > 0 )
+ {
+ funcaoText.setText( funcao );
+ }
+ String dataAdmissaoFuncao = (String)data.get( Importer.DATA_ADMISSAO_FUNCAO );
+ if( dataAdmissaoFuncao != null )
+ {
+ dataAdmissaoFuncaoPanel.setDate( DateUtils.guessDate( dataAdmissaoFuncao ) );
+ }
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/UpperPanel.java b/trunk/SIPRPSoft/src/siprp/ficha/UpperPanel.java
new file mode 100644
index 00000000..23b2d7d9
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/UpperPanel.java
@@ -0,0 +1,294 @@
+/*
+ * UpperPanel.java
+ *
+ * Created on 29 de Marco de 2004, 17:44
+ */
+
+package siprp.ficha;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.data.*;
+import com.evolute.utils.dataui.*;
+import com.evolute.utils.jdo.*;
+import com.evolute.utils.metadb.*;
+import com.evolute.utils.ui.*;
+import com.evolute.utils.ui.text.*;
+
+import siprp.*;
+import siprp.data.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class UpperPanel extends JPanel
+ implements ControllableComponent, ItemListener
+{
+ protected JDOProvider JDO;
+
+ protected JFrame owner;
+ private JTextField empresaText;
+ private JTextField nomeText;
+ private JComboBox medicosCombo;
+ private JTextField cpText;
+
+ private FichaDataProvider provider;
+ private Hashtable medicosHash;
+
+ /** Creates a new instance of UpperPanel */
+ public UpperPanel()
+ throws Exception
+ {
+ provider = (FichaDataProvider)FichaDataProvider.getProvider();
+ medicosHash = new Hashtable();
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ setupComponents();
+ }
+
+ private void setupComponents()
+ throws Exception
+ {
+ JLabel empresaLabel = new JLabel( "Empresa/Entidade" );
+ empresaText = new JTextField();
+ empresaText.setEditable( false );
+ JLabel nomeLabel = new JLabel( "Nome" );
+ nomeText = new JTextField();
+ nomeText.setEditable( false );
+ JLabel medicoLabel = new JLabel( "M\u00e9dico" );
+ medicosCombo = new JComboBox();
+ JLabel cpLabel = new JLabel( "c.p." );
+ cpText = new JTextField();
+ cpText.setEditable( false );
+ fillCombo();
+ GridBagLayout gridbag = new GridBagLayout();
+ setLayout( gridbag );
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.insets = new Insets( 0, 1, 0, 1 );
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ constraints.gridheight = 1;
+ constraints.weighty = 0;
+
+ constraints.gridwidth = 1;
+ constraints.weightx = 0;
+ gridbag.setConstraints( empresaLabel, constraints );
+ add( empresaLabel );
+
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ constraints.weightx = 1;
+ gridbag.setConstraints( empresaText, constraints );
+ add( empresaText );
+
+ constraints.gridwidth = 1;
+ constraints.weightx = 0;
+ gridbag.setConstraints( nomeLabel, constraints );
+ add( nomeLabel );
+
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ constraints.weightx = 1;
+ gridbag.setConstraints( nomeText, constraints );
+ add( nomeText );
+
+ constraints.gridwidth = 1;
+ constraints.weightx = 0;
+ gridbag.setConstraints( medicoLabel, constraints );
+ add( medicoLabel );
+
+ constraints.gridwidth = 1;
+ constraints.weightx = 0.8;
+ gridbag.setConstraints( medicosCombo, constraints );
+ add( medicosCombo );
+
+ constraints.gridwidth = 1;
+ constraints.weightx = 0;
+ gridbag.setConstraints( cpLabel, constraints );
+ add( cpLabel );
+
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ constraints.weightx = 0.2;
+ gridbag.setConstraints( cpText, constraints );
+ add( cpText );
+
+ new CopyPasteHandler( empresaText );
+ new CopyPasteHandler( nomeText );
+ new CopyPasteHandler( cpText );
+ }
+
+ public void fill(Object value)
+ {
+ Integer values[] = (Integer[])value;
+ Integer empresaID = values[0];
+ Integer estabelecimentoID = values[1];
+ Integer trabalhadorID = values[2];
+ clear();
+ try
+ {
+ TrabalhadorData trabalhador;
+ EstabelecimentoData estabelecimento;
+ EmpresaData empresa;
+ if( trabalhadorID != null )
+ {
+ trabalhador = ( TrabalhadorData ) JDO.load( TrabalhadorData.class, trabalhadorID );
+ String nome = (String) trabalhador.get( TrabalhadorData.NOME );
+ nomeText.setText( nome );
+ }
+ String nomeEstabelecimento = "";
+ if( estabelecimentoID != null )
+ {
+ estabelecimento = ( EstabelecimentoData ) JDO.load( EstabelecimentoData.class, estabelecimentoID );
+ nomeEstabelecimento = (String) estabelecimento.get( EstabelecimentoData.NOME );
+ try
+ {
+ Integer medicoID = provider.getMedicoForEstabelecimento( estabelecimentoID );
+ if( medicoID != null && medicoID.intValue() > -1 )
+ {
+ for( int n = 0; n < medicosCombo.getItemCount(); n++ )
+ {
+ IDObject medico = ( IDObject ) medicosCombo.getItemAt( n );
+ if( medico.getID().equals( medicoID ) )
+ {
+ medicosCombo.setSelectedIndex( n );
+ break;
+ }
+ }
+ }
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+ if( empresaID != null )
+ {
+ empresa = ( EmpresaData ) JDO.load( EmpresaData.class, empresaID );
+ String nomeEmpresa = (String) empresa.get( EmpresaData.DESIGNACAO_SOCIAL );
+ empresaText.setText( nomeEmpresa + ( nomeEstabelecimento.length() > 0?" / " + nomeEstabelecimento:"" ) );
+ }
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar os dados do cabe\u00e7alho...", true );
+ }
+ }
+
+ public Object save()
+ {
+ Integer id = ( (IDObject) medicosCombo.getSelectedItem() ).getID();
+ if( id != null )
+ {
+ try
+ {
+ MedicoData medico = ( MedicoData )JDO.load( MedicoData.class, id );
+ return medico;
+ }
+ catch( Exception ex )
+ {
+ ex.printStackTrace();
+ }
+ }
+ else
+ {
+ throw new ValuesException( "A ficha tem de ter um m\u00e9dico associado" );
+ }
+ return null;
+ }
+
+ public void fillCombo()
+ throws Exception
+ {
+ medicosCombo.removeItemListener( this );
+ medicosCombo.removeAllItems();
+ medicosHash.clear();
+ Object medicos[][] = provider.getAllMedicos();
+ for( int n = 0; n < medicos.length; n++ )
+ {
+ Object medico[] = new Object[ 4 ];
+ medico[ 0 ] = new Integer( ( (Number)medicos[n][0] ).intValue() );
+ medico[ 1 ] = medicos[ n ][ 1 ];
+ medico[ 2 ] = medicos[ n ][ 2 ];
+ medico[ 3 ] = new Integer( n );
+ medicosHash.put( medicos[ n ][ 0 ], medico );
+ medicosCombo.addItem( new MappableObject( (Integer) medico[ 0 ], medico[ 1 ] ) );
+ }
+
+ if( medicos.length > 0 )
+ {
+ medicosCombo.setSelectedIndex( 0 );
+ cpText.setText( medicos[ 0 ][ 2 ] != null?(String)medicos[ 0 ][ 2 ]:"" );
+ }
+ else
+ {
+ medicosCombo.addItem( new MappableObject( null, "" ) );
+ medicosCombo.setSelectedIndex( 0 );
+ cpText.setText( "" );
+ }
+ medicosCombo.addItem( new MappableObject( new Integer( -1 ), "Novo/Editar" ) );
+ medicosCombo.addItemListener( this );
+ }
+
+ public void itemStateChanged(java.awt.event.ItemEvent itemEvent)
+ {
+ int index = medicosCombo.getSelectedIndex();
+ if( index == medicosCombo.getItemCount() - 1 )
+ {
+ try
+ {
+ MedicoEditor me = new MedicoEditor( owner );
+ me.show();
+// boolean isNew = me.getIsNew();
+ Integer id = me.getID();
+ if( id == null )
+ {
+ medicosCombo.setSelectedIndex( 0 );
+ }
+ else
+ {
+ fillCombo();
+ if( id != null )
+ {
+ Object[] medico = (Object[])medicosHash.get( id );
+ medicosCombo.setSelectedIndex( ((Integer)medico[ 3 ] ).intValue() );
+ }
+ }
+
+ }
+ catch( Exception ex )
+ {
+ JOptionPane.showMessageDialog( null, "Erro a abrir a janela de edi\u00e7\u00e3o...", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ ex.printStackTrace();
+ medicosCombo.setSelectedIndex( 0 );
+ return;
+ }
+ }
+ else
+ {
+ IDObject selected = (IDObject)medicosCombo.getItemAt( index );
+ Integer id = selected.getID();
+ if( id == null )
+ {
+ cpText.setText( "" );
+ }
+ else
+ {
+ Object[] medico = (Object[])medicosHash.get( id );
+ cpText.setText( medico[ 2 ] != null?(String)medico[ 2 ]:"" );
+ }
+ }
+ }
+
+ public void clear()
+ {
+ empresaText.setText( "" );
+ nomeText.setText( "" );
+ medicosCombo.setSelectedIndex( 0 );
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ medicosCombo.setEnabled( enable );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/ValuesException.java b/trunk/SIPRPSoft/src/siprp/ficha/ValuesException.java
new file mode 100644
index 00000000..e5a14882
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/ValuesException.java
@@ -0,0 +1,22 @@
+/*
+ * ValuesException.java
+ *
+ * Created on 5 de Abril de 2004, 20:22
+ */
+
+package siprp.ficha;
+
+/**
+ *
+ * @author fpalma
+ */
+public class ValuesException extends RuntimeException
+{
+
+ /** Creates a new instance of ValuesException */
+ public ValuesException( String msg )
+ {
+ super( msg );
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/ficha_aptidao.xsl b/trunk/SIPRPSoft/src/siprp/ficha/ficha_aptidao.xsl
new file mode 100644
index 00000000..8a3644de
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/ficha_aptidao.xsl
@@ -0,0 +1,323 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ FICHA DE APTIDÃO
+
+
+ ()
+
+
+
+
+
+
+
+
+
+ Empresa/Entidade
+
+
+
+
+
+
+DESIGNAÇÃO SOCIAL:
+
+
+
+
+
+
+ESTABELECIMENTO:
+
+
+
+
+LOCALIDADE:
+
+
+
+
+
+
+SERVIÇO DE SAÚDE: Tipo
+ Interno
+ Interempresas
+ Externo
+ Serviço Nacional de Saúde
+
+
+DESIGNAÇÃO:
+
+
+SERVIÇO DE HIGIENE E SEGURANÇA: Tipo
+ Interno
+ Interempresas
+ Externo
+ Outro
+
+
+DESIGNAÇÃO:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Trabalhador
+
+
+
+
+
+
+NOME:
+
+
+
+
+
+
+SEXO:
+
+
+
+
+DATA DE NASCIMENTO:
+
+
+
+
+NACIONALIDADE:
+
+
+
+
+
+
+NÚMERO MECANOGRÁFICO/OUTRO:
+
+
+CATEGORIA PROFISSIONAL:
+
+
+FUNCAO PROPOSTA:
+
+
+
+
+DATA DE ADMISSÃO:
+
+
+LOCAL DE TRABALHO:
+
+
+DATA DE ADMISSÃO NA FUNÇÃO:
+
+
+
+
+
+
+
+
+
+
+
+
+ Observações
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Exame Médico
+
+
+
+
+
+
+DATA DO EXAME:
+
+
+TIPO
+
+
+ ADMISSÃO
+
+
+ PERIÓDICO
+
+
+ OCASIONAL
+
+
+ APÓS DOENCA
+
+
+ APÓS ACIDENTE
+
+
+ A PEDIDO DO TRABALHADOR
+
+
+ A PEDIDO DO SERVIÇO
+
+
+ POR MUDANCA DE FUNÇÃO
+
+
+ POR ALTERAÇÃO DAS CONDIÇÕES DE TRABALHO
+
+
+ OUTRO
+
+
+ESPECIFIQUE:
+
+
+
+
+RESULTADO
+
+
+ APTO
+
+
+ APTO CONDICIONALMENTE
+
+
+
+
+
+ INAPTO TEMPORARIAMENTE
+
+
+ INAPTO DEFINITIVAMENTE
+
+
+
+
+
+OUTRAS FUNÇÕES QUE PODE DESEMPENHAR
+
+
+ 1
+
+
+ 2
+
+
+ 3
+
+
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Outras Recomendações
+
+
+
+
+
+
+
+
+
+PRÓXIMO EXAME:
+
+
+
+
+
+
+
+
+
+
+
+
+MÉDICO DO TRABALHO:
+
+
+
+
+C.P.
+
+
+
+
+
+
+ASSINATURA _____________________________________________________________________________________________
+
+
+TOMEI CONHECIMENTO ___________________________________________________________________ DATA: ___/___/______
+
+
+ O RESPONSÁVEL DOS RECURSOS HUMANOS
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/svg/char_square_pure.svg b/trunk/SIPRPSoft/src/siprp/ficha/svg/char_square_pure.svg
new file mode 100644
index 00000000..6c17f710
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/svg/char_square_pure.svg
@@ -0,0 +1,24 @@
+
+
+
diff --git a/trunk/SIPRPSoft/src/siprp/ficha/svg/char_tick_pure.svg b/trunk/SIPRPSoft/src/siprp/ficha/svg/char_tick_pure.svg
new file mode 100644
index 00000000..e5e1b808
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/ficha/svg/char_tick_pure.svg
@@ -0,0 +1,24 @@
+
+
+
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/HigieneDataProvider.java b/trunk/SIPRPSoft/src/siprp/higiene/HigieneDataProvider.java
new file mode 100644
index 00000000..60b2074b
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/higiene/HigieneDataProvider.java
@@ -0,0 +1,255 @@
+/*
+ * HigieneDataProvider.java
+ *
+ * Created on February 1, 2006, 10:49 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.higiene;
+
+import java.awt.*;
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.arrays.*;
+import com.evolute.utils.data.*;
+import com.evolute.utils.db.*;
+import com.evolute.utils.metadb.*;
+import com.evolute.utils.sql.*;
+import com.evolute.utils.strings.*;
+import com.evolute.utils.tables.*;
+
+import siprp.*;
+import siprp.data.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class HigieneDataProvider extends MetaProvider
+{
+ public static final int ESTADO_POR_REALIZAR = 0;
+ public static final int ESTADO_REALIZADO = 2;
+ public static final int ESTADO_DESMARCADO_TRABALHADOR = 3;
+ public static final int ESTADO_DESMARCADO_EMPRESA = 4;
+ public static final int ESTADO_FALTOU = 5;
+
+ public static final String ESTADOS_STR[] =
+ new String[]{ "Por realizar", "", "Realizada",
+ "Desmarcada empresa",
+ "Desmarcada " + Singleton.getInstance( SingletonConstants.COMPANY_ACRONYM ),
+ "Faltou" };
+
+ public static final Color CORES_TECNICOS[] =
+ new Color[]{ Color.white, Color.red.darker(), Color.blue,
+ Color.green.darker(), Color.yellow.darker(),
+ Color.gray, Color.pink.darker() };
+
+ private static final Object LOCK = new Object();
+ private static HigieneDataProvider instance = null;
+ private final Executer executer;
+
+ /** Creates a new instance of HigieneDataProvider */
+ public HigieneDataProvider()
+ throws Exception
+ {
+ DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ );
+ executer = dbm.getSharedExecuter( this );
+ }
+
+ public static MetaProvider getProvider()
+ throws Exception
+ {
+ synchronized( LOCK )
+ {
+ if( instance == null )
+ {
+ instance = new HigieneDataProvider();
+ }
+ }
+ return instance;
+ }
+
+ public Object[][] getAllTecnicosHST()
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "marcacoes_tecnicos_hst" },
+ new String[]{ "id", "nome", "iniciais", "identificador", "nome_plain" },
+ new Field( "inactivo" ).isDifferent( "y" ),
+ new String[]{ "nome_plain" },
+ null );
+ Virtual2DArray array = executer.executeQuery( select );
+ return array.getObjects();
+ }
+
+ public ColumnizedMappable[] getAllEmpresas()
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "empresas" },
+ new String[]{ "id", "designacao_social", "designacao_social_plain" },
+ new Field( "inactivo" ).isDifferent( "y" ),
+ new String[]{ "designacao_social_plain" },
+ null );
+ Virtual2DArray array = executer.executeQuery( select );
+ ColumnizedMappable empresas[] = new ColumnizedMappable[ array.columnLength() ];
+ for( int n = 0; n < empresas.length; n++ )
+ {
+ Integer id = ( Integer ) array.get( n, 0 );
+ String designacao = ( String ) array.get( n, 1 );
+ empresas[ n ] = new ColumnizedMappable( id, designacao );
+ }
+ return empresas;
+ }
+
+ public ColumnizedMappable[] getAllEstabelecimentosForEmpresa( Integer empresaID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "estabelecimentos" },
+ new String[]{ "id", "nome", "nome_plain" },
+ new Field( "empresa_id" ).isEqual( empresaID ).and(
+ new Field( "inactivo" ).isDifferent( "y" ) ),
+ new String[]{ "nome_plain" },
+ null );
+ Virtual2DArray array = executer.executeQuery( select );
+ ColumnizedMappable estabelecimentos[] = new ColumnizedMappable[ array.columnLength() ];
+ for( int n = 0; n < estabelecimentos.length; n++ )
+ {
+ Integer id = ( Integer ) array.get( n, 0 );
+ String nome = ( String ) array.get( n, 1 );
+ estabelecimentos[ n ] = new ColumnizedMappable( id, nome );
+ }
+ return estabelecimentos;
+ }
+
+ public String getEmpresa( Integer empresaID )
+ throws Exception
+ {
+ String nomes[] = new String[ 2 ];
+ Select select = new Select( new String[]{ "empresas" },
+ new String[]{ "designacao_social" },
+ new Field( "id" ).isEqual( empresaID ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ return ( String ) array.get( 0, 0 );
+ }
+
+ public Object[][] getVisitasEstabelecimento( Integer estabelecimentoID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "marcacoes_estabelecimento" },
+ new String[]{ "id", "data", "estado" },
+ new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ),
+ new String[]{ "data desc" },
+ null );
+ Virtual2DArray array = executer.executeQuery( select );
+ Object data[][] = array.getObjects();
+ for( int n = 0; n < data.length; n++ )
+ {
+ int estado = ( ( Integer ) data[ n ][ 2 ] ).intValue();
+ data[ n ][ 2 ] = ESTADOS_STR[ estado ];
+ }
+ return data;
+ }
+
+ public Vector[][] getMapaAnual( Integer ano )
+ throws Exception
+ {
+ String deleted = "__DELETED__";
+ Select select =
+ new Select( new String[]{ "marcacoes_tecnicos_hst" },
+ new String[]{ "id", "nome", "iniciais", "identificador", "nome_plain" },
+ new Field( "inactivo" ).isDifferent( "y" ),
+ new String[]{ "nome_plain" },
+ null );
+ Virtual2DArray array = executer.executeQuery( select );
+ Object tecnicosArr[][] = array.getObjects();
+ Hashtable tecnicos = new Hashtable();
+ for( int n = 0; n < tecnicosArr.length; n++ )
+ {
+ tecnicos.put( tecnicosArr[ n ][ 0 ], tecnicosArr[ n ] );
+ }
+ Hashtable empresas = new Hashtable();
+ Hashtable estabelecimentos = new Hashtable();
+ Hashtable empresasEstabelecimentos = new Hashtable();
+ Vector data[][] = new Vector[ 31 ][ 12 ];
+ select = new Select( new String[]{ "marcacoes_estabelecimento" },
+ new String[]{ "data", "estabelecimento_id", "tecnico_hst" },
+ new Field( "data" ).between( new Object[]{ ano + "-01-01", ano + "-12-31" } ).and(
+ new Field( "estado" ).in( new Integer[]{ new Integer( 0 ), new Integer( 2 ) } ) ) );
+ array = executer.executeQuery( select );
+ for( int n = 0; n < array.columnLength(); n++ )
+ {
+ Date dataVisita = ( Date ) array.get( n, 0 );
+ Integer estabelecimentoID = ( Integer ) array.get( n, 1 );
+ Integer tecnicoID = ( Integer ) array.get( n, 2 );
+ Integer empresaID = null;
+ if( !estabelecimentos.containsKey( estabelecimentoID ) )
+ {
+ Select estabelecimentoSelect =
+ new Select( new String[]{ "estabelecimentos" },
+ new String[]{ "nome", "empresa_id", "inactivo" },
+ new Field( "id" ).isEqual( estabelecimentoID ) );
+ Virtual2DArray estabelecimentoArray = executer.executeQuery( estabelecimentoSelect );
+ if( "y".equals( estabelecimentoArray.get( 0, 2 ) ) )
+ {
+ estabelecimentos.put( estabelecimentoID, deleted );
+ }
+ else
+ {
+ estabelecimentos.put( estabelecimentoID, estabelecimentoArray.get( 0, 0 ) );
+ }
+ empresaID = ( Integer ) estabelecimentoArray.get( 0, 1 );
+ empresasEstabelecimentos.put( estabelecimentoID, empresaID );
+ if( !empresas.containsKey( empresaID ) )
+ {
+ Select empresaSelect =
+ new Select( new String[]{ "empresas" },
+ new String[]{ "designacao_social", "inactivo" },
+ new Field( "id" ).isEqual( empresaID ) );
+ Virtual2DArray empresaArray = executer.executeQuery( empresaSelect );
+ if( "y".equals( empresaArray.get( 0, 1 ) ) )
+ {
+ empresas.put( empresaID, deleted );
+ }
+ else
+ {
+ empresas.put( empresaID, empresaArray.get( 0, 0 ) );
+ }
+ }
+ }
+ String nomeEstabelecimento = ( String ) estabelecimentos.get( estabelecimentoID );
+ empresaID = ( Integer ) empresasEstabelecimentos.get( estabelecimentoID );
+ String nomeEmpresa = ( String ) empresas.get( empresaID );
+ String nomeTecnico = " ";
+ Integer indiceCor = null;
+ Color cor = null;
+ if( tecnicoID != null )
+ {
+ Object tecnico[] = ( Object[] ) tecnicos.get( tecnicoID );
+ nomeTecnico = ( String ) tecnico[ 1 ];
+ indiceCor = ( Integer ) tecnico[ 3 ];
+ cor = CORES_TECNICOS[ indiceCor.intValue() ];
+ }
+ Calendar cal = Calendar.getInstance();
+ cal.setTime( dataVisita );
+ int dia = cal.get( Calendar.DAY_OF_MONTH ) - 1;
+ int mes = cal.get( Calendar.MONTH );
+ if( data[ dia ][ mes ] == null )
+ {
+ data[ dia ][ mes ] = new Vector();
+ data[ dia ][ mes ].add( new Object[]{ new Integer( dia + 1 ) } );
+ }
+ if( nomeEmpresa != deleted && nomeEstabelecimento != deleted )
+ {
+ data[ dia ][ mes ].add( new Object[]{ nomeEmpresa, nomeEstabelecimento, nomeTecnico, cor } );
+ }
+ }
+
+ return data;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/alter2.sql b/trunk/SIPRPSoft/src/siprp/higiene/alter2.sql
new file mode 100644
index 00000000..6166400d
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/higiene/alter2.sql
@@ -0,0 +1,18 @@
+
+CREATE TABLE marcacoes_tecnicos_hst
+(
+ id int4 NOT NULL,
+ nome varchar(255) NOT NULL,
+ nome_plain varchar(255) NOT NULL,
+ iniciais varchar(10) NOT NULL,
+ identificador int4,
+ inactivo char(1) DEFAULT 'n' NOT NULL,
+ CONSTRAINT marcacoes_tecnicos_hst_pkey PRIMARY KEY (id)
+)
+WITHOUT OIDS;
+ALTER TABLE marcacoes_tecnicos_hst OWNER TO postgres;
+
+ALTER TABLE marcacoes_estabelecimento ADD estado INT;
+ALTER TABLE marcacoes_estabelecimento ADD tecnico_hst INT REFERENCES marcacoes_tecnicos_hst(id);
+ALTER TABLE marcacoes_estabelecimento ADD observacoes VARCHAR( 2048 );
+UPDATE marcacoes_estabelecimento SET estado = 2 WHERE realizada = 'y';
\ No newline at end of file
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaLine.java b/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaLine.java
new file mode 100644
index 00000000..7eb4a647
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaLine.java
@@ -0,0 +1,62 @@
+/*
+ * DiaLine.java
+ *
+ * Created on 8 de Fevereiro de 2006, 22:43
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.higiene.mapa;
+
+import java.util.*;
+
+import com.evolute.utils.tables.*;
+
+/**
+ *
+ * @author Frederico
+ */
+public class DiaLine implements ColumnizedObjectForUpdate
+{
+ protected Integer day;
+ protected Vector data[];
+
+ /** Creates a new instance of DiaLine */
+ public DiaLine( int day, Vector data[] )
+ {
+ this.day = new Integer( day );
+ this.data = data;
+ }
+
+ public Object getValue( int col )
+ {
+ switch( col )
+ {
+ case 0:
+ return day;
+
+ default:
+ return data[ col - 1 ].toArray( new Object[ 0 ][] );
+ }
+ }
+
+ public int[] getUpdateableColumns()
+ {
+ return new int[]{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
+ }
+
+ public void setValueAt( Object value, int col )
+ {
+// data[ col - 1 ].clear();
+ if( value != null && value instanceof Vector )
+ {
+ data[ col - 1 ].addAll( ( Vector ) value );
+ }
+ }
+
+ public void clear( int col )
+ {
+ data[ col - 1 ].clear();
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaPanel.java
new file mode 100644
index 00000000..05c508b4
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaPanel.java
@@ -0,0 +1,101 @@
+/*
+ * DiaPanel.java
+ *
+ * Created on February 1, 2006, 6:42 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.higiene.mapa;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+import com.evolute.utils.dataui.*;
+/**
+ *
+ * @author fpalma
+ */
+public class DiaPanel extends JPanel
+ implements ControllableComponent, ActionListener
+{
+ protected Object data[][];
+ protected JButton buttons[];
+
+ /** Creates a new instance of DiaPanel */
+ public DiaPanel()
+ {
+ }
+
+ private void setupComponents()
+ {
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ }
+
+ public void fill( Object value )
+ {
+ removeAll();
+ Object arr[][] = ( Object[][] ) value;
+ data = arr;
+ buttons = new JButton[ arr.length ];
+ if( arr.length > 0 )
+ {
+ GridBagLayout gridbag = new GridBagLayout();
+ setLayout( gridbag );
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.insets = new Insets( 0, 0, 0, 0 );
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ constraints.weighty = 0;
+ constraints.gridheight = 1;
+ Integer dia = ( Integer ) arr[ 0 ][ 0 ];
+ JLabel diaLabel = new JLabel( dia.toString(), JLabel.LEFT );
+ gridbag.setConstraints( diaLabel, constraints );
+ add( diaLabel );
+ for( int n = 1; n < arr.length; n++ )
+ {
+ String empresa = ( String ) arr[ n ][ 0 ];
+ String estabelecimento = ( String ) arr[ n ][ 1 ];
+ String tecnico = ( String ) arr[ n ][ 2 ];
+ Color cor = ( Color ) arr[ n ][ 3 ];
+ String empresaR = empresa.length() > 10 ? empresa.substring( 0, 10 ) : empresa;
+ String estabelecimentoR = estabelecimento.length() > 10 ? estabelecimento.substring( 0, 10 ) : estabelecimento;
+ buttons[ n ] = new JButton( "" + empresaR + "
" + estabelecimentoR + "" );
+ buttons[ n ].setMargin( new Insets( 2, 1, 2, 1 ) );
+ buttons[ n ].setBackground( cor );
+ buttons[ n ].setToolTipText( "T\u00e9cnico: " + ( tecnico != null ? tecnico : "n.d." )
+ + " \nEmpresa: " + empresa + " \nEstabelecimento: " + estabelecimento );
+ gridbag.setConstraints( buttons[ n ], constraints );
+ add( buttons[ n ] );
+ buttons[ n ].addActionListener( this );
+ }
+ JPanel pad = new JPanel();
+ constraints.weighty = 1;
+ constraints.gridheight = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( pad, constraints );
+ add( pad );
+ }
+
+ }
+
+ public Object save()
+ {
+ return data;
+ }
+
+ public void clear()
+ {
+ }
+
+ public void actionPerformed( ActionEvent e )
+ {
+ JButton source = ( JButton ) e.getSource();
+ JOptionPane.showMessageDialog( source, source.getToolTipText(), "", JOptionPane.PLAIN_MESSAGE );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaRenderer.java b/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaRenderer.java
new file mode 100644
index 00000000..40dc967e
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaRenderer.java
@@ -0,0 +1,65 @@
+/*
+ * DiaRenderer.java
+ *
+ * Created on 8 de Fevereiro de 2006, 21:45
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.higiene.mapa;
+
+import java.awt.*;
+import javax.swing.*;
+import javax.swing.table.*;
+import java.util.*;
+/**
+ *
+ * @author Frederico
+ */
+public class DiaRenderer extends DefaultCellEditor
+ implements TableCellRenderer
+{
+ protected JLabel diaLabel;
+ protected DiaPanel diaPanel;
+
+ /** Creates a new instance of DiaRenderer */
+ public DiaRenderer()
+ {
+ super( new JCheckBox() );
+ diaLabel = new JLabel();
+ diaPanel = new DiaPanel();
+ }
+
+ public Component getTableCellRendererComponent( JTable table, Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row, int column )
+ {
+ if( column == 0 )
+ {
+ diaLabel.setText( "" + value );
+ return diaLabel;
+ }
+ diaPanel.fill( value );
+ return diaPanel;
+ }
+
+ public Component getTableCellEditorComponent( JTable table, Object value,
+ boolean isSelected,
+ int row, int column )
+ {
+ if( column == 0 )
+ {
+ diaLabel.setText( "" + value );
+ return diaLabel;
+ }
+ diaPanel.fill( value );
+ return diaPanel;
+ }
+
+ public Object getCellEditorValue()
+ {
+ return diaPanel.save();
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigienePanel.java b/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigienePanel.java
new file mode 100644
index 00000000..05c6d67e
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigienePanel.java
@@ -0,0 +1,112 @@
+/*
+ * MapaHigienePanel.java
+ *
+ * Created on 9 de Fevereiro de 2006, 0:11
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.higiene.mapa;
+
+import java.awt.*;
+import javax.swing.*;
+import java.util.*;
+
+import com.evolute.utils.dataui.*;
+import com.evolute.utils.date.*;
+import com.evolute.utils.tables.*;
+/**
+ *
+ * @author Frederico
+ */
+public class MapaHigienePanel extends JPanel
+ implements ControllableComponent
+{
+ protected BaseTable yearTable;
+ protected VectorTableModel yearModel;
+ protected JScrollPane yearScroll;
+
+ /** Creates a new instance of MapaHigienePanel */
+ public MapaHigienePanel()
+ throws Exception
+ {
+ setupComponents();
+ }
+
+ private void setupComponents()
+ throws Exception
+ {
+ String headers[] = new String[ 13 ];
+ headers[ 0 ] = " ";
+ for( int n = 0; n < DateUtils.MONTHS_FULL_PT.length; n++ )
+ {
+ headers[ n + 1 ] = DateUtils.MONTHS_FULL_PT[ n ];
+ }
+ yearModel = new VectorTableModel( headers );
+ yearTable = new BaseTable( yearModel );
+ yearTable.fixColumnWidth( 0, 20 );
+ yearTable.setNonResizableNorReordable();
+// yearTable.setEnabled( true );
+ yearModel.setEditable( true );
+ yearTable.setTableCellRenderer( new DiaRenderer() );
+ yearTable.setTableCellEditor( new DiaRenderer() );
+ yearScroll = new JScrollPane( yearTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ Vector values = yearModel.getValues();
+ for( int n = 0; n < 31; n++ )
+ {
+ Vector data[] = new Vector[ 12 ];
+ for( int m = 0; m < 12; m++ )
+ {
+ data[ m ] = new Vector();
+ }
+ values.add( new DiaLine( n + 1, data ) );
+ }
+ yearModel.setValues( values );
+
+ setLayout( new GridLayout( 1, 1 ) );
+ add( yearScroll );
+ }
+
+ public void clear()
+ {
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ yearTable.setEnabled( enable );
+ }
+
+ public void fill( Object value )
+ {
+// if( true ) return;
+ Vector arr[][] = ( Vector[][] )value;
+ int maxs[] = new int[ arr.length ];
+ for( int r = 0; r < arr.length; r++ )
+ {
+ maxs[ r ] = 1;
+ for( int c = 0; c < arr[ r ].length; c++ )
+ {
+ if( arr[ r ][ c ] != null && arr[ r ][ c ].size() > maxs[ r ] )
+ {
+ maxs[ r ] = arr[ r ][ c ].size();
+ }
+ DiaLine line = ( DiaLine ) yearModel.getRowAt( r );
+ line.clear( c + 1 );
+ line.setValueAt( arr[ r ][ c ], c + 1 );
+ yearModel.removeRowAt( r );
+ yearModel.insertRowAt( line, r );
+ }
+ }
+ for( int r = 0; r < arr.length; r++ )
+ {
+ yearTable.setRowHeight( r, 20 + ( maxs[ r ] - 1 ) * 40 );
+ }
+ }
+
+ public Object save()
+ {
+ return null;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigieneWindow.java b/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigieneWindow.java
new file mode 100644
index 00000000..26612fc7
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigieneWindow.java
@@ -0,0 +1,139 @@
+/*
+ * MarcacoesHigieneWindow.java
+ *
+ * Created on January 31, 2006, 11:32 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.higiene.mapa;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.util.*;
+
+import com.evolute.utils.documents.*;
+import com.evolute.utils.tables.*;
+import com.evolute.utils.ui.*;
+import com.evolute.utils.ui.window.*;
+
+import siprp.higiene.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class MapaHigieneWindow extends EditorWindow
+ implements ActionListener
+{
+ public final static String TITLE = "Mapa de Higiene e Seguran\u00e7a";
+
+ private final static int iPermissionArray[][] =
+ new int[][]{ { } };
+
+ protected MapaHigienePanel mainPanel;
+ protected JTextField anoText;
+ protected JButton actualizarButton;
+
+ protected HigieneDataProvider provider;
+
+ public static void main( String args[] )
+ throws Exception
+ {
+
+ JFrame frm = new MapaHigieneWindow();
+ frm.setVisible( true );
+ }
+
+ /** Creates a new instance of MarcacoesHigieneWindow */
+ public MapaHigieneWindow()
+ throws Exception
+ {
+ super( iPermissionArray );
+ provider = ( HigieneDataProvider ) HigieneDataProvider.getProvider();
+ setupComponents();
+ setExtendedState(getExtendedState() | MAXIMIZED_BOTH);
+ }
+
+ private void setupComponents()
+ throws Exception
+ {
+ setTitle( TITLE );
+ JPanel upperPanel = new JPanel();
+ mainPanel = new MapaHigienePanel();
+ getContentPane().setLayout( new BorderLayout() );
+ getContentPane().add( upperPanel, BorderLayout.NORTH );
+ getContentPane().add( mainPanel, BorderLayout.CENTER );
+
+ upperPanel.setLayout( new FlowLayout( FlowLayout.LEFT ) );
+ upperPanel.add( new TecnicosPanel() );
+ JLabel anoLabel = new JLabel( "Ano" );
+ anoText = new JTextField();
+ anoText.setPreferredSize( new Dimension( 50, 20 ) );
+ anoText.setDocument( new YearDocument() );
+ anoText.addActionListener( this );
+ actualizarButton = new JButton( "Actualizar" );
+ actualizarButton.addActionListener( this );
+
+ Calendar cal = Calendar.getInstance();
+ anoText.setText( "" + cal.get( Calendar.YEAR ) );
+
+ JPanel pesquisaPanel = new JPanel();
+ upperPanel.add( pesquisaPanel );
+ pesquisaPanel.setLayout( new FlowLayout( FlowLayout.CENTER ) );
+ pesquisaPanel.add( anoLabel );
+ pesquisaPanel.add( anoText );
+ pesquisaPanel.add( actualizarButton );
+
+// Vector data[][] = new Vector[ 31 ][ 12 ];
+// for( int r = 0; r < 31; r++ )
+// {
+// for( int c = 0; c < 12; c++ )
+// {
+// data[ r ][ c ] = new Vector();
+// }
+// }
+//// Vector example = new Vector();
+//// example.add( new Object[]{ "Empresa1", "Estabelecimento1", "Pai Natal", "9:30", Color.red } );
+// data[ 20 ][ 10 ].add( new Object[]{ new Integer( 21 ) } );
+// data[ 20 ][ 10 ].add( new Object[]{ "Empresa1", "Estabelecimento1", "Pai Natal", Color.red } );
+// data[ 20 ][ 10 ].add( new Object[]{ "Empresa1", "Estabelecimento1", "Pai Natal", Color.green } );
+// data[ 20 ][ 10 ].add( new Object[]{ "Empresa1", "Estabelecimento1", "Pai Natal", Color.yellow } );
+// data[ 20 ][ 10 ].add( new Object[]{ "Empresa1", "Estabelecimento1", "Pai Natal", Color.white } );
+// mainPanel.fill( data );
+ }
+
+ public void actualizar()
+ {
+ String anoStr = anoText.getText();
+ if( anoStr.length() == 0 )
+ {
+ mainPanel.clear();
+ }
+ else
+ {
+ Integer ano = new Integer( anoStr );
+ try
+ {
+ mainPanel.fill( provider.getMapaAnual( ano ) );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
+ mainPanel.clear();
+ }
+ }
+ }
+
+ public void actionPerformed( ActionEvent e )
+ {
+ Object source = e.getSource();
+ if( source.equals( actualizarButton ) || source.equals( anoText ) )
+ {
+ actualizar();
+ }
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/mapa/TecnicosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/mapa/TecnicosPanel.java
new file mode 100644
index 00000000..2cf77ab2
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/higiene/mapa/TecnicosPanel.java
@@ -0,0 +1,63 @@
+/*
+ * TecnicosPanel.java
+ *
+ * Created on 12 de Fevereiro de 2006, 17:48
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.higiene.mapa;
+
+import java.awt.*;
+import javax.swing.*;
+
+import siprp.higiene.*;
+
+/**
+ *
+ * @author Frederico
+ */
+public class TecnicosPanel extends JPanel
+{
+ protected HigieneDataProvider provider;
+
+ /** Creates a new instance of TecnicosPanel */
+ public TecnicosPanel()
+ throws Exception
+ {
+ provider = ( HigieneDataProvider ) HigieneDataProvider.getProvider();
+ setupComponents();
+ }
+
+ private void setupComponents()
+ throws Exception
+ {
+ Object tecnicos[][] = provider.getAllTecnicosHST();
+ GridBagLayout gridbag = new GridBagLayout();
+ setLayout( gridbag );
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.insets = new Insets( 1, 1, 1, 1 );
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ constraints.gridheight = 1;
+ constraints.weighty = 0;
+
+ for( int n = 0; n < tecnicos.length; n++ )
+ {
+ constraints.weightx = 0;
+ constraints.gridwidth = 1;
+ JLabel corLabel = new JLabel( " " );
+ corLabel.setBackground( HigieneDataProvider.CORES_TECNICOS[ ( ( Integer ) tecnicos[ n ][ 3 ] ).intValue() ] );
+ corLabel.setOpaque( true );
+ gridbag.setConstraints( corLabel, constraints );
+ add( corLabel );
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ JLabel nomeLabel = new JLabel( (String)tecnicos[ n ][ 1 ] );
+ gridbag.setConstraints( nomeLabel, constraints );
+ add( nomeLabel );
+
+ }
+
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/CorTecnicoCellRenderer.java b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/CorTecnicoCellRenderer.java
new file mode 100644
index 00000000..13d07aff
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/CorTecnicoCellRenderer.java
@@ -0,0 +1,41 @@
+/*
+ * CorTecnicoCellRenderer.java
+ *
+ * Created on February 1, 2006, 11:13 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.higiene.marcacoes;
+
+import java.awt.*;
+import javax.swing.*;
+
+import siprp.higiene.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class CorTecnicoCellRenderer extends JLabel implements ListCellRenderer
+{
+
+ public CorTecnicoCellRenderer()
+ {
+ setOpaque(true);
+ }
+
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
+ {
+ setText( " " );
+ Color color = HigieneDataProvider.CORES_TECNICOS[ ( ( Integer ) value ).intValue() ];
+ if( cellHasFocus )
+ {
+ color = color.darker().darker();
+ }
+ setBackground( color );
+
+ return this;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.java
new file mode 100644
index 00000000..9bb3b888
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.java
@@ -0,0 +1,307 @@
+package siprp.higiene.marcacoes;
+
+import com.evolute.utils.*;
+import com.evolute.utils.arrays.*;
+import com.evolute.utils.data.*;
+import com.evolute.utils.dataui.*;
+import com.evolute.utils.db.*;
+import com.evolute.utils.documents.*;
+import com.evolute.utils.sql.*;
+import com.evolute.utils.ui.*;
+import com.evolute.utils.ui.calendar.*;
+import com.evolute.utils.ui.panel.*;
+import com.evolute.utils.ui.text.*;
+import java.awt.*;
+import java.util.*;
+import javax.swing.*;
+import siprp.data.*;
+
+public class MarcacaoVisitaHSTPanel
+ extends JPanel
+ implements ControllableComponent, DataClassAware
+{
+ private siprp.data.MarcacaoEstabelecimentoData marcacaoEstabelecimentoData;
+ private final ComponentsHashtable components = new ComponentsHashtable();
+
+ protected final SQLExecuter EXECUTER;
+
+ private final JLabel dataLabel = new JLabel( "Data da visita", JLabel.RIGHT );
+ private final JCalendarPanel dataPanel = new JCalendarPanel( null );
+ private final JButton emailButton = new JButton( "Enviar Email" );
+ private final JLabel dataFichaLabel = new JLabel( "Data do Relat\u00f3rio", JLabel.RIGHT );
+ private final JCalendarPanel dataFichaPanel = new JCalendarPanel( null );
+ private final JLabel tecnicoLabel = new JLabel( "T\u00e9cnico", JLabel.RIGHT );
+ private final JComboBox tecnicoList = new JComboBox();
+ private RadioButtonFixedPanel estadoList;
+ private final JScrollPane observacoesTextScroll = new JScrollPane();
+ private final StateTextArea observacoesText = new StateTextArea();
+
+ public MarcacaoVisitaHSTPanel()
+ throws Exception
+ {
+ DBManager dbm = ( DBManager )Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
+ if( dbm != null )
+ {
+ EXECUTER = ( SQLExecuter )dbm.getSharedExecuter( this );
+ }
+ else
+ {
+ EXECUTER = null;
+ }
+ setupComponents();
+ setupComponentsHashtable();
+ place();
+ }
+
+ public void setupComponents()
+ throws Exception
+ {
+ JComponent MarcacaoVisitaHSTPanel = this;
+ emailButton.setMinimumSize( new Dimension( 300, 20 ) );
+ emailButton.setPreferredSize( new Dimension( 200, 20 ) );
+
+ tecnicoList.addItem( new MappableObject( new Integer( -1 ), "" ) );
+ tecnicoList.setSelectedIndex( 0 );
+
+ IDObject estadoListOptions[] = new IDObject[]{
+ new MappableObject( new Integer( 0 ), "Por realizar" ),
+ new MappableObject( new Integer( 2 ), "Realizada" ),
+ new MappableObject( new Integer( 3 ), "Desmarcada pela empresa" ),
+ new MappableObject( new Integer( 4 ), "Desmarcada pela SIPRP" ),
+ };
+ estadoList = new RadioButtonFixedPanel( estadoListOptions, 6, 1, RadioButtonFixedPanel.ORIENTATION_VERTICAL, false, null );
+ estadoList.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Estado" ) );
+
+ observacoesTextScroll.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Observa\u00e7\u00f5es" ) );
+ observacoesText.setLineWrap( true );
+ observacoesText.setWrapStyleWord( true );
+ observacoesText.setRows( 5 );
+
+ }
+
+ public void place()
+ {
+ JPanel MarcacaoVisitaHSTPanel = this;
+ GridBagConstraints MarcacaoVisitaHSTPanelGBC = new GridBagConstraints();
+ MarcacaoVisitaHSTPanelGBC.insets = new Insets( 1, 1, 1, 1 );
+ GridBagLayout MarcacaoVisitaHSTPanelLayout = new GridBagLayout();
+ MarcacaoVisitaHSTPanel.setLayout( MarcacaoVisitaHSTPanelLayout );
+ MarcacaoVisitaHSTPanelGBC.gridx = 0;
+ MarcacaoVisitaHSTPanelGBC.gridy = 0;
+ MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
+ MarcacaoVisitaHSTPanelGBC.gridheight = 1;
+ MarcacaoVisitaHSTPanelGBC.weightx = 0.0;
+ MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
+ MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL;
+ MarcacaoVisitaHSTPanelLayout.setConstraints( dataLabel, MarcacaoVisitaHSTPanelGBC );
+ MarcacaoVisitaHSTPanel.add( dataLabel );
+
+ MarcacaoVisitaHSTPanelGBC.gridx = 1;
+ MarcacaoVisitaHSTPanelGBC.gridy = 0;
+ MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
+ MarcacaoVisitaHSTPanelGBC.gridheight = 1;
+ MarcacaoVisitaHSTPanelGBC.weightx = 0.5;
+ MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
+ MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL;
+ MarcacaoVisitaHSTPanelLayout.setConstraints( dataPanel, MarcacaoVisitaHSTPanelGBC );
+ MarcacaoVisitaHSTPanel.add( dataPanel );
+
+ MarcacaoVisitaHSTPanelGBC.gridx = 2;
+ MarcacaoVisitaHSTPanelGBC.gridy = 0;
+ MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
+ MarcacaoVisitaHSTPanelGBC.gridheight = 1;
+ MarcacaoVisitaHSTPanelGBC.weightx = 0.5;
+ MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
+ MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.NONE;
+ MarcacaoVisitaHSTPanelLayout.setConstraints( emailButton, MarcacaoVisitaHSTPanelGBC );
+ MarcacaoVisitaHSTPanel.add( emailButton );
+
+ MarcacaoVisitaHSTPanelGBC.gridx = 0;
+ MarcacaoVisitaHSTPanelGBC.gridy = 1;
+ MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
+ MarcacaoVisitaHSTPanelGBC.gridheight = 1;
+ MarcacaoVisitaHSTPanelGBC.weightx = 0.0;
+ MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
+ MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL;
+ MarcacaoVisitaHSTPanelLayout.setConstraints( dataFichaLabel, MarcacaoVisitaHSTPanelGBC );
+ MarcacaoVisitaHSTPanel.add( dataFichaLabel );
+
+ MarcacaoVisitaHSTPanelGBC.gridx = 1;
+ MarcacaoVisitaHSTPanelGBC.gridy = 1;
+ MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
+ MarcacaoVisitaHSTPanelGBC.gridheight = 1;
+ MarcacaoVisitaHSTPanelGBC.weightx = 0.5;
+ MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
+ MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL;
+ MarcacaoVisitaHSTPanelLayout.setConstraints( dataFichaPanel, MarcacaoVisitaHSTPanelGBC );
+ MarcacaoVisitaHSTPanel.add( dataFichaPanel );
+
+ MarcacaoVisitaHSTPanelGBC.gridx = 0;
+ MarcacaoVisitaHSTPanelGBC.gridy = 2;
+ MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
+ MarcacaoVisitaHSTPanelGBC.gridheight = 1;
+ MarcacaoVisitaHSTPanelGBC.weightx = 0.0;
+ MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
+ MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL;
+ MarcacaoVisitaHSTPanelLayout.setConstraints( tecnicoLabel, MarcacaoVisitaHSTPanelGBC );
+ MarcacaoVisitaHSTPanel.add( tecnicoLabel );
+
+ MarcacaoVisitaHSTPanelGBC.gridx = 1;
+ MarcacaoVisitaHSTPanelGBC.gridy = 2;
+ MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
+ MarcacaoVisitaHSTPanelGBC.gridheight = 1;
+ MarcacaoVisitaHSTPanelGBC.weightx = 0.5;
+ MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
+ MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL;
+ MarcacaoVisitaHSTPanelLayout.setConstraints( tecnicoList, MarcacaoVisitaHSTPanelGBC );
+ MarcacaoVisitaHSTPanel.add( tecnicoList );
+
+ MarcacaoVisitaHSTPanelGBC.gridx = 0;
+ MarcacaoVisitaHSTPanelGBC.gridy = 3;
+ MarcacaoVisitaHSTPanelGBC.gridwidth = 3;
+ MarcacaoVisitaHSTPanelGBC.gridheight = 1;
+ MarcacaoVisitaHSTPanelGBC.weightx = 1.0;
+ MarcacaoVisitaHSTPanelGBC.weighty = 0.5;
+ MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.BOTH;
+ MarcacaoVisitaHSTPanelLayout.setConstraints( estadoList, MarcacaoVisitaHSTPanelGBC );
+ MarcacaoVisitaHSTPanel.add( estadoList );
+
+ MarcacaoVisitaHSTPanelGBC.gridx = 0;
+ MarcacaoVisitaHSTPanelGBC.gridy = 4;
+ MarcacaoVisitaHSTPanelGBC.gridwidth = 3;
+ MarcacaoVisitaHSTPanelGBC.gridheight = 1;
+ MarcacaoVisitaHSTPanelGBC.weightx = 1.0;
+ MarcacaoVisitaHSTPanelGBC.weighty = 0.5;
+ observacoesTextScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ observacoesTextScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED );
+ observacoesTextScroll.setViewportView( observacoesText );
+ MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.BOTH;
+ MarcacaoVisitaHSTPanelLayout.setConstraints( observacoesTextScroll, MarcacaoVisitaHSTPanelGBC );
+ MarcacaoVisitaHSTPanel.add( observacoesTextScroll );
+
+ }
+
+ private void setupComponentsHashtable()
+ {
+ components.putComponent( siprp.data.MarcacaoEstabelecimentoData.DATA, dataPanel );
+ components.putComponent( siprp.data.MarcacaoEstabelecimentoData.DATA_RELATORIO, dataFichaPanel );
+ components.putComponent( siprp.data.MarcacaoEstabelecimentoData.TECNICO_HST, tecnicoList );
+ components.putComponent( siprp.data.MarcacaoEstabelecimentoData.ESTADO, estadoList );
+ components.putComponent( siprp.data.MarcacaoEstabelecimentoData.OBSERVACOES, observacoesText );
+ }
+
+ public void fill( Object toFill )
+ {
+ clear();
+ if( toFill == null || !( toFill instanceof PropertyObject ) )
+ {
+ return;
+ }
+ Hashtable data = null;
+ if( toFill instanceof PropertyObject )
+ {
+ data = ( (PropertyObject) toFill ).getHashData();
+ if( toFill instanceof siprp.data.MarcacaoEstabelecimentoData )
+ {
+ marcacaoEstabelecimentoData = (siprp.data.MarcacaoEstabelecimentoData) toFill;
+ }
+ }
+ else if( toFill instanceof Hashtable )
+ {
+ data = (Hashtable) toFill;
+ }
+ else
+ {
+ return;
+ }
+ if( marcacaoEstabelecimentoData == null )
+ {
+ marcacaoEstabelecimentoData = new siprp.data.MarcacaoEstabelecimentoData();
+ marcacaoEstabelecimentoData.setHashData( data );
+ }
+ PropertyObject po = (PropertyObject) toFill;
+ String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
+ ComponentController.fill( properties, po.getHashData(), components );
+ }
+
+ public Object save()
+ {
+ if( marcacaoEstabelecimentoData == null )
+ {
+ marcacaoEstabelecimentoData = new siprp.data.MarcacaoEstabelecimentoData();
+ }
+ Hashtable data = marcacaoEstabelecimentoData.getHashData();
+ String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
+ ComponentController.save( properties, data, components );
+ if( !( marcacaoEstabelecimentoData instanceof PropertyObject ) )
+ {
+ return data;
+ }
+ marcacaoEstabelecimentoData.setHashData( data );
+ return marcacaoEstabelecimentoData;
+ }
+
+ public void clear()
+ {
+ marcacaoEstabelecimentoData = null;
+ String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
+ ComponentController.clear( properties, components );
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
+ ComponentController.setEnabled( properties, enable, components );
+ }
+
+ public Class getDataClass()
+ {
+ return siprp.data.MarcacaoEstabelecimentoData.class;
+ }
+
+ public JLabel getDataFichaLabel()
+ {
+ return dataFichaLabel;
+ }
+
+ public JCalendarPanel getDataFichaPanel()
+ {
+ return dataFichaPanel;
+ }
+
+ public JLabel getDataLabel()
+ {
+ return dataLabel;
+ }
+
+ public JCalendarPanel getDataPanel()
+ {
+ return dataPanel;
+ }
+
+ public JButton getEmailButton()
+ {
+ return emailButton;
+ }
+
+ public RadioButtonFixedPanel getEstadoList()
+ {
+ return estadoList;
+ }
+
+ public StateTextArea getObservacoesText()
+ {
+ return observacoesText;
+ }
+
+ public JLabel getTecnicoLabel()
+ {
+ return tecnicoLabel;
+ }
+
+ public JComboBox getTecnicoList()
+ {
+ return tecnicoList;
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.xml b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.xml
new file mode 100644
index 00000000..04a78a45
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.xml
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+ siprp.data.*
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+
+
+
+ Estado
+
+ 6
+
+
+ Por realizar
+ Realizada
+ Desmarcada pela empresa
+ Desmarcada pela SIPRP
+
+
+
+
+
+ Observa\u00e7\u00f5es
+
+
+ 5
+
+
+
+
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacoesHigieneUpperPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacoesHigieneUpperPanel.java
new file mode 100644
index 00000000..1efa12af
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacoesHigieneUpperPanel.java
@@ -0,0 +1,199 @@
+/*
+ * MarcacoesHigieneUpperPanel.java
+ *
+ * Created on February 2, 2006, 12:40 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.higiene.marcacoes;
+
+import java.awt.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.dataui.*;
+import com.evolute.utils.tables.*;
+import com.evolute.utils.ui.*;
+
+import siprp.higiene.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class MarcacoesHigieneUpperPanel extends JPanel
+ implements ListSelectionListener, ControllableComponent
+{
+ protected BaseTable empresasTable;
+ protected VectorTableModel empresasModel;
+ protected BaseTable estabelecimentosTable;
+ protected VectorTableModel estabelecimentosModel;
+
+ protected HigieneDataProvider provider;
+
+ protected final Vector listeners;
+
+ /** Creates a new instance of MedicinaUpperPanel */
+ public MarcacoesHigieneUpperPanel()
+ throws Exception
+ {
+ provider = ( HigieneDataProvider ) HigieneDataProvider.getProvider();
+ listeners = new Vector();
+ setupComponents();
+ }
+
+ private void setupComponents()
+ throws Exception
+ {
+ empresasModel = new VectorTableModel( new String[]{ "empresas" } );
+ empresasTable = new BaseTable( empresasModel );
+ empresasTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ empresasTable.setNonResizableNorReordable();
+ JScrollPane empresasScroll =
+ new JScrollPane( empresasTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ empresasTable.getSelectionModel().addListSelectionListener( this );
+ estabelecimentosModel = new VectorTableModel( new String[]{ "estabelecimentos" } );
+ estabelecimentosTable = new BaseTable( estabelecimentosModel );
+ estabelecimentosTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ estabelecimentosTable.setNonResizableNorReordable();
+ JScrollPane estabelecimentosScroll =
+ new JScrollPane( estabelecimentosTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ estabelecimentosTable.getSelectionModel().addListSelectionListener( this );
+
+ GridBagLayout gridbag = new GridBagLayout();
+ setLayout( gridbag );
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.insets = new Insets( 1, 1, 1, 1 );
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.gridwidth = 1;
+ constraints.gridheight = GridBagConstraints.REMAINDER;
+ constraints.weightx = 0.5;
+ constraints.weighty = 1;
+
+ gridbag.setConstraints( empresasScroll, constraints );
+
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( estabelecimentosScroll, constraints );
+
+ add( empresasScroll );
+ add( estabelecimentosScroll );
+
+ ColumnizedMappable empresas[] = provider.getAllEmpresas();
+ Vector values = empresasModel.getValues();
+ values.addAll( Arrays.asList( empresas ) );
+ empresasModel.setValues( values );
+ }
+
+ public void valueChanged( ListSelectionEvent e )
+ {
+ Object source = e.getSource();
+ if( e.getValueIsAdjusting() )
+ {
+ return;
+ }
+ if( source.equals( empresasTable.getSelectionModel() ) )
+ {
+ carregarEstabelecimentos();
+ }
+ else if( source.equals( estabelecimentosTable.getSelectionModel() ) )
+ {
+ notifyListeners( e );
+ }
+ }
+
+ protected void carregarEstabelecimentos()
+ {
+ estabelecimentosTable.clearSelection();
+ int selected = empresasTable.getSelectedRow();
+ estabelecimentosModel.clearAll();
+ if( selected > -1 )
+ {
+ try
+ {
+ Integer empresaID = ( ( ColumnizedMappable ) empresasModel.getRowAt( selected ) ).getID();
+ ColumnizedMappable estabelecimentos[] = provider.getAllEstabelecimentosForEmpresa( empresaID);
+ Vector values = estabelecimentosModel.getValues();
+ values.addAll( Arrays.asList( estabelecimentos ) );
+ estabelecimentosModel.setValues( values );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar os estabelecimentos.", true );
+ estabelecimentosModel.clearAll();
+ }
+ }
+ }
+
+ protected void notifyListeners( ListSelectionEvent e )
+ {
+ for( int n = 0; n < listeners.size(); n++ )
+ {
+ ListSelectionEvent event =
+ new ListSelectionEvent( this, e.getFirstIndex(), e.getLastIndex(), e.getValueIsAdjusting() );
+ ( ( ListSelectionListener ) listeners.elementAt( n ) ).valueChanged( event );
+ }
+ }
+
+ public void addListSelectionListener( ListSelectionListener listener )
+ {
+ listeners.add( listener );
+ }
+
+ public void removeSelectionListener( ListSelectionListener listener )
+ {
+ listeners.remove( listener );
+ }
+
+ public void clear()
+ {
+// empresasTable.clearSelection();
+ }
+
+ public void fill( Object value )
+ {
+ if( value == null )
+ {
+ clear();
+ }
+ Integer ids[] = ( Integer [] ) value;
+ for( int n = 0; n < empresasTable.getRowCount(); n++ )
+ {
+ if( ( ( ColumnizedMappable ) empresasModel.getRowAt( n ) ).getID().equals( ids[ 0 ] ) )
+ {
+ empresasTable.setRowSelectionInterval( n, n );
+ break;
+ }
+ }
+
+ for( int n = 0; n < estabelecimentosTable.getRowCount(); n++ )
+ {
+ if( ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( n ) ).getID().equals( ids[ 1 ] ) )
+ {
+ estabelecimentosTable.setRowSelectionInterval( n, n );
+ break;
+ }
+ }
+ }
+
+ public Object save()
+ {
+ int empresaSelected = empresasTable.getSelectedRow();
+ int estabelecimentoSelected = estabelecimentosTable.getSelectedRow();
+ return new Integer[]{
+ empresaSelected == -1 ? null : ( ( ColumnizedMappable ) empresasModel.getRowAt( empresaSelected ) ).getID(),
+ estabelecimentoSelected == -1 ? null : ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( estabelecimentoSelected ) ).getID()
+ };
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ empresasTable.setEnabled( enable );
+ estabelecimentosTable.setEnabled( enable );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacoesHigieneWindow.java b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacoesHigieneWindow.java
new file mode 100644
index 00000000..b8643956
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacoesHigieneWindow.java
@@ -0,0 +1,519 @@
+/*
+ * MarcacoesHigieneWindow.java
+ *
+ * Created on January 31, 2006, 11:32 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.higiene.marcacoes;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.text.*;
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.arrays.*;
+import com.evolute.utils.data.*;
+import com.evolute.utils.jdo.*;
+import com.evolute.utils.ui.*;
+import com.evolute.utils.ui.panel.*;
+import com.evolute.utils.ui.search.*;
+import com.evolute.utils.ui.text.*;
+import com.evolute.utils.ui.window.*;
+
+import siprp.*;
+import siprp.data.*;
+import siprp.higiene.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class MarcacoesHigieneWindow extends EditorWindow
+ implements ItemListener, ActionListener, ListSelectionListener
+{
+ public final static String TITLE = "Marca\u00e7\u00f5es de Higiene e Seguran\u00e7a";
+
+ private final static int iPermissionArray[][] =
+ new int[][]{ {}, { NEW_INDEX, EDIT_INDEX, CANCEL_INDEX, SAVE_INDEX, DELETE_INDEX } };
+
+ private static final int INDEX_MAIN = 0;
+ private static final int INDEX_VISITA = 1;
+
+ private static final DateFormat DATE_FORMAT =
+ DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "PT", "pt" ) );
+
+ protected MarcacoesHigieneUpperPanel upperPanel;
+ protected MarcacaoVisitaHSTPanel marcacaoPanel;
+ protected TableEditorPanel marcacaoEditorPanel;
+
+ protected HigieneDataProvider provider;
+ protected JDOProvider JDO;
+ protected SIPRPTracker tracker;
+
+ private Hashtable tecnicosHash;
+
+ protected Integer empresaID;
+ protected String empresa;
+ protected Integer estabelecimentoID;
+ protected EstabelecimentoData estabelecimento;
+
+ protected boolean editing = false;
+
+ /** Creates a new instance of MarcacoesHigieneWindow */
+ public MarcacoesHigieneWindow()
+ throws Exception
+ {
+ super( iPermissionArray );
+ provider = ( HigieneDataProvider ) HigieneDataProvider.getProvider();
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ tecnicosHash = new Hashtable();
+ setupComponents();
+ setExtendedState(getExtendedState() | MAXIMIZED_BOTH);
+ }
+
+ private void setupComponents()
+ throws Exception
+ {
+ setTitle( TITLE );
+ upperPanel = new MarcacoesHigieneUpperPanel();
+ JPanel panel = new JPanel();
+
+ GridBagLayout gridbag = new GridBagLayout();
+ GridBagConstraints constraints = new GridBagConstraints();
+ getContentPane().setLayout( gridbag );
+ constraints.insets = new Insets( 2, 2, 2, 2 );
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ constraints.weightx = 1;
+ constraints.gridheight = 1;
+
+ constraints.weighty = 0.2;
+ gridbag.setConstraints( upperPanel, constraints );
+
+ constraints.weighty = 0.8;
+ gridbag.setConstraints( panel, constraints );
+
+ getContentPane().add( upperPanel );
+ getContentPane().add( panel );
+
+ changeGroupName( INDEX_VISITA, "Visitas" );
+ setActionName( INDEX_VISITA, NEW_INDEX, "Nova" );
+ setActionTooltip( INDEX_VISITA, NEW_INDEX, "Nova" );
+ JPanel toolbar = getToolbarPanel( INDEX_VISITA );
+
+ gridbag = new GridBagLayout();
+// GridBagConstraints constraints = new GridBagConstraints();
+ panel.setLayout( gridbag );
+ constraints.insets = new Insets( 2, 2, 2, 2 );
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ constraints.weightx = 1.0;
+ constraints.weighty = 0;
+
+ gridbag.setConstraints( toolbar, constraints );
+ panel.add( toolbar );
+
+ constraints.gridheight = 1;
+ constraints.weighty = 1.0;
+ try
+ {
+ marcacaoEditorPanel =
+ new TableEditorPanel( new String[]{ "Data",
+ "Estado" },
+ new int[]{0,2}, new int[]{0,0},
+ 0.0, 1.0, new Dimension( 350, 100 ) );
+ marcacaoPanel = new MarcacaoVisitaHSTPanel();
+ new CopyPasteHandler( marcacaoPanel.getObservacoesText() );
+ marcacaoEditorPanel.addComponent( marcacaoPanel,
+ new int[]{0,2}, new int[]{1,2},
+ 1.0, 1.0 );
+ marcacaoEditorPanel.addListSelectionListener( new ListSelectionListener(){
+ public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent)
+ {
+ if( marcacaoEditorPanel.getID() != null )
+ {
+ reload(INDEX_VISITA);
+ select(INDEX_VISITA);
+ }
+ else
+ {
+ clear( INDEX_VISITA );
+ }
+ }
+ });
+ }catch( Exception ex )
+ {
+ DialogException.showException( ex );
+ return;
+ }
+ gridbag.setConstraints( marcacaoEditorPanel, constraints );
+ panel.add( marcacaoEditorPanel );
+ marcacaoPanel.getEmailButton().addActionListener( this );
+
+ fillCombo();
+ upperPanel.addListSelectionListener( this );
+ }
+
+ public void fillCombo()
+ throws Exception
+ {
+ marcacaoPanel.getTecnicoList().removeItemListener( this );
+ marcacaoPanel.getTecnicoList().removeAllItems();
+ tecnicosHash.clear();
+ Object tecnicos[][] = provider.getAllTecnicosHST();
+ marcacaoPanel.getTecnicoList().addItem( new MappableObject( new Integer( -2 ), " " ) );
+ for( int n = 0; n < tecnicos.length; n++ )
+ {
+ Object tecnico[] = new Object[ 4 ];
+ tecnico[ 0 ] = new Integer( ( (Number)tecnicos[n][0] ).intValue() );
+ tecnico[ 1 ] = tecnicos[ n ][ 1 ];
+ tecnico[ 2 ] = tecnicos[ n ][ 2 ];
+ tecnico[ 3 ] = new Integer( n );
+ tecnicosHash.put( tecnicos[ n ][ 0 ], tecnico );
+ marcacaoPanel.getTecnicoList().addItem( new MappableObject( (Integer) tecnico[ 0 ], tecnico[ 1 ] ) );
+ }
+ marcacaoPanel.getTecnicoList().setSelectedIndex( 0 );
+
+ marcacaoPanel.getTecnicoList().addItem( new MappableObject( new Integer( -1 ), "Novo/Editar" ) );
+ marcacaoPanel.getTecnicoList().addItemListener( this );
+ }
+
+ public void itemStateChanged(java.awt.event.ItemEvent itemEvent)
+ {
+ int index = marcacaoPanel.getTecnicoList().getSelectedIndex();
+ if( index == marcacaoPanel.getTecnicoList().getItemCount() - 1 )
+ {
+ try
+ {
+// marcacaoPanel.getTecnicoList().removeItemListener( this );
+ TecnicoEditor te = new TecnicoEditor( this );
+ te.setVisible( true );
+// boolean isNew = me.getIsNew();
+ Integer id = te.getID();
+ if( id == null )
+ {
+ marcacaoPanel.getTecnicoList().setSelectedIndex( 0 );
+ }
+ else
+ {
+ fillCombo();
+ if( id != null )
+ {
+ Object[] tecnico = (Object[])tecnicosHash.get( id );
+ marcacaoPanel.getTecnicoList().setSelectedIndex( ((Integer)tecnico[ 3 ] ).intValue() );
+ }
+ }
+
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro na janela de edi\u00e7\u00e3o...", true );
+ ex.printStackTrace();
+ marcacaoPanel.getTecnicoList().setSelectedIndex( 0 );
+ return;
+ }
+// finally
+// {
+// marcacaoPanel.getTecnicoList().addItemListener( this );
+// }
+ }
+ else
+ {
+ IDObject selected = (IDObject)marcacaoPanel.getTecnicoList().getItemAt( index );
+ Integer id = selected.getID();
+ }
+ }
+
+ public boolean save(int index)
+ {
+ switch( index )
+ {
+ case INDEX_VISITA:
+ MarcacaoEstabelecimentoData visita = ( MarcacaoEstabelecimentoData ) marcacaoPanel.save();
+ Date data = ( Date ) visita.get( MarcacaoEstabelecimentoData.DATA );
+ if( data == null )
+ {
+ JOptionPane.showMessageDialog( this, "Tem de preencher uma data para a visita.",
+ "Erro", JOptionPane.ERROR_MESSAGE );
+ return false;
+ }
+ visita.set( MarcacaoEstabelecimentoData.ESTABELECIMENTO, estabelecimento );
+ try
+ {
+ visita.set( MarcacaoEstabelecimentoData.REALIZADA,
+ ( ( Integer )visita.get( MarcacaoEstabelecimentoData.ESTADO ) ).intValue() ==
+ provider.ESTADO_REALIZADO ? "y" : "n" );
+ System.out.println( "DATA " + visita.get( MarcacaoEstabelecimentoData.DATA ) );
+ Integer tecnico = ( Integer ) visita.get( MarcacaoEstabelecimentoData.TECNICO_HST );
+ if( tecnico != null && tecnico.intValue() < 0 )
+ {
+ visita.set( MarcacaoEstabelecimentoData.TECNICO_HST, null );
+ }
+ visita.save();
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a gravar", true );
+ return false;
+ }
+
+ break;
+ }
+ reload( INDEX_MAIN );
+ editing = false;
+ return true;
+ }
+
+ public boolean delete(int index)
+ {
+ int option = JOptionPane.showConfirmDialog( this, "Tem a certeza que quer apagar a marca\u00e7\u00e3o?",
+ "Apagar", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE );
+ if( option == 0 )
+ {
+ switch( index )
+ {
+ case INDEX_VISITA:
+ MarcacaoEstabelecimentoData visita = ( MarcacaoEstabelecimentoData ) marcacaoPanel.save();
+ try
+ {
+ visita.delete();
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a apagar.", true );
+ return false;
+ }
+ break;
+ }
+ reload( INDEX_MAIN );
+ return true;
+ }
+ return false;
+ }
+
+ public void clear(int index)
+ {
+ switch( index )
+ {
+ case INDEX_MAIN:
+ empresaID = null;
+ empresa = null;
+ estabelecimentoID = null;
+ estabelecimento = null;
+ upperPanel.clear();
+ marcacaoEditorPanel.clear();
+ break;
+
+ case INDEX_VISITA:
+ marcacaoPanel.clear();
+ marcacaoPanel.getEmailButton().setText( "Enviar email" );
+ break;
+ }
+ }
+
+ public void enableComponents(int index, boolean enable)
+ {
+ switch( index )
+ {
+ case INDEX_MAIN:
+
+ break;
+
+ case INDEX_VISITA:
+ marcacaoPanel.setEnabled( enable );
+ marcacaoPanel.getEmailButton().setEnabled( enable );
+ upperPanel.setEnabled( !enable );
+ editing = enable;
+ break;
+ }
+ if( tracker != null )
+ {
+ tracker.getAvisosPanel().setEnabled( !editing,
+ AvisoConstants.TIPO_ESTABELECIMENTO );
+ }
+ }
+
+ protected void enableSelect( int index, boolean select )
+ {
+ switch( index )
+ {
+ case INDEX_VISITA:
+ marcacaoEditorPanel.setEnabled( select );
+ break;
+ }
+ }
+
+ public void reload( int index )
+ {
+ switch( index )
+ {
+ case INDEX_MAIN:
+ try
+ {
+ empresa = provider.getEmpresa( empresaID );
+ estabelecimento = ( EstabelecimentoData ) JDO.load( EstabelecimentoData.class, estabelecimentoID );
+// upperPanel.getEmpresaText().setText( empresa );
+// upperPanel.getEstabelecimentoText().setText( estabelecimento );
+// upperPanel.getTrabalhadorText().setText( ( String ) trabalhador.get( TrabalhadorData.NOME ) );
+ Object visitas[][] = provider.getVisitasEstabelecimento( estabelecimentoID );
+ if( visitas.length > 0 )
+ {
+ marcacaoEditorPanel.setData( new Object2DArray( visitas ) );
+ }
+ else
+ {
+ marcacaoEditorPanel.clear();
+ }
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar os dados.", true );
+ }
+ break;
+
+ case INDEX_VISITA:
+ Integer visitaID = marcacaoEditorPanel.getID();
+ if( visitaID == null )
+ {
+ return;
+ }
+ try
+ {
+ MarcacaoEstabelecimentoData visita =
+ ( MarcacaoEstabelecimentoData ) JDO.load( MarcacaoEstabelecimentoData.class, visitaID );
+ marcacaoPanel.fill( visita );
+ Date dataEmailVisita = ( Date ) visita.get( MarcacaoEstabelecimentoData.DATA_EMAIL );
+ if( dataEmailVisita != null )
+ {
+ marcacaoPanel.getEmailButton().setText( "Enviar email (" + DATE_FORMAT.format( dataEmailVisita ) + ")" );
+ }
+ else
+ {
+ marcacaoPanel.getEmailButton().setText( "Enviar email" );
+ }
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar os dados da visita.", true );
+ }
+ break;
+ }
+ }
+
+ public void actionPerformed( ActionEvent e )
+ {
+ Object source = e.getSource();
+ if( source.equals( marcacaoPanel.getEmailButton() ) )
+ {
+ enviarEmailVisita();
+ }
+ }
+
+ protected void enviarEmailVisita()
+ {
+ MarcacaoEstabelecimentoData visita = ( MarcacaoEstabelecimentoData ) marcacaoPanel.save();
+
+ String subject = ( String ) Singleton.getInstance( SingletonConstants.SUBJECT_VISITA );
+ String texto = ( String ) Singleton.getInstance( SingletonConstants.LETTER_VISITA );
+
+ Date today = new Date();
+ marcacaoPanel.getEmailButton().setText( "Enviar email (" + DATE_FORMAT.format( today ) + ")" );
+
+ try
+ {
+ enviarEmail( subject, texto, ( Date )visita.get( MarcacaoEstabelecimentoData.DATA ) );
+ visita.set( Marcacao.DATA_EMAIL, today );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a enviar mail", true );
+ }
+ }
+
+ protected void enviarEmail( String subject, String texto, Date data )
+ throws Exception
+ {
+ String sede = ( String )estabelecimento.get( EstabelecimentoData.NOME );
+ String dataStr = DATE_FORMAT.format( data );
+ subject = subject.replaceAll( CompanyDataLoader.NOME, sede );
+ String morada = ( String )estabelecimento.get( EstabelecimentoData.MORADA );
+
+ texto = texto.replaceAll( CompanyDataLoader.DATA, dataStr );
+ texto = texto.replaceAll( CompanyDataLoader.NOME, sede );
+ texto = texto.replaceAll( CompanyDataLoader.MORADA, morada );
+
+ ContactoData contacto = ( ContactoData )estabelecimento.get( EstabelecimentoData.CONTACTO );
+ String mail = "";
+ if( contacto != null )
+ {
+ mail = ( String )contacto.get( ContactoData.EMAIL );
+ }
+
+ if( System.getProperty( "os.name" ).startsWith( "Windows" ) )
+ {
+ mail = mail.replaceAll( " ", "%20" );
+ subject = subject.replaceAll( " ", "%20" );
+ texto = texto.replaceAll( " ", "%20" );
+ Process proc = Runtime.getRuntime().exec( "cmd.exe /c start mailto:\"" + mail
+ + "?subject=" + subject + "&body="
+
+ + texto
+ );
+ }
+ else
+ {
+ mail = mail.replaceAll( " ", "%20" );
+ subject = subject.replaceAll( " ", "%20" );
+ texto = texto.replaceAll( " ", "%20" );
+
+ Process proc = Runtime.getRuntime().exec( new String[]{ "/usr/bin/open", "/Applications/Mail.app", "mailto:" + mail
+ + "?subject=" + subject + "&body="
+ + texto } );
+ }
+ }
+
+ public void valueChanged( ListSelectionEvent e )
+ {
+ Object source = e.getSource();
+ if( source.equals( upperPanel ) )
+ {
+ Integer ids[] = ( Integer [] ) upperPanel.save();
+ empresaID = ids[ 0 ];
+ estabelecimentoID = ids[ 1 ];
+ if( ids[ 1 ] == null )
+ {
+ clear( INDEX_MAIN );
+ unselect( INDEX_MAIN );
+ }
+ else
+ {
+ reload( INDEX_MAIN );
+ select( INDEX_MAIN );
+ }
+ }
+ }
+
+ public void setEmpresaAndEstabelecimento( Integer empresaID, Integer estabelecimentoID )
+ {
+ if( editing )
+ {
+ JOptionPane.showMessageDialog( this, "Esta janela est\u00e1 em edi\u00e7\u00e3o.", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ else
+ {
+ upperPanel.fill( new Integer[]{ empresaID, estabelecimentoID } );
+ }
+ }
+
+ public void setTracker( SIPRPTracker tracker )
+ {
+ this.tracker = tracker;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/TecnicoEditor.java b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/TecnicoEditor.java
new file mode 100644
index 00000000..007c119d
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/TecnicoEditor.java
@@ -0,0 +1,317 @@
+/*
+ * TecnicoEditor.java
+ *
+ * Created on February 1, 2006, 10:55 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.higiene.marcacoes;
+
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.jdo.*;
+import com.evolute.utils.tables.*;
+import com.evolute.utils.ui.*;
+import com.evolute.utils.ui.button.*;
+import com.evolute.utils.ui.text.*;
+
+import siprp.*;
+import siprp.data.*;
+import siprp.higiene.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class TecnicoEditor extends CustomJDialog
+ implements ActionListener, ListSelectionListener
+// , ItemListener
+{
+ static
+ {
+ TecnicoHSTData.registerOperationHandlerForClass( DisableDeleteHandler.INSTANCE, TecnicoHSTData.class );
+ }
+
+ private JDOProvider JDO;
+ private HigieneDataProvider provider;
+ private BaseTable table;
+ private VectorTableModel model;
+ private JButton okButton;
+ private JButton cancelarButton;
+ private JButton novoButton;
+ private JTextField nomeText;
+ private JTextField iniciaisText;
+// private JComboBox corCombo;
+ private Integer id;
+ private boolean isNew = false;
+ private BetterButtonGroup corGroup;
+ private JRadioButton cores[];
+
+ /** Creates a new instance of MedicoEditor */
+ public TecnicoEditor( JFrame owner )
+ throws Exception
+ {
+ super( owner, true );
+ provider = (HigieneDataProvider)HigieneDataProvider.getProvider();
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ setupComponents();
+ }
+
+ private void setupComponents()
+ throws Exception
+ {
+ setSize( 600, 300 );
+ setResizable( false );
+ setTitle( "Criar/Editar T\u00e9cnico" );
+ centerSuper();
+
+ model = new VectorTableModel( new String[]{ "Nome", "Iniciais", "Cor" } );
+ table = new BaseTable( model );
+ table.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ table.setTableCellRenderer( new TecnicoRenderer() );
+ JScrollPane scp = new JScrollPane();
+ scp.setMinimumSize( new Dimension( 300, 200 ) );
+ scp.setMaximumSize( new Dimension( 300, 200 ) );
+ scp.setPreferredSize( new Dimension( 300, 200 ) );
+ scp.setSize( new Dimension( 300, 200 ) );
+ scp.setViewportView( table );
+ scp.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ scp.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
+ table.fixColumnWidth( 0, 200 );
+ table.setNonResizableNorReordable();
+ table.getSelectionModel().addListSelectionListener( this );
+ Object obj[][] = provider.getAllTecnicosHST();
+ Vector tecnicosHST = new Vector();
+ for( int n = 0; n < obj.length; n++ )
+ {
+ tecnicosHST.add( new ColumnizedObjectArray( obj[ n ], true ) );
+ }
+ model.setValues( tecnicosHST );
+
+ okButton = new JButton( "OK" );
+ cancelarButton = new JButton( "Cancelar" );
+ novoButton = new JButton( "Novo" );
+ okButton.addActionListener( this );
+ cancelarButton.addActionListener( this );
+ novoButton.addActionListener( this );
+
+ nomeText = new JTextField();
+ nomeText.setEnabled( false );
+ iniciaisText = new JTextField();
+ iniciaisText.setEnabled( false );
+ JPanel corPanel = new JPanel();
+ corPanel.setLayout( new BoxLayout( corPanel, BoxLayout.Y_AXIS ) );
+// corCombo = new JComboBox();
+ corGroup = new BetterButtonGroup( false );
+ cores = new JRadioButton[ HigieneDataProvider.CORES_TECNICOS.length ];
+ for( int n = 0; n < HigieneDataProvider.CORES_TECNICOS.length; n++ )
+ {
+ cores[ n ] = new JRadioButton( " " );
+ cores[ n ].setBackground( HigieneDataProvider.CORES_TECNICOS[ n ] );
+ corPanel.add( cores[ n ] );
+ corGroup.add( cores[ n ] );
+// corCombo.addItem( new Integer( n ) );
+ }
+ JScrollPane corScroll =
+ new JScrollPane( corPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+// corCombo.setRenderer( new CorTecnicoCellRenderer() );
+// corCombo.setEnabled( false );
+
+ GridBagLayout gridbag = new GridBagLayout();
+ getContentPane().setLayout( gridbag );
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.insets = new Insets( 1, 1, 1, 1 );
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.weighty = 1;
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ constraints.gridheight = 1;
+
+ JPanel upperPanel = new JPanel();
+ upperPanel.setLayout( new GridLayout( 1, 2 ) );
+ upperPanel.add( scp );
+ JPanel textPanel = new JPanel();
+ upperPanel.add( textPanel );
+ gridbag.setConstraints( upperPanel, constraints );
+ getContentPane().add( upperPanel );
+
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ constraints.weighty = 0;
+ constraints.weightx = 0.3;
+ constraints.gridwidth = 1;
+ constraints.gridheight = GridBagConstraints.REMAINDER;;
+
+ gridbag.setConstraints( novoButton, constraints );
+ getContentPane().add( novoButton );
+
+ gridbag.setConstraints( okButton, constraints );
+ getContentPane().add( okButton );
+
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( cancelarButton, constraints );
+ getContentPane().add( cancelarButton );
+
+ gridbag = new GridBagLayout();
+ textPanel.setLayout( gridbag );
+ constraints.weighty = 0;
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ constraints.gridheight = 1;
+
+ JLabel nomeLabel = new JLabel( "Nome" );
+ gridbag.setConstraints( nomeLabel, constraints );
+ textPanel.add( nomeLabel );
+
+ gridbag.setConstraints( nomeText, constraints );
+ textPanel.add( nomeText );
+
+ JLabel iniciaisLabel = new JLabel( "Iniciais" );
+ gridbag.setConstraints( iniciaisLabel, constraints );
+ textPanel.add( iniciaisLabel );
+
+ gridbag.setConstraints( iniciaisText, constraints );
+ textPanel.add( iniciaisText );
+
+ JLabel corLabel = new JLabel( "Cor" );
+ gridbag.setConstraints( corLabel, constraints );
+ textPanel.add( corLabel );
+
+// gridbag.setConstraints( corCombo, constraints );
+// textPanel.add( corCombo );
+//
+ constraints.weighty = 1;
+ constraints.gridheight = GridBagConstraints.REMAINDER;
+ constraints.fill = GridBagConstraints.BOTH;
+// JPanel pad = new JPanel();
+// gridbag.setConstraints( pad, constraints );
+// textPanel.add( pad );
+ gridbag.setConstraints( corScroll, constraints );
+ textPanel.add( corScroll );
+
+ new CopyPasteHandler( nomeText );
+ new CopyPasteHandler( iniciaisText );
+// corCombo.addItemListener( this );
+ }
+
+ public void actionPerformed( ActionEvent e )
+ {
+ if( e.getSource().equals( okButton ) )
+ {
+ if( save() )
+ {
+ close();
+ }
+ }
+ else if( e.getSource().equals( cancelarButton ) )
+ {
+ close();
+ }
+ if( e.getSource().equals( novoButton ) )
+ {
+ table.getSelectionModel().removeListSelectionListener( this );
+ nomeText.setText( "" );
+ iniciaisText.setText( "" );
+// corCombo.setSelectedIndex( 0 );
+ corGroup.setIntSelected( 0 );
+ nomeText.setEnabled( true );
+ iniciaisText.setEnabled( true );
+ corGroup.setEnabled( true );
+ id = null;
+ isNew = true;
+ }
+ }
+
+ public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent)
+ {
+ int selected = table.getSelectedRow();
+ if( selected == -1 )
+ {
+ return;
+ }
+ ColumnizedObjectArray row = (ColumnizedObjectArray)model.getRowAt( selected );
+ id = row.getID();
+ String nome = (String) row.getValue( 0 );
+ String iniciais = (String) row.getValue( 1 );
+ Integer cor = ( Integer ) row.getValue( 2 );
+ nomeText.setText( nome );
+ iniciaisText.setText( iniciais );
+// corCombo.setSelectedIndex( cor.intValue() );
+ corGroup.setIntSelected( cor.intValue() );
+ nomeText.setEnabled( true );
+ iniciaisText.setEnabled( true );
+// corCombo.setEnabled( true );
+ corGroup.setEnabled( true );
+ }
+
+ private void close()
+ {
+ setVisible( false );
+ dispose();
+ }
+
+ public boolean getIsNew()
+ {
+ return isNew;
+ }
+
+ public Integer getID()
+ {
+ return id;
+ }
+
+ private boolean save()
+ {
+ String nome = nomeText.getText().trim();
+ String nomePlain = com.evolute.utils.strings.StringPlainer.convertString( nome );
+ String iniciais = iniciaisText.getText().trim();
+ Integer cor = new Integer( corGroup.getIntSelected() );
+ if( nome.length() == 0 || iniciais.length() == 0 )
+ {
+ JOptionPane.showMessageDialog( this, "O Nome e as iniciais n\u00e3o podem ser vazios.", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ return false;
+ }
+ try
+ {
+ TecnicoHSTData tecnico;
+ if( id != null )
+ {
+ tecnico = ( TecnicoHSTData ) JDO.load( TecnicoHSTData.class, id );
+ }
+ else
+ {
+ tecnico = new TecnicoHSTData();
+ }
+ tecnico.set( TecnicoHSTData.NOME, nome );
+ tecnico.set( TecnicoHSTData.NOME_PLAIN, nomePlain );
+ tecnico.set( TecnicoHSTData.INICIAIS, iniciais );
+ tecnico.set( TecnicoHSTData.IDENTIFICADOR, cor );
+ tecnico.save();
+ if( id == null )
+ {
+ id = (Integer)tecnico.get( TecnicoHSTData.ID );
+ }
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a gravar...", false );
+ return false;
+ }
+
+ return true;
+ }
+
+// public void itemStateChanged( ItemEvent e )
+// {
+// corCombo.getEditor().getEditorComponent().setBackground( HigieneDataProvider.CORES_TECNICOS[ corCombo.getSelectedIndex() ] );
+// }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/TecnicoRenderer.java b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/TecnicoRenderer.java
new file mode 100644
index 00000000..7ad36ac8
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/TecnicoRenderer.java
@@ -0,0 +1,58 @@
+/*
+ * DiaRenderer.java
+ *
+ * Created on 8 de Fevereiro de 2006, 21:45
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.higiene.marcacoes;
+
+import java.awt.*;
+import javax.swing.*;
+import javax.swing.table.*;
+
+import siprp.higiene.*;
+
+/**
+ *
+ * @author Frederico
+ */
+public class TecnicoRenderer
+ implements TableCellRenderer
+{
+ protected JLabel labels[];
+ protected Color defaultColor;
+
+ /** Creates a new instance of DiaRenderer */
+ public TecnicoRenderer()
+ {
+ labels = new JLabel[ 3 ];
+ for( int n = 0; n < 3; n++ )
+ {
+ labels[ n ] = new JLabel();
+ }
+ defaultColor = labels[ 0 ].getBackground();
+ labels[ 2 ].setOpaque( true );
+ }
+
+ public Component getTableCellRendererComponent( JTable table, Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row, int column )
+ {
+ switch( column )
+ {
+ case 2:
+ labels[ 2 ].setText( " " );
+ labels[ 2 ].setBackground( value == null ? defaultColor :
+ HigieneDataProvider.CORES_TECNICOS[ ( ( Integer ) value ).intValue() ] );
+ break;
+ default:
+ labels[ column ].setText( ( String ) value );
+ break;
+ }
+ return labels[ column ];
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/importer/DataChooserWindow.java b/trunk/SIPRPSoft/src/siprp/importer/DataChooserWindow.java
new file mode 100644
index 00000000..a341e0b5
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/importer/DataChooserWindow.java
@@ -0,0 +1,190 @@
+/*
+ * DataChooserWindow.java
+ *
+ * Created on 29 de Abril de 2004, 16:53
+ */
+
+package siprp.importer;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+import javax.swing.*;
+
+import com.evolute.utils.ui.*;
+/**
+ *
+ * @author lflores
+ */
+public class DataChooserWindow extends CustomJDialog
+{
+ private final String labels[];
+ private final Object items[];
+ private final Object empty[];
+ private final Object allItems[][];
+ private final JComboBox combos[];
+ private final int preselected[];
+
+ private boolean canceled = false;
+
+ /** Creates a new instance of DataChooserWindow */
+ public DataChooserWindow( JFrame modalFrame, String names[], Object data[][] )
+ {
+ this( modalFrame, names, data, null );
+ }
+
+ public DataChooserWindow( JFrame modalFrame, String names[], Object data[][], int selected[] )
+ {
+ super( modalFrame, true );
+ labels = names;
+ items = data[ 0 ];
+ empty = new String[ items.length ];
+ for( int i = 0; i < empty.length; ++i )
+ {
+ empty[ i ] = "";
+ }
+ allItems = data;
+ combos = new JComboBox[ labels.length ];
+ preselected = selected;
+ setupComponents();
+ if( modalFrame == null )
+ {
+ center();
+ }
+ else
+ {
+ centerSuper();
+ }
+ setVisible( true );
+ }
+
+ private void setupComponents()
+ {
+ setTitle( "Escolha os campos correspondentes:" );
+ setSize(450, 120 + 25 * labels.length );
+ GridBagLayout gbl = new GridBagLayout();
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.insets = new Insets( 2, 2, 2, 2 );
+ gbc.fill = GridBagConstraints.HORIZONTAL;
+ Container cont = getContentPane();
+ cont.setLayout( gbl );
+ for( int i = 0; i < labels.length; ++i )
+ {
+ gbc.weightx = 0;
+ gbc.gridwidth = 1;
+ JLabel label = new JLabel( labels[ i ] );
+ gbl.setConstraints( label, gbc );
+ cont.add( label );
+/* gbc.weightx = 1;
+ JPanel pad = new JPanel();
+ gbl.setConstraints( pad, gbc );
+ cont.add( pad );
+*/ gbc.weightx = 1;
+ gbc.gridwidth = GridBagConstraints.REMAINDER;
+ JComboBox combo = new JComboBox( items );
+ int index;
+ if( preselected == null )
+ {
+ index = Math.min( i, items.length - 1 );
+ }
+ else
+ {
+ if( i < preselected.length )
+ {
+ index = Math.min( preselected[ i ], items.length - 1 );
+ if( index == -1 )
+ {
+ index = items.length - 1;
+ }
+ }
+ else
+ {
+ index = items.length - 1;
+ }
+
+ }
+ combo.setSelectedIndex( index );
+ combos[ i ] = combo;
+ gbl.setConstraints( combo, gbc );
+ cont.add( combo );
+ }
+ gbc.insets = new Insets( 10, 2, 2, 2 );
+ gbc.weightx = 1;
+ gbc.gridwidth = 2;
+ JPanel pad = new JPanel();
+ gbl.setConstraints( pad, gbc );
+ cont.add( pad );
+ gbc.weightx = 0;
+ gbc.gridwidth = 1;
+ JButton butOK = new JButton( "OK" );
+ gbl.setConstraints( butOK, gbc );
+ cont.add( butOK );
+ gbc.weightx = 0;
+ gbc.gridwidth = GridBagConstraints.REMAINDER;
+ JButton butCancel = new JButton( "Cancelar" );
+ gbl.setConstraints( butCancel, gbc );
+ cont.add( butCancel );
+ butOK.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e )
+ {
+ setVisible( false );
+ dispose();
+ }
+ });
+ butCancel.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e )
+ {
+ setVisible( false );
+ dispose();
+ canceled = true;
+ }
+ });
+ }
+
+ public Hashtable getData()
+ {
+ if( canceled )
+ {
+ return null;
+ }
+ Hashtable hash = new Hashtable();
+ for( int i = 0; i < labels.length; ++i )
+ {
+ hash.put( labels[ i ], combos[ i ].getSelectedItem() );
+ }
+ return hash;
+ }
+
+ public Hashtable[] getMultipleData()
+ {
+ if( canceled )
+ {
+ return null;
+ }
+ Hashtable hash[] = new Hashtable[ allItems.length ];
+//System.out.println( "Hash[] size: " + hash.length );
+ for( int j = 0; j < hash.length; ++j )
+ {
+ hash[ j ] = new Hashtable();
+ }
+ for( int i = 0; i < labels.length; ++i )
+ {
+ String sel = combos[ i ].getSelectedItem().toString();
+ if( sel.length() > 0 )
+ {
+ for( int j = 0; j < allItems.length; ++j )
+ {
+ hash[ j ].put( labels[ i ], allItems[ j ][ combos[ i ].getSelectedIndex() ] );
+ }
+ }
+ }
+ return hash;
+ }
+
+/* public static void main( String arg[] )
+ {
+ String names[] = new String[] { "Nome:", "Morada:", "Telefone:" };
+ String data[] = new String[] { "Joao Catita", "Damaiasdg sdfg sdf gsdfs hgf h", "nao tem", "so a noite", "" };
+ DataChooserWindow dcw = new DataChooserWindow( null, names, data, new int[] { 3, 2 ,1 } );
+ }*/
+}
diff --git a/trunk/SIPRPSoft/src/siprp/importer/Importer.java b/trunk/SIPRPSoft/src/siprp/importer/Importer.java
new file mode 100644
index 00000000..c9b7efdb
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/importer/Importer.java
@@ -0,0 +1,363 @@
+/*
+ * Importer.java
+ *
+ * Created on 7 de Abril de 2004, 10:56
+ */
+
+package siprp.importer;
+
+import com.evolute.utils.*;
+import com.evolute.utils.arrays.*;
+import com.evolute.utils.tables.*;
+import com.evolute.utils.ui.*;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.io.*;
+import java.util.*;
+import javax.swing.*;
+import javax.swing.table.*;
+
+import jxl.*;
+
+import siprp.*;
+
+/**
+ *
+ * @author psantos
+ */
+public class Importer extends CustomJDialog
+{
+ public static final int TYPE_ADMISSAO = 0;
+ public static final int TYPE_DEMISSAO = 1;
+
+ public static final String DATA_PREFIX = "Data ";
+
+ public static final String NOME = "Nome do Funcion\u00e1rio";
+ public static final String SEXO = "Sexo";
+ public static final String NACIONALIDADE = "Nacionalidade";
+ public static final String DATA_NASCIMENTO = DATA_PREFIX + "Nascimento";
+ public static final String NUMERO_MECANOGRAFICO = "N\u00famero Mecanogr\u00e1fico";
+ public static final String DATA_ADMISSAO = DATA_PREFIX + "Admiss\u00e3o";
+ public static final String CATEGORIA = "Categoria";
+ public static final String LOCAL_TRABALHO = "Local Trabalho";
+ public static final String FUNCAO = "Fun\u00e7\u00e3o";
+ public static final String DATA_ADMISSAO_FUNCAO = DATA_PREFIX + "Admiss\u00e3o na Fun\u00e7\u00e3o";
+ public static final String DATA_DEMISSAO = DATA_PREFIX + "Demiss\u00e3o";
+
+ private JPanel panel;
+ private BaseTable table;
+ private Excel2DArray e2da;
+ private boolean canceled = false;
+ private DataChooserWindow dcw;
+ private Object vals[][];
+ private int[] DEFAULT_SELECTION = new int[]{ 0, 2, 3, 1, -1, 4, 5, 7, 6, -1 };
+ private int[] DEFAULT_SELECTION_DEMISSAO = new int[]{ 0, 1 };
+
+ public static final String NAMES[] = new String[]{
+ NOME,
+ SEXO,
+ NACIONALIDADE,
+ DATA_NASCIMENTO,
+ NUMERO_MECANOGRAFICO,
+ DATA_ADMISSAO,
+ CATEGORIA,
+ LOCAL_TRABALHO,
+ FUNCAO,
+ DATA_ADMISSAO_FUNCAO
+ };
+
+ public static final String NAMES_DEMISSAO[] = new String[]{
+ NOME,
+ DATA_DEMISSAO
+ };
+ private final boolean multipleSelection;
+ protected final int type;
+
+ /** Creates a new instance of Importer */
+ public Importer( JFrame modalFrame, String filename, boolean multiple, int type )
+ throws Exception
+ {
+ super( modalFrame, true );
+ multipleSelection = multiple;
+ this.type = type;
+
+ int []selection = ( int [] ) Singleton.getInstance( SingletonConstants.EXCEL_FORMAT );
+ if( selection != null )
+ {
+ DEFAULT_SELECTION = selection;
+ }
+ int []selectionDemissao = ( int [] ) Singleton.getInstance( SingletonConstants.EXCEL_FORMAT_DEMISSAO );
+ if( selectionDemissao != null )
+ {
+ DEFAULT_SELECTION_DEMISSAO = selectionDemissao;
+ }
+ setupComponents( filename );
+ if( modalFrame == null )
+ {
+ center();
+ }
+ else
+ {
+ centerSuper();
+ }
+ setVisible( true );
+ }
+
+ private void setupComponents( String filename )
+ {
+ setSize( 800, 500 );
+
+ GridBagLayout gblGridBag = new GridBagLayout();
+ GridBagConstraints gbcConstraints = new GridBagConstraints();
+
+ panel = ( JPanel ) getContentPane();
+
+ panel.setLayout( gblGridBag );
+
+ e2da = new Excel2DArray( filename );
+
+ String colNames[] = new String[ e2da.rowLength() ];
+ for( int i = 0; i < colNames.length; i++ )
+ {
+ colNames[ i ] = " ";
+ }
+ Virtual2DTableModel tm = new Virtual2DTableModel( colNames, null );
+ tm.setValues( e2da );
+ table = new BaseTable( tm );
+ int col = 0;
+ switch( type )
+ {
+ case TYPE_ADMISSAO:
+ col = DEFAULT_SELECTION[ 0 ];
+ break;
+
+ case TYPE_DEMISSAO:
+ col = DEFAULT_SELECTION_DEMISSAO[ 0 ];
+ break;
+ }
+ table.getColumn( col ).setWidth( 200 );
+ if( !multipleSelection )
+ {
+ table.getSelectionModel().setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ }
+ else
+ {
+ table.getSelectionModel().setSelectionMode( ListSelectionModel.SINGLE_INTERVAL_SELECTION );
+ }
+ table.getTableHeader().setResizingAllowed( true );
+ table.getTableHeader().setReorderingAllowed( false );
+ // table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
+
+ for( int i = 0; i < e2da.rowLength(); i++ )
+ {
+ table.getColumn( i ).setMinWidth( 50 );
+ //table.getColumn( i ).setResizable( true );
+ }
+
+ JScrollPane sp = new JScrollPane( table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
+
+ gbcConstraints.anchor = GridBagConstraints.CENTER;
+ gbcConstraints.fill = GridBagConstraints.BOTH;
+ gbcConstraints.insets = new Insets(5, 5, 5, 5);
+ gbcConstraints.gridwidth = 3;
+ gbcConstraints.gridheight = 3;
+ gbcConstraints.weighty = 3;
+ gbcConstraints.gridx = 0;
+ gbcConstraints.gridy = 3;
+ gblGridBag.setConstraints( sp, gbcConstraints );
+
+ panel.add( sp );
+
+ JPanel jpButtons = new JPanel();
+ final JButton jbOK = new JButton( "Escolher" );
+ jbOK.setEnabled( false );
+ jpButtons.add( jbOK );
+ JButton jbCancel = new JButton( "Cancelar" );
+ jpButtons.add( jbCancel );
+
+ gbcConstraints.gridheight = 1;
+ gbcConstraints.weightx = 1;
+ gbcConstraints.weighty = 0;
+ gbcConstraints.anchor = GridBagConstraints.SOUTH;
+ gbcConstraints.fill = GridBagConstraints.BOTH;
+ gbcConstraints.insets = new Insets( 2, 2, 2, 2 );
+ gbcConstraints.gridwidth = 3;
+ gbcConstraints.gridx = 0;
+ gbcConstraints.gridy = 6;
+ gblGridBag.setConstraints( jpButtons, gbcConstraints );
+ panel.add( jpButtons );
+
+ table.addMouseListener( new MouseAdapter() {
+ public void mouseClicked( MouseEvent e ) {
+ jbOK.setEnabled( true );
+ if( e.getButton() == MouseEvent.BUTTON1
+ && e.getClickCount() == 2
+ && table.columnAtPoint( e.getPoint() ) != -1
+ && table.rowAtPoint( e.getPoint() ) != -1 )
+ {
+ acceptResult();
+ }
+ }
+ public void mousePressed( MouseEvent e ) {
+ jbOK.setEnabled( true );
+ }
+ });
+
+ jbOK.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent a ) {
+ acceptResult();
+ }
+ });
+
+ jbCancel.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent a ) {
+ setVisible( false );
+ dispose();
+ canceled = true;
+ }
+ });
+
+ }
+
+ private void acceptResult()
+ {
+ if( multipleSelection )
+ {
+ int rows[] = table.getSelectedRows();
+ vals = new Object[ rows.length ][];
+ for( int i = 0; i < rows.length; ++i )
+ {
+ Vector v = new Vector( Arrays.asList( e2da.getRow( rows[ i ] ) ) );
+ v.add( "" );
+ vals[ i ] = (Object[]) v.toArray( new Object[ v.size() ] );
+ }
+ }
+ else
+ {
+ Vector v = new Vector( Arrays.asList( e2da.getRow( table.getSelectedRow() ) ) );
+ v.add( "" );
+ vals = new Object[][] { ( Object[] )v.toArray( new Object[ v.size() ] ) };
+ }
+
+/*
+ System.out.println( "row: " + table.getSelectedRow() );
+ System.out.print( "vals: " );
+ for( int i = 0; i < vals.length; i++ )
+ {
+ System.out.print( "[" + vals[ i ] + "]" );
+ }
+ System.out.println();
+*/
+ setVisible( false );
+ dispose();
+
+ }
+
+ public Hashtable getData()
+ {
+ if( NAMES == null || vals == null )
+ {
+ return null;
+ }
+ dcw = new DataChooserWindow( null, NAMES, vals, DEFAULT_SELECTION );
+
+ if( canceled || ( dcw == null ) )
+ {
+ return null;
+ }
+
+ return dcw.getData();
+ }
+
+ public Hashtable[] getMultipleData()
+ {
+ switch( type )
+ {
+ case TYPE_ADMISSAO:
+ if( NAMES == null || vals == null )
+ {
+ return null;
+ }
+ dcw = new DataChooserWindow( null, NAMES, vals, DEFAULT_SELECTION );
+ break;
+
+ case TYPE_DEMISSAO:
+ if( NAMES_DEMISSAO == null || vals == null )
+ {
+ return null;
+ }
+ dcw = new DataChooserWindow( null, NAMES_DEMISSAO, vals, DEFAULT_SELECTION_DEMISSAO );
+ break;
+ }
+
+ if( canceled || ( dcw == null ) )
+ {
+ return null;
+ }
+
+ return dcw.getMultipleData();
+ }
+
+
+ public static void main( String args[] )
+ {
+// FileDialog fd = new FileDialog( null, "Escolha um ficheiro Excel:", FileDialog.LOAD );
+// fd.setDirectory( System.getProperty( "user.home" ) );
+// fd.setFilenameFilter( new FilenameFilter() {
+// public boolean accept( File dir, String name )
+// {
+// return (name!=null) && (name.indexOf( ".xls" ) != -1);
+// }
+// } );
+// fd.show();
+ String filename = "c:\\teste_com_dados.xls";
+ //String filename = fd.getFile();
+ if( filename != null )
+ {
+ //filename = fd.getDirectory() + File.separator + filename;
+ try
+ {
+ Importer importer = new Importer( null, filename, true, TYPE_ADMISSAO );
+ Hashtable hash = importer.getData();
+ if( hash != null )
+ {
+ System.out.println( "Data: " + hash );
+ }
+ }
+ catch( Exception ex )
+ {
+ ex.printStackTrace();
+ JOptionPane.showMessageDialog( null, "Erro a importar", "Erro...", JOptionPane.ERROR_MESSAGE );
+ }
+ }
+// Importer im = null;
+// try
+// {
+// im = new Importer( null,
+// "E:\\test.xls"
+// "C:\\Documents and Settings\\psantos\\My Documents\\Devel\\teste.xls"
+// "C:\\Documents and Settings\\psantos\\My Documents\\Devel\\Docs\\jexcelapi\\jxlrwtest.xls"
+// );
+//
+//System.out.println( "Escolhido: " + im.getData() );
+//
+// }
+// catch( Exception e )
+// {
+// e.printStackTrace();
+// }
+
+// String[][] all = (String[][]) e.getObjects();
+//
+// for( int j = 0; j < e.rowLength(); j++ )
+// {
+// String[] r = e.getRow( j );
+// for( int i = 0; i < r.length; i++ )
+// {
+// System.out.print( "[" + r[ i ] + "]" );
+// }
+// System.out.println();
+// }
+ }
+}
\ No newline at end of file
diff --git a/trunk/SIPRPSoft/src/siprp/impressaofichas/FichasPrinter.java b/trunk/SIPRPSoft/src/siprp/impressaofichas/FichasPrinter.java
new file mode 100644
index 00000000..1b21e717
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/impressaofichas/FichasPrinter.java
@@ -0,0 +1,146 @@
+/*
+ * FichasPrinter.java
+ *
+ * Created on 20 de Fevereiro de 2006, 0:43
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.impressaofichas;
+
+import java.io.*;
+import java.text.*;
+import java.util.*;
+import javax.xml.transform.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.date.*;
+import com.evolute.utils.fop.*;
+import com.evolute.utils.jdo.*;
+import com.evolute.utils.strings.*;
+import com.evolute.utils.ui.*;
+import com.evolute.utils.xml.*;
+
+import siprp.data.*;
+import siprp.ficha.*;
+
+/**
+ *
+ * @author Frederico
+ */
+public class FichasPrinter extends Thread
+{
+ protected static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
+ protected static final DateFormat D_F_L = DateFormat.getDateInstance( DateFormat.LONG, new Locale( "pt", "PT" ) );
+
+ private ImpressaoFichasDataProvider provider;
+
+ protected Integer ids[];
+ protected String printerName;
+ protected String listPath;
+ protected String nomeEmpresa;
+ protected String nomeEstabelecimento;
+
+ /** Creates a new instance of FichasPrinter */
+ public FichasPrinter( Integer ids[], String printerName, String listPath,
+ String nomeEmpresa, String nomeEstabelecimento )
+ {
+ this.ids = ids;
+ this.printerName = printerName;
+ this.listPath = listPath;
+ this.nomeEmpresa = nomeEmpresa;
+ this.nomeEstabelecimento = nomeEstabelecimento;
+ }
+
+ public void run()
+ {
+ try
+ {
+ SimpleXMLElement root = new SimpleXMLElement( "LISTA_FICHAS" );
+ for( int n = 0; n < ids.length; n++ )
+ {
+ print( ids[ n ] );
+ Object dados[] = provider.getDadosForExameID( ids[ n ] );
+ SimpleXMLElement linha = new SimpleXMLElement( "FICHA" );
+ linha.addElement( new SimpleXMLElement( "NOME", ( String ) dados[ 0 ] ) );
+ linha.addElement( new SimpleXMLElement( "DATA_EXAME", D_F.format( ( Date ) dados[ 1 ] ) ) );
+ linha.addElement( new SimpleXMLElement( "DATA_PROXIMO_EXAME", dados[ 2 ] != null ? D_F.format( ( Date ) dados[ 2 ] ) : "n/d" ) );
+ root.addElement( linha );
+
+ try
+ {
+ sleep( (n % 5 == 0 && n > 0) ? 3000 : 2000 );
+ }
+ catch( InterruptedException iex )
+ {
+ }
+ }
+ Date today = ( Date ) Singleton.getInstance( Singleton.TODAY );
+ Calendar cal = Calendar.getInstance();
+ cal.setTime( today );
+ SimpleXMLElement data = new SimpleXMLElement( "DATA_EXTENSO", DateUtils.WEEKDAYS_FULL_PT[ cal.get( Calendar.DAY_OF_WEEK ) - Calendar.MONDAY ]
+ + ", " + D_F_L.format( today ) );
+ root.addElement( data );
+ TransformerFactory tFactory = TransformerFactory.newInstance();
+ String xml = root.toString();
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ FOPCreator creator = FOPCreator.getFOPCreator();
+ InputStream xmlIn = new ByteArrayInputStream( xml.getBytes() );
+ creator.createFOfromXML( xmlIn,
+ FichasPrinter.class.getClassLoader().getResourceAsStream(
+ "siprp/impressaofichas/lista_fichas.xsl" ),
+ out );
+ byte toPrint[] = out.toByteArray();
+ ByteArrayInputStream in = new ByteArrayInputStream( toPrint );
+ Hashtable printOptions = new Hashtable();
+//System.out.println( "OUT: " + out.toString() );
+ FOPPrinter.getFOPPrinter().printFO( in, false, true, printOptions );
+ byte []pdfData = PDFCreator.getPDFCreator().createPdfFromFo( toPrint );
+ File dir = new File( new File( listPath ), StringPlainer.convertString( nomeEmpresa ).replace( ' ', '_' ) );
+ if( !dir.exists() )
+ {
+ dir.mkdir();
+ }
+ String fileName = StringPlainer.convertString( nomeEstabelecimento ).replace( ' ', '_' )
+ + "_" + DateUtils.plainFormatDate( today ) + ".pdf";
+ FileOutputStream fos = new FileOutputStream( new File( dir, fileName ) );
+ fos.write( pdfData );
+ fos.close();
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a imprimir", true );
+ }
+ ids = null;
+ }
+
+ private void print( Integer exameID )
+ throws Exception
+ {
+ if( provider == null )
+ {
+ provider = ( ImpressaoFichasDataProvider ) ImpressaoFichasDataProvider.getProvider();
+ }
+// MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) );
+// ExameData exame = (ExameData) JDO.load( ExameData.class, exameID );
+// byte pdf[] = (byte []) exame.get( ExameData.PDF );
+ byte pdf[] = provider.getPDF( exameID );
+ if( pdf == null )
+ {
+ throw new Exception( "N\u00e3o existe exame" );
+ }
+// TrabalhadorData trabalhadorExame = ( TrabalhadorData ) exame.get( ExameData.TRABALHADOR );
+// String nomeFicheiro = StringPlainer.convertString( ( String ) trabalhadorExame.get( TrabalhadorData.NOME ) );
+ String nomeFicheiro = StringPlainer.convertString( provider.getNomeTrabalhadorForExameID( exameID ) );
+// nomeFicheiro.replaceAll( " ", "_" );
+ String split[] = nomeFicheiro.split( " " );
+ nomeFicheiro = "";
+ for( int n = 0; n < split.length; n++ )
+ {
+ nomeFicheiro += split[ n ] + "_";
+ }
+ ExamePDF ePDF = new ExamePDF();
+ ePDF.printSilent( pdf, nomeFicheiro, printerName );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/impressaofichas/ImpressaoFichasDataProvider.java b/trunk/SIPRPSoft/src/siprp/impressaofichas/ImpressaoFichasDataProvider.java
new file mode 100644
index 00000000..11e0910d
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/impressaofichas/ImpressaoFichasDataProvider.java
@@ -0,0 +1,217 @@
+/*
+ * HigieneDataProvider.java
+ *
+ * Created on February 1, 2006, 10:49 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.impressaofichas;
+
+import java.text.*;
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.arrays.*;
+import com.evolute.utils.data.*;
+import com.evolute.utils.db.*;
+import com.evolute.utils.metadb.*;
+import com.evolute.utils.sql.*;
+import com.evolute.utils.strings.*;
+import com.evolute.utils.tables.*;
+
+import siprp.*;
+import siprp.data.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class ImpressaoFichasDataProvider extends MetaProvider
+{
+ private static final DateFormat DATE_FORMAT =
+ DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "PT", "pt" ) );
+
+ private static final Object LOCK = new Object();
+ private static ImpressaoFichasDataProvider instance = null;
+ private final Executer executer;
+
+ /** Creates a new instance of HigieneDataProvider */
+ public ImpressaoFichasDataProvider()
+ throws Exception
+ {
+ DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ );
+ executer = dbm.getSharedExecuter( this );
+ }
+
+ public static MetaProvider getProvider()
+ throws Exception
+ {
+ synchronized( LOCK )
+ {
+ if( instance == null )
+ {
+ instance = new ImpressaoFichasDataProvider();
+ }
+ }
+ return instance;
+ }
+
+ public ColumnizedMappable[] getAllEmpresas()
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "empresas" },
+ new String[]{ "id", "designacao_social", "designacao_social_plain" },
+ new Field( "inactivo" ).isDifferent( "y" ),
+ new String[]{ "designacao_social_plain" },
+ null );
+ Virtual2DArray array = executer.executeQuery( select );
+ ColumnizedMappable empresas[] = new ColumnizedMappable[ array.columnLength() ];
+ for( int n = 0; n < empresas.length; n++ )
+ {
+ Integer id = ( Integer ) array.get( n, 0 );
+ String designacao = ( String ) array.get( n, 1 );
+ empresas[ n ] = new ColumnizedMappable( id, designacao );
+ }
+ return empresas;
+ }
+
+ public ColumnizedMappable[] getAllEstabelecimentosForEmpresa( Integer empresaID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "estabelecimentos" },
+ new String[]{ "id", "nome", "nome_plain" },
+ new Field( "empresa_id" ).isEqual( empresaID ).and(
+ new Field( "inactivo" ).isDifferent( "y" ) ),
+ new String[]{ "nome_plain" },
+ null );
+ Virtual2DArray array = executer.executeQuery( select );
+ ColumnizedMappable estabelecimentos[] = new ColumnizedMappable[ array.columnLength() ];
+ for( int n = 0; n < estabelecimentos.length; n++ )
+ {
+ Integer id = ( Integer ) array.get( n, 0 );
+ String nome = ( String ) array.get( n, 1 );
+ estabelecimentos[ n ] = new ColumnizedMappable( id, nome );
+ }
+ return estabelecimentos;
+ }
+
+ public Object [][]getAllFichasForEstabelecimentoAndDatas( Integer estabelecimentoID, Date dataInicio, Date dataFim )
+ throws Exception
+ {
+ Vector fichas = new Vector();
+ Select select =
+ new Select( new String[]{ "trabalhadores" },
+ new String[]{ "id", "nome", "nome_plain" },
+ new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ),
+ new String[]{ "nome_plain" },
+ null );
+ Virtual2DArray array = executer.executeQuery( select );
+ for( int n = 0; n < array.columnLength(); n++ )
+ {
+ Integer id = ( Integer ) array.get( n, 0 );
+ String nome = ( String ) array.get( n, 1 );
+ String nomePlain = ( String ) array.get( n, 2 );
+ MappableObject fichasTrabalhador[] = getAllFichasForTrabalhadorAndDatas( id, dataInicio, dataFim );
+ for( int f = 0; f < fichasTrabalhador.length; f++ )
+ {
+ fichas.add( new Object[]{ fichasTrabalhador[ f ].getID(), nome, fichasTrabalhador[ f ].getValue(), nomePlain } );
+ }
+ }
+ Object fichasArray[][] = ( Object[][] )fichas.toArray( new Object[ fichas.size() ][] );
+ Arrays.sort( fichasArray, new Comparator(){
+ public int compare( Object o1, Object o2 )
+ {
+ Object arr1[] = ( Object[] )o1;
+ Object arr2[] = ( Object[] )o2;
+ int res = 0;
+ if( arr1[ 2 ] == null && arr2[ 2 ] == null )
+ {
+ res = 0;
+ }
+ else if( arr1[ 2 ] == null )
+ {
+ res = -1;
+ }
+ else if( arr2[ 2 ] == null )
+ {
+ res = 1;
+ }
+ else
+ {
+ res = ( (Date)arr1[ 2 ]).compareTo( (Date)arr2[ 2 ] );
+ }
+
+ if( res == 0 )
+ {
+ res = ( (String)arr1[ 3 ]).compareTo( (String)arr2[ 3 ] );
+ }
+ return res;
+ }
+ } );
+ for( int n = 0; n < fichasArray.length; n++ )
+ {
+ fichasArray[ n ][ 2 ] = fichasArray[ n ][ 2 ] != null? DATE_FORMAT.format( (Date)fichasArray[ n ][ 2 ] ): "";
+ }
+ return fichasArray;
+ }
+
+ public MappableObject []getAllFichasForTrabalhadorAndDatas( Integer trabalhadorID, Date dataInicio, Date dataFim )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "exames" }, new String[]{ "MAX(id)", "data" },
+ new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and(
+ new Field( "inactivo" ).isEqual( "n" ) ).and(
+ new Field( "data" ).between( new Object[]{ dataInicio, dataFim } ) ),
+ new String[]{ "data DESC" }, new String[]{ "data" } );
+ Virtual2DArray array = executer.executeQuery( select );
+ MappableObject exames[] = new MappableObject[ array.columnLength() ];
+ for( int n = 0; n < exames.length; n++ )
+ {
+ Date date = (Date)array.get( n, 1 );
+ Integer id = new Integer( ((Number)array.get( n, 0 )).intValue() );
+ exames[ n ] = new MappableObject( id, date );
+ }
+ return exames;
+ }
+
+ public byte[] getPDF( Integer exameID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "exames" },
+ new String[]{ "pdf" },
+ new Field( "id" ).isEqual( exameID ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ byte pdf[] = ( byte[] ) array.get( 0, 0 );
+ return pdf;
+ }
+
+ public String getNomeTrabalhadorForExameID( Integer exameID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "exames", "trabalhadores" },
+ new String[]{ "trabalhadores.nome_plain" },
+ new Field( "exames.id" ).isEqual( exameID ).and(
+ new Field( "exames.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ return ( String ) array.get( 0, 0 );
+ }
+
+ public Object[] getDadosForExameID( Integer exameID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "exames", "trabalhadores" },
+ new String[]{ "trabalhadores.nome", "exames.data", "exames.proximo_exame" },
+ new Field( "exames.id" ).isEqual( exameID ).and(
+ new Field( "exames.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ return array.getObjects()[ 0 ];
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/impressaofichas/ImpressaoFichasWindow.java b/trunk/SIPRPSoft/src/siprp/impressaofichas/ImpressaoFichasWindow.java
new file mode 100644
index 00000000..3b29b698
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/impressaofichas/ImpressaoFichasWindow.java
@@ -0,0 +1,422 @@
+/*
+ * ImpressaoFichasUpperPanel.java
+ *
+ * Created on 19 de Fevereiro de 2006, 19:00
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.impressaofichas;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.io.*;
+import javax.print.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.util.*;
+
+import com.evolute.utils.properties.*;
+import com.evolute.utils.tables.*;
+import com.evolute.utils.ui.*;
+import com.evolute.utils.ui.calendar.*;
+import com.evolute.utils.ui.window.*;
+
+/**
+ *
+ * @author Frederico
+ */
+public class ImpressaoFichasWindow extends EditorWindow
+ implements ListSelectionListener, ActionListener
+{
+ public final static String TITLE = "Impress\u00e3o de Fichas de Aptid\u00e3o";
+
+ protected final static String PATH_PROPERTY_SUFFIX = ".path";
+
+ private final static int iPermissionArray[][] =
+ new int[][]{ {} };
+
+ protected JCalendarPanel dataInicioPanel;
+ protected JCalendarPanel dataFimPanel;
+ protected VectorTableModel empresasModel;
+ protected BaseTable empresasTable;
+ protected VectorTableModel estabelecimentosModel;
+ protected BaseTable estabelecimentosTable;
+ protected VectorTableModel fichasModel;
+ protected BaseTable fichasTable;
+ protected JButton procurarButton;
+ protected JTextField pathText;
+ protected JButton pathButton;
+ protected JComboBox impressorasCombo;
+ protected JButton imprimirButton;
+ protected JButton imprimirTodasButton;
+
+ protected ImpressaoFichasDataProvider provider;
+ protected PropertyHandler propertyHandler;
+
+ /** Creates a new instance of ImpressaoFichasUpperPanel */
+ public ImpressaoFichasWindow()
+ throws Exception
+ {
+ super( iPermissionArray );
+ provider = ( ImpressaoFichasDataProvider ) ImpressaoFichasDataProvider.getProvider();
+ propertyHandler = new PropertyHandler();
+ setupComponents();
+ }
+
+ private void setupComponents()
+ throws Exception
+ {
+ setTitle( TITLE );
+ empresasModel = new VectorTableModel( new String[]{ "empresas" } );
+ empresasTable = new BaseTable( empresasModel );
+ empresasTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ empresasTable.setNonResizableNorReordable();
+ JScrollPane empresasScroll =
+ new JScrollPane( empresasTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ empresasTable.getSelectionModel().addListSelectionListener( this );
+ estabelecimentosModel = new VectorTableModel( new String[]{ "estabelecimentos" } );
+ estabelecimentosTable = new BaseTable( estabelecimentosModel );
+ estabelecimentosTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ estabelecimentosTable.setNonResizableNorReordable();
+ JScrollPane estabelecimentosScroll =
+ new JScrollPane( estabelecimentosTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ estabelecimentosTable.getSelectionModel().addListSelectionListener( this );
+ fichasModel = new VectorTableModel( new String[]{ "trabalhador", "data" } );
+ fichasTable = new BaseTable( fichasModel );
+ fichasTable.fixColumnWidth( 1, 120 );
+ fichasTable.setNonResizableNorReordable();
+ fichasTable.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
+ fichasTable.getSelectionModel().addListSelectionListener( this );
+ JScrollPane fichasScroll = new JScrollPane( fichasTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ JLabel inicioLabel = new JLabel( "In\u00edcio" );
+ dataInicioPanel = new JCalendarPanel( null );
+ JLabel fimLabel = new JLabel( "Fim" );
+ dataFimPanel = new JCalendarPanel( null );
+ procurarButton = new JButton( "Carregar" );
+ procurarButton.addActionListener( this );
+ procurarButton.setEnabled( false );
+ pathText = new JTextField();
+ pathText.setEditable( false );
+ pathButton = new JButton( "Escolher Direct\u00f3rio" );
+ pathButton.addActionListener( this );
+ impressorasCombo = new JComboBox();
+ PrintService printers[] = PrintServiceLookup.lookupPrintServices( null, null );
+ for( int n = 0; n < printers.length; n++ )
+ {
+ impressorasCombo.addItem( printers[ n ].getName() );
+ }
+ imprimirButton = new JButton( "Imprimir escolhidas" );
+ imprimirButton.addActionListener( this );
+ imprimirButton.setEnabled( false );
+ imprimirTodasButton = new JButton( "Imprimir Todas" );
+ imprimirTodasButton.addActionListener( this );
+ imprimirTodasButton.setEnabled( false );
+ JPanel upperPad = new JPanel();
+ JPanel lowerPad = new JPanel();
+ JPanel upperPanel = new JPanel();
+
+ GridBagLayout gridbag = new GridBagLayout();
+ setLayout( gridbag );
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.insets = new Insets( 1, 1, 1, 1 );
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.gridheight = 1;
+ constraints.weighty = 0.35;
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( upperPanel, constraints );
+
+ constraints.gridwidth = 2;
+ constraints.weightx = 1;
+ constraints.weighty = 0.65;
+ constraints.gridheight = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( fichasScroll, constraints );
+
+ constraints.weighty = 0;
+ constraints.gridheight = 1;
+ constraints.weightx = 0;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( inicioLabel, constraints );
+ gridbag.setConstraints( dataInicioPanel, constraints );
+ gridbag.setConstraints( fimLabel, constraints );
+ gridbag.setConstraints( dataFimPanel, constraints );
+ gridbag.setConstraints( procurarButton, constraints );
+ gridbag.setConstraints( pathText, constraints );
+ gridbag.setConstraints( pathButton, constraints );
+ gridbag.setConstraints( impressorasCombo, constraints );
+ gridbag.setConstraints( imprimirButton, constraints );
+ gridbag.setConstraints( imprimirTodasButton, constraints );
+
+ constraints.weighty = 0.32;
+ gridbag.setConstraints( upperPad, constraints );
+ gridbag.setConstraints( lowerPad, constraints );
+
+ add( upperPanel );
+ add( fichasScroll );
+ add( upperPad );
+ add( inicioLabel );
+ add( dataInicioPanel );
+ add( fimLabel );
+ add( dataFimPanel );
+ add( procurarButton );
+ add( lowerPad );
+ add( pathButton );
+ add( pathText );
+ add( impressorasCombo );
+ add( imprimirButton );
+ add( imprimirTodasButton );
+
+ upperPanel.setLayout( new GridLayout( 1, 2 ) );
+ upperPanel.add( empresasScroll );
+ upperPanel.add( estabelecimentosScroll );
+ ColumnizedMappable empresas[] = provider.getAllEmpresas();
+ Vector values = empresasModel.getValues();
+ values.addAll( Arrays.asList( empresas ) );
+ empresasModel.setValues( values );
+
+ Properties properties = propertyHandler.load();
+System.out.println( properties );
+ String path = (String) properties.get( getClass().getName() + PATH_PROPERTY_SUFFIX );
+ if( path == null )
+ {
+ setDirectorio( System.getProperty( "user.home" ) );
+ }
+ else
+ {
+ pathText.setText( path );
+ }
+ }
+
+ public void valueChanged( ListSelectionEvent e )
+ {
+ Object source = e.getSource();
+ if( e.getValueIsAdjusting() )
+ {
+ return;
+ }
+ if( source.equals( empresasTable.getSelectionModel() ) )
+ {
+ carregarEstabelecimentos();
+ }
+ else if( source.equals( estabelecimentosTable.getSelectionModel() ) )
+ {
+ procurarButton.setEnabled( estabelecimentosTable.getSelectedRow() != -1 );
+ }
+ else if( source.equals( fichasTable.getSelectionModel() ) )
+ {
+ imprimirButton.setEnabled( fichasTable.getSelectedRow() != -1 );
+ }
+ }
+
+ protected void carregarEstabelecimentos()
+ {
+ estabelecimentosTable.clearSelection();
+ int selected = empresasTable.getSelectedRow();
+ estabelecimentosModel.clearAll();
+ if( selected > -1 )
+ {
+ try
+ {
+ Integer empresaID = ( ( ColumnizedMappable ) empresasModel.getRowAt( selected ) ).getID();
+ ColumnizedMappable estabelecimentos[] = provider.getAllEstabelecimentosForEmpresa( empresaID);
+ Vector values = estabelecimentosModel.getValues();
+ values.addAll( Arrays.asList( estabelecimentos ) );
+ estabelecimentosModel.setValues( values );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar os estabelecimentos.", true );
+ estabelecimentosModel.clearAll();
+ }
+ }
+ }
+
+ public void clear()
+ {
+ empresasTable.clearSelection();
+ }
+
+ public void fill( Object value )
+ {
+ if( value == null )
+ {
+ clear();
+ }
+ Integer ids[] = ( Integer [] ) value;
+ for( int n = 0; n < empresasTable.getRowCount(); n++ )
+ {
+ if( ( ( ColumnizedMappable ) empresasModel.getRowAt( n ) ).getID().equals( ids[ 0 ] ) )
+ {
+ empresasTable.setRowSelectionInterval( n, n );
+ break;
+ }
+ }
+
+ for( int n = 0; n < estabelecimentosTable.getRowCount(); n++ )
+ {
+ if( ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( n ) ).getID().equals( ids[ 1 ] ) )
+ {
+ estabelecimentosTable.setRowSelectionInterval( n, n );
+ break;
+ }
+ }
+ }
+
+ public Object save()
+ {
+ int empresaSelected = empresasTable.getSelectedRow();
+ int estabelecimentoSelected = estabelecimentosTable.getSelectedRow();
+ return new Integer[]{
+ empresaSelected == -1 ? null : ( ( ColumnizedMappable ) empresasModel.getRowAt( empresaSelected ) ).getID(),
+ estabelecimentoSelected == -1 ? null : ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( estabelecimentoSelected ) ).getID()
+ };
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ empresasTable.setEnabled( enable );
+ estabelecimentosTable.setEnabled( enable );
+ }
+
+ public void actionPerformed( ActionEvent e )
+ {
+ Object source = e.getSource();
+ if( source.equals( procurarButton ) )
+ {
+ procurar();
+ }
+ else if( source.equals( imprimirButton ) )
+ {
+ imprimir();
+ }
+ else if( source.equals( imprimirTodasButton ) )
+ {
+ imprimirTodas();
+ }
+ else if( source.equals( pathButton ) )
+ {
+ escolherDirectorio();
+ }
+ }
+
+ public void procurar()
+ {
+ int selected = estabelecimentosTable.getSelectedRow();
+ Date dataInicio = dataInicioPanel.getDate();
+ Date dataFim = dataFimPanel.getDate();
+ if( selected == -1 || ( dataInicio == null && dataFim == null ) )
+ {
+ JOptionPane.showMessageDialog( this, "Tem de escolher pelo menos uma data e um estabelecimento.", "Erro",
+ JOptionPane.ERROR_MESSAGE );
+ return;
+ }
+ if( dataInicio == null )
+ {
+ dataInicio = dataFim;
+ }
+ else if( dataFim == null )
+ {
+ dataFim = dataInicio;
+ }
+ fichasModel.clearAll();
+ try
+ {
+ Integer estabelecimentoID = ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( selected ) ).getID();
+ Object fichas[][] = provider.getAllFichasForEstabelecimentoAndDatas( estabelecimentoID, dataInicio, dataFim );
+ Vector values = fichasModel.getValues();
+ for( int n = 0; n < fichas.length; n++ )
+ {
+ values.add( new ColumnizedObjectArray( fichas[ n ], true ) );
+ }
+ fichasModel.setValues( values );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar a lista.", true );
+ estabelecimentosModel.clearAll();
+ }
+ imprimirTodasButton.setEnabled( fichasTable.getRowCount() > 0 );
+ }
+
+ public void imprimir()
+ {
+ imprimirLinhas( fichasTable.getSelectedRows() );
+ }
+
+ public void imprimirTodas()
+ {
+ int linhas[] = new int[ fichasTable.getRowCount() ];
+ for( int n = 0; n < linhas.length; n++ )
+ {
+ linhas[ n ] = n;
+ }
+ imprimirLinhas( linhas );
+ }
+
+ protected void imprimirLinhas( int linhas[] )
+ {
+ try
+ {
+ File file = new File( pathText.getText().trim() );
+ if( !file.exists() || !file.isDirectory() )
+ {
+ throw new IOException( "Direct\u00f3rio inexistente ou indispon\u00edvel: " + pathText.getText().trim() );
+ }
+ }
+ catch( IOException ioex )
+ {
+ JOptionPane.showMessageDialog( this, ioex.getMessage(), "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ return;
+ }
+ String impressora = ( String ) impressorasCombo.getSelectedItem();
+ Integer ids[] = new Integer[ linhas.length ];
+ for( int n = 0; n < ids.length; n++ )
+ {
+ ids[ n ] = ( ( ColumnizedObjectArray )fichasModel.getRowAt( linhas[ n ] ) ).getID();
+ }
+ int option = JOptionPane.showConfirmDialog( this, "Imprimir as " + ids.length + " fichas para a impressora " + impressora + "?",
+ "Imprimir", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE );
+ if( option == 0 )
+ {
+ System.out.println( "imprimir" );
+ new FichasPrinter( ids, impressora, pathText.getText().trim(),
+ empresasModel.getRowAt( empresasTable.getSelectedRow() ).toString(),
+ estabelecimentosModel.getRowAt( estabelecimentosTable.getSelectedRow() ).toString() ).start();
+ }
+ }
+
+ protected void escolherDirectorio()
+ {
+ JFileChooser chooser = new JFileChooser();
+ chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
+ int returnVal = chooser.showOpenDialog( this );
+ if(returnVal == JFileChooser.APPROVE_OPTION)
+ {
+ setDirectorio( chooser.getSelectedFile().getAbsolutePath() );
+ }
+ }
+
+ protected void setDirectorio( String path )
+ {
+ if( path != null )
+ {
+ pathText.setText( path );
+ Properties properties = propertyHandler.load();
+ properties.setProperty( getClass().getName() + PATH_PROPERTY_SUFFIX, path );
+ try
+ {
+ propertyHandler.save( properties );
+ }
+ catch( IOException ioex )
+ {
+ ioex.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/impressaofichas/lista_fichas.xsl b/trunk/SIPRPSoft/src/siprp/impressaofichas/lista_fichas.xsl
new file mode 100644
index 00000000..46096481
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/impressaofichas/lista_fichas.xsl
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ RELAÇÃO DE FICHAS DE APTIDÃO ENVIADAS
+
+
+
+
+
+
+
+
+
+
+
+ NOME
+
+
+
+
+ DATA EXAME
+
+
+
+
+ PRÓXIMO EXAME
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/Lembrete.java b/trunk/SIPRPSoft/src/siprp/lembretes/Lembrete.java
new file mode 100644
index 00000000..67d73eff
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/lembretes/Lembrete.java
@@ -0,0 +1,194 @@
+/*
+ * Lembrete.java
+ *
+ * Created on 12 de Fevereiro de 2007, 23:18
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.lembretes;
+
+import java.util.Date;
+
+/**
+ *
+ * @author Frederico
+ */
+public class Lembrete
+{
+ protected Integer id;
+ protected Integer tipoID;
+ protected Date data;
+ protected String descricao;
+ protected String texto;
+ protected Integer empresaID;
+ protected Integer estabelecimentoID;
+ protected Integer trabalhadorID;
+ protected Integer marcacaoEstabelecimentoID;
+ protected Integer marcacaoTrabalhadorID;
+ protected boolean enviarEmail;
+ protected Integer periodicidadeDias;
+ protected Integer periodicidadeMeses;
+
+ /** Creates a new instance of Lembrete */
+ public Lembrete( Integer id,
+ Integer tipoID,
+ Date data,
+ String descricao,
+ String texto,
+ Integer empresaID,
+ Integer estabelecimentoID,
+ Integer trabalhadorID,
+ Integer marcacaoEstabelecimentoID,
+ Integer marcacaoTrabalhadorID,
+ boolean enviarEmail,
+ Integer periodicidadeDias,
+ Integer periodicidadeMeses )
+ {
+ setId( id );
+ setTipoID( tipoID );
+ setData( data );
+ setDescricao( descricao );
+ setTexto( texto );
+ setEmpresaID( empresaID );
+ setEstabelecimentoID( estabelecimentoID );
+ setTrabalhadorID( trabalhadorID );
+ setMarcacaoEstabelecimentoID( marcacaoEstabelecimentoID );
+ setMarcacaoTrabalhadorID( marcacaoTrabalhadorID );
+ setEnviarEmail( enviarEmail );
+ setPeriodicidadeDias( periodicidadeDias );
+ setPeriodicidadeMeses( periodicidadeMeses );
+ }
+
+ public Integer getTipoID()
+ {
+ return tipoID;
+ }
+
+ public void setTipoID(Integer tipoID)
+ {
+ this.tipoID = tipoID;
+ }
+
+ public Date getData()
+ {
+ return data;
+ }
+
+ public void setData(Date data)
+ {
+ this.data = data;
+ }
+
+ public String getDescricao()
+ {
+ return descricao;
+ }
+
+ public void setDescricao(String descricao)
+ {
+ this.descricao = descricao;
+ }
+
+ public String getTexto()
+ {
+ return texto;
+ }
+
+ public void setTexto(String texto)
+ {
+ this.texto = texto;
+ }
+
+ public Integer getEmpresaID()
+ {
+ return empresaID;
+ }
+
+ public void setEmpresaID(Integer empresaID)
+ {
+ this.empresaID = empresaID;
+ }
+
+ public Integer getEstabelecimentoID()
+ {
+ return estabelecimentoID;
+ }
+
+ public void setEstabelecimentoID(Integer estabelecimentoID)
+ {
+ this.estabelecimentoID = estabelecimentoID;
+ }
+
+ public Integer getTrabalhadorID()
+ {
+ return trabalhadorID;
+ }
+
+ public void setTrabalhadorID(Integer trabalhadorID)
+ {
+ this.trabalhadorID = trabalhadorID;
+ }
+
+ public Integer getMarcacaoEstabelecimentoID()
+ {
+ return marcacaoEstabelecimentoID;
+ }
+
+ public void setMarcacaoEstabelecimentoID(Integer marcacaoEstabelecimentoID)
+ {
+ this.marcacaoEstabelecimentoID = marcacaoEstabelecimentoID;
+ }
+
+ public Integer getMarcacaoTrabalhadorID()
+ {
+ return marcacaoTrabalhadorID;
+ }
+
+ public void setMarcacaoTrabalhadorID(Integer marcacaoTrabalhadorID)
+ {
+ this.marcacaoTrabalhadorID = marcacaoTrabalhadorID;
+ }
+
+ public boolean isEnviarEmail()
+ {
+ return enviarEmail;
+ }
+
+ public void setEnviarEmail(boolean enviarEmail)
+ {
+ this.enviarEmail = enviarEmail;
+ }
+
+ public Integer getPeriodicidadeDias()
+ {
+ return periodicidadeDias;
+ }
+
+ public void setPeriodicidadeDias(Integer periodicidadeDias)
+ {
+ this.periodicidadeDias = periodicidadeDias;
+ }
+
+ public Integer getPeriodicidadeMeses()
+ {
+ return periodicidadeMeses;
+ }
+
+ public void setPeriodicidadeMeses(Integer periodicidadeMeses)
+ {
+ this.periodicidadeMeses = periodicidadeMeses;
+ }
+
+ public Integer getId()
+ {
+ return id;
+ }
+
+ public void setId(Integer id)
+ {
+ this.id = id;
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/LembretesConstants.java b/trunk/SIPRPSoft/src/siprp/lembretes/LembretesConstants.java
new file mode 100644
index 00000000..13f576b7
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/lembretes/LembretesConstants.java
@@ -0,0 +1,26 @@
+/*
+ * LembretesConstants.java
+ *
+ * Created on February 12, 2007, 4:44 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.lembretes;
+
+/**
+ *
+ * @author fpalma
+ */
+public interface LembretesConstants
+{
+ public static final String CODE_EXTERNO = "EXTERNO";
+ public static final String CODE_REMARCACOES = "REMARCACOES";
+ public static final String CODE_MARCACOES = "MARCACOES";
+ public static final String CODE_OUTROS = "OUTROS";
+
+ public static final String CODES[] =
+ new String[]{ CODE_EXTERNO, CODE_REMARCACOES, CODE_MARCACOES,
+ CODE_OUTROS };
+}
diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/LembretesDataProvider.java b/trunk/SIPRPSoft/src/siprp/lembretes/LembretesDataProvider.java
new file mode 100644
index 00000000..9a9d9701
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/lembretes/LembretesDataProvider.java
@@ -0,0 +1,245 @@
+/*
+ * LembretesDataProvider.java
+ *
+ * Created on February 5, 2007, 6:09 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.lembretes;
+
+import com.evolute.utils.Singleton;
+import com.evolute.utils.arrays.Virtual2DArray;
+import com.evolute.utils.db.DBManager;
+import com.evolute.utils.db.Executer;
+import com.evolute.utils.sql.Assignment;
+import com.evolute.utils.sql.Delete;
+import com.evolute.utils.sql.Field;
+import com.evolute.utils.sql.Insert;
+import com.evolute.utils.sql.Select;
+import java.util.Date;
+import java.util.HashMap;
+
+/**
+ *
+ * @author lflores
+ */
+public class LembretesDataProvider
+{
+ private static final Object LOCK = new Object();
+ private static LembretesDataProvider instance = null;
+
+ private final HashMap TIPOS_LEMBRETES_BY_CODIGO =
+ new HashMap();
+ private final HashMap TIPOS_LEMBRETES_BY_ID =
+ new HashMap();
+ private TipoLembrete tiposLembrete[];
+
+ private Executer EXECUTER;
+
+ /** Creates a new instance of LembretesDataProvider */
+ public LembretesDataProvider()
+ throws Exception
+ {
+ DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
+ EXECUTER = dbm.getSharedExecuter( this );
+ }
+
+ public static LembretesDataProvider getProvider()
+ throws Exception
+ {
+ synchronized( LOCK )
+ {
+ if( instance == null )
+ {
+ instance = new LembretesDataProvider();
+ }
+ }
+ return instance;
+ }
+
+ public TipoLembrete[] getTiposLembrete()
+ throws Exception
+ {
+ if( tiposLembrete == null )
+ {
+ Select select =
+ new Select( new String[]{ "lembretes_tipos" },
+ new String[]{ "id", "codigo", "descricao", "ordem" },
+ new Field( "activo" ).isEqual( "y" ),
+ new String[]{ "ordem" },
+ null );
+ Virtual2DArray array = EXECUTER.executeQuery( select );
+ tiposLembrete = new TipoLembrete[ array.columnLength() ];
+ for( int n = 0; n < tiposLembrete.length; n++ )
+ {
+ Integer id = ( Integer ) array.get( n, 0 );
+ String codigo = ( String ) array.get( n, 1 );
+ String descricao = ( String ) array.get( n, 2 );
+ Integer ordem = ( Integer ) array.get( n, 3 );
+ tiposLembrete[ n ] = new TipoLembrete( id, codigo, descricao, ordem );
+ TIPOS_LEMBRETES_BY_CODIGO.put( codigo, tiposLembrete[ n ] );
+ TIPOS_LEMBRETES_BY_ID.put( id, tiposLembrete[ n ] );
+ }
+ }
+ return tiposLembrete;
+ }
+
+ public TipoLembrete getTipoLembreteByCodigo( String codigo )
+ throws Exception
+ {
+ getTiposLembrete();
+ return TIPOS_LEMBRETES_BY_CODIGO.get( codigo );
+ }
+
+ public TipoLembrete getTipoLembreteByID( Integer id )
+ throws Exception
+ {
+ getTiposLembrete();
+ return TIPOS_LEMBRETES_BY_ID.get( id );
+ }
+
+ public void criarLembrete( Integer tipoID,
+ Date data,
+ String descricao,
+ String texto,
+ Integer empresaID,
+ Integer estabelecimentoID,
+ Integer trabalhadorID,
+ Integer marcacaoEstabelecimentoID,
+ Integer marcacaoTrabalhadorID,
+ boolean enviarEmail,
+ Integer periodicidadeDias,
+ Integer periodicidadeMeses )
+ throws Exception
+ {
+ Insert insert =
+ new Insert( "lembretes",
+ new Assignment[]{
+ new Assignment( new Field( "tipo_id" ), tipoID ),
+ new Assignment( new Field( "data" ), data ),
+ 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( "marcacao_estabelecimento_id" ), marcacaoEstabelecimentoID ),
+ new Assignment( new Field( "marcacao_trabalhador_id" ), marcacaoTrabalhadorID ),
+ new Assignment( new Field( "enviar_email" ), enviarEmail ? "y" : "n" ),
+ new Assignment( new Field( "periodicidade_dias" ), periodicidadeDias ),
+ new Assignment( new Field( "periodicidade_meses" ), periodicidadeMeses ) } );
+ EXECUTER.executeQuery( insert );
+ }
+
+ public void apagarLembreteByID( Integer id )
+ throws Exception
+ {
+ Delete delete =
+ new Delete( "lembretes",
+ new Field( "id" ).isEqual( id ) );
+ EXECUTER.executeQuery( delete );
+ }
+
+ public void apagarLembreteByMarcacaoTrabalhadorID( Integer marcacaoID )
+ throws Exception
+ {
+ Delete delete =
+ new Delete( "lembretes",
+ new Field( "marcacao_trabalhador_id" ).isEqual( marcacaoID ) );
+ EXECUTER.executeQuery( delete );
+ }
+
+ public int countLembretesByTipo( Integer tipoID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "lembretes" },
+ new String[]{ "COUNT(*)" },
+ new Field( "tipo_id" ).isEqual( tipoID ).and(
+ new Field( "data" ).isLessOrEqual( new Date() ) ) );
+ Virtual2DArray array = EXECUTER.executeQuery( select );
+ if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
+ {
+ return 0;
+ }
+ else
+ {
+ return ( ( Number ) array.get( 0, 0 ) ).intValue();
+ }
+
+ }
+
+ public Lembrete[] getLembretesByTipo( Integer tipoID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "lembretes" },
+ new String[]{ "id", "tipo_id", "data", "descricao",
+ "texto", "empresa_id", "estabelecimento_id",
+ "trabalhador_id", "marcacao_estabelecimento_id",
+ "marcacao_trabalhador_id", "enviar_email",
+ "periodicidade_dias", "periodicidade_meses" },
+ new Field( "tipo_id" ).isEqual( tipoID ).and(
+ new Field( "data" ).isLessOrEqual( new Date() ) ) );
+ Virtual2DArray array = EXECUTER.executeQuery( select );
+ Lembrete lembretes[] = new Lembrete[ array.columnLength() ];
+ for( int n = 0; n < lembretes.length; n++ )
+ {
+ Integer id = ( Integer ) array.get( n, 0 );
+ Date data = ( Date ) array.get( n, 2 );
+ String descricao = ( String ) array.get( n, 3 );
+ String texto = ( String ) array.get( n, 4 );
+ Integer empresaID = ( Integer ) array.get( n, 5 );
+ Integer estabelecimentoID = ( Integer ) array.get( n, 6 );
+ Integer trabalhadorID = ( Integer ) array.get( n, 7 );
+ Integer marcacaoEstabelecimentoID = ( Integer ) array.get( n, 8 );
+ Integer marcacaoTrabalhadorID = ( Integer ) array.get( n, 9 );
+ boolean enviarEmail = "y".equals( array.get( n, 10 ) );
+ Integer periodicidadeDias = ( Integer ) array.get( n, 11 );
+ Integer periodicidadeMeses = ( Integer ) array.get( n, 12 );
+ lembretes[ n ] = new Lembrete( id, tipoID, data, descricao, texto,
+ empresaID, estabelecimentoID, trabalhadorID,
+ marcacaoEstabelecimentoID, marcacaoTrabalhadorID,
+ enviarEmail, periodicidadeDias, periodicidadeMeses );
+ }
+ return lembretes;
+ }
+
+ public Lembrete getLembreteByID( Integer id )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "lembretes" },
+ new String[]{ "id", "tipo_id", "data", "descricao",
+ "texto", "empresa_id", "estabelecimento_id",
+ "trabalhador_id", "marcacao_estabelecimento_id",
+ "marcacao_trabalhador_id", "enviar_email",
+ "periodicidade_dias", "periodicidade_meses" },
+ new Field( "id" ).isEqual( id ) );
+ Virtual2DArray array = EXECUTER.executeQuery( select );
+ if( array.columnLength() == 0 )
+ {
+ return null;
+ }
+ else
+ {
+ Integer tipoID = ( Integer ) array.get( 0, 1 );
+ Date data = ( Date ) array.get( 0, 2 );
+ String descricao = ( String ) array.get( 0, 3 );
+ String texto = ( String ) array.get( 0, 4 );
+ Integer empresaID = ( Integer ) array.get( 0, 5 );
+ Integer estabelecimentoID = ( Integer ) array.get( 0, 6 );
+ Integer trabalhadorID = ( Integer ) array.get( 0, 7 );
+ Integer marcacaoEstabelecimentoID = ( Integer ) array.get( 0, 8 );
+ Integer marcacaoTrabalhadorID = ( Integer ) array.get( 0, 9 );
+ boolean enviarEmail = "y".equals( array.get( 0, 10 ) );
+ Integer periodicidadeDias = ( Integer ) array.get( 0, 11 );
+ Integer periodicidadeMeses = ( Integer ) array.get( 0, 12 );
+ return new Lembrete( id, tipoID, data, descricao, texto,
+ empresaID, estabelecimentoID, trabalhadorID,
+ marcacaoEstabelecimentoID, marcacaoTrabalhadorID,
+ enviarEmail, periodicidadeDias, periodicidadeMeses );
+ }
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/LembretesPanel.java b/trunk/SIPRPSoft/src/siprp/lembretes/LembretesPanel.java
new file mode 100644
index 00000000..1e7375cf
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/lembretes/LembretesPanel.java
@@ -0,0 +1,31 @@
+/*
+ * LembretesPanel.java
+ *
+ * Created on February 6, 2007, 5:14 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.lembretes;
+
+import java.awt.*;
+import javax.swing.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class LembretesPanel extends JPanel
+{
+
+ /** Creates a new instance of LembretesPanel */
+ public LembretesPanel()
+ {
+ setupComponents();
+ }
+
+ private void setupComponents()
+ {
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/LembretesWindow.java b/trunk/SIPRPSoft/src/siprp/lembretes/LembretesWindow.java
new file mode 100644
index 00000000..dfd77b34
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/lembretes/LembretesWindow.java
@@ -0,0 +1,190 @@
+/*
+ * LembretesWindow.java
+ *
+ * Created on 13 de Fevereiro de 2007, 11:11
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.lembretes;
+
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import javax.swing.*;
+
+import com.evolute.utils.tables.*;
+import com.evolute.utils.tracker.TrackableWindow;
+import com.evolute.utils.ui.DialogException;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.Vector;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import siprp.lembretes.remarcacoes.LembretesRemarcacaoPanel;
+
+/**
+ *
+ * @author Frederico
+ */
+public class LembretesWindow extends JFrame
+ implements ActionListener, TrackableWindow, ListSelectionListener,
+ LembretesConstants
+{
+ public static final String TITLE = "Lembretes";
+
+ protected VectorTableModel tiposModel;
+ protected BaseTable tiposTable;
+ protected JPanel lembretesPanel;
+ protected JButton recarregarButton;
+
+ protected LembretesDataProvider provider;
+
+ /** Creates a new instance of LembretesWindow */
+ public LembretesWindow()
+ throws Exception
+ {
+ provider = LembretesDataProvider.getProvider();
+ setupComponents();
+ }
+
+ private void setupComponents()
+ {
+ setTitle( "Lembretes" );
+ tiposModel = new VectorTableModel( new String[]{ "tipo", "quantidade" } );
+ tiposTable = new BaseTable( tiposModel );
+ tiposTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ tiposTable.fixColumnWidth( 0, 200 );
+ tiposTable.fixColumnWidth( 1, 100 );
+ tiposTable.getSelectionModel().addListSelectionListener( this );
+ JScrollPane scp =
+ new JScrollPane( tiposTable, JScrollPane.VERTICAL_SCROLLBAR_NEVER,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ scp.setPreferredSize( new Dimension( 300, 20 ) );
+ 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 );
+
+ addWindowListener( new WindowAdapter(){
+ public void windowClosing( WindowEvent e )
+ {
+ close();
+ }
+
+ public void windowOpened( WindowEvent e )
+ {
+// setExtendedState( getExtendedState() | MAXIMIZED_BOTH );
+ setSize( 1024, 700 );
+ reloadTotais();
+ }
+ } );
+ }
+
+ public void refresh()
+ {
+ }
+
+ public void open()
+ {
+ setVisible( true );
+ }
+
+ public void close()
+ {
+ SwingUtilities.invokeLater( new Runnable() {
+ public void run()
+ {
+ setVisible( false );
+ dispose();
+ }
+ } );
+ }
+
+ protected void reloadTotais()
+ {
+ try
+ {
+ Vector values = tiposModel.getValues();
+ values.clear();
+ TipoLembrete tipos[] = provider.getTiposLembrete();
+ for( int n = 0; n < tipos.length; n++ )
+ {
+ int count = provider.countLembretesByTipo( tipos[ n ].getID() );
+ values.add( new ColumnizedObjectArray(
+ new Object[]{ tipos[ n ].getID(), tipos[ n ].getDescricao(),
+ "" + count }, true ) );
+ }
+ tiposModel.setValues( values );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar lembretes", true );
+ }
+ }
+
+ protected void reloadLembretes()
+ {
+ lembretesPanel.removeAll();
+ int selected = tiposTable.getSelectedRow();
+ if( selected != -1 )
+ {
+ ColumnizedObjectArray line = ( ColumnizedObjectArray ) tiposModel.getRowAt( selected );
+ Integer tipoID = line.getID();
+ try
+ {
+ TipoLembrete tipo = provider.getTipoLembreteByID( tipoID );
+ if( CODE_EXTERNO.equals( tipo.getCodigo() ) )
+ {
+
+ }
+ if( CODE_REMARCACOES.equals( tipo.getCodigo() ) )
+ {
+ lembretesPanel.add( new LembretesRemarcacaoPanel() );
+ }
+ if( CODE_MARCACOES.equals( tipo.getCodigo() ) )
+ {
+ }
+ if( CODE_OUTROS.equals( tipo.getCodigo() ) )
+ {
+ }
+
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar lembretes", true );
+ }
+ }
+ validate();
+ repaint();
+ }
+
+ public boolean closeIfPossible()
+ {
+ close();
+ return true;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ Object source = e.getSource();
+ if( source.equals( recarregarButton ) )
+ {
+ reloadTotais();
+ }
+ }
+
+ public void valueChanged(ListSelectionEvent e)
+ {
+ if( !e.getValueIsAdjusting() )
+ {
+ reloadLembretes();
+ }
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/TipoLembrete.java b/trunk/SIPRPSoft/src/siprp/lembretes/TipoLembrete.java
new file mode 100644
index 00000000..e5564393
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/lembretes/TipoLembrete.java
@@ -0,0 +1,65 @@
+/*
+ * TipoLembrete.java
+ *
+ * Created on February 5, 2007, 6:28 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.lembretes;
+
+import com.evolute.utils.data.IDObject;
+
+/**
+ *
+ * @author lflores
+ */
+public class TipoLembrete
+ implements IDObject, Comparable
+{
+ protected Integer id;
+ protected String codigo;
+ protected String descricao;
+ protected Integer ordem;
+
+ /** Creates a new instance of TipoLembrete */
+ public TipoLembrete( Integer id, String codigo, String descricao,
+ Integer ordem )
+ {
+ this.id = id;
+ this.codigo = codigo;
+ this.descricao = descricao;
+ this.ordem = ordem;
+ }
+
+ public Integer getID()
+ {
+ return id;
+ }
+
+ protected String getCodigo()
+ {
+ return codigo;
+ }
+
+ protected String getDescricao()
+ {
+ return descricao;
+ }
+
+ protected Integer getOrdem()
+ {
+ return ordem;
+ }
+
+ public int compareTo( Object other )
+ {
+ if( !( other instanceof TipoLembrete ) )
+ {
+ return 0;
+ }
+ TipoLembrete otl = ( TipoLembrete ) other;
+ return getOrdem().compareTo( otl.getOrdem() );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/LembretesRemarcacaoPanel.java b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/LembretesRemarcacaoPanel.java
new file mode 100644
index 00000000..5638688a
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/LembretesRemarcacaoPanel.java
@@ -0,0 +1,88 @@
+/*
+ * LembretesRemarcacaoPanel.java
+ *
+ * Created on 13 de Fevereiro de 2007, 23:24
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.lembretes.remarcacoes;
+
+import com.evolute.utils.data.IDObject;
+import com.evolute.utils.data.MappableObject;
+import com.evolute.utils.jdo.JDOProvider;
+import com.evolute.utils.ui.panel.multipleactionlist.MultipleActionListPanel;
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.util.List;
+import java.util.Vector;
+import javax.swing.*;
+import siprp.lembretes.Lembrete;
+import siprp.lembretes.LembretesConstants;
+import siprp.lembretes.LembretesDataProvider;
+
+/**
+ *
+ * @author Frederico
+ */
+public class LembretesRemarcacaoPanel extends JPanel
+ implements LembretesConstants
+{
+ protected JScrollPane listTrabalhadoresScroll;
+ protected JScrollPane listEstabelecimentosScroll;
+ protected MultipleActionListPanel listTrabalhadoresPanel;
+ protected MultipleActionListPanel listEstabelecimentosPanel;
+
+ protected RemarcacoesDataProvider provider;
+
+ private JDOProvider JDO;
+
+ /** Creates a new instance of LembretesRemarcacaoPanel */
+ public LembretesRemarcacaoPanel()
+ throws Exception
+ {
+ provider = RemarcacoesDataProvider.getProvider();
+ setupComponents();
+ }
+
+ private void setupComponents()
+ throws Exception
+ {
+ listTrabalhadoresPanel =
+ new MultipleActionListPanel(
+ new RemarcacoesActionFactory[]{ },
+ new RemarcacoesActionFactory[]{ new RemarcacoesActionFactory( RemarcacoesActionFactory.TRABALHADOR ) } );
+ listTrabalhadoresScroll =
+ new JScrollPane( listTrabalhadoresPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ listEstabelecimentosPanel =
+ new MultipleActionListPanel(
+ new RemarcacoesActionFactory[]{ },
+ new RemarcacoesActionFactory[]{ new RemarcacoesActionFactory( RemarcacoesActionFactory.ESTABELECIMENTO ) } );
+ listEstabelecimentosScroll =
+ new JScrollPane( listEstabelecimentosPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ setLayout( new GridLayout( 1, 2 ) );
+ JPanel trabalhadoresPanel = new JPanel();
+ JPanel estabelecimentosPanel = new JPanel();
+ add( trabalhadoresPanel );
+ add( estabelecimentosPanel );
+
+ trabalhadoresPanel.setLayout( new BorderLayout() );
+ trabalhadoresPanel.add( new JLabel( "Consultas / ECDs", JLabel.CENTER ), BorderLayout.NORTH );
+ trabalhadoresPanel.add( listTrabalhadoresScroll, BorderLayout.CENTER );
+
+ estabelecimentosPanel.setLayout( new BorderLayout() );
+ estabelecimentosPanel.add( new JLabel( "Higiene e Seguran\u00e7a", JLabel.CENTER ), BorderLayout.NORTH );
+ estabelecimentosPanel.add( listEstabelecimentosScroll, BorderLayout.CENTER );
+
+ listTrabalhadoresPanel.showList( provider.getLembretesRemarcacaoTrabalhador() );
+// listEstabelecimentosPanel.showList( estabelecimentos.toArray( new IDObject[ estabelecimentos.size() ] ) );
+ }
+
+ protected String criarDetalhesMarcacaoTrabalhador( Integer marcacaoID )
+ {
+ return null;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/RemarcacoesActionFactory.java b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/RemarcacoesActionFactory.java
new file mode 100644
index 00000000..25b84227
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/RemarcacoesActionFactory.java
@@ -0,0 +1,57 @@
+/*
+ * RemarcacoesActionFactory.java
+ *
+ * Created on January 31, 2007, 6:37 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.lembretes.remarcacoes;
+
+import com.evolute.utils.data.IDObject;
+import com.evolute.utils.ui.panel.multipleactionlist.ActionFactory;
+import javax.swing.Action;
+import siprp.lembretes.remarcacoes.actions.TratarMarcacaoEstabelecimentoAction;
+import siprp.lembretes.remarcacoes.actions.TratarMarcacaoTrabalhadorAction;
+
+/**
+ *
+ * @author fpalma
+ */
+public class RemarcacoesActionFactory implements ActionFactory
+{
+ public static final int TRABALHADOR = 0;
+ public static final int ESTABELECIMENTO = 1;
+
+ protected final int TIPO;
+
+ /**
+ * Creates a new instance of RemarcacoesActionFactory
+ */
+ public RemarcacoesActionFactory( int tipo )
+ {
+ TIPO = tipo;
+ }
+
+ public Action createAction(IDObject[] objects)
+ {
+ return null;
+ }
+
+ public Action createAction(IDObject object)
+ {
+ switch( TIPO )
+ {
+ case TRABALHADOR:
+ return new TratarMarcacaoTrabalhadorAction( object );
+
+ case ESTABELECIMENTO:
+ return new TratarMarcacaoEstabelecimentoAction( object );
+
+ default:
+ return null;
+ }
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/RemarcacoesDataProvider.java b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/RemarcacoesDataProvider.java
new file mode 100644
index 00000000..209cccf1
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/RemarcacoesDataProvider.java
@@ -0,0 +1,124 @@
+/*
+ * RemarcacoesDataProvider.java
+ *
+ * Created on February 14, 2007, 10:56 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.lembretes.remarcacoes;
+
+import com.evolute.utils.Singleton;
+import com.evolute.utils.arrays.Virtual2DArray;
+import com.evolute.utils.data.IDObject;
+import com.evolute.utils.data.MappableObject;
+import com.evolute.utils.db.DBManager;
+import com.evolute.utils.db.Executer;
+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 java.text.DateFormat;
+import java.util.Date;
+import java.util.Locale;
+import siprp.data.Marcacao;
+import siprp.lembretes.LembretesConstants;
+import siprp.lembretes.LembretesDataProvider;
+
+/**
+ *
+ * @author lflores
+ */
+public class RemarcacoesDataProvider
+{
+ private static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
+
+ private static final Object LOCK = new Object();
+ private static RemarcacoesDataProvider instance = null;
+
+ private Executer EXECUTER;
+ private LembretesDataProvider lembretesProvider;
+
+ /** Creates a new instance of RemarcacoesDataProvider */
+ public RemarcacoesDataProvider()
+ throws Exception
+ {
+ DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
+ EXECUTER = dbm.getSharedExecuter( this );
+ lembretesProvider = LembretesDataProvider.getProvider();
+ }
+
+ public static RemarcacoesDataProvider getProvider()
+ throws Exception
+ {
+ synchronized( LOCK )
+ {
+ if( instance == null )
+ {
+ instance = new RemarcacoesDataProvider();
+ }
+ }
+ return instance;
+ }
+
+ public IDObject[] getLembretesRemarcacaoTrabalhador()
+ 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 },
+ 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( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ),
+ new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.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" ) ) ),
+ new String[]{ "trabalhadores.nome_plain" },
+ null,
+ null,
+ null );
+ Virtual2DArray array = EXECUTER.executeQuery( select );
+ IDObject lembretes[] = new IDObject[ array.columnLength() ];
+ for( int n = 0; n < lembretes.length; n++ )
+ {
+ Integer id = ( Integer ) array.get( n, 0 );
+ String descricao = ( String ) array.get( n, 1 );
+ Integer tipoMarcacao = ( Integer ) array.get( n, 2 );
+ String tipoMarcacaoStr = "";
+ switch( tipoMarcacao.intValue() )
+ {
+ case Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES:
+ tipoMarcacaoStr = "ECDs";
+ break;
+
+ case Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA:
+ 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 ) + ". " : " " ) +
+ ( split.length > 1 ? split[ split.length - 1 ] : "" );
+ String estabelecimento = ( String ) array.get( n, 5 );
+ String empresa = ( String ) array.get( n, 6 );
+ String str = "" + trabalhador + ""
+ + "
" + tipoMarcacaoStr + " de " + D_F.format( data )
+ + "
" + descricao + ""
+ + "
" + empresa.substring( 0, empresa.length() > 20 ? 20 : empresa.length() )
+ + " / " + estabelecimento.substring( 0, estabelecimento.length() > 10 ? 10 : estabelecimento.length() )
+ + "";
+ lembretes[ n ] = new MappableObject( id, str );
+ }
+ return lembretes;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoEstabelecimentoAction.java b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoEstabelecimentoAction.java
new file mode 100644
index 00000000..58047330
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoEstabelecimentoAction.java
@@ -0,0 +1,42 @@
+/*
+ * tratarMarcacaoTrabalhadorAction.java
+ *
+ * Created on January 31, 2007, 6:21 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.lembretes.remarcacoes.actions;
+
+import com.evolute.utils.data.IDObject;
+import com.evolute.utils.ui.DialogException;
+import java.awt.event.ActionEvent;
+import javax.swing.AbstractAction;
+
+/**
+ *
+ * @author fpalma
+ */
+public class TratarMarcacaoEstabelecimentoAction extends AbstractAction
+{
+ /**
+ * Creates a new instance of tratarMarcacaoTrabalhadorAction
+ */
+ public TratarMarcacaoEstabelecimentoAction( IDObject marcacaoID )
+ {
+ super( "Tratar" );
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a marcar", true );
+ }
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoTrabalhadorAction.java b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoTrabalhadorAction.java
new file mode 100644
index 00000000..5de7330c
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoTrabalhadorAction.java
@@ -0,0 +1,88 @@
+/*
+ * TratarMarcacaoTrabalhadorAction.java
+ *
+ * Created on January 31, 2007, 6:21 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.lembretes.remarcacoes.actions;
+
+import com.evolute.utils.Singleton;
+import com.evolute.utils.data.IDObject;
+import com.evolute.utils.jdo.JDOProvider;
+import com.evolute.utils.ui.DialogException;
+import java.awt.event.ActionEvent;
+import javax.swing.AbstractAction;
+import javax.swing.JOptionPane;
+import siprp.SIPRPTracker;
+import siprp.SingletonConstants;
+import siprp.data.EmpresaData;
+import siprp.data.EstabelecimentoData;
+import siprp.data.MarcacaoTrabalhadorData;
+import siprp.data.TrabalhadorData;
+import siprp.lembretes.Lembrete;
+import siprp.lembretes.LembretesDataProvider;
+
+/**
+ *
+ * @author fpalma
+ */
+public class TratarMarcacaoTrabalhadorAction extends AbstractAction
+{
+ private LembretesDataProvider lembretesProvider;
+ private JDOProvider JDO;
+ private SIPRPTracker tracker;
+
+ private Integer lembreteID;
+
+ /**
+ * Creates a new instance of TratarMarcacaoTrabalhadorAction
+ */
+ public TratarMarcacaoTrabalhadorAction( IDObject lembrete )
+ {
+ super( "Tratar" );
+ try
+ {
+ lembreteID = lembrete.getID();
+ lembretesProvider = LembretesDataProvider.getProvider();
+ JDO = (JDOProvider) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ }
+ catch( Exception ex )
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ tracker = ( SIPRPTracker ) Singleton.getInstance( SingletonConstants.SIPRP_TRACKER );
+ Lembrete lembrete = lembretesProvider.getLembreteByID( lembreteID );
+ if( lembrete == null )
+ {
+ JOptionPane.showMessageDialog( null, "Este lembrete j\u00e1 foi tratado.", "J\u00e1 tratado",
+ 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 ) );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a tratar", true );
+ }
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoConsultaExtendedPanel.java b/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoConsultaExtendedPanel.java
new file mode 100644
index 00000000..b1cfe077
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoConsultaExtendedPanel.java
@@ -0,0 +1,31 @@
+/*
+ * MarcacaoConsultaExtendedPanel.java
+ *
+ * Created on 13 de Fevereiro de 2007, 20:36
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina;
+
+import java.awt.*;
+import javax.swing.*;
+
+/**
+ *
+ * @author Frederico
+ */
+public class MarcacaoConsultaExtendedPanel extends JPanel
+{
+
+ /** Creates a new instance of MarcacaoConsultaExtendedPanel */
+ public MarcacaoConsultaExtendedPanel()
+ {
+ setupComponents();
+ }
+
+ private void setupComponents()
+ {
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoConsultaPanel.java b/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoConsultaPanel.java
new file mode 100644
index 00000000..5404688a
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoConsultaPanel.java
@@ -0,0 +1,303 @@
+package siprp.medicina;
+
+import com.evolute.utils.*;
+import com.evolute.utils.arrays.*;
+import com.evolute.utils.data.*;
+import com.evolute.utils.dataui.*;
+import com.evolute.utils.db.*;
+import com.evolute.utils.documents.*;
+import com.evolute.utils.sql.*;
+import com.evolute.utils.ui.*;
+import com.evolute.utils.ui.calendar.*;
+import com.evolute.utils.ui.panel.*;
+import com.evolute.utils.ui.text.*;
+import java.awt.*;
+import java.util.*;
+import javax.swing.*;
+import siprp.data.*;
+
+public class MarcacaoConsultaPanel
+ extends JPanel
+ implements ControllableComponent, DataClassAware
+{
+ private siprp.data.MarcacaoTrabalhadorData marcacaoTrabalhadorData;
+ private final ComponentsHashtable components = new ComponentsHashtable();
+
+ protected final SQLExecuter EXECUTER;
+
+ private final JLabel dataLabel = new JLabel( "Data da consulta", JLabel.RIGHT );
+ private final JCalendarPanel dataPanel = new JCalendarPanel( null );
+ private final JButton emailButton = new JButton( "Enviar Email" );
+ private final JLabel dataFichaLabel = new JLabel( "Data da Ficha de Aptid\u00e3o", JLabel.RIGHT );
+ private final JCalendarPanel dataFichaPanel = new JCalendarPanel( null );
+ private RadioButtonFixedPanel tipoList;
+ private RadioButtonFixedPanel estadoList;
+ private final JScrollPane observacoesTextScroll = new JScrollPane();
+ private final StateTextArea observacoesText = new StateTextArea();
+
+ public MarcacaoConsultaPanel()
+ throws Exception
+ {
+ DBManager dbm = ( DBManager )Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
+ if( dbm != null )
+ {
+ EXECUTER = ( SQLExecuter )dbm.getSharedExecuter( this );
+ }
+ else
+ {
+ EXECUTER = null;
+ }
+ setupComponents();
+ setupComponentsHashtable();
+ place();
+ }
+
+ public void setupComponents()
+ throws Exception
+ {
+ JComponent MarcacaoConsultaPanel = this;
+ dataPanel.setMinimumSize( new Dimension( 300, 20 ) );
+ dataPanel.setPreferredSize( new Dimension( 100, 20 ) );
+
+ emailButton.setMinimumSize( new Dimension( 300, 20 ) );
+ emailButton.setPreferredSize( new Dimension( 200, 20 ) );
+
+ dataFichaPanel.setMinimumSize( new Dimension( 300, 20 ) );
+ dataFichaPanel.setPreferredSize( new Dimension( 100, 20 ) );
+
+ IDObject tipoListOptions[] = new IDObject[]{
+ new MappableObject( new Integer( 1 ), "Admiss\u00e3o" ),
+ new MappableObject( new Integer( 2 ), "Peri\u00f3dico" ),
+ new MappableObject( new Integer( 5 ), "Peri\u00f3dico inicial" ),
+ new MappableObject( new Integer( 3 ), "Ocasional" ),
+ };
+ tipoList = new RadioButtonFixedPanel( tipoListOptions, 4, 1, RadioButtonFixedPanel.ORIENTATION_VERTICAL, false, null );
+ tipoList.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Tipo" ) );
+
+ IDObject estadoListOptions[] = new IDObject[]{
+ new MappableObject( new Integer( 0 ), "Por realizar" ),
+ new MappableObject( new Integer( 2 ), "Realizada" ),
+ new MappableObject( new Integer( 3 ), "Desmarcada pelo trabalhador" ),
+ new MappableObject( new Integer( 4 ), "Desmarcada pela SIPRP" ),
+ new MappableObject( new Integer( 5 ), "Faltou" ),
+ };
+ estadoList = new RadioButtonFixedPanel( estadoListOptions, 6, 1, RadioButtonFixedPanel.ORIENTATION_VERTICAL, false, null );
+ estadoList.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Estado" ) );
+
+ observacoesTextScroll.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Observa\u00e7\u00f5es" ) );
+ observacoesText.setLineWrap( true );
+ observacoesText.setWrapStyleWord( true );
+ observacoesText.setRows( 5 );
+
+ }
+
+ public void place()
+ {
+ JPanel MarcacaoConsultaPanel = this;
+ GridBagConstraints MarcacaoConsultaPanelGBC = new GridBagConstraints();
+ MarcacaoConsultaPanelGBC.insets = new Insets( 1, 1, 1, 1 );
+ GridBagLayout MarcacaoConsultaPanelLayout = new GridBagLayout();
+ MarcacaoConsultaPanel.setLayout( MarcacaoConsultaPanelLayout );
+ MarcacaoConsultaPanelGBC.gridx = 0;
+ MarcacaoConsultaPanelGBC.gridy = 0;
+ MarcacaoConsultaPanelGBC.gridwidth = 1;
+ MarcacaoConsultaPanelGBC.gridheight = 1;
+ MarcacaoConsultaPanelGBC.weightx = 0.0;
+ MarcacaoConsultaPanelGBC.weighty = 0.0;
+ MarcacaoConsultaPanelGBC.fill = GridBagConstraints.HORIZONTAL;
+ MarcacaoConsultaPanelLayout.setConstraints( dataLabel, MarcacaoConsultaPanelGBC );
+ MarcacaoConsultaPanel.add( dataLabel );
+
+ MarcacaoConsultaPanelGBC.gridx = 1;
+ MarcacaoConsultaPanelGBC.gridy = 0;
+ MarcacaoConsultaPanelGBC.gridwidth = 1;
+ MarcacaoConsultaPanelGBC.gridheight = 1;
+ MarcacaoConsultaPanelGBC.weightx = 0.5;
+ MarcacaoConsultaPanelGBC.weighty = 0.0;
+ MarcacaoConsultaPanelGBC.fill = GridBagConstraints.HORIZONTAL;
+ MarcacaoConsultaPanelLayout.setConstraints( dataPanel, MarcacaoConsultaPanelGBC );
+ MarcacaoConsultaPanel.add( dataPanel );
+
+ MarcacaoConsultaPanelGBC.gridx = 2;
+ MarcacaoConsultaPanelGBC.gridy = 0;
+ MarcacaoConsultaPanelGBC.gridwidth = 1;
+ MarcacaoConsultaPanelGBC.gridheight = 1;
+ MarcacaoConsultaPanelGBC.weightx = 0.5;
+ MarcacaoConsultaPanelGBC.weighty = 0.0;
+ MarcacaoConsultaPanelGBC.fill = GridBagConstraints.NONE;
+ MarcacaoConsultaPanelLayout.setConstraints( emailButton, MarcacaoConsultaPanelGBC );
+ MarcacaoConsultaPanel.add( emailButton );
+
+ MarcacaoConsultaPanelGBC.gridx = 0;
+ MarcacaoConsultaPanelGBC.gridy = 1;
+ MarcacaoConsultaPanelGBC.gridwidth = 1;
+ MarcacaoConsultaPanelGBC.gridheight = 1;
+ MarcacaoConsultaPanelGBC.weightx = 0.0;
+ MarcacaoConsultaPanelGBC.weighty = 0.0;
+ MarcacaoConsultaPanelGBC.fill = GridBagConstraints.HORIZONTAL;
+ MarcacaoConsultaPanelLayout.setConstraints( dataFichaLabel, MarcacaoConsultaPanelGBC );
+ MarcacaoConsultaPanel.add( dataFichaLabel );
+
+ MarcacaoConsultaPanelGBC.gridx = 1;
+ MarcacaoConsultaPanelGBC.gridy = 1;
+ MarcacaoConsultaPanelGBC.gridwidth = 1;
+ MarcacaoConsultaPanelGBC.gridheight = 1;
+ MarcacaoConsultaPanelGBC.weightx = 0.5;
+ MarcacaoConsultaPanelGBC.weighty = 0.0;
+ MarcacaoConsultaPanelGBC.fill = GridBagConstraints.HORIZONTAL;
+ MarcacaoConsultaPanelLayout.setConstraints( dataFichaPanel, MarcacaoConsultaPanelGBC );
+ MarcacaoConsultaPanel.add( dataFichaPanel );
+
+ MarcacaoConsultaPanelGBC.gridx = 0;
+ MarcacaoConsultaPanelGBC.gridy = 2;
+ MarcacaoConsultaPanelGBC.gridwidth = 2;
+ MarcacaoConsultaPanelGBC.gridheight = 1;
+ MarcacaoConsultaPanelGBC.weightx = 0.5;
+ MarcacaoConsultaPanelGBC.weighty = 0.0;
+ MarcacaoConsultaPanelGBC.fill = GridBagConstraints.BOTH;
+ MarcacaoConsultaPanelLayout.setConstraints( tipoList, MarcacaoConsultaPanelGBC );
+ MarcacaoConsultaPanel.add( tipoList );
+
+ MarcacaoConsultaPanelGBC.gridx = 2;
+ MarcacaoConsultaPanelGBC.gridy = 2;
+ MarcacaoConsultaPanelGBC.gridwidth = 1;
+ MarcacaoConsultaPanelGBC.gridheight = 1;
+ MarcacaoConsultaPanelGBC.weightx = 0.5;
+ MarcacaoConsultaPanelGBC.weighty = 0.0;
+ MarcacaoConsultaPanelGBC.fill = GridBagConstraints.BOTH;
+ MarcacaoConsultaPanelLayout.setConstraints( estadoList, MarcacaoConsultaPanelGBC );
+ MarcacaoConsultaPanel.add( estadoList );
+
+ MarcacaoConsultaPanelGBC.gridx = 0;
+ MarcacaoConsultaPanelGBC.gridy = 3;
+ MarcacaoConsultaPanelGBC.gridwidth = 3;
+ MarcacaoConsultaPanelGBC.gridheight = 1;
+ MarcacaoConsultaPanelGBC.weightx = 1.0;
+ MarcacaoConsultaPanelGBC.weighty = 1.0;
+ observacoesTextScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ observacoesTextScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED );
+ observacoesTextScroll.setViewportView( observacoesText );
+ MarcacaoConsultaPanelGBC.fill = GridBagConstraints.BOTH;
+ MarcacaoConsultaPanelLayout.setConstraints( observacoesTextScroll, MarcacaoConsultaPanelGBC );
+ MarcacaoConsultaPanel.add( observacoesTextScroll );
+
+ }
+
+ private void setupComponentsHashtable()
+ {
+ components.putComponent( siprp.data.MarcacaoTrabalhadorData.DATA, dataPanel );
+ components.putComponent( siprp.data.MarcacaoTrabalhadorData.DATA_RELATORIO, dataFichaPanel );
+ components.putComponent( siprp.data.MarcacaoTrabalhadorData.MOTIVO, tipoList );
+ components.putComponent( siprp.data.MarcacaoTrabalhadorData.ESTADO, estadoList );
+ components.putComponent( siprp.data.MarcacaoTrabalhadorData.OBSERVACOES, observacoesText );
+ }
+
+ public void fill( Object toFill )
+ {
+ clear();
+ if( toFill == null || !( toFill instanceof PropertyObject ) )
+ {
+ return;
+ }
+ Hashtable data = null;
+ if( toFill instanceof PropertyObject )
+ {
+ data = ( (PropertyObject) toFill ).getHashData();
+ if( toFill instanceof siprp.data.MarcacaoTrabalhadorData )
+ {
+ marcacaoTrabalhadorData = (siprp.data.MarcacaoTrabalhadorData) toFill;
+ }
+ }
+ else if( toFill instanceof Hashtable )
+ {
+ data = (Hashtable) toFill;
+ }
+ else
+ {
+ return;
+ }
+ if( marcacaoTrabalhadorData == null )
+ {
+ marcacaoTrabalhadorData = new siprp.data.MarcacaoTrabalhadorData();
+ marcacaoTrabalhadorData.setHashData( data );
+ }
+ PropertyObject po = (PropertyObject) toFill;
+ String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
+ ComponentController.fill( properties, po.getHashData(), components );
+ }
+
+ public Object save()
+ {
+ if( marcacaoTrabalhadorData == null )
+ {
+ marcacaoTrabalhadorData = new siprp.data.MarcacaoTrabalhadorData();
+ }
+ Hashtable data = marcacaoTrabalhadorData.getHashData();
+ String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
+ ComponentController.save( properties, data, components );
+ if( !( marcacaoTrabalhadorData instanceof PropertyObject ) )
+ {
+ return data;
+ }
+ marcacaoTrabalhadorData.setHashData( data );
+ return marcacaoTrabalhadorData;
+ }
+
+ public void clear()
+ {
+ marcacaoTrabalhadorData = null;
+ String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
+ ComponentController.clear( properties, components );
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
+ ComponentController.setEnabled( properties, enable, components );
+ }
+
+ public Class getDataClass()
+ {
+ return siprp.data.MarcacaoTrabalhadorData.class;
+ }
+
+ public JLabel getDataFichaLabel()
+ {
+ return dataFichaLabel;
+ }
+
+ public JCalendarPanel getDataFichaPanel()
+ {
+ return dataFichaPanel;
+ }
+
+ public JLabel getDataLabel()
+ {
+ return dataLabel;
+ }
+
+ public JCalendarPanel getDataPanel()
+ {
+ return dataPanel;
+ }
+
+ public JButton getEmailButton()
+ {
+ return emailButton;
+ }
+
+ public RadioButtonFixedPanel getEstadoList()
+ {
+ return estadoList;
+ }
+
+ public StateTextArea getObservacoesText()
+ {
+ return observacoesText;
+ }
+
+ public RadioButtonFixedPanel getTipoList()
+ {
+ return tipoList;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoConsultaPanel.xml b/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoConsultaPanel.xml
new file mode 100644
index 00000000..7229c554
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoConsultaPanel.xml
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+ siprp.data.*
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Tipo
+
+ 4
+
+
+ Admiss\u00e3o
+ Peri\u00f3dico
+ Peri\u00f3dico inicial
+ Ocasional
+
+
+
+
+ Estado
+
+ 6
+
+
+ Por realizar
+ Realizada
+ Desmarcada pelo trabalhador
+ Desmarcada pela SIPRP
+ Faltou
+
+
+
+
+
+ Observa\u00e7\u00f5es
+
+
+ 5
+
+
+
+
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoExamePanel.java b/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoExamePanel.java
new file mode 100644
index 00000000..d1f4fd75
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoExamePanel.java
@@ -0,0 +1,262 @@
+package siprp.medicina;
+
+import com.evolute.utils.*;
+import com.evolute.utils.arrays.*;
+import com.evolute.utils.data.*;
+import com.evolute.utils.dataui.*;
+import com.evolute.utils.db.*;
+import com.evolute.utils.documents.*;
+import com.evolute.utils.sql.*;
+import com.evolute.utils.ui.*;
+import com.evolute.utils.ui.calendar.*;
+import com.evolute.utils.ui.panel.*;
+import com.evolute.utils.ui.text.*;
+import java.awt.*;
+import java.util.*;
+import javax.swing.*;
+import siprp.data.*;
+
+public class MarcacaoExamePanel
+ extends JPanel
+ implements ControllableComponent, DataClassAware
+{
+ private siprp.data.MarcacaoTrabalhadorData marcacaoTrabalhadorData;
+ private final ComponentsHashtable components = new ComponentsHashtable();
+
+ protected final SQLExecuter EXECUTER;
+
+ private final JLabel dataLabel = new JLabel( "Data dos Exames", JLabel.RIGHT );
+ private final JCalendarPanel dataPanel = new JCalendarPanel( null );
+ private final JButton emailButton = new JButton( "Enviar Email" );
+ private final JPanelControllable detalhesPanel = new JPanelControllable();
+ private RadioButtonFixedPanel estadoList;
+ private final JScrollPane observacoesTextScroll = new JScrollPane();
+ private final StateTextArea observacoesText = new StateTextArea();
+
+ public MarcacaoExamePanel()
+ throws Exception
+ {
+ DBManager dbm = ( DBManager )Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
+ if( dbm != null )
+ {
+ EXECUTER = ( SQLExecuter )dbm.getSharedExecuter( this );
+ }
+ else
+ {
+ EXECUTER = null;
+ }
+ setupComponents();
+ setupComponentsHashtable();
+ place();
+ }
+
+ public void setupComponents()
+ throws Exception
+ {
+ JComponent MarcacaoExamePanel = this;
+ emailButton.setMinimumSize( new Dimension( 300, 20 ) );
+ emailButton.setPreferredSize( new Dimension( 200, 20 ) );
+
+ detalhesPanel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Detalhes" ) );
+
+ IDObject estadoListOptions[] = new IDObject[]{
+ new MappableObject( new Integer( 0 ), "Por realizar" ),
+ new MappableObject( new Integer( 1 ), "Parcialmente realizados" ),
+ new MappableObject( new Integer( 2 ), "Realizados" ),
+ new MappableObject( new Integer( 3 ), "Desmarcados pelo trabalhador" ),
+ new MappableObject( new Integer( 4 ), "Desmarcados pela SIPRP" ),
+ new MappableObject( new Integer( 5 ), "Faltou" ),
+ };
+ estadoList = new RadioButtonFixedPanel( estadoListOptions, 6, 1, RadioButtonFixedPanel.ORIENTATION_VERTICAL, false, null );
+ estadoList.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Estado" ) );
+
+ observacoesTextScroll.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Observa\u00e7\u00f5es" ) );
+ observacoesText.setLineWrap( true );
+ observacoesText.setWrapStyleWord( true );
+ observacoesText.setRows( 5 );
+
+ }
+
+ public void place()
+ {
+ JPanel MarcacaoExamePanel = this;
+ GridBagConstraints detalhesPanelGBC = new GridBagConstraints();
+ detalhesPanelGBC.insets = new Insets( 1, 1, 1, 1 );
+ GridBagLayout detalhesPanelLayout = new GridBagLayout();
+ detalhesPanel.setLayout( detalhesPanelLayout );
+ GridBagConstraints MarcacaoExamePanelGBC = new GridBagConstraints();
+ MarcacaoExamePanelGBC.insets = new Insets( 1, 1, 1, 1 );
+ GridBagLayout MarcacaoExamePanelLayout = new GridBagLayout();
+ MarcacaoExamePanel.setLayout( MarcacaoExamePanelLayout );
+ MarcacaoExamePanelGBC.gridx = 0;
+ MarcacaoExamePanelGBC.gridy = 0;
+ MarcacaoExamePanelGBC.gridwidth = 1;
+ MarcacaoExamePanelGBC.gridheight = 1;
+ MarcacaoExamePanelGBC.weightx = 0.0;
+ MarcacaoExamePanelGBC.weighty = 0.0;
+ MarcacaoExamePanelGBC.fill = GridBagConstraints.HORIZONTAL;
+ MarcacaoExamePanelLayout.setConstraints( dataLabel, MarcacaoExamePanelGBC );
+ MarcacaoExamePanel.add( dataLabel );
+
+ MarcacaoExamePanelGBC.gridx = 1;
+ MarcacaoExamePanelGBC.gridy = 0;
+ MarcacaoExamePanelGBC.gridwidth = 1;
+ MarcacaoExamePanelGBC.gridheight = 1;
+ MarcacaoExamePanelGBC.weightx = 0.5;
+ MarcacaoExamePanelGBC.weighty = 0.0;
+ MarcacaoExamePanelGBC.fill = GridBagConstraints.HORIZONTAL;
+ MarcacaoExamePanelLayout.setConstraints( dataPanel, MarcacaoExamePanelGBC );
+ MarcacaoExamePanel.add( dataPanel );
+
+ MarcacaoExamePanelGBC.gridx = 2;
+ MarcacaoExamePanelGBC.gridy = 0;
+ MarcacaoExamePanelGBC.gridwidth = 1;
+ MarcacaoExamePanelGBC.gridheight = 1;
+ MarcacaoExamePanelGBC.weightx = 0.5;
+ MarcacaoExamePanelGBC.weighty = 0.0;
+ MarcacaoExamePanelGBC.fill = GridBagConstraints.NONE;
+ MarcacaoExamePanelLayout.setConstraints( emailButton, MarcacaoExamePanelGBC );
+ MarcacaoExamePanel.add( emailButton );
+
+ MarcacaoExamePanelGBC.gridx = 0;
+ MarcacaoExamePanelGBC.gridy = 1;
+ MarcacaoExamePanelGBC.gridwidth = 2;
+ MarcacaoExamePanelGBC.gridheight = 1;
+ MarcacaoExamePanelGBC.weightx = 0.5;
+ MarcacaoExamePanelGBC.weighty = 0.0;
+ MarcacaoExamePanelGBC.fill = GridBagConstraints.BOTH;
+ MarcacaoExamePanelLayout.setConstraints( detalhesPanel, MarcacaoExamePanelGBC );
+ MarcacaoExamePanel.add( detalhesPanel );
+
+ MarcacaoExamePanelGBC.gridx = 2;
+ MarcacaoExamePanelGBC.gridy = 1;
+ MarcacaoExamePanelGBC.gridwidth = 1;
+ MarcacaoExamePanelGBC.gridheight = 1;
+ MarcacaoExamePanelGBC.weightx = 0.5;
+ MarcacaoExamePanelGBC.weighty = 0.0;
+ MarcacaoExamePanelGBC.fill = GridBagConstraints.BOTH;
+ MarcacaoExamePanelLayout.setConstraints( estadoList, MarcacaoExamePanelGBC );
+ MarcacaoExamePanel.add( estadoList );
+
+ MarcacaoExamePanelGBC.gridx = 0;
+ MarcacaoExamePanelGBC.gridy = 2;
+ MarcacaoExamePanelGBC.gridwidth = 3;
+ MarcacaoExamePanelGBC.gridheight = 1;
+ MarcacaoExamePanelGBC.weightx = 1.0;
+ MarcacaoExamePanelGBC.weighty = 1.0;
+ observacoesTextScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ observacoesTextScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED );
+ observacoesTextScroll.setViewportView( observacoesText );
+ MarcacaoExamePanelGBC.fill = GridBagConstraints.BOTH;
+ MarcacaoExamePanelLayout.setConstraints( observacoesTextScroll, MarcacaoExamePanelGBC );
+ MarcacaoExamePanel.add( observacoesTextScroll );
+
+ }
+
+ private void setupComponentsHashtable()
+ {
+ components.putComponent( siprp.data.MarcacaoTrabalhadorData.DATA, dataPanel );
+ components.putComponent( siprp.data.MarcacaoTrabalhadorData.ESTADO, estadoList );
+ components.putComponent( siprp.data.MarcacaoTrabalhadorData.OBSERVACOES, observacoesText );
+ }
+
+ public void fill( Object toFill )
+ {
+ clear();
+ if( toFill == null || !( toFill instanceof PropertyObject ) )
+ {
+ return;
+ }
+ Hashtable data = null;
+ if( toFill instanceof PropertyObject )
+ {
+ data = ( (PropertyObject) toFill ).getHashData();
+ if( toFill instanceof siprp.data.MarcacaoTrabalhadorData )
+ {
+ marcacaoTrabalhadorData = (siprp.data.MarcacaoTrabalhadorData) toFill;
+ }
+ }
+ else if( toFill instanceof Hashtable )
+ {
+ data = (Hashtable) toFill;
+ }
+ else
+ {
+ return;
+ }
+ if( marcacaoTrabalhadorData == null )
+ {
+ marcacaoTrabalhadorData = new siprp.data.MarcacaoTrabalhadorData();
+ marcacaoTrabalhadorData.setHashData( data );
+ }
+ PropertyObject po = (PropertyObject) toFill;
+ String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
+ ComponentController.fill( properties, po.getHashData(), components );
+ }
+
+ public Object save()
+ {
+ if( marcacaoTrabalhadorData == null )
+ {
+ marcacaoTrabalhadorData = new siprp.data.MarcacaoTrabalhadorData();
+ }
+ Hashtable data = marcacaoTrabalhadorData.getHashData();
+ String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
+ ComponentController.save( properties, data, components );
+ if( !( marcacaoTrabalhadorData instanceof PropertyObject ) )
+ {
+ return data;
+ }
+ marcacaoTrabalhadorData.setHashData( data );
+ return marcacaoTrabalhadorData;
+ }
+
+ public void clear()
+ {
+ marcacaoTrabalhadorData = null;
+ String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
+ ComponentController.clear( properties, components );
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
+ ComponentController.setEnabled( properties, enable, components );
+ }
+
+ public Class getDataClass()
+ {
+ return siprp.data.MarcacaoTrabalhadorData.class;
+ }
+
+ public JLabel getDataLabel()
+ {
+ return dataLabel;
+ }
+
+ public JCalendarPanel getDataPanel()
+ {
+ return dataPanel;
+ }
+
+ public JPanelControllable getDetalhesPanel()
+ {
+ return detalhesPanel;
+ }
+
+ public JButton getEmailButton()
+ {
+ return emailButton;
+ }
+
+ public RadioButtonFixedPanel getEstadoList()
+ {
+ return estadoList;
+ }
+
+ public StateTextArea getObservacoesText()
+ {
+ return observacoesText;
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoExamePanel.xml b/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoExamePanel.xml
new file mode 100644
index 00000000..bb5e2ab1
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoExamePanel.xml
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+ siprp.data.*
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Detalhes
+
+
+
+
+
+
+
+
+ Estado
+
+ 6
+
+
+ Por realizar
+ Parcialmente realizados
+ Realizados
+ Desmarcados pelo trabalhador
+ Desmarcados pela SIPRP
+ Faltou
+
+
+
+
+
+ Observa\u00e7\u00f5es
+
+
+ 5
+
+
+
+
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MarcacoesMedicinaHandler.java b/trunk/SIPRPSoft/src/siprp/medicina/MarcacoesMedicinaHandler.java
new file mode 100644
index 00000000..2ccce75a
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/MarcacoesMedicinaHandler.java
@@ -0,0 +1,93 @@
+/*
+ * MarcacoesMedicinaHandler.java
+ *
+ * Created on 28 de Abril de 2006, 9:56
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina;
+
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.jdo.*;
+
+import siprp.data.*;
+
+/**
+ * Classe auxiliar para tratamento de marcações de Medicina.
+ *
+ * @author Frederico
+ */
+public class MarcacoesMedicinaHandler
+{
+ /** Creates a new instance of MarcacoesMedicinaHandler */
+ public MarcacoesMedicinaHandler()
+ {
+ }
+
+ /**
+ * Ajusta os estado das marações corrente e seguinte para uma trabalhador.
+ * Este método é usado pelo sistema de marcaç&atild;o de fichas de aptidaão para ajustar
+ * as marcações existentes às escolhidas na ficha.
+ *
+ * @param trabalhadorID um inteiro que representa o trabalhador em questão
+ * @param motivoCorrente um inteiro que representa o motivo da marcação corrente (admissão/periódico/ocasional)
+ * @param dataCorrente a data que se pretende para a marcação corrente
+ * @param motivoSeguinte um inteiro que representa o motivo da marcação seguinte (admissão/periódico/ocasional)
+ * @param dataSeguinte a data que se pretende para a marcação seguinte
+ * @throws Exception se houver um erro na comunicação com a Base de Dados
+ */
+ public void ajustarMarcacoes( Integer trabalhadorID, Integer motivoCorrente, Date dataCorrente,
+ Integer motivoSeguinte, Date dataSeguinte )
+ throws Exception
+ {
+ Integer idCorrente;
+ Integer idSeguinte;
+ MedicinaDataProvider provider = ( MedicinaDataProvider ) MedicinaDataProvider.getProvider();
+ JDOProvider JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ TrabalhadorData trabalhador = (TrabalhadorData)JDO.load( TrabalhadorData.class, trabalhadorID );
+
+ idCorrente = provider.getConsultaIDByTrabalhadorMotivoAndDate( trabalhadorID, motivoCorrente, dataCorrente );
+ MarcacaoTrabalhadorData consultaCorrente;
+ if( idCorrente == null )
+ {
+ consultaCorrente = new MarcacaoTrabalhadorData();
+ consultaCorrente.set( MarcacaoTrabalhadorData.TRABALHADOR, trabalhador );
+ consultaCorrente.set( MarcacaoTrabalhadorData.TIPO, new Integer( MarcacaoTrabalhadorData.TIPO_CONSULTA ) );
+ consultaCorrente.set( Marcacao.DATA, dataCorrente );
+ consultaCorrente.set( MarcacaoTrabalhadorData.MOTIVO, motivoCorrente );
+ }
+ else
+ {
+ consultaCorrente = ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, idCorrente );
+ }
+ consultaCorrente.set( Marcacao.REALIZADA, "y" );
+ consultaCorrente.set( MarcacaoTrabalhadorData.ESTADO, new Integer( siprp.medicina.MedicinaDataProvider.ESTADO_REALIZADO ) );
+ consultaCorrente.save();
+
+ idSeguinte = provider.getConsultaIDByTrabalhadorMotivoAndDate( trabalhadorID, motivoSeguinte, dataSeguinte );
+ if( idSeguinte == null )
+ {
+ idSeguinte = provider.getProximaConsultaIDByTrabalhadorMotivoAndDate( trabalhadorID, motivoSeguinte, dataCorrente );
+ MarcacaoTrabalhadorData consultaSeguinte;
+ if( idSeguinte == null )
+ {
+ consultaSeguinte = new MarcacaoTrabalhadorData();
+ consultaSeguinte.set( MarcacaoTrabalhadorData.TRABALHADOR, trabalhador );
+ consultaSeguinte.set( MarcacaoTrabalhadorData.TIPO, new Integer( MarcacaoTrabalhadorData.TIPO_CONSULTA ) );
+ consultaSeguinte.set( MarcacaoTrabalhadorData.MOTIVO, motivoSeguinte );
+ consultaSeguinte.set( Marcacao.REALIZADA, "y" );
+ consultaSeguinte.set( MarcacaoTrabalhadorData.ESTADO, new Integer( siprp.medicina.MedicinaDataProvider.ESTADO_POR_REALIZAR ) );
+ }
+ else
+ {
+ consultaSeguinte = ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, idSeguinte );
+ }
+ consultaSeguinte.set( Marcacao.DATA, dataSeguinte );
+ consultaSeguinte.save();
+ }
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MedicinaConstants.java b/trunk/SIPRPSoft/src/siprp/medicina/MedicinaConstants.java
new file mode 100644
index 00000000..a09a59f8
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/MedicinaConstants.java
@@ -0,0 +1,75 @@
+/*
+ * MedicinaConstants.java
+ *
+ * Created on 6 de Julho de 2006, 15:22
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina;
+
+import com.evolute.utils.Singleton;
+import siprp.SingletonConstants;
+
+/**
+ *
+ * @author fpalma
+ */
+public interface MedicinaConstants
+{
+ public static final int MOTIVO_ADMISSAO = 1;
+ public static final Integer MOTIVO_ADMISSAO_INTEGER = new Integer( MOTIVO_ADMISSAO );
+ public static final String MOTIVO_ADMISSAO_STR = "Admiss\u00e3o";
+ public static final int MOTIVO_PERIODICO = 2;
+ public static final Integer MOTIVO_PERIODICO_INTEGER = new Integer( MOTIVO_PERIODICO );
+ public static final String MOTIVO_PERIODICO_STR = "Peri\u00f3dico";
+ public static final int MOTIVO_OCASIONAL = 3;
+ public static final Integer MOTIVO_OCASIONAL_INTEGER = new Integer( MOTIVO_OCASIONAL );
+ public static final String MOTIVO_OCASIONAL_STR = "Ocasional";
+ public static final int MOTIVO_PERIODICO_INICIAL = 5;
+ public static final Integer MOTIVO_PERIODICO_INICIAL_INTEGER = new Integer( MOTIVO_PERIODICO_INICIAL );
+ public static final String MOTIVO_PERIODICO_INICIAL_STR = "Peri\u00f3dico inicial";
+
+ public static final int SUB_MOTIVO_APOS_DOENCA = 1;
+ public static final Integer SUB_MOTIVO_APOS_DOENCA_INTEGER = new Integer( SUB_MOTIVO_APOS_DOENCA );
+ public static final String SUB_MOTIVO_APOS_DOENCA_STR = "Ap\u00f3s doen\u00e7a";
+ public static final int SUB_MOTIVO_APOS_ACIDENTE = 2;
+ public static final Integer SUB_MOTIVO_APOS_ACIDENTE_INTEGER = new Integer( SUB_MOTIVO_APOS_ACIDENTE );
+ public static final String SUB_MOTIVO_APOS_ACIDENTE_STR = "Ap\u00f3s acidente";
+ public static final int SUB_MOTIVO_PEDIDO_TRABALHADOR = 3;
+ public static final Integer SUB_MOTIVO_PEDIDO_TRABALHADOR_INTEGER = new Integer( SUB_MOTIVO_PEDIDO_TRABALHADOR );
+ public static final String SUB_MOTIVO_PEDIDO_TRABALHADOR_STR = "A pedido do trabalhador";
+ public static final int SUB_MOTIVO_PEDIDO_SERVICO = 4;
+ public static final Integer SUB_MOTIVO_PEDIDO_SERVICO_INTEGER = new Integer( SUB_MOTIVO_PEDIDO_SERVICO );
+ public static final String SUB_MOTIVO_PEDIDO_SERVICO_STR = "A pedido do servi\u00e7o";
+ public static final int SUB_MOTIVO_MUDANCA_FUNCAO = 5;
+ public static final Integer SUB_MOTIVO_MUDANCA_FUNCAO_INTEGER = new Integer( SUB_MOTIVO_MUDANCA_FUNCAO );
+ public static final String SUB_MOTIVO_MUDANCA_FUNCAO_STR = "Por mudan\u00e7a de fun\u00e7\u00e3o";
+ public static final int SUB_MOTIVO_ALTERACAO_CONDICOES = 6;
+ public static final Integer SUB_MOTIVO_ALTERACAO_CONDICOES_INTEGER = new Integer( SUB_MOTIVO_ALTERACAO_CONDICOES );
+ public static final String SUB_MOTIVO_ALTERACAO_CONDICOES_STR = "Por altera\u00e7\u00e3o das condi\u00e7\u00f5es de trabalho";
+ public static final int SUB_MOTIVO_OUTRO = 10;
+ public static final Integer SUB_MOTIVO_OUTRO_INTEGER = new Integer( SUB_MOTIVO_OUTRO );
+ public static final String SUB_MOTIVO_OUTRO_STR = "Outro";
+
+ public static final int ESTADO_POR_REALIZAR = 0;
+ public static final int ESTADO_PARCIALMENTE_REALIZADO = 1;
+ public static final int ESTADO_REALIZADO = 2;
+ public static final int ESTADO_DESMARCADO_TRABALHADOR = 3;
+ public static final int ESTADO_DESMARCADO_EMPRESA = 4;
+ public static final int ESTADO_FALTOU = 5;
+
+ public static final String ESTADOS_CONSULTA_STR[] =
+ new String[]{ "Por Realizar", null, "Realizada",
+ "Desmarcada pelo Trabalhador", "Desmarcada pela " + Singleton.getInstance( SingletonConstants.COMPANY_ACRONYM ),
+ "Trabalhador Faltou" };
+
+ public static final String ESTADOS_EXAME_STR[] =
+ new String[]{ "Por Realizar", "Parcialmente Realizados", "Realizados",
+ "Desmarcados pelo Trabalhador", "Desmarcados pela " + Singleton.getInstance( SingletonConstants.COMPANY_ACRONYM ),
+ "Trabalhador Faltou" };
+
+ public static final String ESTADOS_STR[][] =
+ new String[][]{ ESTADOS_EXAME_STR, ESTADOS_CONSULTA_STR };
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MedicinaDataProvider.java b/trunk/SIPRPSoft/src/siprp/medicina/MedicinaDataProvider.java
new file mode 100644
index 00000000..52c1ce92
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/MedicinaDataProvider.java
@@ -0,0 +1,462 @@
+/*
+ * MedicinaDataProvider.java
+ *
+ * Created on January 29, 2006, 12:27 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina;
+
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.arrays.*;
+import com.evolute.utils.data.*;
+import com.evolute.utils.db.*;
+import com.evolute.utils.metadb.*;
+import com.evolute.utils.sql.*;
+import com.evolute.utils.tables.*;
+
+import siprp.*;
+import siprp.data.*;
+/**
+ *
+ * @author fpalma
+ */
+public class MedicinaDataProvider extends MetaProvider
+ implements MedicinaConstants
+{
+
+
+ public static final String TIPOS_CONSULTAS[] =
+ new String[]{ "", MOTIVO_ADMISSAO_STR, MOTIVO_PERIODICO_STR, MOTIVO_OCASIONAL_STR, "", MOTIVO_PERIODICO_INICIAL_STR };
+
+ public static final HashMap MOTIVOS_BY_ID =
+ new HashMap();
+
+ public static final HashMap SUB_MOTIVOS_BY_ID =
+ new HashMap();
+
+ public static final HashMap SUB_MOTIVOS_IDS_BY_MOTIVO_ID =
+ new HashMap();
+
+// public static final String ESTADOS_EXAME_STR[] =
+// new String[]{ "Por realizar", "Parcialmente realizado", "Realizado",
+// "Desmarcado trabalhador",
+// "Desmarcado " + Singleton.getInstance( SingletonConstants.COMPANY_ACRONYM ),
+// "Faltou" };
+//
+// public static final String ESTADOS_CONSULTA_STR[] =
+// new String[]{ "Por realizar", "Parcialmente realizada", "Realizada",
+// "Desmarcada trabalhador",
+// "Desmarcada " + Singleton.getInstance( SingletonConstants.COMPANY_ACRONYM ),
+// "Faltou" };
+
+ private static final Object LOCK = new Object();
+ private static MedicinaDataProvider instance = null;
+
+ static
+ {
+ MOTIVOS_BY_ID.put( MOTIVO_ADMISSAO_INTEGER, MOTIVO_ADMISSAO_STR );
+ MOTIVOS_BY_ID.put( MOTIVO_PERIODICO_INTEGER, MOTIVO_PERIODICO_STR );
+ MOTIVOS_BY_ID.put( MOTIVO_OCASIONAL_INTEGER, MOTIVO_OCASIONAL_STR );
+ MOTIVOS_BY_ID.put( MOTIVO_PERIODICO_INICIAL_INTEGER, MOTIVO_PERIODICO_INICIAL_STR );
+
+ SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_APOS_DOENCA_INTEGER, SUB_MOTIVO_APOS_DOENCA_STR );
+ SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_APOS_ACIDENTE_INTEGER, SUB_MOTIVO_APOS_ACIDENTE_STR );
+ SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_PEDIDO_TRABALHADOR_INTEGER, SUB_MOTIVO_PEDIDO_TRABALHADOR_STR );
+ SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_PEDIDO_SERVICO_INTEGER, SUB_MOTIVO_PEDIDO_SERVICO_STR );
+ SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_MUDANCA_FUNCAO_INTEGER, SUB_MOTIVO_MUDANCA_FUNCAO_STR );
+ SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_ALTERACAO_CONDICOES_INTEGER, SUB_MOTIVO_ALTERACAO_CONDICOES_STR );
+ SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_OUTRO_INTEGER, SUB_MOTIVO_OUTRO_STR );
+
+ SUB_MOTIVOS_IDS_BY_MOTIVO_ID.put( MOTIVO_OCASIONAL_INTEGER,
+ new Integer[]{ SUB_MOTIVO_APOS_DOENCA_INTEGER, SUB_MOTIVO_APOS_ACIDENTE_INTEGER,
+ SUB_MOTIVO_PEDIDO_TRABALHADOR_INTEGER, SUB_MOTIVO_PEDIDO_SERVICO_INTEGER,
+ SUB_MOTIVO_MUDANCA_FUNCAO_INTEGER, SUB_MOTIVO_ALTERACAO_CONDICOES_INTEGER,
+ SUB_MOTIVO_OUTRO_INTEGER } );
+ }
+
+ private final Executer executer;
+
+ /** Creates a new instance of MedicinaDataProvider */
+ public MedicinaDataProvider()
+ throws Exception
+ {
+ DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ );
+ executer = dbm.getSharedExecuter( this );
+ }
+
+ public static MetaProvider getProvider()
+ throws Exception
+ {
+ synchronized( LOCK )
+ {
+ if( instance == null )
+ {
+ instance = new MedicinaDataProvider();
+ }
+ }
+ return instance;
+ }
+
+ public String []getEmpresaEstabelecimento( Integer empresaID, Integer estabelecimentoID )
+ throws Exception
+ {
+ String nomes[] = new String[ 2 ];
+ Select select = new Select( new String[]{ "empresas" },
+ new String[]{ "designacao_social" },
+ new Field( "id" ).isEqual( empresaID ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ nomes[ 0 ] = ( String ) array.get( 0, 0 );
+
+ select = new Select( new String[]{ "estabelecimentos" },
+ new String[]{ "nome" },
+ new Field( "id" ).isEqual( estabelecimentoID ) );
+ array = executer.executeQuery( select );
+ nomes[ 1 ] = ( String ) array.get( 0, 0 );
+
+ return nomes;
+ }
+
+ public IDObject[] getDetalhesValidosTrabalhador( Integer empresaID, Integer trabalhadorID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "trabalhadores" },
+ new String[]{ "perfil" },
+ new Field( "id" ).isEqual( trabalhadorID ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ Integer perfil = ( Integer ) array.get( 0, 0 );
+ if( perfil == null )
+ {
+ return new IDObject[ 0 ];
+ }
+ select =
+ new Select( new String[]{ "prt_elementos_protocolo", "prt_tipos_elementos_protocolo",
+ "prt_grupos_protocolo" },
+ new String[]{ "prt_grupos_protocolo.id" , "prt_grupos_protocolo.descricao",
+ "prt_grupos_protocolo.ordem"},
+ new Field( "prt_elementos_protocolo.empresa_id" ).isEqual( empresaID ).and(
+ new Field( "prt_elementos_protocolo.tipo_elemento_protocolo_id" ).isEqual(
+ new Field( "prt_tipos_elementos_protocolo.id" ) ) ).and(
+ new Field( "prt_tipos_elementos_protocolo.grupo_protocolo_id" ).isEqual(
+ new Field( "prt_grupos_protocolo.id" ) ) ).and(
+ new Field( "prt_elementos_protocolo.numero_perfil" ).isEqual( perfil ) ),
+ new String[]{ "prt_grupos_protocolo.ordem" },
+ null );
+ array = executer.executeQuery( select );
+ Vector detalhes = new Vector();
+ Integer oldID = null;
+ for( int n = 0; n < array.columnLength(); n++ )
+ {
+ Integer id = ( Integer ) array.get( n, 0 );
+ if( id.equals( oldID ) )
+ {
+ continue;
+ }
+ oldID = id;
+ String descricao = ( String ) array.get( n, 1 );
+ detalhes.add( new MappableObject( id, descricao ) );
+ }
+ return ( IDObject[] ) detalhes.toArray( new IDObject[ detalhes.size() ] );
+ }
+
+ public void setDetalhesRealziadosForMarcacao( Integer marcacaoID, Integer detalhes[] )
+ throws Exception
+ {
+ Delete delete =
+ new Delete( "marcacoes_grupos_realizados",
+ new Field( "marcacao_trabalhador_id" ).isEqual( marcacaoID ) );
+ executer.executeQuery( delete );
+ Insert insert =
+ new Insert( "marcacoes_grupos_realizados",
+ new Assignment[]{
+ new Assignment( new Field( "marcacao_trabalhador_id" ), marcacaoID ),
+ new Assignment( new Field( "grupo_protocolo_id" ), detalhes ) } );
+ executer.executeQuery( insert, null );
+ }
+
+ public Integer[] getDetalhesRealizadosForMarcacao( Integer marcacaoID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "marcacoes_grupos_realizados" },
+ new String[]{ "grupo_protocolo_id" },
+ new Field( "marcacao_trabalhador_id" ).isEqual( marcacaoID ) );
+ 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;
+ }
+
+ public Integer[] getDetalhesRealizadosForEstadosMarcacao( Integer marcacaoID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "marcacoes_grupos_realizados", "marcacoes_trabalhador_estados" },
+ new String[]{ "grupo_protocolo_id" },
+ new Field( "marcacoes_trabalhador_estados.marcacao_id" ).isEqual( marcacaoID ).and(
+ new Field( "marcacoes_trabalhador_estados.id" ).isEqual(
+ new Field( "marcacoes_grupos_realizados.marcacoes_trabalhador_estado_id" ) ) ) );
+ 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;
+ }
+
+ public void deleteDetalhesRealizadosForMarcacao( Integer marcacaoID )
+ throws Exception
+ {
+ Delete delete =
+ new Delete( "marcacoes_grupos_realizados",
+ new Field( "marcacao_trabalhador_id" ).isEqual( marcacaoID ) );
+ executer.executeQuery( delete );
+ }
+
+ public Object[][] getExamesTrabalhador( Integer trabalhadorID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "marcacoes_trabalhador" },
+ new String[]{ "id", "data", "estado" },
+ new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and(
+ new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ),
+ new String[]{ "data desc" },
+ null );
+ Virtual2DArray array = executer.executeQuery( select );
+ Object data[][] = array.getObjects();
+ for( int n = 0; n < data.length; n++ )
+ {
+ int estado = ( ( Integer ) data[ n ][ 2 ] ).intValue();
+ data[ n ][ 2 ] = ESTADOS_EXAME_STR[ estado ];
+ }
+ return data;
+ }
+
+ public Object[][] getConsultasTrabalhador( Integer trabalhadorID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "marcacoes_trabalhador" },
+ new String[]{ "id", "data", "estado" },
+ new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and(
+ new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ),
+ new String[]{ "data desc" },
+ null );
+ Virtual2DArray array = executer.executeQuery( select );
+ Object data[][] = array.getObjects();
+ for( int n = 0; n < data.length; n++ )
+ {
+ int estado = ( ( Integer ) data[ n ][ 2 ] ).intValue();
+ data[ n ][ 2 ] = ESTADOS_CONSULTA_STR[ estado ];
+ }
+
+ return data;
+ }
+
+ public ColumnizedMappable[] getAllEmpresas()
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "empresas" },
+ new String[]{ "id", "designacao_social", "designacao_social_plain" },
+ new Field( "inactivo" ).isDifferent( "y" ),
+ new String[]{ "designacao_social_plain" },
+ null );
+ Virtual2DArray array = executer.executeQuery( select );
+ ColumnizedMappable empresas[] = new ColumnizedMappable[ array.columnLength() ];
+ for( int n = 0; n < empresas.length; n++ )
+ {
+ Integer id = ( Integer ) array.get( n, 0 );
+ String designacao = ( String ) array.get( n, 1 );
+ empresas[ n ] = new ColumnizedMappable( id, designacao );
+ }
+ return empresas;
+ }
+
+ public ColumnizedMappable[] getAllEstabelecimentosForEmpresa( Integer empresaID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "estabelecimentos" },
+ new String[]{ "id", "nome", "nome_plain" },
+ new Field( "empresa_id" ).isEqual( empresaID ).and(
+ new Field( "inactivo" ).isDifferent( "y" ) ),
+ new String[]{ "nome_plain" },
+ null );
+ Virtual2DArray array = executer.executeQuery( select );
+ ColumnizedMappable estabelecimentos[] = new ColumnizedMappable[ array.columnLength() ];
+ for( int n = 0; n < estabelecimentos.length; n++ )
+ {
+ Integer id = ( Integer ) array.get( n, 0 );
+ String nome = ( String ) array.get( n, 1 );
+ estabelecimentos[ n ] = new ColumnizedMappable( id, nome );
+ }
+ return estabelecimentos;
+ }
+
+ public ColumnizedMappable[] getAllTrabalhadoresForEstabelecimento( Integer estabelecimentoID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "trabalhadores" },
+ new String[]{ "id", "nome", "nome_plain" },
+ new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ).and(
+ new Field( "inactivo" ).isDifferent( "y" ) ),
+ new String[]{ "nome_plain" },
+ null );
+ Virtual2DArray array = executer.executeQuery( select );
+ ColumnizedMappable trabalhadores[] = new ColumnizedMappable[ array.columnLength() ];
+ for( int n = 0; n < trabalhadores.length; n++ )
+ {
+ Integer id = ( Integer ) array.get( n, 0 );
+ String nome = ( String ) array.get( n, 1 );
+ trabalhadores[ n ] = new ColumnizedMappable( id, nome );
+ }
+ return trabalhadores;
+ }
+
+ /**
+ * Devolve o identificador da consulta de um trabalhador para um dado motivo e dia.
+ *
+ * @param trabalhadorID o identificador do trabalhador
+ * @param motivo o identificador do motivo da marcacao
+ * @param data a data da marcacao
+ * @return o identificador da consulta ou null se não houver nenhuma
+ * @throws Exception se houver um erro na ligaço à Base de Dados
+ */
+ public Integer getConsultaIDByTrabalhadorMotivoAndDate( Integer trabalhadorID, Integer motivo, Date data )
+ throws Exception
+ {
+ Integer motivos[];
+ if( motivo != null && ( motivo.intValue() == MOTIVO_PERIODICO || motivo.intValue() == MOTIVO_PERIODICO_INICIAL ) )
+ {
+ motivos = new Integer[]{ MOTIVO_PERIODICO_INTEGER, MOTIVO_PERIODICO_INICIAL_INTEGER };
+ }
+ else
+ {
+ motivos = new Integer[]{ motivo };
+ }
+ Select select =
+ new Select( new String[]{ "marcacoes_trabalhador" },
+ new String[]{ "id" },
+ new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and(
+ new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
+ new Field( "data" ).isEqual( data ) ).and(
+ new Field( "motivo" ).in( motivos ) ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ Integer id;
+ if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
+ {
+ id = null;
+ }
+ else
+ {
+ id = ( Integer ) array.get( 0, 0 );
+ }
+ return id;
+ }
+
+ /**
+ * Devolve o identificador da primeira consulta de um trabalhador n&ão realizada depois de um diapara um dado motivo.
+ *
+ * @param trabalhadorID o identificador do trabalhador
+ * @param motivo o identificador do motivo da marcacao
+ * @param data a data de início de procura
+ * @return o identificador da consulta ou null se não houver nenhuma
+ * @throws Exception se houver um erro na ligaço à Base de Dados
+ */
+ public Integer getProximaConsultaIDByTrabalhadorMotivoAndDate( Integer trabalhadorID, Integer motivo, Date data )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "marcacoes_trabalhador" },
+ new String[]{ "id", "data" },
+ new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and(
+ new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
+ new Field( "data" ).isGreater( data ) ).and(
+ new Field( "motivo" ).isEqual( motivo ) ).and(
+ new Field( "estado" ).isEqual( new Integer( 0 ) ) ),
+ new String[]{ "data" },
+ null );
+ Virtual2DArray array = executer.executeQuery( select );
+ Integer id;
+ if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
+ {
+ id = null;
+ }
+ else
+ {
+ id = ( Integer ) array.get( 0, 0 );
+ }
+ return id;
+ }
+
+ public Object[][] getListaConsultasByData( Date data )
+ throws Exception
+ {
+ Select2 select =
+ new Select2( new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos", "empresas" },
+ new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER },
+ new Expression[]{
+ new Field( "marcacoes_trabalhador.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 String[]{ "marcacoes_trabalhador.id", "trabalhadores.nome", "trabalhadores.nome_plain",
+ "empresas.designacao_social", "marcacoes_trabalhador.tipo", "prestador_id" },
+ new Field( "marcacoes_trabalhador.data" ).isEqual( data ).and(
+ new Field( "marcacoes_trabalhador.estado" ).isEqual(
+ new Integer( Marcacao.ESTADO_POR_REALIZAR ) ) ).and(
+ new Field( "marcacoes_trabalhador.tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ),
+ null,
+ null,
+ null,
+ null );
+ Virtual2DArray array = executer.executeQuery( select );
+ return array.getObjects();
+ }
+
+ public Object[][] getListaECDsByData( Date data )
+ throws Exception
+ {
+ Select2 select =
+ new Select2( new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos", "empresas" },
+ new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER },
+ new Expression[]{
+ new Field( "marcacoes_trabalhador.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 String[]{ "marcacoes_trabalhador.id", "trabalhadores.nome", "trabalhadores.nome_plain",
+ "empresas.designacao_social", "marcacoes_trabalhador.tipo", "prestador_id" },
+ new Field( "marcacoes_trabalhador.data" ).isEqual( data ).and(
+ new Field( "marcacoes_trabalhador.estado" ).isEqual(
+ new Integer( Marcacao.ESTADO_POR_REALIZAR ) ) ).and(
+ new Field( "marcacoes_trabalhador.tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ),
+ null,
+ null,
+ null,
+ null );
+ Virtual2DArray array = executer.executeQuery( select );
+ return array.getObjects();
+ }
+
+ public Integer getTrabalhadorIDByMarcacaoID( Integer marcacaoID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "marcacoes_trabalhador" },
+ new String[]{ "trabalhador_id" },
+ new Field( "id" ).isEqual( marcacaoID ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ return ( Integer ) array.get( 0, 0 );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MedicinaUpperPanel.java b/trunk/SIPRPSoft/src/siprp/medicina/MedicinaUpperPanel.java
new file mode 100644
index 00000000..dbdd786d
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/MedicinaUpperPanel.java
@@ -0,0 +1,253 @@
+/*
+ * MedicinaUpperPanel.java
+ *
+ * Created on February 1, 2006, 6:48 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina;
+
+import java.awt.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.dataui.*;
+import com.evolute.utils.tables.*;
+import com.evolute.utils.ui.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class MedicinaUpperPanel extends JPanel
+ implements ListSelectionListener, ControllableComponent
+{
+ protected BaseTable empresasTable;
+ protected VectorTableModel empresasModel;
+ protected BaseTable estabelecimentosTable;
+ protected VectorTableModel estabelecimentosModel;
+ protected BaseTable trabalhadoresTable;
+ protected VectorTableModel trabalhadoresModel;
+
+ protected MedicinaDataProvider provider;
+
+ protected final Vector listeners;
+
+ protected boolean editing = false;
+
+ /** Creates a new instance of MedicinaUpperPanel */
+ public MedicinaUpperPanel()
+ throws Exception
+ {
+ provider = ( MedicinaDataProvider ) MedicinaDataProvider.getProvider();
+ listeners = new Vector();
+ setupComponents();
+ }
+
+ private void setupComponents()
+ throws Exception
+ {
+ empresasModel = new VectorTableModel( new String[]{ "empresas" } );
+ empresasTable = new BaseTable( empresasModel );
+ empresasTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ empresasTable.setNonResizableNorReordable();
+ JScrollPane empresasScroll =
+ new JScrollPane( empresasTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ empresasTable.getSelectionModel().addListSelectionListener( this );
+ estabelecimentosModel = new VectorTableModel( new String[]{ "estabelecimentos" } );
+ estabelecimentosTable = new BaseTable( estabelecimentosModel );
+ estabelecimentosTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ estabelecimentosTable.setNonResizableNorReordable();
+ JScrollPane estabelecimentosScroll =
+ new JScrollPane( estabelecimentosTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ estabelecimentosTable.getSelectionModel().addListSelectionListener( this );
+ trabalhadoresModel = new VectorTableModel( new String[]{ "trabalhadores" } );
+ trabalhadoresTable = new BaseTable( trabalhadoresModel );
+ trabalhadoresTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ trabalhadoresTable.setNonResizableNorReordable();
+ JScrollPane trabalhadoresScroll =
+ new JScrollPane( trabalhadoresTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ trabalhadoresTable.getSelectionModel().addListSelectionListener( this );
+
+ GridBagLayout gridbag = new GridBagLayout();
+ setLayout( gridbag );
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.insets = new Insets( 1, 1, 1, 1 );
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.gridwidth = 1;
+ constraints.gridheight = 1;
+ constraints.weightx = 0.3;
+ constraints.weighty = 1;
+
+ gridbag.setConstraints( empresasScroll, constraints );
+
+ gridbag.setConstraints( estabelecimentosScroll, constraints );
+
+ constraints.weightx = 0.4;
+ constraints.gridheight = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( trabalhadoresScroll, constraints );
+
+ add( empresasScroll );
+ add( estabelecimentosScroll );
+ add( trabalhadoresScroll );
+
+ ColumnizedMappable empresas[] = provider.getAllEmpresas();
+ Vector values = empresasModel.getValues();
+ values.addAll( Arrays.asList( empresas ) );
+ empresasModel.setValues( values );
+ }
+
+ public void valueChanged( ListSelectionEvent e )
+ {
+ Object source = e.getSource();
+ if( e.getValueIsAdjusting() )
+ {
+ return;
+ }
+ if( source.equals( empresasTable.getSelectionModel() ) )
+ {
+ carregarEstabelecimentos();
+ }
+ else if( source.equals( estabelecimentosTable.getSelectionModel() ) )
+ {
+ carregarTrabalhadores();
+ }
+ else if( source.equals( trabalhadoresTable.getSelectionModel() ) )
+ {
+ notifyListeners( e );
+ }
+ }
+
+ protected void carregarEstabelecimentos()
+ {
+ estabelecimentosTable.clearSelection();
+ int selected = empresasTable.getSelectedRow();
+ estabelecimentosModel.clearAll();
+ if( selected > -1 )
+ {
+ try
+ {
+ Integer empresaID = ( ( ColumnizedMappable ) empresasModel.getRowAt( selected ) ).getID();
+ ColumnizedMappable estabelecimentos[] = provider.getAllEstabelecimentosForEmpresa( empresaID);
+ Vector values = estabelecimentosModel.getValues();
+ values.addAll( Arrays.asList( estabelecimentos ) );
+ estabelecimentosModel.setValues( values );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar os estabelecimentos.", true );
+ estabelecimentosModel.clearAll();
+ }
+ }
+ }
+
+ protected void carregarTrabalhadores()
+ {
+ trabalhadoresTable.clearSelection();
+ int selected = estabelecimentosTable.getSelectedRow();
+ trabalhadoresModel.clearAll();
+ if( selected > -1 )
+ {
+ try
+ {
+ Integer estabelecimentoID = ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( selected ) ).getID();
+ ColumnizedMappable trabalhadores[] = provider.getAllTrabalhadoresForEstabelecimento( estabelecimentoID );
+ Vector values = trabalhadoresModel.getValues();
+ values.addAll( Arrays.asList( trabalhadores ) );
+ trabalhadoresModel.setValues( values );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar trabalhadores.", true );
+ trabalhadoresModel.clearAll();
+ }
+ }
+ }
+
+ protected void notifyListeners( ListSelectionEvent e )
+ {
+ for( int n = 0; n < listeners.size(); n++ )
+ {
+ ListSelectionEvent event =
+ new ListSelectionEvent( this, e.getFirstIndex(), e.getLastIndex(), e.getValueIsAdjusting() );
+ ( ( ListSelectionListener ) listeners.elementAt( n ) ).valueChanged( event );
+ }
+ }
+
+ public void addListSelectionListener( ListSelectionListener listener )
+ {
+ listeners.add( listener );
+ }
+
+ public void removeSelectionListener( ListSelectionListener listener )
+ {
+ listeners.remove( listener );
+ }
+
+ public void clear()
+ {
+// empresasTable.clearSelection();
+ }
+
+ public void fill( Object value )
+ {
+ if( value == null )
+ {
+ clear();
+ }
+ Integer ids[] = ( Integer [] ) value;
+ for( int n = 0; n < empresasTable.getRowCount(); n++ )
+ {
+ if( ( ( ColumnizedMappable ) empresasModel.getRowAt( n ) ).getID().equals( ids[ 0 ] ) )
+ {
+ empresasTable.setRowSelectionInterval( n, n );
+ break;
+ }
+ }
+
+ for( int n = 0; n < estabelecimentosTable.getRowCount(); n++ )
+ {
+ if( ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( n ) ).getID().equals( ids[ 1 ] ) )
+ {
+ estabelecimentosTable.setRowSelectionInterval( n, n );
+ break;
+ }
+ }
+
+ for( int n = 0; n < trabalhadoresTable.getRowCount(); n++ )
+ {
+ if( ( ( ColumnizedMappable ) trabalhadoresModel.getRowAt( n ) ).getID().equals( ids[ 2 ] ) )
+ {
+ trabalhadoresTable.setRowSelectionInterval( n, n );
+ break;
+ }
+ }
+ }
+
+ public Object save()
+ {
+ int empresaSelected = empresasTable.getSelectedRow();
+ int estabelecimentoSelected = estabelecimentosTable.getSelectedRow();
+ int trabalhadorSelected = trabalhadoresTable.getSelectedRow();
+ return new Integer[]{
+ empresaSelected == -1 ? null : ( ( ColumnizedMappable ) empresasModel.getRowAt( empresaSelected ) ).getID(),
+ estabelecimentoSelected == -1 ? null : ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( estabelecimentoSelected ) ).getID(),
+ trabalhadorSelected == -1 ? null : ( ( ColumnizedMappable ) trabalhadoresModel.getRowAt( trabalhadorSelected ) ).getID()
+ };
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ editing = !enable;
+ empresasTable.setEnabled( enable );
+ estabelecimentosTable.setEnabled( enable );
+ trabalhadoresTable.setEnabled( enable );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MedicinaWindow.java b/trunk/SIPRPSoft/src/siprp/medicina/MedicinaWindow.java
new file mode 100644
index 00000000..fa827ed4
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/MedicinaWindow.java
@@ -0,0 +1,686 @@
+/*
+ * MedicinaWindow.java
+ *
+ * Created on 17 de Janeiro de 2006, 19:43
+ *
+ * To change this template, choose Tools | Options and locate the template under
+ * the Source Creation and Management node. Right-click the template and choose
+ * Open. You can then make changes to the template in the Source Editor.
+ */
+
+package siprp.medicina;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.text.*;
+import java.util.*;
+
+import com.evolute.utils.*;
+import com.evolute.utils.arrays.*;
+import com.evolute.utils.data.*;
+import com.evolute.utils.jdo.*;
+import com.evolute.utils.ui.*;
+import com.evolute.utils.ui.panel.*;
+import com.evolute.utils.ui.search.*;
+import com.evolute.utils.ui.text.*;
+import com.evolute.utils.ui.window.*;
+
+import siprp.*;
+import siprp.clientes.*;
+import siprp.data.*;
+/**
+ *
+ * @author fpalma
+ */
+public class MedicinaWindow extends TabbedWindow
+ implements ActionListener, ListSelectionListener
+{
+ private static int iPermissionArray[][] =
+ new int[][]{ {},
+ { NEW_INDEX, EDIT_INDEX, SAVE_INDEX, DELETE_INDEX, CANCEL_INDEX },
+ { NEW_INDEX, EDIT_INDEX, SAVE_INDEX, DELETE_INDEX, CANCEL_INDEX } };
+
+ private static final int TAB_CONSULTA = 0;
+ private static final int TAB_EXAME = 1;
+
+ private static final int INDEX_MAIN = 0;
+ private static final int INDEX_CONSULTA = 1;
+ private static final int INDEX_EXAME = 2;
+
+ private static final String tabNames[] =
+ new String[]{ "Consultas", "Exames" };
+
+ private static final DateFormat DATE_FORMAT =
+ DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "PT", "pt" ) );
+
+ protected MedicinaDataProvider provider;
+ protected FichaDataProvider fichaProvider;
+ protected JDOProvider JDO;
+ protected SIPRPTracker tracker;
+
+ protected MedicinaUpperPanel upperPanel;
+ protected MarcacaoConsultaPanel marcacaoConsultaPanel;
+ protected TableEditorPanel marcacaoConsultaEditorPanel;
+ protected MarcacaoExamePanel marcacaoExamePanel;
+ protected TableEditorPanel marcacaoExameEditorPanel;
+ protected CheckBoxPanel detalhesExamePanel;
+
+ protected Integer empresaID;
+ protected String empresa;
+ protected Integer estabelecimentoID;
+ protected String estabelecimento;
+ protected Integer trabalhadorID;
+ protected TrabalhadorData trabalhador;
+ protected boolean estado[] = new boolean[]{ false, false };
+
+ /** Creates a new instance of MedicinaWindow */
+ public MedicinaWindow()
+ throws Exception
+ {
+ super( new MedicinaUpperPanel(), tabNames, 0.7, createPermissions( iPermissionArray ) );
+ upperPanel = ( MedicinaUpperPanel ) getUpperPanel();
+ provider = ( MedicinaDataProvider ) MedicinaDataProvider.getProvider();
+ fichaProvider = ( FichaDataProvider ) FichaDataProvider.getProvider();
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ setupComponents();
+ maximizeOnNextActivate();
+ }
+
+ private void setupComponents()
+ throws Exception
+ {
+ setTitle( "Medicina" );
+ setupConsultaComponents();
+ setupExameComponents();
+ upperPanel.addListSelectionListener( this );
+ }
+
+ private void setupConsultaComponents()
+ {
+ JPanel panel = getTab( TAB_CONSULTA );
+
+ panel.setBorder(
+ BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(), "Consultas" ) );
+
+ changeGroupName( INDEX_CONSULTA, "Consultas" );
+ setActionName( INDEX_CONSULTA, NEW_INDEX, "Nova" );
+ setActionTooltip( INDEX_CONSULTA, NEW_INDEX, "Nova" );
+ JPanel toolbar = getToolbarPanel( INDEX_CONSULTA );
+
+ GridBagLayout gridbag = new GridBagLayout();
+ GridBagConstraints constraints = new GridBagConstraints();
+ panel.setLayout( gridbag );
+ constraints.insets = new Insets( 2, 2, 2, 2 );
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ constraints.weightx = 1.0;
+
+ gridbag.setConstraints( toolbar, constraints );
+ panel.add( toolbar );
+
+ constraints.gridheight = 1;
+ constraints.weighty = 1.0;
+ try
+ {
+ marcacaoConsultaEditorPanel =
+ new TableEditorPanel( new String[]{ "Data",
+ "Estado" },
+ new int[]{0,2}, new int[]{0,0},
+ 0.0, 1.0, new Dimension( 350, 100 ) );
+ marcacaoConsultaPanel = new MarcacaoConsultaPanel();
+ new CopyPasteHandler( marcacaoConsultaPanel.getObservacoesText() );
+ marcacaoConsultaEditorPanel.addComponent( marcacaoConsultaPanel,
+ new int[]{0,2}, new int[]{1,2},
+ 1.0, 1.0 );
+ marcacaoConsultaEditorPanel.addListSelectionListener( new ListSelectionListener(){
+ public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent)
+ {
+ if( marcacaoConsultaEditorPanel.getID() != null )
+ {
+ reload(INDEX_CONSULTA);
+ select(INDEX_CONSULTA);
+ }
+ else
+ {
+ clear( INDEX_CONSULTA );
+ }
+ }
+ });
+ }catch( Exception ex )
+ {
+ DialogException.showException( ex );
+ return;
+ }
+ gridbag.setConstraints( marcacaoConsultaEditorPanel, constraints );
+ panel.add( marcacaoConsultaEditorPanel );
+ marcacaoConsultaPanel.getEmailButton().addActionListener( this );
+ }
+
+ private void setupExameComponents()
+ {
+ JPanel panel = getTab( TAB_EXAME );
+
+ panel.setBorder(
+ BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(), "Exames" ) );
+
+ changeGroupName( INDEX_EXAME, "Exames" );
+ JPanel toolbar = getToolbarPanel( INDEX_EXAME );
+
+ GridBagLayout gridbag = new GridBagLayout();
+ GridBagConstraints constraints = new GridBagConstraints();
+ panel.setLayout( gridbag );
+ constraints.insets = new Insets( 2, 2, 2, 2 );
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ constraints.weightx = 1.0;
+
+ gridbag.setConstraints( toolbar, constraints );
+ panel.add( toolbar );
+
+ constraints.gridheight = 1;
+ constraints.weighty = 1.0;
+ try
+ {
+ marcacaoExameEditorPanel =
+ new TableEditorPanel( new String[]{ "Data",
+ "Estado" },
+ new int[]{0,2}, new int[]{0,0},
+ 0.0, 1.0, new Dimension( 350, 100 ) );
+ marcacaoExamePanel = new MarcacaoExamePanel();
+ new CopyPasteHandler( marcacaoExamePanel.getObservacoesText() );
+ marcacaoExameEditorPanel.addComponent( marcacaoExamePanel,
+ new int[]{0,2}, new int[]{1,2},
+ 1.0, 1.0 );
+ marcacaoExameEditorPanel.addListSelectionListener( new ListSelectionListener(){
+ public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent)
+ {
+ if( marcacaoExameEditorPanel.getID() != null )
+ {
+ reload(INDEX_EXAME);
+ select(INDEX_EXAME);
+ }
+ else
+ {
+ clear( INDEX_EXAME );
+ }
+ }
+ });
+ }catch( Exception ex )
+ {
+ DialogException.showException( ex );
+ return;
+ }
+ gridbag.setConstraints( marcacaoExameEditorPanel, constraints );
+ panel.add( marcacaoExameEditorPanel );
+ marcacaoExamePanel.getEmailButton().addActionListener( this );
+ }
+
+ public boolean save(int index)
+ {
+ Date data;
+ switch( index )
+ {
+ case INDEX_EXAME:
+ MarcacaoTrabalhadorData exame = ( MarcacaoTrabalhadorData ) marcacaoExamePanel.save();
+ data = ( Date ) exame.get( MarcacaoTrabalhadorData.DATA );
+ if( data == null )
+ {
+ JOptionPane.showMessageDialog( this, "Tem de preencher uma data para os exames.",
+ "Erro", JOptionPane.ERROR_MESSAGE );
+ return false;
+ }
+ exame.set( MarcacaoTrabalhadorData.TIPO,
+ new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) );
+ exame.set( MarcacaoTrabalhadorData.TRABALHADOR, trabalhador );
+ try
+ {
+ exame.set( MarcacaoTrabalhadorData.REALIZADA,
+ ( ( Integer )exame.get( MarcacaoTrabalhadorData.ESTADO ) ).intValue() ==
+ provider.ESTADO_REALIZADO ? "y" : "n" );
+ exame.save();
+ Integer exameID = ( Integer ) exame.get( MarcacaoTrabalhadorData.ID );
+ Integer detalhesRealizados[] = detalhesExamePanel.getSelected();
+ provider.setDetalhesRealziadosForMarcacao( exameID, detalhesRealizados );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a gravar", true );
+ return false;
+ }
+
+ break;
+
+ case INDEX_CONSULTA:
+ MarcacaoTrabalhadorData consulta = ( MarcacaoTrabalhadorData ) marcacaoConsultaPanel.save();
+ data = ( Date ) consulta.get( MarcacaoTrabalhadorData.DATA );
+ if( data == null )
+ {
+ JOptionPane.showMessageDialog( this, "Tem de preencher uma data para a consulta.",
+ "Erro", JOptionPane.ERROR_MESSAGE );
+ return false;
+ }
+ consulta.set( MarcacaoTrabalhadorData.TIPO,
+ new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) );
+ consulta.set( MarcacaoTrabalhadorData.TRABALHADOR, trabalhador );
+ try
+ {
+ consulta.set( MarcacaoTrabalhadorData.REALIZADA,
+ ( ( Integer )consulta.get( MarcacaoTrabalhadorData.ESTADO ) ).intValue() ==
+ provider.ESTADO_REALIZADO ? "y" : "n" );
+ consulta.save();
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a gravar", true );
+ return false;
+ }
+ break;
+ }
+ reload( INDEX_MAIN );
+ return true;
+ }
+
+ public boolean delete(int index)
+ {
+ int option = JOptionPane.showConfirmDialog( this, "Tem a certeza que quer apagar a marca\u00e7\u00e3o?",
+ "Apagar", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE );
+ if( option == 0 )
+ {
+ switch( index )
+ {
+ case INDEX_CONSULTA:
+ MarcacaoTrabalhadorData consulta = ( MarcacaoTrabalhadorData ) marcacaoConsultaPanel.save();
+ try
+ {
+ consulta.delete();
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a apagar.", true );
+ return false;
+ }
+ break;
+
+ case INDEX_EXAME:
+ MarcacaoTrabalhadorData exame = ( MarcacaoTrabalhadorData ) marcacaoExamePanel.save();
+ try
+ {
+ exame.delete();
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a apagar.", true );
+ return false;
+ }
+ break;
+ }
+ reload( INDEX_MAIN );
+ return true;
+ }
+ return false;
+ }
+
+ public void clear(int index)
+ {
+ switch( index )
+ {
+ case INDEX_MAIN:
+ empresaID = null;
+ empresa = null;
+ estabelecimentoID = null;
+ estabelecimento = null;
+ trabalhadorID = null;
+ trabalhador = null;
+ upperPanel.clear();
+ marcacaoExameEditorPanel.clear();
+ marcacaoConsultaEditorPanel.clear();
+// marcacaoExamePanel.getDetalhesPanel().removeAll();
+ detalhesExamePanel = null;
+ break;
+
+ case INDEX_CONSULTA:
+ marcacaoConsultaPanel.clear();
+ marcacaoConsultaPanel.getEmailButton().setText( "Enviar email" );
+ break;
+
+ case INDEX_EXAME:
+ marcacaoExamePanel.clear();
+ marcacaoExamePanel.getEmailButton().setText( "Enviar email" );
+ if( detalhesExamePanel != null )
+ {
+ detalhesExamePanel.clear();
+ }
+ break;
+ }
+ }
+
+ public void enableComponents(int index, boolean enable)
+ {
+ switch( index )
+ {
+ case INDEX_MAIN:
+
+ break;
+
+ case INDEX_EXAME:
+ marcacaoExamePanel.setEnabled( enable );
+ marcacaoExamePanel.getEmailButton().setEnabled( enable );
+ if( detalhesExamePanel != null )
+ {
+ detalhesExamePanel.setEnabled( enable );
+ }
+ upperPanel.setEnabled( !enable );
+ estado[ 0 ] = enable;
+ break;
+
+ case INDEX_CONSULTA:
+ marcacaoConsultaPanel.setEnabled( enable );
+ marcacaoConsultaPanel.getEmailButton().setEnabled( enable );
+ upperPanel.setEnabled( !enable );
+ estado[ 1 ] = enable;
+ break;
+ }
+ if( tracker != null )
+ {
+ tracker.getAvisosPanel().setEnabled( (!estado[ 0 ]) && (!estado[1]),
+ AvisoConstants.TIPO_TRABALHADOR );
+ }
+ }
+
+// public boolean searchByName()
+// {
+// fichaProvider.setSearch( FichaDataProvider.SEARCH_EMPRESAS );
+// SearchDialog search;
+//
+// search = new SearchDialog( fichaProvider, null, false, null, true );
+// empresaID = ( Integer )search.getSelected();
+//
+// if( empresaID == null )
+// {
+// return false;
+// }
+//
+// fichaProvider.setSearch( FichaDataProvider.SEARCH_ESTABELECIMENTOS );
+// fichaProvider.setSearchID( FichaDataProvider.SEARCH_EMPRESAS, empresaID.intValue() );
+//
+// search = new SearchDialog( fichaProvider, null, false, null, true );
+// estabelecimentoID = ( Integer )search.getSelected();
+//
+// if( estabelecimentoID == null )
+// {
+// return false;
+// }
+//
+// fichaProvider.setSearch( FichaDataProvider.SEARCH_TRABALHADORES );
+// fichaProvider.setSearchID( FichaDataProvider.SEARCH_ESTABELECIMENTOS, estabelecimentoID.intValue() );
+// search = new SearchDialog( fichaProvider, null, false, null, true );
+// trabalhadorID = ( Integer )search.getSelected();
+//
+// if( trabalhadorID == null )
+// {
+// return false;
+// }
+// reload(0);
+// return true;
+// }
+
+ protected void enableSelect( int index, boolean select )
+ {
+ switch( index )
+ {
+ case INDEX_EXAME:
+ marcacaoExameEditorPanel.setEnabled( select );
+ break;
+
+ case INDEX_CONSULTA:
+ marcacaoConsultaEditorPanel.setEnabled( select );
+ break;
+ }
+ }
+
+ public void reload( int index )
+ {
+ switch( index )
+ {
+ case INDEX_MAIN:
+ try
+ {
+ String nomes[] =
+ provider.getEmpresaEstabelecimento( empresaID, estabelecimentoID );
+ empresa = nomes[ 0 ];
+ estabelecimento = nomes[ 1 ];
+ trabalhador = ( TrabalhadorData ) JDO.load( TrabalhadorData.class, trabalhadorID );
+// upperPanel.getEmpresaText().setText( empresa );
+// upperPanel.getEstabelecimentoText().setText( estabelecimento );
+// upperPanel.getTrabalhadorText().setText( ( String ) trabalhador.get( TrabalhadorData.NOME ) );
+ IDObject detalhesExame[] = provider.getDetalhesValidosTrabalhador( empresaID, trabalhadorID );
+ detalhesExamePanel = new CheckBoxPanel( detalhesExame );
+ JPanel detalhesExameOuterPanel = marcacaoExamePanel.getDetalhesPanel();
+ detalhesExameOuterPanel.setLayout( new GridLayout( 1, 1 ) );
+ detalhesExameOuterPanel.removeAll();
+ detalhesExameOuterPanel.add( detalhesExamePanel );
+ detalhesExameOuterPanel.validate();
+ Object examesTrabalhador[][] = provider.getExamesTrabalhador( trabalhadorID );
+ Object consultasTrabalhador[][] = provider.getConsultasTrabalhador( trabalhadorID );
+ if( examesTrabalhador.length > 0 )
+ {
+ marcacaoExameEditorPanel.setData( new Object2DArray( examesTrabalhador ) );
+ }
+ else
+ {
+ marcacaoExameEditorPanel.clear();
+ }
+ if( consultasTrabalhador.length > 0 )
+ {
+ marcacaoConsultaEditorPanel.setData( new Object2DArray( consultasTrabalhador ) );
+ }
+ else
+ {
+ marcacaoConsultaEditorPanel.clear();
+ }
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar os dados.", true );
+ }
+ break;
+
+ case INDEX_EXAME:
+ Integer exameID = marcacaoExameEditorPanel.getID();
+ if( exameID == null )
+ {
+ return;
+ }
+ try
+ {
+ MarcacaoTrabalhadorData exame =
+ ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, exameID );
+ marcacaoExamePanel.fill( exame );
+ Date dataEmailExame = ( Date ) exame.get( MarcacaoTrabalhadorData.DATA_EMAIL );
+ if( dataEmailExame != null )
+ {
+ marcacaoExamePanel.getEmailButton().setText( "Enviar email (" + DATE_FORMAT.format( dataEmailExame ) + ")" );
+ }
+ else
+ {
+ marcacaoExamePanel.getEmailButton().setText( "Enviar email" );
+ }
+ Integer detalhesRealizados[] = provider.getDetalhesRealizadosForMarcacao( exameID );
+ detalhesExamePanel.setSelected( detalhesRealizados );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar os dados do exame.", true );
+ }
+ break;
+
+ case INDEX_CONSULTA:
+ Integer consultaID = marcacaoConsultaEditorPanel.getID();
+ if( consultaID == null )
+ {
+ return;
+ }
+ try
+ {
+ MarcacaoTrabalhadorData consulta =
+ ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, consultaID );
+ marcacaoConsultaPanel.fill( consulta );
+ Date dataEmailConsulta = ( Date ) consulta.get( MarcacaoTrabalhadorData.DATA_EMAIL );
+ if( dataEmailConsulta != null )
+ {
+ marcacaoConsultaPanel.getEmailButton().setText( "Enviar email (" + DATE_FORMAT.format( dataEmailConsulta ) + ")" );
+ }
+ else
+ {
+ marcacaoConsultaPanel.getEmailButton().setText( "Enviar email" );
+ }
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar os dados da consulta.", true );
+ }
+ break;
+ }
+ }
+
+ public void actionPerformed( ActionEvent e )
+ {
+ Object source = e.getSource();
+ if( source.equals( marcacaoExamePanel.getEmailButton() ) )
+ {
+ enviarEmailExame();
+ }
+ else if( source.equals( marcacaoConsultaPanel.getEmailButton() ) )
+ {
+ enviarEmailConsulta();
+ }
+ }
+
+ protected void enviarEmailConsulta()
+ {
+ MarcacaoTrabalhadorData consulta = ( MarcacaoTrabalhadorData ) marcacaoConsultaPanel.save();
+
+ String subject = ( String ) Singleton.getInstance( SingletonConstants.SUBJECT_CONSULTA );
+ String texto = ( String ) Singleton.getInstance( SingletonConstants.LETTER_CONSULTA );
+
+ Date today = new Date();
+ marcacaoConsultaPanel.getEmailButton().setText( "Enviar email (" + DATE_FORMAT.format( today ) + ")" );
+
+ try
+ {
+ enviarEmail( subject, texto, ( Date )consulta.get( MarcacaoTrabalhadorData.DATA ) );
+ consulta.set( Marcacao.DATA_EMAIL, today );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a enviar mail", true );
+ }
+ }
+
+ protected void enviarEmailExame()
+ {
+ MarcacaoTrabalhadorData exame = ( MarcacaoTrabalhadorData ) marcacaoExamePanel.save();
+
+ String subject = ( String ) Singleton.getInstance( SingletonConstants.SUBJECT_EXAMES );
+ String texto = ( String ) Singleton.getInstance( SingletonConstants.LETTER_EXAMES );
+
+ Date today = new Date();
+ marcacaoExamePanel.getEmailButton().setText( "Enviar email (" + DATE_FORMAT.format( today ) + ")" );
+
+ try
+ {
+ enviarEmail( subject, texto, ( Date )exame.get( MarcacaoTrabalhadorData.DATA ) );
+ exame.set( Marcacao.DATA_EMAIL, today );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a enviar mail", true );
+ }
+ }
+
+ protected void enviarEmail( String subject, String texto, Date data )
+ throws Exception
+ {
+ String nome = ( String ) trabalhador.get( TrabalhadorData.NOME );
+ String dataStr = DATE_FORMAT.format( data );
+
+ subject = subject.replaceAll( CompanyDataLoader.NOME, nome );
+ texto = texto.replaceAll( CompanyDataLoader.DATA, dataStr );
+ texto = texto.replaceAll( CompanyDataLoader.NOME, nome );
+
+ EstabelecimentoData estabelecimento =
+ ( EstabelecimentoData ) JDO.load( EstabelecimentoData.class, estabelecimentoID );
+ ContactoData contacto = ( ContactoData )estabelecimento.get( EstabelecimentoData.CONTACTO );
+ String mail = "";
+ if( contacto != null )
+ {
+ mail = ( String )contacto.get( ContactoData.EMAIL );
+ }
+
+ if( System.getProperty( "os.name" ).startsWith( "Windows" ) )
+ {
+ mail = mail.replaceAll( " ", "%20" );
+ subject = subject.replaceAll( " ", "%20" );
+ texto = texto.replaceAll( " ", "%20" );
+ Process proc = Runtime.getRuntime().exec( "cmd.exe /c start mailto:\"" + mail
+ + "?subject=" + subject + "&body="
+
+ + texto
+ );
+ }
+ else
+ {
+ mail = mail.replaceAll( " ", "%20" );
+ subject = subject.replaceAll( " ", "%20" );
+ texto = texto.replaceAll( " ", "%20" );
+
+ Process proc = Runtime.getRuntime().exec( new String[]{ "/usr/bin/open", "/Applications/Mail.app", "mailto:" + mail
+ + "?subject=" + subject + "&body="
+ + texto } );
+ }
+ }
+
+ public void valueChanged( ListSelectionEvent e )
+ {
+ Object source = e.getSource();
+ if( source.equals( upperPanel ) )
+ {
+ Integer ids[] = ( Integer [] ) upperPanel.save();
+ empresaID = ids[ 0 ];
+ estabelecimentoID = ids[ 1 ];
+ trabalhadorID = ids[ 2 ];
+ if( ids[ 2 ] == null )
+ {
+ clear( INDEX_MAIN );
+ unselect( INDEX_MAIN );
+ }
+ else
+ {
+ reload( INDEX_MAIN );
+ select( INDEX_MAIN );
+ }
+ }
+ }
+
+ public void setEmpresaAndEstabelecimentoAndTrabalhador( Integer empresaID, Integer estabelecimentoID, Integer trabalhadorID )
+ {
+ if( upperPanel.editing )
+ {
+ JOptionPane.showMessageDialog( this, "Esta janela est\u00e1 em edi\u00e7\u00e3o.", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ else
+ {
+ upperPanel.fill( new Integer[]{ empresaID, estabelecimentoID, trabalhadorID } );
+ }
+ }
+
+ public void setTracker( SIPRPTracker tracker )
+ {
+ this.tracker = tracker;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/Test.java b/trunk/SIPRPSoft/src/siprp/medicina/Test.java
new file mode 100644
index 00000000..8305609e
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/Test.java
@@ -0,0 +1,38 @@
+/*
+ * Test.java
+ *
+ * Created on 17 de Janeiro de 2006, 18:37
+ *
+ * To change this template, choose Tools | Options and locate the template under
+ * the Source Creation and Management node. Right-click the template and choose
+ * Open. You can then make changes to the template in the Source Editor.
+ */
+
+package siprp.medicina;
+
+import java.awt.*;
+import javax.swing.*;
+/**
+ *
+ * @author fpalma
+ */
+public class Test
+{
+
+ public static void main( String args[] )
+ throws Exception
+ {
+ JFrame frm = new MedicinaWindow();
+// frm.getContentPane().setLayout( new GridLayout() );
+// frm.getContentPane().add( new MedicinaUpperPanel() );
+// frm.setSize( new Dimension( 600, 600 ) );
+ frm.setVisible( true );
+ frm.setExtendedState(frm.getExtendedState() | frm.MAXIMIZED_BOTH);
+ }
+
+ /** Creates a new instance of Test */
+ public Test()
+ {
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/alter.sql b/trunk/SIPRPSoft/src/siprp/medicina/alter.sql
new file mode 100644
index 00000000..3549ed22
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/alter.sql
@@ -0,0 +1,159 @@
+ALTER TABLE empresas ADD a_consultas char(1);
+ALTER TABLE empresas ADD a_exames char(1);
+ALTER TABLE empresas ADD b_consultas char(1);
+ALTER TABLE empresas ADD b_exames char(1);
+ALTER TABLE empresas ADD data_cancelamento DATE;
+
+ALTER TABLE marcacoes_trabalhador ADD motivo INT;
+ALTER TABLE marcacoes_trabalhador ADD estado INT;
+ALTER TABLE marcacoes_trabalhador ADD observacoes VARCHAR( 2048 );
+UPDATE marcacoes_trabalhador SET estado = 2 WHERE realizada = 'y';
+
+
+-- PROTOCOLOS
+
+CREATE TABLE prt_grupos_protocolo
+(
+ id int4 NOT NULL,
+ descricao varchar(255) NOT NULL,
+ descricao_plain varchar(255) NOT NULL,
+ CONSTRAINT grupos_protocolo_pkey PRIMARY KEY (id)
+)
+WITHOUT OIDS;
+ALTER TABLE prt_grupos_protocolo OWNER TO postgres;
+
+
+
+CREATE TABLE prt_tipos_elementos_protocolo
+(
+ id int4 NOT NULL,
+ descricao_plain varchar(255) NOT NULL,
+ descricao varchar(255) NOT NULL,
+ grupo_protocolo_id int4 NOT NULL,
+ CONSTRAINT prt_tipos_elementos_protocolo_pkey PRIMARY KEY (id),
+ CONSTRAINT prt_tipos_elementos_protocolo_grupo_protocolo_id_fkey FOREIGN KEY (grupo_protocolo_id) REFERENCES prt_grupos_protocolo (id) ON UPDATE RESTRICT ON DELETE RESTRICT
+)
+WITHOUT OIDS;
+ALTER TABLE prt_tipos_elementos_protocolo OWNER TO postgres;
+
+
+CREATE TABLE prt_elementos_protocolo
+(
+ id serial NOT NULL,
+ tipo_elemento_protocolo_id int4 NOT NULL,
+ empresa_id int4 NOT NULL,
+ numero_perfil int4 NOT NULL,
+ CONSTRAINT prt_elementos_protocolo_pkey PRIMARY KEY (id),
+ CONSTRAINT prt_elementos_protocolo_empresa_id_fkey FOREIGN KEY (empresa_id) REFERENCES empresas (id) ON UPDATE RESTRICT ON DELETE RESTRICT,
+ CONSTRAINT prt_elementos_protocolo_tipo_elemento_protocolo_id_fkey FOREIGN KEY (tipo_elemento_protocolo_id) REFERENCES prt_tipos_elementos_protocolo (id) ON UPDATE RESTRICT ON DELETE RESTRICT
+)
+WITH OIDS;
+ALTER TABLE prt_elementos_protocolo OWNER TO postgres;
+
+
+CREATE TABLE marcacoes_grupos_realizados
+(
+ id serial NOT NULL,
+ marcacao_trabalhador_id int4 NOT NULL,
+ grupo_protocolo_id int4 NOT NULL,
+ CONSTRAINT marcacoes_grupos_realizados_pkey PRIMARY KEY (id),
+ CONSTRAINT marcacoes_grupos_realizados_grupo_protocolo_id_fkey FOREIGN KEY (grupo_protocolo_id) REFERENCES prt_grupos_protocolo (id) ON UPDATE RESTRICT ON DELETE RESTRICT,
+ CONSTRAINT marcacoes_grupos_realizados_marcacao_trabalhador_id_fkey FOREIGN KEY (marcacao_trabalhador_id) REFERENCES marcacoes_trabalhador (id) ON UPDATE RESTRICT ON DELETE RESTRICT
+)
+WITH OIDS;
+ALTER TABLE marcacoes_grupos_realizados OWNER TO postgres;
+
+INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain )
+ VALUES( 1, 'Sangue', 'sangue' );
+INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain )
+ VALUES( 2, 'Urina', 'urina' );
+INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain )
+ VALUES( 3, 'RX T\\u00f3rax', 'rx torax' );
+INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain )
+ VALUES( 4, 'Audiograma', 'audiograma' );
+INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain )
+ VALUES( 5, 'Rastreio Visual', 'rastreio visual' );
+INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain )
+ VALUES( 6, 'ECG', 'ecg' );
+INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain )
+ VALUES( 7, 'Espirometria', 'espirometria' );
+INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain )
+ VALUES( 8, 'Exsudado Nasofar\\u00edngeo', 'exsudado nasofaringeo' );
+INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain )
+ VALUES( 9, 'Exame Bacteriol\\u00f3gico (Fezes)', 'exame bacteriologico (fezes)' );
+INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain )
+ VALUES( 10, 'Coprocultura', 'coprocultura' );
+INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain )
+ VALUES( 11, 'Outros ECDs', 'outros ecds' );
+INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain )
+ VALUES( 12, 'Outras An\\u00e1lises', 'outras analises' );
+
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 1, 'Hemograma', 'hemograma', 1 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 2, 'Plaquetas', 'plaquetas', 1 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 3, 'VS', 'vs', 1 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 4, 'Glicemia', 'glicemia', 1 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 5, 'Creatinina', 'creatinina', 1 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 6, 'Colesterol Total', 'colesterol total', 1 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 7, 'colesterol hdl', 'Colesterol hdl', 1 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 8, 'Colesterol LDL', 'colesterol ldl', 1 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 9, 'Trigliceridos', 'trigliceridos', 1 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 10, 'Transaminases', 'transaminases', 1 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 11, 'Gama GT', 'gama gt', 1 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 12, 'Ureia', 'ureia', 1 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 13, '\\u00c1cido \\u00darico', 'acido urico', 1 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 14, 'MBE (Chumbo)', 'mbe (chumbo)', 1 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 15, 'MBE (Outros)', 'mbe (outros)', 1 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 16, 'Serologias Hepatite', 'serologias hepatite', 1 );
+
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 17, 'Urina II', 'urina ii', 2 );
+
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 18, 'RX T\\u00f3rax', 'rx torax', 3 );
+
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 19, 'Audiometria', 'audiometria', 4 );
+
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 20, 'Rastreio Visual', 'rastreio visual', 5 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 21, 'ECG', 'ecg', 6 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 22, 'Espirometria', 'espirometria', 7 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 23, 'Exsudado Nasofar\\u00edngeo', 'exsudado nasofaringeo', 8 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 24, 'Exame Bacteriol\\u00f3gico (Fezes)', 'exame bacteriologico (fezes)', 9 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 25, 'Coprocultura', 'coprocultura', 10 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 26, 'Outros ECDs', 'outros ecds', 11 );
+INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id )
+ values( 27, 'Outras An\\u00e1lises', 'outras analises', 12 );
+
+
+ALTER TABLE prt_grupos_protocolo ADD grupo_real char(1);
+UPDATE prt_grupos_protocolo SET grupo_real='y' WHERE id <= 4;
+UPDATE prt_grupos_protocolo SET grupo_real='n' WHERE id > 4;
+
+ALTER TABLE prt_grupos_protocolo ADD ordem int4;
+UPDATE prt_grupos_protocolo SET ordem=id;
+
+ALTER TABLE prt_tipos_elementos_protocolo ADD ordem int4;
+UPDATE prt_tipos_elementos_protocolo SET ordem=id;
\ No newline at end of file
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/FaxPrinter.java b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/FaxPrinter.java
new file mode 100644
index 00000000..392f8f25
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/FaxPrinter.java
@@ -0,0 +1,177 @@
+/*
+ * FaxPrinter.java
+ *
+ * Created on March 1, 2007, 3:26 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.locais_realizacao;
+
+import com.evolute.utils.data.IDObject;
+import com.evolute.utils.data.MappableObject;
+import com.evolute.utils.ui.CustomJDialog;
+import com.evolute.utils.ui.panel.CheckBoxPanel;
+import info.clearthought.layout.TableLayout;
+import info.clearthought.layout.TableLayoutConstraints;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.JToggleButton;
+import javax.swing.SwingUtilities;
+
+/**
+ *
+ * @author fpalma
+ */
+public class FaxPrinter extends CustomJDialog
+ implements ActionListener
+{
+ private JTextField deText;
+ private JTextField deEmailText;
+ private JTextField deFaxText;
+ private JTextField deTelefoneText;
+ private JTextField assuntoText;
+ private JTextField localText;
+ private JToggleButton localAutoButton;
+ private JTextField perfil1Text;
+ private CheckBoxPanel perfil1Panel;
+ private JTextField perfil2Text;
+ private CheckBoxPanel perfil2Panel;
+ private JTextField horaText;
+
+ private JButton imprimirButton;
+ private JButton cancelarButton;
+
+ public static void main( String args[] )
+ {
+ FaxPrinter d = new FaxPrinter();
+ d.setVisible( true );
+ }
+
+ /** Creates a new instance of FaxPrinter */
+ public FaxPrinter()
+ {
+ super( null, true );
+ setupComponents();
+ }
+
+ private void setupComponents()
+ {
+ setTitle( "Por favor preencha os detalhes do Fax" );
+ setSize( 800, 600 );
+
+ JLabel deLabel = new JLabel( "De" );
+ deText = new JTextField();
+ JLabel deEmailLabel = new JLabel( "E-mail" );
+ deEmailText = new JTextField();
+ JLabel deFaxLabel = new JLabel( "Fax" );
+ deFaxText = new JTextField();
+ JLabel deTelefoneLabel = new JLabel( "N\u00famero de telefone" );
+ deTelefoneText = new JTextField();
+ JLabel assuntoLabel = new JLabel( "Assunto" );
+ assuntoText = new JTextField();
+ localAutoButton = new JToggleButton( "Local Autom\u00e1tico" );
+ localText = new JTextField();
+ JLabel perfil1Label = new JLabel( "Nome" );
+ perfil1Text = new JTextField();
+ perfil1Panel = new CheckBoxPanel( new IDObject[]{ new MappableObject( new Integer( 1 ), "teste1" ),
+ new MappableObject( new Integer( 3 ), "teste3" ) } );
+ JLabel perfil2Label = new JLabel( "Nome" );
+ perfil2Text = new JTextField();
+ perfil2Panel = new CheckBoxPanel( new IDObject[]{ new MappableObject( new Integer( 2 ), "teste2" ) } );
+ imprimirButton = new JButton( "Imprimir" );
+ imprimirButton.addActionListener( this );
+ cancelarButton = new JButton( "Cancelar" );
+ cancelarButton.addActionListener( this );
+ JPanel buttonPanel = new JPanel();
+ JPanel perfil1OuterPanel = new JPanel();
+ perfil1OuterPanel.setBorder( BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(), "Perfil 1" ) );
+ JPanel perfil2OuterPanel = new JPanel();
+ perfil2OuterPanel.setBorder( BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(), "Perfil 2" ) );
+
+ double cols[] =
+ new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM,
+ TableLayout.FILL, };
+ double rows[] =
+ new double[]{ TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED,
+ TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED };
+
+ TableLayout tableLayout = new TableLayout( cols,rows );
+ setLayout( tableLayout );
+
+ add( deLabel, new TableLayoutConstraints( 0, 0 ) );
+ add( deText, new TableLayoutConstraints( 1, 0 ) );
+ add( deEmailLabel, new TableLayoutConstraints( 2, 0 ) );
+ add( deEmailText, new TableLayoutConstraints( 3, 0 ) );
+ add( deFaxLabel, new TableLayoutConstraints( 0, 1 ) );
+ add( deFaxText, new TableLayoutConstraints( 1, 1 ) );
+ add( deTelefoneLabel, new TableLayoutConstraints( 2, 1 ) );
+ add( deTelefoneText, new TableLayoutConstraints( 3, 1 ) );
+ add( assuntoLabel, new TableLayoutConstraints( 0, 2 ) );
+ add( assuntoText, new TableLayoutConstraints( 1, 2, 3, 2 ) );
+ add( localAutoButton, new TableLayoutConstraints( 0, 3 ) );
+ add( localText, new TableLayoutConstraints( 1, 3, 3, 3 ) );
+ add( perfil1OuterPanel, new TableLayoutConstraints( 0, 4, 1, 4 ) );
+ add( perfil2OuterPanel, new TableLayoutConstraints( 2, 4, 3, 4 ) );
+ add( buttonPanel, new TableLayoutConstraints( 0, 5, 3, 5 ) );
+
+ cols = new double[]{ TableLayout.MINIMUM, TableLayout.FILL };
+ rows = new double[]{ TableLayout.PREFERRED, TableLayout.FILL };
+
+ tableLayout = new TableLayout( cols,rows );
+ perfil1OuterPanel.setLayout( tableLayout );
+
+ perfil1OuterPanel.add( perfil1Label, new TableLayoutConstraints( 0, 0 ) );
+ perfil1OuterPanel.add( perfil1Text, new TableLayoutConstraints( 1, 0 ) );
+ perfil1OuterPanel.add( perfil1Panel, new TableLayoutConstraints( 0, 1, 1, 1 ) );
+
+ tableLayout = new TableLayout( cols,rows );
+ perfil2OuterPanel.setLayout( tableLayout );
+
+ perfil2OuterPanel.add( perfil2Label, new TableLayoutConstraints( 0, 0 ) );
+ perfil2OuterPanel.add( perfil2Text, new TableLayoutConstraints( 1, 0 ) );
+ perfil2OuterPanel.add( perfil2Panel, new TableLayoutConstraints( 0, 1, 1, 1 ) );
+
+ buttonPanel.setLayout( new FlowLayout( FlowLayout.CENTER ) );
+ buttonPanel.add( imprimirButton );
+ buttonPanel.add( cancelarButton );
+
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ Object source = e.getSource();
+ if( source.equals( imprimirButton ) )
+ {
+ print();
+ }
+ else if( source.equals( cancelarButton ) )
+ {
+ close();
+ }
+ }
+
+ public void close()
+ {
+ SwingUtilities.invokeLater( new Runnable(){
+ public void run()
+ {
+ setVisible( false );
+ dispose();
+ }
+ } );
+ }
+
+ public void print()
+ {
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoDataProvider.java b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoDataProvider.java
new file mode 100644
index 00000000..75a4f86c
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoDataProvider.java
@@ -0,0 +1,196 @@
+/*
+ * LocaisRealizacaoDataProvider.java
+ *
+ * Created on February 22, 2007, 10:44 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.locais_realizacao;
+
+import com.evolute.utils.Singleton;
+import com.evolute.utils.arrays.Virtual2DArray;
+import com.evolute.utils.db.DBManager;
+import com.evolute.utils.db.Executer;
+import com.evolute.utils.sql.Assignment;
+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 com.evolute.utils.sql.Update;
+import com.evolute.utils.tables.ColumnizedMappable;
+import java.util.Date;
+
+/**
+ *
+ * @author fpalma
+ */
+public class LocaisRealizacaoDataProvider
+{
+ private static final Object LOCK = new Object();
+ private static LocaisRealizacaoDataProvider instance = null;
+
+ private Executer EXECUTER;
+
+ /** Creates a new instance of LocaisRealizacaoDataProvider */
+ public LocaisRealizacaoDataProvider()
+ throws Exception
+ {
+ DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
+ EXECUTER = dbm.getSharedExecuter( this );
+ }
+
+ public static LocaisRealizacaoDataProvider getProvider()
+ throws Exception
+ {
+ synchronized( LOCK )
+ {
+ if( instance == null )
+ {
+ instance = new LocaisRealizacaoDataProvider();
+ }
+ }
+ return instance;
+ }
+
+ public ColumnizedMappable[] getEmpresasComMarcacoes( Date data )
+ throws Exception
+ {
+ Select select =
+ new Select2(
+ new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos", "empresas" },
+ new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER },
+ new Expression[]{
+ new Field( "marcacoes_trabalhador.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 String[]{ "DISTINCT empresas.id", "empresas.designacao_social", "empresas.designacao_social_plain" },
+ new Field( "marcacoes_trabalhador.data" ).isEqual( data ),
+ new String[]{ "empresas.designacao_social_plain" },
+ null,
+ null,
+ null );
+ Virtual2DArray array = EXECUTER.executeQuery( select );
+ ColumnizedMappable empresas[] = new ColumnizedMappable[ array.columnLength() ];
+ for( int n = 0; n < empresas.length; n++ )
+ {
+ Integer id = ( Integer ) array.get( n, 0 );
+ String designacao = ( String ) array.get( n, 1 );
+ empresas[ n ] = new ColumnizedMappable( id, designacao );
+ }
+ return empresas;
+ }
+
+ public ColumnizedMappable[] getEstabelecimentosComMarcacoesByEmpresa( Integer empresaID, Date data )
+ throws Exception
+ {
+ Select select =
+ new Select2(
+ new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos" },
+ new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER },
+ new Expression[]{
+ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ),
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) },
+ new String[]{ "DISTINCT estabelecimentos.id", "estabelecimentos.nome", "estabelecimentos.nome_plain" },
+ new Field( "marcacoes_trabalhador.data" ).isEqual( data ).and(
+ new Field( "estabelecimentos.empresa_id" ).isEqual( empresaID ) ),
+ new String[]{ "estabelecimentos.nome_plain" },
+ null,
+ null,
+ null );
+ Virtual2DArray array = EXECUTER.executeQuery( select );
+ ColumnizedMappable estabelecimentos[] = new ColumnizedMappable[ array.columnLength() ];
+ for( int n = 0; n < estabelecimentos.length; n++ )
+ {
+ Integer id = ( Integer ) array.get( n, 0 );
+ String nome = ( String ) array.get( n, 1 );
+ estabelecimentos[ n ] = new ColumnizedMappable( id, nome );
+ }
+ return estabelecimentos;
+ }
+
+ public int getNumeroMarcacoesByEstabelecimentoAndTipo( Integer estabelecimentoID, int tipo, Date data )
+ throws Exception
+ {
+ Select select =
+ new Select2(
+ new String[]{ "marcacoes_trabalhador", "trabalhadores" },
+ new Integer[]{ Select2.JOIN_INNER },
+ new Expression[]{
+ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) },
+ new String[]{ "COUNT( * )" },
+ new Field( "marcacoes_trabalhador.data" ).isEqual( data ).and(
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
+ new Field( "marcacoes_trabalhador.tipo" ).isEqual( tipo ) ),
+ null,
+ null,
+ null,
+ null );
+ Virtual2DArray array = EXECUTER.executeQuery( select );
+ if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
+ {
+ return 0;
+ }
+ else
+ {
+ return ( ( Number ) array.get( 0, 0 ) ).intValue();
+ }
+ }
+
+ public Integer[] getPrestadoresIDByEstabelecimentoAndTipo( Integer estabelecimentoID, int tipo, Date data )
+ throws Exception
+ {
+ Select select =
+ new Select2(
+ new String[]{ "marcacoes_trabalhador", "trabalhadores" },
+ new Integer[]{ Select2.JOIN_INNER },
+ new Expression[]{
+ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) },
+ new String[]{ "DISTINCT prestador_id" },
+ new Field( "marcacoes_trabalhador.data" ).isEqual( data ).and(
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
+ new Field( "marcacoes_trabalhador.tipo" ).isEqual( tipo ) ),
+ null,
+ null,
+ null,
+ null );
+ Virtual2DArray array = EXECUTER.executeQuery( select );
+ Integer ids[] = new Integer[ array.columnLength() ];
+ for( int n = 0; n < ids.length; n++ )
+ {
+ ids[ n ] = ( Integer ) array.get( n, 0 );
+ }
+ return ids;
+ }
+
+ public void setPrestadorIDForEstabelecimentoAndTipo( Integer estabelecimentoID, int tipo, Date data, Integer prestadorID )
+ throws Exception
+ {
+ Select select =
+ new Select2(
+ new String[]{ "marcacoes_trabalhador", "trabalhadores" },
+ new Integer[]{ Select2.JOIN_INNER },
+ new Expression[]{
+ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) },
+ new String[]{ "marcacoes_trabalhador.id" },
+ new Field( "marcacoes_trabalhador.data" ).isEqual( data ).and(
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
+ new Field( "marcacoes_trabalhador.tipo" ).isEqual( tipo ) ),
+ null,
+ null,
+ null,
+ null );
+ Virtual2DArray array = EXECUTER.executeQuery( select );
+ for( int n = 0; n < array.columnLength(); n++ )
+ {
+ Integer id = ( Integer ) array.get( n, 0 );
+ Update update =
+ new Update( "marcacoes_trabalhador",
+ new Assignment[]{
+ new Assignment( "prestador_id", prestadorID ) },
+ new Field( "id" ).isEqual( id ) );
+ EXECUTER.executeQuery( update );
+ }
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoWindow.java b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoWindow.java
new file mode 100644
index 00000000..0a7e7c89
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoWindow.java
@@ -0,0 +1,548 @@
+/*
+ * LocaisRealizacaoWindow.java
+ *
+ * Created on February 22, 2007, 10:19 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.locais_realizacao;
+
+import com.evolute.utils.data.IDObject;
+import com.evolute.utils.data.MappableObject;
+import com.evolute.utils.tables.BaseTable;
+import com.evolute.utils.tables.ColumnizedMappable;
+import com.evolute.utils.tables.VectorTableModel;
+import com.evolute.utils.tracker.TrackableWindow;
+import com.evolute.utils.ui.DialogException;
+import com.evolute.utils.ui.calendar.JCalendarPanel;
+import info.clearthought.layout.TableLayout;
+import info.clearthought.layout.TableLayoutConstraints;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.FlowLayout;
+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.util.Arrays;
+import java.util.Date;
+import java.util.Vector;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.ListSelectionModel;
+import javax.swing.SwingUtilities;
+import javax.swing.WindowConstants;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import siprp.data.Marcacao;
+import siprp.medicina.prestadores.PrestadoresDataProvider;
+
+/**
+ *
+ * @author fpalma
+ */
+public class LocaisRealizacaoWindow extends JFrame
+ implements ActionListener, TrackableWindow, ListSelectionListener
+{
+ protected static final Integer PRESTADOR_ID_SIPRP = new Integer( -1 );
+
+ protected static final IDObject PRESTADOR_SIPRP = new MappableObject( PRESTADOR_ID_SIPRP, "SIPRP" );
+
+ protected JCalendarPanel dataPanel;
+ protected JButton carregarButton;
+ protected JButton recarregarPrestadoresButton;
+ protected VectorTableModel empresasModel;
+ protected BaseTable empresasTable;
+ protected VectorTableModel estabelecimentosModel;
+ protected BaseTable estabelecimentosTable;
+ protected JLabel numeroConsultasLabel;
+ protected JComboBox prestadoresConsultasCombo;
+ protected JButton enviarConsultasButton;
+ protected JButton faxConsultasButton;
+ protected JLabel numeroECDsLabel;
+ protected JComboBox prestadoresECDsCombo;
+ protected JButton enviarECDsButton;
+ protected JButton faxECDsButton;
+
+
+ protected LocaisRealizacaoDataProvider provider;
+ protected PrestadoresDataProvider prestadoresProvider;
+
+ /**
+ * Creates a new instance of LocaisRealizacaoWindow
+ */
+ public LocaisRealizacaoWindow()
+ throws Exception
+ {
+ provider = LocaisRealizacaoDataProvider.getProvider();
+ prestadoresProvider = PrestadoresDataProvider.getProvider();
+ setupComponents();
+ }
+
+ private void setupComponents()
+ {
+ setTitle( "Locais de Realiza\u00e7\u00e3o" );
+ setSize( 1000, 700 );
+ JLabel dataLabel = new JLabel( "Data" );
+ dataPanel = new JCalendarPanel( this );
+
+ carregarButton = new JButton( "Carregar" );
+ carregarButton.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 );
+ empresasTable.getSelectionModel().addListSelectionListener( this );
+ JScrollPane empresasScp = new JScrollPane( empresasTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ estabelecimentosModel = new VectorTableModel( new String[]{ "estabelecimento" } );
+ estabelecimentosTable = new BaseTable( estabelecimentosModel );
+ estabelecimentosTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ estabelecimentosTable.getSelectionModel().addListSelectionListener( this );
+ JScrollPane estabelecimentosScp = new JScrollPane( estabelecimentosTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ JPanel consultasPanel = new JPanel();
+ consultasPanel.setBorder( BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(), "Consultas" ) );
+ JLabel consultasLabel = new JLabel( "Quantidade " );
+ numeroConsultasLabel = new JLabel( " " );
+ numeroConsultasLabel.setForeground( Color.green.darker() );
+ prestadoresConsultasCombo = new JComboBox();
+ enviarConsultasButton = new JButton( "Atribuir" );
+ enviarConsultasButton.addActionListener( this );
+ faxConsultasButton = new JButton( "Fax" );
+ faxConsultasButton.addActionListener( this );
+ JPanel ecdsPanel = new JPanel();
+ ecdsPanel.setBorder( BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(), "ECDs" ) );
+ JLabel ecdsLabel = new JLabel( "Quantidade " );
+ numeroECDsLabel = new JLabel( " " );
+ numeroECDsLabel.setForeground( Color.green.darker() );
+ prestadoresECDsCombo = new JComboBox();
+ enviarECDsButton = new JButton( "Atribuir" );
+ enviarECDsButton.addActionListener( this );
+ faxECDsButton = new JButton( "Fax" );
+ faxECDsButton.addActionListener( this );
+ dataPanel.addChangeListener( new ChangeListener(){
+ public void stateChanged(ChangeEvent e)
+ {
+ empresasTable.clearSelection();
+ Vector values = empresasModel.getValues();
+ values.clear();
+ empresasModel.setValues( values );
+ }
+ } );
+
+ getContentPane().setLayout( new BorderLayout( 5, 5 ) );
+ JPanel upperPanel = new JPanel();
+ getContentPane().add( upperPanel, BorderLayout.NORTH );
+ JPanel centerPanel = new JPanel();
+ getContentPane().add( centerPanel, BorderLayout.CENTER );
+
+ upperPanel.setLayout( new FlowLayout( FlowLayout.CENTER ) );
+ upperPanel.add( dataLabel );
+ upperPanel.add( dataPanel );
+ upperPanel.add( carregarButton );
+ upperPanel.add( recarregarPrestadoresButton );
+
+ centerPanel.setLayout( new GridLayout( 1, 3 ) );
+ centerPanel.add( empresasScp );
+ centerPanel.add( estabelecimentosScp );
+ JPanel detalhesPanel = new JPanel();
+ centerPanel.add( detalhesPanel );
+
+ double cols[] =
+ new double[]{ TableLayout.MINIMUM, TableLayout.FILL };
+ double rows[] =
+ new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM };
+
+ TableLayout tableLayout = new TableLayout( cols,rows );
+ consultasPanel.setLayout( tableLayout );
+
+ consultasPanel.add( consultasLabel, new TableLayoutConstraints( 0, 0 ) );
+ consultasPanel.add( numeroConsultasLabel, new TableLayoutConstraints( 1, 0 ) );
+ consultasPanel.add( prestadoresConsultasCombo, new TableLayoutConstraints( 0, 1, 1, 1 ) );
+ consultasPanel.add( enviarConsultasButton, new TableLayoutConstraints( 0, 2, 1, 2 ) );
+// consultasPanel.add( faxConsultasButton, new TableLayoutConstraints( 0, 3, 1, 3 ) );
+
+ rows = new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM };
+
+ tableLayout = new TableLayout( cols,rows );
+ ecdsPanel.setLayout( tableLayout );
+
+ ecdsPanel.add( ecdsLabel, new TableLayoutConstraints( 0, 0 ) );
+ ecdsPanel.add( numeroECDsLabel, new TableLayoutConstraints( 1, 0 ) );
+ ecdsPanel.add( prestadoresECDsCombo, new TableLayoutConstraints( 0, 1, 1, 1 ) );
+ ecdsPanel.add( enviarECDsButton, new TableLayoutConstraints( 0, 2, 1, 2 ) );
+ ecdsPanel.add( faxECDsButton, new TableLayoutConstraints( 0, 3, 1, 3 ) );
+
+ cols = new double[]{ TableLayout.FILL };
+ rows = new double[]{ TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL };
+
+ tableLayout = new TableLayout( cols,rows );
+ detalhesPanel.setLayout( tableLayout );
+
+ detalhesPanel.add( consultasPanel, new TableLayoutConstraints( 0, 0 ) );
+ detalhesPanel.add( ecdsPanel, new TableLayoutConstraints( 0, 1 ) );
+
+ 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() );
+ recarregarPrestadores();
+ carregar();
+ }
+
+ 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;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ Object source = e.getSource();
+ if( source.equals( carregarButton ) )
+ {
+ carregar();
+ }
+ else if( source.equals( recarregarPrestadoresButton ) )
+ {
+ recarregarPrestadores();
+ }
+ else if( source.equals( enviarConsultasButton ) )
+ {
+ enviarConsultas();
+ }
+ else if( source.equals( faxConsultasButton ) )
+ {
+ faxConsultas();
+ }
+ else if( source.equals( enviarECDsButton ) )
+ {
+ enviarECDs();
+ }
+ else if( source.equals( faxECDsButton ) )
+ {
+ faxECDs();
+ }
+
+ }
+
+ public void valueChanged(ListSelectionEvent e)
+ {
+ Object source = e.getSource();
+ if( e.getValueIsAdjusting() )
+ {
+ return;
+ }
+ if( source.equals( empresasTable.getSelectionModel() ) )
+ {
+ mudarEmpresa();
+ }
+ else if( source.equals( estabelecimentosTable.getSelectionModel() ) )
+ {
+ mudarEstabelecimento();
+ }
+ }
+
+ protected void carregar()
+ {
+ empresasTable.clearSelection();
+ Date data = dataPanel.getDate();
+ if( data == null )
+ {
+ empresasModel.clearAll();
+ return;
+ }
+ try
+ {
+ ColumnizedMappable empresas[] = provider.getEmpresasComMarcacoes( data );
+ Vector values = empresasModel.getValues();
+ values.clear();
+ values.addAll( Arrays.asList( empresas ) );
+ empresasModel.setValues( values );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar empresas", true );
+ }
+ }
+
+ protected void mudarEmpresa()
+ {
+ estabelecimentosTable.clearSelection();
+ Date data = dataPanel.getDate();
+ int selected = empresasTable.getSelectedRow();
+ if( data == null || selected == -1 )
+ {
+ estabelecimentosModel.clearAll();
+ return;
+ }
+ Integer empresaID = ( ( ColumnizedMappable ) empresasModel.getRowAt( selected ) ).getID();
+ try
+ {
+ ColumnizedMappable estabelecimentos[] =
+ provider.getEstabelecimentosComMarcacoesByEmpresa( empresaID, data );
+ Vector values = estabelecimentosModel.getValues();
+ values.clear();
+ values.addAll( Arrays.asList( estabelecimentos ) );
+ estabelecimentosModel.setValues( values );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar estabelecimentos", true );
+ }
+ }
+
+ protected void mudarEstabelecimento()
+ {
+ Date data = dataPanel.getDate();
+ int selectedEstabelecimento = estabelecimentosTable.getSelectedRow();
+ numeroConsultasLabel.setText( " " );
+ numeroECDsLabel.setText( " " );
+ enviarConsultasButton.setEnabled( false );
+ enviarECDsButton.setEnabled( false );
+ if( data == null || selectedEstabelecimento == -1 )
+ {
+ return;
+ }
+ Integer estabelecimentoID = ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( selectedEstabelecimento ) ).getID();
+ try
+ {
+ int countConsultas =
+ provider.getNumeroMarcacoesByEstabelecimentoAndTipo( estabelecimentoID,
+ Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA, data );
+ int countECDs =
+ provider.getNumeroMarcacoesByEstabelecimentoAndTipo( estabelecimentoID,
+ Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES, data );
+ if( countConsultas > 0 )
+ {
+ numeroConsultasLabel.setText( "" + countConsultas );
+ enviarConsultasButton.setEnabled( true );
+ Integer[] escolhidos =
+ provider.getPrestadoresIDByEstabelecimentoAndTipo( estabelecimentoID,
+ Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA, data );
+ if( escolhidos.length == 1 )
+ {
+ numeroConsultasLabel.setForeground( Color.green.darker() );
+ }
+ else
+ {
+ numeroConsultasLabel.setForeground( Color.red.darker() );
+ }
+ int e;
+ for( e = 0; e < escolhidos.length; e++ )
+ {
+ if( escolhidos[ e ] != null )
+ {
+ break;
+ }
+ }
+ if( e == escolhidos.length || escolhidos[ e ] == null )
+ {
+ prestadoresConsultasCombo.setSelectedIndex( 0 );
+ }
+ else
+ {
+ for( int p = 0; p < prestadoresConsultasCombo.getItemCount(); p++ )
+ {
+ IDObject prestador = ( IDObject ) prestadoresConsultasCombo.getItemAt( p );
+ if( prestador.getID().equals( escolhidos[ e ] ) )
+ {
+ prestadoresConsultasCombo.setSelectedIndex( p );
+ }
+ }
+ }
+ }
+ if( countECDs > 0 )
+ {
+ numeroECDsLabel.setText( "" + countECDs );
+ enviarECDsButton.setEnabled( true );
+ Integer[] escolhidos =
+ provider.getPrestadoresIDByEstabelecimentoAndTipo( estabelecimentoID,
+ Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES, data );
+ if( escolhidos.length == 1 )
+ {
+ numeroECDsLabel.setForeground( Color.green.darker() );
+ }
+ else
+ {
+ numeroECDsLabel.setForeground( Color.red.darker() );
+ }
+ int e;
+ for( e = 0; e < escolhidos.length; e++ )
+ {
+ if( escolhidos[ e ] != null )
+ {
+ break;
+ }
+ }
+ if( e == escolhidos.length || escolhidos[ e ] == null )
+ {
+ prestadoresECDsCombo.setSelectedIndex( 0 );
+ }
+ else
+ {
+ for( int p = 0; p < prestadoresECDsCombo.getItemCount(); p++ )
+ {
+ IDObject prestador = ( IDObject ) prestadoresECDsCombo.getItemAt( p );
+ if( prestador.getID().equals( escolhidos[ e ] ) )
+ {
+ prestadoresECDsCombo.setSelectedIndex( p );
+ }
+ }
+ }
+ }
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar detalhes", true );
+ }
+ }
+
+ protected void recarregarPrestadores()
+ {
+ try
+ {
+ IDObject prestadoresConsultas[] = prestadoresProvider.getPrestadoresConsultasActivos();
+ IDObject prestadoresECDs[] = prestadoresProvider.getPrestadoresECDsActivos();
+ prestadoresConsultasCombo.removeAllItems();
+ prestadoresConsultasCombo.addItem( PRESTADOR_SIPRP );
+ for( int n = 0; n < prestadoresConsultas.length; n++ )
+ {
+ prestadoresConsultasCombo.addItem( prestadoresConsultas[ n ] );
+ }
+ prestadoresECDsCombo.removeAllItems();
+ prestadoresECDsCombo.addItem( PRESTADOR_SIPRP );
+ for( int n = 0; n < prestadoresECDs.length; n++ )
+ {
+ prestadoresECDsCombo.addItem( prestadoresECDs[ n ] );
+ }
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar prestadores", true );
+ }
+ }
+
+ protected void enviarECDs()
+ {
+ Date data = dataPanel.getDate();
+ int selectedEstabelecimento = estabelecimentosTable.getSelectedRow();
+ if( data == null || selectedEstabelecimento == -1 )
+ {
+ return;
+ }
+ Integer estabelecimentoID = ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( selectedEstabelecimento ) ).getID();
+ try
+ {
+ Integer prestadorID = ( ( IDObject ) prestadoresECDsCombo.getSelectedItem() ).getID();
+ if( PRESTADOR_ID_SIPRP.equals( prestadorID ) )
+ {
+ prestadorID = null;
+ }
+ provider.setPrestadorIDForEstabelecimentoAndTipo( estabelecimentoID,
+ Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES, data, prestadorID );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a atribuir", true );
+ }
+ }
+
+ protected void faxECDs()
+ {
+ Date data = dataPanel.getDate();
+ int selectedEstabelecimento = estabelecimentosTable.getSelectedRow();
+ if( data == null || selectedEstabelecimento == -1 )
+ {
+ return;
+ }
+ Integer estabelecimentoID = ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( selectedEstabelecimento ) ).getID();
+ try
+ {
+ Integer prestadorID = ( ( IDObject ) prestadoresECDsCombo.getSelectedItem() ).getID();
+ if( PRESTADOR_ID_SIPRP.equals( prestadorID ) )
+ {
+ prestadorID = null;
+ }
+ provider.setPrestadorIDForEstabelecimentoAndTipo( estabelecimentoID,
+ Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES, data, prestadorID );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a atribuir", true );
+ }
+ }
+
+ protected void enviarConsultas()
+ {
+ Date data = dataPanel.getDate();
+ int selectedEstabelecimento = estabelecimentosTable.getSelectedRow();
+ if( data == null || selectedEstabelecimento == -1 )
+ {
+ return;
+ }
+ Integer estabelecimentoID = ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( selectedEstabelecimento ) ).getID();
+ try
+ {
+ Integer prestadorID = ( ( IDObject ) prestadoresConsultasCombo.getSelectedItem() ).getID();
+ if( PRESTADOR_ID_SIPRP.equals( prestadorID ) )
+ {
+ prestadorID = null;
+ }
+ provider.setPrestadorIDForEstabelecimentoAndTipo( estabelecimentoID,
+ Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA, data, prestadorID );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a atribuir", true );
+ }
+ }
+
+ protected void faxConsultas()
+ {
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/fax_ecds.xsl b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/fax_ecds.xsl
new file mode 100644
index 00000000..2559b0c2
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/fax_ecds.xsl
@@ -0,0 +1,313 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ FAX
+
+
+ Nº de Páginas (incluíndo esta)
+ / Number of pages (including this one):
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Data
+ / Date:
+
+
+
+
+
+
+
+
+
+
+
+
+ Para
+ / To:
+
+
+
+
+
+
+
+
+
+
+
+
+ Empresa
+ / Company:
+
+
+
+
+
+
+
+
+
+
+
+
+ Nº Fax
+ / Fax number:
+
+
+
+
+
+
+
+
+
+
+
+
+ De
+ / From:
+
+
+
+
+
+
+
+
+
+ E-mail:
+
+
+
+
+
+
+
+
+
+
+
+
+ Nº Fax
+ / Fax number:
+
+
+
+
+
+
+
+
+
+ Nº Tel.
+ / Phone number:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Assunto
+ / Subject:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Cliente:
+
+
+
+
+
+
+
+
+
+ Local:
+
+
+
+
+
+
+
+
+
+
+
+
+ Data:
+
+
+
+
+
+
+
+
+
+ Hora:
+
+
+
+
+
+
+
+
+
+
+
+
+ Exmos. Senhores,
+
+
+ Informo que os
+ seguintes
+ colaboradores
+ irão
+ irá
+ comparecer nas vossas instalações para colheita:
+
+
+
+
+
+
+
+
+
+
+ NOME DO FUNCIONÁRIO
+
+
+
+
+ DATA_NASCIMENTO
+
+
+
+
+ PERFIL
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PERFIL
+ :
+
+ ,
+
+
+
+
+
+
+
+
+
+
+
+ AGRADEÇO QUE ESTA LISTAGEM NOS SEJA REENVIADA COM INDICAÇÃO DAS
+ EVENTUAIS FALTAS OCORRIDAS
+
+
+
+
+
+
+
+ Sem outro assunto de momento, aproveitamos para apresentar os nossos melhores cumprimentos,
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/fax_ecds_teste.xml b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/fax_ecds_teste.xml
new file mode 100644
index 00000000..8e0366c2
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/fax_ecds_teste.xml
@@ -0,0 +1,234 @@
+
+
+
+
+
+ 24-01-2007
+ Pedro Manuel Silva Bento
+ Laboratorio ao lado da mercearia
+ 21 351 45 67
+ Paula Dias
+ pdias@siprp.pt
+ (+351) 21 789 88 32
+ (+351) 21 789 88 32
+ Marcação de Colheitas para Análise
+ Evolute
+ Laboratorio ao lado da mercearia
+ 28-01-2007
+ 08H00
+ 1
+
+ Frederico Alexandre de Matos Monge Palma
+ 02-10-1976
+ 1
+
+
+ Pedro da Silva Antonio
+ 02-10-1973
+ 2
+
+
+ Joao Pedro Silva
+ 02-10-1976
+ 1
+
+
+ Frederico Alexandre de Matos Monge Palma
+ 02-10-1976
+ 1
+
+
+ Pedro da Silva Antonio
+ 02-10-1973
+ 2
+
+
+ Joao Pedro Silva
+ 02-10-1976
+ 1
+
+
+ Frederico Alexandre de Matos Monge Palma
+ 02-10-1976
+ 1
+
+
+ Pedro da Silva Antonio
+ 02-10-1973
+ 2
+
+
+ Joao Pedro Silva
+ 02-10-1976
+ 1
+
+
+ Frederico Alexandre de Matos Monge Palma
+ 02-10-1976
+ 1
+
+
+ Pedro da Silva Antonio
+ 02-10-1973
+ 2
+
+
+ Joao Pedro Silva
+ 02-10-1976
+ 1
+
+
+ Frederico Alexandre de Matos Monge Palma
+ 02-10-1976
+ 1
+
+
+ Pedro da Silva Antonio
+ 02-10-1973
+ 2
+
+
+ Joao Pedro Silva
+ 02-10-1976
+ 1
+
+
+ Frederico Alexandre de Matos Monge Palma
+ 02-10-1976
+ 1
+
+
+ Pedro da Silva Antonio
+ 02-10-1973
+ 2
+
+
+ Joao Pedro Silva
+ 02-10-1976
+ 1
+
+
+ Frederico Alexandre de Matos Monge Palma
+ 02-10-1976
+ 1
+
+
+ Pedro da Silva Antonio
+ 02-10-1973
+ 2
+
+
+ Joao Pedro Silva
+ 02-10-1976
+ 1
+
+
+ Frederico Alexandre de Matos Monge Palma
+ 02-10-1976
+ 1
+
+
+ Pedro da Silva Antonio
+ 02-10-1973
+ 2
+
+
+ Joao Pedro Silva
+ 02-10-1976
+ 1
+
+
+ Frederico Alexandre de Matos Monge Palma
+ 02-10-1976
+ 1
+
+
+ Pedro da Silva Antonio
+ 02-10-1973
+ 2
+
+
+ Joao Pedro Silva
+ 02-10-1976
+ 1
+
+
+ Frederico Alexandre de Matos Monge Palma
+ 02-10-1976
+ 1
+
+
+ Pedro da Silva Antonio
+ 02-10-1973
+ 2
+
+
+ Joao Pedro Silva
+ 02-10-1976
+ 1
+
+
+ Frederico Alexandre de Matos Monge Palma
+ 02-10-1976
+ 1
+
+
+ Pedro da Silva Antonio
+ 02-10-1973
+ 2
+
+
+ Joao Pedro Silva
+ 02-10-1976
+ 1
+
+
+ Frederico Alexandre de Matos Monge Palma
+ 02-10-1976
+ 1
+
+
+ Pedro da Silva Antonio
+ 02-10-1973
+ 2
+
+
+ Joao Pedro Silva
+ 02-10-1976
+ 1
+
+
+
+ GENÉRICO
+ Hemograma
+ Vel. Sedimentação
+ Glicemia em Jejum
+ Creatinina
+ Colesterol Total
+ Colesterol HDL
+ Triglicéridos
+ Transaminases
+ Gama GT
+ Urina II
+
+
+ MANIPULADORES
+ Hemograma
+ Vel. Sedimentação
+ Glicemia em Jejum
+ Creatinina
+ Colesterol Total
+ Colesterol HDL
+ Triglicéridos
+ Transaminases
+ Gama GT
+ Urina II
+ Quistos
+
+
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/DetalhesRealizacaoDialog.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/DetalhesRealizacaoDialog.java
new file mode 100644
index 00000000..6b939411
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/presencas/DetalhesRealizacaoDialog.java
@@ -0,0 +1,103 @@
+/*
+ * DetalhesRealizacaoDialog.java
+ *
+ * Created on February 1, 2007, 11:19 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.presencas;
+
+import com.evolute.utils.data.IDObject;
+import com.evolute.utils.ui.CustomJDialog;
+import com.evolute.utils.ui.panel.CheckBoxPanel;
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class DetalhesRealizacaoDialog extends CustomJDialog
+ implements ActionListener
+{
+ protected JButton okButton;
+ protected JButton cancelButton;
+ protected CheckBoxPanel opcoesPanel;
+
+ protected IDObject opcoes[];
+
+ protected Integer selected[];
+
+ /** Creates a new instance of DetalhesRealizacaoDialog */
+ public DetalhesRealizacaoDialog( JFrame owner, IDObject opcoes[] )
+ {
+ super( owner, true );
+ this.opcoes = opcoes;
+ setupComponents();
+ if( owner != null )
+ {
+ centerSuper();
+ }
+ else
+ {
+ center();
+ }
+ setVisible( true );
+ }
+
+ private void setupComponents()
+ {
+ setTitle( "Escolha os ECD's realizados" );
+ okButton = new JButton( "OK" );
+ okButton.addActionListener( this );
+ cancelButton = new JButton( "Cancelar" );
+ cancelButton.addActionListener( this );
+ opcoesPanel = new CheckBoxPanel( opcoes );
+
+ setLayout( new BorderLayout() );
+ add( opcoesPanel, BorderLayout.CENTER );
+ JPanel buttonPanel = new JPanel();
+ add( buttonPanel, BorderLayout.SOUTH );
+
+ buttonPanel.setLayout( new FlowLayout( FlowLayout.RIGHT ) );
+ buttonPanel.add( okButton );
+ buttonPanel.add( cancelButton );
+
+ setSize( 250, 300 );
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ Object source = e.getSource();
+ if( source.equals( okButton ) )
+ {
+ selected = opcoesPanel.getSelected();
+ close();
+ }
+ else if( source.equals( cancelButton ) )
+ {
+ close();
+ }
+ }
+
+ public void close()
+ {
+ SwingUtilities.invokeLater( new Runnable(){
+ public void run()
+ {
+ setVisible( false );
+ dispose();
+ }
+ } );
+ }
+
+ public Integer[] getSelected()
+ {
+ return selected;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/ImpressaoAuxiliaresWindow.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/ImpressaoAuxiliaresWindow.java
new file mode 100644
index 00000000..022449ce
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/presencas/ImpressaoAuxiliaresWindow.java
@@ -0,0 +1,40 @@
+/*
+ * ImpressaoAuxiliaresWindow.java
+ *
+ * Created on 7 de Dezembro de 2006, 16:13
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.presencas;
+
+import java.awt.*;
+import javax.swing.*;
+
+import com.evolute.utils.ui.*;
+import com.evolute.utils.ui.calendar.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class ImpressaoAuxiliaresWindow extends JFrame
+{
+ protected JCalendarPanel calendarPanel;
+ protected JButton imprimirButton;
+
+ /** Creates a new instance of ImpressaoAuxiliaresWindow */
+ public ImpressaoAuxiliaresWindow()
+ {
+ setupComponents();
+ }
+
+ private void setupComponents()
+ {
+ setTitle( "Imprimir" );
+ JLabel dataLabel = new JLabel( "Data" );
+ calendarPanel = new JCalendarPanel( this );
+ imprimirButton = new JButton( "Imprimir" );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/Presenca.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/Presenca.java
new file mode 100644
index 00000000..8398bcf9
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/presencas/Presenca.java
@@ -0,0 +1,107 @@
+/*
+ * Presenca.java
+ *
+ * Created on February 1, 2007, 4:54 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.presencas;
+
+import com.evolute.utils.data.IDObject;
+import siprp.data.Marcacao;
+
+/**
+ *
+ * @author fpalma
+ */
+public class Presenca
+ implements IDObject, Comparable
+{
+ protected Integer id;
+ protected String nome;
+ protected String nomePlain;
+ protected String nomeEmpresa;
+ protected Integer tipo;
+
+ /** Creates a new instance of Presenca */
+ public Presenca( Integer id, String nome, String nomePlain, String nomeEmpresa,
+ Integer tipo )
+ {
+ this.setId(id);
+ this.setNome(nome);
+ this.setNomePlain(nomePlain);
+ this.setNomeEmpresa(nomeEmpresa);
+ this.setTipo(tipo);
+ }
+
+ public Integer getID()
+ {
+ return getId();
+ }
+
+ public int compareTo( Object other )
+ {
+ return getNomePlain().compareTo( ( ( Presenca ) other ).getNomePlain() );
+ }
+
+ public String toString()
+ {
+ String empresa = getNomeEmpresa();
+ return "" + getNome() + "
"
+ + " (" + empresa.substring( 0, empresa.length() > 50 ? 50 : empresa.length() )
+ + ")" + "";
+ }
+
+ public Integer getId()
+ {
+ return id;
+ }
+
+ public void setId(Integer id)
+ {
+ this.id = id;
+ }
+
+ public String getNome()
+ {
+ return nome;
+ }
+
+ public void setNome(String nome)
+ {
+ this.nome = nome;
+ }
+
+ public String getNomePlain()
+ {
+ return nomePlain;
+ }
+
+ public void setNomePlain(String nomePlain)
+ {
+ this.nomePlain = nomePlain;
+ }
+
+ public String getNomeEmpresa()
+ {
+ return nomeEmpresa;
+ }
+
+ public void setNomeEmpresa(String nomeEmpresa)
+ {
+ this.nomeEmpresa = nomeEmpresa;
+ }
+
+ public Integer getTipo()
+ {
+ return tipo;
+ }
+
+ public void setTipo(Integer tipo)
+ {
+ this.tipo = tipo;
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/PresencasActionFactory.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/PresencasActionFactory.java
new file mode 100644
index 00000000..a9faca2e
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/presencas/PresencasActionFactory.java
@@ -0,0 +1,80 @@
+/*
+ * PresencasActionFactory.java
+ *
+ * Created on January 31, 2007, 6:37 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.presencas;
+
+import com.evolute.utils.data.IDObject;
+import com.evolute.utils.ui.panel.multipleactionlist.ActionFactory;
+import javax.swing.Action;
+import siprp.medicina.presencas.actions.DesmarcadoSHSTAction;
+import siprp.medicina.presencas.actions.DesmarcadoTrabalhadorAction;
+import siprp.medicina.presencas.actions.FaltouAction;
+import siprp.medicina.presencas.actions.RealizouAction;
+import siprp.medicina.presencas.actions.RealizouParcialmenteAction;
+
+/**
+ *
+ * @author fpalma
+ */
+public class PresencasActionFactory implements ActionFactory
+{
+ public static final int REALIZOU = 0;
+ public static final int REALIZOU_PARCIALMENTE = 1;
+ public static final int TRABALHADOR_DESMARCOU = 2;
+ public static final int SHST_DESMARCOU = 3;
+ public static final int FALTOU = 4;
+
+ protected final int TIPO;
+
+ /** Creates a new instance of PresencasActionFactory */
+ public PresencasActionFactory( int tipo )
+ {
+ TIPO = tipo;
+ }
+
+ public Action createAction(Presenca[] objects)
+ {
+ switch( TIPO )
+ {
+ case SHST_DESMARCOU:
+ return new DesmarcadoSHSTAction( DesmarcadoSHSTAction.MULTIPLE, objects );
+
+ case FALTOU:
+ return new FaltouAction( FaltouAction.MULTIPLE, objects );
+
+ default:
+ return null;
+ }
+ }
+
+ public Action createAction(Presenca object)
+ {
+ switch( TIPO )
+ {
+ case REALIZOU:
+ return new RealizouAction( object );
+
+ case REALIZOU_PARCIALMENTE:
+ return new RealizouParcialmenteAction( object );
+
+ case TRABALHADOR_DESMARCOU:
+ return new DesmarcadoTrabalhadorAction( object );
+
+ case SHST_DESMARCOU:
+ return new DesmarcadoSHSTAction( DesmarcadoSHSTAction.SINGLE, new Presenca[]{ object } );
+
+ case FALTOU:
+ return new FaltouAction( FaltouAction.SINGLE, new Presenca[]{ object } );
+
+ default:
+ return null;
+ }
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/PresencasDataProvider.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/PresencasDataProvider.java
new file mode 100644
index 00000000..eb5521b2
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/presencas/PresencasDataProvider.java
@@ -0,0 +1,191 @@
+/*
+ * PresencasDataProvider.java
+ *
+ * Created on February 5, 2007, 5:51 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.presencas;
+
+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;
+import com.evolute.utils.sql.Update;
+import java.util.Date;
+import siprp.lembretes.LembretesConstants;
+import siprp.lembretes.LembretesDataProvider;
+import siprp.medicina.MedicinaConstants;
+import siprp.medicina.MedicinaDataProvider;
+
+/**
+ *
+ * @author lflores
+ */
+public class PresencasDataProvider
+ implements MedicinaConstants, LembretesConstants
+{
+ private static final Object LOCK = new Object();
+ private static PresencasDataProvider instance = null;
+
+ private MedicinaDataProvider medicinaProvider;
+ private LembretesDataProvider lembretesProvider;
+ private Executer EXECUTER;
+
+ /** Creates a new instance of PresencasDataProvider */
+ public PresencasDataProvider()
+ throws Exception
+ {
+ DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
+ EXECUTER = dbm.getSharedExecuter( this );
+ medicinaProvider = ( MedicinaDataProvider ) MedicinaDataProvider.getProvider();
+ lembretesProvider = LembretesDataProvider.getProvider();
+ }
+
+ public static PresencasDataProvider getProvider()
+ throws Exception
+ {
+ synchronized( LOCK )
+ {
+ if( instance == null )
+ {
+ instance = new PresencasDataProvider();
+ }
+ }
+ return instance;
+ }
+
+ protected void apagarDetalhesRealizacao( Integer marcacaoID )
+ throws Exception
+ {
+ medicinaProvider.deleteDetalhesRealizadosForMarcacao( marcacaoID );
+ }
+
+ public void marcarFaltou( Integer id )
+ throws Exception
+ {
+ apagarDetalhesRealizacao( id );
+ Update update =
+ new Update( "marcacoes_trabalhador",
+ new Assignment[]{
+ new Assignment( new Field( "realizada" ), "n" ),
+ new Assignment( new Field( "estado" ), new Integer( ESTADO_FALTOU ) )
+ },
+ new Field( "id" ).isEqual( id ) );
+ EXECUTER.executeQuery( update );
+ lembretesProvider.apagarLembreteByMarcacaoTrabalhadorID( id );
+ lembretesProvider.criarLembrete( lembretesProvider.getTipoLembreteByCodigo( CODE_REMARCACOES ).getID(),
+ new Date(),
+ "Trabalhador Faltou",
+ null,
+ null,
+ null,
+ null,
+ null,
+ id,
+ false,
+ null,
+ null );
+ }
+
+ public void marcarDesmarcadoSHST( Integer id )
+ throws Exception
+ {
+ apagarDetalhesRealizacao( id );
+ Update update =
+ new Update( "marcacoes_trabalhador",
+ new Assignment[]{
+ new Assignment( new Field( "realizada" ), "n" ),
+ new Assignment( new Field( "estado" ), new Integer( ESTADO_DESMARCADO_EMPRESA ) )
+ },
+ new Field( "id" ).isEqual( id ) );
+ EXECUTER.executeQuery( update );
+ lembretesProvider.apagarLembreteByMarcacaoTrabalhadorID( id );
+ lembretesProvider.criarLembrete( lembretesProvider.getTipoLembreteByCodigo( CODE_REMARCACOES ).getID(),
+ new Date(),
+ "SIPRP Desmarcou",
+ null,
+ null,
+ null,
+ null,
+ null,
+ id,
+ false,
+ null,
+ null );
+ }
+
+ public void marcarDesmarcadoTrabalhador( Integer id )
+ throws Exception
+ {
+ apagarDetalhesRealizacao( id );
+ Update update =
+ new Update( "marcacoes_trabalhador",
+ new Assignment[]{
+ new Assignment( new Field( "realizada" ), "n" ),
+ new Assignment( new Field( "estado" ), new Integer( ESTADO_DESMARCADO_TRABALHADOR ) )
+ },
+ new Field( "id" ).isEqual( id ) );
+ EXECUTER.executeQuery( update );
+ lembretesProvider.apagarLembreteByMarcacaoTrabalhadorID( id );
+ lembretesProvider.criarLembrete( lembretesProvider.getTipoLembreteByCodigo( CODE_REMARCACOES ).getID(),
+ new Date(),
+ "Trabalhador Desmarcou",
+ null,
+ null,
+ null,
+ null,
+ null,
+ id,
+ false,
+ null,
+ null );
+ }
+
+ public void marcarRealizado( Integer id, Integer grupos[] )
+ throws Exception
+ {
+ apagarDetalhesRealizacao( id );
+ medicinaProvider.setDetalhesRealziadosForMarcacao( id, grupos );
+ Update update =
+ new Update( "marcacoes_trabalhador",
+ new Assignment[]{
+ new Assignment( new Field( "realizada" ), "y" ),
+ new Assignment( new Field( "estado" ), new Integer( ESTADO_REALIZADO ) )
+ },
+ new Field( "id" ).isEqual( id ) );
+ EXECUTER.executeQuery( update );
+ lembretesProvider.apagarLembreteByMarcacaoTrabalhadorID( id );
+ }
+
+ public void marcarParcialmenteRealizado( Integer id, Integer grupos[] )
+ throws Exception
+ {
+ apagarDetalhesRealizacao( id );
+ medicinaProvider.setDetalhesRealziadosForMarcacao( id, grupos );
+ Update update =
+ new Update( "marcacoes_trabalhador",
+ new Assignment[]{
+ new Assignment( new Field( "realizada" ), "n" ),
+ new Assignment( new Field( "estado" ), new Integer( ESTADO_PARCIALMENTE_REALIZADO ) )
+ },
+ new Field( "id" ).isEqual( id ) );
+ EXECUTER.executeQuery( update );
+ lembretesProvider.apagarLembreteByMarcacaoTrabalhadorID( id );
+ lembretesProvider.criarLembrete( lembretesProvider.getTipoLembreteByCodigo( CODE_REMARCACOES ).getID(),
+ new Date(),
+ "ECDs por realizar",
+ null,
+ null,
+ null,
+ null,
+ null,
+ id,
+ false,
+ null,
+ null );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/RegistarPresencasWindow.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/RegistarPresencasWindow.java
new file mode 100644
index 00000000..7dab5005
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/presencas/RegistarPresencasWindow.java
@@ -0,0 +1,360 @@
+/*
+ * RegistarPresencasWindow.java
+ *
+ * Created on January 31, 2007, 3:09 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.presencas;
+
+import com.evolute.utils.data.IDObject;
+import com.evolute.utils.data.MappableObject;
+import com.evolute.utils.fop.FOPCreator;
+import com.evolute.utils.fop.FOPPrinter;
+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.multipleactionlist.MultipleActionListPanel;
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.text.DateFormat;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Locale;
+import java.util.Vector;
+import javax.swing.*;
+import org.jdom.*;
+import org.jdom.output.*;
+import siprp.clientes.ClientesDataProvider;
+import siprp.medicina.MedicinaDataProvider;
+import siprp.medicina.prestadores.PrestadoresDataProvider;
+
+/**
+ *
+ * @author fpalma
+ */
+public class RegistarPresencasWindow extends JFrame
+ implements ActionListener, TrackableWindow
+{
+ protected static final String PRINT_TEMPLATE = "/siprp/medicina/presencas/auxiliares.xsl";
+ protected static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
+
+ protected static final Integer PRESTADOR_ID_SIPRP = new Integer( -1 );
+ protected static final Integer PRESTADOR_ID_TODOS = new Integer( -2 );
+
+ protected static final IDObject PRESTADOR_SIPRP = new MappableObject( PRESTADOR_ID_SIPRP, "SIPRP" );
+ protected static final IDObject PRESTADOR_TODOS = new MappableObject( PRESTADOR_ID_TODOS, "Todos" );
+
+ protected JCalendarPanel dataPanel;
+ protected JButton carregarButton;
+ protected JComboBox prestadoresCombo;
+ protected JButton recarregarPrestadoresButton;
+ protected JButton imprimirAuxiliaresButton;
+ protected JScrollPane listECDsScroll;
+ protected JScrollPane listConsultasScroll;
+ protected MultipleActionListPanel listECDsPanel;
+ protected MultipleActionListPanel listConsultasPanel;
+
+ protected MedicinaDataProvider provider;
+ protected PrestadoresDataProvider prestadoresProvider;
+
+ protected Presenca ECDS[];
+
+ /** Creates a new instance of RegistarPresencasWindow */
+ public RegistarPresencasWindow()
+ throws Exception
+ {
+ provider = ( MedicinaDataProvider ) MedicinaDataProvider.getProvider();
+ prestadoresProvider = PrestadoresDataProvider.getProvider();
+ setupComponents();
+
+ }
+
+ private void setupComponents()
+ {
+ setTitle( "Presen\u00e7as" );
+ setSize( 1000, 700 );
+ JLabel dataLabel = new JLabel( "Data" );
+ dataPanel = new JCalendarPanel( this );
+ carregarButton = new JButton( "Carregar" );
+ carregarButton.addActionListener( this );
+ JLabel prestadoresLabel = new JLabel( "Prestador" );
+ prestadoresCombo = new JComboBox ();
+ recarregarPrestadoresButton = new JButton( "Recarregar Prestadores" );
+ recarregarPrestadoresButton.addActionListener( this );
+ imprimirAuxiliaresButton = new JButton( "Imprimir" );
+ imprimirAuxiliaresButton.addActionListener( this );
+
+ PresencasActionFactory realizouFactory = new PresencasActionFactory( PresencasActionFactory.REALIZOU );
+ PresencasActionFactory realizouParcialmenteFactory = new PresencasActionFactory( PresencasActionFactory.REALIZOU_PARCIALMENTE );
+ PresencasActionFactory trabalhadorDesmarcouFactory = new PresencasActionFactory( PresencasActionFactory.TRABALHADOR_DESMARCOU );
+ PresencasActionFactory shstDesmarcouFactory = new PresencasActionFactory( PresencasActionFactory.SHST_DESMARCOU );
+ PresencasActionFactory faltouFactory = new PresencasActionFactory( PresencasActionFactory.FALTOU );
+
+ getContentPane().setLayout( new BorderLayout( 5, 5 ) );
+ JPanel upperPanel = new JPanel();
+ getContentPane().add( upperPanel, BorderLayout.NORTH );
+ JTabbedPane tabbedPane = new JTabbedPane();
+ getContentPane().add( tabbedPane, BorderLayout.CENTER );
+
+ listECDsPanel =
+ new MultipleActionListPanel(
+ new PresencasActionFactory[]{ /*shstDesmarcouFactory, faltouFactory*/ },
+ new PresencasActionFactory[]{ realizouFactory, realizouParcialmenteFactory,
+ trabalhadorDesmarcouFactory, shstDesmarcouFactory,
+ faltouFactory } );
+ listECDsScroll = new JScrollPane( listECDsPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+
+ listConsultasPanel =
+ new MultipleActionListPanel(
+ new PresencasActionFactory[]{ /*shstDesmarcouFactory, faltouFactory*/ },
+ new PresencasActionFactory[]{ realizouFactory, trabalhadorDesmarcouFactory,
+ shstDesmarcouFactory, faltouFactory } );
+ listConsultasScroll = new JScrollPane( listConsultasPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+
+ tabbedPane.add( "ECDs", listECDsScroll );
+ tabbedPane.add( "Consultas", listConsultasScroll );
+
+ upperPanel.setLayout( new FlowLayout( FlowLayout.CENTER ) );
+ upperPanel.add( dataLabel );
+ upperPanel.add( dataPanel );
+ upperPanel.add( carregarButton );
+ upperPanel.add( prestadoresLabel );
+ upperPanel.add( prestadoresCombo );
+ upperPanel.add( recarregarPrestadoresButton );
+ upperPanel.add( imprimirAuxiliaresButton );
+
+ 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() );
+ recarregarPrestadores();
+ carregar();
+ }
+
+ public void actionPerformed( ActionEvent e )
+ {
+ Object source = e.getSource();
+ if( source.equals( carregarButton ) )
+ {
+ carregar();
+ }
+ else if( source.equals( recarregarPrestadoresButton ) )
+ {
+ recarregarPrestadores();
+ }
+ else if( source.equals( imprimirAuxiliaresButton ) )
+ {
+ imprimirAuxiliares();
+ }
+ }
+
+ 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 carregar()
+ {
+ ECDS = null;
+ IDObject prestador = ( IDObject ) prestadoresCombo.getSelectedItem();
+ boolean filtrar = true;
+ Integer prestadorID = null;
+ if( PRESTADOR_TODOS.equals( prestador ) )
+ {
+ filtrar = false;
+ }
+ else if( !PRESTADOR_SIPRP.equals( prestador ) )
+ {
+ prestadorID = prestador.getID();
+ }
+ try
+ {
+ Date data = dataPanel.getDate();
+ Object ecdsArray[][] = provider.getListaECDsByData( data );
+ List ecds = new Vector();
+ for( int n = 0; n < ecdsArray.length; n++ )
+ {
+ Integer id = ( Integer ) ecdsArray[ n ][ 0 ];
+ String nome = ( String ) ecdsArray[ n ][ 1 ];
+ String nomePlain = ( String ) ecdsArray[ n ][ 2 ];
+ String empresa = ( String ) ecdsArray[ n ][ 3 ];
+ int tipo = ( ( Integer )ecdsArray[ n ][ 4 ] ).intValue();
+ Integer prestadorMarcacao = ( Integer )ecdsArray[ n ][ 5 ];
+ if( ( !filtrar ) ||
+ ( prestadorID == null ? prestadorMarcacao == null : prestadorID.equals( prestadorMarcacao ) ) )
+ {
+ ecds.add( new Presenca( id, nome, nomePlain, empresa, tipo ) );
+ }
+ }
+ Collections.sort( ecds );
+ ECDS = ecds.toArray( new Presenca[ ecds.size() ] );
+ listECDsPanel.showList( ECDS );
+ listECDsScroll.setViewportView( listECDsPanel );
+
+ Object consultasArray[][] = provider.getListaConsultasByData( data );
+ List consultas = new Vector();
+ for( int n = 0; n < consultasArray.length; n++ )
+ {
+ Integer id = ( Integer ) consultasArray[ n ][ 0 ];
+ String nome = ( String ) consultasArray[ n ][ 1 ];
+ String nomePlain = ( String ) consultasArray[ n ][ 2 ];
+ String empresa = ( String ) consultasArray[ n ][ 3 ];
+ int tipo = ( ( Integer )consultasArray[ n ][ 4 ] ).intValue();
+ Integer prestadorMarcacao = ( Integer )consultasArray[ n ][ 5 ];
+ if( ( !filtrar ) ||
+ ( prestadorID == null ? prestadorMarcacao == null : prestadorID.equals( prestadorMarcacao ) ) )
+ {
+ consultas.add( new Presenca( id, nome, nomePlain, empresa, tipo ) );
+ }
+ }
+ Collections.sort( consultas );
+ listConsultasPanel.showList( consultas.toArray( new Presenca[ ecds.size() ] ) );
+ listConsultasScroll.setViewportView( listConsultasPanel );
+// setExtendedState( getExtendedState() | MAXIMIZED_BOTH );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
+ }
+ }
+
+ protected void recarregarPrestadores()
+ {
+ try
+ {
+ IDObject prestadores[] = prestadoresProvider.getPrestadoresActivos();
+ prestadoresCombo.removeAllItems();
+ prestadoresCombo.addItem( PRESTADOR_SIPRP );
+ prestadoresCombo.addItem( PRESTADOR_TODOS );
+ for( int n = 0; n < prestadores.length; n++ )
+ {
+ prestadoresCombo.addItem( prestadores[ n ] );
+ }
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar prestadores", true );
+ }
+ }
+
+ protected void imprimirAuxiliares()
+ {
+ try
+ {
+ Date data = dataPanel.getDate();
+ if( ECDS == null || data == null || ECDS.length == 0 )
+ {
+ return;
+ }
+ ClientesDataProvider clientesProvider =
+ ( ClientesDataProvider ) ClientesDataProvider.getProvider();
+ MedicinaDataProvider medicinaProvider =
+ ( MedicinaDataProvider ) MedicinaDataProvider.getProvider();
+
+ String dataStr = D_F.format( data );
+
+ Element rootElement = new Element( "lista-presencas" );
+
+ for( int n = 0; n < ECDS.length; n++ )
+ {
+ Element presencaElement = new Element( "presenca" );
+
+ Element trabalhadorElement = new Element( "trabalhador" );
+ trabalhadorElement.setText( ECDS[ n ].getNome() );
+ presencaElement.addContent( trabalhadorElement );
+
+ Element empresaElement = new Element( "empresa" );
+ empresaElement.setText( ECDS[ n ].getNomeEmpresa() );
+ presencaElement.addContent( empresaElement );
+
+ Element dataElement = new Element( "data" );
+ dataElement.setText( dataStr );
+ presencaElement.addContent( dataElement );
+
+ Integer trabalhadorID = medicinaProvider.getTrabalhadorIDByMarcacaoID( ECDS[ n ].getID() );
+ Integer empresaID = clientesProvider.getEmpresaIDByTrabalhadorID( trabalhadorID );
+ Integer realizados[] = medicinaProvider.getDetalhesRealizadosForEstadosMarcacao( ECDS[ n ].getID() );
+ Vector realizadosVector = new Vector();
+ realizadosVector.addAll( Arrays.asList( realizados ) );
+ IDObject validos[] = medicinaProvider.getDetalhesValidosTrabalhador( empresaID, trabalhadorID );
+ for( int v = 0; v < validos.length; v++ )
+ {
+ Integer id = validos[ v ].getID();
+ if( !realizadosVector.contains( id ) )
+ {
+ Element ecdElement = new Element( "ecd" );
+ ecdElement.setText( validos[ v ].toString() );
+ presencaElement.addContent( ecdElement );
+ }
+ }
+
+ rootElement.addContent( presencaElement );
+ }
+
+ Document doc = new Document( rootElement );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ //new XMLOutputter().output( doc, System.out );
+ new XMLOutputter().output( doc, baos );
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ FOPCreator creator = FOPCreator.getFOPCreator();
+ InputStream xmlIn = new ByteArrayInputStream( baos.toByteArray() );
+ creator.createFOfromXML( xmlIn,
+ getClass().getResourceAsStream( PRINT_TEMPLATE ),
+ out );
+ ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() );
+ Hashtable printOptions = new Hashtable();
+ FOPPrinter.getFOPPrinter().printFO( in, true, true, printOptions );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a imprimir", true );
+ }
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/DesmarcadoSHSTAction.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/DesmarcadoSHSTAction.java
new file mode 100644
index 00000000..7cf7717a
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/DesmarcadoSHSTAction.java
@@ -0,0 +1,58 @@
+/*
+ * DesmarcadoSHSTAction.java
+ *
+ * Created on January 31, 2007, 6:21 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.presencas.actions;
+
+import com.evolute.utils.ui.DialogException;
+import java.awt.event.ActionEvent;
+import javax.swing.AbstractAction;
+import siprp.medicina.presencas.Presenca;
+import siprp.medicina.presencas.PresencasDataProvider;
+
+/**
+ *
+ * @author fpalma
+ */
+public class DesmarcadoSHSTAction extends AbstractAction
+{
+ public static final int SINGLE = 0;
+ public static final int MULTIPLE = 1;
+
+ protected int cardinality;
+ protected Presenca presencas[];
+
+ /** Creates a new instance of DesmarcadoSHSTAction */
+ public DesmarcadoSHSTAction( int cardinality, Presenca presencas[] )
+ {
+ super( cardinality == SINGLE ? "SIPRP Desmarcou" : "Marcar restantes como \"SIPRP desmarcou\"" );
+ this.cardinality = cardinality;
+ this.presencas = presencas;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ PresencasDataProvider provider = PresencasDataProvider.getProvider();
+ for( int n = 0; n < presencas.length; n++ )
+ {
+ provider.marcarDesmarcadoSHST( presencas[ n ].getID() );
+ }
+ if( cardinality == SINGLE )
+ {
+ setEnabled( false );
+ }
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a marcar", true );
+ }
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/DesmarcadoTrabalhadorAction.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/DesmarcadoTrabalhadorAction.java
new file mode 100644
index 00000000..93085547
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/DesmarcadoTrabalhadorAction.java
@@ -0,0 +1,47 @@
+/*
+ * DesmarcadoTrabalhadorAction.java
+ *
+ * Created on January 31, 2007, 6:21 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.presencas.actions;
+
+import com.evolute.utils.ui.DialogException;
+import java.awt.event.ActionEvent;
+import javax.swing.AbstractAction;
+import siprp.medicina.presencas.Presenca;
+import siprp.medicina.presencas.PresencasDataProvider;
+
+/**
+ *
+ * @author fpalma
+ */
+public class DesmarcadoTrabalhadorAction extends AbstractAction
+{
+ protected Presenca presenca;
+
+ /** Creates a new instance of DesmarcadoTrabalhadorAction */
+ public DesmarcadoTrabalhadorAction( Presenca presenca )
+ {
+ super( "Desmarcou" );
+ this.presenca = presenca;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ PresencasDataProvider provider = PresencasDataProvider.getProvider();
+ provider.marcarDesmarcadoTrabalhador( presenca.getID() );
+ setEnabled( false );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a marcar", true );
+ }
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/FaltouAction.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/FaltouAction.java
new file mode 100644
index 00000000..035c8dd5
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/FaltouAction.java
@@ -0,0 +1,57 @@
+/*
+ * FaltouAction.java
+ *
+ * Created on January 31, 2007, 6:21 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.presencas.actions;
+
+import com.evolute.utils.ui.DialogException;
+import java.awt.event.ActionEvent;
+import javax.swing.AbstractAction;
+import siprp.medicina.presencas.Presenca;
+import siprp.medicina.presencas.PresencasDataProvider;
+
+/**
+ *
+ * @author fpalma
+ */
+public class FaltouAction extends AbstractAction
+{
+ public static final int SINGLE = 0;
+ public static final int MULTIPLE = 1;
+
+ protected int cardinality;
+ protected Presenca presencas[];
+
+ /** Creates a new instance of FaltouAction */
+ public FaltouAction( int cardinality, Presenca presencas[] )
+ {
+ super( cardinality == SINGLE ? "Faltou" : "Marcar restantes como \"Faltou\"" );
+ this.cardinality = cardinality;
+ this.presencas = presencas;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ PresencasDataProvider provider = PresencasDataProvider.getProvider();
+ for( int n = 0; n < presencas.length; n++ )
+ {
+ provider.marcarFaltou( presencas[ n ].getID() );
+ }
+ if( cardinality == SINGLE )
+ {
+ setEnabled( false );
+ }
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a marcar", true );
+ }
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/RealizouAction.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/RealizouAction.java
new file mode 100644
index 00000000..105b4ac0
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/RealizouAction.java
@@ -0,0 +1,107 @@
+/*
+ * RealizouAction.java
+ *
+ * Created on January 31, 2007, 6:20 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.presencas.actions;
+
+import com.evolute.utils.data.IDObject;
+import com.evolute.utils.ui.DialogException;
+import java.awt.event.ActionEvent;
+import java.util.Arrays;
+import java.util.Vector;
+import javax.swing.AbstractAction;
+import siprp.clientes.ClientesDataProvider;
+import siprp.medicina.MedicinaDataProvider;
+import siprp.medicina.presencas.DetalhesRealizacaoDialog;
+import siprp.medicina.presencas.Presenca;
+import siprp.medicina.presencas.PresencasDataProvider;
+
+/**
+ *
+ * @author fpalma
+ */
+public class RealizouAction extends AbstractAction
+{
+ protected Presenca presenca;
+
+ /** Creates a new instance of RealizouAction */
+ public RealizouAction( Presenca presenca )
+ {
+ super( "Realizou" );
+ this.presenca = presenca;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ PresencasDataProvider provider = PresencasDataProvider.getProvider();
+ ClientesDataProvider clientesProvider =
+ ( ClientesDataProvider ) ClientesDataProvider.getProvider();
+ MedicinaDataProvider medicinaProvider =
+ ( MedicinaDataProvider ) MedicinaDataProvider.getProvider();
+ Integer trabalhadorID = medicinaProvider.getTrabalhadorIDByMarcacaoID( presenca.getID() );
+ Integer empresaID = clientesProvider.getEmpresaIDByTrabalhadorID( trabalhadorID );
+ Integer realizados[] = medicinaProvider.getDetalhesRealizadosForEstadosMarcacao( presenca.getID() );
+ Vector realizadosVector = new Vector();
+ realizadosVector.addAll( Arrays.asList( realizados ) );
+ IDObject validos[] = medicinaProvider.getDetalhesValidosTrabalhador( empresaID, trabalhadorID );
+ Vector aRealizar = new Vector();
+ for( int n = 0; n < validos.length; n++ )
+ {
+ Integer id = validos[ n ].getID();
+ if( !realizadosVector.contains( id ) )
+ {
+ aRealizar.add( validos[ n ] );
+ }
+ }
+ DetalhesRealizacaoDialog dialog =
+ new DetalhesRealizacaoDialog( null, ( IDObject[] ) aRealizar.toArray( new IDObject[ aRealizar.size() ] ) );
+ Integer escolhidos[] = dialog.getSelected();
+ if( escolhidos != null )
+ {
+ provider.marcarParcialmenteRealizado( presenca.getID(), escolhidos );
+ setEnabled( false );
+ }
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a marcar", true );
+ }
+// try
+// {
+// PresencasDataProvider provider = PresencasDataProvider.getProvider();
+// ClientesDataProvider clientesProvider =
+// ( ClientesDataProvider ) ClientesDataProvider.getProvider();
+// MedicinaDataProvider medicinaProvider =
+// ( MedicinaDataProvider ) MedicinaDataProvider.getProvider();
+// Integer trabalhadorID = medicinaProvider.getTrabalhadorIDByMarcacaoID( presenca.getID() );
+// Integer empresaID = clientesProvider.getEmpresaIDByTrabalhadorID( trabalhadorID );
+// Integer realizados[] = medicinaProvider.getDetalhesRealizadosForEstadosMarcacao( presenca.getID() );
+// Vector realizadosVector = new Vector();
+// realizadosVector.addAll( Arrays.asList( realizados ) );
+// IDObject validos[] = medicinaProvider.getDetalhesValidosTrabalhador( empresaID, trabalhadorID );
+// Vector aRealizar = new Vector();
+// for( int n = 0; n < validos.length; n++ )
+// {
+// Integer id = validos[ n ].getID();
+// if( !realizadosVector.contains( id ) )
+// {
+// aRealizar.add( id );
+// }
+// }
+// provider.marcarRealizado( presenca.getID(), ( Integer[] ) aRealizar.toArray( new Integer[ aRealizar.size() ] ) );
+// setEnabled( false );
+// }
+// catch( Exception ex )
+// {
+// DialogException.showExceptionMessage( ex, "Erro a marcar", true );
+// }
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/RealizouParcialmenteAction.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/RealizouParcialmenteAction.java
new file mode 100644
index 00000000..5384d787
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/RealizouParcialmenteAction.java
@@ -0,0 +1,84 @@
+/*
+ * RealizouParcialmenteAction.java
+ *
+ * Created on January 31, 2007, 6:20 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.presencas.actions;
+
+import com.evolute.utils.data.IDObject;
+import com.evolute.utils.ui.DialogException;
+import java.awt.event.ActionEvent;
+import java.util.Arrays;
+import java.util.Vector;
+import javax.swing.AbstractAction;
+import javax.swing.JOptionPane;
+import siprp.clientes.ClientesDataProvider;
+import siprp.data.Marcacao;
+import siprp.medicina.MedicinaDataProvider;
+import siprp.medicina.presencas.DetalhesRealizacaoDialog;
+import siprp.medicina.presencas.Presenca;
+import siprp.medicina.presencas.PresencasDataProvider;
+
+/**
+ *
+ * @author fpalma
+ */
+public class RealizouParcialmenteAction extends AbstractAction
+{
+ protected Presenca presenca;
+
+ /** Creates a new instance of RealizouParcialmenteAction */
+ public RealizouParcialmenteAction( Presenca presenca )
+ {
+ super( "Parcialmente" );
+ this.presenca = presenca;
+ if( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA == presenca.getTipo().intValue() )
+ {
+ setEnabled( false );
+ }
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ PresencasDataProvider provider = PresencasDataProvider.getProvider();
+ ClientesDataProvider clientesProvider =
+ ( ClientesDataProvider ) ClientesDataProvider.getProvider();
+ MedicinaDataProvider medicinaProvider =
+ ( MedicinaDataProvider ) MedicinaDataProvider.getProvider();
+ Integer trabalhadorID = medicinaProvider.getTrabalhadorIDByMarcacaoID( presenca.getID() );
+ Integer empresaID = clientesProvider.getEmpresaIDByTrabalhadorID( trabalhadorID );
+ Integer realizados[] = medicinaProvider.getDetalhesRealizadosForEstadosMarcacao( presenca.getID() );
+ Vector realizadosVector = new Vector();
+ realizadosVector.addAll( Arrays.asList( realizados ) );
+ IDObject validos[] = medicinaProvider.getDetalhesValidosTrabalhador( empresaID, trabalhadorID );
+ Vector aRealizar = new Vector();
+ for( int n = 0; n < validos.length; n++ )
+ {
+ Integer id = validos[ n ].getID();
+ if( !realizadosVector.contains( id ) )
+ {
+ aRealizar.add( validos[ n ] );
+ }
+ }
+ DetalhesRealizacaoDialog dialog =
+ new DetalhesRealizacaoDialog( null, ( IDObject[] ) aRealizar.toArray( new IDObject[ aRealizar.size() ] ) );
+ Integer escolhidos[] = dialog.getSelected();
+ if( escolhidos != null )
+ {
+ provider.marcarParcialmenteRealizado( presenca.getID(), escolhidos );
+ setEnabled( false );
+ }
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a marcar", true );
+ }
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/auxiliares.xml b/trunk/SIPRPSoft/src/siprp/medicina/presencas/auxiliares.xml
new file mode 100644
index 00000000..f4372ba8
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/presencas/auxiliares.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+ Frederico Palma
+ Evolute
+ 2007/02/21
+ RX
+ ECD
+ Sangue
+ Acuidade Visual
+
+
+ Luis Flores
+ Evolute
+ 2007/02/21
+ RX
+ ECD
+ Acuidade Visual
+
+
+ Smeagol
+ Evolute
+ 2007/02/21
+ RX
+
+
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/auxiliares.xsl b/trunk/SIPRPSoft/src/siprp/medicina/presencas/auxiliares.xsl
new file mode 100644
index 00000000..ae96ca3c
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/presencas/auxiliares.xsl
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Realização de ECDs
+
+
+
+
+
+ ( )
+
+
+ data:
+
+
+ hora de entrada: __h__m
+
+
+
+
+
+
+
+
+
+
+ ECD
+
+
+
+
+ Rúbrica
+
+
+
+
+ Motivo de não realização
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ hora de saída: __h__m
+
+
+ assinatura do trabalhador:________________________________________
+
+
+
+
+
+
+
+
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresDataProvider.java b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresDataProvider.java
new file mode 100644
index 00000000..2538eeab
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresDataProvider.java
@@ -0,0 +1,237 @@
+/*
+ * PrestadoresDataProvider.java
+ *
+ * Created on February 2, 2007, 9:53 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.prestadores;
+
+import com.evolute.utils.Singleton;
+import com.evolute.utils.arrays.Object2DArray;
+import com.evolute.utils.arrays.Virtual2DArray;
+import com.evolute.utils.data.IDObject;
+import com.evolute.utils.data.MappableObject;
+import com.evolute.utils.db.DBManager;
+import com.evolute.utils.db.Executer;
+import com.evolute.utils.jdo.JDOProvider;
+import com.evolute.utils.sql.Assignment;
+import com.evolute.utils.sql.Begin;
+import com.evolute.utils.sql.Commit;
+import com.evolute.utils.sql.Delete;
+import com.evolute.utils.sql.Field;
+import com.evolute.utils.sql.Insert;
+import com.evolute.utils.sql.Rollback;
+import com.evolute.utils.sql.Select;
+import com.evolute.utils.ui.search.SearchDialog;
+import com.evolute.utils.ui.search.SearchExecuter;
+import siprp.data.ContactoData;
+import siprp.medicina.prestadores.data.PrestadoresData;
+
+/**
+ *
+ * @author fpalma
+ */
+public class PrestadoresDataProvider
+ implements SearchExecuter
+{
+ private static final Object LOCK = new Object();
+ private static PrestadoresDataProvider instance = null;
+
+ private static final String SEARCH_TITLE = "Procurar prestadores";
+ private static final String SEARCH_COLUMNS[] =
+ new String[]{ "Designa\u00e7\u00e3o", "Servi\u00e7os" };
+
+ private Executer EXECUTER;
+
+ private JDOProvider JDO;
+
+ /** Creates a new instance of PrestadoresDataProvider */
+ public PrestadoresDataProvider()
+ throws Exception
+ {
+ DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
+ EXECUTER = dbm.getSharedExecuter( this );
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ }
+
+ public static PrestadoresDataProvider getProvider()
+ throws Exception
+ {
+ synchronized( LOCK )
+ {
+ if( instance == null )
+ {
+ instance = new PrestadoresDataProvider();
+ }
+ }
+ return instance;
+ }
+
+ public boolean hasDetails()
+ {
+ return false;
+ }
+
+ public String getSearchTitle()
+ {
+ return SEARCH_TITLE;
+ }
+
+ public String[] getColumnNames()
+ {
+ return SEARCH_COLUMNS;
+ }
+
+ public void showDetails(SearchDialog dialog, Object o) throws Exception
+ {
+ }
+
+ public Virtual2DArray search(String pattern) throws Exception
+ {
+ pattern = pattern.trim().toLowerCase();
+ pattern = pattern.replace( ' ', '%' );
+ Select select =
+ new Select( new String[]{ "prestadores" },
+ new String[]{ "id", "nome", "faz_consultas", "faz_ecds", "nome_plain" },
+ new Field( "nome_plain" ).isLike( "%" + pattern + "%" ),
+ new String[]{ "nome_plain" },
+ null );
+ Virtual2DArray array = EXECUTER.executeQuery( select );
+ Object data[][] = new Object[ array.columnLength() ][ 3 ];
+ for( int n = 0; n < data.length; n++ )
+ {
+ data[ n ][ 0 ] = array.get( n, 0 );
+ data[ n ][ 1 ] = array.get( n, 1 );
+ String str = "";
+ if( "y".equals( array.get( n, 2 ) ) )
+ {
+ str += "consultas";
+ }
+ if( "y".equals( array.get( n, 3 ) ) )
+ {
+ str += ( str.length() > 0 ? ", " : "" ) + "ecds";
+ }
+ data[ n ][ 2 ] = str;
+ }
+ return new Object2DArray( data );
+ }
+
+ public void setGruposProtocoloForPrestador( Integer prestadorID, Integer gruposProtocoloID[] )
+ throws Exception
+ {
+ EXECUTER.executeQuery( Begin.BEGIN );
+ try
+ {
+ Delete delete = new Delete( "prestadores_grupos_protocolo",
+ new Field( "prestador_id" ).isEqual( prestadorID ) );
+ EXECUTER.executeQuery( delete );
+ Insert insert =
+ new Insert( "prestadores_grupos_protocolo",
+ new Assignment[]{
+ new Assignment( new Field( "prestador_id" ), prestadorID ),
+ new Assignment( new Field( "grupo_protocolo_id" ), gruposProtocoloID ) } );
+ EXECUTER.executeQuery( insert );
+ }
+ catch( Exception ex )
+ {
+ EXECUTER.executeQuery( Rollback.ROLLBACK );
+ }
+ EXECUTER.executeQuery( Commit.COMMIT );
+ }
+
+ public Integer []getGruposProtocoloIDByPrestadorID( Integer prestadorID )
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "prestadores_grupos_protocolo" },
+ new String[]{ "grupo_protocolo_id" },
+ new Field( "prestador_id" ).isEqual( prestadorID ) );
+ Virtual2DArray array = EXECUTER.executeQuery( select );
+ Integer ids[] = new Integer[ array.columnLength() ];
+ for( int n = 0; n < ids.length; n++ )
+ {
+ ids[ n ] = ( Integer ) array.get( n, 0 );
+ }
+ return ids;
+ }
+
+ public PrestadoresData getPrestadorByID( Integer id )
+ throws Exception
+ {
+ return ( PrestadoresData ) JDO.load( PrestadoresData.class, id );
+ }
+
+ public void savePrestador( PrestadoresData prestador )
+ throws Exception
+ {
+ if( prestador.get( PrestadoresData.CONTACTO_ID ) instanceof ContactoData )
+ {
+ ContactoData contacto = ( ContactoData )prestador.get( PrestadoresData.CONTACTO_ID );
+ contacto.save();
+ prestador.set( PrestadoresData.CONTACTO_ID, contacto.get( ContactoData.ID ) );
+ }
+ prestador.save();
+ }
+
+ public IDObject[] getPrestadoresActivos()
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "prestadores" },
+ new String[]{ "id", "nome", "nome_plain" },
+ new Field( "activo" ).isEqual( "y" ),
+ new String[]{ "nome_plain" }, null );
+ Virtual2DArray array = EXECUTER.executeQuery( select );
+ IDObject prestadores[] = new IDObject[ array.columnLength() ];
+ for( int n = 0; n < prestadores.length; n++ )
+ {
+ Integer id = ( Integer ) array.get( n, 0 );
+ String nome = ( String ) array.get( n, 1 );
+ prestadores[ n ] = new MappableObject( id, nome );
+ }
+ return prestadores;
+ }
+
+ public IDObject[] getPrestadoresConsultasActivos()
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "prestadores" },
+ new String[]{ "id", "nome", "nome_plain" },
+ new Field( "activo" ).isEqual( "y" ).and(
+ new Field( "faz_consultas" ).isEqual( "y" ) ),
+ new String[]{ "nome_plain" }, null );
+ Virtual2DArray array = EXECUTER.executeQuery( select );
+ IDObject prestadores[] = new IDObject[ array.columnLength() ];
+ for( int n = 0; n < prestadores.length; n++ )
+ {
+ Integer id = ( Integer ) array.get( n, 0 );
+ String nome = ( String ) array.get( n, 1 );
+ prestadores[ n ] = new MappableObject( id, nome );
+ }
+ return prestadores;
+ }
+
+ public IDObject[] getPrestadoresECDsActivos()
+ throws Exception
+ {
+ Select select =
+ new Select( new String[]{ "prestadores" },
+ new String[]{ "id", "nome", "nome_plain" },
+ new Field( "activo" ).isEqual( "y" ).and(
+ new Field( "faz_ecds" ).isEqual( "y" ) ),
+ new String[]{ "nome_plain" }, null );
+ Virtual2DArray array = EXECUTER.executeQuery( select );
+ IDObject prestadores[] = new IDObject[ array.columnLength() ];
+ for( int n = 0; n < prestadores.length; n++ )
+ {
+ Integer id = ( Integer ) array.get( n, 0 );
+ String nome = ( String ) array.get( n, 1 );
+ prestadores[ n ] = new MappableObject( id, nome );
+ }
+ return prestadores;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresWindow.java b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresWindow.java
new file mode 100644
index 00000000..5a2de314
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresWindow.java
@@ -0,0 +1,259 @@
+/*
+ * PrestadoresWindow.java
+ *
+ * Created on February 2, 2007, 9:44 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.prestadores;
+
+import com.evolute.utils.Singleton;
+import com.evolute.utils.data.IDObject;
+import com.evolute.utils.dataui.ComponentController;
+import com.evolute.utils.dataui.ComponentsHashtable;
+import com.evolute.utils.dataui.JDOControllable;
+import com.evolute.utils.dataui.JTextComponentPlainFillerSaver;
+import com.evolute.utils.jdo.JDOProvider;
+import com.evolute.utils.ui.DialogException;
+import com.evolute.utils.ui.panel.CheckBoxPanel;
+import com.evolute.utils.ui.search.SearchDialog;
+import com.evolute.utils.ui.window.EditorWindow;
+import info.clearthought.layout.TableLayout;
+import info.clearthought.layout.TableLayoutConstraints;
+import java.awt.Dimension;
+import java.util.Arrays;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Vector;
+import javax.swing.BorderFactory;
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import siprp.clientes.ClientesDataProvider;
+import siprp.clientes.ContactoPanel;
+import siprp.data.ContactoData;
+import siprp.medicina.prestadores.data.PrestadoresData;
+
+/**
+ *
+ * @author fpalma
+ */
+public class PrestadoresWindow extends EditorWindow
+{
+ public static final String TITLE = "Prestadores";
+
+ protected JTextField nomeText;
+ protected JCheckBox activoCheck;
+ protected JCheckBox consultasCheck;
+ protected JCheckBox ecdsCheck;
+ protected CheckBoxPanel ecdsPanel;
+ protected JTextArea moradaText;
+ protected JTextField codigoPostalText;
+ protected JTextField localidadeCodigoPostalText;
+ protected JTextField localidadeText;
+ protected ContactoPanel contactoPanel;
+ protected JTextField contribuinteText;
+
+
+ protected PrestadoresDataProvider provider;
+ protected ClientesDataProvider clientesProvider;
+
+ protected ComponentsHashtable components;
+
+ protected PrestadoresData prestador;
+ protected Integer gruposProtocolo[];
+
+ /** Creates a new instance of PrestadoresWindow */
+ public PrestadoresWindow()
+ throws Exception
+ {
+ super( new int[][]{{ NEW_INDEX, EDIT_INDEX, CANCEL_INDEX, SAVE_INDEX, DELETE_INDEX,
+ SELECT_BYNAME_INDEX }} );
+ provider = PrestadoresDataProvider.getProvider();
+ clientesProvider = ( ClientesDataProvider ) ClientesDataProvider.getProvider();
+ setupComponents();
+ setupComponentsHashtable();
+ }
+
+ private void setupComponents()
+ throws Exception
+ {
+ setTitle( TITLE );
+ JLabel nomeLabel = new JLabel( "Designa\u00e7\u00e3o" );
+ nomeText = new JTextField();
+ nomeText.setPreferredSize( new Dimension( 500, 20 ) );
+ activoCheck = new JCheckBox( "Activo (actualmente fornece servi\u00e7os \u00e0 SIPRP)" );
+ consultasCheck = new JCheckBox( "Faz consultas" );
+ ecdsCheck = new JCheckBox( "Faz ecds" );
+ List gruposProtocolo = new Vector();
+ IDObject gruposProtocoloReais[] = clientesProvider.getAllGruposProtocoloReais();
+ if( gruposProtocoloReais != null && gruposProtocoloReais.length > 0 )
+ {
+ gruposProtocolo.addAll( Arrays.asList( gruposProtocoloReais ) );
+ }
+ IDObject gruposProtocoloFalsos[] = clientesProvider.getAllGruposProtocoloFalsos();
+ if( gruposProtocoloFalsos != null && gruposProtocoloFalsos.length > 0 )
+ {
+ gruposProtocolo.addAll( Arrays.asList( gruposProtocoloFalsos ) );
+ }
+ ecdsPanel = new CheckBoxPanel( gruposProtocolo.toArray( new IDObject[ gruposProtocolo.size() ] ) );
+ JLabel contactoLabel = new JLabel( "Contacto" );
+ contactoPanel = new ContactoPanel();
+ contactoPanel.setPreferredSize( new Dimension( 350, 120 ) );
+ contactoPanel.setBorder( BorderFactory.createEtchedBorder() );
+ JLabel moradaLabel = new JLabel( "Morada" );
+ moradaText = new JTextArea();
+ moradaText.setLineWrap( true );
+ moradaText.setWrapStyleWord( true );
+ JScrollPane moradaScroll = new JScrollPane( moradaText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ moradaScroll.setPreferredSize( new Dimension( 500, 50 ) );
+ JLabel codigoPostalLabel = new JLabel( "C\u00f3digo Postal" );
+ codigoPostalText = new JTextField();
+ codigoPostalText.setPreferredSize( new Dimension( 100, 50 ) );
+ localidadeCodigoPostalText = new JTextField();
+ localidadeCodigoPostalText.setPreferredSize( new Dimension( 150, 50 ) );
+ JLabel localidadeLabel = new JLabel( "Localidade" );
+ localidadeText = new JTextField();
+ JLabel contribuinteLabel = new JLabel( "Contribuinte" );
+ contribuinteText = new JTextField();
+ contribuinteText.setPreferredSize( new Dimension( 100, 50 ) );
+
+ double cols[] =
+ new double[]{ TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL };
+ double rows[] =
+ new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM,
+ TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED,
+ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM };
+ TableLayout tableLayout = new TableLayout( cols,rows );
+ getContentPane().setLayout( tableLayout );
+
+ getContentPane().add( nomeLabel, new TableLayoutConstraints( 0, 0 ) );
+ getContentPane().add( nomeText, new TableLayoutConstraints( 1, 0, 3, 0 ) );
+ getContentPane().add( activoCheck, new TableLayoutConstraints( 0, 1, 2, 1 ) );
+ getContentPane().add( consultasCheck, new TableLayoutConstraints( 0, 2 ) );
+ getContentPane().add( ecdsCheck, new TableLayoutConstraints( 0, 3 ) );
+ getContentPane().add( ecdsPanel, new TableLayoutConstraints( 1, 3, 2, 3 ) );
+ getContentPane().add( contactoLabel, new TableLayoutConstraints( 0, 4 ) );
+ getContentPane().add( contactoPanel, new TableLayoutConstraints( 1, 4, 2, 4 ) );
+ getContentPane().add( moradaLabel, new TableLayoutConstraints( 0, 5 ) );
+ getContentPane().add( moradaScroll, new TableLayoutConstraints( 1, 5, 3, 5 ) );
+ getContentPane().add( codigoPostalLabel, new TableLayoutConstraints( 0, 6 ) );
+ getContentPane().add( codigoPostalText, new TableLayoutConstraints( 1, 6 ) );
+ getContentPane().add( localidadeCodigoPostalText, new TableLayoutConstraints( 2, 6, 3, 6 ) );
+ getContentPane().add( localidadeLabel, new TableLayoutConstraints( 0, 7 ) );
+ getContentPane().add( localidadeText, new TableLayoutConstraints( 1, 7, 3, 7 ) );
+ getContentPane().add( contribuinteLabel, new TableLayoutConstraints( 0, 8 ) );
+ getContentPane().add( contribuinteText, new TableLayoutConstraints( 1, 8 ) );
+ pack();
+ }
+
+ private void setupComponentsHashtable()
+ {
+ components = new ComponentsHashtable();
+ components.putComponent( PrestadoresData.NOME, nomeText );
+ components.putComponent( PrestadoresData.NOME_PLAIN, new JTextComponentPlainFillerSaver( nomeText ) );
+ components.putComponent( PrestadoresData.MORADA, moradaText );
+ components.putComponent( PrestadoresData.CODIGO_POSTAL, codigoPostalText );
+ components.putComponent( PrestadoresData.LOCALIDADE_CP, localidadeCodigoPostalText );
+ components.putComponent( PrestadoresData.LOCALIDADE, localidadeText );
+ components.putComponent( PrestadoresData.CONTRIBUINTE, contribuinteText );
+ components.putComponent( PrestadoresData.ACTIVO, activoCheck );
+ components.putComponent( PrestadoresData.FAZ_CONSULTAS, consultasCheck );
+ components.putComponent( PrestadoresData.FAZ_ECDS, ecdsCheck );
+ components.putComponent( PrestadoresData.CONTACTO_ID,
+ new JDOControllable( ( JDOProvider )Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ),
+ ContactoData.class, new String[]{ ContactoData.ID },
+ contactoPanel ) );
+ }
+
+
+ public boolean searchByName()
+ {
+ SearchDialog search = new SearchDialog( provider );
+ Integer id = ( Integer )search.getSelected();
+ if( id == null )
+ {
+ return false;
+ }
+ clear( 0 );
+ try
+ {
+ prestador = provider.getPrestadorByID( id );
+ gruposProtocolo = provider.getGruposProtocoloIDByPrestadorID( id );
+ reload( 0 );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Ocorreu um erro a carregar o prestador.", true );
+ return false;
+ }
+
+ return true;
+ }
+
+ public void enableComponents( int index, boolean enable )
+ {
+ String names[] = (String[])components.keySet().toArray( new String[0] );
+ ComponentController.setEnabled( names, enable, components );
+ ecdsPanel.setEnabled( enable );
+ }
+
+ public void reload( int index )
+ {
+ try
+ {
+ String names[] = (String[])components.keySet().toArray( new String[0] );
+ ComponentController.fill( names, prestador.getHashData(), components );
+ ecdsPanel.setSelected( gruposProtocolo );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
+
+ }
+ }
+
+ public void clear( int index )
+ {
+ String names[] = (String[])components.keySet().toArray( new String[0] );
+ ComponentController.clear( names, components );
+ ecdsPanel.clear();
+ prestador = null;
+ gruposProtocolo = null;
+ }
+
+ public boolean newItem( int index )
+ {
+ return true;
+ }
+
+ public boolean save( int index )
+ {
+ if( prestador == null )
+ {
+ prestador = new PrestadoresData();
+ }
+ String names[] = (String[])components.keySet().toArray( new String[0] );
+ Hashtable data = prestador.getHashData();
+ ComponentController.save( names, data, components );
+ prestador.setHashData( data );
+ gruposProtocolo = ecdsPanel.getSelected();
+ try
+ {
+ provider.savePrestador( prestador );
+ provider.setGruposProtocoloForPrestador( ( Integer ) prestador.get( PrestadoresData.ID ),
+ gruposProtocolo );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a guardar dados", true );
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/Prestadores.java b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/Prestadores.java
new file mode 100644
index 00000000..196bf5b8
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/Prestadores.java
@@ -0,0 +1,236 @@
+/*
+* Prestadores.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on Feb 21, 2007
+*
+* Use but DON'T TOUCH
+*/
+package siprp.medicina.prestadores.data;
+
+import com.evolute.utils.jdo.*;
+
+public final class Prestadores implements JDOInnerObject
+{
+ private Integer id;
+ private String nome;
+ private String nome_plain;
+ private String morada;
+ private String codigo_postal;
+ private String localidade;
+ private String localidade_cp;
+ private Integer contacto_id;
+ private String activo;
+ private String faz_consultas;
+ private String faz_ecds;
+ private String contribuinte;
+
+ public Prestadores()
+ {
+ }
+
+ public Object getField( String fieldName )
+ {
+ if( fieldName == PrestadoresData.ID )
+ {
+ return id;
+ }
+ else if( fieldName == PrestadoresData.NOME )
+ {
+ return nome;
+ }
+ else if( fieldName == PrestadoresData.NOME_PLAIN )
+ {
+ return nome_plain;
+ }
+ else if( fieldName == PrestadoresData.MORADA )
+ {
+ return morada;
+ }
+ else if( fieldName == PrestadoresData.CODIGO_POSTAL )
+ {
+ return codigo_postal;
+ }
+ else if( fieldName == PrestadoresData.LOCALIDADE )
+ {
+ return localidade;
+ }
+ else if( fieldName == PrestadoresData.LOCALIDADE_CP )
+ {
+ return localidade_cp;
+ }
+ else if( fieldName == PrestadoresData.CONTACTO_ID )
+ {
+ return contacto_id;
+ }
+ else if( fieldName == PrestadoresData.ACTIVO )
+ {
+ return activo;
+ }
+ else if( fieldName == PrestadoresData.FAZ_CONSULTAS )
+ {
+ return faz_consultas;
+ }
+ else if( fieldName == PrestadoresData.FAZ_ECDS )
+ {
+ return faz_ecds;
+ }
+ else if( fieldName == PrestadoresData.CONTRIBUINTE )
+ {
+ return contribuinte;
+ }
+ else if( fieldName.equals( PrestadoresData.ID ) )
+ {
+ return id;
+ }
+ else if( fieldName.equals( PrestadoresData.NOME ) )
+ {
+ return nome;
+ }
+ else if( fieldName.equals( PrestadoresData.NOME_PLAIN ) )
+ {
+ return nome_plain;
+ }
+ else if( fieldName.equals( PrestadoresData.MORADA ) )
+ {
+ return morada;
+ }
+ else if( fieldName.equals( PrestadoresData.CODIGO_POSTAL ) )
+ {
+ return codigo_postal;
+ }
+ else if( fieldName.equals( PrestadoresData.LOCALIDADE ) )
+ {
+ return localidade;
+ }
+ else if( fieldName.equals( PrestadoresData.LOCALIDADE_CP ) )
+ {
+ return localidade_cp;
+ }
+ else if( fieldName.equals( PrestadoresData.CONTACTO_ID ) )
+ {
+ return contacto_id;
+ }
+ else if( fieldName.equals( PrestadoresData.ACTIVO ) )
+ {
+ return activo;
+ }
+ else if( fieldName.equals( PrestadoresData.FAZ_CONSULTAS ) )
+ {
+ return faz_consultas;
+ }
+ else if( fieldName.equals( PrestadoresData.FAZ_ECDS ) )
+ {
+ return faz_ecds;
+ }
+ else if( fieldName.equals( PrestadoresData.CONTRIBUINTE ) )
+ {
+ return contribuinte;
+ }
+ return null;
+ }
+
+ public void setField( String fieldName, Object value )
+ {
+ if( fieldName == PrestadoresData.ID )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName == PrestadoresData.NOME )
+ {
+ nome = ( String ) value;
+ }
+ else if( fieldName == PrestadoresData.NOME_PLAIN )
+ {
+ nome_plain = ( String ) value;
+ }
+ else if( fieldName == PrestadoresData.MORADA )
+ {
+ morada = ( String ) value;
+ }
+ else if( fieldName == PrestadoresData.CODIGO_POSTAL )
+ {
+ codigo_postal = ( String ) value;
+ }
+ else if( fieldName == PrestadoresData.LOCALIDADE )
+ {
+ localidade = ( String ) value;
+ }
+ else if( fieldName == PrestadoresData.LOCALIDADE_CP )
+ {
+ localidade_cp = ( String ) value;
+ }
+ else if( fieldName == PrestadoresData.CONTACTO_ID )
+ {
+ contacto_id = ( Integer ) value;
+ }
+ else if( fieldName == PrestadoresData.ACTIVO )
+ {
+ activo = ( String ) value;
+ }
+ else if( fieldName == PrestadoresData.FAZ_CONSULTAS )
+ {
+ faz_consultas = ( String ) value;
+ }
+ else if( fieldName == PrestadoresData.FAZ_ECDS )
+ {
+ faz_ecds = ( String ) value;
+ }
+ else if( fieldName == PrestadoresData.CONTRIBUINTE )
+ {
+ contribuinte = ( String ) value;
+ }
+ else if( fieldName.equals( PrestadoresData.ID ) )
+ {
+ id = ( Integer ) value;
+ }
+ else if( fieldName.equals( PrestadoresData.NOME ) )
+ {
+ nome = ( String ) value;
+ }
+ else if( fieldName.equals( PrestadoresData.NOME_PLAIN ) )
+ {
+ nome_plain = ( String ) value;
+ }
+ else if( fieldName.equals( PrestadoresData.MORADA ) )
+ {
+ morada = ( String ) value;
+ }
+ else if( fieldName.equals( PrestadoresData.CODIGO_POSTAL ) )
+ {
+ codigo_postal = ( String ) value;
+ }
+ else if( fieldName.equals( PrestadoresData.LOCALIDADE ) )
+ {
+ localidade = ( String ) value;
+ }
+ else if( fieldName.equals( PrestadoresData.LOCALIDADE_CP ) )
+ {
+ localidade_cp = ( String ) value;
+ }
+ else if( fieldName.equals( PrestadoresData.CONTACTO_ID ) )
+ {
+ contacto_id = ( Integer ) value;
+ }
+ else if( fieldName.equals( PrestadoresData.ACTIVO ) )
+ {
+ activo = ( String ) value;
+ }
+ else if( fieldName.equals( PrestadoresData.FAZ_CONSULTAS ) )
+ {
+ faz_consultas = ( String ) value;
+ }
+ else if( fieldName.equals( PrestadoresData.FAZ_ECDS ) )
+ {
+ faz_ecds = ( String ) value;
+ }
+ else if( fieldName.equals( PrestadoresData.CONTRIBUINTE ) )
+ {
+ contribuinte = ( String ) value;
+ }
+ }
+
+ public Class getOuterClass()
+ {
+ return PrestadoresData.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/PrestadoresData.java b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/PrestadoresData.java
new file mode 100644
index 00000000..0afbd770
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/PrestadoresData.java
@@ -0,0 +1,70 @@
+/*
+* PrestadoresData.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on Feb 21, 2007
+*
+* Use but DON'T TOUCH
+*/
+package siprp.medicina.prestadores.data;
+
+import java.util.HashMap;
+import com.evolute.utils.jdo.*;
+
+public final class PrestadoresData extends JDOObject
+{
+ public static final String ID = "id";
+ public static final String NOME = "nome";
+ public static final String NOME_PLAIN = "nome_plain";
+ public static final String MORADA = "morada";
+ public static final String CODIGO_POSTAL = "codigo_postal";
+ public static final String LOCALIDADE = "localidade";
+ public static final String LOCALIDADE_CP = "localidade_cp";
+ public static final String CONTACTO_ID = "contacto_id";
+ public static final String ACTIVO = "activo";
+ public static final String FAZ_CONSULTAS = "faz_consultas";
+ public static final String FAZ_ECDS = "faz_ecds";
+ public static final String CONTRIBUINTE = "contribuinte";
+
+ public static final String FIELD_NAMES[] = new String[]{
+ NOME, NOME_PLAIN, MORADA, CODIGO_POSTAL, LOCALIDADE, LOCALIDADE_CP, CONTACTO_ID,
+ ACTIVO, FAZ_CONSULTAS, FAZ_ECDS, CONTRIBUINTE, };
+
+
+ protected static final String ALL_FIELD_NAMES[] = new String[]{
+ ID, NOME, NOME_PLAIN, MORADA, CODIGO_POSTAL, LOCALIDADE, LOCALIDADE_CP, CONTACTO_ID,
+ ACTIVO, FAZ_CONSULTAS, FAZ_ECDS, CONTRIBUINTE, };
+
+ private HashMap dataHash;
+
+ public PrestadoresData()
+ {
+ dataHash = new HashMap();
+ }
+
+ protected Object innerGet( String fieldName )
+ throws Exception
+ {
+ return dataHash.get( fieldName );
+ }
+
+ protected void innerSet( String fieldName, Object value )
+ throws Exception
+ {
+ dataHash.put( fieldName, value );
+ }
+
+ public String []getFieldNames()
+ {
+ return FIELD_NAMES;
+ }
+
+ protected String []getAllFieldNames()
+ {
+ return ALL_FIELD_NAMES;
+ }
+
+ public Class getInnerClass()
+ {
+ return Prestadores.class;
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/PrestadoresID.java b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/PrestadoresID.java
new file mode 100644
index 00000000..63ad6666
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/PrestadoresID.java
@@ -0,0 +1,25 @@
+/*
+* PrestadoresID.java
+*
+* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on Feb 21, 2007
+*
+* Use but DON'T TOUCH
+*/
+package siprp.medicina.prestadores.data;
+
+import java.io.*;
+
+import com.evolute.utils.jdo.jpox.*;
+
+public final class PrestadoresID extends IntegerID
+ implements Serializable
+{
+ public PrestadoresID()
+ {
+ }
+
+ public PrestadoresID( String str )
+ {
+ super( str );
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/package.jdo b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/package.jdo
new file mode 100644
index 00000000..a901197b
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/package.jdo
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/EscolherMotivoDialog.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/EscolherMotivoDialog.java
new file mode 100644
index 00000000..1f9f83c5
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/processo/EscolherMotivoDialog.java
@@ -0,0 +1,183 @@
+/*
+ * EscolherMotivoDialog.java
+ *
+ * Created on 13 de Maio de 2007, 22:16
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.processo;
+
+import com.evolute.utils.data.IDObject;
+import com.evolute.utils.data.MappableObject;
+import com.evolute.utils.ui.CustomJDialog;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.HashMap;
+import javax.swing.AbstractButton;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JToggleButton;
+import javax.swing.SwingUtilities;
+import siprp.medicina.MedicinaConstants;
+
+/**
+ *
+ * @author Frederico
+ */
+public class EscolherMotivoDialog extends CustomJDialog
+ implements ActionListener, MedicinaConstants
+{
+ protected IDObject MOTIVOS[] =
+ new IDObject[]{
+ new MappableObject( MOTIVO_ADMISSAO_INTEGER, MOTIVO_ADMISSAO_STR ),
+ new MappableObject( MOTIVO_PERIODICO_INTEGER, MOTIVO_PERIODICO_STR ),
+ new MappableObject( MOTIVO_PERIODICO_INICIAL_INTEGER, MOTIVO_PERIODICO_INICIAL_STR ),
+ new MappableObject( MOTIVO_OCASIONAL_INTEGER, MOTIVO_OCASIONAL_STR )
+ };
+
+ protected IDObject SUB_MOTIVOS[][] =
+ new IDObject[][]{
+ {},
+ {},
+ {},
+ { new MappableObject( SUB_MOTIVO_APOS_DOENCA_INTEGER, SUB_MOTIVO_APOS_DOENCA_STR ),
+ new MappableObject( SUB_MOTIVO_APOS_ACIDENTE_INTEGER, SUB_MOTIVO_APOS_ACIDENTE_STR ),
+ new MappableObject( SUB_MOTIVO_PEDIDO_TRABALHADOR_INTEGER, SUB_MOTIVO_PEDIDO_TRABALHADOR_STR ),
+ new MappableObject( SUB_MOTIVO_PEDIDO_SERVICO_INTEGER, SUB_MOTIVO_PEDIDO_SERVICO_STR ),
+ new MappableObject( SUB_MOTIVO_MUDANCA_FUNCAO_INTEGER, SUB_MOTIVO_MUDANCA_FUNCAO_STR ),
+ new MappableObject( SUB_MOTIVO_ALTERACAO_CONDICOES_INTEGER, SUB_MOTIVO_ALTERACAO_CONDICOES_STR ),
+ new MappableObject( SUB_MOTIVO_OUTRO_INTEGER, SUB_MOTIVO_OUTRO_STR )
+ }
+ };
+
+ protected AbstractButton motivoButtons[];
+ protected HashMap subMotivoButtons;
+ protected HashMap motivoButtonIDs;
+ protected HashMap subMotivoButtonIDs;
+ protected JPanel motivoPanel;
+ protected JPanel subMotivoPanel;
+
+ protected Integer motivoTemp;
+ protected Integer motivo;
+ protected Integer subMotivo;
+
+ /** Creates a new instance of EscolherMotivoDialog */
+ public EscolherMotivoDialog( JFrame owner )
+ {
+ super( owner, true );
+ setupComponents();
+
+ if( owner != null )
+ {
+ centerSuper();
+ }
+ else
+ {
+ center();
+ }
+ }
+
+ private void setupComponents()
+ {
+ setTitle( "Escolher Motivo" );
+ setLayout( new FlowLayout( FlowLayout.LEFT ) );
+ motivoButtons = new JToggleButton[ MOTIVOS.length ];
+ subMotivoButtons = new HashMap();
+ motivoButtonIDs = new HashMap();
+ subMotivoButtonIDs = new HashMap();
+ for( int m = 0; m < MOTIVOS.length; m++ )
+ {
+ JToggleButton motivoButton = new JToggleButton( MOTIVOS[ m ].toString() );
+ motivoButton.addActionListener( this );
+ motivoButtonIDs.put( motivoButton, MOTIVOS[ m ].getID() );
+ motivoButton.setPreferredSize( new Dimension( 250, 20 ) );
+ motivoButtons[ m ] = motivoButton;
+ if( SUB_MOTIVOS[ m ].length > 0 )
+ {
+ JButton subButtons[] = new JButton[ SUB_MOTIVOS[ m ].length ];
+ for( int sm = 0; sm < SUB_MOTIVOS[ m ].length; sm++ )
+ {
+ JButton subButton = new JButton( SUB_MOTIVOS[ m ][ sm ].toString() );
+ subMotivoButtonIDs.put( subButton, SUB_MOTIVOS[ m ][ sm ].getID() );
+ subButtons[ sm ] = subButton;
+ subButton.setPreferredSize( new Dimension( 300, 20 ) );
+ subButton.addActionListener( this );
+ }
+ subMotivoButtons.put( motivoButton, subButtons );
+ }
+ else
+ {
+ subMotivoButtons.put( motivoButton, null );
+ }
+ }
+ motivoPanel = new JPanel();
+ subMotivoPanel = new JPanel();
+
+ motivoPanel.setLayout( new GridLayout( motivoButtons.length + 1, 1 ) );
+ for( int n = 0; n < motivoButtons.length; n++ )
+ {
+ motivoPanel.add( motivoButtons[ n ] );
+ }
+
+ add( motivoPanel );
+ add( subMotivoPanel );
+
+ pack();
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ AbstractButton source = ( AbstractButton ) e.getSource();
+ if( motivoButtonIDs.containsKey( source ) )
+ {
+ motivoTemp = motivoButtonIDs.get( source );
+ }
+ else if( subMotivoButtonIDs.containsKey( source ) )
+ {
+ motivo = motivoTemp;
+ subMotivo = subMotivoButtonIDs.get( source );
+ close();
+ }
+ if( subMotivoButtons.containsKey( source ) )
+ {
+ JButton subButtons[] = subMotivoButtons.get( source );
+ if( subButtons == null || subButtons.length == 0 )
+ {
+ motivo = motivoTemp;
+ close();
+ }
+ else
+ {
+ subMotivoPanel.removeAll();
+ subMotivoPanel.setLayout( new GridLayout( 0, 1 ) );
+ for( int n = 0; n < subButtons.length; n++ )
+ {
+ subMotivoPanel.add( subButtons[ n ] );
+ }
+ pack();
+ }
+ }
+ }
+
+ protected void close()
+ {
+ SwingUtilities.invokeLater( new Runnable(){
+ public void run()
+ {
+ setVisible( false );
+ dispose();
+ }
+ } );
+ }
+
+ public Integer[] getMotivo()
+ {
+ return new Integer[]{ motivo, subMotivo };
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoConstants.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoConstants.java
new file mode 100644
index 00000000..a915de30
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoConstants.java
@@ -0,0 +1,30 @@
+/*
+ * ProcessoConstants.java
+ *
+ * Created on May 14, 2007, 10:08 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.processo;
+
+/**
+ *
+ * @author fpalma
+ */
+public interface ProcessoConstants
+{
+ public static final int TIPO_ECDS = 0;
+ public static final int TIPO_CONSULTA = 1;
+ public static final int TIPO_FICHA_APTIDAO = 2;
+
+ public static final String PROCESSO_ABERTO_CODE = "a";
+ public static final String PROCESSO_FECHADO_CODE = "f";
+ public static final String PROCESSO_CANCELADO_CODE = "c";
+
+ public static final String PROCESSO_ABERTO_DESCRIPTION = "Aberto";
+ public static final String PROCESSO_FECHADO_DESCRIPTION = "Fechado";
+ public static final String PROCESSO_CANCELADO_DESCRIPTION = "Cancelado";
+ public static final String PROCESSO_POR_ABRIR_DESCRIPTION = "Por Abrir";
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoController.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoController.java
new file mode 100644
index 00000000..ee9f22bf
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoController.java
@@ -0,0 +1,405 @@
+ /*
+ * ProcessoController.java
+ *
+ * Created on 25 de Abril de 2007, 15:10
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.processo;
+
+import com.evolute.utils.Singleton;
+import com.evolute.utils.data.MappableObject;
+import com.evolute.utils.jdo.JDOProvider;
+import com.evolute.utils.ui.DialogException;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import siprp.data.TrabalhadorData;
+import siprp.medicina.processo.detalhes.DetalhesProcessoPanel;
+import siprp.medicina.processo.estrutura.EstruturaProcessoPanel;
+
+/**
+ *
+ * @author Frederico
+ */
+public class ProcessoController
+ implements ProcessoListener, ListSelectionListener
+{
+ protected ProcessoUpperPanel processoUpperPanel;
+ protected EstruturaProcessoPanel estruturaProcessoPanel;
+ protected ProcessoPanel processoPanel;
+ protected DetalhesProcessoPanel detalhesProcessoPanel;
+ protected ProcessoDataProvider provider;
+
+ protected JDOProvider JDO;
+
+ protected Integer idProcesso;
+ protected Integer idMarcacao;
+ protected Integer idData;
+
+ /** Creates a new instance of ProcessoController */
+ public ProcessoController( ProcessoUpperPanel processoUpperPanel, EstruturaProcessoPanel estruturaProcessoPanel,
+ ProcessoPanel processoPanel, DetalhesProcessoPanel detalhesProcessoPanel )
+ throws Exception
+ {
+ this.processoUpperPanel = processoUpperPanel;
+ this.estruturaProcessoPanel = estruturaProcessoPanel;
+ this.processoPanel = processoPanel;
+ this.detalhesProcessoPanel = detalhesProcessoPanel;
+ processoUpperPanel.addListSelectionListener( this );
+ estruturaProcessoPanel.addProcessoListener( this );
+ processoPanel.addProcessoListener( this );
+ detalhesProcessoPanel.addProcessoListener( this );
+
+ provider = ProcessoDataProvider.getProvider();
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ }
+
+ public void processoStateChanged(ProcessoEvent e)
+ {
+ int accao = e.getAccao();
+ switch( accao )
+ {
+ case ProcessoEvent.ACCAO_RECARREGAR_TRABALHADOR:
+ recarregarTrabalhador( e );
+ break;
+
+ case ProcessoEvent.ACCAO_ESCOLHER_PROCESSO:
+ escolherProcesso( e );
+ break;
+
+ case ProcessoEvent.ACCAO_ESCOLHER_CONSULTA:
+ escolherConsulta( e );
+ break;
+
+ case ProcessoEvent.ACCAO_ESCOLHER_ECDS:
+ escolherECDs( e );
+ break;
+
+ case ProcessoEvent.ACCAO_ESCOLHER_FA:
+ escolherFichaAptidao( e );
+ break;
+
+ case ProcessoEvent.ACCAO_ESCOLHER_DATA:
+ escolherData( e );
+ break;
+
+ case ProcessoEvent.ACCAO_ESCOLHER_OBSERVACOES:
+ escolherObservacoes( e );
+ break;
+
+ case ProcessoEvent.ACCAO_ESCOLHER_MAIL:
+ escolherMail( e );
+ break;
+
+ case ProcessoEvent.ACCAO_ESCOLHER_MOTIVO:
+ escolherMotivo( e );
+ break;
+
+ case ProcessoEvent.ACCAO_MARCAR_CONSULTA:
+ marcarConsulta( e );
+ break;
+
+ case ProcessoEvent.ACCAO_MARCAR_ECDS:
+ marcarECDs( e );
+ break;
+
+ case ProcessoEvent.ACCAO_EMITIR_FA:
+ emitirFichaAptidao( e );
+ break;
+
+ case ProcessoEvent.ACCAO_FECHAR:
+ fecharProcesso( e );
+ break;
+
+ case ProcessoEvent.ACCAO_MUDAR_ESTADO_MARCACAO:
+ mudarEstadoMarcacao( e );
+ break;
+
+ case ProcessoEvent.ACCAO_MUDAR_DATA_MARCACAO:
+ mudarDataMarcacao( e );
+ break;
+
+ case ProcessoEvent.ACCAO_ESCREVER_OBSERVACOES:
+ escreverObservacoes( e );
+ break;
+
+ case ProcessoEvent.ACCAO_ESCREVER_MAIL:
+ escreverMail( e );
+ break;
+
+ }
+ }
+
+ public void recarregarTrabalhador( ProcessoEvent e )
+ {
+ idProcesso = null;
+ estruturaProcessoPanel.reload();
+ }
+
+ public void escolherProcesso( ProcessoEvent e )
+ {
+ try
+ {
+ idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
+ processoPanel.fill( idProcesso );
+ detalhesProcessoPanel.setProcessoID( idProcesso );
+ detalhesProcessoPanel.clear();
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+
+ public void escolherConsulta( ProcessoEvent e )
+ {
+ try
+ {
+ Integer idProcessoAntigo = idProcesso;
+ idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
+ processoPanel.fill( idProcesso );
+ detalhesProcessoPanel.setProcessoID( idProcesso );
+ idMarcacao = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
+ detalhesProcessoPanel.setConsulta( idMarcacao );
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+
+ public void escolherECDs( ProcessoEvent e )
+ {
+ try
+ {
+ Integer idProcessoAntigo = idProcesso;
+ idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
+ processoPanel.fill( idProcesso );
+ detalhesProcessoPanel.setProcessoID( idProcesso );
+
+ idMarcacao = e.getObjecto( ProcessoEvent.TIPO_ECDS );
+ detalhesProcessoPanel.setECDs( idMarcacao );
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+
+ public void escolherFichaAptidao( ProcessoEvent e )
+ {
+ try
+ {
+ idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
+ Integer idFichaAptidao = e.getObjecto( ProcessoEvent.TIPO_FICHA_APTIDAO );
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+
+ public void escolherData( ProcessoEvent e )
+ {
+ try
+ {
+ Integer idProcessoAntigo = idProcesso;
+ idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
+ processoPanel.fill( idProcesso );
+ detalhesProcessoPanel.setProcessoID( idProcesso );
+ Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
+ Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS );
+ Integer idData = e.getObjecto( ProcessoEvent.TIPO_DATA );
+ if( idConsulta != null )
+ {
+ idMarcacao = idConsulta;
+ detalhesProcessoPanel.setConsulta( idConsulta );
+ }
+ else if( idECDs != null )
+ {
+ idMarcacao = idECDs;
+ detalhesProcessoPanel.setECDs( idECDs );
+ }
+ else
+ {
+ idMarcacao = null;
+ detalhesProcessoPanel.clear();
+ }
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+
+ public void escolherObservacoes( ProcessoEvent e )
+ {
+ try
+ {
+ escolherData( e );
+ Integer idObservacoes = e.getObjecto( ProcessoEvent.TIPO_OBSERVACOES );
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+
+ public void escolherMail( ProcessoEvent e )
+ {
+ try
+ {
+ escolherData( e );
+ Integer idMail = e.getObjecto( ProcessoEvent.TIPO_MAIL );
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+
+ public void escolherMotivo( ProcessoEvent e )
+ {
+ try
+ {
+ idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
+ estruturaProcessoPanel.actualizarProcessoEscolhido( idProcesso );
+ detalhesProcessoPanel.setProcessoID( idProcesso );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a actualizar dados", true );
+ }
+ }
+
+ public void marcarConsulta( ProcessoEvent e )
+ {
+ try
+ {
+ idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
+ detalhesProcessoPanel.setConsulta( null );
+
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+
+ public void marcarECDs( ProcessoEvent e )
+ {
+ try
+ {
+ idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
+ detalhesProcessoPanel.setECDs( null );
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+
+ public void emitirFichaAptidao( ProcessoEvent e )
+ {
+ try
+ {
+ idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
+ estruturaProcessoPanel.actualizarProcessoEscolhido( idProcesso );
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+
+ public void fecharProcesso( ProcessoEvent e )
+ {
+ try
+ {
+ idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
+ estruturaProcessoPanel.actualizarProcessoEscolhido( idProcesso );
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+
+ public void mudarEstadoMarcacao( ProcessoEvent e )
+ {
+ try
+ {
+ idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
+ Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
+ Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS );
+ idMarcacao = idConsulta != null ? idConsulta : idECDs;
+ estruturaProcessoPanel.actualizarMarcacaoEscolhida( idProcesso, idMarcacao );
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+
+ public void mudarDataMarcacao( ProcessoEvent e )
+ {
+ try
+ {
+ idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
+ Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
+ Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS );
+ idMarcacao = idConsulta != null ? idConsulta : idECDs;
+ estruturaProcessoPanel.actualizarMarcacaoEscolhida( idProcesso, idMarcacao );
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+
+ public void escreverObservacoes( ProcessoEvent e )
+ {
+ try
+ {
+ idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
+ Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
+ Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS );
+ idMarcacao = idConsulta != null ? idConsulta : idECDs;
+ estruturaProcessoPanel.actualizarMarcacaoEscolhida( idProcesso, idMarcacao );
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+
+ public void escreverMail( ProcessoEvent e )
+ {
+ try
+ {
+ idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
+ Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
+ Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS );
+ idMarcacao = idConsulta != null ? idConsulta : idECDs;
+ estruturaProcessoPanel.actualizarMarcacaoEscolhida( idProcesso, idMarcacao );
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+
+ public void valueChanged(ListSelectionEvent e)
+ {
+ try
+ {
+ Integer ids[] = ( Integer [] ) processoUpperPanel.save();
+ Integer trabalhadorID = ids[ 2 ];
+ processoPanel.setTrabalhadorID( trabalhadorID );
+ if( trabalhadorID != null )
+ {
+ TrabalhadorData trabalhador = ( TrabalhadorData ) JDO.load( TrabalhadorData.class, trabalhadorID );
+ estruturaProcessoPanel.setTrabalhador( new MappableObject( trabalhadorID, trabalhador.get( TrabalhadorData.NOME ) ) );
+ }
+ else
+ {
+ estruturaProcessoPanel.clear();
+ }
+ processoPanel.clear();
+ detalhesProcessoPanel.clear();
+ processoPanel.setTrabalhadorID( trabalhadorID );
+ detalhesProcessoPanel.setTrabalhadorID( trabalhadorID );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar trabalhador", true );
+ }
+ }
+}
diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoDataProvider.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoDataProvider.java
new file mode 100644
index 00000000..75eafc8d
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoDataProvider.java
@@ -0,0 +1,616 @@
+/*
+ * ProcessoDataProvider.java
+ *
+ * Created on March 20, 2007, 5:14 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package siprp.medicina.processo;
+
+import com.evolute.utils.Singleton;
+import com.evolute.utils.arrays.Virtual2DArray;
+import com.evolute.utils.data.IDObject;
+import com.evolute.utils.data.MappableObject;
+import com.evolute.utils.db.DBManager;
+import com.evolute.utils.db.Executer;
+import com.evolute.utils.jdo.JDOProvider;
+import com.evolute.utils.sql.Assignment;
+import com.evolute.utils.sql.Expression;
+import com.evolute.utils.sql.Field;
+import com.evolute.utils.sql.Insert;
+import com.evolute.utils.sql.Select;
+import com.evolute.utils.sql.Select2;
+import com.evolute.utils.sql.Update;
+import java.text.DateFormat;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+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.TrabalhadoresEcdsData;
+import siprp.medicina.processo.data.TrabalhadoresEcdsDatasData;
+import siprp.medicina.processo.data.TrabalhadoresProcessoData;
+
+/**
+ *
+ * @author fpalma
+ */
+public class ProcessoDataProvider
+ implements MedicinaConstants, ProcessoConstants
+{
+ private static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
+
+ public static final HashMap ESTADO_PROCESSO_BY_CODE =
+ new HashMap();
+
+ static
+ {
+ ESTADO_PROCESSO_BY_CODE.put( PROCESSO_ABERTO_CODE, PROCESSO_ABERTO_DESCRIPTION );
+ ESTADO_PROCESSO_BY_CODE.put( PROCESSO_FECHADO_CODE, PROCESSO_FECHADO_DESCRIPTION );
+ ESTADO_PROCESSO_BY_CODE.put( PROCESSO_CANCELADO_CODE, PROCESSO_CANCELADO_DESCRIPTION );
+ }
+
+ private static final Object LOCK = new Object();
+ private static ProcessoDataProvider instance = null;
+ private Executer EXECUTER;
+ private JDOProvider JDO;
+
+ /** Creates a new instance of ProcessoDataProvider */
+ public ProcessoDataProvider()
+ throws Exception
+ {
+ DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
+ EXECUTER = dbm.getSharedExecuter( this );
+ JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ }
+
+ public static ProcessoDataProvider getProvider()
+ throws Exception
+ {
+ synchronized( LOCK )
+ {
+ if( instance == null )
+ {
+ instance = new ProcessoDataProvider();
+ }
+ }
+ return instance;
+ }
+
+ public Integer[] getIDsProcessosByTrabalhador( Integer trabalhadorID )
+ throws Exception
+ {
+ Select select =
+ new Select2( new String[]{ "trabalhadores_processo" },
+ new Integer[ 0 ],
+ new Expression[ 0 ],
+ new String[]{ "id", "data_inicio" },
+ new Field( "trabalhadores_processo.trabalhador_id" ).isEqual( trabalhadorID ),
+ new String[]{ "data_inicio DESC" },
+ null,
+ null,
+ null );
+ Virtual2DArray array = EXECUTER.executeQuery( select );
+ Integer ids[] = new Integer[ array.columnLength() ];
+ for( int n = 0; n < ids.length; n++ )
+ {
+ ids[ n ] = ( Integer ) array.get( n, 0 );
+ }
+ return ids;
+ }
+
+ public TrabalhadoresProcessoData getProcessoByID( Integer id )
+ throws Exception
+ {
+ return ( TrabalhadoresProcessoData ) JDO.load( TrabalhadoresProcessoData.class, id );
+ }
+
+ public void saveProcesso( TrabalhadoresProcessoData processo )
+ throws Exception
+ {
+ processo.save();
+ }
+
+ public String getDescricaoEstadoProcessoByCodigo( String codigo )
+ throws Exception
+ {
+ return ESTADO_PROCESSO_BY_CODE.get( codigo );
+ }
+
+ public Object[][] getElementosProcesso( Integer processoID )
+ throws Exception
+ {
+ Vector