git-svn-id: https://svn.coded.pt/svn/SIPRP@1498 bb69d46d-e84e-40c8-a05a-06db0d633741

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Tiago Simão 15 years ago
parent 0a2deb5719
commit b0732755c0

@ -1,219 +0,0 @@
/*
* Lembrete.java
*
* Created on 12 de Fevereiro de 2007, 23:18
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes;
import java.util.Date;
/**
*
* @author Frederico
*/
public class Lembrete
{
protected Integer id;
protected Integer tipoID;
protected Date data;
protected String descricao;
protected String texto;
protected Integer empresaID;
protected Integer estabelecimentoID;
protected Integer trabalhadorID;
protected Integer marcacaoEstabelecimentoID;
protected Integer marcacaoTrabalhadorID;
protected boolean enviarEmail;
protected Integer periodicidadeDias;
protected Integer periodicidadeMeses;
protected Integer consultaDataID;
protected Integer exameDataID;
/** Creates a new instance of Lembrete */
public Lembrete( Integer id,
Integer tipoID,
Date data,
String descricao,
String texto,
Integer empresaID,
Integer estabelecimentoID,
Integer trabalhadorID,
Integer marcacaoEstabelecimentoID,
Integer marcacaoTrabalhadorID,
boolean enviarEmail,
Integer periodicidadeDias,
Integer periodicidadeMeses,
Integer consultaDataID,
Integer exameDataID )
{
setId( id );
setTipoID( tipoID );
setData( data );
setDescricao( descricao );
setTexto( texto );
setEmpresaID( empresaID );
setEstabelecimentoID( estabelecimentoID );
setTrabalhadorID( trabalhadorID );
setMarcacaoEstabelecimentoID( marcacaoEstabelecimentoID );
setMarcacaoTrabalhadorID( marcacaoTrabalhadorID );
setEnviarEmail( enviarEmail );
setPeriodicidadeDias( periodicidadeDias );
setPeriodicidadeMeses( periodicidadeMeses );
setConsultaDataID( consultaDataID );
setExameDataID( exameDataID );
}
public Integer getTipoID()
{
return tipoID;
}
public void setTipoID(Integer tipoID)
{
this.tipoID = tipoID;
}
public Date getData()
{
return data;
}
public void setData(Date data)
{
this.data = data;
}
public String getDescricao()
{
return descricao;
}
public void setDescricao(String descricao)
{
this.descricao = descricao;
}
public String getTexto()
{
return texto;
}
public void setTexto(String texto)
{
this.texto = texto;
}
public Integer getEmpresaID()
{
return empresaID;
}
public void setEmpresaID(Integer empresaID)
{
this.empresaID = empresaID;
}
public Integer getEstabelecimentoID()
{
return estabelecimentoID;
}
public void setEstabelecimentoID(Integer estabelecimentoID)
{
this.estabelecimentoID = estabelecimentoID;
}
public Integer getTrabalhadorID()
{
return trabalhadorID;
}
public void setTrabalhadorID(Integer trabalhadorID)
{
this.trabalhadorID = trabalhadorID;
}
public Integer getMarcacaoEstabelecimentoID()
{
return marcacaoEstabelecimentoID;
}
public void setMarcacaoEstabelecimentoID(Integer marcacaoEstabelecimentoID)
{
this.marcacaoEstabelecimentoID = marcacaoEstabelecimentoID;
}
public Integer getMarcacaoTrabalhadorID()
{
return marcacaoTrabalhadorID;
}
public void setMarcacaoTrabalhadorID(Integer marcacaoTrabalhadorID)
{
this.marcacaoTrabalhadorID = marcacaoTrabalhadorID;
}
public boolean isEnviarEmail()
{
return enviarEmail;
}
public void setEnviarEmail(boolean enviarEmail)
{
this.enviarEmail = enviarEmail;
}
public Integer getPeriodicidadeDias()
{
return periodicidadeDias;
}
public void setPeriodicidadeDias(Integer periodicidadeDias)
{
this.periodicidadeDias = periodicidadeDias;
}
public Integer getPeriodicidadeMeses()
{
return periodicidadeMeses;
}
public void setPeriodicidadeMeses(Integer periodicidadeMeses)
{
this.periodicidadeMeses = periodicidadeMeses;
}
public Integer getId()
{
return id;
}
public void setId(Integer id)
{
this.id = id;
}
public void setConsultaDataID( Integer consultaDataID )
{
this.consultaDataID = consultaDataID;
}
public void setExameDataID( Integer exameDataID )
{
this.exameDataID = exameDataID;
}
public Integer getConsultaDataID()
{
return consultaDataID;
}
public Integer getExameDataID()
{
return exameDataID;
}
}

@ -1,26 +0,0 @@
/*
* LembretesConstants.java
*
* Created on February 12, 2007, 4:44 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes;
/**
*
* @author fpalma
*/
public interface LembretesConstants
{
public static final String CODE_EXTERNO = "EXTERNO";
public static final String CODE_REMARCACOES = "REMARCACOES";
public static final String CODE_MARCACOES = "MARCACOES";
public static final String CODE_OUTROS = "OUTROS";
public static final String CODES[] =
new String[]{ CODE_EXTERNO, CODE_REMARCACOES, CODE_MARCACOES,
CODE_OUTROS };
}

@ -1,448 +0,0 @@
/*
* LembretesDataProvider.java
*
* Created on February 5, 2007, 6:09 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import shst.MedicinaConstants;
import shst.data.outer.EmpresasData;
import shst.data.outer.EstabelecimentosData;
import shst.data.outer.ExamesData;
import shst.data.outer.TrabalhadoresData;
import shst.data.provider.MedicinaDataProvider;
import siprp.ficha.FichaAptidaoConstants;
import com.evolute.utils.Singleton;
import com.evolute.utils.arrays.Virtual2DArray;
import com.evolute.utils.db.DBException;
import com.evolute.utils.db.DBManager;
import com.evolute.utils.db.Executer;
import com.evolute.utils.sql.Assignment;
import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Insert;
import com.evolute.utils.sql.Select;
import com.evolute.utils.sql.Select2;
import com.evolute.utils.sql.Update;
/**
*
* @author lflores
*/
public class LembretesDataProvider
{
private static final Object LOCK = new Object();
private static LembretesDataProvider instance = null;
private final HashMap<String,TipoLembrete> TIPOS_LEMBRETES_BY_CODIGO =
new HashMap<String,TipoLembrete>();
private final HashMap<Integer,TipoLembrete> TIPOS_LEMBRETES_BY_ID =
new HashMap<Integer,TipoLembrete>();
private TipoLembrete tiposLembrete[];
private MedicinaDataProvider medicinaDAO = null;
private Executer EXECUTER;
/** Creates a new instance of LembretesDataProvider */
public LembretesDataProvider()
throws Exception
{
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
EXECUTER = dbm.getSharedExecuter( this );
medicinaDAO = MedicinaDataProvider.getProvider();
}
public static LembretesDataProvider getProvider()
throws Exception
{
synchronized( LOCK )
{
if( instance == null )
{
instance = new LembretesDataProvider();
}
}
return instance;
}
public TipoLembrete[] getTiposLembrete()
throws Exception
{
if( tiposLembrete == null )
{
Select select =
new Select( new String[]{ "lembretes_tipos" },
new String[]{ "id", "codigo", "descricao", "ordem" },
new Field( "activo" ).isEqual( "y" ),
new String[]{ "ordem" },
null );
Virtual2DArray array = EXECUTER.executeQuery( select );
tiposLembrete = new TipoLembrete[ array.columnLength() ];
for( int n = 0; n < tiposLembrete.length; n++ )
{
Integer id = ( Integer ) array.get( n, 0 );
String codigo = ( String ) array.get( n, 1 );
String descricao = ( String ) array.get( n, 2 );
Integer ordem = ( Integer ) array.get( n, 3 );
tiposLembrete[ n ] = new TipoLembrete( id, codigo, descricao, ordem );
TIPOS_LEMBRETES_BY_CODIGO.put( codigo, tiposLembrete[ n ] );
TIPOS_LEMBRETES_BY_ID.put( id, tiposLembrete[ n ] );
}
}
return tiposLembrete;
}
public Integer getTipoLembreteIDByCodigo( String codigo )
{
Integer result = null;
TipoLembrete tipo;
try
{
tipo = getTipoLembreteByCodigo( codigo );
if( tipo != null )
{
result = tipo.getID();
}
} catch( Exception e )
{
e.printStackTrace();
}
return result;
}
public TipoLembrete getTipoLembreteByCodigo( String codigo )
throws Exception
{
getTiposLembrete();
return TIPOS_LEMBRETES_BY_CODIGO.get( codigo );
}
public TipoLembrete getTipoLembreteByID( Integer id )
throws Exception
{
getTiposLembrete();
return TIPOS_LEMBRETES_BY_ID.get( id );
}
public void criarLembrete( Integer tipoID,
Date data,
String descricao,
String texto,
Integer empresaID,
Integer estabelecimentoID,
Integer trabalhadorID,
Integer marcacaoEstabelecimentoID,
Integer marcacaoTrabalhadorID,
boolean enviarEmail,
Integer periodicidadeDias,
Integer periodicidadeMeses )
throws Exception
{
Insert insert =
new Insert( "lembretes",
new Assignment[]{
new Assignment( new Field( "tipo_id" ), tipoID ),
new Assignment( new Field( "data" ), data ),
new Assignment( new Field( "descricao" ), descricao ),
new Assignment( new Field( "texto" ), texto ),
new Assignment( new Field( "empresa_id" ), empresaID ),
new Assignment( new Field( "estabelecimento_id" ), estabelecimentoID ),
new Assignment( new Field( "trabalhador_id" ), trabalhadorID ),
new Assignment( new Field( "marcacao_estabelecimento_id" ), marcacaoEstabelecimentoID ),
new Assignment( new Field( "marcacao_trabalhador_id" ), marcacaoTrabalhadorID ),
new Assignment( new Field( "enviar_email" ), enviarEmail ? "y" : "n" ),
new Assignment( new Field( "periodicidade_dias" ), periodicidadeDias ),
new Assignment( new Field( "periodicidade_meses" ), periodicidadeMeses ) } );
EXECUTER.executeQuery( insert );
}
public void criarLembreteConsulta( Integer tipoID, Date date, String descricao, String texto, Integer empresaID, Integer estabelecimentoID, Integer trabalhadorID, Integer consultaMarcacaoID )
{
criarLembreteNew( tipoID, date, descricao, texto, empresaID, estabelecimentoID, trabalhadorID, consultaMarcacaoID, true);
}
public void criarLembreteExame( Integer tipoID, Date date, String descricao, String texto, Integer empresaID, Integer estabelecimentoID, Integer trabalhadorID, Integer consultaExameID )
{
criarLembreteNew( tipoID, date, descricao, texto, empresaID, estabelecimentoID, trabalhadorID, consultaExameID, false );
}
private void criarLembreteNew( Integer tipoID, Date date, String descricao, String texto, Integer empresaID, Integer estabelecimentoID, Integer trabalhadorID, Integer marcacaoID, boolean isConsulta )
{
try
{
Select2 query = new Select2(
new String[]{ "lembretes" },
null,
null,
new String[]{ "id" },
new Field( "tipo_id" ).isEqual( tipoID ).
and( new Field( "data" ).isEqual( date ).
and( new Field( "trabalhador_id" ).isEqual( trabalhadorID ) ) ),
null, null, null, null);
Virtual2DArray array = EXECUTER.executeQuery( query );
if( array.columnLength() == 0 )
{
Insert insert =
new Insert( "lembretes",
new Assignment[]{
new Assignment( new Field( "tipo_id" ), tipoID ),
new Assignment( new Field( "data" ), date ),
new Assignment( new Field( "descricao" ), descricao ),
new Assignment( new Field( "texto" ), texto ),
new Assignment( new Field( "empresa_id" ), empresaID ),
new Assignment( new Field( "estabelecimento_id" ), estabelecimentoID ),
new Assignment( new Field( "trabalhador_id" ), trabalhadorID ),
new Assignment( new Field( isConsulta ? "trabalhadores_consultas_datas_id" : "trabalhadores_ecds_datas_id" ), marcacaoID ) } );
EXECUTER.executeQuery( insert );
}
}
catch( Exception e )
{
e.printStackTrace();
}
}
public void apagarLembreteByID( Integer id )
throws Exception
{
Update update = new Update( "lembretes", new Assignment[]{ new Assignment(new Field("deleted_date"),new Date()) }, new Field("id").isEqual( id ) );
EXECUTER.executeQuery( update );
}
public void apagarLembreteByMarcacaoTrabalhadorID( Integer marcacaoID )
throws Exception
{
Update update = new Update( "lembretes", new Assignment[]{ new Assignment(new Field("deleted_date"),new Date()) }, new Field("marcacao_trabalhador_id").isEqual( marcacaoID ) );
EXECUTER.executeQuery( update );
}
public int countLembretesByTipo( Integer tipoID )
throws Exception
{
Select select =
new Select( new String[]{ "lembretes" },
new String[]{ "COUNT(*)" },
new Field( "tipo_id" ).isEqual( tipoID ).and(
new Field( "data" ).isLessOrEqual( new Date() ) ).and(
new Field( "deleted_date" ).isEqual( null ) ) );
Virtual2DArray array = EXECUTER.executeQuery( select );
if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
{
return 0;
}
else
{
return ( ( Number ) array.get( 0, 0 ) ).intValue();
}
}
public Lembrete[] getLembretesByTipo( Integer tipoID )
throws Exception
{
Select select =
new Select( new String[]{ "lembretes" },
new String[]{ "id", "tipo_id", "data", "descricao",
"texto", "empresa_id", "estabelecimento_id",
"trabalhador_id", "marcacao_estabelecimento_id",
"marcacao_trabalhador_id", "enviar_email",
"periodicidade_dias", "periodicidade_meses" , "trabalhadores_consultas_datas_id", "trabalhadores_ecds_datas_id" },
new Field( "tipo_id" ).isEqual( tipoID ).and(
new Field( "data" ).isLessOrEqual( new Date() ) ).and(
new Field( "deleted_date" ).isEqual( null ) ) );
Virtual2DArray array = EXECUTER.executeQuery( select );
Lembrete lembretes[] = new Lembrete[ array.columnLength() ];
for( int n = 0; n < lembretes.length; n++ )
{
Integer id = ( Integer ) array.get( n, 0 );
Date data = ( Date ) array.get( n, 2 );
String descricao = ( String ) array.get( n, 3 );
String texto = ( String ) array.get( n, 4 );
Integer empresaID = ( Integer ) array.get( n, 5 );
Integer estabelecimentoID = ( Integer ) array.get( n, 6 );
Integer trabalhadorID = ( Integer ) array.get( n, 7 );
Integer marcacaoEstabelecimentoID = ( Integer ) array.get( n, 8 );
Integer marcacaoTrabalhadorID = ( Integer ) array.get( n, 9 );
boolean enviarEmail = "y".equals( array.get( n, 10 ) );
Integer periodicidadeDias = ( Integer ) array.get( n, 11 );
Integer periodicidadeMeses = ( Integer ) array.get( n, 12 );
Integer consultaDataID = ( Integer ) array.get( 0, 13 );
Integer exameDataID = ( Integer ) array.get( 0, 14 );
lembretes[ n ] = new Lembrete( id, tipoID, data, descricao, texto,
empresaID, estabelecimentoID, trabalhadorID,
marcacaoEstabelecimentoID, marcacaoTrabalhadorID,
enviarEmail, periodicidadeDias, periodicidadeMeses, consultaDataID, exameDataID );
}
return lembretes;
}
public Lembrete getLembreteByID( Integer id )
throws Exception
{
Select select =
new Select( new String[]{ "lembretes" },
new String[]{ "id", "tipo_id", "data", "descricao",
"texto", "empresa_id", "estabelecimento_id",
"trabalhador_id", "marcacao_estabelecimento_id",
"marcacao_trabalhador_id", "enviar_email",
"periodicidade_dias", "periodicidade_meses", "trabalhadores_consultas_datas_id", "trabalhadores_ecds_datas_id" },
new Field( "id" ).isEqual( id ).and(
new Field( "deleted_date" ).isEqual( null ) ) );
Virtual2DArray array = EXECUTER.executeQuery( select );
if( array.columnLength() == 0 )
{
return null;
}
else
{
Integer tipoID = ( Integer ) array.get( 0, 1 );
Date data = ( Date ) array.get( 0, 2 );
String descricao = ( String ) array.get( 0, 3 );
String texto = ( String ) array.get( 0, 4 );
Integer empresaID = ( Integer ) array.get( 0, 5 );
Integer estabelecimentoID = ( Integer ) array.get( 0, 6 );
Integer trabalhadorID = ( Integer ) array.get( 0, 7 );
Integer marcacaoEstabelecimentoID = ( Integer ) array.get( 0, 8 );
Integer marcacaoTrabalhadorID = ( Integer ) array.get( 0, 9 );
boolean enviarEmail = "y".equals( array.get( 0, 10 ) );
Integer periodicidadeDias = ( Integer ) array.get( 0, 11 );
Integer periodicidadeMeses = ( Integer ) array.get( 0, 12 );
Integer consultaDataID = ( Integer ) array.get( 0, 13 );
Integer exameDataID = ( Integer ) array.get( 0, 14 );
return new Lembrete( id, tipoID, data, descricao, texto,
empresaID, estabelecimentoID, trabalhadorID,
marcacaoEstabelecimentoID, marcacaoTrabalhadorID,
enviarEmail, periodicidadeDias, periodicidadeMeses, consultaDataID, exameDataID );
}
}
private Calendar makeDateCalendar()
{
Calendar now = Calendar.getInstance();
Calendar nowDate = Calendar.getInstance();
nowDate.clear();
nowDate.set( Calendar.YEAR, now.get( Calendar.YEAR ) );
nowDate.set( Calendar.MONTH, now.get( Calendar.MONTH ) );
nowDate.set( Calendar.DAY_OF_MONTH, now.get( Calendar.DAY_OF_MONTH ) );
return nowDate;
}
public List<Integer> getFichasExpiradasID()
{
List<Integer> fichasExpiradas = new LinkedList<Integer>();
try
{
Calendar nowDate = makeDateCalendar();
Select2 query = new Select2(
new String[]{ "exames" },
null,
null,
new String[]{ "id" },
new Field( "proximo_exame" ).isEqual( nowDate.getTime() ).
and( new Field( "tipo" ).isEqual( FichaAptidaoConstants.CODIGO_TIPO_PERIODICO ) ),
null, null, null, null);
Virtual2DArray array = EXECUTER.executeQuery( query );
for( int i = 0; i < array.columnLength(); fichasExpiradas.add( (Integer) array.get( i, 0 ) ), ++i );
} catch( DBException e )
{
e.printStackTrace();
}
return fichasExpiradas;
}
// public List<Integer> getFichasExpiradasSemData()
// {
// List<Integer> fichasExpiradas = new LinkedList<Integer>();
// try
// {
// Calendar date = makeDateCalendar();
// date.add( Calendar.MONTH, -22 );
// Select2 query = new Select2(
// new String[]{ "exames" },
// null,
// null,
// new String[]{ "id" },
// new Field( "proximo_exame" ).isEqual( null ).and( new Field( "data" ).isEqual( date.getTime() ) ),
// null, null, null, null);
// Virtual2DArray array = EXECUTER.executeQuery( query );
// for( int i = 0; i < array.columnLength(); fichasExpiradas.add( (Integer) array.get( i, 0 ) ), ++i );
// } catch( DBException e )
// {
// e.printStackTrace();
// }
// return fichasExpiradas;
// }
public void createLembretesForFichas( List<Integer> fichas )
{
Integer tipoID = getTipoLembreteIDByCodigo( LembretesConstants.CODE_MARCACOES );
for( Integer fichaID : fichas )
{
createLembreteForFicha( fichaID, tipoID, new Date() );
}
}
private Integer getTrabalhadorIDForFichaID( Integer fichaID )
{
Integer result = null;
try
{
Select2 query = new Select2(
new String[]{ "exames" },
null,
null,
new String[]{ "trabalhador_id" },
new Field( "id" ).isEqual( fichaID ),
null, null, null, null);
Virtual2DArray array = EXECUTER.executeQuery( query );
result = (Integer) array.get( 0, 0 );
} catch( DBException e )
{
e.printStackTrace();
}
return result;
}
private void createLembreteForFicha( Integer fichaID, Integer tipoID, Date when )
{
try
{
Integer trabalhadorID = getTrabalhadorIDForFichaID( fichaID );
TrabalhadoresData trabalhador = medicinaDAO.getTrabalhadorByID( trabalhadorID );
EstabelecimentosData estabelecimento = trabalhador.toEstabelecimento_id();
EmpresasData empresa = estabelecimento.toEmpresa_id();
criarLembreteConsulta( tipoID,
when == null ? new Date() : when,
MedicinaConstants.LEMBRETE_RENOVACAO_FICHA_APTIDAO_STRING,
null,
empresa.getId(),
estabelecimento.getId(),
trabalhador.getId(),
null
);
}
catch(Exception e)
{
System.out.println(e);
}
}
public void criarLembreteFicha( ExamesData exame, Date when )
{
Integer tipoID = getTipoLembreteIDByCodigo( LembretesConstants.CODE_MARCACOES );
createLembreteForFicha( (Integer) exame.get( ExamesData.ID ), tipoID, when );
}
}

@ -1,373 +0,0 @@
/*
* LembretesWindow.java
*
* Created on 13 de Fevereiro de 2007, 11:11
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.List;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import shst.data.outer.EmpresasData;
import shst.data.outer.EstabelecimentosData;
import shst.data.provider.MedicinaDataProvider;
import siprp.lembretes.externos.LembretesExternosPanel;
import siprp.lembretes.marcacoes.LembretesMarcacaoPanel;
import siprp.lembretes.remarcacoes.LembretesRemarcacaoPanel;
import siprp.ui.SIPRPFrame;
import com.evolute.utils.tables.BaseTable;
import com.evolute.utils.tables.ColumnizedObjectArray;
import com.evolute.utils.tables.VectorTableModel;
import com.evolute.utils.tracker.TrackableWindow;
import com.evolute.utils.ui.DialogException;
/**
*
* @author Frederico
*/
public class LembretesWindow extends SIPRPFrame
implements ActionListener, TrackableWindow, ListSelectionListener,
LembretesConstants
{
private static final long serialVersionUID = 1L;
public static final String TITLE = "Lembretes";
private static final int LEFT_COLUMN_WIDTH = 302;
protected VectorTableModel< ColumnizedObjectArray > tiposModel;
protected BaseTable tiposTable;
protected JPanel lembretesPanel;
protected JButton recarregarButton;
private final JPanel leftPanel = new JPanel();
private final JCheckBox checkEmpresas = new JCheckBox();
private final JComboBox comboEmpresas = new JComboBox( );
private final JCheckBox checkEstabelecimentos = new JCheckBox();
private final JComboBox comboEstabelecimentos = new JComboBox( );
// private final MedicinaDAO medicinaDao = new MedicinaDAO();
private final MedicinaDataProvider medicinaDao = MedicinaDataProvider.getProvider();
protected LembretesDataProvider provider;
/** Creates a new instance of LembretesWindow */
public LembretesWindow()
throws Exception
{
provider = LembretesDataProvider.getProvider();
setupComponents();
}
private void setupComponents()
{
setTitle( "Lembretes" );
setSize( 1024, 700 );
tiposModel = new VectorTableModel< ColumnizedObjectArray >( new String[]{ "tipo", "quantidade" } );
tiposTable = new BaseTable( tiposModel );
tiposTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
tiposTable.fixColumnWidth( 0, 200 );
tiposTable.fixColumnWidth( 1, 100 );
tiposTable.getSelectionModel().addListSelectionListener( this );
JScrollPane scp =
new JScrollPane( tiposTable, JScrollPane.VERTICAL_SCROLLBAR_NEVER,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
scp.setPreferredSize( new Dimension( LEFT_COLUMN_WIDTH, 100 ) );
lembretesPanel = new JPanel();
lembretesPanel.setLayout( new GridLayout( 1, 1 ) );
recarregarButton = new JButton( "Recarregar" );
recarregarButton.addActionListener( this );
loadEmpresas();
loadEstabelecimentos();
double[] cols = new double[]{ TableLayout.MINIMUM, TableLayout.FILL };
double[] rows = new double[]{ TableLayout.PREFERRED, TableLayout.PREFERRED,
TableLayout.MINIMUM, TableLayout.MINIMUM,
TableLayout.MINIMUM, TableLayout.MINIMUM,
TableLayout.MINIMUM
};
TableLayout tableLayout = new TableLayout( cols, rows );
tableLayout.setHGap( 5 );
tableLayout.setVGap( 5 );
leftPanel.setPreferredSize( new Dimension( LEFT_COLUMN_WIDTH, 0 ) );
leftPanel.setLayout( tableLayout );
comboEmpresas.setPreferredSize( new Dimension( LEFT_COLUMN_WIDTH - 50, 0 ) );
comboEstabelecimentos.setPreferredSize( new Dimension( LEFT_COLUMN_WIDTH - 50, 0 ) );
checkEstabelecimentos.setEnabled( false );
comboEstabelecimentos.setEnabled( false );
leftPanel.add( scp, new TableLayoutConstraints(0,0,1,0) );
leftPanel.add( new JSeparator(), new TableLayoutConstraints(0,1,1,1) );
leftPanel.add( new JLabel( "Filtrar por:"), new TableLayoutConstraints(0,2,1,2) );
leftPanel.add( checkEmpresas, new TableLayoutConstraints(0,3) );
leftPanel.add( new JLabel( "Empresa"), new TableLayoutConstraints(1,3) );
leftPanel.add( comboEmpresas, new TableLayoutConstraints(1,4) );
leftPanel.add( checkEstabelecimentos, new TableLayoutConstraints(0,5) );
leftPanel.add( new JLabel( "Estabelecimento"), new TableLayoutConstraints(1,5) );
leftPanel.add( comboEstabelecimentos, new TableLayoutConstraints(1,6) );
cols = new double[]{ TableLayout.PREFERRED, TableLayout.FILL };
rows = new double[]{ TableLayout.FILL, TableLayout.MINIMUM };
tableLayout = new TableLayout( cols, rows );
tableLayout.setHGap( 5 );
tableLayout.setVGap( 5 );
// getContentPane().setPreferredSize( new Dimension( 300, 20 ) );
getContentPane().setLayout( tableLayout );
getContentPane().setLayout( tableLayout );
getContentPane().add( leftPanel, new TableLayoutConstraints( 0, 0 ) );
getContentPane().add( lembretesPanel, new TableLayoutConstraints( 1, 0 ) );
getContentPane().add( recarregarButton, new TableLayoutConstraints( 0, 1, 1, 1 ) );
addWindowListener( new WindowAdapter(){
public void windowClosing( WindowEvent e )
{
close();
}
public void windowOpened( WindowEvent e )
{
// setExtendedState( getExtendedState() | MAXIMIZED_BOTH );
// setSize( 1024, 700 );
reloadTotais();
}
} );
setupComboListeners();
setupCheckBoxListeners();
comboEmpresas.setEnabled( false );
comboEstabelecimentos.setEnabled( false );
}
private void setupComboListeners()
{
comboEmpresas.addItemListener( new ItemListener()
{
@Override
public void itemStateChanged( ItemEvent e )
{
if( e.getStateChange() == ItemEvent.SELECTED )
{
loadEstabelecimentos();
if( checkEmpresas.isEnabled() && checkEmpresas.isEnabled() )
{
reloadLembretes();
}
}
}
} );
comboEstabelecimentos.addItemListener( new ItemListener()
{
@Override
public void itemStateChanged( ItemEvent e )
{
if( e.getStateChange() == ItemEvent.SELECTED && checkEstabelecimentos.isEnabled() )
{
reloadLembretes();
}
}
} );
}
private void setupCheckBoxListeners()
{
checkEmpresas.addChangeListener( new ChangeListener()
{
@Override
public void stateChanged( ChangeEvent e )
{
empresasChecked();
reloadLembretes();
}
});
checkEstabelecimentos.addChangeListener( new ChangeListener()
{
@Override
public void stateChanged( ChangeEvent e )
{
reloadLembretes();
}
});
}
private void empresasChecked()
{
boolean filtrarEmpresas = checkEmpresas.isSelected();
checkEstabelecimentos.setEnabled( filtrarEmpresas );
comboEstabelecimentos.setEnabled( filtrarEmpresas );
}
public void refresh()
{
}
public void open()
{
setVisible( true );
}
public void close()
{
SwingUtilities.invokeLater( new Runnable() {
public void run()
{
setVisible( false );
dispose();
}
} );
}
protected void reloadTotais()
{
try
{
Vector< ColumnizedObjectArray > values = tiposModel.getValues();
values.clear();
TipoLembrete tipos[] = provider.getTiposLembrete();
for( int n = 0; n < tipos.length; n++ )
{
int count = provider.countLembretesByTipo( tipos[ n ].getID() );
values.add( new ColumnizedObjectArray(
new Object[]{ tipos[ n ].getID(), tipos[ n ].getDescricao(),
"" + count }, true ) );
}
tiposModel.setValues( values );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar lembretes", true );
}
}
protected void reloadLembretes()
{
lembretesPanel.removeAll();
int selected = tiposTable.getSelectedRow();
if( selected != -1 )
{
ColumnizedObjectArray line = ( ColumnizedObjectArray ) tiposModel.getRowAt( selected );
Integer tipoID = line.getID();
EmpresasData empresa = ( EmpresasData ) comboEmpresas.getSelectedItem();
EstabelecimentosData estabelecimento = ( EstabelecimentosData ) comboEstabelecimentos.getSelectedItem();
Integer empresaID = ( empresa != null && checkEmpresas.isSelected() ) ? empresa.getId() : null;
Integer estabelecimentoID = ( estabelecimento != null && checkEstabelecimentos.isSelected() ) ? estabelecimento.getId() : null;
try
{
TipoLembrete tipo = provider.getTipoLembreteByID( tipoID );
if( CODE_EXTERNO.equals( tipo.getCodigo() ) )
{
lembretesPanel.add( new LembretesExternosPanel( empresaID, estabelecimentoID ) );
}
if( CODE_REMARCACOES.equals( tipo.getCodigo() ) )
{
lembretesPanel.add( new LembretesRemarcacaoPanel( empresaID, estabelecimentoID ) );
}
if( CODE_MARCACOES.equals( tipo.getCodigo() ) )
{
lembretesPanel.add( new LembretesMarcacaoPanel( empresaID, estabelecimentoID ) );
}
if( CODE_OUTROS.equals( tipo.getCodigo() ) )
{
}
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar lembretes", true );
}
}
validate();
repaint();
}
private void loadEmpresas()
{
comboEmpresas.removeAllItems();
List< EmpresasData > allEmpresas = medicinaDao.getAllEmpresas();
for( EmpresasData empresa : allEmpresas )
{
comboEmpresas.addItem( empresa );
}
}
private void loadEstabelecimentos()
{
comboEstabelecimentos.removeAllItems();
Object selectedEmpresa = comboEmpresas.getSelectedItem();
if( selectedEmpresa != null )
{
if( selectedEmpresa instanceof EmpresasData )
{
List< EstabelecimentosData > allEstabelecimentos = ( ( EmpresasData ) selectedEmpresa ).fromEstabelecimentos_empresa_id();
for( EstabelecimentosData estabelecimento : allEstabelecimentos )
{
comboEstabelecimentos.addItem( estabelecimento );
}
}
}
}
public boolean closeIfPossible()
{
close();
return true;
}
public void actionPerformed(ActionEvent e)
{
Object source = e.getSource();
if( source.equals( recarregarButton ) )
{
reloadTotais();
loadEmpresas();
loadEstabelecimentos();
}
}
public void valueChanged(ListSelectionEvent e)
{
if( !e.getValueIsAdjusting() )
{
reloadLembretes();
boolean selected = tiposTable.getSelectedRowCount() > 0;
comboEmpresas.setEnabled( selected );
comboEstabelecimentos.setEnabled( checkEmpresas.isSelected() );
}
}
}

@ -1,65 +0,0 @@
/*
* TipoLembrete.java
*
* Created on February 5, 2007, 6:28 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes;
import com.evolute.utils.data.IDObject;
/**
*
* @author lflores
*/
public class TipoLembrete
implements IDObject, Comparable< Object >
{
protected Integer id;
protected String codigo;
protected String descricao;
protected Integer ordem;
/** Creates a new instance of TipoLembrete */
public TipoLembrete( Integer id, String codigo, String descricao,
Integer ordem )
{
this.id = id;
this.codigo = codigo;
this.descricao = descricao;
this.ordem = ordem;
}
public Integer getID()
{
return id;
}
protected String getCodigo()
{
return codigo;
}
protected String getDescricao()
{
return descricao;
}
protected Integer getOrdem()
{
return ordem;
}
public int compareTo( Object other )
{
if( !( other instanceof TipoLembrete ) )
{
return 0;
}
TipoLembrete otl = ( TipoLembrete ) other;
return getOrdem().compareTo( otl.getOrdem() );
}
}

@ -1,54 +0,0 @@
/*
* RemarcacoesActionFactory.java
*
* Created on January 31, 2007, 6:37 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes.externos;
import javax.swing.Action;
import siprp.lembretes.externos.actions.TratarExternoAction;
import com.evolute.utils.data.IDObject;
import com.evolute.utils.ui.panel.multipleactionlist.ActionFactory;
/**
*
* @author fpalma
*/
public class ExternosActionFactory implements ActionFactory<IDObject>
{
public static final int TRABALHADOR = 0;
protected final int TIPO;
/**
* Creates a new instance of RemarcacoesActionFactory
*/
public ExternosActionFactory( int tipo )
{
TIPO = tipo;
}
public Action createAction(IDObject[] objects)
{
return null;
}
public Action createAction(IDObject object)
{
switch( TIPO )
{
case TRABALHADOR:
return new TratarExternoAction( object );
default:
return null;
}
}
}

@ -1,141 +0,0 @@
/*
* RemarcacoesDataProvider.java
*
* Created on February 14, 2007, 10:56 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes.externos;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import siprp.lembretes.LembretesConstants;
import siprp.lembretes.LembretesDataProvider;
import com.evolute.utils.Singleton;
import com.evolute.utils.arrays.Virtual2DArray;
import com.evolute.utils.data.IDObject;
import com.evolute.utils.data.MappableObject;
import com.evolute.utils.db.DBManager;
import com.evolute.utils.db.Executer;
import com.evolute.utils.sql.Expression;
import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Select;
import com.evolute.utils.sql.Select2;
/**
*
* @author lflores
*/
public class LembretesExternosDataProvider
{
private static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
private static final Object LOCK = new Object();
private static LembretesExternosDataProvider instance = null;
private Executer EXECUTER;
private LembretesDataProvider lembretesProvider;
/** Creates a new instance of RemarcacoesDataProvider */
public LembretesExternosDataProvider()
throws Exception
{
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
EXECUTER = dbm.getSharedExecuter( this );
lembretesProvider = LembretesDataProvider.getProvider();
}
public static LembretesExternosDataProvider getProvider()
throws Exception
{
synchronized( LOCK )
{
if( instance == null )
{
instance = new LembretesExternosDataProvider();
}
}
return instance;
}
private Expression whereExpressionLembretesRemarcacao( Integer empresaID, Integer estabelecimentoID ) throws Exception
{
Expression result = new Field( "lembretes.tipo_id" ).isEqual(
lembretesProvider.getTipoLembreteByCodigo( LembretesConstants.CODE_EXTERNO ).getID() ).and(
new Field( "lembretes.data" ).isLessOrEqual( new Field( "current_date" ) ) ).and(
new Field( "lembretes.deleted_date" ).isEqual( null ) );
if( empresaID != null )
{
result = result.and( new Field("empresas.id").isEqual( empresaID ) );
if( estabelecimentoID != null )
{
result = result.and( new Field("estabelecimentos.id").isEqual( estabelecimentoID ) );
}
}
return result;
}
public IDObject[] getLembretesMarcacaoTrabalhador( Integer empresaID, Integer estabelecimentoID )
throws Exception
{
Select select =
new Select2( new String[]{ "lembretes", "marcacoes_trabalhador", "trabalhadores",
"estabelecimentos", "empresas", "trabalhadores_consultas_datas", "trabalhadores_ecds_datas"},
new Integer [] {
Select2.JOIN_LEFT_OUTER, Select2.JOIN_LEFT_OUTER,
Select2.JOIN_LEFT_OUTER, Select2.JOIN_LEFT_OUTER,
Select2.JOIN_LEFT_OUTER, Select2.JOIN_LEFT_OUTER
},
new Expression[]{
new Field( "lembretes.marcacao_trabalhador_id" ).isEqual( new Field( "marcacoes_trabalhador.id" ) ),/*.or(
new Field( "lembretes.trabalhadores_consultas_datas_id" ).isEqual( new Field( "trabalhadores_consultas_datas.id" ) )
).or(
new Field( "lembretes.trabalhadores_ecds_datas_id" ).isEqual( new Field( "trabalhadores_ecds_datas.id" ) )
),
*/
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).or( new Field( "lembretes.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ),
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ),
new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ),
new Field( "lembretes.trabalhadores_consultas_datas_id" ).isEqual( new Field( "trabalhadores_consultas_datas.id" ) ),
new Field( "lembretes.trabalhadores_ecds_datas_id" ).isEqual( new Field( "trabalhadores_ecds_datas.id" ) )
},
new String[]{ "lembretes.id", "lembretes.descricao",
"marcacoes_trabalhador.tipo", "lembretes.data",
"trabalhadores.nome", "estabelecimentos.nome", "empresas.designacao_social",
"trabalhadores.nome_plain" },
whereExpressionLembretesRemarcacao( empresaID, estabelecimentoID ),
new String[]{ "trabalhadores.nome_plain" },
null,
null,
null
);
Virtual2DArray array = EXECUTER.executeQuery( select );
IDObject lembretes[] = new IDObject[ array.columnLength() ];
for( int n = 0; n < lembretes.length; n++ )
{
Integer id = ( Integer ) array.get( n, 0 );
String descricao = ( String ) array.get( n, 1 );
Date data = ( Date ) array.get( n, 3 );
String trabalhador = ( String ) array.get( n, 4 );
String split[] = trabalhador.split( " " );
trabalhador = split[ 0 ] + " " + ( split.length > 2 ? split[ 1 ].charAt( 0 ) + ". " : " " ) +
( split.length > 1 ? split[ split.length - 1 ] : "" );
String estabelecimento = ( String ) array.get( n, 5 );
String empresa = ( String ) array.get( n, 6 );
String str = "<html><body><font color=\"#00009f\">" + trabalhador + "</font>"
+ "<br>&nbsp;&nbsp;&nbsp;" + "" + " de " + D_F.format( data )
+ "<br>&nbsp;&nbsp;&nbsp;<font color=\"#009f00\">" + descricao + "</font>"
+ "<br>&nbsp;&nbsp;&nbsp;" + empresa.substring( 0, empresa.length() > 20 ? 20 : empresa.length() )
+ " / " + estabelecimento.substring( 0, estabelecimento.length() > 10 ? 10 : estabelecimento.length() )
+ "</body></html>";
lembretes[ n ] = new MappableObject( id, str );
}
return lembretes;
}
}

@ -1,69 +0,0 @@
/*
* LembretesRemarcacaoPanel.java
*
* Created on 13 de Fevereiro de 2007, 23:24
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes.externos;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import siprp.lembretes.LembretesConstants;
import com.evolute.entity.ProviderInterface;
import com.evolute.utils.ui.panel.multipleactionlist.MultipleActionListPanel;
public class LembretesExternosPanel extends JPanel
implements LembretesConstants
{
protected JScrollPane listTrabalhadoresScroll;
protected MultipleActionListPanel listTrabalhadoresPanel;
protected LembretesExternosDataProvider provider;
private final Integer empresaID;
private final Integer estabelecimentoID;
private ProviderInterface JDO;
/** Creates a new instance of LembretesRemarcacaoPanel */
public LembretesExternosPanel( Integer empresaID, Integer estabelecimentoID )
throws Exception
{
this.empresaID = empresaID;
this.estabelecimentoID = estabelecimentoID;
provider = LembretesExternosDataProvider.getProvider();
setupComponents();
}
private void setupComponents()
throws Exception
{
listTrabalhadoresPanel =
new MultipleActionListPanel(
new ExternosActionFactory[]{ },
new ExternosActionFactory[]{ new ExternosActionFactory( ExternosActionFactory.TRABALHADOR ) } );
listTrabalhadoresScroll =
new JScrollPane( listTrabalhadoresPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
setLayout( new GridLayout( 1, 2 ) );
JPanel trabalhadoresPanel = new JPanel();
add( trabalhadoresPanel );
trabalhadoresPanel.setLayout( new BorderLayout() );
trabalhadoresPanel.add( new JLabel( "Consultas / ECDs", JLabel.CENTER ), BorderLayout.NORTH );
trabalhadoresPanel.add( listTrabalhadoresScroll, BorderLayout.CENTER );
listTrabalhadoresPanel.showList( provider.getLembretesMarcacaoTrabalhador( empresaID, estabelecimentoID ) );
// listEstabelecimentosPanel.showList( estabelecimentos.toArray( new IDObject[ estabelecimentos.size() ] ) );
}
}

@ -1,112 +0,0 @@
/*
* TratarMarcacaoTrabalhadorAction.java
*
* Created on January 31, 2007, 6:21 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes.externos.actions;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.JOptionPane;
import shst.SHSTPropertiesConstants;
import shst.data.outer.EmpresasData;
import shst.data.outer.EstabelecimentosData;
import shst.data.outer.TrabalhadoresData;
import shst.data.provider.MedicinaDataProvider;
import shst.medicina.multi.MultiMarcacoesWindow;
import siprp.SIPRPTracker;
import siprp.lembretes.Lembrete;
import siprp.lembretes.LembretesDataProvider;
import com.evolute.utils.Singleton;
import com.evolute.utils.data.IDObject;
import com.evolute.utils.ui.DialogException;
/**
*
* @author fpalma
*/
public class TratarExternoAction extends AbstractAction
{
private static final long serialVersionUID = 1L;
private LembretesDataProvider lembretesProvider;
private SIPRPTracker tracker;
private Integer lembreteID;
private MedicinaDataProvider medicinaDAO = null;
/**
* Creates a new instance of TratarMarcacaoTrabalhadorAction
*/
public TratarExternoAction(IDObject lembrete)
{
super( "Tratar" );
try
{
lembreteID = lembrete.getID();
lembretesProvider = LembretesDataProvider.getProvider();
medicinaDAO = MedicinaDataProvider.getProvider();
} catch( Exception ex )
{
ex.printStackTrace();
}
}
public void actionPerformed( ActionEvent e )
{
try
{
tracker = (SIPRPTracker) Singleton.getInstance( SHSTPropertiesConstants.SHST_TRACKER /*SingletonConstants.SIPRP_TRACKER*/ );
Lembrete lembrete = lembretesProvider.getLembreteByID( lembreteID );
if( lembrete == null )
{
JOptionPane.showMessageDialog( null, "Este lembrete j\u00e1 foi tratado.", "J\u00e1 tratado", JOptionPane.WARNING_MESSAGE );
}
else
{
TrabalhadoresData trabalhador = null;
EstabelecimentosData estabelecimento = null;
EmpresasData empresa = null;
trabalhador = medicinaDAO.getTrabalhadorByID( lembrete.getTrabalhadorID() );
estabelecimento = trabalhador.toEstabelecimento_id();
empresa = estabelecimento.toEmpresa_id();
List< Integer > trabalhadoresIDs = new ArrayList< Integer >();
trabalhadoresIDs.add( trabalhador.getId() );
MultiMarcacoesWindow window = tracker.getMultiMarcacoesWindow();
window.setEmpresaAndEstabelecimento( empresa.getId(), estabelecimento.getId(), trabalhadoresIDs );
window.setVisible( true );
// MedicinaProcessoWindow window = tracker.getMedicinaProcessoWindow();
// window.runActionLater( MedicinaProcessoLogic.SELECT_EMPRESA, empresa );
// window.runActionLater( MedicinaProcessoLogic.SELECT_ESTABELECIMENTO, estabelecimento );
// window.runActionLater( MedicinaProcessoLogic.LOAD_TRABALHADOR, trabalhador );
// window.runActionLater( MedicinaProcessoLogic.SELECT_TRABALHADOR, trabalhador );
// window.runPendingActions();
// window.setVisible( true );
lembretesProvider.apagarLembreteByID( lembreteID );
}
Object source = e.getSource();
if( source instanceof Component )
{
((Component) source).setEnabled( false );
}
} catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a tratar", true );
}
}
}

@ -1,69 +0,0 @@
/*
* LembretesRemarcacaoPanel.java
*
* Created on 13 de Fevereiro de 2007, 23:24
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes.marcacoes;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import siprp.lembretes.LembretesConstants;
import com.evolute.entity.ProviderInterface;
import com.evolute.utils.ui.panel.multipleactionlist.MultipleActionListPanel;
public class LembretesMarcacaoPanel extends JPanel
implements LembretesConstants
{
protected JScrollPane listTrabalhadoresScroll;
protected MultipleActionListPanel listTrabalhadoresPanel;
protected MarcacoesDataProvider provider;
private final Integer empresaID;
private final Integer estabelecimentoID;
private ProviderInterface JDO;
/** Creates a new instance of LembretesRemarcacaoPanel */
public LembretesMarcacaoPanel( Integer empresaID, Integer estabelecimentoID )
throws Exception
{
this.empresaID = empresaID;
this.estabelecimentoID = estabelecimentoID;
provider = MarcacoesDataProvider.getProvider();
setupComponents();
}
private void setupComponents()
throws Exception
{
listTrabalhadoresPanel =
new MultipleActionListPanel(
new MarcacoesActionFactory[]{ },
new MarcacoesActionFactory[]{ new MarcacoesActionFactory( MarcacoesActionFactory.TRABALHADOR ) } );
listTrabalhadoresScroll =
new JScrollPane( listTrabalhadoresPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
setLayout( new GridLayout( 1, 2 ) );
JPanel trabalhadoresPanel = new JPanel();
add( trabalhadoresPanel );
trabalhadoresPanel.setLayout( new BorderLayout() );
trabalhadoresPanel.add( new JLabel( "Consultas / ECDs", JLabel.CENTER ), BorderLayout.NORTH );
trabalhadoresPanel.add( listTrabalhadoresScroll, BorderLayout.CENTER );
listTrabalhadoresPanel.showList( provider.getLembretesMarcacaoTrabalhador( empresaID, estabelecimentoID ) );
// listEstabelecimentosPanel.showList( estabelecimentos.toArray( new IDObject[ estabelecimentos.size() ] ) );
}
}

@ -1,54 +0,0 @@
/*
* RemarcacoesActionFactory.java
*
* Created on January 31, 2007, 6:37 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes.marcacoes;
import javax.swing.Action;
import siprp.lembretes.marcacoes.actions.TratarCriacaoProcessoTrabalhadorAction;
import com.evolute.utils.data.IDObject;
import com.evolute.utils.ui.panel.multipleactionlist.ActionFactory;
/**
*
* @author fpalma
*/
public class MarcacoesActionFactory implements ActionFactory<IDObject>
{
public static final int TRABALHADOR = 0;
protected final int TIPO;
/**
* Creates a new instance of RemarcacoesActionFactory
*/
public MarcacoesActionFactory( int tipo )
{
TIPO = tipo;
}
public Action createAction(IDObject[] objects)
{
return null;
}
public Action createAction(IDObject object)
{
switch( TIPO )
{
case TRABALHADOR:
return new TratarCriacaoProcessoTrabalhadorAction( object );
default:
return null;
}
}
}

@ -1,150 +0,0 @@
/*
* RemarcacoesDataProvider.java
*
* Created on February 14, 2007, 10:56 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes.marcacoes;
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import siprp.lembretes.LembretesConstants;
import siprp.lembretes.LembretesDataProvider;
import com.evolute.utils.Singleton;
import com.evolute.utils.arrays.Virtual2DArray;
import com.evolute.utils.data.IDObject;
import com.evolute.utils.data.MappableObject;
import com.evolute.utils.db.DBManager;
import com.evolute.utils.db.Executer;
import com.evolute.utils.sql.Expression;
import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Select;
import com.evolute.utils.sql.Select2;
/**
*
* @author lflores
*/
public class MarcacoesDataProvider
{
private static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
private static final Object LOCK = new Object();
private static MarcacoesDataProvider instance = null;
private Executer EXECUTER;
private LembretesDataProvider lembretesProvider;
/** Creates a new instance of RemarcacoesDataProvider */
public MarcacoesDataProvider()
throws Exception
{
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
EXECUTER = dbm.getSharedExecuter( this );
lembretesProvider = LembretesDataProvider.getProvider();
}
public static MarcacoesDataProvider getProvider()
throws Exception
{
synchronized( LOCK )
{
if( instance == null )
{
instance = new MarcacoesDataProvider();
}
}
return instance;
}
private Expression whereExpressionLembretesRemarcacao( Integer empresaID, Integer estabelecimentoID ) throws Exception
{
Expression result = new Field( "lembretes.tipo_id" ).isEqual(
lembretesProvider.getTipoLembreteByCodigo( LembretesConstants.CODE_MARCACOES ).getID() ).and(
new Field( "lembretes.data" ).isLessOrEqual( new Field( "current_date" ) ) ).and(
new Field( "lembretes.deleted_date" ).isEqual( null ) );
if( empresaID != null )
{
result = result.and( new Field("empresas.id").isEqual( empresaID ) );
if( estabelecimentoID != null )
{
result = result.and( new Field("estabelecimentos.id").isEqual( estabelecimentoID ) );
}
}
return result;
}
public IDObject[] getLembretesMarcacaoTrabalhador( Integer empresaID, Integer estabelecimentoID )
throws Exception
{
Select select =
new Select2( new String[]{ "lembretes", "marcacoes_trabalhador", "trabalhadores",
"estabelecimentos", "empresas", "trabalhadores_consultas_datas", "trabalhadores_ecds_datas"},
new Integer [] {
Select2.JOIN_LEFT_OUTER, Select2.JOIN_LEFT_OUTER,
Select2.JOIN_LEFT_OUTER, Select2.JOIN_LEFT_OUTER,
Select2.JOIN_LEFT_OUTER, Select2.JOIN_LEFT_OUTER
},
new Expression[]{
new Field( "lembretes.marcacao_trabalhador_id" ).isEqual( new Field( "marcacoes_trabalhador.id" ) ),/*.or(
new Field( "lembretes.trabalhadores_consultas_datas_id" ).isEqual( new Field( "trabalhadores_consultas_datas.id" ) )
).or(
new Field( "lembretes.trabalhadores_ecds_datas_id" ).isEqual( new Field( "trabalhadores_ecds_datas.id" ) )
),
*/
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).or( new Field( "lembretes.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ),
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ),
new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ),
new Field( "lembretes.trabalhadores_consultas_datas_id" ).isEqual( new Field( "trabalhadores_consultas_datas.id" ) ),
new Field( "lembretes.trabalhadores_ecds_datas_id" ).isEqual( new Field( "trabalhadores_ecds_datas.id" ) )
},
new String[]{ "lembretes.id", "lembretes.descricao",
"marcacoes_trabalhador.tipo", "lembretes.data",
"trabalhadores.nome", "estabelecimentos.nome", "empresas.designacao_social",
"trabalhadores.nome_plain" },
whereExpressionLembretesRemarcacao( empresaID, estabelecimentoID ),
new String[]{ "trabalhadores.nome_plain" },
null,
null,
null
);
Virtual2DArray array = EXECUTER.executeQuery( select );
IDObject lembretes[] = new IDObject[ array.columnLength() ];
for( int n = 0; n < lembretes.length; n++ )
{
Integer id = ( Integer ) array.get( n, 0 );
String descricao = ( String ) array.get( n, 1 );
Date data = ( Date ) array.get( n, 3 );
Calendar c = Calendar.getInstance();
c.setTime( data );
// c.add( Calendar.MONTH, 2 );
//
String trabalhador = ( String ) array.get( n, 4 );
String split[] = trabalhador.split( " " );
if( split != null && split.length > 1 && split[0] != null && split[0].length() > 0 && split[1] != null && split[1].length() > 0 )
{
trabalhador = split[ 0 ] + " " + ( split.length > 2 ? split[ 1 ].charAt( 0 ) + ". " : " " ) +
( split.length > 1 ? split[ split.length - 1 ] : "" );
String estabelecimento = ( String ) array.get( n, 5 );
String empresa = ( String ) array.get( n, 6 );
String str = "<html><body><font color=\"#00009f\">" + trabalhador + "</font>"
+ "<br>&nbsp;&nbsp;&nbsp;" + "Ficha de aptid" + atilde + "o caduca a " + D_F.format( c.getTime() )
+ "<br>&nbsp;&nbsp;&nbsp;<font color=\"#009f00\">" + descricao + "</font>"
+ "<br>&nbsp;&nbsp;&nbsp;" + empresa.substring( 0, empresa.length() > 20 ? 20 : empresa.length() )
+ " / " + estabelecimento.substring( 0, estabelecimento.length() > 10 ? 10 : estabelecimento.length() )
+ "</body></html>";
lembretes[ n ] = new MappableObject( id, str );
}
}
return lembretes;
}
}

@ -1,118 +0,0 @@
/*
* TratarMarcacaoTrabalhadorAction.java
*
* Created on January 31, 2007, 6:21 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes.marcacoes.actions;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.JOptionPane;
import shst.SHSTPropertiesConstants;
import shst.data.outer.EmpresasData;
import shst.data.outer.EstabelecimentosData;
import shst.data.outer.TrabalhadoresData;
import shst.data.provider.MedicinaDataProvider;
import shst.medicina.multi.MultiMarcacoesWindow;
import siprp.SIPRPTracker;
import siprp.lembretes.Lembrete;
import siprp.lembretes.LembretesDataProvider;
import com.evolute.entity.ProviderInterface;
import com.evolute.utils.Singleton;
import com.evolute.utils.data.IDObject;
import com.evolute.utils.ui.DialogException;
/**
*
* @author fpalma
*/
public class TratarCriacaoProcessoTrabalhadorAction extends AbstractAction
{
private static final long serialVersionUID = 1L;
private LembretesDataProvider lembretesProvider;
private ProviderInterface JDO;
private SIPRPTracker tracker;
private Integer lembreteID;
private MedicinaDataProvider medicinaDAO = null;
/**
* Creates a new instance of TratarMarcacaoTrabalhadorAction
*/
public TratarCriacaoProcessoTrabalhadorAction( IDObject lembrete )
{
super( "Tratar" );
try
{
lembreteID = lembrete.getID();
lembretesProvider = LembretesDataProvider.getProvider();
JDO = (ProviderInterface) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_PROVIDER );
medicinaDAO = MedicinaDataProvider.getProvider();
}
catch( Exception ex )
{
ex.printStackTrace();
}
}
public void actionPerformed(ActionEvent e)
{
try
{
tracker = ( SIPRPTracker ) Singleton.getInstance( SHSTPropertiesConstants.SHST_TRACKER /*SingletonConstants.SIPRP_TRACKER*/ );
Lembrete lembrete = lembretesProvider.getLembreteByID( lembreteID );
if( lembrete == null )
{
JOptionPane.showMessageDialog( null, "Este lembrete j\u00e1 foi tratado.", "J\u00e1 tratado",
JOptionPane.WARNING_MESSAGE );
}
else
{
TrabalhadoresData trabalhador = null;
EstabelecimentosData estabelecimento = null;
EmpresasData empresa = null;
trabalhador = medicinaDAO.getTrabalhadorByID( lembrete.getTrabalhadorID() );
estabelecimento = trabalhador.toEstabelecimento_id();
empresa = estabelecimento.toEmpresa_id();
List< Integer > trabalhadoresIDs = new ArrayList< Integer >();
trabalhadoresIDs.add( trabalhador.getId() );
MultiMarcacoesWindow window = tracker.getMultiMarcacoesWindow();
window.setEmpresaAndEstabelecimento( empresa.getId(), estabelecimento.getId(), trabalhadoresIDs );
window.setVisible( true );
// MedicinaProcessoWindow window = tracker.getMedicinaProcessoWindow();
// window.runActionLater( MedicinaProcessoLogic.SELECT_EMPRESA, empresa );
// window.runActionLater( MedicinaProcessoLogic.SELECT_ESTABELECIMENTO, estabelecimento );
// window.runActionLater( MedicinaProcessoLogic.LOAD_TRABALHADOR, trabalhador );
// window.runActionLater( MedicinaProcessoLogic.SELECT_TRABALHADOR, trabalhador );
// window.runPendingActions();
// window.setVisible( true );
lembretesProvider.apagarLembreteByID( lembreteID );
}
Object source = e.getSource();
if( source instanceof Component )
{
((Component) source).setEnabled( false );
}
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a tratar", true );
}
}
}

@ -1,92 +0,0 @@
/*
* LembretesRemarcacaoPanel.java
*
* Created on 13 de Fevereiro de 2007, 23:24
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes.remarcacoes;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import siprp.lembretes.LembretesConstants;
import com.evolute.entity.ProviderInterface;
import com.evolute.utils.ui.panel.multipleactionlist.MultipleActionListPanel;
/**
*
* @author Frederico
*/
public class LembretesRemarcacaoPanel extends JPanel
implements LembretesConstants
{
protected JScrollPane listTrabalhadoresScroll;
protected JScrollPane listEstabelecimentosScroll;
protected MultipleActionListPanel listTrabalhadoresPanel;
protected MultipleActionListPanel listEstabelecimentosPanel;
protected RemarcacoesDataProvider provider;
private final Integer empresaID;
private final Integer estabelecimentoID;
private ProviderInterface JDO;
/** Creates a new instance of LembretesRemarcacaoPanel */
public LembretesRemarcacaoPanel( Integer empresaID, Integer estabelecimentoID )
throws Exception
{
this.empresaID = empresaID;
this.estabelecimentoID = estabelecimentoID;
provider = RemarcacoesDataProvider.getProvider();
setupComponents();
}
private void setupComponents()
throws Exception
{
listTrabalhadoresPanel =
new MultipleActionListPanel(
new RemarcacoesActionFactory[]{ },
new RemarcacoesActionFactory[]{ new RemarcacoesActionFactory( RemarcacoesActionFactory.TRABALHADOR ) } );
listTrabalhadoresScroll =
new JScrollPane( listTrabalhadoresPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
listEstabelecimentosPanel =
new MultipleActionListPanel(
new RemarcacoesActionFactory[]{ },
new RemarcacoesActionFactory[]{ new RemarcacoesActionFactory( RemarcacoesActionFactory.ESTABELECIMENTO ) } );
listEstabelecimentosScroll =
new JScrollPane( listEstabelecimentosPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
setLayout( new GridLayout( 1, 2 ) );
JPanel trabalhadoresPanel = new JPanel();
JPanel estabelecimentosPanel = new JPanel();
add( trabalhadoresPanel );
add( estabelecimentosPanel );
trabalhadoresPanel.setLayout( new BorderLayout() );
trabalhadoresPanel.add( new JLabel( "Consultas / ECDs", JLabel.CENTER ), BorderLayout.NORTH );
trabalhadoresPanel.add( listTrabalhadoresScroll, BorderLayout.CENTER );
estabelecimentosPanel.setLayout( new BorderLayout() );
estabelecimentosPanel.add( new JLabel( "Higiene e Seguran\u00e7a", JLabel.CENTER ), BorderLayout.NORTH );
estabelecimentosPanel.add( listEstabelecimentosScroll, BorderLayout.CENTER );
listTrabalhadoresPanel.showList( provider.getLembretesRemarcacaoTrabalhador( empresaID, estabelecimentoID ) );
// listEstabelecimentosPanel.showList( estabelecimentos.toArray( new IDObject[ estabelecimentos.size() ] ) );
}
protected String criarDetalhesMarcacaoTrabalhador( Integer marcacaoID )
{
return null;
}
}

@ -1,59 +0,0 @@
/*
* RemarcacoesActionFactory.java
*
* Created on January 31, 2007, 6:37 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes.remarcacoes;
import javax.swing.Action;
import siprp.lembretes.remarcacoes.actions.TratarMarcacaoEstabelecimentoAction;
import siprp.lembretes.remarcacoes.actions.TratarMarcacaoTrabalhadorAction;
import com.evolute.utils.data.IDObject;
import com.evolute.utils.ui.panel.multipleactionlist.ActionFactory;
/**
*
* @author fpalma
*/
public class RemarcacoesActionFactory implements ActionFactory<IDObject>
{
public static final int TRABALHADOR = 0;
public static final int ESTABELECIMENTO = 1;
protected final int TIPO;
/**
* Creates a new instance of RemarcacoesActionFactory
*/
public RemarcacoesActionFactory( int tipo )
{
TIPO = tipo;
}
public Action createAction(IDObject[] objects)
{
return null;
}
public Action createAction(IDObject object)
{
switch( TIPO )
{
case TRABALHADOR:
return new TratarMarcacaoTrabalhadorAction( object );
case ESTABELECIMENTO:
return new TratarMarcacaoEstabelecimentoAction( object );
default:
return null;
}
}
}

@ -1,170 +0,0 @@
/*
* RemarcacoesDataProvider.java
*
* Created on February 14, 2007, 10:56 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes.remarcacoes;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import shst.data.Marcacao;
import siprp.lembretes.LembretesConstants;
import siprp.lembretes.LembretesDataProvider;
import com.evolute.utils.Singleton;
import com.evolute.utils.arrays.Virtual2DArray;
import com.evolute.utils.data.IDObject;
import com.evolute.utils.data.MappableObject;
import com.evolute.utils.db.DBManager;
import com.evolute.utils.db.Executer;
import com.evolute.utils.sql.Expression;
import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Select;
import com.evolute.utils.sql.Select2;
/**
*
* @author lflores
*/
public class RemarcacoesDataProvider
{
private static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
private static final Object LOCK = new Object();
private static RemarcacoesDataProvider instance = null;
private Executer EXECUTER;
private LembretesDataProvider lembretesProvider;
/** Creates a new instance of RemarcacoesDataProvider */
public RemarcacoesDataProvider()
throws Exception
{
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
EXECUTER = dbm.getSharedExecuter( this );
lembretesProvider = LembretesDataProvider.getProvider();
}
public static RemarcacoesDataProvider getProvider()
throws Exception
{
synchronized( LOCK )
{
if( instance == null )
{
instance = new RemarcacoesDataProvider();
}
}
return instance;
}
private Expression whereExpressionLembretesRemarcacao( Integer empresaID, Integer estabelecimentoID ) throws Exception
{
Expression result = new Field( "lembretes.tipo_id" ).isEqual(
lembretesProvider.getTipoLembreteByCodigo( LembretesConstants.CODE_REMARCACOES ).getID() ).and(
new Field( "lembretes.data" ).isLessOrEqual( new Field( "current_date" ) ) ).and(
new Field( "lembretes.deleted_date" ).isEqual( null ) );
if( empresaID != null )
{
result = result.and( new Field("empresas.id").isEqual( empresaID ) );
if( estabelecimentoID != null )
{
result = result.and( new Field("estabelecimentos.id").isEqual( estabelecimentoID ) );
}
}
return result;
}
public IDObject[] getLembretesRemarcacaoTrabalhador( Integer empresaID, Integer estabelecimentoID )
throws Exception
{
Select select =
new Select2( new String[]{ "lembretes", "marcacoes_trabalhador", "trabalhadores",
"estabelecimentos", "empresas", "trabalhadores_consultas_datas", "trabalhadores_ecds_datas"},
new Integer [] {
Select2.JOIN_LEFT_OUTER, Select2.JOIN_LEFT_OUTER,
Select2.JOIN_LEFT_OUTER, Select2.JOIN_LEFT_OUTER,
Select2.JOIN_LEFT_OUTER, Select2.JOIN_LEFT_OUTER
},
new Expression[]{
new Field( "lembretes.marcacao_trabalhador_id" ).isEqual( new Field( "marcacoes_trabalhador.id" ) ),/*.or(
new Field( "lembretes.trabalhadores_consultas_datas_id" ).isEqual( new Field( "trabalhadores_consultas_datas.id" ) )
).or(
new Field( "lembretes.trabalhadores_ecds_datas_id" ).isEqual( new Field( "trabalhadores_ecds_datas.id" ) )
),
*/
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).or( new Field( "lembretes.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ),
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ),
new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ),
new Field( "lembretes.trabalhadores_consultas_datas_id" ).isEqual( new Field( "trabalhadores_consultas_datas.id" ) ),
new Field( "lembretes.trabalhadores_ecds_datas_id" ).isEqual( new Field( "trabalhadores_ecds_datas.id" ) )
},
new String[]{ "lembretes.id", "lembretes.descricao",
"marcacoes_trabalhador.tipo", "marcacoes_trabalhador.data",
"trabalhadores.nome", "estabelecimentos.nome", "empresas.designacao_social",
"trabalhadores.nome_plain", "trabalhadores_consultas_datas.data", "trabalhadores_ecds_datas.data" },
whereExpressionLembretesRemarcacao( empresaID, estabelecimentoID ),
new String[]{ "trabalhadores.nome_plain" },
null,
null,
null
);
Virtual2DArray array = EXECUTER.executeQuery( select );
IDObject lembretes[] = new IDObject[ array.columnLength() ];
for( int n = 0; n < lembretes.length; n++ )
{
Integer id = ( Integer ) array.get( n, 0 );
String descricao = ( String ) array.get( n, 1 );
Integer tipoMarcacao = ( Integer ) array.get( n, 2 );
Date trabalhadorConsultaDataData = ( Date ) array.get( n, 8 );
Date trabalhadorExameDataData = ( Date ) array.get( n, 9 );
Date data = ( Date ) array.get( n, 3 );
if( tipoMarcacao == null )
{
if( trabalhadorConsultaDataData != null )
{
tipoMarcacao = Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA;
data = trabalhadorConsultaDataData;
}
else if( trabalhadorExameDataData != null )
{
tipoMarcacao = Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES;
data = trabalhadorExameDataData;
}
}
String tipoMarcacaoStr = "";
if( tipoMarcacao != null )
{
switch( tipoMarcacao.intValue() )
{
case Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES:
tipoMarcacaoStr = "ECDs";
break;
case Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA:
tipoMarcacaoStr = "Consulta";
break;
}
}
String trabalhador = ( String ) array.get( n, 4 );
String split[] = trabalhador.split( " " );
trabalhador = split[ 0 ] + " " + ( split.length > 2 ? split[ 1 ].charAt( 0 ) + ". " : " " ) +
( split.length > 1 ? split[ split.length - 1 ] : "" );
String estabelecimento = ( String ) array.get( n, 5 );
String empresa = ( String ) array.get( n, 6 );
String str = "<html><body><font color=\"#00009f\">" + trabalhador + "</font>"
+ "<br>&nbsp;&nbsp;&nbsp;" + tipoMarcacaoStr + " de " + (data == null ? "(data desconhecida)" : D_F.format( data ))
+ "<br>&nbsp;&nbsp;&nbsp;<font color=\"#009f00\">" + descricao + "</font>"
+ "<br>&nbsp;&nbsp;&nbsp;" + empresa.substring( 0, empresa.length() > 20 ? 20 : empresa.length() )
+ " / " + estabelecimento.substring( 0, estabelecimento.length() > 10 ? 10 : estabelecimento.length() )
+ "</body></html>";
lembretes[ n ] = new MappableObject( id, str );
}
return lembretes;
}
}

@ -1,50 +0,0 @@
/*
* tratarMarcacaoTrabalhadorAction.java
*
* Created on January 31, 2007, 6:21 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes.remarcacoes.actions;
import java.awt.Component;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import com.evolute.utils.data.IDObject;
import com.evolute.utils.ui.DialogException;
/**
*
* @author fpalma
*/
public class TratarMarcacaoEstabelecimentoAction extends AbstractAction
{
/**
* Creates a new instance of tratarMarcacaoTrabalhadorAction
*/
public TratarMarcacaoEstabelecimentoAction( IDObject marcacaoID )
{
super( "Tratar" );
}
public void actionPerformed(ActionEvent e)
{
try
{
Object source = e.getSource();
if( source instanceof Component )
{
((Component) source).setEnabled( false );
}
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a marcar", true );
}
}
}

@ -1,167 +0,0 @@
/*
* TratarMarcacaoTrabalhadorAction.java
*
* Created on January 31, 2007, 6:21 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes.remarcacoes.actions;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.JOptionPane;
import shst.SHSTPropertiesConstants;
import shst.data.outer.EmpresasData;
import shst.data.outer.EstabelecimentosData;
import shst.data.outer.MarcacoesTrabalhadorData;
import shst.data.outer.TrabalhadoresConsultasData;
import shst.data.outer.TrabalhadoresConsultasDatasData;
import shst.data.outer.TrabalhadoresData;
import shst.data.outer.TrabalhadoresEcdsData;
import shst.data.outer.TrabalhadoresEcdsDatasData;
import shst.data.outer.TrabalhadoresProcessoData;
import shst.data.provider.BaseProvider;
import shst.data.provider.MedicinaDataProvider;
import shst.medicina.multi.MultiMarcacoesWindow;
import siprp.SIPRPTracker;
import siprp.lembretes.Lembrete;
import siprp.lembretes.LembretesDataProvider;
import com.evolute.entity.evo.EvoDataProvider;
import com.evolute.utils.Singleton;
import com.evolute.utils.data.IDObject;
import com.evolute.utils.ui.DialogException;
/**
*
* @author fpalma
*/
public class TratarMarcacaoTrabalhadorAction extends AbstractAction
{
private static final long serialVersionUID = 1L;
private LembretesDataProvider lembretesProvider;
private EvoDataProvider evoProvider;
private SIPRPTracker tracker;
private Integer lembreteID;
private MedicinaDataProvider medicinaDAO = null;
/**
* Creates a new instance of TratarMarcacaoTrabalhadorAction
*/
public TratarMarcacaoTrabalhadorAction( IDObject lembrete )
{
super( "Tratar" );
try
{
lembreteID = lembrete.getID();
lembretesProvider = LembretesDataProvider.getProvider();
evoProvider = BaseProvider.getInstance().getEvoProvider();
// JDO = (ProviderInterface) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_PROVIDER );
medicinaDAO = MedicinaDataProvider.getProvider();
}
catch( Exception ex )
{
ex.printStackTrace();
}
}
public void actionPerformed(ActionEvent e)
{
try
{
tracker = ( SIPRPTracker ) Singleton.getInstance( SHSTPropertiesConstants.SHST_TRACKER /*SingletonConstants.SIPRP_TRACKER*/ );
Lembrete lembrete = lembretesProvider.getLembreteByID( lembreteID );
if( lembrete == null )
{
JOptionPane.showMessageDialog( null, "Este lembrete j\u00e1 foi tratado.", "J\u00e1 tratado",
JOptionPane.WARNING_MESSAGE );
}
else
{
if( lembrete.getMarcacaoTrabalhadorID() != null )
{
// old model
MarcacoesTrabalhadorData marcacao = ( MarcacoesTrabalhadorData ) evoProvider.load( MarcacoesTrabalhadorData.class, lembrete.getMarcacaoTrabalhadorID() );
TrabalhadoresData trabalhador = marcacao.toTrabalhador_id();
EstabelecimentosData estabelecimento = trabalhador.toEstabelecimento_id();
EmpresasData empresa = estabelecimento.toEmpresa_id();
lembretesProvider.apagarLembreteByID( lembreteID );
setEnabled( false );
tracker.getMedicinaWindow().setVisible( true );
tracker.getMedicinaWindow().setEmpresaAndEstabelecimentoAndTrabalhador( (Integer) empresa.get( EmpresasData.ID ),
( Integer ) estabelecimento.get( EstabelecimentosData.ID ),
( Integer ) trabalhador.get( TrabalhadoresData.ID ) );
}
else
{
// new model
Integer consultaID = lembrete.getConsultaDataID();
Integer exameID = lembrete.getExameDataID();
TrabalhadoresConsultasDatasData consultaMarcacao = null;
TrabalhadoresConsultasData consulta = null;
TrabalhadoresEcdsDatasData exameMarcacao = null;
TrabalhadoresEcdsData exame = null;
TrabalhadoresProcessoData processo = null;
TrabalhadoresData trabalhador = null;
EstabelecimentosData estabelecimento = null;
EmpresasData empresa = null;
if( consultaID != null )
{
consultaMarcacao = medicinaDAO.getConsultaMarcacaoByID( consultaID );
consulta = consultaMarcacao.toTrabalhadores_consultas_id();
processo = consulta.toProcesso_id();
}
else if( exameID != null )
{
exameMarcacao = medicinaDAO.getExameMarcacaoByID( exameID );
exame = exameMarcacao.toTrabalhadores_ecds_id();
processo = exame.toProcesso_id();
}
trabalhador = processo.toTrabalhador_id();
estabelecimento = trabalhador.toEstabelecimento_id();
empresa = estabelecimento.toEmpresa_id();
// MedicinaProcessoWindow window = tracker.getMedicinaProcessoWindow();
// window.runActionLater( MedicinaProcessoLogic.SELECT_EMPRESA, empresa );
// window.runActionLater( MedicinaProcessoLogic.SELECT_ESTABELECIMENTO, estabelecimento );
// window.runActionLater( MedicinaProcessoLogic.LOAD_TRABALHADOR, trabalhador );
// window.runActionLater( MedicinaProcessoLogic.SELECT_TRABALHADOR, trabalhador );
// window.runActionLater( MedicinaProcessoLogic.SELECT_PROCESSO, processo );
// window.runActionLater( consulta == null ? MedicinaProcessoLogic.SELECT_EXAME : MedicinaProcessoLogic.SELECT_CONSULTA, consulta == null ? exame : consulta );
// window.runActionLater( consulta == null ? MedicinaProcessoLogic.CREATE_EXAME_MARCACAO : MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO, null );
// window.runPendingActions();
// window.setVisible( true );
List< Integer > trabalhadoresIDs = new ArrayList< Integer >();
trabalhadoresIDs.add( trabalhador.getId() );
MultiMarcacoesWindow window = tracker.getMultiMarcacoesWindow();
window.setEmpresaAndEstabelecimento( empresa.getId(), estabelecimento.getId(), trabalhadoresIDs );
window.setVisible( true );
lembretesProvider.apagarLembreteByID( lembreteID );
}
}
Object source = e.getSource();
if( source instanceof Component )
{
((Component) source).setEnabled( false );
}
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a tratar", true );
}
}
}
Loading…
Cancel
Save