" );
+ }
+ }
+ 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/siprp/clientes/UserWindow.java b/trunk/siprp/clientes/UserWindow.java
new file mode 100644
index 00000000..31943edd
--- /dev/null
+++ b/trunk/siprp/clientes/UserWindow.java
@@ -0,0 +1,66 @@
+/*
+ * UserWindow.java
+ *
+ * Created on 15 de Março 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/siprp/clientes/etiqueta.xsl b/trunk/siprp/clientes/etiqueta.xsl
new file mode 100644
index 00000000..4603a50b
--- /dev/null
+++ b/trunk/siprp/clientes/etiqueta.xsl
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Cuidado Prestado
+
+
+
+
+ Código
+
+
+
+
+ Valor
+
+
+
+
+ Benef.
+
+
+
+
+ Entidade
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/trunk/siprp/clientes/etiquetas.dtd b/trunk/siprp/clientes/etiquetas.dtd
new file mode 100644
index 00000000..69d2b4f1
--- /dev/null
+++ b/trunk/siprp/clientes/etiquetas.dtd
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/trunk/siprp/data/ActualizacaoSaveHandler.java b/trunk/siprp/data/ActualizacaoSaveHandler.java
new file mode 100644
index 00000000..087e6213
--- /dev/null
+++ b/trunk/siprp/data/ActualizacaoSaveHandler.java
@@ -0,0 +1,51 @@
+/*
+ * StampSaveHandler.java
+ *
+ * Created on 15 de Março 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/siprp/data/ActualizacaoSaveable.java b/trunk/siprp/data/ActualizacaoSaveable.java
new file mode 100644
index 00000000..5427c27f
--- /dev/null
+++ b/trunk/siprp/data/ActualizacaoSaveable.java
@@ -0,0 +1,16 @@
+/*
+ * ActualizacaoSaveable.java
+ *
+ * Created on 15 de Março de 2005, 15:32
+ */
+
+package siprp.data;
+
+/**
+ *
+ * @author fpalma
+ */
+public interface ActualizacaoSaveable
+{
+ public static final String ACTUALIZACAO = "actualizacao";
+}
diff --git a/trunk/siprp/data/Aviso.java b/trunk/siprp/data/Aviso.java
new file mode 100644
index 00000000..791fad87
--- /dev/null
+++ b/trunk/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/siprp/data/AvisoConstants.java b/trunk/siprp/data/AvisoConstants.java
new file mode 100644
index 00000000..1f8ca61f
--- /dev/null
+++ b/trunk/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/siprp/data/AvisoData.java b/trunk/siprp/data/AvisoData.java
new file mode 100644
index 00000000..dace2057
--- /dev/null
+++ b/trunk/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/siprp/data/AvisoID.java b/trunk/siprp/data/AvisoID.java
new file mode 100644
index 00000000..9a7cfb3f
--- /dev/null
+++ b/trunk/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/siprp/data/Contacto.java b/trunk/siprp/data/Contacto.java
new file mode 100644
index 00000000..38941701
--- /dev/null
+++ b/trunk/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/siprp/data/ContactoData.java b/trunk/siprp/data/ContactoData.java
new file mode 100644
index 00000000..a3fd1829
--- /dev/null
+++ b/trunk/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/siprp/data/ContactoID.java b/trunk/siprp/data/ContactoID.java
new file mode 100644
index 00000000..a142d5ef
--- /dev/null
+++ b/trunk/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/siprp/data/DisableDeleteHandler.java b/trunk/siprp/data/DisableDeleteHandler.java
new file mode 100644
index 00000000..d6f2650e
--- /dev/null
+++ b/trunk/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/siprp/data/DisableDeleteable.java b/trunk/siprp/data/DisableDeleteable.java
new file mode 100644
index 00000000..b3ba4e52
--- /dev/null
+++ b/trunk/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/siprp/data/Empresa.java b/trunk/siprp/data/Empresa.java
new file mode 100644
index 00000000..bc4af209
--- /dev/null
+++ b/trunk/siprp/data/Empresa.java
@@ -0,0 +1,713 @@
+/*
+* Empresa.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on Jan 31, 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 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.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.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.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.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/siprp/data/EmpresaData.java b/trunk/siprp/data/EmpresaData.java
new file mode 100644
index 00000000..eea9b2e5
--- /dev/null
+++ b/trunk/siprp/data/EmpresaData.java
@@ -0,0 +1,111 @@
+/*
+* EmpresaData.java
+*
+* Generated by com.evutils.codegen.JDOObjectGenerator on Jan 31, 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 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, 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, 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/siprp/data/EmpresaID.java b/trunk/siprp/data/EmpresaID.java
new file mode 100644
index 00000000..68fcce9d
--- /dev/null
+++ b/trunk/siprp/data/EmpresaID.java
@@ -0,0 +1,25 @@
+/*
+* EmpresaID.java
+*
+* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on Jan 31, 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/siprp/data/Estabelecimento.java b/trunk/siprp/data/Estabelecimento.java
new file mode 100644
index 00000000..e14be8da
--- /dev/null
+++ b/trunk/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/siprp/data/EstabelecimentoData.java b/trunk/siprp/data/EstabelecimentoData.java
new file mode 100644
index 00000000..e11cfb6b
--- /dev/null
+++ b/trunk/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/siprp/data/EstabelecimentoID.java b/trunk/siprp/data/EstabelecimentoID.java
new file mode 100644
index 00000000..3824759b
--- /dev/null
+++ b/trunk/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/siprp/data/Etiqueta.java b/trunk/siprp/data/Etiqueta.java
new file mode 100644
index 00000000..7a35bb38
--- /dev/null
+++ b/trunk/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/siprp/data/EtiquetaData.java b/trunk/siprp/data/EtiquetaData.java
new file mode 100644
index 00000000..8d244d95
--- /dev/null
+++ b/trunk/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/siprp/data/EtiquetaID.java b/trunk/siprp/data/EtiquetaID.java
new file mode 100644
index 00000000..d014ef55
--- /dev/null
+++ b/trunk/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/siprp/data/Exame.java b/trunk/siprp/data/Exame.java
new file mode 100644
index 00000000..b00c1146
--- /dev/null
+++ b/trunk/siprp/data/Exame.java
@@ -0,0 +1,305 @@
+/*
+* 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 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.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.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.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.INACTIVO ) )
+ {
+ inactivo = ( String ) value;
+ }
+ }
+
+ public Class getOuterClass()
+ {
+ return ExameData.class;
+ }
+}
diff --git a/trunk/siprp/data/ExameData.java b/trunk/siprp/data/ExameData.java
new file mode 100644
index 00000000..2ad3f40f
--- /dev/null
+++ b/trunk/siprp/data/ExameData.java
@@ -0,0 +1,77 @@
+/*
+* 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 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, };
+
+
+ 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, 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/siprp/data/ExameID.java b/trunk/siprp/data/ExameID.java
new file mode 100644
index 00000000..3fc144de
--- /dev/null
+++ b/trunk/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/siprp/data/Historico.java b/trunk/siprp/data/Historico.java
new file mode 100644
index 00000000..3a641ee1
--- /dev/null
+++ b/trunk/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/siprp/data/HistoricoEstabelecimento.java b/trunk/siprp/data/HistoricoEstabelecimento.java
new file mode 100644
index 00000000..0bd186b8
--- /dev/null
+++ b/trunk/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/siprp/data/HistoricoEstabelecimentoData.java b/trunk/siprp/data/HistoricoEstabelecimentoData.java
new file mode 100644
index 00000000..38f82221
--- /dev/null
+++ b/trunk/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/siprp/data/HistoricoEstabelecimentoID.java b/trunk/siprp/data/HistoricoEstabelecimentoID.java
new file mode 100644
index 00000000..1513d1bc
--- /dev/null
+++ b/trunk/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/siprp/data/Marcacao.java b/trunk/siprp/data/Marcacao.java
new file mode 100644
index 00000000..55759225
--- /dev/null
+++ b/trunk/siprp/data/Marcacao.java
@@ -0,0 +1,345 @@
+/*
+ * 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 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/siprp/data/MarcacaoEmpresa.java b/trunk/siprp/data/MarcacaoEmpresa.java
new file mode 100644
index 00000000..1f32cac8
--- /dev/null
+++ b/trunk/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/siprp/data/MarcacaoEmpresaData.java b/trunk/siprp/data/MarcacaoEmpresaData.java
new file mode 100644
index 00000000..54921f1f
--- /dev/null
+++ b/trunk/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/siprp/data/MarcacaoEmpresaID.java b/trunk/siprp/data/MarcacaoEmpresaID.java
new file mode 100644
index 00000000..8b074d13
--- /dev/null
+++ b/trunk/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/siprp/data/MarcacaoEstabelecimento.java b/trunk/siprp/data/MarcacaoEstabelecimento.java
new file mode 100644
index 00000000..16f5fca4
--- /dev/null
+++ b/trunk/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/siprp/data/MarcacaoEstabelecimentoData.java b/trunk/siprp/data/MarcacaoEstabelecimentoData.java
new file mode 100644
index 00000000..4c8551ca
--- /dev/null
+++ b/trunk/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/siprp/data/MarcacaoEstabelecimentoID.java b/trunk/siprp/data/MarcacaoEstabelecimentoID.java
new file mode 100644
index 00000000..36240581
--- /dev/null
+++ b/trunk/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/siprp/data/MarcacaoListLoader.java b/trunk/siprp/data/MarcacaoListLoader.java
new file mode 100644
index 00000000..c966c222
--- /dev/null
+++ b/trunk/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/siprp/data/MarcacaoSaveAndDeleteHandler.java b/trunk/siprp/data/MarcacaoSaveAndDeleteHandler.java
new file mode 100644
index 00000000..52ce02e5
--- /dev/null
+++ b/trunk/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.deleteDetalhesRealziadosForMarcacao( ( 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/siprp/data/MarcacaoTrabalhador.java b/trunk/siprp/data/MarcacaoTrabalhador.java
new file mode 100644
index 00000000..a4af4d07
--- /dev/null
+++ b/trunk/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/siprp/data/MarcacaoTrabalhadorConstants.java b/trunk/siprp/data/MarcacaoTrabalhadorConstants.java
new file mode 100644
index 00000000..e0096a87
--- /dev/null
+++ b/trunk/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/siprp/data/MarcacaoTrabalhadorData.java b/trunk/siprp/data/MarcacaoTrabalhadorData.java
new file mode 100644
index 00000000..67273b67
--- /dev/null
+++ b/trunk/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/siprp/data/MarcacaoTrabalhadorID.java b/trunk/siprp/data/MarcacaoTrabalhadorID.java
new file mode 100644
index 00000000..7dc15955
--- /dev/null
+++ b/trunk/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/siprp/data/Medico.java b/trunk/siprp/data/Medico.java
new file mode 100644
index 00000000..a9c4785e
--- /dev/null
+++ b/trunk/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/siprp/data/MedicoData.java b/trunk/siprp/data/MedicoData.java
new file mode 100644
index 00000000..6e385ce8
--- /dev/null
+++ b/trunk/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/siprp/data/MedicoID.java b/trunk/siprp/data/MedicoID.java
new file mode 100644
index 00000000..8c13efb7
--- /dev/null
+++ b/trunk/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/siprp/data/SearchExecuterFactory.java b/trunk/siprp/data/SearchExecuterFactory.java
new file mode 100644
index 00000000..e011144d
--- /dev/null
+++ b/trunk/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/siprp/data/TecnicoHST.java b/trunk/siprp/data/TecnicoHST.java
new file mode 100644
index 00000000..352d6096
--- /dev/null
+++ b/trunk/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/siprp/data/TecnicoHSTData.java b/trunk/siprp/data/TecnicoHSTData.java
new file mode 100644
index 00000000..1d70e935
--- /dev/null
+++ b/trunk/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/siprp/data/TecnicoHSTID.java b/trunk/siprp/data/TecnicoHSTID.java
new file mode 100644
index 00000000..f7f90bd4
--- /dev/null
+++ b/trunk/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/siprp/data/Trabalhador.java b/trunk/siprp/data/Trabalhador.java
new file mode 100644
index 00000000..e7da2172
--- /dev/null
+++ b/trunk/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/siprp/data/TrabalhadorData.java b/trunk/siprp/data/TrabalhadorData.java
new file mode 100644
index 00000000..396b512f
--- /dev/null
+++ b/trunk/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/siprp/data/TrabalhadorID.java b/trunk/siprp/data/TrabalhadorID.java
new file mode 100644
index 00000000..6f37784d
--- /dev/null
+++ b/trunk/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/siprp/data/package.jdo b/trunk/siprp/data/package.jdo
new file mode 100644
index 00000000..477f0586
--- /dev/null
+++ b/trunk/siprp/data/package.jdo
@@ -0,0 +1,1104 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/trunk/siprp/estatistica/EstatisticaDataProvider.java b/trunk/siprp/estatistica/EstatisticaDataProvider.java
new file mode 100644
index 00000000..935afc49
--- /dev/null
+++ b/trunk/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/siprp/estatistica/EstatisticaWindow.java b/trunk/siprp/estatistica/EstatisticaWindow.java
new file mode 100644
index 00000000..7bdbd736
--- /dev/null
+++ b/trunk/siprp/estatistica/EstatisticaWindow.java
@@ -0,0 +1,1323 @@
+/*
+ * 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.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/siprp/higiene/HigieneDataProvider.java b/trunk/siprp/higiene/HigieneDataProvider.java
new file mode 100644
index 00000000..60b2074b
--- /dev/null
+++ b/trunk/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/siprp/higiene/alter2.sql b/trunk/siprp/higiene/alter2.sql
new file mode 100644
index 00000000..6166400d
--- /dev/null
+++ b/trunk/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/siprp/higiene/mapa/DiaLine.java b/trunk/siprp/higiene/mapa/DiaLine.java
new file mode 100644
index 00000000..7eb4a647
--- /dev/null
+++ b/trunk/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/siprp/higiene/mapa/DiaPanel.java b/trunk/siprp/higiene/mapa/DiaPanel.java
new file mode 100644
index 00000000..05c508b4
--- /dev/null
+++ b/trunk/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/siprp/higiene/mapa/DiaRenderer.java b/trunk/siprp/higiene/mapa/DiaRenderer.java
new file mode 100644
index 00000000..40dc967e
--- /dev/null
+++ b/trunk/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/siprp/higiene/mapa/MapaHigienePanel.java b/trunk/siprp/higiene/mapa/MapaHigienePanel.java
new file mode 100644
index 00000000..05c6d67e
--- /dev/null
+++ b/trunk/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/siprp/higiene/mapa/MapaHigieneWindow.java b/trunk/siprp/higiene/mapa/MapaHigieneWindow.java
new file mode 100644
index 00000000..26612fc7
--- /dev/null
+++ b/trunk/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/siprp/higiene/mapa/TecnicosPanel.java b/trunk/siprp/higiene/mapa/TecnicosPanel.java
new file mode 100644
index 00000000..2cf77ab2
--- /dev/null
+++ b/trunk/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/siprp/higiene/marcacoes/CorTecnicoCellRenderer.java b/trunk/siprp/higiene/marcacoes/CorTecnicoCellRenderer.java
new file mode 100644
index 00000000..13d07aff
--- /dev/null
+++ b/trunk/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/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.java b/trunk/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.java
new file mode 100644
index 00000000..13d30081
--- /dev/null
+++ b/trunk/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.java
@@ -0,0 +1,306 @@
+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.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/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.xml b/trunk/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.xml
new file mode 100644
index 00000000..04a78a45
--- /dev/null
+++ b/trunk/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/siprp/higiene/marcacoes/MarcacoesHigieneUpperPanel.java b/trunk/siprp/higiene/marcacoes/MarcacoesHigieneUpperPanel.java
new file mode 100644
index 00000000..1efa12af
--- /dev/null
+++ b/trunk/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/siprp/higiene/marcacoes/MarcacoesHigieneWindow.java b/trunk/siprp/higiene/marcacoes/MarcacoesHigieneWindow.java
new file mode 100644
index 00000000..b8643956
--- /dev/null
+++ b/trunk/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/siprp/higiene/marcacoes/TecnicoEditor.java b/trunk/siprp/higiene/marcacoes/TecnicoEditor.java
new file mode 100644
index 00000000..007c119d
--- /dev/null
+++ b/trunk/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/siprp/higiene/marcacoes/TecnicoRenderer.java b/trunk/siprp/higiene/marcacoes/TecnicoRenderer.java
new file mode 100644
index 00000000..7ad36ac8
--- /dev/null
+++ b/trunk/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/siprp/impressaofichas/FichasPrinter.java b/trunk/siprp/impressaofichas/FichasPrinter.java
new file mode 100644
index 00000000..5f7c5e22
--- /dev/null
+++ b/trunk/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 = new FOPCreator();
+ 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() );
+ new FOPPrinter().printFO( in, false, true, printOptions );
+ byte []pdfData = new PDFCreator().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/siprp/impressaofichas/ImpressaoFichasDataProvider.java b/trunk/siprp/impressaofichas/ImpressaoFichasDataProvider.java
new file mode 100644
index 00000000..11e0910d
--- /dev/null
+++ b/trunk/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/siprp/impressaofichas/ImpressaoFichasWindow.java b/trunk/siprp/impressaofichas/ImpressaoFichasWindow.java
new file mode 100644
index 00000000..65f95930
--- /dev/null
+++ b/trunk/siprp/impressaofichas/ImpressaoFichasWindow.java
@@ -0,0 +1,421 @@
+/*
+ * 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.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/siprp/impressaofichas/lista_fichas.xsl b/trunk/siprp/impressaofichas/lista_fichas.xsl
new file mode 100644
index 00000000..46096481
--- /dev/null
+++ b/trunk/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/siprp/pesquisas/PesquisasProvider.java b/trunk/siprp/pesquisas/PesquisasProvider.java
new file mode 100644
index 00000000..632d8b18
--- /dev/null
+++ b/trunk/siprp/pesquisas/PesquisasProvider.java
@@ -0,0 +1,751 @@
+/*
+ * EstatisticasProvider.java
+ *
+ * Created on 3 de Junho de 2004, 18:23
+ */
+
+package siprp.pesquisas;
+
+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 PesquisasProvider extends MetaProvider
+{
+ private static final Object LOCK = new Object();
+ private static PesquisasProvider instance = null;
+ private final Executer executer;
+
+ private static final int TIPOS_OCASIONAL[] =
+ new int[]{ 5, //mudanca de posto
+ 6, //mudancas das condicoes
+ -1, //apos 30 dias
+ 4, //iniciativa do medico
+ 3, //pedido do trabalhador
+ 2, //acidente de trabalho
+ 1, //Doenca subita
+ -1, //Cessacao do contrato
+ 10 //Outras razoes
+ };
+ public static final String DESCRICAO_TIPOS_OCASIONAL[] =
+ new String[]{ "MUDAN\u00C7A DE POSTO DE TRABALHO",
+ "ALTERA\u00C7\u00D5ES NO POSTO DE TRABALHO",
+ "REGRESSO AO TRABALHO AP\u00D3S AUS\u00CANCIA SUPERIOR A 30 DIAS",
+ "INICIATIVA DO M\u00C9DICO",
+ "PEDIDO DO TRABALHADOR",
+ "ACIDENTE DE TRABALHO",
+ "DOEN\u00C7A S\u00DABITA",
+ "POR CESSA\u00C7\u00C3O DO CONTRATO DE TRABALHO",
+ "OUTRAS RAZ\u00D5ES" };
+
+ private static final int TIPOS_EXAME[] =
+ new int[]{ 1, //admissao
+ 2, //periodico
+ 3 //ocasional
+ };
+ private static final int TIPO_OCASIONAL = 3;
+
+ public static final String DESCRICAO_TIPOS_EXAME[] =
+ new String[]{ "TOTAL DE EXAMES DE ADMISS\u00C3O",
+ "TOTAL DE EXAMES PERI\u00D3DICOS",
+ "TOTAL DE EXAMES OCASIONAIS" };
+
+ public static final String PAR_ANO = "PAR_ANO";
+ public static final String PAR_EMPRESA = "PAR_EMPRESA";
+ public static final String PAR_ESTABELECIMENTO = "PAR_ESTABELECIMENTO";
+ public static final String PAR_TIPO_EXAME = "PAR_TIPO_EXAME";
+ public static final String PAR_RESULTADO = "PAR_RESULTADO";
+ public static final String PAR_SEXO = "PAR_SEXO";
+ public static final String PAR_GRUPO_ETARIO = "PAR_GRUPO_ETARIO";
+
+ /** Creates a new instance of EstatisticasProvider */
+ public PesquisasProvider() 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 PesquisasProvider();
+ }
+ }
+ return instance;
+ }
+
+ public IDObject[] getAllEmpresas()
+ throws Exception
+ {
+ Select select = new Select( new String[]{ "empresas" },
+ new String[]{ EmpresaData.ID, EmpresaData.DESIGNACAO_SOCIAL, EmpresaData.DESIGNACAO_SOCIAL_PLAIN },
+ new Field( EmpresaData.INACTIVO ).isDifferent( "y" ),
+ new String[]{ EmpresaData.DESIGNACAO_SOCIAL_PLAIN }, null );
+// Select select = new Select( "SELECT e.id, e.designacao_social FROM empresas e ORDER BY lower( e.designacao_social );" );
+ Virtual2DArray array = executer.executeQuery( select );
+ IDObject empresas[] = new IDObject[ array.columnLength() ];
+ for( int n = 0; n < empresas.length; n++ )
+ {
+ empresas[ n ] = new MappableObject( (Integer)array.get( n, 0 ), array.get( n, 1 ) );
+ }
+ return empresas;
+ }
+
+ public IDObject []getAllEstabelecimentosForEmpresa( Integer empresaID )
+ throws Exception
+ {
+ return ( ( siprp.FichaDataProvider )siprp.FichaDataProvider.getProvider() ).getAllEstabelecimentosForEmpresa( empresaID );
+ }
+
+ public int[] countTrabalhadoresEstabelecimentoDezembro( Integer estabelecimentoID, int ano )
+ throws Exception
+ {
+ Calendar cal = Calendar.getInstance();
+ cal.set( Calendar.YEAR, ano );
+ cal.set( Calendar.MONTH, 11 );
+ cal.set( Calendar.DAY_OF_MONTH, 30 );
+ Select select =
+ new Select( new String[]{ "trabalhadores" },
+ new String[]{ "COUNT(" + TrabalhadorData.ID + ")" },
+ new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or(
+ new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ).and(
+ new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
+ new Field( TrabalhadorData.SEXO ).isEqual( "m" ) ).and(
+ new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and(
+ new Par( new Field( TrabalhadorData.DATA_DEMISSAO ).isGreater( cal.getTime() ).or(
+ new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ int contagem[] = new int[ 2 ];
+ contagem[ 0 ] = ( ( Number ) array.get( 0, 0 ) ).intValue();
+ select =
+ new Select( new String[]{ "trabalhadores" },
+ new String[]{ "COUNT(" + TrabalhadorData.ID + ")" },
+ new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or(
+ new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ).and(
+ new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
+ new Field( TrabalhadorData.SEXO ).isEqual( "f" ) ).and(
+ new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and(
+ new Par( new Field( TrabalhadorData.DATA_DEMISSAO ).isGreater( cal.getTime() ).or(
+ new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ) );
+ array = executer.executeQuery( select );
+ contagem[ 1 ] = ( ( Number ) array.get( 0, 0 ) ).intValue();
+ return contagem;
+ }
+
+ public int[][] countTrabalhadoresEstabelecimentoDezembroPorGrupoEtario( Integer estabelecimentoID, int ano )
+ throws Exception
+ {
+ Calendar eoy = Calendar.getInstance();
+ eoy.set( Calendar.YEAR, ano );
+ eoy.set( Calendar.MONTH, 11 );
+ eoy.set( Calendar.DAY_OF_MONTH, 30 );
+
+ Calendar today = Calendar.getInstance();
+ today.set( Calendar.YEAR, ano );
+ today.set( Calendar.MONTH, 11 );
+ today.set( Calendar.DAY_OF_MONTH, 31 );
+ today.set( Calendar.HOUR_OF_DAY, 23 );
+ Calendar age18 = (Calendar) today.clone();
+ age18.add( Calendar.YEAR, -18 );
+ Calendar age50 = (Calendar) today.clone();
+ age50.add( Calendar.YEAR, -50 );
+ //0-18
+ Select select =
+ new Select( new String[]{ "trabalhadores" },
+ new String[]{ "COUNT(" + TrabalhadorData.ID + ")" },
+ new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or(
+ new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ).and(
+ new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
+ new Field( TrabalhadorData.SEXO ).isEqual( "m" ) ).and(
+ new Field( TrabalhadorData.DATA_NASCIMENTO ).isGreater( age18.getTime() ) ).and(
+ new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and(
+ new Par( new Field( TrabalhadorData.DATA_DEMISSAO ).isGreater( eoy.getTime() ).or(
+ new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ int contagem[][] = new int[ 3 ][ 2 ];
+ contagem[ 0 ][ 0 ] = ( ( Number ) array.get( 0, 0 ) ).intValue();
+ select =
+ new Select( new String[]{ "trabalhadores" },
+ new String[]{ "COUNT(" + TrabalhadorData.ID + ")" },
+ new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or(
+ new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ).and(
+ new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
+ new Field( TrabalhadorData.SEXO ).isEqual( "f" ) ).and(
+ new Field( TrabalhadorData.DATA_NASCIMENTO ).isGreater( age18.getTime() ) ).and(
+ new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and(
+ new Par( new Field( TrabalhadorData.DATA_DEMISSAO ).isGreater( eoy.getTime() ).or(
+ new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ) );
+ array = executer.executeQuery( select );
+ contagem[ 0 ][ 1 ] = ( ( Number ) array.get( 0, 0 ) ).intValue();
+ //18-49
+ select =
+ new Select( new String[]{ "trabalhadores" },
+ new String[]{ "COUNT(" + TrabalhadorData.ID + ")" },
+ new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or(
+ new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ).and(
+ new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
+ new Field( TrabalhadorData.SEXO ).isEqual( "m" ) ).and(
+ new Field( TrabalhadorData.DATA_NASCIMENTO ).isLessOrEqual( age18.getTime() ) ).and(
+ new Field( TrabalhadorData.DATA_NASCIMENTO ).isGreater( age50.getTime() ) ).and(
+ new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and(
+ new Par( new Field( TrabalhadorData.DATA_DEMISSAO ).isGreater( eoy.getTime() ).or(
+ new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ) );
+ array = executer.executeQuery( select );
+ contagem[ 1 ][ 0 ] = ( ( Number ) array.get( 0, 0 ) ).intValue();
+ select =
+ new Select( new String[]{ "trabalhadores" },
+ new String[]{ "COUNT(" + TrabalhadorData.ID + ")" },
+ new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or(
+ new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ).and(
+ new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
+ new Field( TrabalhadorData.SEXO ).isEqual( "f" ) ).and(
+ new Field( TrabalhadorData.DATA_NASCIMENTO ).isLessOrEqual( age18.getTime() ) ).and(
+ new Field( TrabalhadorData.DATA_NASCIMENTO ).isGreater( age50.getTime() ) ).and(
+ new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and(
+ new Par( new Field( TrabalhadorData.DATA_DEMISSAO ).isGreater( eoy.getTime() ).or(
+ new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ) );
+ array = executer.executeQuery( select );
+ contagem[ 1 ][ 1 ] = ( ( Number ) array.get( 0, 0 ) ).intValue();
+
+ //50-
+ select =
+ new Select( new String[]{ "trabalhadores" },
+ new String[]{ "COUNT(" + TrabalhadorData.ID + ")" },
+ new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or(
+ new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ).and(
+ new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
+ new Field( TrabalhadorData.SEXO ).isEqual( "m" ) ).and(
+ new Field( TrabalhadorData.DATA_NASCIMENTO ).isLessOrEqual( age50.getTime() ) ).and(
+ new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and(
+ new Par( new Field( TrabalhadorData.DATA_DEMISSAO ).isGreater( eoy.getTime() ).or(
+ new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ) );
+ array = executer.executeQuery( select );
+ contagem[ 2 ][ 0 ] = ( ( Number ) array.get( 0, 0 ) ).intValue();
+ select =
+ new Select( new String[]{ "trabalhadores" },
+ new String[]{ "COUNT(" + TrabalhadorData.ID + ")" },
+ new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or(
+ new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ).and(
+ new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
+ new Field( TrabalhadorData.SEXO ).isEqual( "f" ) ).and(
+ new Field( TrabalhadorData.DATA_NASCIMENTO ).isLessOrEqual( age50.getTime() ) ).and(
+ new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and(
+ new Par( new Field( TrabalhadorData.DATA_DEMISSAO ).isGreater( eoy.getTime() ).or(
+ new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ) );
+ array = executer.executeQuery( select );
+ contagem[ 2 ][ 1 ] = ( ( Number ) array.get( 0, 0 ) ).intValue();
+
+ return contagem;
+ }
+
+ public int[][] countExamesEstabelecimentoDezembroPorGrupoEtario( Integer estabelecimentoID, int ano )
+ throws Exception
+ {
+ Calendar today = Calendar.getInstance();
+ today.set( Calendar.YEAR, ano );
+ today.set( Calendar.MONTH, 11 );
+ today.set( Calendar.DAY_OF_MONTH, 31 );
+ today.set( Calendar.HOUR_OF_DAY, 23 );
+ Calendar age18 = (Calendar) today.clone();
+ age18.add( Calendar.YEAR, -18 );
+ Calendar age50 = (Calendar) today.clone();
+ age50.add( Calendar.YEAR, -50 );
+ Calendar dates[] = new Calendar[]{ null, age18, age50, null };
+ String sexos[] = new String[]{ "m", "f" };
+
+ int contagem[][] = new int[ 4 ][ 6 ];
+ for( int t = 0; t < TIPOS_EXAME.length; t++ )
+ {
+ for( int s = 0; s < sexos.length; s++ )
+ {
+ for( int d = 0; d < dates.length - 1; d++ )
+ {
+ Select select =
+ new Select( new String[]{ "exames", "trabalhadores" },
+ new String[]{ "DISTINCT trabalhadores.id, exames.data" },
+ new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ).and(
+ new Field( "exames.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ).and(
+ new Field( TrabalhadorData.SEXO ).isEqual( sexos[s] ) ).and(
+ new Field( "YEAR( exames.data )" ).isEqual( new Integer( ano ) ) ).and(
+ dates[ d ] == null ? new Field( "exames.id" ).isDifferent( null ) :
+ new Field( TrabalhadorData.DATA_NASCIMENTO ).isLessOrEqual( dates[ d ].getTime() ) ).and(
+ dates[ d + 1 ] == null ? new Field( "exames.id" ).isDifferent( null ) :
+ new Field( TrabalhadorData.DATA_NASCIMENTO ).isGreater( dates[ d + 1 ].getTime() ) ).and(
+ new Field( "exames.tipo" ).isEqual( new Integer( TIPOS_EXAME[ t ] ) ) ).and(
+ new Field( "exames.inactivo" ).isDifferent( "y" ) ).and(
+ new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
+ try
+ {
+ Virtual2DArray array = executer.executeQuery( select );
+ contagem[ t ][ s * 3 + d ] = array.columnLength();
+//System.out.println( select + ": " + contagem[ t ][ s * 3 + d ] );
+ }
+ catch( Exception ex )
+ {
+ contagem[ t ][ s * 3 + d ] = -1;
+ }
+ }
+ }
+ }
+
+ return contagem;
+ }
+
+ public int[][] countExamesOcasionaisEstabelecimentoDezembroPorGrupoEtario( Integer estabelecimentoID, int ano )
+ throws Exception
+ {
+ Calendar today = Calendar.getInstance();
+ today.set( Calendar.YEAR, ano );
+ today.set( Calendar.MONTH, 11 );
+ today.set( Calendar.DAY_OF_MONTH, 31 );
+ today.set( Calendar.HOUR_OF_DAY, 23 );
+ Calendar age18 = (Calendar) today.clone();
+ age18.add( Calendar.YEAR, -18 );
+ Calendar age50 = (Calendar) today.clone();
+ age50.add( Calendar.YEAR, -50 );
+ Calendar dates[] = new Calendar[]{ null, age18, age50, null };
+ String sexos[] = new String[]{ "m", "f" };
+
+ int contagem[][] = new int[ TIPOS_OCASIONAL.length ][ ( dates.length - 1 ) * sexos.length ];
+ for( int t = 0; t < TIPOS_OCASIONAL.length; t++ )
+ {
+ for( int s = 0; s < sexos.length; s++ )
+ {
+ for( int d = 0; d < dates.length - 1; d++ )
+ {
+ if( TIPOS_OCASIONAL[t] == -1 )
+ {
+ contagem[ t ][ s * 3 + d ] = -1;
+ continue;
+ }
+
+ Select select =
+ new Select( new String[]{ "exames", "trabalhadores" },
+ new String[]{ "DISTINCT trabalhadores.id, exames.data" },
+ new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ).and(
+ new Field( "exames.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ).and(
+ new Field( TrabalhadorData.SEXO ).isEqual( sexos[s] ) ).and(
+ new Field( "YEAR( exames.data )" ).isEqual( new Integer( ano ) ) ).and(
+ dates[ d ] == null ? new Field( "exames.id" ).isDifferent( null ) :
+ new Field( TrabalhadorData.DATA_NASCIMENTO ).isLessOrEqual( dates[ d ].getTime() ) ).and(
+ dates[ d + 1 ] == null ? new Field( "exames.id" ).isDifferent( null ) :
+ new Field( TrabalhadorData.DATA_NASCIMENTO ).isGreater( dates[ d + 1 ].getTime() ) ).and(
+ new Field( "exames.tipo" ).isEqual( new Integer( 3 ) ) ).and(
+ new Field( "exames.ocasional" ).isEqual( new Integer( TIPOS_OCASIONAL[ t ] ) ) ).and(
+ new Field( "exames.inactivo" ).isDifferent( "y" ) ).and(
+ new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
+ try
+ {
+ Virtual2DArray array = executer.executeQuery( select );
+ contagem[ t ][ s * 3 + d ] = array.columnLength();
+ }
+ catch( Exception ex )
+ {
+ contagem[ t ][ s * 3 + d ] = -1;
+ }
+ }
+ }
+ }
+
+ return contagem;
+ }
+
+ public double[] countNumeroMedioTrabalhadoresEmpresa( Integer empresaID, int ano )
+ throws Exception
+ {
+ double contagens[] = new double[ 2 ];;
+ Select select;
+ String sexos[] = new String[]{ "m", "f" };
+
+ for( int n = 0; n < sexos.length; n++ )
+ {
+ select =
+ new Select( new String[]{ "estabelecimentos", "trabalhadores" },
+ new String[]{ "COUNT(trabalhadores.id)" },
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ).and(
+ new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLess( new Integer( ano ) ).or(
+ new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ) ).and(
+ new Par( new Field( "YEAR(" + TrabalhadorData.DATA_DEMISSAO + ")" ).isGreater( new Integer( ano ) ).or(
+ new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ).and(
+ new Field( "empresa_id" ).isEqual( empresaID ) ).and(
+ new Field( TrabalhadorData.SEXO ).isEqual( sexos[ n ] ) ).and(
+ new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ contagens[ n ] = ( ( Number ) array.get( 0, 0 ) ).doubleValue();
+ }
+ for( int n = 0; n < sexos.length; n++ )
+ {
+ select =
+ new Select( new String[]{ "estabelecimentos", "trabalhadores" },
+ new String[]{ "SUM( MONTH( data_demissao ) )" },
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ).and(
+ new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLess( new Integer( ano ) ).or(
+ new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ) ).and(
+ new Field( "YEAR(" + TrabalhadorData.DATA_DEMISSAO + ")" ).isEqual( new Integer( ano ) ) ).and(
+ new Field( "empresa_id" ).isEqual( empresaID ) ).and(
+ new Field( TrabalhadorData.SEXO ).isEqual( sexos[ n ] ) ).and(
+ new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ) );
+System.out.println( "SELECT: " + select );
+ Virtual2DArray array = executer.executeQuery( select );
+ if( array.get( 0, 0 ) != null )
+ {
+ contagens[ n ] += ( ( Number ) array.get( 0, 0 ) ).doubleValue() / 12.0;
+ }
+ }
+
+ for( int n = 0; n < sexos.length; n++ )
+ {
+ select =
+ new Select( new String[]{ "estabelecimentos", "trabalhadores" },
+ new String[]{ "SUM( ( 1 + 12 - MONTH( data_admissao ) ) )" },
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ).and(
+ new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isEqual( new Integer( ano ) ) ).and(
+ new Par( new Field( "YEAR(" + TrabalhadorData.DATA_DEMISSAO + ")" ).isGreater( new Integer( ano ) ).or(
+ new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ).and(
+ new Field( "empresa_id" ).isEqual( empresaID ) ).and(
+ new Field( TrabalhadorData.SEXO ).isEqual( sexos[ n ] ) ).and(
+ new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ if( array.get( 0, 0 ) != null )
+ {
+ contagens[ n ] += ( ( Number ) array.get( 0, 0 ) ).doubleValue() / 12.0;
+ }
+ }
+
+ for( int n = 0; n < sexos.length; n++ )
+ {
+ select =
+ new Select( new String[]{ "estabelecimentos", "trabalhadores" },
+ new String[]{ "SUM( ( 1 + MONTH( data_demissao ) - MONTH( data_admissao ) ) )" },
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ).and(
+ new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isEqual( new Integer( ano ) ) ).and(
+ new Field( "YEAR(" + TrabalhadorData.DATA_DEMISSAO + ")" ).isEqual( new Integer( ano ) ) ).and(
+ new Field( "empresa_id" ).isEqual( empresaID ) ).and(
+ new Field( TrabalhadorData.SEXO ).isEqual( sexos[ n ] ) ).and(
+ new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ if( array.get( 0, 0 ) != null )
+ {
+ contagens[ n ] += ( ( Number ) array.get( 0, 0 ) ).doubleValue() / 12.0;
+ }
+ }
+
+ return contagens;
+ }
+
+ public double[] countNumeroTotalTrabalhadoresEmpresa( Integer empresaID, int ano )
+ throws Exception
+ {
+ double contagens[] = new double[ 2 ];;
+ Select select;
+ String sexos[] = new String[]{ "m", "f" };
+
+ for( int n = 0; n < sexos.length; n++ )
+ {
+ select =
+ new Select( new String[]{ "estabelecimentos", "trabalhadores" },
+ new String[]{ "COUNT(trabalhadores.id)" },
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ).and(
+ new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or(
+ new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ) ).and(
+ new Par( new Field( "YEAR(" + TrabalhadorData.DATA_DEMISSAO + ")" ).isGreaterOrEqual( new Integer( ano ) ).or(
+ new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ).and(
+ new Field( "empresa_id" ).isEqual( empresaID ) ).and(
+ new Field( TrabalhadorData.SEXO ).isEqual( sexos[ n ] ) ).and(
+ new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ contagens[ n ] = ( ( Number ) array.get( 0, 0 ) ).doubleValue();
+ }
+ return contagens;
+ }
+
+ public String []getNomesExames()
+ throws Exception
+ {
+ String nomes[];
+ Select select =
+ new Select( new String[]{ "tipos_exames_comp" },
+ new String[]{ "descricao", "ordem" },
+ null,
+ new String[]{ "ordem" }, null );
+ Virtual2DArray array = executer.executeQuery( select );
+ nomes = new String[ array.columnLength() ];
+ for( int n = 0; n < array.columnLength(); n++ )
+ {
+ nomes[ n ] = ( String )array.get( n, 0 );
+ }
+ return nomes;
+ }
+
+ public int []countExamesComplementaresEmpresa( Integer empresaID, int ano )
+ throws Exception
+ {
+// Vector perfis[] = new Vector[ 2 ];
+// Hashtable contagens[] = new Hashtable[ 2 ];
+// Select select;
+// Virtual2DArray array;
+//
+// for( int p = 0; p < 2; p++ )
+// {
+// Integer pAux = new Integer( p + 1 );
+// perfis[ p ] = new Vector();
+// select = new Select( new String[]{"estabelecimentos", "trabalhadores", "marcacoes_trabalhador"},
+// new String[]{"COUNT(marcacoes_trabalhador.id)", TrabalhadorData.PERFIL },
+// 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( "empresa_id" ).isEqual( empresaID ) ).and(
+// new Field( MarcacaoTrabalhadorData.TIPO ).isEqual( new Integer( MarcacaoTrabalhadorData.TIPO_EXAMES ) ) ).and(
+// new Field( "YEAR( marcacoes_trabalhador.data ) " ).isEqual( new Integer( ano ) ).and(
+// new Field( MarcacaoTrabalhadorData.ESTADO ).in( new Integer[]{ new Integer( 1 ), new Integer( 2 ) } ) ) ).and(
+// new Field( "trabalhadores.perfil" ).isEqual( pAux ) ) );
+// array = executer.executeQuery( select );
+//
+// select =
+// new Select( new String[]{ "prt_elementos_protocolo", "prt_tipos_elementos_protocolo" },
+// new String[]{ "DISTINCT prt_tipos_elementos_protocolo.grupo_protocolo_id" },
+// new Field( "prt_elementos_protocolo.empresa_id" ).isEqual( empresaID ).and(
+// new Field( "prt_elementos_protocolo.tipo_elemento_protocolo_id" ).isEqual( new Field( "prt_elementos_protocolo.id" ) ) ).and(
+// new Field( "pr_elementos_protocolo.perfil" ).isEqual( new Integer( p + 1 ) ) ) );
+// array = executer.executeQuery( select );
+// for( int ecd = 0; ecd < array.columnLength(); ecd++ )
+// {
+// perfis[ p ].add( ( Integer ) array.get( 0, 0 ) );
+// }
+// }
+//
+//
+// return contagens;
+
+
+ int contagens[];
+ Select select;
+ select = new Select( new String[]{"empresas"}, new String[]{ "perfil_1", "perfil_2" },
+ new Field( "id" ).isEqual( empresaID ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ String p1Str = (String)array.get( 0, 0 );
+ String p2Str = (String)array.get( 0, 1 );
+ Number perfil1 = ( p1Str != null && p1Str.length() > 0 )?new Integer( p1Str ):null;
+ Number perfil2 = ( p2Str != null && p2Str.length() > 0 )?new Integer( p2Str ):null;
+ select =
+ new Select( new String[]{ "tipos_exames_comp" },
+ new String[]{ "id", "ordem" },
+ null,
+ new String[]{ "ordem" }, null );
+ array = executer.executeQuery( select );
+ contagens = new int[ array.columnLength() ];
+ Hashtable idExames = new Hashtable();
+ for( int n = 0; n < array.columnLength(); n++ )
+ {
+ idExames.put( ( Number )array.get( n, 0 ), new Integer( n ) );
+ }
+ if( perfil1 == null && perfil2 == null )
+ {
+ return contagens;
+ }
+ else if( perfil1 == null )
+ {
+ perfil1 = perfil2;
+ }
+ else if( perfil2 == null )
+ {
+ perfil2 = perfil1;
+ }
+ select = new Select( new String[]{"estabelecimentos", "trabalhadores", "marcacoes_trabalhador"},
+ new String[]{"COUNT(marcacoes_trabalhador.id)", TrabalhadorData.PERFIL },
+ 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( "empresa_id" ).isEqual( empresaID ) ).and(
+ new Field( MarcacaoTrabalhadorData.TIPO ).isEqual( new Integer( MarcacaoTrabalhadorData.TIPO_EXAMES ) ) ).and(
+ new Field( "YEAR( marcacoes_trabalhador.data ) " ).isEqual( new Integer( ano ) ).and(
+ new Field( Marcacao.REALIZADA ).isEqual( "y" ) ) ),
+ new String[]{ TrabalhadorData.PERFIL },
+ new String[]{ TrabalhadorData.PERFIL } );
+ array = executer.executeQuery( select );
+ int numeroExames[] = new int[ 2 ];
+ for( int n = 0; n < array.columnLength(); n++ )
+ {
+ Integer perfil = (Integer)array.get( n, 1 );
+ if( perfil == null || perfil.intValue() == 1 )
+ {
+ numeroExames[0] += ( (Number) array.get( n, 0 ) ).intValue();
+ }
+ else if( perfil.intValue() == 2 )
+ {
+ numeroExames[1] += ( (Number) array.get( n, 0 ) ).intValue();
+ }
+ }
+
+ Hashtable hash = new Hashtable();
+ select = new Select( new String[]{ "exames_perfis" },
+ new String[]{ "tipo", "multiplicador" },
+ new Field( "perfil" ).isEqual( perfil1 ) );
+ array = executer.executeQuery( select );
+ for( int n = 0; n < array.columnLength(); n++ )
+ {
+ Number tipo = (Number) array.get( n, 0 );
+ if( tipo == null )
+ {
+ continue;
+ }
+ Number multiplicador = (Number) array.get( n, 1 );
+ if( multiplicador == null )
+ {
+ multiplicador = new Integer( 1 );
+ }
+ if( idExames.containsKey( tipo ) )
+ {
+ int pos = ((Integer)idExames.get( tipo )).intValue();
+ contagens[ pos ] += numeroExames[0] * multiplicador.intValue();
+ }
+ }
+ select = new Select( new String[]{ "exames_perfis" },
+ new String[]{ "tipo", "multiplicador" },
+ new Field( "perfil" ).isEqual( perfil2 ) );
+ array = executer.executeQuery( select );
+ for( int n = 0; n < array.columnLength(); n++ )
+ {
+ Number tipo = (Number) array.get( n, 0 );
+ if( tipo == null )
+ {
+ continue;
+ }
+ Number multiplicador = (Number) array.get( n, 1 );
+ if( multiplicador == null )
+ {
+ multiplicador = new Integer( 1 );
+ }
+ if( idExames.containsKey( tipo ) )
+ {
+ int pos = ((Integer)idExames.get( tipo )).intValue();
+ contagens[ pos ] += numeroExames[1] * multiplicador.intValue();
+ }
+ }
+ return contagens;
+ }
+
+ public int []countExamesComplementaresEstabelecimento( Integer estabelecimentoID, int ano )
+ throws Exception
+ {
+ int contagens[];
+ Select select;
+ select = new Select( new String[]{"estabelecimentos", "empresas"},
+ new String[]{ "empresas.perfil_1", "empresas.perfil_2" },
+ new Field( "estabelecimentos.id" ).isEqual( estabelecimentoID ).and(
+ new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) ) );
+ Virtual2DArray array = executer.executeQuery( select );
+ String p1Str = (String)array.get( 0, 0 );
+ String p2Str = (String)array.get( 0, 1 );
+ Number perfil1 = ( p1Str != null && p1Str.length() > 0 )?new Integer( p1Str ):null;
+ Number perfil2 = ( p2Str != null && p2Str.length() > 0 )?new Integer( p2Str ):null;
+ select =
+ new Select( new String[]{ "tipos_exames_comp" },
+ new String[]{ "id", "ordem" },
+ null,
+ new String[]{ "ordem" }, null );
+ array = executer.executeQuery( select );
+ contagens = new int[ array.columnLength() ];
+ Hashtable idExames = new Hashtable();
+ for( int n = 0; n < array.columnLength(); n++ )
+ {
+ idExames.put( ( Number )array.get( n, 0 ), new Integer( n ) );
+ }
+ if( perfil1 == null && perfil2 == null )
+ {
+ return contagens;
+ }
+ else if( perfil1 == null )
+ {
+ perfil1 = perfil2;
+ }
+ else if( perfil2 == null )
+ {
+ perfil2 = perfil1;
+ }
+ select = new Select( new String[]{"trabalhadores", "marcacoes_trabalhador"},
+ new String[]{"COUNT(marcacoes_trabalhador.id)", TrabalhadorData.PERFIL },
+ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
+ new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
+ new Field( MarcacaoTrabalhadorData.TIPO ).isEqual( new Integer( MarcacaoTrabalhadorData.TIPO_EXAMES ) ) ).and(
+ new Field( "YEAR( marcacoes_trabalhador.data ) " ).isEqual( new Integer( ano ) ).and(
+ new Field( Marcacao.REALIZADA ).isEqual( "y" ) ) ),
+ new String[]{ TrabalhadorData.PERFIL },
+ new String[]{ TrabalhadorData.PERFIL } );
+ array = executer.executeQuery( select );
+ int numeroExames[] = new int[ 2 ];
+ for( int n = 0; n < array.columnLength(); n++ )
+ {
+ Integer perfil = (Integer)array.get( n, 1 );
+ if( perfil == null || perfil.intValue() == 1 )
+ {
+ numeroExames[0] += ( (Number) array.get( n, 0 ) ).intValue();
+ }
+ else if( perfil.intValue() == 2 )
+ {
+ numeroExames[1] += ( (Number) array.get( n, 0 ) ).intValue();
+ }
+ }
+
+ Hashtable hash = new Hashtable();
+ select = new Select( new String[]{ "exames_perfis" },
+ new String[]{ "tipo", "multiplicador" },
+ new Field( "perfil" ).isEqual( perfil1 ) );
+ array = executer.executeQuery( select );
+ for( int n = 0; n < array.columnLength(); n++ )
+ {
+ Number tipo = (Number) array.get( n, 0 );
+ if( tipo == null )
+ {
+ continue;
+ }
+ Number multiplicador = (Number) array.get( n, 1 );
+ if( multiplicador == null )
+ {
+ multiplicador = new Integer( 1 );
+ }
+ if( idExames.containsKey( tipo ) )
+ {
+ int pos = ((Integer)idExames.get( tipo )).intValue();
+ contagens[ pos ] += numeroExames[0] * multiplicador.intValue();
+ }
+ }
+ select = new Select( new String[]{ "exames_perfis" },
+ new String[]{ "tipo", "multiplicador" },
+ new Field( "perfil" ).isEqual( perfil2 ) );
+ array = executer.executeQuery( select );
+ for( int n = 0; n < array.columnLength(); n++ )
+ {
+ Number tipo = (Number) array.get( n, 0 );
+ if( tipo == null )
+ {
+ continue;
+ }
+ Number multiplicador = (Number) array.get( n, 1 );
+ if( multiplicador == null )
+ {
+ multiplicador = new Integer( 1 );
+ }
+ if( idExames.containsKey( tipo ) )
+ {
+ int pos = ((Integer)idExames.get( tipo )).intValue();
+ contagens[ pos ] += numeroExames[1] * multiplicador.intValue();
+ }
+ }
+ return contagens;
+ }
+}
diff --git a/trunk/siprp/pesquisas/PesquisasWindow.java b/trunk/siprp/pesquisas/PesquisasWindow.java
new file mode 100644
index 00000000..c08d21b1
--- /dev/null
+++ b/trunk/siprp/pesquisas/PesquisasWindow.java
@@ -0,0 +1,578 @@
+/*
+ * PesquisasWindow.java
+ *
+ * Created on 3 de Junho de 2004, 18:13
+ */
+
+package siprp.pesquisas;
+
+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.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.text.*;
+
+import siprp.data.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class PesquisasWindow extends JFrame
+ implements TrackableWindow, ListSelectionListener, ActionListener
+{
+ private JDOProvider JDO;
+ private PesquisasProvider provider;
+
+ private JTextField anoText;
+ private BaseTable empresasTable;
+ private VectorTableModel empresasModel;
+ private BaseTable estabelecimentosTable;
+ private VectorTableModel estabelecimentosModel;
+ private JButton pesquisarButton;
+ private JButton exportarButton;
+ private JEditorPane resultadoText;
+
+// public static void main( String args[] )
+// throws Exception
+// {
+// new PesquisasWindow().show();
+// }
+
+ /** Creates a new instance of PesquisasWindow */
+ public PesquisasWindow()
+ throws Exception
+ {
+ provider = (PesquisasProvider)PesquisasProvider.getProvider();
+ JDO =( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
+ setupComponents();
+ }
+
+ private void setupComponents()
+ {
+ setSize( 1000, 700 );
+ setTitle( "Relat\u00f3rio Anual" );
+
+ 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 );
+ exportarButton = new JButton( "Exportar" );
+ exportarButton.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_NEVER );
+ 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 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, 2 ) );
+ buttonPanel.add( pesquisarButton );
+ buttonPanel.add( exportarButton );
+ 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 );
+ }
+
+ private boolean close()
+ {
+ setVisible( false );
+ dispose();
+ return true;
+ }
+
+ public boolean closeIfPossible()
+ {
+ return close();
+ }
+
+ public void open()
+ {
+ empresasTable.clearSelection();
+ try
+ {
+ IDObject empresas[] = provider.getAllEmpresas();
+ empresasModel.setValues( new Vector( Arrays.asList( empresas ) ) );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
+ }
+ setVisible( true );
+ }
+
+ public void refresh()
+ {
+ }
+
+ public void valueChanged( 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 = provider.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 );
+ }
+/* else if( source.equals( estabelecimentosTable.getSelectionModel() ) )
+ {
+ }*/
+ }
+
+ public void actionPerformed( ActionEvent e )
+ {
+ Object source = e.getSource();
+ if( source.equals( pesquisarButton ) )
+ {
+ int sEmpresa = empresasTable.getSelectedRow();
+ int sEstabelecimento = estabelecimentosTable.getSelectedRow();
+ String anoStr = anoText.getText();
+ int ano = ( anoStr.length() != 0 )? Integer.parseInt( anoStr ): -1;
+ if( sEmpresa == -1 || ano == -1 )
+ {
+ JOptionPane.showMessageDialog( this, "Tem de escolher ano e empresa", "Erro...",
+ JOptionPane.ERROR_MESSAGE );
+ return;
+ }
+ StringBuffer buff = new StringBuffer();
+ buff.append( "ANO: " );
+ buff.append( "" + ano + "
" );
+ buff.append( "
EMPRESA
" );
+ try
+ {
+ Integer idEmpresa = ( (IDObject)empresasModel.getRowAt( sEmpresa ) ).getID();
+ EmpresaData empresa = (EmpresaData)JDO.load( EmpresaData.class, idEmpresa );
+ buff.append( " DESIGNA\u00C7\u00C3O SOCIAL: " );
+ String designacao = (String)empresa.get( EmpresaData.DESIGNACAO_SOCIAL );
+ buff.append( "" + ( designacao == null ? "" : designacao.trim() ) + "
" );
+ buff.append( " MORADA: " );
+ String morada = (String)empresa.get( EmpresaData.MORADA );
+ buff.append( "" + ( morada == null ? "" : morada.trim() ) + "
" );
+ buff.append( " LOCALIDADE: " );
+ String localidade = ( String ) empresa.get( EmpresaData.LOCALIDADE );
+ buff.append( "" + ( localidade == null ? "" : localidade.trim() ) + "
" );
+ buff.append( " C\u00D3DIGO POSTAL: " );
+ String codigoPostal = ( String ) empresa.get( EmpresaData.CODIGO_POSTAL );
+ buff.append( "" + ( codigoPostal == null ? "" : codigoPostal.trim() ) + "
" );
+ ContactoData contacto = (ContactoData)empresa.get( EmpresaData.CONTACTO_2 );
+ if( contacto == null )
+ {
+ buff.append( " TELEFONE:
" );
+ buff.append( " FAX:
" );
+ }
+ else
+ {
+ buff.append( " TELEFONE: " );
+ String telefone = ( String ) contacto.get( ContactoData.TELEFONE );
+ buff.append( "" + ( telefone == null ? "" : telefone.trim() ) + "
" );
+ buff.append( " FAX: " );
+ String fax = ( String ) contacto.get( ContactoData.TELEFONE );
+ buff.append( "" + ( fax == null ? "" : fax.trim() ) + "
" );
+ }
+ buff.append( " DISTRITO: " );
+ String distrito = ( String ) empresa.get( EmpresaData.DISTRITO );
+ buff.append( "" + ( distrito == null ? "" : distrito ) + "
" );
+ buff.append( " CONCELHO: " );
+ String concelho = ( String ) empresa.get( EmpresaData.CONCELHO );
+ buff.append( "" + ( concelho == null ? "" : concelho ) + "
" );
+ buff.append( " N\u00DAMERO PESSOA COLECTIVA: " );
+ String contribuinte = ( String ) empresa.get( EmpresaData.CONTRIBUINTE );
+ buff.append( "" + ( contribuinte == null ? "" : contribuinte ) + "
" );
+ buff.append( " N\u00DAMERO SEGURAN\u00C7A SOCIAL: " );
+ String segSocial = ( String ) empresa.get( EmpresaData.SEGURANCA_SOCIAL );
+ buff.append( "" + ( segSocial == null ? "" : segSocial ) + "
" );
+ buff.append( " CAE: " );
+ String CAE = ( String ) empresa.get( EmpresaData.CAE );
+ buff.append( "" + ( CAE == null ? "" : CAE ) + "
" );
+ buff.append( "
N\u00DAMERO M\u00C9DIO DE TRABALHADORES DURANTE O ANO" );
+ double contagemMedia[] = provider.countNumeroMedioTrabalhadoresEmpresa( idEmpresa, ano );
+ buff.append( "" );
+ buff.append( "" );
+ buff.append( "| | | | TOTAL | | HOMENS | | MULHERES | " );
+ buff.append( "
" );
+ buff.append( "| | TOTAL | | " + (int)( Math.round( contagemMedia[0] ) + Math.round( contagemMedia[1] ) ) + " | ");
+ buff.append( " | " + ( (int)Math.round( contagemMedia[0] ) ) + " | " );
+ buff.append( " | " + ( (int)Math.round( contagemMedia[1] ) ) + " | " );
+ buff.append( "
" );
+ buff.append( "
" );
+ buff.append( "
N\u00DAMERO TOTAL DE TRABALHADORES DURANTE O ANO" );
+ double contagemTotal[] = provider.countNumeroTotalTrabalhadoresEmpresa( idEmpresa, ano );
+ buff.append( "" );
+ buff.append( "" );
+ buff.append( "| | | | TOTAL | | HOMENS | | MULHERES | " );
+ buff.append( "
" );
+ buff.append( "| | TOTAL | | " + (int)( Math.round( contagemTotal[0] ) + Math.round( contagemTotal[1] ) ) + " | ");
+ buff.append( " | " + ( (int)Math.round( contagemTotal[0] ) ) + " | " );
+ buff.append( " | " + ( (int)Math.round( contagemTotal[1] ) ) + " | " );
+ buff.append( "
" );
+ buff.append( "
" );
+
+ IDObject estabelecimentos[];
+ if( sEstabelecimento == -1 || ( ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento ) ).getID().equals( new Integer( -1 ) ) )
+ {
+ estabelecimentos = provider.getAllEstabelecimentosForEmpresa( idEmpresa );
+ }
+ else
+ {
+ estabelecimentos = new IDObject[ 1 ];
+ estabelecimentos[ 0 ] = ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento );
+ }
+ buff.append( "
" );
+ buff.append( "
ESTABELECIMENTOS
" );
+ buff.append( "
" );
+ for( int n = 0; n < estabelecimentos.length; n++ )
+ {
+ EstabelecimentoData estabelecimento = (EstabelecimentoData)JDO.load( EstabelecimentoData.class, estabelecimentos[ n ].getID() );
+ buff.append( " NOME: " );
+ String nome = (String)estabelecimento.get( EstabelecimentoData.NOME );
+ buff.append( "" + ( nome == null ? "" : nome.trim() ) + "
" );
+ buff.append( " MORADA: " );
+ morada = (String)estabelecimento.get( EstabelecimentoData.MORADA );
+ buff.append( "" + ( morada == null ? "" : morada.trim() ) + "
" );
+ buff.append( " LOCALIDADE: " );
+ localidade = (String)estabelecimento.get( EstabelecimentoData.LOCALIDADE );
+ buff.append( "" + ( localidade == null ? "" : localidade.trim() ) + "
" );
+ buff.append( " C\u00D3DIGO POSTAL: " );
+ codigoPostal = (String)estabelecimento.get( EstabelecimentoData.CODIGO_POSTAL );
+ buff.append( "" + ( codigoPostal == null ? "" : codigoPostal.trim() ) + "
" );
+ contacto = (ContactoData)estabelecimento.get( EstabelecimentoData.CONTACTO );
+ if( contacto == null )
+ {
+ buff.append( " TELEFONE:
" );
+ buff.append( " FAX:
" );
+ }
+ else
+ {
+ buff.append( " TELEFONE: " );
+ String telefone = ( String ) contacto.get( ContactoData.TELEFONE );
+ buff.append( "" + ( telefone == null ? "" : telefone.trim() ) + "
" );
+ buff.append( " FAX: " );
+ String fax = ( String ) contacto.get( ContactoData.TELEFONE );
+ buff.append( "" + ( fax == null ? "" : fax.trim() ) + "
" );
+ }
+ int countTrabalhadores[] = provider.countTrabalhadoresEstabelecimentoDezembro( estabelecimentos[ n ].getID(), ano );
+ buff.append( "
" );
+ buff.append( " TRABALHADORES A 31 DE DEZEMBRO DE " + ano + ": " );
+ buff.append( "
" );
+ buff.append( "" );
+ buff.append( "" );
+ buff.append( "| |   | TOTAL | HOMENS | MULHERES | " );
+ buff.append( "
" );
+ buff.append( "" );
+ buff.append( "| | TOTAL | "
+ + " " + ( countTrabalhadores[0] + countTrabalhadores[1] ) + " | "
+ + " " + ( countTrabalhadores[0] ) + " | "
+ + " " + ( countTrabalhadores[1] ) + " | " );
+ buff.append( "
" );
+ int countTrabalhadoresEtario[][] = provider.countTrabalhadoresEstabelecimentoDezembroPorGrupoEtario( estabelecimentos[ n ].getID(), ano );
+ buff.append( "" );
+ buff.append( "| | MENOS DE 18 ANOS | "
+ + " " + ( countTrabalhadoresEtario[0][0] + countTrabalhadoresEtario[0][1] ) + " | "
+ + " " + ( countTrabalhadoresEtario[0][0] ) + " | "
+ + " " + ( countTrabalhadoresEtario[0][1] ) + " | " );
+ buff.append( "
" );
+ buff.append( "" );
+ buff.append( "| | 18 A 49 ANOS | "
+ + " " + ( countTrabalhadoresEtario[1][0] + countTrabalhadoresEtario[1][1] ) + " | "
+ + " " + ( countTrabalhadoresEtario[1][0] ) + " | "
+ + " " + ( countTrabalhadoresEtario[1][1] ) + " | " );
+ buff.append( "
" );
+ buff.append( "" );
+ buff.append( "| | MAIS DE 50 ANOS | "
+ + " " + ( countTrabalhadoresEtario[2][0] + countTrabalhadoresEtario[2][1] ) + " | "
+ + " " + ( countTrabalhadoresEtario[2][0] ) + " | "
+ + " " + ( countTrabalhadoresEtario[2][1] ) + " | " );
+ buff.append( "
" );
+ buff.append( "
" );
+ buff.append( "
" );
+ int countExames[][] = provider.countExamesEstabelecimentoDezembroPorGrupoEtario( estabelecimentos[ n ].getID(), ano );
+ for( int cE = 0; cE < countExames[ countExames.length - 2 ].length; cE++ )
+ {
+ countExames[ countExames.length - 2 ][ cE ] += countExames[ countExames.length - 1 ][ cE ];
+ }
+ int totais[] = new int[ 6 ];
+ for( int cE1 = 0; cE1 < totais.length; cE1++ )
+ {
+ for( int cE2 = 0; cE2 < countExames.length; cE2++ )
+ {
+ totais[ cE1 ] += countExames[ cE2 ][ cE1 ];
+ }
+ }
+ buff.append( "
" );
+ buff.append( " N\u00DAMERO DE EXAMES DE ADMISS\u00C3O, PERI\u00D3DICOS E OCASIONAIS EFECTUADOS" );
+ buff.append( "
" );
+ buff.append( "" );
+ buff.append( "| | | | | TOTAL | | INFERIOR A 18 ANOS | "
+ + " | 18 A 49 ANOS | | 50 E MAIS ANOS | |
" );
+ buff.append( "| | TOTAL DE EXAMES | | H | " );
+ buff.append( "" + ( totais[0] + totais[1] + totais[2] ) + " | | " );
+ for( int t = 0; t < 3; t++ )
+ {
+ buff.append( "" + totais[t] + " | | " );
+ }
+ buff.append( "
" );
+ buff.append( "| | | | M | " );
+ buff.append( "" + ( totais[3] + totais[4] + totais[5] ) + " | | " );
+ for( int t = 3; t < 6; t++ )
+ {
+ buff.append( "" + totais[t] + " | | " );
+ }
+ buff.append( "
" );
+ String sexos[] = new String[]{ "H", "M" };
+ for( int t = 0; t < provider.DESCRICAO_TIPOS_EXAME.length; t++ )
+ {
+ buff.append( "| | "+provider.DESCRICAO_TIPOS_EXAME[t]+" | " );
+
+ for( int s = 0; s < 2; s++ )
+ {
+ buff.append( " | " + sexos[ s ] + " | " );
+ buff.append( "" + (countExames[t][s*3]+countExames[t][s*3+1]+countExames[t][s*3+2]) + " | | " );
+ for( int d = 0; d < 3; d++ )
+ {
+ buff.append( "" + countExames[t][s*3+d] + " | | " );
+ }
+ if( s == 0 )
+ {
+ buff.append( "
| | | " );
+ }
+ else
+ {
+ buff.append( "
" );
+ }
+ }
+ }
+ int countExamesOcasionais[][] = provider.countExamesOcasionaisEstabelecimentoDezembroPorGrupoEtario( estabelecimentos[ n ].getID(), ano );
+ for( int t = 0; t < provider.DESCRICAO_TIPOS_OCASIONAL.length; t++ )
+ {
+ buff.append( "| | "+provider.DESCRICAO_TIPOS_OCASIONAL[t]+" | " );
+
+ for( int s = 0; s < 2; s++ )
+ {
+ buff.append( " | " + sexos[ s ] + " | " );
+ int sum = countExamesOcasionais[t][s*3]+countExamesOcasionais[t][s*3+1]+countExamesOcasionais[t][s*3+2];
+ buff.append( "" + ( sum < 0 ? "-" : "" + sum ) + " | | " );
+ for( int d = 0; d < 3; d++ )
+ {
+ int val = countExamesOcasionais[t][s*3+d];
+ if( val < 0 )
+ {
+ countExamesOcasionais[t][s*3+d] = 0;
+ }
+ buff.append( "" + ( val < 0 ? "-" : "" + val ) + " | | " );
+ }
+ if( s == 0 )
+ {
+ buff.append( "
| | | " );
+ }
+ else
+ {
+ buff.append( "
" );
+ }
+ }
+ }
+ buff.append( "
" );
+ buff.append( "
" );
+ buff.append( " EXAMES COMPLEMENTARES REALIZADOS" );
+ buff.append( "
" );
+ buff.append( "" );
+ buff.append( "| | TIPO DE EXAME | | " );
+ buff.append( "N\u00BA TOTAL DE EXAMES |
" );
+ String nomesExamesComp[] = provider.getNomesExames();
+// int countExamesComp[] = provider.countExamesComplementaresEmpresa( idEmpresa, ano );
+ int countExamesComp[] = provider.countExamesComplementaresEstabelecimento( estabelecimentos[ n ].getID(), ano );
+ for( int nec = 0; nec < nomesExamesComp.length; nec++ )
+ {
+ buff.append( "" );
+ buff.append( "| | " + nomesExamesComp[nec] + " | " );
+ buff.append( " | " + countExamesComp[nec] + " | " );
+ buff.append( "
" );
+ }
+ buff.append( "
" );
+ buff.append("
");
+ }
+
+ resultadoText.setText( buff.toString() );
+ }
+ catch( Exception ex )
+ {
+ DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
+ return;
+ }
+ }
+ else if( source.equals( exportarButton ) )
+ {
+ exportar();
+ }
+ }
+
+ 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( "", "
" );
+ text = text.replace( "", "\nRelatório Anual
" );
+// String title = "S.I.P.R.P. - Sociedade Ibérica de Prevenção de Riscos Profissionais";
+// text = text.replace( "", "\n\t\t" + title + "" );
+// System.out.println( text );
+ try
+ {
+ FileWriter writer = new FileWriter( new File( fullName ) );
+ writer.write( text );
+ writer.close();
+ }
+ catch( IOException ex )
+ {
+ DialogException.showException( ex );
+ return;
+ }
+ }
+ }
+}
+
diff --git a/trunk/siprp/web/WebUpdater.java b/trunk/siprp/web/WebUpdater.java
new file mode 100644
index 00000000..cf84448f
--- /dev/null
+++ b/trunk/siprp/web/WebUpdater.java
@@ -0,0 +1,1210 @@
+/*
+ * WebUpdater.java
+ *
+ * Created on 27 de Outubro de 2004, 15:54
+ */
+
+package siprp.web;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.io.*;
+import java.sql.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.util.*;
+
+//import siprp.*;
+//import siprp.clientes.*;
+
+/**
+ *
+ * @author fpalma
+ */
+public class WebUpdater extends JFrame
+ implements ActionListener, Runnable, DocumentListener
+{
+ private Connection softwareConnection;
+ private Connection webConnection;
+
+ public static final String GET_ULTIMA_ACTUALIZACAO = "SELECT stamp FROM actualizacao";
+
+ public static final String GET_EMPRESAS =
+ "SELECT id, designacao_social, perfil_1, perfil_2, codigo_1, codigo_2, "
+ + "codigo_3, cae, contribuinte, seguranca_social, actividade, servicos, morada, "
+ + "localidade, codigo_postal, distrito, concelho, inactivo, contacto_1 "
+ + "FROM empresas WHERE actualizacao >= ";
+
+ public static final String GET_EMAIL =
+ "SELECT email FROM contactos WHERE id = ";
+
+ public static final String GET_ESTABELECIMENTOS =
+ "SELECT id, empresa_id, nome, contacto, morada, localidade, codigo_postal, inactivo "
+ + "FROM estabelecimentos WHERE actualizacao >= ";
+
+ public static final String GET_TRABALHADORES =
+ "SELECT id, nome, sexo, data_nascimento, numero_mecanografico, categoria, estabelecimento_id, data_demissao, inactivo "
+ + "FROM trabalhadores WHERE actualizacao >= ";
+
+ public static final String GET_CONTACTO =
+ "SELECT nome, telefone, telemovel, fax, email, cargo FROM contactos WHERE id = ";
+
+ public static final String GET_MARCACOES_ESTABELECIMENTO =
+ "SELECT id, data, realizada, data_relatorio FROM marcacoes_estabelecimento "
+ + "WHERE estabelecimento_id = ";
+
+ public static final String GET_EXAMES_TRABALHADOR =
+ "SELECT id, data, realizada, data_relatorio FROM marcacoes_trabalhador "
+ + "WHERE tipo = 0 and trabalhador_id = ?trabalhador_id "
+ + "ORDER BY data";
+
+ public static final String GET_CONSULTAS_TRABALHADOR =
+ "SELECT id, data, realizada, data_relatorio FROM marcacoes_trabalhador "
+ + "WHERE tipo = 1 and trabalhador_id = ?trabalhador_id "
+ + "ORDER BY data";
+
+ public static final String GET_ID_FICHA_APTIDAO =
+ "SELECT MAX(id) FROM exames WHERE trabalhador_id = ?trabalhador_id AND inactivo <> 'y'";
+
+ public static final String GET_DADOS_FICHA_APTIDAO =
+ "SELECT data, resultado FROM exames WHERE id = ?id";
+
+ public static final String DELETE_TRABALHADOR =
+ "DELETE FROM trabalhadores WHERE id = ";
+
+ public static final String DELETE_TRABALHADORES_BY_ESTABELECIMENTO =
+ "DELETE FROM trabalhadores WHERE estabelecimento_id = ";
+
+ public static final String DELETE_ESTABELECIMENTO =
+ "DELETE FROM estabelecimentos WHERE id = ";
+
+ public static final String DELETE_ESTABELECIMENTOS_BY_EMPRESA =
+ "DELETE FROM estabelecimentos WHERE empresa_id = ";
+
+ public static final String DELETE_TRABALHADORES_BY_EMPRESA =
+ "DELETE FROM trabalhadores WHERE estabelecimento_id IN ( SELECT id FROM estabelecimentos WHERE empresa_id = ?empresa_id )";
+
+ public static final String DELETE_EMPRESA =
+ "DELETE FROM empresas WHERE id = ";
+
+ public static final String CREATE_EMPRESA =
+ "INSERT INTO empresas(id) VALUES( ?id )";
+
+ public static final String CREATE_ESTABELECIMENTO =
+ "INSERT INTO estabelecimentos(id) VALUES( ?id )";
+
+ public static final String CREATE_TRABALHADOR =
+ "INSERT INTO trabalhadores(id) VALUES( ?id )";
+
+ public static final String UPDATE_EMPRESA =
+ "UPDATE empresas SET morada = ?morada, codigo_postal = ?codigo_postal, "
+ + "localidade = ?localidade, distrito = ?distrito, concelho = ?concelho, "
+ + "perfil_1 = ?perfil_1, perfil_2 = ?perfil_2, codigo = ?codigo, cae = ?cae, "
+ + "contribuinte = ?contribuinte, seguranca_social = ?seguranca_social, "
+ + "actividade = ?actividade, servicos = ?servicos, designacao_social = ?designacao_social, "
+ + "email = ?email "
+ + "WHERE id = ?id";
+
+ public static final String UPDATE_ESTABELECIMENTO =
+ "UPDATE estabelecimentos SET empresa_id = ?empresa_id, morada = ?morada, "
+ + "codigo_postal = ?codigo_postal, localidade = ?localidade, "
+ + "ultima_visita = ?ultima_visita, realizada = ?realizada, "
+ + "proxima_visita = ?proxima_visita, nome = ?nome "
+ + "WHERE id = ?id";
+
+ public static final String UPDATE_TRABALHADOR =
+ "UPDATE trabalhadores SET sexo = ?sexo, data_nascimento = ?data_nascimento, "
+ + "numero_mecanografico = ?numero_mecanografico, categoria = ?categoria, "
+ + "ultimo_exame = ?ultimo_exame, realizado = ?realizado, proximo_exame = ?proximo_exame, "
+ + "ultima_consulta = ?ultima_consulta, realizada = ?realizada, "
+ + "proxima_consulta = ?proxima_consulta, nome = ?nome, "
+ + "resultado = ?resultado, data_ficha = ?data_ficha, "
+ + "estabelecimento_id = ?estabelecimento_id "
+ + "WHERE id = ?id";
+
+ public static final String UPDATE_ACTUALIZACAO = "UPDATE actualizacao SET stamp = ";
+
+
+ public static final String PROPERTIES_FILE = "updtprop.txt";
+ public static final String PROP_LOCAL = "interno";
+ public static final String PROP_LOCAL_U = "iuser";
+ public static final String PROP_LOCAL_P = "ipasswd";
+ public static final String PROP_REMOTE = "externo";
+ public static final String PROP_REMOTE_U = "euser";
+ public static final String PROP_REMOTE_P = "epasswd";
+ public static final String PROP_INTERVAL = "intervalo";
+
+
+ protected Vector deletes;
+ protected Vector updates;
+
+ protected Thread updateThread;
+
+ protected JTextField servidorInternoText;
+ protected JTextField servidorExternoText;
+ protected JTextField intervaloText;
+ protected JTextField ultimaActualizacaoText;
+ protected JTextField proximaActualizacaoText;
+ protected JButton actionButton;
+ protected JButton saveButton;
+ protected JButton cancelButton;
+ protected JLabel stateLabel;
+
+ protected boolean running;
+ protected String servidorInterno;
+ protected String servidorExterno;
+ protected String internalUser;
+ protected String internalPassword;
+ protected String externalUser;
+ protected String externalPassword;
+ protected long intervalo;
+
+ /** Creates a new instance of WebUpdater */
+ public WebUpdater()
+ {
+ deletes = new Vector();
+ updates = new Vector();
+ running = false;
+ servidorInterno = "ws_fpalma";
+ servidorExterno = "localhost:5436";
+ intervalo = 10;
+ setupComponents();
+ }
+
+ protected void setupComponents()
+ {
+ setSize( 500, 200 );
+ setResizable( false );
+ setTitle( "Actualiza\u00e7\u00e3o do Site" );
+ JLabel servidorInternoLabel = new JLabel( "Servidor Interno" );
+ servidorInternoText = new JTextField();
+ servidorInternoText.setPreferredSize( new Dimension( 120, 20 ) );
+ servidorInternoText.setForeground( Color.red );
+ JLabel servidorExternoLabel = new JLabel( "Servidor Externo" );
+ servidorExternoText = new JTextField();
+ servidorExternoText.setPreferredSize( new Dimension( 120, 20 ) );
+ servidorExternoText.setForeground( Color.red );
+ JLabel intervaloLabel = new JLabel( "Intervalo de Actualiza\u00e7\u00e3o (minutos)" );
+ intervaloText = new JTextField();
+ intervaloText.setPreferredSize( new Dimension( 50, 20 ) );
+ JLabel ultimaActualizacaoLabel = new JLabel( "\u00daltima Actualiza\u00e7\u00e3o" );
+ ultimaActualizacaoText = new JTextField();
+ ultimaActualizacaoText.setPreferredSize( new Dimension( 120, 20 ) );
+ ultimaActualizacaoText.setEditable( false );
+ JLabel proximaActualizacaoLabel = new JLabel( "Pr\u00f3xima Actualiza\u00e7\u00e3o" );
+ proximaActualizacaoText = new JTextField();
+ proximaActualizacaoText.setPreferredSize( new Dimension( 120, 20 ) );
+ proximaActualizacaoText.setEditable( false );
+ actionButton = new JButton( "Executar" );
+ saveButton = new JButton( "Guardar Altera\u00e7\u00f5es" );
+ saveButton.setEnabled( false );
+ cancelButton = new JButton( "Cancelar Altera\u00e7\u00f5es" );
+ cancelButton.setEnabled( false );
+ stateLabel = new JLabel( " " );
+ JPanel buttonPanel = new JPanel();
+ JPanel pad = new JPanel();
+ pad.setPreferredSize( new Dimension( 120, 20 ) );
+
+ Container container = getContentPane();
+ GridBagLayout gridbag = new GridBagLayout();
+ container.setLayout( gridbag );
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.insets = new Insets( 1, 1, 1, 1 );
+// constraints.anchor = GridBagConstraints.EAST;
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.weighty = 0;
+ constraints.gridheight = 1;
+
+ constraints.weightx = 0;
+ constraints.gridwidth = 1;
+ gridbag.setConstraints( servidorInternoLabel, constraints );
+ gridbag.setConstraints( servidorExternoLabel, constraints );
+ gridbag.setConstraints( intervaloLabel, constraints );
+ gridbag.setConstraints( ultimaActualizacaoLabel, constraints );
+ gridbag.setConstraints( proximaActualizacaoLabel, constraints );
+
+ constraints.weightx = 1;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( servidorInternoText, constraints );
+ gridbag.setConstraints( servidorExternoText, constraints );
+ gridbag.setConstraints( ultimaActualizacaoText, constraints );
+ gridbag.setConstraints( proximaActualizacaoText, constraints );
+ gridbag.setConstraints( buttonPanel, constraints );
+ gridbag.setConstraints( stateLabel, constraints );
+
+ constraints.weightx = 0.5;
+ constraints.gridwidth = 1;
+ gridbag.setConstraints( intervaloText, constraints );
+
+ constraints.weightx = 0.5;
+ constraints.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints( pad, constraints );
+
+ container.add( servidorInternoLabel );
+ container.add( servidorInternoText );
+ container.add( servidorExternoLabel );
+ container.add( servidorExternoText );
+ container.add( intervaloLabel );
+ container.add( intervaloText );
+ container.add( pad );
+ container.add( ultimaActualizacaoLabel );
+ container.add( ultimaActualizacaoText );
+ container.add( proximaActualizacaoLabel );
+ container.add( proximaActualizacaoText );
+ container.add( buttonPanel );
+ container.add( stateLabel );
+
+ buttonPanel.setLayout( new FlowLayout( FlowLayout.RIGHT ) );
+ buttonPanel.add( saveButton );
+ buttonPanel.add( cancelButton );
+ buttonPanel.add( actionButton );
+
+ actionButton.addActionListener( this );
+ stateLabel.setText( "Parado" );
+ stateLabel.setForeground( Color.red );
+
+// servidorInternoText.setText( servidorInterno );
+// servidorExternoText.setText( servidorExterno );
+// intervaloText.setText( "" + intervalo );
+ reload();
+
+ servidorInternoText.getDocument().addDocumentListener( this );
+ servidorExternoText.getDocument().addDocumentListener( this );
+ intervaloText.getDocument().addDocumentListener( this );
+ saveButton.addActionListener( this );
+ cancelButton.addActionListener( this );
+ }
+
+ public void actionPerformed(java.awt.event.ActionEvent actionEvent)
+ {
+ Object source = actionEvent.getSource();
+ if( actionButton.equals( source ) )
+ {
+ if( running )
+ {
+ running = false;
+ updateThread.interrupt();
+ actionButton.setText( "Executar" );
+ stateLabel.setText( "Parado" );
+ stateLabel.setBackground( Color.red );
+ }
+ else
+ {
+ updateThread = new Thread( this );
+ updateThread.start();
+ actionButton.setText( "Parar" );
+ }
+ }
+ else if( saveButton.equals( source ) )
+ {
+ save();
+ saveButton.setEnabled( false );
+ cancelButton.setEnabled( false );
+ }
+ else if( cancelButton.equals( source ) )
+ {
+ reload();
+ saveButton.setEnabled( false );
+ cancelButton.setEnabled( false );
+ }
+ }
+
+
+ public void changedUpdate(javax.swing.event.DocumentEvent documentEvent)
+ {
+ saveButton.setEnabled( true );
+ cancelButton.setEnabled( true );
+ }
+
+ public void insertUpdate(javax.swing.event.DocumentEvent documentEvent)
+ {
+ saveButton.setEnabled( true );
+ cancelButton.setEnabled( true );
+ }
+
+ public void removeUpdate(javax.swing.event.DocumentEvent documentEvent)
+ {
+ saveButton.setEnabled( true );
+ cancelButton.setEnabled( true );
+ }
+
+ protected void save()
+ {
+ Properties props = new Properties();
+ try
+ {
+ OutputStream out = new FileOutputStream( PROPERTIES_FILE );
+ String auxSI = servidorInternoText.getText();
+ String auxSE = servidorExternoText.getText();
+ String auxI = intervaloText.getText();;
+ if( auxSI == null || auxSI.length() == 0 ||
+ auxSE == null || auxSE.length() == 0 ||
+ auxI == null || auxI.length() == 0 )
+ {
+ throw new Exception( "" );
+ }
+ intervalo = Long.parseLong( auxI );
+ servidorInterno = auxSI;
+ servidorExterno = auxSE;
+ props.setProperty( PROP_LOCAL, servidorInterno );
+ props.setProperty( PROP_LOCAL_U, internalUser );
+ props.setProperty( PROP_LOCAL_P, internalPassword );
+ props.setProperty( PROP_REMOTE, servidorExterno );
+ props.setProperty( PROP_REMOTE_U, externalUser );
+ props.setProperty( PROP_REMOTE_P, externalPassword );
+ props.setProperty( PROP_INTERVAL, "" + intervalo );
+ props.store( out, "Configura\u00e7\u00e3o da Ferramenta de Actualiza\u00e7\u00e3o da SIPRP" );
+ out.close();
+ }
+ catch( Exception ex )
+ {
+ JOptionPane.showMessageDialog( this, "Erro a gravar altera\u00e7\u00f5es", "Erro",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ }
+
+ protected void reload()
+ {
+ Properties props = new Properties();
+ try
+ {
+
+System.out.println( new File( PROPERTIES_FILE ) );
+ InputStream in = new FileInputStream( PROPERTIES_FILE );
+ props.load( in );
+ internalUser = props.getProperty( PROP_LOCAL_U );
+ internalPassword = props.getProperty( PROP_LOCAL_P );
+ externalUser = props.getProperty( PROP_REMOTE_U );
+ externalPassword = props.getProperty( PROP_REMOTE_P );
+
+ String aux;
+ aux = props.getProperty( PROP_LOCAL );
+ if( aux != null && aux.length() > 0 )
+ {
+ servidorInterno = aux;
+ }
+ aux = props.getProperty( PROP_REMOTE );
+ if( aux != null && aux.length() > 0 )
+ {
+ servidorExterno = aux;
+ }
+ aux = props.getProperty( PROP_INTERVAL );
+ if( aux != null && aux.length() > 0 )
+ {
+ try
+ {
+ intervalo = Long.parseLong( aux );
+ }
+ catch( NumberFormatException nfe )
+ {
+ }
+ }
+
+ }
+ catch( Exception ex )
+ {
+ JOptionPane.showMessageDialog( this, "Erro a carregar os dados", "Erro",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ servidorInternoText.setText( servidorInterno );
+ servidorExternoText.setText( servidorExterno );
+ intervaloText.setText( "" + intervalo );
+ }
+
+ public void run()
+ {
+ running = true;
+ while( true )
+ {
+ boolean erro = false;
+ if( !running )
+ {
+ return;
+ }
+ proximaActualizacaoText.setText( "" );
+ try
+ {
+ stateLabel.setText( "A Actualizar" );
+ stateLabel.setForeground( Color.green );
+ doUpdates();
+ java.util.Date date = new java.util.Date();
+ ultimaActualizacaoText.setText( date.toString() );
+ }
+ catch( Exception ex )
+ {
+ erro = true;
+ stateLabel.setText( "ERRO A ACTUALIZAR!!!" );
+ stateLabel.setForeground( Color.red );
+ }
+ if( !running )
+ {
+ return;
+ }
+ try
+ {
+ if( !erro )
+ {
+ stateLabel.setText( "Em Intervalo (" + intervalo + " minuto" + ( intervalo > 1 ? "s" : "" ) + ")" );
+ stateLabel.setForeground( Color.black );
+ }
+ Calendar cal = Calendar.getInstance();
+ cal.add( Calendar.MINUTE, (int)intervalo );
+ proximaActualizacaoText.setText( "" + cal.getTime() );
+ Thread.sleep( intervalo * 60000 );
+ }
+ catch( InterruptedException iex )
+ {
+ }
+ }
+ }
+
+ protected void doUpdates()
+ throws Exception
+ {
+ try
+ {
+ connect();
+ getData();
+ updateData();
+ }
+ catch( Exception ex )
+ {
+ ex.printStackTrace();
+ throw ex;
+ }
+
+ }
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main( String[] args )
+ throws Exception
+ {
+ WebUpdater updater = new WebUpdater();
+ updater.show();
+ }
+
+ protected void connect()
+ throws Exception
+ {
+ Class.forName( "org.postgresql.Driver" );
+ Class.forName( "com.mysql.jdbc.Driver" );
+ webConnection = DriverManager.getConnection( "jdbc:postgresql://" + servidorExterno + "/siprp", externalUser, externalPassword );
+ webConnection.setAutoCommit( true );
+ softwareConnection = DriverManager.getConnection( "jdbc:mysql://" + servidorInterno + "/siprp", internalUser, internalPassword );
+// softwareConnection = DriverManager.getConnection( "jdbc:postgresql://" + servidorInterno + "/siprp", internalUser, internalPassword );
+ softwareConnection.setAutoCommit( true );
+ }
+
+ protected void getData()
+ throws Exception
+ {
+ Object r[][];
+ r = doQuery( webConnection, GET_ULTIMA_ACTUALIZACAO );
+ String actualizacao = "'" + r[0][0] + "'";
+ Calendar cal = Calendar.getInstance();
+ //int hour = cal.get( Calendar.HOUR_OF_DAY );
+ //if( hour < 3 && hour > 1 )
+ //{
+ // actualizacao = "'1970-01-01 00:00:00'";
+ //}
+ doQuery(softwareConnection, "DELETE FROM actualizacao;", true);
+ doQuery(softwareConnection, "INSERT INTO actualizacao(hora) VALUES(now());", true);
+ readTrabalhadores( actualizacao );
+ readEstabelecimentos( actualizacao );
+ readEmpresas( actualizacao );
+ }
+
+ protected void updateData()
+ throws Exception
+ {
+ System.out.println( "DELETES" );
+ for( int d = 0; d < deletes.size(); d++ )
+ {
+ try
+ {
+ System.out.println( deletes.elementAt( d ).toString() );
+ doQuery( webConnection, deletes.elementAt( d ).toString(), true );
+ }
+ catch( Exception ex )
+ {
+ ex.printStackTrace();
+ }
+ }
+ System.out.println( "" );
+ System.out.println( "UPDATES" );
+ for( int u = 0; u < updates.size(); u++ )
+ {
+ String queries[] = ( String[] ) updates.elementAt( u );
+ System.out.println( queries[ 0 ] + "\n " + queries[ 1 ] );
+ try
+ {
+ doQuery( webConnection, queries[ 0 ], true );
+ }
+ catch( Exception ex )
+ {
+ System.out.println( " ERRO DE INSERT" );
+ }
+ try
+ {
+ doQuery( webConnection, queries[ 1 ], true );
+ }
+ catch( Exception ex )
+ {
+ ex.printStackTrace();
+ }
+ }
+ Object r[][] = doQuery( softwareConnection, "SELECT hora FROM actualizacao;" );
+ String actualizacao = "'" + r[0][0] + "'";
+ doQuery( webConnection, UPDATE_ACTUALIZACAO + actualizacao, true );
+ }
+
+ protected void readTrabalhadores( String actualizacao )
+ throws Exception
+ {
+ Object trabalhadores[][] = doQuery( softwareConnection, GET_TRABALHADORES + actualizacao );
+ for( int t = 0; t < trabalhadores.length; t++ )
+ {
+ for( int c = 0; c < trabalhadores[ t ].length; c++ )
+ {
+ if( trabalhadores[ t ][ c ] instanceof String )
+ {
+ trabalhadores[ t ][ c ] = unicodeToHTML( (String) trabalhadores[ t ][ c ] );
+ }
+ }
+ int id = ( ( Number ) trabalhadores[t][0] ).intValue();
+ boolean inactivo = "y".equals( trabalhadores[ t ][ trabalhadores[ t ].length - 1 ] ) ||
+ trabalhadores[ t ][ trabalhadores[ t ].length - 2 ] != null;
+ if( inactivo )
+ {
+ deletes.add( DELETE_TRABALHADOR + id );
+ continue;
+ }
+ String queries[] = new String[ 2 ];
+ updates.insertElementAt( queries, 0 );
+ queries[ 0 ] = CREATE_TRABALHADOR.replaceFirst( "[?]id", "" + id );
+ String update = UPDATE_TRABALHADOR.replaceFirst( "[?]id", "" + id );
+
+ String nome = "'" + trabalhadores[ t ][ 1 ] + "'";
+ update = update.replaceFirst( "[?]nome", nome );
+ String sexo = "'" + trabalhadores[ t ][ 2 ] + "'";
+ update = update.replaceFirst( "[?]sexo", sexo );
+ String dataNasc;
+ if( trabalhadores[ t ][ 3 ] != null )
+ {
+ dataNasc = "'" + trabalhadores[ t ][ 3 ] + "'";
+ }
+ else
+ {
+ dataNasc = "''";
+ }
+ update = update.replaceFirst( "[?]data_nascimento", dataNasc );
+ String numeroMecanografico;
+ if( trabalhadores[ t ][ 4 ] != null )
+ {
+ numeroMecanografico = "'" + trabalhadores[ t ][ 4 ] + "'";
+ }
+ else
+ {
+ numeroMecanografico = "''";
+ }
+ update = update.replaceFirst( "[?]numero_mecanografico", numeroMecanografico );
+ String categoria;
+ if( trabalhadores[ t ][ 5 ] != null )
+ {
+ categoria = "'" + trabalhadores[ t ][ 5 ] + "'";
+ }
+ else
+ {
+ categoria = "''";
+ }
+ update = update.replaceFirst( "[?]categoria", categoria );
+ int estabelecimentoID = ( ( Number ) trabalhadores[t][6] ).intValue();
+ update = update.replaceFirst( "[?]estabelecimento_id", "" + estabelecimentoID );
+ Object exames[][] = doQuery( softwareConnection,
+ GET_EXAMES_TRABALHADOR.replaceFirst( "[?]trabalhador_id", ""+id ) );
+
+ if( exames != null && exames.length > 0 )
+ {
+ java.util.Date dataExame2 = ( java.util.Date ) exames[ exames.length - 1 ] [ 1 ];
+ String realizado2 = ( String ) exames[ exames.length - 1 ][ 2 ];
+ java.util.Date dataExame1;
+ String realizado1;
+ if( exames.length >= 2 )
+ {
+ dataExame1 = ( java.util.Date ) exames[ exames.length - 2 ] [ 1 ];
+ realizado1 = ( String ) exames[ exames.length - 2 ][ 2 ];
+ }
+ else
+ {
+ dataExame1 = dataExame2;
+ realizado1 = realizado2;
+ }
+ if( "y".equals( realizado2 ) )
+ {
+ update = update.replaceFirst( "[?]ultimo_exame", "'" + dataExame2 + "'" );
+ update = update.replaceFirst( "[?]realizado", "'" + realizado2 + "'" );
+ update = update.replaceFirst( "[?]proximo_exame", "null" );
+ }
+ else if( new java.util.Date().after( dataExame2 ) )
+ {
+ update = update.replaceFirst( "[?]ultimo_exame", "'" + dataExame2 + "'" );
+ update = update.replaceFirst( "[?]realizado", "'" + realizado2 + "'" );
+ update = update.replaceFirst( "[?]proximo_exame", "null" );
+ }
+ else
+ {
+ update = update.replaceFirst( "[?]proximo_exame", "'" + dataExame2 + "'" );
+ if( !dataExame2.equals( dataExame1 ) )
+ {
+ update = update.replaceFirst( "[?]ultimo_exame", "'" + dataExame1 + "'" );
+ update = update.replaceFirst( "[?]realizado", "'" + realizado1 + "'" );
+ }
+ else
+ {
+ update = update.replaceFirst( "[?]ultimo_exame", "null" );
+ update = update.replaceFirst( "[?]realizado", "null" );
+ }
+ }
+ }
+ else
+ {
+ update = update.replaceFirst( "[?]ultimo_exame", "null" );
+ update = update.replaceFirst( "[?]realizado", "null" );
+ update = update.replaceFirst( "[?]proximo_exame", "null" );
+ }
+ Object consultas[][] = doQuery( softwareConnection,
+ GET_CONSULTAS_TRABALHADOR.replaceFirst( "[?]trabalhador_id", ""+id ) );
+
+ if( consultas != null && consultas.length > 0 )
+ {
+ java.util.Date dataConsulta2 = ( java.util.Date ) consultas[ consultas.length - 1 ] [ 1 ];
+ String realizada2 = ( String ) consultas[ consultas.length - 1 ][ 2 ];
+ java.util.Date dataConsulta1;
+ java.util.Date dataRelatorio1;
+ java.util.Date dataRelatorio2 = (java.util.Date) consultas[ consultas.length - 1 ][ 3 ];
+ String realizada1;
+ if( consultas.length >= 2 )
+ {
+ dataConsulta1 = ( java.util.Date ) consultas[ consultas.length - 2 ] [ 1 ];
+ realizada1 = ( String ) consultas[ consultas.length - 2 ][ 2 ];
+ dataRelatorio1 = (java.util.Date) consultas[ consultas.length - 2 ][ 3 ];
+ }
+ else
+ {
+ dataConsulta1 = dataConsulta2;
+ realizada1 = realizada2;
+ dataRelatorio1 = dataRelatorio2;
+ }
+ if( "y".equals( realizada2 ) )
+ {
+ update = update.replaceFirst( "[?]ultima_consulta", "'" + dataConsulta2 + "'" );
+ update = update.replaceFirst( "[?]realizada", "'" + realizada2 + "'" );
+ update = update.replaceFirst( "[?]proxima_consulta", "null" );
+ if( dataRelatorio2 != null )
+ {
+ update = update.replaceFirst( "[?]data_ficha", "'" + dataRelatorio2 + "'" );
+ }
+ else
+ {
+ update = update.replaceFirst( "[?]data_ficha", "null" );
+ }
+ }
+ else if( new java.util.Date().after( dataConsulta2 ) )
+ {
+ update = update.replaceFirst( "[?]ultima_consulta", "'" + dataConsulta2 + "'" );
+ update = update.replaceFirst( "[?]realizada", "'" + realizada2 + "'" );
+ update = update.replaceFirst( "[?]proxima_consulta", "null" );
+ if( dataRelatorio2 != null )
+ {
+ update = update.replaceFirst( "[?]data_ficha", "'" + dataRelatorio2 + "'" );
+ }
+ else
+ {
+ update = update.replaceFirst( "[?]data_ficha", "null" );
+ }
+ }
+ else
+ {
+ update = update.replaceFirst( "[?]proxima_consulta", "'" + dataConsulta2 + "'" );
+ if( !dataConsulta2.equals( dataConsulta1 ) )
+ {
+ update = update.replaceFirst( "[?]ultima_consulta", "'" + dataConsulta1 + "'" );
+ update = update.replaceFirst( "[?]realizada", "'" + realizada1 + "'" );
+ if( dataRelatorio1 != null )
+ {
+ update = update.replaceFirst( "[?]data_ficha", "'" + dataRelatorio1 + "'" );
+ }
+ else
+ {
+ update = update.replaceFirst( "[?]data_ficha", "null" );
+ }
+ }
+ else
+ {
+ update = update.replaceFirst( "[?]ultima_consulta", "null" );
+ update = update.replaceFirst( "[?]realizada", "null" );
+ update = update.replaceFirst( "[?]data_ficha", "null" );
+ }
+ }
+ }
+ else
+ {
+ update = update.replaceFirst( "[?]ultima_consulta", "null" );
+ update = update.replaceFirst( "[?]realizada", "null" );
+ update = update.replaceFirst( "[?]proxima_consulta", "null" );
+ update = update.replaceFirst( "[?]data_ficha", "null" );
+
+ }
+ Object fichas[][] = doQuery( softwareConnection,
+ GET_ID_FICHA_APTIDAO.replaceFirst( "[?]trabalhador_id", ""+id ) );
+ if( fichas != null && fichas.length > 0 && fichas[0].length > 0 && fichas[0][0] != null )
+ {
+ Integer idFicha = (Integer)fichas[0][0];
+ fichas = doQuery( softwareConnection,
+ GET_DADOS_FICHA_APTIDAO.replaceFirst( "[?]id", "" + idFicha ) );
+ java.util.Date dataFicha = ( java.util.Date ) fichas[ 0 ][ 0 ];
+ /*if( dataFicha != null )
+ {
+ update = update.replaceFirst( "[?]data_ficha", "null" );
+ }
+ else
+ {
+ update = update.replaceFirst( "[?]data_ficha", "'" + dataFicha + "'" );
+ }*/
+ Integer resultadoFicha = (Integer) fichas[ 0 ][ 1 ];
+ if( resultadoFicha != null )
+ {
+ switch( resultadoFicha.intValue() )
+ {
+ case 1:
+ update = update.replaceFirst( "[?]resultado", "'Apto'" );
+ break;
+ case 2:
+ update = update.replaceFirst( "[?]resultado", "'Apto Condicionalmente'" );
+ break;
+ case 3:
+ update = update.replaceFirst( "[?]resultado", "'Inapto Temporariamente'" );
+ break;
+ case 4:
+ update = update.replaceFirst( "[?]resultado", "'Inapto Definitivamente'" );
+ break;
+ default:
+ update = update.replaceFirst( "[?]resultado", "null" );
+ }
+ }
+ else
+ {
+ update = update.replaceFirst( "[?]resultado", "null" );
+ }
+ }
+ else
+ {
+ update = update.replaceFirst( "[?]data_ficha", "null" );
+ update = update.replaceFirst( "[?]resultado", "null" );
+ }
+
+ queries[ 1 ] = update;
+
+ }
+ }
+
+ protected void readEstabelecimentos( String actualizacao )
+ throws Exception
+ {
+ Object estabelecimentos[][] = doQuery( softwareConnection, GET_ESTABELECIMENTOS + actualizacao );
+ //id, empresa_id, nome, contacto, inactivo
+ for( int t = 0; t < estabelecimentos.length; t++ )
+ {
+ for( int c = 0; c < estabelecimentos[ t ].length; c++ )
+ {
+ if( estabelecimentos[ t ][ c ] instanceof String )
+ {
+ estabelecimentos[ t ][ c ] = unicodeToHTML( (String) estabelecimentos[ t ][ c ] );
+ }
+ }
+ int id = ( ( Number ) estabelecimentos[t][0] ).intValue();
+ boolean inactivo = "y".equals( estabelecimentos[ t ][ estabelecimentos[ t ].length - 1 ] );
+ if( inactivo )
+ {
+ deletes.add( DELETE_TRABALHADORES_BY_ESTABELECIMENTO + id );
+ deletes.add( DELETE_ESTABELECIMENTO + id );
+ continue;
+ }
+ String queries[] = new String[ 2 ];
+ updates.insertElementAt( queries, 0 );
+ queries[ 0 ] = CREATE_ESTABELECIMENTO.replaceFirst( "[?]id", "" + id );
+ String update = UPDATE_ESTABELECIMENTO.replaceFirst( "[?]id", "" + id );
+
+ int empresaID = ( ( Number ) estabelecimentos[t][1] ).intValue();
+ update = update.replaceFirst( "[?]empresa_id", "" + empresaID );
+ String nome = "'" + estabelecimentos[ t ][ 2 ] + "'";
+ update = update.replaceFirst( "[?]nome", nome );
+ String morada;
+ if( estabelecimentos[ t ][ 4 ] != null )
+ {
+ morada = "'" + estabelecimentos[ t ][ 4 ] + "'";
+ }
+ else
+ {
+ morada = "''";
+ }
+ update = update.replaceFirst( "[?]morada", morada );
+ String localidade;
+ if( estabelecimentos[ t ][ 5 ] != null )
+ {
+ localidade = "'" + estabelecimentos[ t ][ 5 ] + "'";
+ }
+ else
+ {
+ localidade = "''";
+ }
+ update = update.replaceFirst( "[?]localidade", localidade );
+ String codigoPostal;
+ if( estabelecimentos[ t ][ 6 ] != null )
+ {
+ codigoPostal = "'" + estabelecimentos[ t ][ 6 ] + "'";
+ }
+ else
+ {
+ codigoPostal = "''";
+ }
+ update = update.replaceFirst( "[?]codigo_postal", codigoPostal );
+
+ Object marcacoes[][] = doQuery( softwareConnection,
+ GET_MARCACOES_ESTABELECIMENTO +id );
+
+ if( marcacoes != null && marcacoes.length > 0 )
+ {
+ java.util.Date dataConsulta2 = ( java.util.Date ) marcacoes[ marcacoes.length - 1 ] [ 1 ];
+ String realizada2 = ( String ) marcacoes[ marcacoes.length - 1 ][ 2 ];
+ java.util.Date dataConsulta1;
+ String realizada1;
+ if( marcacoes.length >= 2 )
+ {
+ dataConsulta1 = ( java.util.Date ) marcacoes[ marcacoes.length - 2 ] [ 1 ];
+ realizada1 = ( String ) marcacoes[ marcacoes.length - 2 ][ 2 ];
+ }
+ else
+ {
+ dataConsulta1 = dataConsulta2;
+ realizada1 = realizada2;
+ }
+ if( "y".equals( realizada2 ) )
+ {
+ update = update.replaceFirst( "[?]ultima_visita", "'" + dataConsulta2 + "'" );
+ update = update.replaceFirst( "[?]realizada", "'" + realizada2 + "'" );
+ update = update.replaceFirst( "[?]proxima_visita", "null" );
+ }
+ else if( new java.util.Date().after( dataConsulta2 ) )
+ {
+ update = update.replaceFirst( "[?]ultima_visita", "'" + dataConsulta2 + "'" );
+ update = update.replaceFirst( "[?]realizada", "'" + realizada2 + "'" );
+ update = update.replaceFirst( "[?]proxima_visita", "null" );
+ }
+ else
+ {
+ update = update.replaceFirst( "[?]proxima_visita", "'" + dataConsulta2 + "'" );
+ if( !dataConsulta2.equals( dataConsulta1 ) )
+ {
+ update = update.replaceFirst( "[?]ultima_visita", "'" + dataConsulta1 + "'" );
+ update = update.replaceFirst( "[?]realizada", "'" + realizada2 + "'" );
+ }
+ else
+ {
+ update = update.replaceFirst( "[?]ultima_visita", "null" );
+ update = update.replaceFirst( "[?]realizada", "null" );
+ }
+ }
+ }
+ else
+ {
+ update = update.replaceFirst( "[?]ultima_visita", "null" );
+ update = update.replaceFirst( "[?]realizada", "null" );
+ update = update.replaceFirst( "[?]proxima_visita", "null" );
+ }
+
+ queries[ 1 ] = update;
+ }
+ }
+
+ protected void readEmpresas( String actualizacao )
+ throws Exception
+ {
+ Object empresas[][] = doQuery( softwareConnection, GET_EMPRESAS + actualizacao );
+ //id, empresa_id, nome, contacto, inactivo
+ for( int t = 0; t < empresas.length; t++ )
+ {
+ for( int c = 0; c < empresas[ t ].length; c++ )
+ {
+ if( empresas[ t ][ c ] instanceof String )
+ {
+ empresas[ t ][ c ] = unicodeToHTML( (String) empresas[ t ][ c ] );
+ }
+ }
+ int id = ( ( Number ) empresas[t][0] ).intValue();
+ boolean inactivo = "y".equals( empresas[ t ][ 17 ] );
+ if( inactivo )
+ {
+ String str = DELETE_TRABALHADORES_BY_EMPRESA.replaceFirst( "[?]empresa_id", "" + id );
+ deletes.add( str );
+ deletes.add( DELETE_ESTABELECIMENTOS_BY_EMPRESA + id );
+ deletes.add( DELETE_EMPRESA + id );
+ continue;
+ }
+ String queries[] = new String[ 2 ];
+ updates.insertElementAt( queries, 0 );
+ queries[ 0 ] = CREATE_EMPRESA.replaceFirst( "[?]id", "" + id );
+ String update = UPDATE_EMPRESA.replaceFirst( "[?]id", "" + id );
+
+ String designacaoSocial = "'" + empresas[ t ][ 1 ] + "'";
+ update = update.replaceFirst( "[?]designacao_social", designacaoSocial );
+ String cae;
+ if( empresas[ t ][ 7 ] != null )
+ {
+ cae = "'" + empresas[ t ][ 7 ] + "'";
+ }
+ else
+ {
+ cae = "''";
+ }
+ update = update.replaceFirst( "[?]cae", cae );
+ String contribuinte;
+ if( empresas[ t ][ 8 ] != null )
+ {
+ contribuinte = "'" + empresas[ t ][ 8 ] + "'";
+ }
+ else
+ {
+ contribuinte = "''";
+ }
+ update = update.replaceFirst( "[?]contribuinte", contribuinte );
+ String segurancaSocial;
+ if( empresas[ t ][ 9 ] != null )
+ {
+ segurancaSocial = "'" + empresas[ t ][ 9 ] + "'";
+ }
+ else
+ {
+ segurancaSocial = "''";
+ }
+ update = update.replaceFirst( "[?]seguranca_social", segurancaSocial );
+ String actividade;
+ if( empresas[ t ][ 10 ] != null )
+ {
+ actividade = "'" + empresas[ t ][ 10 ] + "'";
+ }
+ else
+ {
+ actividade = "''";
+ }
+ update = update.replaceFirst( "[?]actividade", actividade );
+ String morada;
+ if( empresas[ t ][ 12 ] != null )
+ {
+ morada = "'" + empresas[ t ][ 12 ] + "'";
+ }
+ else
+ {
+ morada = "''";
+ }
+ update = update.replaceFirst( "[?]morada", morada );
+ String localidade;
+ if( empresas[ t ][ 13 ] != null )
+ {
+ localidade = "'" + empresas[ t ][ 13 ] + "'";
+ }
+ else
+ {
+ localidade = "''";
+ }
+ update = update.replaceFirst( "[?]localidade", localidade );
+ String codigoPostal;
+ if( empresas[ t ][ 14 ] != null )
+ {
+ codigoPostal = "'" + empresas[ t ][ 14 ] + "'";
+ }
+ else
+ {
+ codigoPostal = "''";
+ }
+ update = update.replaceFirst( "[?]codigo_postal", codigoPostal );
+ String distrito;
+ if( empresas[ t ][ 15 ] != null )
+ {
+ distrito = "'" + empresas[ t ][ 15 ] + "'";
+ }
+ else
+ {
+ distrito = "''";
+ }
+ update = update.replaceFirst( "[?]distrito", distrito );
+ String concelho;
+ if( empresas[ t ][ 16 ] != null )
+ {
+ concelho = "'" + empresas[ t ][ 16 ] + "'";
+ }
+ else
+ {
+ concelho = "''";
+ }
+ update = update.replaceFirst( "[?]concelho", concelho );
+ String email = null;
+ if( empresas[ t ][ 18 ] != null )
+ {
+ try
+ {
+ Object em[][] = doQuery( softwareConnection, GET_EMAIL + empresas[ t ][ 18 ] );
+ if( em != null && em.length > 0 && em[ 0 ][ 0 ] != null )
+ {
+ email = "'" + (String)em[ 0 ][ 0 ] + "'";
+ }
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+ if( email == null )
+ {
+ email = "''";
+ }
+ update = update.replaceFirst( "[?]email", email );
+
+ String codigo1 = (String) empresas[ t ][ 4 ];
+ String codigo2 = (String) empresas[ t ][ 5 ];
+ String codigo3 = (String) empresas[ t ][ 6 ];
+ String codigo = "'" + ( codigo1 != null ? codigo1 : "_" ) + "/"
+ + ( codigo2 != null ? codigo2 : "_" ) + "/"
+ + ( codigo3 != null ? codigo3 : "_" ) + "'";
+ update = update.replaceFirst( "[?]codigo", codigo );
+ update = update.replaceFirst( "[?]perfil_1", "null" );
+ update = update.replaceFirst( "[?]perfil_2", "null" );
+ update = update.replaceFirst( "[?]perfil_3", "null" );
+ update = update.replaceFirst( "[?]servicos", "null" );
+
+ queries[ 1 ] = update;
+ }
+ }
+
+ protected Object [][]doQuery( Connection con, String query )
+ throws Exception
+ {
+ return doQuery( con, query, false );
+ }
+
+ protected Object [][]doQuery( Connection con, String query, boolean isUpdate )
+ throws Exception
+ {
+// if( con == webConnection )
+// {
+// System.out.println( "WEB" );
+// }
+// else
+// {
+// System.out.println( "LOCAL" );
+// }
+// if( query.indexOf( "INSERT" ) != -1 || query.indexOf( "UPDATE" ) != -1 )
+// {
+//// System.out.println( "AAAAAAAAAAAAAHHHHHHH" + query );
+// return new Object[0][0];
+// }
+ Statement stm = null;
+ stm = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE,
+ ResultSet.CONCUR_READ_ONLY );
+ if( isUpdate )
+ {
+ stm.executeUpdate( query );
+ return null;
+ }
+ ResultSet rs = stm.executeQuery( query );
+
+ if( rs == null )
+ {
+ return null;
+ }
+ ResultSetMetaData rsmd = rs.getMetaData();
+ int columns = rsmd.getColumnCount();
+ rs.last();
+ int rows = rs.getRow();
+ Object data[][] = new Object[ rows ][ columns ];
+ for( int i = 0; i < rows; ++i )
+ {
+ rs.absolute( i + 1 );
+ for( int j = 0; j < columns; j++ )
+ {
+ data[ i ][ j ] = rs.getObject( j + 1 );
+ }
+ }
+ return data;
+ }
+
+ protected static String unicodeToHTML( String text )
+ {
+ if( text == null || text.length() == 0 )
+ {
+ return "";
+ }
+
+ String output = text;
+
+ output = output.replaceAll( "\\\\u0009", " " );
+ output = output.replaceAll( "\\\\u000a", "
" );
+
+ output = output.replaceAll( "\\\\u00a0", " " );
+
+ output = output.replaceAll( "\\\\u00c0", "À" );
+ output = output.replaceAll( "\\\\u00c1", "Á" );
+ output = output.replaceAll( "\\\\u00c2", "Â" );
+ output = output.replaceAll( "\\\\u00c3", "Ã" );
+ output = output.replaceAll( "\\\\u00c7", "Ç" );
+ output = output.replaceAll( "\\\\u00c8", "È" );
+ output = output.replaceAll( "\\\\u00c9", "É" );
+ output = output.replaceAll( "\\\\u00ca", "Ê" );
+ output = output.replaceAll( "\\\\u00cc", "Ì" );
+ output = output.replaceAll( "\\\\u00cd", "Í" );
+ output = output.replaceAll( "\\\\u00ce", "Î" );
+ output = output.replaceAll( "\\\\u00d2", "Ò" );
+ output = output.replaceAll( "\\\\u00d3", "Ó" );
+ output = output.replaceAll( "\\\\u00d4", "Ô" );
+ output = output.replaceAll( "\\\\u00d5", "Õ" );
+ output = output.replaceAll( "\\\\u00d9", "Ù" );
+ output = output.replaceAll( "\\\\u00da", "Ú" );
+ output = output.replaceAll( "\\\\u00db", "Û" );
+
+ output = output.replaceAll( "\\\\u00e0", "à" );
+ output = output.replaceAll( "\\\\u00e1", "á" );
+ output = output.replaceAll( "\\\\u00e2", "â" );
+ output = output.replaceAll( "\\\\u00e3", "ã" );
+ output = output.replaceAll( "\\\\u00e7", "ç" );
+ output = output.replaceAll( "\\\\u00e8", "è" );
+ output = output.replaceAll( "\\\\u00e9", "é" );
+ output = output.replaceAll( "\\\\u00ea", "ê" );
+ output = output.replaceAll( "\\\\u00ec", "ì" );
+ output = output.replaceAll( "\\\\u00ed", "í" );
+ output = output.replaceAll( "\\\\u00ee", "î" );
+ output = output.replaceAll( "\\\\u00f2", "ò" );
+ output = output.replaceAll( "\\\\u00f3", "ó" );
+ output = output.replaceAll( "\\\\u00f4", "ô" );
+ output = output.replaceAll( "\\\\u00f5", "õ" );
+ output = output.replaceAll( "\\\\u00f9", "ù" );
+ output = output.replaceAll( "\\\\u00fa", "ú" );
+ output = output.replaceAll( "\\\\u00fb", "û" );
+ output = output.replaceAll( "\\\\u00aa", "ª" );
+ output = output.replaceAll( "\\\\u00ba", "º" );
+
+ output = output.replaceAll( "\\\\u0153", "" );
+
+ output = output.replaceAll( "\\\\u2013", "-" );
+ output = output.replaceAll( "\\\\u2014", "-" );
+ output = output.replaceAll( "\\\\u2018|\\\\u2019", "'" );
+ output = output.replaceAll( "\\\\u201c|\\\\u201d", "\"" );
+
+ output = output.replaceAll( "\\\\u2022", "*" );
+ output = output.replaceAll( "\\\\u2026", "..." );
+
+ return output;
+ }
+
+
+}
diff --git a/trunk/siprp_create.sql b/trunk/siprp_create.sql
new file mode 100644
index 00000000..56b89f27
--- /dev/null
+++ b/trunk/siprp_create.sql
@@ -0,0 +1,569 @@
+--
+-- PostgreSQL database dump
+--
+
+SET client_encoding = 'LATIN1';
+SET check_function_bodies = false;
+SET client_min_messages = warning;
+
+
+--
+-- Name: actualizacao; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
+--
+
+CREATE TABLE actualizacao (
+ hora timestamp without time zone,
+ id serial NOT NULL
+);
+
+
+ALTER TABLE public.actualizacao OWNER TO postgres;
+
+--
+-- Name: avisos; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
+--
+
+CREATE TABLE avisos (
+ id integer NOT NULL,
+ tipo integer DEFAULT 0 NOT NULL,
+ empresa_id integer,
+ estabelecimento_id integer,
+ trabalhador_id integer,
+ evento_id integer,
+ data_aviso date NOT NULL,
+ data_evento date,
+ descricao character varying(255)
+);
+
+
+ALTER TABLE public.avisos OWNER TO postgres;
+
+--
+-- Name: contactos; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
+--
+
+CREATE TABLE contactos (
+ id integer NOT NULL,
+ nome character varying(255),
+ telefone character varying(255),
+ telemovel character varying(255),
+ fax character varying(255),
+ email character varying(255),
+ cargo character varying(255)
+);
+
+
+ALTER TABLE public.contactos OWNER TO postgres;
+
+--
+-- Name: empresas; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
+--
+
+CREATE TABLE empresas (
+ id integer NOT NULL,
+ designacao_social character varying(255) DEFAULT ''::character varying NOT NULL,
+ servico_saude_tipo integer,
+ servico_saude_designacao character varying(255) DEFAULT 'Sociedade Ibu00e9rica de Prevenu00e7u00e3o de Riscos Profissionais'::character varying,
+ servico_higiene_tipo integer,
+ servico_higiene_designacao character varying(255),
+ inactivo character(1) DEFAULT 'n'::bpchar NOT NULL,
+ morada character varying(255),
+ codigo_postal character varying(8),
+ localidade character varying(255),
+ distrito character varying(255),
+ concelho character varying(255),
+ numero_trabalhadores integer,
+ data_proposta date,
+ data_aceitacao date,
+ perfil_1 character varying(255),
+ perfil_2 character varying(255),
+ data_envio_contrato date,
+ data_recepcao_contrato date,
+ data_envio_idict date,
+ cae character varying(255),
+ contribuinte character varying(255),
+ seguranca_social character varying(255),
+ codigo_1 character varying(255),
+ codigo_2 character varying(255),
+ codigo_3 character varying(255),
+ servicos integer,
+ contacto_1 integer,
+ contacto_2 integer,
+ data_relatorio_anual date,
+ preco_higiene double precision,
+ preco_medicina double precision,
+ periodicidade character varying(255),
+ actividade character varying(255),
+ actualizacao timestamp without time zone,
+ designacao_social_plain character varying(255)
+);
+
+
+ALTER TABLE public.empresas OWNER TO postgres;
+
+--
+-- Name: errors; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
+--
+
+CREATE TABLE errors (
+ id integer NOT NULL,
+ date timestamp without time zone,
+ "type" character varying(20),
+ environment character varying(255),
+ description character varying(65535)
+);
+
+
+ALTER TABLE public.errors OWNER TO postgres;
+
+--
+-- Name: estabelecimentos; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
+--
+
+CREATE TABLE estabelecimentos (
+ id integer NOT NULL,
+ nome character varying(255) DEFAULT ''::character varying NOT NULL,
+ localidade character varying(255),
+ inactivo character(1) DEFAULT 'n'::bpchar NOT NULL,
+ empresa_id integer DEFAULT 0 NOT NULL,
+ morada character varying(255),
+ codigo_postal character varying(255),
+ contacto character varying(255),
+ historico character varying(65535),
+ actualizacao timestamp without time zone,
+ nome_plain character varying(255)
+);
+
+
+ALTER TABLE public.estabelecimentos OWNER TO postgres;
+
+--
+-- Name: exames; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
+--
+
+CREATE TABLE exames (
+ id integer NOT NULL,
+ data date,
+ tipo integer DEFAULT 0 NOT NULL,
+ ocasional integer,
+ outro_tipo character varying(255),
+ resultado integer,
+ outra_funcao_1 character varying(255),
+ outra_funcao_2 character varying(255),
+ outra_funcao_3 character varying(255),
+ outra_funcao_4 character varying(255),
+ proximo_exame date,
+ outras_recomendacoes character varying(65535),
+ inactivo character(1) DEFAULT 'n'::bpchar NOT NULL,
+ trabalhador_id integer DEFAULT 0 NOT NULL,
+ medico_id integer DEFAULT 0 NOT NULL,
+ pdf bytea
+);
+
+
+ALTER TABLE public.exames OWNER TO postgres;
+
+--
+-- Name: exames_perfis; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
+--
+
+CREATE TABLE exames_perfis (
+ id integer NOT NULL,
+ perfil integer DEFAULT 0 NOT NULL,
+ tipo integer DEFAULT 0 NOT NULL,
+ multiplicador integer DEFAULT 0 NOT NULL
+);
+
+
+ALTER TABLE public.exames_perfis OWNER TO postgres;
+
+--
+-- Name: historico_estabelecimento; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
+--
+
+CREATE TABLE historico_estabelecimento (
+ id integer NOT NULL,
+ estabelecimento_id integer DEFAULT 0 NOT NULL,
+ data date,
+ texto character varying(65535)
+);
+
+
+ALTER TABLE public.historico_estabelecimento OWNER TO postgres;
+
+--
+-- Name: ids; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
+--
+
+CREATE TABLE ids (
+ id integer NOT NULL
+);
+
+
+ALTER TABLE public.ids OWNER TO postgres;
+
+--
+-- Name: marcacoes_empresa; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
+--
+
+CREATE TABLE marcacoes_empresa (
+ id integer NOT NULL,
+ data date NOT NULL,
+ texto character varying(65535),
+ empresa_id integer DEFAULT 0 NOT NULL,
+ realizada character(1)
+);
+
+
+ALTER TABLE public.marcacoes_empresa OWNER TO postgres;
+
+--
+-- Name: marcacoes_estabelecimento; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
+--
+
+CREATE TABLE marcacoes_estabelecimento (
+ id integer NOT NULL,
+ data date NOT NULL,
+ realizada character(1) DEFAULT 'n'::bpchar NOT NULL,
+ data_email date,
+ data_relatorio date,
+ estabelecimento_id integer DEFAULT 0 NOT NULL
+);
+
+
+ALTER TABLE public.marcacoes_estabelecimento OWNER TO postgres;
+
+--
+-- Name: marcacoes_trabalhador; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
+--
+
+CREATE TABLE marcacoes_trabalhador (
+ id integer NOT NULL,
+ data date,
+ realizada character(1) DEFAULT 'n'::bpchar NOT NULL,
+ data_email date,
+ data_relatorio date,
+ tipo integer,
+ trabalhador_id integer
+);
+
+
+ALTER TABLE public.marcacoes_trabalhador OWNER TO postgres;
+
+--
+-- Name: medicos; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
+--
+
+CREATE TABLE medicos (
+ id integer NOT NULL,
+ nome character varying(255) DEFAULT ''::character varying NOT NULL,
+ numero_cedula character varying(255) DEFAULT ''::character varying NOT NULL,
+ inactivo character(1) DEFAULT 'n'::bpchar NOT NULL
+);
+
+
+ALTER TABLE public.medicos OWNER TO postgres;
+
+--
+-- Name: tipos_exames_comp; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
+--
+
+CREATE TABLE tipos_exames_comp (
+ id integer NOT NULL,
+ ordem integer DEFAULT 0 NOT NULL,
+ descricao character varying(255) DEFAULT ''::character varying NOT NULL
+);
+
+
+ALTER TABLE public.tipos_exames_comp OWNER TO postgres;
+
+--
+-- Name: trabalhadores; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
+--
+
+CREATE TABLE trabalhadores (
+ id integer NOT NULL,
+ nome character varying(255) DEFAULT ''::character varying NOT NULL,
+ sexo character(1),
+ data_nascimento date,
+ nacionalidade character varying(255),
+ numero_mecanografico character varying(255),
+ data_admissao date,
+ categoria character varying(255),
+ local_trabalho character varying(255),
+ funcao_proposta character varying(255),
+ data_admissao_funcao date,
+ observacoes character varying(65535),
+ inactivo character(1) DEFAULT 'n'::bpchar NOT NULL,
+ estabelecimento_id integer DEFAULT 0 NOT NULL,
+ data_demissao date,
+ observacoes_gestao character varying(65535),
+ perfil integer,
+ actualizacao timestamp without time zone,
+ nome_plain character varying(255)
+);
+
+
+ALTER TABLE public.trabalhadores OWNER TO postgres;
+
+--
+-- Name: actualizacao_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
+--
+
+ALTER TABLE ONLY actualizacao
+ ADD CONSTRAINT actualizacao_pkey PRIMARY KEY (id);
+
+
+ALTER INDEX public.actualizacao_pkey OWNER TO postgres;
+
+--
+-- Name: avisos_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
+--
+
+ALTER TABLE ONLY avisos
+ ADD CONSTRAINT avisos_pkey PRIMARY KEY (id);
+
+
+ALTER INDEX public.avisos_pkey OWNER TO postgres;
+
+--
+-- Name: contactos_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
+--
+
+ALTER TABLE ONLY contactos
+ ADD CONSTRAINT contactos_pkey PRIMARY KEY (id);
+
+
+ALTER INDEX public.contactos_pkey OWNER TO postgres;
+
+--
+-- Name: empresas_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
+--
+
+ALTER TABLE ONLY empresas
+ ADD CONSTRAINT empresas_pkey PRIMARY KEY (id);
+
+
+ALTER INDEX public.empresas_pkey OWNER TO postgres;
+
+--
+-- Name: errors_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
+--
+
+ALTER TABLE ONLY errors
+ ADD CONSTRAINT errors_pkey PRIMARY KEY (id);
+
+
+ALTER INDEX public.errors_pkey OWNER TO postgres;
+
+--
+-- Name: estabelecimentos_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
+--
+
+ALTER TABLE ONLY estabelecimentos
+ ADD CONSTRAINT estabelecimentos_pkey PRIMARY KEY (id);
+
+
+ALTER INDEX public.estabelecimentos_pkey OWNER TO postgres;
+
+--
+-- Name: exames_perfis_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
+--
+
+ALTER TABLE ONLY exames_perfis
+ ADD CONSTRAINT exames_perfis_pkey PRIMARY KEY (id);
+
+
+ALTER INDEX public.exames_perfis_pkey OWNER TO postgres;
+
+--
+-- Name: exames_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
+--
+
+ALTER TABLE ONLY exames
+ ADD CONSTRAINT exames_pkey PRIMARY KEY (id);
+
+
+ALTER INDEX public.exames_pkey OWNER TO postgres;
+
+--
+-- Name: historico_estabelecimento_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
+--
+
+ALTER TABLE ONLY historico_estabelecimento
+ ADD CONSTRAINT historico_estabelecimento_pkey PRIMARY KEY (id);
+
+
+ALTER INDEX public.historico_estabelecimento_pkey OWNER TO postgres;
+
+--
+-- Name: ids_pk; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
+--
+
+ALTER TABLE ONLY ids
+ ADD CONSTRAINT ids_pk PRIMARY KEY (id);
+
+
+ALTER INDEX public.ids_pk OWNER TO postgres;
+
+--
+-- Name: marcacoes_empresa_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
+--
+
+ALTER TABLE ONLY marcacoes_empresa
+ ADD CONSTRAINT marcacoes_empresa_pkey PRIMARY KEY (id);
+
+
+ALTER INDEX public.marcacoes_empresa_pkey OWNER TO postgres;
+
+--
+-- Name: marcacoes_estabelecimento_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
+--
+
+ALTER TABLE ONLY marcacoes_estabelecimento
+ ADD CONSTRAINT marcacoes_estabelecimento_pkey PRIMARY KEY (id);
+
+
+ALTER INDEX public.marcacoes_estabelecimento_pkey OWNER TO postgres;
+
+--
+-- Name: marcacoes_trabalhador_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
+--
+
+ALTER TABLE ONLY marcacoes_trabalhador
+ ADD CONSTRAINT marcacoes_trabalhador_pkey PRIMARY KEY (id);
+
+
+ALTER INDEX public.marcacoes_trabalhador_pkey OWNER TO postgres;
+
+--
+-- Name: medicos_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
+--
+
+ALTER TABLE ONLY medicos
+ ADD CONSTRAINT medicos_pkey PRIMARY KEY (id);
+
+
+ALTER INDEX public.medicos_pkey OWNER TO postgres;
+
+--
+-- Name: tipos_exames_comp_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
+--
+
+ALTER TABLE ONLY tipos_exames_comp
+ ADD CONSTRAINT tipos_exames_comp_pkey PRIMARY KEY (id);
+
+
+ALTER INDEX public.tipos_exames_comp_pkey OWNER TO postgres;
+
+--
+-- Name: trabalhadores_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
+--
+
+ALTER TABLE ONLY trabalhadores
+ ADD CONSTRAINT trabalhadores_pkey PRIMARY KEY (id);
+
+
+ALTER INDEX public.trabalhadores_pkey OWNER TO postgres;
+
+
+--
+-- Name: avisos_empresa_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
+--
+
+ALTER TABLE ONLY avisos
+ ADD CONSTRAINT avisos_empresa_id_fkey FOREIGN KEY (empresa_id) REFERENCES empresas(id);
+
+
+--
+-- Name: avisos_estabelecimento_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
+--
+
+ALTER TABLE ONLY avisos
+ ADD CONSTRAINT avisos_estabelecimento_id_fkey FOREIGN KEY (estabelecimento_id) REFERENCES estabelecimentos(id);
+
+
+--
+-- Name: empresas_contacto_1_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
+--
+
+ALTER TABLE ONLY empresas
+ ADD CONSTRAINT empresas_contacto_1_fkey FOREIGN KEY (contacto_1) REFERENCES contactos(id);
+
+
+--
+-- Name: empresas_contacto_2_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
+--
+
+ALTER TABLE ONLY empresas
+ ADD CONSTRAINT empresas_contacto_2_fkey FOREIGN KEY (contacto_2) REFERENCES contactos(id);
+
+
+--
+-- Name: estabelecimentos_empresa_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
+--
+
+ALTER TABLE ONLY estabelecimentos
+ ADD CONSTRAINT estabelecimentos_empresa_id_fkey FOREIGN KEY (empresa_id) REFERENCES empresas(id);
+
+
+--
+-- Name: exames_medico_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
+--
+
+ALTER TABLE ONLY exames
+ ADD CONSTRAINT exames_medico_id_fkey FOREIGN KEY (medico_id) REFERENCES medicos(id);
+
+
+--
+-- Name: exames_perfis_tipo_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
+--
+
+ALTER TABLE ONLY exames_perfis
+ ADD CONSTRAINT exames_perfis_tipo_fkey FOREIGN KEY (tipo) REFERENCES tipos_exames_comp(id);
+
+
+--
+-- Name: historico_estabelecimento_estabelecimento_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
+--
+
+ALTER TABLE ONLY historico_estabelecimento
+ ADD CONSTRAINT historico_estabelecimento_estabelecimento_id_fkey FOREIGN KEY (estabelecimento_id) REFERENCES estabelecimentos(id);
+
+
+--
+-- Name: marcacoes_empresa_empresa_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
+--
+
+ALTER TABLE ONLY marcacoes_empresa
+ ADD CONSTRAINT marcacoes_empresa_empresa_id_fkey FOREIGN KEY (empresa_id) REFERENCES empresas(id);
+
+
+--
+-- Name: marcacoes_estabelecimento_estabelecimento_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
+--
+
+ALTER TABLE ONLY marcacoes_estabelecimento
+ ADD CONSTRAINT marcacoes_estabelecimento_estabelecimento_id_fkey FOREIGN KEY (estabelecimento_id) REFERENCES estabelecimentos(id);
+
+
+--
+-- Name: trabalhadores_estabelecimento_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
+--
+
+ALTER TABLE ONLY trabalhadores
+ ADD CONSTRAINT trabalhadores_estabelecimento_id_fkey FOREIGN KEY (estabelecimento_id) REFERENCES estabelecimentos(id);
+
+
+
+--
+-- Name: public; Type: ACL; Schema: -; Owner: postgres
+--
+
+REVOKE ALL ON SCHEMA public FROM PUBLIC;
+REVOKE ALL ON SCHEMA public FROM postgres;
+GRANT ALL ON SCHEMA public TO postgres;
+GRANT ALL ON SCHEMA public TO PUBLIC;
+
+
+
diff --git a/trunk/updtprop.txt b/trunk/updtprop.txt
new file mode 100644
index 00000000..6153dbeb
--- /dev/null
+++ b/trunk/updtprop.txt
@@ -0,0 +1,7 @@
+interno=localhost:5432
+iuser=postgres
+ipasswd=Typein
+externo=www.evolute.pt:5436
+euser=siprp
+epasswd=rg2h-opksiprp
+intervalo=10