no message

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

@ -0,0 +1,32 @@
UPDATE trabalhadores SET perfil=1 WHERE perfil IS NULL;
UPDATE marcacoes_trabalhador SET motivo =
( SELECT tipo FROM exames WHERE exames.trabalhador_id = marcacoes_trabalhador.trabalhador_id AND
exames.data = marcacoes_trabalhador.data )
WHERE motivo IS NULL AND realizada = 'y';
CREATE TABLE etiquetas
(
id serial NOT NULL,
descricao varchar(255) NOT NULL,
descricao_plain varchar,
altura float4,
largura float4,
margem_esquerda float4,
margem_cima float4,
colunas int4,
linhas int4,
continua char(1) NOT NULL DEFAULT 'n'::bpchar,
altura_folha float4,
largura_folha float4,
margem_vertical_folha float4,
margem_horizontal_folha float4,
CONSTRAINT etiquetas_pkey PRIMARY KEY (id)
)
WITHOUT OIDS;
ALTER TABLE etiquetas OWNER TO postgres;
ALTER TABLE estabelecimentos ADD medico_id int4 REFERENCES medicos( id );
insert into etiquetas ( descricao, descricao_plain, altura, largura, margem_esquerda, margem_cima, colunas, linhas, continua, altura_folha, largura_folha,
margem_horizontal_folha, margem_vertical_folha )
values( 'Etiquetas em folha A4', 'etiquetas em folha a4', 3.7125, 10.5, 0.0, 0.0, 2, 8, 'n', 29.7, 21.0, 0.7, 0.5 );

@ -0,0 +1,90 @@
<project name="SIPRP" default="compile" basedir=".">
<target name="init">
<!-- directory definition -->
<property name="src" value="${basedir}"/>
<property name="build" value="${basedir}/build"/>
<property name="dist" value="${basedir}/../jars"/>
<property environment="env"/>
<condition property="etc" value="${env.SPEEDO_CONF}">
<isset property="env.SPEEDO_CONF"/>
</condition>
<property name="etc" value="${basedir}/../siprp"/>
<property file="${etc}/speedo.properties"/>
<fail unless="org.objectweb.speedo.mapperName"
message="YOU MUST CONFIGURE THE FILE ${etc}/speedo.properties"/>
<condition property="speedo.archive.exist">
<available file="${dist}/speedo.jar"/>
</condition>
<fail unless="speedo.archive.exist"
message="YOU MUST BUILD SPEEDO ARCHIVE in the speedo distribution by lauching the build.xml (Ant)"/>
<!-- Building of a path which contains external jars -->
<path id="classpath">
<pathelement location="${etc}"/>
<pathelement location="${basedir}/../evutils"/>
<pathelement location="${basedir}/../siprp"/>
<pathelement location="${basedir}/../images"/>
<pathelement location="${build}"/>
<fileset dir="${dist}">
<include name="speedo.jar"/>
<include name="jcalendar.jar"/>
<include name="jxl.jar"/>
<!-- <include name="lib/log/log4j.jar"/> -->
<include name="mysql*.jar"/>
<include name="iText.jar"/>
</fileset>
</path>
</target>
<!-- ============================================================== -->
<!-- ======================= Generation =========================== -->
<!-- ============================================================== -->
<target name="compile" depends="init">
<mkdir dir="${build}"/>
<javac srcdir="${src}" destdir="${build}" debug="on">
<classpath refid="classpath"/>
<include name="**/*.java"/>
</javac>
<taskdef name ="speedo"
classname="org.objectweb.speedo.ant.AntSpeedo"
classpathref="classpath" />
<speedo confFile="${etc}/speedo.properties"
output="${build}"
src="${src}"
classpathref="classpath"/>
</target>
<!-- ============================================================== -->
<!-- ======================== Cleaning ============================ -->
<!-- ============================================================== -->
<target name="clean" depends="init">
<delete dir="${build}"/>
</target>
<!-- ============================================================== -->
<!-- =========================== Run ============================== -->
<!-- ============================================================== -->
<target name="createDataStruct" depends="init"
description="Create the data structure for persistent classes">
<property environment="env"/>
<java classname="org.objectweb.speedo.tools.DataStructureCreation"
fork="yes" classpathref="classpath">
<arg line="siprp.data.Contacto siprp.data.Empresa siprp.data.Estabelecimento siprp.data.Trabalhador siprp.data.Aviso siprp.data.Marcacao siprp.data.MarcacaoEstabelecimento siprp.data.MarcacaoTrabalhador"/>
<!--<arg line="siprp.data.Contacto invoice.Address invoice.Invoice invoice.Product invoice.ProductUnits"/>-->
</java>
</target>
<target name="run" depends="init">
<java classname="siprp.Main" fork="yes" classpathref="classpath">
<sysproperty key="server.address"
value="ws_fpalma"
/>
<arg value="${etc}/speedo.properties"/>
</java>
</target>
</project>

@ -0,0 +1,5 @@
cd build
cd classes
java -cp .;../../evutils;../../jpox;../../jpox/jpox-1.0.4.jar;../../jpox/jpox-enhancer-1.0.4.jar;../../jars/log4j-1.2.8.jar;../../jdo/jdo.jar;../../jdo;../../jpox/bcel-5.1.jar org.jpox.enhancer.JPOXEnhancer siprp/data/package.jdo
cd ..
cd ..

@ -0,0 +1,5 @@
cd build
cd classes
java -cp .:../../evutils:../../jpox:../../jpox/jpox-1.0.4.jar:../../jpox/jpox-enhancer-1.0.4.jar:../../jars/log4j-1.2.8.jar:../../jdo/jdo.jar:../../jdo:../../jpox/bcel-5.1.jar org.jpox.enhancer.JPOXEnhancer siprp/data/package.jdo
cd ..
cd ..

@ -0,0 +1,576 @@
/*
* AvisosPanel.java
*
* Created on 21 de Maio de 2004, 13:06
*/
package siprp.clientes;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.util.*;
import javax.swing.*;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.dataui.*;
import com.evolute.utils.jdo.*;
import com.evolute.utils.ui.*;
import siprp.*;
import siprp.data.*;
/**
*
* @author fpalma
*/
public class AvisosPanel extends JPanel
implements ActionListener, ControllableComponent
{
private static final DateFormat DATE_FORMAT = DateFormat.getDateInstance( DateFormat.SHORT );
private JDOProvider JDO;
private FichaDataProvider provider;
private SIPRPTracker tracker;
private JPanel empresaPanel;
private JPanel estabelecimentosPanel;
private JPanel trabalhadoresPanel;
// private AvisoData avisos[];
// private AvisoData avisosEmpresa[];
// private AvisoData avisosEstabelecimento[];
// private AvisoData avisosTrabalhador[];
private Object avisosEmpresa[][];
private Object avisosEstabelecimento[][];
private Object avisosTrabalhador[][];
private boolean refreshed = false;
private Hashtable buttonHash;
private Hashtable buttonTypeHash;
/** Creates a new instance of AvisosPanel */
public AvisosPanel(/* AvisoData avisosEmpresa[], AvisoData avisosEstabelecimento[], AvisoData avisosTrabalhador[]*/ )
throws Exception
{
// this.avisosEmpresa = new AvisoData[ 0 ];
// this.avisosEstabelecimento = new AvisoData[ 0 ];
// this.avisosTrabalhador = new AvisoData[ 0 ];
// setupComponents();
buttonHash = new Hashtable();
buttonTypeHash = new Hashtable();
JDO = (JDOProvider) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
// System.out.println( "public AvisosPanel() JDO: " + JDO );
}
private void setupComponents()
{
empresaPanel = new JPanel();
empresaPanel.setBorder(
BorderFactory.createTitledBorder(
BorderFactory.createLineBorder( new Color( 0.0f, 0.0f, 0.0f, 0.0f ), 1 ), "Empresas" ) );
empresaPanel.setLayout( new GridLayout( avisosEmpresa.length, 1 ) );
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets( 1, 1, 1, 1 );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weighty = 0;
for( int n = 0; n < avisosEmpresa.length; n++ )
{
JPanel pan = new JPanel();
GridBagLayout gridbag = new GridBagLayout();
pan.setBorder( BorderFactory.createLineBorder( Color.black, 1 ) );
// EmpresaData empresa = (EmpresaData)avisosEmpresa[ n ].get( AvisoData.EMPRESA );
pan.setLayout( gridbag );
constraints.gridheight = GridBagConstraints.REMAINDER;
constraints.gridx = 0;
constraints.weightx = 0;
constraints.gridwidth = 1;
JButton tratarButton = new JButton( "Tratar" );
gridbag.setConstraints( tratarButton, constraints );
pan.add( tratarButton );
//buttonHash.put( tratarButton, avisosEmpresa[ n ] );
// buttonHash.put( tratarButton, new Integer( n ) );
// buttonHash.put( tratarButton, avisosEmpresa[ n ].get( AvisoData.ID ) );
buttonHash.put( tratarButton, avisosEmpresa[ n ][ 0 ] );
buttonTypeHash.put( tratarButton, new Integer( AvisoConstants.TIPO_EMPRESA ) );
tratarButton.addActionListener( this );
constraints.gridx = 1;
constraints.weightx = 1;
constraints.gridheight = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
// JLabel empresaLabel = new JLabel( "" + empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) );
JLabel empresaLabel = new JLabel( "" + avisosEmpresa[ n ][ 3 ] );
gridbag.setConstraints( empresaLabel, constraints );
pan.add( empresaLabel );
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
//JLabel descricaoLabel = new JLabel( (String)avisosEmpresa[ n ].get( AvisoData.DESCRICAO ) );
JLabel descricaoLabel = criarDescricao( avisosEmpresa[ n ] );
gridbag.setConstraints( descricaoLabel, constraints );
pan.add( descricaoLabel );
empresaPanel.add( pan );
}
estabelecimentosPanel = new JPanel();
estabelecimentosPanel.setBorder(
BorderFactory.createTitledBorder(
BorderFactory.createLineBorder( new Color( 0.0f, 0.0f, 0.0f, 0.0f ), 1 ), "Estabelecimentos" ) );
estabelecimentosPanel.setLayout( new GridLayout( avisosEstabelecimento.length, 1 ) );
for( int n = 0; n < avisosEstabelecimento.length; n++ )
{
Date dataAviso = ( Date ) avisosEstabelecimento[ n ][ 5 ];
Date dataEvento = ( Date ) avisosEstabelecimento[ n ][ 1 ];
Calendar calAviso = Calendar.getInstance();
calAviso.setTime( dataAviso );
Calendar calEvento = Calendar.getInstance();
calEvento.setTime( dataEvento );
boolean mesmoDia =
( calAviso.get( Calendar.YEAR ) == calEvento.get( Calendar.YEAR ) ) &&
( calAviso.get( Calendar.MONTH ) == calEvento.get( Calendar.MONTH ) ) &&
( calAviso.get( Calendar.DAY_OF_MONTH ) == calEvento.get( Calendar.DAY_OF_MONTH ) );
JPanel pan = new JPanel();
GridBagLayout gridbag = new GridBagLayout();
pan.setBorder( BorderFactory.createLineBorder( Color.black, 1 ) );
// EstabelecimentoData estabelecimento = (EstabelecimentoData)avisosEstabelecimento[ n ].get( AvisoData.ESTABELECIMENTO );
// EmpresaData empresa = (EmpresaData)estabelecimento.get( EstabelecimentoData.EMPRESA );
pan.setLayout( gridbag );
constraints.gridheight = GridBagConstraints.REMAINDER;
constraints.gridx = 0;
constraints.weightx = 0;
constraints.gridwidth = 1;
JButton tratarButton = new JButton( mesmoDia ? "Confirmar" : "Marcar" );
gridbag.setConstraints( tratarButton, constraints );
pan.add( tratarButton );
//buttonHash.put( tratarButton, avisosEstabelecimento[ n ] );
// buttonHash.put( tratarButton, new Integer( n + avisosEmpresa.length ) );
// buttonHash.put( tratarButton, avisosEstabelecimento[ n ].get( AvisoData.ID ) );
buttonHash.put( tratarButton, avisosEstabelecimento[ n ][ 0 ] );
buttonTypeHash.put( tratarButton, new Integer( AvisoConstants.TIPO_ESTABELECIMENTO ) );
tratarButton.addActionListener( this );
constraints.gridx = 1;
constraints.weightx = 1;
constraints.gridheight = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
// JLabel empresaLabel = new JLabel( "" + empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) );
JLabel empresaLabel = new JLabel( "" + avisosEstabelecimento[ n ][ 3 ] );
gridbag.setConstraints( empresaLabel, constraints );
pan.add( empresaLabel );
// JLabel estabelecimentoLabel = new JLabel( "" + estabelecimento.get( EstabelecimentoData.NOME ) );
JLabel estabelecimentoLabel = new JLabel( "" + avisosEstabelecimento[ n ][ 4 ] );
gridbag.setConstraints( estabelecimentoLabel, constraints );
pan.add( estabelecimentoLabel );
constraints.gridwidth = GridBagConstraints.REMAINDER;
//JLabel descricaoLabel = new JLabel( (String)avisosEstabelecimento[ n ].get( AvisoData.DESCRICAO ) );
JLabel descricaoLabel = criarDescricao( avisosEstabelecimento[ n ] );
gridbag.setConstraints( descricaoLabel, constraints );
pan.add( descricaoLabel );
estabelecimentosPanel.add( pan );
}
trabalhadoresPanel = new JPanel();
trabalhadoresPanel.setBorder(
BorderFactory.createTitledBorder(
BorderFactory.createLineBorder( new Color( 0.0f, 0.0f, 0.0f, 0.0f ), 1 ), "Trabalhadores" ) );
trabalhadoresPanel.setLayout( new GridLayout( avisosTrabalhador.length, 1 ) );
for( int n = 0; n < avisosTrabalhador.length; n++ )
{
Date dataAviso = ( Date ) avisosTrabalhador[ n ][ 6 ];
Date dataEvento = ( Date ) avisosTrabalhador[ n ][ 1 ];
Calendar calAviso = Calendar.getInstance();
calAviso.setTime( dataAviso );
Calendar calEvento = Calendar.getInstance();
calEvento.setTime( dataEvento );
boolean mesmoDia =
( calAviso.get( Calendar.YEAR ) == calEvento.get( Calendar.YEAR ) ) &&
( calAviso.get( Calendar.MONTH ) == calEvento.get( Calendar.MONTH ) ) &&
( calAviso.get( Calendar.DAY_OF_MONTH ) == calEvento.get( Calendar.DAY_OF_MONTH ) );
JPanel pan = new JPanel();
GridBagLayout gridbag = new GridBagLayout();
pan.setBorder( BorderFactory.createLineBorder( Color.black, 1 ) );
// TrabalhadorData trabalhador = (TrabalhadorData)avisosTrabalhador[ n ].get( AvisoData.TRABALHADOR );
// EstabelecimentoData estabelecimento = (EstabelecimentoData)trabalhador.get( TrabalhadorData.ESTABELECIMENTO );
// EmpresaData empresa = (EmpresaData)estabelecimento.get( EstabelecimentoData.EMPRESA );
pan.setLayout( gridbag );
constraints.gridheight = GridBagConstraints.REMAINDER;
constraints.gridx = 0;
constraints.weightx = 0;
constraints.gridwidth = 1;
JButton tratarButton = new JButton( mesmoDia ? "Confirmar" : "Marcar" );
gridbag.setConstraints( tratarButton, constraints );
pan.add( tratarButton );
//buttonHash.put( tratarButton, avisosTrabalhador[ n ] );
// buttonHash.put( tratarButton, new Integer( n + avisosEmpresa.length + avisosEstabelecimento.length ) );
// buttonHash.put( tratarButton, avisosTrabalhador[ n ].get( AvisoData.ID ) );
buttonHash.put( tratarButton, avisosTrabalhador[ n ][ 0 ] );
buttonTypeHash.put( tratarButton, new Integer( AvisoConstants.TIPO_TRABALHADOR ) );
tratarButton.addActionListener( this );
constraints.gridx = 1;
constraints.weightx = 1;
constraints.gridheight = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
// JLabel empresaLabel = new JLabel( "" + empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) );
JLabel empresaLabel = new JLabel( "" + avisosTrabalhador[ n ][ 3 ] );
gridbag.setConstraints( empresaLabel, constraints );
pan.add( empresaLabel );
// JLabel estabelecimentoLabel = new JLabel( "" + estabelecimento.get( EstabelecimentoData.NOME ) );
JLabel estabelecimentoLabel = new JLabel( "" + avisosTrabalhador[ n ][ 4 ] );
gridbag.setConstraints( estabelecimentoLabel, constraints );
pan.add( estabelecimentoLabel );
// JLabel trabalhadorLabel = new JLabel( "" + trabalhador.get( TrabalhadorData.NOME ) );
JLabel trabalhadorLabel = new JLabel( "" + avisosTrabalhador[ n ][ 5 ] );
gridbag.setConstraints( trabalhadorLabel, constraints );
pan.add( trabalhadorLabel );
constraints.gridwidth = GridBagConstraints.REMAINDER;
//JLabel descricaoLabel = new JLabel( (String)avisosTrabalhador[ n ].get( AvisoData.DESCRICAO ) );
JLabel descricaoLabel = criarDescricao( avisosTrabalhador[ n ] );
gridbag.setConstraints( descricaoLabel, constraints );
pan.add( descricaoLabel );
trabalhadoresPanel.add( pan );
}
// Vector v = new Vector( Arrays.asList( avisosEmpresa ) );
// v.addAll( Arrays.asList( avisosTrabalhador ) );
// v.addAll( Arrays.asList( avisosEstabelecimento ) );
// avisos = (AvisoData []) v.toArray( new AvisoData[0] );
JScrollPane scp = new JScrollPane();
setLayout( new GridLayout( 1, 1 ) );
add( scp );
JPanel contentPanel = new JPanel();
scp.setViewportView( contentPanel );
contentPanel.setLayout( new BoxLayout( contentPanel, BoxLayout.Y_AXIS ) );
if( avisosEmpresa.length > 0 )
{
contentPanel.add( empresaPanel );
}
if( avisosTrabalhador.length > 0 )
{
contentPanel.add( new JLabel( " " ) );
contentPanel.add( trabalhadoresPanel );
}
if( avisosEstabelecimento.length > 0 )
{
contentPanel.add( new JLabel( " " ) );
contentPanel.add( estabelecimentosPanel );
}
}
public void refresh()
{
if( refreshed )
{
return;
}
refreshed = true;
try
{
provider = ( FichaDataProvider ) FichaDataProvider.getProvider();
// Collection c = AvisoData.load( AvisoData.class, " estabelecimento_id == \"null\" ",
// AvisoData.DATA_EVENTO + " ascending" );
// Collection c = AvisoData.load( AvisoData.class, "(tipo == " + AvisoData.TIPO_EMPRESA+")",// + ") && ( data_aviso <= CURRENT_DATE )",
// AvisoData.DATA_EVENTO + " ascending" );
// Collection c = AvisoData.load( AvisoData.class, new Object[]{ /*new Integer( AvisoData.TIPO_EMPRESA ), */new Date() },
// new String[]{ /*"tipo", */"data_aviso" },
// new String[]{ "=="/*, "==" */},
// new String[]{ AvisoData.DATA_EVENTO + " ascending" } );
// if( c == null )
// {
// avisosEmpresa = new AvisoData[ 0 ];
// }
// else
// {
//
// avisosEmpresa = ( AvisoData[] )c.toArray( new AvisoData[ c.size() ] );
// }
// Integer ids[] = provider.getAvisosIDByTipoAndDate( new Integer( AvisoConstants.TIPO_EMPRESA ), new Date() );
// avisosEmpresa = new AvisoData[ ids.length ];
// if( JDO == null )
// {
// JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
// }
//// System.out.println( "JDO: " + JDO );
// for( int n = 0; n < avisosEmpresa.length; n++ )
// {
// avisosEmpresa[ n ] = (AvisoData) JDO.load( AvisoData.class, ids[ n ] );
// }
//
////System.out.println( "EmpresaData " + avisosEmpresa.length );
//// c = AvisoData.load( AvisoData.class, " tipo == " + AvisoData.TIPO_ESTABELECIMENTO,// + ") && ( data_aviso <= new Date() )",
//// AvisoData.DATA_EVENTO + " ascending" );
//// c = AvisoData.load( AvisoData.class, "estabelecimento_id != \"null\" "
//// + " && trabalhador_id == \"null\"", AvisoData.DATA_EVENTO + " ascending" );
//// if( c == null )
//// {
//// avisosEstabelecimento = new AvisoData[ 0 ];
//// }
//// else
//// {
//// avisosEstabelecimento = ( AvisoData[] )c.toArray( new AvisoData[ c.size() ] );
//// }
//
// ids = provider.getAvisosIDByTipoAndDate( new Integer( AvisoConstants.TIPO_ESTABELECIMENTO ), new Date() );
// avisosEstabelecimento = new AvisoData[ ids.length ];
// for( int n = 0; n < avisosEstabelecimento.length; n++ )
// {
// avisosEstabelecimento[ n ] = (AvisoData) JDO.load( AvisoData.class, new Object[]{ids[ n ]}, new String[]{ "id" } );
// }
////System.out.println( "EstabelecimentoData " + avisosEstabelecimento.length );
//// c = AvisoData.load( AvisoData.class, " tipo == " + AvisoData.TIPO_TRABALHADOR,// + ") && ( data_aviso <= new Date() )",
//// AvisoData.DATA_EVENTO + " ascending" );
//// c = AvisoData.load( AvisoData.class, "trabalhador_id != \"null\"", AvisoData.DATA_EVENTO + " ascending" );
//// if( c == null )
//// {
//// avisosTrabalhador = new AvisoData[ 0 ];
//// }
//// else
//// {
//// avisosTrabalhador = ( AvisoData[] )c.toArray( new AvisoData[ c.size() ] );
//// }
// ids = provider.getAvisosIDByTipoAndDate( new Integer( AvisoConstants.TIPO_TRABALHADOR ), new Date() );
//
// avisosTrabalhador = new AvisoData[ ids.length ];
// for( int n = 0; n < avisosTrabalhador.length; n++ )
// {
// avisosTrabalhador[ n ] = (AvisoData) JDO.load( AvisoData.class, ids[ n ] );
// }
//System.out.println( "trabalhador " + avisosTrabalhador.length );
avisosEmpresa = provider.getAvisosEmpresaByDate( new Date() );
avisosEstabelecimento = provider.getAvisosEstabelecimentoByDate( new Date() );
avisosTrabalhador = provider.getAvisosTrabalhadorByDate( new Date() );
}
catch( Exception ex )
{
ex.printStackTrace();
}
setupComponents();
setVisible( true );
repaint();
}
private JLabel criarDescricao( Object aviso[] )
{
Date dataEvento = ( Date )aviso[ 1 ];
String descricao = (String)aviso[ 2 ];
Calendar cal = Calendar.getInstance();
cal.setTime( dataEvento );
cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 0, 0, 0 );
cal.set( Calendar.MILLISECOND, 0 );
dataEvento = cal.getTime();
cal = Calendar.getInstance();
cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 0, 0, 0 );
cal.set( Calendar.MILLISECOND, 0 );
Date hoje = cal.getTime();
if( !hoje.after( dataEvento ) && !hoje.before( dataEvento ) )
{
descricao += " hoje";
}
else
{
descricao += " no dia " + DATE_FORMAT.format( dataEvento );
}
JLabel descricaoLabel = new JLabel( descricao );
if( hoje.after( dataEvento ) )
{
descricaoLabel.setForeground( Color.red );
}
else if( hoje.equals( dataEvento ) )
{
descricaoLabel.setForeground( Color.green.darker() );
}
return descricaoLabel;
}
// private JLabel criarDescricao( AvisoData aviso )
// {
// Date dataEvento = ( Date )aviso.get( AvisoData.DATA_EVENTO );
//
// String descricao = (String)aviso.get( AvisoData.DESCRICAO );
// String descricao2 = (String)aviso.get( AvisoData.DESCRICAO );
// Calendar cal = Calendar.getInstance();
// cal.setTime( dataEvento );
// cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 0, 0, 0 );
// cal.set( Calendar.MILLISECOND, 0 );
// dataEvento = cal.getTime();
//
// cal = Calendar.getInstance();
// cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 0, 0, 0 );
// cal.set( Calendar.MILLISECOND, 0 );
// Date hoje = cal.getTime();
//
// if( !hoje.after( dataEvento ) && !hoje.before( dataEvento ) )
// {
// descricao += " hoje";
// }
// else
// {
// descricao += " no dia " + DATE_FORMAT.format( dataEvento );
// }
// JLabel descricaoLabel = new JLabel( descricao );
// if( hoje.after( dataEvento ) )
// {
// descricaoLabel.setForeground( Color.red );
// }
// else if( hoje.equals( dataEvento ) )
// {
// descricaoLabel.setForeground( Color.green.darker() );
// }
// return descricaoLabel;
// }
public void actionPerformed( ActionEvent e )
{
if( JDO == null )
{
JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
}
Object source = e.getSource();
if( source instanceof JButton )
{
// AvisoData aviso = (AvisoData) buttonHash.get( source );
try
{
( (JButton) source ).setEnabled( false );
Integer id = (Integer)buttonHash.get( source );
if( id == null )
{
return;
}
buttonHash.remove( source );
AvisoData aviso = (AvisoData) JDO.load( AvisoData.class, id );
if( aviso == null )
{
JOptionPane.showMessageDialog( null, "Este aviso j\u00e1 foi tratado.", "J\u00e1 tratado",
JOptionPane.WARNING_MESSAGE );
return;
}
Hashtable dataHash = aviso.getHashData();
Date dataEvento = (Date)dataHash.get( AvisoData.DATA_EVENTO );
Calendar cal = Calendar.getInstance();
cal.setTime( dataEvento );
cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 0, 0, 0 );
cal.set( Calendar.MILLISECOND, 0 );
dataEvento = cal.getTime();
cal = Calendar.getInstance();
cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 10, 0, 0 );
cal.set( Calendar.MILLISECOND, 0 );
Date hoje = cal.getTime();
if( hoje.before( dataEvento ) )
{
AvisoData novoAviso = new AvisoData();
novoAviso.setHashData( dataHash );
novoAviso.set( AvisoData.DATA_AVISO, dataEvento );
novoAviso.save();
}
Integer tipo = (Integer) aviso.get( AvisoData.TIPO );
TrabalhadorData trabalhador;
EstabelecimentoData estabelecimento;
EmpresaData empresa;
switch( tipo.intValue() )
{
case AvisoConstants.TIPO_TRABALHADOR:
trabalhador = (TrabalhadorData) aviso.get( AvisoData.TRABALHADOR );
estabelecimento = (EstabelecimentoData) trabalhador.get( TrabalhadorData.ESTABELECIMENTO );
empresa = (EmpresaData) estabelecimento.get( EstabelecimentoData.EMPRESA );
aviso.delete();
tracker.getMedicinaWindow().setVisible( true );
tracker.getMedicinaWindow().setEmpresaAndEstabelecimentoAndTrabalhador( (Integer) empresa.get( EmpresaData.ID ),
( Integer ) estabelecimento.get( EstabelecimentoData.ID ),
( Integer ) trabalhador.get( TrabalhadorData.ID ) );
break;
case AvisoConstants.TIPO_ESTABELECIMENTO:
estabelecimento = (EstabelecimentoData) aviso.get( AvisoData.ESTABELECIMENTO );
empresa = (EmpresaData) estabelecimento.get( EstabelecimentoData.EMPRESA );
aviso.delete();
tracker.getHigieneWindow().setVisible( true );
tracker.getHigieneWindow().setEmpresaAndEstabelecimento( (Integer) empresa.get( EmpresaData.ID ),
( Integer ) estabelecimento.get( EstabelecimentoData.ID ) );
break;
case AvisoConstants.TIPO_EMPRESA:
empresa = (EmpresaData) aviso.get( AvisoData.EMPRESA );
aviso.delete();
ClientesWindow clientesWindow = tracker.getClientesWindow();
clientesWindow.setVisible( true );
clientesWindow.setJDOObject( empresa );
break;
}
System.out.println( "delete aviso" );
// aviso.set( AvisoData.TRABALHADOR, null );
// aviso.set( AvisoData.ESTABELECIMENTO, null );
// aviso.set( AvisoData.EMPRESA, null );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a limpar o aviso", true );
}
}
}
public void clear()
{
}
public void fill(Object value)
{
}
public Object save()
{
return null;
}
public void setEnabled( boolean enable )
{
Set buttonSet = buttonHash.keySet();
JButton buttons[] = (JButton[]) buttonSet.toArray( new JButton[0] );
for( int n = 0;n < buttons.length; n++ )
{
buttons[ n ].setEnabled( enable );
}
}
public void setEnabled( boolean enable, int type )
{
Set buttonSet = buttonHash.keySet();
JButton buttons[] = (JButton[]) buttonSet.toArray( new JButton[0] );
for( int n = 0;n < buttons.length; n++ )
{
Integer buttonType = ( Integer ) buttonTypeHash.get( buttons[ n ] );
if( buttonType.intValue() == type )
{
buttons[ n ].setEnabled( enable );
}
}
}
public void setTracker( SIPRPTracker tracker )
{
this.tracker = tracker;
}
}

@ -0,0 +1,197 @@
/*
* ClientesDataProvider.java
*
* Created on January 27, 2006, 12:50 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.clientes;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.arrays.*;
import com.evolute.utils.data.*;
import com.evolute.utils.db.*;
import com.evolute.utils.metadb.*;
import com.evolute.utils.sql.*;
import com.evolute.utils.strings.*;
/**
*
* @author fpalma
*/
public class ClientesDataProvider extends MetaProvider
{
private static final Object LOCK = new Object();
private static ClientesDataProvider instance = null;
private final Executer executer;
private Integer etiquetaID;
/** Creates a new instance of ClientesDataProvider */
public ClientesDataProvider()
throws Exception
{
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ );
executer = dbm.getSharedExecuter( this );
}
public static MetaProvider getProvider()
throws Exception
{
synchronized( LOCK )
{
if( instance == null )
{
instance = new ClientesDataProvider();
}
}
return instance;
}
public IDObject[] getAllGruposProtocoloReais()
throws Exception
{
return getAllGruposProtocoloPorTipo( true );
}
public IDObject[] getAllGruposProtocoloFalsos()
throws Exception
{
return getAllGruposProtocoloPorTipo( false );
}
public IDObject[] getAllGruposProtocoloPorTipo( boolean real )
throws Exception
{
Select select =
new Select( new String[]{ "prt_grupos_protocolo" },
new String[]{ "id", "descricao", "ordem" },
new Field( "grupo_real" ).isEqual( real ? "y" : "n" ),
new String[]{ "ordem" },
null );
Virtual2DArray array = executer.executeQuery( select );
IDObject grupos[] = new IDObject[ array.columnLength() ];
for( int n = 0; n < grupos.length; n++ )
{
grupos[ n ] = new MappableObject( ( Integer ) array.get( n, 0 ), ( String ) array.get( n, 1 ) );
}
return grupos;
}
public Hashtable getAllTiposElementosProtocoloByGrupo()
throws Exception
{
Select select =
new Select( new String[]{ "prt_tipos_elementos_protocolo" },
new String[]{ "id", "descricao", "ordem", "grupo_protocolo_id" },
null,
new String[]{ "grupo_protocolo_id", "ordem" },
null );
Virtual2DArray array = executer.executeQuery( select );
Hashtable tipos = new Hashtable();
for( int n = 0; n < array.columnLength(); n++ )
{
IDObject tipo = new MappableObject( ( Integer ) array.get( n, 0 ), ( String ) array.get( n, 1 ) );
Integer grupoID = ( Integer ) array.get( n, 3 );
if( !tipos.containsKey( grupoID ) )
{
tipos.put( grupoID, new Vector() );
}
Vector tiposGrupo = ( Vector ) tipos.get( grupoID );
tiposGrupo.add( tipo );
}
return tipos;
}
public void setElementosProtocoloForEmpresa( Integer empresaID, Integer elementos[][] )
throws Exception
{
// executer.executeQuery( Begin.BEGIN );
try
{
Delete delete =
new Delete( "prt_elementos_protocolo",
new Field( "empresa_id" ).isEqual( empresaID ) );
executer.executeQuery( delete );
for( int p = 0; p < elementos.length; p++ )
{
Integer numeroPerfil = new Integer( p + 1 );
for( int e = 0; e < elementos[ p ].length; e++ )
{
Insert insert =
new Insert( "prt_elementos_protocolo",
new Assignment[]{
new Assignment( new Field( "empresa_id" ), empresaID ),
new Assignment( new Field( "tipo_elemento_protocolo_id" ), elementos[ p ][ e ] ),
new Assignment( new Field( "numero_perfil" ), numeroPerfil ) } );
executer.executeQuery( insert, null );
}
}
// executer.executeQuery( Commit.COMMIT );
}
catch( Exception ex )
{
// executer.executeQuery( Rollback.ROLLBACK );
throw ex;
}
}
public Integer[][] getElementosProtocoloForEmpresa( Integer empresaID, int numeroPerfis )
throws Exception
{
Select select =
new Select( new String[]{ "prt_elementos_protocolo" },
new String[]{ "tipo_elemento_protocolo_id", "numero_perfil" },
new Field( "empresa_id" ).isEqual( empresaID ) ,
new String[]{ "numero_perfil" },
null );
Virtual2DArray array = executer.executeQuery( select );
Vector data[] = new Vector[ numeroPerfis ];
for( int n = 0; n < array.columnLength(); n++ )
{
int perfil = ( ( Integer ) array.get( n, 1 ) ).intValue() - 1;
Integer tipo = ( Integer ) array.get( n, 0 );
if( data[ perfil ] == null )
{
data[ perfil ] = new Vector();
}
data[ perfil ].add( tipo );
}
Integer elementos[][] = new Integer[ numeroPerfis ][];
for( int n = 0; n < numeroPerfis; n++ )
{
if( data[ n ] == null )
{
elementos[ n ] = new Integer[ 0 ];
}
else
{
elementos[ n ] = ( Integer [] ) data[ n ].toArray( new Integer[ data[ n ].size() ] );
}
}
return elementos;
}
public Integer getEtiquetaID()
throws Exception
{
if( etiquetaID == null )
{
Select select =
new Select( new String[]{ "etiquetas" },
new String[]{ "max(id)" },
null );
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
{
return null;
}
etiquetaID = ( Integer ) array.get( 0, 0 );
}
return etiquetaID;
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,181 @@
/*
* ContactoPanel.java
*
* Created on 14 de Maio de 2004, 15:26
*/
package siprp.clientes;
import java.awt.*;
import javax.swing.*;
import java.util.*;
import com.evolute.utils.dataui.*;
import com.evolute.utils.ui.text.*;
import siprp.data.*;
/**
*
* @author fpalma
*/
public class ContactoPanel extends JPanel
implements ControllableComponent
{
private ContactoData contacto;
private ComponentsHashtable components;
private JTextField nomeText;
private JTextField cargoText;
private JTextField telefoneText;
private JTextField telemovelText;
private JTextField faxText;
private JTextField emailText;
/** Creates a new instance of ContactoPanel */
public ContactoPanel()
{
setupComponents();
setupComponentsHashtable();
}
private void setupComponents()
{
JLabel nomeLabel = new JLabel( "Nome" );
nomeText = new JTextField();
JLabel cargoLabel = new JLabel( "Cargo" );
cargoText = new JTextField();
JLabel telefoneLabel = new JLabel( "Telef." );
telefoneText = new JTextField();
JLabel telemovelLabel = new JLabel( "Tlm." );
telemovelText = new JTextField();
JLabel faxLabel = new JLabel( "Fax" );
faxText = new JTextField();
JLabel emailLabel = new JLabel( "Email" );
emailText = new JTextField();
GridBagLayout gridbag = new GridBagLayout();
setLayout( gridbag );
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets( 1, 1, 1, 1 );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.gridheight = 1;
constraints.weighty = 0;
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( nomeLabel, constraints );
add( nomeLabel );
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( nomeText, constraints );
add( nomeText );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( cargoLabel, constraints );
add( cargoLabel );
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( cargoText, constraints );
add( cargoText );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( telefoneLabel, constraints );
add( telefoneLabel );
constraints.weightx = .5;
constraints.gridwidth = 1;
gridbag.setConstraints( telefoneText, constraints );
add( telefoneText );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( telemovelLabel, constraints );
add( telemovelLabel );
constraints.weightx = .5;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( telemovelText, constraints );
add( telemovelText );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( faxLabel, constraints );
add( faxLabel );
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( faxText, constraints );
add( faxText );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( emailLabel, constraints );
add( emailLabel );
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( emailText, constraints );
add( emailText );
new CopyPasteHandler( nomeText );
new CopyPasteHandler( cargoText );
new CopyPasteHandler( telefoneText );
new CopyPasteHandler( telemovelText );
new CopyPasteHandler( faxText );
new CopyPasteHandler( emailText );
}
private void setupComponentsHashtable()
{
components = new ComponentsHashtable();
components.putComponent( ContactoData.NOME, nomeText );
components.putComponent( ContactoData.CARGO, cargoText );
components.putComponent( ContactoData.TELEFONE, telefoneText );
components.putComponent( ContactoData.TELEMOVEL, telemovelText );
components.putComponent( ContactoData.FAX, faxText );
components.putComponent( ContactoData.EMAIL, emailText );
}
public void clear()
{
String names[] = (String[])components.keySet().toArray( new String[0] );
ComponentController.clear( names, components );
contacto = null;
}
public void fill(Object value)
{
clear();
contacto = ( ContactoData ) value;
if( contacto == null )
{
return;
}
String names[] = contacto.getFieldNames();
ComponentController.fill( names, contacto.getHashData(), components );
}
public Object save()
{
if( contacto == null )
{
contacto = new ContactoData();
}
String names[] = contacto.getFieldNames();
Hashtable hash = new Hashtable();
ComponentController.save( names, hash, components );
contacto.setHashData( hash );
return contacto;
}
public void setEnabled( boolean enable )
{
String names[] = (String[])components.keySet().toArray( new String[0] );
ComponentController.setEnabled( names, enable, components );
}
}

@ -0,0 +1,933 @@
/*
* EmpresaPanel.java
*
* Created on 12 de Maio de 2004, 19:08
*/
package siprp.clientes;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.data.*;
import com.evolute.utils.dataui.*;
import com.evolute.utils.documents.*;
import com.evolute.utils.jdo.*;
import com.evolute.utils.tables.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.ui.text.*;
import siprp.*;
import siprp.data.*;
/**
*
* @author fpalma
*/
public class EmpresaPanel extends JPanel
implements ControllableComponent, ListSelectionListener
{
private JDOProvider JDO;
private FichaDataProvider provider;
private EmpresaData empresa;
private ComponentsHashtable components;
private Integer id;
private JTextField designacaoSocialText;
private JTextField moradaText;
private JTextField codigoPostalText;
private JTextField localText;
private JTextField distritoText;
private JTextField concelhoText;
private JTextField codigo1Text;
private JTextField codigo2Text;
private JTextField codigo3Text;
// private JTextField perfil1Text;
// private JTextField perfil2Text;
private JComboBox servicosCombo;
private JTextField precoHigieneText;
private JTextField precoMedicinaText;
private JTextField modalidadePagamentoText;
private ContactoPanel contacto1Panel;
private ContactoPanel contacto2Panel;
private JCalendarPanel envioPropostaPanel;
private JCalendarPanel aceitacaoPropostaPanel;
private JCalendarPanel cancelamentoPanel;
private JCalendarPanel envioContratoPanel;
private JCalendarPanel recepcaoContratoPanel;
private JCalendarPanel envioIdictPanel;
private JCalendarPanel relatorioAnualPanel;
private JTextField caeText;
private JTextField actividadeText;
private JTextField contribuinteText;
private JTextField segSocialText;
private JPanel marcacoesPanel;
private JPanel listaMarcacoesPanel;
private BaseTable marcacoesTable;
private MarcacaoEmpresaPanel marcacaoPanel;
private CardLayout marcacoesCardLayout;
private ProtocoloPanel protocoloPanel;
// private UserPanel userPanel;
private BaseTable estabelecimentosTable;
private VectorTableModel estabelecimentosModel;
private boolean webAware;
private Vector listSelectionListeners;
/** Creates a new instance of EmpresaPanel */
public EmpresaPanel()
throws Exception
{
webAware = ( ( Boolean ) Singleton.getInstance( SingletonConstants.WEB_AWARE ) ).booleanValue();
provider = (FichaDataProvider)FichaDataProvider.getProvider();
listSelectionListeners = new Vector();
JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
setupComponents();
setupComponentsHashtable();
}
private void setupComponents()
throws Exception
{
String codeFormat = ( String ) Singleton.getInstance( SingletonConstants.CODIGO_EMPRESA_FORMAT );
String formatElements[] = codeFormat.split( " " );
int formatFieldLengths[] = new int[ formatElements.length ];
String fieldSeparators[] = new String[ formatElements.length ];
int n1 = 0;
int n2 = 0;
for( ; n1 < formatElements.length; n1++ )
{
try
{
formatFieldLengths[ n2 ] = Integer.parseInt( formatElements[ n1 ] );
n2++;
}
catch( NumberFormatException ex )
{
fieldSeparators[ n2 - 1 ] = formatElements[ n1 ];
}
}
int countFields = n2;
JLabel designacaoSocialLabel = new JLabel( "Designa\u00e7\u00e3o Social" );
designacaoSocialText = new StateTextField();
JLabel codigoLabel = new JLabel( "C\u00f3digo" );
JPanel codigoPanel = new JPanel();
codigo1Text = new StateTextField();
if( countFields > 0 && formatFieldLengths[ 0 ] > 0 )
{
codigo1Text.setDocument( new MaximumLengthDocument( formatFieldLengths[ 0 ] ) );
}
codigo2Text = new StateTextField();
if( countFields > 1 && formatFieldLengths[ 1 ] > 0 )
{
codigo2Text.setDocument( new MaximumLengthDocument( formatFieldLengths[ 1 ] ) );
}
codigo3Text = new StateTextField();
if( countFields > 2 && formatFieldLengths[ 2 ] > 0 )
{
codigo3Text.setDocument( new MaximumLengthDocument( formatFieldLengths[ 2 ] ) );
}
// JLabel perfisLabel = new JLabel( "Perfis (A/B)" );
// perfil1Text = new JTextField();
// JLabel perfil2Label = new JLabel( "/" );
// perfil2Text = new JTextField();
servicosCombo = new JComboBox();
servicosCombo.setPreferredSize( new Dimension( 120, 20 ) );
JLabel precoLabel = new JLabel( "Pre\u00e7os" );
JLabel precoHigieneLabel = new JLabel( " Higiene" );
precoHigieneText = new JTextField();
precoHigieneText.setDocument( new DoubleDocument( 15, true ) );
JLabel higieneEuroLabel = new JLabel( "\u20ac" );
JLabel precoMedicinaLabel = new JLabel( " Medicina" );
precoMedicinaText = new JTextField();
precoMedicinaText.setDocument( new DoubleDocument( 15, true ) );
JLabel medicinaEuroLabel = new JLabel( "\u20ac" );
JLabel modalidadePagamentoLabel = new JLabel( "Periodicidade" );
modalidadePagamentoText = new JTextField();
JLabel moradaLabel = new JLabel( "Morada" );
moradaText = new StateTextField();
JLabel codigoPostalLabel = new JLabel( "C\u00f3digo Postal" );
codigoPostalText = new StateTextField();
codigoPostalText.setPreferredSize( new Dimension( 50, 20 ) );
codigoPostalText.setDocument( new MaximumLengthDocument( 8 ) );
JLabel localLabel = new JLabel( "Localidade" );
localText = new StateTextField();
JLabel distritoLabel = new JLabel( "Distrito" );
distritoText = new JTextField();
JLabel concelhoLabel = new JLabel( "Concelho" );
concelhoText = new JTextField();
contacto1Panel = new ContactoPanel();
contacto1Panel.setBorder( BorderFactory.createEtchedBorder() );
contacto2Panel = new ContactoPanel();
contacto2Panel.setBorder( BorderFactory.createEtchedBorder() );
JLabel envioPropostaLabel = new JLabel( "Proposta" );
envioPropostaPanel = new JCalendarPanel( null );
JLabel aceitacaoPropostaLabel = new JLabel( "Aceita\u00e7\u00e3o" );
aceitacaoPropostaPanel = new JCalendarPanel( null );
JLabel cancelamentoLabel = new JLabel( "Cancelamento" );
cancelamentoPanel = new JCalendarPanel( null );
JLabel envioContratoLabel = new JLabel( "Envio Contrato" );
envioContratoPanel = new JCalendarPanel( null );
JLabel recepcaoContratoLabel = new JLabel( "Recep\u00e7\u00e3o" );
recepcaoContratoPanel = new JCalendarPanel( null );
JLabel envioIdictLabel = new JLabel( "Mod. 1360" );
envioIdictPanel = new JCalendarPanel( null );
JLabel relatorioAnualLabel = new JLabel( "Relat\u00f3rio Anual" );
relatorioAnualPanel = new JCalendarPanel( null );
JTabbedPane tabbedPane = new JTabbedPane();
JLabel caeLabel = new JLabel( "CAE" );
caeText = new JTextField();
JLabel actividadeLabel = new JLabel( " - " );
actividadeText = new JTextField();
JLabel contribuinteLabel = new JLabel( "Contribuinte" );
contribuinteText = new JTextField();
JLabel segSocialLabel = new JLabel( "Seguran\u00e7a Social" );
segSocialText = new JTextField();
JPanel moradaPanel = new JPanel();
marcacoesPanel = new JPanel();
protocoloPanel = new ProtocoloPanel();
// userPanel = new UserPanel();
JScrollPane estabelecimentosScroll = new JScrollPane();
estabelecimentosScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
estabelecimentosModel = new VectorTableModel( new String[]{ "Estabelecimentos" } );
estabelecimentosTable = new BaseTable( estabelecimentosModel );
estabelecimentosTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
estabelecimentosTable.getSelectionModel().addListSelectionListener( this );
estabelecimentosScroll.setViewportView( estabelecimentosTable );
JPanel dadosEmpresaPanel = new JPanel();
JPanel contactosPanel = new JPanel();
JScrollPane contactosScroll = new JScrollPane();
contactosScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
contactosScroll.setViewportView( contactosPanel );
contactosScroll.setBorder( BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(), "Contactos" ) );
JPanel formalidadesPanel = new JPanel();
JPanel pad;
JPanel upperPanel = new JPanel();
GridBagLayout gridbag = new GridBagLayout();
upperPanel.setLayout( gridbag );
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets( 1, 1, 1, 1 );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weighty = 0;
constraints.gridheight = 1;
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( designacaoSocialLabel, constraints );
upperPanel.add( designacaoSocialLabel );
constraints.weightx = 0.9;
constraints.gridwidth = 5;
gridbag.setConstraints( designacaoSocialText, constraints );
upperPanel.add( designacaoSocialText );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( codigoLabel, constraints );
upperPanel.add( codigoLabel );
constraints.weightx = 0.1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( codigoPanel, constraints );
upperPanel.add( codigoPanel );
constraints.weightx = 0;
constraints.gridwidth = 1;
// gridbag.setConstraints( moradaLabel, constraints );
// upperPanel.add( moradaLabel );
gridbag.setConstraints( caeLabel, constraints );
upperPanel.add( caeLabel );
constraints.weightx = 0.2;
constraints.gridwidth = 1;
gridbag.setConstraints( caeText, constraints );
upperPanel.add( caeText );
constraints.weightx = 0;
constraints.gridwidth = 1;
// gridbag.setConstraints( moradaLabel, constraints );
// upperPanel.add( moradaLabel );
gridbag.setConstraints( actividadeLabel, constraints );
upperPanel.add( actividadeLabel );
constraints.weightx = 0.6;
constraints.gridwidth = 1;
gridbag.setConstraints( actividadeText, constraints );
upperPanel.add( actividadeText );
constraints.weightx = 0;
constraints.gridwidth = 1;
// gridbag.setConstraints( codigoPostalLabel, constraints );
// upperPanel.add( codigoPostalLabel );
gridbag.setConstraints( contribuinteLabel, constraints );
upperPanel.add( contribuinteLabel );
constraints.weightx = 0.1;
constraints.gridwidth = 1;
gridbag.setConstraints( contribuinteText, constraints );
upperPanel.add( contribuinteText );
constraints.weightx = 0;
constraints.gridwidth = 2;
// gridbag.setConstraints( localLabel, constraints );
// upperPanel.add( localLabel );
gridbag.setConstraints( segSocialLabel, constraints );
upperPanel.add( segSocialLabel );
constraints.weightx = 0.1;
constraints.gridwidth = 1;
gridbag.setConstraints( segSocialText, constraints );
upperPanel.add( segSocialText );
gridbag = new GridBagLayout();
dadosEmpresaPanel.setLayout( gridbag );
constraints = new GridBagConstraints();
constraints.insets = new Insets( 1, 1, 1, 1 );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weighty = 0;
constraints.gridheight = 1;
contactosPanel.setLayout( new GridLayout( 1, 2 ) );
contactosPanel.add( contacto1Panel );
contactosPanel.add( contacto2Panel );
gridbag = new GridBagLayout();
formalidadesPanel.setLayout( gridbag );
constraints.weighty = 0;
constraints.gridheight = 1;
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( envioPropostaLabel, constraints );
formalidadesPanel.add( envioPropostaLabel );
constraints.weightx = 0.3;
gridbag.setConstraints( envioPropostaPanel, constraints );
formalidadesPanel.add( envioPropostaPanel );
constraints.weightx = 0;
gridbag.setConstraints( cancelamentoLabel, constraints );
formalidadesPanel.add( cancelamentoLabel );
constraints.weightx = 0.2;
constraints.gridwidth = 1;
// JPanel perfisPanel = new JPanel();
gridbag.setConstraints( cancelamentoPanel, constraints );
formalidadesPanel.add( cancelamentoPanel );
constraints.weightx = 0.4;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( precoLabel, constraints );
formalidadesPanel.add( precoLabel );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( aceitacaoPropostaLabel, constraints );
formalidadesPanel.add( aceitacaoPropostaLabel );
constraints.weightx = 0.3;
constraints.gridwidth = 1;
gridbag.setConstraints( aceitacaoPropostaPanel, constraints );
formalidadesPanel.add( aceitacaoPropostaPanel );
constraints.weightx = 0.2;
constraints.gridwidth = 2;
gridbag.setConstraints( servicosCombo, constraints );
formalidadesPanel.add( servicosCombo );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( precoHigieneLabel, constraints );
formalidadesPanel.add( precoHigieneLabel );
constraints.weightx = 0.4;
constraints.gridwidth = 1;
gridbag.setConstraints( precoHigieneText, constraints );
formalidadesPanel.add( precoHigieneText );
constraints.weightx = 0;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( higieneEuroLabel, constraints );
formalidadesPanel.add( higieneEuroLabel );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( envioContratoLabel, constraints );
formalidadesPanel.add( envioContratoLabel );
constraints.weightx = 0.3;
gridbag.setConstraints( envioContratoPanel, constraints );
formalidadesPanel.add( envioContratoPanel );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( relatorioAnualLabel, constraints );
formalidadesPanel.add( relatorioAnualLabel );
constraints.weightx = 0.2;
constraints.gridwidth = 1;
gridbag.setConstraints( relatorioAnualPanel, constraints );
formalidadesPanel.add( relatorioAnualPanel );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( precoMedicinaLabel, constraints );
formalidadesPanel.add( precoMedicinaLabel );
constraints.weightx = 0.4;
constraints.gridwidth = 1;
gridbag.setConstraints( precoMedicinaText, constraints );
formalidadesPanel.add( precoMedicinaText );
constraints.weightx = 0;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( medicinaEuroLabel, constraints );
formalidadesPanel.add( medicinaEuroLabel );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( recepcaoContratoLabel, constraints );
formalidadesPanel.add( recepcaoContratoLabel );
constraints.weightx = 0.3;
constraints.gridwidth = 1;
gridbag.setConstraints( recepcaoContratoPanel, constraints );
formalidadesPanel.add( recepcaoContratoPanel );
constraints.weightx = 0.2;
constraints.gridwidth = 2;
pad = new JPanel();
gridbag.setConstraints( pad, constraints );
formalidadesPanel.add( pad );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( modalidadePagamentoLabel, constraints );
formalidadesPanel.add( modalidadePagamentoLabel );
constraints.weightx = 0.4;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( modalidadePagamentoText, constraints );
formalidadesPanel.add( modalidadePagamentoText );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( envioIdictLabel, constraints );
formalidadesPanel.add( envioIdictLabel );
constraints.weightx = 0.3;
gridbag.setConstraints( envioIdictPanel, constraints );
formalidadesPanel.add( envioIdictPanel );
constraints.weightx = 0.7;
constraints.gridwidth = GridBagConstraints.REMAINDER;
pad = new JPanel();
gridbag.setConstraints( pad, constraints );
formalidadesPanel.add( pad );
// constraints.weightx = 0.5;
// constraints.gridwidth = GridBagConstraints.REMAINDER;
// pad = new JPanel();
// gridbag.setConstraints( pad, constraints );
// formalidadesPanel.add( pad );
setLayout( new BorderLayout() );
add( upperPanel, BorderLayout.NORTH );
JPanel lowerPanel = new JPanel();
add( lowerPanel, BorderLayout.CENTER );
gridbag = new GridBagLayout();
lowerPanel.setLayout( gridbag );
constraints.fill = GridBagConstraints.BOTH;
constraints.insets = new Insets( 0, 0, 0, 0 );
constraints.weighty = 1;
constraints.gridheight = GridBagConstraints.REMAINDER;
constraints.weightx = 0.55;
constraints.gridwidth = 1;
// lowerPanel.setLayout( new BorderLayout() );
//lowerPanel.add( dadosEmpresaPanel );
//lowerPanel.add( new JPanel() );
gridbag.setConstraints( tabbedPane, constraints );
lowerPanel.add( tabbedPane );
// lowerPanel.add( tabbedPane, BorderLayout.CENTER );
tabbedPane.add( "Contactos", contactosPanel );
tabbedPane.add( "Morada", moradaPanel );
tabbedPane.add( "Formalidades", formalidadesPanel );
tabbedPane.add( "Protocolo", protocoloPanel );
tabbedPane.add( "Tarefas", marcacoesPanel );
// if( webAware )
// {
// tabbedPane.add( "Utilizador da P\u00e1gina", userPanel );
// }
constraints.weightx = 0.45;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( estabelecimentosScroll, constraints );
lowerPanel.add( estabelecimentosScroll );
// lowerPanel.add( estabelecimentosScroll, BorderLayout.EAST );
gridbag = new GridBagLayout();
codigoPanel.setLayout( gridbag );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.insets = new Insets( 1, 0, 1, 2 );
constraints.weighty = 1;
constraints.gridheight = GridBagConstraints.REMAINDER;
if( countFields > 0 )
{
constraints.weightx = 0.2;
constraints.gridwidth = 1;
gridbag.setConstraints( codigo1Text, constraints );
codigoPanel.add( codigo1Text );
if( fieldSeparators[ 0 ] != null )
{
constraints.weightx = 0;
JLabel divLabel = new JLabel( fieldSeparators[ 0 ] );
gridbag.setConstraints( divLabel, constraints );
codigoPanel.add( divLabel );
}
}
if( countFields > 1 )
{
constraints.weightx = 0.5;
gridbag.setConstraints( codigo2Text, constraints );
codigoPanel.add( codigo2Text );
if( fieldSeparators[ 1 ] != null )
{
constraints.weightx = 0;
JLabel divLabel = new JLabel( fieldSeparators[ 1 ] );
gridbag.setConstraints( divLabel, constraints );
codigoPanel.add( divLabel );
}
// constraints.weightx = 0;
// JLabel divLabel = new JLabel( "/" );
// gridbag.setConstraints( divLabel, constraints );
// codigoPanel.add( divLabel );
}
if( countFields > 2 )
{
constraints.weightx = 0.2;
// constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( codigo3Text, constraints );
codigoPanel.add( codigo3Text );
if( fieldSeparators[ 2 ] != null )
{
constraints.weightx = 0;
JLabel divLabel = new JLabel( fieldSeparators[ 2 ] );
gridbag.setConstraints( divLabel, constraints );
codigoPanel.add( divLabel );
}
}
// gridbag = new GridBagLayout();
// perfisPanel.setLayout( gridbag );
// constraints.fill = GridBagConstraints.HORIZONTAL;
// constraints.insets = new Insets( 1, 0, 1, 2 );
// constraints.weighty = 1;
// constraints.gridheight = GridBagConstraints.REMAINDER;
//
// constraints.weightx = 0.5;
// constraints.gridwidth = 1;
// gridbag.setConstraints( perfil1Text, constraints );
// perfisPanel.add( perfil1Text );
//
// constraints.weightx = 0;
// constraints.gridwidth = 1;
// gridbag.setConstraints( perfil2Label, constraints );
// perfisPanel.add( perfil2Label );
//
// constraints.weightx = 0.5;
// //constraints.gridwidth = GridBagConstraints.REMAINDER;
// gridbag.setConstraints( perfil2Text, constraints );
// perfisPanel.add( perfil2Text );
gridbag = new GridBagLayout();
moradaPanel.setLayout( gridbag );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weighty = 0;
constraints.gridheight = 1;
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( moradaLabel, constraints );
moradaPanel.add( moradaLabel );
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( moradaText, constraints );
moradaPanel.add( moradaText );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( codigoPostalLabel, constraints );
moradaPanel.add( codigoPostalLabel );
constraints.weightx = 0.3;
gridbag.setConstraints( codigoPostalText, constraints );
moradaPanel.add( codigoPostalText );
constraints.weightx = 0.7;
constraints.gridwidth = GridBagConstraints.REMAINDER;
pad = new JPanel();
gridbag.setConstraints( pad, constraints );
moradaPanel.add( pad );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( localLabel, constraints );
moradaPanel.add( localLabel );
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( localText, constraints );
moradaPanel.add( localText );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( distritoLabel, constraints );
moradaPanel.add( distritoLabel );
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( distritoText, constraints );
moradaPanel.add( distritoText );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( concelhoLabel, constraints );
moradaPanel.add( concelhoLabel );
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( concelhoText, constraints );
moradaPanel.add( concelhoText );
listaMarcacoesPanel = new JPanel();
listaMarcacoesPanel.setLayout( new GridLayout( 1, 1 ) );
VectorTableModel marcacoesModel = new VectorTableModel( new String[]{ "Data", "Realizada", "Texto" } );
marcacoesTable = new BaseTable( marcacoesModel );
marcacoesTable.setToolTipColumn( 2 );
marcacoesTable.fixColumnWidth( 0, 150 );
marcacoesTable.fixColumnWidth( 1, 80 );
marcacoesTable.setNonResizableNorReordable();
JScrollPane marcacoesScp = new JScrollPane( marcacoesTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
listaMarcacoesPanel.add( marcacoesScp );
marcacoesCardLayout = new CardLayout();
marcacaoPanel = new MarcacaoEmpresaPanel( this );
marcacoesPanel.setLayout( marcacoesCardLayout );
marcacoesPanel.add( MarcacaoEmpresaPanel.LIST_PANEL, listaMarcacoesPanel );
marcacoesPanel.add( MarcacaoEmpresaPanel.EDIT_PANEL, marcacaoPanel );
marcacoesTable.getSelectionModel().addListSelectionListener( new ListSelectionListener(){
public void valueChanged( ListSelectionEvent e )
{
int selected = marcacoesTable.getSelectedRow();
if( selected == -1 || e.getValueIsAdjusting() )
{
return;
}
Object row = ( (VectorTableModel)marcacoesTable.getModel() ).getRowAt( selected );
marcacoesTable.clearSelection();
marcacaoPanel.setEmpresa( empresa );
if( row != null && row instanceof MarcacaoEmpresaData )
{
marcacaoPanel.fill( row );
}
else
{
marcacaoPanel.fill( null );
}
marcacoesCardLayout.show( marcacoesPanel, MarcacaoEmpresaPanel.EDIT_PANEL );
}
} );
servicosCombo.addItem( new MappableObject( new Integer( 1 ), "SHST" ) );
servicosCombo.addItem( new MappableObject( new Integer( 2 ), "Medicina do Trabalho" ) );
servicosCombo.addItem( new MappableObject( new Integer( 3 ), "Higiene e Seguran\u00e7a" ) );
servicosCombo.addItem( new MappableObject( new Integer( 4 ), "Forma\u00e7\u00e3o" ) );
servicosCombo.addItem( new MappableObject( new Integer( 5 ), "Estudos Especificos HS" ) );
servicosCombo.addItem( new MappableObject( new Integer( 6 ), "Sinal\u00e9tica" ) );
new CopyPasteHandler( designacaoSocialText );
new CopyPasteHandler( moradaText );
new CopyPasteHandler( codigoPostalText );
new CopyPasteHandler( localText );
new CopyPasteHandler( distritoText );
new CopyPasteHandler( concelhoText );
new CopyPasteHandler( codigo1Text );
new CopyPasteHandler( codigo2Text );
new CopyPasteHandler( codigo3Text );
// new CopyPasteHandler( perfil1Text );
// new CopyPasteHandler( perfil2Text );
new CopyPasteHandler( precoHigieneText );
new CopyPasteHandler( precoMedicinaText );
new CopyPasteHandler( modalidadePagamentoText );
new CopyPasteHandler( caeText );
new CopyPasteHandler( actividadeText );
new CopyPasteHandler( contribuinteText );
new CopyPasteHandler( segSocialText );
}
private void setupComponentsHashtable()
{
components = new ComponentsHashtable();
components.putComponent( EmpresaData.DESIGNACAO_SOCIAL, designacaoSocialText );
components.putComponent( EmpresaData.MORADA, moradaText );
components.putComponent( EmpresaData.CODIGO_POSTAL, codigoPostalText );
components.putComponent( EmpresaData.LOCALIDADE, localText );
components.putComponent( EmpresaData.DISTRITO, distritoText );
components.putComponent( EmpresaData.CONCELHO, concelhoText );
components.putComponent( EmpresaData.DATA_PROPOSTA, envioPropostaPanel );
components.putComponent( EmpresaData.DATA_ACEITACAO, aceitacaoPropostaPanel );
components.putComponent( EmpresaData.DATA_CANCELAMENTO, cancelamentoPanel );
components.putDummy( EmpresaData.PERFIL_1 );
components.putDummy( EmpresaData.PERFIL_2);
components.putComponent( EmpresaData.DATA_ENVIO_CONTRATO, envioContratoPanel );
components.putComponent( EmpresaData.DATA_RECEPCAO_CONTRATO, recepcaoContratoPanel );
components.putComponent( EmpresaData.DATA_ENVIO_IDICT, envioIdictPanel );
components.putComponent( EmpresaData.DATA_RELATORIO_ANUAL, relatorioAnualPanel );
components.putComponent( EmpresaData.CODIGO_1, codigo1Text );
components.putComponent( EmpresaData.CODIGO_2, codigo2Text );
components.putComponent( EmpresaData.CODIGO_3, codigo3Text );
components.putComponent( EmpresaData.CAE, caeText );
components.putComponent( EmpresaData.ACTIVIDADE, actividadeText );
components.putComponent( EmpresaData.CONTRIBUINTE, contribuinteText );
components.putComponent( EmpresaData.SEGURANCA_SOCIAL, segSocialText );
components.putComponent( EmpresaData.CONTACTO_1, contacto1Panel );
components.putComponent( EmpresaData.CONTACTO_2, contacto2Panel );
components.putComponent( EmpresaData.SERVICOS, servicosCombo );
components.putComponent( EmpresaData.PRECO_HIGIENE, precoHigieneText );
components.putComponent( EmpresaData.PRECO_MEDICINA, precoMedicinaText );
components.putComponent( EmpresaData.PERIODICIDADE, modalidadePagamentoText );
components.putDummy( EmpresaData.SERVICO_SAUDE_TIPO );
components.putDummy( EmpresaData.SERVICO_SAUDE_DESIGNACAO );
components.putDummy( EmpresaData.SERVICO_HIGIENE_TIPO );
components.putDummy( EmpresaData.SERVICO_HIGIENE_DESIGNACAO );
components.putDummy( EmpresaData.DESIGNACAO_SOCIAL_PLAIN );
}
public void clear()
{
String names[] = (String[])components.keySet().toArray( new String[0] );
ComponentController.clear( names, components );
estabelecimentosModel.clearAll();
protocoloPanel.clear();
clearMarcacoes();
empresa = null;
}
public void fill(Object value)
{
clear();
if( value == null || ( ( Object[] )value )[ 0 ] == null )
{
// userPanel.setEmpresaID( null );
return;
}
empresa = ( EmpresaData ) ( ( Object [] )value )[ 0 ];
Integer elementosProtocolo[][] = ( Integer [][] ) ( ( Object [] )value )[ 1 ];
String names[] = ( String[] ) components.keySet().toArray( new String[ components.size() ] );
ComponentController.fill( names, empresa.getHashData(), components );
id = (Integer) empresa.get( EmpresaData.ID );
IDObject estabelecimentos[];
try
{
estabelecimentos = provider.getAllEstabelecimentosForEmpresa( id );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar a lista de estabelecimentos", true );
estabelecimentos = new IDObject[0];
}
reloadMarcacoes();
Vector v = new Vector( Arrays.asList( estabelecimentos ) );
estabelecimentosModel.setValues( v );
Vector dadosProtocolo[] = new Vector[]{ new Vector(), new Vector() };
boolean analisesExamesA[] = new boolean[2];
analisesExamesA[ 0 ] = "y".equals( empresa.get( EmpresaData.A_CONSULTAS ) );
analisesExamesA[ 1 ] = "y".equals( empresa.get( EmpresaData.A_EXAMES ) );
dadosProtocolo[ 0 ].add( analisesExamesA );
dadosProtocolo[ 0 ].add( elementosProtocolo[ 0 ] );
boolean analisesExamesB[] = new boolean[2];
analisesExamesB[ 0 ] = "y".equals( empresa.get( EmpresaData.B_CONSULTAS ) );
analisesExamesB[ 1 ] = "y".equals( empresa.get( EmpresaData.B_EXAMES ) );
dadosProtocolo[ 1 ].add( analisesExamesB );
dadosProtocolo[ 1 ].add( elementosProtocolo[ 1 ] );
protocoloPanel.fill( dadosProtocolo );
// if( webAware )
// {
// userPanel.setEmpresaID( (Integer) empresa.get( EmpresaData.ID ) );
// userPanel.setEnabled( id != null );
// }
}
public Object save()
{
if( empresa == null )
{
empresa = new EmpresaData();
}
String names[] = ( String[] ) components.keySet().toArray( new String[ components.size() ] );
Hashtable hash = empresa.getHashData();
ComponentController.save( names, hash, components );
empresa.setHashData( hash );
Vector dadosProtocolo[] = ( Vector[] ) protocoloPanel.save();
boolean analisesExamesA[] = ( boolean [] ) dadosProtocolo[ 0 ].elementAt( 0 );
empresa.set( EmpresaData.A_CONSULTAS, analisesExamesA[ 0 ] ? "y" : "n" );
empresa.set( EmpresaData.A_EXAMES, analisesExamesA[ 1 ] ? "y" : "n" );
boolean analisesExamesB[] = ( boolean [] ) dadosProtocolo[ 1 ].elementAt( 0 );
empresa.set( EmpresaData.B_CONSULTAS, analisesExamesB[ 0 ] ? "y" : "n" );
empresa.set( EmpresaData.B_EXAMES, analisesExamesB[ 1 ] ? "y" : "n" );
Integer elementosProtocolo[][] =
new Integer[][]{ ( Integer [] ) dadosProtocolo[ 0 ].elementAt( 1 ),
( Integer [] ) dadosProtocolo[ 1 ].elementAt( 1 ) };
return new Object[] { empresa, elementosProtocolo };
}
public void setEnabled( boolean enable )
{
super.setEnabled( enable );
String names[] = (String[])components.keySet().toArray( new String[0] );
ComponentController.setEnabled( names, enable, components );
protocoloPanel.setEnabled( enable );
//estabelecimentosTable.setEnabled( enable );
}
public void addListSelectionListener( ListSelectionListener listener )
{
listSelectionListeners.add( listener );
}
public void removeListSelectionListener( ListSelectionListener listener )
{
listSelectionListeners.remove( listener );
}
public void valueChanged( ListSelectionEvent e )
{
for( int n = 0; n < listSelectionListeners.size(); n++ )
{
ListSelectionEvent newEvent =
new ListSelectionEvent( this, e.getFirstIndex(), e.getLastIndex(), e.getValueIsAdjusting() );
( (ListSelectionListener) listSelectionListeners.elementAt( n ) ).valueChanged( newEvent );
}
}
public Integer getSelectedEstabelecimento()
{
int selected = estabelecimentosTable.getSelectedRow();
if( selected == -1 )
{
return null;
}
return ( (IDObject) estabelecimentosModel.getRowAt( selected ) ).getID();
}
public void reload()
{
int selected = estabelecimentosTable.getSelectedRow();
fill( empresa );
if( selected != -1 )
{
estabelecimentosTable.setRowSelectionInterval( selected, selected );
}
}
public JTable getEstabelecimentosTable()
{
return estabelecimentosTable;
}
public void setSelectedEstabelecimento( EstabelecimentoData estab )
{
IDObject lista[] = (IDObject [])estabelecimentosModel.getValues().toArray( new IDObject[ 0 ] );
Integer id = (Integer)estab.get( EstabelecimentoData.ID );
for( int n = 0; n < lista.length; n++ )
{
if( lista[ n ].getID().equals( id ) )
{
estabelecimentosTable.setRowSelectionInterval( n, n );
return;
}
}
estabelecimentosTable.clearSelection();
}
protected void reloadMarcacoes()
{
try
{
Collection marcacoesCollection =
JDO.listLoad( MarcacaoEmpresa.class, new Object[]{ empresa.get( EmpresaData.ID ) },
new String []{ "empresa.id" }, new String[]{ "data descending" } );
Vector marcacoes = new Vector();
marcacoes.add( new ColumnizedObject(){
public Object getValue( int col )
{
switch( col )
{
case 0: case 1:
return "";
case 2:
return "NOVA TAREFA...";
}
return null;
}
} );
if( marcacoesCollection != null )
{
marcacoes.addAll( marcacoesCollection );
}
marcacoesTable.clearSelection();
( (VectorTableModel) marcacoesTable.getModel() ).setValues( marcacoes );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar as Marca\u00e7\u00f5es", true );
}
showMarcacoes();
}
protected void showMarcacoes()
{
marcacoesCardLayout.show( marcacoesPanel, MarcacaoEmpresaPanel.LIST_PANEL );
}
protected void clearMarcacoes()
{
( (VectorTableModel) marcacoesTable.getModel() ).clearAll();
}
}

@ -0,0 +1,450 @@
/*
* EstabelecimentoPanel.java
*
* Created on 14 de Maio de 2004, 12:21
*/
package siprp.clientes;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.data.*;
import com.evolute.utils.dataui.*;
import com.evolute.utils.documents.*;
import com.evolute.utils.jdo.*;
import com.evolute.utils.tables.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.ui.text.*;
import siprp.*;
import siprp.data.*;
/**
*
* @author fpalma
*/
public class EstabelecimentoPanel extends JPanel
implements ControllableComponent, ListSelectionListener, ActionListener
{
public static int disables = 0;
private JDOProvider JDO;
private EstabelecimentoData estabelecimento;
private ComponentsHashtable components;
private EmpresaData empresa;
private JTable estabelecimentosTable;
private JPanel toolbarPanel;
private JTextField designacaoText;
private JTextField moradaText;
private JTextField localText;
private JTextField codigoPostalText;
private ContactoPanel contactoPanel;
private JTextArea historicoText;
private JButton marcacoesButton;
private JPanel historicoPanel;
private JPanel listaHistoricoPanel;
private BaseTable historicoTable;
private HistoricoEstabelecimentoPanel edicaoHistoricoPanel;
private CardLayout historicoCardLayout;
// private MarcacaoPanel marcacaoPanel;
private SIPRPTracker tracker;
private boolean lastEnable = false;
/** Creates a new instance of EstabelecimentoPanel */
public EstabelecimentoPanel( JPanel toolbarPanel, JTextField designacaoText, JTable estabelecimentosTable )
{
this.toolbarPanel = toolbarPanel;
this.designacaoText = designacaoText;
this.estabelecimentosTable = estabelecimentosTable;
JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
setupComponents();
setupComponentsHashtable();
}
private void setupComponents()
{
JPanel dadosEstabelecimentoPanel = new JPanel();
JLabel designacaoLabel = new JLabel( "Designa\u00e7\u00e3o" );
//designacaoText = new JTextField();
JLabel moradaLabel = new JLabel( "Morada" );
moradaText = new JTextField();
JLabel codigoPostalLabel = new JLabel( "C\u00f3digo Postal" );
codigoPostalText = new JTextField();
codigoPostalText.setDocument( new MaximumLengthDocument( 8 ) );
JLabel localLabel = new JLabel( "Local" );
localText = new JTextField();
contactoPanel = new ContactoPanel();
contactoPanel.setBorder( BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(),
"Contacto" ) );
marcacoesButton = new JButton( "Marca\u00e7\u00f5es" );
marcacoesButton.addActionListener( this );
JPanel pad;
historicoText = new JTextArea();
new CopyPasteHandler( historicoText );
historicoText.setLineWrap( true );
historicoText.setWrapStyleWord( true );
JScrollPane observacoesScp = new JScrollPane( historicoText, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
observacoesScp.setBorder( BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(), "Observa\u00e7\u00f5es" ) );
historicoPanel = new JPanel();
historicoPanel.setBorder( BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(), "Hist\u00f3rico" ) );
// marcacaoPanel = new MarcacaoPanel( true, "Realizada", "Relat\u00f3rio", Marcacao.TIPO_MARCACAO_ESTABELECIMENTO );
// marcacaoPanel.setCalendarDialogOrientation( JCalendarDialog.ABOVE, JCalendarDialog.LEFT );
// marcacaoPanel.setBorder( BorderFactory.createTitledBorder(
// BorderFactory.createEtchedBorder(),
// "Visita" ) );
GridBagLayout gridbag = new GridBagLayout();
dadosEstabelecimentoPanel.setLayout( gridbag );
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets( 1, 1, 1, 1 );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.gridheight = 1;
constraints.weighty = 0;
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( toolbarPanel, constraints );
dadosEstabelecimentoPanel.add( toolbarPanel );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weighty = 1;
pad = new JPanel();
gridbag.setConstraints( pad, constraints );
dadosEstabelecimentoPanel.add( pad );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weighty = 0;
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( moradaLabel, constraints );
dadosEstabelecimentoPanel.add( moradaLabel );
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( moradaText, constraints );
dadosEstabelecimentoPanel.add( moradaText );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( codigoPostalLabel, constraints );
dadosEstabelecimentoPanel.add( codigoPostalLabel );
constraints.weightx = 0.3;
constraints.gridwidth = 1;
gridbag.setConstraints( codigoPostalText, constraints );
dadosEstabelecimentoPanel.add( codigoPostalText );
constraints.weightx = 0.7;
constraints.gridwidth = GridBagConstraints.REMAINDER;
pad = new JPanel();
gridbag.setConstraints( pad, constraints );
dadosEstabelecimentoPanel.add( pad );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( localLabel, constraints );
dadosEstabelecimentoPanel.add( localLabel );
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( localText, constraints );
dadosEstabelecimentoPanel.add( localText );
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( marcacoesButton, constraints );
dadosEstabelecimentoPanel.add( marcacoesButton );
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( contactoPanel, constraints );
gridbag = new GridBagLayout();
setLayout( gridbag );
constraints.fill = GridBagConstraints.BOTH;
constraints.weighty = 0;
constraints.gridheight = 1;
constraints.weightx = 0.5;
constraints.gridwidth = 1;
gridbag.setConstraints( dadosEstabelecimentoPanel, constraints );
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( contactoPanel, constraints );
constraints.weightx = 0.5;
constraints.weighty = 1;
constraints.gridwidth = 1;
constraints.gridheight = GridBagConstraints.REMAINDER;
gridbag.setConstraints( historicoPanel, constraints );
constraints.weightx = 0.5;
constraints.weighty = 1;
constraints.gridheight = GridBagConstraints.REMAINDER;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( observacoesScp, constraints );
add( dadosEstabelecimentoPanel );
add( contactoPanel );
add( historicoPanel );
add( observacoesScp );
listaHistoricoPanel = new JPanel();
listaHistoricoPanel.setLayout( new GridLayout( 1, 1 ) );
VectorTableModel marcacoesModel = new VectorTableModel( new String[]{ "Data", "Texto" } );
historicoTable = new BaseTable( marcacoesModel );
historicoTable.setToolTipColumn( 1 );
historicoTable.fixColumnWidth( 0, 150 );
historicoTable.setNonResizableNorReordable();
JScrollPane listaHistoricoScp = new JScrollPane( historicoTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
listaHistoricoPanel.add( listaHistoricoScp );
historicoCardLayout = new CardLayout();
edicaoHistoricoPanel = new HistoricoEstabelecimentoPanel( this );
historicoPanel.setLayout( historicoCardLayout );
historicoPanel.add( HistoricoEstabelecimentoPanel.LIST_PANEL, listaHistoricoPanel );
historicoPanel.add( HistoricoEstabelecimentoPanel.EDIT_PANEL, edicaoHistoricoPanel );
historicoTable.getSelectionModel().addListSelectionListener( new ListSelectionListener(){
public void valueChanged( ListSelectionEvent e )
{
int selected = historicoTable.getSelectedRow();
if( selected == -1 || e.getValueIsAdjusting() )
{
return;
}
Object row = ( (VectorTableModel)historicoTable.getModel() ).getRowAt( selected );
historicoTable.clearSelection();
edicaoHistoricoPanel.setEstabelecimento( estabelecimento );
if( row != null && row instanceof HistoricoEstabelecimentoData )
{
edicaoHistoricoPanel.fill( row );
}
else
{
edicaoHistoricoPanel.fill( null );
}
historicoCardLayout.show( historicoPanel, HistoricoEstabelecimentoPanel.EDIT_PANEL );
}
} );
new CopyPasteHandler( designacaoText );
new CopyPasteHandler( moradaText );
new CopyPasteHandler( localText );
new CopyPasteHandler( codigoPostalText );
}
private void setupComponentsHashtable()
{
components = new ComponentsHashtable();
components.putComponent( EstabelecimentoData.NOME, designacaoText );
components.putComponent( EstabelecimentoData.MORADA, moradaText );
components.putComponent( EstabelecimentoData.LOCALIDADE, localText );
components.putComponent( EstabelecimentoData.CODIGO_POSTAL, codigoPostalText );
components.putComponent( EstabelecimentoData.CONTACTO, contactoPanel );
// components.putComponent( EstabelecimentoData.HISTORICO, historicoText );
components.putComponent( EstabelecimentoData.HISTORICO, historicoText );
components.putDummy( EstabelecimentoData.EMPRESA );
components.putDummy( EstabelecimentoData.NOME_PLAIN );
// components.putDummy( EstabelecimentoData.INACTIVO );
}
public void clear()
{
String names[] = (String[])components.keySet().toArray( new String[0] );
ComponentController.clear( names, components );
clearHistorico();
estabelecimento = null;
}
public void fill(Object value)
{
clear();
estabelecimento = ( EstabelecimentoData ) value;
// marcacaoPanel.setEnabled( estabelecimento != null );
// marcacaoPanel.fill( estabelecimento );
if( estabelecimento == null )
{
estabelecimentosTable.clearSelection();
return;
}
String names[] = estabelecimento.getFieldNames();
ComponentController.fill( names, estabelecimento.getHashData(), components );
reloadHistorico();
}
public Object save()
{
if( estabelecimento == null )
{
estabelecimento = new EstabelecimentoData();
}
String names[] = estabelecimento.getFieldNames();
Hashtable hash = new Hashtable();
ComponentController.save( names, hash, components );
estabelecimento.setHashData( hash );
estabelecimento.set( EstabelecimentoData.EMPRESA, empresa );
return estabelecimento;
}
public void postSave()
{
int selected = estabelecimentosTable.getSelectedRow();
if( estabelecimento != null )
{
IDObject obj = new MappableObject( (Integer) estabelecimento.get( EstabelecimentoData.ID ), estabelecimento.get( EstabelecimentoData.NOME ) );
VectorTableModel model = (VectorTableModel)estabelecimentosTable.getModel();
if( selected == -1 )
{
model.insertRowAt( obj, estabelecimentosTable.getRowCount() );
estabelecimentosTable.setRowSelectionInterval( estabelecimentosTable.getRowCount() - 1, estabelecimentosTable.getRowCount() - 1 );
}
else
{
model.removeRowAt( selected );
model.insertRowAt( obj, selected );
estabelecimentosTable.setRowSelectionInterval( selected, selected );
}
}
}
public void setEnabled( boolean enable )
{
super.setEnabled( enable );
String names[] = (String[])components.keySet().toArray( new String[0] );
ComponentController.setEnabled( names, enable, components );
if( enable != lastEnable )
{
if( enable )
{
disables++;
}
else
{
disables--;
}
lastEnable = enable;
}
estabelecimentosTable.setEnabled( disables == 0 );
// if( estabelecimento == null )
// {
// marcacaoPanel.setEnabled( false );
// }
}
public void valueChanged( ListSelectionEvent e )
{
Object source = e.getSource();
if( source instanceof EmpresaPanel )
{
Integer id = ( ( EmpresaPanel ) source ).getSelectedEstabelecimento();
if( id != null )
{
try
{
EstabelecimentoData estab = ( EstabelecimentoData ) JDO.load( EstabelecimentoData.class, id );
fill( estab );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar o estabelecimento", true );
clear();
}
}
else
{
clear();
}
}
}
public void reload()
{
fill( estabelecimento );
}
public void setEmpresa( EmpresaData empresa )
{
this.empresa = empresa;
}
protected void reloadHistorico()
{
try
{
Collection historicoCollection =
JDO.listLoad( HistoricoEstabelecimento.class, new Object[]{ estabelecimento.get( EstabelecimentoData.ID ) },
new String []{ "estabelecimento.id" }, new String[]{ "data descending" } );
Vector historico = new Vector();
historico.add( new ColumnizedObject(){
public Object getValue( int col )
{
switch( col )
{
case 0:
return "";
case 1:
return "NOVO EVENTO...";
}
return null;
}
} );
if( historicoCollection != null )
{
historico.addAll( historicoCollection );
}
historicoTable.clearSelection();
( (VectorTableModel) historicoTable.getModel() ).setValues( historico );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar as Marca\u00e7\u00f5es", true );
}
showHistorico();
}
protected void showHistorico()
{
historicoCardLayout.show( historicoPanel, HistoricoEstabelecimentoPanel.LIST_PANEL );
}
protected void clearHistorico()
{
( (VectorTableModel) historicoTable.getModel() ).clearAll();
}
public void actionPerformed( ActionEvent e )
{
Object source = e.getSource();
if( source.equals( marcacoesButton ) )
{
if( empresa == null || estabelecimento == null )
{
return;
}
else
{
tracker.getHigieneWindow().setVisible( true );
tracker.getHigieneWindow().setEmpresaAndEstabelecimento( (Integer) empresa.get( EmpresaData.ID ),
( Integer ) estabelecimento.get( EstabelecimentoData.ID ) );
}
}
}
public void setTracker( SIPRPTracker tracker )
{
this.tracker = tracker;
}
}

@ -0,0 +1,89 @@
/*
* EtiquetaChooserPanel.java
*
* Created on 27 de Fevereiro de 2006, 11:21
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.clientes;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import com.evolute.utils.ui.*;
/**
*
* @author Frederico
*/
public class EtiquetaChooserDialog extends CustomJDialog
implements ActionListener
{
private int rows;
private int cols;
private final Hashtable<JButton,int[]> positionHash = new Hashtable<JButton,int[]>();
private int choice[];
/** Creates a new instance of EtiquetaChooserPanel */
public EtiquetaChooserDialog( JFrame owner, int rows, int cols )
{
super( owner, true );
this.rows = rows;
this.cols = cols;
setupComponents();
if( owner != null )
{
centerSuper();
}
else
{
center();
}
}
private void setupComponents()
{
setTitle( "Escolha a posi\u00e7\u00e3o" );
setSize( cols * 200, rows * 50 );
setLayout( new GridLayout( rows, cols ) );
for( int r = 0; r < rows; r++ )
{
for( int c = 0; c < cols; c++ )
{
JButton button = new JButton( "( " + ( r + 1 ) + " , " + ( c + 1 ) + " )" );
add( button );
positionHash.put( button, new int[]{ r, c } );
button.addActionListener( this );
}
}
}
protected void close()
{
SwingUtilities.invokeLater( new Runnable(){
public void run()
{
setVisible( false );
dispose();
}
} );
}
public int[] choose()
{
setVisible( true );
return choice;
}
public void actionPerformed( ActionEvent e )
{
Object source = e.getSource();
choice = positionHash.get( ( JButton ) source );
close();
}
}

@ -0,0 +1,200 @@
/*
* EtiquetaPrinter.java
*
* Created on 27 de Fevereiro de 2006, 14:41
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.clientes;
import java.io.*;
import java.text.*;
import java.util.*;
import com.evolute.utils.fop.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.xml.*;
import siprp.data.*;
/**
*
* @author Frederico
*/
public class EtiquetaPrinter
{
protected static final DecimalFormat N_F = new DecimalFormat();
static
{
DecimalFormatSymbols dfs = new DecimalFormatSymbols( new Locale( "pt", "PT" ) );
dfs.setDecimalSeparator( '.' );
N_F.setDecimalFormatSymbols( dfs );
N_F.setMaximumFractionDigits( 4 );
N_F.setMinimumFractionDigits( 0 );
}
protected Double altura;
protected Double largura;
protected Double margemEsquerda;
protected Double margemCima;
protected Integer colunas;
protected Integer linhas;
protected boolean continua;
protected Double alturaFolha;
protected Double larguraFolha;
protected Double margemVerticalFolha;
protected Double margemHorizontalFolha;
/** Creates a new instance of EtiquetaPrinter */
public EtiquetaPrinter( EtiquetaData etiqueta )
{
altura = ( Double ) etiqueta.get( EtiquetaData.ALTURA );
largura = ( Double ) etiqueta.get( EtiquetaData.LARGURA );
margemEsquerda = ( Double ) etiqueta.get( EtiquetaData.MARGEM_ESQUERDA );
margemCima = ( Double ) etiqueta.get( EtiquetaData.MARGEM_CIMA );
colunas = ( Integer ) etiqueta.get( EtiquetaData.COLUNAS );
linhas = ( Integer ) etiqueta.get( EtiquetaData.LINHAS );
continua = "y".equals( etiqueta.get( EtiquetaData.CONTINUA ) );
alturaFolha = ( Double ) etiqueta.get( EtiquetaData.ALTURA_FOLHA );
larguraFolha = ( Double ) etiqueta.get( EtiquetaData.LARGURA_FOLHA );
margemVerticalFolha = ( Double ) etiqueta.get( EtiquetaData.MARGEM_VERTICAL_FOLHA );
margemHorizontalFolha = ( Double ) etiqueta.get( EtiquetaData.MARGEM_HORIZONTAL_FOLHA );
}
public void print( Vector<Object[]> data )
{
int pos[] = new EtiquetaChooserDialog( null, linhas.intValue(), colunas.intValue() ).choose();
if( pos == null )
{
return;
}
int row = pos[ 0 ];
int col = pos[ 1 ];
String header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
SimpleXMLElement styleSheet =
new SimpleXMLElement( "xsl:stylesheet" );
styleSheet.addAttribute( "version", "1.1" );
styleSheet.addAttribute( "xmlns:xsl", "http://www.w3.org/1999/XSL/Transform" );
styleSheet.addAttribute( "xmlns:fo", "http://www.w3.org/1999/XSL/Format" );
styleSheet.addAttribute( "exclude-result-prefixes", "fo" );
styleSheet.setCompact( false );
SimpleXMLElement output =
new SimpleXMLElement( "xsl:output" );
styleSheet.addElement( output );
output.addAttribute( "method", "xml" );
output.addAttribute( "version", "1.0" );
output.addAttribute( "omit-xml-declaration", "no" );
output.addAttribute( "indent", "yes" );
SimpleXMLElement template =
new SimpleXMLElement( "xsl:template" );
styleSheet.addElement( template );
template.addAttribute( "match", "ETIQUETA" );
SimpleXMLElement root =
new SimpleXMLElement( "fo:root" );
template.addElement( root );
SimpleXMLElement layoutMasterSet =
new SimpleXMLElement( "fo:layout-master-set" );
root.addElement( layoutMasterSet );
SimpleXMLElement simplePageMaster =
new SimpleXMLElement( "fo:simple-page-master" );
layoutMasterSet.addElement( simplePageMaster );
simplePageMaster.addAttribute( "master-name", "simpleA4" );
simplePageMaster.addAttribute( "page-height", N_F.format( alturaFolha ) + "cm" );
simplePageMaster.addAttribute( "page-width", N_F.format( larguraFolha ) + "cm" );
simplePageMaster.addAttribute( "margin-top", N_F.format( ( row == 0 ? margemVerticalFolha : 0.0 ) + row * ( altura + margemCima ) ) + "cm" );
simplePageMaster.addAttribute( "margin-bottom", "0.5cm" );
simplePageMaster.addAttribute( "margin-left", N_F.format( ( col == 0 ? margemHorizontalFolha : 0.0 ) + col * ( largura + margemEsquerda ) ) + "cm" );
simplePageMaster.addAttribute( "margin-right", N_F.format( col == colunas - 1 ? margemHorizontalFolha : 0.0 ) );
SimpleXMLElement regionBody =
new SimpleXMLElement( "fo:region-body" );
simplePageMaster.addElement( regionBody );
SimpleXMLElement pageSequence =
new SimpleXMLElement( "fo:page-sequence" );
root.addElement( pageSequence );
pageSequence.addAttribute( "master-reference", "simpleA4" );
SimpleXMLElement flow =
new SimpleXMLElement( "fo:flow" );
pageSequence.addElement( flow );
flow.addAttribute( "flow-name", "xsl-region-body" );
for( Object line[] : data )
{
SimpleXMLElement lineXML = createLine( line, largura - ( col == 0 || col == colunas - 1 ? margemHorizontalFolha : 0.0 ) );
flow.addElement( lineXML );
}
//System.out.println( "XSL: " + styleSheet.toString() );
String xml = "<ETIQUETA></ETIQUETA>";
ByteArrayOutputStream out = new ByteArrayOutputStream();
FOPCreator creator = new FOPCreator();
InputStream xmlIn = new ByteArrayInputStream( xml.getBytes() );
try
{
creator.createFOfromXML( xmlIn, new ByteArrayInputStream( (header+styleSheet).getBytes() ), out );
ByteArrayInputStream in = new ByteArrayInputStream( out.toString().getBytes() );
Hashtable printOptions = new Hashtable();
//System.out.println( "OUT: " + out.toString() );
com.evolute.utils.fop.FOPPrinter printer = new com.evolute.utils.fop.FOPPrinter();
printer.printFO( in, false, true, printOptions );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a imprimir", true );
}
}
protected SimpleXMLElement createLine( Object[] line, Double larguraDisponival )
{
SimpleXMLElement table =
new SimpleXMLElement( "fo:table" );
table.addAttribute( "table-layout", "fixed" );
table.addAttribute( "width", N_F.format( larguraDisponival ) + "cm" );
table.addAttribute( "space-before.optimum", "0pt" );
table.addAttribute( "space-after.optimum", "0pt" );
for( int n = 1; n < line.length; n += 2 )
{
SimpleXMLElement tableColumn =
new SimpleXMLElement( "fo:table-column" );
table.addElement( tableColumn );
tableColumn.addAttribute( "column-width", N_F.format( ( ( Double ) line[ n ] ) * larguraDisponival ) + "cm" );
}
SimpleXMLElement tableBody =
new SimpleXMLElement( "fo:table-body" );
table.addElement( tableBody );
SimpleXMLElement tableRow =
new SimpleXMLElement( "fo:table-row" );
tableBody.addElement( tableRow );
for( int n = 0; n < line.length; n += 2 )
{
SimpleXMLElement tableCell =
new SimpleXMLElement( "fo:table-cell" );
tableRow.addElement( tableCell );
SimpleXMLElement block =
new SimpleXMLElement( "fo:block" );
tableCell.addElement( block );
block.addAttribute( "font-size", "10pt" );
block.addAttribute( "text-align", "left" );
// block.addAttribute( "wrap-option", "no-wrap" );
// block.addAttribute( "overflow", "scroll" );
block.addTextElement( ( String ) line[ n ] );
}
return table;
}
}

@ -0,0 +1,272 @@
/*
* HistoricoEstabelecimentoPanel.java
*
* Created on 7 de Dezembro de 2004, 15:17
*/
package siprp.clientes;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.dataui.*;
import com.evolute.utils.toolbar.*;
import com.evolute.utils.tables.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.ui.text.*;
import siprp.data.*;
/**
*
* @author fpalma
*/
public class HistoricoEstabelecimentoPanel extends JPanel
implements ControllableComponent, DocumentListener, ActionListener
{
protected static final String LIST_PANEL = "LIST_PANEL";
protected static final String FULL_LIST_PANEL = "FULL_LIST_PANEL";
protected static final String EDIT_PANEL = "EDIT_PANEL";
private ComponentsHashtable components;
private EstabelecimentoPanel owner;
private JCalendarPanel calendarPanel;
private JTextArea text;
private JButton saveButton;
private JButton cancelButton;
private EstabelecimentoData estabelecimento;
private boolean changed = false;
private boolean filling = false;
private HistoricoEstabelecimentoData historico;
public HistoricoEstabelecimentoPanel( EstabelecimentoPanel owner )
{
this.owner = owner;
setupComponents();
setupComponentsHashtable();
}
private void setupComponents()
{
calendarPanel = new JCalendarPanel( null );
// calendarPanel.addDocumentListener( this );
text = new JTextArea();
new CopyPasteHandler( text );
// text.getDocument().addDocumentListener( this );
text.setLineWrap( true );
text.setWrapStyleWord( true );
JScrollPane textScp = new JScrollPane( text, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
saveButton = new JButton( "Guardar" );
saveButton.addActionListener( this );
cancelButton = new JButton( "Voltar" );
cancelButton.addActionListener( this );
GridBagLayout gridbag = new GridBagLayout();
setLayout( gridbag );
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets( 1, 1, 1, 1 );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weightx = 0;
constraints.gridwidth = 1;
constraints.weighty = 0;
constraints.gridheight = 1;
calendarPanel.setPreferredSize( new Dimension( 130, 30 ) );
gridbag.setConstraints( calendarPanel, constraints );
add( calendarPanel );
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
JPanel buttonPanel = new JPanel();
gridbag.setConstraints( buttonPanel, constraints );
add( buttonPanel );
constraints.fill = GridBagConstraints.BOTH;
constraints.weighty = 1;
constraints.gridheight = GridBagConstraints.REMAINDER;
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.weightx = 1;
gridbag.setConstraints( textScp, constraints );
add( textScp );
buttonPanel.setLayout( new FlowLayout( FlowLayout.RIGHT ) );
initButtons();
buttonPanel.add( cancelButton );
buttonPanel.add( saveButton );
}
private void setupComponentsHashtable()
{
components = new ComponentsHashtable();
components.putComponent( HistoricoEstabelecimentoData.DATA, calendarPanel );
components.putComponent( HistoricoEstabelecimentoData.TEXTO, text );
components.putDummy( HistoricoEstabelecimentoData.ESTABELECIMENTO );
}
public void clear()
{
String names[] = (String[])components.keySet().toArray( new String[0] );
ComponentController.clear( names, components );
historico = null;
}
public void fill(Object value)
{
filling = true;
clear();
initButtons();
historico = (HistoricoEstabelecimentoData)value;
if( historico == null )
{
filling = false;
return;
}
String names[] = historico.getFieldNames();
ComponentController.fill( names, historico.getHashData(), components );
filling = false;
}
public Object save()
{
if( historico == null )
{
historico = new HistoricoEstabelecimentoData();
}
String names[] = historico.getFieldNames();
Hashtable hash = new Hashtable();
ComponentController.save( names, hash, components );
hash.put( HistoricoEstabelecimentoData.ESTABELECIMENTO, estabelecimento );
historico.setHashData( hash );
return historico;
}
public void setEnabled(boolean enable)
{
super.setEnabled( enable );
String names[] = (String[])components.keySet().toArray( new String[0] );
ComponentController.setEnabled( names, enable, components );
}
public void changedUpdate(javax.swing.event.DocumentEvent documentEvent)
{
startEditedState();
}
public void insertUpdate(javax.swing.event.DocumentEvent documentEvent)
{
startEditedState();
}
public void removeUpdate(javax.swing.event.DocumentEvent documentEvent)
{
startEditedState();
}
private void startEditedState()
{
if( !filling )
{
calendarPanel.removeDocumentListener( this );
text.getDocument().removeDocumentListener( this );
changed = true;
saveButton.setEnabled( true );
changeButton();
}
}
private void initButtons()
{
saveButton.setEnabled( false );
calendarPanel.addDocumentListener( this );
text.getDocument().addDocumentListener( this );
ClassLoader cl = new EVUtilsImageLib().getClass().getClassLoader();
Icon normal = new ImageIcon( cl.getResource( "buttons/save_normal.gif" ) );
Icon rollover = new ImageIcon( cl.getResource( "buttons/save_rollover.gif" ) );
Icon pressed = new ImageIcon( cl.getResource( "buttons/save_pressed.gif" ) );
Icon disabled = new ImageIcon( cl.getResource( "buttons/save_disabled.gif" ) );
saveButton.setIcon( normal );
saveButton.setRolloverIcon( rollover );
saveButton.setPressedIcon( pressed );
saveButton.setDisabledIcon( disabled );
saveButton.setText( null );
saveButton.setBorderPainted( false );
saveButton.setRequestFocusEnabled( false );
saveButton.setMargin( new Insets( 0, 0, 0, 0 ) );
saveButton.setToolTipText( "Gravar" );
normal = new ImageIcon( cl.getResource( "buttons/shiftl_normal.gif" ) );
rollover = new ImageIcon( cl.getResource( "buttons/shiftl_rollover.gif" ) );
pressed = new ImageIcon( cl.getResource( "buttons/shiftl_pressed.gif" ) );
disabled = new ImageIcon( cl.getResource( "buttons/shiftl_disabled.gif" ) );
cancelButton.setIcon( normal );
cancelButton.setRolloverIcon( rollover );
cancelButton.setPressedIcon( pressed );
cancelButton.setDisabledIcon( disabled );
cancelButton.setText( null );
cancelButton.setBorderPainted( false );
cancelButton.setRequestFocusEnabled( false );
cancelButton.setMargin( new Insets( 0, 0, 0, 0 ) );
cancelButton.setToolTipText( "Voltar \u00e0 lista" );
}
private void changeButton()
{
ClassLoader cl = new EVUtilsImageLib().getClass().getClassLoader();
Icon normal = new ImageIcon( cl.getResource( "buttons/cancel_normal.gif" ) );
Icon rollover = new ImageIcon( cl.getResource( "buttons/cancel_rollover.gif" ) );
Icon pressed = new ImageIcon( cl.getResource( "buttons/cancel_pressed.gif" ) );
Icon disabled = new ImageIcon( cl.getResource( "buttons/cancel_disabled.gif" ) );
cancelButton.setIcon( normal );
cancelButton.setRolloverIcon( rollover );
cancelButton.setPressedIcon( pressed );
cancelButton.setDisabledIcon( disabled );
cancelButton.setToolTipText( "Cancelar" );
}
public void actionPerformed( ActionEvent e )
{
Object source = e.getSource();
if( source.equals( saveButton ) )
{
if( calendarPanel.getDate() == null )
{
JOptionPane.showMessageDialog( this, "Tem de escolher uma data", "Erro...", JOptionPane.ERROR_MESSAGE );
return;
}
HistoricoEstabelecimentoData hist = ( HistoricoEstabelecimentoData ) save();
try
{
hist.save();
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a gravar", true );
return;
}
owner.reloadHistorico();
}
else if( source.equals( cancelButton ) )
{
owner.showHistorico();
}
}
public void setEstabelecimento( EstabelecimentoData estabelecimento )
{
this.estabelecimento = estabelecimento;
}
}

@ -0,0 +1,287 @@
/*
* MarcacaoEmpresaPanel.java
*
* Created on 25 de Junho de 2004, 20:32
*/
package siprp.clientes;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.dataui.*;
import com.evolute.utils.toolbar.*;
import com.evolute.utils.tables.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.ui.text.*;
import siprp.data.*;
/**
*
* @author fpalma
*/
public class MarcacaoEmpresaPanel extends JPanel
implements ControllableComponent, DocumentListener, ActionListener, ChangeListener
{
protected static final String LIST_PANEL = "LIST_PANEL";
protected static final String EDIT_PANEL = "EDIT_PANEL";
private ComponentsHashtable components;
private EmpresaPanel owner;
private JCalendarPanel calendarPanel;
private JTextArea text;
private JCheckBox realizadaCheck;
private JButton saveButton;
private JButton cancelButton;
private EmpresaData empresa;
private boolean changed = false;
private boolean filling = false;
private MarcacaoEmpresaData marcacao;
/** Creates a new instance of MarcacaoEmpresaPanel */
public MarcacaoEmpresaPanel( EmpresaPanel owner )
{
this.owner = owner;
setupComponents();
setupComponentsHashtable();
}
private void setupComponents()
{
calendarPanel = new JCalendarPanel( null );
// calendarPanel.addDocumentListener( this );
text = new JTextArea();
new CopyPasteHandler( text );
// text.getDocument().addDocumentListener( this );
text.setLineWrap( true );
text.setWrapStyleWord( true );
JScrollPane textScp = new JScrollPane( text, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
realizadaCheck = new JCheckBox( "Realizada" );
saveButton = new JButton( "Guardar" );
saveButton.addActionListener( this );
cancelButton = new JButton( "Voltar" );
cancelButton.addActionListener( this );
GridBagLayout gridbag = new GridBagLayout();
setLayout( gridbag );
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets( 1, 1, 1, 1 );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weightx = 0;
constraints.gridwidth = 1;
constraints.weighty = 0;
constraints.gridheight = 1;
calendarPanel.setPreferredSize( new Dimension( 130, 30 ) );
gridbag.setConstraints( calendarPanel, constraints );
add( calendarPanel );
gridbag.setConstraints( realizadaCheck, constraints );
add( realizadaCheck );
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
JPanel buttonPanel = new JPanel();
gridbag.setConstraints( buttonPanel, constraints );
add( buttonPanel );
constraints.fill = GridBagConstraints.BOTH;
constraints.weighty = 1;
constraints.gridheight = GridBagConstraints.REMAINDER;
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.weightx = 1;
gridbag.setConstraints( textScp, constraints );
add( textScp );
buttonPanel.setLayout( new FlowLayout( FlowLayout.RIGHT ) );
initButtons();
buttonPanel.add( cancelButton );
buttonPanel.add( saveButton );
}
private void setupComponentsHashtable()
{
components = new ComponentsHashtable();
components.putComponent( MarcacaoEmpresaData.DATA, calendarPanel );
components.putComponent( MarcacaoEmpresaData.TEXTO, text );
components.putComponent( MarcacaoEmpresaData.REALIZADA, realizadaCheck );
components.putDummy( MarcacaoEmpresaData.EMPRESA );
}
public void clear()
{
String names[] = (String[])components.keySet().toArray( new String[0] );
ComponentController.clear( names, components );
marcacao = null;
}
public void fill(Object value)
{
filling = true;
clear();
initButtons();
marcacao = (MarcacaoEmpresaData)value;
if( marcacao == null )
{
filling = false;
return;
}
String names[] = marcacao.getFieldNames();
ComponentController.fill( names, marcacao.getHashData(), components );
filling = false;
}
public Object save()
{
if( marcacao == null )
{
marcacao = new MarcacaoEmpresaData();
}
String names[] = marcacao.getFieldNames();
Hashtable hash = new Hashtable();
ComponentController.save( names, hash, components );
hash.put( MarcacaoEmpresaData.EMPRESA, empresa );
marcacao.setHashData( hash );
System.out.println( "EMPRESA:: " + marcacao.get( MarcacaoEmpresaData.EMPRESA ) );
return marcacao;
}
public void setEnabled(boolean enable)
{
super.setEnabled( enable );
String names[] = (String[])components.keySet().toArray( new String[0] );
ComponentController.setEnabled( names, enable, components );
}
public void changedUpdate(javax.swing.event.DocumentEvent documentEvent)
{
startEditedState();
}
public void insertUpdate(javax.swing.event.DocumentEvent documentEvent)
{
startEditedState();
}
public void removeUpdate(javax.swing.event.DocumentEvent documentEvent)
{
startEditedState();
}
private void startEditedState()
{
if( !filling )
{
calendarPanel.removeDocumentListener( this );
text.getDocument().removeDocumentListener( this );
realizadaCheck.removeChangeListener( this );
changed = true;
saveButton.setEnabled( true );
changeButton();
}
}
private void initButtons()
{
saveButton.setEnabled( false );
calendarPanel.addDocumentListener( this );
realizadaCheck.addChangeListener( this );
text.getDocument().addDocumentListener( this );
ClassLoader cl = new EVUtilsImageLib().getClass().getClassLoader();
Icon normal = new ImageIcon( cl.getResource( "buttons/save_normal.gif" ) );
Icon rollover = new ImageIcon( cl.getResource( "buttons/save_rollover.gif" ) );
Icon pressed = new ImageIcon( cl.getResource( "buttons/save_pressed.gif" ) );
Icon disabled = new ImageIcon( cl.getResource( "buttons/save_disabled.gif" ) );
saveButton.setIcon( normal );
saveButton.setRolloverIcon( rollover );
saveButton.setPressedIcon( pressed );
saveButton.setDisabledIcon( disabled );
saveButton.setText( null );
saveButton.setBorderPainted( false );
saveButton.setRequestFocusEnabled( false );
saveButton.setMargin( new Insets( 0, 0, 0, 0 ) );
saveButton.setToolTipText( "Gravar" );
normal = new ImageIcon( cl.getResource( "buttons/shiftl_normal.gif" ) );
rollover = new ImageIcon( cl.getResource( "buttons/shiftl_rollover.gif" ) );
pressed = new ImageIcon( cl.getResource( "buttons/shiftl_pressed.gif" ) );
disabled = new ImageIcon( cl.getResource( "buttons/shiftl_disabled.gif" ) );
cancelButton.setIcon( normal );
cancelButton.setRolloverIcon( rollover );
cancelButton.setPressedIcon( pressed );
cancelButton.setDisabledIcon( disabled );
cancelButton.setText( null );
cancelButton.setBorderPainted( false );
cancelButton.setRequestFocusEnabled( false );
cancelButton.setMargin( new Insets( 0, 0, 0, 0 ) );
cancelButton.setToolTipText( "Voltar \u00e0 lista" );
}
private void changeButton()
{
ClassLoader cl = new EVUtilsImageLib().getClass().getClassLoader();
Icon normal = new ImageIcon( cl.getResource( "buttons/cancel_normal.gif" ) );
Icon rollover = new ImageIcon( cl.getResource( "buttons/cancel_rollover.gif" ) );
Icon pressed = new ImageIcon( cl.getResource( "buttons/cancel_pressed.gif" ) );
Icon disabled = new ImageIcon( cl.getResource( "buttons/cancel_disabled.gif" ) );
cancelButton.setIcon( normal );
cancelButton.setRolloverIcon( rollover );
cancelButton.setPressedIcon( pressed );
cancelButton.setDisabledIcon( disabled );
cancelButton.setToolTipText( "Cancelar" );
}
public void actionPerformed( ActionEvent e )
{
Object source = e.getSource();
if( source.equals( saveButton ) )
{
if( calendarPanel.getDate() == null )
{
JOptionPane.showMessageDialog( this, "Tem de escolher uma data", "Erro...", JOptionPane.ERROR_MESSAGE );
return;
}
MarcacaoEmpresaData marc = ( MarcacaoEmpresaData ) save();
try
{
marc.save();
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a gravar", true );
return;
}
owner.reloadMarcacoes();
}
else if( source.equals( cancelButton ) )
{
owner.showMarcacoes();
}
}
public void setEmpresa( EmpresaData empresa )
{
this.empresa = empresa;
}
public void stateChanged(javax.swing.event.ChangeEvent changeEvent)
{
startEditedState();
}
}

@ -0,0 +1,625 @@
/*
* MarcacaoPanel.java
*
* Created on 14 de Maio de 2004, 15:52
*/
package siprp.clientes;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.text.*;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.dataui.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.ui.panel.*;
import siprp.*;
import siprp.data.*;
/**
*
* @author fpalma
*/
public class MarcacaoPanel extends JPanel
implements ControllableComponent, ActionListener
{
private final String COLUMN_NAMES_REL[];
private static final DateFormat DATE_FORMAT = DateFormat.getDateInstance( DateFormat.SHORT );
private Marcacao marcacoes[];
private ComponentsHashtable components;
private int tipo;
private final boolean comRelatorio;
private Box anteriorPanel;
private JPanel correntePanel;
private String realizadoLabelText;
private String relatorioLabelText;
private JLabel dataMarcacaoAnteriorLabel;
private JCheckBox realizadaCheckBox;
private JCalendarPanel dataRelatorioPanel;
private JCalendarPanel dataMarcacaoPanel;
private JButton enviarEmailButton;
private JLabel dataEnvioMailLabel;
private JButton historicoButton;
private TrabalhadorData trabalhador;
private EstabelecimentoData estabelecimento;
private MarcacaoListLoader loader;
private Marcacao current;
private Marcacao last;
private boolean filling = false;
/** Creates a new instance of MarcacaoPanel */
public MarcacaoPanel( boolean comRelatorio, String realizadoLabelText, String relatorioLabelText, int tipo )
{
this.comRelatorio = comRelatorio;
this.realizadoLabelText = realizadoLabelText;
this.relatorioLabelText = relatorioLabelText;
this.tipo = tipo;
COLUMN_NAMES_REL = new String[ comRelatorio ? 3 : 2 ];
COLUMN_NAMES_REL[ 0 ] = "Data";
COLUMN_NAMES_REL[ 1 ] = realizadoLabelText;
if( comRelatorio )
{
COLUMN_NAMES_REL[ 2 ] = relatorioLabelText;
}
loader = new MarcacaoListLoader();
setupComponents();
setupComponentsHashtable();
}
private void setupComponents()
{
anteriorPanel = new Box( BoxLayout.X_AXIS );
anteriorPanel.setBorder( BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(),
"Anterior" ) );
correntePanel = new JPanel();
// correntePanel.setBorder( BorderFactory.createTitledBorder(
// BorderFactory.createEtchedBorder(),
// "Corrente" ) );
JPanel dataPanel = new JPanel();
Box relatorioBox = new Box( BoxLayout.X_AXIS );
dataMarcacaoAnteriorLabel = new JLabel( "-" );
dataEnvioMailLabel = new JLabel( "" );
realizadaCheckBox = new JCheckBox( realizadoLabelText + " " );
realizadaCheckBox.addChangeListener( new ChangeListener(){
public void stateChanged( ChangeEvent e )
{
System.out.println( "stateChanged" );
if( last != null && !filling )
{
System.out.println( "stateChanged2" );
last.set( Marcacao.REALIZADA, realizadaCheckBox.isSelected() ? "y": "n" );
try
{
last.save();
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a gravar", true );
realizadaCheckBox.setSelected( realizadaCheckBox.isSelected() );
}
}
}
} );
JLabel relatorioLabel = new JLabel( relatorioLabelText );
dataRelatorioPanel = new JCalendarPanel( null );
dataRelatorioPanel.addDocumentListener( new DocumentListener(){
public void changedUpdate( DocumentEvent e )
{
if( !filling )
{
marcarRelatorio();
}
}
public void insertUpdate( DocumentEvent e )
{
if( !filling )
{
marcarRelatorio();
}
}
public void removeUpdate( DocumentEvent e )
{
if( !filling )
{
marcarRelatorio();
}
}
private void marcarRelatorio()
{
last.set( Marcacao.DATA_RELATORIO, dataRelatorioPanel.getDate() );
try
{
last.save();
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a gravar", true );
}
}
} );
dataMarcacaoPanel = new JCalendarPanel( null );
dataMarcacaoPanel.addDocumentListener( new DocumentListener(){
public void changedUpdate( DocumentEvent e )
{
if( !filling )
{
marcar();
}
}
public void insertUpdate( DocumentEvent e )
{
if( !filling )
{
marcar();
}
}
public void removeUpdate( DocumentEvent e )
{
if( !filling )
{
marcar();
}
}
} );
enviarEmailButton = new JButton( "Enviar Email" );
enviarEmailButton.addActionListener( this );
historicoButton = new JButton( "H" );
historicoButton.addActionListener( this );
anteriorPanel.add( dataPanel );
if( comRelatorio )
{
anteriorPanel.add( relatorioBox );
anteriorPanel.add( relatorioLabel );
anteriorPanel.add( dataRelatorioPanel );
}
dataPanel.setLayout( new GridLayout( 1, 2 ) );
dataPanel.add( dataMarcacaoAnteriorLabel );
dataPanel.add( realizadaCheckBox );
correntePanel.setLayout( new GridLayout( 1, 2 ) );
correntePanel.add( dataMarcacaoPanel );
correntePanel.add( enviarEmailButton );
//setLayout( new BoxLayout( this, BoxLayout.Y_AXIS ) );
GridBagLayout gridbag = new GridBagLayout();
setLayout( gridbag );
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets( 1, 1, 1, 1 );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weighty = 0.5;
constraints.gridheight = 1;
constraints.weightx = 1;
constraints.gridwidth = 1;
gridbag.setConstraints( anteriorPanel, constraints );
add( anteriorPanel );
constraints.fill = GridBagConstraints.BOTH;
constraints.weighty = 1;
constraints.gridheight = 2;
constraints.weightx = 0;
constraints.gridwidth = GridBagConstraints.REMAINDER;
historicoButton.setPreferredSize( new Dimension( 20, 40 ) );
gridbag.setConstraints( historicoButton, constraints );
add( historicoButton );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weighty = 0.5;
constraints.gridheight = 1;
constraints.weightx = 1;
constraints.gridwidth = 1;
constraints.gridx = 0;
gridbag.setConstraints( correntePanel, constraints );
add( correntePanel );
}
private void setupComponentsHashtable()
{
components = new ComponentsHashtable();
components.putComponent( Marcacao.DATA, dataMarcacaoPanel );
components.putComponent( Marcacao.REALIZADA, realizadaCheckBox );
components.putComponent( Marcacao.DATA_RELATORIO, dataRelatorioPanel );
}
public void clear()
{
String names[] = (String[])components.keySet().toArray( new String[0] );
ComponentController.clear( names, components );
dataMarcacaoAnteriorLabel.setText( "" );
dataEnvioMailLabel.setText( "" );
marcacoes = null;
trabalhador = null;
estabelecimento = null;
current = null;
last = null;
}
public void fill( Object value )
{
filling = true;
clear();
if( value == null )
{
setEnabled( false );
filling = false;
return;
}
switch( tipo )
{
case Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES: case Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA:
if( ! ( value instanceof TrabalhadorData ) )
{
filling = false;
return ;
}
trabalhador = (TrabalhadorData) value;
try
{
marcacoes = loader.load( tipo, (Integer)trabalhador.get( TrabalhadorData.ID ) );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar as marca\u00e7\u00f5es", true );
marcacoes = null;
}
break;
case Marcacao.TIPO_MARCACAO_ESTABELECIMENTO:
if( ! ( value instanceof EstabelecimentoData ) )
{
filling = false;
return ;
}
estabelecimento = (EstabelecimentoData) value;
try
{
marcacoes = loader.load( tipo, (Integer)estabelecimento.get( EstabelecimentoData.ID ) );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar as marca\u00e7\u00f5es", true );
marcacoes = null;
}
break;
}
if( marcacoes == null || marcacoes.length == 0 )
{
filling = false;
return;
}
Date lastDate = (Date) marcacoes[ 0 ].get( Marcacao.DATA );
current = null;
last = null;
if( !lastDate.after( new Date() ) )
{
current = null;
last = marcacoes[ 0 ];
}
else
{
current = marcacoes[ 0 ];
if( marcacoes.length > 1 )
{
last = marcacoes[ 1 ];
}
}
fillCurrent();
fillLast();
filling = false;
}
private void fillCurrent()
{
if( current != null )
{
Date dataMarcacao = (Date) current.get( Marcacao.DATA );
dataMarcacaoPanel.setDate( dataMarcacao );
Date dataMail = (Date) current.get( Marcacao.DATA_EMAIL );
if( dataMail == null )
{
enviarEmailButton.setEnabled( dataMarcacao != null );
dataEnvioMailLabel.setText( "" );
}
else
{
enviarEmailButton.setEnabled( false );
dataEnvioMailLabel.setText( DATE_FORMAT.format( dataMail ) );
}
}
else
{
enviarEmailButton.setEnabled( false );
}
}
private void fillLast()
{
if( last != null )
{
Date dataMarcacao = (Date) last.get( Marcacao.DATA );
dataMarcacaoAnteriorLabel.setText( DATE_FORMAT.format( dataMarcacao ) );
String realizada = (String) last.get( Marcacao.REALIZADA );
boolean isRealizada = "y".equals( realizada );
realizadaCheckBox.setSelected( isRealizada );
realizadaCheckBox.setEnabled( !isRealizada );
Date dataRelatorio = (Date) last.get( Marcacao.DATA_RELATORIO );
dataRelatorioPanel.setDate( dataRelatorio );
}
else
{
realizadaCheckBox.setEnabled( false );
dataRelatorioPanel.setEnabled( false );
}
}
public Object save()
{
// if( marcacoes == null )
// {
// marcacoes = new Marcacao[ 0 ];
// }
// if( marcacoes[ marcacoes.length - 1 ] == null )
// {
// marcacoes[ marcacoes.length - 1 ] = Marcacao.getMarcacao( tipo );
// }
// if( marcacoes.length > 1 )
// {
// }
return null;
}
public void setEnabled( boolean enable )
{
filling = true;
String names[] = (String[])components.keySet().toArray( new String[0] );
ComponentController.setEnabled( names, enable, components );
if( !enable )
{
enviarEmailButton.setEnabled( false );
}
if( last == null )
{
realizadaCheckBox.setEnabled( false );
dataRelatorioPanel.setEnabled( false );
}
filling = false;
}
public void actionPerformed( ActionEvent e )
{
Object source = e.getSource();
if( source.equals( enviarEmailButton ) )
{
Date today = new Date();
current.set( Marcacao.DATA_EMAIL, today );
String subject = ".";
String texto = "";
EstabelecimentoData estab = null;
if( current instanceof MarcacaoTrabalhadorData )
{
TrabalhadorData trab = ( TrabalhadorData )current.get( MarcacaoTrabalhadorData.TRABALHADOR );
String nome = ( String )trab.get( TrabalhadorData.NOME );
String data = DateFormat.getDateInstance( DateFormat.SHORT ).format( ( Date )current.get( MarcacaoTrabalhadorData.DATA ) );
if( ( ( Number )current.get( MarcacaoTrabalhadorData.TIPO ) ).intValue() == MarcacaoTrabalhadorConstants.TIPO_EXAMES )
{
subject = ( String ) Singleton.getInstance( SingletonConstants.SUBJECT_EXAMES );
subject = subject.replaceAll( CompanyDataLoader.NOME, nome );
texto = ( String ) Singleton.getInstance( SingletonConstants.LETTER_EXAMES );
texto = texto.replaceAll( CompanyDataLoader.DATA, data );
texto = texto.replaceAll( CompanyDataLoader.NOME, nome );
// subject = "Marca\u00E7\u00E3o de exame";
// texto = "Vimos pelo presente informar que '" + nome + "' dever\u00E1 comparecer "
// + "nas nossas instala\u00E7\u00F5es para a realiza\u00E7\u00E3o dos exames de Medicina "
// + "do Trabalho, no dia '" + data + "', pelas 08H30."
// + "%0A%0A"
// + "Relembramos que o colaborador dever\u00E1 comparecer em jejum."
// + "%0A%0A"
// + "Caso n\u00E3o seja poss\u00EDvel a compar\u00EAncia deste colaborador na data "
// + "indicada, contacte-nos, por favor, atrav\u00E9s do telefone 21 350 45 40 "
//// + "indicada, contacte-nos, por favor, atrav\u00E9s do telefone 21 210 21 21 "
// + "ou respondendo ao remetente desta mensagem."
// + "%0A%0A%0A"
// + "Cumprimentos,%0A%0ASIPRP";
//// + "Cumprimentos,";
}
else
{
subject = ( String ) Singleton.getInstance( SingletonConstants.SUBJECT_CONSULTA );
subject = subject.replaceAll( CompanyDataLoader.NOME, nome );
texto = ( String ) Singleton.getInstance( SingletonConstants.LETTER_CONSULTA );
texto = texto.replaceAll( CompanyDataLoader.DATA, data );
texto = texto.replaceAll( CompanyDataLoader.NOME, nome );
// subject = "Marca\u00E7\u00E3o de consulta";
// texto = "Vimos pelo presente informar que '" + nome + "' dever\u00E1 comparecer "
// + "nas nossas instala\u00E7\u00F5es para a realiza\u00E7\u00E3o da consulta de Medicina "
// + "do Trabalho, no dia '" + data + "', pelas 08H30."
// + "%0A%0A"
// + "%0A%0A"
// + "Solicitamos, tamb\u00E9m, que o colaborador seja portador do Boletim de Vacinas e "
// + "dos \u00FAltimos exames complementares realizados."
// + "%0A%0A"
// + "%0A%0A"
// + "Caso n\u00E3o seja poss\u00EDvel a compar\u00EAncia deste colaborador na data "
// + "indicada, contacte-nos, por favor, atrav\u00E9s do telefone 21 350 45 40 "
//// + "indicada, contacte-nos, por favor, atrav\u00E9s do telefone 21 210 21 21 "
// + "ou respondendo ao remetente desta mensagem."
// + "%0A%0A%0A"
// + "Cumprimentos,"
// + "%0A%0ASIPRP"
// + "%0A%0AATRIUM SALDANHA"
// + "%0A%0APra\u00e7a Duque de Saldanha, 1 - 9\u00BAC"
// + "%0A%0A1050-094 Lisboa";
}
estab = ( EstabelecimentoData )trab.get( TrabalhadorData.ESTABELECIMENTO );
}
else
{
estab = ( EstabelecimentoData )current.get( MarcacaoEstabelecimentoData.ESTABELECIMENTO );
String sede = ( String )estab.get( EstabelecimentoData.NOME );
subject = ( String ) Singleton.getInstance( SingletonConstants.SUBJECT_VISITA );
subject = subject.replaceAll( CompanyDataLoader.NOME, sede );
String morada = ( String )estab.get( EstabelecimentoData.MORADA );
String data = DateFormat.getDateInstance( DateFormat.SHORT ).format( ( Date )current.get( MarcacaoEstabelecimentoData.DATA ) );
texto = ( String ) Singleton.getInstance( SingletonConstants.LETTER_VISITA );
texto = texto.replaceAll( CompanyDataLoader.DATA, data );
texto = texto.replaceAll( CompanyDataLoader.NOME, sede );
texto = texto.replaceAll( CompanyDataLoader.MORADA, morada );
// texto = "Vimos pelo presente informar que iremos efectuar a auditoria de Higiene e "
// + "Seguran\u00E7a \u00E0s vossas instala\u00E7\u00F5es de '" + sede + "', no dia '" + data + "'."
// + "%0A%0A"
// + "Agradecemos que nos confirme, pela mesma via, o nome do representante "
// + "da empresa que nos ir\u00E1 acompanhar e a vossa disponibilidade para a "
// + "realiza\u00E7\u00E3o da visita na data indicada."
// + "%0A%0A"
// + "Caso necessite de qualquer esclarecimento, contacte-nos, por favor, "
// + "atrav\u00E9s dos telefones 21 350 45 43 (Pedro Vieira), 21 350 45 44 "
// + "(Catarina Leonardo) ou responda ao remetente desta mensagem."
//// + "atrav\u00E9s dos telefones 21 210 21 21 (Colaborador), 21 210 21 21 "
//// + "(Outro Colaborador) ou responda ao remetente desta mensagem."
// + "%0A%0A%0A"
// + "Cumprimentos,%0A%0ASIPRP";
//// + "Cumprimentos,";
}
ContactoData cont = ( ContactoData )estab.get( EstabelecimentoData.CONTACTO );
String mail = "";
if( cont != null )
{
mail = ( String )cont.get( ContactoData.EMAIL );
}
try
{
current.save();
if( System.getProperty( "os.name" ).startsWith( "Windows" ) )
{
mail = mail.replaceAll( " ", "%20" );
subject = subject.replaceAll( " ", "%20" );
texto = texto.replaceAll( " ", "%20" );
Process proc = Runtime.getRuntime().exec( "cmd.exe /c start mailto:\"" + mail
+ "?subject=" + subject + "&body="
// + "?subject=" + subject + "&body="
+ texto
);
}
else
{
mail = mail.replaceAll( " ", "%20" );
subject = subject.replaceAll( " ", "%20" );
texto = texto.replaceAll( " ", "%20" );
// System.out.println( "mailto:" + mail
// // + "?subject=SIPRP - " + subject + "&body="
// + "?subject=" + subject + "&body="
// + texto );
Process proc = Runtime.getRuntime().exec( new String[]{ "/usr/bin/open", "/Applications/Mail.app", "mailto:" + mail
// + "?subject=SIPRP - " + subject + "&body="
+ "?subject=" + subject + "&body="
+ texto } );
}
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a enviar mail", true );
}
dataEnvioMailLabel.setText( DATE_FORMAT.format( today ) );
}
else if( source.equals( historicoButton ) )
{
Vector v = new Vector();
if( marcacoes != null )
{
v.addAll( Arrays.asList( marcacoes ) );
}
ListActionDialog dialog =
new ListActionDialog( null, "Anteriores",
COLUMN_NAMES_REL,
v, null );
dialog.show();
}
}
public void marcar()
{
System.out.println( "MARCAR" );
Date data = dataMarcacaoPanel.getDate();
Vector aux = new Vector();
if( marcacoes != null )
{
aux.addAll( Arrays.asList( marcacoes ) );
}
if( current == null && data != null )
{
current = Marcacao.getMarcacao( tipo );
current.set( Marcacao.REALIZADA, "n" );
aux.insertElementAt( current, 0 );
switch( tipo )
{
case Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES: case Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA:
current.set( MarcacaoTrabalhadorData.TRABALHADOR, trabalhador );
current.set( MarcacaoTrabalhadorData.TIPO, new Integer( tipo ) );
break;
case Marcacao.TIPO_MARCACAO_ESTABELECIMENTO:
current.set( MarcacaoEstabelecimentoData.ESTABELECIMENTO, estabelecimento );
break;
}
marcacoes = ( Marcacao [])aux.toArray( new Marcacao[0] );
// System.out.println( "INSERI ! !! ! ! !! ! " );
}
else if( current != null && data == null )
{
aux.remove( 0 );
marcacoes = ( Marcacao [])aux.toArray( new Marcacao[0] );
// System.out.println( "REMOVI ! !! ! ! !! ! " );
}
current.set( Marcacao.DATA, data );
try
{
if( data != null )
{
current.save();
enviarEmailButton.setEnabled( true );
}
else
{
System.out.println( "DELETE DA MARCACAO" );
current.delete();
}
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a gravar", true );
}
}
public void setCalendarDialogOrientation( int vertical, int horizontal )
{
dataRelatorioPanel.setOrientation( vertical, horizontal );
dataMarcacaoPanel.setOrientation( vertical, horizontal );
}
}

@ -0,0 +1,96 @@
/*
* NoticiasDataProvider.java
*
* Created on 24 de Maio de 2005, 15:39
*/
package siprp.clientes;
import com.evolute.utils.*;
import com.evolute.utils.arrays.*;
import com.evolute.utils.data.*;
import com.evolute.utils.db.*;
import com.evolute.utils.metadb.*;
import com.evolute.utils.ui.search.*;
import com.evolute.utils.sql.*;
import siprp.*;
/**
*
* @author fpalma
*/
public class NoticiasDataProvider extends MetaProvider
{
private static final Object LOCK = new Object();
private static NoticiasDataProvider instance = null;
private final Executer executer;
/** Creates a new instance of NoticiasDataProvider */
public NoticiasDataProvider()
throws Exception
{
boolean webAware = ( ( Boolean ) Singleton.getInstance( SingletonConstants.WEB_AWARE ) ).booleanValue();
DBManager dbm;
if( webAware )
{
String url = ( String ) Singleton.getInstance( SingletonConstants.WEB_URL_PREFIX );
url += ( String ) Singleton.getInstance( SingletonConstants.WEB_URL ) + "/";
url += ( String ) Singleton.getInstance( SingletonConstants.WEB_DB_NAME ) + "/";
String user = ( String ) Singleton.getInstance( SingletonConstants.WEB_USER );
String pwd = ( String ) Singleton.getInstance( SingletonConstants.WEB_PASSWORD );
dbm = new JDBCManager( url, user, pwd, 10, 8, 8, null );
executer = dbm.getSharedExecuter( this );
}
else
{
dbm = null;
executer = null;
}
}
public static MetaProvider getProvider()
throws Exception
{
synchronized( LOCK )
{
if( instance == null )
{
instance = new NoticiasDataProvider();
}
}
return instance;
}
public String getNoticias()
throws Exception
{
Select subSelect =
new Select( new String[]{ "not_noticias" },
new String[]{ "MAX(id)" }, null );
Select select =
new Select( new String[]{ "not_noticias" },
new String[]{ "noticia" },
new Field( "id" ).isEqual( subSelect ) );
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
{
return "";
}
return array.get( 0, 0 ).toString().trim();
}
public void saveNoticias( String noticias )
throws Exception
{
Insert insert =
new Insert( "not_noticias",
new Assignment[]{ new Assignment( new Field( "utilizador" ), Singleton.getInstance( Singleton.USERNAME ) ),
new Assignment( new Field( "data" ), Singleton.getInstance( Singleton.TODAY ) ),
new Assignment( new Field( "noticia" ), noticias.trim() ) } );
executer.executeQuery( insert );
}
}

@ -0,0 +1,101 @@
/*
* NoticiasPanel.java
*
* Created on 24 de Maio de 2005, 15:12
*/
package siprp.clientes;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.ui.panel.*;
/**
*
* @author fpalma
*/
public class NoticiasDialog extends CustomJDialog
implements ActionListener
{
protected HTMLEditorPanel textText;
protected JButton okButton;
protected JButton cancelButton;
protected NoticiasDataProvider provider;
/** Creates a new instance of NoticiasPanel */
public NoticiasDialog( JFrame owner )
throws Exception
{
super( owner, true );
provider = (NoticiasDataProvider)NoticiasDataProvider.getProvider();
setupComponents();
if( owner != null )
{
centerSuper();
}
else
{
center();
}
textText.fill( provider.getNoticias() );
}
private void setupComponents()
{
setTitle( "Editar Texto das Not\u00edcias" );
setSize( 300, 200 );
textText = new HTMLEditorPanel( true );
// textText.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(),
// "Texto" ) );
okButton = new JButton( "OK" );
okButton.addActionListener( this );
cancelButton = new JButton( "Cancelar" );
cancelButton.addActionListener( this );
getContentPane().setLayout( new BorderLayout() );
getContentPane().add( textText, BorderLayout.CENTER );
JPanel buttonPanel = new JPanel();
getContentPane().add( buttonPanel, BorderLayout.SOUTH );
buttonPanel.setLayout( new FlowLayout( FlowLayout.RIGHT ) );
buttonPanel.add( okButton );
buttonPanel.add( cancelButton );
}
public void actionPerformed( ActionEvent e )
{
Object source = e.getSource();
if( source.equals( okButton ) )
{
try
{
provider.saveNoticias( (String) textText.save() );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a gravar not\u00edcias", true );
return;
}
close();
}
else if( source.equals( cancelButton ) )
{
close();
}
}
public void close()
{
SwingUtilities.invokeLater( new Thread(){
public void run()
{
setVisible( false );
dispose();
}
} );
}
}

@ -0,0 +1,153 @@
/*
* PerfilProtocoloPanel.java
*
* Created on January 27, 2006, 12:24 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.clientes;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import com.evolute.utils.data.*;
import com.evolute.utils.dataui.*;
import com.evolute.utils.ui.panel.*;
/**
*
* @author fpalma
*/
public class PerfilProtocoloPanel extends JPanel
implements ControllableComponent, ItemListener
{
protected JCheckBox consultasCheck;
protected JCheckBox examesCheck;
protected CheckBoxPanel tiposCheck[];
protected IDObject grupos[];
protected IDObject tipos[][];
/** Creates a new instance of PerfilProtocoloPanel */
public PerfilProtocoloPanel( IDObject grupos[], IDObject tipos[][] )
{
this.grupos = grupos;
this.tipos = tipos;
setupComponents();
}
private void setupComponents()
{
consultasCheck = new JCheckBox( "Consultas" );
examesCheck = new JCheckBox( "Exames" );
examesCheck.addItemListener( this );
tiposCheck = new CheckBoxPanel[ grupos.length ];
GridBagLayout gridbag = new GridBagLayout();
setLayout( gridbag );
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets( 1, 1, 1, 1 );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weighty = 0;
constraints.weightx = 1;
constraints.gridheight = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( consultasCheck, constraints );
gridbag.setConstraints( examesCheck, constraints );
add( consultasCheck );
add( examesCheck );
constraints.fill = GridBagConstraints.BOTH;
constraints.weighty = grupos.length > 0 ? 1.0 / grupos.length : 0.0;
for( int n = 0; n < grupos.length; n++ )
{
tiposCheck[ n ] = setupComponentsGrupo( n );
gridbag.setConstraints( tiposCheck[ n ], constraints );
add( tiposCheck[ n ] );
tiposCheck[ n ].setEnabled( false );
}
}
private CheckBoxPanel setupComponentsGrupo( int indice )
{
String desc = grupos[ indice ].toString();
CheckBoxPanel panel = new CheckBoxPanel( tipos[ indice ] );
panel.setBorder( BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(), desc ) );
return panel;
}
public void fill( Object data )
{
clear();
if( data != null )
{
Vector list = ( Vector ) data;
boolean consultasExames[] = (boolean[]) list.elementAt( 0 );
Integer tiposEscolhidos[] = ( Integer [] ) list.elementAt( 1 );
consultasCheck.setSelected( consultasExames[ 0 ] );
examesCheck.setSelected( consultasExames[ 1 ] );
for( int n = 0; n < tiposCheck.length; n++ )
{
tiposCheck[ n ].fill( tiposEscolhidos );
}
}
}
public Object save()
{
boolean consultasExames[] = new boolean[ 2 ];
consultasExames[ 0 ] = consultasCheck.isSelected();
consultasExames[ 1 ] = examesCheck.isSelected();
Vector tiposEscolhidos = new Vector();
if( consultasExames[ 1 ] )
{
for( int n = 0; n < tiposCheck.length; n++ )
{
tiposEscolhidos.addAll( Arrays.asList( tiposCheck[ n ].getSelected() ) );
}
}
Vector list = new Vector();
list.add( consultasExames );
list.add( tiposEscolhidos.toArray( new Integer[ tiposEscolhidos.size() ] ) );
return list;
}
public void setEnabled( boolean enable )
{
consultasCheck.setEnabled( enable );
examesCheck.setEnabled( enable );
for( int n = 0; n < tiposCheck.length; n++ )
{
tiposCheck[ n ].setEnabled( enable && examesCheck.isSelected() );
}
}
public void clear()
{
consultasCheck.setSelected( false );
examesCheck.setSelected( false );
for( int n = 0; n < tiposCheck.length; n++ )
{
tiposCheck[ n ].clear();
}
}
public void itemStateChanged( ItemEvent e )
{
Object source = e.getSource();
if( source.equals( examesCheck ) )
{
for( int n = 0; n < tiposCheck.length; n++ )
{
tiposCheck[ n ].setEnabled( examesCheck.isEnabled() && examesCheck.isSelected() );
}
}
}
}

@ -0,0 +1,111 @@
/*
* ProtocoloPanel.java
*
* Created on January 27, 2006, 12:23 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.clientes;
import java.awt.*;
import javax.swing.*;
import java.util.*;
import com.evolute.utils.data.*;
import com.evolute.utils.dataui.*;
/**
*
* @author fpalma
*/
public class ProtocoloPanel extends JPanel
implements ControllableComponent
{
protected ClientesDataProvider provider;
protected IDObject grupos[];
protected IDObject tipos[][];
protected PerfilProtocoloPanel perfisPanels[];
/** Creates a new instance of ProtocoloPanel */
public ProtocoloPanel()
throws Exception
{
provider = ( ClientesDataProvider ) ClientesDataProvider.getProvider();
IDObject gruposReais[] = provider.getAllGruposProtocoloReais();
Vector gruposAux = new Vector( Arrays.asList( gruposReais ) );
gruposAux.add( new MappableObject( new Integer( 0 ), "Outros" ) );
grupos = ( IDObject[] ) gruposAux.toArray( new IDObject[ gruposReais.length + 1 ] );
IDObject gruposFalsos[] = provider.getAllGruposProtocoloFalsos();
Hashtable tiposHash = provider.getAllTiposElementosProtocoloByGrupo();
tipos = new IDObject[ grupos.length ][];
for( int n = 0; n < gruposReais.length; n++ )
{
Vector tiposGrupo = ( Vector ) tiposHash.get( gruposReais[ n ].getID() );
tipos[ n ] = ( IDObject[] ) tiposGrupo.toArray( new IDObject[ tiposGrupo.size() ] );
}
Vector outros = new Vector();
for( int n = 0; n < gruposFalsos.length; n++ )
{
Vector tiposGrupo = ( Vector ) tiposHash.get( gruposFalsos[ n ].getID() );
outros.addAll( tiposGrupo );
}
tipos[ gruposReais.length ] = ( IDObject[] ) outros.toArray( new IDObject[ outros.size() ] );
setupComponents();
}
private void setupComponents()
{
perfisPanels = new PerfilProtocoloPanel[ 2 ];
setLayout( new GridLayout( 1, 2 ) );
perfisPanels[ 0 ] = new PerfilProtocoloPanel( grupos, tipos );
JScrollPane perfilAScp =
new JScrollPane( perfisPanels[ 0 ], JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
perfilAScp.setBorder( BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(), "Perfil A" ) );
add( perfilAScp );
perfisPanels[ 1 ] = new PerfilProtocoloPanel( grupos, tipos );
JScrollPane perfilBScp =
new JScrollPane( perfisPanels[ 1 ], JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
perfilBScp.setBorder( BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(), "Perfil B" ) );
add( perfilBScp );
}
public void fill( Object data )
{
Vector lists[] = ( Vector [] ) data;
perfisPanels[ 0 ].fill( lists[ 0 ] );
perfisPanels[ 1 ].fill( lists[ 1 ] );
}
public Object save()
{
Vector lists[] = new Vector[ 2 ];
lists[ 0 ] = ( Vector ) perfisPanels[ 0 ].save();
lists[ 1 ] = ( Vector ) perfisPanels[ 1 ].save();
return lists;
}
public void setEnabled( boolean enable )
{
perfisPanels[ 0 ].setEnabled( enable );
perfisPanels[ 1 ].setEnabled( enable );
}
public void clear()
{
perfisPanels[ 0 ].clear();
perfisPanels[ 1 ].clear();
}
}

@ -0,0 +1,611 @@
/*
* TrabalhadorPanel.java
*
* Created on 14 de Maio de 2004, 12:29
*/
package siprp.clientes;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import com.evolute.utils.data.*;
import com.evolute.utils.dataui.*;
import com.evolute.utils.date.*;
import com.evolute.utils.metadb.*;
import com.evolute.utils.tables.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.ui.panel.*;
import com.evolute.utils.ui.text.*;
import siprp.*;
import siprp.data.*;
import siprp.importer.*;
/**
*
* @author fpalma
*/
public class TrabalhadorPanel extends JPanel
implements ControllableComponent, ListSelectionListener, ActionListener
{
private FichaDataProvider provider;
private TrabalhadorData trabalhador;
private ComponentsHashtable components;
private EstabelecimentoData estabelecimento;
private JTable estabelecimentosTable;
private JPanel toolbarPanel;
private JPanel dadosTrabalhadorPanel;
private JTextField nomeText;
private RadioButtonFixedPanel sexoPanel;
private JCalendarPanel dataNascimentoPanel;
private JTextField nacionalidadeText;
private JTextField numeroMecanograficoText;
private JCalendarPanel dataAdmissaoPanel;
private JTextField categoriaText;
private JTextField localText;
private JTextField funcaoText;
private JCalendarPanel dataAdmissaoFuncaoPanel;
private JCalendarPanel dataDemissaoPanel;
private JTextField observacoesText;
//private JComboBox perfilCombo;
private RadioButtonFixedPanel perfilPanel;
private SIPRPTracker tracker;
private BaseTable trabalhadoresTable;
private VectorTableModel trabalhadoresModel;
private JButton marcacoesButton;
// private MarcacaoPanel examesPanel;
// private MarcacaoPanel consultaPanel;
private Vector listeners;
private boolean lastEnable = false;
/** Creates a new instance of TrabalhadorPanel */
public TrabalhadorPanel( JPanel toolbarPanel, JTable estabelecimentosTable )
throws Exception
{
this.toolbarPanel = toolbarPanel;
this.estabelecimentosTable = estabelecimentosTable;
provider = ( FichaDataProvider )FichaDataProvider.getProvider();
listeners = new Vector();
setupComponents();
setupComponentsHashtable();
}
private void setupComponents()
{
dadosTrabalhadorPanel = new JPanel();
// JPanel marcacoesPanel = new JPanel();
JLabel nomeLabel = new JLabel( "Nome" );
nomeText = new JTextField();
JLabel sexoLabel = new JLabel( "Sexo" );
sexoPanel =
new RadioButtonFixedPanel(
new IDObject[]{ new MappableObject( new Integer( 1 ), "M" ),
new MappableObject( new Integer( 2 ), "F" ) },
1, 2, RadioButtonPanel.ORIENTATION_HORIZONTAL, false );
JLabel dataNascimentoLabel = new JLabel( "Data de Nascimento" );
dataNascimentoPanel = new JCalendarPanel( null );
JLabel nacionalidadeLabel = new JLabel( "Nacionalidade" );
nacionalidadeText = new JTextField();
JLabel numeroMecanograficoLabel = new JLabel( "N\u00famero Mecanogr\u00e1fico/Outro" );
numeroMecanograficoText = new JTextField();
JLabel dataAdmissaoLabel = new JLabel( "Data de Admiss\u00e3o" );
dataAdmissaoPanel = new JCalendarPanel( null );
JLabel categoriaLabel = new JLabel( "Categoria Profissional" );
categoriaText = new JTextField();
JLabel localLabel = new JLabel( "Local de Trabalho" );
localText = new JTextField();
JLabel funcaoLabel = new JLabel( "Fun\u00e7\u00e3o Proposta" );
funcaoText = new JTextField();
JLabel dataAdmissaoFuncaoLabel = new JLabel( "Data de Admiss\u00e3o na Fun\u00e7\u00e3o" );
dataAdmissaoFuncaoPanel = new JCalendarPanel( null );
JLabel perfilLabel = new JLabel( "Perfil" );
// perfilCombo = new JComboBox();
// perfilCombo.addItem( new MappableObject( new Integer( 1 ), "A" ) );
// perfilCombo.addItem( new MappableObject( new Integer( 2 ), "B" ) );
perfilPanel = new RadioButtonFixedPanel(
new IDObject[]{ new MappableObject( new Integer( 1 ), "A" ),
new MappableObject( new Integer( 2 ), "B" ) },
1, 2, RadioButtonPanel.ORIENTATION_HORIZONTAL, false );
JLabel dataDemissaoLabel = new JLabel( "Data de Demiss\u00e3o" );
dataDemissaoPanel = new JCalendarPanel( null );
JLabel observacoesLabel = new JLabel( "Observa\u00e7\u00f5es" );
observacoesText = new JTextField();
marcacoesButton = new JButton( "Marca\u00e7\u00f5es" );
marcacoesButton.addActionListener( this );
JScrollPane trabalhadoresScroll = new JScrollPane();
trabalhadoresScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
trabalhadoresScroll.setPreferredSize( new Dimension( 250, 300 ) );
trabalhadoresModel = new VectorTableModel( new String[]{ "Trabalhadores" } );
trabalhadoresTable = new BaseTable( trabalhadoresModel );
trabalhadoresTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
trabalhadoresTable.setNonResizableNorReordable();
trabalhadoresScroll.setViewportView( trabalhadoresTable );
JPanel pad;
GridBagLayout gridbag = new GridBagLayout();
dadosTrabalhadorPanel.setLayout( gridbag );
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets( 1, 1, 1, 1 );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weighty = 0;
constraints.gridheight = 1;
constraints.gridwidth = 1;
constraints.weightx = 0;
gridbag.setConstraints( nomeLabel, constraints );
dadosTrabalhadorPanel.add( nomeLabel );
constraints.weightx = 1;
constraints.gridwidth = 3;
gridbag.setConstraints( nomeText, constraints );
dadosTrabalhadorPanel.add( nomeText );
constraints.gridwidth = 1;
constraints.weightx = 0;
gridbag.setConstraints( sexoLabel, constraints );
dadosTrabalhadorPanel.add( sexoLabel );
constraints.weightx = 0;
//constraints.gridwidth = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
JPanel sexoOuterPanel = new JPanel();
sexoOuterPanel.setLayout( new GridLayout( 1, 2 ) );
sexoOuterPanel.add( sexoPanel );
sexoOuterPanel.add( new JPanel() );
gridbag.setConstraints( sexoOuterPanel, constraints );
dadosTrabalhadorPanel.add( sexoOuterPanel );
constraints.weightx = 0;
constraints.gridwidth = 2;
gridbag.setConstraints( nacionalidadeLabel, constraints );
dadosTrabalhadorPanel.add( nacionalidadeLabel );
constraints.weightx = 0.5;
constraints.gridwidth = 1;
gridbag.setConstraints( nacionalidadeText, constraints );
dadosTrabalhadorPanel.add( nacionalidadeText );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( dataNascimentoLabel, constraints );
dadosTrabalhadorPanel.add( dataNascimentoLabel );
constraints.weightx = 0.5;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( dataNascimentoPanel, constraints );
dadosTrabalhadorPanel.add( dataNascimentoPanel );
constraints.weightx = 0;
constraints.gridwidth = 2;
gridbag.setConstraints( numeroMecanograficoLabel, constraints );
dadosTrabalhadorPanel.add( numeroMecanograficoLabel );
constraints.weightx = 0.5;
constraints.gridwidth = 1;
gridbag.setConstraints( numeroMecanograficoText, constraints );
dadosTrabalhadorPanel.add( numeroMecanograficoText );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( dataAdmissaoLabel, constraints );
dadosTrabalhadorPanel.add( dataAdmissaoLabel );
constraints.weightx = 0.5;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( dataAdmissaoPanel, constraints );
dadosTrabalhadorPanel.add( dataAdmissaoPanel );
constraints.weightx = 0;
constraints.gridwidth = 2;
gridbag.setConstraints( categoriaLabel, constraints );
dadosTrabalhadorPanel.add( categoriaLabel );
constraints.weightx = 0.5;
constraints.gridwidth = 1;
gridbag.setConstraints( categoriaText, constraints );
dadosTrabalhadorPanel.add( categoriaText );
constraints.weightx = 0;
gridbag.setConstraints( localLabel, constraints );
dadosTrabalhadorPanel.add( localLabel );
constraints.weightx = 0.5;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( localText, constraints );
dadosTrabalhadorPanel.add( localText );
constraints.weightx = 0;
constraints.gridwidth = 2;
gridbag.setConstraints( funcaoLabel, constraints );
dadosTrabalhadorPanel.add( funcaoLabel );
constraints.weightx = 0.5;
constraints.gridwidth = 1;
gridbag.setConstraints( funcaoText, constraints );
dadosTrabalhadorPanel.add( funcaoText );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( dataAdmissaoFuncaoLabel, constraints );
dadosTrabalhadorPanel.add( dataAdmissaoFuncaoLabel );
constraints.weightx = 0.5;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( dataAdmissaoFuncaoPanel, constraints );
dadosTrabalhadorPanel.add( dataAdmissaoFuncaoPanel );
constraints.weightx = 0;
constraints.gridwidth = 2;
gridbag.setConstraints( perfilLabel, constraints );
dadosTrabalhadorPanel.add( perfilLabel );
constraints.weightx = 0.5;
constraints.gridwidth = 1;
// gridbag.setConstraints( perfilCombo, constraints );
// dadosTrabalhadorPanel.add( perfilCombo );
gridbag.setConstraints( perfilPanel, constraints );
dadosTrabalhadorPanel.add( perfilPanel );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( dataDemissaoLabel, constraints );
dadosTrabalhadorPanel.add( dataDemissaoLabel );
constraints.weightx = 0.5;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( dataDemissaoPanel, constraints );
dadosTrabalhadorPanel.add( dataDemissaoPanel );
constraints.weightx = 0;
constraints.gridwidth = 1;
gridbag.setConstraints( observacoesLabel, constraints );
dadosTrabalhadorPanel.add( observacoesLabel );
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( observacoesText, constraints );
dadosTrabalhadorPanel.add( observacoesText );
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( marcacoesButton, constraints );
dadosTrabalhadorPanel.add( marcacoesButton );
// examesPanel = new MarcacaoPanel( false, "Realizados", "", Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES );
// examesPanel.setCalendarDialogOrientation( JCalendarDialog.ABOVE, JCalendarDialog.RIGHT );
// examesPanel.setBorder( BorderFactory.createTitledBorder(
// BorderFactory.createEtchedBorder(),
// "Exames" ) );
// consultaPanel = new MarcacaoPanel( true, "Realizada", "Ficha de Aptid\u00e3o", Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA );
// consultaPanel.setCalendarDialogOrientation( JCalendarDialog.ABOVE, JCalendarDialog.LEFT );
// consultaPanel.setBorder( BorderFactory.createTitledBorder(
// BorderFactory.createEtchedBorder(),
// "Consulta" ) );
// //marcacoesPanel.setLayout( new BoxLayout( marcacoesPanel, BoxLayout.X_AXIS ) );
// marcacoesPanel.setLayout( new GridLayout( 1, 2 ) );
// marcacoesPanel.add( examesPanel );
// marcacoesPanel.add( consultaPanel );
JPanel leftPanel = new JPanel();
leftPanel.setLayout( new BorderLayout() );
leftPanel.add( toolbarPanel, BorderLayout.NORTH );
leftPanel.add( trabalhadoresScroll, BorderLayout.CENTER );
setLayout( new BorderLayout() );
add( leftPanel, BorderLayout.WEST );
add( dadosTrabalhadorPanel, BorderLayout.CENTER );
// add( marcacoesPanel, BorderLayout.SOUTH );
trabalhadoresTable.getSelectionModel().addListSelectionListener( this );
new CopyPasteHandler( nomeText );
new CopyPasteHandler( nacionalidadeText );
new CopyPasteHandler( numeroMecanograficoText );
new CopyPasteHandler( categoriaText );
new CopyPasteHandler( localText );
new CopyPasteHandler( funcaoText );
new CopyPasteHandler( observacoesText );
}
private void setupComponentsHashtable()
{
components = new ComponentsHashtable();
components.putComponent( TrabalhadorData.NOME, nomeText );
components.putComponent( TrabalhadorData.SEXO, new ControllableComponent()
{
public void fill( Object value )
{
if( value != null && value.equals( "f" ) )
{
sexoPanel.fill( new Integer(2) );
}
else
{
sexoPanel.fill( new Integer(1) );
}
}
public Object save()
{
Integer id = (Integer)sexoPanel.save();
if( id != null && id.intValue() == 1 )
{
return "m";
}
return "f";
}
public void clear()
{
sexoPanel.clear();
}
public void setEnabled( boolean enable )
{
sexoPanel.setEnabled( enable );
}
} );
components.putComponent( TrabalhadorData.DATA_NASCIMENTO, dataNascimentoPanel );
components.putComponent( TrabalhadorData.NACIONALIDADE, nacionalidadeText );
components.putComponent( TrabalhadorData.NUMERO_MECANOGRAFICO, numeroMecanograficoText );
components.putComponent( TrabalhadorData.DATA_ADMISSAO, dataAdmissaoPanel );
components.putComponent( TrabalhadorData.CATEGORIA, categoriaText );
components.putComponent( TrabalhadorData.LOCAL_TRABALHO, localText );
components.putComponent( TrabalhadorData.FUNCAO_PROPOSTA, funcaoText );
components.putComponent( TrabalhadorData.DATA_ADMISSAO_FUNCAO, dataAdmissaoFuncaoPanel );
components.putComponent( TrabalhadorData.DATA_DEMISSAO, dataDemissaoPanel );
components.putDummy( TrabalhadorData.OBSERVACOES );
components.putComponent( TrabalhadorData.OBSERVACOES_GESTAO, observacoesText );
components.putComponent( TrabalhadorData.PERFIL, perfilPanel );
// components.putDummy( TrabalhadorData.INACTIVO );
components.putDummy( TrabalhadorData.ESTABELECIMENTO );
components.putDummy( TrabalhadorData.NOME_PLAIN );
}
public void clear()
{
String names[] = (String[])components.keySet().toArray( new String[0] );
ComponentController.clear( names, components );
trabalhador = null;
}
public void fill(Object value)
{
clear();
trabalhador = ( TrabalhadorData ) value;
// examesPanel.setEnabled( trabalhador != null );
// examesPanel.fill( trabalhador );
// consultaPanel.setEnabled( trabalhador != null );
// consultaPanel.fill( trabalhador );
if( trabalhador == null )
{
trabalhadoresTable.clearSelection();
return;
}
String names[] = trabalhador.getFieldNames();
ComponentController.fill( names, trabalhador.getHashData(), components );
}
public Object save()
{
if( trabalhador == null )
{
trabalhador = new TrabalhadorData();
}
String names[] = trabalhador.getFieldNames();
Hashtable hash = new Hashtable();
ComponentController.save( names, hash, components );
trabalhador.setHashData( hash );
trabalhador.set( TrabalhadorData.ESTABELECIMENTO, estabelecimento );
return trabalhador;
}
public void setEnabled( boolean enable )
{
super.setEnabled( enable );
String names[] = (String[])components.keySet().toArray( new String[0] );
ComponentController.setEnabled( names, enable, components );
trabalhadoresTable.setEnabled( !enable );
if( lastEnable != enable )
{
if( enable )
{
EstabelecimentoPanel.disables++;
}
else
{
EstabelecimentoPanel.disables--;
}
lastEnable = enable;
}
estabelecimentosTable.setEnabled( EstabelecimentoPanel.disables == 0 );
// if( trabalhador == null )
// {
// examesPanel.setEnabled( false );
// consultaPanel.setEnabled( false );
// }
}
public void reloaList()
throws Exception
{
if( estabelecimento == null )
{
trabalhadoresModel.clearAll();
}
else
{
Integer id = ( Integer )estabelecimento.get( EstabelecimentoData.ID );
IDObject []trabalhadores = provider.getAllTrabalhadoresForEstabelecimento( id );
trabalhadoresModel.setValues( new Vector( Arrays.asList( trabalhadores ) ) );
}
}
public void valueChanged( ListSelectionEvent e )
{
Object source = e.getSource();
if( source instanceof EmpresaPanel )
{
Integer id = ( ( EmpresaPanel ) source ).getSelectedEstabelecimento();
if( id != null )
{
try
{
IDObject []trabalhadores = provider.getAllTrabalhadoresForEstabelecimento( id );
trabalhadoresModel.setValues( new Vector( Arrays.asList( trabalhadores ) ) );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar os trabalhadores", true );
clear();
}
}
else
{
trabalhadoresModel.clearAll();
clear();
}
}
else if( source.equals( trabalhadoresTable.getSelectionModel() ) )
{
// int selected = trabalhadoresTable.getSelectedRow();
// if( selected == -1 )
// {
// clear();
//
// }
// else
// {
// Integer id = ( ( IDObject ) trabalhadoresModel.getRowAt( selected ) ).getID();;
// try
// {
// TrabalhadorData trabalhador = (TrabalhadorData) TrabalhadorData.load( TrabalhadorData.class, id );
// fill( trabalhador );
// }
// catch( Exception ex )
// {
// DialogException.showExceptionMessage( ex, "Erro a carregar o trabalhador", true );
// clear();
// }
for( int n = 0; n < listeners.size(); n++ )
{
ListSelectionEvent newEvent =
new ListSelectionEvent( this, e.getFirstIndex(), e.getLastIndex(), e.getValueIsAdjusting() );
( (ListSelectionListener) listeners.elementAt( n ) ).valueChanged( newEvent );
}
// }
}
}
public void postSave()
{
int selected = trabalhadoresTable.getSelectedRow();
//System.out.println( "postSave TRABALHADOR PANEL " + selected + " : " + ( trabalhador == null ) );
if( trabalhador != null )
{
IDObject obj = new MappableObject( (Integer) trabalhador.get( TrabalhadorData.ID ), trabalhador.get( TrabalhadorData.NOME ) );
if( selected == -1 )
{
trabalhadoresModel.insertRowAt( obj, trabalhadoresTable.getRowCount() );
trabalhadoresTable.setRowSelectionInterval( trabalhadoresTable.getRowCount() - 1, trabalhadoresTable.getRowCount() - 1 );
}
else
{
trabalhadoresModel.removeRowAt( selected );
trabalhadoresModel.insertRowAt( obj, selected );
trabalhadoresTable.setRowSelectionInterval( selected, selected );
}
}
}
public void reload()
{
fill( trabalhador );
}
public void addListSelectionListener( ListSelectionListener listener )
{
listeners.add( listener );
}
public void removeListSelectionListener( ListSelectionListener listener )
{
listeners.remove( listener );
}
public Integer getSelectedTrabalhador()
{
int selected = trabalhadoresTable.getSelectedRow();
if( selected == -1 )
{
return null;
}
return ( (IDObject) trabalhadoresModel.getRowAt( selected ) ).getID();
}
public void setEstabelecimento( EstabelecimentoData estabelecimento )
{
this.estabelecimento = estabelecimento;
}
public void setSelectedTrabalhador( TrabalhadorData trab )
{
IDObject lista[] = (IDObject [])trabalhadoresModel.getValues().toArray( new IDObject[ 0 ] );
Integer id = (Integer)trab.get( TrabalhadorData.ID );
for( int n = 0; n < lista.length; n++ )
{
if( lista[ n ].getID().equals( id ) )
{
trabalhadoresTable.setRowSelectionInterval( n, n );
return;
}
}
trabalhadoresTable.clearSelection();
}
public void actionPerformed( ActionEvent e )
{
Object source = e.getSource();
if( source.equals( marcacoesButton ) )
{
if( trabalhador == null )
{
return;
}
else
{
EstabelecimentoData estabelecimento = ( EstabelecimentoData ) trabalhador.get( TrabalhadorData.ESTABELECIMENTO );
EmpresaData empresa = ( EmpresaData ) estabelecimento.get( EstabelecimentoData.EMPRESA );
tracker.getMedicinaWindow().setVisible( true );
tracker.getMedicinaWindow().setEmpresaAndEstabelecimentoAndTrabalhador( (Integer) empresa.get( EmpresaData.ID ),
( Integer ) estabelecimento.get( EstabelecimentoData.ID ),
( Integer ) trabalhador.get( TrabalhadorData.ID ) );
}
}
}
public void setTracker( SIPRPTracker tracker )
{
this.tracker = tracker;
}
}

@ -0,0 +1,156 @@
/*
* UserDataProvider.java
*
* Created on 8 de Novembro de 2004, 18:38
*/
package siprp.clientes;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.arrays.*;
import com.evolute.utils.data.*;
import com.evolute.utils.db.*;
import com.evolute.utils.metadb.*;
import com.evolute.utils.ui.search.*;
import com.evolute.utils.sql.*;
import siprp.*;
/**
*
* @author fpalma
*/
public class UserDataProvider extends MetaProvider
{
private static final String RESERVED_ROLES_MANAGER = "manager";
private static final String RESERVED_ROLES_ADMIN = "admin";
private static final Object LOCK = new Object();
private static UserDataProvider instance = null;
private final Executer executer;
protected final Expression excludeReserved;
/** Creates a new instance of UserDataProvider */
public UserDataProvider()
throws Exception
{
boolean webAware = ( ( Boolean ) Singleton.getInstance( SingletonConstants.WEB_AWARE ) ).booleanValue();
DBManager dbm;
if( webAware )
{
String url = ( String ) Singleton.getInstance( SingletonConstants.WEB_URL_PREFIX );
url += ( String ) Singleton.getInstance( SingletonConstants.WEB_URL ) + "/";
url += ( String ) Singleton.getInstance( SingletonConstants.WEB_DB_NAME ) + "/";
String user = ( String ) Singleton.getInstance( SingletonConstants.WEB_USER );
String pwd = ( String ) Singleton.getInstance( SingletonConstants.WEB_PASSWORD );
dbm = new JDBCManager( url, user, pwd, 10, 8, 8, null );
executer = dbm.getSharedExecuter( this );
}
else
{
dbm = null;
executer = null;
}
excludeReserved = new Field( "role" ).isDifferent( RESERVED_ROLES_MANAGER ).and(
new Field( "role" ).isDifferent( RESERVED_ROLES_ADMIN ) );
}
public static MetaProvider getProvider()
throws Exception
{
synchronized( LOCK )
{
if( instance == null )
{
instance = new UserDataProvider();
}
}
return instance;
}
public String getUserName( Integer empresaID )
throws Exception
{
System.out.println( "getUserName( " +empresaID+ " )" ) ;
Select select = new Select( new String[]{ "roles" }, new String[]{ "username" },
new Field( "role" ).isEqual( empresaID == null ? "siprpuser" : empresaID.toString() ) );
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() == 0 )
{
return null;
}
return array.get( 0, 0 ).toString();
}
public void saveUser( String userName, String password, Integer empresaID, boolean isNew )
throws Exception
{
if( isNew )
{
Insert insert =
new Insert( "roles",
new Assignment[]{ new Assignment( new Field( "username" ), userName ),
new Assignment( new Field( "role" ), empresaID == null ? "siprpuser" : empresaID.toString() ) } );
executer.executeQuery( insert, null );
insert =
new Insert( "users",
new Assignment[]{ new Assignment( new Field( "username" ), userName ),
new Assignment( new Field( "password" ), password ) } );
executer.executeQuery( insert, null );
}
else
{
Select select = new Select( new String[]{ "roles" }, new String[]{ "username" },
new Field( "role" ).isEqual( empresaID == null ? "siprpuser" : empresaID.toString() ) );
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() == 0 )
{
saveUser( userName, password, empresaID, true );
return;
}
String oldName = array.get( 0, 0 ).toString();
Update update =
new Update( "roles",
new Assignment[]{ new Assignment( new Field( "username" ), userName ),
new Assignment( new Field( "role" ), empresaID == null ? "siprpuser" : empresaID.toString() ) },
new Field( "username" ).isEqual( oldName ).and( excludeReserved ) );
executer.executeQuery( update );
update =
new Update( "users",
new Assignment[]{ new Assignment( new Field( "username" ), userName ),
new Assignment( new Field( "password" ), password ) },
new Field( "username" ).isEqual( oldName ) );
executer.executeQuery( update );
}
}
public boolean checkNewName( String name, Integer empresaID )
throws Exception
{
Select select = new Select( new String[]{ "roles" }, new String[]{ "username" },
new Field( "role" ).isDifferent( empresaID == null ? "siprpuser" : empresaID.toString() ).and(
new Field( "lower( username )" ).isEqual( new Field( "lower( '" + name + "' )" ) ) ) );
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() != 0 )
{
if( empresaID != null )
{
return false;
}
else
{
select = new Select( new String[]{ "roles" }, new String[]{ "username" },
new Field( "role" ).isEqual( empresaID == null ? "siprpuser" : empresaID.toString() ).and(
new Field( "lower( username )" ).isEqual( new Field( "lower( '" + name + "' )" ) ) ) );
array = executer.executeQuery( select );
if( array.columnLength() == 0 )
{
return false;
}
}
}
return true;
}
}

@ -0,0 +1,232 @@
/*
* UserPanel.java
*
* Created on 8 de Novembro de 2004, 17:03
*/
package siprp.clientes;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.ui.text.*;
/**
*
* @author fpalma
*/
public class UserPanel extends JPanel
implements DocumentListener, FocusListener, ActionListener
{
private UserDataProvider provider;
private JTextField userNameText;
private JTextField passwordText;
private JButton applyButton;
private JButton cancelButton;
private boolean passwordEdited = false;
private boolean hasPassword = false;
private boolean error = false;
private Integer empresaID;
// public static void main( String args[] )
// {
// JFrame frame = new JFrame();
// frame.setSize( 300, 200 );
// frame.getContentPane().setLayout( new GridLayout( 1, 1 ) );
// frame.getContentPane().add( new UserPanel() );
// frame.show();
// }
/** Creates a new instance of UserPanel */
public UserPanel()
throws Exception
{
provider = ( UserDataProvider ) UserDataProvider.getProvider();
setupComponents();
}
private void setupComponents()
{
JLabel userNameLabel = new JLabel( "Utilizador" );
userNameText = new JTextField();
JLabel passwordLabel = new JLabel( "Senha" );
passwordText = new JTextField();
applyButton = new JButton( "Actualizar" );
cancelButton = new JButton( "Cancelar" );
userNameText.setPreferredSize( new Dimension( 200, 20 ) );
passwordText.setPreferredSize( new Dimension( 200, 20 ) );
passwordText.setText( "<N\u00e3o Definida>" );
GridBagLayout gridbag = new GridBagLayout();
setLayout( gridbag );
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets( 1, 1, 1, 1 );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weighty = 0;
constraints.gridheight = 1;
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( userNameLabel, constraints );
gridbag.setConstraints( passwordLabel, constraints );
gridbag.setConstraints( userNameText, constraints );
gridbag.setConstraints( passwordText, constraints );
JPanel buttonPanel = new JPanel();
gridbag.setConstraints( buttonPanel, constraints );
add( userNameLabel );
add( userNameText );
add( passwordLabel );
add( passwordText );
add( buttonPanel );
buttonPanel.setLayout( new FlowLayout( FlowLayout.RIGHT ) );
buttonPanel.add( applyButton );
buttonPanel.add( cancelButton );
passwordText.addFocusListener( this );
passwordText.getDocument().addDocumentListener( this );
applyButton.addActionListener( this );
cancelButton.addActionListener( this );
new CopyPasteHandler( userNameText );
new CopyPasteHandler( passwordText );
}
public void changedUpdate(javax.swing.event.DocumentEvent documentEvent)
{
passwordEdited = true;
}
public void insertUpdate(javax.swing.event.DocumentEvent documentEvent)
{
passwordEdited = true;
}
public void removeUpdate(javax.swing.event.DocumentEvent documentEvent)
{
passwordEdited = true;
}
public void focusGained(java.awt.event.FocusEvent focusEvent)
{
if( !passwordEdited )
{
passwordText.getDocument().removeDocumentListener( this );
passwordText.setText( "" );
passwordText.getDocument().addDocumentListener( this );
}
}
public void focusLost(java.awt.event.FocusEvent focusEvent)
{
}
public void actionPerformed(java.awt.event.ActionEvent actionEvent)
{
try
{
Object source = actionEvent.getSource();
if( applyButton.equals( source ) )
{
if( save() )
{
hasPassword = true;
}
refresh();
}
else if( cancelButton.equals( source ) )
{
reload();
refresh();
}
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro na liga\u00e7\u00e3o \u00e0 Base de Dados WEB", true );
}
}
private void refresh()
{
passwordText.getDocument().removeDocumentListener( this );
if( !passwordEdited )
{
if( hasPassword )
{
passwordText.setText( "<Definida>" );
}
else
{
passwordText.setText( "<N\u00e3o Definida>" );
}
}
passwordText.getDocument().addDocumentListener( this );
}
public void setEmpresaID( Integer empresaID )
{
try
{
userNameText.setText( "" );
passwordText.setText( "" );
passwordEdited = false;
hasPassword = false;
this.empresaID = empresaID;
// if( empresaID == null )
// {
// return;
// }
reload();
refresh();
error = false;
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro na liga\u00e7\u00e3o \u00e0 Base de Dados WEB", true );
userNameText.setText( "Erro na liga\u00e7\u00e3o" );
setEnabled( false );
error = true;
}
}
private boolean save()
throws Exception
{
if( !provider.checkNewName( userNameText.getText(), empresaID ) )
{
JOptionPane.showMessageDialog( null, "O Utilizador " + userNameText.getText() + " j\u00e1 est\u00e1 em uso por outra entidade." );
return false;
}
provider.saveUser( userNameText.getText(), passwordText.getText(), empresaID, !hasPassword );
passwordEdited = false;
return true;
}
private boolean reload()
throws Exception
{
String userName = provider.getUserName( empresaID );
if( userName != null )
{
userNameText.setText( userName );
hasPassword = true;
}
passwordEdited = false;
return true;
}
public void setEnabled( boolean enable )
{
userNameText.setEnabled( enable && !error );
passwordText.setEnabled( enable && !error );
applyButton.setEnabled( enable && !error );
cancelButton.setEnabled( enable && !error );
}
}

@ -0,0 +1,66 @@
/*
* UserWindow.java
*
* Created on 15 de Março de 2005, 11:35
*/
package siprp.clientes;
import java.awt.*;
import javax.swing.*;
import com.evolute.utils.*;
import com.evolute.utils.jdo.*;
import com.evolute.utils.ui.*;
import siprp.data.*;
/**
*
* @author fpalma
*/
public class UserWindow extends CustomJDialog
{
protected JDOProvider JDO;
// protected JTextField empresaText;
protected UserPanel userPanel;
protected Integer empresaID;
/** Creates a new instance of UserWindow */
public UserWindow( JFrame owner, Integer empresaID )
throws Exception
{
super( owner, true );
this.empresaID = empresaID;
JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
setupComponents();
centerSuper();
}
private void setupComponents()
throws Exception
{
setSize( 500, 200 );
userPanel = new UserPanel();
// empresaText = new JTextField();
getContentPane().setLayout( new BorderLayout() );
// getContentPane().add( empresaText, BorderLayout.NORTH );
getContentPane().add( userPanel, BorderLayout.CENTER );
if( empresaID == null )
{
// empresaText.setText( "SIPRP" );
setTitle( "SIPRP" );
}
else
{
EmpresaData empresa = ( EmpresaData )JDO.load( EmpresaData.class, empresaID );
if( empresa == null )
{
return;
}
// empresaText.setText( (String)empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) );
setTitle( (String)empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) );
}
userPanel.setEmpresaID( empresaID );
}
}

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>
<xsl:template match="GUIA">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="simpleA4"
page-height="29.7cm"
page-width="21cm"
margin-top="2cm"
margin-bottom="2cm"
margin-left="2cm"
margin-right="2cm">
<fo:region-body />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simpleA4">
<fo:flow flow-name="xsl-region-body">
<fo:table table-layout="fixed" width="100%" space-before.optimum="0pt" space-after.optimum="0pt">
<fo:table-column column-width="10cm"/>
<fo:table-column/>
<fo:table-column/>
<fo:table-column/>
<fo:table-column/>
<fo:table-header>
<fo:table-row>
<fo:table-cell border="0.7pt solid #000000">
<fo:block font-size="10pt" text-align="center" font-weight="bold">
Cuidado Prestado
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.7pt solid #000000">
<fo:block font-size="10pt" text-align="center" font-weight="bold">
C&#xf3;digo
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.7pt solid #000000">
<fo:block font-size="10pt" text-align="center" font-weight="bold">
Valor
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.7pt solid #000000">
<fo:block font-size="10pt" text-align="center" font-weight="bold">
Benef.
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.7pt solid #000000">
<fo:block font-size="10pt" text-align="center" font-weight="bold">
Entidade
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<xsl:for-each select="CORPO/LINHA_CORPO">
<fo:table-row>
<fo:table-cell border="0.7pt solid #000000">
<fo:block font-size="10pt" text-align="left">
<xsl:value-of select="PRODUTO/DESCRICAO" />
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.7pt solid #000000">
<fo:block font-size="10pt" text-align="right">
<xsl:value-of select="PRODUTO/CODIGO_TABELA" />
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.7pt solid #000000">
<fo:block font-size="10pt" text-align="right">
<xsl:value-of select="PRECO/PRECO_TOTAL" />
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.7pt solid #000000">
<fo:block font-size="10pt" text-align="right">
<xsl:value-of select="PRECO/PRECO_BENEFICIARIO" />
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.7pt solid #000000">
<fo:block font-size="10pt" text-align="right">
<xsl:value-of select="PRECO/PRECO_ENTIDADE" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!ELEMENT LISTA_MENSAL (CABECALHO,CORPO,RODAPE)>
<!ELEMENT CABECALHO (MES,ANO,DATA)>
<!ELEMENT DATA (DIA,MES,ANO)>
<!ELEMENT DIA (#PCDATA)>
<!ELEMENT MES (#PCDATA)>
<!ELEMENT ANO (#PCDATA)>
<!ELEMENT CORPO (GUIA*)>
<!ELEMENT GUIA (#PCDATA)>
<!ELEMENT RODAPE (TOTAL_C?,TOTAL_C_E?,TOTAL_K?,TOTAL_K_E?,TOTAL_E?,NUMERO_GUIAS?)>
<!ELEMENT TOTAL_C (#PCDATA)>
<!ELEMENT TOTAL_C_E (#PCDATA)>
<!ELEMENT TOTAL_K (#PCDATA)>
<!ELEMENT TOTAL_K_E (#PCDATA)>
<!ELEMENT TOTAL_E (#PCDATA)>
<!ELEMENT NUMERO_GUIAS (#PCDATA)>

@ -0,0 +1,51 @@
/*
* StampSaveHandler.java
*
* Created on 15 de Março de 2005, 15:00
*/
package siprp.data;
import java.util.*;
import com.evolute.utils.jdo.*;
/**
*
* @author fpalma
*/
public class ActualizacaoSaveHandler implements JDOOperationHandlerInterface
{
public static final ActualizacaoSaveHandler INSTANCE = new ActualizacaoSaveHandler();
/** Creates a new instance of StampSaveHandler */
public ActualizacaoSaveHandler()
{
}
public boolean handle(JDOObject object, int operation, int moment) throws Exception
{
if( !( object instanceof ActualizacaoSaveable ) )
{
return false;
}
switch( operation )
{
case OP_SAVE:
return save( object, moment );
case OP_DELETE:
return false;
}
return false;
}
protected boolean save( JDOObject object, int moment )
{
if( moment != MOMENT_BEFORE )
{
return false;
}
object.set( ActualizacaoSaveable.ACTUALIZACAO, new Date() );
return true;
}
}

@ -0,0 +1,16 @@
/*
* ActualizacaoSaveable.java
*
* Created on 15 de Março de 2005, 15:32
*/
package siprp.data;
/**
*
* @author fpalma
*/
public interface ActualizacaoSaveable
{
public static final String ACTUALIZACAO = "actualizacao";
}

@ -0,0 +1,186 @@
/*
* Aviso.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on 13/Out/2004
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.Date;
import com.evolute.utils.jdo.*;
public final class Aviso implements JDOInnerObject
{
private Integer id;
private Integer tipo;
private Empresa empresa;
private Estabelecimento estabelecimento;
private Trabalhador trabalhador;
private Integer evento_id;
private Date data_aviso;
private Date data_evento;
private String descricao;
public Aviso()
{
}
public Object getField( String fieldName )
{
if( fieldName == AvisoData.ID )
{
return id;
}
else if( fieldName == AvisoData.TIPO )
{
return tipo;
}
else if( fieldName == AvisoData.EMPRESA )
{
return empresa;
}
else if( fieldName == AvisoData.ESTABELECIMENTO )
{
return estabelecimento;
}
else if( fieldName == AvisoData.TRABALHADOR )
{
return trabalhador;
}
else if( fieldName == AvisoData.EVENTO_ID )
{
return evento_id;
}
else if( fieldName == AvisoData.DATA_AVISO )
{
return data_aviso;
}
else if( fieldName == AvisoData.DATA_EVENTO )
{
return data_evento;
}
else if( fieldName == AvisoData.DESCRICAO )
{
return descricao;
}
else if( fieldName.equals( AvisoData.ID ) )
{
return id;
}
else if( fieldName.equals( AvisoData.TIPO ) )
{
return tipo;
}
else if( fieldName.equals( AvisoData.EMPRESA ) )
{
return empresa;
}
else if( fieldName.equals( AvisoData.ESTABELECIMENTO ) )
{
return estabelecimento;
}
else if( fieldName.equals( AvisoData.TRABALHADOR ) )
{
return trabalhador;
}
else if( fieldName.equals( AvisoData.EVENTO_ID ) )
{
return evento_id;
}
else if( fieldName.equals( AvisoData.DATA_AVISO ) )
{
return data_aviso;
}
else if( fieldName.equals( AvisoData.DATA_EVENTO ) )
{
return data_evento;
}
else if( fieldName.equals( AvisoData.DESCRICAO ) )
{
return descricao;
}
return null;
}
public void setField( String fieldName, Object value )
{
if( fieldName == AvisoData.ID )
{
id = ( Integer ) value;
}
else if( fieldName == AvisoData.TIPO )
{
tipo = ( Integer ) value;
}
else if( fieldName == AvisoData.EMPRESA )
{
empresa = ( Empresa ) value;
}
else if( fieldName == AvisoData.ESTABELECIMENTO )
{
estabelecimento = ( Estabelecimento ) value;
}
else if( fieldName == AvisoData.TRABALHADOR )
{
trabalhador = ( Trabalhador ) value;
}
else if( fieldName == AvisoData.EVENTO_ID )
{
evento_id = ( Integer ) value;
}
else if( fieldName == AvisoData.DATA_AVISO )
{
data_aviso = ( Date ) value;
}
else if( fieldName == AvisoData.DATA_EVENTO )
{
data_evento = ( Date ) value;
}
else if( fieldName == AvisoData.DESCRICAO )
{
descricao = ( String ) value;
}
else if( fieldName.equals( AvisoData.ID ) )
{
id = ( Integer ) value;
}
else if( fieldName.equals( AvisoData.TIPO ) )
{
tipo = ( Integer ) value;
}
else if( fieldName.equals( AvisoData.EMPRESA ) )
{
empresa = ( Empresa ) value;
}
else if( fieldName.equals( AvisoData.ESTABELECIMENTO ) )
{
estabelecimento = ( Estabelecimento ) value;
}
else if( fieldName.equals( AvisoData.TRABALHADOR ) )
{
trabalhador = ( Trabalhador ) value;
}
else if( fieldName.equals( AvisoData.EVENTO_ID ) )
{
evento_id = ( Integer ) value;
}
else if( fieldName.equals( AvisoData.DATA_AVISO ) )
{
data_aviso = ( Date ) value;
}
else if( fieldName.equals( AvisoData.DATA_EVENTO ) )
{
data_evento = ( Date ) value;
}
else if( fieldName.equals( AvisoData.DESCRICAO ) )
{
descricao = ( String ) value;
}
}
public Class getOuterClass()
{
return AvisoData.class;
}
}

@ -0,0 +1,18 @@
/*
* AvisoConstants.java
*
* Created on 11 de Outubro de 2004, 13:03
*/
package siprp.data;
/**
*
* @author fpalma
*/
public interface AvisoConstants
{
public static final int TIPO_TRABALHADOR = 0;
public static final int TIPO_ESTABELECIMENTO = 1;
public static final int TIPO_EMPRESA = 2;
}

@ -0,0 +1,68 @@
/*
* AvisoData.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on 13/Out/2004
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.HashMap;
import com.evolute.utils.jdo.*;
public final class AvisoData extends JDOObject
implements AvisoConstants
{
public static final String ID = "id";
public static final String TIPO = "tipo";
public static final String EMPRESA = "empresa";
public static final String ESTABELECIMENTO = "estabelecimento";
public static final String TRABALHADOR = "trabalhador";
public static final String EVENTO_ID = "evento_id";
public static final String DATA_AVISO = "data_aviso";
public static final String DATA_EVENTO = "data_evento";
public static final String DESCRICAO = "descricao";
public static final String FIELD_NAMES[] = new String[]{
TIPO, EMPRESA, ESTABELECIMENTO, TRABALHADOR, EVENTO_ID, DATA_AVISO, DATA_EVENTO,
DESCRICAO, };
protected static final String ALL_FIELD_NAMES[] = new String[]{
ID, TIPO, EMPRESA, ESTABELECIMENTO, TRABALHADOR, EVENTO_ID, DATA_AVISO, DATA_EVENTO,
DESCRICAO, };
private HashMap dataHash;
public AvisoData()
{
dataHash = new HashMap();
}
protected Object innerGet( String fieldName )
throws Exception
{
return dataHash.get( fieldName );
}
protected void innerSet( String fieldName, Object value )
throws Exception
{
dataHash.put( fieldName, value );
}
public String []getFieldNames()
{
return FIELD_NAMES;
}
protected String []getAllFieldNames()
{
return ALL_FIELD_NAMES;
}
public Class getInnerClass()
{
return Aviso.class;
}
}

@ -0,0 +1,22 @@
/*
* AvisoID.java
*
* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 13/Out/2004
*
* Use but DON'T TOUCH
*/
package siprp.data;
import com.evolute.utils.jdo.jpox.*;
public final class AvisoID extends IntegerID
{
public AvisoID()
{
}
public AvisoID( String str )
{
super( str );
}
}

@ -0,0 +1,152 @@
/*
* Contacto.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on 13/Out/2004
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.Date;
import com.evolute.utils.jdo.*;
public final class Contacto implements JDOInnerObject
{
private Integer id;
private String nome;
private String cargo;
private String telefone;
private String telemovel;
private String fax;
private String email;
public Contacto()
{
}
public Object getField( String fieldName )
{
if( fieldName == ContactoData.ID )
{
return id;
}
else if( fieldName == ContactoData.NOME )
{
return nome;
}
else if( fieldName == ContactoData.CARGO )
{
return cargo;
}
else if( fieldName == ContactoData.TELEFONE )
{
return telefone;
}
else if( fieldName == ContactoData.TELEMOVEL )
{
return telemovel;
}
else if( fieldName == ContactoData.FAX )
{
return fax;
}
else if( fieldName == ContactoData.EMAIL )
{
return email;
}
else if( fieldName.equals( ContactoData.ID ) )
{
return id;
}
else if( fieldName.equals( ContactoData.NOME ) )
{
return nome;
}
else if( fieldName.equals( ContactoData.CARGO ) )
{
return cargo;
}
else if( fieldName.equals( ContactoData.TELEFONE ) )
{
return telefone;
}
else if( fieldName.equals( ContactoData.TELEMOVEL ) )
{
return telemovel;
}
else if( fieldName.equals( ContactoData.FAX ) )
{
return fax;
}
else if( fieldName.equals( ContactoData.EMAIL ) )
{
return email;
}
return null;
}
public void setField( String fieldName, Object value )
{
if( fieldName == ContactoData.ID )
{
id = ( Integer ) value;
}
else if( fieldName == ContactoData.NOME )
{
nome = ( String ) value;
}
else if( fieldName == ContactoData.CARGO )
{
cargo = ( String ) value;
}
else if( fieldName == ContactoData.TELEFONE )
{
telefone = ( String ) value;
}
else if( fieldName == ContactoData.TELEMOVEL )
{
telemovel = ( String ) value;
}
else if( fieldName == ContactoData.FAX )
{
fax = ( String ) value;
}
else if( fieldName == ContactoData.EMAIL )
{
email = ( String ) value;
}
else if( fieldName.equals( ContactoData.ID ) )
{
id = ( Integer ) value;
}
else if( fieldName.equals( ContactoData.NOME ) )
{
nome = ( String ) value;
}
else if( fieldName.equals( ContactoData.CARGO ) )
{
cargo = ( String ) value;
}
else if( fieldName.equals( ContactoData.TELEFONE ) )
{
telefone = ( String ) value;
}
else if( fieldName.equals( ContactoData.TELEMOVEL ) )
{
telemovel = ( String ) value;
}
else if( fieldName.equals( ContactoData.FAX ) )
{
fax = ( String ) value;
}
else if( fieldName.equals( ContactoData.EMAIL ) )
{
email = ( String ) value;
}
}
public Class getOuterClass()
{
return ContactoData.class;
}
}

@ -0,0 +1,63 @@
/*
* ContactoData.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on 13/Out/2004
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.HashMap;
import com.evolute.utils.jdo.*;
public final class ContactoData extends JDOObject
{
public static final String ID = "id";
public static final String NOME = "nome";
public static final String CARGO = "cargo";
public static final String TELEFONE = "telefone";
public static final String TELEMOVEL = "telemovel";
public static final String FAX = "fax";
public static final String EMAIL = "email";
public static final String FIELD_NAMES[] = new String[]{
NOME, CARGO, TELEFONE, TELEMOVEL, FAX, EMAIL, };
protected static final String ALL_FIELD_NAMES[] = new String[]{
ID, NOME, CARGO, TELEFONE, TELEMOVEL, FAX, EMAIL, };
private HashMap dataHash;
public ContactoData()
{
dataHash = new HashMap();
}
protected Object innerGet( String fieldName )
throws Exception
{
return dataHash.get( fieldName );
}
protected void innerSet( String fieldName, Object value )
throws Exception
{
dataHash.put( fieldName, value );
}
public String []getFieldNames()
{
return FIELD_NAMES;
}
protected String []getAllFieldNames()
{
return ALL_FIELD_NAMES;
}
public Class getInnerClass()
{
return Contacto.class;
}
}

@ -0,0 +1,22 @@
/*
* ContactoID.java
*
* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 13/Out/2004
*
* Use but DON'T TOUCH
*/
package siprp.data;
import com.evolute.utils.jdo.jpox.*;
public final class ContactoID extends IntegerID
{
public ContactoID()
{
}
public ContactoID( String str )
{
super( str );
}
}

@ -0,0 +1,70 @@
/*
* DeleteHandler.java
*
* Created on 11 de Outubro de 2004, 16:04
*/
package siprp.data;
import com.evolute.utils.jdo.*;
/**
*
* @author fpalma
*/
public class DisableDeleteHandler implements JDOOperationHandlerInterface
{
public static final DisableDeleteHandler INSTANCE = new DisableDeleteHandler();
/** Creates a new instance of DeleteHandler */
public DisableDeleteHandler()
{
}
public boolean handle( JDOObject object, int operation, int moment )
throws Exception
{
if( !( object instanceof DisableDeleteable ) )
{
return false;
}
switch( operation )
{
case OP_SAVE:
return save( object, moment );
case OP_DELETE:
return delete( object, moment );
}
return false;
}
protected boolean save( JDOObject object, int moment )
throws Exception
{
if( moment != MOMENT_BEFORE )
{
return false;
}
String old = (String) object.get( DisableDeleteable.INACTIVO );
if( old == null )
{
object.set( DisableDeleteable.INACTIVO, "n" );
}
return true;
}
protected boolean delete( JDOObject object, int moment )
throws Exception
{
if( moment != MOMENT_INSTEAD )
{
return false;
}
object.set( DisableDeleteable.INACTIVO, "y" );
object.save();
return true;
}
}

@ -0,0 +1,16 @@
/*
* DisableDeleteable.java
*
* Created on 11 de Outubro de 2004, 16:09
*/
package siprp.data;
/**
*
* @author fpalma
*/
public interface DisableDeleteable
{
public static final String INACTIVO = "inactivo";
}

@ -0,0 +1,713 @@
/*
* Empresa.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on Jan 31, 2006
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.Date;
import com.evolute.utils.jdo.*;
public final class Empresa implements JDOInnerObject
{
private Integer id;
private String designacao_social;
private String designacao_social_plain;
private Integer servico_saude_tipo;
private String servico_saude_designacao;
private Integer servico_higiene_tipo;
private String servico_higiene_designacao;
private String morada;
private String codigo_postal;
private String localidade;
private String distrito;
private String concelho;
private Date data_proposta;
private Date data_aceitacao;
private Date data_cancelamento;
private String perfil_1;
private String perfil_2;
private Date data_envio_contrato;
private Date data_recepcao_contrato;
private Date data_envio_idict;
private Date data_relatorio_anual;
private String codigo_1;
private String codigo_2;
private String codigo_3;
private String cae;
private String actividade;
private String contribuinte;
private String seguranca_social;
private Double preco_higiene;
private Double preco_medicina;
private String periodicidade;
private Contacto contacto_1;
private Contacto contacto_2;
private Integer servicos;
private String inactivo;
private Date actualizacao;
private String a_consultas;
private String a_exames;
private String b_consultas;
private String b_exames;
public Empresa()
{
}
public Object getField( String fieldName )
{
if( fieldName == EmpresaData.ID )
{
return id;
}
else if( fieldName == EmpresaData.DESIGNACAO_SOCIAL )
{
return designacao_social;
}
else if( fieldName == EmpresaData.DESIGNACAO_SOCIAL_PLAIN )
{
return designacao_social_plain;
}
else if( fieldName == EmpresaData.SERVICO_SAUDE_TIPO )
{
return servico_saude_tipo;
}
else if( fieldName == EmpresaData.SERVICO_SAUDE_DESIGNACAO )
{
return servico_saude_designacao;
}
else if( fieldName == EmpresaData.SERVICO_HIGIENE_TIPO )
{
return servico_higiene_tipo;
}
else if( fieldName == EmpresaData.SERVICO_HIGIENE_DESIGNACAO )
{
return servico_higiene_designacao;
}
else if( fieldName == EmpresaData.MORADA )
{
return morada;
}
else if( fieldName == EmpresaData.CODIGO_POSTAL )
{
return codigo_postal;
}
else if( fieldName == EmpresaData.LOCALIDADE )
{
return localidade;
}
else if( fieldName == EmpresaData.DISTRITO )
{
return distrito;
}
else if( fieldName == EmpresaData.CONCELHO )
{
return concelho;
}
else if( fieldName == EmpresaData.DATA_PROPOSTA )
{
return data_proposta;
}
else if( fieldName == EmpresaData.DATA_ACEITACAO )
{
return data_aceitacao;
}
else if( fieldName == EmpresaData.DATA_CANCELAMENTO )
{
return data_cancelamento;
}
else if( fieldName == EmpresaData.PERFIL_1 )
{
return perfil_1;
}
else if( fieldName == EmpresaData.PERFIL_2 )
{
return perfil_2;
}
else if( fieldName == EmpresaData.DATA_ENVIO_CONTRATO )
{
return data_envio_contrato;
}
else if( fieldName == EmpresaData.DATA_RECEPCAO_CONTRATO )
{
return data_recepcao_contrato;
}
else if( fieldName == EmpresaData.DATA_ENVIO_IDICT )
{
return data_envio_idict;
}
else if( fieldName == EmpresaData.DATA_RELATORIO_ANUAL )
{
return data_relatorio_anual;
}
else if( fieldName == EmpresaData.CODIGO_1 )
{
return codigo_1;
}
else if( fieldName == EmpresaData.CODIGO_2 )
{
return codigo_2;
}
else if( fieldName == EmpresaData.CODIGO_3 )
{
return codigo_3;
}
else if( fieldName == EmpresaData.CAE )
{
return cae;
}
else if( fieldName == EmpresaData.ACTIVIDADE )
{
return actividade;
}
else if( fieldName == EmpresaData.CONTRIBUINTE )
{
return contribuinte;
}
else if( fieldName == EmpresaData.SEGURANCA_SOCIAL )
{
return seguranca_social;
}
else if( fieldName == EmpresaData.PRECO_HIGIENE )
{
return preco_higiene;
}
else if( fieldName == EmpresaData.PRECO_MEDICINA )
{
return preco_medicina;
}
else if( fieldName == EmpresaData.PERIODICIDADE )
{
return periodicidade;
}
else if( fieldName == EmpresaData.CONTACTO_1 )
{
return contacto_1;
}
else if( fieldName == EmpresaData.CONTACTO_2 )
{
return contacto_2;
}
else if( fieldName == EmpresaData.SERVICOS )
{
return servicos;
}
else if( fieldName == EmpresaData.INACTIVO )
{
return inactivo;
}
else if( fieldName == EmpresaData.ACTUALIZACAO )
{
return actualizacao;
}
else if( fieldName == EmpresaData.A_CONSULTAS )
{
return a_consultas;
}
else if( fieldName == EmpresaData.A_EXAMES )
{
return a_exames;
}
else if( fieldName == EmpresaData.B_CONSULTAS )
{
return b_consultas;
}
else if( fieldName == EmpresaData.B_EXAMES )
{
return b_exames;
}
else if( fieldName.equals( EmpresaData.ID ) )
{
return id;
}
else if( fieldName.equals( EmpresaData.DESIGNACAO_SOCIAL ) )
{
return designacao_social;
}
else if( fieldName.equals( EmpresaData.DESIGNACAO_SOCIAL_PLAIN ) )
{
return designacao_social_plain;
}
else if( fieldName.equals( EmpresaData.SERVICO_SAUDE_TIPO ) )
{
return servico_saude_tipo;
}
else if( fieldName.equals( EmpresaData.SERVICO_SAUDE_DESIGNACAO ) )
{
return servico_saude_designacao;
}
else if( fieldName.equals( EmpresaData.SERVICO_HIGIENE_TIPO ) )
{
return servico_higiene_tipo;
}
else if( fieldName.equals( EmpresaData.SERVICO_HIGIENE_DESIGNACAO ) )
{
return servico_higiene_designacao;
}
else if( fieldName.equals( EmpresaData.MORADA ) )
{
return morada;
}
else if( fieldName.equals( EmpresaData.CODIGO_POSTAL ) )
{
return codigo_postal;
}
else if( fieldName.equals( EmpresaData.LOCALIDADE ) )
{
return localidade;
}
else if( fieldName.equals( EmpresaData.DISTRITO ) )
{
return distrito;
}
else if( fieldName.equals( EmpresaData.CONCELHO ) )
{
return concelho;
}
else if( fieldName.equals( EmpresaData.DATA_PROPOSTA ) )
{
return data_proposta;
}
else if( fieldName.equals( EmpresaData.DATA_ACEITACAO ) )
{
return data_aceitacao;
}
else if( fieldName.equals( EmpresaData.DATA_CANCELAMENTO ) )
{
return data_cancelamento;
}
else if( fieldName.equals( EmpresaData.PERFIL_1 ) )
{
return perfil_1;
}
else if( fieldName.equals( EmpresaData.PERFIL_2 ) )
{
return perfil_2;
}
else if( fieldName.equals( EmpresaData.DATA_ENVIO_CONTRATO ) )
{
return data_envio_contrato;
}
else if( fieldName.equals( EmpresaData.DATA_RECEPCAO_CONTRATO ) )
{
return data_recepcao_contrato;
}
else if( fieldName.equals( EmpresaData.DATA_ENVIO_IDICT ) )
{
return data_envio_idict;
}
else if( fieldName.equals( EmpresaData.DATA_RELATORIO_ANUAL ) )
{
return data_relatorio_anual;
}
else if( fieldName.equals( EmpresaData.CODIGO_1 ) )
{
return codigo_1;
}
else if( fieldName.equals( EmpresaData.CODIGO_2 ) )
{
return codigo_2;
}
else if( fieldName.equals( EmpresaData.CODIGO_3 ) )
{
return codigo_3;
}
else if( fieldName.equals( EmpresaData.CAE ) )
{
return cae;
}
else if( fieldName.equals( EmpresaData.ACTIVIDADE ) )
{
return actividade;
}
else if( fieldName.equals( EmpresaData.CONTRIBUINTE ) )
{
return contribuinte;
}
else if( fieldName.equals( EmpresaData.SEGURANCA_SOCIAL ) )
{
return seguranca_social;
}
else if( fieldName.equals( EmpresaData.PRECO_HIGIENE ) )
{
return preco_higiene;
}
else if( fieldName.equals( EmpresaData.PRECO_MEDICINA ) )
{
return preco_medicina;
}
else if( fieldName.equals( EmpresaData.PERIODICIDADE ) )
{
return periodicidade;
}
else if( fieldName.equals( EmpresaData.CONTACTO_1 ) )
{
return contacto_1;
}
else if( fieldName.equals( EmpresaData.CONTACTO_2 ) )
{
return contacto_2;
}
else if( fieldName.equals( EmpresaData.SERVICOS ) )
{
return servicos;
}
else if( fieldName.equals( EmpresaData.INACTIVO ) )
{
return inactivo;
}
else if( fieldName.equals( EmpresaData.ACTUALIZACAO ) )
{
return actualizacao;
}
else if( fieldName.equals( EmpresaData.A_CONSULTAS ) )
{
return a_consultas;
}
else if( fieldName.equals( EmpresaData.A_EXAMES ) )
{
return a_exames;
}
else if( fieldName.equals( EmpresaData.B_CONSULTAS ) )
{
return b_consultas;
}
else if( fieldName.equals( EmpresaData.B_EXAMES ) )
{
return b_exames;
}
return null;
}
public void setField( String fieldName, Object value )
{
if( fieldName == EmpresaData.ID )
{
id = ( Integer ) value;
}
else if( fieldName == EmpresaData.DESIGNACAO_SOCIAL )
{
designacao_social = ( String ) value;
}
else if( fieldName == EmpresaData.DESIGNACAO_SOCIAL_PLAIN )
{
designacao_social_plain = ( String ) value;
}
else if( fieldName == EmpresaData.SERVICO_SAUDE_TIPO )
{
servico_saude_tipo = ( Integer ) value;
}
else if( fieldName == EmpresaData.SERVICO_SAUDE_DESIGNACAO )
{
servico_saude_designacao = ( String ) value;
}
else if( fieldName == EmpresaData.SERVICO_HIGIENE_TIPO )
{
servico_higiene_tipo = ( Integer ) value;
}
else if( fieldName == EmpresaData.SERVICO_HIGIENE_DESIGNACAO )
{
servico_higiene_designacao = ( String ) value;
}
else if( fieldName == EmpresaData.MORADA )
{
morada = ( String ) value;
}
else if( fieldName == EmpresaData.CODIGO_POSTAL )
{
codigo_postal = ( String ) value;
}
else if( fieldName == EmpresaData.LOCALIDADE )
{
localidade = ( String ) value;
}
else if( fieldName == EmpresaData.DISTRITO )
{
distrito = ( String ) value;
}
else if( fieldName == EmpresaData.CONCELHO )
{
concelho = ( String ) value;
}
else if( fieldName == EmpresaData.DATA_PROPOSTA )
{
data_proposta = ( Date ) value;
}
else if( fieldName == EmpresaData.DATA_ACEITACAO )
{
data_aceitacao = ( Date ) value;
}
else if( fieldName == EmpresaData.DATA_CANCELAMENTO )
{
data_cancelamento = ( Date ) value;
}
else if( fieldName == EmpresaData.PERFIL_1 )
{
perfil_1 = ( String ) value;
}
else if( fieldName == EmpresaData.PERFIL_2 )
{
perfil_2 = ( String ) value;
}
else if( fieldName == EmpresaData.DATA_ENVIO_CONTRATO )
{
data_envio_contrato = ( Date ) value;
}
else if( fieldName == EmpresaData.DATA_RECEPCAO_CONTRATO )
{
data_recepcao_contrato = ( Date ) value;
}
else if( fieldName == EmpresaData.DATA_ENVIO_IDICT )
{
data_envio_idict = ( Date ) value;
}
else if( fieldName == EmpresaData.DATA_RELATORIO_ANUAL )
{
data_relatorio_anual = ( Date ) value;
}
else if( fieldName == EmpresaData.CODIGO_1 )
{
codigo_1 = ( String ) value;
}
else if( fieldName == EmpresaData.CODIGO_2 )
{
codigo_2 = ( String ) value;
}
else if( fieldName == EmpresaData.CODIGO_3 )
{
codigo_3 = ( String ) value;
}
else if( fieldName == EmpresaData.CAE )
{
cae = ( String ) value;
}
else if( fieldName == EmpresaData.ACTIVIDADE )
{
actividade = ( String ) value;
}
else if( fieldName == EmpresaData.CONTRIBUINTE )
{
contribuinte = ( String ) value;
}
else if( fieldName == EmpresaData.SEGURANCA_SOCIAL )
{
seguranca_social = ( String ) value;
}
else if( fieldName == EmpresaData.PRECO_HIGIENE )
{
preco_higiene = ( Double ) value;
}
else if( fieldName == EmpresaData.PRECO_MEDICINA )
{
preco_medicina = ( Double ) value;
}
else if( fieldName == EmpresaData.PERIODICIDADE )
{
periodicidade = ( String ) value;
}
else if( fieldName == EmpresaData.CONTACTO_1 )
{
contacto_1 = ( Contacto ) value;
}
else if( fieldName == EmpresaData.CONTACTO_2 )
{
contacto_2 = ( Contacto ) value;
}
else if( fieldName == EmpresaData.SERVICOS )
{
servicos = ( Integer ) value;
}
else if( fieldName == EmpresaData.INACTIVO )
{
inactivo = ( String ) value;
}
else if( fieldName == EmpresaData.ACTUALIZACAO )
{
actualizacao = ( Date ) value;
}
else if( fieldName == EmpresaData.A_CONSULTAS )
{
a_consultas = ( String ) value;
}
else if( fieldName == EmpresaData.A_EXAMES )
{
a_exames = ( String ) value;
}
else if( fieldName == EmpresaData.B_CONSULTAS )
{
b_consultas = ( String ) value;
}
else if( fieldName == EmpresaData.B_EXAMES )
{
b_exames = ( String ) value;
}
else if( fieldName.equals( EmpresaData.ID ) )
{
id = ( Integer ) value;
}
else if( fieldName.equals( EmpresaData.DESIGNACAO_SOCIAL ) )
{
designacao_social = ( String ) value;
}
else if( fieldName.equals( EmpresaData.DESIGNACAO_SOCIAL_PLAIN ) )
{
designacao_social_plain = ( String ) value;
}
else if( fieldName.equals( EmpresaData.SERVICO_SAUDE_TIPO ) )
{
servico_saude_tipo = ( Integer ) value;
}
else if( fieldName.equals( EmpresaData.SERVICO_SAUDE_DESIGNACAO ) )
{
servico_saude_designacao = ( String ) value;
}
else if( fieldName.equals( EmpresaData.SERVICO_HIGIENE_TIPO ) )
{
servico_higiene_tipo = ( Integer ) value;
}
else if( fieldName.equals( EmpresaData.SERVICO_HIGIENE_DESIGNACAO ) )
{
servico_higiene_designacao = ( String ) value;
}
else if( fieldName.equals( EmpresaData.MORADA ) )
{
morada = ( String ) value;
}
else if( fieldName.equals( EmpresaData.CODIGO_POSTAL ) )
{
codigo_postal = ( String ) value;
}
else if( fieldName.equals( EmpresaData.LOCALIDADE ) )
{
localidade = ( String ) value;
}
else if( fieldName.equals( EmpresaData.DISTRITO ) )
{
distrito = ( String ) value;
}
else if( fieldName.equals( EmpresaData.CONCELHO ) )
{
concelho = ( String ) value;
}
else if( fieldName.equals( EmpresaData.DATA_PROPOSTA ) )
{
data_proposta = ( Date ) value;
}
else if( fieldName.equals( EmpresaData.DATA_ACEITACAO ) )
{
data_aceitacao = ( Date ) value;
}
else if( fieldName.equals( EmpresaData.DATA_CANCELAMENTO ) )
{
data_cancelamento = ( Date ) value;
}
else if( fieldName.equals( EmpresaData.PERFIL_1 ) )
{
perfil_1 = ( String ) value;
}
else if( fieldName.equals( EmpresaData.PERFIL_2 ) )
{
perfil_2 = ( String ) value;
}
else if( fieldName.equals( EmpresaData.DATA_ENVIO_CONTRATO ) )
{
data_envio_contrato = ( Date ) value;
}
else if( fieldName.equals( EmpresaData.DATA_RECEPCAO_CONTRATO ) )
{
data_recepcao_contrato = ( Date ) value;
}
else if( fieldName.equals( EmpresaData.DATA_ENVIO_IDICT ) )
{
data_envio_idict = ( Date ) value;
}
else if( fieldName.equals( EmpresaData.DATA_RELATORIO_ANUAL ) )
{
data_relatorio_anual = ( Date ) value;
}
else if( fieldName.equals( EmpresaData.CODIGO_1 ) )
{
codigo_1 = ( String ) value;
}
else if( fieldName.equals( EmpresaData.CODIGO_2 ) )
{
codigo_2 = ( String ) value;
}
else if( fieldName.equals( EmpresaData.CODIGO_3 ) )
{
codigo_3 = ( String ) value;
}
else if( fieldName.equals( EmpresaData.CAE ) )
{
cae = ( String ) value;
}
else if( fieldName.equals( EmpresaData.ACTIVIDADE ) )
{
actividade = ( String ) value;
}
else if( fieldName.equals( EmpresaData.CONTRIBUINTE ) )
{
contribuinte = ( String ) value;
}
else if( fieldName.equals( EmpresaData.SEGURANCA_SOCIAL ) )
{
seguranca_social = ( String ) value;
}
else if( fieldName.equals( EmpresaData.PRECO_HIGIENE ) )
{
preco_higiene = ( Double ) value;
}
else if( fieldName.equals( EmpresaData.PRECO_MEDICINA ) )
{
preco_medicina = ( Double ) value;
}
else if( fieldName.equals( EmpresaData.PERIODICIDADE ) )
{
periodicidade = ( String ) value;
}
else if( fieldName.equals( EmpresaData.CONTACTO_1 ) )
{
contacto_1 = ( Contacto ) value;
}
else if( fieldName.equals( EmpresaData.CONTACTO_2 ) )
{
contacto_2 = ( Contacto ) value;
}
else if( fieldName.equals( EmpresaData.SERVICOS ) )
{
servicos = ( Integer ) value;
}
else if( fieldName.equals( EmpresaData.INACTIVO ) )
{
inactivo = ( String ) value;
}
else if( fieldName.equals( EmpresaData.ACTUALIZACAO ) )
{
actualizacao = ( Date ) value;
}
else if( fieldName.equals( EmpresaData.A_CONSULTAS ) )
{
a_consultas = ( String ) value;
}
else if( fieldName.equals( EmpresaData.A_EXAMES ) )
{
a_exames = ( String ) value;
}
else if( fieldName.equals( EmpresaData.B_CONSULTAS ) )
{
b_consultas = ( String ) value;
}
else if( fieldName.equals( EmpresaData.B_EXAMES ) )
{
b_exames = ( String ) value;
}
}
public Class getOuterClass()
{
return EmpresaData.class;
}
}

@ -0,0 +1,111 @@
/*
* EmpresaData.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on Jan 31, 2006
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.HashMap;
import com.evolute.utils.jdo.*;
public final class EmpresaData extends JDOObject
implements DisableDeleteable, ActualizacaoSaveable
{
public static final String ID = "id";
public static final String DESIGNACAO_SOCIAL = "designacao_social";
public static final String DESIGNACAO_SOCIAL_PLAIN = "designacao_social_plain";
public static final String SERVICO_SAUDE_TIPO = "servico_saude_tipo";
public static final String SERVICO_SAUDE_DESIGNACAO = "servico_saude_designacao";
public static final String SERVICO_HIGIENE_TIPO = "servico_higiene_tipo";
public static final String SERVICO_HIGIENE_DESIGNACAO = "servico_higiene_designacao";
public static final String MORADA = "morada";
public static final String CODIGO_POSTAL = "codigo_postal";
public static final String LOCALIDADE = "localidade";
public static final String DISTRITO = "distrito";
public static final String CONCELHO = "concelho";
public static final String DATA_PROPOSTA = "data_proposta";
public static final String DATA_ACEITACAO = "data_aceitacao";
public static final String DATA_CANCELAMENTO = "data_cancelamento";
public static final String PERFIL_1 = "perfil_1";
public static final String PERFIL_2 = "perfil_2";
public static final String DATA_ENVIO_CONTRATO = "data_envio_contrato";
public static final String DATA_RECEPCAO_CONTRATO = "data_recepcao_contrato";
public static final String DATA_ENVIO_IDICT = "data_envio_idict";
public static final String DATA_RELATORIO_ANUAL = "data_relatorio_anual";
public static final String CODIGO_1 = "codigo_1";
public static final String CODIGO_2 = "codigo_2";
public static final String CODIGO_3 = "codigo_3";
public static final String CAE = "cae";
public static final String ACTIVIDADE = "actividade";
public static final String CONTRIBUINTE = "contribuinte";
public static final String SEGURANCA_SOCIAL = "seguranca_social";
public static final String PRECO_HIGIENE = "preco_higiene";
public static final String PRECO_MEDICINA = "preco_medicina";
public static final String PERIODICIDADE = "periodicidade";
public static final String CONTACTO_1 = "contacto_1";
public static final String CONTACTO_2 = "contacto_2";
public static final String SERVICOS = "servicos";
public static final String INACTIVO = "inactivo";
public static final String ACTUALIZACAO = "actualizacao";
public static final String A_CONSULTAS = "a_consultas";
public static final String A_EXAMES = "a_exames";
public static final String B_CONSULTAS = "b_consultas";
public static final String B_EXAMES = "b_exames";
public static final String FIELD_NAMES[] = new String[]{
DESIGNACAO_SOCIAL, DESIGNACAO_SOCIAL_PLAIN, SERVICO_SAUDE_TIPO,
SERVICO_SAUDE_DESIGNACAO, SERVICO_HIGIENE_TIPO, SERVICO_HIGIENE_DESIGNACAO,
MORADA, CODIGO_POSTAL, LOCALIDADE, DISTRITO, CONCELHO, DATA_PROPOSTA,
DATA_ACEITACAO, DATA_CANCELAMENTO, PERFIL_1, PERFIL_2, DATA_ENVIO_CONTRATO,
DATA_RECEPCAO_CONTRATO, DATA_ENVIO_IDICT, DATA_RELATORIO_ANUAL, CODIGO_1,
CODIGO_2, CODIGO_3, CAE, ACTIVIDADE, CONTRIBUINTE, SEGURANCA_SOCIAL, PRECO_HIGIENE,
PRECO_MEDICINA, PERIODICIDADE, CONTACTO_1, CONTACTO_2, SERVICOS, A_CONSULTAS,
A_EXAMES, B_CONSULTAS, B_EXAMES, };
protected static final String ALL_FIELD_NAMES[] = new String[]{
ID, DESIGNACAO_SOCIAL, DESIGNACAO_SOCIAL_PLAIN, SERVICO_SAUDE_TIPO,
SERVICO_SAUDE_DESIGNACAO, SERVICO_HIGIENE_TIPO, SERVICO_HIGIENE_DESIGNACAO,
MORADA, CODIGO_POSTAL, LOCALIDADE, DISTRITO, CONCELHO, DATA_PROPOSTA,
DATA_ACEITACAO, DATA_CANCELAMENTO, PERFIL_1, PERFIL_2, DATA_ENVIO_CONTRATO,
DATA_RECEPCAO_CONTRATO, DATA_ENVIO_IDICT, DATA_RELATORIO_ANUAL, CODIGO_1,
CODIGO_2, CODIGO_3, CAE, ACTIVIDADE, CONTRIBUINTE, SEGURANCA_SOCIAL, PRECO_HIGIENE,
PRECO_MEDICINA, PERIODICIDADE, CONTACTO_1, CONTACTO_2, SERVICOS, INACTIVO,
ACTUALIZACAO, A_CONSULTAS, A_EXAMES, B_CONSULTAS, B_EXAMES, };
private HashMap dataHash;
public EmpresaData()
{
dataHash = new HashMap();
}
protected Object innerGet( String fieldName )
throws Exception
{
return dataHash.get( fieldName );
}
protected void innerSet( String fieldName, Object value )
throws Exception
{
dataHash.put( fieldName, value );
}
public String []getFieldNames()
{
return FIELD_NAMES;
}
protected String []getAllFieldNames()
{
return ALL_FIELD_NAMES;
}
public Class getInnerClass()
{
return Empresa.class;
}
}

@ -0,0 +1,25 @@
/*
* EmpresaID.java
*
* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on Jan 31, 2006
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.io.*;
import com.evolute.utils.jdo.jpox.*;
public final class EmpresaID extends IntegerID
implements Serializable
{
public EmpresaID()
{
}
public EmpresaID( String str )
{
super( str );
}
}

@ -0,0 +1,220 @@
/*
* Estabelecimento.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on 24/Nov/2005
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.Date;
import com.evolute.utils.jdo.*;
public final class Estabelecimento implements JDOInnerObject
{
private Integer id;
private String nome;
private String nome_plain;
private String morada;
private String codigo_postal;
private String localidade;
private String historico;
private Empresa empresa;
private Contacto contacto;
private String inactivo;
private Date actualizacao;
public Estabelecimento()
{
}
public Object getField( String fieldName )
{
if( fieldName == EstabelecimentoData.ID )
{
return id;
}
else if( fieldName == EstabelecimentoData.NOME )
{
return nome;
}
else if( fieldName == EstabelecimentoData.NOME_PLAIN )
{
return nome_plain;
}
else if( fieldName == EstabelecimentoData.MORADA )
{
return morada;
}
else if( fieldName == EstabelecimentoData.CODIGO_POSTAL )
{
return codigo_postal;
}
else if( fieldName == EstabelecimentoData.LOCALIDADE )
{
return localidade;
}
else if( fieldName == EstabelecimentoData.HISTORICO )
{
return historico;
}
else if( fieldName == EstabelecimentoData.EMPRESA )
{
return empresa;
}
else if( fieldName == EstabelecimentoData.CONTACTO )
{
return contacto;
}
else if( fieldName == EstabelecimentoData.INACTIVO )
{
return inactivo;
}
else if( fieldName == EstabelecimentoData.ACTUALIZACAO )
{
return actualizacao;
}
else if( fieldName.equals( EstabelecimentoData.ID ) )
{
return id;
}
else if( fieldName.equals( EstabelecimentoData.NOME ) )
{
return nome;
}
else if( fieldName.equals( EstabelecimentoData.NOME_PLAIN ) )
{
return nome_plain;
}
else if( fieldName.equals( EstabelecimentoData.MORADA ) )
{
return morada;
}
else if( fieldName.equals( EstabelecimentoData.CODIGO_POSTAL ) )
{
return codigo_postal;
}
else if( fieldName.equals( EstabelecimentoData.LOCALIDADE ) )
{
return localidade;
}
else if( fieldName.equals( EstabelecimentoData.HISTORICO ) )
{
return historico;
}
else if( fieldName.equals( EstabelecimentoData.EMPRESA ) )
{
return empresa;
}
else if( fieldName.equals( EstabelecimentoData.CONTACTO ) )
{
return contacto;
}
else if( fieldName.equals( EstabelecimentoData.INACTIVO ) )
{
return inactivo;
}
else if( fieldName.equals( EstabelecimentoData.ACTUALIZACAO ) )
{
return actualizacao;
}
return null;
}
public void setField( String fieldName, Object value )
{
if( fieldName == EstabelecimentoData.ID )
{
id = ( Integer ) value;
}
else if( fieldName == EstabelecimentoData.NOME )
{
nome = ( String ) value;
}
else if( fieldName == EstabelecimentoData.NOME_PLAIN )
{
nome_plain = ( String ) value;
}
else if( fieldName == EstabelecimentoData.MORADA )
{
morada = ( String ) value;
}
else if( fieldName == EstabelecimentoData.CODIGO_POSTAL )
{
codigo_postal = ( String ) value;
}
else if( fieldName == EstabelecimentoData.LOCALIDADE )
{
localidade = ( String ) value;
}
else if( fieldName == EstabelecimentoData.HISTORICO )
{
historico = ( String ) value;
}
else if( fieldName == EstabelecimentoData.EMPRESA )
{
empresa = ( Empresa ) value;
}
else if( fieldName == EstabelecimentoData.CONTACTO )
{
contacto = ( Contacto ) value;
}
else if( fieldName == EstabelecimentoData.INACTIVO )
{
inactivo = ( String ) value;
}
else if( fieldName == EstabelecimentoData.ACTUALIZACAO )
{
actualizacao = ( Date ) value;
}
else if( fieldName.equals( EstabelecimentoData.ID ) )
{
id = ( Integer ) value;
}
else if( fieldName.equals( EstabelecimentoData.NOME ) )
{
nome = ( String ) value;
}
else if( fieldName.equals( EstabelecimentoData.NOME_PLAIN ) )
{
nome_plain = ( String ) value;
}
else if( fieldName.equals( EstabelecimentoData.MORADA ) )
{
morada = ( String ) value;
}
else if( fieldName.equals( EstabelecimentoData.CODIGO_POSTAL ) )
{
codigo_postal = ( String ) value;
}
else if( fieldName.equals( EstabelecimentoData.LOCALIDADE ) )
{
localidade = ( String ) value;
}
else if( fieldName.equals( EstabelecimentoData.HISTORICO ) )
{
historico = ( String ) value;
}
else if( fieldName.equals( EstabelecimentoData.EMPRESA ) )
{
empresa = ( Empresa ) value;
}
else if( fieldName.equals( EstabelecimentoData.CONTACTO ) )
{
contacto = ( Contacto ) value;
}
else if( fieldName.equals( EstabelecimentoData.INACTIVO ) )
{
inactivo = ( String ) value;
}
else if( fieldName.equals( EstabelecimentoData.ACTUALIZACAO ) )
{
actualizacao = ( Date ) value;
}
}
public Class getOuterClass()
{
return EstabelecimentoData.class;
}
}

@ -0,0 +1,69 @@
/*
* EstabelecimentoData.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on 24/Nov/2005
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.HashMap;
import com.evolute.utils.jdo.*;
public final class EstabelecimentoData extends JDOObject
implements DisableDeleteable, ActualizacaoSaveable
{
public static final String ID = "id";
public static final String NOME = "nome";
public static final String NOME_PLAIN = "nome_plain";
public static final String MORADA = "morada";
public static final String CODIGO_POSTAL = "codigo_postal";
public static final String LOCALIDADE = "localidade";
public static final String HISTORICO = "historico";
public static final String EMPRESA = "empresa";
public static final String CONTACTO = "contacto";
public static final String INACTIVO = "inactivo";
public static final String ACTUALIZACAO = "actualizacao";
public static final String FIELD_NAMES[] = new String[]{
NOME, NOME_PLAIN, MORADA, CODIGO_POSTAL, LOCALIDADE, HISTORICO, EMPRESA, CONTACTO, };
protected static final String ALL_FIELD_NAMES[] = new String[]{
ID, NOME, NOME_PLAIN, MORADA, CODIGO_POSTAL, LOCALIDADE, HISTORICO, EMPRESA, CONTACTO,
INACTIVO, ACTUALIZACAO, };
private HashMap dataHash;
public EstabelecimentoData()
{
dataHash = new HashMap();
}
protected Object innerGet( String fieldName )
throws Exception
{
return dataHash.get( fieldName );
}
protected void innerSet( String fieldName, Object value )
throws Exception
{
dataHash.put( fieldName, value );
}
public String []getFieldNames()
{
return FIELD_NAMES;
}
protected String []getAllFieldNames()
{
return ALL_FIELD_NAMES;
}
public Class getInnerClass()
{
return Estabelecimento.class;
}
}

@ -0,0 +1,25 @@
/*
* EstabelecimentoID.java
*
* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 24/Nov/2005
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.io.*;
import com.evolute.utils.jdo.jpox.*;
public final class EstabelecimentoID extends IntegerID
implements Serializable
{
public EstabelecimentoID()
{
}
public EstabelecimentoID( String str )
{
super( str );
}
}

@ -0,0 +1,270 @@
/*
* Etiqueta.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on 27/Fev/2006
*
* Use but DON'T TOUCH
*/
package siprp.data;
import com.evolute.utils.jdo.*;
public final class Etiqueta implements JDOInnerObject
{
private Integer id;
private String descricao;
private String descricao_plain;
private Double altura;
private Double largura;
private Double margem_esquerda;
private Double margem_cima;
private Integer colunas;
private Integer linhas;
private String continua;
private Double altura_folha;
private Double largura_folha;
private Double margem_vertical_folha;
private Double margem_horizontal_folha;
public Etiqueta()
{
}
public Object getField( String fieldName )
{
if( fieldName == EtiquetaData.ID )
{
return id;
}
else if( fieldName == EtiquetaData.DESCRICAO )
{
return descricao;
}
else if( fieldName == EtiquetaData.DESCRICAO_PLAIN )
{
return descricao_plain;
}
else if( fieldName == EtiquetaData.ALTURA )
{
return altura;
}
else if( fieldName == EtiquetaData.LARGURA )
{
return largura;
}
else if( fieldName == EtiquetaData.MARGEM_ESQUERDA )
{
return margem_esquerda;
}
else if( fieldName == EtiquetaData.MARGEM_CIMA )
{
return margem_cima;
}
else if( fieldName == EtiquetaData.COLUNAS )
{
return colunas;
}
else if( fieldName == EtiquetaData.LINHAS )
{
return linhas;
}
else if( fieldName == EtiquetaData.CONTINUA )
{
return continua;
}
else if( fieldName == EtiquetaData.ALTURA_FOLHA )
{
return altura_folha;
}
else if( fieldName == EtiquetaData.LARGURA_FOLHA )
{
return largura_folha;
}
else if( fieldName == EtiquetaData.MARGEM_VERTICAL_FOLHA )
{
return margem_vertical_folha;
}
else if( fieldName == EtiquetaData.MARGEM_HORIZONTAL_FOLHA )
{
return margem_horizontal_folha;
}
else if( fieldName.equals( EtiquetaData.ID ) )
{
return id;
}
else if( fieldName.equals( EtiquetaData.DESCRICAO ) )
{
return descricao;
}
else if( fieldName.equals( EtiquetaData.DESCRICAO_PLAIN ) )
{
return descricao_plain;
}
else if( fieldName.equals( EtiquetaData.ALTURA ) )
{
return altura;
}
else if( fieldName.equals( EtiquetaData.LARGURA ) )
{
return largura;
}
else if( fieldName.equals( EtiquetaData.MARGEM_ESQUERDA ) )
{
return margem_esquerda;
}
else if( fieldName.equals( EtiquetaData.MARGEM_CIMA ) )
{
return margem_cima;
}
else if( fieldName.equals( EtiquetaData.COLUNAS ) )
{
return colunas;
}
else if( fieldName.equals( EtiquetaData.LINHAS ) )
{
return linhas;
}
else if( fieldName.equals( EtiquetaData.CONTINUA ) )
{
return continua;
}
else if( fieldName.equals( EtiquetaData.ALTURA_FOLHA ) )
{
return altura_folha;
}
else if( fieldName.equals( EtiquetaData.LARGURA_FOLHA ) )
{
return largura_folha;
}
else if( fieldName.equals( EtiquetaData.MARGEM_VERTICAL_FOLHA ) )
{
return margem_vertical_folha;
}
else if( fieldName.equals( EtiquetaData.MARGEM_HORIZONTAL_FOLHA ) )
{
return margem_horizontal_folha;
}
return null;
}
public void setField( String fieldName, Object value )
{
if( fieldName == EtiquetaData.ID )
{
id = ( Integer ) value;
}
else if( fieldName == EtiquetaData.DESCRICAO )
{
descricao = ( String ) value;
}
else if( fieldName == EtiquetaData.DESCRICAO_PLAIN )
{
descricao_plain = ( String ) value;
}
else if( fieldName == EtiquetaData.ALTURA )
{
altura = ( Double ) value;
}
else if( fieldName == EtiquetaData.LARGURA )
{
largura = ( Double ) value;
}
else if( fieldName == EtiquetaData.MARGEM_ESQUERDA )
{
margem_esquerda = ( Double ) value;
}
else if( fieldName == EtiquetaData.MARGEM_CIMA )
{
margem_cima = ( Double ) value;
}
else if( fieldName == EtiquetaData.COLUNAS )
{
colunas = ( Integer ) value;
}
else if( fieldName == EtiquetaData.LINHAS )
{
linhas = ( Integer ) value;
}
else if( fieldName == EtiquetaData.CONTINUA )
{
continua = ( String ) value;
}
else if( fieldName == EtiquetaData.ALTURA_FOLHA )
{
altura_folha = ( Double ) value;
}
else if( fieldName == EtiquetaData.LARGURA_FOLHA )
{
largura_folha = ( Double ) value;
}
else if( fieldName == EtiquetaData.MARGEM_VERTICAL_FOLHA )
{
margem_vertical_folha = ( Double ) value;
}
else if( fieldName == EtiquetaData.MARGEM_HORIZONTAL_FOLHA )
{
margem_horizontal_folha = ( Double ) value;
}
else if( fieldName.equals( EtiquetaData.ID ) )
{
id = ( Integer ) value;
}
else if( fieldName.equals( EtiquetaData.DESCRICAO ) )
{
descricao = ( String ) value;
}
else if( fieldName.equals( EtiquetaData.DESCRICAO_PLAIN ) )
{
descricao_plain = ( String ) value;
}
else if( fieldName.equals( EtiquetaData.ALTURA ) )
{
altura = ( Double ) value;
}
else if( fieldName.equals( EtiquetaData.LARGURA ) )
{
largura = ( Double ) value;
}
else if( fieldName.equals( EtiquetaData.MARGEM_ESQUERDA ) )
{
margem_esquerda = ( Double ) value;
}
else if( fieldName.equals( EtiquetaData.MARGEM_CIMA ) )
{
margem_cima = ( Double ) value;
}
else if( fieldName.equals( EtiquetaData.COLUNAS ) )
{
colunas = ( Integer ) value;
}
else if( fieldName.equals( EtiquetaData.LINHAS ) )
{
linhas = ( Integer ) value;
}
else if( fieldName.equals( EtiquetaData.CONTINUA ) )
{
continua = ( String ) value;
}
else if( fieldName.equals( EtiquetaData.ALTURA_FOLHA ) )
{
altura_folha = ( Double ) value;
}
else if( fieldName.equals( EtiquetaData.LARGURA_FOLHA ) )
{
largura_folha = ( Double ) value;
}
else if( fieldName.equals( EtiquetaData.MARGEM_VERTICAL_FOLHA ) )
{
margem_vertical_folha = ( Double ) value;
}
else if( fieldName.equals( EtiquetaData.MARGEM_HORIZONTAL_FOLHA ) )
{
margem_horizontal_folha = ( Double ) value;
}
}
public Class getOuterClass()
{
return EtiquetaData.class;
}
}

@ -0,0 +1,74 @@
/*
* EtiquetaData.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on 27/Fev/2006
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.HashMap;
import com.evolute.utils.jdo.*;
public final class EtiquetaData extends JDOObject
{
public static final String ID = "id";
public static final String DESCRICAO = "descricao";
public static final String DESCRICAO_PLAIN = "descricao_plain";
public static final String ALTURA = "altura";
public static final String LARGURA = "largura";
public static final String MARGEM_ESQUERDA = "margem_esquerda";
public static final String MARGEM_CIMA = "margem_cima";
public static final String COLUNAS = "colunas";
public static final String LINHAS = "linhas";
public static final String CONTINUA = "continua";
public static final String ALTURA_FOLHA = "altura_folha";
public static final String LARGURA_FOLHA = "largura_folha";
public static final String MARGEM_VERTICAL_FOLHA = "margem_vertical_folha";
public static final String MARGEM_HORIZONTAL_FOLHA = "margem_horizontal_folha";
public static final String FIELD_NAMES[] = new String[]{
DESCRICAO, DESCRICAO_PLAIN, ALTURA, LARGURA, MARGEM_ESQUERDA, MARGEM_CIMA, COLUNAS,
LINHAS, CONTINUA, ALTURA_FOLHA, LARGURA_FOLHA, MARGEM_VERTICAL_FOLHA,
MARGEM_HORIZONTAL_FOLHA, };
protected static final String ALL_FIELD_NAMES[] = new String[]{
ID, DESCRICAO, DESCRICAO_PLAIN, ALTURA, LARGURA, MARGEM_ESQUERDA, MARGEM_CIMA,
COLUNAS, LINHAS, CONTINUA, ALTURA_FOLHA, LARGURA_FOLHA, MARGEM_VERTICAL_FOLHA,
MARGEM_HORIZONTAL_FOLHA, };
private HashMap dataHash;
public EtiquetaData()
{
dataHash = new HashMap();
}
protected Object innerGet( String fieldName )
throws Exception
{
return dataHash.get( fieldName );
}
protected void innerSet( String fieldName, Object value )
throws Exception
{
dataHash.put( fieldName, value );
}
public String []getFieldNames()
{
return FIELD_NAMES;
}
protected String []getAllFieldNames()
{
return ALL_FIELD_NAMES;
}
public Class getInnerClass()
{
return Etiqueta.class;
}
}

@ -0,0 +1,25 @@
/*
* EtiquetaID.java
*
* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 27/Fev/2006
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.io.*;
import com.evolute.utils.jdo.jpox.*;
public final class EtiquetaID extends IntegerID
implements Serializable
{
public EtiquetaID()
{
}
public EtiquetaID( String str )
{
super( str );
}
}

@ -0,0 +1,305 @@
/*
* Exame.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on 28/Jan/2005
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.Date;
import com.evolute.utils.jdo.*;
public final class Exame implements JDOInnerObject
{
private Integer id;
private Date data;
private Integer tipo;
private Integer ocasional;
private String outro_tipo;
private Integer resultado;
private String outra_funcao_1;
private String outra_funcao_2;
private String outra_funcao_3;
private String outra_funcao_4;
private Date proximo_exame;
private String outras_recomendacoes;
private Trabalhador trabalhador;
private Medico medico;
private byte[] pdf;
private String inactivo;
public Exame()
{
}
public Object getField( String fieldName )
{
if( fieldName == ExameData.ID )
{
return id;
}
else if( fieldName == ExameData.DATA )
{
return data;
}
else if( fieldName == ExameData.TIPO )
{
return tipo;
}
else if( fieldName == ExameData.OCASIONAL )
{
return ocasional;
}
else if( fieldName == ExameData.OUTRO_TIPO )
{
return outro_tipo;
}
else if( fieldName == ExameData.RESULTADO )
{
return resultado;
}
else if( fieldName == ExameData.OUTRA_FUNCAO_1 )
{
return outra_funcao_1;
}
else if( fieldName == ExameData.OUTRA_FUNCAO_2 )
{
return outra_funcao_2;
}
else if( fieldName == ExameData.OUTRA_FUNCAO_3 )
{
return outra_funcao_3;
}
else if( fieldName == ExameData.OUTRA_FUNCAO_4 )
{
return outra_funcao_4;
}
else if( fieldName == ExameData.PROXIMO_EXAME )
{
return proximo_exame;
}
else if( fieldName == ExameData.OUTRAS_RECOMENDACOES )
{
return outras_recomendacoes;
}
else if( fieldName == ExameData.TRABALHADOR )
{
return trabalhador;
}
else if( fieldName == ExameData.MEDICO )
{
return medico;
}
else if( fieldName == ExameData.PDF )
{
return pdf;
}
else if( fieldName == ExameData.INACTIVO )
{
return inactivo;
}
else if( fieldName.equals( ExameData.ID ) )
{
return id;
}
else if( fieldName.equals( ExameData.DATA ) )
{
return data;
}
else if( fieldName.equals( ExameData.TIPO ) )
{
return tipo;
}
else if( fieldName.equals( ExameData.OCASIONAL ) )
{
return ocasional;
}
else if( fieldName.equals( ExameData.OUTRO_TIPO ) )
{
return outro_tipo;
}
else if( fieldName.equals( ExameData.RESULTADO ) )
{
return resultado;
}
else if( fieldName.equals( ExameData.OUTRA_FUNCAO_1 ) )
{
return outra_funcao_1;
}
else if( fieldName.equals( ExameData.OUTRA_FUNCAO_2 ) )
{
return outra_funcao_2;
}
else if( fieldName.equals( ExameData.OUTRA_FUNCAO_3 ) )
{
return outra_funcao_3;
}
else if( fieldName.equals( ExameData.OUTRA_FUNCAO_4 ) )
{
return outra_funcao_4;
}
else if( fieldName.equals( ExameData.PROXIMO_EXAME ) )
{
return proximo_exame;
}
else if( fieldName.equals( ExameData.OUTRAS_RECOMENDACOES ) )
{
return outras_recomendacoes;
}
else if( fieldName.equals( ExameData.TRABALHADOR ) )
{
return trabalhador;
}
else if( fieldName.equals( ExameData.MEDICO ) )
{
return medico;
}
else if( fieldName.equals( ExameData.PDF ) )
{
return pdf;
}
else if( fieldName.equals( ExameData.INACTIVO ) )
{
return inactivo;
}
return null;
}
public void setField( String fieldName, Object value )
{
if( fieldName == ExameData.ID )
{
id = ( Integer ) value;
}
else if( fieldName == ExameData.DATA )
{
data = ( Date ) value;
}
else if( fieldName == ExameData.TIPO )
{
tipo = ( Integer ) value;
}
else if( fieldName == ExameData.OCASIONAL )
{
ocasional = ( Integer ) value;
}
else if( fieldName == ExameData.OUTRO_TIPO )
{
outro_tipo = ( String ) value;
}
else if( fieldName == ExameData.RESULTADO )
{
resultado = ( Integer ) value;
}
else if( fieldName == ExameData.OUTRA_FUNCAO_1 )
{
outra_funcao_1 = ( String ) value;
}
else if( fieldName == ExameData.OUTRA_FUNCAO_2 )
{
outra_funcao_2 = ( String ) value;
}
else if( fieldName == ExameData.OUTRA_FUNCAO_3 )
{
outra_funcao_3 = ( String ) value;
}
else if( fieldName == ExameData.OUTRA_FUNCAO_4 )
{
outra_funcao_4 = ( String ) value;
}
else if( fieldName == ExameData.PROXIMO_EXAME )
{
proximo_exame = ( Date ) value;
}
else if( fieldName == ExameData.OUTRAS_RECOMENDACOES )
{
outras_recomendacoes = ( String ) value;
}
else if( fieldName == ExameData.TRABALHADOR )
{
trabalhador = ( Trabalhador ) value;
}
else if( fieldName == ExameData.MEDICO )
{
medico = ( Medico ) value;
}
else if( fieldName == ExameData.PDF )
{
pdf = ( byte[] ) value;
}
else if( fieldName == ExameData.INACTIVO )
{
inactivo = ( String ) value;
}
else if( fieldName.equals( ExameData.ID ) )
{
id = ( Integer ) value;
}
else if( fieldName.equals( ExameData.DATA ) )
{
data = ( Date ) value;
}
else if( fieldName.equals( ExameData.TIPO ) )
{
tipo = ( Integer ) value;
}
else if( fieldName.equals( ExameData.OCASIONAL ) )
{
ocasional = ( Integer ) value;
}
else if( fieldName.equals( ExameData.OUTRO_TIPO ) )
{
outro_tipo = ( String ) value;
}
else if( fieldName.equals( ExameData.RESULTADO ) )
{
resultado = ( Integer ) value;
}
else if( fieldName.equals( ExameData.OUTRA_FUNCAO_1 ) )
{
outra_funcao_1 = ( String ) value;
}
else if( fieldName.equals( ExameData.OUTRA_FUNCAO_2 ) )
{
outra_funcao_2 = ( String ) value;
}
else if( fieldName.equals( ExameData.OUTRA_FUNCAO_3 ) )
{
outra_funcao_3 = ( String ) value;
}
else if( fieldName.equals( ExameData.OUTRA_FUNCAO_4 ) )
{
outra_funcao_4 = ( String ) value;
}
else if( fieldName.equals( ExameData.PROXIMO_EXAME ) )
{
proximo_exame = ( Date ) value;
}
else if( fieldName.equals( ExameData.OUTRAS_RECOMENDACOES ) )
{
outras_recomendacoes = ( String ) value;
}
else if( fieldName.equals( ExameData.TRABALHADOR ) )
{
trabalhador = ( Trabalhador ) value;
}
else if( fieldName.equals( ExameData.MEDICO ) )
{
medico = ( Medico ) value;
}
else if( fieldName.equals( ExameData.PDF ) )
{
pdf = ( byte[] ) value;
}
else if( fieldName.equals( ExameData.INACTIVO ) )
{
inactivo = ( String ) value;
}
}
public Class getOuterClass()
{
return ExameData.class;
}
}

@ -0,0 +1,77 @@
/*
* ExameData.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on 28/Jan/2005
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.HashMap;
import com.evolute.utils.jdo.*;
public final class ExameData extends JDOObject
implements DisableDeleteable
{
public static final String ID = "id";
public static final String DATA = "data";
public static final String TIPO = "tipo";
public static final String OCASIONAL = "ocasional";
public static final String OUTRO_TIPO = "outro_tipo";
public static final String RESULTADO = "resultado";
public static final String OUTRA_FUNCAO_1 = "outra_funcao_1";
public static final String OUTRA_FUNCAO_2 = "outra_funcao_2";
public static final String OUTRA_FUNCAO_3 = "outra_funcao_3";
public static final String OUTRA_FUNCAO_4 = "outra_funcao_4";
public static final String PROXIMO_EXAME = "proximo_exame";
public static final String OUTRAS_RECOMENDACOES = "outras_recomendacoes";
public static final String TRABALHADOR = "trabalhador";
public static final String MEDICO = "medico";
public static final String PDF = "pdf";
public static final String INACTIVO = "inactivo";
public static final String FIELD_NAMES[] = 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, MEDICO, PDF, };
protected static final String ALL_FIELD_NAMES[] = new String[]{
ID, DATA, TIPO, OCASIONAL, OUTRO_TIPO, RESULTADO, OUTRA_FUNCAO_1, OUTRA_FUNCAO_2,
OUTRA_FUNCAO_3, OUTRA_FUNCAO_4, PROXIMO_EXAME, OUTRAS_RECOMENDACOES,
TRABALHADOR, MEDICO, PDF, INACTIVO, };
private HashMap dataHash;
public ExameData()
{
dataHash = new HashMap();
}
protected Object innerGet( String fieldName )
throws Exception
{
return dataHash.get( fieldName );
}
protected void innerSet( String fieldName, Object value )
throws Exception
{
dataHash.put( fieldName, value );
}
public String []getFieldNames()
{
return FIELD_NAMES;
}
protected String []getAllFieldNames()
{
return ALL_FIELD_NAMES;
}
public Class getInnerClass()
{
return Exame.class;
}
}

@ -0,0 +1,22 @@
/*
* ExameID.java
*
* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 28/Jan/2005
*
* Use but DON'T TOUCH
*/
package siprp.data;
import com.evolute.utils.jdo.jpox.*;
public final class ExameID extends IntegerID
{
public ExameID()
{
}
public ExameID( String str )
{
super( str );
}
}

@ -0,0 +1,58 @@
/*
* Historico.java
*
* Created on 7 de Dezembro de 2004, 16:50
*/
package siprp.data;
import java.text.*;
import java.util.*;
import com.evolute.utils.jdo.*;
import com.evolute.utils.tables.*;
import siprp.*;
/**
*
* @author fpalma
*/
public abstract class Historico extends JDOObject
implements ColumnizedObject
{
protected static final DateFormat DATE_FORMAT = DateFormat.getDateInstance( DateFormat.SHORT );
public static final String DATA = "data";
public static final String TEXTO = "texto";
/** Creates a new instance of Historico */
public Historico()
{
}
public Object getValue(int col)
{
switch( col )
{
case 0:
Date data = (Date) get( DATA );
String dataStr = DATE_FORMAT.format( data );
return dataStr;
case 1:
String textoStr = (String ) get( TEXTO );
if( textoStr == null )
{
textoStr = "";
}
textoStr = textoStr.trim();
int index = textoStr.indexOf( "\n" );
if( index != -1 )
{
textoStr = textoStr.substring( 0, index );
}
return textoStr;
}
return null;
}
}

@ -0,0 +1,101 @@
/*
* HistoricoEstabelecimento.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on 7/Dez/2004
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.Date;
import com.evolute.utils.jdo.*;
public final class HistoricoEstabelecimento implements JDOInnerObject
{
private Integer id;
private Date data;
private String texto;
private Estabelecimento estabelecimento;
public HistoricoEstabelecimento()
{
}
public Object getField( String fieldName )
{
if( fieldName == HistoricoEstabelecimentoData.ID )
{
return id;
}
else if( fieldName == HistoricoEstabelecimentoData.DATA )
{
return data;
}
else if( fieldName == HistoricoEstabelecimentoData.TEXTO )
{
return texto;
}
else if( fieldName == HistoricoEstabelecimentoData.ESTABELECIMENTO )
{
return estabelecimento;
}
else if( fieldName.equals( HistoricoEstabelecimentoData.ID ) )
{
return id;
}
else if( fieldName.equals( HistoricoEstabelecimentoData.DATA ) )
{
return data;
}
else if( fieldName.equals( HistoricoEstabelecimentoData.TEXTO ) )
{
return texto;
}
else if( fieldName.equals( HistoricoEstabelecimentoData.ESTABELECIMENTO ) )
{
return estabelecimento;
}
return null;
}
public void setField( String fieldName, Object value )
{
if( fieldName == HistoricoEstabelecimentoData.ID )
{
id = ( Integer ) value;
}
else if( fieldName == HistoricoEstabelecimentoData.DATA )
{
data = ( Date ) value;
}
else if( fieldName == HistoricoEstabelecimentoData.TEXTO )
{
texto = ( String ) value;
}
else if( fieldName == HistoricoEstabelecimentoData.ESTABELECIMENTO )
{
estabelecimento = ( Estabelecimento ) value;
}
else if( fieldName.equals( HistoricoEstabelecimentoData.ID ) )
{
id = ( Integer ) value;
}
else if( fieldName.equals( HistoricoEstabelecimentoData.DATA ) )
{
data = ( Date ) value;
}
else if( fieldName.equals( HistoricoEstabelecimentoData.TEXTO ) )
{
texto = ( String ) value;
}
else if( fieldName.equals( HistoricoEstabelecimentoData.ESTABELECIMENTO ) )
{
estabelecimento = ( Estabelecimento ) value;
}
}
public Class getOuterClass()
{
return HistoricoEstabelecimentoData.class;
}
}

@ -0,0 +1,60 @@
/*
* HistoricoEstabelecimentoData.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on 7/Dez/2004
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.HashMap;
import com.evolute.utils.jdo.*;
public final class HistoricoEstabelecimentoData extends Historico
{
public static final String ID = "id";
public static final String DATA = "data";
public static final String TEXTO = "texto";
public static final String ESTABELECIMENTO = "estabelecimento";
public static final String FIELD_NAMES[] = new String[]{
DATA, TEXTO, ESTABELECIMENTO, };
protected static final String ALL_FIELD_NAMES[] = new String[]{
ID, DATA, TEXTO, ESTABELECIMENTO, };
private HashMap dataHash;
public HistoricoEstabelecimentoData()
{
dataHash = new HashMap();
}
protected Object innerGet( String fieldName )
throws Exception
{
return dataHash.get( fieldName );
}
protected void innerSet( String fieldName, Object value )
throws Exception
{
dataHash.put( fieldName, value );
}
public String []getFieldNames()
{
return FIELD_NAMES;
}
protected String []getAllFieldNames()
{
return ALL_FIELD_NAMES;
}
public Class getInnerClass()
{
return HistoricoEstabelecimento.class;
}
}

@ -0,0 +1,22 @@
/*
* HistoricoEstabelecimentoID.java
*
* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 7/Dez/2004
*
* Use but DON'T TOUCH
*/
package siprp.data;
import com.evolute.utils.jdo.jpox.*;
public final class HistoricoEstabelecimentoID extends IntegerID
{
public HistoricoEstabelecimentoID()
{
}
public HistoricoEstabelecimentoID( String str )
{
super( str );
}
}

@ -0,0 +1,345 @@
/*
* Marcacao.java
*
* Created on 21 de Maio de 2004, 16:59
*/
package siprp.data;
import java.text.*;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.jdo.*;
import com.evolute.utils.tables.*;
import siprp.*;
/**
*
* @author fpalma
*/
public abstract class Marcacao extends JDOObject
implements ColumnizedObject
//, JDOOperationHandlerInterface
{
public static final int TIPO_MARCACAO_TRABALHADOR_EXAMES = 0;
public static final int TIPO_MARCACAO_TRABALHADOR_CONSULTA = 1;
public static final int TIPO_MARCACAO_ESTABELECIMENTO = 2;
public static final int TIPO_MARCACAO_EMPRESA = 3;
public static final String DATA = "data";
public static final String REALIZADA = "realizada";
public static final String DATA_EMAIL = "data_email";
public static final String DATA_RELATORIO = "data_relatorio";
public static final String ANTECEDENCIA_AVISO = "antecedencia_aviso";
protected static final DateFormat DATE_FORMAT = DateFormat.getDateInstance( DateFormat.SHORT );
protected static JDOProvider JDO;
public static Marcacao getMarcacao( int tipo )
{
switch( tipo )
{
case TIPO_MARCACAO_TRABALHADOR_EXAMES: case TIPO_MARCACAO_TRABALHADOR_CONSULTA:
return new MarcacaoTrabalhadorData();
case TIPO_MARCACAO_ESTABELECIMENTO:
return new MarcacaoEstabelecimentoData();
case TIPO_MARCACAO_EMPRESA:
return new MarcacaoEmpresaData();
}
return null;
}
public Object getValue( int col )
{
switch( col )
{
case 0:
Date data = (Date) get( DATA );
String dataStr = DATE_FORMAT.format( data );
return dataStr;
case 1:
String realizada = (String) get( REALIZADA );
// if( this instanceof MarcacaoEmpresaData )
// {
// return new Boolean( "y".equals( realizada ) );
// }
// else
// {
realizada = "y".equals( realizada ) ? "Sim" : "N\u00e3o";
return realizada;
// }
case 2:
if( this instanceof MarcacaoEmpresaData )
{
String textoStr = (String ) get( MarcacaoEmpresaData.TEXTO );
if( textoStr == null )
{
textoStr = "";
}
textoStr = textoStr.trim();
int index = textoStr.indexOf( "\n" );
if( index != -1 )
{
textoStr = textoStr.substring( 0, index );
}
return textoStr;
}
else
{
Date dataRelatorio = (Date) get( DATA_RELATORIO );
String dataRelatorioStr = ( dataRelatorio != null ? DATE_FORMAT.format( dataRelatorio ) : "" );
return dataRelatorioStr;
}
default:
return null;
}
}
public static void saveMarcacaoConsultaForTrabalhadorID( Integer trabalhadorID, Date date )
throws Exception
{
if( date != null )
{
date = (Date)date.clone();
}
FichaDataProvider provider = (FichaDataProvider) FichaDataProvider.getProvider();
if( trabalhadorID == null )
{
return;
}
Integer marcacaoID = provider.getMarcacaoIDByTrabalhador( trabalhadorID );
MarcacaoTrabalhadorData marcacao;
if( marcacaoID == null )
{
marcacao = null;
}
else
{
if( JDO == null )
{
JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
}
marcacao = ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, marcacaoID );
}
if( date == null && marcacao != null )
{
marcacao.delete();
}
else if( date != null && marcacao != null )
{
marcacao.set( Marcacao.DATA, date );
marcacao.save();
}
else if( date != null && marcacao == null )
{
marcacao = new MarcacaoTrabalhadorData();
if( JDO == null )
{
JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
}
TrabalhadorData trab = (TrabalhadorData)JDO.load( TrabalhadorData.class, trabalhadorID );
marcacao.set( MarcacaoTrabalhadorData.TRABALHADOR, trab );
marcacao.set( MarcacaoTrabalhadorData.TIPO, new Integer( MarcacaoTrabalhadorData.TIPO_CONSULTA ) );
marcacao.set( Marcacao.DATA, date );
marcacao.set( Marcacao.REALIZADA, "n" );
marcacao.set( MarcacaoTrabalhadorData.ESTADO, new Integer( siprp.medicina.MedicinaDataProvider.ESTADO_POR_REALIZAR ) );
marcacao.set( MarcacaoTrabalhadorData.MOTIVO, new Integer( 2 ) );
marcacao.save();
}
}
//
// public boolean handle( JDOObject object, int operation, int moment )
// throws Exception
// {
// switch( operation )
// {
// case JDOOperationHandlerInterface.OP_SAVE:
// switch( moment )
// {
// case JDOOperationHandlerInterface.MOMENT_BEFORE:
// return preSave( (Marcacao) object );
//
// case JDOOperationHandlerInterface.MOMENT_AFTER:
// return postSave( (Marcacao) object );
// }
// return false;
//
// case JDOOperationHandlerInterface.OP_DELETE:
// switch( moment )
// {
// case JDOOperationHandlerInterface.MOMENT_BEFORE:
// return preDelete( (Marcacao) object );
//
// case JDOOperationHandlerInterface.MOMENT_AFTER:
// return postDelete( (Marcacao) object );
// }
// return false;
// }
// return false;
// }
//
// protected boolean preSave( Marcacao object )
// throws Exception
// {
// return false;
// }
//
// protected boolean postSave( Marcacao object )
// throws Exception
// {
// if( object instanceof MarcacaoEmpresaData )
// {
// AvisoData aviso = (AvisoData) load( AvisoData.class, new Object[]{ get( MarcacaoEmpresaData.ID ), new Integer( AvisoData.TIPO_EMPRESA ) }, new String[]{ AvisoData.EVENTO_ID, AvisoData.TIPO } );
// if( aviso == null )
// {
// aviso = new AvisoData();
// }
// aviso.set( AvisoData.TIPO, new Integer( AvisoData.TIPO_EMPRESA ) );
// EmpresaData empresa = ( EmpresaData ) object.get( MarcacaoEmpresaData.EMPRESA );
// aviso.set( AvisoData.EMPRESA, empresa );
// aviso.set( AvisoData.EVENTO_ID, object.get( MarcacaoEmpresaData.ID ) );
// Date dataEvento = (Date) object.get( DATA );
// aviso.set( AvisoData.DATA_EVENTO, dataEvento );
// aviso.set( AvisoData.DATA_AVISO, dataEvento );
// String descricao = "Tarefa ";
// aviso.set( AvisoData.DESCRICAO, descricao );
// aviso.save();
// }
// else if( object instanceof MarcacaoEstabelecimentoData )
// {
// AvisoData aviso = (AvisoData) load( AvisoData.class, new Object[]{ get( MarcacaoEstabelecimentoData.ID ), new Integer( AvisoData.TIPO_ESTABELECIMENTO ) }, new String[]{ AvisoData.EVENTO_ID, AvisoData.TIPO } );
// if( aviso == null )
// {
// aviso = new AvisoData();
// }
// aviso.set( AvisoData.TIPO, new Integer( AvisoData.TIPO_ESTABELECIMENTO ) );
// EstabelecimentoData estabelecimento = ( EstabelecimentoData ) object.get( MarcacaoEstabelecimentoData.ESTABELECIMENTO );
// aviso.set( AvisoData.ESTABELECIMENTO, estabelecimento );
// EmpresaData empresa = ( EmpresaData )estabelecimento.get( EstabelecimentoData.EMPRESA );
// aviso.set( AvisoData.EMPRESA, empresa );
// aviso.set( AvisoData.EVENTO_ID, object.get( MarcacaoEstabelecimentoData.ID ) );
// Date dataEvento = (Date) object.get( DATA );
// Date dataAviso = new Date( dataEvento.getTime() );
// Calendar cal = Calendar.getInstance();
// cal.setTime( dataAviso );
// cal.add( Calendar.DAY_OF_MONTH, -14 );
// dataAviso = cal.getTime();
// aviso.set( AvisoData.DATA_AVISO, dataAviso );
// aviso.set( AvisoData.DATA_EVENTO, dataEvento );
// String descricao = "Visita ";
// aviso.set( AvisoData.DESCRICAO, descricao );
// cal = Calendar.getInstance();
// cal.setTime( dataEvento );
// cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 0, 0, 0 );
// cal.set( Calendar.MILLISECOND, 0 );
// dataEvento = cal.getTime();
//
// cal = Calendar.getInstance();
// cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 10, 0, 0 );
// cal.set( Calendar.MILLISECOND, 0 );
// Date hoje = cal.getTime();
// if( hoje.before( dataEvento ) )
// {
// aviso.save();
// }
// }
// if( object instanceof MarcacaoTrabalhadorData )
// {
// AvisoData aviso = (AvisoData) load( AvisoData.class, new Object[]{ object.get( MarcacaoTrabalhadorData.ID ), new Integer( AvisoData.TIPO_TRABALHADOR ) }, new String[]{ AvisoData.EVENTO_ID, AvisoData.TIPO } );
// if( aviso == null )
// {
// aviso = new AvisoData();
// }
// aviso.set( AvisoData.TIPO, new Integer( AvisoData.TIPO_TRABALHADOR ) );
// TrabalhadorData trab = ( TrabalhadorData ) object.get( MarcacaoTrabalhadorData.TRABALHADOR );
// aviso.set( AvisoData.TRABALHADOR, trab );
// EstabelecimentoData estabelecimento = ( EstabelecimentoData ) trab.get( TrabalhadorData.ESTABELECIMENTO );
// aviso.set( AvisoData.ESTABELECIMENTO, estabelecimento );
// EmpresaData empresa = ( EmpresaData ) estabelecimento.get( EstabelecimentoData.EMPRESA );
// aviso.set( AvisoData.EMPRESA, empresa );
// aviso.set( AvisoData.EVENTO_ID, object.get( MarcacaoTrabalhadorData.ID ) );
// Date dataEvento = (Date) object.get( DATA );
// Date dataAviso = new Date( dataEvento.getTime() );
// Calendar cal = Calendar.getInstance();
// cal.setTime( dataAviso );
// cal.add( Calendar.DAY_OF_MONTH, -14 );
// dataAviso = cal.getTime();
// aviso.set( AvisoData.DATA_AVISO, dataAviso );
// aviso.set( AvisoData.DATA_EVENTO, dataEvento );
// String descricao = "";
// switch( ( ( Integer ) object.get( MarcacaoTrabalhadorData.TIPO ) ).intValue() )
// {
// case MarcacaoTrabalhadorData.TIPO_EXAMES:
// descricao = "Exames ";
// break;
//
// case MarcacaoTrabalhadorData.TIPO_CONSULTA:
// descricao = "Consulta ";
// break;
// }
// aviso.set( AvisoData.DESCRICAO, descricao );
// cal = Calendar.getInstance();
// cal.setTime( dataEvento );
// cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 0, 0, 0 );
// cal.set( Calendar.MILLISECOND, 0 );
// dataEvento = cal.getTime();
//
// cal = Calendar.getInstance();
// cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 10, 0, 0 );
// cal.set( Calendar.MILLISECOND, 0 );
// Date hoje = cal.getTime();
// if( hoje.before( dataEvento ) )
// {
// aviso.save();
// }
// }
// else
// {
// return false;
// }
// return true;
// }
//
// protected boolean preDelete( Marcacao object )
// throws Exception
// {
// return false;
// }
//
// protected boolean postDelete( Marcacao object )
// throws Exception
// {
// Integer tipo;
// if( object instanceof MarcacaoEmpresaData )
// {
// tipo = new Integer( AvisoData.TIPO_EMPRESA );
// }
// else if( object instanceof MarcacaoEstabelecimentoData )
// {
// tipo = new Integer( AvisoData.TIPO_ESTABELECIMENTO );
// }
// if( object instanceof MarcacaoTrabalhadorData )
// {
// tipo = new Integer( AvisoData.TIPO_TRABALHADOR );
// }
// else
// {
// return false;
// }
// AvisoData aviso = (AvisoData) load( AvisoData.class, new Object[]{ object.get( "id" ), tipo }, new String[]{ AvisoData.EVENTO_ID, AvisoData.TIPO } );
// if( aviso != null )
// {
// aviso.delete();
// }
//
// return true;
// }
}

@ -0,0 +1,118 @@
/*
* MarcacaoEmpresa.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on 7/Dez/2004
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.Date;
import com.evolute.utils.jdo.*;
public final class MarcacaoEmpresa implements JDOInnerObject
{
private Integer id;
private Date data;
private String texto;
private String realizada;
private Empresa empresa;
public MarcacaoEmpresa()
{
}
public Object getField( String fieldName )
{
if( fieldName == MarcacaoEmpresaData.ID )
{
return id;
}
else if( fieldName == MarcacaoEmpresaData.DATA )
{
return data;
}
else if( fieldName == MarcacaoEmpresaData.TEXTO )
{
return texto;
}
else if( fieldName == MarcacaoEmpresaData.REALIZADA )
{
return realizada;
}
else if( fieldName == MarcacaoEmpresaData.EMPRESA )
{
return empresa;
}
else if( fieldName.equals( MarcacaoEmpresaData.ID ) )
{
return id;
}
else if( fieldName.equals( MarcacaoEmpresaData.DATA ) )
{
return data;
}
else if( fieldName.equals( MarcacaoEmpresaData.TEXTO ) )
{
return texto;
}
else if( fieldName.equals( MarcacaoEmpresaData.REALIZADA ) )
{
return realizada;
}
else if( fieldName.equals( MarcacaoEmpresaData.EMPRESA ) )
{
return empresa;
}
return null;
}
public void setField( String fieldName, Object value )
{
if( fieldName == MarcacaoEmpresaData.ID )
{
id = ( Integer ) value;
}
else if( fieldName == MarcacaoEmpresaData.DATA )
{
data = ( Date ) value;
}
else if( fieldName == MarcacaoEmpresaData.TEXTO )
{
texto = ( String ) value;
}
else if( fieldName == MarcacaoEmpresaData.REALIZADA )
{
realizada = ( String ) value;
}
else if( fieldName == MarcacaoEmpresaData.EMPRESA )
{
empresa = ( Empresa ) value;
}
else if( fieldName.equals( MarcacaoEmpresaData.ID ) )
{
id = ( Integer ) value;
}
else if( fieldName.equals( MarcacaoEmpresaData.DATA ) )
{
data = ( Date ) value;
}
else if( fieldName.equals( MarcacaoEmpresaData.TEXTO ) )
{
texto = ( String ) value;
}
else if( fieldName.equals( MarcacaoEmpresaData.REALIZADA ) )
{
realizada = ( String ) value;
}
else if( fieldName.equals( MarcacaoEmpresaData.EMPRESA ) )
{
empresa = ( Empresa ) value;
}
}
public Class getOuterClass()
{
return MarcacaoEmpresaData.class;
}
}

@ -0,0 +1,61 @@
/*
* MarcacaoEmpresaData.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on 7/Dez/2004
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.HashMap;
import com.evolute.utils.jdo.*;
public final class MarcacaoEmpresaData extends Marcacao
{
public static final String ID = "id";
public static final String DATA = "data";
public static final String TEXTO = "texto";
public static final String REALIZADA = "realizada";
public static final String EMPRESA = "empresa";
public static final String FIELD_NAMES[] = new String[]{
DATA, TEXTO, REALIZADA, EMPRESA, };
protected static final String ALL_FIELD_NAMES[] = new String[]{
ID, DATA, TEXTO, REALIZADA, EMPRESA, };
private HashMap dataHash;
public MarcacaoEmpresaData()
{
dataHash = new HashMap();
}
protected Object innerGet( String fieldName )
throws Exception
{
return dataHash.get( fieldName );
}
protected void innerSet( String fieldName, Object value )
throws Exception
{
dataHash.put( fieldName, value );
}
public String []getFieldNames()
{
return FIELD_NAMES;
}
protected String []getAllFieldNames()
{
return ALL_FIELD_NAMES;
}
public Class getInnerClass()
{
return MarcacaoEmpresa.class;
}
}

@ -0,0 +1,22 @@
/*
* MarcacaoEmpresaID.java
*
* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 7/Dez/2004
*
* Use but DON'T TOUCH
*/
package siprp.data;
import com.evolute.utils.jdo.jpox.*;
public final class MarcacaoEmpresaID extends IntegerID
{
public MarcacaoEmpresaID()
{
}
public MarcacaoEmpresaID( String str )
{
super( str );
}
}

@ -0,0 +1,186 @@
/*
* MarcacaoEstabelecimento.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on Feb 1, 2006
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.Date;
import com.evolute.utils.jdo.*;
public final class MarcacaoEstabelecimento implements JDOInnerObject
{
private Integer id;
private Date data;
private String realizada;
private Integer estado;
private Integer tecnico_hst;
private Date data_email;
private Date data_relatorio;
private Estabelecimento estabelecimento;
private String observacoes;
public MarcacaoEstabelecimento()
{
}
public Object getField( String fieldName )
{
if( fieldName == MarcacaoEstabelecimentoData.ID )
{
return id;
}
else if( fieldName == MarcacaoEstabelecimentoData.DATA )
{
return data;
}
else if( fieldName == MarcacaoEstabelecimentoData.REALIZADA )
{
return realizada;
}
else if( fieldName == MarcacaoEstabelecimentoData.ESTADO )
{
return estado;
}
else if( fieldName == MarcacaoEstabelecimentoData.TECNICO_HST )
{
return tecnico_hst;
}
else if( fieldName == MarcacaoEstabelecimentoData.DATA_EMAIL )
{
return data_email;
}
else if( fieldName == MarcacaoEstabelecimentoData.DATA_RELATORIO )
{
return data_relatorio;
}
else if( fieldName == MarcacaoEstabelecimentoData.ESTABELECIMENTO )
{
return estabelecimento;
}
else if( fieldName == MarcacaoEstabelecimentoData.OBSERVACOES )
{
return observacoes;
}
else if( fieldName.equals( MarcacaoEstabelecimentoData.ID ) )
{
return id;
}
else if( fieldName.equals( MarcacaoEstabelecimentoData.DATA ) )
{
return data;
}
else if( fieldName.equals( MarcacaoEstabelecimentoData.REALIZADA ) )
{
return realizada;
}
else if( fieldName.equals( MarcacaoEstabelecimentoData.ESTADO ) )
{
return estado;
}
else if( fieldName.equals( MarcacaoEstabelecimentoData.TECNICO_HST ) )
{
return tecnico_hst;
}
else if( fieldName.equals( MarcacaoEstabelecimentoData.DATA_EMAIL ) )
{
return data_email;
}
else if( fieldName.equals( MarcacaoEstabelecimentoData.DATA_RELATORIO ) )
{
return data_relatorio;
}
else if( fieldName.equals( MarcacaoEstabelecimentoData.ESTABELECIMENTO ) )
{
return estabelecimento;
}
else if( fieldName.equals( MarcacaoEstabelecimentoData.OBSERVACOES ) )
{
return observacoes;
}
return null;
}
public void setField( String fieldName, Object value )
{
if( fieldName == MarcacaoEstabelecimentoData.ID )
{
id = ( Integer ) value;
}
else if( fieldName == MarcacaoEstabelecimentoData.DATA )
{
data = ( Date ) value;
}
else if( fieldName == MarcacaoEstabelecimentoData.REALIZADA )
{
realizada = ( String ) value;
}
else if( fieldName == MarcacaoEstabelecimentoData.ESTADO )
{
estado = ( Integer ) value;
}
else if( fieldName == MarcacaoEstabelecimentoData.TECNICO_HST )
{
tecnico_hst = ( Integer ) value;
}
else if( fieldName == MarcacaoEstabelecimentoData.DATA_EMAIL )
{
data_email = ( Date ) value;
}
else if( fieldName == MarcacaoEstabelecimentoData.DATA_RELATORIO )
{
data_relatorio = ( Date ) value;
}
else if( fieldName == MarcacaoEstabelecimentoData.ESTABELECIMENTO )
{
estabelecimento = ( Estabelecimento ) value;
}
else if( fieldName == MarcacaoEstabelecimentoData.OBSERVACOES )
{
observacoes = ( String ) value;
}
else if( fieldName.equals( MarcacaoEstabelecimentoData.ID ) )
{
id = ( Integer ) value;
}
else if( fieldName.equals( MarcacaoEstabelecimentoData.DATA ) )
{
data = ( Date ) value;
}
else if( fieldName.equals( MarcacaoEstabelecimentoData.REALIZADA ) )
{
realizada = ( String ) value;
}
else if( fieldName.equals( MarcacaoEstabelecimentoData.ESTADO ) )
{
estado = ( Integer ) value;
}
else if( fieldName.equals( MarcacaoEstabelecimentoData.TECNICO_HST ) )
{
tecnico_hst = ( Integer ) value;
}
else if( fieldName.equals( MarcacaoEstabelecimentoData.DATA_EMAIL ) )
{
data_email = ( Date ) value;
}
else if( fieldName.equals( MarcacaoEstabelecimentoData.DATA_RELATORIO ) )
{
data_relatorio = ( Date ) value;
}
else if( fieldName.equals( MarcacaoEstabelecimentoData.ESTABELECIMENTO ) )
{
estabelecimento = ( Estabelecimento ) value;
}
else if( fieldName.equals( MarcacaoEstabelecimentoData.OBSERVACOES ) )
{
observacoes = ( String ) value;
}
}
public Class getOuterClass()
{
return MarcacaoEstabelecimentoData.class;
}
}

@ -0,0 +1,67 @@
/*
* MarcacaoEstabelecimentoData.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on Feb 1, 2006
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.HashMap;
import com.evolute.utils.jdo.*;
public final class MarcacaoEstabelecimentoData extends Marcacao
{
public static final String ID = "id";
public static final String DATA = "data";
public static final String REALIZADA = "realizada";
public static final String ESTADO = "estado";
public static final String TECNICO_HST = "tecnico_hst";
public static final String DATA_EMAIL = "data_email";
public static final String DATA_RELATORIO = "data_relatorio";
public static final String ESTABELECIMENTO = "estabelecimento";
public static final String OBSERVACOES = "observacoes";
public static final String FIELD_NAMES[] = new String[]{
DATA, REALIZADA, ESTADO, TECNICO_HST, DATA_EMAIL, DATA_RELATORIO, ESTABELECIMENTO,
OBSERVACOES, };
protected static final String ALL_FIELD_NAMES[] = new String[]{
ID, DATA, REALIZADA, ESTADO, TECNICO_HST, DATA_EMAIL, DATA_RELATORIO,
ESTABELECIMENTO, OBSERVACOES, };
private HashMap dataHash;
public MarcacaoEstabelecimentoData()
{
dataHash = new HashMap();
}
protected Object innerGet( String fieldName )
throws Exception
{
return dataHash.get( fieldName );
}
protected void innerSet( String fieldName, Object value )
throws Exception
{
dataHash.put( fieldName, value );
}
public String []getFieldNames()
{
return FIELD_NAMES;
}
protected String []getAllFieldNames()
{
return ALL_FIELD_NAMES;
}
public Class getInnerClass()
{
return MarcacaoEstabelecimento.class;
}
}

@ -0,0 +1,25 @@
/*
* MarcacaoEstabelecimentoID.java
*
* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on Feb 1, 2006
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.io.*;
import com.evolute.utils.jdo.jpox.*;
public final class MarcacaoEstabelecimentoID extends IntegerID
implements Serializable
{
public MarcacaoEstabelecimentoID()
{
}
public MarcacaoEstabelecimentoID( String str )
{
super( str );
}
}

@ -0,0 +1,80 @@
/*
* MarcacaoListLoader.java
*
* Created on 27 de Maio de 2004, 16:18
*/
package siprp.data;
import javax.jdo.*;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.jdo.*;
import siprp.*;
/**
*
* @author fpalma
*/
public class MarcacaoListLoader
{
// private static PersistenceManager MANAGER = null;
private JDOProvider JDO;
/** Creates a new instance of MarcacaoListLoader */
public MarcacaoListLoader()
{
JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
}
public Marcacao[] load( int tipo, Integer targetID )
throws Exception
{
Class theClass;
String filterString;
switch( tipo )
{
case Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES: case Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA:
theClass = MarcacaoTrabalhador.class;
filterString = "(trabalhador.id == " + targetID + ") && (tipo == " + tipo + ")";
break;
case Marcacao.TIPO_MARCACAO_ESTABELECIMENTO:
theClass = MarcacaoEstabelecimento.class;
filterString = "estabelecimento.id == " + targetID;
break;
default:
return new Marcacao[ 0 ];
}
// if( MANAGER == null )
// {
// MANAGER = (PersistenceManager) Singleton.getInstance( SingletonConstants.PERSISTENCE_MANAGER );
// }
// Transaction tx = MANAGER.currentTransaction();
Object sessionID = null;
try
{
sessionID = JDO.begin();
Query q = JDO.getManager().newQuery( theClass, filterString );
q.setOrdering( Marcacao.DATA + " descending" );
Collection c = ( Collection )q.execute();
JDOInnerObject innerObjects[] = ( JDOInnerObject [] ) c.toArray( new JDOInnerObject[0] );
JDO.commit( sessionID );
Marcacao marcacoes[] = new Marcacao[ innerObjects.length ];
for( int n = 0; n < marcacoes.length; n++ )
{
marcacoes[ n ] = ( Marcacao ) innerObjects[ n ].getOuterClass().newInstance();
marcacoes[ n ].setInnerObject( innerObjects[ n ] );
}
return marcacoes;
}
catch( RuntimeException ex )
{
JDO.rollback( sessionID );
// Main.reconnectJDO();
throw ex;
}
}
}

@ -0,0 +1,258 @@
/*
* MarcacaoSaveAndDeleteHandler.java
*
* Created on 13 de Outubro de 2004, 18:31
*/
package siprp.data;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.jdo.*;
import siprp.medicina.*;
/**
*
* @author fpalma
*/
public class MarcacaoSaveAndDeleteHandler
implements JDOOperationHandlerInterface
{
public static final MarcacaoSaveAndDeleteHandler INSTANCE = new MarcacaoSaveAndDeleteHandler();
public JDOProvider JDO;
protected MedicinaDataProvider medicinaProvider;
/** Creates a new instance of MarcacaoSaveAndDeleteHandler */
public MarcacaoSaveAndDeleteHandler()
{
JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
}
public boolean handle( JDOObject object, int operation, int moment )
throws Exception
{
if( JDO == null )
{
JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
}
switch( operation )
{
case JDOOperationHandlerInterface.OP_SAVE:
switch( moment )
{
case JDOOperationHandlerInterface.MOMENT_BEFORE:
return preSave( (Marcacao) object );
case JDOOperationHandlerInterface.MOMENT_AFTER:
return postSave( (Marcacao) object );
}
return false;
case JDOOperationHandlerInterface.OP_DELETE:
switch( moment )
{
case JDOOperationHandlerInterface.MOMENT_BEFORE:
return preDelete( (Marcacao) object );
case JDOOperationHandlerInterface.MOMENT_AFTER:
return postDelete( (Marcacao) object );
}
return false;
}
return false;
}
protected boolean preSave( Marcacao object )
throws Exception
{
return false;
}
protected boolean postSave( Marcacao object )
throws Exception
{
if( object instanceof MarcacaoEmpresaData )
{
AvisoData aviso = (AvisoData) JDO.load( AvisoData.class,
new Object[]{ object.get( MarcacaoEmpresaData.ID ), new Integer( AvisoData.TIPO_EMPRESA ) },
new String[]{ AvisoData.EVENTO_ID, AvisoData.TIPO } );
if( aviso == null )
{
aviso = new AvisoData();
}
aviso.set( AvisoData.TIPO, new Integer( AvisoData.TIPO_EMPRESA ) );
EmpresaData empresa = ( EmpresaData ) object.get( MarcacaoEmpresaData.EMPRESA );
aviso.set( AvisoData.EMPRESA, empresa );
aviso.set( AvisoData.EVENTO_ID, object.get( MarcacaoEmpresaData.ID ) );
Date dataEvento = (Date) object.get( Marcacao.DATA );
aviso.set( AvisoData.DATA_EVENTO, dataEvento );
aviso.set( AvisoData.DATA_AVISO, dataEvento );
String descricao = "Tarefa ";
aviso.set( AvisoData.DESCRICAO, descricao );
aviso.save();
empresa.save();
}
else if( object instanceof MarcacaoEstabelecimentoData )
{
AvisoData aviso = (AvisoData) JDO.load( AvisoData.class,
new Object[]{ object.get( MarcacaoEstabelecimentoData.ID ), new Integer( AvisoData.TIPO_ESTABELECIMENTO ) },
new String[]{ AvisoData.EVENTO_ID, AvisoData.TIPO } );
if( aviso == null )
{
aviso = new AvisoData();
}
aviso.set( AvisoData.TIPO, new Integer( AvisoData.TIPO_ESTABELECIMENTO ) );
EstabelecimentoData estabelecimento = ( EstabelecimentoData ) object.get( MarcacaoEstabelecimentoData.ESTABELECIMENTO );
aviso.set( AvisoData.ESTABELECIMENTO, estabelecimento );
EmpresaData empresa = ( EmpresaData )estabelecimento.get( EstabelecimentoData.EMPRESA );
aviso.set( AvisoData.EMPRESA, empresa );
aviso.set( AvisoData.EVENTO_ID, object.get( MarcacaoEstabelecimentoData.ID ) );
Date dataEvento = (Date) object.get( Marcacao.DATA );
Date dataAviso = new Date( dataEvento.getTime() );
Calendar cal = Calendar.getInstance();
cal.setTime( dataAviso );
cal.add( Calendar.DAY_OF_MONTH, -14 );
dataAviso = cal.getTime();
aviso.set( AvisoData.DATA_AVISO, dataAviso );
aviso.set( AvisoData.DATA_EVENTO, dataEvento );
String descricao = "Visita ";
aviso.set( AvisoData.DESCRICAO, descricao );
cal = Calendar.getInstance();
cal.setTime( dataEvento );
cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 0, 0, 0 );
cal.set( Calendar.MILLISECOND, 0 );
dataEvento = cal.getTime();
cal = Calendar.getInstance();
cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 10, 0, 0 );
cal.set( Calendar.MILLISECOND, 0 );
Date hoje = cal.getTime();
if( hoje.before( dataEvento ) )
{
aviso.save();
}
estabelecimento.save();
}
if( object instanceof MarcacaoTrabalhadorData )
{
AvisoData aviso = (AvisoData) JDO.load( AvisoData.class,
new Object[]{ object.get( MarcacaoTrabalhadorData.ID ), new Integer( AvisoData.TIPO_TRABALHADOR ) },
new String[]{ AvisoData.EVENTO_ID, AvisoData.TIPO } );
System.out.println( "AVISO LOADED: " + aviso + " id: " + ( aviso != null ? aviso.get( AvisoData.ID ) : "n/a" )
+ " MT.ID: " + object.get( MarcacaoTrabalhadorData.ID )
+ " AD.TIPO: " + new Integer( AvisoData.TIPO_TRABALHADOR ) );
if( aviso == null )
{
System.out.println( "novo aviso" );
aviso = new AvisoData();
}
aviso.set( AvisoData.TIPO, new Integer( AvisoData.TIPO_TRABALHADOR ) );
TrabalhadorData trab = ( TrabalhadorData ) object.get( MarcacaoTrabalhadorData.TRABALHADOR );
aviso.set( AvisoData.TRABALHADOR, trab );
EstabelecimentoData estabelecimento = ( EstabelecimentoData ) trab.get( TrabalhadorData.ESTABELECIMENTO );
aviso.set( AvisoData.ESTABELECIMENTO, estabelecimento );
EmpresaData empresa = ( EmpresaData ) estabelecimento.get( EstabelecimentoData.EMPRESA );
aviso.set( AvisoData.EMPRESA, empresa );
aviso.set( AvisoData.EVENTO_ID, object.get( MarcacaoTrabalhadorData.ID ) );
Date dataEvento = (Date) object.get( Marcacao.DATA );
Date dataAviso = new Date( dataEvento.getTime() );
Calendar cal = Calendar.getInstance();
cal.setTime( dataAviso );
cal.add( Calendar.DAY_OF_MONTH, -14 );
dataAviso = cal.getTime();
aviso.set( AvisoData.DATA_AVISO, dataAviso );
aviso.set( AvisoData.DATA_EVENTO, dataEvento.clone() );
String descricao = "";
switch( ( ( Integer ) object.get( MarcacaoTrabalhadorData.TIPO ) ).intValue() )
{
case MarcacaoTrabalhadorData.TIPO_EXAMES:
descricao = "Exames";
break;
case MarcacaoTrabalhadorData.TIPO_CONSULTA:
Integer motivo = ( ( Integer ) object.get( MarcacaoTrabalhadorData.MOTIVO ) );
descricao = "Consulta " + ( motivo == null ? "" : ("(" + MedicinaDataProvider.TIPOS_CONSULTAS[ motivo.intValue() ] + ")" ) );
break;
}
aviso.set( AvisoData.DESCRICAO, descricao );
cal = Calendar.getInstance();
cal.setTime( dataEvento );
cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 0, 0, 0 );
cal.set( Calendar.MILLISECOND, 0 );
dataEvento = cal.getTime();
cal = Calendar.getInstance();
cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 10, 0, 0 );
cal.set( Calendar.MILLISECOND, 0 );
Date hoje = cal.getTime();
if( hoje.before( dataEvento ) )
{
if( !hoje.before( dataAviso ) )
{
aviso.set( AvisoData.DATA_AVISO, dataEvento.clone() );
}
aviso.save();
}
trab.save();
}
else
{
return false;
}
return true;
}
protected boolean preDelete( Marcacao object )
throws Exception
{
if( object instanceof MarcacaoTrabalhadorData &&
( ( Integer ) object.get( MarcacaoTrabalhadorData.TIPO ) ).intValue() == MarcacaoTrabalhadorData.TIPO_EXAMES )
{
if( medicinaProvider == null )
{
medicinaProvider = (MedicinaDataProvider)MedicinaDataProvider.getProvider();
}
medicinaProvider.deleteDetalhesRealziadosForMarcacao( ( Integer ) object.get( MarcacaoTrabalhadorData.ID ) );
return true;
}
return false;
}
protected boolean postDelete( Marcacao object )
throws Exception
{
System.out.println( "!delete!" );
Integer tipo;
if( object instanceof MarcacaoEmpresaData )
{
tipo = new Integer( AvisoData.TIPO_EMPRESA );
}
else if( object instanceof MarcacaoEstabelecimentoData )
{
tipo = new Integer( AvisoData.TIPO_ESTABELECIMENTO );
}
if( object instanceof MarcacaoTrabalhadorData )
{
tipo = new Integer( AvisoData.TIPO_TRABALHADOR );
}
else
{
return false;
}
AvisoData aviso = (AvisoData) JDO.load( AvisoData.class,
new Object[]{ object.get( "id" ), tipo },
new String[]{ AvisoData.EVENTO_ID, AvisoData.TIPO } );
if( aviso != null )
{
aviso.delete();
}
return true;
}
}

@ -0,0 +1,203 @@
/*
* MarcacaoTrabalhador.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on Jan 28, 2006
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.Date;
import com.evolute.utils.jdo.*;
public final class MarcacaoTrabalhador implements JDOInnerObject
{
private Integer id;
private Date data;
private String realizada;
private Integer estado;
private Integer motivo;
private Date data_email;
private Date data_relatorio;
private Integer tipo;
private Trabalhador trabalhador;
private String observacoes;
public MarcacaoTrabalhador()
{
}
public Object getField( String fieldName )
{
if( fieldName == MarcacaoTrabalhadorData.ID )
{
return id;
}
else if( fieldName == MarcacaoTrabalhadorData.DATA )
{
return data;
}
else if( fieldName == MarcacaoTrabalhadorData.REALIZADA )
{
return realizada;
}
else if( fieldName == MarcacaoTrabalhadorData.ESTADO )
{
return estado;
}
else if( fieldName == MarcacaoTrabalhadorData.MOTIVO )
{
return motivo;
}
else if( fieldName == MarcacaoTrabalhadorData.DATA_EMAIL )
{
return data_email;
}
else if( fieldName == MarcacaoTrabalhadorData.DATA_RELATORIO )
{
return data_relatorio;
}
else if( fieldName == MarcacaoTrabalhadorData.TIPO )
{
return tipo;
}
else if( fieldName == MarcacaoTrabalhadorData.TRABALHADOR )
{
return trabalhador;
}
else if( fieldName == MarcacaoTrabalhadorData.OBSERVACOES )
{
return observacoes;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.ID ) )
{
return id;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.DATA ) )
{
return data;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.REALIZADA ) )
{
return realizada;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.ESTADO ) )
{
return estado;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.MOTIVO ) )
{
return motivo;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.DATA_EMAIL ) )
{
return data_email;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.DATA_RELATORIO ) )
{
return data_relatorio;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.TIPO ) )
{
return tipo;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.TRABALHADOR ) )
{
return trabalhador;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.OBSERVACOES ) )
{
return observacoes;
}
return null;
}
public void setField( String fieldName, Object value )
{
if( fieldName == MarcacaoTrabalhadorData.ID )
{
id = ( Integer ) value;
}
else if( fieldName == MarcacaoTrabalhadorData.DATA )
{
data = ( Date ) value;
}
else if( fieldName == MarcacaoTrabalhadorData.REALIZADA )
{
realizada = ( String ) value;
}
else if( fieldName == MarcacaoTrabalhadorData.ESTADO )
{
estado = ( Integer ) value;
}
else if( fieldName == MarcacaoTrabalhadorData.MOTIVO )
{
motivo = ( Integer ) value;
}
else if( fieldName == MarcacaoTrabalhadorData.DATA_EMAIL )
{
data_email = ( Date ) value;
}
else if( fieldName == MarcacaoTrabalhadorData.DATA_RELATORIO )
{
data_relatorio = ( Date ) value;
}
else if( fieldName == MarcacaoTrabalhadorData.TIPO )
{
tipo = ( Integer ) value;
}
else if( fieldName == MarcacaoTrabalhadorData.TRABALHADOR )
{
trabalhador = ( Trabalhador ) value;
}
else if( fieldName == MarcacaoTrabalhadorData.OBSERVACOES )
{
observacoes = ( String ) value;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.ID ) )
{
id = ( Integer ) value;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.DATA ) )
{
data = ( Date ) value;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.REALIZADA ) )
{
realizada = ( String ) value;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.ESTADO ) )
{
estado = ( Integer ) value;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.MOTIVO ) )
{
motivo = ( Integer ) value;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.DATA_EMAIL ) )
{
data_email = ( Date ) value;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.DATA_RELATORIO ) )
{
data_relatorio = ( Date ) value;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.TIPO ) )
{
tipo = ( Integer ) value;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.TRABALHADOR ) )
{
trabalhador = ( Trabalhador ) value;
}
else if( fieldName.equals( MarcacaoTrabalhadorData.OBSERVACOES ) )
{
observacoes = ( String ) value;
}
}
public Class getOuterClass()
{
return MarcacaoTrabalhadorData.class;
}
}

@ -0,0 +1,17 @@
/*
* MarcacaoTrabalhadorConstants.java
*
* Created on 11 de Outubro de 2004, 13:18
*/
package siprp.data;
/**
*
* @author fpalma
*/
public interface MarcacaoTrabalhadorConstants
{
public static final int TIPO_EXAMES = 0;
public static final int TIPO_CONSULTA = 1;
}

@ -0,0 +1,69 @@
/*
* MarcacaoTrabalhadorData.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on Jan 28, 2006
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.HashMap;
import com.evolute.utils.jdo.*;
public final class MarcacaoTrabalhadorData extends Marcacao
implements MarcacaoTrabalhadorConstants
{
public static final String ID = "id";
public static final String DATA = "data";
public static final String REALIZADA = "realizada";
public static final String ESTADO = "estado";
public static final String MOTIVO = "motivo";
public static final String DATA_EMAIL = "data_email";
public static final String DATA_RELATORIO = "data_relatorio";
public static final String TIPO = "tipo";
public static final String TRABALHADOR = "trabalhador";
public static final String OBSERVACOES = "observacoes";
public static final String FIELD_NAMES[] = new String[]{
DATA, REALIZADA, ESTADO, MOTIVO, DATA_EMAIL, DATA_RELATORIO, TIPO, TRABALHADOR,
OBSERVACOES, };
protected static final String ALL_FIELD_NAMES[] = new String[]{
ID, DATA, REALIZADA, ESTADO, MOTIVO, DATA_EMAIL, DATA_RELATORIO, TIPO, TRABALHADOR,
OBSERVACOES, };
private HashMap dataHash;
public MarcacaoTrabalhadorData()
{
dataHash = new HashMap();
}
protected Object innerGet( String fieldName )
throws Exception
{
return dataHash.get( fieldName );
}
protected void innerSet( String fieldName, Object value )
throws Exception
{
dataHash.put( fieldName, value );
}
public String []getFieldNames()
{
return FIELD_NAMES;
}
protected String []getAllFieldNames()
{
return ALL_FIELD_NAMES;
}
public Class getInnerClass()
{
return MarcacaoTrabalhador.class;
}
}

@ -0,0 +1,25 @@
/*
* MarcacaoTrabalhadorID.java
*
* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on Jan 28, 2006
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.io.*;
import com.evolute.utils.jdo.jpox.*;
public final class MarcacaoTrabalhadorID extends IntegerID
implements Serializable
{
public MarcacaoTrabalhadorID()
{
}
public MarcacaoTrabalhadorID( String str )
{
super( str );
}
}

@ -0,0 +1,100 @@
/*
* Medico.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on 27/Jan/2005
*
* Use but DON'T TOUCH
*/
package siprp.data;
import com.evolute.utils.jdo.*;
public final class Medico implements JDOInnerObject
{
private Integer id;
private String nome;
private String numero_cedula;
private String inactivo;
public Medico()
{
}
public Object getField( String fieldName )
{
if( fieldName == MedicoData.ID )
{
return id;
}
else if( fieldName == MedicoData.NOME )
{
return nome;
}
else if( fieldName == MedicoData.NUMERO_CEDULA )
{
return numero_cedula;
}
else if( fieldName == MedicoData.INACTIVO )
{
return inactivo;
}
else if( fieldName.equals( MedicoData.ID ) )
{
return id;
}
else if( fieldName.equals( MedicoData.NOME ) )
{
return nome;
}
else if( fieldName.equals( MedicoData.NUMERO_CEDULA ) )
{
return numero_cedula;
}
else if( fieldName.equals( MedicoData.INACTIVO ) )
{
return inactivo;
}
return null;
}
public void setField( String fieldName, Object value )
{
if( fieldName == MedicoData.ID )
{
id = ( Integer ) value;
}
else if( fieldName == MedicoData.NOME )
{
nome = ( String ) value;
}
else if( fieldName == MedicoData.NUMERO_CEDULA )
{
numero_cedula = ( String ) value;
}
else if( fieldName == MedicoData.INACTIVO )
{
inactivo = ( String ) value;
}
else if( fieldName.equals( MedicoData.ID ) )
{
id = ( Integer ) value;
}
else if( fieldName.equals( MedicoData.NOME ) )
{
nome = ( String ) value;
}
else if( fieldName.equals( MedicoData.NUMERO_CEDULA ) )
{
numero_cedula = ( String ) value;
}
else if( fieldName.equals( MedicoData.INACTIVO ) )
{
inactivo = ( String ) value;
}
}
public Class getOuterClass()
{
return MedicoData.class;
}
}

@ -0,0 +1,61 @@
/*
* MedicoData.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on 27/Jan/2005
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.HashMap;
import com.evolute.utils.jdo.*;
public final class MedicoData extends JDOObject
implements DisableDeleteable
{
public static final String ID = "id";
public static final String NOME = "nome";
public static final String NUMERO_CEDULA = "numero_cedula";
public static final String INACTIVO = "inactivo";
public static final String FIELD_NAMES[] = new String[]{
NOME, NUMERO_CEDULA, };
protected static final String ALL_FIELD_NAMES[] = new String[]{
ID, NOME, NUMERO_CEDULA, INACTIVO, };
private HashMap dataHash;
public MedicoData()
{
dataHash = new HashMap();
}
protected Object innerGet( String fieldName )
throws Exception
{
return dataHash.get( fieldName );
}
protected void innerSet( String fieldName, Object value )
throws Exception
{
dataHash.put( fieldName, value );
}
public String []getFieldNames()
{
return FIELD_NAMES;
}
protected String []getAllFieldNames()
{
return ALL_FIELD_NAMES;
}
public Class getInnerClass()
{
return Medico.class;
}
}

@ -0,0 +1,22 @@
/*
* MedicoID.java
*
* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 27/Jan/2005
*
* Use but DON'T TOUCH
*/
package siprp.data;
import com.evolute.utils.jdo.jpox.*;
public final class MedicoID extends IntegerID
{
public MedicoID()
{
}
public MedicoID( String str )
{
super( str );
}
}

@ -0,0 +1,180 @@
/*
* SearchExecuterFactory.java
*
* Created on 24 de Maio de 2004, 19:30
*/
package siprp.data;
import com.evolute.utils.*;
import com.evolute.utils.arrays.*;
import com.evolute.utils.db.*;
import com.evolute.utils.sql.*;
import com.evolute.utils.ui.search.*;
/**
*
* @author fpalma
*/
public class SearchExecuterFactory
{
private static SearchExecuter empresaExecuter;
private static SearchExecuter estabelecimentoExecuter;
private static SearchExecuter trabalhadorExecuter;
/** Creates a new instance of SearchExecuterFactory */
private SearchExecuterFactory()
{
}
public static SearchExecuter getSearchExecuter( Class objectClass )
{
if( objectClass.equals( EmpresaData.class ) )
{
System.out.println( "Empresa" );
return getEmpresaSearchExecuter();
}
else if( objectClass == EstabelecimentoData.class )
{
return getEstabelecimentoSearchExecuter();
}
else if( objectClass == TrabalhadorData.class )
{
return getTrabalhadorSearchExecuter();
}
return null;
}
private static SearchExecuter getEmpresaSearchExecuter()
{
if( empresaExecuter == null )
{
empresaExecuter = new SearchExecuter(){
private final DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ );
public Virtual2DArray search( String pattern )
throws Exception
{
Executer executer = dbm.getSharedExecuter( this );
Select select = new Select( new String[]{ "empresas" },
new String[]{ EmpresaData.ID, EmpresaData.DESIGNACAO_SOCIAL, EmpresaData.DESIGNACAO_SOCIAL_PLAIN },
new Field( EmpresaData.DESIGNACAO_SOCIAL_PLAIN ).isLike( "%" + com.evolute.utils.strings.StringPlainer.convertString( pattern, false, false ) + "%" ).and(
new Field( EmpresaData.INACTIVO ).isDifferent( "y" ) ),
new String[]{ EmpresaData.DESIGNACAO_SOCIAL_PLAIN }, null );
System.out.println( "SELECT : " + select );
return executer.executeQuery( select );
}
public boolean hasDetails()
{
return false;
}
public void showDetails( SearchDialog dialog, Object o )
throws Exception
{
}
public String getSearchTitle()
{
return "Procurar Empresa";
}
public String[] getColumnNames()
{
return new String[]{ "Designa\u00e7\u00e3o Social" };
}
};
}
return empresaExecuter;
}
private static SearchExecuter getEstabelecimentoSearchExecuter()
{
if( estabelecimentoExecuter == null )
{
estabelecimentoExecuter = new SearchExecuter(){
private final DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ );
public Virtual2DArray search( String pattern )
throws Exception
{
Executer executer = dbm.getSharedExecuter( this );
Select select = new Select( new String[]{ "estabelecimentos" },
new String[]{ EstabelecimentoData.ID, EstabelecimentoData.NOME, EstabelecimentoData.NOME_PLAIN },
new Field( EstabelecimentoData.NOME_PLAIN ).isLike( "%" + com.evolute.utils.strings.StringPlainer.convertString( pattern, false, false ) + "%" ),
new String[]{ EstabelecimentoData.NOME_PLAIN }, null );
return executer.executeQuery( select );
}
public boolean hasDetails()
{
return false;
}
public void showDetails( SearchDialog dialog, Object o )
throws Exception
{
}
public String getSearchTitle()
{
return "Procurar Estabelecimento";
}
public String[] getColumnNames()
{
return new String[]{ "Designa\u00e7\u00e3o" };
}
};
}
return estabelecimentoExecuter;
}
private static SearchExecuter getTrabalhadorSearchExecuter()
{
if( trabalhadorExecuter == null )
{
trabalhadorExecuter = new SearchExecuter(){
private final DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ );
public Virtual2DArray search( String pattern )
throws Exception
{
Executer executer = dbm.getSharedExecuter( this );
Select select = new Select( new String[]{ "trabalhadores" },
new String[]{ TrabalhadorData.ID, TrabalhadorData.NOME, TrabalhadorData.NOME_PLAIN },
new Field( TrabalhadorData.NOME_PLAIN ).isLike( "%" + com.evolute.utils.strings.StringPlainer.convertString( pattern, false, false ) + "%" ),
new String[]{ TrabalhadorData.NOME_PLAIN }, null );
return executer.executeQuery( select );
}
public boolean hasDetails()
{
return false;
}
public void showDetails( SearchDialog dialog, Object o )
throws Exception
{
}
public String getSearchTitle()
{
return "Procurar Trablhador";
}
public String[] getColumnNames()
{
return new String[]{ "Nome" };
}
};
}
return trabalhadorExecuter;
}
}

@ -0,0 +1,134 @@
/*
* TecnicoHST.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on Feb 1, 2006
*
* Use but DON'T TOUCH
*/
package siprp.data;
import com.evolute.utils.jdo.*;
public final class TecnicoHST implements JDOInnerObject
{
private Integer id;
private String nome;
private String nome_plain;
private String iniciais;
private Integer identificador;
private String inactivo;
public TecnicoHST()
{
}
public Object getField( String fieldName )
{
if( fieldName == TecnicoHSTData.ID )
{
return id;
}
else if( fieldName == TecnicoHSTData.NOME )
{
return nome;
}
else if( fieldName == TecnicoHSTData.NOME_PLAIN )
{
return nome_plain;
}
else if( fieldName == TecnicoHSTData.INICIAIS )
{
return iniciais;
}
else if( fieldName == TecnicoHSTData.IDENTIFICADOR )
{
return identificador;
}
else if( fieldName == TecnicoHSTData.INACTIVO )
{
return inactivo;
}
else if( fieldName.equals( TecnicoHSTData.ID ) )
{
return id;
}
else if( fieldName.equals( TecnicoHSTData.NOME ) )
{
return nome;
}
else if( fieldName.equals( TecnicoHSTData.NOME_PLAIN ) )
{
return nome_plain;
}
else if( fieldName.equals( TecnicoHSTData.INICIAIS ) )
{
return iniciais;
}
else if( fieldName.equals( TecnicoHSTData.IDENTIFICADOR ) )
{
return identificador;
}
else if( fieldName.equals( TecnicoHSTData.INACTIVO ) )
{
return inactivo;
}
return null;
}
public void setField( String fieldName, Object value )
{
if( fieldName == TecnicoHSTData.ID )
{
id = ( Integer ) value;
}
else if( fieldName == TecnicoHSTData.NOME )
{
nome = ( String ) value;
}
else if( fieldName == TecnicoHSTData.NOME_PLAIN )
{
nome_plain = ( String ) value;
}
else if( fieldName == TecnicoHSTData.INICIAIS )
{
iniciais = ( String ) value;
}
else if( fieldName == TecnicoHSTData.IDENTIFICADOR )
{
identificador = ( Integer ) value;
}
else if( fieldName == TecnicoHSTData.INACTIVO )
{
inactivo = ( String ) value;
}
else if( fieldName.equals( TecnicoHSTData.ID ) )
{
id = ( Integer ) value;
}
else if( fieldName.equals( TecnicoHSTData.NOME ) )
{
nome = ( String ) value;
}
else if( fieldName.equals( TecnicoHSTData.NOME_PLAIN ) )
{
nome_plain = ( String ) value;
}
else if( fieldName.equals( TecnicoHSTData.INICIAIS ) )
{
iniciais = ( String ) value;
}
else if( fieldName.equals( TecnicoHSTData.IDENTIFICADOR ) )
{
identificador = ( Integer ) value;
}
else if( fieldName.equals( TecnicoHSTData.INACTIVO ) )
{
inactivo = ( String ) value;
}
}
public Class getOuterClass()
{
return TecnicoHSTData.class;
}
}

@ -0,0 +1,63 @@
/*
* TecnicoHSTData.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on Feb 1, 2006
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.HashMap;
import com.evolute.utils.jdo.*;
public final class TecnicoHSTData extends JDOObject
implements DisableDeleteable
{
public static final String ID = "id";
public static final String NOME = "nome";
public static final String NOME_PLAIN = "nome_plain";
public static final String INICIAIS = "iniciais";
public static final String IDENTIFICADOR = "identificador";
public static final String INACTIVO = "inactivo";
public static final String FIELD_NAMES[] = new String[]{
NOME, NOME_PLAIN, INICIAIS, IDENTIFICADOR, };
protected static final String ALL_FIELD_NAMES[] = new String[]{
ID, NOME, NOME_PLAIN, INICIAIS, IDENTIFICADOR, INACTIVO, };
private HashMap dataHash;
public TecnicoHSTData()
{
dataHash = new HashMap();
}
protected Object innerGet( String fieldName )
throws Exception
{
return dataHash.get( fieldName );
}
protected void innerSet( String fieldName, Object value )
throws Exception
{
dataHash.put( fieldName, value );
}
public String []getFieldNames()
{
return FIELD_NAMES;
}
protected String []getAllFieldNames()
{
return ALL_FIELD_NAMES;
}
public Class getInnerClass()
{
return TecnicoHST.class;
}
}

@ -0,0 +1,25 @@
/*
* TecnicoHSTID.java
*
* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on Feb 1, 2006
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.io.*;
import com.evolute.utils.jdo.jpox.*;
public final class TecnicoHSTID extends IntegerID
implements Serializable
{
public TecnicoHSTID()
{
}
public TecnicoHSTID( String str )
{
super( str );
}
}

@ -0,0 +1,356 @@
/*
* Trabalhador.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on 24/Nov/2005
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.Date;
import com.evolute.utils.jdo.*;
public final class Trabalhador implements JDOInnerObject
{
private Integer id;
private String nome;
private String nome_plain;
private String sexo;
private Date data_nascimento;
private String nacionalidade;
private String numero_mecanografico;
private Date data_admissao;
private String categoria;
private String local_trabalho;
private String funcao_proposta;
private Date data_admissao_funcao;
private String observacoes;
private Estabelecimento estabelecimento;
private Date data_demissao;
private String observacoes_gestao;
private Integer perfil;
private String inactivo;
private Date actualizacao;
public Trabalhador()
{
}
public Object getField( String fieldName )
{
if( fieldName == TrabalhadorData.ID )
{
return id;
}
else if( fieldName == TrabalhadorData.NOME )
{
return nome;
}
else if( fieldName == TrabalhadorData.NOME_PLAIN )
{
return nome_plain;
}
else if( fieldName == TrabalhadorData.SEXO )
{
return sexo;
}
else if( fieldName == TrabalhadorData.DATA_NASCIMENTO )
{
return data_nascimento;
}
else if( fieldName == TrabalhadorData.NACIONALIDADE )
{
return nacionalidade;
}
else if( fieldName == TrabalhadorData.NUMERO_MECANOGRAFICO )
{
return numero_mecanografico;
}
else if( fieldName == TrabalhadorData.DATA_ADMISSAO )
{
return data_admissao;
}
else if( fieldName == TrabalhadorData.CATEGORIA )
{
return categoria;
}
else if( fieldName == TrabalhadorData.LOCAL_TRABALHO )
{
return local_trabalho;
}
else if( fieldName == TrabalhadorData.FUNCAO_PROPOSTA )
{
return funcao_proposta;
}
else if( fieldName == TrabalhadorData.DATA_ADMISSAO_FUNCAO )
{
return data_admissao_funcao;
}
else if( fieldName == TrabalhadorData.OBSERVACOES )
{
return observacoes;
}
else if( fieldName == TrabalhadorData.ESTABELECIMENTO )
{
return estabelecimento;
}
else if( fieldName == TrabalhadorData.DATA_DEMISSAO )
{
return data_demissao;
}
else if( fieldName == TrabalhadorData.OBSERVACOES_GESTAO )
{
return observacoes_gestao;
}
else if( fieldName == TrabalhadorData.PERFIL )
{
return perfil;
}
else if( fieldName == TrabalhadorData.INACTIVO )
{
return inactivo;
}
else if( fieldName == TrabalhadorData.ACTUALIZACAO )
{
return actualizacao;
}
else if( fieldName.equals( TrabalhadorData.ID ) )
{
return id;
}
else if( fieldName.equals( TrabalhadorData.NOME ) )
{
return nome;
}
else if( fieldName.equals( TrabalhadorData.NOME_PLAIN ) )
{
return nome_plain;
}
else if( fieldName.equals( TrabalhadorData.SEXO ) )
{
return sexo;
}
else if( fieldName.equals( TrabalhadorData.DATA_NASCIMENTO ) )
{
return data_nascimento;
}
else if( fieldName.equals( TrabalhadorData.NACIONALIDADE ) )
{
return nacionalidade;
}
else if( fieldName.equals( TrabalhadorData.NUMERO_MECANOGRAFICO ) )
{
return numero_mecanografico;
}
else if( fieldName.equals( TrabalhadorData.DATA_ADMISSAO ) )
{
return data_admissao;
}
else if( fieldName.equals( TrabalhadorData.CATEGORIA ) )
{
return categoria;
}
else if( fieldName.equals( TrabalhadorData.LOCAL_TRABALHO ) )
{
return local_trabalho;
}
else if( fieldName.equals( TrabalhadorData.FUNCAO_PROPOSTA ) )
{
return funcao_proposta;
}
else if( fieldName.equals( TrabalhadorData.DATA_ADMISSAO_FUNCAO ) )
{
return data_admissao_funcao;
}
else if( fieldName.equals( TrabalhadorData.OBSERVACOES ) )
{
return observacoes;
}
else if( fieldName.equals( TrabalhadorData.ESTABELECIMENTO ) )
{
return estabelecimento;
}
else if( fieldName.equals( TrabalhadorData.DATA_DEMISSAO ) )
{
return data_demissao;
}
else if( fieldName.equals( TrabalhadorData.OBSERVACOES_GESTAO ) )
{
return observacoes_gestao;
}
else if( fieldName.equals( TrabalhadorData.PERFIL ) )
{
return perfil;
}
else if( fieldName.equals( TrabalhadorData.INACTIVO ) )
{
return inactivo;
}
else if( fieldName.equals( TrabalhadorData.ACTUALIZACAO ) )
{
return actualizacao;
}
return null;
}
public void setField( String fieldName, Object value )
{
if( fieldName == TrabalhadorData.ID )
{
id = ( Integer ) value;
}
else if( fieldName == TrabalhadorData.NOME )
{
nome = ( String ) value;
}
else if( fieldName == TrabalhadorData.NOME_PLAIN )
{
nome_plain = ( String ) value;
}
else if( fieldName == TrabalhadorData.SEXO )
{
sexo = ( String ) value;
}
else if( fieldName == TrabalhadorData.DATA_NASCIMENTO )
{
data_nascimento = ( Date ) value;
}
else if( fieldName == TrabalhadorData.NACIONALIDADE )
{
nacionalidade = ( String ) value;
}
else if( fieldName == TrabalhadorData.NUMERO_MECANOGRAFICO )
{
numero_mecanografico = ( String ) value;
}
else if( fieldName == TrabalhadorData.DATA_ADMISSAO )
{
data_admissao = ( Date ) value;
}
else if( fieldName == TrabalhadorData.CATEGORIA )
{
categoria = ( String ) value;
}
else if( fieldName == TrabalhadorData.LOCAL_TRABALHO )
{
local_trabalho = ( String ) value;
}
else if( fieldName == TrabalhadorData.FUNCAO_PROPOSTA )
{
funcao_proposta = ( String ) value;
}
else if( fieldName == TrabalhadorData.DATA_ADMISSAO_FUNCAO )
{
data_admissao_funcao = ( Date ) value;
}
else if( fieldName == TrabalhadorData.OBSERVACOES )
{
observacoes = ( String ) value;
}
else if( fieldName == TrabalhadorData.ESTABELECIMENTO )
{
estabelecimento = ( Estabelecimento ) value;
}
else if( fieldName == TrabalhadorData.DATA_DEMISSAO )
{
data_demissao = ( Date ) value;
}
else if( fieldName == TrabalhadorData.OBSERVACOES_GESTAO )
{
observacoes_gestao = ( String ) value;
}
else if( fieldName == TrabalhadorData.PERFIL )
{
perfil = ( Integer ) value;
}
else if( fieldName == TrabalhadorData.INACTIVO )
{
inactivo = ( String ) value;
}
else if( fieldName == TrabalhadorData.ACTUALIZACAO )
{
actualizacao = ( Date ) value;
}
else if( fieldName.equals( TrabalhadorData.ID ) )
{
id = ( Integer ) value;
}
else if( fieldName.equals( TrabalhadorData.NOME ) )
{
nome = ( String ) value;
}
else if( fieldName.equals( TrabalhadorData.NOME_PLAIN ) )
{
nome_plain = ( String ) value;
}
else if( fieldName.equals( TrabalhadorData.SEXO ) )
{
sexo = ( String ) value;
}
else if( fieldName.equals( TrabalhadorData.DATA_NASCIMENTO ) )
{
data_nascimento = ( Date ) value;
}
else if( fieldName.equals( TrabalhadorData.NACIONALIDADE ) )
{
nacionalidade = ( String ) value;
}
else if( fieldName.equals( TrabalhadorData.NUMERO_MECANOGRAFICO ) )
{
numero_mecanografico = ( String ) value;
}
else if( fieldName.equals( TrabalhadorData.DATA_ADMISSAO ) )
{
data_admissao = ( Date ) value;
}
else if( fieldName.equals( TrabalhadorData.CATEGORIA ) )
{
categoria = ( String ) value;
}
else if( fieldName.equals( TrabalhadorData.LOCAL_TRABALHO ) )
{
local_trabalho = ( String ) value;
}
else if( fieldName.equals( TrabalhadorData.FUNCAO_PROPOSTA ) )
{
funcao_proposta = ( String ) value;
}
else if( fieldName.equals( TrabalhadorData.DATA_ADMISSAO_FUNCAO ) )
{
data_admissao_funcao = ( Date ) value;
}
else if( fieldName.equals( TrabalhadorData.OBSERVACOES ) )
{
observacoes = ( String ) value;
}
else if( fieldName.equals( TrabalhadorData.ESTABELECIMENTO ) )
{
estabelecimento = ( Estabelecimento ) value;
}
else if( fieldName.equals( TrabalhadorData.DATA_DEMISSAO ) )
{
data_demissao = ( Date ) value;
}
else if( fieldName.equals( TrabalhadorData.OBSERVACOES_GESTAO ) )
{
observacoes_gestao = ( String ) value;
}
else if( fieldName.equals( TrabalhadorData.PERFIL ) )
{
perfil = ( Integer ) value;
}
else if( fieldName.equals( TrabalhadorData.INACTIVO ) )
{
inactivo = ( String ) value;
}
else if( fieldName.equals( TrabalhadorData.ACTUALIZACAO ) )
{
actualizacao = ( Date ) value;
}
}
public Class getOuterClass()
{
return TrabalhadorData.class;
}
}

@ -0,0 +1,82 @@
/*
* TrabalhadorData.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator on 24/Nov/2005
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.util.HashMap;
import com.evolute.utils.jdo.*;
public final class TrabalhadorData extends JDOObject
implements DisableDeleteable, ActualizacaoSaveable
{
public static final String ID = "id";
public static final String NOME = "nome";
public static final String NOME_PLAIN = "nome_plain";
public static final String SEXO = "sexo";
public static final String DATA_NASCIMENTO = "data_nascimento";
public static final String NACIONALIDADE = "nacionalidade";
public static final String NUMERO_MECANOGRAFICO = "numero_mecanografico";
public static final String DATA_ADMISSAO = "data_admissao";
public static final String CATEGORIA = "categoria";
public static final String LOCAL_TRABALHO = "local_trabalho";
public static final String FUNCAO_PROPOSTA = "funcao_proposta";
public static final String DATA_ADMISSAO_FUNCAO = "data_admissao_funcao";
public static final String OBSERVACOES = "observacoes";
public static final String ESTABELECIMENTO = "estabelecimento";
public static final String DATA_DEMISSAO = "data_demissao";
public static final String OBSERVACOES_GESTAO = "observacoes_gestao";
public static final String PERFIL = "perfil";
public static final String INACTIVO = "inactivo";
public static final String ACTUALIZACAO = "actualizacao";
public static final String FIELD_NAMES[] = new String[]{
NOME, NOME_PLAIN, SEXO, DATA_NASCIMENTO, NACIONALIDADE, NUMERO_MECANOGRAFICO,
DATA_ADMISSAO, CATEGORIA, LOCAL_TRABALHO, FUNCAO_PROPOSTA,
DATA_ADMISSAO_FUNCAO, OBSERVACOES, ESTABELECIMENTO, DATA_DEMISSAO,
OBSERVACOES_GESTAO, PERFIL, };
protected static final String ALL_FIELD_NAMES[] = new String[]{
ID, NOME, NOME_PLAIN, SEXO, DATA_NASCIMENTO, NACIONALIDADE, NUMERO_MECANOGRAFICO,
DATA_ADMISSAO, CATEGORIA, LOCAL_TRABALHO, FUNCAO_PROPOSTA,
DATA_ADMISSAO_FUNCAO, OBSERVACOES, ESTABELECIMENTO, DATA_DEMISSAO,
OBSERVACOES_GESTAO, PERFIL, INACTIVO, ACTUALIZACAO, };
private HashMap dataHash;
public TrabalhadorData()
{
dataHash = new HashMap();
}
protected Object innerGet( String fieldName )
throws Exception
{
return dataHash.get( fieldName );
}
protected void innerSet( String fieldName, Object value )
throws Exception
{
dataHash.put( fieldName, value );
}
public String []getFieldNames()
{
return FIELD_NAMES;
}
protected String []getAllFieldNames()
{
return ALL_FIELD_NAMES;
}
public Class getInnerClass()
{
return Trabalhador.class;
}
}

@ -0,0 +1,25 @@
/*
* TrabalhadorID.java
*
* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 24/Nov/2005
*
* Use but DON'T TOUCH
*/
package siprp.data;
import java.io.*;
import com.evolute.utils.jdo.jpox.*;
public final class TrabalhadorID extends IntegerID
implements Serializable
{
public TrabalhadorID()
{
}
public TrabalhadorID( String str )
{
super( str );
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,777 @@
/*
* EstatisticaDataProvider.java
*
* Created on 16 de Dezembro de 2004, 12:50
*/
package siprp.estatistica;
import java.text.*;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.arrays.*;
import com.evolute.utils.data.*;
import com.evolute.utils.db.*;
import com.evolute.utils.db.keyretrievers.*;
import com.evolute.utils.metadb.*;
import com.evolute.utils.sql.*;
import com.evolute.utils.sql.expression.*;
import siprp.data.*;
/**
*
* @author fpalma
*/
public class EstatisticaDataProvider extends MetaProvider
{
private static final Object LOCK = new Object();
private static EstatisticaDataProvider instance = null;
private final Executer executer;
public static final DateFormat DF = DateFormat.getDateInstance( DateFormat.SHORT );
/** Creates a new instance of EstatisticaDataProvider */
public EstatisticaDataProvider()
throws Exception
{
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ );
executer = dbm.getSharedExecuter( this );
}
public static MetaProvider getProvider()
throws Exception
{
synchronized( LOCK )
{
if( instance == null )
{
instance = new EstatisticaDataProvider();
}
}
return instance;
}
public String[][] getMarcacoesPeriodo( Date dataInicio, Date dataFim )
throws Exception
{
String [][]result = null;
Select select =
new Select( new String[]{ "marcacoes_trabalhador" },
new String[]{ MarcacaoTrabalhadorData.DATA,
"trabalhador_id",
MarcacaoTrabalhadorData.REALIZADA,
MarcacaoTrabalhadorData.TIPO },
new Field( "data" ).isGreaterOrEqual( dataInicio ).and(
new Field( "data" ).isLessOrEqual( dataFim ) ),
new String[]{ "data" }, null );
Virtual2DArray array = executer.executeQuery( select );
result = new String[ array.columnLength() ][ 5 ];
for( int n = 0; n < result.length; n++ )
{
Date data = ( Date ) array.get( n, 0 );
int trabalhadorID = ( ( Number ) array.get( n, 1 ) ).intValue();
boolean realizada = "y".equals( array.get( n, 2 ) );
int tipo = ( ( Number ) array.get( n, 3 ) ).intValue();
String nomeEstabEmp[] = getNomeEstabelecimentoEmpresaForTrabalhador( trabalhadorID );
result[ n ][ 0 ] = nomeEstabEmp[ 2 ];
result[ n ][ 1 ] = nomeEstabEmp[ 0 ];
result[ n ][ 2 ] = nomeEstabEmp[ 1 ];
result[ n ][ 3 ] = DF.format( data );
result[ n ][ 4 ] = ( tipo == Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ? "(Exame)" : "(Consulta)" );
}
return result;
}
public String[] getNomeEstabelecimentoEmpresaForTrabalhador( int trabalhadorID )
throws Exception
{
String data[] = new String[ 3 ];
Select select =
new Select( new String[]{ "trabalhadores", "estabelecimentos", "empresas"},
new String[]{ "trabalhadores.nome", "estabelecimentos.nome", "empresas.designacao_social" },
new Field( "trabalhadores.id" ).isEqual( new Integer( trabalhadorID ) ).and(
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) ) );
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() == 1 )
{
data[ 0 ] = ( String ) array.get( 0, 0 );
data[ 1 ] = ( String ) array.get( 0, 1 );
data[ 2 ] = ( String ) array.get( 0, 2 );
}
return data;
}
public int countExamesPeriodo( Date dataInicio, Date dataFim )
throws Exception
{
Select select =
new Select( new String[]{ "marcacoes_trabalhador" },
new String[]{ "count(*)" },
new Field( "data" ).isGreaterOrEqual( dataInicio ).and(
new Field( "data" ).isLessOrEqual( dataFim ) ).and(
new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ) );
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
{
return 0;
}
return ( ( Number ) array.get( 0, 0 ) ).intValue();
}
public int countConsultasPeriodo( Date dataInicio, Date dataFim )
throws Exception
{
Select select =
new Select( new String[]{ "marcacoes_trabalhador" },
new String[]{ "count(*)" },
new Field( "data" ).isGreaterOrEqual( dataInicio ).and(
new Field( "data" ).isLessOrEqual( dataFim ) ).and(
new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ) );
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
{
return 0;
}
return ( ( Number ) array.get( 0, 0 ) ).intValue();
}
public int countExamesPeriodoForEmpresa( Date dataInicio, Date dataFim, Integer empresaID )
throws Exception
{
Select select =
new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos" },
new String[]{ "count(*)" },
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
new Field( "estabelecimentos.empresa_id" ).isEqual( empresaID ) ).and(
new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
new Field( "data" ).isLessOrEqual( dataFim ) ).and(
new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ) );
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
{
return 0;
}
return ( ( Number ) array.get( 0, 0 ) ).intValue();
}
public int countConsultasPeriodoForEmpresa( Date dataInicio, Date dataFim, Integer empresaID )
throws Exception
{
Select select =
new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos" },
new String[]{ "count(*)" },
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
new Field( "estabelecimentos.empresa_id" ).isEqual( empresaID ) ).and(
new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
new Field( "data" ).isLessOrEqual( dataFim ) ).and(
new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ) );
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
{
return 0;
}
return ( ( Number ) array.get( 0, 0 ) ).intValue();
}
public String[][] getMarcacoesPeriodoForEstabelecimento( Date dataInicio, Date dataFim, Integer estabelecimentoID )
throws Exception
{
String [][]result = null;
Select select =
new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores" },
new String[]{ MarcacaoTrabalhadorData.DATA,
"trabalhador_id",
MarcacaoTrabalhadorData.REALIZADA,
MarcacaoTrabalhadorData.TIPO },
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
new Field( "data" ).isLessOrEqual( dataFim ) ),
new String[]{ "data" }, null );
Virtual2DArray array = executer.executeQuery( select );
result = new String[ array.columnLength() ][ 5 ];
for( int n = 0; n < result.length; n++ )
{
Date data = ( Date ) array.get( n, 0 );
int trabalhadorID = ( ( Number ) array.get( n, 1 ) ).intValue();
boolean realizada = "y".equals( array.get( n, 2 ) );
int tipo = ( ( Number ) array.get( n, 3 ) ).intValue();
String nomeEstabEmp[] = getNomeEstabelecimentoEmpresaForTrabalhador( trabalhadorID );
result[ n ][ 0 ] = nomeEstabEmp[ 2 ];
result[ n ][ 1 ] = nomeEstabEmp[ 0 ];
result[ n ][ 2 ] = nomeEstabEmp[ 1 ];
result[ n ][ 3 ] = DF.format( data );
result[ n ][ 4 ] = ( tipo == Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ? "(Exame)" : "(Consulta)" );
}
return result;
}
public int countExamesPeriodoForEstabelecimento( Date dataInicio, Date dataFim, Integer estabelecimentoID )
throws Exception
{
Select select =
new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores" },
new String[]{ "count(*)" },
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
new Field( "data" ).isLessOrEqual( dataFim ) ).and(
new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ) );
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
{
return 0;
}
return ( ( Number ) array.get( 0, 0 ) ).intValue();
}
public int countConsultasPeriodoForEstabelecimento( Date dataInicio, Date dataFim, Integer estabelecimentoID )
throws Exception
{
Select select =
new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores" },
new String[]{ "count(*)" },
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
new Field( "data" ).isLessOrEqual( dataFim ) ).and(
new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ) );
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() == 0 || array.get( 0, 0 ) == null )
{
return 0;
}
return ( ( Number ) array.get( 0, 0 ) ).intValue();
}
public String[][] getTrabalhadoresSemExamesOuConsultas( Date dataInicio, Date dataFim, boolean exames )
throws Exception
{
// Select subSelect =
// new Select( new String[]{ "marcacoes_trabalhador" },
// new String[]{ "trabalhador_id" },
// new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ).and(
// new Field( "realizada" ).isEqual( "y" ) ) );
Select select =
new Select( new String[]{ "empresas", "estabelecimentos",
"trabalhadores LEFT OUTER JOIN marcacoes_trabalhador ON "
+ "( trabalhadores.id = marcacoes_trabalhador.trabalhador_id AND marcacoes_trabalhador.tipo = "
+ (exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA) + " AND marcacoes_trabalhador.realizada = 'y' )" },
new String[]{ "empresas.designacao_social", "estabelecimentos.nome", "trabalhadores.nome",
"empresas.designacao_social_plain", "estabelecimentos.nome_plain", "trabalhadores.nome_plain" },
new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ).and(
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( null ) ).and(
new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
new Field( "trabalhadores.inactivo" ).isDifferent( "y" ).or(
new Field( "marcacoes_trabalhador.realizada" ).isDifferent( "y" ) ) ).and(
new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
new Field( "data" ).isLessOrEqual( dataFim ) ),
new String[]{ "empresas.designacao_social_plain", "estabelecimentos.nome_plain", "trabalhadores.nome_plain" }, null );
Virtual2DArray array = executer.executeQuery( select );
String data[][] = new String[ array.columnLength() ][ 3 ];
for( int r = 0; r < array.columnLength(); r++ )
{
for( int c = 0; c < 3; c++ )
{
data[ r ][ c ] = (String) array.get( r, c );
}
}
return data;
}
public int countTrabalhadoresSemExamesOuConsultas( Date dataInicio, Date dataFim, boolean exames )
throws Exception
{
Select select =
new Select( new String[]{ "trabalhadores" }, new String[]{ "COUNT(*)" },
new Field( "inactivo" ).isDifferent( "y" ) );
int totalCount = 0;
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() > 0 && array.rowLength() > 0 )
{
Number n = (Number) array.get( 0, 0 );
if( n != null )
{
totalCount = n.intValue();
}
}
// select =
// new Select( new String[]{ "marcacoes_trabalhador" },
// new String[]{ "COUNT(*)" },
// new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ).and(
// new Field( "realizada" ).isEqual( "y" ) ).and(
// new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
// int subCount = 0;
// array = executer.executeQuery( select );
// if( array.columnLength() > 0 && array.rowLength() > 0 )
// {
// Number n = (Number) array.get( 0, 0 );
// if( n != null )
// {
// subCount = n.intValue();
// }
// }
return totalCount - countTrabalhadoresComExamesOuConsultasPeriodo( dataInicio, dataFim, exames );
}
public String[][] getTrabalhadoresSemExamesOuConsultasEstabelecimento( Integer estabelecimentoID, Date dataInicio, Date dataFim, boolean exames )
throws Exception
{
Select select =
new Select( new String[]{ "marcacoes_trabalhador" },
new String[]{ "trabalhador_id" },
new Field( "tipo" ).isEqual( new Integer( exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ).and(
new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
new Field( "data" ).isLessOrEqual( dataFim ) ).and(
new Field( "realizada" ).isEqual( "y" ) ) );
Virtual2DArray array = executer.executeQuery( select );
Integer ids[] = new Integer[ array.columnLength() ];
for( int n = 0; n < ids.length; n++ )
{
ids[ n ] = ( Integer ) array.get( n, 0 );
}
if( ids.length == 0 )
{
ids = new Integer[]{ new Integer( -1 ) };
}
select =
new Select( new String[]{ "estabelecimentos",
"trabalhadores" },
new String[]{ "estabelecimentos.nome", "trabalhadores.nome" },
new Field( "estabelecimentos.id" ).isEqual( estabelecimentoID ).and(
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ).and(
new Field( "trabalhadores.id" ).notIn( ids ) ),
new String[]{ "trabalhadores.nome" }, null );
// Select select =
// new Select( new String[]{ "estabelecimentos",
// "trabalhadores LEFT OUTER JOIN marcacoes_trabalhador ON "
// + "( trabalhadores.id = marcacoes_trabalhador.trabalhador_id AND marcacoes_trabalhador.tipo = "
// + (exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA) + " AND marcacoes_trabalhador.realizada = 'y' )" },
// new String[]{ "estabelecimentos.nome", "trabalhadores.nome" },
// new Field( "estabelecimentos.id" ).isEqual( estabelecimentoID ).and(
// new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
// new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
// new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( null ).or(
// new Field( "marcacoes_trabalhador.realizada" ).isDifferent( "y" ) ) ).and(
// new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
// new Field( "data" ).isLessOrEqual( dataFim ) ).and(
// new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ),
// new String[]{ "trabalhadores.nome" }, null );
array = executer.executeQuery( select );
String data[][] = new String[ array.columnLength() ][ 2 ];
for( int r = 0; r < array.columnLength(); r++ )
{
for( int c = 0; c < 2; c++ )
{
data[ r ][ c ] = (String) array.get( r, c );
}
}
return data;
}
public Object[][] getCountTrabalhadoresSemExamesOuConsultasPeriodoForAllEmpresas( Date dataInicio, Date dataFim, boolean exames )
throws Exception
{
Select select =
new Select( new String[]{ "empresas" },
new String[]{ "id", "designacao_social", "designacao_social_plain" },
new Field( "inactivo" ).isDifferent( "y" ),
new String[]{ "designacao_social_plain" }, null );
Virtual2DArray array = executer.executeQuery( select );
Object data[][] = new Object[ array.columnLength() ][ 3 ];
for( int n = 0; n < data.length; n++ )
{
data[ n ][ 0 ] = array.get( n, 1 );
Integer empresaID = (Integer)array.get( n, 0 );
data[ n ][ 1 ] = new Integer( countTrabalhadoresSemExamesOuConsultasEmpresa( empresaID, dataInicio, dataFim, exames ) );
data[ n ][ 2 ] = empresaID;
}
return data;
}
public int countTrabalhadoresSemExamesOuConsultasEmpresa( Integer empresaID, Date dataInicio, Date dataFim, boolean exames )
throws Exception
{
Select select =
new Select( new String[]{ "trabalhadores", "estabelecimentos" }, new String[]{ "COUNT(*)" },
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ).and(
new Field( "estabelecimentos.empresa_id" ).isEqual( empresaID ) ).and(
new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
int totalCount = 0;
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() > 0 && array.rowLength() > 0 )
{
Number n = (Number) array.get( 0, 0 );
if( n != null )
{
totalCount = n.intValue();
}
}
// select =
// new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos" },
// new String[]{ "COUNT(*)" },
// new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
// new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
// new Field( "estabelecimentos.empresa_id" ).isEqual( empresaID ) ).and(
// new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ).and(
// new Field( "realizada" ).isEqual( "y" ) ).and(
// new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
// int subCount = 0;
// array = executer.executeQuery( select );
// if( array.columnLength() > 0 && array.rowLength() > 0 )
// {
// Number n = (Number) array.get( 0, 0 );
// if( n != null )
// {
// subCount = n.intValue();
// }
// }
return totalCount - countTrabalhadoresComExamesOuConsultasPeriodoForEmpresa( dataInicio, dataFim, empresaID, exames );
}
public int countTrabalhadoresSemExamesOuConsultasEstabelecimento( Integer estabelecimentoID, Date dataInicio, Date dataFim, boolean exames )
throws Exception
{
Select select =
new Select( new String[]{ "trabalhadores" }, new String[]{ "COUNT(*)" },
new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ).and(
new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
int totalCount = 0;
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() > 0 && array.rowLength() > 0 )
{
Number n = (Number) array.get( 0, 0 );
if( n != null )
{
totalCount = n.intValue();
}
}
// select =
// new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores" },
// new String[]{ "COUNT(*)" },
// new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
// new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
// new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ).and(
// new Field( "realizada" ).isEqual( "y" ) ).and(
// new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
// int subCount = 0;
// array = executer.executeQuery( select );
// if( array.columnLength() > 0 && array.rowLength() > 0 )
// {
// Number n = (Number) array.get( 0, 0 );
// if( n != null )
// {
// subCount = n.intValue();
// }
// }
return totalCount - countTrabalhadoresComExamesOuConsultasPeriodoForEstabelecimento( dataInicio, dataFim, estabelecimentoID, exames );
}
public String[][]getTrabalhadoresComExamesOuConsultasPeriodo( Date dataInicio, Date dataFim, boolean exames )
throws Exception
{
Select select =
new Select( new String[]{ "empresas", "estabelecimentos",
"trabalhadores", "marcacoes_trabalhador" },
new String[]{ "empresas.designacao_social", "estabelecimentos.nome", "trabalhadores.nome",
"empresas.designacao_social_plain", "estabelecimentos.nome_plain", "trabalhadores.nome_plain" },
new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ).and(
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ).and(
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ).and(
new Field( "marcacoes_trabalhador.tipo" ).isEqual( new Integer( exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
new Field( "marcacoes_trabalhador.realizada" ).isEqual( "y" ) ).and(
new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
new Field( "data" ).isLessOrEqual( dataFim ) ),
new String[]{ "empresas.designacao_social_plain", "estabelecimentos.nome_plain", "trabalhadores.nome_plain" }, null );
Virtual2DArray array = executer.executeQuery( select );
String data[][] = new String[ array.columnLength() ][ 3 ];
for( int r = 0; r < array.columnLength(); r++ )
{
for( int c = 0; c < 3; c++ )
{
data[ r ][ c ] = (String) array.get( r, c );
}
}
return data;
}
public int countTrabalhadoresComExamesOuConsultasPeriodo( Date dataInicio, Date dataFim, boolean exames )
throws Exception
{
Select select =
new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores" },
new String[]{ "COUNT(*)" },
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
new Field( "tipo" ).isEqual( new Integer( exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
new Field( "realizada" ).isEqual( "y" ) ).and(
new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ).and(
new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
new Field( "data" ).isLessOrEqual( dataFim ) ) );
int count = 0;
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() > 0 && array.rowLength() > 0 )
{
Number n = (Number) array.get( 0, 0 );
if( n != null )
{
count = n.intValue();
}
}
return count;
}
public String[][]getTrabalhadoresComExamesOuConsultasPeriodoForEstabelecimento( Date dataInicio, Date dataFim, Integer estabelecimentoID, boolean exames )
throws Exception
{
Select select =
new Select( new String[]{ "estabelecimentos",
"trabalhadores", "marcacoes_trabalhador" },
new String[]{ "estabelecimentos.nome", "trabalhadores.nome" },
new Field( "estabelecimentos.id" ).isEqual( estabelecimentoID ).and(
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ).and(
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ).and(
new Field( "marcacoes_trabalhador.tipo" ).isEqual( new Integer( exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
new Field( "marcacoes_trabalhador.realizada" ).isEqual( "y" ) ).and(
new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
new Field( "data" ).isLessOrEqual( dataFim ) ),
new String[]{ "estabelecimentos.nome", "trabalhadores.nome" }, null );
Virtual2DArray array = executer.executeQuery( select );
String data[][] = new String[ array.columnLength() ][ 2 ];
for( int r = 0; r < array.columnLength(); r++ )
{
for( int c = 0; c < 2; c++ )
{
data[ r ][ c ] = (String) array.get( r, c );
}
}
return data;
}
public Object[][] getCountTrabalhadoresComExamesOuConsultasPeriodoForAllEmpresas( Date dataInicio, Date dataFim, boolean exames )
throws Exception
{
Select select =
new Select( new String[]{ "empresas" },
new String[]{ "id", "designacao_social", "designacao_social_plain" },
new Field( "inactivo" ).isDifferent( "y" ),
new String[]{ "designacao_social_plain" }, null );
Virtual2DArray array = executer.executeQuery( select );
Object data[][] = new Object[ array.columnLength() ][ 3 ];
for( int n = 0; n < data.length; n++ )
{
data[ n ][ 0 ] = array.get( n, 1 );
Integer empresaID = (Integer)array.get( n, 0 );
data[ n ][ 1 ] = new Integer( countTrabalhadoresComExamesOuConsultasPeriodoForEmpresa( dataInicio, dataFim, empresaID, exames ) );
data[ n ][ 2 ] = empresaID;
}
return data;
}
public int countTrabalhadoresComExamesOuConsultasPeriodoForEmpresa( Date dataInicio, Date dataFim, Integer empresaID, boolean exames )
throws Exception
{
Select select =
new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos" },
new String[]{ "COUNT(*)" },
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
new Field( "estabelecimentos.empresa_id" ).isEqual( empresaID ) ).and(
new Field( "tipo" ).isEqual( new Integer( exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
new Field( "realizada" ).isEqual( "y" ) ).and(
new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ).and(
new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
new Field( "data" ).isLessOrEqual( dataFim ) ) );
int count = 0;
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() > 0 && array.rowLength() > 0 )
{
Number n = (Number) array.get( 0, 0 );
if( n != null )
{
count = n.intValue();
}
}
return count;
}
public int countTrabalhadoresComExamesOuConsultasPeriodoForEstabelecimento( Date dataInicio, Date dataFim, Integer estabelecimentoID, boolean exames )
throws Exception
{
Select select =
new Select( new String[]{ "marcacoes_trabalhador", "trabalhadores" },
new String[]{ "COUNT(*)" },
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
new Field( "tipo" ).isEqual( new Integer( exames ? Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES : Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and(
new Field( "realizada" ).isEqual( "y" ) ).and(
new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ).and(
new Field( "data" ).isGreaterOrEqual( dataInicio ) ).and(
new Field( "data" ).isLessOrEqual( dataFim ) ) );
int count = 0;
Virtual2DArray array = executer.executeQuery( select );
if( array.columnLength() > 0 && array.rowLength() > 0 )
{
Number n = (Number) array.get( 0, 0 );
if( n != null )
{
count = n.intValue();
}
}
return count;
}
public String [][]getDadosTrabalhadoresPeriodo( Date dataInicio, Date dataFim )
throws Exception
{
Select select =
new Select( new String[]{ "empresas", "estabelecimentos", "trabalhadores" },
new String[]{ "empresas.designacao_social", "estabelecimentos.nome", "trabalhadores.nome", "trabalhadores.id",
"empresas.designacao_social_plain", "estabelecimentos.nome_plain", "trabalhadores.nome_plain" },
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ).and(
new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) ).and(
new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ).and(
new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ),
new String[]{ "empresas.designacao_social_plain", "estabelecimentos.nome_plain", "trabalhadores.nome_plain" }, null );
Virtual2DArray array = executer.executeQuery( select );
String data[][] = new String[ array.columnLength() ][ 7 ];
for( int n = 0; n < array.columnLength(); n++ )
{
data[ n ][ 0 ] = ( String ) array.get( n, 0 );
data[ n ][ 1 ] = ( String ) array.get( n, 1 );
data[ n ][ 2 ] = ( String ) array.get( n, 2 );
Integer id = new Integer( ( (Number) array.get( n, 3 ) ).intValue() );
Select exameSelect =
new Select( new String[]{ "trabalhadores", "marcacoes_trabalhador" },
new String[]{ "data", "realizada" },
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
new Field( "trabalhadores.id" ).isEqual( id ) ).and(
new Field( "marcacoes_trabalhador.data" ).isLessOrEqual( dataFim ) ).and(
new Field( "marcacoes_trabalhador.tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ),
new String[]{ "data desc" }, null );
Virtual2DArray exameArray = executer.executeQuery( exameSelect );
if( exameArray.columnLength() > 0 )
{
Date dataExame = ( Date ) exameArray.get( 0, 0 );
String estado = ( String ) exameArray.get( 0, 1 );
data[ n ][ 3 ] = DF.format( dataExame );
data[ n ][ 4 ] = "y".equals( estado ) ? "Realizado" : "Faltou";
}
else
{
data[ n ][ 3 ] = "--";
data[ n ][ 4 ] = "--";
}
Select consultaSelect =
new Select( new String[]{ "trabalhadores", "marcacoes_trabalhador" },
new String[]{ "data", "realizada" },
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
new Field( "trabalhadores.id" ).isEqual( id ) ).and(
new Field( "marcacoes_trabalhador.data" ).isLessOrEqual( dataFim ) ).and(
new Field( "marcacoes_trabalhador.tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ),
new String[]{ "data desc" }, null );
Virtual2DArray consultaArray = executer.executeQuery( consultaSelect );
if( consultaArray.columnLength() > 0 )
{
Date dataConsulta = ( Date ) consultaArray.get( 0, 0 );
String estado = ( String ) consultaArray.get( 0, 1 );
data[ n ][ 5 ] = DF.format( dataConsulta );
data[ n ][ 6 ] = "y".equals( estado ) ? "Realizada" : "Faltou";
}
else
{
data[ n ][ 5 ] = "--";
data[ n ][ 6 ] = "--";
}
}
return data;
}
public String[][]getDadosHigieneSeguranca()
throws Exception
{
Select select =
new Select( new String[]{ "empresas", "estabelecimentos" },
new String[]{ "empresas.designacao_social", "estabelecimentos.nome", "estabelecimentos.id",
"empresas.designacao_social_plain", "estabelecimentos.nome_plain" },
new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ).and(
new Field( "empresas.inactivo" ).isDifferent( "y" ) ).and(
new Field( "estabelecimentos.inactivo" ).isDifferent( "y" ) ),
new String[]{ "empresas.designacao_social_plain", "estabelecimentos.nome_plain" }, null );
Virtual2DArray array = executer.executeQuery( select );
String data[][] = new String[ array.columnLength() ][ 6 ];
for( int n = 0; n < array.columnLength(); n++ )
{
data[ n ][ 0 ] = ( String ) array.get( n, 0 );
data[ n ][ 1 ] = ( String ) array.get( n, 1 );
Integer id = new Integer( ( (Number) array.get( n, 2 ) ).intValue() );
Select ultimaSelect =
new Select( new String[]{ "marcacoes_estabelecimento" },
new String[]{ "data", "realizada", "data_relatorio" },
new Field( "marcacoes_estabelecimento.estabelecimento_id" ).isEqual( id ).and(
new Field( "marcacoes_estabelecimento.data" ).isLessOrEqual( new Date() ) ),
new String[]{ "data desc" }, null );
Virtual2DArray ultimaArray = executer.executeQuery( ultimaSelect );
if( ultimaArray.columnLength() > 0 )
{
Date dataAud = ( Date ) ultimaArray.get( 0, 0 );
String estado = ( String ) ultimaArray.get( 0, 1 );
Date dataRel = ( Date ) ultimaArray.get( 0, 2 );
data[ n ][ 2 ] = DF.format( dataAud );
data[ n ][ 3 ] = "y".equals( estado ) ? "Realizada" : "N&atilde;o Realizada";
data[ n ][ 4 ] = dataRel != null ? DF.format( dataRel ) : "--";
}
else
{
data[ n ][ 2 ] = "--";
data[ n ][ 3 ] = "--";
data[ n ][ 4 ] = "--";
}
Select proximaSelect =
new Select( new String[]{ "marcacoes_estabelecimento" },
new String[]{ "data" },
new Field( "marcacoes_estabelecimento.estabelecimento_id" ).isEqual( id ).and(
new Field( "marcacoes_estabelecimento.data" ).isGreaterOrEqual( new Date() ) ),
new String[]{ "data desc" }, null );
Virtual2DArray proximaArray = executer.executeQuery( proximaSelect );
if( proximaArray.columnLength() > 0 )
{
Date dataProx = ( Date ) proximaArray.get( 0, 0 );
data[ n ][ 5 ] = DF.format( dataProx );
}
else
{
data[ n ][ 5 ] = "--";
}
}
return data;
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,255 @@
/*
* HigieneDataProvider.java
*
* Created on February 1, 2006, 10:49 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.higiene;
import java.awt.*;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.arrays.*;
import com.evolute.utils.data.*;
import com.evolute.utils.db.*;
import com.evolute.utils.metadb.*;
import com.evolute.utils.sql.*;
import com.evolute.utils.strings.*;
import com.evolute.utils.tables.*;
import siprp.*;
import siprp.data.*;
/**
*
* @author fpalma
*/
public class HigieneDataProvider extends MetaProvider
{
public static final int ESTADO_POR_REALIZAR = 0;
public static final int ESTADO_REALIZADO = 2;
public static final int ESTADO_DESMARCADO_TRABALHADOR = 3;
public static final int ESTADO_DESMARCADO_EMPRESA = 4;
public static final int ESTADO_FALTOU = 5;
public static final String ESTADOS_STR[] =
new String[]{ "Por realizar", "", "Realizada",
"Desmarcada empresa",
"Desmarcada " + Singleton.getInstance( SingletonConstants.COMPANY_ACRONYM ),
"Faltou" };
public static final Color CORES_TECNICOS[] =
new Color[]{ Color.white, Color.red.darker(), Color.blue,
Color.green.darker(), Color.yellow.darker(),
Color.gray, Color.pink.darker() };
private static final Object LOCK = new Object();
private static HigieneDataProvider instance = null;
private final Executer executer;
/** Creates a new instance of HigieneDataProvider */
public HigieneDataProvider()
throws Exception
{
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ );
executer = dbm.getSharedExecuter( this );
}
public static MetaProvider getProvider()
throws Exception
{
synchronized( LOCK )
{
if( instance == null )
{
instance = new HigieneDataProvider();
}
}
return instance;
}
public Object[][] getAllTecnicosHST()
throws Exception
{
Select select =
new Select( new String[]{ "marcacoes_tecnicos_hst" },
new String[]{ "id", "nome", "iniciais", "identificador", "nome_plain" },
new Field( "inactivo" ).isDifferent( "y" ),
new String[]{ "nome_plain" },
null );
Virtual2DArray array = executer.executeQuery( select );
return array.getObjects();
}
public ColumnizedMappable[] getAllEmpresas()
throws Exception
{
Select select =
new Select( new String[]{ "empresas" },
new String[]{ "id", "designacao_social", "designacao_social_plain" },
new Field( "inactivo" ).isDifferent( "y" ),
new String[]{ "designacao_social_plain" },
null );
Virtual2DArray array = executer.executeQuery( select );
ColumnizedMappable empresas[] = new ColumnizedMappable[ array.columnLength() ];
for( int n = 0; n < empresas.length; n++ )
{
Integer id = ( Integer ) array.get( n, 0 );
String designacao = ( String ) array.get( n, 1 );
empresas[ n ] = new ColumnizedMappable( id, designacao );
}
return empresas;
}
public ColumnizedMappable[] getAllEstabelecimentosForEmpresa( Integer empresaID )
throws Exception
{
Select select =
new Select( new String[]{ "estabelecimentos" },
new String[]{ "id", "nome", "nome_plain" },
new Field( "empresa_id" ).isEqual( empresaID ).and(
new Field( "inactivo" ).isDifferent( "y" ) ),
new String[]{ "nome_plain" },
null );
Virtual2DArray array = executer.executeQuery( select );
ColumnizedMappable estabelecimentos[] = new ColumnizedMappable[ array.columnLength() ];
for( int n = 0; n < estabelecimentos.length; n++ )
{
Integer id = ( Integer ) array.get( n, 0 );
String nome = ( String ) array.get( n, 1 );
estabelecimentos[ n ] = new ColumnizedMappable( id, nome );
}
return estabelecimentos;
}
public String getEmpresa( Integer empresaID )
throws Exception
{
String nomes[] = new String[ 2 ];
Select select = new Select( new String[]{ "empresas" },
new String[]{ "designacao_social" },
new Field( "id" ).isEqual( empresaID ) );
Virtual2DArray array = executer.executeQuery( select );
return ( String ) array.get( 0, 0 );
}
public Object[][] getVisitasEstabelecimento( Integer estabelecimentoID )
throws Exception
{
Select select =
new Select( new String[]{ "marcacoes_estabelecimento" },
new String[]{ "id", "data", "estado" },
new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ),
new String[]{ "data desc" },
null );
Virtual2DArray array = executer.executeQuery( select );
Object data[][] = array.getObjects();
for( int n = 0; n < data.length; n++ )
{
int estado = ( ( Integer ) data[ n ][ 2 ] ).intValue();
data[ n ][ 2 ] = ESTADOS_STR[ estado ];
}
return data;
}
public Vector[][] getMapaAnual( Integer ano )
throws Exception
{
String deleted = "__DELETED__";
Select select =
new Select( new String[]{ "marcacoes_tecnicos_hst" },
new String[]{ "id", "nome", "iniciais", "identificador", "nome_plain" },
new Field( "inactivo" ).isDifferent( "y" ),
new String[]{ "nome_plain" },
null );
Virtual2DArray array = executer.executeQuery( select );
Object tecnicosArr[][] = array.getObjects();
Hashtable tecnicos = new Hashtable();
for( int n = 0; n < tecnicosArr.length; n++ )
{
tecnicos.put( tecnicosArr[ n ][ 0 ], tecnicosArr[ n ] );
}
Hashtable empresas = new Hashtable();
Hashtable estabelecimentos = new Hashtable();
Hashtable empresasEstabelecimentos = new Hashtable();
Vector data[][] = new Vector[ 31 ][ 12 ];
select = new Select( new String[]{ "marcacoes_estabelecimento" },
new String[]{ "data", "estabelecimento_id", "tecnico_hst" },
new Field( "data" ).between( new Object[]{ ano + "-01-01", ano + "-12-31" } ).and(
new Field( "estado" ).in( new Integer[]{ new Integer( 0 ), new Integer( 2 ) } ) ) );
array = executer.executeQuery( select );
for( int n = 0; n < array.columnLength(); n++ )
{
Date dataVisita = ( Date ) array.get( n, 0 );
Integer estabelecimentoID = ( Integer ) array.get( n, 1 );
Integer tecnicoID = ( Integer ) array.get( n, 2 );
Integer empresaID = null;
if( !estabelecimentos.containsKey( estabelecimentoID ) )
{
Select estabelecimentoSelect =
new Select( new String[]{ "estabelecimentos" },
new String[]{ "nome", "empresa_id", "inactivo" },
new Field( "id" ).isEqual( estabelecimentoID ) );
Virtual2DArray estabelecimentoArray = executer.executeQuery( estabelecimentoSelect );
if( "y".equals( estabelecimentoArray.get( 0, 2 ) ) )
{
estabelecimentos.put( estabelecimentoID, deleted );
}
else
{
estabelecimentos.put( estabelecimentoID, estabelecimentoArray.get( 0, 0 ) );
}
empresaID = ( Integer ) estabelecimentoArray.get( 0, 1 );
empresasEstabelecimentos.put( estabelecimentoID, empresaID );
if( !empresas.containsKey( empresaID ) )
{
Select empresaSelect =
new Select( new String[]{ "empresas" },
new String[]{ "designacao_social", "inactivo" },
new Field( "id" ).isEqual( empresaID ) );
Virtual2DArray empresaArray = executer.executeQuery( empresaSelect );
if( "y".equals( empresaArray.get( 0, 1 ) ) )
{
empresas.put( empresaID, deleted );
}
else
{
empresas.put( empresaID, empresaArray.get( 0, 0 ) );
}
}
}
String nomeEstabelecimento = ( String ) estabelecimentos.get( estabelecimentoID );
empresaID = ( Integer ) empresasEstabelecimentos.get( estabelecimentoID );
String nomeEmpresa = ( String ) empresas.get( empresaID );
String nomeTecnico = " ";
Integer indiceCor = null;
Color cor = null;
if( tecnicoID != null )
{
Object tecnico[] = ( Object[] ) tecnicos.get( tecnicoID );
nomeTecnico = ( String ) tecnico[ 1 ];
indiceCor = ( Integer ) tecnico[ 3 ];
cor = CORES_TECNICOS[ indiceCor.intValue() ];
}
Calendar cal = Calendar.getInstance();
cal.setTime( dataVisita );
int dia = cal.get( Calendar.DAY_OF_MONTH ) - 1;
int mes = cal.get( Calendar.MONTH );
if( data[ dia ][ mes ] == null )
{
data[ dia ][ mes ] = new Vector();
data[ dia ][ mes ].add( new Object[]{ new Integer( dia + 1 ) } );
}
if( nomeEmpresa != deleted && nomeEstabelecimento != deleted )
{
data[ dia ][ mes ].add( new Object[]{ nomeEmpresa, nomeEstabelecimento, nomeTecnico, cor } );
}
}
return data;
}
}

@ -0,0 +1,18 @@
CREATE TABLE marcacoes_tecnicos_hst
(
id int4 NOT NULL,
nome varchar(255) NOT NULL,
nome_plain varchar(255) NOT NULL,
iniciais varchar(10) NOT NULL,
identificador int4,
inactivo char(1) DEFAULT 'n' NOT NULL,
CONSTRAINT marcacoes_tecnicos_hst_pkey PRIMARY KEY (id)
)
WITHOUT OIDS;
ALTER TABLE marcacoes_tecnicos_hst OWNER TO postgres;
ALTER TABLE marcacoes_estabelecimento ADD estado INT;
ALTER TABLE marcacoes_estabelecimento ADD tecnico_hst INT REFERENCES marcacoes_tecnicos_hst(id);
ALTER TABLE marcacoes_estabelecimento ADD observacoes VARCHAR( 2048 );
UPDATE marcacoes_estabelecimento SET estado = 2 WHERE realizada = 'y';

@ -0,0 +1,62 @@
/*
* DiaLine.java
*
* Created on 8 de Fevereiro de 2006, 22:43
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.higiene.mapa;
import java.util.*;
import com.evolute.utils.tables.*;
/**
*
* @author Frederico
*/
public class DiaLine implements ColumnizedObjectForUpdate
{
protected Integer day;
protected Vector data[];
/** Creates a new instance of DiaLine */
public DiaLine( int day, Vector data[] )
{
this.day = new Integer( day );
this.data = data;
}
public Object getValue( int col )
{
switch( col )
{
case 0:
return day;
default:
return data[ col - 1 ].toArray( new Object[ 0 ][] );
}
}
public int[] getUpdateableColumns()
{
return new int[]{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
}
public void setValueAt( Object value, int col )
{
// data[ col - 1 ].clear();
if( value != null && value instanceof Vector )
{
data[ col - 1 ].addAll( ( Vector ) value );
}
}
public void clear( int col )
{
data[ col - 1 ].clear();
}
}

@ -0,0 +1,101 @@
/*
* DiaPanel.java
*
* Created on February 1, 2006, 6:42 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.higiene.mapa;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.evolute.utils.dataui.*;
/**
*
* @author fpalma
*/
public class DiaPanel extends JPanel
implements ControllableComponent, ActionListener
{
protected Object data[][];
protected JButton buttons[];
/** Creates a new instance of DiaPanel */
public DiaPanel()
{
}
private void setupComponents()
{
}
public void setEnabled( boolean enable )
{
}
public void fill( Object value )
{
removeAll();
Object arr[][] = ( Object[][] ) value;
data = arr;
buttons = new JButton[ arr.length ];
if( arr.length > 0 )
{
GridBagLayout gridbag = new GridBagLayout();
setLayout( gridbag );
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets( 0, 0, 0, 0 );
constraints.fill = GridBagConstraints.BOTH;
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.weighty = 0;
constraints.gridheight = 1;
Integer dia = ( Integer ) arr[ 0 ][ 0 ];
JLabel diaLabel = new JLabel( dia.toString(), JLabel.LEFT );
gridbag.setConstraints( diaLabel, constraints );
add( diaLabel );
for( int n = 1; n < arr.length; n++ )
{
String empresa = ( String ) arr[ n ][ 0 ];
String estabelecimento = ( String ) arr[ n ][ 1 ];
String tecnico = ( String ) arr[ n ][ 2 ];
Color cor = ( Color ) arr[ n ][ 3 ];
String empresaR = empresa.length() > 10 ? empresa.substring( 0, 10 ) : empresa;
String estabelecimentoR = estabelecimento.length() > 10 ? estabelecimento.substring( 0, 10 ) : estabelecimento;
buttons[ n ] = new JButton( "<html><FONT SIZE=\"-2\">" + empresaR + "<br>" + estabelecimentoR + "</FONT></html>" );
buttons[ n ].setMargin( new Insets( 2, 1, 2, 1 ) );
buttons[ n ].setBackground( cor );
buttons[ n ].setToolTipText( "T\u00e9cnico: " + ( tecnico != null ? tecnico : "n.d." )
+ " \nEmpresa: " + empresa + " \nEstabelecimento: " + estabelecimento );
gridbag.setConstraints( buttons[ n ], constraints );
add( buttons[ n ] );
buttons[ n ].addActionListener( this );
}
JPanel pad = new JPanel();
constraints.weighty = 1;
constraints.gridheight = GridBagConstraints.REMAINDER;
gridbag.setConstraints( pad, constraints );
add( pad );
}
}
public Object save()
{
return data;
}
public void clear()
{
}
public void actionPerformed( ActionEvent e )
{
JButton source = ( JButton ) e.getSource();
JOptionPane.showMessageDialog( source, source.getToolTipText(), "", JOptionPane.PLAIN_MESSAGE );
}
}

@ -0,0 +1,65 @@
/*
* DiaRenderer.java
*
* Created on 8 de Fevereiro de 2006, 21:45
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.higiene.mapa;
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
import java.util.*;
/**
*
* @author Frederico
*/
public class DiaRenderer extends DefaultCellEditor
implements TableCellRenderer
{
protected JLabel diaLabel;
protected DiaPanel diaPanel;
/** Creates a new instance of DiaRenderer */
public DiaRenderer()
{
super( new JCheckBox() );
diaLabel = new JLabel();
diaPanel = new DiaPanel();
}
public Component getTableCellRendererComponent( JTable table, Object value,
boolean isSelected,
boolean hasFocus,
int row, int column )
{
if( column == 0 )
{
diaLabel.setText( "" + value );
return diaLabel;
}
diaPanel.fill( value );
return diaPanel;
}
public Component getTableCellEditorComponent( JTable table, Object value,
boolean isSelected,
int row, int column )
{
if( column == 0 )
{
diaLabel.setText( "" + value );
return diaLabel;
}
diaPanel.fill( value );
return diaPanel;
}
public Object getCellEditorValue()
{
return diaPanel.save();
}
}

@ -0,0 +1,112 @@
/*
* MapaHigienePanel.java
*
* Created on 9 de Fevereiro de 2006, 0:11
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.higiene.mapa;
import java.awt.*;
import javax.swing.*;
import java.util.*;
import com.evolute.utils.dataui.*;
import com.evolute.utils.date.*;
import com.evolute.utils.tables.*;
/**
*
* @author Frederico
*/
public class MapaHigienePanel extends JPanel
implements ControllableComponent
{
protected BaseTable yearTable;
protected VectorTableModel yearModel;
protected JScrollPane yearScroll;
/** Creates a new instance of MapaHigienePanel */
public MapaHigienePanel()
throws Exception
{
setupComponents();
}
private void setupComponents()
throws Exception
{
String headers[] = new String[ 13 ];
headers[ 0 ] = " ";
for( int n = 0; n < DateUtils.MONTHS_FULL_PT.length; n++ )
{
headers[ n + 1 ] = DateUtils.MONTHS_FULL_PT[ n ];
}
yearModel = new VectorTableModel( headers );
yearTable = new BaseTable( yearModel );
yearTable.fixColumnWidth( 0, 20 );
yearTable.setNonResizableNorReordable();
// yearTable.setEnabled( true );
yearModel.setEditable( true );
yearTable.setTableCellRenderer( new DiaRenderer() );
yearTable.setTableCellEditor( new DiaRenderer() );
yearScroll = new JScrollPane( yearTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
Vector values = yearModel.getValues();
for( int n = 0; n < 31; n++ )
{
Vector data[] = new Vector[ 12 ];
for( int m = 0; m < 12; m++ )
{
data[ m ] = new Vector();
}
values.add( new DiaLine( n + 1, data ) );
}
yearModel.setValues( values );
setLayout( new GridLayout( 1, 1 ) );
add( yearScroll );
}
public void clear()
{
}
public void setEnabled( boolean enable )
{
yearTable.setEnabled( enable );
}
public void fill( Object value )
{
// if( true ) return;
Vector arr[][] = ( Vector[][] )value;
int maxs[] = new int[ arr.length ];
for( int r = 0; r < arr.length; r++ )
{
maxs[ r ] = 1;
for( int c = 0; c < arr[ r ].length; c++ )
{
if( arr[ r ][ c ] != null && arr[ r ][ c ].size() > maxs[ r ] )
{
maxs[ r ] = arr[ r ][ c ].size();
}
DiaLine line = ( DiaLine ) yearModel.getRowAt( r );
line.clear( c + 1 );
line.setValueAt( arr[ r ][ c ], c + 1 );
yearModel.removeRowAt( r );
yearModel.insertRowAt( line, r );
}
}
for( int r = 0; r < arr.length; r++ )
{
yearTable.setRowHeight( r, 20 + ( maxs[ r ] - 1 ) * 40 );
}
}
public Object save()
{
return null;
}
}

@ -0,0 +1,139 @@
/*
* MarcacoesHigieneWindow.java
*
* Created on January 31, 2006, 11:32 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.higiene.mapa;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import com.evolute.utils.documents.*;
import com.evolute.utils.tables.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.ui.window.*;
import siprp.higiene.*;
/**
*
* @author fpalma
*/
public class MapaHigieneWindow extends EditorWindow
implements ActionListener
{
public final static String TITLE = "Mapa de Higiene e Seguran\u00e7a";
private final static int iPermissionArray[][] =
new int[][]{ { } };
protected MapaHigienePanel mainPanel;
protected JTextField anoText;
protected JButton actualizarButton;
protected HigieneDataProvider provider;
public static void main( String args[] )
throws Exception
{
JFrame frm = new MapaHigieneWindow();
frm.setVisible( true );
}
/** Creates a new instance of MarcacoesHigieneWindow */
public MapaHigieneWindow()
throws Exception
{
super( iPermissionArray );
provider = ( HigieneDataProvider ) HigieneDataProvider.getProvider();
setupComponents();
setExtendedState(getExtendedState() | MAXIMIZED_BOTH);
}
private void setupComponents()
throws Exception
{
setTitle( TITLE );
JPanel upperPanel = new JPanel();
mainPanel = new MapaHigienePanel();
getContentPane().setLayout( new BorderLayout() );
getContentPane().add( upperPanel, BorderLayout.NORTH );
getContentPane().add( mainPanel, BorderLayout.CENTER );
upperPanel.setLayout( new FlowLayout( FlowLayout.LEFT ) );
upperPanel.add( new TecnicosPanel() );
JLabel anoLabel = new JLabel( "Ano" );
anoText = new JTextField();
anoText.setPreferredSize( new Dimension( 50, 20 ) );
anoText.setDocument( new YearDocument() );
anoText.addActionListener( this );
actualizarButton = new JButton( "Actualizar" );
actualizarButton.addActionListener( this );
Calendar cal = Calendar.getInstance();
anoText.setText( "" + cal.get( Calendar.YEAR ) );
JPanel pesquisaPanel = new JPanel();
upperPanel.add( pesquisaPanel );
pesquisaPanel.setLayout( new FlowLayout( FlowLayout.CENTER ) );
pesquisaPanel.add( anoLabel );
pesquisaPanel.add( anoText );
pesquisaPanel.add( actualizarButton );
// Vector data[][] = new Vector[ 31 ][ 12 ];
// for( int r = 0; r < 31; r++ )
// {
// for( int c = 0; c < 12; c++ )
// {
// data[ r ][ c ] = new Vector();
// }
// }
//// Vector example = new Vector();
//// example.add( new Object[]{ "Empresa1", "Estabelecimento1", "Pai Natal", "9:30", Color.red } );
// data[ 20 ][ 10 ].add( new Object[]{ new Integer( 21 ) } );
// data[ 20 ][ 10 ].add( new Object[]{ "Empresa1", "Estabelecimento1", "Pai Natal", Color.red } );
// data[ 20 ][ 10 ].add( new Object[]{ "Empresa1", "Estabelecimento1", "Pai Natal", Color.green } );
// data[ 20 ][ 10 ].add( new Object[]{ "Empresa1", "Estabelecimento1", "Pai Natal", Color.yellow } );
// data[ 20 ][ 10 ].add( new Object[]{ "Empresa1", "Estabelecimento1", "Pai Natal", Color.white } );
// mainPanel.fill( data );
}
public void actualizar()
{
String anoStr = anoText.getText();
if( anoStr.length() == 0 )
{
mainPanel.clear();
}
else
{
Integer ano = new Integer( anoStr );
try
{
mainPanel.fill( provider.getMapaAnual( ano ) );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
mainPanel.clear();
}
}
}
public void actionPerformed( ActionEvent e )
{
Object source = e.getSource();
if( source.equals( actualizarButton ) || source.equals( anoText ) )
{
actualizar();
}
}
}

@ -0,0 +1,63 @@
/*
* TecnicosPanel.java
*
* Created on 12 de Fevereiro de 2006, 17:48
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.higiene.mapa;
import java.awt.*;
import javax.swing.*;
import siprp.higiene.*;
/**
*
* @author Frederico
*/
public class TecnicosPanel extends JPanel
{
protected HigieneDataProvider provider;
/** Creates a new instance of TecnicosPanel */
public TecnicosPanel()
throws Exception
{
provider = ( HigieneDataProvider ) HigieneDataProvider.getProvider();
setupComponents();
}
private void setupComponents()
throws Exception
{
Object tecnicos[][] = provider.getAllTecnicosHST();
GridBagLayout gridbag = new GridBagLayout();
setLayout( gridbag );
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets( 1, 1, 1, 1 );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.gridheight = 1;
constraints.weighty = 0;
for( int n = 0; n < tecnicos.length; n++ )
{
constraints.weightx = 0;
constraints.gridwidth = 1;
JLabel corLabel = new JLabel( " " );
corLabel.setBackground( HigieneDataProvider.CORES_TECNICOS[ ( ( Integer ) tecnicos[ n ][ 3 ] ).intValue() ] );
corLabel.setOpaque( true );
gridbag.setConstraints( corLabel, constraints );
add( corLabel );
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
JLabel nomeLabel = new JLabel( (String)tecnicos[ n ][ 1 ] );
gridbag.setConstraints( nomeLabel, constraints );
add( nomeLabel );
}
}
}

@ -0,0 +1,41 @@
/*
* CorTecnicoCellRenderer.java
*
* Created on February 1, 2006, 11:13 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.higiene.marcacoes;
import java.awt.*;
import javax.swing.*;
import siprp.higiene.*;
/**
*
* @author fpalma
*/
public class CorTecnicoCellRenderer extends JLabel implements ListCellRenderer
{
public CorTecnicoCellRenderer()
{
setOpaque(true);
}
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
{
setText( " " );
Color color = HigieneDataProvider.CORES_TECNICOS[ ( ( Integer ) value ).intValue() ];
if( cellHasFocus )
{
color = color.darker().darker();
}
setBackground( color );
return this;
}
}

@ -0,0 +1,306 @@
package siprp.higiene.marcacoes;
import com.evolute.utils.*;
import com.evolute.utils.arrays.*;
import com.evolute.utils.data.*;
import com.evolute.utils.dataui.*;
import com.evolute.utils.db.*;
import com.evolute.utils.documents.*;
import com.evolute.utils.sql.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.ui.panel.*;
import com.evolute.utils.ui.text.*;
import java.awt.*;
import java.util.*;
import javax.swing.*;
import siprp.data.*;
public class MarcacaoVisitaHSTPanel
extends JPanel
implements ControllableComponent, DataClassAware
{
private siprp.data.MarcacaoEstabelecimentoData marcacaoEstabelecimentoData;
private final ComponentsHashtable components = new ComponentsHashtable();
protected final SQLExecuter EXECUTER;
private final JLabel dataLabel = new JLabel( "Data da visita", JLabel.RIGHT );
private final JCalendarPanel dataPanel = new JCalendarPanel( null );
private final JButton emailButton = new JButton( "Enviar Email" );
private final JLabel dataFichaLabel = new JLabel( "Data do Relat\u00f3rio", JLabel.RIGHT );
private final JCalendarPanel dataFichaPanel = new JCalendarPanel( null );
private final JLabel tecnicoLabel = new JLabel( "T\u00e9cnico", JLabel.RIGHT );
private final JComboBox tecnicoList = new JComboBox();
private RadioButtonFixedPanel estadoList;
private final JScrollPane observacoesTextScroll = new JScrollPane();
private final StateTextArea observacoesText = new StateTextArea();
public MarcacaoVisitaHSTPanel()
throws Exception
{
DBManager dbm = ( DBManager )Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
if( dbm != null )
{
EXECUTER = ( SQLExecuter )dbm.getSharedExecuter( this );
}
else
{
EXECUTER = null;
}
setupComponents();
setupComponentsHashtable();
place();
}
public void setupComponents()
throws Exception
{
JComponent MarcacaoVisitaHSTPanel = this;
emailButton.setMinimumSize( new Dimension( 300, 20 ) );
emailButton.setPreferredSize( new Dimension( 200, 20 ) );
tecnicoList.addItem( new MappableObject( new Integer( -1 ), "" ) );
tecnicoList.setSelectedIndex( 0 );
IDObject estadoListOptions[] = new IDObject[]{
new MappableObject( new Integer( 0 ), "Por realizar" ),
new MappableObject( new Integer( 2 ), "Realizada" ),
new MappableObject( new Integer( 3 ), "Desmarcada pela empresa" ),
new MappableObject( new Integer( 4 ), "Desmarcada pela SIPRP" ),
};
estadoList = new RadioButtonFixedPanel( estadoListOptions, 6, 1, RadioButtonFixedPanel.ORIENTATION_VERTICAL, false, null );
estadoList.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Estado" ) );
observacoesTextScroll.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Observa\u00e7\u00f5es" ) );
observacoesText.setLineWrap( true );
observacoesText.setWrapStyleWord( true );
observacoesText.setRows( 5 );
}
public void place()
{
JPanel MarcacaoVisitaHSTPanel = this;
GridBagConstraints MarcacaoVisitaHSTPanelGBC = new GridBagConstraints();
MarcacaoVisitaHSTPanelGBC.insets = new Insets( 1, 1, 1, 1 );
GridBagLayout MarcacaoVisitaHSTPanelLayout = new GridBagLayout();
MarcacaoVisitaHSTPanel.setLayout( MarcacaoVisitaHSTPanelLayout );
MarcacaoVisitaHSTPanelGBC.gridx = 0;
MarcacaoVisitaHSTPanelGBC.gridy = 0;
MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
MarcacaoVisitaHSTPanelGBC.gridheight = 1;
MarcacaoVisitaHSTPanelGBC.weightx = 0.0;
MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL;
MarcacaoVisitaHSTPanelLayout.setConstraints( dataLabel, MarcacaoVisitaHSTPanelGBC );
MarcacaoVisitaHSTPanel.add( dataLabel );
MarcacaoVisitaHSTPanelGBC.gridx = 1;
MarcacaoVisitaHSTPanelGBC.gridy = 0;
MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
MarcacaoVisitaHSTPanelGBC.gridheight = 1;
MarcacaoVisitaHSTPanelGBC.weightx = 0.5;
MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL;
MarcacaoVisitaHSTPanelLayout.setConstraints( dataPanel, MarcacaoVisitaHSTPanelGBC );
MarcacaoVisitaHSTPanel.add( dataPanel );
MarcacaoVisitaHSTPanelGBC.gridx = 2;
MarcacaoVisitaHSTPanelGBC.gridy = 0;
MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
MarcacaoVisitaHSTPanelGBC.gridheight = 1;
MarcacaoVisitaHSTPanelGBC.weightx = 0.5;
MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.NONE;
MarcacaoVisitaHSTPanelLayout.setConstraints( emailButton, MarcacaoVisitaHSTPanelGBC );
MarcacaoVisitaHSTPanel.add( emailButton );
MarcacaoVisitaHSTPanelGBC.gridx = 0;
MarcacaoVisitaHSTPanelGBC.gridy = 1;
MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
MarcacaoVisitaHSTPanelGBC.gridheight = 1;
MarcacaoVisitaHSTPanelGBC.weightx = 0.0;
MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL;
MarcacaoVisitaHSTPanelLayout.setConstraints( dataFichaLabel, MarcacaoVisitaHSTPanelGBC );
MarcacaoVisitaHSTPanel.add( dataFichaLabel );
MarcacaoVisitaHSTPanelGBC.gridx = 1;
MarcacaoVisitaHSTPanelGBC.gridy = 1;
MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
MarcacaoVisitaHSTPanelGBC.gridheight = 1;
MarcacaoVisitaHSTPanelGBC.weightx = 0.5;
MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL;
MarcacaoVisitaHSTPanelLayout.setConstraints( dataFichaPanel, MarcacaoVisitaHSTPanelGBC );
MarcacaoVisitaHSTPanel.add( dataFichaPanel );
MarcacaoVisitaHSTPanelGBC.gridx = 0;
MarcacaoVisitaHSTPanelGBC.gridy = 2;
MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
MarcacaoVisitaHSTPanelGBC.gridheight = 1;
MarcacaoVisitaHSTPanelGBC.weightx = 0.0;
MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL;
MarcacaoVisitaHSTPanelLayout.setConstraints( tecnicoLabel, MarcacaoVisitaHSTPanelGBC );
MarcacaoVisitaHSTPanel.add( tecnicoLabel );
MarcacaoVisitaHSTPanelGBC.gridx = 1;
MarcacaoVisitaHSTPanelGBC.gridy = 2;
MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
MarcacaoVisitaHSTPanelGBC.gridheight = 1;
MarcacaoVisitaHSTPanelGBC.weightx = 0.5;
MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL;
MarcacaoVisitaHSTPanelLayout.setConstraints( tecnicoList, MarcacaoVisitaHSTPanelGBC );
MarcacaoVisitaHSTPanel.add( tecnicoList );
MarcacaoVisitaHSTPanelGBC.gridx = 0;
MarcacaoVisitaHSTPanelGBC.gridy = 3;
MarcacaoVisitaHSTPanelGBC.gridwidth = 3;
MarcacaoVisitaHSTPanelGBC.gridheight = 1;
MarcacaoVisitaHSTPanelGBC.weightx = 1.0;
MarcacaoVisitaHSTPanelGBC.weighty = 0.5;
MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.BOTH;
MarcacaoVisitaHSTPanelLayout.setConstraints( estadoList, MarcacaoVisitaHSTPanelGBC );
MarcacaoVisitaHSTPanel.add( estadoList );
MarcacaoVisitaHSTPanelGBC.gridx = 0;
MarcacaoVisitaHSTPanelGBC.gridy = 4;
MarcacaoVisitaHSTPanelGBC.gridwidth = 3;
MarcacaoVisitaHSTPanelGBC.gridheight = 1;
MarcacaoVisitaHSTPanelGBC.weightx = 1.0;
MarcacaoVisitaHSTPanelGBC.weighty = 0.5;
observacoesTextScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
observacoesTextScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED );
observacoesTextScroll.setViewportView( observacoesText );
MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.BOTH;
MarcacaoVisitaHSTPanelLayout.setConstraints( observacoesTextScroll, MarcacaoVisitaHSTPanelGBC );
MarcacaoVisitaHSTPanel.add( observacoesTextScroll );
}
private void setupComponentsHashtable()
{
components.putComponent( siprp.data.MarcacaoEstabelecimentoData.DATA, dataPanel );
components.putComponent( siprp.data.MarcacaoEstabelecimentoData.DATA_RELATORIO, dataFichaPanel );
components.putComponent( siprp.data.MarcacaoEstabelecimentoData.TECNICO_HST, tecnicoList );
components.putComponent( siprp.data.MarcacaoEstabelecimentoData.ESTADO, estadoList );
components.putComponent( siprp.data.MarcacaoEstabelecimentoData.OBSERVACOES, observacoesText );
}
public void fill( Object toFill )
{
clear();
if( toFill == null || !( toFill instanceof PropertyObject ) )
{
return;
}
Hashtable data = null;
if( toFill instanceof PropertyObject )
{
data = ( (PropertyObject) toFill ).getHashData();
if( toFill instanceof siprp.data.MarcacaoEstabelecimentoData )
{
marcacaoEstabelecimentoData = (siprp.data.MarcacaoEstabelecimentoData) toFill;
}
}
else if( toFill instanceof Hashtable )
{
data = (Hashtable) toFill;
}
else
{
return;
}
if( marcacaoEstabelecimentoData == null )
{
marcacaoEstabelecimentoData = new siprp.data.MarcacaoEstabelecimentoData();
marcacaoEstabelecimentoData.setHashData( data );
}
PropertyObject po = (PropertyObject) toFill;
String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
ComponentController.fill( properties, po.getHashData(), components );
}
public Object save()
{
if( marcacaoEstabelecimentoData == null )
{
marcacaoEstabelecimentoData = new siprp.data.MarcacaoEstabelecimentoData();
}
Hashtable data = marcacaoEstabelecimentoData.getHashData();
String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
ComponentController.save( properties, data, components );
if( !( marcacaoEstabelecimentoData instanceof PropertyObject ) )
{
return data;
}
marcacaoEstabelecimentoData.setHashData( data );
return marcacaoEstabelecimentoData;
}
public void clear()
{
marcacaoEstabelecimentoData = null;
String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
ComponentController.clear( properties, components );
}
public void setEnabled( boolean enable )
{
String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
ComponentController.setEnabled( properties, enable, components );
}
public Class getDataClass()
{
return siprp.data.MarcacaoEstabelecimentoData.class;
}
public JLabel getDataFichaLabel()
{
return dataFichaLabel;
}
public JCalendarPanel getDataFichaPanel()
{
return dataFichaPanel;
}
public JLabel getDataLabel()
{
return dataLabel;
}
public JCalendarPanel getDataPanel()
{
return dataPanel;
}
public JButton getEmailButton()
{
return emailButton;
}
public RadioButtonFixedPanel getEstadoList()
{
return estadoList;
}
public StateTextArea getObservacoesText()
{
return observacoesText;
}
public JLabel getTecnicoLabel()
{
return tecnicoLabel;
}
public JComboBox getTecnicoList()
{
return tecnicoList;
}
}

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Document : HolterPanel.xml
Created on : 1 de Outubro de 2004, 11:17
Author : fpalma
Description:
Purpose of the document follows.
-->
<!DOCTYPE UICOMPONENT SYSTEM 'http://evolute.dyndns.tv/dtd/uicomponent.dtd' >
<UICOMPONENT DATA_CLASS="siprp.data.MarcacaoEstabelecimentoData">
<INCLUDE LANGUAGE="JAVA" >siprp.data.*</INCLUDE>
<PANEL NAME="MarcacaoVisitaHSTPanel" ROW="0" COLUMN="0">
<GRID>
<ROW TYPE="MIN"/> <!--R0-->
<ROW TYPE="MIN"/> <!--R1-->
<ROW TYPE="MIN"/> <!--R2-->
<ROW TYPE="MAX"/> <!--R3-->
<ROW TYPE="MAX"/> <!--R4-->
<COL TYPE="MIN" /> <!--C0-->
<COL TYPE="MAX" /> <!--C1-->
<COL TYPE="MAX" /> <!--C2-->
</GRID>
<!-- ROW 0 -->
<LABEL NAME="dataLabel" ROW="0" COLUMN="0">
<CAPTION>
Data da visita
</CAPTION>
</LABEL>
<EDITOR NAME="dataPanel" ROW="0" COLUMN="1" DATA_FIELD="data">
<CONTENT TYPE="DATE" />
</EDITOR>
<BUTTON NAME="emailButton" ROW="0" COLUMN="2">
<CAPTION>
Enviar Email
</CAPTION>
<SIZE>
<WIDTH PREFERRED="200" MIN="300" />
<HEIGHT PREFERRED="20" MIN="20" />
</SIZE>
</BUTTON>
<!-- ROW 1 -->
<LABEL NAME="dataFichaLabel" ROW="1" COLUMN="0">
<CAPTION>
Data do Relat\u00f3rio
</CAPTION>
</LABEL>
<EDITOR NAME="dataFichaPanel" ROW="1" COLUMN="1" DATA_FIELD="data_relatorio">
<CONTENT TYPE="DATE" />
</EDITOR>
<!-- ROW 2 -->
<LABEL NAME="tecnicoLabel" ROW="2" COLUMN="0">
<CAPTION>
T\u00e9cnico
</CAPTION>
</LABEL>
<EDITOR NAME="tecnicoList" ROW="2" COLUMN="1" EDITABLE="FALSE" DATA_FIELD="tecnico_hst">
<CONTENT TYPE="INTEGER" ISLIST="TRUE">
<ROWS>1</ROWS>
</CONTENT>
<LIST_CONTENT HAS_IDS="TRUE" SELECTABLE="TRUE" DISPLAY_COLUMNS="1">
<LIST_OPTION OPTION_ID="-1" DEFAULT="TRUE"> </LIST_OPTION>
</LIST_CONTENT>
</EDITOR>
<EDITOR NAME="estadoList" ROW="3" COLUMN="0" COLSPAN="3" EDITABLE="FALSE" DATA_FIELD="estado">
<BORDER TYPE="ETCHED">Estado</BORDER>
<CONTENT TYPE="INTEGER" ISLIST="TRUE">
<ROWS>6</ROWS>
</CONTENT>
<LIST_CONTENT HAS_IDS="TRUE" SELECTABLE="TRUE" DISPLAY_COLUMNS="1">
<LIST_OPTION OPTION_ID="0" DEFAULT="TRUE">Por realizar</LIST_OPTION>
<LIST_OPTION OPTION_ID="2">Realizada</LIST_OPTION>
<LIST_OPTION OPTION_ID="3">Desmarcada pela empresa</LIST_OPTION>
<LIST_OPTION OPTION_ID="4">Desmarcada pela SIPRP</LIST_OPTION>
</LIST_CONTENT>
</EDITOR>
<!-- ROW 4 -->
<EDITOR NAME="observacoesText" ROW="4" COLUMN="0" COLSPAN="3" DATA_FIELD="observacoes">
<BORDER TYPE="ETCHED">Observa\u00e7\u00f5es</BORDER>
<SCROLL/>
<CONTENT TYPE="CHAR" ACCEPTS_NEGATIVE="FALSE">
<ROWS>5</ROWS>
</CONTENT>
</EDITOR>
</PANEL>
</UICOMPONENT>

@ -0,0 +1,199 @@
/*
* MarcacoesHigieneUpperPanel.java
*
* Created on February 2, 2006, 12:40 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.higiene.marcacoes;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.dataui.*;
import com.evolute.utils.tables.*;
import com.evolute.utils.ui.*;
import siprp.higiene.*;
/**
*
* @author fpalma
*/
public class MarcacoesHigieneUpperPanel extends JPanel
implements ListSelectionListener, ControllableComponent
{
protected BaseTable empresasTable;
protected VectorTableModel empresasModel;
protected BaseTable estabelecimentosTable;
protected VectorTableModel estabelecimentosModel;
protected HigieneDataProvider provider;
protected final Vector listeners;
/** Creates a new instance of MedicinaUpperPanel */
public MarcacoesHigieneUpperPanel()
throws Exception
{
provider = ( HigieneDataProvider ) HigieneDataProvider.getProvider();
listeners = new Vector();
setupComponents();
}
private void setupComponents()
throws Exception
{
empresasModel = new VectorTableModel( new String[]{ "empresas" } );
empresasTable = new BaseTable( empresasModel );
empresasTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
empresasTable.setNonResizableNorReordable();
JScrollPane empresasScroll =
new JScrollPane( empresasTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
empresasTable.getSelectionModel().addListSelectionListener( this );
estabelecimentosModel = new VectorTableModel( new String[]{ "estabelecimentos" } );
estabelecimentosTable = new BaseTable( estabelecimentosModel );
estabelecimentosTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
estabelecimentosTable.setNonResizableNorReordable();
JScrollPane estabelecimentosScroll =
new JScrollPane( estabelecimentosTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
estabelecimentosTable.getSelectionModel().addListSelectionListener( this );
GridBagLayout gridbag = new GridBagLayout();
setLayout( gridbag );
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets( 1, 1, 1, 1 );
constraints.fill = GridBagConstraints.BOTH;
constraints.gridwidth = 1;
constraints.gridheight = GridBagConstraints.REMAINDER;
constraints.weightx = 0.5;
constraints.weighty = 1;
gridbag.setConstraints( empresasScroll, constraints );
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( estabelecimentosScroll, constraints );
add( empresasScroll );
add( estabelecimentosScroll );
ColumnizedMappable empresas[] = provider.getAllEmpresas();
Vector values = empresasModel.getValues();
values.addAll( Arrays.asList( empresas ) );
empresasModel.setValues( values );
}
public void valueChanged( ListSelectionEvent e )
{
Object source = e.getSource();
if( e.getValueIsAdjusting() )
{
return;
}
if( source.equals( empresasTable.getSelectionModel() ) )
{
carregarEstabelecimentos();
}
else if( source.equals( estabelecimentosTable.getSelectionModel() ) )
{
notifyListeners( e );
}
}
protected void carregarEstabelecimentos()
{
estabelecimentosTable.clearSelection();
int selected = empresasTable.getSelectedRow();
estabelecimentosModel.clearAll();
if( selected > -1 )
{
try
{
Integer empresaID = ( ( ColumnizedMappable ) empresasModel.getRowAt( selected ) ).getID();
ColumnizedMappable estabelecimentos[] = provider.getAllEstabelecimentosForEmpresa( empresaID);
Vector values = estabelecimentosModel.getValues();
values.addAll( Arrays.asList( estabelecimentos ) );
estabelecimentosModel.setValues( values );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar os estabelecimentos.", true );
estabelecimentosModel.clearAll();
}
}
}
protected void notifyListeners( ListSelectionEvent e )
{
for( int n = 0; n < listeners.size(); n++ )
{
ListSelectionEvent event =
new ListSelectionEvent( this, e.getFirstIndex(), e.getLastIndex(), e.getValueIsAdjusting() );
( ( ListSelectionListener ) listeners.elementAt( n ) ).valueChanged( event );
}
}
public void addListSelectionListener( ListSelectionListener listener )
{
listeners.add( listener );
}
public void removeSelectionListener( ListSelectionListener listener )
{
listeners.remove( listener );
}
public void clear()
{
// empresasTable.clearSelection();
}
public void fill( Object value )
{
if( value == null )
{
clear();
}
Integer ids[] = ( Integer [] ) value;
for( int n = 0; n < empresasTable.getRowCount(); n++ )
{
if( ( ( ColumnizedMappable ) empresasModel.getRowAt( n ) ).getID().equals( ids[ 0 ] ) )
{
empresasTable.setRowSelectionInterval( n, n );
break;
}
}
for( int n = 0; n < estabelecimentosTable.getRowCount(); n++ )
{
if( ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( n ) ).getID().equals( ids[ 1 ] ) )
{
estabelecimentosTable.setRowSelectionInterval( n, n );
break;
}
}
}
public Object save()
{
int empresaSelected = empresasTable.getSelectedRow();
int estabelecimentoSelected = estabelecimentosTable.getSelectedRow();
return new Integer[]{
empresaSelected == -1 ? null : ( ( ColumnizedMappable ) empresasModel.getRowAt( empresaSelected ) ).getID(),
estabelecimentoSelected == -1 ? null : ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( estabelecimentoSelected ) ).getID()
};
}
public void setEnabled( boolean enable )
{
empresasTable.setEnabled( enable );
estabelecimentosTable.setEnabled( enable );
}
}

@ -0,0 +1,519 @@
/*
* MarcacoesHigieneWindow.java
*
* Created on January 31, 2006, 11:32 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.higiene.marcacoes;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.text.*;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.arrays.*;
import com.evolute.utils.data.*;
import com.evolute.utils.jdo.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.ui.panel.*;
import com.evolute.utils.ui.search.*;
import com.evolute.utils.ui.text.*;
import com.evolute.utils.ui.window.*;
import siprp.*;
import siprp.data.*;
import siprp.higiene.*;
/**
*
* @author fpalma
*/
public class MarcacoesHigieneWindow extends EditorWindow
implements ItemListener, ActionListener, ListSelectionListener
{
public final static String TITLE = "Marca\u00e7\u00f5es de Higiene e Seguran\u00e7a";
private final static int iPermissionArray[][] =
new int[][]{ {}, { NEW_INDEX, EDIT_INDEX, CANCEL_INDEX, SAVE_INDEX, DELETE_INDEX } };
private static final int INDEX_MAIN = 0;
private static final int INDEX_VISITA = 1;
private static final DateFormat DATE_FORMAT =
DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "PT", "pt" ) );
protected MarcacoesHigieneUpperPanel upperPanel;
protected MarcacaoVisitaHSTPanel marcacaoPanel;
protected TableEditorPanel marcacaoEditorPanel;
protected HigieneDataProvider provider;
protected JDOProvider JDO;
protected SIPRPTracker tracker;
private Hashtable tecnicosHash;
protected Integer empresaID;
protected String empresa;
protected Integer estabelecimentoID;
protected EstabelecimentoData estabelecimento;
protected boolean editing = false;
/** Creates a new instance of MarcacoesHigieneWindow */
public MarcacoesHigieneWindow()
throws Exception
{
super( iPermissionArray );
provider = ( HigieneDataProvider ) HigieneDataProvider.getProvider();
JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
tecnicosHash = new Hashtable();
setupComponents();
setExtendedState(getExtendedState() | MAXIMIZED_BOTH);
}
private void setupComponents()
throws Exception
{
setTitle( TITLE );
upperPanel = new MarcacoesHigieneUpperPanel();
JPanel panel = new JPanel();
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints constraints = new GridBagConstraints();
getContentPane().setLayout( gridbag );
constraints.insets = new Insets( 2, 2, 2, 2 );
constraints.fill = GridBagConstraints.BOTH;
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.weightx = 1;
constraints.gridheight = 1;
constraints.weighty = 0.2;
gridbag.setConstraints( upperPanel, constraints );
constraints.weighty = 0.8;
gridbag.setConstraints( panel, constraints );
getContentPane().add( upperPanel );
getContentPane().add( panel );
changeGroupName( INDEX_VISITA, "Visitas" );
setActionName( INDEX_VISITA, NEW_INDEX, "Nova" );
setActionTooltip( INDEX_VISITA, NEW_INDEX, "Nova" );
JPanel toolbar = getToolbarPanel( INDEX_VISITA );
gridbag = new GridBagLayout();
// GridBagConstraints constraints = new GridBagConstraints();
panel.setLayout( gridbag );
constraints.insets = new Insets( 2, 2, 2, 2 );
constraints.fill = GridBagConstraints.BOTH;
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.weightx = 1.0;
constraints.weighty = 0;
gridbag.setConstraints( toolbar, constraints );
panel.add( toolbar );
constraints.gridheight = 1;
constraints.weighty = 1.0;
try
{
marcacaoEditorPanel =
new TableEditorPanel( new String[]{ "Data",
"Estado" },
new int[]{0,2}, new int[]{0,0},
0.0, 1.0, new Dimension( 350, 100 ) );
marcacaoPanel = new MarcacaoVisitaHSTPanel();
new CopyPasteHandler( marcacaoPanel.getObservacoesText() );
marcacaoEditorPanel.addComponent( marcacaoPanel,
new int[]{0,2}, new int[]{1,2},
1.0, 1.0 );
marcacaoEditorPanel.addListSelectionListener( new ListSelectionListener(){
public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent)
{
if( marcacaoEditorPanel.getID() != null )
{
reload(INDEX_VISITA);
select(INDEX_VISITA);
}
else
{
clear( INDEX_VISITA );
}
}
});
}catch( Exception ex )
{
DialogException.showException( ex );
return;
}
gridbag.setConstraints( marcacaoEditorPanel, constraints );
panel.add( marcacaoEditorPanel );
marcacaoPanel.getEmailButton().addActionListener( this );
fillCombo();
upperPanel.addListSelectionListener( this );
}
public void fillCombo()
throws Exception
{
marcacaoPanel.getTecnicoList().removeItemListener( this );
marcacaoPanel.getTecnicoList().removeAllItems();
tecnicosHash.clear();
Object tecnicos[][] = provider.getAllTecnicosHST();
marcacaoPanel.getTecnicoList().addItem( new MappableObject( new Integer( -2 ), " " ) );
for( int n = 0; n < tecnicos.length; n++ )
{
Object tecnico[] = new Object[ 4 ];
tecnico[ 0 ] = new Integer( ( (Number)tecnicos[n][0] ).intValue() );
tecnico[ 1 ] = tecnicos[ n ][ 1 ];
tecnico[ 2 ] = tecnicos[ n ][ 2 ];
tecnico[ 3 ] = new Integer( n );
tecnicosHash.put( tecnicos[ n ][ 0 ], tecnico );
marcacaoPanel.getTecnicoList().addItem( new MappableObject( (Integer) tecnico[ 0 ], tecnico[ 1 ] ) );
}
marcacaoPanel.getTecnicoList().setSelectedIndex( 0 );
marcacaoPanel.getTecnicoList().addItem( new MappableObject( new Integer( -1 ), "Novo/Editar" ) );
marcacaoPanel.getTecnicoList().addItemListener( this );
}
public void itemStateChanged(java.awt.event.ItemEvent itemEvent)
{
int index = marcacaoPanel.getTecnicoList().getSelectedIndex();
if( index == marcacaoPanel.getTecnicoList().getItemCount() - 1 )
{
try
{
// marcacaoPanel.getTecnicoList().removeItemListener( this );
TecnicoEditor te = new TecnicoEditor( this );
te.setVisible( true );
// boolean isNew = me.getIsNew();
Integer id = te.getID();
if( id == null )
{
marcacaoPanel.getTecnicoList().setSelectedIndex( 0 );
}
else
{
fillCombo();
if( id != null )
{
Object[] tecnico = (Object[])tecnicosHash.get( id );
marcacaoPanel.getTecnicoList().setSelectedIndex( ((Integer)tecnico[ 3 ] ).intValue() );
}
}
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro na janela de edi\u00e7\u00e3o...", true );
ex.printStackTrace();
marcacaoPanel.getTecnicoList().setSelectedIndex( 0 );
return;
}
// finally
// {
// marcacaoPanel.getTecnicoList().addItemListener( this );
// }
}
else
{
IDObject selected = (IDObject)marcacaoPanel.getTecnicoList().getItemAt( index );
Integer id = selected.getID();
}
}
public boolean save(int index)
{
switch( index )
{
case INDEX_VISITA:
MarcacaoEstabelecimentoData visita = ( MarcacaoEstabelecimentoData ) marcacaoPanel.save();
Date data = ( Date ) visita.get( MarcacaoEstabelecimentoData.DATA );
if( data == null )
{
JOptionPane.showMessageDialog( this, "Tem de preencher uma data para a visita.",
"Erro", JOptionPane.ERROR_MESSAGE );
return false;
}
visita.set( MarcacaoEstabelecimentoData.ESTABELECIMENTO, estabelecimento );
try
{
visita.set( MarcacaoEstabelecimentoData.REALIZADA,
( ( Integer )visita.get( MarcacaoEstabelecimentoData.ESTADO ) ).intValue() ==
provider.ESTADO_REALIZADO ? "y" : "n" );
System.out.println( "DATA " + visita.get( MarcacaoEstabelecimentoData.DATA ) );
Integer tecnico = ( Integer ) visita.get( MarcacaoEstabelecimentoData.TECNICO_HST );
if( tecnico != null && tecnico.intValue() < 0 )
{
visita.set( MarcacaoEstabelecimentoData.TECNICO_HST, null );
}
visita.save();
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a gravar", true );
return false;
}
break;
}
reload( INDEX_MAIN );
editing = false;
return true;
}
public boolean delete(int index)
{
int option = JOptionPane.showConfirmDialog( this, "Tem a certeza que quer apagar a marca\u00e7\u00e3o?",
"Apagar", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE );
if( option == 0 )
{
switch( index )
{
case INDEX_VISITA:
MarcacaoEstabelecimentoData visita = ( MarcacaoEstabelecimentoData ) marcacaoPanel.save();
try
{
visita.delete();
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a apagar.", true );
return false;
}
break;
}
reload( INDEX_MAIN );
return true;
}
return false;
}
public void clear(int index)
{
switch( index )
{
case INDEX_MAIN:
empresaID = null;
empresa = null;
estabelecimentoID = null;
estabelecimento = null;
upperPanel.clear();
marcacaoEditorPanel.clear();
break;
case INDEX_VISITA:
marcacaoPanel.clear();
marcacaoPanel.getEmailButton().setText( "Enviar email" );
break;
}
}
public void enableComponents(int index, boolean enable)
{
switch( index )
{
case INDEX_MAIN:
break;
case INDEX_VISITA:
marcacaoPanel.setEnabled( enable );
marcacaoPanel.getEmailButton().setEnabled( enable );
upperPanel.setEnabled( !enable );
editing = enable;
break;
}
if( tracker != null )
{
tracker.getAvisosPanel().setEnabled( !editing,
AvisoConstants.TIPO_ESTABELECIMENTO );
}
}
protected void enableSelect( int index, boolean select )
{
switch( index )
{
case INDEX_VISITA:
marcacaoEditorPanel.setEnabled( select );
break;
}
}
public void reload( int index )
{
switch( index )
{
case INDEX_MAIN:
try
{
empresa = provider.getEmpresa( empresaID );
estabelecimento = ( EstabelecimentoData ) JDO.load( EstabelecimentoData.class, estabelecimentoID );
// upperPanel.getEmpresaText().setText( empresa );
// upperPanel.getEstabelecimentoText().setText( estabelecimento );
// upperPanel.getTrabalhadorText().setText( ( String ) trabalhador.get( TrabalhadorData.NOME ) );
Object visitas[][] = provider.getVisitasEstabelecimento( estabelecimentoID );
if( visitas.length > 0 )
{
marcacaoEditorPanel.setData( new Object2DArray( visitas ) );
}
else
{
marcacaoEditorPanel.clear();
}
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar os dados.", true );
}
break;
case INDEX_VISITA:
Integer visitaID = marcacaoEditorPanel.getID();
if( visitaID == null )
{
return;
}
try
{
MarcacaoEstabelecimentoData visita =
( MarcacaoEstabelecimentoData ) JDO.load( MarcacaoEstabelecimentoData.class, visitaID );
marcacaoPanel.fill( visita );
Date dataEmailVisita = ( Date ) visita.get( MarcacaoEstabelecimentoData.DATA_EMAIL );
if( dataEmailVisita != null )
{
marcacaoPanel.getEmailButton().setText( "Enviar email (" + DATE_FORMAT.format( dataEmailVisita ) + ")" );
}
else
{
marcacaoPanel.getEmailButton().setText( "Enviar email" );
}
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar os dados da visita.", true );
}
break;
}
}
public void actionPerformed( ActionEvent e )
{
Object source = e.getSource();
if( source.equals( marcacaoPanel.getEmailButton() ) )
{
enviarEmailVisita();
}
}
protected void enviarEmailVisita()
{
MarcacaoEstabelecimentoData visita = ( MarcacaoEstabelecimentoData ) marcacaoPanel.save();
String subject = ( String ) Singleton.getInstance( SingletonConstants.SUBJECT_VISITA );
String texto = ( String ) Singleton.getInstance( SingletonConstants.LETTER_VISITA );
Date today = new Date();
marcacaoPanel.getEmailButton().setText( "Enviar email (" + DATE_FORMAT.format( today ) + ")" );
try
{
enviarEmail( subject, texto, ( Date )visita.get( MarcacaoEstabelecimentoData.DATA ) );
visita.set( Marcacao.DATA_EMAIL, today );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a enviar mail", true );
}
}
protected void enviarEmail( String subject, String texto, Date data )
throws Exception
{
String sede = ( String )estabelecimento.get( EstabelecimentoData.NOME );
String dataStr = DATE_FORMAT.format( data );
subject = subject.replaceAll( CompanyDataLoader.NOME, sede );
String morada = ( String )estabelecimento.get( EstabelecimentoData.MORADA );
texto = texto.replaceAll( CompanyDataLoader.DATA, dataStr );
texto = texto.replaceAll( CompanyDataLoader.NOME, sede );
texto = texto.replaceAll( CompanyDataLoader.MORADA, morada );
ContactoData contacto = ( ContactoData )estabelecimento.get( EstabelecimentoData.CONTACTO );
String mail = "";
if( contacto != null )
{
mail = ( String )contacto.get( ContactoData.EMAIL );
}
if( System.getProperty( "os.name" ).startsWith( "Windows" ) )
{
mail = mail.replaceAll( " ", "%20" );
subject = subject.replaceAll( " ", "%20" );
texto = texto.replaceAll( " ", "%20" );
Process proc = Runtime.getRuntime().exec( "cmd.exe /c start mailto:\"" + mail
+ "?subject=" + subject + "&body="
+ texto
);
}
else
{
mail = mail.replaceAll( " ", "%20" );
subject = subject.replaceAll( " ", "%20" );
texto = texto.replaceAll( " ", "%20" );
Process proc = Runtime.getRuntime().exec( new String[]{ "/usr/bin/open", "/Applications/Mail.app", "mailto:" + mail
+ "?subject=" + subject + "&body="
+ texto } );
}
}
public void valueChanged( ListSelectionEvent e )
{
Object source = e.getSource();
if( source.equals( upperPanel ) )
{
Integer ids[] = ( Integer [] ) upperPanel.save();
empresaID = ids[ 0 ];
estabelecimentoID = ids[ 1 ];
if( ids[ 1 ] == null )
{
clear( INDEX_MAIN );
unselect( INDEX_MAIN );
}
else
{
reload( INDEX_MAIN );
select( INDEX_MAIN );
}
}
}
public void setEmpresaAndEstabelecimento( Integer empresaID, Integer estabelecimentoID )
{
if( editing )
{
JOptionPane.showMessageDialog( this, "Esta janela est\u00e1 em edi\u00e7\u00e3o.", "Erro...",
JOptionPane.ERROR_MESSAGE );
}
else
{
upperPanel.fill( new Integer[]{ empresaID, estabelecimentoID } );
}
}
public void setTracker( SIPRPTracker tracker )
{
this.tracker = tracker;
}
}

@ -0,0 +1,317 @@
/*
* TecnicoEditor.java
*
* Created on February 1, 2006, 10:55 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.higiene.marcacoes;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.jdo.*;
import com.evolute.utils.tables.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.ui.button.*;
import com.evolute.utils.ui.text.*;
import siprp.*;
import siprp.data.*;
import siprp.higiene.*;
/**
*
* @author fpalma
*/
public class TecnicoEditor extends CustomJDialog
implements ActionListener, ListSelectionListener
// , ItemListener
{
static
{
TecnicoHSTData.registerOperationHandlerForClass( DisableDeleteHandler.INSTANCE, TecnicoHSTData.class );
}
private JDOProvider JDO;
private HigieneDataProvider provider;
private BaseTable table;
private VectorTableModel model;
private JButton okButton;
private JButton cancelarButton;
private JButton novoButton;
private JTextField nomeText;
private JTextField iniciaisText;
// private JComboBox corCombo;
private Integer id;
private boolean isNew = false;
private BetterButtonGroup corGroup;
private JRadioButton cores[];
/** Creates a new instance of MedicoEditor */
public TecnicoEditor( JFrame owner )
throws Exception
{
super( owner, true );
provider = (HigieneDataProvider)HigieneDataProvider.getProvider();
JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
setupComponents();
}
private void setupComponents()
throws Exception
{
setSize( 600, 300 );
setResizable( false );
setTitle( "Criar/Editar T\u00e9cnico" );
centerSuper();
model = new VectorTableModel( new String[]{ "Nome", "Iniciais", "Cor" } );
table = new BaseTable( model );
table.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
table.setTableCellRenderer( new TecnicoRenderer() );
JScrollPane scp = new JScrollPane();
scp.setMinimumSize( new Dimension( 300, 200 ) );
scp.setMaximumSize( new Dimension( 300, 200 ) );
scp.setPreferredSize( new Dimension( 300, 200 ) );
scp.setSize( new Dimension( 300, 200 ) );
scp.setViewportView( table );
scp.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
scp.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
table.fixColumnWidth( 0, 200 );
table.setNonResizableNorReordable();
table.getSelectionModel().addListSelectionListener( this );
Object obj[][] = provider.getAllTecnicosHST();
Vector tecnicosHST = new Vector();
for( int n = 0; n < obj.length; n++ )
{
tecnicosHST.add( new ColumnizedObjectArray( obj[ n ], true ) );
}
model.setValues( tecnicosHST );
okButton = new JButton( "OK" );
cancelarButton = new JButton( "Cancelar" );
novoButton = new JButton( "Novo" );
okButton.addActionListener( this );
cancelarButton.addActionListener( this );
novoButton.addActionListener( this );
nomeText = new JTextField();
nomeText.setEnabled( false );
iniciaisText = new JTextField();
iniciaisText.setEnabled( false );
JPanel corPanel = new JPanel();
corPanel.setLayout( new BoxLayout( corPanel, BoxLayout.Y_AXIS ) );
// corCombo = new JComboBox();
corGroup = new BetterButtonGroup( false );
cores = new JRadioButton[ HigieneDataProvider.CORES_TECNICOS.length ];
for( int n = 0; n < HigieneDataProvider.CORES_TECNICOS.length; n++ )
{
cores[ n ] = new JRadioButton( " " );
cores[ n ].setBackground( HigieneDataProvider.CORES_TECNICOS[ n ] );
corPanel.add( cores[ n ] );
corGroup.add( cores[ n ] );
// corCombo.addItem( new Integer( n ) );
}
JScrollPane corScroll =
new JScrollPane( corPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
// corCombo.setRenderer( new CorTecnicoCellRenderer() );
// corCombo.setEnabled( false );
GridBagLayout gridbag = new GridBagLayout();
getContentPane().setLayout( gridbag );
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets( 1, 1, 1, 1 );
constraints.fill = GridBagConstraints.BOTH;
constraints.weighty = 1;
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.gridheight = 1;
JPanel upperPanel = new JPanel();
upperPanel.setLayout( new GridLayout( 1, 2 ) );
upperPanel.add( scp );
JPanel textPanel = new JPanel();
upperPanel.add( textPanel );
gridbag.setConstraints( upperPanel, constraints );
getContentPane().add( upperPanel );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weighty = 0;
constraints.weightx = 0.3;
constraints.gridwidth = 1;
constraints.gridheight = GridBagConstraints.REMAINDER;;
gridbag.setConstraints( novoButton, constraints );
getContentPane().add( novoButton );
gridbag.setConstraints( okButton, constraints );
getContentPane().add( okButton );
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( cancelarButton, constraints );
getContentPane().add( cancelarButton );
gridbag = new GridBagLayout();
textPanel.setLayout( gridbag );
constraints.weighty = 0;
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.gridheight = 1;
JLabel nomeLabel = new JLabel( "Nome" );
gridbag.setConstraints( nomeLabel, constraints );
textPanel.add( nomeLabel );
gridbag.setConstraints( nomeText, constraints );
textPanel.add( nomeText );
JLabel iniciaisLabel = new JLabel( "Iniciais" );
gridbag.setConstraints( iniciaisLabel, constraints );
textPanel.add( iniciaisLabel );
gridbag.setConstraints( iniciaisText, constraints );
textPanel.add( iniciaisText );
JLabel corLabel = new JLabel( "Cor" );
gridbag.setConstraints( corLabel, constraints );
textPanel.add( corLabel );
// gridbag.setConstraints( corCombo, constraints );
// textPanel.add( corCombo );
//
constraints.weighty = 1;
constraints.gridheight = GridBagConstraints.REMAINDER;
constraints.fill = GridBagConstraints.BOTH;
// JPanel pad = new JPanel();
// gridbag.setConstraints( pad, constraints );
// textPanel.add( pad );
gridbag.setConstraints( corScroll, constraints );
textPanel.add( corScroll );
new CopyPasteHandler( nomeText );
new CopyPasteHandler( iniciaisText );
// corCombo.addItemListener( this );
}
public void actionPerformed( ActionEvent e )
{
if( e.getSource().equals( okButton ) )
{
if( save() )
{
close();
}
}
else if( e.getSource().equals( cancelarButton ) )
{
close();
}
if( e.getSource().equals( novoButton ) )
{
table.getSelectionModel().removeListSelectionListener( this );
nomeText.setText( "" );
iniciaisText.setText( "" );
// corCombo.setSelectedIndex( 0 );
corGroup.setIntSelected( 0 );
nomeText.setEnabled( true );
iniciaisText.setEnabled( true );
corGroup.setEnabled( true );
id = null;
isNew = true;
}
}
public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent)
{
int selected = table.getSelectedRow();
if( selected == -1 )
{
return;
}
ColumnizedObjectArray row = (ColumnizedObjectArray)model.getRowAt( selected );
id = row.getID();
String nome = (String) row.getValue( 0 );
String iniciais = (String) row.getValue( 1 );
Integer cor = ( Integer ) row.getValue( 2 );
nomeText.setText( nome );
iniciaisText.setText( iniciais );
// corCombo.setSelectedIndex( cor.intValue() );
corGroup.setIntSelected( cor.intValue() );
nomeText.setEnabled( true );
iniciaisText.setEnabled( true );
// corCombo.setEnabled( true );
corGroup.setEnabled( true );
}
private void close()
{
setVisible( false );
dispose();
}
public boolean getIsNew()
{
return isNew;
}
public Integer getID()
{
return id;
}
private boolean save()
{
String nome = nomeText.getText().trim();
String nomePlain = com.evolute.utils.strings.StringPlainer.convertString( nome );
String iniciais = iniciaisText.getText().trim();
Integer cor = new Integer( corGroup.getIntSelected() );
if( nome.length() == 0 || iniciais.length() == 0 )
{
JOptionPane.showMessageDialog( this, "O Nome e as iniciais n\u00e3o podem ser vazios.", "Erro...",
JOptionPane.ERROR_MESSAGE );
return false;
}
try
{
TecnicoHSTData tecnico;
if( id != null )
{
tecnico = ( TecnicoHSTData ) JDO.load( TecnicoHSTData.class, id );
}
else
{
tecnico = new TecnicoHSTData();
}
tecnico.set( TecnicoHSTData.NOME, nome );
tecnico.set( TecnicoHSTData.NOME_PLAIN, nomePlain );
tecnico.set( TecnicoHSTData.INICIAIS, iniciais );
tecnico.set( TecnicoHSTData.IDENTIFICADOR, cor );
tecnico.save();
if( id == null )
{
id = (Integer)tecnico.get( TecnicoHSTData.ID );
}
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a gravar...", false );
return false;
}
return true;
}
// public void itemStateChanged( ItemEvent e )
// {
// corCombo.getEditor().getEditorComponent().setBackground( HigieneDataProvider.CORES_TECNICOS[ corCombo.getSelectedIndex() ] );
// }
}

@ -0,0 +1,58 @@
/*
* DiaRenderer.java
*
* Created on 8 de Fevereiro de 2006, 21:45
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.higiene.marcacoes;
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
import siprp.higiene.*;
/**
*
* @author Frederico
*/
public class TecnicoRenderer
implements TableCellRenderer
{
protected JLabel labels[];
protected Color defaultColor;
/** Creates a new instance of DiaRenderer */
public TecnicoRenderer()
{
labels = new JLabel[ 3 ];
for( int n = 0; n < 3; n++ )
{
labels[ n ] = new JLabel();
}
defaultColor = labels[ 0 ].getBackground();
labels[ 2 ].setOpaque( true );
}
public Component getTableCellRendererComponent( JTable table, Object value,
boolean isSelected,
boolean hasFocus,
int row, int column )
{
switch( column )
{
case 2:
labels[ 2 ].setText( " " );
labels[ 2 ].setBackground( value == null ? defaultColor :
HigieneDataProvider.CORES_TECNICOS[ ( ( Integer ) value ).intValue() ] );
break;
default:
labels[ column ].setText( ( String ) value );
break;
}
return labels[ column ];
}
}

@ -0,0 +1,146 @@
/*
* FichasPrinter.java
*
* Created on 20 de Fevereiro de 2006, 0:43
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.impressaofichas;
import java.io.*;
import java.text.*;
import java.util.*;
import javax.xml.transform.*;
import com.evolute.utils.*;
import com.evolute.utils.date.*;
import com.evolute.utils.fop.*;
import com.evolute.utils.jdo.*;
import com.evolute.utils.strings.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.xml.*;
import siprp.data.*;
import siprp.ficha.*;
/**
*
* @author Frederico
*/
public class FichasPrinter extends Thread
{
protected static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
protected static final DateFormat D_F_L = DateFormat.getDateInstance( DateFormat.LONG, new Locale( "pt", "PT" ) );
private ImpressaoFichasDataProvider provider;
protected Integer ids[];
protected String printerName;
protected String listPath;
protected String nomeEmpresa;
protected String nomeEstabelecimento;
/** Creates a new instance of FichasPrinter */
public FichasPrinter( Integer ids[], String printerName, String listPath,
String nomeEmpresa, String nomeEstabelecimento )
{
this.ids = ids;
this.printerName = printerName;
this.listPath = listPath;
this.nomeEmpresa = nomeEmpresa;
this.nomeEstabelecimento = nomeEstabelecimento;
}
public void run()
{
try
{
SimpleXMLElement root = new SimpleXMLElement( "LISTA_FICHAS" );
for( int n = 0; n < ids.length; n++ )
{
print( ids[ n ] );
Object dados[] = provider.getDadosForExameID( ids[ n ] );
SimpleXMLElement linha = new SimpleXMLElement( "FICHA" );
linha.addElement( new SimpleXMLElement( "NOME", ( String ) dados[ 0 ] ) );
linha.addElement( new SimpleXMLElement( "DATA_EXAME", D_F.format( ( Date ) dados[ 1 ] ) ) );
linha.addElement( new SimpleXMLElement( "DATA_PROXIMO_EXAME", dados[ 2 ] != null ? D_F.format( ( Date ) dados[ 2 ] ) : "n/d" ) );
root.addElement( linha );
try
{
sleep( (n % 5 == 0 && n > 0) ? 3000 : 2000 );
}
catch( InterruptedException iex )
{
}
}
Date today = ( Date ) Singleton.getInstance( Singleton.TODAY );
Calendar cal = Calendar.getInstance();
cal.setTime( today );
SimpleXMLElement data = new SimpleXMLElement( "DATA_EXTENSO", DateUtils.WEEKDAYS_FULL_PT[ cal.get( Calendar.DAY_OF_WEEK ) - Calendar.MONDAY ]
+ ", " + D_F_L.format( today ) );
root.addElement( data );
TransformerFactory tFactory = TransformerFactory.newInstance();
String xml = root.toString();
ByteArrayOutputStream out = new ByteArrayOutputStream();
FOPCreator creator = new FOPCreator();
InputStream xmlIn = new ByteArrayInputStream( xml.getBytes() );
creator.createFOfromXML( xmlIn,
FichasPrinter.class.getClassLoader().getResourceAsStream(
"siprp/impressaofichas/lista_fichas.xsl" ),
out );
byte toPrint[] = out.toByteArray();
ByteArrayInputStream in = new ByteArrayInputStream( toPrint );
Hashtable printOptions = new Hashtable();
//System.out.println( "OUT: " + out.toString() );
new FOPPrinter().printFO( in, false, true, printOptions );
byte []pdfData = new PDFCreator().createPdfFromFo( toPrint );
File dir = new File( new File( listPath ), StringPlainer.convertString( nomeEmpresa ).replace( ' ', '_' ) );
if( !dir.exists() )
{
dir.mkdir();
}
String fileName = StringPlainer.convertString( nomeEstabelecimento ).replace( ' ', '_' )
+ "_" + DateUtils.plainFormatDate( today ) + ".pdf";
FileOutputStream fos = new FileOutputStream( new File( dir, fileName ) );
fos.write( pdfData );
fos.close();
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a imprimir", true );
}
ids = null;
}
private void print( Integer exameID )
throws Exception
{
if( provider == null )
{
provider = ( ImpressaoFichasDataProvider ) ImpressaoFichasDataProvider.getProvider();
}
// MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) );
// ExameData exame = (ExameData) JDO.load( ExameData.class, exameID );
// byte pdf[] = (byte []) exame.get( ExameData.PDF );
byte pdf[] = provider.getPDF( exameID );
if( pdf == null )
{
throw new Exception( "N\u00e3o existe exame" );
}
// TrabalhadorData trabalhadorExame = ( TrabalhadorData ) exame.get( ExameData.TRABALHADOR );
// String nomeFicheiro = StringPlainer.convertString( ( String ) trabalhadorExame.get( TrabalhadorData.NOME ) );
String nomeFicheiro = StringPlainer.convertString( provider.getNomeTrabalhadorForExameID( exameID ) );
// nomeFicheiro.replaceAll( " ", "_" );
String split[] = nomeFicheiro.split( " " );
nomeFicheiro = "";
for( int n = 0; n < split.length; n++ )
{
nomeFicheiro += split[ n ] + "_";
}
ExamePDF ePDF = new ExamePDF();
ePDF.printSilent( pdf, nomeFicheiro, printerName );
}
}

@ -0,0 +1,217 @@
/*
* HigieneDataProvider.java
*
* Created on February 1, 2006, 10:49 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.impressaofichas;
import java.text.*;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.arrays.*;
import com.evolute.utils.data.*;
import com.evolute.utils.db.*;
import com.evolute.utils.metadb.*;
import com.evolute.utils.sql.*;
import com.evolute.utils.strings.*;
import com.evolute.utils.tables.*;
import siprp.*;
import siprp.data.*;
/**
*
* @author fpalma
*/
public class ImpressaoFichasDataProvider extends MetaProvider
{
private static final DateFormat DATE_FORMAT =
DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "PT", "pt" ) );
private static final Object LOCK = new Object();
private static ImpressaoFichasDataProvider instance = null;
private final Executer executer;
/** Creates a new instance of HigieneDataProvider */
public ImpressaoFichasDataProvider()
throws Exception
{
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ );
executer = dbm.getSharedExecuter( this );
}
public static MetaProvider getProvider()
throws Exception
{
synchronized( LOCK )
{
if( instance == null )
{
instance = new ImpressaoFichasDataProvider();
}
}
return instance;
}
public ColumnizedMappable[] getAllEmpresas()
throws Exception
{
Select select =
new Select( new String[]{ "empresas" },
new String[]{ "id", "designacao_social", "designacao_social_plain" },
new Field( "inactivo" ).isDifferent( "y" ),
new String[]{ "designacao_social_plain" },
null );
Virtual2DArray array = executer.executeQuery( select );
ColumnizedMappable empresas[] = new ColumnizedMappable[ array.columnLength() ];
for( int n = 0; n < empresas.length; n++ )
{
Integer id = ( Integer ) array.get( n, 0 );
String designacao = ( String ) array.get( n, 1 );
empresas[ n ] = new ColumnizedMappable( id, designacao );
}
return empresas;
}
public ColumnizedMappable[] getAllEstabelecimentosForEmpresa( Integer empresaID )
throws Exception
{
Select select =
new Select( new String[]{ "estabelecimentos" },
new String[]{ "id", "nome", "nome_plain" },
new Field( "empresa_id" ).isEqual( empresaID ).and(
new Field( "inactivo" ).isDifferent( "y" ) ),
new String[]{ "nome_plain" },
null );
Virtual2DArray array = executer.executeQuery( select );
ColumnizedMappable estabelecimentos[] = new ColumnizedMappable[ array.columnLength() ];
for( int n = 0; n < estabelecimentos.length; n++ )
{
Integer id = ( Integer ) array.get( n, 0 );
String nome = ( String ) array.get( n, 1 );
estabelecimentos[ n ] = new ColumnizedMappable( id, nome );
}
return estabelecimentos;
}
public Object [][]getAllFichasForEstabelecimentoAndDatas( Integer estabelecimentoID, Date dataInicio, Date dataFim )
throws Exception
{
Vector fichas = new Vector();
Select select =
new Select( new String[]{ "trabalhadores" },
new String[]{ "id", "nome", "nome_plain" },
new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ),
new String[]{ "nome_plain" },
null );
Virtual2DArray array = executer.executeQuery( select );
for( int n = 0; n < array.columnLength(); n++ )
{
Integer id = ( Integer ) array.get( n, 0 );
String nome = ( String ) array.get( n, 1 );
String nomePlain = ( String ) array.get( n, 2 );
MappableObject fichasTrabalhador[] = getAllFichasForTrabalhadorAndDatas( id, dataInicio, dataFim );
for( int f = 0; f < fichasTrabalhador.length; f++ )
{
fichas.add( new Object[]{ fichasTrabalhador[ f ].getID(), nome, fichasTrabalhador[ f ].getValue(), nomePlain } );
}
}
Object fichasArray[][] = ( Object[][] )fichas.toArray( new Object[ fichas.size() ][] );
Arrays.sort( fichasArray, new Comparator(){
public int compare( Object o1, Object o2 )
{
Object arr1[] = ( Object[] )o1;
Object arr2[] = ( Object[] )o2;
int res = 0;
if( arr1[ 2 ] == null && arr2[ 2 ] == null )
{
res = 0;
}
else if( arr1[ 2 ] == null )
{
res = -1;
}
else if( arr2[ 2 ] == null )
{
res = 1;
}
else
{
res = ( (Date)arr1[ 2 ]).compareTo( (Date)arr2[ 2 ] );
}
if( res == 0 )
{
res = ( (String)arr1[ 3 ]).compareTo( (String)arr2[ 3 ] );
}
return res;
}
} );
for( int n = 0; n < fichasArray.length; n++ )
{
fichasArray[ n ][ 2 ] = fichasArray[ n ][ 2 ] != null? DATE_FORMAT.format( (Date)fichasArray[ n ][ 2 ] ): "";
}
return fichasArray;
}
public MappableObject []getAllFichasForTrabalhadorAndDatas( Integer trabalhadorID, Date dataInicio, Date dataFim )
throws Exception
{
Select select =
new Select( new String[]{ "exames" }, new String[]{ "MAX(id)", "data" },
new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and(
new Field( "inactivo" ).isEqual( "n" ) ).and(
new Field( "data" ).between( new Object[]{ dataInicio, dataFim } ) ),
new String[]{ "data DESC" }, new String[]{ "data" } );
Virtual2DArray array = executer.executeQuery( select );
MappableObject exames[] = new MappableObject[ array.columnLength() ];
for( int n = 0; n < exames.length; n++ )
{
Date date = (Date)array.get( n, 1 );
Integer id = new Integer( ((Number)array.get( n, 0 )).intValue() );
exames[ n ] = new MappableObject( id, date );
}
return exames;
}
public byte[] getPDF( Integer exameID )
throws Exception
{
Select select =
new Select( new String[]{ "exames" },
new String[]{ "pdf" },
new Field( "id" ).isEqual( exameID ) );
Virtual2DArray array = executer.executeQuery( select );
byte pdf[] = ( byte[] ) array.get( 0, 0 );
return pdf;
}
public String getNomeTrabalhadorForExameID( Integer exameID )
throws Exception
{
Select select =
new Select( new String[]{ "exames", "trabalhadores" },
new String[]{ "trabalhadores.nome_plain" },
new Field( "exames.id" ).isEqual( exameID ).and(
new Field( "exames.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ) );
Virtual2DArray array = executer.executeQuery( select );
return ( String ) array.get( 0, 0 );
}
public Object[] getDadosForExameID( Integer exameID )
throws Exception
{
Select select =
new Select( new String[]{ "exames", "trabalhadores" },
new String[]{ "trabalhadores.nome", "exames.data", "exames.proximo_exame" },
new Field( "exames.id" ).isEqual( exameID ).and(
new Field( "exames.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ) );
Virtual2DArray array = executer.executeQuery( select );
return array.getObjects()[ 0 ];
}
}

@ -0,0 +1,421 @@
/*
* ImpressaoFichasUpperPanel.java
*
* Created on 19 de Fevereiro de 2006, 19:00
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.impressaofichas;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.print.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import com.evolute.utils.properties.*;
import com.evolute.utils.tables.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.ui.window.*;
/**
*
* @author Frederico
*/
public class ImpressaoFichasWindow extends EditorWindow
implements ListSelectionListener, ActionListener
{
public final static String TITLE = "Impress\u00e3o de Fichas de Aptid\u00e3o";
protected final static String PATH_PROPERTY_SUFFIX = ".path";
private final static int iPermissionArray[][] =
new int[][]{ {} };
protected JCalendarPanel dataInicioPanel;
protected JCalendarPanel dataFimPanel;
protected VectorTableModel empresasModel;
protected BaseTable empresasTable;
protected VectorTableModel estabelecimentosModel;
protected BaseTable estabelecimentosTable;
protected VectorTableModel fichasModel;
protected BaseTable fichasTable;
protected JButton procurarButton;
protected JTextField pathText;
protected JButton pathButton;
protected JComboBox impressorasCombo;
protected JButton imprimirButton;
protected JButton imprimirTodasButton;
protected ImpressaoFichasDataProvider provider;
protected PropertyHandler propertyHandler;
/** Creates a new instance of ImpressaoFichasUpperPanel */
public ImpressaoFichasWindow()
throws Exception
{
super( iPermissionArray );
provider = ( ImpressaoFichasDataProvider ) ImpressaoFichasDataProvider.getProvider();
propertyHandler = new PropertyHandler();
setupComponents();
}
private void setupComponents()
throws Exception
{
setTitle( TITLE );
empresasModel = new VectorTableModel( new String[]{ "empresas" } );
empresasTable = new BaseTable( empresasModel );
empresasTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
empresasTable.setNonResizableNorReordable();
JScrollPane empresasScroll =
new JScrollPane( empresasTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
empresasTable.getSelectionModel().addListSelectionListener( this );
estabelecimentosModel = new VectorTableModel( new String[]{ "estabelecimentos" } );
estabelecimentosTable = new BaseTable( estabelecimentosModel );
estabelecimentosTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
estabelecimentosTable.setNonResizableNorReordable();
JScrollPane estabelecimentosScroll =
new JScrollPane( estabelecimentosTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
estabelecimentosTable.getSelectionModel().addListSelectionListener( this );
fichasModel = new VectorTableModel( new String[]{ "trabalhador", "data" } );
fichasTable = new BaseTable( fichasModel );
fichasTable.fixColumnWidth( 1, 120 );
fichasTable.setNonResizableNorReordable();
fichasTable.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
fichasTable.getSelectionModel().addListSelectionListener( this );
JScrollPane fichasScroll = new JScrollPane( fichasTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
JLabel inicioLabel = new JLabel( "In\u00edcio" );
dataInicioPanel = new JCalendarPanel( null );
JLabel fimLabel = new JLabel( "Fim" );
dataFimPanel = new JCalendarPanel( null );
procurarButton = new JButton( "Carregar" );
procurarButton.addActionListener( this );
procurarButton.setEnabled( false );
pathText = new JTextField();
pathText.setEditable( false );
pathButton = new JButton( "Escolher Direct\u00f3rio" );
pathButton.addActionListener( this );
impressorasCombo = new JComboBox();
PrintService printers[] = PrintServiceLookup.lookupPrintServices( null, null );
for( int n = 0; n < printers.length; n++ )
{
impressorasCombo.addItem( printers[ n ].getName() );
}
imprimirButton = new JButton( "Imprimir escolhidas" );
imprimirButton.addActionListener( this );
imprimirButton.setEnabled( false );
imprimirTodasButton = new JButton( "Imprimir Todas" );
imprimirTodasButton.addActionListener( this );
imprimirTodasButton.setEnabled( false );
JPanel upperPad = new JPanel();
JPanel lowerPad = new JPanel();
JPanel upperPanel = new JPanel();
GridBagLayout gridbag = new GridBagLayout();
setLayout( gridbag );
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets( 1, 1, 1, 1 );
constraints.fill = GridBagConstraints.BOTH;
constraints.gridheight = 1;
constraints.weighty = 0.35;
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( upperPanel, constraints );
constraints.gridwidth = 2;
constraints.weightx = 1;
constraints.weighty = 0.65;
constraints.gridheight = GridBagConstraints.REMAINDER;
gridbag.setConstraints( fichasScroll, constraints );
constraints.weighty = 0;
constraints.gridheight = 1;
constraints.weightx = 0;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( inicioLabel, constraints );
gridbag.setConstraints( dataInicioPanel, constraints );
gridbag.setConstraints( fimLabel, constraints );
gridbag.setConstraints( dataFimPanel, constraints );
gridbag.setConstraints( procurarButton, constraints );
gridbag.setConstraints( pathText, constraints );
gridbag.setConstraints( pathButton, constraints );
gridbag.setConstraints( impressorasCombo, constraints );
gridbag.setConstraints( imprimirButton, constraints );
gridbag.setConstraints( imprimirTodasButton, constraints );
constraints.weighty = 0.32;
gridbag.setConstraints( upperPad, constraints );
gridbag.setConstraints( lowerPad, constraints );
add( upperPanel );
add( fichasScroll );
add( upperPad );
add( inicioLabel );
add( dataInicioPanel );
add( fimLabel );
add( dataFimPanel );
add( procurarButton );
add( lowerPad );
add( pathButton );
add( pathText );
add( impressorasCombo );
add( imprimirButton );
add( imprimirTodasButton );
upperPanel.setLayout( new GridLayout( 1, 2 ) );
upperPanel.add( empresasScroll );
upperPanel.add( estabelecimentosScroll );
ColumnizedMappable empresas[] = provider.getAllEmpresas();
Vector values = empresasModel.getValues();
values.addAll( Arrays.asList( empresas ) );
empresasModel.setValues( values );
Properties properties = propertyHandler.load();
System.out.println( properties );
String path = (String) properties.get( getClass().getName() + PATH_PROPERTY_SUFFIX );
if( path == null )
{
setDirectorio( System.getProperty( "user.home" ) );
}
else
{
pathText.setText( path );
}
}
public void valueChanged( ListSelectionEvent e )
{
Object source = e.getSource();
if( e.getValueIsAdjusting() )
{
return;
}
if( source.equals( empresasTable.getSelectionModel() ) )
{
carregarEstabelecimentos();
}
else if( source.equals( estabelecimentosTable.getSelectionModel() ) )
{
procurarButton.setEnabled( estabelecimentosTable.getSelectedRow() != -1 );
}
else if( source.equals( fichasTable.getSelectionModel() ) )
{
imprimirButton.setEnabled( fichasTable.getSelectedRow() != -1 );
}
}
protected void carregarEstabelecimentos()
{
estabelecimentosTable.clearSelection();
int selected = empresasTable.getSelectedRow();
estabelecimentosModel.clearAll();
if( selected > -1 )
{
try
{
Integer empresaID = ( ( ColumnizedMappable ) empresasModel.getRowAt( selected ) ).getID();
ColumnizedMappable estabelecimentos[] = provider.getAllEstabelecimentosForEmpresa( empresaID);
Vector values = estabelecimentosModel.getValues();
values.addAll( Arrays.asList( estabelecimentos ) );
estabelecimentosModel.setValues( values );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar os estabelecimentos.", true );
estabelecimentosModel.clearAll();
}
}
}
public void clear()
{
empresasTable.clearSelection();
}
public void fill( Object value )
{
if( value == null )
{
clear();
}
Integer ids[] = ( Integer [] ) value;
for( int n = 0; n < empresasTable.getRowCount(); n++ )
{
if( ( ( ColumnizedMappable ) empresasModel.getRowAt( n ) ).getID().equals( ids[ 0 ] ) )
{
empresasTable.setRowSelectionInterval( n, n );
break;
}
}
for( int n = 0; n < estabelecimentosTable.getRowCount(); n++ )
{
if( ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( n ) ).getID().equals( ids[ 1 ] ) )
{
estabelecimentosTable.setRowSelectionInterval( n, n );
break;
}
}
}
public Object save()
{
int empresaSelected = empresasTable.getSelectedRow();
int estabelecimentoSelected = estabelecimentosTable.getSelectedRow();
return new Integer[]{
empresaSelected == -1 ? null : ( ( ColumnizedMappable ) empresasModel.getRowAt( empresaSelected ) ).getID(),
estabelecimentoSelected == -1 ? null : ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( estabelecimentoSelected ) ).getID()
};
}
public void setEnabled( boolean enable )
{
empresasTable.setEnabled( enable );
estabelecimentosTable.setEnabled( enable );
}
public void actionPerformed( ActionEvent e )
{
Object source = e.getSource();
if( source.equals( procurarButton ) )
{
procurar();
}
else if( source.equals( imprimirButton ) )
{
imprimir();
}
else if( source.equals( imprimirTodasButton ) )
{
imprimirTodas();
}
else if( source.equals( pathButton ) )
{
escolherDirectorio();
}
}
public void procurar()
{
int selected = estabelecimentosTable.getSelectedRow();
Date dataInicio = dataInicioPanel.getDate();
Date dataFim = dataFimPanel.getDate();
if( selected == -1 || ( dataInicio == null && dataFim == null ) )
{
JOptionPane.showMessageDialog( this, "Tem de escolher pelo menos uma data e um estabelecimento.", "Erro",
JOptionPane.ERROR_MESSAGE );
return;
}
if( dataInicio == null )
{
dataInicio = dataFim;
}
else if( dataFim == null )
{
dataFim = dataInicio;
}
fichasModel.clearAll();
try
{
Integer estabelecimentoID = ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( selected ) ).getID();
Object fichas[][] = provider.getAllFichasForEstabelecimentoAndDatas( estabelecimentoID, dataInicio, dataFim );
Vector values = fichasModel.getValues();
for( int n = 0; n < fichas.length; n++ )
{
values.add( new ColumnizedObjectArray( fichas[ n ], true ) );
}
fichasModel.setValues( values );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar a lista.", true );
estabelecimentosModel.clearAll();
}
imprimirTodasButton.setEnabled( fichasTable.getRowCount() > 0 );
}
public void imprimir()
{
imprimirLinhas( fichasTable.getSelectedRows() );
}
public void imprimirTodas()
{
int linhas[] = new int[ fichasTable.getRowCount() ];
for( int n = 0; n < linhas.length; n++ )
{
linhas[ n ] = n;
}
imprimirLinhas( linhas );
}
protected void imprimirLinhas( int linhas[] )
{
try
{
File file = new File( pathText.getText().trim() );
if( !file.exists() || !file.isDirectory() )
{
throw new IOException( "Direct\u00f3rio inexistente ou indispon\u00edvel: " + pathText.getText().trim() );
}
}
catch( IOException ioex )
{
JOptionPane.showMessageDialog( this, ioex.getMessage(), "Erro...",
JOptionPane.ERROR_MESSAGE );
return;
}
String impressora = ( String ) impressorasCombo.getSelectedItem();
Integer ids[] = new Integer[ linhas.length ];
for( int n = 0; n < ids.length; n++ )
{
ids[ n ] = ( ( ColumnizedObjectArray )fichasModel.getRowAt( linhas[ n ] ) ).getID();
}
int option = JOptionPane.showConfirmDialog( this, "Imprimir as " + ids.length + " fichas para a impressora " + impressora + "?",
"Imprimir", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE );
if( option == 0 )
{
System.out.println( "imprimir" );
new FichasPrinter( ids, impressora, pathText.getText().trim(),
empresasModel.getRowAt( empresasTable.getSelectedRow() ).toString(),
estabelecimentosModel.getRowAt( estabelecimentosTable.getSelectedRow() ).toString() ).start();
}
}
protected void escolherDirectorio()
{
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
int returnVal = chooser.showOpenDialog( this );
if(returnVal == JFileChooser.APPROVE_OPTION)
{
setDirectorio( chooser.getSelectedFile().getAbsolutePath() );
}
}
protected void setDirectorio( String path )
{
if( path != null )
{
pathText.setText( path );
Properties properties = propertyHandler.load();
properties.setProperty( getClass().getName() + PATH_PROPERTY_SUFFIX, path );
try
{
propertyHandler.save( properties );
}
catch( IOException ioex )
{
ioex.printStackTrace();
}
}
}
}

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>
<xsl:template match="LISTA_FICHAS">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="simpleA4" page-height="29.7cm" page-width="21cm" margin-top="2cm" margin-bottom="2cm" margin-left="2cm" margin-right="2cm">
<fo:region-before extent="30pt"/>
<fo:region-body margin-top="30pt"/>
<fo:region-after extent="6pt"
padding="6pt 1in"
display-align="after"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simpleA4">
<fo:static-content flow-name="xsl-region-before">
<fo:block font-size="14pt" text-align="center" font-weight="bold">
RELA&#xc7;&#xc3;O DE FICHAS DE APTID&#xc3;O ENVIADAS
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:table table-layout="fixed" width="100%" space-before.optimum="10pt"
border="1pt solid #000000">
<fo:table-column/>
<fo:table-column column-width="100pt"/>
<fo:table-column column-width="100pt"/>
<fo:table-body >
<fo:table-row>
<fo:table-cell border-right-color="black" border-right-style="solid" border-right-width="thin">
<fo:block font-size="8pt" font="Arial" text-align="center" font-weight="bold" space-before="5pt" space-after="5pt">
NOME
</fo:block>
</fo:table-cell>
<fo:table-cell border-right-color="black" border-right-style="solid" border-right-width="thin">
<fo:block font-size="8pt" font="Arial" text-align="center" font-weight="bold" space-before="5pt" space-after="5pt">
DATA EXAME
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="8pt" font="Arial" text-align="center" font-weight="bold" space-before="5pt" space-after="5pt">
PR&#xd3;XIMO EXAME
</fo:block>
</fo:table-cell>
</fo:table-row>
<xsl:for-each select="FICHA">
<fo:table-row>
<fo:table-cell border-top-color="black" border-top-style="solid" border-top-width="thin" border-right-color="black" border-right-style="solid" border-right-width="thin">
<fo:block font-size="8pt" font="Arial" text-align="center" space-before="2pt">
<xsl:value-of select="NOME" />
</fo:block>
</fo:table-cell>
<fo:table-cell border-top-color="black" border-top-style="solid" border-top-width="thin" border-right-color="black" border-right-style="solid" border-right-width="thin">
<fo:block font-size="8pt" font="Arial" text-align="center" space-before="2pt">
<xsl:value-of select="DATA_EXAME" />
</fo:block>
</fo:table-cell>
<fo:table-cell border-top-color="black" border-top-style="solid" border-top-width="thin">
<fo:block font-size="8pt" font="Arial" text-align="center" space-before="2pt">
<xsl:value-of select="DATA_PROXIMO_EXAME" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
<fo:block font-size="8pt" text-align="left">
<xsl:value-of select="DATA_EXTENSO" />
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>

@ -0,0 +1,751 @@
/*
* EstatisticasProvider.java
*
* Created on 3 de Junho de 2004, 18:23
*/
package siprp.pesquisas;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.arrays.*;
import com.evolute.utils.data.*;
import com.evolute.utils.db.*;
import com.evolute.utils.db.keyretrievers.*;
import com.evolute.utils.metadb.*;
import com.evolute.utils.sql.*;
import com.evolute.utils.sql.expression.*;
import siprp.data.*;
/**
*
* @author fpalma
*/
public class PesquisasProvider extends MetaProvider
{
private static final Object LOCK = new Object();
private static PesquisasProvider instance = null;
private final Executer executer;
private static final int TIPOS_OCASIONAL[] =
new int[]{ 5, //mudanca de posto
6, //mudancas das condicoes
-1, //apos 30 dias
4, //iniciativa do medico
3, //pedido do trabalhador
2, //acidente de trabalho
1, //Doenca subita
-1, //Cessacao do contrato
10 //Outras razoes
};
public static final String DESCRICAO_TIPOS_OCASIONAL[] =
new String[]{ "MUDAN\u00C7A DE POSTO DE TRABALHO",
"ALTERA\u00C7\u00D5ES NO POSTO DE TRABALHO",
"REGRESSO AO TRABALHO AP\u00D3S AUS\u00CANCIA SUPERIOR A 30 DIAS",
"INICIATIVA DO M\u00C9DICO",
"PEDIDO DO TRABALHADOR",
"ACIDENTE DE TRABALHO",
"DOEN\u00C7A S\u00DABITA",
"POR CESSA\u00C7\u00C3O DO CONTRATO DE TRABALHO",
"OUTRAS RAZ\u00D5ES" };
private static final int TIPOS_EXAME[] =
new int[]{ 1, //admissao
2, //periodico
3 //ocasional
};
private static final int TIPO_OCASIONAL = 3;
public static final String DESCRICAO_TIPOS_EXAME[] =
new String[]{ "TOTAL DE EXAMES DE ADMISS\u00C3O",
"TOTAL DE EXAMES PERI\u00D3DICOS",
"TOTAL DE EXAMES OCASIONAIS" };
public static final String PAR_ANO = "PAR_ANO";
public static final String PAR_EMPRESA = "PAR_EMPRESA";
public static final String PAR_ESTABELECIMENTO = "PAR_ESTABELECIMENTO";
public static final String PAR_TIPO_EXAME = "PAR_TIPO_EXAME";
public static final String PAR_RESULTADO = "PAR_RESULTADO";
public static final String PAR_SEXO = "PAR_SEXO";
public static final String PAR_GRUPO_ETARIO = "PAR_GRUPO_ETARIO";
/** Creates a new instance of EstatisticasProvider */
public PesquisasProvider() throws Exception
{
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ );
executer = dbm.getSharedExecuter( this );
}
public static MetaProvider getProvider()
throws Exception
{
synchronized( LOCK )
{
if( instance == null )
{
instance = new PesquisasProvider();
}
}
return instance;
}
public IDObject[] getAllEmpresas()
throws Exception
{
Select select = new Select( new String[]{ "empresas" },
new String[]{ EmpresaData.ID, EmpresaData.DESIGNACAO_SOCIAL, EmpresaData.DESIGNACAO_SOCIAL_PLAIN },
new Field( EmpresaData.INACTIVO ).isDifferent( "y" ),
new String[]{ EmpresaData.DESIGNACAO_SOCIAL_PLAIN }, null );
// Select select = new Select( "SELECT e.id, e.designacao_social FROM empresas e ORDER BY lower( e.designacao_social );" );
Virtual2DArray array = executer.executeQuery( select );
IDObject empresas[] = new IDObject[ array.columnLength() ];
for( int n = 0; n < empresas.length; n++ )
{
empresas[ n ] = new MappableObject( (Integer)array.get( n, 0 ), array.get( n, 1 ) );
}
return empresas;
}
public IDObject []getAllEstabelecimentosForEmpresa( Integer empresaID )
throws Exception
{
return ( ( siprp.FichaDataProvider )siprp.FichaDataProvider.getProvider() ).getAllEstabelecimentosForEmpresa( empresaID );
}
public int[] countTrabalhadoresEstabelecimentoDezembro( Integer estabelecimentoID, int ano )
throws Exception
{
Calendar cal = Calendar.getInstance();
cal.set( Calendar.YEAR, ano );
cal.set( Calendar.MONTH, 11 );
cal.set( Calendar.DAY_OF_MONTH, 30 );
Select select =
new Select( new String[]{ "trabalhadores" },
new String[]{ "COUNT(" + TrabalhadorData.ID + ")" },
new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or(
new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ).and(
new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
new Field( TrabalhadorData.SEXO ).isEqual( "m" ) ).and(
new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and(
new Par( new Field( TrabalhadorData.DATA_DEMISSAO ).isGreater( cal.getTime() ).or(
new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ) );
Virtual2DArray array = executer.executeQuery( select );
int contagem[] = new int[ 2 ];
contagem[ 0 ] = ( ( Number ) array.get( 0, 0 ) ).intValue();
select =
new Select( new String[]{ "trabalhadores" },
new String[]{ "COUNT(" + TrabalhadorData.ID + ")" },
new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or(
new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ).and(
new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
new Field( TrabalhadorData.SEXO ).isEqual( "f" ) ).and(
new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and(
new Par( new Field( TrabalhadorData.DATA_DEMISSAO ).isGreater( cal.getTime() ).or(
new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ) );
array = executer.executeQuery( select );
contagem[ 1 ] = ( ( Number ) array.get( 0, 0 ) ).intValue();
return contagem;
}
public int[][] countTrabalhadoresEstabelecimentoDezembroPorGrupoEtario( Integer estabelecimentoID, int ano )
throws Exception
{
Calendar eoy = Calendar.getInstance();
eoy.set( Calendar.YEAR, ano );
eoy.set( Calendar.MONTH, 11 );
eoy.set( Calendar.DAY_OF_MONTH, 30 );
Calendar today = Calendar.getInstance();
today.set( Calendar.YEAR, ano );
today.set( Calendar.MONTH, 11 );
today.set( Calendar.DAY_OF_MONTH, 31 );
today.set( Calendar.HOUR_OF_DAY, 23 );
Calendar age18 = (Calendar) today.clone();
age18.add( Calendar.YEAR, -18 );
Calendar age50 = (Calendar) today.clone();
age50.add( Calendar.YEAR, -50 );
//0-18
Select select =
new Select( new String[]{ "trabalhadores" },
new String[]{ "COUNT(" + TrabalhadorData.ID + ")" },
new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or(
new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ).and(
new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
new Field( TrabalhadorData.SEXO ).isEqual( "m" ) ).and(
new Field( TrabalhadorData.DATA_NASCIMENTO ).isGreater( age18.getTime() ) ).and(
new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and(
new Par( new Field( TrabalhadorData.DATA_DEMISSAO ).isGreater( eoy.getTime() ).or(
new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ) );
Virtual2DArray array = executer.executeQuery( select );
int contagem[][] = new int[ 3 ][ 2 ];
contagem[ 0 ][ 0 ] = ( ( Number ) array.get( 0, 0 ) ).intValue();
select =
new Select( new String[]{ "trabalhadores" },
new String[]{ "COUNT(" + TrabalhadorData.ID + ")" },
new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or(
new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ).and(
new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
new Field( TrabalhadorData.SEXO ).isEqual( "f" ) ).and(
new Field( TrabalhadorData.DATA_NASCIMENTO ).isGreater( age18.getTime() ) ).and(
new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and(
new Par( new Field( TrabalhadorData.DATA_DEMISSAO ).isGreater( eoy.getTime() ).or(
new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ) );
array = executer.executeQuery( select );
contagem[ 0 ][ 1 ] = ( ( Number ) array.get( 0, 0 ) ).intValue();
//18-49
select =
new Select( new String[]{ "trabalhadores" },
new String[]{ "COUNT(" + TrabalhadorData.ID + ")" },
new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or(
new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ).and(
new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
new Field( TrabalhadorData.SEXO ).isEqual( "m" ) ).and(
new Field( TrabalhadorData.DATA_NASCIMENTO ).isLessOrEqual( age18.getTime() ) ).and(
new Field( TrabalhadorData.DATA_NASCIMENTO ).isGreater( age50.getTime() ) ).and(
new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and(
new Par( new Field( TrabalhadorData.DATA_DEMISSAO ).isGreater( eoy.getTime() ).or(
new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ) );
array = executer.executeQuery( select );
contagem[ 1 ][ 0 ] = ( ( Number ) array.get( 0, 0 ) ).intValue();
select =
new Select( new String[]{ "trabalhadores" },
new String[]{ "COUNT(" + TrabalhadorData.ID + ")" },
new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or(
new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ).and(
new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
new Field( TrabalhadorData.SEXO ).isEqual( "f" ) ).and(
new Field( TrabalhadorData.DATA_NASCIMENTO ).isLessOrEqual( age18.getTime() ) ).and(
new Field( TrabalhadorData.DATA_NASCIMENTO ).isGreater( age50.getTime() ) ).and(
new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and(
new Par( new Field( TrabalhadorData.DATA_DEMISSAO ).isGreater( eoy.getTime() ).or(
new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ) );
array = executer.executeQuery( select );
contagem[ 1 ][ 1 ] = ( ( Number ) array.get( 0, 0 ) ).intValue();
//50-
select =
new Select( new String[]{ "trabalhadores" },
new String[]{ "COUNT(" + TrabalhadorData.ID + ")" },
new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or(
new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ).and(
new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
new Field( TrabalhadorData.SEXO ).isEqual( "m" ) ).and(
new Field( TrabalhadorData.DATA_NASCIMENTO ).isLessOrEqual( age50.getTime() ) ).and(
new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and(
new Par( new Field( TrabalhadorData.DATA_DEMISSAO ).isGreater( eoy.getTime() ).or(
new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ) );
array = executer.executeQuery( select );
contagem[ 2 ][ 0 ] = ( ( Number ) array.get( 0, 0 ) ).intValue();
select =
new Select( new String[]{ "trabalhadores" },
new String[]{ "COUNT(" + TrabalhadorData.ID + ")" },
new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or(
new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ).and(
new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
new Field( TrabalhadorData.SEXO ).isEqual( "f" ) ).and(
new Field( TrabalhadorData.DATA_NASCIMENTO ).isLessOrEqual( age50.getTime() ) ).and(
new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and(
new Par( new Field( TrabalhadorData.DATA_DEMISSAO ).isGreater( eoy.getTime() ).or(
new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ) );
array = executer.executeQuery( select );
contagem[ 2 ][ 1 ] = ( ( Number ) array.get( 0, 0 ) ).intValue();
return contagem;
}
public int[][] countExamesEstabelecimentoDezembroPorGrupoEtario( Integer estabelecimentoID, int ano )
throws Exception
{
Calendar today = Calendar.getInstance();
today.set( Calendar.YEAR, ano );
today.set( Calendar.MONTH, 11 );
today.set( Calendar.DAY_OF_MONTH, 31 );
today.set( Calendar.HOUR_OF_DAY, 23 );
Calendar age18 = (Calendar) today.clone();
age18.add( Calendar.YEAR, -18 );
Calendar age50 = (Calendar) today.clone();
age50.add( Calendar.YEAR, -50 );
Calendar dates[] = new Calendar[]{ null, age18, age50, null };
String sexos[] = new String[]{ "m", "f" };
int contagem[][] = new int[ 4 ][ 6 ];
for( int t = 0; t < TIPOS_EXAME.length; t++ )
{
for( int s = 0; s < sexos.length; s++ )
{
for( int d = 0; d < dates.length - 1; d++ )
{
Select select =
new Select( new String[]{ "exames", "trabalhadores" },
new String[]{ "DISTINCT trabalhadores.id, exames.data" },
new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ).and(
new Field( "exames.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ).and(
new Field( TrabalhadorData.SEXO ).isEqual( sexos[s] ) ).and(
new Field( "YEAR( exames.data )" ).isEqual( new Integer( ano ) ) ).and(
dates[ d ] == null ? new Field( "exames.id" ).isDifferent( null ) :
new Field( TrabalhadorData.DATA_NASCIMENTO ).isLessOrEqual( dates[ d ].getTime() ) ).and(
dates[ d + 1 ] == null ? new Field( "exames.id" ).isDifferent( null ) :
new Field( TrabalhadorData.DATA_NASCIMENTO ).isGreater( dates[ d + 1 ].getTime() ) ).and(
new Field( "exames.tipo" ).isEqual( new Integer( TIPOS_EXAME[ t ] ) ) ).and(
new Field( "exames.inactivo" ).isDifferent( "y" ) ).and(
new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
try
{
Virtual2DArray array = executer.executeQuery( select );
contagem[ t ][ s * 3 + d ] = array.columnLength();
//System.out.println( select + ": " + contagem[ t ][ s * 3 + d ] );
}
catch( Exception ex )
{
contagem[ t ][ s * 3 + d ] = -1;
}
}
}
}
return contagem;
}
public int[][] countExamesOcasionaisEstabelecimentoDezembroPorGrupoEtario( Integer estabelecimentoID, int ano )
throws Exception
{
Calendar today = Calendar.getInstance();
today.set( Calendar.YEAR, ano );
today.set( Calendar.MONTH, 11 );
today.set( Calendar.DAY_OF_MONTH, 31 );
today.set( Calendar.HOUR_OF_DAY, 23 );
Calendar age18 = (Calendar) today.clone();
age18.add( Calendar.YEAR, -18 );
Calendar age50 = (Calendar) today.clone();
age50.add( Calendar.YEAR, -50 );
Calendar dates[] = new Calendar[]{ null, age18, age50, null };
String sexos[] = new String[]{ "m", "f" };
int contagem[][] = new int[ TIPOS_OCASIONAL.length ][ ( dates.length - 1 ) * sexos.length ];
for( int t = 0; t < TIPOS_OCASIONAL.length; t++ )
{
for( int s = 0; s < sexos.length; s++ )
{
for( int d = 0; d < dates.length - 1; d++ )
{
if( TIPOS_OCASIONAL[t] == -1 )
{
contagem[ t ][ s * 3 + d ] = -1;
continue;
}
Select select =
new Select( new String[]{ "exames", "trabalhadores" },
new String[]{ "DISTINCT trabalhadores.id, exames.data" },
new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ).and(
new Field( "exames.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ).and(
new Field( TrabalhadorData.SEXO ).isEqual( sexos[s] ) ).and(
new Field( "YEAR( exames.data )" ).isEqual( new Integer( ano ) ) ).and(
dates[ d ] == null ? new Field( "exames.id" ).isDifferent( null ) :
new Field( TrabalhadorData.DATA_NASCIMENTO ).isLessOrEqual( dates[ d ].getTime() ) ).and(
dates[ d + 1 ] == null ? new Field( "exames.id" ).isDifferent( null ) :
new Field( TrabalhadorData.DATA_NASCIMENTO ).isGreater( dates[ d + 1 ].getTime() ) ).and(
new Field( "exames.tipo" ).isEqual( new Integer( 3 ) ) ).and(
new Field( "exames.ocasional" ).isEqual( new Integer( TIPOS_OCASIONAL[ t ] ) ) ).and(
new Field( "exames.inactivo" ).isDifferent( "y" ) ).and(
new Field( "trabalhadores.inactivo" ).isDifferent( "y" ) ) );
try
{
Virtual2DArray array = executer.executeQuery( select );
contagem[ t ][ s * 3 + d ] = array.columnLength();
}
catch( Exception ex )
{
contagem[ t ][ s * 3 + d ] = -1;
}
}
}
}
return contagem;
}
public double[] countNumeroMedioTrabalhadoresEmpresa( Integer empresaID, int ano )
throws Exception
{
double contagens[] = new double[ 2 ];;
Select select;
String sexos[] = new String[]{ "m", "f" };
for( int n = 0; n < sexos.length; n++ )
{
select =
new Select( new String[]{ "estabelecimentos", "trabalhadores" },
new String[]{ "COUNT(trabalhadores.id)" },
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ).and(
new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLess( new Integer( ano ) ).or(
new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ) ).and(
new Par( new Field( "YEAR(" + TrabalhadorData.DATA_DEMISSAO + ")" ).isGreater( new Integer( ano ) ).or(
new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ).and(
new Field( "empresa_id" ).isEqual( empresaID ) ).and(
new Field( TrabalhadorData.SEXO ).isEqual( sexos[ n ] ) ).and(
new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ) );
Virtual2DArray array = executer.executeQuery( select );
contagens[ n ] = ( ( Number ) array.get( 0, 0 ) ).doubleValue();
}
for( int n = 0; n < sexos.length; n++ )
{
select =
new Select( new String[]{ "estabelecimentos", "trabalhadores" },
new String[]{ "SUM( MONTH( data_demissao ) )" },
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ).and(
new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLess( new Integer( ano ) ).or(
new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ) ).and(
new Field( "YEAR(" + TrabalhadorData.DATA_DEMISSAO + ")" ).isEqual( new Integer( ano ) ) ).and(
new Field( "empresa_id" ).isEqual( empresaID ) ).and(
new Field( TrabalhadorData.SEXO ).isEqual( sexos[ n ] ) ).and(
new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ) );
System.out.println( "SELECT: " + select );
Virtual2DArray array = executer.executeQuery( select );
if( array.get( 0, 0 ) != null )
{
contagens[ n ] += ( ( Number ) array.get( 0, 0 ) ).doubleValue() / 12.0;
}
}
for( int n = 0; n < sexos.length; n++ )
{
select =
new Select( new String[]{ "estabelecimentos", "trabalhadores" },
new String[]{ "SUM( ( 1 + 12 - MONTH( data_admissao ) ) )" },
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ).and(
new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isEqual( new Integer( ano ) ) ).and(
new Par( new Field( "YEAR(" + TrabalhadorData.DATA_DEMISSAO + ")" ).isGreater( new Integer( ano ) ).or(
new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ).and(
new Field( "empresa_id" ).isEqual( empresaID ) ).and(
new Field( TrabalhadorData.SEXO ).isEqual( sexos[ n ] ) ).and(
new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ) );
Virtual2DArray array = executer.executeQuery( select );
if( array.get( 0, 0 ) != null )
{
contagens[ n ] += ( ( Number ) array.get( 0, 0 ) ).doubleValue() / 12.0;
}
}
for( int n = 0; n < sexos.length; n++ )
{
select =
new Select( new String[]{ "estabelecimentos", "trabalhadores" },
new String[]{ "SUM( ( 1 + MONTH( data_demissao ) - MONTH( data_admissao ) ) )" },
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ).and(
new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isEqual( new Integer( ano ) ) ).and(
new Field( "YEAR(" + TrabalhadorData.DATA_DEMISSAO + ")" ).isEqual( new Integer( ano ) ) ).and(
new Field( "empresa_id" ).isEqual( empresaID ) ).and(
new Field( TrabalhadorData.SEXO ).isEqual( sexos[ n ] ) ).and(
new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ) );
Virtual2DArray array = executer.executeQuery( select );
if( array.get( 0, 0 ) != null )
{
contagens[ n ] += ( ( Number ) array.get( 0, 0 ) ).doubleValue() / 12.0;
}
}
return contagens;
}
public double[] countNumeroTotalTrabalhadoresEmpresa( Integer empresaID, int ano )
throws Exception
{
double contagens[] = new double[ 2 ];;
Select select;
String sexos[] = new String[]{ "m", "f" };
for( int n = 0; n < sexos.length; n++ )
{
select =
new Select( new String[]{ "estabelecimentos", "trabalhadores" },
new String[]{ "COUNT(trabalhadores.id)" },
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ).and(
new Par( new Field( "YEAR(" + TrabalhadorData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or(
new Field( TrabalhadorData.DATA_ADMISSAO ).isEqual( null ) ) ) ).and(
new Par( new Field( "YEAR(" + TrabalhadorData.DATA_DEMISSAO + ")" ).isGreaterOrEqual( new Integer( ano ) ).or(
new Field( TrabalhadorData.DATA_DEMISSAO ).isEqual( null ) ) ) ).and(
new Field( "empresa_id" ).isEqual( empresaID ) ).and(
new Field( TrabalhadorData.SEXO ).isEqual( sexos[ n ] ) ).and(
new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ) );
Virtual2DArray array = executer.executeQuery( select );
contagens[ n ] = ( ( Number ) array.get( 0, 0 ) ).doubleValue();
}
return contagens;
}
public String []getNomesExames()
throws Exception
{
String nomes[];
Select select =
new Select( new String[]{ "tipos_exames_comp" },
new String[]{ "descricao", "ordem" },
null,
new String[]{ "ordem" }, null );
Virtual2DArray array = executer.executeQuery( select );
nomes = new String[ array.columnLength() ];
for( int n = 0; n < array.columnLength(); n++ )
{
nomes[ n ] = ( String )array.get( n, 0 );
}
return nomes;
}
public int []countExamesComplementaresEmpresa( Integer empresaID, int ano )
throws Exception
{
// Vector perfis[] = new Vector[ 2 ];
// Hashtable contagens[] = new Hashtable[ 2 ];
// Select select;
// Virtual2DArray array;
//
// for( int p = 0; p < 2; p++ )
// {
// Integer pAux = new Integer( p + 1 );
// perfis[ p ] = new Vector();
// select = new Select( new String[]{"estabelecimentos", "trabalhadores", "marcacoes_trabalhador"},
// new String[]{"COUNT(marcacoes_trabalhador.id)", TrabalhadorData.PERFIL },
// new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
// new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
// new Field( "empresa_id" ).isEqual( empresaID ) ).and(
// new Field( MarcacaoTrabalhadorData.TIPO ).isEqual( new Integer( MarcacaoTrabalhadorData.TIPO_EXAMES ) ) ).and(
// new Field( "YEAR( marcacoes_trabalhador.data ) " ).isEqual( new Integer( ano ) ).and(
// new Field( MarcacaoTrabalhadorData.ESTADO ).in( new Integer[]{ new Integer( 1 ), new Integer( 2 ) } ) ) ).and(
// new Field( "trabalhadores.perfil" ).isEqual( pAux ) ) );
// array = executer.executeQuery( select );
//
// select =
// new Select( new String[]{ "prt_elementos_protocolo", "prt_tipos_elementos_protocolo" },
// new String[]{ "DISTINCT prt_tipos_elementos_protocolo.grupo_protocolo_id" },
// new Field( "prt_elementos_protocolo.empresa_id" ).isEqual( empresaID ).and(
// new Field( "prt_elementos_protocolo.tipo_elemento_protocolo_id" ).isEqual( new Field( "prt_elementos_protocolo.id" ) ) ).and(
// new Field( "pr_elementos_protocolo.perfil" ).isEqual( new Integer( p + 1 ) ) ) );
// array = executer.executeQuery( select );
// for( int ecd = 0; ecd < array.columnLength(); ecd++ )
// {
// perfis[ p ].add( ( Integer ) array.get( 0, 0 ) );
// }
// }
//
//
// return contagens;
int contagens[];
Select select;
select = new Select( new String[]{"empresas"}, new String[]{ "perfil_1", "perfil_2" },
new Field( "id" ).isEqual( empresaID ) );
Virtual2DArray array = executer.executeQuery( select );
String p1Str = (String)array.get( 0, 0 );
String p2Str = (String)array.get( 0, 1 );
Number perfil1 = ( p1Str != null && p1Str.length() > 0 )?new Integer( p1Str ):null;
Number perfil2 = ( p2Str != null && p2Str.length() > 0 )?new Integer( p2Str ):null;
select =
new Select( new String[]{ "tipos_exames_comp" },
new String[]{ "id", "ordem" },
null,
new String[]{ "ordem" }, null );
array = executer.executeQuery( select );
contagens = new int[ array.columnLength() ];
Hashtable idExames = new Hashtable();
for( int n = 0; n < array.columnLength(); n++ )
{
idExames.put( ( Number )array.get( n, 0 ), new Integer( n ) );
}
if( perfil1 == null && perfil2 == null )
{
return contagens;
}
else if( perfil1 == null )
{
perfil1 = perfil2;
}
else if( perfil2 == null )
{
perfil2 = perfil1;
}
select = new Select( new String[]{"estabelecimentos", "trabalhadores", "marcacoes_trabalhador"},
new String[]{"COUNT(marcacoes_trabalhador.id)", TrabalhadorData.PERFIL },
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and(
new Field( "empresa_id" ).isEqual( empresaID ) ).and(
new Field( MarcacaoTrabalhadorData.TIPO ).isEqual( new Integer( MarcacaoTrabalhadorData.TIPO_EXAMES ) ) ).and(
new Field( "YEAR( marcacoes_trabalhador.data ) " ).isEqual( new Integer( ano ) ).and(
new Field( Marcacao.REALIZADA ).isEqual( "y" ) ) ),
new String[]{ TrabalhadorData.PERFIL },
new String[]{ TrabalhadorData.PERFIL } );
array = executer.executeQuery( select );
int numeroExames[] = new int[ 2 ];
for( int n = 0; n < array.columnLength(); n++ )
{
Integer perfil = (Integer)array.get( n, 1 );
if( perfil == null || perfil.intValue() == 1 )
{
numeroExames[0] += ( (Number) array.get( n, 0 ) ).intValue();
}
else if( perfil.intValue() == 2 )
{
numeroExames[1] += ( (Number) array.get( n, 0 ) ).intValue();
}
}
Hashtable hash = new Hashtable();
select = new Select( new String[]{ "exames_perfis" },
new String[]{ "tipo", "multiplicador" },
new Field( "perfil" ).isEqual( perfil1 ) );
array = executer.executeQuery( select );
for( int n = 0; n < array.columnLength(); n++ )
{
Number tipo = (Number) array.get( n, 0 );
if( tipo == null )
{
continue;
}
Number multiplicador = (Number) array.get( n, 1 );
if( multiplicador == null )
{
multiplicador = new Integer( 1 );
}
if( idExames.containsKey( tipo ) )
{
int pos = ((Integer)idExames.get( tipo )).intValue();
contagens[ pos ] += numeroExames[0] * multiplicador.intValue();
}
}
select = new Select( new String[]{ "exames_perfis" },
new String[]{ "tipo", "multiplicador" },
new Field( "perfil" ).isEqual( perfil2 ) );
array = executer.executeQuery( select );
for( int n = 0; n < array.columnLength(); n++ )
{
Number tipo = (Number) array.get( n, 0 );
if( tipo == null )
{
continue;
}
Number multiplicador = (Number) array.get( n, 1 );
if( multiplicador == null )
{
multiplicador = new Integer( 1 );
}
if( idExames.containsKey( tipo ) )
{
int pos = ((Integer)idExames.get( tipo )).intValue();
contagens[ pos ] += numeroExames[1] * multiplicador.intValue();
}
}
return contagens;
}
public int []countExamesComplementaresEstabelecimento( Integer estabelecimentoID, int ano )
throws Exception
{
int contagens[];
Select select;
select = new Select( new String[]{"estabelecimentos", "empresas"},
new String[]{ "empresas.perfil_1", "empresas.perfil_2" },
new Field( "estabelecimentos.id" ).isEqual( estabelecimentoID ).and(
new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) ) );
Virtual2DArray array = executer.executeQuery( select );
String p1Str = (String)array.get( 0, 0 );
String p2Str = (String)array.get( 0, 1 );
Number perfil1 = ( p1Str != null && p1Str.length() > 0 )?new Integer( p1Str ):null;
Number perfil2 = ( p2Str != null && p2Str.length() > 0 )?new Integer( p2Str ):null;
select =
new Select( new String[]{ "tipos_exames_comp" },
new String[]{ "id", "ordem" },
null,
new String[]{ "ordem" }, null );
array = executer.executeQuery( select );
contagens = new int[ array.columnLength() ];
Hashtable idExames = new Hashtable();
for( int n = 0; n < array.columnLength(); n++ )
{
idExames.put( ( Number )array.get( n, 0 ), new Integer( n ) );
}
if( perfil1 == null && perfil2 == null )
{
return contagens;
}
else if( perfil1 == null )
{
perfil1 = perfil2;
}
else if( perfil2 == null )
{
perfil2 = perfil1;
}
select = new Select( new String[]{"trabalhadores", "marcacoes_trabalhador"},
new String[]{"COUNT(marcacoes_trabalhador.id)", TrabalhadorData.PERFIL },
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and(
new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(
new Field( MarcacaoTrabalhadorData.TIPO ).isEqual( new Integer( MarcacaoTrabalhadorData.TIPO_EXAMES ) ) ).and(
new Field( "YEAR( marcacoes_trabalhador.data ) " ).isEqual( new Integer( ano ) ).and(
new Field( Marcacao.REALIZADA ).isEqual( "y" ) ) ),
new String[]{ TrabalhadorData.PERFIL },
new String[]{ TrabalhadorData.PERFIL } );
array = executer.executeQuery( select );
int numeroExames[] = new int[ 2 ];
for( int n = 0; n < array.columnLength(); n++ )
{
Integer perfil = (Integer)array.get( n, 1 );
if( perfil == null || perfil.intValue() == 1 )
{
numeroExames[0] += ( (Number) array.get( n, 0 ) ).intValue();
}
else if( perfil.intValue() == 2 )
{
numeroExames[1] += ( (Number) array.get( n, 0 ) ).intValue();
}
}
Hashtable hash = new Hashtable();
select = new Select( new String[]{ "exames_perfis" },
new String[]{ "tipo", "multiplicador" },
new Field( "perfil" ).isEqual( perfil1 ) );
array = executer.executeQuery( select );
for( int n = 0; n < array.columnLength(); n++ )
{
Number tipo = (Number) array.get( n, 0 );
if( tipo == null )
{
continue;
}
Number multiplicador = (Number) array.get( n, 1 );
if( multiplicador == null )
{
multiplicador = new Integer( 1 );
}
if( idExames.containsKey( tipo ) )
{
int pos = ((Integer)idExames.get( tipo )).intValue();
contagens[ pos ] += numeroExames[0] * multiplicador.intValue();
}
}
select = new Select( new String[]{ "exames_perfis" },
new String[]{ "tipo", "multiplicador" },
new Field( "perfil" ).isEqual( perfil2 ) );
array = executer.executeQuery( select );
for( int n = 0; n < array.columnLength(); n++ )
{
Number tipo = (Number) array.get( n, 0 );
if( tipo == null )
{
continue;
}
Number multiplicador = (Number) array.get( n, 1 );
if( multiplicador == null )
{
multiplicador = new Integer( 1 );
}
if( idExames.containsKey( tipo ) )
{
int pos = ((Integer)idExames.get( tipo )).intValue();
contagens[ pos ] += numeroExames[1] * multiplicador.intValue();
}
}
return contagens;
}
}

@ -0,0 +1,578 @@
/*
* PesquisasWindow.java
*
* Created on 3 de Junho de 2004, 18:13
*/
package siprp.pesquisas;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import com.evolute.utils.*;
import com.evolute.utils.data.*;
import com.evolute.utils.documents.*;
import com.evolute.utils.jdo.*;
import com.evolute.utils.tables.*;
import com.evolute.utils.tracker.*;
import com.evolute.utils.ui.*;
import com.evolute.utils.ui.text.*;
import siprp.data.*;
/**
*
* @author fpalma
*/
public class PesquisasWindow extends JFrame
implements TrackableWindow, ListSelectionListener, ActionListener
{
private JDOProvider JDO;
private PesquisasProvider provider;
private JTextField anoText;
private BaseTable empresasTable;
private VectorTableModel empresasModel;
private BaseTable estabelecimentosTable;
private VectorTableModel estabelecimentosModel;
private JButton pesquisarButton;
private JButton exportarButton;
private JEditorPane resultadoText;
// public static void main( String args[] )
// throws Exception
// {
// new PesquisasWindow().show();
// }
/** Creates a new instance of PesquisasWindow */
public PesquisasWindow()
throws Exception
{
provider = (PesquisasProvider)PesquisasProvider.getProvider();
JDO =( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
setupComponents();
}
private void setupComponents()
{
setSize( 1000, 700 );
setTitle( "Relat\u00f3rio Anual" );
JLabel anoLabel = new JLabel( "Ano" );
anoText = new JTextField();
anoText.setDocument( new YearDocument() );
anoText.setPreferredSize( new Dimension( 50, 20 ) );
new CopyPasteHandler( anoText );
empresasModel = new VectorTableModel( new String[]{ "Designa\u00e7\u00e3o Social" } );
empresasTable = new BaseTable( empresasModel );
empresasTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
empresasTable.setNonResizableNorReordable();
empresasTable.getSelectionModel().addListSelectionListener( this );
JScrollPane empresasScroll = new JScrollPane();
empresasScroll.setBorder( BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(), "Empresa" ) );
empresasScroll.setViewportView( empresasTable );
empresasScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
empresasScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
empresasScroll.getVerticalScrollBar().setBlockIncrement(20);
estabelecimentosModel = new VectorTableModel( new String[]{ "Nome" } );
estabelecimentosTable = new BaseTable( estabelecimentosModel );
estabelecimentosTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
estabelecimentosTable.setNonResizableNorReordable();
estabelecimentosTable.getSelectionModel().addListSelectionListener( this );
JScrollPane estabelecimentosScroll = new JScrollPane();
estabelecimentosScroll.setBorder( BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(), "Estabelecimento" ) );
estabelecimentosScroll.setViewportView( estabelecimentosTable );
estabelecimentosScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
estabelecimentosScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
pesquisarButton = new JButton( "Pesquisar" );
pesquisarButton.addActionListener( this );
exportarButton = new JButton( "Exportar" );
exportarButton.addActionListener( this );
resultadoText = new JEditorPane( "text/html", "" );
resultadoText.setEditable( false );
// resultadoText.setLineWrap( true );
// resultadoText.setWrapStyleWord( true );
new CopyPasteHandler( resultadoText );
JScrollPane resultadoScroll = new JScrollPane();
resultadoScroll.setViewportView( resultadoText );
resultadoScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
resultadoScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
JPanel pad;
GridBagLayout gridbag = new GridBagLayout();
getContentPane().setLayout( gridbag );
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets( 5, 5, 5, 5 );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weighty = 0;
constraints.gridheight = 1;
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
JPanel anoPanel = new JPanel();
anoPanel.setLayout( new FlowLayout( FlowLayout.LEFT ) );
anoPanel.add( anoLabel );
anoPanel.add( anoText );
gridbag.setConstraints( anoPanel, constraints );
getContentPane().add( anoPanel );
constraints.fill = GridBagConstraints.BOTH;
constraints.weighty = 0.2;
constraints.gridheight = 2;
constraints.weightx = 0.3;
constraints.gridwidth = 3;
gridbag.setConstraints( empresasScroll, constraints );
getContentPane().add( empresasScroll );
gridbag.setConstraints( estabelecimentosScroll, constraints );
getContentPane().add( estabelecimentosScroll );
constraints.weighty = 0;
constraints.gridheight = 1;
constraints.weightx = 0.4;
constraints.gridwidth = GridBagConstraints.REMAINDER;
pad = new JPanel();
gridbag.setConstraints( pad, constraints );
getContentPane().add( pad );
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weighty = 0;
constraints.gridheight = 1;
constraints.weightx = 0;
constraints.gridwidth = 1;
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout( new GridLayout( 1, 2 ) );
buttonPanel.add( pesquisarButton );
buttonPanel.add( exportarButton );
gridbag.setConstraints( buttonPanel, constraints );
getContentPane().add( buttonPanel );
constraints.weighty = 0;
constraints.gridheight = 1;
constraints.weightx = 0.4;
constraints.gridwidth = GridBagConstraints.REMAINDER;
pad = new JPanel();
gridbag.setConstraints( pad, constraints );
getContentPane().add( pad );
constraints.fill = GridBagConstraints.BOTH;
constraints.weighty = 0.8;
constraints.gridheight = GridBagConstraints.REMAINDER;
constraints.weightx = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( resultadoScroll, constraints );
getContentPane().add( resultadoScroll );
}
private boolean close()
{
setVisible( false );
dispose();
return true;
}
public boolean closeIfPossible()
{
return close();
}
public void open()
{
empresasTable.clearSelection();
try
{
IDObject empresas[] = provider.getAllEmpresas();
empresasModel.setValues( new Vector( Arrays.asList( empresas ) ) );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
}
setVisible( true );
}
public void refresh()
{
}
public void valueChanged( ListSelectionEvent e )
{
Object source = e.getSource();
if( source.equals( empresasTable.getSelectionModel() ) )
{
estabelecimentosTable.clearSelection();
int selected = empresasTable.getSelectedRow();
if( selected == -1 )
{
return;
}
IDObject empresa = (IDObject) empresasModel.getRowAt( selected );
estabelecimentosModel.clearAll();
IDObject estabelecimentos[];
try
{
estabelecimentos = provider.getAllEstabelecimentosForEmpresa( empresa.getID() );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar os estabelecimentos", true );
return;
}
Vector v = new Vector( Arrays.asList( estabelecimentos ) );
v.add( new MappableObject( new Integer( -1 ), "TODOS" ) );
estabelecimentosModel.setValues( v );
}
/* else if( source.equals( estabelecimentosTable.getSelectionModel() ) )
{
}*/
}
public void actionPerformed( ActionEvent e )
{
Object source = e.getSource();
if( source.equals( pesquisarButton ) )
{
int sEmpresa = empresasTable.getSelectedRow();
int sEstabelecimento = estabelecimentosTable.getSelectedRow();
String anoStr = anoText.getText();
int ano = ( anoStr.length() != 0 )? Integer.parseInt( anoStr ): -1;
if( sEmpresa == -1 || ano == -1 )
{
JOptionPane.showMessageDialog( this, "Tem de escolher ano e empresa", "Erro...",
JOptionPane.ERROR_MESSAGE );
return;
}
StringBuffer buff = new StringBuffer();
buff.append( "ANO: " );
buff.append( "<B>" + ano + "</B><BR>" );
buff.append( "<BR><I>EMPRESA</I><BR>" );
try
{
Integer idEmpresa = ( (IDObject)empresasModel.getRowAt( sEmpresa ) ).getID();
EmpresaData empresa = (EmpresaData)JDO.load( EmpresaData.class, idEmpresa );
buff.append( "&nbsp;DESIGNA\u00C7\u00C3O SOCIAL: " );
String designacao = (String)empresa.get( EmpresaData.DESIGNACAO_SOCIAL );
buff.append( "<B>" + ( designacao == null ? "" : designacao.trim() ) + "</B><BR>" );
buff.append( "&nbsp;MORADA: " );
String morada = (String)empresa.get( EmpresaData.MORADA );
buff.append( "<B>" + ( morada == null ? "" : morada.trim() ) + "</B><BR>" );
buff.append( "&nbsp;LOCALIDADE: " );
String localidade = ( String ) empresa.get( EmpresaData.LOCALIDADE );
buff.append( "<B>" + ( localidade == null ? "" : localidade.trim() ) + "</B><BR>" );
buff.append( "&nbsp;C\u00D3DIGO POSTAL: " );
String codigoPostal = ( String ) empresa.get( EmpresaData.CODIGO_POSTAL );
buff.append( "<B>" + ( codigoPostal == null ? "" : codigoPostal.trim() ) + "</B><BR>" );
ContactoData contacto = (ContactoData)empresa.get( EmpresaData.CONTACTO_2 );
if( contacto == null )
{
buff.append( "&nbsp;TELEFONE: <BR>" );
buff.append( "&nbsp;FAX: <BR>" );
}
else
{
buff.append( "&nbsp;TELEFONE: " );
String telefone = ( String ) contacto.get( ContactoData.TELEFONE );
buff.append( "<B>" + ( telefone == null ? "" : telefone.trim() ) + "</B><BR>" );
buff.append( "&nbsp;FAX: " );
String fax = ( String ) contacto.get( ContactoData.TELEFONE );
buff.append( "<B>" + ( fax == null ? "" : fax.trim() ) + "</B><BR>" );
}
buff.append( "&nbsp;DISTRITO: " );
String distrito = ( String ) empresa.get( EmpresaData.DISTRITO );
buff.append( "<B>" + ( distrito == null ? "" : distrito ) + "</B><BR>" );
buff.append( "&nbsp;CONCELHO: " );
String concelho = ( String ) empresa.get( EmpresaData.CONCELHO );
buff.append( "<B>" + ( concelho == null ? "" : concelho ) + "</B><BR>" );
buff.append( "&nbsp;N\u00DAMERO PESSOA COLECTIVA: " );
String contribuinte = ( String ) empresa.get( EmpresaData.CONTRIBUINTE );
buff.append( "<B>" + ( contribuinte == null ? "" : contribuinte ) + "</B><BR>" );
buff.append( "&nbsp;N\u00DAMERO SEGURAN\u00C7A SOCIAL: " );
String segSocial = ( String ) empresa.get( EmpresaData.SEGURANCA_SOCIAL );
buff.append( "<B>" + ( segSocial == null ? "" : segSocial ) + "</B><BR>" );
buff.append( "&nbsp;CAE: " );
String CAE = ( String ) empresa.get( EmpresaData.CAE );
buff.append( "<B>" + ( CAE == null ? "" : CAE ) + "</B><BR>" );
buff.append( "<BR>&nbsp;N\u00DAMERO M\u00C9DIO DE TRABALHADORES DURANTE O ANO" );
double contagemMedia[] = provider.countNumeroMedioTrabalhadoresEmpresa( idEmpresa, ano );
buff.append( "<TABLE BORDER=\"0\">" );
buff.append( "<TR>" );
buff.append( "<TD>&nbsp;&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>TOTAL</TD><TD>&nbsp;</TD><TD>HOMENS</TD><TD>&nbsp;</TD><TD>MULHERES</TD>" );
buff.append( "</TR><TR>" );
buff.append( "<TD>&nbsp;&nbsp;</TD><TD>TOTAL</TD><TD>&nbsp;</TD><TD ALIGN=\"CENTER\"><B>" + (int)( Math.round( contagemMedia[0] ) + Math.round( contagemMedia[1] ) ) + "</B></TD>");
buff.append( "<TD>&nbsp;</TD><TD ALIGN=\"CENTER\"><B>" + ( (int)Math.round( contagemMedia[0] ) ) + "</B></TD>" );
buff.append( "<TD>&nbsp;</TD><TD ALIGN=\"CENTER\"><B>" + ( (int)Math.round( contagemMedia[1] ) ) + "</B></TD>" );
buff.append( "</TR>" );
buff.append( "</TABLE>" );
buff.append( "<BR>&nbsp;N\u00DAMERO TOTAL DE TRABALHADORES DURANTE O ANO" );
double contagemTotal[] = provider.countNumeroTotalTrabalhadoresEmpresa( idEmpresa, ano );
buff.append( "<TABLE BORDER=\"0\">" );
buff.append( "<TR>" );
buff.append( "<TD>&nbsp;&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>TOTAL</TD><TD>&nbsp;</TD><TD>HOMENS</TD><TD>&nbsp;</TD><TD>MULHERES</TD>" );
buff.append( "</TR><TR>" );
buff.append( "<TD>&nbsp;&nbsp;</TD><TD>TOTAL</TD><TD>&nbsp;</TD><TD ALIGN=\"CENTER\"><B>" + (int)( Math.round( contagemTotal[0] ) + Math.round( contagemTotal[1] ) ) + "</B></TD>");
buff.append( "<TD>&nbsp;</TD><TD ALIGN=\"CENTER\"><B>" + ( (int)Math.round( contagemTotal[0] ) ) + "</B></TD>" );
buff.append( "<TD>&nbsp;</TD><TD ALIGN=\"CENTER\"><B>" + ( (int)Math.round( contagemTotal[1] ) ) + "</B></TD>" );
buff.append( "</TR>" );
buff.append( "</TABLE>" );
IDObject estabelecimentos[];
if( sEstabelecimento == -1 || ( ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento ) ).getID().equals( new Integer( -1 ) ) )
{
estabelecimentos = provider.getAllEstabelecimentosForEmpresa( idEmpresa );
}
else
{
estabelecimentos = new IDObject[ 1 ];
estabelecimentos[ 0 ] = ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento );
}
buff.append( "<BR>" );
buff.append( "<BR><I>&nbsp;ESTABELECIMENTOS</I><BR>" );
buff.append( "<BR>" );
for( int n = 0; n < estabelecimentos.length; n++ )
{
EstabelecimentoData estabelecimento = (EstabelecimentoData)JDO.load( EstabelecimentoData.class, estabelecimentos[ n ].getID() );
buff.append( "&nbsp;&nbsp;NOME: " );
String nome = (String)estabelecimento.get( EstabelecimentoData.NOME );
buff.append( "<B>" + ( nome == null ? "" : nome.trim() ) + "</B><BR>" );
buff.append( "&nbsp;&nbsp;MORADA: " );
morada = (String)estabelecimento.get( EstabelecimentoData.MORADA );
buff.append( "<B>" + ( morada == null ? "" : morada.trim() ) + "</B><BR>" );
buff.append( "&nbsp;&nbsp;LOCALIDADE: " );
localidade = (String)estabelecimento.get( EstabelecimentoData.LOCALIDADE );
buff.append( "<B>" + ( localidade == null ? "" : localidade.trim() ) + "</B><BR>" );
buff.append( "&nbsp;&nbsp;C\u00D3DIGO POSTAL: " );
codigoPostal = (String)estabelecimento.get( EstabelecimentoData.CODIGO_POSTAL );
buff.append( "<B>" + ( codigoPostal == null ? "" : codigoPostal.trim() ) + "</B><BR>" );
contacto = (ContactoData)estabelecimento.get( EstabelecimentoData.CONTACTO );
if( contacto == null )
{
buff.append( "&nbsp;&nbsp;TELEFONE: <BR>" );
buff.append( "&nbsp;&nbsp;FAX: <BR>" );
}
else
{
buff.append( "&nbsp;&nbsp;TELEFONE: " );
String telefone = ( String ) contacto.get( ContactoData.TELEFONE );
buff.append( "<B>" + ( telefone == null ? "" : telefone.trim() ) + "</B><BR>" );
buff.append( "&nbsp;&nbsp;FAX: " );
String fax = ( String ) contacto.get( ContactoData.TELEFONE );
buff.append( "<B>" + ( fax == null ? "" : fax.trim() ) + "</B><BR>" );
}
int countTrabalhadores[] = provider.countTrabalhadoresEstabelecimentoDezembro( estabelecimentos[ n ].getID(), ano );
buff.append( "<BR>" );
buff.append( "&nbsp;&nbsp;<I>TRABALHADORES A 31 DE DEZEMBRO DE " + ano + ":</I> " );
buff.append( "<BR>" );
buff.append( "<TABLE BORDER=\"0\">" );
buff.append( "<TR>" );
buff.append( "<TD>&nbsp;&nbsp;</TD><TD>&nbsp</TD><TD>TOTAL</TD><TD>HOMENS</TD><TD>MULHERES</TD>" );
buff.append( "</TR>" );
buff.append( "<TR>" );
buff.append( "<TD>&nbsp;&nbsp;</TD><TD>TOTAL</TD>"
+ "<TD ALIGN=\"CENTER\"><B> " + ( countTrabalhadores[0] + countTrabalhadores[1] ) + "</B></Td>"
+ "<TD ALIGN=\"CENTER\"><B> " + ( countTrabalhadores[0] ) + "</B></TD>"
+ "<TD ALIGN=\"CENTER\"><B> " + ( countTrabalhadores[1] ) + "</B></TD>" );
buff.append( "</TR>" );
int countTrabalhadoresEtario[][] = provider.countTrabalhadoresEstabelecimentoDezembroPorGrupoEtario( estabelecimentos[ n ].getID(), ano );
buff.append( "<TR>" );
buff.append( "<TD>&nbsp;&nbsp;</TD><TD>MENOS DE 18 ANOS</TD>"
+ "<TD ALIGN=\"CENTER\"><B> " + ( countTrabalhadoresEtario[0][0] + countTrabalhadoresEtario[0][1] ) + "</B></Td>"
+ "<TD ALIGN=\"CENTER\"><B> " + ( countTrabalhadoresEtario[0][0] ) + "</B></TD>"
+ "<TD ALIGN=\"CENTER\"><B> " + ( countTrabalhadoresEtario[0][1] ) + "</B></TD>" );
buff.append( "</TR>" );
buff.append( "<TR>" );
buff.append( "<TD>&nbsp;&nbsp;</TD><TD>18 A 49 ANOS</TD>"
+ "<TD ALIGN=\"CENTER\"><B> " + ( countTrabalhadoresEtario[1][0] + countTrabalhadoresEtario[1][1] ) + "</B></Td>"
+ "<TD ALIGN=\"CENTER\"><B> " + ( countTrabalhadoresEtario[1][0] ) + "</B></TD>"
+ "<TD ALIGN=\"CENTER\"><B> " + ( countTrabalhadoresEtario[1][1] ) + "</B></TD>" );
buff.append( "</TR>" );
buff.append( "<TR>" );
buff.append( "<TD>&nbsp;&nbsp;</TD><TD>MAIS DE 50 ANOS</TD>"
+ "<TD ALIGN=\"CENTER\"><B> " + ( countTrabalhadoresEtario[2][0] + countTrabalhadoresEtario[2][1] ) + "</B></Td>"
+ "<TD ALIGN=\"CENTER\"><B> " + ( countTrabalhadoresEtario[2][0] ) + "</B></TD>"
+ "<TD ALIGN=\"CENTER\"><B> " + ( countTrabalhadoresEtario[2][1] ) + "</B></TD>" );
buff.append( "</TR>" );
buff.append( "</TABLE>" );
buff.append( "<BR>" );
int countExames[][] = provider.countExamesEstabelecimentoDezembroPorGrupoEtario( estabelecimentos[ n ].getID(), ano );
for( int cE = 0; cE < countExames[ countExames.length - 2 ].length; cE++ )
{
countExames[ countExames.length - 2 ][ cE ] += countExames[ countExames.length - 1 ][ cE ];
}
int totais[] = new int[ 6 ];
for( int cE1 = 0; cE1 < totais.length; cE1++ )
{
for( int cE2 = 0; cE2 < countExames.length; cE2++ )
{
totais[ cE1 ] += countExames[ cE2 ][ cE1 ];
}
}
buff.append( "<BR>" );
buff.append( "&nbsp;&nbsp;<I>N\u00DAMERO DE EXAMES DE ADMISS\u00C3O, PERI\u00D3DICOS E OCASIONAIS EFECTUADOS</I>" );
buff.append( "<BR>" );
buff.append( "<TABLE BORDER=\"0\">" );
buff.append( "<TR><TD>&nbsp;&nbsp;&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>TOTAL</TD><TD>&nbsp;</TD><TD>INFERIOR A 18 ANOS</TD>"
+ "<TD>&nbsp;</TD><TD>18 A 49 ANOS</TD><TD>&nbsp;</TD><TD>50 E MAIS ANOS</TD><TD>&nbsp;</TD></TR>" );
buff.append( "<TR><TD>&nbsp;&nbsp;&nbsp;</TD><TD>TOTAL DE EXAMES</TD><TD>&nbsp;</TD><TD>H</TD>" );
buff.append( "<TD ALIGN=\"CENTER\"><B>" + ( totais[0] + totais[1] + totais[2] ) + "</B></TD><TD>&nbsp;</TD>" );
for( int t = 0; t < 3; t++ )
{
buff.append( "<TD ALIGN=\"CENTER\"><B>" + totais[t] + "</B></TD><TD>&nbsp;</TD>" );
}
buff.append( "</TR>" );
buff.append( "<TR><TD>&nbsp;&nbsp;&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>M</TD>" );
buff.append( "<TD ALIGN=\"CENTER\"><B>" + ( totais[3] + totais[4] + totais[5] ) + "</B></TD><TD>&nbsp;</TD>" );
for( int t = 3; t < 6; t++ )
{
buff.append( "<TD ALIGN=\"CENTER\"><B>" + totais[t] + "</B></TD><TD>&nbsp;</TD>" );
}
buff.append( "</TR>" );
String sexos[] = new String[]{ "H", "M" };
for( int t = 0; t < provider.DESCRICAO_TIPOS_EXAME.length; t++ )
{
buff.append( "<TR><TD>&nbsp;&nbsp;&nbsp;</TD><TD>&nbsp;"+provider.DESCRICAO_TIPOS_EXAME[t]+"</TD>" );
for( int s = 0; s < 2; s++ )
{
buff.append( "<TD>&nbsp;</TD><TD>" + sexos[ s ] + "</TD>" );
buff.append( "<TD ALIGN=\"CENTER\"><B>" + (countExames[t][s*3]+countExames[t][s*3+1]+countExames[t][s*3+2]) + "</B></TD><TD>&nbsp;</TD>" );
for( int d = 0; d < 3; d++ )
{
buff.append( "<TD ALIGN=\"CENTER\"><B>" + countExames[t][s*3+d] + "</B></TD><TD>&nbsp;</TD>" );
}
if( s == 0 )
{
buff.append( "</TR><TR><TD>&nbsp;&nbsp;&nbsp;</TD><TD>&nbsp;</TD>" );
}
else
{
buff.append( "</TR>" );
}
}
}
int countExamesOcasionais[][] = provider.countExamesOcasionaisEstabelecimentoDezembroPorGrupoEtario( estabelecimentos[ n ].getID(), ano );
for( int t = 0; t < provider.DESCRICAO_TIPOS_OCASIONAL.length; t++ )
{
buff.append( "<TR><TD>&nbsp;&nbsp;&nbsp;</TD><TD>&nbsp;&nbsp;&nbsp;&nbsp;"+provider.DESCRICAO_TIPOS_OCASIONAL[t]+"</TD>" );
for( int s = 0; s < 2; s++ )
{
buff.append( "<TD>&nbsp;</TD><TD>" + sexos[ s ] + "</TD>" );
int sum = countExamesOcasionais[t][s*3]+countExamesOcasionais[t][s*3+1]+countExamesOcasionais[t][s*3+2];
buff.append( "<TD ALIGN=\"CENTER\"><B>" + ( sum < 0 ? "-" : "" + sum ) + "</B></TD><TD>&nbsp;</TD>" );
for( int d = 0; d < 3; d++ )
{
int val = countExamesOcasionais[t][s*3+d];
if( val < 0 )
{
countExamesOcasionais[t][s*3+d] = 0;
}
buff.append( "<TD ALIGN=\"CENTER\"><B>" + ( val < 0 ? "-" : "" + val ) + "</B></TD><TD>&nbsp;</TD>" );
}
if( s == 0 )
{
buff.append( "</TR><TR><TD>&nbsp;&nbsp;&nbsp;</TD><TD>&nbsp;&nbsp;&nbsp;&nbsp;</TD>" );
}
else
{
buff.append( "</TR>" );
}
}
}
buff.append( "</TABLE>" );
buff.append( "<BR>" );
buff.append( "&nbsp;&nbsp;<I>EXAMES COMPLEMENTARES REALIZADOS</I>" );
buff.append( "<BR>" );
buff.append( "<TABLE BORDER=\"0\">" );
buff.append( "<TR><TD>&nbsp;&nbsp;&nbsp;</TD><TD>TIPO DE EXAME</TD><TD>&nbsp;</TD>" );
buff.append( "<TD>N\u00BA TOTAL DE EXAMES</TD></TR>" );
String nomesExamesComp[] = provider.getNomesExames();
// int countExamesComp[] = provider.countExamesComplementaresEmpresa( idEmpresa, ano );
int countExamesComp[] = provider.countExamesComplementaresEstabelecimento( estabelecimentos[ n ].getID(), ano );
for( int nec = 0; nec < nomesExamesComp.length; nec++ )
{
buff.append( "<TR>" );
buff.append( "<TD>&nbsp;&nbsp;&nbsp;</TD><TD>" + nomesExamesComp[nec] + "</TD>" );
buff.append( "<TD>&nbsp;</TD><TD ALIGN=\"CENTER\"><B>" + countExamesComp[nec] + "</B></TD>" );
buff.append( "</TR>" );
}
buff.append( "</TABLE>" );
buff.append("<BR><HR><BR>");
}
resultadoText.setText( buff.toString() );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
return;
}
}
else if( source.equals( exportarButton ) )
{
exportar();
}
}
public void exportar()
{
FileDialog dialog = new FileDialog( this, "Ficheiro de destino", FileDialog.SAVE );
dialog.setDirectory( System.getProperty( "user.home" ) );
dialog.setVisible( true );
String fileName;
String dirName;
fileName = dialog.getFile();
dirName = dialog.getDirectory();
if( fileName != null )
{
int index = fileName.indexOf( '.' );
if( index == -1 )
{
fileName += ".html";
}
if( index == fileName.length() - 1 )
{
fileName += "html";
}
String fullName = dirName + fileName;
String text = resultadoText.getText();
String title = "S.I.P.R.P. - Sociedade Ib&eacute;rica de Preven&ccedil;&atilde;o de Riscos Profissionais";
String style = "<style type=\"text/css\">\n"
+ " body,td{font-family: arial;"
+ " font-size: 8pt; }\n"
+ " p{font-family: arial;"
+ " font-size: 1pt; }\n"
+ "</style>";
text = text.replace( "<head>", "<head>\n\t\t<title>" + title + "</title>\n" + style );
text = text.replace( "<font size=\"+2\">", "<div style=\"font-family : arial; font-size : 12pt;\">" );
text = text.replace( "</font>", "</div>" );
text = text.replace( "<body>", "<body>\n<div style=\"font-family : arial; font-size : 12pt;\" align=\"center\"><b>Relat&oacute;rio Anual</b></div>" );
// String title = "S.I.P.R.P. - Sociedade Ib&eacute;rica de Preven&ccedil;&atilde;o de Riscos Profissionais";
// text = text.replace( "<head>", "<head>\n\t\t<title>" + title + "</title>" );
// System.out.println( text );
try
{
FileWriter writer = new FileWriter( new File( fullName ) );
writer.write( text );
writer.close();
}
catch( IOException ex )
{
DialogException.showException( ex );
return;
}
}
}
}

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save