no message

git-svn-id: https://svn.coded.pt/svn/SIPRP@33 bb69d46d-e84e-40c8-a05a-06db0d633741
lxbfYeaa
Frederico Palma 22 years ago
parent 5724ac65c3
commit bcc5b5447f

@ -108,6 +108,7 @@ public class FichaDataProvider extends MetaProvider implements SearchExecuter {
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 String PDF = "pdf";
public static final DBTable EXAMES =
new DBTable( T_EXAMES,
@ -115,7 +116,7 @@ public class FichaDataProvider extends MetaProvider implements SearchExecuter {
OUTRO_TIPO, RESULTADO, OUTRA_FUNCAO_1,
OUTRA_FUNCAO_2, OUTRA_FUNCAO_3,
OUTRA_FUNCAO_4, PROXIMO_EXAME,
OUTRAS_RECOMENDACOES, TRABALHADOR_ID, MEDICO_ID },
OUTRAS_RECOMENDACOES, TRABALHADOR_ID, MEDICO_ID, PDF },
ID );
public static DBReference R_ESTABELECIMENTO_EMPRESA = new DBReference( ESTABELECIMENTOS.getFieldByName( EMPRESA_ID ) );
@ -141,6 +142,7 @@ public class FichaDataProvider extends MetaProvider implements SearchExecuter {
EMPRESAS.disableSave( INACTIVO );
ESTABELECIMENTOS.disableSave( INACTIVO );
TRABALHADORES.disableSave( INACTIVO );
EXAMES.disableSave( PDF );
}
catch( Exception e )
{
@ -292,4 +294,39 @@ public class FichaDataProvider extends MetaProvider implements SearchExecuter {
return array.getObjects();
}
public void savePDF( MetaObject exame )
throws Exception
{
if( exame == null )
{
return;
}
DBKey key = exame.getPrimaryKeyValue();
DBField fields[] = EXAMES.getPrimaryKey();
Integer id = new Integer( ((Number)key.getFieldValue( fields[ 0 ] )).intValue() );
if( id == null )
{
throw new Exception( "Error saving pdf: id is null" );
}
byte []pdf = (byte[]) exame.getProperty( PDF );
BlobUpdate bUpdate = new BlobUpdate( T_EXAMES, PDF, pdf, new Field( ID ).isEqual( id ) );
executer.executeQuery( bUpdate );
bUpdate = new BlobUpdate( T_EXAMES, "pdf2", pdf, new Field( ID ).isEqual( id ) );
executer.executeQuery( bUpdate );
}
public Integer getLastExameIDForTrabalhador( Integer trabalhadorID )
throws Exception
{
Select select = new Select( new String[]{ T_EXAMES },
new String[]{ ID, DATA },
new Field( TRABALHADOR_ID ).isEqual( trabalhadorID ),
new String[]{ DATA + " DESC", ID + " DESC" }, null );
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() == 0 )
{
return null;
}
return new Integer( ( (Number) array.get( 0, 0 ) ).intValue() );
}
}

@ -8,6 +8,7 @@ package siprp.ficha;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
@ -266,6 +267,32 @@ public class ExamePanel extends JPanel
public void fill( Object value )
{
clear();
Integer trabID = (Integer) value;
if( trabID == null )
{
return;
}
try
{
Integer id = provider.getLastExameIDForTrabalhador( trabID );
if( id == null )
{
return;
}
MetaObject exame = provider.load( provider.EXAMES, new DBKey( id ) );
byte pdf[] = (byte []) exame.getProperty( provider.PDF );
if( pdf != null )
{
FileOutputStream fos = new FileOutputStream( "C:\\teste.pdf" );
fos.write( pdf );
fos.close();
}
}
catch( Exception ex )
{
ex.printStackTrace();
return;
}
}
public Object save()
@ -317,16 +344,7 @@ public class ExamePanel extends JPanel
{
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 )
{

@ -163,8 +163,10 @@ public class FichaWindow extends TabbedWindow
exame.setProperty( fdpProvider.R_EXAME_TRABALHADOR, trabalhador );
try
{
exame.save();
ExamePDF ePDF = new ExamePDF();
exame.setProperty( fdpProvider.PDF, ePDF.createPDF() );
fdpProvider.savePDF( exame );
}
catch( Exception ex )
{
@ -284,7 +286,7 @@ public class FichaWindow extends TabbedWindow
empresaPanel.fill( empresaData );
trabalhadorPanel.fill( trabalhadorID );
observacoesPanel.fill( trabalhadorID );
examePanel.fill( null );
examePanel.fill( trabalhadorID );
}
public void enableComponents( int index, boolean enable )

Loading…
Cancel
Save