no message

git-svn-id: https://svn.coded.pt/svn/SIPRP@26 bb69d46d-e84e-40c8-a05a-06db0d633741
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Frederico Palma 22 years ago
parent 657d6a03dc
commit 716e119ca0

@ -83,6 +83,15 @@ public class FichaDataProvider extends MetaProvider implements SearchExecuter {
OBSERVACOES, ESTABELECIMENTO_ID, INACTIVO },
ID );
//medicos
public static final String T_MEDICOS = "medicos";
private static final String NUMERO_CEDULA = "numero_cedula";
public static final DBTable MEDICOS =
new DBTable( T_MEDICOS,
new String[]{ NOME, NUMERO_CEDULA }, ID );
// exames
public static final String T_EXAMES = "exames";
// ID
@ -98,23 +107,28 @@ public class FichaDataProvider extends MetaProvider implements SearchExecuter {
public static final String PROXIMO_EXAME = "proximo_exame";
public static final String OUTRAS_RECOMENDACOES = "outras_recomendacoes";
public static final String TRABALHADOR_ID = "trabalhador_id";
public static final String MEDICO_ID = "medico_id";
public static final DBTable EXAMES =
new DBTable( T_EXAMES,
new String[]{ OBSERVACOES, DATA, TIPO, OCASIONAL,
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_ID },
OUTRAS_RECOMENDACOES, TRABALHADOR_ID, MEDICO_ID },
ID );
public static DBReference R_ESTABELECIMENTO_EMPRESA = new DBReference( ESTABELECIMENTOS.getFieldByName( EMPRESA_ID ) );
public static DBReference R_TRABALHADOR_ESTABELECIMENTO = new DBReference( TRABALHADORES.getFieldByName( ESTABELECIMENTO_ID ) );
public static DBReference R_EXAME_TRABALHADOR = new DBReference( EXAMES.getFieldByName( TRABALHADOR_ID ) );
public static DBReference R_EXAME_MEDICO = new DBReference( EXAMES.getFieldByName( MEDICO_ID ) );
static
{
try
{
EXAMES.addRelation( MEDICOS,
new DBField[]{ EXAMES.getFieldByName( MEDICO_ID ) },
"R_EXAMES_MEDICOS" );
EXAMES.addRelation( TRABALHADORES,
new DBField[]{ EXAMES.getFieldByName( TRABALHADOR_ID ) },
"R_EXAMES_TRABALHADORES" );

@ -17,7 +17,7 @@ public class Main
{
Insert.setDefaultKeyRetriever( JDBCAutoKeyRetriever.DEFAULT );
String server = "localhost";
String dbase = "test";
String dbase = "siprp";
String user = "admin";
String passwd = "";

@ -14,19 +14,23 @@ import java.util.*;
import com.evolute.utils.data.*;
import com.evolute.utils.dataui.*;
import com.evolute.utils.metadb.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.ui.button.*;
import com.evolute.utils.ui.panel.*;
import siprp.*;
/**
*
* @author fpalma
*/
public class ExamePanel extends JPanel
implements ChangeListener, FillerSaverWrapper
implements ChangeListener, ControllableComponent
{
private JCalendarPanel dataExamePanel;
private BetterButtonGroup tipoGroup;
private JRadioButton admissaoRadio;
private JRadioButton periodicoRadio;
private JRadioButton ocasionalRadio;
private JRadioButton outroRadio;
private RadioButtonFixedPanel ocasionalPanel;
@ -36,10 +40,16 @@ public class ExamePanel extends JPanel
private JTextField outrasFuncoesTexts[];
private JTextArea recomendacoesText;
private FichaDataProvider provider;
private ComponentsHashtable components;
/** Creates a new instance of ExamePanel */
public ExamePanel()
throws Exception
{
provider = (FichaDataProvider)FichaDataProvider.getProvider();
setupComponents();
setupComponentsHashtable();
}
private void setupComponents()
@ -57,9 +67,9 @@ public class ExamePanel extends JPanel
tipoPanel.setBorder( BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(), "Tipo" ) );
tipoGroup = new BetterButtonGroup( false );
JRadioButton admissaoRadio = new JRadioButton( "Admiss\u00e3o" );
admissaoRadio = new JRadioButton( "Admiss\u00e3o" );
tipoGroup.add( admissaoRadio );
JRadioButton periodicoRadio = new JRadioButton( "Peri\u00f3dico" );
periodicoRadio = new JRadioButton( "Peri\u00f3dico" );
tipoGroup.add( periodicoRadio );
ocasionalRadio = new JRadioButton( "Ocasional" );
tipoGroup.add( ocasionalRadio );
@ -223,24 +233,130 @@ public class ExamePanel extends JPanel
}
}
private void setupComponentsHashtable()
{
components = new ComponentsHashtable();
components.putComponent( provider.T_EXAMES + "." + provider.DATA, dataExamePanel );
components.putDummy( provider.T_EXAMES + "." + provider.TIPO );
components.putComponent( provider.T_EXAMES + "." + provider.OCASIONAL, ocasionalPanel );
components.putComponent( provider.T_EXAMES + "." + provider.OUTRO_TIPO, especificarText );
components.putComponent( provider.T_EXAMES + "." + provider.PROXIMO_EXAME, proximoExamePanel );
components.putComponent( provider.T_EXAMES + "." + provider.RESULTADO, resultadoPanel );
components.putComponent( provider.T_EXAMES + "." + provider.OUTRA_FUNCAO_1, outrasFuncoesTexts[ 0 ] );
components.putComponent( provider.T_EXAMES + "." + provider.OUTRA_FUNCAO_2, outrasFuncoesTexts[ 1 ] );
components.putComponent( provider.T_EXAMES + "." + provider.OUTRA_FUNCAO_3, outrasFuncoesTexts[ 2 ] );
components.putComponent( provider.T_EXAMES + "." + provider.OUTRA_FUNCAO_4, outrasFuncoesTexts[ 3 ] );
components.putComponent( provider.T_EXAMES + "." + provider.OUTRAS_RECOMENDACOES, recomendacoesText );
components.putDummy( provider.T_EXAMES + "." + provider.TRABALHADOR_ID );
components.putDummy( provider.T_EXAMES + "." + provider.MEDICO_ID );
}
public void stateChanged( ChangeEvent e )
{
if( e.getSource().equals( ocasionalRadio ) )
{
ocasionalPanel.setEnabled( ocasionalRadio.isSelected() ) ;
ocasionalPanel.setEnabled( ocasionalRadio.isSelected() && ocasionalRadio.isEnabled() ) ;
}
else if( e.getSource().equals( outroRadio ) )
{
especificarText.setEnabled( outroRadio.isSelected() ) ;
especificarText.setEnabled( outroRadio.isSelected() && outroRadio.isEnabled() ) ;
}
}
public void fill(Object value)
public void fill( Object value )
{
clear();
}
public Object save()
{
return null;
StringBuffer msg = new StringBuffer();
boolean hasMsg = false;
boolean hasData = false;
MetaObject exame;
try
{
exame = provider.createObject( provider.EXAMES );
DBField fields[] = provider.EXAMES.getInsertFields();
String exameFields[] = new String[ fields.length ];
for( int i = 0; i < exameFields.length; ++i )
{
exameFields[ i ] = fields[ i ].FULL_NAME;
}
Hashtable hash = new Hashtable();
ComponentController.save( exameFields, hash, components );
Enumeration enum = hash.keys();
while( enum.hasMoreElements() )
{
String name = ( String )enum.nextElement();
exame.setProperty( name, hash.get( name ) );
}
int tipo = 0;
if( admissaoRadio.isSelected() )
{
tipo = 1;
}
else if( periodicoRadio.isSelected() )
{
tipo = 2;
}
else if( ocasionalRadio.isSelected() )
{
tipo = 3;
}
else if( outroRadio.isSelected() )
{
tipo = 4;
}
exame.setProperty( provider.TIPO, new Integer( tipo ) );
if( tipo != 3 )
{
exame.setProperty( provider.EXAMES.getFieldByName( provider.OCASIONAL ).FULL_NAME, null );
}
if( tipo != 4 )
{
exame.setProperty( provider.EXAMES.getFieldByName( provider.OUTRO_TIPO ).FULL_NAME, "" );
}
// if( ((String)trabalhador.getProperty( provider.NOME )).trim().length() == 0 )
// {
// msg.append( "O trabalhador tem de ter nome\n" );
// hasMsg = true;
// }
// if( trabalhador.getProperty( provider.SEXO ) == null )
// {
// msg.append( "O trabalhador tem de ter um sexo definido\n" );
// hasMsg = true;
// }
}
catch( Exception ex )
{
ex.printStackTrace();
return null;
}
if( hasMsg )
{
throw new ValuesException( msg.toString() );
}
return exame;
}
public void clear()
{
String names[] = (String[])components.keySet().toArray( new String[0] );
ComponentController.clear( names, components );
tipoGroup.setIntSelected( 0 );
dataExamePanel.setDate( new Date() );
}
public void setEnabled( boolean enable )
{
String names[] = (String[])components.keySet().toArray( new String[0] );
ComponentController.setEnabled( names, enable, components );
admissaoRadio.setEnabled( enable );
periodicoRadio.setEnabled( enable );
ocasionalRadio.setEnabled( enable );
outroRadio.setEnabled( enable );
ocasionalPanel.setEnabled( ocasionalRadio.isSelected() && ocasionalRadio.isEnabled() ) ;
especificarText.setEnabled( outroRadio.isSelected() && outroRadio.isEnabled() );
}
}

@ -130,17 +130,39 @@ public class FichaWindow extends TabbedWindow
msg.append( vex.getMessage() );
trabalhador = null;
}
if( estabelecimento == null || trabalhador == null )
MetaObject exame;
try
{
exame = (MetaObject)examePanel.save();
}
catch( ValuesException vex )
{
msg.append( vex.getMessage() );
exame = null;
}
if( estabelecimento == null || trabalhador == null || exame == null )
{
JOptionPane.showMessageDialog( this, msg.toString(), "Erro...", JOptionPane.ERROR_MESSAGE );
return false;
}
trabalhador.setProperty( fdpProvider.R_TRABALHADOR_ESTABELECIMENTO, estabelecimento );
trabalhador.setProperty( fdpProvider.OBSERVACOES, observacoesPanel.save() );
MetaObject medico;
try
{
medico = fdpProvider.load( fdpProvider.MEDICOS, new DBKey( new Integer(1) ) );
}
catch( Exception ex )
{
ex.printStackTrace();
return false;
}
exame.setProperty( fdpProvider.R_EXAME_MEDICO, medico );
exame.setProperty( fdpProvider.R_EXAME_TRABALHADOR, trabalhador );
try
{
trabalhador.save();
exame.save();
}
catch( Exception ex )
{
@ -219,6 +241,7 @@ public class FichaWindow extends TabbedWindow
empresaPanel.fill( empresaData );
trabalhadorPanel.fill( trabalhadorID );
observacoesPanel.fill( trabalhadorID );
examePanel.fill( null );
}
public void enableComponents( int index, boolean enable )
@ -226,6 +249,7 @@ public class FichaWindow extends TabbedWindow
empresaPanel.setEnabled( enable );
trabalhadorPanel.setEnabled( enable );
observacoesPanel.setEnabled( enable );
examePanel.setEnabled( enable );
}
public void clear( int index )
@ -233,5 +257,6 @@ public class FichaWindow extends TabbedWindow
empresaPanel.clear();
trabalhadorPanel.clear();
observacoesPanel.clear();
examePanel.clear();
}
}

Loading…
Cancel
Save