no message

git-svn-id: https://svn.coded.pt/svn/SIPRP@158 bb69d46d-e84e-40c8-a05a-06db0d633741
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Frederico Palma 21 years ago
parent ab3531d8f2
commit e27f01cb7e

@ -20,6 +20,7 @@ import com.evolute.utils.ui.button.*;
import com.evolute.utils.ui.panel.*; import com.evolute.utils.ui.panel.*;
import siprp.*; import siprp.*;
import siprp.data.*;
/** /**
* *
@ -39,10 +40,11 @@ public class EmpresaPanel extends JPanel
private JButton defaultServicoHigieneButton; private JButton defaultServicoHigieneButton;
private FichaDataProvider provider; private FichaDataProvider provider;
private ComponentsHashtable components; private ComponentsHashtable empresaComponents;
private ComponentsHashtable estabelecimentoComponents;
private MetaObject estabelecimento; private EstabelecimentoData estabelecimento;
private MetaObject empresa; private EmpresaData empresa;
/** Creates a new instance of EmpresaPanel */ /** Creates a new instance of EmpresaPanel */
@ -221,19 +223,61 @@ public class EmpresaPanel extends JPanel
private void setupComponentsHashtable() private void setupComponentsHashtable()
{ {
components = new ComponentsHashtable(); empresaComponents = new ComponentsHashtable();
components.putComponent( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.DESIGNACAO_SOCIAL, designacaoSocialText ); empresaComponents.putComponent( EmpresaData.DESIGNACAO_SOCIAL, designacaoSocialText );
components.put( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_SAUDE_TIPO, servicoSaudeTipoPanel ); empresaComponents.putComponent( EmpresaData.SERVICO_SAUDE_TIPO, servicoSaudeTipoPanel );
components.putComponent( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_SAUDE_DESIGNACAO, designacaoServicoSaudeText ); empresaComponents.putComponent( EmpresaData.SERVICO_SAUDE_DESIGNACAO, designacaoServicoSaudeText );
components.put( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_HIGIENE_TIPO, servicoHigieneTipoPanel ); empresaComponents.putComponent( EmpresaData.SERVICO_HIGIENE_TIPO, servicoHigieneTipoPanel );
components.putComponent( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_HIGIENE_DESIGNACAO, designacaoText ); empresaComponents.putComponent( EmpresaData.SERVICO_HIGIENE_DESIGNACAO, designacaoText );
components.putComponent( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.NOME, estabelecimentoText ); empresaComponents.putDummy( EmpresaData.MORADA );
components.putComponent( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.LOCALIDADE, localidadeText ); empresaComponents.putDummy( EmpresaData.CODIGO_POSTAL );
empresaComponents.putDummy( EmpresaData.LOCALIDADE );
components.putDummy( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.INACTIVO ); empresaComponents.putDummy( EmpresaData.DISTRITO );
components.putDummy( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.EMPRESA_ID ); empresaComponents.putDummy( EmpresaData.CONCELHO );
components.putDummy( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.INACTIVO ); empresaComponents.putDummy( EmpresaData.DATA_PROPOSTA );
empresaComponents.putDummy( EmpresaData.DATA_ACEITACAO );
empresaComponents.putDummy( EmpresaData.PERFIL_1 );
empresaComponents.putDummy( EmpresaData.PERFIL_2 );
empresaComponents.putDummy( EmpresaData.DATA_ENVIO_CONTRATO );
empresaComponents.putDummy( EmpresaData.DATA_RECEPCAO_CONTRATO );
empresaComponents.putDummy( EmpresaData.DATA_ENVIO_IDICT );
empresaComponents.putDummy( EmpresaData.DATA_RELATORIO_ANUAL );
empresaComponents.putDummy( EmpresaData.CODIGO_1 );
empresaComponents.putDummy( EmpresaData.CODIGO_2 );
empresaComponents.putDummy( EmpresaData.CODIGO_3 );
empresaComponents.putDummy( EmpresaData.CAE );
empresaComponents.putDummy( EmpresaData.ACTIVIDADE );
empresaComponents.putDummy( EmpresaData.CONTRIBUINTE );
empresaComponents.putDummy( EmpresaData.SEGURANCA_SOCIAL );
empresaComponents.putDummy( EmpresaData.CONTACTO_1 );
empresaComponents.putDummy( EmpresaData.CONTACTO_2 );
empresaComponents.putDummy( EmpresaData.SERVICOS );
empresaComponents.putDummy( EmpresaData.PRECO_HIGIENE );
empresaComponents.putDummy( EmpresaData.PRECO_MEDICINA );
empresaComponents.putDummy( EmpresaData.PERIODICIDADE );
estabelecimentoComponents = new ComponentsHashtable();
estabelecimentoComponents.putComponent( EstabelecimentoData.NOME, estabelecimentoText );
estabelecimentoComponents.putComponent( EstabelecimentoData.LOCALIDADE, localidadeText );
estabelecimentoComponents.putDummy( EstabelecimentoData.MORADA );
estabelecimentoComponents.putDummy( EstabelecimentoData.CODIGO_POSTAL );
estabelecimentoComponents.putDummy( EstabelecimentoData.CONTACTO );
estabelecimentoComponents.putDummy( EstabelecimentoData.HISTORICO );
estabelecimentoComponents.putDummy( EstabelecimentoData.EMPRESA );
// components.putComponent( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.DESIGNACAO_SOCIAL, designacaoSocialText );
// components.put( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_SAUDE_TIPO, servicoSaudeTipoPanel );
// components.putComponent( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_SAUDE_DESIGNACAO, designacaoServicoSaudeText );
// components.put( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_HIGIENE_TIPO, servicoHigieneTipoPanel );
// components.putComponent( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_HIGIENE_DESIGNACAO, designacaoText );
//
// components.putComponent( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.NOME, estabelecimentoText );
// components.putComponent( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.LOCALIDADE, localidadeText );
//
// components.putDummy( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.INACTIVO );
// components.putDummy( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.EMPRESA_ID );
// components.putDummy( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.INACTIVO );
} }
public void fill(Object value) public void fill(Object value)
@ -249,36 +293,46 @@ public class EmpresaPanel extends JPanel
{ {
try try
{ {
empresa = provider.load( provider.EMPRESAS, new DBKey( empresaID ) ); empresa = (EmpresaData)EmpresaData.load( EmpresaData.class, empresaID );
DBField fields[] = provider.EMPRESAS.getInsertFields(); String names[] = empresa.getFieldNames();
String empresaFields[] = new String[ fields.length ]; ComponentController.fill( names, estabelecimento.getHashData(), empresaComponents );
Hashtable data = new Hashtable();
for( int i = 0; i < empresaFields.length; ++i )
{
empresaFields[ i ] = fields[ i ].FULL_NAME;
Object fieldValue = empresa.getProperty( empresaFields[ i ] );
if( fieldValue != null )
{
data.put( empresaFields[ i ], fieldValue );
}
}
ComponentController.fill( empresaFields, data, components );
if( estabelecimentoID != null ) if( estabelecimentoID != null )
{ {
estabelecimento = provider.load( provider.ESTABELECIMENTOS, new DBKey( estabelecimentoID ) ); estabelecimento = (EstabelecimentoData)EstabelecimentoData.load( EstabelecimentoData.class, estabelecimentoID );
fields = provider.ESTABELECIMENTOS.getInsertFields(); names = estabelecimento.getFieldNames();
String estabelecimentoFields[] = new String[ fields.length ]; ComponentController.fill( names, estabelecimento.getHashData(), estabelecimentoComponents );
for( int i = 0; i < estabelecimentoFields.length; ++i ) }
{
estabelecimentoFields[ i ] = fields[ i ].FULL_NAME; // DBField fields[] = provider.EMPRESAS.getInsertFields();
Object fieldValue = estabelecimento.getProperty( estabelecimentoFields[ i ] ); // String empresaFields[] = new String[ fields.length ];
if( fieldValue != null ) // Hashtable data = new Hashtable();
{ // for( int i = 0; i < empresaFields.length; ++i )
data.put( estabelecimentoFields[ i ], fieldValue ); // {
} // empresaFields[ i ] = fields[ i ].FULL_NAME;
} // Object fieldValue = empresa.getProperty( empresaFields[ i ] );
ComponentController.fill( estabelecimentoFields, data, components ); // if( fieldValue != null )
} // {
// data.put( empresaFields[ i ], fieldValue );
// }
// }
// ComponentController.fill( empresaFields, data, components );
// if( estabelecimentoID != null )
// {
// estabelecimento = provider.load( provider.ESTABELECIMENTOS, new DBKey( estabelecimentoID ) );
// fields = provider.ESTABELECIMENTOS.getInsertFields();
// String estabelecimentoFields[] = new String[ fields.length ];
// for( int i = 0; i < estabelecimentoFields.length; ++i )
// {
// estabelecimentoFields[ i ] = fields[ i ].FULL_NAME;
// Object fieldValue = estabelecimento.getProperty( estabelecimentoFields[ i ] );
// if( fieldValue != null )
// {
// data.put( estabelecimentoFields[ i ], fieldValue );
// }
// }
// ComponentController.fill( estabelecimentoFields, data, components );
// }
} }
catch( Exception ex ) catch( Exception ex )
{ {
@ -300,58 +354,76 @@ public class EmpresaPanel extends JPanel
{ {
if( estabelecimento == null ) if( estabelecimento == null )
{ {
estabelecimento = provider.createObject( provider.ESTABELECIMENTOS ); // estabelecimento = provider.createObject( provider.ESTABELECIMENTOS );
estabelecimento = new EstabelecimentoData();
} }
if( empresa == null ) if( empresa == null )
{ {
empresa = provider.createObject( provider.EMPRESAS ); // empresa = provider.createObject( provider.EMPRESAS );
} empresa = new EmpresaData();
DBField fields[] = provider.EMPRESAS.getInsertFields(); }
String empresaFields[] = new String[ fields.length ]; // DBField fields[] = provider.EMPRESAS.getInsertFields();
for( int i = 0; i < empresaFields.length; ++i ) // String empresaFields[] = new String[ fields.length ];
{ // for( int i = 0; i < empresaFields.length; ++i )
empresaFields[ i ] = fields[ i ].FULL_NAME; // {
} // empresaFields[ i ] = fields[ i ].FULL_NAME;
// }
// Hashtable hash = new Hashtable();
// ComponentController.save( empresaFields, hash, components );
// Enumeration enum = hash.keys();
// while( enum.hasMoreElements() )
// {
// String name = ( String )enum.nextElement();
// empresa.setProperty( name, hash.get( name ) );
// }
// fields = provider.ESTABELECIMENTOS.getInsertFields();
// String estabelecimentoFields[] = new String[ fields.length ];
// for( int i = 0; i < estabelecimentoFields.length; ++i )
// {
// estabelecimentoFields[ i ] = fields[ i ].FULL_NAME;
// }
// hash = new Hashtable();
// ComponentController.save( estabelecimentoFields, hash, components );
// enum = hash.keys();
// while( enum.hasMoreElements() )
// {
// String name = ( String )enum.nextElement();
// estabelecimento.setProperty( name, hash.get( name ) );
// }
String names[] = empresa.getFieldNames();
Hashtable hash = new Hashtable(); Hashtable hash = new Hashtable();
ComponentController.save( empresaFields, hash, components ); ComponentController.save( names, hash, empresaComponents );
Enumeration enum = hash.keys(); empresa.setHashData( hash );
while( enum.hasMoreElements() )
{ names = estabelecimento.getFieldNames();
String name = ( String )enum.nextElement();
empresa.setProperty( name, hash.get( name ) );
}
fields = provider.ESTABELECIMENTOS.getInsertFields();
String estabelecimentoFields[] = new String[ fields.length ];
for( int i = 0; i < estabelecimentoFields.length; ++i )
{
estabelecimentoFields[ i ] = fields[ i ].FULL_NAME;
}
hash = new Hashtable(); hash = new Hashtable();
ComponentController.save( estabelecimentoFields, hash, components ); ComponentController.save( names, hash, estabelecimentoComponents );
enum = hash.keys(); estabelecimento.setHashData( hash );
while( enum.hasMoreElements() ) estabelecimento.set( EstabelecimentoData.EMPRESA, empresa );
{
String name = ( String )enum.nextElement(); // estabelecimento.setProperty( provider.R_ESTABELECIMENTO_EMPRESA, empresa );
estabelecimento.setProperty( name, hash.get( name ) );
}
estabelecimento.setProperty( provider.R_ESTABELECIMENTO_EMPRESA, empresa );
if( ((String)empresa.getProperty( provider.DESIGNACAO_SOCIAL )).trim().length() == 0 ) // if( ((String)empresa.getProperty( provider.DESIGNACAO_SOCIAL )).trim().length() == 0 )
if( ((String)empresa.get( EmpresaData.DESIGNACAO_SOCIAL )).trim().length() == 0 )
{ {
msg.append( "A empresa tem de ter uma design\u00e7\u00e3o social\n" ); msg.append( "A empresa tem de ter uma design\u00e7\u00e3o social\n" );
hasMsg = true; hasMsg = true;
} }
if( empresa.getProperty( provider.SERVICO_SAUDE_TIPO ) == null ) // if( empresa.getProperty( provider.SERVICO_SAUDE_TIPO ) == null )
if( empresa.get( EmpresaData.SERVICO_SAUDE_TIPO ) == null )
{ {
msg.append( "A empresa tem de ter um tipo de seri\00e7o de sa\u00fade\n" ); msg.append( "A empresa tem de ter um tipo de seri\00e7o de sa\u00fade\n" );
hasMsg = true; hasMsg = true;
} }
if( empresa.getProperty( provider.SERVICO_HIGIENE_TIPO ) == null ) // if( empresa.getProperty( provider.SERVICO_HIGIENE_TIPO ) == null )
if( empresa.get( EmpresaData.SERVICO_HIGIENE_TIPO ) == null )
{ {
msg.append( "A empresa tem de ter um tipo de seri\00e7o de higiene\n" ); msg.append( "A empresa tem de ter um tipo de seri\00e7o de higiene\n" );
hasMsg = true; hasMsg = true;
} }
if( ((String)estabelecimento.getProperty( provider.NOME )).trim().length() == 0 ) // if( ((String)estabelecimento.getProperty( provider.NOME )).trim().length() == 0 )
if( ((String)estabelecimento.get( EstabelecimentoData.NOME )).trim().length() == 0 )
{ {
msg.append( "O estabelecimento tem de ter nome\n" ); msg.append( "O estabelecimento tem de ter nome\n" );
hasMsg = true; hasMsg = true;
@ -373,8 +445,10 @@ public class EmpresaPanel extends JPanel
public void clear() public void clear()
{ {
String names[] = (String[])components.keySet().toArray( new String[0] ); String names[] = (String[])empresaComponents.keySet().toArray( new String[0] );
ComponentController.clear( names, components ); ComponentController.clear( names, empresaComponents );
names = (String[])estabelecimentoComponents.keySet().toArray( new String[0] );
ComponentController.clear( names, estabelecimentoComponents );
estabelecimentoText.setText( "Sede" ); estabelecimentoText.setText( "Sede" );
empresa = null; empresa = null;
estabelecimento = null; estabelecimento = null;
@ -382,7 +456,9 @@ public class EmpresaPanel extends JPanel
public void setEnabled( boolean enable ) public void setEnabled( boolean enable )
{ {
String names[] = (String[])components.keySet().toArray( new String[0] ); String names[] = (String[])empresaComponents.keySet().toArray( new String[0] );
ComponentController.setEnabled( names, enable, components ); ComponentController.setEnabled( names, enable, empresaComponents );
names = (String[])estabelecimentoComponents.keySet().toArray( new String[0] );
ComponentController.setEnabled( names, enable, estabelecimentoComponents );
} }
} }

@ -7,6 +7,7 @@
package siprp.ficha; package siprp.ficha;
import siprp.*; import siprp.*;
import siprp.data.*;
import siprp.importer.*; import siprp.importer.*;
import java.awt.*; import java.awt.*;
@ -183,40 +184,40 @@ public class FichaWindow extends TabbedWindow
} }
}); });
StringBuffer msg = new StringBuffer(); StringBuffer msg = new StringBuffer();
MetaObject medico; MedicoData medico;
try try
{ {
medico = (MetaObject)upperPanel.save(); medico = (MedicoData)upperPanel.save();
} }
catch( ValuesException vex ) catch( ValuesException vex )
{ {
msg.append( vex.getMessage() ); msg.append( vex.getMessage() );
medico = null; medico = null;
} }
MetaObject estabelecimento; EstabelecimentoData estabelecimento;
try try
{ {
estabelecimento = (MetaObject)empresaPanel.save(); estabelecimento = (EstabelecimentoData)empresaPanel.save();
} }
catch( ValuesException vex ) catch( ValuesException vex )
{ {
msg.append( vex.getMessage() ); msg.append( vex.getMessage() );
estabelecimento = null; estabelecimento = null;
} }
MetaObject trabalhador; TrabalhadorData trabalhador;
try try
{ {
trabalhador = (MetaObject)trabalhadorPanel.save(); trabalhador = (TrabalhadorData)trabalhadorPanel.save();
} }
catch( ValuesException vex ) catch( ValuesException vex )
{ {
msg.append( vex.getMessage() ); msg.append( vex.getMessage() );
trabalhador = null; trabalhador = null;
} }
MetaObject exame; ExameData exame;
try try
{ {
exame = (MetaObject)examePanel.save(); exame = (ExameData)examePanel.save();
} }
catch( ValuesException vex ) catch( ValuesException vex )
{ {
@ -228,22 +229,28 @@ public class FichaWindow extends TabbedWindow
JOptionPane.showMessageDialog( this, msg.toString(), "Erro...", JOptionPane.ERROR_MESSAGE ); JOptionPane.showMessageDialog( this, msg.toString(), "Erro...", JOptionPane.ERROR_MESSAGE );
return false; return false;
} }
trabalhador.setProperty( FichaDataProvider.R_TRABALHADOR_ESTABELECIMENTO, estabelecimento ); // trabalhador.setProperty( FichaDataProvider.R_TRABALHADOR_ESTABELECIMENTO, estabelecimento );
trabalhador.setProperty( FichaDataProvider.OBSERVACOES, observacoesPanel.save() ); // trabalhador.setProperty( FichaDataProvider.OBSERVACOES, observacoesPanel.save() );
trabalhador.set( TrabalhadorData.ESTABELECIMENTO, estabelecimento );
trabalhador.set( TrabalhadorData.OBSERVACOES, observacoesPanel.save() );
exame.setProperty( FichaDataProvider.R_EXAME_MEDICO, medico ); // exame.setProperty( FichaDataProvider.R_EXAME_MEDICO, medico );
exame.setProperty( FichaDataProvider.R_EXAME_TRABALHADOR, trabalhador ); // exame.setProperty( FichaDataProvider.R_EXAME_TRABALHADOR, trabalhador );
exame.set( ExameData.MEDICO, medico );
exame.set( ExameData.TRABALHADOR, trabalhador );
try try
{ {
exame.save(); exame.save();
exame.setProperty( FichaDataProvider.PDF, createPDF( exame ) ); // exame.setProperty( FichaDataProvider.PDF, createPDF( exame ) );
fdpProvider.savePDF( exame ); // fdpProvider.savePDF( exame );
DBKey key = trabalhador.getPrimaryKeyValue();
DBField fields[] = FichaDataProvider.TRABALHADORES.getPrimaryKey(); // DBKey key = trabalhador.getPrimaryKeyValue();
trabalhadorID = new Integer( ((Number)key.getFieldValue( fields[ 0 ] )).intValue() ); // DBField fields[] = FichaDataProvider.TRABALHADORES.getPrimaryKey();
// trabalhadorID = new Integer( ((Number)key.getFieldValue( fields[ 0 ] )).intValue() );
trabalhadorID = ( Integer ) trabalhador.get( TrabalhadorData.ID );
try try
{ {
siprp.data.Marcacao.saveMarcacaoExameForTrabalhadorID( trabalhadorID, (Date)exame.getProperty( FichaDataProvider.PROXIMO_EXAME ) ); Marcacao.saveMarcacaoExameForTrabalhadorID( trabalhadorID, (Date)exame.get( ExameData.PROXIMO_EXAME ) );
} }
catch( Exception iex ) catch( Exception iex )
{ {
@ -466,30 +473,30 @@ public class FichaWindow extends TabbedWindow
private void print( Integer exameID ) private void print( Integer exameID )
throws Exception throws Exception
{ {
MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) ); // MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) );
byte pdf[] = (byte []) exame.getProperty( fdpProvider.PDF ); // byte pdf[] = (byte []) exame.get( ExameData.PDF );
if( exame == null ) // if( exame == null )
{ // {
throw new Exception( "N\u00e3o existe exame" ); // throw new Exception( "N\u00e3o existe exame" );
} // }
ExamePDF ePDF = new ExamePDF(); // ExamePDF ePDF = new ExamePDF();
ePDF.print( pdf ); // ePDF.print( pdf );
} }
public byte[] createPDF( MetaObject exame ) public byte[] createPDF( ExameData exame )
throws Exception throws Exception
{ {
MetaObject medico = ( (MetaObject []) exame.getProperty( fdpProvider.R_EXAME_MEDICO ) )[0]; MedicoData medico = (MedicoData)exame.get( ExameData.MEDICO );
MetaObject trabalhador = ( (MetaObject []) exame.getProperty( fdpProvider.R_EXAME_TRABALHADOR ) )[0]; TrabalhadorData trabalhador = (TrabalhadorData) exame.get( ExameData.TRABALHADOR );
MetaObject estabelecimento = ( (MetaObject []) trabalhador.getProperty( fdpProvider.R_TRABALHADOR_ESTABELECIMENTO ) )[0]; EstabelecimentoData estabelecimento = (EstabelecimentoData) trabalhador.get( TrabalhadorData.ESTABELECIMENTO );
MetaObject empresa = ( (MetaObject []) estabelecimento.getProperty( fdpProvider.R_ESTABELECIMENTO_EMPRESA ) )[0]; EmpresaData empresa = (EmpresaData) estabelecimento.get( EstabelecimentoData.EMPRESA );
empresa.load( empresa.getPrimaryKeyValue() ); // empresa.load( empresa.getPrimaryKeyValue() );
Hashtable ht = new Hashtable(); Hashtable ht = new Hashtable();
ht.put( "designacao_social", empresa.getProperty( fdpProvider.DESIGNACAO_SOCIAL ) ); ht.put( "designacao_social", empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) );
ht.put( "estabelecimentos.nome", estabelecimento.getProperty( fdpProvider.NOME ) ); ht.put( "estabelecimentos.nome", estabelecimento.get( EstabelecimentoData.NOME ) );
String aux = (String)estabelecimento.getProperty( fdpProvider.LOCALIDADE ); String aux = (String)estabelecimento.get( EstabelecimentoData.LOCALIDADE );
ht.put( "estabelecimentos.localidade", aux != null ? aux : "" ); ht.put( "estabelecimentos.localidade", aux != null ? aux : "" );
Integer tipo = (Integer)empresa.getProperty( fdpProvider.SERVICO_SAUDE_TIPO ); Integer tipo = (Integer)empresa.get( EmpresaData.SERVICO_SAUDE_TIPO );
switch( tipo.intValue() ) switch( tipo.intValue() )
{ {
case 1: case 1:
@ -505,8 +512,8 @@ public class FichaWindow extends TabbedWindow
ht.put( "servico_saude_tipo_sns", "" ); ht.put( "servico_saude_tipo_sns", "" );
break; break;
} }
ht.put( "servico_saude_designacao", empresa.getProperty( fdpProvider.SERVICO_SAUDE_DESIGNACAO ) ); ht.put( "servico_saude_designacao", empresa.get( EmpresaData.SERVICO_SAUDE_DESIGNACAO ) );
tipo = (Integer)empresa.getProperty( fdpProvider.SERVICO_HIGIENE_TIPO ); tipo = (Integer)empresa.get( EmpresaData.SERVICO_HIGIENE_TIPO );
switch( tipo.intValue() ) switch( tipo.intValue() )
{ {
case 1: case 1:
@ -522,9 +529,9 @@ public class FichaWindow extends TabbedWindow
ht.put( "servico_higiene_outro", "" ); ht.put( "servico_higiene_outro", "" );
break; break;
} }
ht.put( "servico_higiene_designacao", empresa.getProperty( fdpProvider.SERVICO_HIGIENE_DESIGNACAO ) ); ht.put( "servico_higiene_designacao", empresa.get( EmpresaData.SERVICO_HIGIENE_DESIGNACAO ) );
ht.put( "trabalhadores.nome", trabalhador.getProperty( fdpProvider.NOME ) ); ht.put( "trabalhadores.nome", trabalhador.get( TrabalhadorData.NOME ) );
aux = (String)trabalhador.getProperty( fdpProvider.SEXO ); aux = (String)trabalhador.get( TrabalhadorData.SEXO );
switch( aux.charAt( 0 ) ) switch( aux.charAt( 0 ) )
{ {
case 'm': case 'm':
@ -535,27 +542,27 @@ public class FichaWindow extends TabbedWindow
break; break;
} }
DateFormat df = DateFormat.getDateInstance( DateFormat.SHORT ); DateFormat df = DateFormat.getDateInstance( DateFormat.SHORT );
Date data = ( Date )trabalhador.getProperty( fdpProvider.DATA_NASCIMENTO ); Date data = ( Date )trabalhador.get( TrabalhadorData.DATA_NASCIMENTO );
ht.put( "data_nascimento", data != null ? df.format( data ) : "" ); ht.put( "data_nascimento", data != null ? df.format( data ) : "" );
aux = (String)trabalhador.getProperty( fdpProvider.NACIONALIDADE ); aux = (String)trabalhador.get( TrabalhadorData.NACIONALIDADE );
ht.put( "nacionalidade", aux != null ? aux : "" ); ht.put( "nacionalidade", aux != null ? aux : "" );
aux = (String)trabalhador.getProperty( fdpProvider.NUMERO_MECANOGRAFICO ); aux = (String)trabalhador.get( TrabalhadorData.NUMERO_MECANOGRAFICO );
ht.put( "numero_mecanografico", aux != null ? aux : "" ); ht.put( "numero_mecanografico", aux != null ? aux : "" );
data = ( Date )trabalhador.getProperty( fdpProvider.DATA_ADMISSAO ); data = ( Date )trabalhador.get( TrabalhadorData.DATA_ADMISSAO );
ht.put( "data_admissao", data != null ? df.format( data ) : "" ); ht.put( "data_admissao", data != null ? df.format( data ) : "" );
aux = (String)trabalhador.getProperty( fdpProvider.CATEGORIA ); aux = (String)trabalhador.get( TrabalhadorData.CATEGORIA );
ht.put( "categoria", aux != null ? aux : "" ); ht.put( "categoria", aux != null ? aux : "" );
aux = (String)trabalhador.getProperty( fdpProvider.LOCAL_TRABALHO ); aux = (String)trabalhador.get( TrabalhadorData.LOCAL_TRABALHO );
ht.put( "local_trabalho", aux != null ? aux : "" ); ht.put( "local_trabalho", aux != null ? aux : "" );
aux = (String)trabalhador.getProperty( fdpProvider.FUNCAO_PROPOSTA ); aux = (String)trabalhador.get( TrabalhadorData.FUNCAO_PROPOSTA );
ht.put( "funcao_proposta", aux != null ? aux : "" ); ht.put( "funcao_proposta", aux != null ? aux : "" );
data = ( Date )trabalhador.getProperty( fdpProvider.DATA_ADMISSAO_FUNCAO ); data = ( Date )trabalhador.get( TrabalhadorData.DATA_ADMISSAO_FUNCAO );
ht.put( "data_admissao_funcao", data != null ? df.format( data ) : "" ); ht.put( "data_admissao_funcao", data != null ? df.format( data ) : "" );
aux = (String)trabalhador.getProperty( fdpProvider.OBSERVACOES ); aux = (String)trabalhador.get( TrabalhadorData.OBSERVACOES );
ht.put( "observacoes", aux != null ? aux : "" ); ht.put( "observacoes", aux != null ? aux : "" );
data = ( Date )exame.getProperty( fdpProvider.DATA ); data = ( Date )exame.get( ExameData.DATA );
ht.put( "exames.data", data != null ? df.format( data ) : "" ); ht.put( "exames.data", data != null ? df.format( data ) : "" );
tipo = (Integer)exame.getProperty( fdpProvider.TIPO ); tipo = (Integer)exame.get( ExameData.TIPO );
switch( tipo.intValue() ) switch( tipo.intValue() )
{ {
case 1: case 1:
@ -566,7 +573,7 @@ public class FichaWindow extends TabbedWindow
break; break;
case 3: case 3:
ht.put( "tipo_ocasional", "" ); ht.put( "tipo_ocasional", "" );
tipo = (Integer)exame.getProperty( fdpProvider.OCASIONAL ); tipo = (Integer)exame.get( ExameData.OCASIONAL );
switch( tipo.intValue() ) switch( tipo.intValue() )
{ {
case 1: case 1:
@ -588,17 +595,17 @@ public class FichaWindow extends TabbedWindow
ht.put( "tipo_trabalho", "" ); ht.put( "tipo_trabalho", "" );
break; break;
case 10: case 10:
aux = (String)exame.getProperty( fdpProvider.OUTRO_TIPO ); aux = (String)exame.get( ExameData.OUTRO_TIPO );
ht.put( "tipo_outro", aux != null ? aux : "" ); ht.put( "tipo_outro", aux != null ? aux : "" );
break; break;
} }
break; break;
// case 4: // case 4:
// aux = (String)exame.getProperty( fdpProvider.OUTRO_TIPO ); // aux = (String)exame.get( ExameData.OUTRO_TIPO );
// ht.put( "tipo_outro", aux != null ? aux : "" ); // ht.put( "tipo_outro", aux != null ? aux : "" );
// break; // break;
} }
tipo = (Integer)exame.getProperty( fdpProvider.RESULTADO ); tipo = (Integer)exame.get( ExameData.RESULTADO );
switch( tipo.intValue() ) switch( tipo.intValue() )
{ {
case 1: case 1:
@ -614,21 +621,21 @@ public class FichaWindow extends TabbedWindow
ht.put( "resultado_inapto_def", "" ); ht.put( "resultado_inapto_def", "" );
break; break;
} }
aux = (String)exame.getProperty( fdpProvider.OUTRA_FUNCAO_1 ); aux = (String)exame.get( ExameData.OUTRA_FUNCAO_1 );
ht.put( "outra_funcao_1", aux != null ? aux : "" ); ht.put( "outra_funcao_1", aux != null ? aux : "" );
aux = (String)exame.getProperty( fdpProvider.OUTRA_FUNCAO_2 ); aux = (String)exame.get( ExameData.OUTRA_FUNCAO_2 );
ht.put( "outra_funcao_2", aux != null ? aux : "" ); ht.put( "outra_funcao_2", aux != null ? aux : "" );
aux = (String)exame.getProperty( fdpProvider.OUTRA_FUNCAO_3 ); aux = (String)exame.get( ExameData.OUTRA_FUNCAO_3 );
ht.put( "outra_funcao_3", aux != null ? aux : "" ); ht.put( "outra_funcao_3", aux != null ? aux : "" );
aux = (String)exame.getProperty( fdpProvider.OUTRA_FUNCAO_4 ); aux = (String)exame.get( ExameData.OUTRA_FUNCAO_4 );
ht.put( "outra_funcao_4", aux != null ? aux : "" ); ht.put( "outra_funcao_4", aux != null ? aux : "" );
aux = (String)exame.getProperty( fdpProvider.OUTRAS_RECOMENDACOES ); aux = (String)exame.get( ExameData.OUTRAS_RECOMENDACOES );
ht.put( "outras_recomendacoes", aux != null ? aux : "" ); ht.put( "outras_recomendacoes", aux != null ? aux : "" );
data = ( Date )exame.getProperty( fdpProvider.PROXIMO_EXAME ); data = ( Date )exame.get( ExameData.PROXIMO_EXAME );
ht.put( "proximo_exame", data != null ? df.format( data ) : "n/d" ); ht.put( "proximo_exame", data != null ? df.format( data ) : "n/d" );
aux = (String)medico.getProperty( fdpProvider.NOME ); aux = (String)medico.get( MedicoData.NOME );
ht.put( "medicos.nome", aux != null ? aux : "" ); ht.put( "medicos.nome", aux != null ? aux : "" );
aux = (String)medico.getProperty( fdpProvider.NUMERO_CEDULA ); aux = (String)medico.get( MedicoData.NUMERO_CEDULA );
ht.put( "numero_cedula", aux != null ? aux : "" ); ht.put( "numero_cedula", aux != null ? aux : "" );
ExamePDF ePDF = new ExamePDF(); ExamePDF ePDF = new ExamePDF();
return ePDF.createPDF( ht ); return ePDF.createPDF( ht );
@ -717,17 +724,19 @@ public class FichaWindow extends TabbedWindow
private void delete( Integer exameID ) private void delete( Integer exameID )
throws Exception throws Exception
{ {
MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) ); // MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) );
ExameData exame = (ExameData) ExameData.load( ExameData.class, exameID );
if( exame == null ) if( exame == null )
{ {
throw new Exception( "N\u00e3o existe exame" ); throw new Exception( "N\u00e3o existe exame" );
} }
if( JOptionPane.showConfirmDialog( this, if( JOptionPane.showConfirmDialog( this,
"Tem a certeza que quer apagar o exame de " + exame.getProperty( fdpProvider.DATA ) + "?", "Tem a certeza que quer apagar o exame de " + exame.get( ExameData.DATA ) + "?",
"...", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null ) == 0 ) "...", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null ) == 0 )
{ {
exame.setProperty( fdpProvider.INACTIVO, "y" ); // exame.set( ExameData.INACTIVO, "y" );
exame.save(); // exame.save();
exame.delete();
} }
} }
} }

@ -18,6 +18,7 @@ import com.evolute.utils.ui.*;
import com.evolute.utils.ui.panel.*; import com.evolute.utils.ui.panel.*;
import siprp.*; import siprp.*;
import siprp.data.*;
import siprp.importer.*; import siprp.importer.*;
/** /**
* *
@ -39,7 +40,7 @@ public class TrabalhadorPanel extends JPanel
private ComponentsHashtable components; private ComponentsHashtable components;
private FichaDataProvider provider; private FichaDataProvider provider;
private MetaObject trabalhador; private TrabalhadorData trabalhador;
/** Creates a new instance of TrabalhadorPanel */ /** Creates a new instance of TrabalhadorPanel */
@ -194,19 +195,8 @@ public class TrabalhadorPanel extends JPanel
private void setupComponentsHashtable() private void setupComponentsHashtable()
{ {
components = new ComponentsHashtable(); components = new ComponentsHashtable();
components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.NOME, nomeText ); components.putComponent( TrabalhadorData.NOME, nomeText );
components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.DATA_NASCIMENTO, dataNascimentoPanel ); components.putComponent( TrabalhadorData.SEXO, new ControllableComponent()
components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.NACIONALIDADE, nacionalidadeText );
components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.NUMERO_MECANOGRAFICO, numeroMecanograficoText );
components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.DATA_ADMISSAO, dataAdmissaoPanel );
components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.CATEGORIA, categoriaText );
components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.LOCAL_TRABALHO, localText );
components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.FUNCAO_PROPOSTA, funcaoText );
components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.DATA_ADMISSAO_FUNCAO, dataAdmissaoFuncaoPanel );
components.putDummy( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.ESTABELECIMENTO_ID );
components.putDummy( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.OBSERVACOES );
components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.SEXO,
new ControllableComponent()
{ {
public void fill( Object value ) public void fill( Object value )
{ {
@ -240,6 +230,66 @@ public class TrabalhadorPanel extends JPanel
sexoPanel.setEnabled( enable ); sexoPanel.setEnabled( enable );
} }
} ); } );
components.putComponent( TrabalhadorData.DATA_NASCIMENTO, dataNascimentoPanel );
components.putComponent( TrabalhadorData.NACIONALIDADE, nacionalidadeText );
components.putComponent( TrabalhadorData.NUMERO_MECANOGRAFICO, numeroMecanograficoText );
components.putComponent( TrabalhadorData.DATA_ADMISSAO, dataAdmissaoPanel );
components.putComponent( TrabalhadorData.CATEGORIA, categoriaText );
components.putComponent( TrabalhadorData.LOCAL_TRABALHO, localText );
components.putComponent( TrabalhadorData.FUNCAO_PROPOSTA, funcaoText );
components.putComponent( TrabalhadorData.DATA_ADMISSAO_FUNCAO, dataAdmissaoFuncaoPanel );
components.putDummy( TrabalhadorData.DATA_DEMISSAO );
components.putDummy( TrabalhadorData.OBSERVACOES );
components.putDummy( TrabalhadorData.OBSERVACOES_GESTAO );
components.putDummy( TrabalhadorData.PERFIL );
components.putDummy( TrabalhadorData.ESTABELECIMENTO );
// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.NOME, nomeText );
// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.DATA_NASCIMENTO, dataNascimentoPanel );
// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.NACIONALIDADE, nacionalidadeText );
// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.NUMERO_MECANOGRAFICO, numeroMecanograficoText );
// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.DATA_ADMISSAO, dataAdmissaoPanel );
// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.CATEGORIA, categoriaText );
// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.LOCAL_TRABALHO, localText );
// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.FUNCAO_PROPOSTA, funcaoText );
// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.DATA_ADMISSAO_FUNCAO, dataAdmissaoFuncaoPanel );
// components.putDummy( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.ESTABELECIMENTO_ID );
// components.putDummy( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.OBSERVACOES );
// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.SEXO,
// new ControllableComponent()
// {
// public void fill( Object value )
// {
// if( value != null && value.equals( "f" ) )
// {
// sexoPanel.fill( new Integer(2) );
// }
// else
// {
// sexoPanel.fill( new Integer(1) );
// }
// }
//
// public Object save()
// {
// Integer id = (Integer)sexoPanel.save();
// if( id != null && id.intValue() == 1 )
// {
// return "m";
// }
// return "f";
// }
//
// public void clear()
// {
// sexoPanel.clear();
// }
//
// public void setEnabled( boolean enable )
// {
// sexoPanel.setEnabled( enable );
// }
// } );
} }
public void fill(Object value) public void fill(Object value)
@ -253,20 +303,23 @@ public class TrabalhadorPanel extends JPanel
{ {
try try
{ {
trabalhador = provider.load( FichaDataProvider.TRABALHADORES, new DBKey( trabalhadorID ) ); trabalhador = ( TrabalhadorData ) TrabalhadorData.load( TrabalhadorData.class, trabalhadorID );
DBField fields[] = FichaDataProvider.TRABALHADORES.getInsertFields(); String names[] = trabalhador.getFieldNames();
String trabalhadorFields[] = new String[ fields.length ]; ComponentController.fill( names, trabalhador.getHashData(), components );
Hashtable data = new Hashtable(); // trabalhador = provider.load( FichaDataProvider.TRABALHADORES, new DBKey( trabalhadorID ) );
for( int i = 0; i < trabalhadorFields.length; ++i ) // DBField fields[] = FichaDataProvider.TRABALHADORES.getInsertFields();
{ // String trabalhadorFields[] = new String[ fields.length ];
trabalhadorFields[ i ] = fields[ i ].FULL_NAME; // Hashtable data = new Hashtable();
Object fieldValue = trabalhador.getProperty( trabalhadorFields[ i ] ); // for( int i = 0; i < trabalhadorFields.length; ++i )
if( fieldValue != null ) // {
{ // trabalhadorFields[ i ] = fields[ i ].FULL_NAME;
data.put( trabalhadorFields[ i ], fieldValue ); // Object fieldValue = trabalhador.getProperty( trabalhadorFields[ i ] );
} // if( fieldValue != null )
} // {
ComponentController.fill( trabalhadorFields, data, components ); // data.put( trabalhadorFields[ i ], fieldValue );
// }
// }
// ComponentController.fill( trabalhadorFields, data, components );
} }
catch( Exception ex ) catch( Exception ex )
{ {
@ -285,28 +338,35 @@ public class TrabalhadorPanel extends JPanel
{ {
if( trabalhador == null ) if( trabalhador == null )
{ {
trabalhador = provider.createObject( FichaDataProvider.TRABALHADORES ); // trabalhador = provider.createObject( FichaDataProvider.TRABALHADORES );
} trabalhador = new TrabalhadorData();
DBField fields[] = FichaDataProvider.TRABALHADORES.getInsertFields(); }
String trabalhadorFields[] = new String[ fields.length ]; // DBField fields[] = FichaDataProvider.TRABALHADORES.getInsertFields();
for( int i = 0; i < trabalhadorFields.length; ++i ) // String trabalhadorFields[] = new String[ fields.length ];
{ // for( int i = 0; i < trabalhadorFields.length; ++i )
trabalhadorFields[ i ] = fields[ i ].FULL_NAME; // {
} // trabalhadorFields[ i ] = fields[ i ].FULL_NAME;
// }
// Hashtable hash = new Hashtable();
// ComponentController.save( trabalhadorFields, hash, components );
// Enumeration enum = hash.keys();
// while( enum.hasMoreElements() )
// {
// String name = ( String )enum.nextElement();
// trabalhador.setProperty( name, hash.get( name ) );
// }
String names[] = trabalhador.getFieldNames();
Hashtable hash = new Hashtable(); Hashtable hash = new Hashtable();
ComponentController.save( trabalhadorFields, hash, components ); ComponentController.save( names, hash, components );
Enumeration enum = hash.keys(); trabalhador.setHashData( hash );
while( enum.hasMoreElements() ) // if( ((String)trabalhador.getProperty( FichaDataProvider.NOME )).trim().length() == 0 )
{ if( ((String)trabalhador.get( TrabalhadorData.NOME )).trim().length() == 0 )
String name = ( String )enum.nextElement();
trabalhador.setProperty( name, hash.get( name ) );
}
if( ((String)trabalhador.getProperty( FichaDataProvider.NOME )).trim().length() == 0 )
{ {
msg.append( "O trabalhador tem de ter nome\n" ); msg.append( "O trabalhador tem de ter nome\n" );
hasMsg = true; hasMsg = true;
} }
if( trabalhador.getProperty( FichaDataProvider.SEXO ) == null ) // if( trabalhador.getProperty( FichaDataProvider.SEXO ) == null )
if( trabalhador.get( TrabalhadorData.SEXO ) == null )
{ {
msg.append( "O trabalhador tem de ter um sexo definido\n" ); msg.append( "O trabalhador tem de ter um sexo definido\n" );
hasMsg = true; hasMsg = true;

@ -17,6 +17,7 @@ import com.evolute.utils.metadb.*;
import com.evolute.utils.ui.*; import com.evolute.utils.ui.*;
import siprp.*; import siprp.*;
import siprp.data.*;
/** /**
* *
@ -116,25 +117,25 @@ public class UpperPanel extends JPanel
clear(); clear();
try try
{ {
MetaObject trabalhador; TrabalhadorData trabalhador;
MetaObject estabelecimento; EstabelecimentoData estabelecimento;
MetaObject empresa; EmpresaData empresa;
if( trabalhadorID != null ) if( trabalhadorID != null )
{ {
trabalhador = provider.load( provider.TRABALHADORES, new DBKey( trabalhadorID ) ); trabalhador = ( TrabalhadorData ) TrabalhadorData.load( TrabalhadorData.class, trabalhadorID );
String nome = (String) trabalhador.getProperty( provider.NOME ); String nome = (String) trabalhador.get( TrabalhadorData.NOME );
nomeText.setText( nome ); nomeText.setText( nome );
} }
String nomeEstabelecimento = ""; String nomeEstabelecimento = "";
if( estabelecimentoID != null ) if( estabelecimentoID != null )
{ {
estabelecimento = provider.load( provider.ESTABELECIMENTOS, new DBKey( estabelecimentoID ) ); estabelecimento = ( EstabelecimentoData ) EstabelecimentoData.load( EstabelecimentoData.class, estabelecimentoID );
nomeEstabelecimento = (String) estabelecimento.getProperty( provider.NOME ); nomeEstabelecimento = (String) estabelecimento.get( EstabelecimentoData.NOME );
} }
if( empresaID != null ) if( empresaID != null )
{ {
empresa = provider.load( provider.EMPRESAS, new DBKey( empresaID ) ); empresa = ( EmpresaData ) EmpresaData.load( EmpresaData.class, empresaID );
String nomeEmpresa = (String) empresa.getProperty( provider.DESIGNACAO_SOCIAL ); String nomeEmpresa = (String) empresa.get( EmpresaData.DESIGNACAO_SOCIAL );
empresaText.setText( nomeEmpresa + ( nomeEstabelecimento.length() > 0?" / " + nomeEstabelecimento:"" ) ); empresaText.setText( nomeEmpresa + ( nomeEstabelecimento.length() > 0?" / " + nomeEstabelecimento:"" ) );
} }
} }
@ -151,7 +152,7 @@ public class UpperPanel extends JPanel
{ {
try try
{ {
MetaObject medico = provider.load( provider.MEDICOS, new DBKey( id ) ); MedicoData medico = ( MedicoData )MedicoData.load( MedicoData.class, id );
return medico; return medico;
} }
catch( Exception ex ) catch( Exception ex )

Loading…
Cancel
Save