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