diff --git a/trunk/.classpath b/trunk/.classpath deleted file mode 100644 index 884a915d..00000000 --- a/trunk/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/trunk/.project b/trunk/.project deleted file mode 100644 index 200965fb..00000000 --- a/trunk/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - SIPRP - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/trunk/SIPRPSoft/src/alter3.sql b/trunk/SIPRPSoft/src/alter3.sql deleted file mode 100644 index 4bfea09d..00000000 --- a/trunk/SIPRPSoft/src/alter3.sql +++ /dev/null @@ -1,32 +0,0 @@ -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 ); \ No newline at end of file diff --git a/trunk/SIPRPSoft/src/alter_20060516.sql b/trunk/SIPRPSoft/src/alter_20060516.sql deleted file mode 100644 index 3e76a52c..00000000 --- a/trunk/SIPRPSoft/src/alter_20060516.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table empresas add inicio_contrato date; -alter table empresas add duracao int; \ No newline at end of file diff --git a/trunk/SIPRPSoft/src/alter_20070124.sql b/trunk/SIPRPSoft/src/alter_20070124.sql deleted file mode 100644 index 0f7cfb06..00000000 --- a/trunk/SIPRPSoft/src/alter_20070124.sql +++ /dev/null @@ -1,154 +0,0 @@ --- Table: ecd_oficial - --- DROP TABLE ecd_oficial; - -CREATE TABLE ecd_oficial -( - id serial NOT NULL, - descricao varchar(255), - descricao_plain varchar(255), - ordem int4, - activo char(1), - CONSTRAINT ecd_oficial_pkey PRIMARY KEY (id) -) -WITHOUT OIDS; -ALTER TABLE ecd_oficial OWNER TO postgres; - - --- Table: prestadores - --- DROP TABLE prestadores; - -CREATE TABLE prestadores -( - id serial NOT NULL, - nome varchar(255), - nome_plain varchar(255), - morada varchar(2048), - codigo_postal varchar(16), - localidade varchar(255), - localidade_cp varchar(255), - contacto_id int4, - activo char(1), - faz_consultas char(1), - faz_ecds char(1), - CONSTRAINT prestadores_pkey PRIMARY KEY (id), - CONSTRAINT prestadores_contacto_id_fkey FOREIGN KEY (contacto_id) - REFERENCES contactos (id) MATCH SIMPLE - ON UPDATE NO ACTION ON DELETE NO ACTION -) -WITHOUT OIDS; -ALTER TABLE prestadores OWNER TO postgres; - - --- Table: prestadores_grupos_protocolo - --- DROP TABLE prestadores_grupos_protocolo; - -CREATE TABLE prestadores_grupos_protocolo -( - id serial NOT NULL, - prestador_id int4 NOT NULL, - grupo_protocolo_id int4 NOT NULL, - CONSTRAINT prestadores_grupos_protocolo_pkey PRIMARY KEY (id), - CONSTRAINT prestadores_grupos_protocolo_grupo_protocolo_id_fkey FOREIGN KEY (grupo_protocolo_id) - REFERENCES prt_grupos_protocolo (id) MATCH SIMPLE - ON UPDATE NO ACTION ON DELETE NO ACTION, - CONSTRAINT prestadores_grupos_protocolo_prestador_id_fkey FOREIGN KEY (prestador_id) - REFERENCES prestadores (id) MATCH SIMPLE - ON UPDATE NO ACTION ON DELETE NO ACTION -) -WITHOUT OIDS; -ALTER TABLE prestadores_grupos_protocolo OWNER TO postgres; - - - --- Table: marcacoes_trabalhador_estados - --- DROP TABLE marcacoes_trabalhador_estados; - -CREATE TABLE marcacoes_trabalhador_estados -( - id serial NOT NULL, - data date, - estado int4, - marcacao_id int4, - CONSTRAINT marcacoes_trabalhador_estados_pkey PRIMARY KEY (id), - CONSTRAINT marcacoes_trabalhador_estados_marcacao_id_fkey FOREIGN KEY (marcacao_id) - REFERENCES marcacoes_trabalhador (id) MATCH SIMPLE - ON UPDATE NO ACTION ON DELETE NO ACTION -) -WITHOUT OIDS; -ALTER TABLE marcacoes_trabalhador_estados OWNER TO postgres; - -alter table marcacoes_grupos_realizados add marcacoes_trabalhador_estado_id int4 references marcacoes_trabalhador_estados(id); - --- Table: lembretes_tipos - --- DROP TABLE lembretes_tipos; - -CREATE TABLE lembretes_tipos -( - id serial NOT NULL, - codigo varchar(16) NOT NULL, - descricao varchar(255) NOT NULL, - ordem int4 NOT NULL, - activo char(1) NOT NULL DEFAULT 'y'::bpchar, - CONSTRAINT lembretes_tipos_pkey PRIMARY KEY (id) -) -WITHOUT OIDS; -ALTER TABLE lembretes_tipos OWNER TO postgres; - -INSERT INTO lembretes_tipos (codigo, descricao, ordem, activo ) - VALUES( 'EXTERNO','Avisos Externos', 1, 'y' ); -INSERT INTO lembretes_tipos (codigo, descricao, ordem, activo ) - VALUES( 'REMARCACOES', 'Remarca\\u00e7\\u00f5es', 3 , 'y' ); -INSERT INTO lembretes_tipos (codigo, descricao, ordem, activo ) - VALUES( 'MARCACOES', 'Marca\\u00e7\\u00f5es Pendentes', 2, 'y' ); -INSERT INTO lembretes_tipos (codigo, descricao, ordem, activo ) - VALUES( 'OUTROS','Outros',4,'y' ); - --- Table: lembretes - --- DROP TABLE lembretes; - -CREATE TABLE lembretes -( - id serial NOT NULL, - tipo_id int4 NOT NULL, - data date NOT NULL, - descricao varchar(255) NOT NULL, - texto varchar(16384), - empresa_id int4, - estabelecimento_id int4, - trabalhador_id int4, - marcacao_estabelecimento_id int4, - marcacao_trabalhador_id int4, - enviar_email char(1) DEFAULT 'n'::bpchar, - periodicidade_dias int4, - periodicidade_meses int4, - ultimo_envio date, - CONSTRAINT lembretes_pkey PRIMARY KEY (id), - CONSTRAINT lembretes_empresa_id_fkey FOREIGN KEY (empresa_id) - REFERENCES empresas (id) MATCH SIMPLE - ON UPDATE NO ACTION ON DELETE NO ACTION, - CONSTRAINT lembretes_estabelecimento_id_fkey FOREIGN KEY (estabelecimento_id) - REFERENCES estabelecimentos (id) MATCH SIMPLE - ON UPDATE NO ACTION ON DELETE NO ACTION, - CONSTRAINT lembretes_marcacao_estabelecimento_id_fkey FOREIGN KEY (marcacao_estabelecimento_id) - REFERENCES marcacoes_estabelecimento (id) MATCH SIMPLE - ON UPDATE NO ACTION ON DELETE NO ACTION, - CONSTRAINT lembretes_marcacao_trabalhador_id_fkey FOREIGN KEY (marcacao_trabalhador_id) - REFERENCES marcacoes_trabalhador (id) MATCH SIMPLE - ON UPDATE NO ACTION ON DELETE NO ACTION, - CONSTRAINT lembretes_tipo_id_fkey FOREIGN KEY (tipo_id) - REFERENCES lembretes_tipos (id) MATCH SIMPLE - ON UPDATE NO ACTION ON DELETE NO ACTION, - CONSTRAINT lembretes_trabalhador_id_fkey FOREIGN KEY (trabalhador_id) - REFERENCES trabalhadores (id) MATCH SIMPLE - ON UPDATE NO ACTION ON DELETE NO ACTION -) -WITHOUT OIDS; -ALTER TABLE lembretes OWNER TO postgres; - - diff --git a/trunk/SIPRPSoft/src/alter_20070221.sql b/trunk/SIPRPSoft/src/alter_20070221.sql deleted file mode 100644 index 722c7dd1..00000000 --- a/trunk/SIPRPSoft/src/alter_20070221.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE prestadores ADD contribuinte VARCHAR(64); -ALTER TABLE marcacoes_trabalhador ADD prestador_id int4 REFERENCES prestadores( id ); -ALTER TABLE marcacoes_trabalhador_estados ADD prestador_id int4 REFERENCES prestadores( id ); \ No newline at end of file diff --git a/trunk/SIPRPSoft/src/build.xml b/trunk/SIPRPSoft/src/build.xml deleted file mode 100644 index d0a1900e..00000000 --- a/trunk/SIPRPSoft/src/build.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/trunk/SIPRPSoft/src/jpox_siprp.bat b/trunk/SIPRPSoft/src/jpox_siprp.bat deleted file mode 100644 index 782060b7..00000000 --- a/trunk/SIPRPSoft/src/jpox_siprp.bat +++ /dev/null @@ -1,7 +0,0 @@ -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 -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/medicina/prestadores/data/package.jdo -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/medicina/processo/data/package.jdo -cd .. -cd .. \ No newline at end of file diff --git a/trunk/SIPRPSoft/src/jpox_siprp.sh b/trunk/SIPRPSoft/src/jpox_siprp.sh deleted file mode 100644 index 10724bcc..00000000 --- a/trunk/SIPRPSoft/src/jpox_siprp.sh +++ /dev/null @@ -1,7 +0,0 @@ -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 -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/medicina/prestadores/data/package.jdo -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/medicina/processo/data/package.jdo -cd .. -cd .. \ No newline at end of file diff --git a/trunk/SIPRPSoft/src/jws/siprp.jnlp b/trunk/SIPRPSoft/src/jws/siprp.jnlp deleted file mode 100644 index 09ba18d2..00000000 --- a/trunk/SIPRPSoft/src/jws/siprp.jnlp +++ /dev/null @@ -1,41 +0,0 @@ - - - - - SIPRP - EVOLUTE 2005 - - SIPRP, v3.2 - SIPRP - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/trunk/SIPRPSoft/src/log4j.properties b/trunk/SIPRPSoft/src/log4j.properties deleted file mode 100644 index 3a9b9feb..00000000 --- a/trunk/SIPRPSoft/src/log4j.properties +++ /dev/null @@ -1,3 +0,0 @@ -log4j.rootCategory=ERROR, dest1 -log4j.appender.dest1=org.apache.log4j.ConsoleAppender -log4j.appender.dest1.layout=org.apache.log4j.PatternLayout diff --git a/trunk/SIPRPSoft/src/logo/logo_combo.jpg b/trunk/SIPRPSoft/src/logo/logo_combo.jpg deleted file mode 100644 index 24d6543a..00000000 Binary files a/trunk/SIPRPSoft/src/logo/logo_combo.jpg and /dev/null differ diff --git a/trunk/SIPRPSoft/src/logo/logo_w400.jpg b/trunk/SIPRPSoft/src/logo/logo_w400.jpg deleted file mode 100644 index 97fa4634..00000000 Binary files a/trunk/SIPRPSoft/src/logo/logo_w400.jpg and /dev/null differ diff --git a/trunk/SIPRPSoft/src/logo/logo_w400.png b/trunk/SIPRPSoft/src/logo/logo_w400.png deleted file mode 100644 index 2e9fe434..00000000 Binary files a/trunk/SIPRPSoft/src/logo/logo_w400.png and /dev/null differ diff --git a/trunk/SIPRPSoft/src/logo_combo.jpg b/trunk/SIPRPSoft/src/logo_combo.jpg deleted file mode 100644 index 24d6543a..00000000 Binary files a/trunk/SIPRPSoft/src/logo_combo.jpg and /dev/null differ diff --git a/trunk/SIPRPSoft/src/logo_evo.jpg b/trunk/SIPRPSoft/src/logo_evo.jpg deleted file mode 100644 index 230ae585..00000000 Binary files a/trunk/SIPRPSoft/src/logo_evo.jpg and /dev/null differ diff --git a/trunk/SIPRPSoft/src/siprp/CompanyDataLoader.java b/trunk/SIPRPSoft/src/siprp/CompanyDataLoader.java deleted file mode 100644 index 645bc01f..00000000 --- a/trunk/SIPRPSoft/src/siprp/CompanyDataLoader.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * CompanyDataLoader.java - * - * Created on 25 de Janeiro de 2005, 13:18 - */ - -package siprp; - -/** - * - * @author fpalma - */ -public interface CompanyDataLoader -{ - public static final String DATA = "XDATAX"; - public static final String NOME = "XNOMEX"; - public static final String MORADA = "XMORADAX"; - public static final String HORA = "XHORAX"; - public void load(); -} diff --git a/trunk/SIPRPSoft/src/siprp/FichaDataProvider.java b/trunk/SIPRPSoft/src/siprp/FichaDataProvider.java deleted file mode 100644 index 2026e483..00000000 --- a/trunk/SIPRPSoft/src/siprp/FichaDataProvider.java +++ /dev/null @@ -1,698 +0,0 @@ -/* - * FichaDataProvider.java - * - * Created on 30 de Marco de 2004, 11:31 - */ - -package siprp; - -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.ui.search.*; -import com.evolute.utils.sql.*; -import com.evolute.utils.strings.*; - -import siprp.data.*; - -/** - * - * @author pars - */ -public class FichaDataProvider extends MetaProvider implements SearchExecuter { - - private static final Object LOCK = new Object(); - private static FichaDataProvider instance = null; - private final Executer executer; - - public static final String SIPRP = "SIPRP - Sociedade Ib\u00e9rica de Preven\u00e7\u00e3o de Riscos Profissionais"; - - // empresas - public static final String T_EMPRESAS = "empresas"; - public static final String ID = "id"; - public static final String DESIGNACAO_SOCIAL = "designacao_social"; - 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 INACTIVO = "inactivo"; - - public static final DBTable EMPRESAS = - new DBTable( T_EMPRESAS, - new String[]{ DESIGNACAO_SOCIAL, - SERVICO_SAUDE_TIPO, - SERVICO_SAUDE_DESIGNACAO, - SERVICO_HIGIENE_TIPO, - SERVICO_HIGIENE_DESIGNACAO, - INACTIVO }, - ID ); - - // estabelecimentos - public static final String T_ESTABELECIMENTOS = "estabelecimentos"; - // ID - public static final String NOME = "nome"; - public static final String LOCALIDADE = "localidade"; - public static final String EMPRESA_ID = "empresa_id"; - // INACTIVO - - public static final DBTable ESTABELECIMENTOS = - new DBTable( T_ESTABELECIMENTOS, - new String[]{ NOME, LOCALIDADE, EMPRESA_ID, INACTIVO }, - ID ); - - // trabalhadores - public static final String T_TRABALHADORES = "trabalhadores"; - // ID - // public static final String NOME = "nome"; - 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_ID = "estabelecimento_id"; - // INACTIVO - - public static final DBTable TRABALHADORES = - new DBTable( T_TRABALHADORES, - new String[]{ NOME, SEXO, DATA_NASCIMENTO, - NACIONALIDADE, NUMERO_MECANOGRAFICO, - DATA_ADMISSAO, CATEGORIA, LOCAL_TRABALHO, - FUNCAO_PROPOSTA, DATA_ADMISSAO_FUNCAO, - OBSERVACOES, ESTABELECIMENTO_ID, INACTIVO }, - ID ); - - //medicos - public static final String T_MEDICOS = "medicos"; - - public static final String NUMERO_CEDULA = "numero_cedula"; - - public static final DBTable MEDICOS = - new DBTable( T_MEDICOS, - new String[]{ NOME, NUMERO_CEDULA }, ID ); - - // exames - public static final String T_EXAMES = "exames"; - // ID - 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_ID = "trabalhador_id"; - public static final String MEDICO_ID = "medico_id"; - public static final String PDF = "pdf"; - - public static final DBTable EXAMES = - new DBTable( T_EXAMES, - new String[]{ DATA, TIPO, OCASIONAL, - OUTRO_TIPO, RESULTADO, OUTRA_FUNCAO_1, - OUTRA_FUNCAO_2, OUTRA_FUNCAO_3, - OUTRA_FUNCAO_4, PROXIMO_EXAME, - OUTRAS_RECOMENDACOES, TRABALHADOR_ID, MEDICO_ID, PDF, INACTIVO }, - ID ); - - public static DBReference R_ESTABELECIMENTO_EMPRESA = new DBReference( ESTABELECIMENTOS.getFieldByName( EMPRESA_ID ) ); - public static DBReference R_TRABALHADOR_ESTABELECIMENTO = new DBReference( TRABALHADORES.getFieldByName( ESTABELECIMENTO_ID ) ); - public static DBReference R_EXAME_TRABALHADOR = new DBReference( EXAMES.getFieldByName( TRABALHADOR_ID ) ); - public static DBReference R_EXAME_MEDICO = new DBReference( EXAMES.getFieldByName( MEDICO_ID ) ); - static - { - try - { - EXAMES.addRelation( MEDICOS, - new DBField[]{ EXAMES.getFieldByName( MEDICO_ID ) }, - "R_EXAMES_MEDICOS" ); - EXAMES.addRelation( TRABALHADORES, - new DBField[]{ EXAMES.getFieldByName( TRABALHADOR_ID ) }, - "R_EXAMES_TRABALHADORES" ); - TRABALHADORES.addRelation( ESTABELECIMENTOS, - new DBField[]{ TRABALHADORES.getFieldByName( ESTABELECIMENTO_ID ) }, - "R_TRABALHADORES_ESTABELECIMENTOS" ); - ESTABELECIMENTOS.addRelation( EMPRESAS, - new DBField[]{ ESTABELECIMENTOS.getFieldByName( EMPRESA_ID ) }, - "R_ESTABELECIMENTOS_EMPRESAS" ); - EMPRESAS.disableSave( INACTIVO ); - ESTABELECIMENTOS.disableSave( INACTIVO ); - TRABALHADORES.disableSave( INACTIVO ); - EXAMES.disableSave( PDF ); - } - catch( Exception e ) - { - throw new RuntimeException( e ); - } - } - - public static final int SEARCH_EMPRESAS = 0; - public static final int SEARCH_ESTABELECIMENTOS = 1; - public static final int SEARCH_TRABALHADORES = 2; - public static final int SEARCH_EXAMES = 3; - private int SEARCH = 0; - private int SEARCH_EMPRESAS_ID = -1; - private int SEARCH_ESTABELECIMENTOS_ID = -1; - private int SEARCH_TRABALHADORES_ID = -1; - private int SEARCH_EXAMES_ID = -1; - - protected final Hashtable medicosEstabelecimentosHash = new Hashtable(); - - /** Creates a new instance of FichaDataProvider */ - public FichaDataProvider() - throws Exception - { - DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ ); - executer = dbm.getSharedExecuter( this ); - - setDBTable( EXAMES ); - - } - - public static MetaProvider getProvider() - throws Exception - { - synchronized( LOCK ) - { - if( instance == null ) - { - instance = new FichaDataProvider(); - } - } - return instance; - } - - public String[] getColumnNames() { - return new String[]{ "Nome" }; - } - - public String getSearchTitle() { - switch( SEARCH ) - { - case SEARCH_EMPRESAS: - return "Procurar empresa"; - case SEARCH_ESTABELECIMENTOS: - return "Procurar estabelecimento"; - case SEARCH_TRABALHADORES: - return "Procurar trabalhador"; - case SEARCH_EXAMES: - return "Procurar exame"; - } - return ""; - } - - public boolean hasDetails() { - return false; - } - - public void setSearch( int what ) - { - switch( what ) - { - case SEARCH_EMPRESAS: - case SEARCH_ESTABELECIMENTOS: - case SEARCH_TRABALHADORES: - case SEARCH_EXAMES: - SEARCH = what; - break; - } - } - - public void setSearchID( int what, int id ) - { - switch( what ) - { - case SEARCH_EMPRESAS: - SEARCH_EMPRESAS_ID = id; - break; - case SEARCH_ESTABELECIMENTOS: - SEARCH_ESTABELECIMENTOS_ID = id; - break; - case SEARCH_TRABALHADORES: - SEARCH_TRABALHADORES_ID = id; - break; - case SEARCH_EXAMES: - SEARCH_EXAMES_ID = id; - break; - } - } - - public Virtual2DArray search( String pattern ) throws Exception { - switch( SEARCH ) - { - case SEARCH_EMPRESAS: - return searchEmpresas( pattern ); - case SEARCH_ESTABELECIMENTOS: - return searchEstabelecimentos( pattern ); - case SEARCH_TRABALHADORES: - return searchTrabalhadores( pattern ); - case SEARCH_EXAMES: - return searchExames( pattern ); - } - return null; - } - - public Virtual2DArray searchEmpresas( String pattern ) throws Exception { - Select select = new Select( new String[]{ T_EMPRESAS }, - new String[]{ ID, DESIGNACAO_SOCIAL, "designacao_social_plain" }, - new Field( "designacao_social_plain" ).isLike( "%" + StringPlainer.convertString( pattern, false, false ) + "%" ).and( - new Field( INACTIVO ).isDifferent( "y" ) ), - new String[]{ "designacao_social_plain" }, null ); -// Select select = new Select( "SELECT e.id, e.designacao_social FROM empresas e ORDER BY lower( e.designacao_social );" ); - return executer.executeQuery( select ); - } - - public Virtual2DArray searchEstabelecimentos( String pattern ) throws Exception { -// Select select = new Select( "SELECT e.id, e.nome FROM estabelecimentos e WHERE empresa_id = " + SEARCH_EMPRESAS_ID -// + " ORDER BY lower( e.nome )"); - Select select = new Select( new String[]{ T_ESTABELECIMENTOS }, - new String[]{ ID, NOME, "nome_plain" }, - new Field( "nome_plain" ).isLike( "%" + StringPlainer.convertString( pattern, false, false ) + "%" ).and( - new Field( EMPRESA_ID ).isEqual( new Integer( SEARCH_EMPRESAS_ID ) ) ).and( - new Field( INACTIVO ).isDifferent( "y" ) ), - new String[]{ "nome_plain" }, null ); - return executer.executeQuery( select ); - } - - public Virtual2DArray searchTrabalhadores( String pattern ) throws Exception { -// Select select = -// new Select( "SELECT t.id, t.nome FROM trabalhadores t, estabelecimentos es " -// + " WHERE t.estabelecimento_id = es.id " -// + " AND es.empresa_id = " + SEARCH_EMPRESAS_ID + " ORDER BY lower(t.nome);" ); - Select select = new Select( new String[]{ T_TRABALHADORES, T_ESTABELECIMENTOS }, - new String[]{ T_TRABALHADORES + "." + ID, T_TRABALHADORES + "." + NOME }, - new Field( T_TRABALHADORES + ".nome_plain" ).isLike( "%" + StringPlainer.convertString( pattern, false, false ) + "%" ).and( - new Field( ESTABELECIMENTO_ID ).isEqual( new Field( T_ESTABELECIMENTOS + "." + ID ) ) ).and( - new Field( ESTABELECIMENTO_ID ).isEqual( new Integer( SEARCH_ESTABELECIMENTOS_ID ) ) ).and( - new Field( EMPRESA_ID ).isEqual( new Integer( SEARCH_EMPRESAS_ID ) ) ).and( - new Field( T_TRABALHADORES + "." + INACTIVO ).isDifferent( "y" ) ), - new String[]{ T_TRABALHADORES + ".nome_plain" }, null ); - return executer.executeQuery( select ); - } - - public Virtual2DArray searchExames( String pattern ) throws Exception { - Select select = new Select( "SELECT e.id, e.data FROM exames e " - + " WHERE e.trabalhador_id = " + SEARCH_TRABALHADORES_ID - + " ORDER BY e.data DESC;" ); - return executer.executeQuery( select ); - } - - public void showDetails(SearchDialog dialog, Object o) throws Exception { - } - - public Object [][]getAllMedicos() - throws Exception - { - Select select = new Select( new String[]{ T_MEDICOS }, - new String[]{ ID, NOME, NUMERO_CEDULA }, - null, new String[]{ NOME }, null ); - Virtual2DArray array = executer.executeQuery( select ); - return array.getObjects(); - } - - public void savePDF( MetaObject exame ) - throws Exception - { - if( exame == null ) - { - return; - } - DBKey key = exame.getPrimaryKeyValue(); - DBField fields[] = EXAMES.getPrimaryKey(); - Integer id = new Integer( ((Number)key.getFieldValue( fields[ 0 ] )).intValue() ); - if( id == null ) - { - throw new Exception( "Error saving pdf: id is null" ); - } - byte []pdf = (byte[]) exame.getProperty( PDF ); - BlobUpdate bUpdate = new BlobUpdate( T_EXAMES, PDF, pdf, new Field( ID ).isEqual( id ) ); - executer.executeQuery( bUpdate ); - } - - public Integer getLastExameIDForTrabalhador( Integer trabalhadorID ) - throws Exception - { - Select select = new Select( new String[]{ T_EXAMES }, - new String[]{ ID, DATA }, - new Field( TRABALHADOR_ID ).isEqual( trabalhadorID ), - new String[]{ DATA + " DESC", ID + " DESC" }, null ); - Virtual2DArray array = executer.executeQuery( select ); - if( array.columnLength() == 0 ) - { - return null; - } - return new Integer( ( (Number) array.get( 0, 0 ) ).intValue() ); - } - - public IDObject []getAllFichasForTrabalhador( Integer trabalhadorID ) - throws Exception - { - Select select = - new Select( new String[]{ T_EXAMES }, new String[]{ "MAX("+ID+")", DATA }, - new Field( TRABALHADOR_ID ).isEqual( trabalhadorID ).and( - new Field( INACTIVO ).isEqual( "n" ) ), - new String[]{ DATA + " DESC" }, new String[]{ DATA } ); - Virtual2DArray array = executer.executeQuery( select ); - IDObject exames[] = new IDObject[ array.columnLength() ]; - DateFormat df = DateFormat.getDateInstance( DateFormat.SHORT ); - 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 != null? df.format( date ): "" ); - } - return exames; - } - - public IDObject []getAllEstabelecimentosForEmpresa( Integer empresaID ) - throws Exception - { - Select select = new Select( new String[]{ T_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 ); - IDObject objects[] = new IDObject[ array.columnLength() ]; - for( int n = 0; n < objects.length; n++ ) - { - Integer id = new Integer( ((Number)array.get( n, 0 )).intValue() ); - String desc = (String)array.get( n, 1 ); - objects[ n ] = new MappableObject( id, desc ); - } - return objects; - } - - public IDObject []getAllTrabalhadoresForEmpresa( Integer empresaID ) - throws Exception - { - Select select = new Select( new String[]{ T_TRABALHADORES, T_ESTABELECIMENTOS }, - new String[]{ T_TRABALHADORES + "." + ID, - T_TRABALHADORES + "." + NOME, - T_TRABALHADORES + ".nome_plain" }, - new Field( T_ESTABELECIMENTOS + "." + EMPRESA_ID ).isEqual( empresaID ).and( - new Field( T_TRABALHADORES + "." + ESTABELECIMENTO_ID ).isEqual( - new Field( T_ESTABELECIMENTOS + "." + ID ) ) ), - new String[]{ T_TRABALHADORES + ".nome_plain" }, null ); - Virtual2DArray array = executer.executeQuery( select ); - IDObject objects[] = new IDObject[ array.columnLength() ]; - for( int n = 0; n < objects.length; n++ ) - { - Integer id = new Integer( ((Number)array.get( n, 0 )).intValue() ); - String desc = (String)array.get( n, 1 ); - objects[ n ] = new MappableObject( id, desc ); - } - return objects; - } - - public IDObject []getAllTrabalhadoresForEstabelecimento( Integer estabelecimentoID ) - throws Exception - { - Select select = new Select( new String[]{ T_TRABALHADORES }, - new String[]{ ID, NOME, "nome_plain" }, - new Field( ESTABELECIMENTO_ID ).isEqual( estabelecimentoID ).and( - new Field( INACTIVO ).isDifferent( "y" ) ), - new String[]{ "nome_plain" }, null ); - Virtual2DArray array = executer.executeQuery( select ); - IDObject objects[] = new IDObject[ array.columnLength() ]; - for( int n = 0; n < objects.length; n++ ) - { - Integer id = new Integer( ((Number)array.get( n, 0 )).intValue() ); - String desc = (String)array.get( n, 1 ); - objects[ n ] = new MappableObject( id, desc ); - } - return objects; - } - - public Integer getEstabelecimentoIDForTrabalhador( Integer trabalhadorID ) - throws Exception - { - Select select = new Select( new String[]{ T_TRABALHADORES }, - new String[]{ ESTABELECIMENTO_ID }, - new Field( ID ).isEqual( trabalhadorID ).and( - new Field( INACTIVO ).isDifferent( "y" ) ), - null, null ); - Virtual2DArray array = executer.executeQuery( select ); - Integer estabelecimentoID = null; - if( array != null && array.columnLength() > 0 ) - { - estabelecimentoID = ( Integer )array.get( 0, 0 ); - } - return estabelecimentoID; - } - - public Integer getEmpresaIDForEstabelecimento( Integer estabelecimentoID ) - throws Exception - { - Select select = new Select( new String[]{ T_ESTABELECIMENTOS }, - new String[]{ EMPRESA_ID }, - new Field( ID ).isEqual( estabelecimentoID ).and( - new Field( INACTIVO ).isDifferent( "y" ) ), - null, null ); - Virtual2DArray array = executer.executeQuery( select ); - Integer empresaID = null; - if( array != null && array.columnLength() > 0 ) - { - empresaID = ( Integer )array.get( 0, 0 ); - } - return empresaID; - } - - public Integer []getAvisosIDByTipoAndDate( Integer tipo, Date date ) - throws Exception - { - Select select = new Select( new String[]{ "avisos" }, new String[]{ "id", "data_evento" }, - new Field( "tipo" ).isEqual( tipo ).and( - new Field( "data_aviso" ).isLessOrEqual( date )), - new String[]{ "data_evento" }, null ); - Virtual2DArray array = executer.executeQuery( select ); - Integer ids[] = new Integer[ array.columnLength() ]; - for( int n = 0; n < ids.length; n++ ) - { - ids[ n ] = new Integer( ((Number)array.get( n, 0 )).intValue() ); - } - return ids; - } - - public Object [][]getAvisosTrabalhadorByDate( Date date ) - throws Exception - { - Select select = new Select( new String[]{ "avisos", "empresas", "estabelecimentos", "trabalhadores" }, - new String[]{ "avisos.id", "avisos.data_evento", "avisos.descricao", - "empresas.designacao_social", "estabelecimentos.nome", - "trabalhadores.nome", "data_aviso" }, - new Field( "tipo" ).isEqual( new Integer( AvisoConstants.TIPO_TRABALHADOR ) ).and( - new Field( "data_aviso" ).isLessOrEqual( date ) ).and( - new Field( "avisos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) ).and( - new Field( "avisos.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ).and( - new Field( "avisos.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ), - new String[]{ "data_evento" }, null ); - Virtual2DArray array = executer.executeQuery( select ); - return array.getObjects(); - } - - public Object [][]getAvisosEstabelecimentoByDate( Date date ) - throws Exception - { - Select select = new Select( new String[]{ "avisos", "empresas", "estabelecimentos" }, - new String[]{ "avisos.id", "avisos.data_evento", "avisos.descricao", - "empresas.designacao_social", "estabelecimentos.nome", "data_aviso" }, - new Field( "tipo" ).isEqual( new Integer( AvisoConstants.TIPO_ESTABELECIMENTO ) ).and( - new Field( "data_aviso" ).isLessOrEqual( date ) ).and( - new Field( "avisos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) ).and( - new Field( "avisos.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) ), - new String[]{ "data_evento" }, null ); - Virtual2DArray array = executer.executeQuery( select ); - return array.getObjects(); - } - - public Object [][]getAvisosEmpresaByDate( Date date ) - throws Exception - { - Select select = new Select( new String[]{ "avisos", "empresas" }, - new String[]{ "avisos.id", "avisos.data_evento", "avisos.descricao", - "empresas.designacao_social", "data_aviso" }, - new Field( "tipo" ).isEqual( new Integer( AvisoConstants.TIPO_EMPRESA ) ).and( - new Field( "data_aviso" ).isLessOrEqual( date ) ).and( - new Field( "avisos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) ), - new String[]{ "data_evento" }, null ); - Virtual2DArray array = executer.executeQuery( select ); - return array.getObjects(); - } - - public Integer getMarcacaoIDByTrabalhador( Integer trabalhadorID ) - throws Exception - { - Select realizadaSelect = - new Select( new String[]{ "marcacoes_trabalhador" }, - new String[]{ "MAX(data)" }, - new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and( - new Field( "estado" ).isEqual( new Integer( 2 ) ) ).and( - new Field( "tipo" ).isEqual( new Integer( siprp.data.MarcacaoTrabalhadorData.TIPO_CONSULTA ) ) ) ); - Virtual2DArray realizadaArray = executer.executeQuery( realizadaSelect ); - Date realizada = (Date) realizadaArray.get( 0, 0 ); - Select select; - if( realizada == null ) - { - select = new Select( new String[]{ "marcacoes_trabalhador" }, - new String[]{ "MIN(id)" }, - new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and( - new Field( "estado" ).isEqual( new Integer( 0 ) ) ).and( - new Field( "tipo" ).isEqual( new Integer( siprp.data.MarcacaoTrabalhadorData.TIPO_CONSULTA ) ) ) ); - } - else - { - select = new Select( new String[]{ "marcacoes_trabalhador" }, - new String[]{ "MIN(id)" }, - new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and( - new Field( "estado" ).isEqual( new Integer( 0 ) ) ).and( - new Field( "data" ).isGreater( realizada ) ).and( - new Field( "tipo" ).isEqual( new Integer( siprp.data.MarcacaoTrabalhadorData.TIPO_CONSULTA ) ) ) ); - } - Virtual2DArray array = executer.executeQuery( select ); - if( array.columnLength() == 0 || array.get( 0, 0 ) == null ) - { - return null; - } - return new Integer( ( ( Number ) array.get( 0, 0 ) ).intValue() ); - } - - public IDObject[] getAllEmpresasDeleted() - throws Exception - { - Select select = new Select( new String[]{ T_EMPRESAS }, - new String[]{ ID, DESIGNACAO_SOCIAL, "designacao_social_plain" }, - new Field( INACTIVO ).isEqual( "y" ), - new String[]{ "designacao_social_plain" }, null ); - Virtual2DArray array = executer.executeQuery( select ); - IDObject empresas[] = new IDObject[ array.columnLength() ]; - for( int n = 0; n < array.columnLength(); n++ ) - { - Integer id = new Integer( ((Number)array.get( n, 0 )).intValue() ); - String designacao = ( String ) array.get( n, 1 ); - empresas[ n ] = new MappableObject( id, designacao ); - } - return empresas; - } - - public IDObject []getAllEstabelecimentosDeletedForEmpresa( Integer empresaID ) - throws Exception - { - Select select = new Select( new String[]{ T_ESTABELECIMENTOS }, - new String[]{ ID, NOME, "nome_plain" }, - new Field( EMPRESA_ID ).isEqual( empresaID ).and( - new Field( INACTIVO ).isEqual( "y" ) ), - new String[]{ "nome_plain" }, null ); - Virtual2DArray array = executer.executeQuery( select ); - IDObject objects[] = new IDObject[ array.columnLength() ]; - for( int n = 0; n < objects.length; n++ ) - { - Integer id = new Integer( ((Number)array.get( n, 0 )).intValue() ); - String desc = (String)array.get( n, 1 ); - objects[ n ] = new MappableObject( id, desc ); - } - return objects; - } - - public IDObject []getAllTrabalhadoresDeletedForEstabelecimento( Integer estabelecimentoID ) - throws Exception - { - Select select = new Select( new String[]{ T_TRABALHADORES }, - new String[]{ ID, NOME, "nome_plain" }, - new Field( ESTABELECIMENTO_ID ).isEqual( estabelecimentoID ).and( - new Field( INACTIVO ).isEqual( "y" ) ), - new String[]{ "nome_plain" }, null ); - Virtual2DArray array = executer.executeQuery( select ); - IDObject objects[] = new IDObject[ array.columnLength() ]; - for( int n = 0; n < objects.length; n++ ) - { - Integer id = new Integer( ((Number)array.get( n, 0 )).intValue() ); - String desc = (String)array.get( n, 1 ); - objects[ n ] = new MappableObject( id, desc ); - } - return objects; - } - - public Object[] getDadosUltimaMarcacao( Integer trabalhadorID ) - throws Exception - { - Select select = - new Select( new String[]{ "marcacoes_trabalhador" }, - new String[]{ "MAX( data )" }, - new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and( - new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and( - new Field( "realizada" ).isEqual( "y" ).or( - new Field( "estado" ).isEqual( new Integer( 2 ) ) ) ) ); - Virtual2DArray array = executer.executeQuery( select ); - if( array.columnLength() == 0 || array.get( 0, 0 ) == null ) - { - return new Object[]{ null, null }; - } - Date data = ( Date ) array.get( 0, 0 ); - select = - new Select( new String[]{ "marcacoes_trabalhador" }, - new String[]{ "motivo", "id" }, - new Field( "data" ).isEqual( data ).and( - new Field( "trabalhador_id" ).isEqual( trabalhadorID ) ).and( - new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and( - new Field( "realizada" ).isEqual( "y" ).or( - new Field( "estado" ).isEqual( new Integer( 2 ) ) ) ), - new String[]{ "id" }, null ); - array = executer.executeQuery( select ); - Integer tipo = ( Integer ) array.get( 0, 0 ); - if( tipo.intValue() == 5 ) - { - tipo = new Integer( 2 ); - } - return new Object[]{ data, tipo }; - } - - public void setMedicoForEstabelecimento( Integer estabelecimentoID, Integer medicoID ) - throws Exception - { - Integer medicoAntigo = ( Integer ) medicosEstabelecimentosHash.get( estabelecimentoID ); - if( !medicoID.equals( medicoAntigo ) ) - { - Update update = - new Update( "estabelecimentos", - new Assignment[]{ - new Assignment( new Field( "medico_id" ), medicoID ) }, - new Field( "id" ).isEqual( estabelecimentoID ) ); - executer.executeQuery( update ); - medicosEstabelecimentosHash.put( estabelecimentoID, medicoID ); - } - } - - public Integer getMedicoForEstabelecimento( Integer estabelecimentoID ) - throws Exception - { - if( !medicosEstabelecimentosHash.containsKey( estabelecimentoID ) ) - { - Select select = - new Select( new String[]{ "estabelecimentos" }, - new String[]{ "medico_id" }, - new Field( "id" ).isEqual( estabelecimentoID ) ); - Virtual2DArray array = executer.executeQuery( select ); - Integer medicoID = ( Integer ) array.get( 0, 0 ); - if( medicoID == null ) - { - medicoID = new Integer( -1 ); - } - medicosEstabelecimentosHash.put( estabelecimentoID, medicoID ); - } - return ( Integer ) medicosEstabelecimentosHash.get( estabelecimentoID ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/Main.java b/trunk/SIPRPSoft/src/siprp/Main.java deleted file mode 100644 index 260302f5..00000000 --- a/trunk/SIPRPSoft/src/siprp/Main.java +++ /dev/null @@ -1,285 +0,0 @@ -package siprp; - -import siprp.companydataloaders.*; -import siprp.data.*; -import siprp.clientes.*; - -import com.evolute.utils.*; -import com.evolute.utils.db.*; -import com.evolute.utils.db.keyretrievers.*; -import com.evolute.utils.error.*; -import com.evolute.utils.jdbc.*; -import com.evolute.utils.jdo.*; -import com.evolute.utils.sql.*; -import com.evolute.utils.ui.*; -import com.evolute.utils.ui.window.*; - -import java.awt.*; -import java.util.*; -import javax.swing.*; -import javax.swing.tree.*; -import siprp.update.UpdateWindow; - -public class Main implements com.evolute.utils.ui.window.Connector -{ - public final static String SHST_VERSION = "7.8"; - - private final static ClassLoader classLoader = new EVUtilsImageLib().getClass().getClassLoader(); - - private static String dbase; - private SIPRPTracker siprpTracker; - - private static AvisosPanel avisos = null; - - static - { - JDOObject.registerOperationHandlerForClass( DisableDeleteHandler.INSTANCE, EmpresaData.class ); - JDOObject.registerOperationHandlerForClass( DisableDeleteHandler.INSTANCE, EstabelecimentoData.class ); - JDOObject.registerOperationHandlerForClass( DisableDeleteHandler.INSTANCE, TrabalhadorData.class ); - - JDOObject.registerOperationHandlerForClass( ActualizacaoSaveHandler.INSTANCE, EmpresaData.class ); - JDOObject.registerOperationHandlerForClass( ActualizacaoSaveHandler.INSTANCE, EstabelecimentoData.class ); - JDOObject.registerOperationHandlerForClass( ActualizacaoSaveHandler.INSTANCE, TrabalhadorData.class ); - - JDOObject.registerOperationHandlerForClass( MarcacaoSaveAndDeleteHandler.INSTANCE, MarcacaoEmpresaData.class ); - JDOObject.registerOperationHandlerForClass( MarcacaoSaveAndDeleteHandler.INSTANCE, MarcacaoEstabelecimentoData.class ); - JDOObject.registerOperationHandlerForClass( MarcacaoSaveAndDeleteHandler.INSTANCE, MarcacaoTrabalhadorData.class ); - } - - public static void main( String args[] ) - throws Exception - { -// Singleton.setInstance( SingletonConstants.COMPANY_NAME, "Centro Cl\u00ednico Avenida" ); -// Singleton.setInstance( SingletonConstants.COMPANY_LOGO, "logo_evo.jpg" ); -// Singleton.setInstance( SingletonConstants.WEB_AWARE, Boolean.FALSE ); -// Singleton.setInstance( SingletonConstants.DB_NAME, "shst" ); - -// Singleton.setInstance( SingletonConstants.COMPANY_NAME, "SIPRP - Sociedade Ib\u00e9rica de Preven\u00e7\u00e3o de Riscos Profissionais" ); -// Singleton.setInstance( SingletonConstants.COMPANY_LOGO, "logo_combo.jpg" ); -// Singleton.setInstance( SingletonConstants.WEB_AWARE, Boolean.TRUE ); -// Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp" ); - new SIPRPDataLoader().load(); -// new ClinicaAvenidaDataLoader().load(); -// new IBookDataLoader().load(); - - dbase = (String)Singleton.getInstance( SingletonConstants.LOCAL_DB_NAME ); -/* Calendar cal = Calendar.getInstance(); - cal.set( 2004, 06, 14 ); - if( cal.before( Calendar.getInstance() ) ) - { - com.evolute.utils.ui.DialogException.showException( new RuntimeException( "Unknown error ocurred." ) ); - } - else - { -*/ Insert.setDefaultKeyRetriever( JDBCAutoKeyRetriever.DEFAULT ); - String server = System.getProperty( "server.address" ); -// if( server == null ) -// { -// server = "ws_fpalma"; -// } -// -// String user = "root"; -// String passwd = "UNIXLuvsU"; -// -// DBManager dbm = new JDBCManager( "jdbc:mysql://" + server + "/" + dbase, -// user, passwd , 10, 8, 8, null ); - - UnicodeChecker.setUseDoubleSlash( true ); -// Singleton.setInstance( Singleton.DEFAULT_DBMANAGER, dbm ); - -// StatementExecuterFactory.initialize( -// new DBStatementExecuter( dbm.getSharedExecuter() ) ); -// } -// FichaWindow window = new FichaWindow(); -/* window.setLogo( new ImageIcon( - new Main().getClass().getClassLoader().getResource( "logo/logo_w400.png" ) - ).getImage() );*/ -// window.show(); - avisos = new AvisosPanel(); - String logoFileName = ( String ) Singleton.getInstance( SingletonConstants.COMPANY_LOGO ); - LoginWindow loginWindow = new LoginWindow( new Main(), /*"logo"+File.separator +*/ logoFileName,//"logo"+File.separator + "logo_w400.jpg", - new String[] { (String) Singleton.getInstance( SingletonConstants.SOFTWARE_NAME ) }, - new String[] { "Vers\u00E3o " + SHST_VERSION, "(EVOLUTE 2004-2006)" }, "", - (String)Singleton.getInstance( SingletonConstants.LOCAL_USER ), - (String)Singleton.getInstance( SingletonConstants.LOCAL_PASSWORD ), avisos, false ); - loginWindow.setTitle( (String) Singleton.getInstance( SingletonConstants.SOFTWARE_NAME ) ); - JPanel left = loginWindow.getLeftPanel(); - left.setBackground( Color.white ); - GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); - loginWindow.setExtendedState(loginWindow.getExtendedState() | loginWindow.MAXIMIZED_BOTH); - loginWindow.setVisible( true ); - loginWindow.expandAll(); - new UpdateWindow().update(); - } - - public boolean connect( String user, String passwd ) - { - try - { - // run initialization SQL - SQLQuery initQuery[] = new SQLQuery[] {}; - String server = System.getProperty( "server.address" ); - if( server == null ) - { - //server = "192.168.1.191"; - server = (String)Singleton.getInstance( SingletonConstants.LOCAL_URL ); -// server = "ws_fpalma"; - } - String prefix = (String)Singleton.getInstance( SingletonConstants.LOCAL_URL_PREFIX ); - String url = prefix + server + "/" + dbase; -// System.out.println( "url: " + url + " user: " + user + " ps: " + passwd ); - DBManager dbm = new JDBCManager( url, user, passwd , 10, 8, 8, null ); -// UnicodeChecker.setUseDoubleSlash( true ); - Singleton.setInstance( Singleton.DEFAULT_DBMANAGER, dbm ); - - StatementExecuterFactory.initialize( - new DBStatementExecuter( dbm.getSharedExecuter() ) ); - initializeJPOX( url, user, passwd ); - StatementExecuterFactory.initialize( - new DBStatementExecuter( dbm.getSharedExecuter() ) ); - StatementExecuterFactory.initialize( - new DBStatementExecuter( dbm.getSharedExecuter() ) ); - Singleton.setInstance( Singleton.TODAY, new Date() ); - -//cleanData( dbm.getSharedExecuter() ); -//msg( dbm.getSharedExecuter() ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "N\u00E3o foi poss\u00EDvel estabelecer" - + " a liga\u00E7\u00E3o \u00E0 base de dados.", false ); - return false; - } - Singleton.setInstance( Singleton.USERNAME, user ); - try - { - ErrorLogger.initializeLogger( new SHSTLogger() ); - } - catch( Exception ex ) - { - } - //Singleton.setInstance( Singleton.USERNAME, user ); - siprpTracker = new SIPRPTracker( avisos ); - - avisos.refresh(); -// new Exception().printStackTrace(); -// try -// { -// Thread.sleep( 1000 ); -// } -// catch( Exception ex ){} -// new Exception().printStackTrace(); - return true; - } - -// public static void reconnectJDO() -// { -// PersistenceManagerFactory pmf = ( PersistenceManagerFactory ) Singleton.getInstance( Singleton.DEFAULT_PERSISTENCE_MANAGER_FACTORY ); -// PersistenceManager pm = pmf.getPersistenceManager(); -// Singleton.setInstance( SingletonConstants.PERSISTENCE_MANAGER, pm ); -// com.evolute.utils.jdo.JDOObject.setPersistentManager( pm ); -// } - - public boolean disconnect() - { - if( siprpTracker.quit() ) - { - siprpTracker = null; - try - { - ( ( DBManager )Singleton.getInstance( - Singleton.DEFAULT_DBMANAGER ) ).close(); - Singleton.clear(); - } - catch( DBException ex ) - { - DialogException.showException( ex ); - } - return true; - } - return false; - } - - public void executeAction( DefaultMutableTreeNode node ) - { - try - { - siprpTracker.openWindow( ( String )node.getUserObject() ); - } - catch( Exception ex ) - { - DialogException.showException( ex ); - } - } - - public void exit() - { - if( siprpTracker == null || siprpTracker.quit() ) - { - System.exit( 0 ); - } - } - - public MutableTreeNode getTree() - { - return siprpTracker.getRoot(); - } - - public void initializeJPOX(String url, String user, String password) - { - Date d = new Date(); -System.out.println( "INIT: " + d ); - - - Properties jpoxProps; - jpoxProps = System.getProperties();//new Properties(); - // Set the PersistenceManagerFactoryClass to the TJDO class. - jpoxProps.setProperty( "javax.jdo.PersistenceManagerFactoryClass", - "org.jpox.PersistenceManagerFactoryImpl" ); - // Set the JDBC driver name. - jpoxProps.setProperty( "javax.jdo.option.ConnectionDriverName", (String) Singleton.getInstance( SingletonConstants.LOCAL_DRIVER_NAME ) ); - jpoxProps.setProperty( "org.jpox.identifier.fullyQualifiedNames", "false" ); - // props.setProperty("com.triactive.jdo.transactionIsolation", - // "read-uncommitted" ); - - // Set the connection URL -// jpoxProps.setProperty( "javax.jdo.option.ConnectionURL", "jdbc:informix-sqli://192.168.0.3:6666" -// + "/apdp_db:informixserver=server" ); - jpoxProps.setProperty( "javax.jdo.option.ConnectionURL", url ); - jpoxProps.setProperty( "javax.jdo.option.ConnectionUserName", user ); - jpoxProps.setProperty( "javax.jdo.option.ConnectionPassword", password ); -// jpoxProps.setProperty( "javax.jdo.option.IgnoreCache", "true" ); -// jpoxProps.setProperty( "javax.jdo.option.NonTransactionalRead", "true" ); - jpoxProps.setProperty( "javax.jdo.option.RetainValues", "true" ); - - jpoxProps.setProperty( "org.jpox.autoCreateTables", "false" ); - jpoxProps.setProperty( "org.jpox.autoCreateSchema", "false" ); - jpoxProps.setProperty( "org.jpox.autoCreateConstraints", "false" ); - jpoxProps.setProperty( "org.jpox.validateTables", "false" ); - jpoxProps.setProperty( "org.jpox.validateConstraints", "false" ); - jpoxProps.setProperty( "org.jpox.autoStartMechanismMode", "Ignored" ); - jpoxProps.setProperty( "org.jpox.autoStartMechanism", "None" ); - -// jpoxProps.setProperty( "javax.jdo.option.RetainValues", "true" ); -// jpoxProps.setProperty( "javax.jdo.option.Optimistic", "true" ); - -// jpoxProps.setProperty( "org.jpox.identifier.defaultSchemaName", "informix" ); - jpoxProps.setProperty( "org.jpox.rdbms.CheckExistTablesOrViews", "false" ); - - System.setProperty( "org.jpox.catalogName", (String)Singleton.getInstance( SingletonConstants.LOCAL_DB_NAME ) ); - System.setProperty( "org.jpox.schemaName", "" ); - -// PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory( jpoxProps ); -//// pmf.setOptimistic( true ); -//System.out.print( "Loading PM: " + new Date() ); -// // ( ( PersistenceManagerFactoryImpl )pmf ).setTransactionIsolation( Connection.TRANSACTION_READ_UNCOMMITTED ); -// // Retrieve a PersistenceManager from the PersistenceManagerFactory. -// PersistenceManager pm = pmf.getPersistenceManager(); -// JDOObject.setPersistentManager( pm ); -// Singleton.setInstance( Singleton.DEFAULT_PERSISTENCE_MANAGER_FACTORY, pmf ); -// Singleton.setInstance( SingletonConstants.PERSISTENCE_MANAGER, pm ); - JDOProvider jdoProvider = new JDOProvider( jpoxProps ); - Singleton.setInstance( Singleton.DEFAULT_JDO_PROVIDER, jdoProvider ); -System.out.println( "PM done " + new Date() + "JDO: " + jdoProvider ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/SHSTLogger.java b/trunk/SIPRPSoft/src/siprp/SHSTLogger.java deleted file mode 100644 index 9330e900..00000000 --- a/trunk/SIPRPSoft/src/siprp/SHSTLogger.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * SIPRPLogger.java - * - * Created on 15 de Marco de 2005, 15:31 - */ - -package siprp; - -import com.evolute.utils.*; -import com.evolute.utils.db.*; -import com.evolute.utils.error.*; -import com.evolute.utils.sql.*; - -/** - * - * @author lflores - - * MySQL -CREATE TABLE errors -( - id INT NOT NULL AUTO_INCREMENT, - PRIMARY KEY( id ), - date TIMESTAMP NOT NULL DEFAULT 'now()', - type VARCHAR(20), - environment VARCHAR( 255 ), - description TEXT -); - * - *PostgreSQL -CREATE TABLE errors -( - id SERIAL, - PRIMARY KEY( id ), - date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - type VARCHAR(20), - environment VARCHAR( 255 ), - description VARCHAR( 256000 ) -) - - */ -public class SHSTLogger implements Logger -{ - private final String java = System.getProperty( "java.version" ) - + "-" + System.getProperty( "java.vm.version" ); - private final String os = System.getProperty( "os.name" ) + " - " + - System.getProperty( "os.version" ); - private final String user = ( String )Singleton.getInstance( Singleton.USERNAME ); - private final String ENV = "Java: " + java + " \nOS: " + os + " \nUser: " + user - + "\n Software: " + ( String )Singleton.getInstance( SingletonConstants.SOFTWARE_NAME ) - + "\n Version: " + Main.SHST_VERSION; - private final Executer executer; - - /** Creates a new instance of SIPRPLogger */ - public SHSTLogger() - throws Exception - { - DBManager dbm = ( DBManager )Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); - executer = dbm.getExclusiveExecuter( this ); - } - - public void log( String str ) - { - String mem = "(" + Runtime.getRuntime().freeMemory() + "/" + - Runtime.getRuntime().maxMemory() + ")"; - if( str.length() > 254000 ) - { - str = str.substring( 0, 254000 ) + " Message too big (" + str.length() + "), truncated."; - } - try - { - executer.executeQuery( new Insert( "errors", new Assignment[] { - new Assignment( new Field( "type" ), "LOG" ), - new Assignment( new Field( "environment" ), ENV + mem ), - new Assignment( new Field( "description" ), str ) - } ), null ); - } - catch( Exception ex ) - { - logException( ex ); - } - } - - public void logException( Throwable ex ) - { - StackTraceElement ste[] = ex.getStackTrace(); - StringBuffer sb = new StringBuffer(); - for( int i = 0; i < ste.length; ++i ) - { - sb.append( ste[ i ].toString() ); - } - String str = "Exception Message: " + ex.getMessage() + "\nStack Trace: " + sb.toString(); - String mem = "(" + Runtime.getRuntime().freeMemory() + "/" + - Runtime.getRuntime().maxMemory() + ")"; - if( str.length() > 254000 ) - { - str = str.substring( 0, 254000 ) + " Message too big (" + str.length() + "), truncated."; - } - try - { - executer.executeQuery( new Insert( "errors", new Assignment[] { - new Assignment( new Field( "type" ), "ERROR" ), - new Assignment( new Field( "environment" ), ENV + mem ), - new Assignment( new Field( "description" ), str ) - } ), new SQLRetriever() ); - } - catch( Exception ex1 ) - { - ex.printStackTrace(); - } - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java b/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java deleted file mode 100644 index c33b4f82..00000000 --- a/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * SIPRPTracker.java - * - * Created on 18 de Maio de 2004, 19:46 - */ - -package siprp; - -import javax.swing.tree.*; -import java.util.*; - -import com.evolute.utils.*; -import com.evolute.utils.tracker.*; -import siprp.ficha.*; -import siprp.clientes.*; -import siprp.estatistica.*; -import siprp.higiene.mapa.*; -import siprp.higiene.marcacoes.*; -import siprp.impressaofichas.*; -import siprp.lembretes.LembretesWindow; -import siprp.medicina.*; -import siprp.medicina.locais_realizacao.LocaisRealizacaoWindow; -import siprp.medicina.presencas.RegistarPresencasWindow; -import siprp.medicina.prestadores.PrestadoresWindow; -import siprp.medicina.processo.ProcessoWindow; -import siprp.pesquisas.*; -/** - * - * @author fpalma - */ -public class SIPRPTracker extends WindowTracker -{ - public static final String FICHA_APTIDAO = "Ficha de Aptid\u00e3o"; - public static final String CRIACAO_FICHA_APTIDAO = "Cria\u00e7\u00e3o de Fichas de Aptid\u00e3o"; - public static final String GESTAO_CLIENTES = "Gest\u00e3o de Clientes"; - public static final String MEDICINA = "Medicina"; - public static final String MEDICINA_MARCACOES = "Marca\u00e7\u00f5es"; - public static final String MEDICINA_LOCAIS = "Locais de Realiza\u00e7\u00e3o"; - public static final String MEDICINA_PRESENCAS = "Presen\u00e7as"; - public static final String HIGIENE_SEGURANCA = "Higiene e Seguran\u00e7a"; - public static final String RELATORIO_ANUAL = "Relat\u00f3rio Anual"; - public static final String LISTAGENS = "Listagens"; - - private final AvisosPanel avisos; - private ClientesWindow clientesWindow; - private MedicinaWindow medicinaWindow; - private MarcacoesHigieneWindow higieneWindow; - - /** Creates a new instance of SIPRPTracker */ - public SIPRPTracker( AvisosPanel avisosP ) - { - Singleton.setInstance( SingletonConstants.SIPRP_TRACKER, this ); - this.avisos = avisosP; - avisos.setTracker( this ); - Hashtable creators = new Hashtable(); - DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode( - Singleton.getInstance( SingletonConstants.COMPANY_ACRONYM ) ); - - boolean hasFicha = ( (Boolean)Singleton.getInstance( SingletonConstants.MODULE_FICHA ) ).booleanValue(); - boolean hasGestao = ( (Boolean)Singleton.getInstance( SingletonConstants.MODULE_CLIENTES ) ).booleanValue(); - boolean hasRelatorio = ( (Boolean)Singleton.getInstance( SingletonConstants.MODULE_RELATORIO ) ).booleanValue(); - boolean hasListagens = ( (Boolean)Singleton.getInstance( SingletonConstants.MODULE_LISTAGENS ) ).booleanValue(); - - if( hasGestao ) - { - try - { - clientesWindow = new ClientesWindow( avisos ); - clientesWindow.setTracker( this ); - medicinaWindow = new MedicinaWindow(); - medicinaWindow.setTracker( this ); - higieneWindow = new MarcacoesHigieneWindow(); - higieneWindow.setTracker( this ); - } - catch( Exception ex ) - { - clientesWindow = null; - medicinaWindow = null; - higieneWindow = null; - ex.printStackTrace(); - } - } - else - { - clientesWindow = null; - medicinaWindow = null; - } - - if( hasFicha ) - { - DefaultMutableTreeNode fichaNode = new DefaultMutableTreeNode( FICHA_APTIDAO ); - - fichaNode.add( new DefaultMutableTreeNode( CRIACAO_FICHA_APTIDAO ) ); - creators.put( CRIACAO_FICHA_APTIDAO, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return FichaWindow.getWindow(); - } - } ); - - fichaNode.add( new DefaultMutableTreeNode( ImpressaoFichasWindow.TITLE ) ); - creators.put( ImpressaoFichasWindow.TITLE, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new ImpressaoFichasWindow(); - } - } ); - - rootNode.add( fichaNode ); - } - - if( hasGestao ) - { - rootNode.add( new DefaultMutableTreeNode( GESTAO_CLIENTES ) ); - creators.put( GESTAO_CLIENTES, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - if( clientesWindow == null ) - { - clientesWindow = new ClientesWindow( avisos ); - clientesWindow.setTracker( SIPRPTracker.this ); - } - return clientesWindow; - } - } ); - - rootNode.add( new DefaultMutableTreeNode( LembretesWindow.TITLE ) ); - creators.put( LembretesWindow.TITLE, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new LembretesWindow(); - } - } ); - - DefaultMutableTreeNode medicinaNode = new DefaultMutableTreeNode( MEDICINA ); - - medicinaNode.add( new DefaultMutableTreeNode( ProcessoWindow.TITLE ) ); - creators.put( ProcessoWindow.TITLE, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new ProcessoWindow(); - } - } ); - - medicinaNode.add( new DefaultMutableTreeNode( MEDICINA_MARCACOES ) ); - creators.put( MEDICINA_MARCACOES, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - if( medicinaWindow == null ) - { - medicinaWindow = new MedicinaWindow(); - medicinaWindow.setTracker( SIPRPTracker.this ); - } - return medicinaWindow; - } - } ); - - medicinaNode.add( new DefaultMutableTreeNode( MEDICINA_LOCAIS ) ); - creators.put( MEDICINA_LOCAIS, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new LocaisRealizacaoWindow(); - } - } ); - - medicinaNode.add( new DefaultMutableTreeNode( MEDICINA_PRESENCAS ) ); - creators.put( MEDICINA_PRESENCAS, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new RegistarPresencasWindow(); - } - } ); - - medicinaNode.add( new DefaultMutableTreeNode( PrestadoresWindow.TITLE ) ); - creators.put( PrestadoresWindow.TITLE, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new PrestadoresWindow(); - } - } ); - - rootNode.add( medicinaNode ); - - DefaultMutableTreeNode higieneNode = new DefaultMutableTreeNode( HIGIENE_SEGURANCA ); - - higieneNode.add( new DefaultMutableTreeNode( MarcacoesHigieneWindow.TITLE ) ); - creators.put( MarcacoesHigieneWindow.TITLE, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - if( higieneWindow == null ) - { - higieneWindow = new MarcacoesHigieneWindow(); - higieneWindow.setTracker( SIPRPTracker.this ); - } - return higieneWindow; - } - } ); - - higieneNode.add( new DefaultMutableTreeNode( MapaHigieneWindow.TITLE ) ); - creators.put( MapaHigieneWindow.TITLE, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new MapaHigieneWindow(); - } - } ); - - rootNode.add( higieneNode ); - } - - if( hasRelatorio ) - { - rootNode.add( new DefaultMutableTreeNode( RELATORIO_ANUAL ) ); - creators.put( RELATORIO_ANUAL, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new PesquisasWindow(); - } - } ); - } - - if( hasListagens ) - { - rootNode.add( new DefaultMutableTreeNode( LISTAGENS ) ); - creators.put( LISTAGENS, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new EstatisticaWindow(); - } - } ); - } - setRoot( rootNode ); - setCreators( creators ); - } - - public ClientesWindow getClientesWindow() - { - return clientesWindow; - } - - public MedicinaWindow getMedicinaWindow() - { - return medicinaWindow; - } - - public MarcacoesHigieneWindow getHigieneWindow() - { - return higieneWindow; - } - - public AvisosPanel getAvisosPanel() - { - return avisos; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/SingletonConstants.java b/trunk/SIPRPSoft/src/siprp/SingletonConstants.java deleted file mode 100644 index 6f8cdbc1..00000000 --- a/trunk/SIPRPSoft/src/siprp/SingletonConstants.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SingletonConstants.java - * - * Created on 25 de Maio de 2004, 13:34 - */ - -package siprp; - -/** - * - * @author fpalma - */ -public class SingletonConstants -{ - public static final String PERSISTENCE_MANAGER = "PERSISTENCE_MANAGER"; - public static final String SOFTWARE_NAME = "software_name"; - public static final String COMPANY_NAME = "company_name"; - public static final String COMPANY_LOGO = "company_logo"; - public static final String COMPANY_ACRONYM = "company_acronym"; - public static final String SUBJECT_CONSULTA = "subject_consulta"; - public static final String LETTER_CONSULTA = "letter_consulta"; - public static final String SUBJECT_EXAMES = "subject_exames"; - public static final String LETTER_EXAMES = "letter_exames"; - public static final String SUBJECT_VISITA = "subject_visita"; - public static final String LETTER_VISITA = "letter_visita"; - public static final String USES_HOUR = "uses_hour"; - public static final String CODIGO_EMPRESA_FORMAT = "codigo_empresa_format"; - public static final String FICHA_MARCA_EXAMES = "ficha_marca_exames"; - public static final String EXCEL_FORMAT = "excel_format"; - public static final String EXCEL_FORMAT_DEMISSAO = "excel_format_demissao"; - - public static final String MODULE_FICHA = "module_ficha"; - public static final String MODULE_CLIENTES = "module_clientes"; - public static final String WEB_AWARE = "web_aware"; - public static final String MODULE_RELATORIO = "module_relatorio"; - public static final String MODULE_LISTAGENS = "module_listagens"; - - public static final String WEB_USER = "web_user"; - public static final String WEB_PASSWORD = "web_password"; - public static final String WEB_URL_PREFIX = "web_url_prefix"; - public static final String WEB_URL = "web_url"; - public static final String WEB_DB_NAME = "web_db_name"; - public static final String WEB_DRIVER_NAME = "web_driver_name"; - - public static final String LOCAL_USER = "local_user"; - public static final String LOCAL_PASSWORD = "local_password"; - public static final String LOCAL_URL_PREFIX = "local_url_prefix"; - public static final String LOCAL_URL = "local_url"; - public static final String LOCAL_DB_NAME = "local_db_name"; - public static final String LOCAL_DRIVER_NAME = "local_driver_name"; - - public static final String SIPRP_TRACKER = "SIPRP_TRACKER"; - - /** Creates a new instance of SingletonConstants */ - private SingletonConstants() - { - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/AvisosPanel.java b/trunk/SIPRPSoft/src/siprp/clientes/AvisosPanel.java deleted file mode 100644 index fa73c5d2..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/AvisosPanel.java +++ /dev/null @@ -1,589 +0,0 @@ -/* - * 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 ) ); -// contentPanel.setLayout( new FlowLayout() ); - GridBagLayout gridbag = new GridBagLayout(); - contentPanel.setLayout( gridbag ); - constraints = new GridBagConstraints(); - constraints.insets = new Insets( 1, 1, 1, 1 ); - constraints.fill = GridBagConstraints.BOTH; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 1; - constraints.gridheight = 1; - constraints.weighty = 0; - if( avisosEmpresa.length > 0 ) - { - gridbag.setConstraints( empresaPanel, constraints ); - contentPanel.add( empresaPanel ); - } - if( avisosTrabalhador.length > 0 ) - { -// contentPanel.add( new JLabel( " " ) ); - gridbag.setConstraints( trabalhadoresPanel, constraints ); - contentPanel.add( trabalhadoresPanel ); - } - if( avisosEstabelecimento.length > 0 ) - { -// contentPanel.add( new JLabel( " " ) ); - gridbag.setConstraints( estabelecimentosPanel, constraints ); - 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/ClientesDataProvider.java b/trunk/SIPRPSoft/src/siprp/clientes/ClientesDataProvider.java deleted file mode 100644 index 1ecb612a..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/ClientesDataProvider.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * 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; - } - - public Integer getEmpresaIDByTrabalhadorID( Integer trabalhadorID ) - throws Exception - { - Select select = - new Select( new String[]{ "trabalhadores", "estabelecimentos" }, - new String[]{ "estabelecimentos.empresa_id" }, - new Field( "trabalhadores.id" ).isEqual( trabalhadorID ).and( - new Field( "trabalhadores.estabelecimento_id" ).isEqual( - new Field( "estabelecimentos.id" ) ) ) ); - Virtual2DArray array = executer.executeQuery( select ); - return ( Integer ) array.get( 0, 0 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/ClientesWindow.java b/trunk/SIPRPSoft/src/siprp/clientes/ClientesWindow.java deleted file mode 100644 index 65f12e84..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/ClientesWindow.java +++ /dev/null @@ -1,1435 +0,0 @@ -/* - * ClientesWindow.java - * - * Created on 12 de Maio de 2004, 18:11 - */ - -package siprp.clientes; - -import java.awt.*; -import java.io.*; -import java.text.*; -import java.util.*; -import javax.swing.*; -import javax.swing.event.*; - -import com.evolute.utils.*; -import com.evolute.utils.data.*; -import com.evolute.utils.dataui.*; -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.ui.dialog.*; -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 com.evolute.utils.xml.*; - -import siprp.*; -import siprp.data.*; -import siprp.ficha.*; -import siprp.importer.*; - -/** - * - * @author fpalma - */ -public class ClientesWindow extends EditorWindow - implements ListSelectionListener -{ - private static final DateFormat DF = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) ); - - public static final Hashtable TR_IMPORT_NAMES_TO_TRAB = new Hashtable(); - public static final Hashtable TR_IMPORT_NAMES_TO_DEMISSOES = new Hashtable(); - - static - { - TR_IMPORT_NAMES_TO_TRAB.put( Importer.NOME, TrabalhadorData.NOME ); - TR_IMPORT_NAMES_TO_TRAB.put( Importer.SEXO, TrabalhadorData.SEXO ); - TR_IMPORT_NAMES_TO_TRAB.put( Importer.NACIONALIDADE, TrabalhadorData.NACIONALIDADE ); - TR_IMPORT_NAMES_TO_TRAB.put( Importer.DATA_NASCIMENTO, TrabalhadorData.DATA_NASCIMENTO ); - TR_IMPORT_NAMES_TO_TRAB.put( Importer.NUMERO_MECANOGRAFICO, TrabalhadorData.NUMERO_MECANOGRAFICO ); - TR_IMPORT_NAMES_TO_TRAB.put( Importer.DATA_ADMISSAO, TrabalhadorData.DATA_ADMISSAO ); - TR_IMPORT_NAMES_TO_TRAB.put( Importer.CATEGORIA, TrabalhadorData.CATEGORIA ); - TR_IMPORT_NAMES_TO_TRAB.put( Importer.LOCAL_TRABALHO, TrabalhadorData.LOCAL_TRABALHO ); - TR_IMPORT_NAMES_TO_TRAB.put( Importer.FUNCAO, TrabalhadorData.FUNCAO_PROPOSTA ); - TR_IMPORT_NAMES_TO_TRAB.put( Importer.DATA_ADMISSAO_FUNCAO, TrabalhadorData.DATA_ADMISSAO_FUNCAO ); - - TR_IMPORT_NAMES_TO_DEMISSOES.put( Importer.NOME, TrabalhadorData.NOME ); - TR_IMPORT_NAMES_TO_DEMISSOES.put( Importer.DATA_DEMISSAO, TrabalhadorData.DATA_DEMISSAO ); - -// JDOObject.registerOperationHandlerForClass( DisableDeleteHandler.INSTANCE, EmpresaData.class ); -// JDOObject.registerOperationHandlerForClass( DisableDeleteHandler.INSTANCE, EstabelecimentoData.class ); -// JDOObject.registerOperationHandlerForClass( DisableDeleteHandler.INSTANCE, TrabalhadorData.class ); -// -// JDOObject.registerOperationHandlerForClass( MarcacaoSaveAndDeleteHandler.INSTANCE, MarcacaoEmpresaData.class ); -// JDOObject.registerOperationHandlerForClass( MarcacaoSaveAndDeleteHandler.INSTANCE, MarcacaoEstabelecimentoData.class ); -// JDOObject.registerOperationHandlerForClass( MarcacaoSaveAndDeleteHandler.INSTANCE, MarcacaoTrabalhadorData.class ); - } - - public static final int INDEX_EMPRESA = 0; - public static final int INDEX_ESTABELECIMENTO = 1; - public static final int INDEX_TRABALHADOR = 2; - - private static int hierarchy[] = new int[]{0,0,1}; - private static int permissions[][] = - new int[][]{ { NEW_INDEX, EDIT_INDEX, CANCEL_INDEX, SAVE_INDEX, SELECT_BYNAME_INDEX, DELETE_INDEX }, - { NEW_INDEX, EDIT_INDEX, CANCEL_INDEX, SAVE_INDEX, DELETE_INDEX }, - { NEW_INDEX, EDIT_INDEX, CANCEL_INDEX, SAVE_INDEX, DELETE_INDEX } }; - - private JDOProvider JDO; - private ClientesDataProvider clientesProvider; - private ControllableComponent panels[] = new ControllableComponent[ 4 ]; - private EmpresaPanel empresaPanel; - private JPanel estabelecimentoOuterPanel; - private JTabbedPane tabbedPane; - private JTextField estabelecimentoText; - private EstabelecimentoPanel estabelecimentoPanel; - private TrabalhadorPanel trabalhadorPanel; - - private SIPRPTracker tracker; - - private EmpresaData empresa; - private Integer elementosProtocolo[][]; - private EstabelecimentoData estabelecimento; - private TrabalhadorData trabalhador; - - private AvisosPanel avisos; - - protected boolean webAware; - -// public static void main( String args[] ) -// throws Exception -// { -// ClientesWindow window = new ClientesWindow(); -// window.show(); -// } - - /** Creates a new instance of ClientesWindow */ - public ClientesWindow( AvisosPanel avisos ) - throws Exception - { - super( permissions ); - this.avisos = avisos; - webAware = ( ( Boolean ) Singleton.getInstance( SingletonConstants.WEB_AWARE ) ).booleanValue(); - JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); - clientesProvider = ( ClientesDataProvider ) ClientesDataProvider.getProvider(); - setEditorManagerHierarchy( hierarchy ); - setupComponents(); - this.setExtendedState(this.getExtendedState() | this.MAXIMIZED_BOTH); - } - - private void setupComponents() - throws Exception - { - setSize( 1000, 740 ); - setTitle( "Gest\u00e3o de Clientes" ); - - changeGroupName( INDEX_ESTABELECIMENTO, "Estabelecimento" ); - JPanel toolbarEstabelecimento = getToolbarPanel( INDEX_ESTABELECIMENTO ); - - changeGroupName( INDEX_TRABALHADOR, "Trabalhador" ); - JPanel toolbarTrabalhador = getToolbarPanel( INDEX_TRABALHADOR ); - - tabbedPane = new JTabbedPane(); - empresaPanel = new EmpresaPanel(); - empresaPanel.setBorder( BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), - "Empresa/Entidade" ) ); - estabelecimentoText = new JTextField(); - estabelecimentoPanel = new EstabelecimentoPanel( toolbarEstabelecimento, estabelecimentoText, empresaPanel.getEstabelecimentosTable() ); - estabelecimentoOuterPanel = new JPanel(); - estabelecimentoOuterPanel.setBorder( BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), - "Estabelecimento" ) ); - JLabel estabelecimentoLabel = new JLabel( "Designa\u00e7\u00e3o" ); - - trabalhadorPanel = new TrabalhadorPanel( toolbarTrabalhador, empresaPanel.getEstabelecimentosTable() ); - - GridBagLayout gridbag = new GridBagLayout(); - getContentPane().setLayout( gridbag ); - GridBagConstraints constraints = new GridBagConstraints(); - constraints.insets = new Insets( 1, 1, 1, 1 ); - constraints.fill = GridBagConstraints.BOTH; - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - - constraints.weighty = 0.5; - constraints.gridheight = 1; - gridbag.setConstraints( empresaPanel, constraints ); - getContentPane().add( empresaPanel ); - - constraints.weighty = 0.5; - constraints.gridheight = GridBagConstraints.REMAINDER; - gridbag.setConstraints( estabelecimentoOuterPanel, constraints ); - getContentPane().add( estabelecimentoOuterPanel ); - - gridbag = new GridBagLayout(); - estabelecimentoOuterPanel.setLayout( gridbag ); - constraints = new GridBagConstraints(); - constraints.insets = new Insets( 1, 1, 1, 1 ); - constraints.fill = GridBagConstraints.BOTH; - - constraints.weightx = 0; - constraints.gridwidth = 1; - constraints.weighty = 0; - constraints.gridheight = 1; - gridbag.setConstraints( estabelecimentoLabel, constraints ); - estabelecimentoOuterPanel.add( estabelecimentoLabel ); - - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( estabelecimentoText, constraints ); - estabelecimentoOuterPanel.add( estabelecimentoText ); - - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weighty = 1; - constraints.gridheight = GridBagConstraints.REMAINDER; - gridbag.setConstraints( tabbedPane, constraints ); - estabelecimentoOuterPanel.add( tabbedPane ); - - tabbedPane.add( "Dados", estabelecimentoPanel ); - tabbedPane.add( "Trabalhadores", trabalhadorPanel ); - - panels[ INDEX_EMPRESA ] = empresaPanel; - panels[ INDEX_ESTABELECIMENTO ] = estabelecimentoPanel; - panels[ INDEX_TRABALHADOR ] = trabalhadorPanel; - //empresaPanel.addListSelectionListener( estabelecimentoPanel ); - empresaPanel.addListSelectionListener( trabalhadorPanel ); - empresaPanel.addListSelectionListener( this ); - trabalhadorPanel.addListSelectionListener( this ); - - registerAction( new ActionHandler(){ - public void execute() - { - excel(); - } - - public boolean activate( boolean newAction, boolean editAction, - boolean cancelAction, boolean saveAction, - boolean deleteAction, boolean selectAction ) - { - return editAction; - } - }, "Importar", - "Importar de Excel", "excel", - 0, true ); - - registerAction( new ActionHandler(){ - public void execute() - { - excelDemissoes(); - } - - public boolean activate( boolean newAction, boolean editAction, - boolean cancelAction, boolean saveAction, - boolean deleteAction, boolean selectAction ) - { - return editAction; - } - }, "Demiss\u00f5es", - "Demiss\u00f5es por Excel", null, - 0, true ); - - registerAction( new ActionHandler(){ - public void execute() - { - mudarEstabelecimento(); - } - - public boolean activate( boolean newAction, boolean editAction, - boolean cancelAction, boolean saveAction, - boolean deleteAction, boolean selectAction ) - { - return editAction; - } - }, "Mudar Estabelecimento", - "Mudar Estabelecimento", null, - INDEX_TRABALHADOR, false ); - - registerAction( new ActionHandler(){ - public void execute() - { - imprimirFicha(); - } - - public boolean activate( boolean newAction, boolean editAction, - boolean cancelAction, boolean saveAction, - boolean deleteAction, boolean selectAction ) - { - return editAction ; - } - }, "Imprimir Ficha de Aptid\u00e3o", - "Imprimir Ficha de Aptid\u00e3o", null, - INDEX_TRABALHADOR, false ); - - registerAction( new ActionHandler(){ - public void execute() - { - imprimirEtiquetaTrabalhador(); - } - - public boolean activate( boolean newAction, boolean editAction, - boolean cancelAction, boolean saveAction, - boolean deleteAction, boolean selectAction ) - { - return editAction ; - } - }, "Imprimir Etiqueta", - "Imprimir Etiqueta de Trabalhador", null, - INDEX_TRABALHADOR, false ); - - registerAction( new ActionHandler(){ - public void execute() - { - imprimirEtiquetaEstabelecimento(); - } - - public boolean activate( boolean newAction, boolean editAction, - boolean cancelAction, boolean saveAction, - boolean deleteAction, boolean selectAction ) - { - return editAction ; - } - }, "Imprimir Etiqueta", - "Imprimir Etiqueta de Estabelecimento", null, - INDEX_ESTABELECIMENTO, false ); - - registerAction( new ActionHandler(){ - public void execute() - { - restaurarEmpresa(); - } - - public boolean activate( boolean newAction, boolean editAction, - boolean cancelAction, boolean saveAction, - boolean deleteAction, boolean selectAction ) - { - return true; - } - }, "Restaurar Empresa", - "Restaurar Empresa", null, - INDEX_EMPRESA, false ); - - if( webAware ) - { - registerAction( new ActionHandler(){ - public void execute() - { - utilizadorWeb( false ); - } - - public boolean activate( boolean newAction, boolean editAction, - boolean cancelAction, boolean saveAction, - boolean deleteAction, boolean selectAction ) - { - return editAction; - } - }, "Utilizador Web da Empresa", - "Utilizador Web da Empresa", null, - INDEX_EMPRESA, false ); - - registerAction( new ActionHandler(){ - public void execute() - { - utilizadorWeb( true ); - } - - public boolean activate( boolean newAction, boolean editAction, - boolean cancelAction, boolean saveAction, - boolean deleteAction, boolean selectAction ) - { - return true; - } - }, "Utilizador Web", - "Utilizador Web", null, - INDEX_EMPRESA, false ); - - registerAction( new ActionHandler(){ - public void execute() - { - noticias(); - } - - public boolean activate( boolean newAction, boolean editAction, - boolean cancelAction, boolean saveAction, - boolean deleteAction, boolean selectAction ) - { - return true; - } - }, "Not\u00edcias", - "Not\u00edcias", null, - INDEX_EMPRESA, false ); - } - - registerAction( new ActionHandler(){ - public void execute() - { - restaurarEstabelecimento(); - } - - public boolean activate( boolean newAction, boolean editAction, - boolean cancelAction, boolean saveAction, - boolean deleteAction, boolean selectAction ) - { - return newAction || saveAction; - } - }, "Restaurar Estabelecimento", - "Restaurar Estabelecimento", null, - INDEX_ESTABELECIMENTO, false ); - - registerAction( new ActionHandler(){ - public void execute() - { - restaurarTrabalhador(); - } - - public boolean activate( boolean newAction, boolean editAction, - boolean cancelAction, boolean saveAction, - boolean deleteAction, boolean selectAction ) - { - return newAction || saveAction; - } - }, "Restaurar Trabalhador", - "Restaurar Trabalhador", null, - INDEX_TRABALHADOR, false ); - - new CopyPasteHandler( estabelecimentoText ); - } - - public boolean searchByName( ) - { - SearchDialog search; - Integer empresaID; -// switch( index ) -// { -// case INDEX_EMPRESA: - search = new SearchDialog( SearchExecuterFactory.getSearchExecuter( EmpresaData.class ), null, false, null, true ); - empresaID = ( Integer )search.getSelected(); - if( empresaID != null ) - { - try - { - empresa = (EmpresaData) JDO.load( EmpresaData.class, empresaID ); - elementosProtocolo = clientesProvider.getElementosProtocoloForEmpresa( empresaID, 2 ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar a empresa", true ); - empresa = null; - } - reload( INDEX_EMPRESA ); - } -// break; -// } - return true; - } - - public boolean newItem( int index ) - { - return true; - } - - public void reload( int index ) - { -//System.out.println( "RELOAD: " + index + " e: " + empresa + " e: " +estabelecimento + " t: " + trabalhador ); - switch( index ) - { - case INDEX_EMPRESA: - empresaPanel.fill( new Object[]{ empresa, elementosProtocolo } ); - estabelecimentoPanel.setEmpresa( empresa ); - break; - - case INDEX_ESTABELECIMENTO: -// trabalhadorPanel.fill( null ); - estabelecimentoPanel.fill( estabelecimento ); - trabalhadorPanel.setEstabelecimento( estabelecimento ); - break; - - case INDEX_TRABALHADOR: - trabalhadorPanel.fill( trabalhador ); -// trabalhadorPanel.reload(); - break; - - } - } - - public boolean save( int index ) - { - boolean isNew = false; - Object object = panels[ index ].save(); - try - { - switch( index ) - { - case INDEX_EMPRESA: - empresa = (EmpresaData) ( ( Object [] )object )[ 0 ]; - if( empresa.get( EmpresaData.ID ) == null ) - { - isNew = true; - } - elementosProtocolo = (Integer [][]) ( ( Object [] )object )[ 1 ]; - // System.out.println( empresa.debug() ); - ContactoData c1 = ( ContactoData )empresa.get( EmpresaData.CONTACTO_1 ); - ContactoData c2 = ( ContactoData )empresa.get( EmpresaData.CONTACTO_2 ); -// empresa.set( EmpresaData.CONTACTO_1, null ); -// empresa.set( EmpresaData.CONTACTO_2, null ); -// empresa.save(); - -// empresa.set( EmpresaData.CONTACTO_1, c1 ); - -// empresa.set( EmpresaData.CONTACTO_2, c2 ); - c1.save(); - c2.save(); - -// empresa.set( EmpresaData.INACTIVO, "n" ); - empresa.set( EmpresaData.DESIGNACAO_SOCIAL_PLAIN, - com.evolute.utils.strings.StringPlainer.convertString( ( String ) - empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) ) ); - empresa.save(); - clientesProvider.setElementosProtocoloForEmpresa( - ( Integer ) empresa.get( EmpresaData.ID ), elementosProtocolo ); - - if( isNew ) - { - estabelecimentoPanel.setEmpresa( empresa ); - } - ( ( EmpresaPanel )panels[ INDEX_EMPRESA ] ).reloadMarcacoes(); - break; - - case INDEX_ESTABELECIMENTO: - estabelecimento = (EstabelecimentoData) object; - if( estabelecimento.get( EstabelecimentoData.ID ) == null ) - { - isNew = true; - } - ContactoData c = ( ContactoData )estabelecimento.get( EstabelecimentoData.CONTACTO ); - c.save(); - if( estabelecimento.get( EstabelecimentoData.EMPRESA ) == null ) - { - JOptionPane.showMessageDialog( this, "Erro a guardar estabelecimento (NULL).", "Erro...", - JOptionPane.ERROR_MESSAGE ); - return false; - } - estabelecimento.set( EstabelecimentoData.NOME_PLAIN, - com.evolute.utils.strings.StringPlainer.convertString( ( String ) - estabelecimento.get( EstabelecimentoData.NOME ) ) ); - estabelecimento.save(); - estabelecimentoPanel.postSave(); - if( isNew ) - { - trabalhadorPanel.setEstabelecimento( estabelecimento ); - } - break; - - case INDEX_TRABALHADOR: - trabalhador = (TrabalhadorData) object; - trabalhador.set( TrabalhadorData.NOME_PLAIN, - com.evolute.utils.strings.StringPlainer.convertString( ( String ) - trabalhador.get( TrabalhadorData.NOME ) ) ); - trabalhador.save(); - trabalhadorPanel.postSave(); - break; - - default: - ( ( JDOObject )object ).save(); - } -// object.save(); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a gravar", true ); - return false; - } - //reload( index ); - return true; - } - - public void enableComponents( int index, boolean enable ) - { - panels[ index ].setEnabled( enable ); - avisos.setEnabled( !empresaPanel.isEnabled() && !estabelecimentoPanel.isEnabled() && !trabalhadorPanel.isEnabled(), - AvisoConstants.TIPO_EMPRESA ); - } - - public void clear( int index ) - { - panels[ index ].fill( null ); - } - - public void valueChanged( ListSelectionEvent e ) - { - Object source = e.getSource(); - Integer id; - if( source.equals( empresaPanel ) ) - { - id = empresaPanel.getSelectedEstabelecimento(); - if( id != null ) - { - select( INDEX_ESTABELECIMENTO ); - try - { - estabelecimento = ( EstabelecimentoData ) JDO.load( EstabelecimentoData.class, id ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar o estabelecimento", true ); - estabelecimento = null; - } - - } - else - { - estabelecimento = null; - } - reload( INDEX_ESTABELECIMENTO ); - } - else if( source.equals( trabalhadorPanel ) ) - { - id = trabalhadorPanel.getSelectedTrabalhador(); -//System.out.println( "trabalhadorid: " + id ); - if( id != null ) - { - try - { - trabalhador = (TrabalhadorData) JDO.load( TrabalhadorData.class, id ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar o trabalhador", true ); - trabalhador = null; - } - select( INDEX_TRABALHADOR ); - } - else - { - trabalhador = null; - } - - reload( INDEX_TRABALHADOR ); - } - } - - public boolean delete( int index ) - { - String yes = "Sim"; - String no = "N\u00e3o"; - switch( index ) - { - case INDEX_EMPRESA: - if( empresa == null ) - { - return false; - } - if( JOptionPane.showOptionDialog( - this, "Tem a certeza que quer apagar esta Empresa?", "Apagar Empresa...", - JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, new String[]{ no, yes }, no ) == 1 ) - { - try - { - empresa.delete(); - empresa = null; - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a apagar", true ); - return false; - } - return true; - } - break; - case INDEX_ESTABELECIMENTO: - if( estabelecimento == null ) - { - return false; - } - if( JOptionPane.showOptionDialog( - this, "Tem a certeza que quer apagar este Estabelecimento?", "Apagar Estabelecimento...", - JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, new String[]{ no, yes }, no ) == 1 ) - { - try - { - estabelecimento.delete(); - estabelecimento = null; - reload( INDEX_EMPRESA ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a apagar", true ); - return false; - } - return true; - } - break; - case INDEX_TRABALHADOR: - if( trabalhador == null ) - { - return false; - } - if( JOptionPane.showOptionDialog( - this, "Tem a certeza que quer apagar este Trabalhador?", "Apagar Trabalhador...", - JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, new String[]{ no, yes }, no ) == 1 ) - { - try - { - TrabalhadorData trabalhadorAux = trabalhador; - trabalhador = null; - trabalhadorAux.delete(); - - reload( INDEX_ESTABELECIMENTO ); - try - { - trabalhadorPanel.reloaList(); - } - catch( Exception ex ) - { - ex.printStackTrace(); - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a apagar", true ); - return false; - } - return true; - } - break; - } - return false; - } - - private void excel() - { - FileDialog fd = new FileDialog( this, "Escolha um ficheiro Excel:", FileDialog.LOAD ); - fd.setDirectory( System.getProperty( "user.home" ) ); - fd.setFilenameFilter( new FilenameFilter() { - public boolean accept( File dir, String name ) - { - return (name!=null) && (name.indexOf( ".xls" ) != -1); - } - } ); - fd.setVisible( true ); - //String filename = "c:\\test.xls"; - String filename = fd.getFile(); - if( filename != null ) - { - filename = fd.getDirectory() + File.separator + filename; - try - { - Importer importer = new Importer( this, filename, true, Importer.TYPE_ADMISSAO ); - Hashtable hash[] = importer.getMultipleData(); - Vector activate = new Vector(); - if( hash != null ) - { - // load all (active) trabalhadores for this company - IDObject trab[] = ( ( FichaDataProvider )FichaDataProvider.getProvider() - ).getAllTrabalhadoresForEmpresa( - ( Integer )empresa.get( EmpresaData.ID ) ); - Hashtable trabalhadores = new Hashtable(); - for( int i = 0; i < trab.length; ++i ) - { - trabalhadores.put( trab[ i ].toString().trim().toLowerCase(), trab[ i ].getID() ); - } - // load all active estabelecimentos for this company - IDObject estab[] = ( ( FichaDataProvider )FichaDataProvider.getProvider() - ).getAllEstabelecimentosForEmpresa( - ( Integer )empresa.get( EmpresaData.ID ) ); - Hashtable estabelecimentos = new Hashtable(); - for( int i = 0; i < estab.length; ++i ) - { - estabelecimentos.put( estab[ i ].toString().trim().toLowerCase(), estab[ i ].getID() ); - } - Hashtable estabCache = new Hashtable(); - for( int i = 0; i < hash.length; ++i ) - { -// if( hash[ i ] == null ) -// { -// continue; -// } - for( int j = 0; j < Importer.NAMES.length; ++j ) - { - if( hash[ i ] == null ) - { - continue; - } - Object value = hash[ i ].remove( Importer.NAMES[ j ] ); - if( Importer.NAMES[ j ].equals( Importer.NOME ) ) - { - if( value != null - && trabalhadores.get( value.toString().trim().toLowerCase() ) == null ) - { - trabalhadores.put( value.toString().trim().toLowerCase(), value ); - - hash[ i ].put( TR_IMPORT_NAMES_TO_TRAB.get( Importer.NOME ), - value.toString().trim() ); - hash[ i ].put( TrabalhadorData.NOME_PLAIN, - com.evolute.utils.strings.StringPlainer.convertString( value.toString().trim(), false, false ) ); - } - else - { - Integer tID = (Integer) trabalhadores.get( value.toString().trim().toLowerCase() ); - if( tID != null ) - { - activate.add( tID ); - } - hash[ i ] = null; - } - } - else if( Importer.NAMES[ j ].equals( Importer.LOCAL_TRABALHO ) ) - { - if( value == null ) - { - value = "sede"; - } - Integer eid = ( Integer )estabelecimentos.get( value.toString().trim().toLowerCase() ); - EstabelecimentoData esta; - if( eid == null ) - { - // save this estab - esta = new EstabelecimentoData(); - esta.set( EstabelecimentoData.EMPRESA, empresa ); - esta.set( EstabelecimentoData.NOME, value.toString().trim() ); - esta.set( EstabelecimentoData.NOME_PLAIN, com.evolute.utils.strings.StringPlainer.convertString( value.toString().trim(), false, false ) ); - esta.save(); - estabelecimentos.put( value.toString().trim().toLowerCase(), - esta.get( EstabelecimentoData.ID ) ); - - } - else - { - esta = ( EstabelecimentoData )estabCache.get( value ); - if( esta == null ) - { - esta = (EstabelecimentoData) JDO.load( EstabelecimentoData.class, eid ); - estabCache.put( value, esta ); - } - } -//System.out.println( "Put " + i + " esta " + esta.debug() ); - hash[ i ].put( TrabalhadorData.ESTABELECIMENTO, - esta ); - hash[ i ].put( TR_IMPORT_NAMES_TO_TRAB.get( Importer.LOCAL_TRABALHO ), - value.toString().trim() ); - } - else - { - if( Importer.NAMES[ j ].indexOf( Importer.DATA_PREFIX ) == 0 ) - { - value = DateUtils.guessDate( (String)value ); - if( value != null ) - { - hash[ i ].put( TR_IMPORT_NAMES_TO_TRAB.get( Importer.NAMES[ j ] ), - value ); - } - } - else - { - if( Importer.NAMES[ j ].equals( Importer.SEXO ) ) - { - if( value == null || ( (String) value ).length() == 0 ) - { - value = "m"; - } - else - { - value = ( (String) value ).substring(0,1).toLowerCase(); - if( !value.equals( "m" ) && !value.equals( "f" ) ) - { - value = "m"; - } - } - } - if( value != null ) - { - hash[ i ].put( TR_IMPORT_NAMES_TO_TRAB.get( Importer.NAMES[ j ] ), - value.toString().trim() ); - } - } - } - } - } - for( int i = 0; i < hash.length; ++i ) - { - if( hash[ i ] == null ) - { - continue; - } - // save trab - TrabalhadorData tr = new TrabalhadorData(); - tr.setHashData( hash[ i ] ); -// o estabelecimento nao faz parte da lista por causa do UI - tr.set( TrabalhadorData.ESTABELECIMENTO, - hash[ i ].get( TrabalhadorData.ESTABELECIMENTO ) ); - tr.set( TrabalhadorData.PERFIL, new Integer( 1 ) ); -// System.out.println( "T: " + i + "\n" + tr.debug() ); - tr.save(); - } - for( int i = 0; i < activate.size(); i++ ) - { - TrabalhadorData trabalhadorR = (TrabalhadorData)JDO.load( TrabalhadorData.class, ( Integer ) activate.elementAt( i ) ); - trabalhadorR.set( TrabalhadorData.INACTIVO, "n" ); - trabalhadorR.save(); - } - } - reload( INDEX_EMPRESA ); - } - catch( Exception ex ) - { - ex.printStackTrace(); - JOptionPane.showMessageDialog( this, "Erro a importar", "Erro...", JOptionPane.ERROR_MESSAGE ); - } - } - - } - - private void excelDemissoes() - { - FileDialog fd = new FileDialog( this, "Escolha um ficheiro Excel:", FileDialog.LOAD ); - fd.setDirectory( System.getProperty( "user.home" ) ); - fd.setFilenameFilter( new FilenameFilter() { - public boolean accept( File dir, String name ) - { - return (name!=null) && (name.indexOf( ".xls" ) != -1); - } - } ); - fd.setVisible( true ); - //String filename = "c:\\test.xls"; - String filename = fd.getFile(); - if( filename != null ) - { - filename = fd.getDirectory() + File.separator + filename; - try - { - Importer importer = new Importer( this, filename, true, Importer.TYPE_DEMISSAO ); - Hashtable hash[] = importer.getMultipleData(); - Vector invalidos = new Vector(); - Vector validos = new Vector(); - Vector semData = new Vector(); - if( hash != null ) - { - // load all (active) trabalhadores for this company - IDObject trab[] = ( ( FichaDataProvider )FichaDataProvider.getProvider() - ).getAllTrabalhadoresForEmpresa( - ( Integer )empresa.get( EmpresaData.ID ) ); - Hashtable trabalhadores = new Hashtable(); - for( int i = 0; i < trab.length; ++i ) - { - trabalhadores.put( StringPlainer.convertString( - trab[ i ].toString().trim().toLowerCase() ), trab[ i ].getID() ); - } - Hashtable estabCache = new Hashtable(); - for( int i = 0; i < hash.length; ++i ) - { -// if( hash[ i ] == null ) -// { -// continue; -// } - for( int j = 0; j < Importer.NAMES_DEMISSAO.length; ++j ) - { - if( hash[ i ] == null ) - { - continue; - } - Object value = hash[ i ].remove( Importer.NAMES_DEMISSAO[ j ] ); - if( Importer.NAMES_DEMISSAO[ j ].equals( Importer.NOME ) ) - { -System.out.println( "VALUE NOME: " + value ); - if( value != null - && !trabalhadores.containsKey( StringPlainer.convertString( value.toString().trim().toLowerCase() ) ) ) - { - invalidos.add( new String[]{ value.toString().trim(), - StringPlainer.convertString( value.toString().trim(), false, false ) } ); - hash[ i ] = null; - } - else if( value != null ) - { - Integer tID = (Integer) trabalhadores.get( StringPlainer.convertString( value.toString().trim().toLowerCase() ) ); - hash[ i ].put( TrabalhadorData.ID, tID ); - validos.add( new String[]{ value.toString().trim(), - StringPlainer.convertString( value.toString().trim(), false, false ) } ); - } - else - { - hash[ i ] = null; - } - } - else if( Importer.NAMES_DEMISSAO[ j ].equals( Importer.DATA_DEMISSAO ) ) - { - value = DateUtils.guessDate( (String)value ); - if( value != null ) - { - hash[ i ].put( TR_IMPORT_NAMES_TO_DEMISSOES.get( Importer.NAMES_DEMISSAO[ j ] ), - value ); - } - else - { - hash[ i ] = null; - validos.removeElementAt( validos.size() - 1 ); - semData.add( new String[]{ value.toString().trim(), - StringPlainer.convertString( value.toString().trim(), false, false ) } ); - } - } - } - } -//System.out.println( "HASH.LENGTH: " + hash.length ); - for( int i = 0; i < hash.length; ++i ) - { -//System.out.println( "HASH[ " + i + " ]: " + hash[ i ] ); - if( hash[ i ] == null ) - { -//System.out.println( "TRABALHADOR:continue" ); - continue; - } -//System.out.println( "TRABALHADOR:not continue" ); - TrabalhadorData tr = (TrabalhadorData)JDO.load( TrabalhadorData.class, ( Integer ) hash[ i ].get( TrabalhadorData.ID ) ); -//System.out.println( "TRABALHADORID: " + tr.get( TrabalhadorData.ID ) ); - tr.set( TrabalhadorData.DATA_DEMISSAO, hash[ i ].get( TrabalhadorData.DATA_DEMISSAO ) ); -//System.out.println( "TRABALHADORDEMISSAO: " + tr.get( TrabalhadorData.DATA_DEMISSAO ) ); - tr.save(); - } - StringBuffer buff = new StringBuffer( "" ); - buff.append( "Demitidos:\n" ); - for( int i = 0; i < validos.size(); i++ ) - { - buff.append( ( ( String [] ) validos.elementAt( i ) )[ 1 ] + "\n" ); - } - buff.append( "\nSem data ou data inv\u00e1lida:\n" ); - for( int i = 0; i < semData.size(); i++ ) - { - buff.append( ( ( String [] ) semData.elementAt( i ) )[ 1 ] + "\n" ); - } - buff.append( "\nN\u00e3o encontrados na base de dados:\n" ); - for( int i = 0; i < invalidos.size(); i++ ) - { - buff.append( ( ( String [] ) invalidos.elementAt( i ) )[ 1 ] + "\n" ); - } - new LongMessageDialog( this, false, buff.toString(), new Dimension( 600, 500 ) ); - } - reload( INDEX_EMPRESA ); - } - catch( Exception ex ) - { - ex.printStackTrace(); - JOptionPane.showMessageDialog( this, "Erro a importar", "Erro...", JOptionPane.ERROR_MESSAGE ); - } - } - - } - - public void mudarEstabelecimento() - { - ListAction lAction = new ListAction(){ - public String getListActionName() - { - return "Escolher"; - } - - public boolean executeListAction( int line, Object value ) - { - if( trabalhador == null ) - { - return false; - } - try - { - EstabelecimentoData eatabelecimentoNovo = (EstabelecimentoData)JDO.load( EstabelecimentoData.class, ( (IDObject)value ).getID() ); - trabalhador.set( TrabalhadorData.ESTABELECIMENTO, eatabelecimentoNovo ); - trabalhador.save(); - trabalhador = null; - reload( INDEX_ESTABELECIMENTO ); - trabalhadorPanel.reloaList(); - } - catch( Exception ex ) - { - ex.printStackTrace(); - return false; - } - return true; - } - }; - - try - { - IDObject estab[] = ( ( FichaDataProvider )FichaDataProvider.getProvider() - ).getAllEstabelecimentosForEmpresa( - ( Integer )empresa.get( EmpresaData.ID ) ); - ListActionDialog dialog = new ListActionDialog( this, "Escolher Estabelecimento", new String []{ "Designa\u00e7\u00e3o" }, - new Vector( Arrays.asList( estab ) ), lAction ); - dialog.setSize( 250, 200 ); - dialog.setVisible( true ); - } - catch( Exception ex ) - { - ex.printStackTrace(); - } - } - - public void setJDOObject( JDOObject object ) - { - empresa = null; - estabelecimento = null; - trabalhador = null; - reload(0); - if( object instanceof TrabalhadorData ) - { - tabbedPane.setSelectedIndex( 1 ); - trabalhador = (TrabalhadorData) object; - estabelecimento = (EstabelecimentoData)trabalhador.get( TrabalhadorData.ESTABELECIMENTO ); - empresa = (EmpresaData)estabelecimento.get( EstabelecimentoData.EMPRESA ); - } - else if( object instanceof EstabelecimentoData ) - { - tabbedPane.setSelectedIndex( 0 ); - estabelecimento = (EstabelecimentoData)object; - empresa = (EmpresaData)estabelecimento.get( EstabelecimentoData.EMPRESA ); - } - else if( object instanceof EmpresaData ) - { - empresa = (EmpresaData)object; - } - if( empresa != null ) - { - try - { - elementosProtocolo = - clientesProvider.getElementosProtocoloForEmpresa( - ( Integer ) empresa.get( EmpresaData.ID ), 2 ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar dados do protocolo.", true ); - elementosProtocolo = new Integer[2][0]; - } - } - reload(0); - if( empresa != null ) - { - select( INDEX_EMPRESA ); - } - if( estabelecimento != null ) - { - empresaPanel.setSelectedEstabelecimento( estabelecimento ); - } - if( trabalhador != null ) - { - trabalhadorPanel.setSelectedTrabalhador( trabalhador ); - } - } - - public void postSetup() - { - } - - public void restaurarEmpresa() - { - ListAction lAction = new ListAction(){ - public String getListActionName() - { - return "Restaurar"; - } - - public boolean executeListAction( int line, Object value ) - { - try - { - EmpresaData empresaR = (EmpresaData)JDO.load( EmpresaData.class, ( (IDObject)value ).getID() ); - empresaR.set( EmpresaData.INACTIVO, "n" ); - empresaR.save(); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a restaurar a Empresa", true ); - return false; - } - return true; - } - }; - - try - { - IDObject empresas[] = ( ( FichaDataProvider )FichaDataProvider.getProvider() - ).getAllEmpresasDeleted(); - ListActionDialog dialog = new ListActionDialog( this, "Restaurar Empresa", new String []{ "Designa\u00e7\u00e3o Social" }, - new Vector( Arrays.asList( empresas ) ), lAction ); - dialog.setSize( 250, 200 ); - dialog.setVisible( true ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a criar lista de Empresas", true ); - ex.printStackTrace(); - } - } - - public void restaurarEstabelecimento() - { - ListAction lAction = new ListAction(){ - public String getListActionName() - { - return "Restaurar"; - } - - public boolean executeListAction( int line, Object value ) - { - try - { - EstabelecimentoData estabelecimentoR = (EstabelecimentoData)JDO.load( EstabelecimentoData.class, ( (IDObject)value ).getID() ); - estabelecimentoR.set( EstabelecimentoData.INACTIVO, "n" ); - estabelecimentoR.save(); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a restaurar o Estabelecimento", true ); - return false; - } - return true; - } - }; - if( empresa == null ) - { - return; - } - try - { - IDObject estabelecimentos[] = ( ( FichaDataProvider )FichaDataProvider.getProvider() - ).getAllEstabelecimentosDeletedForEmpresa( ( Integer ) empresa.get( EmpresaData.ID ) ); - ListActionDialog dialog = new ListActionDialog( this, "Restaurar Estabelecimento", new String []{ "Nome" }, - new Vector( Arrays.asList( estabelecimentos ) ), lAction ); - dialog.setSize( 250, 200 ); - dialog.setVisible( true ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a criar lista de Estabelecimentos", true ); - ex.printStackTrace(); - } - } - - public void restaurarTrabalhador() - { - ListAction lAction = new ListAction(){ - public String getListActionName() - { - return "Restaurar"; - } - - public boolean executeListAction( int line, Object value ) - { - try - { - TrabalhadorData trabalhadorR = (TrabalhadorData)JDO.load( TrabalhadorData.class, ( (IDObject)value ).getID() ); - trabalhadorR.set( TrabalhadorData.INACTIVO, "n" ); - trabalhadorR.save(); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a restaurar o Trabalhador", true ); - return false; - } - return true; - } - }; - if( estabelecimento == null ) - { - return; - } - try - { - IDObject trabalhadores[] = ( ( FichaDataProvider )FichaDataProvider.getProvider() - ).getAllTrabalhadoresDeletedForEstabelecimento( ( Integer ) estabelecimento.get( EstabelecimentoData.ID ) ); - ListActionDialog dialog = new ListActionDialog( this, "Restaurar Trabalhador", new String []{ "Nome" }, - new Vector( Arrays.asList( trabalhadores ) ), lAction ); - dialog.setSize( 250, 200 ); - dialog.setVisible( true ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a criar lista de Trabalhadores", true ); - ex.printStackTrace(); - } - } - - protected void utilizadorWeb( boolean siprp ) - { -// new Exception().printStackTrace(); - if( !siprp && empresa == null ) - { - JOptionPane.showMessageDialog( this, "Tem de escolher uma empresa", "Erro...", - JOptionPane.ERROR_MESSAGE ); - } - try - { - - UserWindow window = new UserWindow( this, siprp ? null : ( Integer ) empresa.get( EmpresaData.ID ) ); - window.setVisible( true ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a estabelecer a liga\u00e7\u00e3o com a p\u00e1gina", true ); - } - } - - public void noticias() - { - try - { - NoticiasDialog dialog = new NoticiasDialog( this ); - dialog.setVisible( true ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar not\u00edcias", true ); - } - } - - public void imprimirFicha() - { - ListAction lAction = new ListAction(){ - public String getListActionName() - { - return "Escolher"; - } - - public boolean executeListAction( int line, Object value ) - { - if( trabalhador == null ) - { - return false; - } - try - { - printFicha(( (IDObject)value ).getID() ); - } - catch( Exception ex ) - { - ex.printStackTrace(); - return false; - } - return true; - } - }; - if( trabalhador == null ) - { - return; - } - Vector linhas; - try - { - IDObject fichas[] = ( ( FichaDataProvider )FichaDataProvider.getProvider() - ).getAllFichasForTrabalhador( ( Integer ) trabalhador.get( TrabalhadorData.ID ) ); - linhas = new Vector( Arrays.asList( fichas ) ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a criar lista de Fichas anteriores", true ); - return; - } - ListActionDialog dialog = new ListActionDialog( this, "Imprimir Fichas Anteriores", new String[]{ "Data" }, - linhas, lAction ); - dialog.setSize( 250, 200 ); - dialog.setVisible( true ); - } - - private void printFicha( Integer exameID ) - throws Exception - { -// MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) ); - ExameData exame = (ExameData) JDO.load( ExameData.class, exameID ); - byte pdf[] = (byte []) exame.get( ExameData.PDF ); - if( exame == null ) - { - throw new Exception( "N\u00e3o existe exame" ); - } - TrabalhadorData trabalhadorExame = ( TrabalhadorData ) exame.get( ExameData.TRABALHADOR ); - String nomeFicheiro = StringPlainer.convertString( ( String ) trabalhadorExame.get( TrabalhadorData.NOME ) ); - nomeFicheiro.replaceAll( " ", "_" ); - ExamePDF ePDF = new ExamePDF(); - ePDF.print( pdf, nomeFicheiro ); - } - - public void setTracker( SIPRPTracker tracker ) - { - this.tracker = tracker; - estabelecimentoPanel.setTracker( tracker ); - trabalhadorPanel.setTracker( tracker ); - } - - public void imprimirEtiquetaTrabalhador() - { - if( trabalhador == null ) - { - return; - } - String nomeEmpresa = ( ( String ) empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) ); - String nomeTrabalhador = ( ( String ) trabalhador.get( TrabalhadorData.NOME ) ); - String numeroMecanografico = ( ( String ) trabalhador.get( TrabalhadorData.NUMERO_MECANOGRAFICO ) ); - String sexo = "m".equals( trabalhador.get( TrabalhadorData.SEXO ) ) ? "M" : "F"; - Date data = ( Date ) trabalhador.get( TrabalhadorData.DATA_NASCIMENTO ); - String dataNascimento = data != null ? DF.format( data ) : "--"; - String nacionalidade = ( String ) trabalhador.get( TrabalhadorData.NACIONALIDADE ); - data = ( Date ) trabalhador.get( TrabalhadorData.DATA_ADMISSAO ); - String dataAdmissao = data != null ? DF.format( data ) : "--"; - String categoria = ( String ) trabalhador.get( TrabalhadorData.CATEGORIA ); - String funcao = ( String ) trabalhador.get( TrabalhadorData.FUNCAO_PROPOSTA ); - try - { - Integer id = clientesProvider.getEtiquetaID(); - EtiquetaData etiqueta = ( EtiquetaData ) JDO.load( EtiquetaData.class, id ); - EtiquetaPrinter printer = new EtiquetaPrinter( etiqueta ); - Vector linhas = new Vector(); - linhas.add( new Object[]{ nomeEmpresa, new Double( 1.0 ) } ); - linhas.add( new Object[]{ nomeTrabalhador, new Double( 1.0 ) } ); - linhas.add( new Object[]{ "N\u00ba mec.:" + ( numeroMecanografico != null ? numeroMecanografico.toString() : "" ), new Double( 0.80 ), - "Sexo:" + sexo, new Double( 0.20 ) } ); - linhas.add( new Object[]{ "Data nasc:" + dataNascimento, new Double( 0.4 ), - "Nacionalidade:" + nacionalidade, new Double( 0.85 ) } ); - linhas.add( new Object[]{ "Data adm.:" + dataAdmissao, new Double( 0.4 ), - "Categoria:" + categoria, new Double( 0.6 ) } ); - linhas.add( new Object[]{ "Fun\u00e7\u00e3o:" + funcao, new Double( 1.0 ) } ); - printer.print( linhas ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar etiqueta.", true ); - } - } - - public void imprimirEtiquetaEstabelecimento() - { - if( estabelecimento == null ) - { - return; - } - String nomeEmpresa = ( ( String ) empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) ); - String nomeEstabelecimento = ( ( String ) estabelecimento.get( EstabelecimentoData.NOME ) ); - ContactoData contacto = ( ContactoData )estabelecimento.get( EstabelecimentoData.CONTACTO ); - String nomeContacto = ""; - if( contacto != null ) - { - nomeContacto = ( String )contacto.get( ContactoData.NOME ); - } - String morada = ( ( String ) estabelecimento.get( EstabelecimentoData.MORADA ) ); - String codigoPostal = ( ( String ) estabelecimento.get( EstabelecimentoData.CODIGO_POSTAL ) ); - String local = ( ( String ) estabelecimento.get( EstabelecimentoData.LOCALIDADE ) ); - - try - { - Integer id = clientesProvider.getEtiquetaID(); - EtiquetaData etiqueta = ( EtiquetaData ) JDO.load( EtiquetaData.class, id ); - EtiquetaPrinter printer = new EtiquetaPrinter( etiqueta ); - Vector linhas = new Vector(); - linhas.add( new Object[]{ nomeEmpresa, new Double( 1.0 ) } ); - linhas.add( new Object[]{ nomeContacto, new Double( 1.0 ) } ); - linhas.add( new Object[]{ morada, new Double( 1.0 ) } ); - linhas.add( new Object[]{ codigoPostal + " " + local, new Double( 1.0 ) } ); - printer.print( linhas ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar etiqueta.", true ); - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/ContactoPanel.java b/trunk/SIPRPSoft/src/siprp/clientes/ContactoPanel.java deleted file mode 100644 index 71c5dae3..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/ContactoPanel.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/EmpresaPanel.java b/trunk/SIPRPSoft/src/siprp/clientes/EmpresaPanel.java deleted file mode 100644 index e71bf0d0..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/EmpresaPanel.java +++ /dev/null @@ -1,956 +0,0 @@ -/* - * 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.calendar.*; -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 inicioContratoPanel; - private JTextField duracaoContratoText; - 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 inicioContratoLabel = new JLabel( "In\u00edcio" ); - inicioContratoPanel = new JCalendarPanel( null ); - JLabel duracaoContratoLabel = new JLabel( "Dura\u00e7\u00e3o (meses)" ); - duracaoContratoText = new JTextField(); - duracaoContratoText.setDocument( new IntegerDocument( 5, false ) ); - 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( inicioContratoLabel, constraints ); - formalidadesPanel.add( inicioContratoLabel ); - - constraints.weightx = 0.2; - constraints.gridwidth = 1; -// JPanel perfisPanel = new JPanel(); - gridbag.setConstraints( inicioContratoPanel, constraints ); - formalidadesPanel.add( inicioContratoPanel ); - - 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; - gridbag.setConstraints( duracaoContratoLabel, constraints ); - formalidadesPanel.add( duracaoContratoLabel ); - - constraints.weightx = 0.2; - constraints.gridwidth = 1; -// JPanel perfisPanel = new JPanel(); - gridbag.setConstraints( duracaoContratoText, constraints ); - formalidadesPanel.add( duracaoContratoText ); - - 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; - 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; - 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; - gridbag.setConstraints( servicosCombo, constraints ); - formalidadesPanel.add( servicosCombo ); - - 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; - 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.4; - 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.INICIO_CONTRATO, inicioContratoPanel ); - components.putComponent( EmpresaData.DURACAO, duracaoContratoText ); - 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(); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/EstabelecimentoPanel.java b/trunk/SIPRPSoft/src/siprp/clientes/EstabelecimentoPanel.java deleted file mode 100644 index 07d20df7..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/EstabelecimentoPanel.java +++ /dev/null @@ -1,450 +0,0 @@ -/* - * 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/EtiquetaChooserDialog.java b/trunk/SIPRPSoft/src/siprp/clientes/EtiquetaChooserDialog.java deleted file mode 100644 index d6324e91..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/EtiquetaChooserDialog.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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 positionHash = new Hashtable(); - - 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(); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/EtiquetaPrinter.java b/trunk/SIPRPSoft/src/siprp/clientes/EtiquetaPrinter.java deleted file mode 100644 index aa868078..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/EtiquetaPrinter.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * 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 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 = ""; - 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 = ""; - ByteArrayOutputStream out = new ByteArrayOutputStream(); - FOPCreator creator = FOPCreator.getFOPCreator(); - 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() ); - FOPPrinter printer = FOPPrinter.getFOPPrinter(); - 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/HistoricoEstabelecimentoPanel.java b/trunk/SIPRPSoft/src/siprp/clientes/HistoricoEstabelecimentoPanel.java deleted file mode 100644 index 275e7a71..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/HistoricoEstabelecimentoPanel.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * 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.ui.*; -import com.evolute.utils.ui.calendar.*; -import com.evolute.utils.ui.text.*; - -import siprp.data.*; - -/** - * - * @author fpalma - */ -public class HistoricoEstabelecimentoPanel extends JPanel - implements ControllableComponent, DocumentListener, ChangeListener, 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.removeChangeListener( this ); - text.getDocument().removeDocumentListener( this ); - changed = true; - saveButton.setEnabled( true ); - changeButton(); - } - } - - private void initButtons() - { - saveButton.setEnabled( false ); - calendarPanel.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; - } - 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; - } - - public void stateChanged(ChangeEvent e) - { - startEditedState(); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/MarcacaoEmpresaPanel.java b/trunk/SIPRPSoft/src/siprp/clientes/MarcacaoEmpresaPanel.java deleted file mode 100644 index 4a271a73..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/MarcacaoEmpresaPanel.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * 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.calendar.*; -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.removeChangeListener( this ); - text.getDocument().removeDocumentListener( this ); - realizadaCheck.removeChangeListener( this ); - changed = true; - saveButton.setEnabled( true ); - changeButton(); - } - } - - private void initButtons() - { - saveButton.setEnabled( false ); - calendarPanel.addChangeListener( 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(); - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/MarcacaoPanel.java b/trunk/SIPRPSoft/src/siprp/clientes/MarcacaoPanel.java deleted file mode 100644 index 5d1002b7..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/MarcacaoPanel.java +++ /dev/null @@ -1,594 +0,0 @@ -/* - * 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.calendar.*; -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.addChangeListener( new ChangeListener(){ - public void stateChanged(ChangeEvent 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.addChangeListener( new ChangeListener(){ - public void stateChanged(ChangeEvent 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/NoticiasDataProvider.java b/trunk/SIPRPSoft/src/siprp/clientes/NoticiasDataProvider.java deleted file mode 100644 index a678cd7c..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/NoticiasDataProvider.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/NoticiasDialog.java b/trunk/SIPRPSoft/src/siprp/clientes/NoticiasDialog.java deleted file mode 100644 index 5e432c05..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/NoticiasDialog.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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(); - } - } ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/PerfilProtocoloPanel.java b/trunk/SIPRPSoft/src/siprp/clientes/PerfilProtocoloPanel.java deleted file mode 100644 index bfe2a4e8..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/PerfilProtocoloPanel.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * 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() ); - } - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/ProtocoloPanel.java b/trunk/SIPRPSoft/src/siprp/clientes/ProtocoloPanel.java deleted file mode 100644 index af0e2ae0..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/ProtocoloPanel.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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(); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/TrabalhadorPanel.java b/trunk/SIPRPSoft/src/siprp/clientes/TrabalhadorPanel.java deleted file mode 100644 index 4b9f630a..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/TrabalhadorPanel.java +++ /dev/null @@ -1,612 +0,0 @@ -/* - * 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.calendar.*; -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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/UserDataProvider.java b/trunk/SIPRPSoft/src/siprp/clientes/UserDataProvider.java deleted file mode 100644 index 1d89bc93..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/UserDataProvider.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/UserPanel.java b/trunk/SIPRPSoft/src/siprp/clientes/UserPanel.java deleted file mode 100644 index d9a8bf2f..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/UserPanel.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * 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( "" ); - - 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( "" ); - } - else - { - passwordText.setText( "" ); - } - } - 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/UserWindow.java b/trunk/SIPRPSoft/src/siprp/clientes/UserWindow.java deleted file mode 100644 index 8ba90d39..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/UserWindow.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * UserWindow.java - * - * Created on 15 de Marco 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/etiqueta.xsl b/trunk/SIPRPSoft/src/siprp/clientes/etiqueta.xsl deleted file mode 100644 index 4603a50b..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/etiqueta.xsl +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - Cuidado Prestado - - - - - Código - - - - - Valor - - - - - Benef. - - - - - Entidade - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/trunk/SIPRPSoft/src/siprp/clientes/etiquetas.dtd b/trunk/SIPRPSoft/src/siprp/clientes/etiquetas.dtd deleted file mode 100644 index 69d2b4f1..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/etiquetas.dtd +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/trunk/SIPRPSoft/src/siprp/companydataloaders/ClinicaAvenidaDataLoader.java b/trunk/SIPRPSoft/src/siprp/companydataloaders/ClinicaAvenidaDataLoader.java deleted file mode 100644 index 89dbdca8..00000000 --- a/trunk/SIPRPSoft/src/siprp/companydataloaders/ClinicaAvenidaDataLoader.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * ClinicaAvenidaDtaLoader.java - * - * Created on 25 de Janeiro de 2005, 13:27 - */ - -package siprp.companydataloaders; - -import com.evolute.utils.*; - -import siprp.*; - -/** - * - * @author fpalma - */ -public class ClinicaAvenidaDataLoader implements CompanyDataLoader -{ - - /** Creates a new instance of ClinicaAvenidaDtaLoader */ - public ClinicaAvenidaDataLoader() - { - } - - public void load() - { - Singleton.setInstance( SingletonConstants.SOFTWARE_NAME, "SHSTSoft" ); - Singleton.setInstance( SingletonConstants.COMPANY_NAME, "Centro Cl\u00ednico Avenida" ); - Singleton.setInstance( SingletonConstants.COMPANY_LOGO, "logo_evo.jpg" ); - Singleton.setInstance( SingletonConstants.COMPANY_ACRONYM, "CCA" ); - Singleton.setInstance( SingletonConstants.SUBJECT_CONSULTA, "Centro Cl\u00ednico da Avenida - Marca\u00e7\u00e3o de consulta m\u00e9dica" ); - Singleton.setInstance( SingletonConstants.LETTER_CONSULTA, "Vimos por este meio informar que " + NOME + " " - + "dever\u00e1 comparecer no Centro Cl\u00ednico da Avenida para a realiza\u00e7\u00e3o da " - + "consulta de Medicina do Trabalho, no dia " + DATA + ".\n" - + "Caso n\u00e3o seja poss\u00edvel a compar\u00eancia do referido colaborador na " - + "data indicada, agradecemos que nos informem atrav\u00e9s do telefone 214928612 " - + "ou respondendo a esta mensagem.\n\n" - + "Departamento de Seguran\u00e7a e Higiene do Trabalho\n" - + "Centro Cl\u00ednico da Avenida\n" - + "Av. General Humberto Delgado 128 R/C D\n" - + "2700-419 Amadora" ); - Singleton.setInstance( SingletonConstants.SUBJECT_EXAMES, "Centro Cl\u00ednico da Avenida - Marca\u00e7\u00e3o de exames de Medicina do Trabalho" ); - Singleton.setInstance( SingletonConstants.LETTER_EXAMES, "Vimos por este meio informar que " + NOME + " " - + "dever\u00e1 comparecer no Centro Cl\u00ednico da Avenida para a realiza\u00e7\u00e3o " - + "de exames relativos \u00e0 Medicina do Trabalho, no dia " + DATA + ".\n" - + "Caso n\u00e3o seja poss\u00edvel a compar\u00eancia do referido colaborador na " - + "data indicada, agradecemos que nos informem atrav\u00e9s do telefone 214928612 " - + "ou respondendo a esta mensagem.\n\n" - + "Departamento de Seguran\u00e7a e Higiene do Trabalho\n" - + "Centro Cl\u00ednico da Avenida\n" - + "Av. General Humberto Delgado 128 R/C D\n" - + "2700-419 Amadora" ); - Singleton.setInstance( SingletonConstants.SUBJECT_VISITA, "Centro Cl\u00ednico da Avenida - Marca\u00e7\u00e3�o da Auditoria de Seguran\u00e7a e Higiene do Trabalho" ); - Singleton.setInstance( SingletonConstants.LETTER_VISITA, "Vimos por este meio informar que pretendemos " - + "realizar a auditoria de Seguran\u00e7a e Higiene do Trabalho \u00e0s vossas " - + "instala��es em " + MORADA + ", no dia " + DATA + ".\n" - + "Agradecemos que confirmem a vossa disponibilidade para a realiza\u00e7\u00e3o " - + "da visita na data indicada, atrav\u00e9s do telefone 214928612 ou " - + "respondendo a esta mensagem.\n\n" - + "Departamento de Seguran\u00e7a e Higiene do Trabalho\n" - + "Centro Cl\u00ednico da Avenida\n" - + "Av. General Humberto Delgado 128 R/C D\n" - + "2700-419 Amadora\n" - + "Tel.: 214928612" ); - Singleton.setInstance( SingletonConstants.USES_HOUR, Boolean.TRUE ); - Singleton.setInstance( SingletonConstants.CODIGO_EMPRESA_FORMAT, "15" ); - Singleton.setInstance( SingletonConstants.FICHA_MARCA_EXAMES, Boolean.FALSE ); - Singleton.setInstance( SingletonConstants.EXCEL_FORMAT, new int[]{ 0, 2, 3, 1, 4, 5, 6, 9, 7, 8 } ); - - Singleton.setInstance( SingletonConstants.MODULE_FICHA, Boolean.TRUE ); - Singleton.setInstance( SingletonConstants.MODULE_CLIENTES, Boolean.TRUE ); - Singleton.setInstance( SingletonConstants.WEB_AWARE, Boolean.FALSE ); - Singleton.setInstance( SingletonConstants.MODULE_RELATORIO, Boolean.TRUE ); - Singleton.setInstance( SingletonConstants.MODULE_LISTAGENS, Boolean.FALSE ); - - Singleton.setInstance( SingletonConstants.WEB_USER, "" ); - Singleton.setInstance( SingletonConstants.WEB_PASSWORD, "" ); - Singleton.setInstance( SingletonConstants.WEB_URL_PREFIX, "" ); - Singleton.setInstance( SingletonConstants.WEB_URL, "" ); - Singleton.setInstance( SingletonConstants.WEB_DB_NAME, "" ); - Singleton.setInstance( SingletonConstants.WEB_DRIVER_NAME, "" ); - - Singleton.setInstance( SingletonConstants.LOCAL_USER, "postgres" ); - Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "Typein" ); - Singleton.setInstance( SingletonConstants.LOCAL_URL_PREFIX, "jdbc:postgresql://" ); - Singleton.setInstance( SingletonConstants.LOCAL_URL, "localhost" ); - Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "shst" ); - Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/companydataloaders/IBookDataLoader.java b/trunk/SIPRPSoft/src/siprp/companydataloaders/IBookDataLoader.java deleted file mode 100644 index 1f1d3e4b..00000000 --- a/trunk/SIPRPSoft/src/siprp/companydataloaders/IBookDataLoader.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * SIPRPDataLoader.java - * - * Created on 25 de Janeiro de 2005, 13:19 - */ - -package siprp.companydataloaders; - -import com.evolute.utils.*; - -import siprp.*; - -/** - * - * @author fpalma - */ -public class IBookDataLoader implements CompanyDataLoader -{ - - /** Creates a new instance of SIPRPDataLoader */ - public IBookDataLoader() - { - } - - public void load() - { - Singleton.setInstance( SingletonConstants.SOFTWARE_NAME, "SHSTSoft" ); - Singleton.setInstance( SingletonConstants.COMPANY_NAME, "SHST" ); - Singleton.setInstance( SingletonConstants.COMPANY_LOGO, "logo_evo.jpg" ); - Singleton.setInstance( SingletonConstants.COMPANY_ACRONYM, "SHST" ); - Singleton.setInstance( SingletonConstants.SUBJECT_CONSULTA, "SHST - Marca\u00E7\u00E3o de consulta"); - Singleton.setInstance( SingletonConstants.LETTER_CONSULTA, "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 212 12 12 " - + "ou respondendo ao remetente desta mensagem." - + "%0A%0A%0A" - + "Cumprimentos," - + "%0A%0ASHST" ); - Singleton.setInstance( SingletonConstants.SUBJECT_EXAMES, "SHST - Marca\u00E7\u00E3o de exame"); - Singleton.setInstance( SingletonConstants.LETTER_EXAMES, "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 212 12 12 " - + "ou respondendo ao remetente desta mensagem." - + "%0A%0A%0A" - + "Cumprimentos,%0A%0ASHST" ); - Singleton.setInstance( SingletonConstants.SUBJECT_VISITA, "SHST - Marca\u00E7\u00E3o de visita de higiene e seguran\u00E7a"); - Singleton.setInstance( SingletonConstants.LETTER_VISITA, "Vimos pelo presente informar que iremos efectuar a auditoria de Higiene e " - + "Seguran\u00E7a \u00E0s vossas instala\u00E7\u00F5es de '" + NOME + "', 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 do telefone 21 212 12 12 " - + "ou responda ao remetente desta mensagem." - + "%0A%0A%0A" - + "Cumprimentos,%0A%0ASHST" ); - Singleton.setInstance( SingletonConstants.USES_HOUR, Boolean.FALSE ); - Singleton.setInstance( SingletonConstants.CODIGO_EMPRESA_FORMAT, "2 6 / 2" ); - Singleton.setInstance( SingletonConstants.FICHA_MARCA_EXAMES, Boolean.TRUE ); - Singleton.setInstance( SingletonConstants.EXCEL_FORMAT, new int[]{ 0, 2, 3, 1, -1, 4, 5, 7, 6, -1 } ); - - Singleton.setInstance( SingletonConstants.MODULE_FICHA, Boolean.TRUE ); - Singleton.setInstance( SingletonConstants.MODULE_CLIENTES, Boolean.TRUE ); - Singleton.setInstance( SingletonConstants.WEB_AWARE, Boolean.FALSE ); - Singleton.setInstance( SingletonConstants.MODULE_RELATORIO, Boolean.TRUE ); - Singleton.setInstance( SingletonConstants.MODULE_LISTAGENS, Boolean.TRUE ); - - Singleton.setInstance( SingletonConstants.WEB_USER, "" ); - Singleton.setInstance( SingletonConstants.WEB_PASSWORD, "" ); - Singleton.setInstance( SingletonConstants.WEB_URL_PREFIX, "" ); - Singleton.setInstance( SingletonConstants.WEB_URL, "" ); - Singleton.setInstance( SingletonConstants.WEB_DB_NAME, "" ); - Singleton.setInstance( SingletonConstants.WEB_DRIVER_NAME, "" ); - -// Singleton.setInstance( SingletonConstants.LOCAL_USER, "postgres" ); -// Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "Typein" ); -// Singleton.setInstance( SingletonConstants.LOCAL_URL_PREFIX, "jdbc:postgresql://" ); -// Singleton.setInstance( SingletonConstants.LOCAL_URL, "192.168.1.1:5432" ); -// Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" ); -// Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); - - Singleton.setInstance( SingletonConstants.LOCAL_USER, "postgres" ); - Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "Typein" ); - Singleton.setInstance( SingletonConstants.LOCAL_URL_PREFIX, "jdbc:postgresql://" ); - Singleton.setInstance( SingletonConstants.LOCAL_URL, "localhost:5432" ); - Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" ); - Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/companydataloaders/SIPRPDataLoader.java b/trunk/SIPRPSoft/src/siprp/companydataloaders/SIPRPDataLoader.java deleted file mode 100644 index 497bb5d6..00000000 --- a/trunk/SIPRPSoft/src/siprp/companydataloaders/SIPRPDataLoader.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * SIPRPDataLoader.java - * - * Created on 25 de Janeiro de 2005, 13:19 - */ - -package siprp.companydataloaders; - -import com.evolute.utils.*; - -import siprp.*; - -/** - * - * @author fpalma - */ -public class SIPRPDataLoader implements CompanyDataLoader -{ - - /** Creates a new instance of SIPRPDataLoader */ - public SIPRPDataLoader() - { - } - - public void load() - { - Singleton.setInstance( SingletonConstants.SOFTWARE_NAME, "SIPRPSoft" ); - Singleton.setInstance( SingletonConstants.COMPANY_NAME, "SIPRP - Sociedade Ib\u00e9rica de Preven\u00e7\u00e3o de Riscos Profissionais" ); - Singleton.setInstance( SingletonConstants.COMPANY_LOGO, "logo_combo.jpg" ); - Singleton.setInstance( SingletonConstants.COMPANY_ACRONYM, "SIPRP" ); - Singleton.setInstance( SingletonConstants.SUBJECT_CONSULTA, "SIPRP - Marca\u00E7\u00E3o de consulta de '" + NOME + "'"); - Singleton.setInstance( SingletonConstants.LETTER_CONSULTA, "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 " - + "ou respondendo ao remetente desta mensagem." - + "%0A%0A%0A" - + "Cumprimentos," - + "%0A%0ASIPRP" - + "%0A%0AATRIUM SALDANHA" - + "%0A%0APra\u00e7a Duque de Saldanha, 1 - 9\u00BAG" - + "%0A%0A1050-094 Lisboa" ); - Singleton.setInstance( SingletonConstants.SUBJECT_EXAMES, "SIPRP - Marca\u00E7\u00E3o de exame de '" + NOME + "'"); - Singleton.setInstance( SingletonConstants.LETTER_EXAMES, "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 " - + "ou respondendo ao remetente desta mensagem." - + "%0A%0A%0A" - + "Cumprimentos,%0A%0ASIPRP" ); - Singleton.setInstance( SingletonConstants.SUBJECT_VISITA, "SIPRP - Marca\u00E7\u00E3o de visita de higiene e seguran\u00E7a a '" + NOME + "'" ); - Singleton.setInstance( SingletonConstants.LETTER_VISITA, "Vimos pelo presente informar que iremos efectuar a auditoria de Higiene e " - + "Seguran\u00E7a \u00E0s vossas instala\u00E7\u00F5es de '" + NOME + "', 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." - + "%0A%0A%0A" - + "Cumprimentos,%0A%0ASIPRP" ); - Singleton.setInstance( SingletonConstants.USES_HOUR, Boolean.FALSE ); - Singleton.setInstance( SingletonConstants.CODIGO_EMPRESA_FORMAT, "2 6 / 2" ); - Singleton.setInstance( SingletonConstants.FICHA_MARCA_EXAMES, Boolean.TRUE ); - Singleton.setInstance( SingletonConstants.EXCEL_FORMAT, new int[]{ 0, 2, 3, 1, -1, 4, 5, 7, 6, -1 } ); - Singleton.setInstance( SingletonConstants.EXCEL_FORMAT_DEMISSAO, new int[]{ 0, 1 } ); - - Singleton.setInstance( SingletonConstants.MODULE_FICHA, Boolean.TRUE ); - Singleton.setInstance( SingletonConstants.MODULE_CLIENTES, Boolean.TRUE ); - Singleton.setInstance( SingletonConstants.WEB_AWARE, Boolean.TRUE ); - Singleton.setInstance( SingletonConstants.MODULE_RELATORIO, Boolean.TRUE ); - Singleton.setInstance( SingletonConstants.MODULE_LISTAGENS, Boolean.TRUE ); - - Singleton.setInstance( SingletonConstants.WEB_USER, "siprp" ); - Singleton.setInstance( SingletonConstants.WEB_PASSWORD, "rg2h-opksiprp" ); - Singleton.setInstance( SingletonConstants.WEB_URL_PREFIX, "jdbc:postgresql://" ); - Singleton.setInstance( SingletonConstants.WEB_URL, "www.evolute.pt:5436" ); - Singleton.setInstance( SingletonConstants.WEB_DB_NAME, "siprp" ); - Singleton.setInstance( SingletonConstants.WEB_DRIVER_NAME, "org.postgresql.Driver" ); - -// Singleton.setInstance( SingletonConstants.LOCAL_USER, "slony" ); -// Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "-rg2hevoevo" ); -// Singleton.setInstance( SingletonConstants.LOCAL_URL_PREFIX, "jdbc:postgresql://" ); -// Singleton.setInstance( SingletonConstants.LOCAL_URL, "www.evolute.pt:5436" ); -// Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local_3" ); -// Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); - - Singleton.setInstance( SingletonConstants.LOCAL_USER, "postgres" ); - Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "Typein" ); - Singleton.setInstance( SingletonConstants.LOCAL_URL_PREFIX, "jdbc:postgresql://" ); - Singleton.setInstance( SingletonConstants.LOCAL_URL, "10.158.2.3:5432" ); - Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" ); - Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); -// -// Singleton.setInstance( SingletonConstants.LOCAL_USER, "postgres" ); -// Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "Typein" ); -// Singleton.setInstance( SingletonConstants.LOCAL_URL_PREFIX, "jdbc:postgresql://" ); -// Singleton.setInstance( SingletonConstants.LOCAL_URL, "localhost:5432" ); -// Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" ); -// Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); - -// Singleton.setInstance( SingletonConstants.LOCAL_USER, "postgres" ); -// Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "Typein" ); -// Singleton.setInstance( SingletonConstants.LOCAL_URL_PREFIX, "jdbc:postgresql://" ); -// Singleton.setInstance( SingletonConstants.LOCAL_URL, "192.168.1.1:5432" ); -// Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" ); -// Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/data/ActualizacaoSaveHandler.java b/trunk/SIPRPSoft/src/siprp/data/ActualizacaoSaveHandler.java deleted file mode 100644 index a951e86a..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/ActualizacaoSaveHandler.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * StampSaveHandler.java - * - * Created on 15 de Marco 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/ActualizacaoSaveable.java b/trunk/SIPRPSoft/src/siprp/data/ActualizacaoSaveable.java deleted file mode 100644 index 87d79372..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/ActualizacaoSaveable.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * ActualizacaoSaveable.java - * - * Created on 15 de Marco de 2005, 15:32 - */ - -package siprp.data; - -/** - * - * @author fpalma - */ -public interface ActualizacaoSaveable -{ - public static final String ACTUALIZACAO = "actualizacao"; -} diff --git a/trunk/SIPRPSoft/src/siprp/data/Aviso.java b/trunk/SIPRPSoft/src/siprp/data/Aviso.java deleted file mode 100644 index 791fad87..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/Aviso.java +++ /dev/null @@ -1,186 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/AvisoConstants.java b/trunk/SIPRPSoft/src/siprp/data/AvisoConstants.java deleted file mode 100644 index 1f8ca61f..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/AvisoConstants.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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; -} diff --git a/trunk/SIPRPSoft/src/siprp/data/AvisoData.java b/trunk/SIPRPSoft/src/siprp/data/AvisoData.java deleted file mode 100644 index dace2057..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/AvisoData.java +++ /dev/null @@ -1,68 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/AvisoID.java b/trunk/SIPRPSoft/src/siprp/data/AvisoID.java deleted file mode 100644 index 9a7cfb3f..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/AvisoID.java +++ /dev/null @@ -1,22 +0,0 @@ -/* -* 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/Contacto.java b/trunk/SIPRPSoft/src/siprp/data/Contacto.java deleted file mode 100644 index 38941701..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/Contacto.java +++ /dev/null @@ -1,152 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/ContactoData.java b/trunk/SIPRPSoft/src/siprp/data/ContactoData.java deleted file mode 100644 index a3fd1829..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/ContactoData.java +++ /dev/null @@ -1,63 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/ContactoID.java b/trunk/SIPRPSoft/src/siprp/data/ContactoID.java deleted file mode 100644 index a142d5ef..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/ContactoID.java +++ /dev/null @@ -1,22 +0,0 @@ -/* -* 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/DisableDeleteHandler.java b/trunk/SIPRPSoft/src/siprp/data/DisableDeleteHandler.java deleted file mode 100644 index d6f2650e..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/DisableDeleteHandler.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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; - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/data/DisableDeleteable.java b/trunk/SIPRPSoft/src/siprp/data/DisableDeleteable.java deleted file mode 100644 index b3ba4e52..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/DisableDeleteable.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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"; -} diff --git a/trunk/SIPRPSoft/src/siprp/data/Empresa.java b/trunk/SIPRPSoft/src/siprp/data/Empresa.java deleted file mode 100644 index 7a64f2dc..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/Empresa.java +++ /dev/null @@ -1,747 +0,0 @@ -/* -* Empresa.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on 17/Mai/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 inicio_contrato; - private Integer duracao; - 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.INICIO_CONTRATO ) - { - return inicio_contrato; - } - else if( fieldName == EmpresaData.DURACAO ) - { - return duracao; - } - 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.INICIO_CONTRATO ) ) - { - return inicio_contrato; - } - else if( fieldName.equals( EmpresaData.DURACAO ) ) - { - return duracao; - } - 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.INICIO_CONTRATO ) - { - inicio_contrato = ( Date ) value; - } - else if( fieldName == EmpresaData.DURACAO ) - { - duracao = ( Integer ) 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.INICIO_CONTRATO ) ) - { - inicio_contrato = ( Date ) value; - } - else if( fieldName.equals( EmpresaData.DURACAO ) ) - { - duracao = ( Integer ) 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/EmpresaData.java b/trunk/SIPRPSoft/src/siprp/data/EmpresaData.java deleted file mode 100644 index 437a7f72..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/EmpresaData.java +++ /dev/null @@ -1,114 +0,0 @@ -/* -* EmpresaData.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on 17/Mai/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 INICIO_CONTRATO = "inicio_contrato"; - public static final String DURACAO = "duracao"; - 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, INICIO_CONTRATO, DURACAO, 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, INICIO_CONTRATO, DURACAO, 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/EmpresaID.java b/trunk/SIPRPSoft/src/siprp/data/EmpresaID.java deleted file mode 100644 index ddee27c0..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/EmpresaID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* EmpresaID.java -* -* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on 17/Mai/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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/Estabelecimento.java b/trunk/SIPRPSoft/src/siprp/data/Estabelecimento.java deleted file mode 100644 index e14be8da..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/Estabelecimento.java +++ /dev/null @@ -1,220 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/EstabelecimentoData.java b/trunk/SIPRPSoft/src/siprp/data/EstabelecimentoData.java deleted file mode 100644 index e11cfb6b..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/EstabelecimentoData.java +++ /dev/null @@ -1,69 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/EstabelecimentoID.java b/trunk/SIPRPSoft/src/siprp/data/EstabelecimentoID.java deleted file mode 100644 index 3824759b..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/EstabelecimentoID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/Etiqueta.java b/trunk/SIPRPSoft/src/siprp/data/Etiqueta.java deleted file mode 100644 index 7a35bb38..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/Etiqueta.java +++ /dev/null @@ -1,270 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/EtiquetaData.java b/trunk/SIPRPSoft/src/siprp/data/EtiquetaData.java deleted file mode 100644 index 8d244d95..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/EtiquetaData.java +++ /dev/null @@ -1,74 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/EtiquetaID.java b/trunk/SIPRPSoft/src/siprp/data/EtiquetaID.java deleted file mode 100644 index d014ef55..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/EtiquetaID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/Exame.java b/trunk/SIPRPSoft/src/siprp/data/Exame.java deleted file mode 100644 index 58ade49b..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/Exame.java +++ /dev/null @@ -1,322 +0,0 @@ -/* -* 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 byte[] fo; - 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.FO ) - { - return fo; - } - 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.FO ) ) - { - return fo; - } - 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.FO ) - { - fo = ( 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.FO ) ) - { - fo = ( byte[] ) value; - } - else if( fieldName.equals( ExameData.INACTIVO ) ) - { - inactivo = ( String ) value; - } - } - - public Class getOuterClass() - { - return ExameData.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/ExameData.java b/trunk/SIPRPSoft/src/siprp/data/ExameData.java deleted file mode 100644 index ffc17877..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/ExameData.java +++ /dev/null @@ -1,78 +0,0 @@ -/* -* 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 FO = "fo"; - 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, FO, }; - - - 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, FO, 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/ExameID.java b/trunk/SIPRPSoft/src/siprp/data/ExameID.java deleted file mode 100644 index 3fc144de..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/ExameID.java +++ /dev/null @@ -1,22 +0,0 @@ -/* -* 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/Historico.java b/trunk/SIPRPSoft/src/siprp/data/Historico.java deleted file mode 100644 index 3a641ee1..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/Historico.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/HistoricoEstabelecimento.java b/trunk/SIPRPSoft/src/siprp/data/HistoricoEstabelecimento.java deleted file mode 100644 index 0bd186b8..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/HistoricoEstabelecimento.java +++ /dev/null @@ -1,101 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/HistoricoEstabelecimentoData.java b/trunk/SIPRPSoft/src/siprp/data/HistoricoEstabelecimentoData.java deleted file mode 100644 index 38f82221..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/HistoricoEstabelecimentoData.java +++ /dev/null @@ -1,60 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/HistoricoEstabelecimentoID.java b/trunk/SIPRPSoft/src/siprp/data/HistoricoEstabelecimentoID.java deleted file mode 100644 index 1513d1bc..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/HistoricoEstabelecimentoID.java +++ /dev/null @@ -1,22 +0,0 @@ -/* -* 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/Marcacao.java b/trunk/SIPRPSoft/src/siprp/data/Marcacao.java deleted file mode 100644 index 5302e965..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/Marcacao.java +++ /dev/null @@ -1,352 +0,0 @@ -/* - * 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 int ESTADO_POR_REALIZAR = 0; - public static final int ESTADO_PARCIALMENTE_REALIZADA = 1; - public static final int ESTADO_REALIZADA = 2; - public static final int ESTADO_DESMARCADA_TRABALHADOR = 3; - public static final int ESTADO_DESMARCADA_SHST = 4; - public static final int ESTADO_FALTOU = 5; - - 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; -// } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoEmpresa.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoEmpresa.java deleted file mode 100644 index 1f32cac8..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/MarcacaoEmpresa.java +++ /dev/null @@ -1,118 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoEmpresaData.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoEmpresaData.java deleted file mode 100644 index 54921f1f..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/MarcacaoEmpresaData.java +++ /dev/null @@ -1,61 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoEmpresaID.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoEmpresaID.java deleted file mode 100644 index 8b074d13..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/MarcacaoEmpresaID.java +++ /dev/null @@ -1,22 +0,0 @@ -/* -* 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoEstabelecimento.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoEstabelecimento.java deleted file mode 100644 index 16f5fca4..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/MarcacaoEstabelecimento.java +++ /dev/null @@ -1,186 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoEstabelecimentoData.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoEstabelecimentoData.java deleted file mode 100644 index 4c8551ca..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/MarcacaoEstabelecimentoData.java +++ /dev/null @@ -1,67 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoEstabelecimentoID.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoEstabelecimentoID.java deleted file mode 100644 index 36240581..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/MarcacaoEstabelecimentoID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoListLoader.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoListLoader.java deleted file mode 100644 index c966c222..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/MarcacaoListLoader.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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; - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoSaveAndDeleteHandler.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoSaveAndDeleteHandler.java deleted file mode 100644 index c8df3dc6..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/MarcacaoSaveAndDeleteHandler.java +++ /dev/null @@ -1,258 +0,0 @@ -/* -* 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.deleteDetalhesRealizadosForMarcacao( ( 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhador.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhador.java deleted file mode 100644 index a4af4d07..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhador.java +++ /dev/null @@ -1,203 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhadorConstants.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhadorConstants.java deleted file mode 100644 index e0096a87..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhadorConstants.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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; -} diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhadorData.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhadorData.java deleted file mode 100644 index 67273b67..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhadorData.java +++ /dev/null @@ -1,69 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhadorID.java b/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhadorID.java deleted file mode 100644 index 7dc15955..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/MarcacaoTrabalhadorID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/Medico.java b/trunk/SIPRPSoft/src/siprp/data/Medico.java deleted file mode 100644 index a9c4785e..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/Medico.java +++ /dev/null @@ -1,100 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/MedicoData.java b/trunk/SIPRPSoft/src/siprp/data/MedicoData.java deleted file mode 100644 index 6e385ce8..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/MedicoData.java +++ /dev/null @@ -1,61 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/MedicoID.java b/trunk/SIPRPSoft/src/siprp/data/MedicoID.java deleted file mode 100644 index 8c13efb7..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/MedicoID.java +++ /dev/null @@ -1,22 +0,0 @@ -/* -* 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/SearchExecuterFactory.java b/trunk/SIPRPSoft/src/siprp/data/SearchExecuterFactory.java deleted file mode 100644 index e011144d..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/SearchExecuterFactory.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/TecnicoHST.java b/trunk/SIPRPSoft/src/siprp/data/TecnicoHST.java deleted file mode 100644 index 352d6096..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/TecnicoHST.java +++ /dev/null @@ -1,134 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/TecnicoHSTData.java b/trunk/SIPRPSoft/src/siprp/data/TecnicoHSTData.java deleted file mode 100644 index 1d70e935..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/TecnicoHSTData.java +++ /dev/null @@ -1,63 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/TecnicoHSTID.java b/trunk/SIPRPSoft/src/siprp/data/TecnicoHSTID.java deleted file mode 100644 index f7f90bd4..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/TecnicoHSTID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/Trabalhador.java b/trunk/SIPRPSoft/src/siprp/data/Trabalhador.java deleted file mode 100644 index e7da2172..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/Trabalhador.java +++ /dev/null @@ -1,356 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/TrabalhadorData.java b/trunk/SIPRPSoft/src/siprp/data/TrabalhadorData.java deleted file mode 100644 index 396b512f..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/TrabalhadorData.java +++ /dev/null @@ -1,82 +0,0 @@ -/* -* 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/TrabalhadorID.java b/trunk/SIPRPSoft/src/siprp/data/TrabalhadorID.java deleted file mode 100644 index 6f37784d..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/TrabalhadorID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/data/package.jdo b/trunk/SIPRPSoft/src/siprp/data/package.jdo deleted file mode 100644 index 6911c812..00000000 --- a/trunk/SIPRPSoft/src/siprp/data/package.jdo +++ /dev/null @@ -1,1122 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaDataProvider.java b/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaDataProvider.java deleted file mode 100644 index 935afc49..00000000 --- a/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaDataProvider.java +++ /dev/null @@ -1,777 +0,0 @@ -/* - * 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ã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; - } - - - -} - diff --git a/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaWindow.java b/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaWindow.java deleted file mode 100644 index eb4fed2f..00000000 --- a/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaWindow.java +++ /dev/null @@ -1,1324 +0,0 @@ -/* - * EstatisticaWindow.java - * - * Created on 16 de Dezembro de 2004, 13:50 - */ - -package siprp.estatistica; - -import java.awt.*; -import java.awt.event.*; -import java.io.*; -import javax.swing.*; -import javax.swing.event.*; -import java.text.*; -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.calendar.*; -import com.evolute.utils.ui.text.*; - -import siprp.data.*; -import siprp.pesquisas.*; -/** - * - * @author fpalma - */ -public class EstatisticaWindow extends JFrame - implements TrackableWindow, ListSelectionListener, ActionListener, ItemListener -{ - public static final DateFormat DF = DateFormat.getDateInstance( DateFormat.SHORT ); - - public static final int NONE = 0; - public static final int LISTAGEM_GERAL_MARCACOES_PERIODO = 1; - public static final int LISTAGEM_MARCACOES_PERIODO_EMPRESA_ESTABELECIMENTO = 2; - public static final int LISTAGEM_GLOBAL_TRABALHADORES_SEM_EXAMES = 3; - public static final int LISTAGEM_TRABALHADORES_SEM_EXAMES_EMPRESA_ESTABELECIMENTO = 4; - public static final int LISTAGEM_GLOBAL_TRABALHADORES_COM_EXAMES_PERIODO = 5; - public static final int LISTAGEM_TRABALHADORES_COM_EXAMES_PERIODO_EMPRESA_ESTABELECIMENTO = 6; - public static final int LISTAGEM_GLOBAL_TRABALHADORES_SEM_CONSULTA = 7; - public static final int LISTAGEM_TRABALHADORES_SEM_CONSULTA_EMPRESA_ESTABELECIMENTO = 8; - public static final int LISTAGEM_GLOBAL_TRABALHADORES_COM_CONSULTA_PERIODO = 9; - public static final int LISTAGEM_TRABALHADORES_COM_CONSULTA_PERIODO_EMPRESA_ESTABELECIMENTO = 10; - public static final int LISTAGEM_GLOBAL_TRABALHADORES_PERIODO = -1; - public static final int LISTAGEM_GLOBAL_HIGIENE_SEGURANCA = 11; - - public static final String ESTATISTICAS[] = - new String[]{ "", - "Marca\u00e7\u00f5es efectuadas e pendentes (geral)", - "Marca\u00e7\u00f5es efectuadas e pendentes (por Empresa e Estabelecimento)", - "Contagem global de trabalhadores que ainda n\u00e3o realizaram exames (por per\u00edodo)", - "Listagem de trabalhadores que ainda n\u00e3o realizaram exames (por per\u00edodo, Empresa e Estabelecimento)", - "Contagem global de trabalhadores que j\u00e1 realizaram exames (por per\u00edodo)", - "Listagem de trabalhadores que j\u00e1 realizaram exames (por per\u00edodo, Empresa e Estabelecimento)", - "Contagem global de trabalhadores que ainda n\u00e3o realizaram consultas (por per\u00edodo)", - "Listagem de trabalhadores que ainda n\u00e3o realizaram consultas (por per\u00edodo, Empresa e Estabelecimento)", - "Contagem global de trabalhadores que j\u00e1 realizaram consultas (por per\u00edodo)", - "Listagem de trabalhadores que j\u00e1 realizaram consultas (por per\u00edodo, Empresa e Estabelecimento)", - //"Listagem global de trabalhadores (por per\u00edodo)", - "Listagem global com os dados de higiene e seguran\u00e7a" }; - - - public static final int OPTION_INTERVALO = 0; - public static final int OPTION_ANO = 1; - public static final int OPTION_EMPRESA = 2; - public static final int OPTION_ESTABELECIMENTO = 0; - - public static final boolean ESTATISTICAS_OPTIONS[][] = - // intervalo, ano, empresa, estabelecimento - new boolean[][]{ { false, false, false, false }, - { true, false, false, false }, - { true, false, true, true }, - { true, false, false, false }, - { true, false, true, true }, - { true, false, false, false }, - { true, false, true, true }, - { true, false, false, false }, - { true, false, true, true }, - { true, false, false, false }, - { true, false, true, true }, -// { true, false, false, false }, - { false, false, false, false } }; - - private JDOProvider JDO; - private EstatisticaDataProvider provider; - private PesquisasProvider pesquisasProvider; - - private JComboBox estatisticaCombo; - private JCalendarPanel dataInicioPanel; - private JCalendarPanel dataFimPanel; - private JTextField anoText; - private BaseTable empresasTable; - private VectorTableModel empresasModel; - private BaseTable estabelecimentosTable; - private VectorTableModel estabelecimentosModel; - private JButton pesquisarButton; - private JButton excelButton; - private JEditorPane resultadoText; - - /** Creates a new instance of EstatisticaWindow */ - public EstatisticaWindow() - throws Exception - { - provider = (EstatisticaDataProvider)EstatisticaDataProvider.getProvider(); - pesquisasProvider = (PesquisasProvider)PesquisasProvider.getProvider(); - JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); - setupComponents(); - } - - private void setupComponents() - { - setSize( 1000, 700 ); - setTitle( "Listagens" ); - - JLabel estatisticaLabel = new JLabel( "Listagem" ); - estatisticaCombo = new JComboBox(); - for( int n = 0; n < ESTATISTICAS.length; n++ ) - { - estatisticaCombo.addItem( ESTATISTICAS[ n ] ); - } - estatisticaCombo.setSelectedIndex( 0 ); - estatisticaCombo.addItemListener( this ); - estatisticaCombo.setPreferredSize( new Dimension( 700, 20 ) ); - JLabel intervalo1Label = new JLabel( "De" ); - JLabel intervalo2Label = new JLabel( "a" ); - dataInicioPanel = new JCalendarPanel( null ); - dataInicioPanel.setPreferredSize( new Dimension( 200, 20 ) ); - dataFimPanel = new JCalendarPanel( null ); - dataFimPanel.setPreferredSize( new Dimension( 200, 20 ) ); - - 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 ); - excelButton = new JButton( "Exportar" ); - excelButton.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_ALWAYS ); - 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 escolhaEstatisticaPanel = new JPanel(); - escolhaEstatisticaPanel.setLayout( new FlowLayout( FlowLayout.LEFT ) ); - escolhaEstatisticaPanel.add( estatisticaLabel ); - escolhaEstatisticaPanel.add( estatisticaCombo ); - gridbag.setConstraints( escolhaEstatisticaPanel, constraints ); - getContentPane().add( escolhaEstatisticaPanel ); - - JPanel periodoPanel = new JPanel(); - periodoPanel.setLayout( new FlowLayout( FlowLayout.LEFT ) ); - periodoPanel.add( intervalo1Label ); - periodoPanel.add( dataInicioPanel ); - periodoPanel.add( intervalo2Label ); - periodoPanel.add( dataFimPanel ); - gridbag.setConstraints( periodoPanel, constraints ); - getContentPane().add( periodoPanel ); - - 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, 1 ) ); - buttonPanel.add( pesquisarButton ); - buttonPanel.add( excelButton ); - 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 ); - - processarEscolha(); - } - - public void actionPerformed(java.awt.event.ActionEvent e) - { - Object source = e.getSource(); - if( source.equals( pesquisarButton ) ) - { - int index = estatisticaCombo.getSelectedIndex(); - switch( index ) - { - case LISTAGEM_GERAL_MARCACOES_PERIODO: - listagemGeralMarcacoesPeriodo(); - break; - - case LISTAGEM_MARCACOES_PERIODO_EMPRESA_ESTABELECIMENTO: - listagemMarcacoesPeriodoEmpresaEstabelecimento(); - break; - - case LISTAGEM_GLOBAL_TRABALHADORES_SEM_EXAMES: - listagemGeralTrabalhadoresSemExamesOuConsultas( true ); - break; - - case LISTAGEM_TRABALHADORES_SEM_EXAMES_EMPRESA_ESTABELECIMENTO: - listagemTrabalhadoresSemExamesOuConsultasEmpresaEstabelecimento( true ); - break; - - case LISTAGEM_GLOBAL_TRABALHADORES_COM_EXAMES_PERIODO: - listagemGeralTrabalhadoresComExamesOuConsultasPeriodo( true ); - break; - - case LISTAGEM_TRABALHADORES_COM_EXAMES_PERIODO_EMPRESA_ESTABELECIMENTO: - listagemGeralTrabalhadoresComExamesOuConsultasPeriodoEmpresaEstabelecimento( true ); - break; - - case LISTAGEM_GLOBAL_TRABALHADORES_SEM_CONSULTA: - listagemGeralTrabalhadoresSemExamesOuConsultas( false ); - break; - - case LISTAGEM_TRABALHADORES_SEM_CONSULTA_EMPRESA_ESTABELECIMENTO: - listagemTrabalhadoresSemExamesOuConsultasEmpresaEstabelecimento( false ); - break; - - case LISTAGEM_GLOBAL_TRABALHADORES_COM_CONSULTA_PERIODO: - listagemGeralTrabalhadoresComExamesOuConsultasPeriodo( false ); - break; - - case LISTAGEM_TRABALHADORES_COM_CONSULTA_PERIODO_EMPRESA_ESTABELECIMENTO: - listagemGeralTrabalhadoresComExamesOuConsultasPeriodoEmpresaEstabelecimento( false ); - break; - - case LISTAGEM_GLOBAL_TRABALHADORES_PERIODO: - listagemGeralTrabalhadoresPeriodo(); - break; - - case LISTAGEM_GLOBAL_HIGIENE_SEGURANCA: - listagemGlobalHigieneSeguranca(); - break; - } - } - else if( source.equals( excelButton ) ) - { - exportar(); - } - } - - private boolean close() - { - setVisible( false ); - dispose(); - return true; - } - - public boolean closeIfPossible() - { - return close(); - } - - public void open() - { - empresasTable.clearSelection(); - estatisticaCombo.setSelectedIndex( 0 ); - try - { - IDObject empresas[] = pesquisasProvider.getAllEmpresas(); - empresasModel.setValues( new Vector( Arrays.asList( empresas ) ) ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar dados", true ); - } - setVisible( true ); - } - - public void refresh() - { - setVisible( true ); - } - - public void valueChanged(javax.swing.event.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 = pesquisasProvider.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 ); - } - } - - public void itemStateChanged(java.awt.event.ItemEvent itemEvent) - { - processarEscolha(); - } - - protected void processarEscolha() - { - int index = estatisticaCombo.getSelectedIndex(); - boolean optionLine[] = ESTATISTICAS_OPTIONS[ index ]; - dataInicioPanel.setEnabled( optionLine[ OPTION_INTERVALO ] ); - dataFimPanel.setEnabled( optionLine[ OPTION_INTERVALO ] ); - anoText.setEnabled( optionLine[ OPTION_ANO ] ); - empresasTable.setEnabled( optionLine[ OPTION_EMPRESA ] ); - estabelecimentosTable.setEnabled( optionLine[ OPTION_ESTABELECIMENTO ] ); - pesquisarButton.setEnabled( index != NONE ); - } - - protected void listagemGeralMarcacoesPeriodo() - { - try - { - Date inicio = dataInicioPanel.getDate(); - Date fim = dataFimPanel.getDate(); - if( inicio == null || fim == null ) - { - JOptionPane.showMessageDialog( this, "Tem de escolher o intervalo de datas.", "Erro...", - JOptionPane.ERROR_MESSAGE ); - resultadoText.setText( "ERRO!" ); - return; - } - if( inicio.after( fim ) ) - { - JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...", - JOptionPane.ERROR_MESSAGE ); - resultadoText.setText( "ERRO!" ); - return; - } - StringBuffer buffer = new StringBuffer(); - int exames = provider.countExamesPeriodo( inicio, fim ); - int consultas = provider.countConsultasPeriodo( inicio, fim ); - int total = exames + consultas; - buffer.append( "

" ); - buffer.append( "" + ESTATISTICAS[ LISTAGEM_GERAL_MARCACOES_PERIODO ] + "" ); - buffer.append( "

" ); - buffer.append( "
" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "
" ); - buffer.append( "PER\u00cdODO:" ); - buffer.append( "" ); - buffer.append( "" + DF.format( dataInicioPanel.getDate() ) + " a " - + DF.format( dataFimPanel.getDate() ) + "" ); - buffer.append( "
" ); - buffer.append( "EXAMES:" ); - buffer.append( "" ); - buffer.append( "" + exames + "" ); - buffer.append( "
" ); - buffer.append( "CONSULTAS:" ); - buffer.append( "" ); - buffer.append( "" + consultas + "" ); - buffer.append( "
" ); - buffer.append( "TOTAL:" ); - buffer.append( "" ); - buffer.append( "" + ( exames + consultas ) + "" ); - buffer.append( "
" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - String data[][] = provider.getMarcacoesPeriodo( inicio, fim ); - for( int l = 0; l < data.length; l++ ) - { - buffer.append( "" ); - for( int c = 0; c < data[ l ].length; c++ ) - { - buffer.append( "" ); - buffer.append( "" ); - } - buffer.append( "" ); - } - buffer.append( "
" ); - buffer.append( "EMPRESA" ); - buffer.append( "" ); - buffer.append( "NOME" ); - buffer.append( "" ); - buffer.append( "ESTABELECIMENTO" ); - buffer.append( "" ); - buffer.append( "DATA" ); - buffer.append( "" ); - buffer.append( " " ); - buffer.append( "
" ); - buffer.append( "" + data[ l ][ c ] + "" ); - buffer.append( "
" ); - resultadoText.setText( buffer.toString() ); - } - catch( Exception ex ) - { - resultadoText.setText( "ERRO a carregar dados!" ); - ex.printStackTrace(); - } - } - - protected void listagemMarcacoesPeriodoEmpresaEstabelecimento() - { - try - { - Date inicio = dataInicioPanel.getDate(); - Date fim = dataFimPanel.getDate(); - int sEmpresa = empresasTable.getSelectedRow(); - int sEstabelecimento = estabelecimentosTable.getSelectedRow(); - if( inicio == null || fim == null || sEmpresa == -1 ) - { - JOptionPane.showMessageDialog( this, "Tem de escolher Empresa e intervalo de datas.", "Erro...", - JOptionPane.ERROR_MESSAGE ); - resultadoText.setText( "ERRO!" ); - return; - } - if( inicio.after( fim ) ) - { - JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...", - JOptionPane.ERROR_MESSAGE ); - resultadoText.setText( "ERRO!" ); - return; - } - StringBuffer buffer = new StringBuffer(); - Integer idEmpresa = ( (IDObject)empresasModel.getRowAt( sEmpresa ) ).getID(); - EmpresaData empresa = (EmpresaData)JDO.load( EmpresaData.class, idEmpresa ); - String designacao = (String)empresa.get( EmpresaData.DESIGNACAO_SOCIAL ); - IDObject estabelecimentos[]; - if( sEstabelecimento == -1 || ( ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento ) ).getID().equals( new Integer( -1 ) ) ) - { - estabelecimentos = pesquisasProvider.getAllEstabelecimentosForEmpresa( idEmpresa ); - } - else - { - estabelecimentos = new IDObject[ 1 ]; - estabelecimentos[ 0 ] = ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento ); - } - int examesEmpresa = provider.countExamesPeriodoForEmpresa( inicio, fim, idEmpresa ); - int consultasEmpresa = provider.countConsultasPeriodoForEmpresa( inicio, fim, idEmpresa ); - buffer.append( "

" ); - buffer.append( "" + ESTATISTICAS[ LISTAGEM_MARCACOES_PERIODO_EMPRESA_ESTABELECIMENTO ] + "" ); - buffer.append( "

" ); - buffer.append( "
" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "
" ); - buffer.append( "EMPRESA:" ); - buffer.append( "" ); - buffer.append( "" + designacao + "" ); - buffer.append( "
" ); - buffer.append( "PER\u00cdODO:" ); - buffer.append( "" ); - buffer.append( "" + DF.format( dataInicioPanel.getDate() ) + " a " - + DF.format( dataFimPanel.getDate() ) + "" ); - buffer.append( "
" ); - buffer.append( "EXAMES:" ); - buffer.append( "" ); - buffer.append( "" + examesEmpresa + "" ); - buffer.append( "
" ); - buffer.append( "CONSULTAS:" ); - buffer.append( "" ); - buffer.append( "" + consultasEmpresa + "" ); - buffer.append( "
" ); - buffer.append( "TOTAL:" ); - buffer.append( "" ); - buffer.append( "" + ( examesEmpresa + consultasEmpresa ) + "" ); - buffer.append( "
" ); - for( int e = 0; e < estabelecimentos.length; e++ ) - { - EstabelecimentoData estabelecimento = (EstabelecimentoData)JDO.load( EstabelecimentoData.class, estabelecimentos[ e ].getID() ); - String nome = (String)estabelecimento.get( EstabelecimentoData.NOME ); - int exames = provider.countExamesPeriodoForEstabelecimento( inicio, fim, estabelecimentos[ e ].getID() ); - int consultas = provider.countConsultasPeriodoForEstabelecimento( inicio, fim, estabelecimentos[ e ].getID() ); - int total = exames + consultas; - buffer.append( "



" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "
" ); - buffer.append( "ESTABELECIMENTO:" ); - buffer.append( "" ); - buffer.append( "" + nome + "" ); - buffer.append( "
" ); - buffer.append( "EXAMES:" ); - buffer.append( "" ); - buffer.append( "" + exames + "" ); - buffer.append( "
" ); - buffer.append( "CONSULTAS:" ); - buffer.append( "" ); - buffer.append( "" + consultas + "" ); - buffer.append( "
" ); - buffer.append( "TOTAL:" ); - buffer.append( "" ); - buffer.append( "" + ( exames + consultas ) + "" ); - buffer.append( "
" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - String data[][] = provider.getMarcacoesPeriodoForEstabelecimento( inicio, fim, estabelecimentos[ e ].getID() ); - for( int l = 0; l < data.length; l++ ) - { - buffer.append( "" ); - for( int c = 1; c < data[ l ].length; c++ ) - { - buffer.append( "" ); - buffer.append( "" ); - } - buffer.append( "" ); - } - buffer.append( "
" ); - buffer.append( "NOME" ); - buffer.append( "" ); - buffer.append( "ESTABELECIMENTO" ); - buffer.append( "" ); - buffer.append( "DATA" ); - buffer.append( "" ); - buffer.append( " " ); - buffer.append( "
" ); - buffer.append( "" + data[ l ][ c ] + "" ); - buffer.append( "
" ); - } - resultadoText.setText( buffer.toString() ); - } - catch( Exception ex ) - { - resultadoText.setText( "ERRO a carregar dados!" ); - ex.printStackTrace(); - } - } - - protected void listagemGeralTrabalhadoresSemExamesOuConsultas( boolean exames ) - { - try - { - Date inicio = dataInicioPanel.getDate(); - Date fim = dataFimPanel.getDate(); - if( inicio == null || fim == null ) - { - JOptionPane.showMessageDialog( this, "Tem de escolher o intervalo de datas.", "Erro...", - JOptionPane.ERROR_MESSAGE ); - resultadoText.setText( "ERRO!" ); - return; - } - if( inicio.after( fim ) ) - { - JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...", - JOptionPane.ERROR_MESSAGE ); - resultadoText.setText( "ERRO!" ); - return; - } - int count = provider.countTrabalhadoresSemExamesOuConsultas( inicio, fim, exames ); - //String data[][] = provider.getTrabalhadoresComExamesOuConsultasPeriodo( inicio, fim, exames ); - Object data[][] = provider.getCountTrabalhadoresSemExamesOuConsultasPeriodoForAllEmpresas( inicio, fim, exames ); - StringBuffer buffer = new StringBuffer(); - buffer.append( "

" ); - buffer.append( "" + ESTATISTICAS[ exames ? LISTAGEM_GLOBAL_TRABALHADORES_SEM_EXAMES : LISTAGEM_GLOBAL_TRABALHADORES_SEM_CONSULTA ] + "" ); - buffer.append( "

" ); - buffer.append( "
" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "
" ); - buffer.append( "PER\u00cdODO:" ); - buffer.append( "" ); - buffer.append( "" + DF.format( dataInicioPanel.getDate() ) + " a " - + DF.format( dataFimPanel.getDate() ) + "" ); - buffer.append( "
" ); - buffer.append( "TOTAL:" ); - buffer.append( "" ); - buffer.append( "" + count + "" ); - buffer.append( "
" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - for( int l = 0; l < data.length; l++ ) - { - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - } - buffer.append( "
" ); - buffer.append( "EMPRESA" ); - buffer.append( "" ); - buffer.append( "N\u00ba" ); - buffer.append( "
" ); - buffer.append( "" + data[ l ][ 0 ] + "" ); - buffer.append( "" ); - buffer.append( "" + data[ l ][ 1 ] + "" ); - buffer.append( "
" ); - resultadoText.setText( buffer.toString() ); - } - catch( Exception ex ) - { - resultadoText.setText( "ERRO a carregar dados!" ); - ex.printStackTrace(); - } - } - - protected void listagemTrabalhadoresSemExamesOuConsultasEmpresaEstabelecimento( boolean exames ) - { - try - { - Date inicio = dataInicioPanel.getDate(); - Date fim = dataFimPanel.getDate(); - if( inicio == null || fim == null ) - { - JOptionPane.showMessageDialog( this, "Tem de escolher o intervalo de datas.", "Erro...", - JOptionPane.ERROR_MESSAGE ); - resultadoText.setText( "ERRO!" ); - return; - } - if( inicio.after( fim ) ) - { - JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...", - JOptionPane.ERROR_MESSAGE ); - resultadoText.setText( "ERRO!" ); - return; - } - int sEmpresa = empresasTable.getSelectedRow(); - int sEstabelecimento = estabelecimentosTable.getSelectedRow(); - if( sEmpresa == -1 ) - { - JOptionPane.showMessageDialog( this, "Tem de escolher Empresa.", "Erro...", - JOptionPane.ERROR_MESSAGE ); - resultadoText.setText( "ERRO!" ); - return; - } - StringBuffer buffer = new StringBuffer(); - Integer idEmpresa = ( (IDObject)empresasModel.getRowAt( sEmpresa ) ).getID(); - EmpresaData empresa = (EmpresaData)JDO.load( EmpresaData.class, idEmpresa ); - String designacao = (String)empresa.get( EmpresaData.DESIGNACAO_SOCIAL ); - IDObject estabelecimentos[]; - if( sEstabelecimento == -1 || ( ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento ) ).getID().equals( new Integer( -1 ) ) ) - { - estabelecimentos = pesquisasProvider.getAllEstabelecimentosForEmpresa( idEmpresa ); - } - else - { - estabelecimentos = new IDObject[ 1 ]; - estabelecimentos[ 0 ] = ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento ); - } - int countEmpresa = provider.countTrabalhadoresSemExamesOuConsultasEmpresa( idEmpresa, inicio, fim, exames ); - buffer.append( "

" ); - buffer.append( "" + ESTATISTICAS[ exames ? LISTAGEM_TRABALHADORES_SEM_EXAMES_EMPRESA_ESTABELECIMENTO : LISTAGEM_TRABALHADORES_SEM_CONSULTA_EMPRESA_ESTABELECIMENTO ] + "" ); - buffer.append( "

" ); - buffer.append( "
" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "
" ); - buffer.append( "EMPRESA:" ); - buffer.append( "" ); - buffer.append( "" + designacao + "" ); - buffer.append( "
" ); - buffer.append( "Nº DE TRABALHADORES:" ); - buffer.append( "" ); - buffer.append( "" + countEmpresa + "" ); - buffer.append( "
" ); - for( int e = 0; e < estabelecimentos.length; e++ ) - { - EstabelecimentoData estabelecimento = (EstabelecimentoData)JDO.load( EstabelecimentoData.class, estabelecimentos[ e ].getID() ); - String nome = (String)estabelecimento.get( EstabelecimentoData.NOME ); - int countEstabelecimento = provider.countTrabalhadoresSemExamesOuConsultasEstabelecimento( estabelecimentos[ e ].getID(), inicio, fim, exames ); - buffer.append( "



" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "
" ); - buffer.append( "ESTABELECIMENTO:" ); - buffer.append( "" ); - buffer.append( "" + nome + "" ); - buffer.append( "
" ); - buffer.append( "Nº DE TRABALHADORES:" ); - buffer.append( "" ); - buffer.append( "" + countEstabelecimento + "" ); - buffer.append( "
" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - String data[][] = provider.getTrabalhadoresSemExamesOuConsultasEstabelecimento( estabelecimentos[ e ].getID(), inicio, fim, exames ); - for( int l = 0; l < data.length; l++ ) - { - buffer.append( "" ); - for( int c = 0; c < data[ l ].length; c++ ) - { - buffer.append( "" ); - buffer.append( "" ); - } - buffer.append( "" ); - } - buffer.append( "
" ); - buffer.append( "ESTABELECIMENTO" ); - buffer.append( "" ); - buffer.append( "NOME" ); - buffer.append( "
" ); - buffer.append( "" + data[ l ][ c ] + "" ); - buffer.append( "
" ); - } - resultadoText.setText( buffer.toString() ); - } - catch( Exception ex ) - { - resultadoText.setText( "ERRO a carregar dados!" ); - ex.printStackTrace(); - } - } - - protected void listagemGeralTrabalhadoresComExamesOuConsultasPeriodo( boolean exames ) - { - try - { - Date inicio = dataInicioPanel.getDate(); - Date fim = dataFimPanel.getDate(); - if( inicio == null || fim == null ) - { - JOptionPane.showMessageDialog( this, "Tem de escolher o intervalo de datas.", "Erro...", - JOptionPane.ERROR_MESSAGE ); - resultadoText.setText( "ERRO!" ); - return; - } - if( inicio.after( fim ) ) - { - JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...", - JOptionPane.ERROR_MESSAGE ); - resultadoText.setText( "ERRO!" ); - return; - } - int count = provider.countTrabalhadoresComExamesOuConsultasPeriodo( inicio, fim, exames ); - //String data[][] = provider.getTrabalhadoresComExamesOuConsultasPeriodo( inicio, fim, exames ); - Object data[][] = provider.getCountTrabalhadoresComExamesOuConsultasPeriodoForAllEmpresas( inicio, fim, exames ); - StringBuffer buffer = new StringBuffer(); - buffer.append( "

" ); - buffer.append( "" + ESTATISTICAS[ exames ? LISTAGEM_GLOBAL_TRABALHADORES_COM_EXAMES_PERIODO : LISTAGEM_GLOBAL_TRABALHADORES_COM_CONSULTA_PERIODO ] + "" ); - buffer.append( "

" ); - buffer.append( "
" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "
" ); - buffer.append( "PER\u00cdODO:" ); - buffer.append( "" ); - buffer.append( "" + DF.format( dataInicioPanel.getDate() ) + " a " - + DF.format( dataFimPanel.getDate() ) + "" ); - buffer.append( "
" ); - buffer.append( "TOTAL:" ); - buffer.append( "" ); - buffer.append( "" + count + "" ); - buffer.append( "
" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - for( int l = 0; l < data.length; l++ ) - { - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - } - buffer.append( "
" ); - buffer.append( "EMPRESA" ); - buffer.append( "" ); - buffer.append( "N\u00ba" ); - buffer.append( "
" ); - buffer.append( "" + data[ l ][ 0 ] + "" ); - buffer.append( "" ); - buffer.append( "" + data[ l ][ 1 ] + "" ); - buffer.append( "
" ); - resultadoText.setText( buffer.toString() ); - } - catch( Exception ex ) - { - resultadoText.setText( "ERRO a carregar dados!" ); - ex.printStackTrace(); - } - } - - protected void listagemGeralTrabalhadoresComExamesOuConsultasPeriodoEmpresaEstabelecimento( boolean exames ) - { - try - { - Date inicio = dataInicioPanel.getDate(); - Date fim = dataFimPanel.getDate(); - int sEmpresa = empresasTable.getSelectedRow(); - int sEstabelecimento = estabelecimentosTable.getSelectedRow(); - if( inicio == null || fim == null || sEmpresa == -1 ) - { - JOptionPane.showMessageDialog( this, "Tem de escolher Empresa e intervalo de datas.", "Erro...", - JOptionPane.ERROR_MESSAGE ); - resultadoText.setText( "ERRO!" ); - return; - } - if( inicio.after( fim ) ) - { - JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...", - JOptionPane.ERROR_MESSAGE ); - resultadoText.setText( "ERRO!" ); - return; - } - StringBuffer buffer = new StringBuffer(); - Integer idEmpresa = ( (IDObject)empresasModel.getRowAt( sEmpresa ) ).getID(); - EmpresaData empresa = (EmpresaData)JDO.load( EmpresaData.class, idEmpresa ); - String designacao = (String)empresa.get( EmpresaData.DESIGNACAO_SOCIAL ); - IDObject estabelecimentos[]; - if( sEstabelecimento == -1 || ( ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento ) ).getID().equals( new Integer( -1 ) ) ) - { - estabelecimentos = pesquisasProvider.getAllEstabelecimentosForEmpresa( idEmpresa ); - } - else - { - estabelecimentos = new IDObject[ 1 ]; - estabelecimentos[ 0 ] = ( IDObject )estabelecimentosModel.getRowAt( sEstabelecimento ); - } - int countEmpresa = provider.countTrabalhadoresComExamesOuConsultasPeriodoForEmpresa( inicio, fim, idEmpresa, exames ); - buffer.append( "

" ); - buffer.append( "" + ESTATISTICAS[ exames ? LISTAGEM_TRABALHADORES_COM_EXAMES_PERIODO_EMPRESA_ESTABELECIMENTO : LISTAGEM_TRABALHADORES_COM_CONSULTA_PERIODO_EMPRESA_ESTABELECIMENTO ] + "" ); - buffer.append( "

" ); - buffer.append( "
" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - - buffer.append( "
" ); - buffer.append( "EMPRESA:" ); - buffer.append( "" ); - buffer.append( "" + designacao + "" ); - buffer.append( "
" ); - buffer.append( "PER\u00cdODO:" ); - buffer.append( "" ); - buffer.append( "" + DF.format( dataInicioPanel.getDate() ) + " a " - + DF.format( dataFimPanel.getDate() ) + "" ); - buffer.append( "
" ); - buffer.append( "Nº:" ); - buffer.append( "" ); - buffer.append( "" + countEmpresa + "" ); - buffer.append( "
" ); - for( int e = 0; e < estabelecimentos.length; e++ ) - { - EstabelecimentoData estabelecimento = (EstabelecimentoData)JDO.load( EstabelecimentoData.class, estabelecimentos[ e ].getID() ); - String nome = (String)estabelecimento.get( EstabelecimentoData.NOME ); - int countEstabelecimento = provider.countTrabalhadoresComExamesOuConsultasPeriodoForEstabelecimento( inicio, fim, estabelecimentos[ e ].getID(), exames ); - buffer.append( "



" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "
" ); - buffer.append( "ESTABELECIMENTO:" ); - buffer.append( "" ); - buffer.append( "" + nome + "" ); - buffer.append( "
" ); - buffer.append( "Nº:" ); - buffer.append( "" ); - buffer.append( "" + countEstabelecimento + "" ); - buffer.append( "
" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - String data[][] = provider.getTrabalhadoresComExamesOuConsultasPeriodoForEstabelecimento( inicio, fim, estabelecimentos[ e ].getID(), exames ); - for( int l = 0; l < data.length; l++ ) - { - buffer.append( "" ); - for( int c = 0; c < data[ l ].length; c++ ) - { - buffer.append( "" ); - buffer.append( "" ); - } - buffer.append( "" ); - } - buffer.append( "
" ); - buffer.append( "ESTABELECIMENTO" ); - buffer.append( "" ); - buffer.append( "NOME" ); - buffer.append( "
" ); - buffer.append( "" + data[ l ][ c ] + "" ); - buffer.append( "
" ); - } - resultadoText.setText( buffer.toString() ); - } - catch( Exception ex ) - { - resultadoText.setText( "ERRO a carregar dados!" ); - ex.printStackTrace(); - } - } - - protected void listagemGeralTrabalhadoresPeriodo() - { - try - { - Date inicio = dataInicioPanel.getDate(); - Date fim = dataFimPanel.getDate(); - if( inicio == null || fim == null ) - { - JOptionPane.showMessageDialog( this, "Tem de escolher o intervalo de datas.", "Erro...", - JOptionPane.ERROR_MESSAGE ); - resultadoText.setText( "ERRO!" ); - return; - } - if( inicio.after( fim ) ) - { - JOptionPane.showMessageDialog( this, "A data de in\u00edcio tem de ser inferior \u00e0 de fim..", "Erro...", - JOptionPane.ERROR_MESSAGE ); - resultadoText.setText( "ERRO!" ); - return; - } - StringBuffer buffer = new StringBuffer(); - buffer.append( "

" ); - buffer.append( "" + ESTATISTICAS[ LISTAGEM_GLOBAL_TRABALHADORES_PERIODO ] + "" ); - buffer.append( "

" ); - buffer.append( "
" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "
" ); - buffer.append( "PER\u00cdODO:" ); - buffer.append( "" ); - buffer.append( "" + DF.format( dataInicioPanel.getDate() ) + " a " - + DF.format( dataFimPanel.getDate() ) + "" ); - buffer.append( "
" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - String data[][] = provider.getDadosTrabalhadoresPeriodo( inicio, fim ); - for( int l = 0; l < data.length; l++ ) - { - buffer.append( "" ); - for( int c = 0; c < data[ l ].length; c++ ) - { - buffer.append( "" ); - buffer.append( "" ); - } - buffer.append( "" ); - } - buffer.append( "
" ); - buffer.append( "EMPRESA" ); - buffer.append( "" ); - buffer.append( "ESTABELECIMENTO" ); - buffer.append( "" ); - buffer.append( "NOME" ); - buffer.append( "" ); - buffer.append( "ÚLTIMO EXAME" ); - buffer.append( "" ); - buffer.append( "ESTADO" ); - buffer.append( "" ); - buffer.append( "ÚLTIMA CONSULTA" ); - buffer.append( "" ); - buffer.append( "ESTADO" ); - buffer.append( "
" ); - buffer.append( "" + data[ l ][ c ] + "" ); - buffer.append( "
" ); - resultadoText.setText( buffer.toString() ); - } - catch( Exception ex ) - { - resultadoText.setText( "ERRO a carregar dados!" ); - ex.printStackTrace(); - } - } - - protected void listagemGlobalHigieneSeguranca() - { - try - { - StringBuffer buffer = new StringBuffer(); - buffer.append( "

" ); - buffer.append( "" + ESTATISTICAS[ LISTAGEM_GLOBAL_HIGIENE_SEGURANCA ] + "" ); - buffer.append( "

" ); - buffer.append( "
" ); - - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - buffer.append( "" ); - String data[][] = provider.getDadosHigieneSeguranca(); - for( int l = 0; l < data.length; l++ ) - { - buffer.append( "" ); - for( int c = 0; c < data[ l ].length; c++ ) - { - buffer.append( "" ); - buffer.append( "" ); - } - buffer.append( "" ); - } - buffer.append( "
" ); - buffer.append( "EMPRESA" ); - buffer.append( "" ); - buffer.append( "ESTABELECIMENTO" ); - buffer.append( "" ); - buffer.append( "ÚLTIMA AUDITORIA" ); - buffer.append( "" ); - buffer.append( "ESTADO" ); - buffer.append( "" ); - buffer.append( "RELATÓRIO" ); - buffer.append( "" ); - buffer.append( "PRÓXIMA AUDITORIA" ); - buffer.append( "
" ); - buffer.append( "" + data[ l ][ c ] + "" ); - buffer.append( "
" ); - resultadoText.setText( buffer.toString() ); - } - catch( Exception ex ) - { - resultadoText.setText( "ERRO a carregar dados!" ); - ex.printStackTrace(); - } - } - - 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érica de Prevenção de Riscos Profissionais"; - String style = ""; - text = text.replace( "", "\n\t\t" + title + "\n" + style ); - text = text.replace( "", "
" ); - text = text.replace( "", "
" ); -// System.out.println( text ); - try - { - FileWriter writer = new FileWriter( new File( fullName ) ); - writer.write( text ); - writer.close(); - } - catch( IOException ex ) - { - DialogException.showException( ex ); - return; - } - } - } -} \ No newline at end of file diff --git a/trunk/SIPRPSoft/src/siprp/estatisticas/EstatisticasWindow.java b/trunk/SIPRPSoft/src/siprp/estatisticas/EstatisticasWindow.java deleted file mode 100644 index 71e4e844..00000000 --- a/trunk/SIPRPSoft/src/siprp/estatisticas/EstatisticasWindow.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * EstatisticasWindow.java - * - * Created on 11 de Maio de 2004, 17:57 - */ - -package siprp.estatisticas; - -import javax.swing.*; - -import com.evolute.utils.ui.window.*; - -/** - * - * @author fpalma - */ -public class EstatisticasWindow - extends CustomJFrame -{ - private JPanel filtrosPanel; - private JPanel agrupamentosPanel; - private JPanel buttonPanel; - - private JComboBox filtroEmpresa; - - /** Creates a new instance of EstatisticasWindow */ - public EstatisticasWindow() - { - setupComponents(); - } - - private void setupComponents() - { - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/EmpresaPanel.java b/trunk/SIPRPSoft/src/siprp/ficha/EmpresaPanel.java deleted file mode 100644 index bede830c..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/EmpresaPanel.java +++ /dev/null @@ -1,492 +0,0 @@ -/* - * EmpresaPanel.java - * - * Created on 29 de Marco de 2004, 11:53 - */ - -package siprp.ficha; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import java.util.*; - -import com.evolute.utils.*; -import com.evolute.utils.data.*; -import com.evolute.utils.dataui.*; -import com.evolute.utils.jdo.*; -import com.evolute.utils.metadb.*; -import com.evolute.utils.ui.*; -import com.evolute.utils.ui.button.*; -import com.evolute.utils.ui.panel.*; -import com.evolute.utils.ui.text.*; - -import siprp.*; -import siprp.data.*; - -/** - * - * @author fpalma - */ -public class EmpresaPanel extends JPanel - implements ControllableComponent -{ - private JDOProvider JDO; - private JTextField designacaoSocialText; - private JTextField estabelecimentoText; - private JTextField localidadeText; - private RadioButtonFixedPanel servicoSaudeTipoPanel; - private JTextField designacaoServicoSaudeText; - private JButton defaultServicoSaudeButton; - private RadioButtonFixedPanel servicoHigieneTipoPanel; - private JTextField designacaoText; - private JButton defaultServicoHigieneButton; - - private FichaDataProvider provider; - private ComponentsHashtable empresaComponents; - private ComponentsHashtable estabelecimentoComponents; - - private EstabelecimentoData estabelecimento; - private EmpresaData empresa; - - - /** Creates a new instance of EmpresaPanel */ - public EmpresaPanel() - throws Exception - { - provider = (FichaDataProvider)FichaDataProvider.getProvider(); - JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); - setupComponents(); - setupComponentsHashtable(); - } - - private void setupComponents() - { - setBorder( BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), - "Empresa/Entidade" ) ); - - JLabel designacaoSocialLabel = new JLabel( "Designa\u00e7\u00e3o Social" ); - designacaoSocialText = new JTextField(); -// JPanel servicoSaudePanel = new JPanel(); - JLabel estabelecimentoLabel = new JLabel( "Estabelecimento" ); - estabelecimentoText = new JTextField(); - JLabel localidadeLabel = new JLabel( "Localidade" ); - localidadeText = new JTextField(); - JLabel servicoSaudeLabel = new JLabel( "Servi\u00e7o de Sa\u00fade: Tipo" ); - servicoSaudeTipoPanel = - new RadioButtonFixedPanel( new IDObject[]{ new MappableObject( new Integer(1), "Interno" ), - new MappableObject( new Integer(2), "Interempresas" ), - new MappableObject( new Integer(3), "Externo" ), - new MappableObject( new Integer(4), "Servi\u00e7o Nacional de Sa\u00fade" ) }, - 1, 4, RadioButtonPanel.ORIENTATION_HORIZONTAL, false ); - JLabel designacaoServicoSaudeLabel = new JLabel( "Designa\u00e7\u00e3o" ); - designacaoServicoSaudeText = new JTextField(); - defaultServicoSaudeButton = new JButton("-"); - defaultServicoSaudeButton.addActionListener( new ActionListener(){ - public void actionPerformed( ActionEvent e ) - { - designacaoServicoSaudeText.setText( (String) Singleton.getInstance( SingletonConstants.COMPANY_NAME ) ); - } - } ); - - JLabel servicoHigieneLabel = new JLabel( "Servi\u00e7o de Higiene e Seguran\u00e7a: Tipo" ); - servicoHigieneTipoPanel = - new RadioButtonFixedPanel( new IDObject[]{ new MappableObject( new Integer(1), "Interno" ), - new MappableObject( new Integer(2), "Interempresas" ), - new MappableObject( new Integer(3), "Externo" ), - new MappableObject( new Integer(4), "Outro" ) }, - 1, 4, RadioButtonPanel.ORIENTATION_HORIZONTAL, false ); - JLabel designacaoLabel = new JLabel( "Designa\u00e7\u00e3o" ); - designacaoText = new JTextField(); - defaultServicoHigieneButton = new JButton("-"); - defaultServicoHigieneButton.addActionListener( new ActionListener(){ - public void actionPerformed( ActionEvent e ) - { - designacaoText.setText( (String) Singleton.getInstance( SingletonConstants.COMPANY_NAME ) ); - } - } ); - - GridBagLayout gridbag = new GridBagLayout(); - setLayout( gridbag ); - GridBagConstraints constraints = new GridBagConstraints(); - constraints.insets = new Insets( 0, 1, 0, 1 ); - constraints.fill = GridBagConstraints.HORIZONTAL; - constraints.gridwidth = 1; - constraints.weightx = 0; - constraints.gridheight = 1; - constraints.weighty = 0; - - gridbag.setConstraints( designacaoSocialLabel, constraints ); - add( designacaoSocialLabel ); - - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( designacaoSocialText, constraints ); - add( designacaoSocialText ); - - constraints.weightx = 0; - constraints.gridwidth = 1; - gridbag.setConstraints( estabelecimentoLabel, constraints ); - add( estabelecimentoLabel ); - - constraints.weightx = 0.6; - constraints.gridwidth = 3; - gridbag.setConstraints( estabelecimentoText, constraints ); - add( estabelecimentoText ); - - constraints.weightx = 0; - constraints.gridwidth = 1; - gridbag.setConstraints( localidadeLabel, constraints ); - add( localidadeLabel ); - - constraints.weightx = 0.4; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( localidadeText, constraints ); - add( localidadeText ); - - constraints.weightx = 0; - constraints.gridwidth = 2; - gridbag.setConstraints( servicoSaudeLabel, constraints ); - add( servicoSaudeLabel ); - - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( servicoSaudeTipoPanel, constraints ); - add( servicoSaudeTipoPanel ); - - constraints.weightx = 0; - constraints.gridwidth = 1; - gridbag.setConstraints( designacaoServicoSaudeLabel, constraints ); - add( designacaoServicoSaudeLabel ); - - JPanel designacaoServicoSaudePanel = new JPanel(); - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( designacaoServicoSaudePanel, constraints ); - add( designacaoServicoSaudePanel ); - - constraints.weightx = 0; - constraints.gridwidth = 3; - gridbag.setConstraints( servicoHigieneLabel, constraints ); - add( servicoHigieneLabel ); - - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( servicoHigieneTipoPanel, constraints ); - add( servicoHigieneTipoPanel ); - - constraints.gridwidth = 1; - constraints.weightx = 0; - constraints.weighty = 1; - constraints.gridheight = GridBagConstraints.REMAINDER; - gridbag.setConstraints( designacaoLabel, constraints ); - add( designacaoLabel ); - - JPanel designacaoServicoHigienePanel = new JPanel(); - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( designacaoServicoHigienePanel, constraints ); - add( designacaoServicoHigienePanel ); - - gridbag = new GridBagLayout(); - designacaoServicoSaudePanel.setLayout( gridbag ); - constraints.insets = new Insets( 0, 0, 0, 0 ); - constraints.fill = GridBagConstraints.HORIZONTAL; - constraints.gridwidth = 1; - constraints.weightx = 1; - constraints.weighty = 1; - constraints.gridheight = GridBagConstraints.REMAINDER; - - gridbag.setConstraints( designacaoServicoSaudeText, constraints ); - designacaoServicoSaudePanel.add( designacaoServicoSaudeText ); - - constraints.weightx = 0; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( defaultServicoSaudeButton, constraints ); - designacaoServicoSaudePanel.add( defaultServicoSaudeButton ); - - - gridbag = new GridBagLayout(); - designacaoServicoHigienePanel.setLayout( gridbag ); - constraints.insets = new Insets( 0, 0, 0, 0 ); - constraints.fill = GridBagConstraints.HORIZONTAL; - constraints.gridwidth = 1; - constraints.weightx = 1; - constraints.weighty = 1; - constraints.gridheight = GridBagConstraints.REMAINDER; - - gridbag.setConstraints( designacaoText, constraints ); - designacaoServicoHigienePanel.add( designacaoText ); - - constraints.weightx = 0; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( defaultServicoHigieneButton, constraints ); - designacaoServicoHigienePanel.add( defaultServicoHigieneButton ); - - new CopyPasteHandler( designacaoSocialText ); - new CopyPasteHandler( estabelecimentoText ); - new CopyPasteHandler( localidadeText ); - new CopyPasteHandler( designacaoServicoSaudeText ); - new CopyPasteHandler( designacaoText ); - } - - private void setupComponentsHashtable() - { - empresaComponents = new ComponentsHashtable(); - empresaComponents.putComponent( EmpresaData.DESIGNACAO_SOCIAL, designacaoSocialText ); - empresaComponents.putComponent( EmpresaData.SERVICO_SAUDE_TIPO, servicoSaudeTipoPanel ); - empresaComponents.putComponent( EmpresaData.SERVICO_SAUDE_DESIGNACAO, designacaoServicoSaudeText ); - empresaComponents.putComponent( EmpresaData.SERVICO_HIGIENE_TIPO, servicoHigieneTipoPanel ); - empresaComponents.putComponent( EmpresaData.SERVICO_HIGIENE_DESIGNACAO, designacaoText ); - - empresaComponents.putDummy( EmpresaData.MORADA ); - empresaComponents.putDummy( EmpresaData.CODIGO_POSTAL ); - empresaComponents.putDummy( EmpresaData.LOCALIDADE ); - empresaComponents.putDummy( EmpresaData.DISTRITO ); - empresaComponents.putDummy( EmpresaData.CONCELHO ); - empresaComponents.putDummy( EmpresaData.DATA_PROPOSTA ); - empresaComponents.putDummy( EmpresaData.DATA_ACEITACAO ); - empresaComponents.putDummy( EmpresaData.PERFIL_1 ); - empresaComponents.putDummy( EmpresaData.PERFIL_2 ); - empresaComponents.putDummy( EmpresaData.DATA_ENVIO_CONTRATO ); - empresaComponents.putDummy( EmpresaData.DATA_RECEPCAO_CONTRATO ); - empresaComponents.putDummy( EmpresaData.DATA_ENVIO_IDICT ); - empresaComponents.putDummy( EmpresaData.DATA_RELATORIO_ANUAL ); - empresaComponents.putDummy( EmpresaData.CODIGO_1 ); - empresaComponents.putDummy( EmpresaData.CODIGO_2 ); - empresaComponents.putDummy( EmpresaData.CODIGO_3 ); - empresaComponents.putDummy( EmpresaData.CAE ); - empresaComponents.putDummy( EmpresaData.ACTIVIDADE ); - empresaComponents.putDummy( EmpresaData.CONTRIBUINTE ); - empresaComponents.putDummy( EmpresaData.SEGURANCA_SOCIAL ); - empresaComponents.putDummy( EmpresaData.CONTACTO_1 ); - empresaComponents.putDummy( EmpresaData.CONTACTO_2 ); - empresaComponents.putDummy( EmpresaData.SERVICOS ); - empresaComponents.putDummy( EmpresaData.PRECO_HIGIENE ); - empresaComponents.putDummy( EmpresaData.PRECO_MEDICINA ); - empresaComponents.putDummy( EmpresaData.PERIODICIDADE ); - empresaComponents.putDummy( EmpresaData.DESIGNACAO_SOCIAL_PLAIN ); - empresaComponents.putDummy( EmpresaData.DATA_CANCELAMENTO ); - empresaComponents.putDummy( EmpresaData.A_CONSULTAS ); - empresaComponents.putDummy( EmpresaData.A_EXAMES ); - empresaComponents.putDummy( EmpresaData.B_CONSULTAS ); - empresaComponents.putDummy( EmpresaData.B_EXAMES ); - empresaComponents.putDummy( EmpresaData.INICIO_CONTRATO ); - empresaComponents.putDummy( EmpresaData.DURACAO ); - - estabelecimentoComponents = new ComponentsHashtable(); - estabelecimentoComponents.putComponent( EstabelecimentoData.NOME, estabelecimentoText ); - estabelecimentoComponents.putComponent( EstabelecimentoData.LOCALIDADE, localidadeText ); - estabelecimentoComponents.putDummy( EstabelecimentoData.MORADA ); - estabelecimentoComponents.putDummy( EstabelecimentoData.CODIGO_POSTAL ); - estabelecimentoComponents.putDummy( EstabelecimentoData.CONTACTO ); - estabelecimentoComponents.putDummy( EstabelecimentoData.HISTORICO ); - estabelecimentoComponents.putDummy( EstabelecimentoData.EMPRESA ); - estabelecimentoComponents.putDummy( EstabelecimentoData.NOME_PLAIN ); - -// components.putComponent( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.DESIGNACAO_SOCIAL, designacaoSocialText ); -// components.put( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_SAUDE_TIPO, servicoSaudeTipoPanel ); -// components.putComponent( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_SAUDE_DESIGNACAO, designacaoServicoSaudeText ); -// components.put( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_HIGIENE_TIPO, servicoHigieneTipoPanel ); -// components.putComponent( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.SERVICO_HIGIENE_DESIGNACAO, designacaoText ); -// -// components.putComponent( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.NOME, estabelecimentoText ); -// components.putComponent( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.LOCALIDADE, localidadeText ); -// -// components.putDummy( FichaDataProvider.T_EMPRESAS + "." + FichaDataProvider.INACTIVO ); -// components.putDummy( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.EMPRESA_ID ); -// components.putDummy( FichaDataProvider.T_ESTABELECIMENTOS + "." + FichaDataProvider.INACTIVO ); - } - - public void fill(Object value) - { - clear(); - empresa = null; - estabelecimento = null; - if( value != null ) - { - Integer empresaID = (Integer)((Object[])value)[0]; - Integer estabelecimentoID = (Integer)((Object[])value)[1]; - if( empresaID != null ) - { - try - { - empresa = (EmpresaData)JDO.load( EmpresaData.class, empresaID ); - String names[] = (String[])empresaComponents.keySet().toArray( new String[0] ); - ComponentController.fill( names, empresa.getHashData(), empresaComponents ); - - if( estabelecimentoID != null ) - { - estabelecimento = (EstabelecimentoData)JDO.load( EstabelecimentoData.class, estabelecimentoID ); - names = estabelecimento.getFieldNames(); - ComponentController.fill( names, estabelecimento.getHashData(), estabelecimentoComponents ); - } - -// DBField fields[] = provider.EMPRESAS.getInsertFields(); -// String empresaFields[] = new String[ fields.length ]; -// Hashtable data = new Hashtable(); -// for( int i = 0; i < empresaFields.length; ++i ) -// { -// empresaFields[ i ] = fields[ i ].FULL_NAME; -// Object fieldValue = empresa.getProperty( empresaFields[ i ] ); -// if( fieldValue != null ) -// { -// data.put( empresaFields[ i ], fieldValue ); -// } -// } -// ComponentController.fill( empresaFields, data, components ); -// if( estabelecimentoID != null ) -// { -// estabelecimento = provider.load( provider.ESTABELECIMENTOS, new DBKey( estabelecimentoID ) ); -// fields = provider.ESTABELECIMENTOS.getInsertFields(); -// String estabelecimentoFields[] = new String[ fields.length ]; -// for( int i = 0; i < estabelecimentoFields.length; ++i ) -// { -// estabelecimentoFields[ i ] = fields[ i ].FULL_NAME; -// Object fieldValue = estabelecimento.getProperty( estabelecimentoFields[ i ] ); -// if( fieldValue != null ) -// { -// data.put( estabelecimentoFields[ i ], fieldValue ); -// } -// } -// ComponentController.fill( estabelecimentoFields, data, components ); -// } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar os dados da Empresa", true ); - } - } - } - else - { - estabelecimentoText.setText( "Sede" ); - } - } - - public Object save() - { - StringBuffer msg = new StringBuffer(); - boolean hasMsg = false; - try - { - if( estabelecimento == null ) - { -// estabelecimento = provider.createObject( provider.ESTABELECIMENTOS ); - estabelecimento = new EstabelecimentoData(); - } - if( empresa == null ) - { -// empresa = provider.createObject( provider.EMPRESAS ); - empresa = new EmpresaData(); - } -// DBField fields[] = provider.EMPRESAS.getInsertFields(); -// String empresaFields[] = new String[ fields.length ]; -// for( int i = 0; i < empresaFields.length; ++i ) -// { -// empresaFields[ i ] = fields[ i ].FULL_NAME; -// } -// Hashtable hash = new Hashtable(); -// ComponentController.save( empresaFields, hash, components ); -// Enumeration enum = hash.keys(); -// while( enum.hasMoreElements() ) -// { -// String name = ( String )enum.nextElement(); -// empresa.setProperty( name, hash.get( name ) ); -// } -// fields = provider.ESTABELECIMENTOS.getInsertFields(); -// String estabelecimentoFields[] = new String[ fields.length ]; -// for( int i = 0; i < estabelecimentoFields.length; ++i ) -// { -// estabelecimentoFields[ i ] = fields[ i ].FULL_NAME; -// } -// hash = new Hashtable(); -// ComponentController.save( estabelecimentoFields, hash, components ); -// enum = hash.keys(); -// while( enum.hasMoreElements() ) -// { -// String name = ( String )enum.nextElement(); -// estabelecimento.setProperty( name, hash.get( name ) ); -// } - - String names[] = (String[])empresaComponents.keySet().toArray( new String[0] ); -// String names[] = new String[]{ EmpresaData.DESIGNACAO_SOCIAL, EmpresaData.SERVICO_SAUDE_TIPO, -// EmpresaData.SERVICO_SAUDE_DESIGNACAO, EmpresaData.SERVICO_HIGIENE_TIPO, -// EmpresaData.SERVICO_HIGIENE_DESIGNACAO }; - Hashtable hash = empresa.getHashData(); - ComponentController.save( names, hash, empresaComponents ); - empresa.setHashData( hash ); - - names = estabelecimento.getFieldNames(); - hash = estabelecimento.getHashData(); - ComponentController.save( names, hash, estabelecimentoComponents ); - estabelecimento.setHashData( hash ); - estabelecimento.set( EstabelecimentoData.EMPRESA, empresa ); - -// estabelecimento.setProperty( provider.R_ESTABELECIMENTO_EMPRESA, empresa ); - -// if( ((String)empresa.getProperty( provider.DESIGNACAO_SOCIAL )).trim().length() == 0 ) - if( ((String)empresa.get( EmpresaData.DESIGNACAO_SOCIAL )).trim().length() == 0 ) - { - msg.append( "A empresa tem de ter uma design\u00e7\u00e3o social\n" ); - hasMsg = true; - } - else - { - empresa.set( EmpresaData.DESIGNACAO_SOCIAL_PLAIN, - com.evolute.utils.strings.StringPlainer.convertString( ( String ) - empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) ) ); - } -// if( empresa.getProperty( provider.SERVICO_SAUDE_TIPO ) == null ) - if( empresa.get( EmpresaData.SERVICO_SAUDE_TIPO ) == null ) - { - msg.append( "A empresa tem de ter um tipo de seri\00e7o de sa\u00fade\n" ); - hasMsg = true; - } -// if( empresa.getProperty( provider.SERVICO_HIGIENE_TIPO ) == null ) - if( empresa.get( EmpresaData.SERVICO_HIGIENE_TIPO ) == null ) - { - msg.append( "A empresa tem de ter um tipo de seri\00e7o de higiene\n" ); - hasMsg = true; - } -// if( ((String)estabelecimento.getProperty( provider.NOME )).trim().length() == 0 ) - if( ((String)estabelecimento.get( EstabelecimentoData.NOME )).trim().length() == 0 ) - { - msg.append( "O estabelecimento tem de ter nome\n" ); - hasMsg = true; - } - - } - catch( Exception ex ) - { - ex.printStackTrace(); - return null; - } - if( hasMsg ) - { - throw new ValuesException( msg.toString() ); - } - return estabelecimento; - - } - - public void clear() - { - String names[] = (String[])empresaComponents.keySet().toArray( new String[0] ); - ComponentController.clear( names, empresaComponents ); - names = (String[])estabelecimentoComponents.keySet().toArray( new String[0] ); - ComponentController.clear( names, estabelecimentoComponents ); - estabelecimentoText.setText( "Sede" ); - empresa = null; - estabelecimento = null; - } - - public void setEnabled( boolean enable ) - { - String names[] = (String[])empresaComponents.keySet().toArray( new String[0] ); - ComponentController.setEnabled( names, enable, empresaComponents ); - names = (String[])estabelecimentoComponents.keySet().toArray( new String[0] ); - ComponentController.setEnabled( names, enable, estabelecimentoComponents ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/ExamePDF.java b/trunk/SIPRPSoft/src/siprp/ficha/ExamePDF.java deleted file mode 100644 index 32b7702e..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/ExamePDF.java +++ /dev/null @@ -1,461 +0,0 @@ -package siprp.ficha; - -import java.awt.Color; -import java.io.*; -import java.util.*; - -import com.lowagie.text.*; -import com.lowagie.text.pdf.*; - -import com.evolute.utils.*; -import siprp.*; - -public class ExamePDF implements FichaAptidaoConstants -{ - private final Font FONT_BOLD = FontFactory.getFont( "Arial", 8, Font.BOLD ); - private final Font FONT_NORMAL = FontFactory.getFont( "Arial", 8, Font.NORMAL ); - private final Font FONT_ZAPFDINGBATS = new Font( Font.ZAPFDINGBATS , 12, Font.NORMAL, new Color( 0, 0, 0 ) ); - - private BaseFont BASE_WINGDINGS; - private Font FONT_WINGDINGS; - -// static -// { -// try -// { -// //BASE_WINGDINGS = BaseFont.createFont("C:\\WINNT\\Fonts\\WINGDING.TTF", BaseFont.CP1252, BaseFont.NOT_EMBEDDED); -// BASE_WINGDINGS = BaseFont.createFont("WingDings", BaseFont.CP1252, BaseFont.EMBEDDED); -// InputStream stream = BaseFont.getResourceStream( "WING", ClassLoader loader) -// BASE_WINGDINGS = BaseFont.createFont("WingDings", BaseFont.CP1252, BaseFont.EMBEDDED, -// true, byte[] ttfAfm, null ); -// FONT_WINGDINGS = new Font(BASE_WINGDINGS, 12); -// } -// catch( Exception ex ) -// { -// FONT_WINGDINGS = FONT_NORMAL; -// System.out.println( "NO FONT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" ); -// } -// } - - public ExamePDF() - { - FontFactory.registerDirectories(); - String possibleNames[] = new String[]{ "Wingdings", "WingDings", "wingdings", "WINGDINGS" }; - - for( int n = 0; n < 4; n++ ) - { - FONT_WINGDINGS = FontFactory.getFont( possibleNames[ n ] ); - if( FONT_WINGDINGS.getFamilyname().toLowerCase().equals( "wingdings" ) ) - { - break; - } - } - - } - - public static void main( String[] args ) - { - try - { - HashMap ht = new HashMap(); - // designacao_social - // estabelecimentos.nome - // estabelecimentos.localidade - // servico_saude_tipo_interno - // servico_saude_tipo_interempresas - // servico_saude_tipo_externo - // servico_saude_tipo_sns - // servico_saude_designacao - // servico_higiene_tipo_interno - // servico_higiene_tipo_interempresas - // servico_higiene_tipo_externo - // servico_higiene_outro - // servico_higiene_designacao - // trabalhadores.nome - // sexo - // data_nascimento - // nacionalidade - // numero_mecanografico - // data_admissao - // categoria - // local_trabalho - // funcao_proposta - // data_admissao_funcao - // observacoes - // exames.data - // tipo_admissao - // tipo_periodico - // tipo_ocasional - // tipo_apos_doenca - // tipo_apos_acidente - // tipo_pedido_trabalhador - // tipo_pedido_empresa - // tipo_mudanca_funcao - // tipo_trabalho - // tipo_outro - // resultado_apto - // resultado_apto_condicionalmente - // resultado_inapto_temp - // resultado_inapto_def - // outra_funcao_1 - // outra_funcao_2 - // outra_funcao_3 - // outra_funcao_4 - // proximo_exame - // outras_recomendacoes - // medicos.nome - // numero_cedula - - ht.put( TRABALHADORES_NOME, "Trabalhador do com\u00e9rcio" ); - ht.put( SERVICO_SAUDE_DESIGNACAO, "Designacao servico saude" ); - ht.put( SERVICO_SAUDE_TIPO_EXTERNO, "" + Boolean.TRUE ); - ht.put( TIPO_PERIODICO, "" + Boolean.TRUE ); - ht.put( RESULTADO_INAPTO_TEMP, "" + Boolean.TRUE ); - FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + "\\report.pdf" ); - fos.write( new ExamePDF().createPDF( ht ) ); - fos.close(); - System.out.println( "File saved." ); - Process proc = Runtime.getRuntime().exec( "cmd.exe /c \"" + System.getProperty( "user.home" ) + "\\report.pdf\"" ); - proc.waitFor(); - new File( System.getProperty( "user.home" ) + "\\report.pdf" ).delete(); - System.out.println( "Done." ); - } - catch( Exception e ) - { - e.printStackTrace(); - } - } - - public void print( byte []pdf, String nome ) - throws Exception - { - long time = System.currentTimeMillis(); -// FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha" + time + ".pdf" ); - FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf" ); - fos.write( pdf ); - fos.close(); - System.out.println( "File saved ( " + nome + "_" + time + " )." ); - Process proc; - if( System.getProperty( "os.name" ).startsWith( "Windows" ) ) - { -//System.out.println( "cmd.exe /c \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf\"" ); - proc = Runtime.getRuntime().exec( "cmd.exe /c \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf\"" ); - proc.waitFor(); - if( !new File( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf" ).delete() ) - { - System.err.println( "File: report_ficha" + time + ".pdf - NOT DELETED" ); - } - } - else - { -//System.out.println( "/usr/bin/open \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf\"" ); - try{ - proc = Runtime.getRuntime().exec( new String[]{"/usr/bin/open", "" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf" } ); - } - catch( Exception ex ) - { - ex.printStackTrace(); - } -// proc = Runtime.getRuntime().exec( "/usr/bin/open \"/Users/Shared/teste.pdf.pdf\"" ); - } - } - - public void printSilent( byte []pdf, String nome, String printerName ) - throws Exception - { - long time = System.currentTimeMillis(); -// FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha" + time + ".pdf" ); - - if( System.getProperty( "os.name" ).startsWith( "Windows" ) ) - { - Process proc; - -// FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + "\\print_fichas_temp\\" + nome + "_" + time + ".pdf" ); - FileOutputStream fos = new FileOutputStream( "c:\\temp\\" + nome + "_" + time + ".pdf" ); - fos.write( pdf ); - fos.close(); - - System.out.println( "File saved ( " + nome + "_" + time + " )." ); -//System.out.println("cmd /c \"c:\\temp\\acrord32.lnk /t \"c:" + System.getProperty( "file.separator" ) + "temp" + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf\" \"" + printerName + "\"\""); -// proc = Runtime.getRuntime().exec( new String[]{ System.getProperty( "user.home" ) + "\\print.bat", -// System.getProperty( "user.home" ) + "\\print_fichas_temp\\" + nome + "_" + time + ".pdf", -// printerName }); - proc = Runtime.getRuntime().exec( new String[]{ System.getProperty( "user.home" ) + "\\print.bat", - "c:\\temp\\" + nome + "_" + time + ".pdf", - printerName }); - proc.waitFor(); -// if( !new File( "c:\\temp\\" + nome + "_" + time + ".pdf" ).delete() ) -// { -// System.err.println( "File: " + nome + "_" + ".pdf - NOT DELETED" ); -// } - } - - } - - public void cleanSilentPrint() - throws Exception - { - Process proc; - proc = Runtime.getRuntime().exec( "cmd /c \"del c:\\temp\\*.pdf\"" ); - proc.waitFor(); - } - - public byte[] createPDF( HashMap values ) - { - Document document = new Document(); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - - document.setPageSize( PageSize.A4 ); - - try { - PdfWriter pdfw = PdfWriter.getInstance( document, bos ); - - document.addTitle( "Ficha de Aptid\u00e3o" ); - String acronym = (String) Singleton.getInstance( SingletonConstants.COMPANY_ACRONYM ); - document.addAuthor( acronym != null ? acronym: "n/a" ); - document.addCreator( "Evolute" ); - - document.open(); - - Paragraph conteudo = new Paragraph(); - - conteudo.add( new Chunk( "\n\nFICHA DE APTID\u00c3O\n", - FontFactory.getFont( "Arial", 10, Font.BOLD ) ) ); - conteudo.add( new Chunk( "(Portaria n.\u00ba 299/2007, de 16 de Mar\u00e7o)", -// conteudo.add( new Chunk( "(Portaria n\u00ba1031/2002, de 10 de Agosto)", - FontFactory.getFont( "Arial", 7, Font.BOLD ) ) ); - - conteudo.setAlignment( Element.ALIGN_CENTER ); - - document.add( conteudo ); - - Table table = new Table( 1 ); - table.setBorderWidth( 1 ); - table.setPadding( 5 ); - table.setOffset( 0 ); - table.setWidth( 100 ); - - table.addCell( new Phrase( "Empresa/Entidade", FONT_BOLD ) ); - - StringBuilder texto = new StringBuilder(); - Phrase ph = new Phrase( 12f ); - - Cell cell = new Cell(); - texto.append( "DESIGNA\u00c7\u00c3O SOCIAL: " + values.get( DESIGNACAO_SOCIAL ) + "\n" ); - texto.append( "ESTABELECIMENTO: " + values.get( ESTABELECIMENTOS_NOME ) - + " LOCALIDADE: " + values.get( ESTABELECIMENTOS_LOCALIDADE ) + "\n" ); - texto.append( "SERVI\u00c7O DE SA\u00DaDE: Tipo " ); - ph.add( new Chunk( texto.toString(), FONT_NORMAL ) ); - - texto = new StringBuilder( "Interno" ); - ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_SAUDE_TIPO_INTERNO ) ) ); - - texto = new StringBuilder( "Interempresas" ); - ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_SAUDE_TIPO_INTEREMPRESAS ), true ) ); - - texto = new StringBuilder( "Externo" ); - ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_SAUDE_TIPO_EXTERNO ), true ) ); - - texto = new StringBuilder( "Servi\u00e7o Nacional de Sa\u00fade\n" ); - ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_SAUDE_TIPO_SNS ), true ) ); - - texto = new StringBuilder(); - - texto.append( "DESIGNA\u00c7\u00c3O: " + values.get( SERVICO_SAUDE_DESIGNACAO ) + "\n" ); - texto.append( "SERVI\u00c7O DE HIGIENE E SEGURAN\u00c7A: Tipo " ); - ph.add( new Chunk( texto.toString(), FONT_NORMAL ) ); - - texto = new StringBuilder( "Interno" ); - ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_HIGIENE_TIPO_INTERNO ) ) ); - - texto = new StringBuilder( "Interempresas" ); - ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_HIGIENE_TIPO_INTEREMPRESAS ), true ) ); - - texto = new StringBuilder( "Externo" ); - ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_HIGIENE_TIPO_EXTERNO ), true ) ); - - texto = new StringBuilder( "Outro\n" ); - ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_HIGIENE_TIPO_OUTRO ), true ) ); - - texto = new StringBuilder(); - - texto.append( "DESIGNA\u00c7\u00c3O: " + values.get( SERVICO_HIGIENE_DESIGNACAO ) + "" ); - - ph.add( new Chunk( texto.toString(), FONT_NORMAL ) ); - - cell.addElement( ph ); - table.addCell( cell ); - document.add( table ); - - table = new Table( 1 ); - table.setBorderWidth( 1 ); - table.setPadding( 5 ); - table.setOffset( 0 ); - table.setWidth( 100 ); - - table.addCell( new Phrase( "Trabalhador", - FONT_BOLD ) ); - - texto = new StringBuilder(); - - texto.append( "NOME: " + values.get( TRABALHADORES_NOME ) + "\n" ); - texto.append( "SEXO: " + values.get( SEXO ) + " DATA DE NASCIMENTO: " - + values.get( DATA_NASCIMENTO ) + " NACIONALIDADE: " - + values.get( NACIONALIDADE ) + "\n" ); - texto.append( "N\u00daMERO MECANOGR\u00c1FICO/OUTRO: " + values.get( NUMERO_MECANOGRAFICO ) - + " DATA DE ADMISS\u00c3O: " + values.get( DATA_ADMISSAO ) + "\n" ); - texto.append( "CATEGORIA PROFISSIONAL: " + values.get( CATEGORIA ) - + " LOCAL DE TRABALHO: " + values.get( LOCAL_TRABALHO ) + "\n" ); - texto.append( "FUN\u00c7\u00c3O PROPOSTA: " + values.get( FUNCAO_PROPOSTA ) - + " DATA DE ADMISS\u00c3O NA FUN\u00c7\u00c3O: " - + values.get( DATA_ADMISSAO_FUNCAO ) + "" ); - - table.addCell( new Phrase( 12f, texto.toString(), FONT_NORMAL ) ); - document.add( table ); - - table = new Table( 1 ); - table.setBorderWidth( 1 ); - table.setOffset( 0 ); - table.setPadding( 5 ); - table.setWidth( 100 ); - - table.addCell( new Phrase( "Observa\u00e7\u00f5es", - FONT_BOLD ) ); - - texto = new StringBuilder(); - texto.append( values.get( OBSERVACOES ) ); - - table.addCell( new Phrase( 12f, texto.toString(), FONT_NORMAL ) ); - document.add( table ); - - table = new Table( 2 ); - table.setBorderWidth( 1 ); - table.setOffset( 0 ); - table.setPadding( 5 ); - table.setWidth( 100 ); - - cell = new Cell( new Phrase( "Exame M\u00e9dico", - FONT_BOLD ) ); - - cell.setColspan( 2 ); - table.addCell( cell ); - - texto = new StringBuilder(); - ph = new Phrase( 12f ); - texto.append( "DATA DO EXAME: " + values.get( EXAMES_DATA ) + "\n" ); - texto.append( "TIPO\n" ); - ph.add( new Chunk( texto.toString(), FONT_NORMAL ) ); - - ph.add( doCheckedPhrase( "ADMISS\u00c3O\n", values.get( TIPO_ADMISSAO ) ) ); - - ph.add( doCheckedPhrase( "PERI\u00d3DICO\n", values.get( TIPO_PERIODICO ) ) ); - - ph.add( doCheckedPhrase( "OCASIONAL\n", values.get( TIPO_OCASIONAL ) ) ); - - ph.add( doCheckedPhrase( "AP\u00d3S DOEN\u00c7A\n", values.get( TIPO_APOS_DOENCA ), true ) ); - - ph.add( doCheckedPhrase( "AP\u00d3S ACIDENTE\n", values.get( TIPO_APOS_ACIDENTE ), true ) ); - - ph.add( doCheckedPhrase( "A PEDIDO DO TRABALHADOR\n", values.get( TIPO_PEDIDO_TRABALHADOR ), true ) ); - - ph.add( doCheckedPhrase( "A PEDIDO DO SERVI\u00c7O\n", values.get( TIPO_PEDIDO_EMPRESA ), true ) ); - - ph.add( doCheckedPhrase( "POR MUDAN\u00c7A DE FUN\u00c7\u00c3O\n", values.get( TIPO_MUDANCA_FUNCAO ), true ) ); - - ph.add( doCheckedPhrase( "POR ALTERA\u00c7\u00c3O DAS CONDI\u00c7\u00d5ES DE TRABALHO\n", values.get( TIPO_TRABALHO ), true ) ); - - ph.add( doCheckedPhrase( "OUTRO\n", values.get( TIPO_OUTRO ), true ) ); - - texto = new StringBuilder(); - texto.append( " ESPECIFIQUE: " + values.get( TIPO_OUTRO_TEXTO ) ); - - ph.add( new Chunk( texto.toString(), FONT_NORMAL ) ); - - table.addCell( ph ); - - ph = new Phrase( 12f ); - ph.add( new Chunk( "RESULTADO\n", FONT_NORMAL ) ); - ph.add( doCheckedPhrase( "APTO\n", values.get( RESULTADO_APTO ) ) ); - - ph.add( doCheckedPhrase( "APTO CONDICIONALMENTE\n\n", values.get( RESULTADO_APTO_CONDICIONALMENTE ) ) ); - - ph.add( doCheckedPhrase( "INAPTO TEMPORARIAMENTE\n", values.get( RESULTADO_INAPTO_TEMP ) ) ); - - ph.add( doCheckedPhrase( "INAPTO DEFINITIVAMENTE\n\n", values.get( RESULTADO_INAPTO_DEF ) ) ); - - texto = new StringBuilder(); - texto.append( "OUTRAS FUN\u00c7\u00d5ES QUE PODE DESEMPENHAR\n" ); - texto.append( " 1 " + values.get( OUTRA_FUNCAO_1 ) + "\n" ); - texto.append( " 2 " + values.get( OUTRA_FUNCAO_2 ) + "\n" ); - texto.append( " 3 " + values.get( OUTRA_FUNCAO_3 ) + "\n" ); - texto.append( " 4 " + values.get( OUTRA_FUNCAO_4 ) + "\n" ); - ph.add( new Chunk( texto.toString(), FONT_NORMAL ) ); - table.addCell( ph ); - - document.add( table ); - - table = new Table( 1 ); - table.setBorderWidth( 1 ); - table.setOffset( 0 ); - table.setPadding( 5 ); - table.setWidth( 100 ); - - table.addCell( new Phrase( "Outras Recomenda\u00e7\u00f5es", - FONT_BOLD ) ); - - texto = new StringBuilder(); - if( ( (Boolean) Singleton.getInstance( SingletonConstants.FICHA_MARCA_EXAMES ) ).booleanValue() ) - { - System.out.println( "ficha marca exames" ); - texto.append( "PR\u00d3XIMO EXAME: " + values.get( PROXIMO_EXAME ) + "\n" ); - } - texto.append( "" + values.get( OUTRAS_RECOMENDACOES ) + "" ); - - table.addCell( new Phrase( 12f, texto.toString(), FONT_NORMAL ) ); - document.add( table ); - - - table = new Table( 1 ); - table.setBorderWidth( 1 ); - table.setOffset( 0 ); - table.setPadding( 5 ); - table.setWidth( 100 ); - - texto = new StringBuilder(); - - texto.append( "M\u00c9DICO DO TRABALHO: " - + values.get( MEDICOS_NOME ) + " C.P. " + values.get( NUMERO_CEDULA ) + "\n" ); - texto.append( "ASSINATURA _____________________________________________________________________________________\n\n" ); - texto.append( "TOMEI CONHECIMENTO ___________________________________________________________ DATA:____/____/________\n" ); - texto.append( " O RESPONS\u00c1VEL DOS RECURSOS HUMANOS" ); - - table.addCell( new Phrase( 18f, texto.toString(), FONT_NORMAL ) ); - document.add( table ); - - } - catch( Exception e ) { - e.printStackTrace(); - return null; - } - - document.close(); - return bos.toByteArray(); - } - - private Phrase doCheckedPhrase( String text, String phrase, boolean indent ) - { - boolean checked = CHECKED.equals( phrase ); - Phrase p = new Phrase( 12f ); - //p.add( new Chunk( ( indent ? " " : "" ) + ( char )( checked? 110: 111) + " ", FONT_ZAPFDINGBATS ) ); - //System.out.println( "FAMILY: " + FONT_WINGDINGS.getFamilyname() ); - p.add( new Chunk( ( indent ? " " : "" ) + ( char )( checked? 0xfe: 0xa8), FONT_WINGDINGS ) ); -// p.add( new Chunk( ( indent ? " " : "" ) + ( char )( checked? 'X': '_'), FONT_WINGDINGS ) ); - p.add( new Chunk( text, FONT_NORMAL ) ); - return p; - } - - private Phrase doCheckedPhrase( String text, String phrase ) - { - return doCheckedPhrase( text, phrase, false ); - } -} \ No newline at end of file diff --git a/trunk/SIPRPSoft/src/siprp/ficha/ExamePanel.java b/trunk/SIPRPSoft/src/siprp/ficha/ExamePanel.java deleted file mode 100644 index 36853696..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/ExamePanel.java +++ /dev/null @@ -1,527 +0,0 @@ -/* - * ExamePanel.java - * - * Created on 29 de Marco de 2004, 11:57 - */ - -package siprp.ficha; - -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.documents.*; -import com.evolute.utils.data.*; -import com.evolute.utils.dataui.*; -import com.evolute.utils.jdo.*; -//import com.evolute.utils.metadb.*; -import com.evolute.utils.ui.*; -import com.evolute.utils.ui.button.*; -import com.evolute.utils.ui.calendar.*; -import com.evolute.utils.ui.panel.*; -import com.evolute.utils.ui.text.*; - -import siprp.*; -import siprp.data.*; -/** - * - * @author fpalma - */ -public class ExamePanel extends JPanel - implements ChangeListener, ControllableComponent, ListSelectionListener -{ - static - { - ExameData.registerOperationHandlerForClass( DisableDeleteHandler.INSTANCE, ExameData.class ); - } - private JDOProvider JDO; - - private JCalendarPanel dataExamePanel; - private BetterButtonGroup tipoGroup; - private JRadioButton admissaoRadio; - private JRadioButton periodicoRadio; - private JRadioButton ocasionalRadio; -// private JRadioButton outroRadio; - private RadioButtonFixedPanel ocasionalPanel; - private JTextField especificarText; - private RadioButtonFixedPanel tipoProximoPanel; - private JCalendarPanel proximoExamePanel; - private RadioButtonFixedPanel resultadoPanel; - private JTextField outrasFuncoesTexts[]; - private JTextArea recomendacoesText; - - private FichaDataProvider provider; - private ComponentsHashtable components; - - private Integer trabalhadorID; - private MarcacaoTrabalhadorData marcacao; - - /** Creates a new instance of ExamePanel */ - public ExamePanel() - throws Exception - { - provider = (FichaDataProvider)FichaDataProvider.getProvider(); - JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); - setupComponents(); - setupComponentsHashtable(); - } - - private void setupComponents() - { - setBorder( BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), - "Exame M\u00e9dico" ) ); - - JPanel leftPanel = new JPanel(); - JPanel rightPanel = new JPanel(); - JPanel dataExameOuterPanel = new JPanel(); - JLabel dataExameLabel = new JLabel( "Data do Exame" ); - dataExamePanel = new JCalendarPanel( null ); - JPanel tipoPanel = new JPanel(); - tipoPanel.setBorder( BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), "Tipo" ) ); - tipoGroup = new BetterButtonGroup( false ); - admissaoRadio = new JRadioButton( "Admiss\u00e3o" ); - tipoGroup.add( admissaoRadio ); - periodicoRadio = new JRadioButton( "Peri\u00f3dico" ); - tipoGroup.add( periodicoRadio ); - ocasionalRadio = new JRadioButton( "Ocasional" ); - tipoGroup.add( ocasionalRadio ); - ocasionalRadio.addChangeListener( this ); -// outroRadio = new JRadioButton( "Outro" ); -// tipoGroup.add( outroRadio ); -// outroRadio.addChangeListener( this ); - ocasionalPanel = new RadioButtonFixedPanel( - new IDObject[]{ new MappableObject( new Integer( 1 ), "Ap\u00f3s doen\u00e7a" ), - new MappableObject( new Integer( 2 ), "Ap\u00f3s acidente" ), - new MappableObject( new Integer( 3 ), "A pedido do trabalhador" ), - new MappableObject( new Integer( 4 ), "A pedido do servi\u00e7o" ), - new MappableObject( new Integer( 5 ), "Por mudan\u00e7a de fun\u00e7\u00e3o" ), - new MappableObject( new Integer( 6 ), "Por altera\u00e7\u00e3o das condi\u00e7\u00f5es de trabalho" ), - new MappableObject( new Integer( 10 ), "Outro" ) }, - false ); - ocasionalPanel.addListSelectionListener( this ); - ocasionalPanel.setEnabled( false ); - especificarText = new JTextField(); - especificarText.setEnabled( false ); - JPanel proximoExameOuterPanel = new JPanel(); - proximoExameOuterPanel.setBorder( BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), "Pr\u00f3ximo Exame" ) ); - proximoExamePanel = new JCalendarPanel( null ); - tipoProximoPanel = new RadioButtonFixedPanel( - new IDObject[]{ new MappableObject( new Integer( 2 ), "Peri\u00f3dico" ), - new MappableObject( new Integer( 3 ), "Ocasional" ) }, - RadioButtonFixedPanel.ORIENTATION_HORIZONTAL, 1, 2, false ); -// JLabel proximoExameLabel = new JLabel( "Pr\u00f3ximo Exame" ); - - JPanel resultadoOuterPanel = new JPanel(); - resultadoOuterPanel.setBorder( BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), "Resultado" ) ); - resultadoPanel = new RadioButtonFixedPanel( - new IDObject[]{ new MappableObject( new Integer( 1 ), "Apto" ), - new MappableObject( new Integer( 2 ), "Apto condicionalmente" ), - new MappableObject( new Integer( 3 ), "Inapto temporariamente" ), - new MappableObject( new Integer( 4 ), "Inapto definitivamente" ) }, - false ); - JLabel outrasFuncoesLabel = new JLabel( "Outras fun\u00e7\u00f5es que pode desempenhar", JLabel.CENTER ); - JPanel outrasFuncoesPanel = new JPanel(); - JLabel outrasFuncoesLabels[] = new JLabel[ 4 ]; - outrasFuncoesTexts = new JTextField[ 4 ]; - for( int n = 0; n < 4; n++ ) - { - outrasFuncoesLabels[ n ] = new JLabel( "" + ( n + 1 ) ); - outrasFuncoesTexts[ n ] = new JTextField(); - } - JScrollPane recomendacoesScp = new JScrollPane(); - recomendacoesScp.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - recomendacoesScp.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); - recomendacoesText = new JTextArea(); - recomendacoesText.setLineWrap( true ); - recomendacoesText.setWrapStyleWord( true ); - recomendacoesText.setDocument( new MaximumLengthDocument( 300 ) ); - recomendacoesScp.setViewportView( recomendacoesText ); - recomendacoesScp.setBorder( BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), - "Outras recomenda\u00e7\u00f5es" ) ); - - setLayout( new GridLayout( 1, 2 ) ); - add( leftPanel ); - add( rightPanel ); - - leftPanel.setLayout( new BorderLayout() ); - - dataExameOuterPanel.setLayout( new BorderLayout() ); - dataExameOuterPanel.add( dataExameLabel, BorderLayout.WEST ); - dataExameOuterPanel.add( dataExamePanel, BorderLayout.CENTER ); - leftPanel.add( dataExameOuterPanel, BorderLayout.NORTH ); - leftPanel.add( tipoPanel, BorderLayout.CENTER ); - proximoExameOuterPanel.setLayout( new BorderLayout() ); -// proximoExameOuterPanel.add( proximoExameLabel, BorderLayout.WEST ); - proximoExameOuterPanel.add( proximoExamePanel, BorderLayout.CENTER ); - proximoExameOuterPanel.add( tipoProximoPanel, BorderLayout.SOUTH ); - if( ( ( Boolean ) Singleton.getInstance( SingletonConstants.FICHA_MARCA_EXAMES ) ).booleanValue() ) - { - leftPanel.add( proximoExameOuterPanel, BorderLayout.SOUTH ); - } - - GridBagLayout gridbag = new GridBagLayout(); - tipoPanel.setLayout( gridbag ); - GridBagConstraints constraints = new GridBagConstraints(); - constraints.insets = new Insets( 0, 1, 0, 1 ); - constraints.fill = GridBagConstraints.HORIZONTAL; - constraints.weighty = 0; - constraints.gridheight = 1; - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - - gridbag.setConstraints( admissaoRadio, constraints ); - tipoPanel.add( admissaoRadio ); - - gridbag.setConstraints( periodicoRadio, constraints ); - tipoPanel.add( periodicoRadio ); - - gridbag.setConstraints( ocasionalRadio, constraints ); - tipoPanel.add( ocasionalRadio ); - - constraints.weightx = 0.1; - constraints.gridwidth = 1; - JPanel pad = new JPanel(); - gridbag.setConstraints( pad, constraints ); - tipoPanel.add( pad ); - - constraints.weightx = 0.9; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( ocasionalPanel, constraints ); - tipoPanel.add( ocasionalPanel ); - -// constraints.weightx = 0; -// constraints.gridwidth = 1; -// gridbag.setConstraints( outroRadio, constraints ); -// tipoPanel.add( outroRadio ); - - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( especificarText, constraints ); - tipoPanel.add( especificarText ); - - - gridbag = new GridBagLayout(); - rightPanel.setLayout( gridbag ); - constraints.fill = GridBagConstraints.BOTH; - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.gridheight = 1; - constraints.weighty = 0; - - gridbag.setConstraints( resultadoOuterPanel, constraints ); - rightPanel.add( resultadoOuterPanel ); - - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - //constraints.gridheight = GridBagConstraints.REMAINDER; - constraints.weighty = 1; -// JPanel recomendacoesOuterPanel = new JPanel(); -// recomendacoesOuterPanel.setLayout( new GridLayout( 1, 1 ) ); -// recomendacoesOuterPanel.add( recomendacoesScp ); - gridbag.setConstraints( recomendacoesScp, constraints ); - rightPanel.add( recomendacoesScp ); - - gridbag = new GridBagLayout(); - resultadoOuterPanel.setLayout( gridbag ); - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.gridheight = 1; - constraints.weighty = 0; - - gridbag.setConstraints( resultadoPanel, constraints ); - resultadoOuterPanel.add( resultadoPanel ); - - gridbag.setConstraints( outrasFuncoesLabel, constraints ); - resultadoOuterPanel.add( outrasFuncoesLabel ); - - gridbag.setConstraints( outrasFuncoesPanel, constraints ); - resultadoOuterPanel.add( outrasFuncoesPanel ); - - for( int n = 0; n < outrasFuncoesTexts.length; n++ ) - { - constraints.weightx = 0.1; - constraints.gridwidth = 1; - pad = new JPanel(); - gridbag.setConstraints( pad, constraints ); - resultadoOuterPanel.add( pad ); - - constraints.weightx = 0; - gridbag.setConstraints( outrasFuncoesLabels[ n ], constraints ); - resultadoOuterPanel.add( outrasFuncoesLabels[ n ] ); - - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( outrasFuncoesTexts[ n ], constraints ); - resultadoOuterPanel.add( outrasFuncoesTexts[ n ] ); - new CopyPasteHandler( outrasFuncoesTexts[ n ] ); - } - - new CopyPasteHandler( especificarText ); - new CopyPasteHandler( recomendacoesText ); - } - - private void setupComponentsHashtable() - { - components = new ComponentsHashtable(); - components.putDummy( ExameData.TIPO ); - components.putComponent( ExameData.DATA, dataExamePanel ); - components.putComponent( ExameData.OCASIONAL, ocasionalPanel ); - components.putComponent( ExameData.OUTRO_TIPO, especificarText ); - components.putComponent( ExameData.PROXIMO_EXAME, proximoExamePanel ); - components.putComponent( ExameData.RESULTADO, resultadoPanel ); - components.putComponent( ExameData.OUTRA_FUNCAO_1, outrasFuncoesTexts[ 0 ] ); - components.putComponent( ExameData.OUTRA_FUNCAO_2, outrasFuncoesTexts[ 1 ] ); - components.putComponent( ExameData.OUTRA_FUNCAO_3, outrasFuncoesTexts[ 2 ] ); - components.putComponent( ExameData.OUTRA_FUNCAO_4, outrasFuncoesTexts[ 3 ] ); - components.putComponent( ExameData.OUTRAS_RECOMENDACOES, recomendacoesText ); - components.putDummy( ExameData.INACTIVO ); - components.putDummy( ExameData.TRABALHADOR ); - components.putDummy( ExameData.MEDICO ); - components.putDummy( ExameData.PDF ); - components.putDummy( ExameData.FO ); - } - - public void stateChanged( ChangeEvent e ) - { - if( e.getSource().equals( ocasionalRadio ) ) - { - ocasionalPanel.setEnabled( ocasionalRadio.isSelected() && ocasionalRadio.isEnabled() ) ; - } -// else if( e.getSource().equals( outroRadio ) ) -// { -// especificarText.setEnabled( outroRadio.isSelected() && outroRadio.isEnabled() ); -// } - } - - - public void fill( Object value ) - { - clear(); - trabalhadorID = ( Integer ) value; - if( trabalhadorID == null ) - { - return; - } - try - { - Integer marcacaoID = provider.getMarcacaoIDByTrabalhador( trabalhadorID ); - - if( marcacaoID != null ) - { - marcacao = ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, marcacaoID ); - proximoExamePanel.setDate( (Date) marcacao.get( Marcacao.DATA ) ); - } - Object dadosMarcacao[] = provider.getDadosUltimaMarcacao( trabalhadorID ); - if( dadosMarcacao != null ) - { - dataExamePanel.setDate( ( Date ) dadosMarcacao[ 0 ] ); - Integer tipo = ( Integer ) dadosMarcacao[ 1 ]; - int tipoValue = tipo != null ? tipo.intValue() : 0; - tipoGroup.setIntSelected( tipoValue > 0 ? tipoValue - 1 : 0 ); - } - - } - catch( Exception ex ) - { - ex.printStackTrace(); - return; - } - -// Integer trabID = (Integer) value; -// if( trabID == null ) -// { -// return; -// } -// try -// { -// Integer id = provider.getLastExameIDForTrabalhador( trabID ); -// if( id == null ) -// { -// return; -// } -// MetaObject exame = provider.load( provider.EXAMES, new DBKey( id ) ); -// byte pdf[] = (byte []) exame.getProperty( provider.PDF ); -// if( pdf != null ) -// { -// FileOutputStream fos = new FileOutputStream( "C:\\teste.pdf" ); -// fos.write( pdf ); -// fos.close(); -// } -// } -// catch( Exception ex ) -// { -// ex.printStackTrace(); -// return; -// } - } - - public Object save() - { - StringBuffer msg = new StringBuffer(); - boolean hasMsg = false; - boolean hasData = false; - ExameData exame; - Date dataExame = dataExamePanel.getDate(); - if( dataExame == null ) - { - dataExame = new Date(); - } - Calendar cal = Calendar.getInstance(); - cal.add( Calendar.DAY_OF_MONTH, 1 ); - if( !cal.getTime().after( dataExame ) ) - { - throw new ValuesException( "N\u00E3o \u00E9 poss\u00EDvel gravar exames com datas futuras." ); - } - try - { - String recomendacoes = recomendacoesText.getText(); - String linhas[] = recomendacoes.split( "\\n" ); - Vector linhasV = new Vector(); - for( int n = 0; n < linhas.length; n++ ) - { - if( linhas[ n ].trim().length() > 0 ) - { - linhasV.add( linhas[ n ] ); - } - } - if( linhasV.size() > 0 ) - { - linhas = ( String[] ) linhasV.toArray( new String[0] ); - boolean compress = false; - if( linhas.length == 2 ) - { - linhas[ 0 ] += " "; - } - recomendacoes = ""; - for( int n = 0; n < linhas.length; n++ ) - { - recomendacoes += linhas[ n ]; - } - } - recomendacoesText.setText( recomendacoes.trim() ); - -// exame = provider.createObject( FichaDataProvider.EXAMES ); - exame = new ExameData(); -// DBField fields[] = FichaDataProvider.EXAMES.getInsertFields(); -// String exameFields[] = new String[ fields.length ]; -// for( int i = 0; i < exameFields.length; ++i ) -// { -// exameFields[ i ] = fields[ i ].FULL_NAME; -// } -// Hashtable hash = new Hashtable(); -// ComponentController.save( exameFields, hash, components ); -// hash.put( FichaDataProvider.T_EXAMES + "." + FichaDataProvider.INACTIVO, "n" ); -// Enumeration enum = hash.keys(); -// while( enum.hasMoreElements() ) -// { -// String name = ( String )enum.nextElement(); -// exame.setProperty( name, hash.get( name ) ); -// } - String names[] = exame.getFieldNames(); - Hashtable hash = new Hashtable(); - ComponentController.save( names, hash, components ); - exame.setHashData( hash ); - - int tipo = 0; - if( admissaoRadio.isSelected() ) - { - tipo = 1; - } - else if( periodicoRadio.isSelected() ) - { - tipo = 2; - } - else if( ocasionalRadio.isSelected() ) - { - tipo = 3; - } -// else if( outroRadio.isSelected() ) -// { -// tipo = 4; -// } -// exame.setProperty( FichaDataProvider.TIPO, new Integer( tipo ) ); - exame.set( ExameData.TIPO, new Integer( tipo ) ); - if( tipo != 3 ) - { -// exame.setProperty( FichaDataProvider.EXAMES.getFieldByName( FichaDataProvider.OCASIONAL ).FULL_NAME, null ); - exame.set( ExameData.OCASIONAL, null ); -// exame.setProperty( FichaDataProvider.EXAMES.getFieldByName( FichaDataProvider.OUTRO_TIPO ).FULL_NAME, "" ); - exame.set( ExameData.OUTRO_TIPO, "" ); - } - else - { - Integer ocasionalID = ( Integer )ocasionalPanel.save(); - if( ocasionalID == null || ocasionalID.intValue() != 10 ) - { -// exame.setProperty( FichaDataProvider.EXAMES.getFieldByName( FichaDataProvider.OUTRO_TIPO ).FULL_NAME, "" ); - exame.set( ExameData.OUTRO_TIPO, "" ); - } - } - } - catch( Exception ex ) - { - ex.printStackTrace(); - return null; - } - if( hasMsg ) - { - throw new ValuesException( msg.toString() ); - } - return exame; - } - - public void clear() - { - String names[] = (String[])components.keySet().toArray( new String[0] ); - ComponentController.clear( names, components ); - tipoGroup.setIntSelected( 0 ); - dataExamePanel.setDate( new Date() ); - tipoProximoPanel.setSelected( new Integer( 2 ) ); - marcacao = null; - } - - public void setEnabled( boolean enable ) - { - String names[] = (String[])components.keySet().toArray( new String[0] ); - ComponentController.setEnabled( names, enable, components ); - admissaoRadio.setEnabled( enable ); - periodicoRadio.setEnabled( enable ); - ocasionalRadio.setEnabled( enable ); -// outroRadio.setEnabled( enable ); - ocasionalPanel.setEnabled( ocasionalRadio.isSelected() && ocasionalRadio.isEnabled() ) ; -// especificarText.setEnabled( outroRadio.isSelected() && outroRadio.isEnabled() ); - setEspecificarState(); - } - - public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent) - { - setEspecificarState(); - } - - public void setEspecificarState() - { - Integer id = ( Integer )ocasionalPanel.save(); - if( id != null && id.intValue() == 10 ) - { - especificarText.setEnabled( ocasionalRadio.isSelected() && ocasionalRadio.isEnabled() ); - } - else - { - especificarText.setEnabled( false ); - } - } - - public Integer getMotivoProximoExame() - { - return tipoProximoPanel.getSelected(); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoConstants.java b/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoConstants.java deleted file mode 100644 index 6fb08f27..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoConstants.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * FichaAptidaoConstants.java - * - * Created on May 14, 2007, 5:12 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.ficha; - -/** - * - * @author lflores - */ -public interface FichaAptidaoConstants -{ - /* unicode - private final String SQUARE = "☐"; - private final String CHECKED = "☑";*/ -/* windows arial circle (full circle) */ - public static final String SQUARE = "○"; - public static final String CHECKED = "●"; - - public static final String PORTARIA = "portaria"; - public static final String DESIGNACAO_SOCIAL = "designacao_social"; - public static final String ESTABELECIMENTOS_NOME = "estabelecimentos.nome"; - public static final String ESTABELECIMENTOS_LOCALIDADE = "estabelecimentos.localidade"; - public static final String SERVICO_SAUDE_TIPO_INTERNO = "servico_saude_tipo_interno"; - public static final String SERVICO_SAUDE_TIPO_INTEREMPRESAS = "servico_saude_tipo_interempresas"; - public static final String SERVICO_SAUDE_TIPO_EXTERNO = "servico_saude_tipo_externo"; - public static final String SERVICO_SAUDE_TIPO_SNS = "servico_saude_tipo_sns"; - public static final String SERVICO_SAUDE_DESIGNACAO = "servico_saude_designacao"; - public static final String SERVICO_HIGIENE_TIPO_INTERNO = "servico_higiene_tipo_interno"; - public static final String SERVICO_HIGIENE_TIPO_INTEREMPRESAS = "servico_higiene_tipo_interempresas"; - public static final String SERVICO_HIGIENE_TIPO_EXTERNO = "servico_higiene_tipo_externo"; - public static final String SERVICO_HIGIENE_TIPO_OUTRO = "servico_higiene_tipo_outro"; - public static final String SERVICO_HIGIENE_DESIGNACAO = "servico_higiene_designacao"; - public static final String TRABALHADORES_NOME = "trabalhadores.nome"; - 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 EXAMES_DATA = "exames.data"; - public static final String TIPO_ADMISSAO = "tipo_admissao"; - public static final String TIPO_PERIODICO = "tipo_periodico"; - public static final String TIPO_OCASIONAL = "tipo_ocasional"; - public static final String TIPO_APOS_DOENCA = "tipo_apos_doenca"; - public static final String TIPO_APOS_ACIDENTE = "tipo_apos_acidente"; - public static final String TIPO_PEDIDO_TRABALHADOR = "tipo_pedido_trabalhador"; - public static final String TIPO_PEDIDO_EMPRESA = "tipo_pedido_empresa"; - public static final String TIPO_MUDANCA_FUNCAO = "tipo_mudanca_funcao"; - public static final String TIPO_TRABALHO = "tipo_trabalho"; - public static final String TIPO_OUTRO = "tipo_outro"; - public static final String TIPO_OUTRO_TEXTO = "tipo_outro_texto"; - public static final String RESULTADO_APTO = "resultado_apto"; - public static final String RESULTADO_APTO_CONDICIONALMENTE = "resultado_apto_condicionalmente"; - public static final String RESULTADO_INAPTO_TEMP = "resultado_inapto_temp"; - public static final String RESULTADO_INAPTO_DEF = "resultado_inapto_def"; - 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 OUTRAS_RECOMENDACOES = "outras_recomendacoes"; - public static final String PROXIMO_EXAME = "proximo_exame"; - public static final String MEDICOS_NOME = "medicos.nome"; - public static final String NUMERO_CEDULA = "numero_cedula"; -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoCreator.java b/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoCreator.java deleted file mode 100644 index 36e0e272..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoCreator.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * FichaAptidaoCreator.java - * - * Created on May 14, 2007, 4:50 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.ficha; - -import com.evolute.utils.fop.FOPCreator; -import com.evolute.utils.fop.FOPPrinter; -import com.evolute.utils.fop.PDFCreator; -import com.evolute.utils.strings.UnicodeChecker; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.util.HashMap; - -/** - * - * @author lflores - */ -public class FichaAptidaoCreator implements FichaAptidaoConstants -{ - private final FOPCreator fopCreator; - private final PDFCreator pdfCreator; - private final FOPPrinter fopPrinter; - - private static FichaAptidaoCreator creator = null; - - /** Creates a new instance of FichaAptidaoCreator */ - private FichaAptidaoCreator() - { - fopCreator = FOPCreator.getFOPCreator(); - pdfCreator = PDFCreator.getPDFCreator(); - fopPrinter = FOPPrinter.getFOPPrinter(); - } - - public static FichaAptidaoCreator getCreator() - { - if( creator == null ) - { - creator = new FichaAptidaoCreator(); - } - return creator; - } - - public void print( byte fo[] ) - throws Exception - { - ByteArrayInputStream in = new ByteArrayInputStream( fo ); - fopPrinter.printFO( in, true, true, null ); -// System.out.println( "DONE" ); - } - - public void printSilent( byte fo[], String printerName ) - throws Exception - { - ByteArrayInputStream in = new ByteArrayInputStream( fo ); - fopPrinter.printFO( in, true, false, null ); - } - - public byte[] createFO( HashMap values ) - throws Exception - { - StringBuilder buff = new StringBuilder( "\n\n" ); - - values.put( PORTARIA, "Portaria n. 299/2007, de 16 de Março" ); - -// ☐ square -// ☑ checked square - - for( String key: values.keySet() ) - { - buff.append( "\t<" + key + ">" ); - String val = values.get( key ); - buff.append( UnicodeChecker.parseToUnicode( "&#x", ";", val, true ) ); - buff.append( "\n" ); - } - buff.append( "" ); - String xml = buff.toString(); - - System.out.println( "XML: " + xml ); - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - InputStream xmlIn = new ByteArrayInputStream( xml.getBytes() ); - - InputStream xslStream = getClass().getClassLoader().getResourceAsStream( "siprp/ficha/ficha_aptidao.xsl" ); - fopCreator.createFOfromXML( xmlIn, xslStream, out ); - // System.out.println( "FO created" ); - - return out.toByteArray(); - } - - public byte[] createPDF( byte[] fo ) - throws Exception - { - return pdfCreator.createPdfFromFo( fo ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoEditorManager.java b/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoEditorManager.java deleted file mode 100644 index ce664623..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoEditorManager.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * FichaAptidaoEditorManager.java - * - * Created on 30 de Marco de 2004, 19:23 - */ - -package siprp.ficha; - -import com.evolute.utils.editormanager.*; - -/** - * - * @author fpalma - */ -public class FichaAptidaoEditorManager extends EditorManager -{ - private static final EditorManagerFactory FACTORY = new FichaAptidaoEditorManagerFactory(); - - public static EditorManagerFactory getEditorManagerFactory() - { - return FACTORY; - } - - /** Creates a new instance of FichaAptidaoEditorManager */ - public FichaAptidaoEditorManager( Editor ed, int i ) - { - super( ed, i ); - } - - /** Creates a new instance of FichaAptidaoEditorManager */ - public FichaAptidaoEditorManager( Editor ed, int i, EditorManagerInterface subMan ) - { - super( ed, i, subMan ); - throw new RuntimeException( "FichaAptidaoEditorManager cannot have subManagers" ); - } - - /** Creates a new instance of FichaAptidaoEditorManager */ - public FichaAptidaoEditorManager( Editor ed, int i, EditorManagerInterface subMan[] ) - { - super( ed, i, subMan ); - throw new RuntimeException( "FichaAptidaoEditorManager cannot have subManagers" ); - } - - public boolean isEditing() - { - if( state != STATE_UNSELECT ) - { - return true; - } - return false; - } - - public void enable() - { -// System.out.println( "EditorManager: enable " + this ); - editor.enableComponents( index, false ); - // new, edit, cancel, save, delete, select - editor.actions( index, true, false, false, false, false, true ); - enabled = true; - } - - public void disable() - { -// System.out.println( "EditorManager: disable " + this ); - editor.clear( index ); - editor.enableComponents( index, false ); - // new, edit, cancel, save, delete, select - editor.actions( index, false, false, false, false, false, false ); - enabled = false; - state = STATE_UNSELECT; - } - - public void unlock(boolean direction) - { - editor.enableComponents( index, false ); - if( enabled ) - { - if( state == STATE_UNSELECT ) - { - // new, edit, cancel, save, delete, select - editor.actions( index, true, false, false, false, false, true ); - } - else - { - // new, edit, cancel, save, delete, select - editor.actions( index, true, true, false, false, true, true ); - } - } - } - - public void select() - { -// System.out.println( "EditorManager: select " + this ); - // new, edit, cancel, save, delete, select - editor.actions( index, true, true, true, true, true, true ); - state = STATE_EDIT; - } - - public void unselect() - { -// System.out.println( "EditorManager: select " + this ); - // new, edit, cancel, save, delete, select - editor.actions( index, true, false, false, false, false, true ); - state = STATE_UNSELECT; - } - - public void newItem() - { -// System.out.println( "EditorManager: new " + this ); - editor.enableComponents( index, true ); - // new, edit, cancel, save, delete, select - editor.actions( index, false, false, true, true, true, false ); - state = STATE_NEW; - } - - public void cancelItem() - { -// System.out.println( "EditorManager: cancel " + this ); - if( state == STATE_NEW ) - { - editor.clear( index ); - editor.enableComponents( index, false ); - // new, edit, cancel, save, delete, select - editor.actions( index, true, false, false, false, false, true ); - state = STATE_UNSELECT; - } - else if( state == STATE_EDIT ) - { - editor.reload( index ); - editor.enableComponents( index, true ); - // new, edit, cancel, save, delete, select - editor.actions( index, true, true, true, true, true, true ); - state = STATE_EDIT; - } - } - - public void saveItem() - { -// System.out.println( "EditorManager: save " + this ); - if( ! editor.save( index ) ) - { - return; - } - editor.enableComponents( index, false ); - // new, edit, cancel, save, delete, select - editor.actions( index, true, true, false, false, true, true ); - state = STATE_EDIT; - } - - public void deleteItem() - { -// System.out.println( "EditorManager: delete " + this ); - if( editor.delete( index ) ) - { - editor.clear( index ); - editor.enableComponents( index, false ); - // new, edit, cancel, save, delete, select - editor.actions( index, true, false, false, false, false, true ); - state = STATE_UNSELECT; - } - } - - public void refresh() - { -// System.out.println( "EditorManager: refresh " + this ); - if( !enabled ) - { - disable(); - return; - } - switch( state ) - { - case STATE_NEW: - editItem(); - state = STATE_NEW; - break; - case STATE_EDIT: - editItem(); - break; - case STATE_SELECT: - throw new RuntimeException( "FichaAptidaoEditorManager cannot be in STATE_SELECT" ); - case STATE_UNSELECT: - enable(); - break; - } - } - - public void editItem() - { - state = STATE_EDIT; - editor.actions( index, false, false, true, true, true, false ); - } - - public void lock(boolean direction) - { - throw new RuntimeException( "lock cannot be called on FichaAptidaoEditorManager" ); - } - - public void registerMain(EditorManagerInterface mainMan) - { - throw new RuntimeException( "registerMain cannot be called on FichaAptidaoEditorManager" ); - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoEditorManagerFactory.java b/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoEditorManagerFactory.java deleted file mode 100644 index e7d4196f..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoEditorManagerFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * FichaAptidaoEditorManagerFactory.java - * - * Created on 30 de Marco de 2004, 20:48 - */ - -package siprp.ficha; - -import com.evolute.utils.editormanager.*; -/** - * - * @author fpalma - */ -public class FichaAptidaoEditorManagerFactory - implements EditorManagerFactory -{ - - /** Creates a new instance of FichaAptidaoEditorManagerFactory */ - public FichaAptidaoEditorManagerFactory() - { - } - - public EditorManagerInterface createEditorManager(Editor ed, int i) - { - return new FichaAptidaoEditorManager( ed, i ); - } - - public EditorManagerInterface createEditorManager(Editor ed, int i, EditorManagerInterface[] subMan) - { - return new FichaAptidaoEditorManager( ed, i, subMan ); - } - - public EditorManagerInterface createEditorManager(Editor ed, int i, EditorManagerInterface subMan) - { - return new FichaAptidaoEditorManager( ed, i, subMan ); - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java b/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java deleted file mode 100644 index 27e45569..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java +++ /dev/null @@ -1,860 +0,0 @@ -/* - * FichaWindow.java - * - * Created on 29 de Marco de 2004, 11:50 - */ - -package siprp.ficha; - -import siprp.*; -import siprp.data.*; -import siprp.importer.*; -import siprp.medicina.*; - -import java.awt.*; -import java.io.*; -import java.util.*; -import javax.swing.*; -import java.text.*; - -import com.evolute.utils.*; -import com.evolute.utils.data.*; -import com.evolute.utils.jdo.*; -import com.evolute.utils.metadb.*; -import com.evolute.utils.strings.*; -import com.evolute.utils.tracker.*; -import com.evolute.utils.ui.*; -import com.evolute.utils.ui.panel.*; -import com.evolute.utils.ui.search.*; -import com.evolute.utils.ui.window.*; - -/** - * - * @author fpalma - */ -public class FichaWindow extends TabbedWindow - implements ListAction, FichaAptidaoConstants -{ - private JDOProvider JDO; - - private UpperPanel upperPanel; - private EmpresaPanel empresaPanel; - private TrabalhadorPanel trabalhadorPanel; - private ObservacoesPanel observacoesPanel; - private ExamePanel examePanel; - - private FichaDataProvider fdpProvider; - private MarcacoesMedicinaHandler marcacoesHandler; - private Integer empresaID; - private Integer estabelecimentoID; - private Integer trabalhadorID; - - private final ExamePDF ePDF = new ExamePDF(); - - private static int permissions[][] = - new int[][]{ { NEW_INDEX, CANCEL_INDEX, SAVE_INDEX } }; - - private static FichaWindow window = null; - - private Integer imposedTrabalhadorID = null; - private SaveExameListener exameListener = null; - - /** Creates a new instance of FichaWindow */ - private FichaWindow() - throws Exception - { - super( new UpperPanel(), new String[]{ "Empresa/Trabalhador", "Exame" }, - createPermissions( permissions ) ); - setEditorManagerFactory( FichaAptidaoEditorManager.getEditorManagerFactory() ); - upperPanel = (UpperPanel) getUpperPanel(); - upperPanel.owner = this; - fdpProvider = ( FichaDataProvider ) FichaDataProvider.getProvider(); - JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); - marcacoesHandler = new MarcacoesMedicinaHandler(); - setupComponents(); - } - - public static FichaWindow getWindow() - throws Exception - { - if( window == null ) - { - window = new FichaWindow(); - } - return window; - } - - private void setupComponents() - throws Exception - { - setSize( 700, 640 ); - setResizable( false ); - setTitle( "Ficha de Aptid\u00e3o" ); - - JPanel empresaTrabalhadorPanel = getTab( 0 ); - JPanel exameRecomendacoesPanel = getTab( 1 ); - - GridBagLayout gridbag = new GridBagLayout(); - empresaTrabalhadorPanel.setLayout( gridbag ); - GridBagConstraints constraints = new GridBagConstraints(); - constraints.insets = new Insets( 0, 1, 0, 1 ); - constraints.fill = GridBagConstraints.BOTH; - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.gridheight = 1; - constraints.weighty = 0; - - empresaPanel = new EmpresaPanel(); - empresaPanel.setEnabled( false ); - gridbag.setConstraints( empresaPanel, constraints ); - empresaTrabalhadorPanel.add( empresaPanel ); - - constraints.weighty = 0; - trabalhadorPanel = new TrabalhadorPanel(); - gridbag.setConstraints( trabalhadorPanel, constraints ); - empresaTrabalhadorPanel.add( trabalhadorPanel ); - - constraints.weighty = 1; - observacoesPanel = new ObservacoesPanel(); - gridbag.setConstraints( observacoesPanel, constraints ); - empresaTrabalhadorPanel.add( observacoesPanel ); - - - gridbag = new GridBagLayout(); - exameRecomendacoesPanel.setLayout( gridbag ); - constraints = new GridBagConstraints(); - constraints.insets = new Insets( 0, 1, 0, 1 ); - constraints.fill = GridBagConstraints.BOTH; - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.gridheight = 1; - constraints.weighty = 0; - - constraints.weighty = 1; - examePanel = new ExamePanel(); - gridbag.setConstraints( examePanel, constraints ); - exameRecomendacoesPanel.add( examePanel ); - - registerAction( new ActionHandler(){ - public void execute() - { - print(); - } - - public boolean activate( boolean newAction, boolean editAction, - boolean cancelAction, boolean saveAction, - boolean deleteAction, boolean selectAction ) - { - return saveAction || editAction; - } - }, "Imprimir", - "Imprimir Ficha", "print", - 0, true ); - - registerAction( new ActionHandler(){ - public void execute() - { - printOld(); - } - - public boolean activate( boolean newAction, boolean editAction, - boolean cancelAction, boolean saveAction, - boolean deleteAction, boolean selectAction ) - { - return saveAction || editAction; - } - }, "Imprimir Fichas Anteriores", - "Imprimir Fichas Anteriores", null, - 0, false ); - - registerAction( new ActionHandler(){ - public void execute() - { - deleteOld(); - } - - public boolean activate( boolean newAction, boolean editAction, - boolean cancelAction, boolean saveAction, - boolean deleteAction, boolean selectAction ) - { - return saveAction || editAction; - } - }, "Apagar Fichas Anteriores", - "Apagar Fichas Anteriores", null, - 0, false ); - -// registerAction( new ActionHandler(){ -// public void execute() -// { -// excel(); -// } -// -// public boolean activate( boolean newAction, boolean editAction, -// boolean cancelAction, boolean saveAction, -// boolean deleteAction, boolean selectAction ) -// { -// return saveAction; -// } -// }, "Importar", -// "Importar de Excel", "excel", -// 0, true ); - } - - public boolean save( int index ) - { - new ProgressDialog( this, "A gravar...", - new Runnable(){ - public void run() - { - - } - }); - StringBuilder msg = new StringBuilder(); - MedicoData medico; - try - { - medico = (MedicoData)upperPanel.save(); - } - catch( ValuesException vex ) - { - msg.append( vex.getMessage() ); - medico = null; - } - EstabelecimentoData estabelecimento; - try - { - estabelecimento = (EstabelecimentoData)empresaPanel.save(); - } - catch( ValuesException vex ) - { - msg.append( vex.getMessage() ); - estabelecimento = null; - } - TrabalhadorData trabalhador; - try - { - trabalhador = (TrabalhadorData)trabalhadorPanel.save(); - } - catch( ValuesException vex ) - { - msg.append( vex.getMessage() ); - trabalhador = null; - } - ExameData exame; - try - { - exame = (ExameData)examePanel.save(); - } - catch( ValuesException vex ) - { - msg.append( vex.getMessage() ); - exame = null; - } - if( estabelecimento == null || trabalhador == null || exame == null || medico == null ) - { - JOptionPane.showMessageDialog( this, msg.toString(), "Erro...", JOptionPane.ERROR_MESSAGE ); - return false; - } - estabelecimento.set( EstabelecimentoData.NOME_PLAIN, - com.evolute.utils.strings.StringPlainer.convertString( ( String ) - estabelecimento.get( EstabelecimentoData.NOME ) ) ); - -// trabalhador.setProperty( FichaDataProvider.R_TRABALHADOR_ESTABELECIMENTO, estabelecimento ); -// trabalhador.setProperty( FichaDataProvider.OBSERVACOES, observacoesPanel.save() ); - trabalhador.set( TrabalhadorData.ESTABELECIMENTO, estabelecimento ); - trabalhador.set( TrabalhadorData.OBSERVACOES, observacoesPanel.save() ); - trabalhador.set( TrabalhadorData.NOME_PLAIN, - com.evolute.utils.strings.StringPlainer.convertString( ( String ) - trabalhador.get( TrabalhadorData.NOME ) ) ); - - -// exame.setProperty( FichaDataProvider.R_EXAME_MEDICO, medico ); -// exame.setProperty( FichaDataProvider.R_EXAME_TRABALHADOR, trabalhador ); - exame.set( ExameData.MEDICO, medico ); - exame.set( ExameData.TRABALHADOR, trabalhador ); - try - { - // lflores - disable FO for now - byte fo[] = null; //createFO( exame ); - -// System.out.println( "FO sz: " + fo.length ); - exame.set( ExameData.FO, fo ); - exame.set( ExameData.PDF, createPDF( exame ) ); - -// empresa.save(); -// estabelecimento.save(); - - exame.save(); - trabalhador.save(); - try - { - if( medico != null ) - { - fdpProvider.setMedicoForEstabelecimento( ( Integer ) estabelecimento.get( EstabelecimentoData.ID ), - ( Integer ) medico.get( MedicoData.ID ) ); - } - } - catch( Exception mex ) - { - } -// fdpProvider.savePDF( exame ); - -// DBKey key = trabalhador.getPrimaryKeyValue(); -// DBField fields[] = FichaDataProvider.TRABALHADORES.getPrimaryKey(); -// trabalhadorID = new Integer( ((Number)key.getFieldValue( fields[ 0 ] )).intValue() ); - trabalhadorID = ( Integer ) trabalhador.get( TrabalhadorData.ID ); - try - { - //Marcacao.saveMarcacaoConsultaForTrabalhadorID( trabalhadorID, (Date)exame.get( ExameData.PROXIMO_EXAME ) ); - marcacoesHandler.ajustarMarcacoes( - trabalhadorID, (Integer)exame.get( ExameData.TIPO ), - (Date)exame.get( ExameData.DATA ), - examePanel.getMotivoProximoExame(), (Date)exame.get( ExameData.PROXIMO_EXAME ) ); - } - catch( Exception iex ) - { - iex.printStackTrace(); - } -// createPDF( exame ); -// print(); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a guardar", true ); - return false; - } - if( exameListener != null ) - { - exameListener.exameSaved( trabalhadorID, ( Integer )exame.get( ExameData.ID ) ); - exameListener = null; - } - return true; - } - - public boolean newItem( int index ) - { - exameListener = null; - if( imposedTrabalhadorID == null ) - { - fdpProvider.setSearch( FichaDataProvider.SEARCH_EMPRESAS ); - SearchDialog search; - Integer oldID = empresaID; - - search = new SearchDialog( fdpProvider, null, false, null, true ); - empresaID = ( Integer )search.getSelected(); - - if( empresaID == null ) - { - if( search.getIsNew() ) - { - estabelecimentoID = null; - trabalhadorID = null; - clear( 0 ); - return true; - } - else - { - return false; - } - } - - fdpProvider.setSearch( FichaDataProvider.SEARCH_ESTABELECIMENTOS ); - fdpProvider.setSearchID( FichaDataProvider.SEARCH_EMPRESAS, empresaID.intValue() ); - - search = new SearchDialog( fdpProvider, null, false, null, true ); - estabelecimentoID = ( Integer )search.getSelected(); - - if( estabelecimentoID == null ) - { - if( search.getIsNew() ) - { - trabalhadorID = null; - reload(0); - return true; - } - else - { - return false; - } - } - - fdpProvider.setSearch( FichaDataProvider.SEARCH_TRABALHADORES ); - fdpProvider.setSearchID( FichaDataProvider.SEARCH_ESTABELECIMENTOS, estabelecimentoID.intValue() ); - search = new SearchDialog( fdpProvider, null, false, null, true ); - trabalhadorID = ( Integer )search.getSelected(); - if( trabalhadorID == null && search.getIsNew() ) - { - reload(0); - return true; - } - } - else - { - trabalhadorID = imposedTrabalhadorID; - imposedTrabalhadorID = null; - try - { - estabelecimentoID = fdpProvider.getEstabelecimentoIDForTrabalhador( trabalhadorID ); - empresaID = fdpProvider.getEmpresaIDForEstabelecimento( estabelecimentoID ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar dados.", true ); - return false; - } - } - if( trabalhadorID == null ) - { - return false; - } - reload(0); - return true; - } - - public boolean delete( int index ) - { - return true; - } - - public void deleteOld() - { - if( trabalhadorID == null ) - { - return; - } - Vector linhas; - try - { - IDObject fichas[] = fdpProvider.getAllFichasForTrabalhador( trabalhadorID ); - linhas = new Vector( Arrays.asList( fichas ) ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a criar lista de Fichas anteriores", true ); - return; - } - ListActionDialog dialog = - new ListActionDialog( this, "Apagar Fichas Anteriores", new String[]{ "Data" }, linhas, - new ListAction(){ - public String getListActionName() - { - return "Apagar"; - } - - public boolean executeListAction( int line, Object value ) - { - if( value == null ) - { - return true; - } - try - { - delete( ( ( IDObject )value ).getID() ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a Apagar Ficha", true ); - return false; - } - return true; - } - } ); - dialog.setSize( 250, 200 ); - dialog.setVisible( true ); - } - - public void reload( int index ) - { - Integer upperData[] = new Integer[]{ empresaID, estabelecimentoID, trabalhadorID }; - upperPanel.fill( upperData ); - Object empresaData[] = new Object[]{ empresaID, estabelecimentoID }; - empresaPanel.fill( empresaData ); - trabalhadorPanel.fill( trabalhadorID ); - observacoesPanel.fill( trabalhadorID ); - examePanel.fill( trabalhadorID ); - } - - public void enableComponents( int index, boolean enable ) - { - upperPanel.setEnabled( enable ); - empresaPanel.setEnabled( enable ); - trabalhadorPanel.setEnabled( enable ); - observacoesPanel.setEnabled( enable ); - examePanel.setEnabled( enable ); - } - - public void clear( int index ) - { - upperPanel.clear(); - empresaPanel.clear(); - trabalhadorPanel.clear(); - observacoesPanel.clear(); - examePanel.clear(); - } - - public void print() - { - try - { - if( trabalhadorID == null ) - { - System.out.println( "no trab" ); - return; - } - - Integer id = fdpProvider.getLastExameIDForTrabalhador( trabalhadorID ); - if( id == null ) - { - System.out.println( "no id" ); - return; - } - print( id ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "N\u00e3o foi poss\u00edvel imprimir", true ); - } - } - - private void print( Integer exameID ) - throws Exception - { -// MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) ); - ExameData exame = (ExameData) JDO.load( ExameData.class, exameID ); - if( exame == null ) - { - throw new Exception( "N\u00e3o existe exame" ); - } - - // lflores - ignore FO (for now) - byte fo[] = null; //(byte []) exame.get( ExameData.FO ); - byte pdf[] = (byte []) exame.get( ExameData.PDF ); - - if( fo != null ) - { - FichaAptidaoCreator.getCreator().print( fo ); - } - else - { - TrabalhadorData trabalhadorExame = ( TrabalhadorData ) exame.get( ExameData.TRABALHADOR ); - String nomeFicheiro = StringPlainer.convertString( ( String ) trabalhadorExame.get( TrabalhadorData.NOME ) ); - nomeFicheiro = nomeFicheiro.replaceAll( " ", "_" ); - ePDF.print( pdf, nomeFicheiro ); - } - } - - public byte[] createFO( ExameData exame ) - throws Exception - { - HashMap ht = createMapFromExame(exame); -// ExamePDF ePDF = new ExamePDF(); -// return ePDF.createPDF( ht ); - - return FichaAptidaoCreator.getCreator().createFO( ht ); - } - - public byte[] createPDF( ExameData exame ) - throws Exception - { - // byte fo[] = exame.get( ExameData.FO, fo ); - HashMap ht = createMapFromExame( exame ); - return ePDF.createPDF( ht ); -// return FichaAptidaoCreator.getCreator().createPDF( fo ); - } - - private HashMap createMapFromExame(final ExameData exame) - { - MedicoData medico = (MedicoData)exame.get( ExameData.MEDICO ); - TrabalhadorData trabalhador = (TrabalhadorData) exame.get( ExameData.TRABALHADOR ); - EstabelecimentoData estabelecimento = (EstabelecimentoData) trabalhador.get( TrabalhadorData.ESTABELECIMENTO ); - EmpresaData empresa = (EmpresaData) estabelecimento.get( EstabelecimentoData.EMPRESA ); -// empresa.load( empresa.getPrimaryKeyValue() ); - HashMap ht = new HashMap(); - ht.put( DESIGNACAO_SOCIAL, ( String )empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) ); - ht.put( ESTABELECIMENTOS_NOME, ( String )estabelecimento.get( EstabelecimentoData.NOME ) ); - String aux = (String)estabelecimento.get( EstabelecimentoData.LOCALIDADE ); - ht.put( ESTABELECIMENTOS_LOCALIDADE, aux != null ? aux : "" ); - Integer tipo = (Integer)empresa.get( EmpresaData.SERVICO_SAUDE_TIPO ); - ht.put( SERVICO_SAUDE_TIPO_INTERNO, SQUARE ); - ht.put( SERVICO_SAUDE_TIPO_INTEREMPRESAS, SQUARE ); - ht.put( SERVICO_SAUDE_TIPO_EXTERNO, SQUARE ); - ht.put( SERVICO_SAUDE_TIPO_SNS, SQUARE ); - switch( tipo.intValue() ) - { - case 1: - ht.put( SERVICO_SAUDE_TIPO_INTERNO, CHECKED ); - break; - case 2: - ht.put( SERVICO_SAUDE_TIPO_INTEREMPRESAS, CHECKED ); - break; - case 3: - ht.put( SERVICO_SAUDE_TIPO_EXTERNO, CHECKED ); - break; - case 4: - ht.put( SERVICO_SAUDE_TIPO_SNS, CHECKED ); - break; - } - ht.put( SERVICO_SAUDE_DESIGNACAO, ( String )empresa.get( EmpresaData.SERVICO_SAUDE_DESIGNACAO ) ); - tipo = (Integer)empresa.get( EmpresaData.SERVICO_HIGIENE_TIPO ); - ht.put( SERVICO_HIGIENE_TIPO_INTERNO, SQUARE ); - ht.put( SERVICO_HIGIENE_TIPO_INTEREMPRESAS, SQUARE ); - ht.put( SERVICO_HIGIENE_TIPO_EXTERNO, SQUARE ); - ht.put( SERVICO_HIGIENE_TIPO_OUTRO, SQUARE ); - switch( tipo.intValue() ) - { - case 1: - ht.put( SERVICO_HIGIENE_TIPO_INTERNO, CHECKED ); - break; - case 2: - ht.put( SERVICO_HIGIENE_TIPO_INTEREMPRESAS, CHECKED ); - break; - case 3: - ht.put( SERVICO_HIGIENE_TIPO_EXTERNO, CHECKED ); - break; - case 4: - ht.put( SERVICO_HIGIENE_TIPO_OUTRO, CHECKED ); - break; - } - ht.put( SERVICO_HIGIENE_DESIGNACAO, ( String )empresa.get( EmpresaData.SERVICO_HIGIENE_DESIGNACAO ) ); - ht.put( TRABALHADORES_NOME, ( String )trabalhador.get( TrabalhadorData.NOME ) ); - aux = (String)trabalhador.get( TrabalhadorData.SEXO ); - switch( aux.charAt( 0 ) ) - { - case 'm': - ht.put( SEXO, "Masculino" ); - break; - case 'f': - ht.put( SEXO, "Feminino" ); - break; - } - DateFormat df = DateFormat.getDateInstance( DateFormat.SHORT ); - Date data = ( Date )trabalhador.get( TrabalhadorData.DATA_NASCIMENTO ); - ht.put( DATA_NASCIMENTO, data != null ? df.format( data ) : "" ); - aux = (String)trabalhador.get( TrabalhadorData.NACIONALIDADE ); - ht.put( NACIONALIDADE, aux != null ? aux : "" ); - aux = (String)trabalhador.get( TrabalhadorData.NUMERO_MECANOGRAFICO ); - ht.put( NUMERO_MECANOGRAFICO, aux != null ? aux : "" ); - data = ( Date )trabalhador.get( TrabalhadorData.DATA_ADMISSAO ); - ht.put( DATA_ADMISSAO, data != null ? df.format( data ) : "" ); - aux = (String)trabalhador.get( TrabalhadorData.CATEGORIA ); - ht.put( CATEGORIA, aux != null ? aux : "" ); - aux = (String)trabalhador.get( TrabalhadorData.LOCAL_TRABALHO ); - ht.put( LOCAL_TRABALHO, aux != null ? aux : "" ); - aux = (String)trabalhador.get( TrabalhadorData.FUNCAO_PROPOSTA ); - ht.put( FUNCAO_PROPOSTA, aux != null ? aux : "" ); - data = ( Date )trabalhador.get( TrabalhadorData.DATA_ADMISSAO_FUNCAO ); - ht.put( DATA_ADMISSAO_FUNCAO, data != null ? df.format( data ) : "" ); - aux = (String)trabalhador.get( TrabalhadorData.OBSERVACOES ); - ht.put( OBSERVACOES, aux != null ? aux : "" ); - data = ( Date )exame.get( ExameData.DATA ); - ht.put( EXAMES_DATA, data != null ? df.format( data ) : "" ); - tipo = (Integer)exame.get( ExameData.TIPO ); - ht.put( TIPO_ADMISSAO, SQUARE ); - ht.put( TIPO_PERIODICO, SQUARE ); - ht.put( TIPO_OCASIONAL, SQUARE ); - - ht.put( TIPO_APOS_DOENCA, SQUARE ); - ht.put( TIPO_APOS_ACIDENTE, SQUARE ); - ht.put( TIPO_PEDIDO_TRABALHADOR, SQUARE ); - ht.put( TIPO_PEDIDO_EMPRESA, SQUARE ); - ht.put( TIPO_MUDANCA_FUNCAO, SQUARE ); - ht.put( TIPO_TRABALHO, SQUARE ); - ht.put( TIPO_OUTRO, SQUARE ); - - switch( tipo.intValue() ) - { - case 1: - ht.put( TIPO_ADMISSAO, CHECKED ); - break; - case 2: - ht.put( TIPO_PERIODICO, CHECKED ); - break; - case 3: - ht.put( TIPO_OCASIONAL, CHECKED ); - tipo = (Integer)exame.get( ExameData.OCASIONAL ); - - switch( tipo.intValue() ) - { - case 1: - ht.put( TIPO_APOS_DOENCA, CHECKED ); - break; - case 2: - ht.put( TIPO_APOS_ACIDENTE, CHECKED ); - break; - case 3: - ht.put( TIPO_PEDIDO_TRABALHADOR, CHECKED ); - break; - case 4: - ht.put( TIPO_PEDIDO_EMPRESA, CHECKED ); - break; - case 5: - ht.put( TIPO_MUDANCA_FUNCAO, CHECKED ); - break; - case 6: - ht.put( TIPO_TRABALHO, CHECKED ); - break; - case 10: - ht.put( TIPO_OUTRO, CHECKED ); - break; - } - break; -// case 4: -// aux = (String)exame.get( ExameData.OUTRO_TIPO ); -// ht.put( "tipo_outro", aux != null ? aux : "" ); -// break; - } - aux = (String)exame.get( ExameData.OUTRO_TIPO ); - ht.put( TIPO_OUTRO_TEXTO, aux != null ? aux : "" ); - tipo = (Integer)exame.get( ExameData.RESULTADO ); - ht.put( RESULTADO_APTO, SQUARE ); - ht.put( RESULTADO_APTO_CONDICIONALMENTE, SQUARE ); - ht.put( RESULTADO_INAPTO_TEMP, SQUARE ); - ht.put( RESULTADO_INAPTO_DEF, SQUARE ); - switch( tipo.intValue() ) - { - case 1: - ht.put( RESULTADO_APTO, CHECKED ); - break; - case 2: - ht.put( RESULTADO_APTO_CONDICIONALMENTE, CHECKED ); - break; - case 3: - ht.put( RESULTADO_INAPTO_TEMP, CHECKED ); - break; - case 4: - ht.put( RESULTADO_INAPTO_DEF, CHECKED ); - break; - } - aux = (String)exame.get( ExameData.OUTRA_FUNCAO_1 ); - ht.put( OUTRA_FUNCAO_1, aux != null ? aux : "" ); - aux = (String)exame.get( ExameData.OUTRA_FUNCAO_2 ); - ht.put( OUTRA_FUNCAO_2, aux != null ? aux : "" ); - aux = (String)exame.get( ExameData.OUTRA_FUNCAO_3 ); - ht.put( OUTRA_FUNCAO_3, aux != null ? aux : "" ); - aux = (String)exame.get( ExameData.OUTRA_FUNCAO_4 ); - ht.put( OUTRA_FUNCAO_4, aux != null ? aux : "" ); - aux = (String)exame.get( ExameData.OUTRAS_RECOMENDACOES ); - ht.put( OUTRAS_RECOMENDACOES, aux != null ? aux : "" ); - data = ( Date )exame.get( ExameData.PROXIMO_EXAME ); - ht.put( PROXIMO_EXAME, data != null ? df.format( data ) : "n/d" ); - aux = (String)medico.get( MedicoData.NOME ); - ht.put( MEDICOS_NOME, aux != null ? aux : "" ); - aux = (String)medico.get( MedicoData.NUMERO_CEDULA ); - ht.put( NUMERO_CEDULA, aux != null ? aux : "" ); - return ht; - } - - private void excel() - { - FileDialog fd = new FileDialog( this, "Escolha um ficheiro Excel:", FileDialog.LOAD ); - fd.setDirectory( System.getProperty( "user.home" ) ); - fd.setFilenameFilter( new FilenameFilter() { - public boolean accept( File dir, String name ) - { - return (name!=null) && (name.indexOf( ".xls" ) != -1); - } - } ); - fd.setVisible( true ); - //String filename = "c:\\test.xls"; - String filename = fd.getFile(); - if( filename != null ) - { - filename = fd.getDirectory() + File.separator + filename; - try - { - Importer importer = new Importer( this, filename, false, Importer.TYPE_ADMISSAO ); - Hashtable hash = importer.getData(); - if( hash != null ) - { - trabalhadorPanel.setData( hash ); - } - } - catch( Exception ex ) - { - ex.printStackTrace(); - JOptionPane.showMessageDialog( this, "Erro a importar", "Erro...", JOptionPane.ERROR_MESSAGE ); - } - } - - } - - private void printOld() - { - if( trabalhadorID != null ) - { - Vector linhas; - try - { - IDObject fichas[] = fdpProvider.getAllFichasForTrabalhador( trabalhadorID ); - linhas = new Vector( Arrays.asList( fichas ) ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a criar lista de Fichas anteriores", true ); - return; - } - ListActionDialog dialog = new ListActionDialog( this, "Imprimir Fichas Anteriores", new String[]{ "Data" }, - linhas, this ); - dialog.setSize( 250, 200 ); - dialog.setVisible( true ); - } - } - - public boolean executeListAction( int line, Object value ) - { - if( value != null ) - { - try - { - print( ( ( IDObject )value ).getID() ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a imprimir Ficha", true ); - return false; - } - } - return true; - } - - public String getListActionName() - { - return "Imprimir"; - } - - private void delete( Integer exameID ) - throws Exception - { -// MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) ); - ExameData exame = (ExameData) JDO.load( ExameData.class, exameID ); - if( exame == null ) - { - throw new Exception( "N\u00e3o existe exame" ); - } - if( JOptionPane.showConfirmDialog( this, - "Tem a certeza que quer apagar o exame de " + exame.get( ExameData.DATA ) + "?", - "...", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null ) == 0 ) - { -// exame.set( ExameData.INACTIVO, "y" ); -// exame.save(); - exame.delete(); - } - } - - public void editTrabalhador( Integer trabalhadorID, SaveExameListener listener ) - { -System.out.println( "edit trabalhador: " + trabalhadorID ); - - if( isVisible() ) - { - toFront(); - } - else - { - setVisible( true ); - } - imposedTrabalhadorID = trabalhadorID; - executeAction( NEW_INDEX ); - exameListener = listener; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/MedicoColumnizedObject.java b/trunk/SIPRPSoft/src/siprp/ficha/MedicoColumnizedObject.java deleted file mode 100644 index 4253604d..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/MedicoColumnizedObject.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * MedicoColumnizedObject.java - * - * Created on 12 de Abril de 2004, 11:53 - */ - -package siprp.ficha; - -import com.evolute.utils.tables.*; - -/** - * - * @author fpalma - */ -public class MedicoColumnizedObject implements ColumnizedObject -{ - private Integer id; - private String nome; - private String numero; - - /** Creates a new instance of MedicoColumnizedObject */ - public MedicoColumnizedObject( Integer id, String nome, String numero ) - { - this.id = id; - this.nome = nome; - this.numero = numero; - } - - public Object getValue( int col ) - { - switch( col ) - { - case 0: - return nome; - - case 1: - return numero; - } - return null; - } - - public Integer getID() - { - return id; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/MedicoEditor.java b/trunk/SIPRPSoft/src/siprp/ficha/MedicoEditor.java deleted file mode 100644 index a6268c29..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/MedicoEditor.java +++ /dev/null @@ -1,270 +0,0 @@ -/* - * MedicoEditor.java - * - * Created on 10 de Abril de 2004, 20:50 - */ - -package siprp.ficha; - -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.metadb.*; -import com.evolute.utils.tables.*; -import com.evolute.utils.ui.*; -import com.evolute.utils.ui.text.*; - -import siprp.*; -import siprp.data.*; - -/** - * - * @author Administrator - */ -public class MedicoEditor extends CustomJDialog - implements ActionListener, ListSelectionListener -{ - static - { - MedicoData.registerOperationHandlerForClass( DisableDeleteHandler.INSTANCE, MedicoData.class ); - } - private JDOProvider JDO; - private FichaDataProvider provider; - private BaseTable table; - private VectorTableModel model; - private JButton okButton; - private JButton cancelarButton; - private JButton novoButton; - private JTextField nomeText; - private JTextField numeroText; - private Integer id; - private boolean isNew = false; - - /** Creates a new instance of MedicoEditor */ - public MedicoEditor( JFrame owner ) - throws Exception - { - super( owner, true ); - provider = (FichaDataProvider)FichaDataProvider.getProvider(); - JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); - setupComponents(); - } - - private void setupComponents() - throws Exception - { - setSize( 600, 300 ); - setResizable( false ); - setTitle( "Criar/Editar M\u00e9dico" ); - centerSuper(); - - model = new VectorTableModel( new String[]{ "Nome", "NC" } ); - table = new BaseTable( model ); - table.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - 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.getAllMedicos(); - Vector medicos = new Vector(); - for( int n = 0; n < obj.length; n++ ) - { - medicos.add( new MedicoColumnizedObject( (Integer)obj[n][0], - (String)obj[n][1], - (String)obj[n][2] ) ); - } - model.setValues( medicos ); - - 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 ); - numeroText = new JTextField(); - numeroText.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 numeroLabel = new JLabel( "N\u00famero" ); - gridbag.setConstraints( numeroLabel, constraints ); - textPanel.add( numeroLabel ); - - gridbag.setConstraints( numeroText, constraints ); - textPanel.add( numeroText ); - - constraints.weighty = 1; - constraints.gridheight = GridBagConstraints.REMAINDER;; - JPanel pad = new JPanel(); - gridbag.setConstraints( pad, constraints ); - textPanel.add( pad ); - - new CopyPasteHandler( nomeText ); - new CopyPasteHandler( numeroText ); - } - - 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( "" ); - numeroText.setText( "" ); - nomeText.setEnabled( true ); - numeroText.setEnabled( true ); - id = null; - isNew = true; - } - } - - public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent) - { - int selected = table.getSelectedRow(); - if( selected == -1 ) - { - return; - } - MedicoColumnizedObject row = (MedicoColumnizedObject)model.getRowAt( selected ); - id = row.getID(); - String nome = (String) row.getValue( 0 ); - String numero = (String) row.getValue( 1 ); - nomeText.setText( nome ); - numeroText.setText( numero ); - nomeText.setEnabled( true ); - numeroText.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 numero = numeroText.getText().trim(); - if( nome.length() == 0 ) - { - JOptionPane.showMessageDialog( this, "O Nome n\u00e3o pode ser vazio.", "Erro...", - JOptionPane.ERROR_MESSAGE ); - return false; - } - try - { - MedicoData medico; - if( id != null ) - { - medico = ( MedicoData ) JDO.load( MedicoData.class, id ); -// medico = provider.load( provider.MEDICOS, new DBKey( id ) ); - } - else - { - medico = new MedicoData(); -// medico = provider.createObject( provider.MEDICOS ); - } -// medico.setProperty( provider.NOME, nome ); -// medico.setProperty( provider.NUMERO_CEDULA, numero ); - medico.set( MedicoData.NOME, nome ); - medico.set( MedicoData.NUMERO_CEDULA, numero ); - medico.save(); - if( id == null ) - { -// DBKey key = medico.getPrimaryKeyValue(); -// DBField fields[] = provider.MEDICOS.getPrimaryKey(); -// id = new Integer( ((Number)key.getFieldValue( fields[ 0 ] )).intValue() ); - id = (Integer)medico.get( MedicoData.ID ); - } - } - catch( Exception ex ) - { -// JOptionPane.showMessageDialog( this, "Erro a gravar...", "Erro...", -// JOptionPane.ERROR_MESSAGE ); - DialogException.showExceptionMessage( ex, "Erro a gravar...", false ); - return false; - } - return true; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/ObservacoesPanel.java b/trunk/SIPRPSoft/src/siprp/ficha/ObservacoesPanel.java deleted file mode 100644 index 68edd548..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/ObservacoesPanel.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * ObservacoesPanel.java - * - * Created on 29 de Marco de 2004, 11:56 - */ - -package siprp.ficha; - -import java.awt.*; -import javax.swing.*; - -import com.evolute.utils.*; -import com.evolute.utils.dataui.*; -import com.evolute.utils.documents.*; -import com.evolute.utils.jdo.*; -import com.evolute.utils.metadb.*; -import com.evolute.utils.ui.text.*; - -import siprp.*; -import siprp.data.*; -/** - * - * @author fpalma - */ -public class ObservacoesPanel extends JPanel - implements ControllableComponent -{ - private JDOProvider JDO; - - private JTextField observacoesText; - - private FichaDataProvider provider; - - /** Creates a new instance of ObservacoesPanel */ - public ObservacoesPanel() - throws Exception - { - provider = (FichaDataProvider)FichaDataProvider.getProvider(); - JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); - setupComponents(); - } - - private void setupComponents() - { - setBorder( BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), - "Observa\u00e7\u00f5es" ) ); - -// JScrollPane scp = new JScrollPane(); -// scp.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); -// scp.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); - observacoesText = new JTextField(); - observacoesText.setDocument( new MaximumLengthDocument( 150 ) ); -// observacoesText.setLineWrap( true ); -// observacoesText.setWrapStyleWord( true ); -// scp.setViewportView( observacoesText ); - - setLayout( new GridLayout( 1, 1, 0, 0 ) ); - add( observacoesText ); - - new CopyPasteHandler( observacoesText ); - } - - public void fill(Object value) - { - clear(); - Integer trabalhadorID = (Integer)value; - if( trabalhadorID != null ) - { - - try - { - TrabalhadorData trabalhador = (TrabalhadorData)JDO.load( TrabalhadorData.class, trabalhadorID ); - String observacoes = (String) trabalhador.get( TrabalhadorData.OBSERVACOES ); - if( observacoes != null ) - { - observacoesText.setText( observacoes ); - } - } - catch( Exception ex ) - { - ex.printStackTrace(); - } - } - } - - public Object save() - { - return observacoesText.getText(); - } - - public void clear() - { - observacoesText.setText( "" ); - } - - public void setEnabled( boolean enable ) - { - observacoesText.setEnabled( enable ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/RecomendacoesPanel.java b/trunk/SIPRPSoft/src/siprp/ficha/RecomendacoesPanel.java deleted file mode 100644 index 7d74be41..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/RecomendacoesPanel.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * RecomendacoesPanel.java - * - * Created on 29 de Marco de 2004, 11:58 - */ - -package siprp.ficha; - -import java.awt.*; -import javax.swing.*; - -import com.evolute.utils.documents.*; -import com.evolute.utils.ui.*; -import com.evolute.utils.ui.calendar.*; -import com.evolute.utils.ui.text.*; - -/** - * - * @author fpalma - */ -public class RecomendacoesPanel extends JPanel -{ - private JTextArea recomendacoesText; - private JCalendarPanel proximoExamePanel; - /** Creates a new instance of RecomendacoesPanel */ - public RecomendacoesPanel() - { - setupComponents(); - } - - private void setupComponents() - { - setBorder( BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), - "Outras Recomenda\u00e7\u00f5es" ) ); - - JScrollPane scp = new JScrollPane(); - scp.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - scp.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); - recomendacoesText = new JTextArea(); - recomendacoesText.setLineWrap( true ); - recomendacoesText.setWrapStyleWord( true ); - recomendacoesText.setDocument( new MaximumLengthDocument( 150 ) ); - scp.setViewportView( recomendacoesText ); - JPanel rightPanel = new JPanel(); - JLabel proximoExameLabel = new JLabel( "Pr\u00f3ximo Exame" ); - proximoExamePanel = new JCalendarPanel( null ); - - setLayout( new GridLayout( 1, 2, 0, 0 ) ); - add( scp ); - add( rightPanel ); - - rightPanel.setLayout( new BorderLayout() ); - rightPanel.add( proximoExameLabel, BorderLayout.WEST ); - rightPanel.add( proximoExamePanel, BorderLayout.CENTER ); - - new CopyPasteHandler( recomendacoesText ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/SaveExameListener.java b/trunk/SIPRPSoft/src/siprp/ficha/SaveExameListener.java deleted file mode 100644 index ccb16da8..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/SaveExameListener.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * SaveExameListener.java - * - * Created on May 17, 2007, 12:33 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.ficha; - -/** - * - * @author lflores - */ -public interface SaveExameListener -{ - public void exameSaved( Integer trabalhadorID, Integer exameID ); -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/TrabalhadorPanel.java b/trunk/SIPRPSoft/src/siprp/ficha/TrabalhadorPanel.java deleted file mode 100644 index c44cbc9d..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/TrabalhadorPanel.java +++ /dev/null @@ -1,477 +0,0 @@ -/* - * TrabalhadorPanel.java - * - * Created on 29 de Marco de 2004, 11:55 - */ - -package siprp.ficha; - -import java.awt.*; -import javax.swing.*; -import java.util.*; - -import com.evolute.utils.*; -import com.evolute.utils.data.*; -import com.evolute.utils.dataui.*; -import com.evolute.utils.date.*; -import com.evolute.utils.jdo.*; -import com.evolute.utils.metadb.*; -import com.evolute.utils.ui.*; -import com.evolute.utils.ui.calendar.*; -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 -{ - private JDOProvider JDO; - 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 ComponentsHashtable components; - private FichaDataProvider provider; - private TrabalhadorData trabalhador; - - /** Creates a new instance of TrabalhadorPanel */ - - public TrabalhadorPanel() - throws Exception - { - provider = (FichaDataProvider)FichaDataProvider.getProvider(); - JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); - setupComponents(); - setupComponentsHashtable(); - } - - - private void setupComponents() - { - setBorder( BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), - "Trabalhador" ) ); - 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 ); - - GridBagLayout gridbag = new GridBagLayout(); - setLayout( gridbag ); - GridBagConstraints constraints = new GridBagConstraints(); - constraints.insets = new Insets( 0, 1, 0, 1 ); - constraints.fill = GridBagConstraints.HORIZONTAL; - constraints.weighty = 0; - constraints.gridheight = 1; - constraints.gridwidth = 1; - constraints.weightx = 0; - - gridbag.setConstraints( nomeLabel, constraints ); - add( nomeLabel ); - - constraints.weightx = 1; - constraints.gridwidth = 3; - gridbag.setConstraints( nomeText, constraints ); - add( nomeText ); - - constraints.gridwidth = 1; - constraints.weightx = 0; - gridbag.setConstraints( sexoLabel, constraints ); - add( sexoLabel ); - - constraints.weightx = 0; - //constraints.gridwidth = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( sexoPanel, constraints ); - add( sexoPanel ); - - constraints.weightx = 0; - constraints.gridwidth = 2; - gridbag.setConstraints( nacionalidadeLabel, constraints ); - add( nacionalidadeLabel ); - - constraints.weightx = 0.5; - constraints.gridwidth = 1; - gridbag.setConstraints( nacionalidadeText, constraints ); - add( nacionalidadeText ); - - constraints.weightx = 0; - constraints.gridwidth = 1; - gridbag.setConstraints( dataNascimentoLabel, constraints ); - add( dataNascimentoLabel ); - - constraints.weightx = 0.5; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( dataNascimentoPanel, constraints ); - add( dataNascimentoPanel ); - - constraints.weightx = 0; - constraints.gridwidth = 2; - gridbag.setConstraints( numeroMecanograficoLabel, constraints ); - add( numeroMecanograficoLabel ); - - constraints.weightx = 0.5; - constraints.gridwidth = 1; - gridbag.setConstraints( numeroMecanograficoText, constraints ); - add( numeroMecanograficoText ); - - constraints.weightx = 0; - constraints.gridwidth = 1; - gridbag.setConstraints( dataAdmissaoLabel, constraints ); - add( dataAdmissaoLabel ); - - constraints.weightx = 0.5; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( dataAdmissaoPanel, constraints ); - add( dataAdmissaoPanel ); - - constraints.weightx = 0; - constraints.gridwidth = 2; - gridbag.setConstraints( categoriaLabel, constraints ); - add( categoriaLabel ); - - constraints.weightx = 0.5; - constraints.gridwidth = 1; - gridbag.setConstraints( categoriaText, constraints ); - add( categoriaText ); - - constraints.weightx = 0; - gridbag.setConstraints( localLabel, constraints ); - add( localLabel ); - - constraints.weightx = 0.5; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( localText, constraints ); - add( localText ); - - constraints.weightx = 0; - constraints.gridwidth = 2; - gridbag.setConstraints( funcaoLabel, constraints ); - add( funcaoLabel ); - - constraints.weightx = 0.5; - constraints.gridwidth = 1; - gridbag.setConstraints( funcaoText, constraints ); - add( funcaoText ); - - constraints.weightx = 0; - constraints.gridwidth = 1; - gridbag.setConstraints( dataAdmissaoFuncaoLabel, constraints ); - add( dataAdmissaoFuncaoLabel ); - - constraints.weightx = 0.5; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( dataAdmissaoFuncaoPanel, constraints ); - add( dataAdmissaoFuncaoPanel ); - - new CopyPasteHandler( nomeText ); - new CopyPasteHandler( nacionalidadeText ); - new CopyPasteHandler( numeroMecanograficoText ); - new CopyPasteHandler( categoriaText ); - new CopyPasteHandler( localText ); - new CopyPasteHandler( funcaoText ); - } - - 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.putDummy( TrabalhadorData.DATA_DEMISSAO ); - components.putDummy( TrabalhadorData.OBSERVACOES ); - components.putDummy( TrabalhadorData.OBSERVACOES_GESTAO ); - components.putDummy( TrabalhadorData.PERFIL ); - components.putDummy( TrabalhadorData.ESTABELECIMENTO ); - components.putDummy( TrabalhadorData.NOME_PLAIN ); - -// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.NOME, nomeText ); -// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.DATA_NASCIMENTO, dataNascimentoPanel ); -// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.NACIONALIDADE, nacionalidadeText ); -// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.NUMERO_MECANOGRAFICO, numeroMecanograficoText ); -// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.DATA_ADMISSAO, dataAdmissaoPanel ); -// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.CATEGORIA, categoriaText ); -// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.LOCAL_TRABALHO, localText ); -// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.FUNCAO_PROPOSTA, funcaoText ); -// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.DATA_ADMISSAO_FUNCAO, dataAdmissaoFuncaoPanel ); -// components.putDummy( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.ESTABELECIMENTO_ID ); -// components.putDummy( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.OBSERVACOES ); -// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.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 ); -// } -// } ); - } - - public void fill(Object value) - { - clear(); - trabalhador = null; - if( value != null ) - { - Integer trabalhadorID = (Integer)value; - if( trabalhadorID != null ) - { - try - { - trabalhador = ( TrabalhadorData ) JDO.load( TrabalhadorData.class, trabalhadorID ); - String names[] = trabalhador.getFieldNames(); - ComponentController.fill( names, trabalhador.getHashData(), components ); -// trabalhador = provider.load( FichaDataProvider.TRABALHADORES, new DBKey( trabalhadorID ) ); -// DBField fields[] = FichaDataProvider.TRABALHADORES.getInsertFields(); -// String trabalhadorFields[] = new String[ fields.length ]; -// Hashtable data = new Hashtable(); -// for( int i = 0; i < trabalhadorFields.length; ++i ) -// { -// trabalhadorFields[ i ] = fields[ i ].FULL_NAME; -// Object fieldValue = trabalhador.getProperty( trabalhadorFields[ i ] ); -// if( fieldValue != null ) -// { -// data.put( trabalhadorFields[ i ], fieldValue ); -// } -// } -// ComponentController.fill( trabalhadorFields, data, components ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar os dados do trabalhador", true ); - } - } - } - - } - - public Object save() - { - StringBuffer msg = new StringBuffer(); - boolean hasMsg = false; - try - { - if( trabalhador == null ) - { -// trabalhador = provider.createObject( FichaDataProvider.TRABALHADORES ); - trabalhador = new TrabalhadorData(); - trabalhador.set( TrabalhadorData.PERFIL, new Integer( 1 ) ); - } -// DBField fields[] = FichaDataProvider.TRABALHADORES.getInsertFields(); -// String trabalhadorFields[] = new String[ fields.length ]; -// for( int i = 0; i < trabalhadorFields.length; ++i ) -// { -// trabalhadorFields[ i ] = fields[ i ].FULL_NAME; -// } -// Hashtable hash = new Hashtable(); -// ComponentController.save( trabalhadorFields, hash, components ); -// Enumeration enum = hash.keys(); -// while( enum.hasMoreElements() ) -// { -// String name = ( String )enum.nextElement(); -// trabalhador.setProperty( name, hash.get( name ) ); -// } - String names[] = trabalhador.getFieldNames(); - Hashtable hash = trabalhador.getHashData(); - ComponentController.save( names, hash, components ); - trabalhador.setHashData( hash ); -// if( ((String)trabalhador.getProperty( FichaDataProvider.NOME )).trim().length() == 0 ) - if( ((String)trabalhador.get( TrabalhadorData.NOME )).trim().length() == 0 ) - { - msg.append( "O trabalhador tem de ter nome\n" ); - hasMsg = true; - } -// if( trabalhador.getProperty( FichaDataProvider.SEXO ) == null ) - if( trabalhador.get( TrabalhadorData.SEXO ) == null ) - { - msg.append( "O trabalhador tem de ter um sexo definido\n" ); - hasMsg = true; - } - } - catch( Exception ex ) - { - ex.printStackTrace(); - return null; - } - if( hasMsg ) - { - throw new ValuesException( msg.toString() ); - } - return trabalhador; - } - - public void clear() - { - String names[] = (String[])components.keySet().toArray( new String[0] ); - ComponentController.clear( names, components ); - trabalhador = null; - } - - public void setEnabled( boolean enable ) - { - String names[] = (String[])components.keySet().toArray( new String[0] ); - ComponentController.setEnabled( names, enable, components ); - } - - public void setData( Hashtable data ) - { - String nome = (String)data.get( Importer.NOME ); - if( nome != null && nome.trim().length() > 0 ) - { - nomeText.setText( nome ); - } - String sexo = (String)data.get( Importer.SEXO ); - if( sexo != null && sexo.trim().length() > 0 ) - { - Integer sexoInt; - if( sexo.trim().toLowerCase().charAt(0) == 'f' ) - { - sexoInt = new Integer( 2 ); - } - else - { - sexoInt = new Integer( 1 ); - } - sexoPanel.fill( sexoInt ); - } - String nacionalidade = (String)data.get( Importer.NACIONALIDADE ); - if( nacionalidade != null && nacionalidade.trim().length() > 0 ) - { - nacionalidadeText.setText( nacionalidade ); - } - String dataNascimento = (String)data.get( Importer.DATA_NASCIMENTO ); - if( dataNascimento != null ) - { - dataNascimentoPanel.setDate( DateUtils.guessDate( dataNascimento ) ); - } - String numeroMecanografico = (String)data.get( Importer.NUMERO_MECANOGRAFICO ); - if( numeroMecanografico != null && numeroMecanografico.trim().length() > 0 ) - { - numeroMecanograficoText.setText( numeroMecanografico ); - } - String dataAdmissao = (String)data.get( Importer.DATA_ADMISSAO ); - if( dataAdmissao != null ) - { - dataAdmissaoPanel.setDate( DateUtils.guessDate( dataAdmissao ) ); - } - String categoria = (String)data.get( Importer.CATEGORIA ); - if( categoria != null && categoria.trim().length() > 0 ) - { - categoriaText.setText( categoria ); - } - String localTrabalho = (String)data.get( Importer.LOCAL_TRABALHO ); - if( localTrabalho != null && localTrabalho.trim().length() > 0 ) - { - localText.setText( localTrabalho ); - } - String funcao = (String)data.get( Importer.FUNCAO ); - if( funcao != null && funcao.trim().length() > 0 ) - { - funcaoText.setText( funcao ); - } - String dataAdmissaoFuncao = (String)data.get( Importer.DATA_ADMISSAO_FUNCAO ); - if( dataAdmissaoFuncao != null ) - { - dataAdmissaoFuncaoPanel.setDate( DateUtils.guessDate( dataAdmissaoFuncao ) ); - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/UpperPanel.java b/trunk/SIPRPSoft/src/siprp/ficha/UpperPanel.java deleted file mode 100644 index 23b2d7d9..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/UpperPanel.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * UpperPanel.java - * - * Created on 29 de Marco de 2004, 17:44 - */ - -package siprp.ficha; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import java.util.*; - -import com.evolute.utils.*; -import com.evolute.utils.data.*; -import com.evolute.utils.dataui.*; -import com.evolute.utils.jdo.*; -import com.evolute.utils.metadb.*; -import com.evolute.utils.ui.*; -import com.evolute.utils.ui.text.*; - -import siprp.*; -import siprp.data.*; - -/** - * - * @author fpalma - */ -public class UpperPanel extends JPanel - implements ControllableComponent, ItemListener -{ - protected JDOProvider JDO; - - protected JFrame owner; - private JTextField empresaText; - private JTextField nomeText; - private JComboBox medicosCombo; - private JTextField cpText; - - private FichaDataProvider provider; - private Hashtable medicosHash; - - /** Creates a new instance of UpperPanel */ - public UpperPanel() - throws Exception - { - provider = (FichaDataProvider)FichaDataProvider.getProvider(); - medicosHash = new Hashtable(); - JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); - setupComponents(); - } - - private void setupComponents() - throws Exception - { - JLabel empresaLabel = new JLabel( "Empresa/Entidade" ); - empresaText = new JTextField(); - empresaText.setEditable( false ); - JLabel nomeLabel = new JLabel( "Nome" ); - nomeText = new JTextField(); - nomeText.setEditable( false ); - JLabel medicoLabel = new JLabel( "M\u00e9dico" ); - medicosCombo = new JComboBox(); - JLabel cpLabel = new JLabel( "c.p." ); - cpText = new JTextField(); - cpText.setEditable( false ); - fillCombo(); - GridBagLayout gridbag = new GridBagLayout(); - setLayout( gridbag ); - GridBagConstraints constraints = new GridBagConstraints(); - constraints.insets = new Insets( 0, 1, 0, 1 ); - constraints.fill = GridBagConstraints.HORIZONTAL; - constraints.gridheight = 1; - constraints.weighty = 0; - - constraints.gridwidth = 1; - constraints.weightx = 0; - gridbag.setConstraints( empresaLabel, constraints ); - add( empresaLabel ); - - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 1; - gridbag.setConstraints( empresaText, constraints ); - add( empresaText ); - - constraints.gridwidth = 1; - constraints.weightx = 0; - gridbag.setConstraints( nomeLabel, constraints ); - add( nomeLabel ); - - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 1; - gridbag.setConstraints( nomeText, constraints ); - add( nomeText ); - - constraints.gridwidth = 1; - constraints.weightx = 0; - gridbag.setConstraints( medicoLabel, constraints ); - add( medicoLabel ); - - constraints.gridwidth = 1; - constraints.weightx = 0.8; - gridbag.setConstraints( medicosCombo, constraints ); - add( medicosCombo ); - - constraints.gridwidth = 1; - constraints.weightx = 0; - gridbag.setConstraints( cpLabel, constraints ); - add( cpLabel ); - - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 0.2; - gridbag.setConstraints( cpText, constraints ); - add( cpText ); - - new CopyPasteHandler( empresaText ); - new CopyPasteHandler( nomeText ); - new CopyPasteHandler( cpText ); - } - - public void fill(Object value) - { - Integer values[] = (Integer[])value; - Integer empresaID = values[0]; - Integer estabelecimentoID = values[1]; - Integer trabalhadorID = values[2]; - clear(); - try - { - TrabalhadorData trabalhador; - EstabelecimentoData estabelecimento; - EmpresaData empresa; - if( trabalhadorID != null ) - { - trabalhador = ( TrabalhadorData ) JDO.load( TrabalhadorData.class, trabalhadorID ); - String nome = (String) trabalhador.get( TrabalhadorData.NOME ); - nomeText.setText( nome ); - } - String nomeEstabelecimento = ""; - if( estabelecimentoID != null ) - { - estabelecimento = ( EstabelecimentoData ) JDO.load( EstabelecimentoData.class, estabelecimentoID ); - nomeEstabelecimento = (String) estabelecimento.get( EstabelecimentoData.NOME ); - try - { - Integer medicoID = provider.getMedicoForEstabelecimento( estabelecimentoID ); - if( medicoID != null && medicoID.intValue() > -1 ) - { - for( int n = 0; n < medicosCombo.getItemCount(); n++ ) - { - IDObject medico = ( IDObject ) medicosCombo.getItemAt( n ); - if( medico.getID().equals( medicoID ) ) - { - medicosCombo.setSelectedIndex( n ); - break; - } - } - } - } - catch( Exception ex ) - { - } - } - if( empresaID != null ) - { - empresa = ( EmpresaData ) JDO.load( EmpresaData.class, empresaID ); - String nomeEmpresa = (String) empresa.get( EmpresaData.DESIGNACAO_SOCIAL ); - empresaText.setText( nomeEmpresa + ( nomeEstabelecimento.length() > 0?" / " + nomeEstabelecimento:"" ) ); - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar os dados do cabe\u00e7alho...", true ); - } - } - - public Object save() - { - Integer id = ( (IDObject) medicosCombo.getSelectedItem() ).getID(); - if( id != null ) - { - try - { - MedicoData medico = ( MedicoData )JDO.load( MedicoData.class, id ); - return medico; - } - catch( Exception ex ) - { - ex.printStackTrace(); - } - } - else - { - throw new ValuesException( "A ficha tem de ter um m\u00e9dico associado" ); - } - return null; - } - - public void fillCombo() - throws Exception - { - medicosCombo.removeItemListener( this ); - medicosCombo.removeAllItems(); - medicosHash.clear(); - Object medicos[][] = provider.getAllMedicos(); - for( int n = 0; n < medicos.length; n++ ) - { - Object medico[] = new Object[ 4 ]; - medico[ 0 ] = new Integer( ( (Number)medicos[n][0] ).intValue() ); - medico[ 1 ] = medicos[ n ][ 1 ]; - medico[ 2 ] = medicos[ n ][ 2 ]; - medico[ 3 ] = new Integer( n ); - medicosHash.put( medicos[ n ][ 0 ], medico ); - medicosCombo.addItem( new MappableObject( (Integer) medico[ 0 ], medico[ 1 ] ) ); - } - - if( medicos.length > 0 ) - { - medicosCombo.setSelectedIndex( 0 ); - cpText.setText( medicos[ 0 ][ 2 ] != null?(String)medicos[ 0 ][ 2 ]:"" ); - } - else - { - medicosCombo.addItem( new MappableObject( null, "" ) ); - medicosCombo.setSelectedIndex( 0 ); - cpText.setText( "" ); - } - medicosCombo.addItem( new MappableObject( new Integer( -1 ), "Novo/Editar" ) ); - medicosCombo.addItemListener( this ); - } - - public void itemStateChanged(java.awt.event.ItemEvent itemEvent) - { - int index = medicosCombo.getSelectedIndex(); - if( index == medicosCombo.getItemCount() - 1 ) - { - try - { - MedicoEditor me = new MedicoEditor( owner ); - me.show(); -// boolean isNew = me.getIsNew(); - Integer id = me.getID(); - if( id == null ) - { - medicosCombo.setSelectedIndex( 0 ); - } - else - { - fillCombo(); - if( id != null ) - { - Object[] medico = (Object[])medicosHash.get( id ); - medicosCombo.setSelectedIndex( ((Integer)medico[ 3 ] ).intValue() ); - } - } - - } - catch( Exception ex ) - { - JOptionPane.showMessageDialog( null, "Erro a abrir a janela de edi\u00e7\u00e3o...", "Erro...", - JOptionPane.ERROR_MESSAGE ); - ex.printStackTrace(); - medicosCombo.setSelectedIndex( 0 ); - return; - } - } - else - { - IDObject selected = (IDObject)medicosCombo.getItemAt( index ); - Integer id = selected.getID(); - if( id == null ) - { - cpText.setText( "" ); - } - else - { - Object[] medico = (Object[])medicosHash.get( id ); - cpText.setText( medico[ 2 ] != null?(String)medico[ 2 ]:"" ); - } - } - } - - public void clear() - { - empresaText.setText( "" ); - nomeText.setText( "" ); - medicosCombo.setSelectedIndex( 0 ); - } - - public void setEnabled( boolean enable ) - { - medicosCombo.setEnabled( enable ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/ValuesException.java b/trunk/SIPRPSoft/src/siprp/ficha/ValuesException.java deleted file mode 100644 index e5a14882..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/ValuesException.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * ValuesException.java - * - * Created on 5 de Abril de 2004, 20:22 - */ - -package siprp.ficha; - -/** - * - * @author fpalma - */ -public class ValuesException extends RuntimeException -{ - - /** Creates a new instance of ValuesException */ - public ValuesException( String msg ) - { - super( msg ); - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/ficha_aptidao.xsl b/trunk/SIPRPSoft/src/siprp/ficha/ficha_aptidao.xsl deleted file mode 100644 index 8a3644de..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/ficha_aptidao.xsl +++ /dev/null @@ -1,323 +0,0 @@ - - - - - - - - - - - - - - - - - FICHA DE APTIDÃO - - - () - - - - - - - - - - Empresa/Entidade - - - - - - -DESIGNAÇÃO SOCIAL: - - - - - - -ESTABELECIMENTO: - - - - -LOCALIDADE: - - - - - - -SERVIÇO DE SAÚDE: Tipo -      Interno -      Interempresas -      Externo -      Serviço Nacional de Saúde - - -DESIGNAÇÃO: - - -SERVIÇO DE HIGIENE E SEGURANÇA: Tipo -      Interno -      Interempresas -      Externo -      Outro - - -DESIGNAÇÃO: - - - - - - - - - - - - - - - - - - Trabalhador - - - - - - -NOME: - - - - - - -SEXO: - - - - -DATA DE NASCIMENTO: - - - - -NACIONALIDADE: - - - - - - -NÚMERO MECANOGRÁFICO/OUTRO: - - -CATEGORIA PROFISSIONAL: - - -FUNCAO PROPOSTA: - - - - -DATA DE ADMISSÃO: - - -LOCAL DE TRABALHO: - - -DATA DE ADMISSÃO NA FUNÇÃO: - - - - - - - - - - - - - Observações - - - - - - - - - - - - - - - - - - - Exame Médico - - - - - - -DATA DO EXAME: - - -TIPO - - - ADMISSÃO - - - PERIÓDICO - - - OCASIONAL - - - APÓS DOENCA - - - APÓS ACIDENTE - - - A PEDIDO DO TRABALHADOR - - - A PEDIDO DO SERVIÇO - - - POR MUDANCA DE FUNÇÃO - - - POR ALTERAÇÃO DAS CONDIÇÕES DE TRABALHO - - - OUTRO - - -ESPECIFIQUE: - - - - -RESULTADO - - - APTO - - - APTO CONDICIONALMENTE - - -   - - - INAPTO TEMPORARIAMENTE - - - INAPTO DEFINITIVAMENTE - - -   - - -OUTRAS FUNÇÕES QUE PODE DESEMPENHAR - - - 1 - - - 2 - - - 3 - - - 4 - - -   - - - - - - - - - - - - - Outras Recomendações - - - - - - - - - -PRÓXIMO EXAME: - - - - - - - - - - - - -MÉDICO DO TRABALHO: - - - - -C.P. - - - - - - -ASSINATURA _____________________________________________________________________________________________ - - -TOMEI CONHECIMENTO ___________________________________________________________________ DATA: ___/___/______ - - - O RESPONSÁVEL DOS RECURSOS HUMANOS - - - - - - - - - - - - diff --git a/trunk/SIPRPSoft/src/siprp/ficha/svg/char_square_pure.svg b/trunk/SIPRPSoft/src/siprp/ficha/svg/char_square_pure.svg deleted file mode 100644 index 6c17f710..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/svg/char_square_pure.svg +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - diff --git a/trunk/SIPRPSoft/src/siprp/ficha/svg/char_tick_pure.svg b/trunk/SIPRPSoft/src/siprp/ficha/svg/char_tick_pure.svg deleted file mode 100644 index e5e1b808..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/svg/char_tick_pure.svg +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - diff --git a/trunk/SIPRPSoft/src/siprp/higiene/HigieneDataProvider.java b/trunk/SIPRPSoft/src/siprp/higiene/HigieneDataProvider.java deleted file mode 100644 index 60b2074b..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/HigieneDataProvider.java +++ /dev/null @@ -1,255 +0,0 @@ -/* - * 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/alter2.sql b/trunk/SIPRPSoft/src/siprp/higiene/alter2.sql deleted file mode 100644 index 6166400d..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/alter2.sql +++ /dev/null @@ -1,18 +0,0 @@ - -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'; \ No newline at end of file diff --git a/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaLine.java b/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaLine.java deleted file mode 100644 index 7eb4a647..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaLine.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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(); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaPanel.java deleted file mode 100644 index 05c508b4..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaPanel.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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( "" + empresaR + "
" + estabelecimentoR + "
" ); - 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaRenderer.java b/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaRenderer.java deleted file mode 100644 index 40dc967e..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaRenderer.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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(); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigienePanel.java b/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigienePanel.java deleted file mode 100644 index 05c6d67e..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigienePanel.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigieneWindow.java b/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigieneWindow.java deleted file mode 100644 index 26612fc7..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigieneWindow.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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(); - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/mapa/TecnicosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/mapa/TecnicosPanel.java deleted file mode 100644 index 2cf77ab2..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/mapa/TecnicosPanel.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 ); - - } - - } -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/CorTecnicoCellRenderer.java b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/CorTecnicoCellRenderer.java deleted file mode 100644 index 13d07aff..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/CorTecnicoCellRenderer.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.java deleted file mode 100644 index 9bb3b888..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.java +++ /dev/null @@ -1,307 +0,0 @@ -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.calendar.*; -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; - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.xml b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.xml deleted file mode 100644 index 04a78a45..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - siprp.data.* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - - - - Estado - - 6 - - - Por realizar - Realizada - Desmarcada pela empresa - Desmarcada pela SIPRP - - - - - - Observa\u00e7\u00f5es - - - 5 - - - - diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacoesHigieneUpperPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacoesHigieneUpperPanel.java deleted file mode 100644 index 1efa12af..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacoesHigieneUpperPanel.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * 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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacoesHigieneWindow.java b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacoesHigieneWindow.java deleted file mode 100644 index b8643956..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacoesHigieneWindow.java +++ /dev/null @@ -1,519 +0,0 @@ -/* - * 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/TecnicoEditor.java b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/TecnicoEditor.java deleted file mode 100644 index 007c119d..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/TecnicoEditor.java +++ /dev/null @@ -1,317 +0,0 @@ -/* - * 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() ] ); -// } -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/TecnicoRenderer.java b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/TecnicoRenderer.java deleted file mode 100644 index 7ad36ac8..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/TecnicoRenderer.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 ]; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/importer/DataChooserWindow.java b/trunk/SIPRPSoft/src/siprp/importer/DataChooserWindow.java deleted file mode 100644 index a341e0b5..00000000 --- a/trunk/SIPRPSoft/src/siprp/importer/DataChooserWindow.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * DataChooserWindow.java - * - * Created on 29 de Abril de 2004, 16:53 - */ - -package siprp.importer; - -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import javax.swing.*; - -import com.evolute.utils.ui.*; -/** - * - * @author lflores - */ -public class DataChooserWindow extends CustomJDialog -{ - private final String labels[]; - private final Object items[]; - private final Object empty[]; - private final Object allItems[][]; - private final JComboBox combos[]; - private final int preselected[]; - - private boolean canceled = false; - - /** Creates a new instance of DataChooserWindow */ - public DataChooserWindow( JFrame modalFrame, String names[], Object data[][] ) - { - this( modalFrame, names, data, null ); - } - - public DataChooserWindow( JFrame modalFrame, String names[], Object data[][], int selected[] ) - { - super( modalFrame, true ); - labels = names; - items = data[ 0 ]; - empty = new String[ items.length ]; - for( int i = 0; i < empty.length; ++i ) - { - empty[ i ] = ""; - } - allItems = data; - combos = new JComboBox[ labels.length ]; - preselected = selected; - setupComponents(); - if( modalFrame == null ) - { - center(); - } - else - { - centerSuper(); - } - setVisible( true ); - } - - private void setupComponents() - { - setTitle( "Escolha os campos correspondentes:" ); - setSize(450, 120 + 25 * labels.length ); - GridBagLayout gbl = new GridBagLayout(); - GridBagConstraints gbc = new GridBagConstraints(); - gbc.insets = new Insets( 2, 2, 2, 2 ); - gbc.fill = GridBagConstraints.HORIZONTAL; - Container cont = getContentPane(); - cont.setLayout( gbl ); - for( int i = 0; i < labels.length; ++i ) - { - gbc.weightx = 0; - gbc.gridwidth = 1; - JLabel label = new JLabel( labels[ i ] ); - gbl.setConstraints( label, gbc ); - cont.add( label ); -/* gbc.weightx = 1; - JPanel pad = new JPanel(); - gbl.setConstraints( pad, gbc ); - cont.add( pad ); -*/ gbc.weightx = 1; - gbc.gridwidth = GridBagConstraints.REMAINDER; - JComboBox combo = new JComboBox( items ); - int index; - if( preselected == null ) - { - index = Math.min( i, items.length - 1 ); - } - else - { - if( i < preselected.length ) - { - index = Math.min( preselected[ i ], items.length - 1 ); - if( index == -1 ) - { - index = items.length - 1; - } - } - else - { - index = items.length - 1; - } - - } - combo.setSelectedIndex( index ); - combos[ i ] = combo; - gbl.setConstraints( combo, gbc ); - cont.add( combo ); - } - gbc.insets = new Insets( 10, 2, 2, 2 ); - gbc.weightx = 1; - gbc.gridwidth = 2; - JPanel pad = new JPanel(); - gbl.setConstraints( pad, gbc ); - cont.add( pad ); - gbc.weightx = 0; - gbc.gridwidth = 1; - JButton butOK = new JButton( "OK" ); - gbl.setConstraints( butOK, gbc ); - cont.add( butOK ); - gbc.weightx = 0; - gbc.gridwidth = GridBagConstraints.REMAINDER; - JButton butCancel = new JButton( "Cancelar" ); - gbl.setConstraints( butCancel, gbc ); - cont.add( butCancel ); - butOK.addActionListener( new ActionListener() { - public void actionPerformed( ActionEvent e ) - { - setVisible( false ); - dispose(); - } - }); - butCancel.addActionListener( new ActionListener() { - public void actionPerformed( ActionEvent e ) - { - setVisible( false ); - dispose(); - canceled = true; - } - }); - } - - public Hashtable getData() - { - if( canceled ) - { - return null; - } - Hashtable hash = new Hashtable(); - for( int i = 0; i < labels.length; ++i ) - { - hash.put( labels[ i ], combos[ i ].getSelectedItem() ); - } - return hash; - } - - public Hashtable[] getMultipleData() - { - if( canceled ) - { - return null; - } - Hashtable hash[] = new Hashtable[ allItems.length ]; -//System.out.println( "Hash[] size: " + hash.length ); - for( int j = 0; j < hash.length; ++j ) - { - hash[ j ] = new Hashtable(); - } - for( int i = 0; i < labels.length; ++i ) - { - String sel = combos[ i ].getSelectedItem().toString(); - if( sel.length() > 0 ) - { - for( int j = 0; j < allItems.length; ++j ) - { - hash[ j ].put( labels[ i ], allItems[ j ][ combos[ i ].getSelectedIndex() ] ); - } - } - } - return hash; - } - -/* public static void main( String arg[] ) - { - String names[] = new String[] { "Nome:", "Morada:", "Telefone:" }; - String data[] = new String[] { "Joao Catita", "Damaiasdg sdfg sdf gsdfs hgf h", "nao tem", "so a noite", "" }; - DataChooserWindow dcw = new DataChooserWindow( null, names, data, new int[] { 3, 2 ,1 } ); - }*/ -} diff --git a/trunk/SIPRPSoft/src/siprp/importer/Importer.java b/trunk/SIPRPSoft/src/siprp/importer/Importer.java deleted file mode 100644 index c9b7efdb..00000000 --- a/trunk/SIPRPSoft/src/siprp/importer/Importer.java +++ /dev/null @@ -1,363 +0,0 @@ -/* - * Importer.java - * - * Created on 7 de Abril de 2004, 10:56 - */ - -package siprp.importer; - -import com.evolute.utils.*; -import com.evolute.utils.arrays.*; -import com.evolute.utils.tables.*; -import com.evolute.utils.ui.*; - -import java.awt.*; -import java.awt.event.*; -import java.io.*; -import java.util.*; -import javax.swing.*; -import javax.swing.table.*; - -import jxl.*; - -import siprp.*; - -/** - * - * @author psantos - */ -public class Importer extends CustomJDialog -{ - public static final int TYPE_ADMISSAO = 0; - public static final int TYPE_DEMISSAO = 1; - - public static final String DATA_PREFIX = "Data "; - - public static final String NOME = "Nome do Funcion\u00e1rio"; - public static final String SEXO = "Sexo"; - public static final String NACIONALIDADE = "Nacionalidade"; - public static final String DATA_NASCIMENTO = DATA_PREFIX + "Nascimento"; - public static final String NUMERO_MECANOGRAFICO = "N\u00famero Mecanogr\u00e1fico"; - public static final String DATA_ADMISSAO = DATA_PREFIX + "Admiss\u00e3o"; - public static final String CATEGORIA = "Categoria"; - public static final String LOCAL_TRABALHO = "Local Trabalho"; - public static final String FUNCAO = "Fun\u00e7\u00e3o"; - public static final String DATA_ADMISSAO_FUNCAO = DATA_PREFIX + "Admiss\u00e3o na Fun\u00e7\u00e3o"; - public static final String DATA_DEMISSAO = DATA_PREFIX + "Demiss\u00e3o"; - - private JPanel panel; - private BaseTable table; - private Excel2DArray e2da; - private boolean canceled = false; - private DataChooserWindow dcw; - private Object vals[][]; - private int[] DEFAULT_SELECTION = new int[]{ 0, 2, 3, 1, -1, 4, 5, 7, 6, -1 }; - private int[] DEFAULT_SELECTION_DEMISSAO = new int[]{ 0, 1 }; - - public static final String NAMES[] = new String[]{ - NOME, - SEXO, - NACIONALIDADE, - DATA_NASCIMENTO, - NUMERO_MECANOGRAFICO, - DATA_ADMISSAO, - CATEGORIA, - LOCAL_TRABALHO, - FUNCAO, - DATA_ADMISSAO_FUNCAO - }; - - public static final String NAMES_DEMISSAO[] = new String[]{ - NOME, - DATA_DEMISSAO - }; - private final boolean multipleSelection; - protected final int type; - - /** Creates a new instance of Importer */ - public Importer( JFrame modalFrame, String filename, boolean multiple, int type ) - throws Exception - { - super( modalFrame, true ); - multipleSelection = multiple; - this.type = type; - - int []selection = ( int [] ) Singleton.getInstance( SingletonConstants.EXCEL_FORMAT ); - if( selection != null ) - { - DEFAULT_SELECTION = selection; - } - int []selectionDemissao = ( int [] ) Singleton.getInstance( SingletonConstants.EXCEL_FORMAT_DEMISSAO ); - if( selectionDemissao != null ) - { - DEFAULT_SELECTION_DEMISSAO = selectionDemissao; - } - setupComponents( filename ); - if( modalFrame == null ) - { - center(); - } - else - { - centerSuper(); - } - setVisible( true ); - } - - private void setupComponents( String filename ) - { - setSize( 800, 500 ); - - GridBagLayout gblGridBag = new GridBagLayout(); - GridBagConstraints gbcConstraints = new GridBagConstraints(); - - panel = ( JPanel ) getContentPane(); - - panel.setLayout( gblGridBag ); - - e2da = new Excel2DArray( filename ); - - String colNames[] = new String[ e2da.rowLength() ]; - for( int i = 0; i < colNames.length; i++ ) - { - colNames[ i ] = " "; - } - Virtual2DTableModel tm = new Virtual2DTableModel( colNames, null ); - tm.setValues( e2da ); - table = new BaseTable( tm ); - int col = 0; - switch( type ) - { - case TYPE_ADMISSAO: - col = DEFAULT_SELECTION[ 0 ]; - break; - - case TYPE_DEMISSAO: - col = DEFAULT_SELECTION_DEMISSAO[ 0 ]; - break; - } - table.getColumn( col ).setWidth( 200 ); - if( !multipleSelection ) - { - table.getSelectionModel().setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - } - else - { - table.getSelectionModel().setSelectionMode( ListSelectionModel.SINGLE_INTERVAL_SELECTION ); - } - table.getTableHeader().setResizingAllowed( true ); - table.getTableHeader().setReorderingAllowed( false ); - // table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF ); - - for( int i = 0; i < e2da.rowLength(); i++ ) - { - table.getColumn( i ).setMinWidth( 50 ); - //table.getColumn( i ).setResizable( true ); - } - - JScrollPane sp = new JScrollPane( table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - - gbcConstraints.anchor = GridBagConstraints.CENTER; - gbcConstraints.fill = GridBagConstraints.BOTH; - gbcConstraints.insets = new Insets(5, 5, 5, 5); - gbcConstraints.gridwidth = 3; - gbcConstraints.gridheight = 3; - gbcConstraints.weighty = 3; - gbcConstraints.gridx = 0; - gbcConstraints.gridy = 3; - gblGridBag.setConstraints( sp, gbcConstraints ); - - panel.add( sp ); - - JPanel jpButtons = new JPanel(); - final JButton jbOK = new JButton( "Escolher" ); - jbOK.setEnabled( false ); - jpButtons.add( jbOK ); - JButton jbCancel = new JButton( "Cancelar" ); - jpButtons.add( jbCancel ); - - gbcConstraints.gridheight = 1; - gbcConstraints.weightx = 1; - gbcConstraints.weighty = 0; - gbcConstraints.anchor = GridBagConstraints.SOUTH; - gbcConstraints.fill = GridBagConstraints.BOTH; - gbcConstraints.insets = new Insets( 2, 2, 2, 2 ); - gbcConstraints.gridwidth = 3; - gbcConstraints.gridx = 0; - gbcConstraints.gridy = 6; - gblGridBag.setConstraints( jpButtons, gbcConstraints ); - panel.add( jpButtons ); - - table.addMouseListener( new MouseAdapter() { - public void mouseClicked( MouseEvent e ) { - jbOK.setEnabled( true ); - if( e.getButton() == MouseEvent.BUTTON1 - && e.getClickCount() == 2 - && table.columnAtPoint( e.getPoint() ) != -1 - && table.rowAtPoint( e.getPoint() ) != -1 ) - { - acceptResult(); - } - } - public void mousePressed( MouseEvent e ) { - jbOK.setEnabled( true ); - } - }); - - jbOK.addActionListener( new ActionListener() { - public void actionPerformed( ActionEvent a ) { - acceptResult(); - } - }); - - jbCancel.addActionListener( new ActionListener() { - public void actionPerformed( ActionEvent a ) { - setVisible( false ); - dispose(); - canceled = true; - } - }); - - } - - private void acceptResult() - { - if( multipleSelection ) - { - int rows[] = table.getSelectedRows(); - vals = new Object[ rows.length ][]; - for( int i = 0; i < rows.length; ++i ) - { - Vector v = new Vector( Arrays.asList( e2da.getRow( rows[ i ] ) ) ); - v.add( "" ); - vals[ i ] = (Object[]) v.toArray( new Object[ v.size() ] ); - } - } - else - { - Vector v = new Vector( Arrays.asList( e2da.getRow( table.getSelectedRow() ) ) ); - v.add( "" ); - vals = new Object[][] { ( Object[] )v.toArray( new Object[ v.size() ] ) }; - } - -/* - System.out.println( "row: " + table.getSelectedRow() ); - System.out.print( "vals: " ); - for( int i = 0; i < vals.length; i++ ) - { - System.out.print( "[" + vals[ i ] + "]" ); - } - System.out.println(); -*/ - setVisible( false ); - dispose(); - - } - - public Hashtable getData() - { - if( NAMES == null || vals == null ) - { - return null; - } - dcw = new DataChooserWindow( null, NAMES, vals, DEFAULT_SELECTION ); - - if( canceled || ( dcw == null ) ) - { - return null; - } - - return dcw.getData(); - } - - public Hashtable[] getMultipleData() - { - switch( type ) - { - case TYPE_ADMISSAO: - if( NAMES == null || vals == null ) - { - return null; - } - dcw = new DataChooserWindow( null, NAMES, vals, DEFAULT_SELECTION ); - break; - - case TYPE_DEMISSAO: - if( NAMES_DEMISSAO == null || vals == null ) - { - return null; - } - dcw = new DataChooserWindow( null, NAMES_DEMISSAO, vals, DEFAULT_SELECTION_DEMISSAO ); - break; - } - - if( canceled || ( dcw == null ) ) - { - return null; - } - - return dcw.getMultipleData(); - } - - - public static void main( String args[] ) - { -// FileDialog fd = new FileDialog( null, "Escolha um ficheiro Excel:", FileDialog.LOAD ); -// fd.setDirectory( System.getProperty( "user.home" ) ); -// fd.setFilenameFilter( new FilenameFilter() { -// public boolean accept( File dir, String name ) -// { -// return (name!=null) && (name.indexOf( ".xls" ) != -1); -// } -// } ); -// fd.show(); - String filename = "c:\\teste_com_dados.xls"; - //String filename = fd.getFile(); - if( filename != null ) - { - //filename = fd.getDirectory() + File.separator + filename; - try - { - Importer importer = new Importer( null, filename, true, TYPE_ADMISSAO ); - Hashtable hash = importer.getData(); - if( hash != null ) - { - System.out.println( "Data: " + hash ); - } - } - catch( Exception ex ) - { - ex.printStackTrace(); - JOptionPane.showMessageDialog( null, "Erro a importar", "Erro...", JOptionPane.ERROR_MESSAGE ); - } - } -// Importer im = null; -// try -// { -// im = new Importer( null, -// "E:\\test.xls" -// "C:\\Documents and Settings\\psantos\\My Documents\\Devel\\teste.xls" -// "C:\\Documents and Settings\\psantos\\My Documents\\Devel\\Docs\\jexcelapi\\jxlrwtest.xls" -// ); -// -//System.out.println( "Escolhido: " + im.getData() ); -// -// } -// catch( Exception e ) -// { -// e.printStackTrace(); -// } - -// String[][] all = (String[][]) e.getObjects(); -// -// for( int j = 0; j < e.rowLength(); j++ ) -// { -// String[] r = e.getRow( j ); -// for( int i = 0; i < r.length; i++ ) -// { -// System.out.print( "[" + r[ i ] + "]" ); -// } -// System.out.println(); -// } - } -} \ No newline at end of file diff --git a/trunk/SIPRPSoft/src/siprp/impressaofichas/FichasPrinter.java b/trunk/SIPRPSoft/src/siprp/impressaofichas/FichasPrinter.java deleted file mode 100644 index 1b21e717..00000000 --- a/trunk/SIPRPSoft/src/siprp/impressaofichas/FichasPrinter.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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 = FOPCreator.getFOPCreator(); - 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() ); - FOPPrinter.getFOPPrinter().printFO( in, false, true, printOptions ); - byte []pdfData = PDFCreator.getPDFCreator().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 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/impressaofichas/ImpressaoFichasDataProvider.java b/trunk/SIPRPSoft/src/siprp/impressaofichas/ImpressaoFichasDataProvider.java deleted file mode 100644 index 11e0910d..00000000 --- a/trunk/SIPRPSoft/src/siprp/impressaofichas/ImpressaoFichasDataProvider.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * 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 ]; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/impressaofichas/ImpressaoFichasWindow.java b/trunk/SIPRPSoft/src/siprp/impressaofichas/ImpressaoFichasWindow.java deleted file mode 100644 index 3b29b698..00000000 --- a/trunk/SIPRPSoft/src/siprp/impressaofichas/ImpressaoFichasWindow.java +++ /dev/null @@ -1,422 +0,0 @@ -/* - * 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.calendar.*; -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(); - } - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/impressaofichas/lista_fichas.xsl b/trunk/SIPRPSoft/src/siprp/impressaofichas/lista_fichas.xsl deleted file mode 100644 index 46096481..00000000 --- a/trunk/SIPRPSoft/src/siprp/impressaofichas/lista_fichas.xsl +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - RELAÇÃO DE FICHAS DE APTIDÃO ENVIADAS - - - - - - - - - - - - NOME - - - - - DATA EXAME - - - - - PRÓXIMO EXAME - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/Lembrete.java b/trunk/SIPRPSoft/src/siprp/lembretes/Lembrete.java deleted file mode 100644 index 67d73eff..00000000 --- a/trunk/SIPRPSoft/src/siprp/lembretes/Lembrete.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Lembrete.java - * - * Created on 12 de Fevereiro de 2007, 23:18 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.lembretes; - -import java.util.Date; - -/** - * - * @author Frederico - */ -public class Lembrete -{ - protected Integer id; - protected Integer tipoID; - protected Date data; - protected String descricao; - protected String texto; - protected Integer empresaID; - protected Integer estabelecimentoID; - protected Integer trabalhadorID; - protected Integer marcacaoEstabelecimentoID; - protected Integer marcacaoTrabalhadorID; - protected boolean enviarEmail; - protected Integer periodicidadeDias; - protected Integer periodicidadeMeses; - - /** Creates a new instance of Lembrete */ - public Lembrete( Integer id, - Integer tipoID, - Date data, - String descricao, - String texto, - Integer empresaID, - Integer estabelecimentoID, - Integer trabalhadorID, - Integer marcacaoEstabelecimentoID, - Integer marcacaoTrabalhadorID, - boolean enviarEmail, - Integer periodicidadeDias, - Integer periodicidadeMeses ) - { - setId( id ); - setTipoID( tipoID ); - setData( data ); - setDescricao( descricao ); - setTexto( texto ); - setEmpresaID( empresaID ); - setEstabelecimentoID( estabelecimentoID ); - setTrabalhadorID( trabalhadorID ); - setMarcacaoEstabelecimentoID( marcacaoEstabelecimentoID ); - setMarcacaoTrabalhadorID( marcacaoTrabalhadorID ); - setEnviarEmail( enviarEmail ); - setPeriodicidadeDias( periodicidadeDias ); - setPeriodicidadeMeses( periodicidadeMeses ); - } - - public Integer getTipoID() - { - return tipoID; - } - - public void setTipoID(Integer tipoID) - { - this.tipoID = tipoID; - } - - public Date getData() - { - return data; - } - - public void setData(Date data) - { - this.data = data; - } - - public String getDescricao() - { - return descricao; - } - - public void setDescricao(String descricao) - { - this.descricao = descricao; - } - - public String getTexto() - { - return texto; - } - - public void setTexto(String texto) - { - this.texto = texto; - } - - public Integer getEmpresaID() - { - return empresaID; - } - - public void setEmpresaID(Integer empresaID) - { - this.empresaID = empresaID; - } - - public Integer getEstabelecimentoID() - { - return estabelecimentoID; - } - - public void setEstabelecimentoID(Integer estabelecimentoID) - { - this.estabelecimentoID = estabelecimentoID; - } - - public Integer getTrabalhadorID() - { - return trabalhadorID; - } - - public void setTrabalhadorID(Integer trabalhadorID) - { - this.trabalhadorID = trabalhadorID; - } - - public Integer getMarcacaoEstabelecimentoID() - { - return marcacaoEstabelecimentoID; - } - - public void setMarcacaoEstabelecimentoID(Integer marcacaoEstabelecimentoID) - { - this.marcacaoEstabelecimentoID = marcacaoEstabelecimentoID; - } - - public Integer getMarcacaoTrabalhadorID() - { - return marcacaoTrabalhadorID; - } - - public void setMarcacaoTrabalhadorID(Integer marcacaoTrabalhadorID) - { - this.marcacaoTrabalhadorID = marcacaoTrabalhadorID; - } - - public boolean isEnviarEmail() - { - return enviarEmail; - } - - public void setEnviarEmail(boolean enviarEmail) - { - this.enviarEmail = enviarEmail; - } - - public Integer getPeriodicidadeDias() - { - return periodicidadeDias; - } - - public void setPeriodicidadeDias(Integer periodicidadeDias) - { - this.periodicidadeDias = periodicidadeDias; - } - - public Integer getPeriodicidadeMeses() - { - return periodicidadeMeses; - } - - public void setPeriodicidadeMeses(Integer periodicidadeMeses) - { - this.periodicidadeMeses = periodicidadeMeses; - } - - public Integer getId() - { - return id; - } - - public void setId(Integer id) - { - this.id = id; - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/LembretesConstants.java b/trunk/SIPRPSoft/src/siprp/lembretes/LembretesConstants.java deleted file mode 100644 index 13f576b7..00000000 --- a/trunk/SIPRPSoft/src/siprp/lembretes/LembretesConstants.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * LembretesConstants.java - * - * Created on February 12, 2007, 4:44 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.lembretes; - -/** - * - * @author fpalma - */ -public interface LembretesConstants -{ - public static final String CODE_EXTERNO = "EXTERNO"; - public static final String CODE_REMARCACOES = "REMARCACOES"; - public static final String CODE_MARCACOES = "MARCACOES"; - public static final String CODE_OUTROS = "OUTROS"; - - public static final String CODES[] = - new String[]{ CODE_EXTERNO, CODE_REMARCACOES, CODE_MARCACOES, - CODE_OUTROS }; -} diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/LembretesDataProvider.java b/trunk/SIPRPSoft/src/siprp/lembretes/LembretesDataProvider.java deleted file mode 100644 index 9a9d9701..00000000 --- a/trunk/SIPRPSoft/src/siprp/lembretes/LembretesDataProvider.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * LembretesDataProvider.java - * - * Created on February 5, 2007, 6:09 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.lembretes; - -import com.evolute.utils.Singleton; -import com.evolute.utils.arrays.Virtual2DArray; -import com.evolute.utils.db.DBManager; -import com.evolute.utils.db.Executer; -import com.evolute.utils.sql.Assignment; -import com.evolute.utils.sql.Delete; -import com.evolute.utils.sql.Field; -import com.evolute.utils.sql.Insert; -import com.evolute.utils.sql.Select; -import java.util.Date; -import java.util.HashMap; - -/** - * - * @author lflores - */ -public class LembretesDataProvider -{ - private static final Object LOCK = new Object(); - private static LembretesDataProvider instance = null; - - private final HashMap TIPOS_LEMBRETES_BY_CODIGO = - new HashMap(); - private final HashMap TIPOS_LEMBRETES_BY_ID = - new HashMap(); - private TipoLembrete tiposLembrete[]; - - private Executer EXECUTER; - - /** Creates a new instance of LembretesDataProvider */ - public LembretesDataProvider() - throws Exception - { - DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); - EXECUTER = dbm.getSharedExecuter( this ); - } - - public static LembretesDataProvider getProvider() - throws Exception - { - synchronized( LOCK ) - { - if( instance == null ) - { - instance = new LembretesDataProvider(); - } - } - return instance; - } - - public TipoLembrete[] getTiposLembrete() - throws Exception - { - if( tiposLembrete == null ) - { - Select select = - new Select( new String[]{ "lembretes_tipos" }, - new String[]{ "id", "codigo", "descricao", "ordem" }, - new Field( "activo" ).isEqual( "y" ), - new String[]{ "ordem" }, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - tiposLembrete = new TipoLembrete[ array.columnLength() ]; - for( int n = 0; n < tiposLembrete.length; n++ ) - { - Integer id = ( Integer ) array.get( n, 0 ); - String codigo = ( String ) array.get( n, 1 ); - String descricao = ( String ) array.get( n, 2 ); - Integer ordem = ( Integer ) array.get( n, 3 ); - tiposLembrete[ n ] = new TipoLembrete( id, codigo, descricao, ordem ); - TIPOS_LEMBRETES_BY_CODIGO.put( codigo, tiposLembrete[ n ] ); - TIPOS_LEMBRETES_BY_ID.put( id, tiposLembrete[ n ] ); - } - } - return tiposLembrete; - } - - public TipoLembrete getTipoLembreteByCodigo( String codigo ) - throws Exception - { - getTiposLembrete(); - return TIPOS_LEMBRETES_BY_CODIGO.get( codigo ); - } - - public TipoLembrete getTipoLembreteByID( Integer id ) - throws Exception - { - getTiposLembrete(); - return TIPOS_LEMBRETES_BY_ID.get( id ); - } - - public void criarLembrete( Integer tipoID, - Date data, - String descricao, - String texto, - Integer empresaID, - Integer estabelecimentoID, - Integer trabalhadorID, - Integer marcacaoEstabelecimentoID, - Integer marcacaoTrabalhadorID, - boolean enviarEmail, - Integer periodicidadeDias, - Integer periodicidadeMeses ) - throws Exception - { - Insert insert = - new Insert( "lembretes", - new Assignment[]{ - new Assignment( new Field( "tipo_id" ), tipoID ), - new Assignment( new Field( "data" ), data ), - new Assignment( new Field( "descricao" ), descricao ), - new Assignment( new Field( "texto" ), texto ), - new Assignment( new Field( "empresa_id" ), empresaID ), - new Assignment( new Field( "estabelecimento_id" ), estabelecimentoID ), - new Assignment( new Field( "trabalhador_id" ), trabalhadorID ), - new Assignment( new Field( "marcacao_estabelecimento_id" ), marcacaoEstabelecimentoID ), - new Assignment( new Field( "marcacao_trabalhador_id" ), marcacaoTrabalhadorID ), - new Assignment( new Field( "enviar_email" ), enviarEmail ? "y" : "n" ), - new Assignment( new Field( "periodicidade_dias" ), periodicidadeDias ), - new Assignment( new Field( "periodicidade_meses" ), periodicidadeMeses ) } ); - EXECUTER.executeQuery( insert ); - } - - public void apagarLembreteByID( Integer id ) - throws Exception - { - Delete delete = - new Delete( "lembretes", - new Field( "id" ).isEqual( id ) ); - EXECUTER.executeQuery( delete ); - } - - public void apagarLembreteByMarcacaoTrabalhadorID( Integer marcacaoID ) - throws Exception - { - Delete delete = - new Delete( "lembretes", - new Field( "marcacao_trabalhador_id" ).isEqual( marcacaoID ) ); - EXECUTER.executeQuery( delete ); - } - - public int countLembretesByTipo( Integer tipoID ) - throws Exception - { - Select select = - new Select( new String[]{ "lembretes" }, - new String[]{ "COUNT(*)" }, - new Field( "tipo_id" ).isEqual( tipoID ).and( - new Field( "data" ).isLessOrEqual( new Date() ) ) ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - if( array.columnLength() == 0 || array.get( 0, 0 ) == null ) - { - return 0; - } - else - { - return ( ( Number ) array.get( 0, 0 ) ).intValue(); - } - - } - - public Lembrete[] getLembretesByTipo( Integer tipoID ) - throws Exception - { - Select select = - new Select( new String[]{ "lembretes" }, - new String[]{ "id", "tipo_id", "data", "descricao", - "texto", "empresa_id", "estabelecimento_id", - "trabalhador_id", "marcacao_estabelecimento_id", - "marcacao_trabalhador_id", "enviar_email", - "periodicidade_dias", "periodicidade_meses" }, - new Field( "tipo_id" ).isEqual( tipoID ).and( - new Field( "data" ).isLessOrEqual( new Date() ) ) ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - Lembrete lembretes[] = new Lembrete[ array.columnLength() ]; - for( int n = 0; n < lembretes.length; n++ ) - { - Integer id = ( Integer ) array.get( n, 0 ); - Date data = ( Date ) array.get( n, 2 ); - String descricao = ( String ) array.get( n, 3 ); - String texto = ( String ) array.get( n, 4 ); - Integer empresaID = ( Integer ) array.get( n, 5 ); - Integer estabelecimentoID = ( Integer ) array.get( n, 6 ); - Integer trabalhadorID = ( Integer ) array.get( n, 7 ); - Integer marcacaoEstabelecimentoID = ( Integer ) array.get( n, 8 ); - Integer marcacaoTrabalhadorID = ( Integer ) array.get( n, 9 ); - boolean enviarEmail = "y".equals( array.get( n, 10 ) ); - Integer periodicidadeDias = ( Integer ) array.get( n, 11 ); - Integer periodicidadeMeses = ( Integer ) array.get( n, 12 ); - lembretes[ n ] = new Lembrete( id, tipoID, data, descricao, texto, - empresaID, estabelecimentoID, trabalhadorID, - marcacaoEstabelecimentoID, marcacaoTrabalhadorID, - enviarEmail, periodicidadeDias, periodicidadeMeses ); - } - return lembretes; - } - - public Lembrete getLembreteByID( Integer id ) - throws Exception - { - Select select = - new Select( new String[]{ "lembretes" }, - new String[]{ "id", "tipo_id", "data", "descricao", - "texto", "empresa_id", "estabelecimento_id", - "trabalhador_id", "marcacao_estabelecimento_id", - "marcacao_trabalhador_id", "enviar_email", - "periodicidade_dias", "periodicidade_meses" }, - new Field( "id" ).isEqual( id ) ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - if( array.columnLength() == 0 ) - { - return null; - } - else - { - Integer tipoID = ( Integer ) array.get( 0, 1 ); - Date data = ( Date ) array.get( 0, 2 ); - String descricao = ( String ) array.get( 0, 3 ); - String texto = ( String ) array.get( 0, 4 ); - Integer empresaID = ( Integer ) array.get( 0, 5 ); - Integer estabelecimentoID = ( Integer ) array.get( 0, 6 ); - Integer trabalhadorID = ( Integer ) array.get( 0, 7 ); - Integer marcacaoEstabelecimentoID = ( Integer ) array.get( 0, 8 ); - Integer marcacaoTrabalhadorID = ( Integer ) array.get( 0, 9 ); - boolean enviarEmail = "y".equals( array.get( 0, 10 ) ); - Integer periodicidadeDias = ( Integer ) array.get( 0, 11 ); - Integer periodicidadeMeses = ( Integer ) array.get( 0, 12 ); - return new Lembrete( id, tipoID, data, descricao, texto, - empresaID, estabelecimentoID, trabalhadorID, - marcacaoEstabelecimentoID, marcacaoTrabalhadorID, - enviarEmail, periodicidadeDias, periodicidadeMeses ); - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/LembretesPanel.java b/trunk/SIPRPSoft/src/siprp/lembretes/LembretesPanel.java deleted file mode 100644 index 1e7375cf..00000000 --- a/trunk/SIPRPSoft/src/siprp/lembretes/LembretesPanel.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * LembretesPanel.java - * - * Created on February 6, 2007, 5:14 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.lembretes; - -import java.awt.*; -import javax.swing.*; - -/** - * - * @author fpalma - */ -public class LembretesPanel extends JPanel -{ - - /** Creates a new instance of LembretesPanel */ - public LembretesPanel() - { - setupComponents(); - } - - private void setupComponents() - { - } -} diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/LembretesWindow.java b/trunk/SIPRPSoft/src/siprp/lembretes/LembretesWindow.java deleted file mode 100644 index dfd77b34..00000000 --- a/trunk/SIPRPSoft/src/siprp/lembretes/LembretesWindow.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * LembretesWindow.java - * - * Created on 13 de Fevereiro de 2007, 11:11 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.lembretes; - -import java.awt.*; -import java.awt.event.ActionEvent; -import javax.swing.*; - -import com.evolute.utils.tables.*; -import com.evolute.utils.tracker.TrackableWindow; -import com.evolute.utils.ui.DialogException; -import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.util.Vector; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import siprp.lembretes.remarcacoes.LembretesRemarcacaoPanel; - -/** - * - * @author Frederico - */ -public class LembretesWindow extends JFrame - implements ActionListener, TrackableWindow, ListSelectionListener, - LembretesConstants -{ - public static final String TITLE = "Lembretes"; - - protected VectorTableModel tiposModel; - protected BaseTable tiposTable; - protected JPanel lembretesPanel; - protected JButton recarregarButton; - - protected LembretesDataProvider provider; - - /** Creates a new instance of LembretesWindow */ - public LembretesWindow() - throws Exception - { - provider = LembretesDataProvider.getProvider(); - setupComponents(); - } - - private void setupComponents() - { - setTitle( "Lembretes" ); - tiposModel = new VectorTableModel( new String[]{ "tipo", "quantidade" } ); - tiposTable = new BaseTable( tiposModel ); - tiposTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - tiposTable.fixColumnWidth( 0, 200 ); - tiposTable.fixColumnWidth( 1, 100 ); - tiposTable.getSelectionModel().addListSelectionListener( this ); - JScrollPane scp = - new JScrollPane( tiposTable, JScrollPane.VERTICAL_SCROLLBAR_NEVER, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - scp.setPreferredSize( new Dimension( 300, 20 ) ); - lembretesPanel = new JPanel(); - lembretesPanel.setLayout( new GridLayout( 1, 1 ) ); - recarregarButton = new JButton( "Recarregar" ); - recarregarButton.addActionListener( this ); - - getContentPane().setLayout( new BorderLayout() ); - getContentPane().add( scp, BorderLayout.WEST ); - getContentPane().add( lembretesPanel, BorderLayout.CENTER ); - getContentPane().add( recarregarButton, BorderLayout.SOUTH ); - - addWindowListener( new WindowAdapter(){ - public void windowClosing( WindowEvent e ) - { - close(); - } - - public void windowOpened( WindowEvent e ) - { -// setExtendedState( getExtendedState() | MAXIMIZED_BOTH ); - setSize( 1024, 700 ); - reloadTotais(); - } - } ); - } - - public void refresh() - { - } - - public void open() - { - setVisible( true ); - } - - public void close() - { - SwingUtilities.invokeLater( new Runnable() { - public void run() - { - setVisible( false ); - dispose(); - } - } ); - } - - protected void reloadTotais() - { - try - { - Vector values = tiposModel.getValues(); - values.clear(); - TipoLembrete tipos[] = provider.getTiposLembrete(); - for( int n = 0; n < tipos.length; n++ ) - { - int count = provider.countLembretesByTipo( tipos[ n ].getID() ); - values.add( new ColumnizedObjectArray( - new Object[]{ tipos[ n ].getID(), tipos[ n ].getDescricao(), - "" + count }, true ) ); - } - tiposModel.setValues( values ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar lembretes", true ); - } - } - - protected void reloadLembretes() - { - lembretesPanel.removeAll(); - int selected = tiposTable.getSelectedRow(); - if( selected != -1 ) - { - ColumnizedObjectArray line = ( ColumnizedObjectArray ) tiposModel.getRowAt( selected ); - Integer tipoID = line.getID(); - try - { - TipoLembrete tipo = provider.getTipoLembreteByID( tipoID ); - if( CODE_EXTERNO.equals( tipo.getCodigo() ) ) - { - - } - if( CODE_REMARCACOES.equals( tipo.getCodigo() ) ) - { - lembretesPanel.add( new LembretesRemarcacaoPanel() ); - } - if( CODE_MARCACOES.equals( tipo.getCodigo() ) ) - { - } - if( CODE_OUTROS.equals( tipo.getCodigo() ) ) - { - } - - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar lembretes", true ); - } - } - validate(); - repaint(); - } - - public boolean closeIfPossible() - { - close(); - return true; - } - - public void actionPerformed(ActionEvent e) - { - Object source = e.getSource(); - if( source.equals( recarregarButton ) ) - { - reloadTotais(); - } - } - - public void valueChanged(ListSelectionEvent e) - { - if( !e.getValueIsAdjusting() ) - { - reloadLembretes(); - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/TipoLembrete.java b/trunk/SIPRPSoft/src/siprp/lembretes/TipoLembrete.java deleted file mode 100644 index e5564393..00000000 --- a/trunk/SIPRPSoft/src/siprp/lembretes/TipoLembrete.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * TipoLembrete.java - * - * Created on February 5, 2007, 6:28 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.lembretes; - -import com.evolute.utils.data.IDObject; - -/** - * - * @author lflores - */ -public class TipoLembrete - implements IDObject, Comparable -{ - protected Integer id; - protected String codigo; - protected String descricao; - protected Integer ordem; - - /** Creates a new instance of TipoLembrete */ - public TipoLembrete( Integer id, String codigo, String descricao, - Integer ordem ) - { - this.id = id; - this.codigo = codigo; - this.descricao = descricao; - this.ordem = ordem; - } - - public Integer getID() - { - return id; - } - - protected String getCodigo() - { - return codigo; - } - - protected String getDescricao() - { - return descricao; - } - - protected Integer getOrdem() - { - return ordem; - } - - public int compareTo( Object other ) - { - if( !( other instanceof TipoLembrete ) ) - { - return 0; - } - TipoLembrete otl = ( TipoLembrete ) other; - return getOrdem().compareTo( otl.getOrdem() ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/LembretesRemarcacaoPanel.java b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/LembretesRemarcacaoPanel.java deleted file mode 100644 index 5638688a..00000000 --- a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/LembretesRemarcacaoPanel.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * LembretesRemarcacaoPanel.java - * - * Created on 13 de Fevereiro de 2007, 23:24 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.lembretes.remarcacoes; - -import com.evolute.utils.data.IDObject; -import com.evolute.utils.data.MappableObject; -import com.evolute.utils.jdo.JDOProvider; -import com.evolute.utils.ui.panel.multipleactionlist.MultipleActionListPanel; -import java.awt.BorderLayout; -import java.awt.GridLayout; -import java.util.List; -import java.util.Vector; -import javax.swing.*; -import siprp.lembretes.Lembrete; -import siprp.lembretes.LembretesConstants; -import siprp.lembretes.LembretesDataProvider; - -/** - * - * @author Frederico - */ -public class LembretesRemarcacaoPanel extends JPanel - implements LembretesConstants -{ - protected JScrollPane listTrabalhadoresScroll; - protected JScrollPane listEstabelecimentosScroll; - protected MultipleActionListPanel listTrabalhadoresPanel; - protected MultipleActionListPanel listEstabelecimentosPanel; - - protected RemarcacoesDataProvider provider; - - private JDOProvider JDO; - - /** Creates a new instance of LembretesRemarcacaoPanel */ - public LembretesRemarcacaoPanel() - throws Exception - { - provider = RemarcacoesDataProvider.getProvider(); - setupComponents(); - } - - private void setupComponents() - throws Exception - { - listTrabalhadoresPanel = - new MultipleActionListPanel( - new RemarcacoesActionFactory[]{ }, - new RemarcacoesActionFactory[]{ new RemarcacoesActionFactory( RemarcacoesActionFactory.TRABALHADOR ) } ); - listTrabalhadoresScroll = - new JScrollPane( listTrabalhadoresPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - listEstabelecimentosPanel = - new MultipleActionListPanel( - new RemarcacoesActionFactory[]{ }, - new RemarcacoesActionFactory[]{ new RemarcacoesActionFactory( RemarcacoesActionFactory.ESTABELECIMENTO ) } ); - listEstabelecimentosScroll = - new JScrollPane( listEstabelecimentosPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - setLayout( new GridLayout( 1, 2 ) ); - JPanel trabalhadoresPanel = new JPanel(); - JPanel estabelecimentosPanel = new JPanel(); - add( trabalhadoresPanel ); - add( estabelecimentosPanel ); - - trabalhadoresPanel.setLayout( new BorderLayout() ); - trabalhadoresPanel.add( new JLabel( "Consultas / ECDs", JLabel.CENTER ), BorderLayout.NORTH ); - trabalhadoresPanel.add( listTrabalhadoresScroll, BorderLayout.CENTER ); - - estabelecimentosPanel.setLayout( new BorderLayout() ); - estabelecimentosPanel.add( new JLabel( "Higiene e Seguran\u00e7a", JLabel.CENTER ), BorderLayout.NORTH ); - estabelecimentosPanel.add( listEstabelecimentosScroll, BorderLayout.CENTER ); - - listTrabalhadoresPanel.showList( provider.getLembretesRemarcacaoTrabalhador() ); -// listEstabelecimentosPanel.showList( estabelecimentos.toArray( new IDObject[ estabelecimentos.size() ] ) ); - } - - protected String criarDetalhesMarcacaoTrabalhador( Integer marcacaoID ) - { - return null; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/RemarcacoesActionFactory.java b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/RemarcacoesActionFactory.java deleted file mode 100644 index 25b84227..00000000 --- a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/RemarcacoesActionFactory.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * RemarcacoesActionFactory.java - * - * Created on January 31, 2007, 6:37 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.lembretes.remarcacoes; - -import com.evolute.utils.data.IDObject; -import com.evolute.utils.ui.panel.multipleactionlist.ActionFactory; -import javax.swing.Action; -import siprp.lembretes.remarcacoes.actions.TratarMarcacaoEstabelecimentoAction; -import siprp.lembretes.remarcacoes.actions.TratarMarcacaoTrabalhadorAction; - -/** - * - * @author fpalma - */ -public class RemarcacoesActionFactory implements ActionFactory -{ - public static final int TRABALHADOR = 0; - public static final int ESTABELECIMENTO = 1; - - protected final int TIPO; - - /** - * Creates a new instance of RemarcacoesActionFactory - */ - public RemarcacoesActionFactory( int tipo ) - { - TIPO = tipo; - } - - public Action createAction(IDObject[] objects) - { - return null; - } - - public Action createAction(IDObject object) - { - switch( TIPO ) - { - case TRABALHADOR: - return new TratarMarcacaoTrabalhadorAction( object ); - - case ESTABELECIMENTO: - return new TratarMarcacaoEstabelecimentoAction( object ); - - default: - return null; - } - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/RemarcacoesDataProvider.java b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/RemarcacoesDataProvider.java deleted file mode 100644 index 209cccf1..00000000 --- a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/RemarcacoesDataProvider.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * RemarcacoesDataProvider.java - * - * Created on February 14, 2007, 10:56 AM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.lembretes.remarcacoes; - -import com.evolute.utils.Singleton; -import com.evolute.utils.arrays.Virtual2DArray; -import com.evolute.utils.data.IDObject; -import com.evolute.utils.data.MappableObject; -import com.evolute.utils.db.DBManager; -import com.evolute.utils.db.Executer; -import com.evolute.utils.sql.Expression; -import com.evolute.utils.sql.Field; -import com.evolute.utils.sql.Select; -import com.evolute.utils.sql.Select2; -import java.text.DateFormat; -import java.util.Date; -import java.util.Locale; -import siprp.data.Marcacao; -import siprp.lembretes.LembretesConstants; -import siprp.lembretes.LembretesDataProvider; - -/** - * - * @author lflores - */ -public class RemarcacoesDataProvider -{ - private static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) ); - - private static final Object LOCK = new Object(); - private static RemarcacoesDataProvider instance = null; - - private Executer EXECUTER; - private LembretesDataProvider lembretesProvider; - - /** Creates a new instance of RemarcacoesDataProvider */ - public RemarcacoesDataProvider() - throws Exception - { - DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); - EXECUTER = dbm.getSharedExecuter( this ); - lembretesProvider = LembretesDataProvider.getProvider(); - } - - public static RemarcacoesDataProvider getProvider() - throws Exception - { - synchronized( LOCK ) - { - if( instance == null ) - { - instance = new RemarcacoesDataProvider(); - } - } - return instance; - } - - public IDObject[] getLembretesRemarcacaoTrabalhador() - throws Exception - { - Select select = - new Select2( new String[]{ "lembretes", "marcacoes_trabalhador", "trabalhadores", - "estabelecimentos", "empresas" }, - new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER }, - new Expression[]{ - new Field( "lembretes.marcacao_trabalhador_id" ).isEqual( new Field( "marcacoes_trabalhador.id" ) ), - new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ), - new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ), - new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ), - }, - new String[]{ "lembretes.id", "lembretes.descricao", - "marcacoes_trabalhador.tipo", "marcacoes_trabalhador.data", - "trabalhadores.nome", "estabelecimentos.nome", "empresas.designacao_social", - "trabalhadores.nome_plain" }, - new Field( "lembretes.tipo_id" ).isEqual( - lembretesProvider.getTipoLembreteByCodigo( LembretesConstants.CODE_REMARCACOES ).getID() ).and( - new Field( "lembretes.data" ).isLessOrEqual( new Field( "current_date" ) ) ), - new String[]{ "trabalhadores.nome_plain" }, - null, - null, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - IDObject lembretes[] = new IDObject[ array.columnLength() ]; - for( int n = 0; n < lembretes.length; n++ ) - { - Integer id = ( Integer ) array.get( n, 0 ); - String descricao = ( String ) array.get( n, 1 ); - Integer tipoMarcacao = ( Integer ) array.get( n, 2 ); - String tipoMarcacaoStr = ""; - switch( tipoMarcacao.intValue() ) - { - case Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES: - tipoMarcacaoStr = "ECDs"; - break; - - case Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA: - tipoMarcacaoStr = "Consulta"; - break; - } - Date data = ( Date ) array.get( n, 3 ); - String trabalhador = ( String ) array.get( n, 4 ); - String split[] = trabalhador.split( " " ); - trabalhador = split[ 0 ] + " " + ( split.length > 2 ? split[ 1 ].charAt( 0 ) + ". " : " " ) + - ( split.length > 1 ? split[ split.length - 1 ] : "" ); - String estabelecimento = ( String ) array.get( n, 5 ); - String empresa = ( String ) array.get( n, 6 ); - String str = "" + trabalhador + "" - + "
   " + tipoMarcacaoStr + " de " + D_F.format( data ) - + "
   " + descricao + "" - + "
   " + empresa.substring( 0, empresa.length() > 20 ? 20 : empresa.length() ) - + " / " + estabelecimento.substring( 0, estabelecimento.length() > 10 ? 10 : estabelecimento.length() ) - + ""; - lembretes[ n ] = new MappableObject( id, str ); - } - return lembretes; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoEstabelecimentoAction.java b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoEstabelecimentoAction.java deleted file mode 100644 index 58047330..00000000 --- a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoEstabelecimentoAction.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * tratarMarcacaoTrabalhadorAction.java - * - * Created on January 31, 2007, 6:21 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.lembretes.remarcacoes.actions; - -import com.evolute.utils.data.IDObject; -import com.evolute.utils.ui.DialogException; -import java.awt.event.ActionEvent; -import javax.swing.AbstractAction; - -/** - * - * @author fpalma - */ -public class TratarMarcacaoEstabelecimentoAction extends AbstractAction -{ - /** - * Creates a new instance of tratarMarcacaoTrabalhadorAction - */ - public TratarMarcacaoEstabelecimentoAction( IDObject marcacaoID ) - { - super( "Tratar" ); - } - - public void actionPerformed(ActionEvent e) - { - try - { - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a marcar", true ); - } - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoTrabalhadorAction.java b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoTrabalhadorAction.java deleted file mode 100644 index 5de7330c..00000000 --- a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoTrabalhadorAction.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * TratarMarcacaoTrabalhadorAction.java - * - * Created on January 31, 2007, 6:21 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.lembretes.remarcacoes.actions; - -import com.evolute.utils.Singleton; -import com.evolute.utils.data.IDObject; -import com.evolute.utils.jdo.JDOProvider; -import com.evolute.utils.ui.DialogException; -import java.awt.event.ActionEvent; -import javax.swing.AbstractAction; -import javax.swing.JOptionPane; -import siprp.SIPRPTracker; -import siprp.SingletonConstants; -import siprp.data.EmpresaData; -import siprp.data.EstabelecimentoData; -import siprp.data.MarcacaoTrabalhadorData; -import siprp.data.TrabalhadorData; -import siprp.lembretes.Lembrete; -import siprp.lembretes.LembretesDataProvider; - -/** - * - * @author fpalma - */ -public class TratarMarcacaoTrabalhadorAction extends AbstractAction -{ - private LembretesDataProvider lembretesProvider; - private JDOProvider JDO; - private SIPRPTracker tracker; - - private Integer lembreteID; - - /** - * Creates a new instance of TratarMarcacaoTrabalhadorAction - */ - public TratarMarcacaoTrabalhadorAction( IDObject lembrete ) - { - super( "Tratar" ); - try - { - lembreteID = lembrete.getID(); - lembretesProvider = LembretesDataProvider.getProvider(); - JDO = (JDOProvider) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); - } - catch( Exception ex ) - { - ex.printStackTrace(); - } - } - - public void actionPerformed(ActionEvent e) - { - try - { - tracker = ( SIPRPTracker ) Singleton.getInstance( SingletonConstants.SIPRP_TRACKER ); - Lembrete lembrete = lembretesProvider.getLembreteByID( lembreteID ); - if( lembrete == null ) - { - JOptionPane.showMessageDialog( null, "Este lembrete j\u00e1 foi tratado.", "J\u00e1 tratado", - JOptionPane.WARNING_MESSAGE ); - return; - } - MarcacaoTrabalhadorData marcacao = ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, lembrete.getMarcacaoTrabalhadorID() ); - TrabalhadorData trabalhador = ( TrabalhadorData ) marcacao.get( MarcacaoTrabalhadorData.TRABALHADOR ); - EstabelecimentoData estabelecimento = ( EstabelecimentoData ) trabalhador.get( TrabalhadorData.ESTABELECIMENTO ); - EmpresaData empresa = ( EmpresaData ) estabelecimento.get( EstabelecimentoData.EMPRESA ); - - lembretesProvider.apagarLembreteByID( lembreteID ); - setEnabled( false ); - tracker.getMedicinaWindow().setVisible( true ); - tracker.getMedicinaWindow().setEmpresaAndEstabelecimentoAndTrabalhador( (Integer) empresa.get( EmpresaData.ID ), - ( Integer ) estabelecimento.get( EstabelecimentoData.ID ), - ( Integer ) trabalhador.get( TrabalhadorData.ID ) ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a tratar", true ); - } - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoConsultaExtendedPanel.java b/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoConsultaExtendedPanel.java deleted file mode 100644 index b1cfe077..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoConsultaExtendedPanel.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * MarcacaoConsultaExtendedPanel.java - * - * Created on 13 de Fevereiro de 2007, 20:36 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina; - -import java.awt.*; -import javax.swing.*; - -/** - * - * @author Frederico - */ -public class MarcacaoConsultaExtendedPanel extends JPanel -{ - - /** Creates a new instance of MarcacaoConsultaExtendedPanel */ - public MarcacaoConsultaExtendedPanel() - { - setupComponents(); - } - - private void setupComponents() - { - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoConsultaPanel.java b/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoConsultaPanel.java deleted file mode 100644 index 5404688a..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoConsultaPanel.java +++ /dev/null @@ -1,303 +0,0 @@ -package siprp.medicina; - -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.calendar.*; -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 MarcacaoConsultaPanel - extends JPanel - implements ControllableComponent, DataClassAware -{ - private siprp.data.MarcacaoTrabalhadorData marcacaoTrabalhadorData; - private final ComponentsHashtable components = new ComponentsHashtable(); - - protected final SQLExecuter EXECUTER; - - private final JLabel dataLabel = new JLabel( "Data da consulta", JLabel.RIGHT ); - private final JCalendarPanel dataPanel = new JCalendarPanel( null ); - private final JButton emailButton = new JButton( "Enviar Email" ); - private final JLabel dataFichaLabel = new JLabel( "Data da Ficha de Aptid\u00e3o", JLabel.RIGHT ); - private final JCalendarPanel dataFichaPanel = new JCalendarPanel( null ); - private RadioButtonFixedPanel tipoList; - private RadioButtonFixedPanel estadoList; - private final JScrollPane observacoesTextScroll = new JScrollPane(); - private final StateTextArea observacoesText = new StateTextArea(); - - public MarcacaoConsultaPanel() - 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 MarcacaoConsultaPanel = this; - dataPanel.setMinimumSize( new Dimension( 300, 20 ) ); - dataPanel.setPreferredSize( new Dimension( 100, 20 ) ); - - emailButton.setMinimumSize( new Dimension( 300, 20 ) ); - emailButton.setPreferredSize( new Dimension( 200, 20 ) ); - - dataFichaPanel.setMinimumSize( new Dimension( 300, 20 ) ); - dataFichaPanel.setPreferredSize( new Dimension( 100, 20 ) ); - - IDObject tipoListOptions[] = new IDObject[]{ - new MappableObject( new Integer( 1 ), "Admiss\u00e3o" ), - new MappableObject( new Integer( 2 ), "Peri\u00f3dico" ), - new MappableObject( new Integer( 5 ), "Peri\u00f3dico inicial" ), - new MappableObject( new Integer( 3 ), "Ocasional" ), - }; - tipoList = new RadioButtonFixedPanel( tipoListOptions, 4, 1, RadioButtonFixedPanel.ORIENTATION_VERTICAL, false, null ); - tipoList.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Tipo" ) ); - - IDObject estadoListOptions[] = new IDObject[]{ - new MappableObject( new Integer( 0 ), "Por realizar" ), - new MappableObject( new Integer( 2 ), "Realizada" ), - new MappableObject( new Integer( 3 ), "Desmarcada pelo trabalhador" ), - new MappableObject( new Integer( 4 ), "Desmarcada pela SIPRP" ), - new MappableObject( new Integer( 5 ), "Faltou" ), - }; - 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 MarcacaoConsultaPanel = this; - GridBagConstraints MarcacaoConsultaPanelGBC = new GridBagConstraints(); - MarcacaoConsultaPanelGBC.insets = new Insets( 1, 1, 1, 1 ); - GridBagLayout MarcacaoConsultaPanelLayout = new GridBagLayout(); - MarcacaoConsultaPanel.setLayout( MarcacaoConsultaPanelLayout ); - MarcacaoConsultaPanelGBC.gridx = 0; - MarcacaoConsultaPanelGBC.gridy = 0; - MarcacaoConsultaPanelGBC.gridwidth = 1; - MarcacaoConsultaPanelGBC.gridheight = 1; - MarcacaoConsultaPanelGBC.weightx = 0.0; - MarcacaoConsultaPanelGBC.weighty = 0.0; - MarcacaoConsultaPanelGBC.fill = GridBagConstraints.HORIZONTAL; - MarcacaoConsultaPanelLayout.setConstraints( dataLabel, MarcacaoConsultaPanelGBC ); - MarcacaoConsultaPanel.add( dataLabel ); - - MarcacaoConsultaPanelGBC.gridx = 1; - MarcacaoConsultaPanelGBC.gridy = 0; - MarcacaoConsultaPanelGBC.gridwidth = 1; - MarcacaoConsultaPanelGBC.gridheight = 1; - MarcacaoConsultaPanelGBC.weightx = 0.5; - MarcacaoConsultaPanelGBC.weighty = 0.0; - MarcacaoConsultaPanelGBC.fill = GridBagConstraints.HORIZONTAL; - MarcacaoConsultaPanelLayout.setConstraints( dataPanel, MarcacaoConsultaPanelGBC ); - MarcacaoConsultaPanel.add( dataPanel ); - - MarcacaoConsultaPanelGBC.gridx = 2; - MarcacaoConsultaPanelGBC.gridy = 0; - MarcacaoConsultaPanelGBC.gridwidth = 1; - MarcacaoConsultaPanelGBC.gridheight = 1; - MarcacaoConsultaPanelGBC.weightx = 0.5; - MarcacaoConsultaPanelGBC.weighty = 0.0; - MarcacaoConsultaPanelGBC.fill = GridBagConstraints.NONE; - MarcacaoConsultaPanelLayout.setConstraints( emailButton, MarcacaoConsultaPanelGBC ); - MarcacaoConsultaPanel.add( emailButton ); - - MarcacaoConsultaPanelGBC.gridx = 0; - MarcacaoConsultaPanelGBC.gridy = 1; - MarcacaoConsultaPanelGBC.gridwidth = 1; - MarcacaoConsultaPanelGBC.gridheight = 1; - MarcacaoConsultaPanelGBC.weightx = 0.0; - MarcacaoConsultaPanelGBC.weighty = 0.0; - MarcacaoConsultaPanelGBC.fill = GridBagConstraints.HORIZONTAL; - MarcacaoConsultaPanelLayout.setConstraints( dataFichaLabel, MarcacaoConsultaPanelGBC ); - MarcacaoConsultaPanel.add( dataFichaLabel ); - - MarcacaoConsultaPanelGBC.gridx = 1; - MarcacaoConsultaPanelGBC.gridy = 1; - MarcacaoConsultaPanelGBC.gridwidth = 1; - MarcacaoConsultaPanelGBC.gridheight = 1; - MarcacaoConsultaPanelGBC.weightx = 0.5; - MarcacaoConsultaPanelGBC.weighty = 0.0; - MarcacaoConsultaPanelGBC.fill = GridBagConstraints.HORIZONTAL; - MarcacaoConsultaPanelLayout.setConstraints( dataFichaPanel, MarcacaoConsultaPanelGBC ); - MarcacaoConsultaPanel.add( dataFichaPanel ); - - MarcacaoConsultaPanelGBC.gridx = 0; - MarcacaoConsultaPanelGBC.gridy = 2; - MarcacaoConsultaPanelGBC.gridwidth = 2; - MarcacaoConsultaPanelGBC.gridheight = 1; - MarcacaoConsultaPanelGBC.weightx = 0.5; - MarcacaoConsultaPanelGBC.weighty = 0.0; - MarcacaoConsultaPanelGBC.fill = GridBagConstraints.BOTH; - MarcacaoConsultaPanelLayout.setConstraints( tipoList, MarcacaoConsultaPanelGBC ); - MarcacaoConsultaPanel.add( tipoList ); - - MarcacaoConsultaPanelGBC.gridx = 2; - MarcacaoConsultaPanelGBC.gridy = 2; - MarcacaoConsultaPanelGBC.gridwidth = 1; - MarcacaoConsultaPanelGBC.gridheight = 1; - MarcacaoConsultaPanelGBC.weightx = 0.5; - MarcacaoConsultaPanelGBC.weighty = 0.0; - MarcacaoConsultaPanelGBC.fill = GridBagConstraints.BOTH; - MarcacaoConsultaPanelLayout.setConstraints( estadoList, MarcacaoConsultaPanelGBC ); - MarcacaoConsultaPanel.add( estadoList ); - - MarcacaoConsultaPanelGBC.gridx = 0; - MarcacaoConsultaPanelGBC.gridy = 3; - MarcacaoConsultaPanelGBC.gridwidth = 3; - MarcacaoConsultaPanelGBC.gridheight = 1; - MarcacaoConsultaPanelGBC.weightx = 1.0; - MarcacaoConsultaPanelGBC.weighty = 1.0; - observacoesTextScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - observacoesTextScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED ); - observacoesTextScroll.setViewportView( observacoesText ); - MarcacaoConsultaPanelGBC.fill = GridBagConstraints.BOTH; - MarcacaoConsultaPanelLayout.setConstraints( observacoesTextScroll, MarcacaoConsultaPanelGBC ); - MarcacaoConsultaPanel.add( observacoesTextScroll ); - - } - - private void setupComponentsHashtable() - { - components.putComponent( siprp.data.MarcacaoTrabalhadorData.DATA, dataPanel ); - components.putComponent( siprp.data.MarcacaoTrabalhadorData.DATA_RELATORIO, dataFichaPanel ); - components.putComponent( siprp.data.MarcacaoTrabalhadorData.MOTIVO, tipoList ); - components.putComponent( siprp.data.MarcacaoTrabalhadorData.ESTADO, estadoList ); - components.putComponent( siprp.data.MarcacaoTrabalhadorData.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.MarcacaoTrabalhadorData ) - { - marcacaoTrabalhadorData = (siprp.data.MarcacaoTrabalhadorData) toFill; - } - } - else if( toFill instanceof Hashtable ) - { - data = (Hashtable) toFill; - } - else - { - return; - } - if( marcacaoTrabalhadorData == null ) - { - marcacaoTrabalhadorData = new siprp.data.MarcacaoTrabalhadorData(); - marcacaoTrabalhadorData.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( marcacaoTrabalhadorData == null ) - { - marcacaoTrabalhadorData = new siprp.data.MarcacaoTrabalhadorData(); - } - Hashtable data = marcacaoTrabalhadorData.getHashData(); - String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] ); - ComponentController.save( properties, data, components ); - if( !( marcacaoTrabalhadorData instanceof PropertyObject ) ) - { - return data; - } - marcacaoTrabalhadorData.setHashData( data ); - return marcacaoTrabalhadorData; - } - - public void clear() - { - marcacaoTrabalhadorData = 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.MarcacaoTrabalhadorData.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 RadioButtonFixedPanel getTipoList() - { - return tipoList; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoConsultaPanel.xml b/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoConsultaPanel.xml deleted file mode 100644 index 7229c554..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoConsultaPanel.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - siprp.data.* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Tipo - - 4 - - - Admiss\u00e3o - Peri\u00f3dico - Peri\u00f3dico inicial - Ocasional - - - - - Estado - - 6 - - - Por realizar - Realizada - Desmarcada pelo trabalhador - Desmarcada pela SIPRP - Faltou - - - - - - Observa\u00e7\u00f5es - - - 5 - - - - diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoExamePanel.java b/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoExamePanel.java deleted file mode 100644 index d1f4fd75..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoExamePanel.java +++ /dev/null @@ -1,262 +0,0 @@ -package siprp.medicina; - -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.calendar.*; -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 MarcacaoExamePanel - extends JPanel - implements ControllableComponent, DataClassAware -{ - private siprp.data.MarcacaoTrabalhadorData marcacaoTrabalhadorData; - private final ComponentsHashtable components = new ComponentsHashtable(); - - protected final SQLExecuter EXECUTER; - - private final JLabel dataLabel = new JLabel( "Data dos Exames", JLabel.RIGHT ); - private final JCalendarPanel dataPanel = new JCalendarPanel( null ); - private final JButton emailButton = new JButton( "Enviar Email" ); - private final JPanelControllable detalhesPanel = new JPanelControllable(); - private RadioButtonFixedPanel estadoList; - private final JScrollPane observacoesTextScroll = new JScrollPane(); - private final StateTextArea observacoesText = new StateTextArea(); - - public MarcacaoExamePanel() - 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 MarcacaoExamePanel = this; - emailButton.setMinimumSize( new Dimension( 300, 20 ) ); - emailButton.setPreferredSize( new Dimension( 200, 20 ) ); - - detalhesPanel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Detalhes" ) ); - - IDObject estadoListOptions[] = new IDObject[]{ - new MappableObject( new Integer( 0 ), "Por realizar" ), - new MappableObject( new Integer( 1 ), "Parcialmente realizados" ), - new MappableObject( new Integer( 2 ), "Realizados" ), - new MappableObject( new Integer( 3 ), "Desmarcados pelo trabalhador" ), - new MappableObject( new Integer( 4 ), "Desmarcados pela SIPRP" ), - new MappableObject( new Integer( 5 ), "Faltou" ), - }; - 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 MarcacaoExamePanel = this; - GridBagConstraints detalhesPanelGBC = new GridBagConstraints(); - detalhesPanelGBC.insets = new Insets( 1, 1, 1, 1 ); - GridBagLayout detalhesPanelLayout = new GridBagLayout(); - detalhesPanel.setLayout( detalhesPanelLayout ); - GridBagConstraints MarcacaoExamePanelGBC = new GridBagConstraints(); - MarcacaoExamePanelGBC.insets = new Insets( 1, 1, 1, 1 ); - GridBagLayout MarcacaoExamePanelLayout = new GridBagLayout(); - MarcacaoExamePanel.setLayout( MarcacaoExamePanelLayout ); - MarcacaoExamePanelGBC.gridx = 0; - MarcacaoExamePanelGBC.gridy = 0; - MarcacaoExamePanelGBC.gridwidth = 1; - MarcacaoExamePanelGBC.gridheight = 1; - MarcacaoExamePanelGBC.weightx = 0.0; - MarcacaoExamePanelGBC.weighty = 0.0; - MarcacaoExamePanelGBC.fill = GridBagConstraints.HORIZONTAL; - MarcacaoExamePanelLayout.setConstraints( dataLabel, MarcacaoExamePanelGBC ); - MarcacaoExamePanel.add( dataLabel ); - - MarcacaoExamePanelGBC.gridx = 1; - MarcacaoExamePanelGBC.gridy = 0; - MarcacaoExamePanelGBC.gridwidth = 1; - MarcacaoExamePanelGBC.gridheight = 1; - MarcacaoExamePanelGBC.weightx = 0.5; - MarcacaoExamePanelGBC.weighty = 0.0; - MarcacaoExamePanelGBC.fill = GridBagConstraints.HORIZONTAL; - MarcacaoExamePanelLayout.setConstraints( dataPanel, MarcacaoExamePanelGBC ); - MarcacaoExamePanel.add( dataPanel ); - - MarcacaoExamePanelGBC.gridx = 2; - MarcacaoExamePanelGBC.gridy = 0; - MarcacaoExamePanelGBC.gridwidth = 1; - MarcacaoExamePanelGBC.gridheight = 1; - MarcacaoExamePanelGBC.weightx = 0.5; - MarcacaoExamePanelGBC.weighty = 0.0; - MarcacaoExamePanelGBC.fill = GridBagConstraints.NONE; - MarcacaoExamePanelLayout.setConstraints( emailButton, MarcacaoExamePanelGBC ); - MarcacaoExamePanel.add( emailButton ); - - MarcacaoExamePanelGBC.gridx = 0; - MarcacaoExamePanelGBC.gridy = 1; - MarcacaoExamePanelGBC.gridwidth = 2; - MarcacaoExamePanelGBC.gridheight = 1; - MarcacaoExamePanelGBC.weightx = 0.5; - MarcacaoExamePanelGBC.weighty = 0.0; - MarcacaoExamePanelGBC.fill = GridBagConstraints.BOTH; - MarcacaoExamePanelLayout.setConstraints( detalhesPanel, MarcacaoExamePanelGBC ); - MarcacaoExamePanel.add( detalhesPanel ); - - MarcacaoExamePanelGBC.gridx = 2; - MarcacaoExamePanelGBC.gridy = 1; - MarcacaoExamePanelGBC.gridwidth = 1; - MarcacaoExamePanelGBC.gridheight = 1; - MarcacaoExamePanelGBC.weightx = 0.5; - MarcacaoExamePanelGBC.weighty = 0.0; - MarcacaoExamePanelGBC.fill = GridBagConstraints.BOTH; - MarcacaoExamePanelLayout.setConstraints( estadoList, MarcacaoExamePanelGBC ); - MarcacaoExamePanel.add( estadoList ); - - MarcacaoExamePanelGBC.gridx = 0; - MarcacaoExamePanelGBC.gridy = 2; - MarcacaoExamePanelGBC.gridwidth = 3; - MarcacaoExamePanelGBC.gridheight = 1; - MarcacaoExamePanelGBC.weightx = 1.0; - MarcacaoExamePanelGBC.weighty = 1.0; - observacoesTextScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - observacoesTextScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED ); - observacoesTextScroll.setViewportView( observacoesText ); - MarcacaoExamePanelGBC.fill = GridBagConstraints.BOTH; - MarcacaoExamePanelLayout.setConstraints( observacoesTextScroll, MarcacaoExamePanelGBC ); - MarcacaoExamePanel.add( observacoesTextScroll ); - - } - - private void setupComponentsHashtable() - { - components.putComponent( siprp.data.MarcacaoTrabalhadorData.DATA, dataPanel ); - components.putComponent( siprp.data.MarcacaoTrabalhadorData.ESTADO, estadoList ); - components.putComponent( siprp.data.MarcacaoTrabalhadorData.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.MarcacaoTrabalhadorData ) - { - marcacaoTrabalhadorData = (siprp.data.MarcacaoTrabalhadorData) toFill; - } - } - else if( toFill instanceof Hashtable ) - { - data = (Hashtable) toFill; - } - else - { - return; - } - if( marcacaoTrabalhadorData == null ) - { - marcacaoTrabalhadorData = new siprp.data.MarcacaoTrabalhadorData(); - marcacaoTrabalhadorData.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( marcacaoTrabalhadorData == null ) - { - marcacaoTrabalhadorData = new siprp.data.MarcacaoTrabalhadorData(); - } - Hashtable data = marcacaoTrabalhadorData.getHashData(); - String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] ); - ComponentController.save( properties, data, components ); - if( !( marcacaoTrabalhadorData instanceof PropertyObject ) ) - { - return data; - } - marcacaoTrabalhadorData.setHashData( data ); - return marcacaoTrabalhadorData; - } - - public void clear() - { - marcacaoTrabalhadorData = 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.MarcacaoTrabalhadorData.class; - } - - public JLabel getDataLabel() - { - return dataLabel; - } - - public JCalendarPanel getDataPanel() - { - return dataPanel; - } - - public JPanelControllable getDetalhesPanel() - { - return detalhesPanel; - } - - public JButton getEmailButton() - { - return emailButton; - } - - public RadioButtonFixedPanel getEstadoList() - { - return estadoList; - } - - public StateTextArea getObservacoesText() - { - return observacoesText; - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoExamePanel.xml b/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoExamePanel.xml deleted file mode 100644 index bb5e2ab1..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/MarcacaoExamePanel.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - siprp.data.* - - - - - - - - - - - - - - - - - - - - - Detalhes - - - - - - - - - Estado - - 6 - - - Por realizar - Parcialmente realizados - Realizados - Desmarcados pelo trabalhador - Desmarcados pela SIPRP - Faltou - - - - - - Observa\u00e7\u00f5es - - - 5 - - - - diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MarcacoesMedicinaHandler.java b/trunk/SIPRPSoft/src/siprp/medicina/MarcacoesMedicinaHandler.java deleted file mode 100644 index 2ccce75a..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/MarcacoesMedicinaHandler.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * MarcacoesMedicinaHandler.java - * - * Created on 28 de Abril de 2006, 9:56 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina; - -import java.util.*; - -import com.evolute.utils.*; -import com.evolute.utils.jdo.*; - -import siprp.data.*; - -/** - * Classe auxiliar para tratamento de marcações de Medicina. - * - * @author Frederico - */ -public class MarcacoesMedicinaHandler -{ - /** Creates a new instance of MarcacoesMedicinaHandler */ - public MarcacoesMedicinaHandler() - { - } - - /** - * Ajusta os estado das marações corrente e seguinte para uma trabalhador. - * Este método é usado pelo sistema de marcaç&atild;o de fichas de aptidaão para ajustar - * as marcações existentes às escolhidas na ficha. - * - * @param trabalhadorID um inteiro que representa o trabalhador em questão - * @param motivoCorrente um inteiro que representa o motivo da marcação corrente (admissão/periódico/ocasional) - * @param dataCorrente a data que se pretende para a marcação corrente - * @param motivoSeguinte um inteiro que representa o motivo da marcação seguinte (admissão/periódico/ocasional) - * @param dataSeguinte a data que se pretende para a marcação seguinte - * @throws Exception se houver um erro na comunicação com a Base de Dados - */ - public void ajustarMarcacoes( Integer trabalhadorID, Integer motivoCorrente, Date dataCorrente, - Integer motivoSeguinte, Date dataSeguinte ) - throws Exception - { - Integer idCorrente; - Integer idSeguinte; - MedicinaDataProvider provider = ( MedicinaDataProvider ) MedicinaDataProvider.getProvider(); - JDOProvider JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); - TrabalhadorData trabalhador = (TrabalhadorData)JDO.load( TrabalhadorData.class, trabalhadorID ); - - idCorrente = provider.getConsultaIDByTrabalhadorMotivoAndDate( trabalhadorID, motivoCorrente, dataCorrente ); - MarcacaoTrabalhadorData consultaCorrente; - if( idCorrente == null ) - { - consultaCorrente = new MarcacaoTrabalhadorData(); - consultaCorrente.set( MarcacaoTrabalhadorData.TRABALHADOR, trabalhador ); - consultaCorrente.set( MarcacaoTrabalhadorData.TIPO, new Integer( MarcacaoTrabalhadorData.TIPO_CONSULTA ) ); - consultaCorrente.set( Marcacao.DATA, dataCorrente ); - consultaCorrente.set( MarcacaoTrabalhadorData.MOTIVO, motivoCorrente ); - } - else - { - consultaCorrente = ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, idCorrente ); - } - consultaCorrente.set( Marcacao.REALIZADA, "y" ); - consultaCorrente.set( MarcacaoTrabalhadorData.ESTADO, new Integer( siprp.medicina.MedicinaDataProvider.ESTADO_REALIZADO ) ); - consultaCorrente.save(); - - idSeguinte = provider.getConsultaIDByTrabalhadorMotivoAndDate( trabalhadorID, motivoSeguinte, dataSeguinte ); - if( idSeguinte == null ) - { - idSeguinte = provider.getProximaConsultaIDByTrabalhadorMotivoAndDate( trabalhadorID, motivoSeguinte, dataCorrente ); - MarcacaoTrabalhadorData consultaSeguinte; - if( idSeguinte == null ) - { - consultaSeguinte = new MarcacaoTrabalhadorData(); - consultaSeguinte.set( MarcacaoTrabalhadorData.TRABALHADOR, trabalhador ); - consultaSeguinte.set( MarcacaoTrabalhadorData.TIPO, new Integer( MarcacaoTrabalhadorData.TIPO_CONSULTA ) ); - consultaSeguinte.set( MarcacaoTrabalhadorData.MOTIVO, motivoSeguinte ); - consultaSeguinte.set( Marcacao.REALIZADA, "y" ); - consultaSeguinte.set( MarcacaoTrabalhadorData.ESTADO, new Integer( siprp.medicina.MedicinaDataProvider.ESTADO_POR_REALIZAR ) ); - } - else - { - consultaSeguinte = ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, idSeguinte ); - } - consultaSeguinte.set( Marcacao.DATA, dataSeguinte ); - consultaSeguinte.save(); - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MedicinaConstants.java b/trunk/SIPRPSoft/src/siprp/medicina/MedicinaConstants.java deleted file mode 100644 index a09a59f8..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/MedicinaConstants.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * MedicinaConstants.java - * - * Created on 6 de Julho de 2006, 15:22 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina; - -import com.evolute.utils.Singleton; -import siprp.SingletonConstants; - -/** - * - * @author fpalma - */ -public interface MedicinaConstants -{ - public static final int MOTIVO_ADMISSAO = 1; - public static final Integer MOTIVO_ADMISSAO_INTEGER = new Integer( MOTIVO_ADMISSAO ); - public static final String MOTIVO_ADMISSAO_STR = "Admiss\u00e3o"; - public static final int MOTIVO_PERIODICO = 2; - public static final Integer MOTIVO_PERIODICO_INTEGER = new Integer( MOTIVO_PERIODICO ); - public static final String MOTIVO_PERIODICO_STR = "Peri\u00f3dico"; - public static final int MOTIVO_OCASIONAL = 3; - public static final Integer MOTIVO_OCASIONAL_INTEGER = new Integer( MOTIVO_OCASIONAL ); - public static final String MOTIVO_OCASIONAL_STR = "Ocasional"; - public static final int MOTIVO_PERIODICO_INICIAL = 5; - public static final Integer MOTIVO_PERIODICO_INICIAL_INTEGER = new Integer( MOTIVO_PERIODICO_INICIAL ); - public static final String MOTIVO_PERIODICO_INICIAL_STR = "Peri\u00f3dico inicial"; - - public static final int SUB_MOTIVO_APOS_DOENCA = 1; - public static final Integer SUB_MOTIVO_APOS_DOENCA_INTEGER = new Integer( SUB_MOTIVO_APOS_DOENCA ); - public static final String SUB_MOTIVO_APOS_DOENCA_STR = "Ap\u00f3s doen\u00e7a"; - public static final int SUB_MOTIVO_APOS_ACIDENTE = 2; - public static final Integer SUB_MOTIVO_APOS_ACIDENTE_INTEGER = new Integer( SUB_MOTIVO_APOS_ACIDENTE ); - public static final String SUB_MOTIVO_APOS_ACIDENTE_STR = "Ap\u00f3s acidente"; - public static final int SUB_MOTIVO_PEDIDO_TRABALHADOR = 3; - public static final Integer SUB_MOTIVO_PEDIDO_TRABALHADOR_INTEGER = new Integer( SUB_MOTIVO_PEDIDO_TRABALHADOR ); - public static final String SUB_MOTIVO_PEDIDO_TRABALHADOR_STR = "A pedido do trabalhador"; - public static final int SUB_MOTIVO_PEDIDO_SERVICO = 4; - public static final Integer SUB_MOTIVO_PEDIDO_SERVICO_INTEGER = new Integer( SUB_MOTIVO_PEDIDO_SERVICO ); - public static final String SUB_MOTIVO_PEDIDO_SERVICO_STR = "A pedido do servi\u00e7o"; - public static final int SUB_MOTIVO_MUDANCA_FUNCAO = 5; - public static final Integer SUB_MOTIVO_MUDANCA_FUNCAO_INTEGER = new Integer( SUB_MOTIVO_MUDANCA_FUNCAO ); - public static final String SUB_MOTIVO_MUDANCA_FUNCAO_STR = "Por mudan\u00e7a de fun\u00e7\u00e3o"; - public static final int SUB_MOTIVO_ALTERACAO_CONDICOES = 6; - public static final Integer SUB_MOTIVO_ALTERACAO_CONDICOES_INTEGER = new Integer( SUB_MOTIVO_ALTERACAO_CONDICOES ); - public static final String SUB_MOTIVO_ALTERACAO_CONDICOES_STR = "Por altera\u00e7\u00e3o das condi\u00e7\u00f5es de trabalho"; - public static final int SUB_MOTIVO_OUTRO = 10; - public static final Integer SUB_MOTIVO_OUTRO_INTEGER = new Integer( SUB_MOTIVO_OUTRO ); - public static final String SUB_MOTIVO_OUTRO_STR = "Outro"; - - public static final int ESTADO_POR_REALIZAR = 0; - public static final int ESTADO_PARCIALMENTE_REALIZADO = 1; - 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_CONSULTA_STR[] = - new String[]{ "Por Realizar", null, "Realizada", - "Desmarcada pelo Trabalhador", "Desmarcada pela " + Singleton.getInstance( SingletonConstants.COMPANY_ACRONYM ), - "Trabalhador Faltou" }; - - public static final String ESTADOS_EXAME_STR[] = - new String[]{ "Por Realizar", "Parcialmente Realizados", "Realizados", - "Desmarcados pelo Trabalhador", "Desmarcados pela " + Singleton.getInstance( SingletonConstants.COMPANY_ACRONYM ), - "Trabalhador Faltou" }; - - public static final String ESTADOS_STR[][] = - new String[][]{ ESTADOS_EXAME_STR, ESTADOS_CONSULTA_STR }; -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MedicinaDataProvider.java b/trunk/SIPRPSoft/src/siprp/medicina/MedicinaDataProvider.java deleted file mode 100644 index 52c1ce92..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/MedicinaDataProvider.java +++ /dev/null @@ -1,462 +0,0 @@ -/* - * MedicinaDataProvider.java - * - * Created on January 29, 2006, 12:27 AM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina; - -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.tables.*; - -import siprp.*; -import siprp.data.*; -/** - * - * @author fpalma - */ -public class MedicinaDataProvider extends MetaProvider - implements MedicinaConstants -{ - - - public static final String TIPOS_CONSULTAS[] = - new String[]{ "", MOTIVO_ADMISSAO_STR, MOTIVO_PERIODICO_STR, MOTIVO_OCASIONAL_STR, "", MOTIVO_PERIODICO_INICIAL_STR }; - - public static final HashMap MOTIVOS_BY_ID = - new HashMap(); - - public static final HashMap SUB_MOTIVOS_BY_ID = - new HashMap(); - - public static final HashMap SUB_MOTIVOS_IDS_BY_MOTIVO_ID = - new HashMap(); - -// public static final String ESTADOS_EXAME_STR[] = -// new String[]{ "Por realizar", "Parcialmente realizado", "Realizado", -// "Desmarcado trabalhador", -// "Desmarcado " + Singleton.getInstance( SingletonConstants.COMPANY_ACRONYM ), -// "Faltou" }; -// -// public static final String ESTADOS_CONSULTA_STR[] = -// new String[]{ "Por realizar", "Parcialmente realizada", "Realizada", -// "Desmarcada trabalhador", -// "Desmarcada " + Singleton.getInstance( SingletonConstants.COMPANY_ACRONYM ), -// "Faltou" }; - - private static final Object LOCK = new Object(); - private static MedicinaDataProvider instance = null; - - static - { - MOTIVOS_BY_ID.put( MOTIVO_ADMISSAO_INTEGER, MOTIVO_ADMISSAO_STR ); - MOTIVOS_BY_ID.put( MOTIVO_PERIODICO_INTEGER, MOTIVO_PERIODICO_STR ); - MOTIVOS_BY_ID.put( MOTIVO_OCASIONAL_INTEGER, MOTIVO_OCASIONAL_STR ); - MOTIVOS_BY_ID.put( MOTIVO_PERIODICO_INICIAL_INTEGER, MOTIVO_PERIODICO_INICIAL_STR ); - - SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_APOS_DOENCA_INTEGER, SUB_MOTIVO_APOS_DOENCA_STR ); - SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_APOS_ACIDENTE_INTEGER, SUB_MOTIVO_APOS_ACIDENTE_STR ); - SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_PEDIDO_TRABALHADOR_INTEGER, SUB_MOTIVO_PEDIDO_TRABALHADOR_STR ); - SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_PEDIDO_SERVICO_INTEGER, SUB_MOTIVO_PEDIDO_SERVICO_STR ); - SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_MUDANCA_FUNCAO_INTEGER, SUB_MOTIVO_MUDANCA_FUNCAO_STR ); - SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_ALTERACAO_CONDICOES_INTEGER, SUB_MOTIVO_ALTERACAO_CONDICOES_STR ); - SUB_MOTIVOS_BY_ID.put( SUB_MOTIVO_OUTRO_INTEGER, SUB_MOTIVO_OUTRO_STR ); - - SUB_MOTIVOS_IDS_BY_MOTIVO_ID.put( MOTIVO_OCASIONAL_INTEGER, - new Integer[]{ SUB_MOTIVO_APOS_DOENCA_INTEGER, SUB_MOTIVO_APOS_ACIDENTE_INTEGER, - SUB_MOTIVO_PEDIDO_TRABALHADOR_INTEGER, SUB_MOTIVO_PEDIDO_SERVICO_INTEGER, - SUB_MOTIVO_MUDANCA_FUNCAO_INTEGER, SUB_MOTIVO_ALTERACAO_CONDICOES_INTEGER, - SUB_MOTIVO_OUTRO_INTEGER } ); - } - - private final Executer executer; - - /** Creates a new instance of MedicinaDataProvider */ - public MedicinaDataProvider() - 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 MedicinaDataProvider(); - } - } - return instance; - } - - public String []getEmpresaEstabelecimento( Integer empresaID, Integer estabelecimentoID ) - 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 ); - nomes[ 0 ] = ( String ) array.get( 0, 0 ); - - select = new Select( new String[]{ "estabelecimentos" }, - new String[]{ "nome" }, - new Field( "id" ).isEqual( estabelecimentoID ) ); - array = executer.executeQuery( select ); - nomes[ 1 ] = ( String ) array.get( 0, 0 ); - - return nomes; - } - - public IDObject[] getDetalhesValidosTrabalhador( Integer empresaID, Integer trabalhadorID ) - throws Exception - { - Select select = - new Select( new String[]{ "trabalhadores" }, - new String[]{ "perfil" }, - new Field( "id" ).isEqual( trabalhadorID ) ); - Virtual2DArray array = executer.executeQuery( select ); - Integer perfil = ( Integer ) array.get( 0, 0 ); - if( perfil == null ) - { - return new IDObject[ 0 ]; - } - select = - new Select( new String[]{ "prt_elementos_protocolo", "prt_tipos_elementos_protocolo", - "prt_grupos_protocolo" }, - new String[]{ "prt_grupos_protocolo.id" , "prt_grupos_protocolo.descricao", - "prt_grupos_protocolo.ordem"}, - new Field( "prt_elementos_protocolo.empresa_id" ).isEqual( empresaID ).and( - new Field( "prt_elementos_protocolo.tipo_elemento_protocolo_id" ).isEqual( - new Field( "prt_tipos_elementos_protocolo.id" ) ) ).and( - new Field( "prt_tipos_elementos_protocolo.grupo_protocolo_id" ).isEqual( - new Field( "prt_grupos_protocolo.id" ) ) ).and( - new Field( "prt_elementos_protocolo.numero_perfil" ).isEqual( perfil ) ), - new String[]{ "prt_grupos_protocolo.ordem" }, - null ); - array = executer.executeQuery( select ); - Vector detalhes = new Vector(); - Integer oldID = null; - for( int n = 0; n < array.columnLength(); n++ ) - { - Integer id = ( Integer ) array.get( n, 0 ); - if( id.equals( oldID ) ) - { - continue; - } - oldID = id; - String descricao = ( String ) array.get( n, 1 ); - detalhes.add( new MappableObject( id, descricao ) ); - } - return ( IDObject[] ) detalhes.toArray( new IDObject[ detalhes.size() ] ); - } - - public void setDetalhesRealziadosForMarcacao( Integer marcacaoID, Integer detalhes[] ) - throws Exception - { - Delete delete = - new Delete( "marcacoes_grupos_realizados", - new Field( "marcacao_trabalhador_id" ).isEqual( marcacaoID ) ); - executer.executeQuery( delete ); - Insert insert = - new Insert( "marcacoes_grupos_realizados", - new Assignment[]{ - new Assignment( new Field( "marcacao_trabalhador_id" ), marcacaoID ), - new Assignment( new Field( "grupo_protocolo_id" ), detalhes ) } ); - executer.executeQuery( insert, null ); - } - - public Integer[] getDetalhesRealizadosForMarcacao( Integer marcacaoID ) - throws Exception - { - Select select = - new Select( new String[]{ "marcacoes_grupos_realizados" }, - new String[]{ "grupo_protocolo_id" }, - new Field( "marcacao_trabalhador_id" ).isEqual( marcacaoID ) ); - Virtual2DArray array = executer.executeQuery( select ); - Integer ids[] = new Integer[ array.columnLength() ]; - for( int n = 0; n < array.columnLength(); n++ ) - { - ids[ n ] = ( Integer ) array.get( n, 0 ); - } - return ids; - } - - public Integer[] getDetalhesRealizadosForEstadosMarcacao( Integer marcacaoID ) - throws Exception - { - Select select = - new Select( new String[]{ "marcacoes_grupos_realizados", "marcacoes_trabalhador_estados" }, - new String[]{ "grupo_protocolo_id" }, - new Field( "marcacoes_trabalhador_estados.marcacao_id" ).isEqual( marcacaoID ).and( - new Field( "marcacoes_trabalhador_estados.id" ).isEqual( - new Field( "marcacoes_grupos_realizados.marcacoes_trabalhador_estado_id" ) ) ) ); - Virtual2DArray array = executer.executeQuery( select ); - Integer ids[] = new Integer[ array.columnLength() ]; - for( int n = 0; n < array.columnLength(); n++ ) - { - ids[ n ] = ( Integer ) array.get( n, 0 ); - } - return ids; - } - - public void deleteDetalhesRealizadosForMarcacao( Integer marcacaoID ) - throws Exception - { - Delete delete = - new Delete( "marcacoes_grupos_realizados", - new Field( "marcacao_trabalhador_id" ).isEqual( marcacaoID ) ); - executer.executeQuery( delete ); - } - - public Object[][] getExamesTrabalhador( Integer trabalhadorID ) - throws Exception - { - Select select = - new Select( new String[]{ "marcacoes_trabalhador" }, - new String[]{ "id", "data", "estado" }, - new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and( - new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ), - 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_EXAME_STR[ estado ]; - } - return data; - } - - public Object[][] getConsultasTrabalhador( Integer trabalhadorID ) - throws Exception - { - Select select = - new Select( new String[]{ "marcacoes_trabalhador" }, - new String[]{ "id", "data", "estado" }, - new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and( - new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ), - 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_CONSULTA_STR[ estado ]; - } - - return data; - } - - 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 ColumnizedMappable[] getAllTrabalhadoresForEstabelecimento( Integer estabelecimentoID ) - throws Exception - { - Select select = - new Select( new String[]{ "trabalhadores" }, - new String[]{ "id", "nome", "nome_plain" }, - new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ).and( - new Field( "inactivo" ).isDifferent( "y" ) ), - new String[]{ "nome_plain" }, - null ); - Virtual2DArray array = executer.executeQuery( select ); - ColumnizedMappable trabalhadores[] = new ColumnizedMappable[ array.columnLength() ]; - for( int n = 0; n < trabalhadores.length; n++ ) - { - Integer id = ( Integer ) array.get( n, 0 ); - String nome = ( String ) array.get( n, 1 ); - trabalhadores[ n ] = new ColumnizedMappable( id, nome ); - } - return trabalhadores; - } - - /** - * Devolve o identificador da consulta de um trabalhador para um dado motivo e dia. - * - * @param trabalhadorID o identificador do trabalhador - * @param motivo o identificador do motivo da marcacao - * @param data a data da marcacao - * @return o identificador da consulta ou null se não houver nenhuma - * @throws Exception se houver um erro na ligaço à Base de Dados - */ - public Integer getConsultaIDByTrabalhadorMotivoAndDate( Integer trabalhadorID, Integer motivo, Date data ) - throws Exception - { - Integer motivos[]; - if( motivo != null && ( motivo.intValue() == MOTIVO_PERIODICO || motivo.intValue() == MOTIVO_PERIODICO_INICIAL ) ) - { - motivos = new Integer[]{ MOTIVO_PERIODICO_INTEGER, MOTIVO_PERIODICO_INICIAL_INTEGER }; - } - else - { - motivos = new Integer[]{ motivo }; - } - Select select = - new Select( new String[]{ "marcacoes_trabalhador" }, - new String[]{ "id" }, - new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and( - new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and( - new Field( "data" ).isEqual( data ) ).and( - new Field( "motivo" ).in( motivos ) ) ); - Virtual2DArray array = executer.executeQuery( select ); - Integer id; - if( array.columnLength() == 0 || array.get( 0, 0 ) == null ) - { - id = null; - } - else - { - id = ( Integer ) array.get( 0, 0 ); - } - return id; - } - - /** - * Devolve o identificador da primeira consulta de um trabalhador n&ão realizada depois de um diapara um dado motivo. - * - * @param trabalhadorID o identificador do trabalhador - * @param motivo o identificador do motivo da marcacao - * @param data a data de início de procura - * @return o identificador da consulta ou null se não houver nenhuma - * @throws Exception se houver um erro na ligaço à Base de Dados - */ - public Integer getProximaConsultaIDByTrabalhadorMotivoAndDate( Integer trabalhadorID, Integer motivo, Date data ) - throws Exception - { - Select select = - new Select( new String[]{ "marcacoes_trabalhador" }, - new String[]{ "id", "data" }, - new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and( - new Field( "tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ).and( - new Field( "data" ).isGreater( data ) ).and( - new Field( "motivo" ).isEqual( motivo ) ).and( - new Field( "estado" ).isEqual( new Integer( 0 ) ) ), - new String[]{ "data" }, - null ); - Virtual2DArray array = executer.executeQuery( select ); - Integer id; - if( array.columnLength() == 0 || array.get( 0, 0 ) == null ) - { - id = null; - } - else - { - id = ( Integer ) array.get( 0, 0 ); - } - return id; - } - - public Object[][] getListaConsultasByData( Date data ) - throws Exception - { - Select2 select = - new Select2( new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos", "empresas" }, - new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER }, - new Expression[]{ - new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ), - new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ), - new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) }, - new String[]{ "marcacoes_trabalhador.id", "trabalhadores.nome", "trabalhadores.nome_plain", - "empresas.designacao_social", "marcacoes_trabalhador.tipo", "prestador_id" }, - new Field( "marcacoes_trabalhador.data" ).isEqual( data ).and( - new Field( "marcacoes_trabalhador.estado" ).isEqual( - new Integer( Marcacao.ESTADO_POR_REALIZAR ) ) ).and( - new Field( "marcacoes_trabalhador.tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ) ), - null, - null, - null, - null ); - Virtual2DArray array = executer.executeQuery( select ); - return array.getObjects(); - } - - public Object[][] getListaECDsByData( Date data ) - throws Exception - { - Select2 select = - new Select2( new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos", "empresas" }, - new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER }, - new Expression[]{ - new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ), - new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ), - new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) }, - new String[]{ "marcacoes_trabalhador.id", "trabalhadores.nome", "trabalhadores.nome_plain", - "empresas.designacao_social", "marcacoes_trabalhador.tipo", "prestador_id" }, - new Field( "marcacoes_trabalhador.data" ).isEqual( data ).and( - new Field( "marcacoes_trabalhador.estado" ).isEqual( - new Integer( Marcacao.ESTADO_POR_REALIZAR ) ) ).and( - new Field( "marcacoes_trabalhador.tipo" ).isEqual( new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ) ), - null, - null, - null, - null ); - Virtual2DArray array = executer.executeQuery( select ); - return array.getObjects(); - } - - public Integer getTrabalhadorIDByMarcacaoID( Integer marcacaoID ) - throws Exception - { - Select select = - new Select( new String[]{ "marcacoes_trabalhador" }, - new String[]{ "trabalhador_id" }, - new Field( "id" ).isEqual( marcacaoID ) ); - Virtual2DArray array = executer.executeQuery( select ); - return ( Integer ) array.get( 0, 0 ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MedicinaUpperPanel.java b/trunk/SIPRPSoft/src/siprp/medicina/MedicinaUpperPanel.java deleted file mode 100644 index dbdd786d..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/MedicinaUpperPanel.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * MedicinaUpperPanel.java - * - * Created on February 1, 2006, 6:48 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina; - -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.*; - -/** - * - * @author fpalma - */ -public class MedicinaUpperPanel extends JPanel - implements ListSelectionListener, ControllableComponent -{ - protected BaseTable empresasTable; - protected VectorTableModel empresasModel; - protected BaseTable estabelecimentosTable; - protected VectorTableModel estabelecimentosModel; - protected BaseTable trabalhadoresTable; - protected VectorTableModel trabalhadoresModel; - - protected MedicinaDataProvider provider; - - protected final Vector listeners; - - protected boolean editing = false; - - /** Creates a new instance of MedicinaUpperPanel */ - public MedicinaUpperPanel() - throws Exception - { - provider = ( MedicinaDataProvider ) MedicinaDataProvider.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 ); - trabalhadoresModel = new VectorTableModel( new String[]{ "trabalhadores" } ); - trabalhadoresTable = new BaseTable( trabalhadoresModel ); - trabalhadoresTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - trabalhadoresTable.setNonResizableNorReordable(); - JScrollPane trabalhadoresScroll = - new JScrollPane( trabalhadoresTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - trabalhadoresTable.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 = 1; - constraints.weightx = 0.3; - constraints.weighty = 1; - - gridbag.setConstraints( empresasScroll, constraints ); - - gridbag.setConstraints( estabelecimentosScroll, constraints ); - - constraints.weightx = 0.4; - constraints.gridheight = GridBagConstraints.REMAINDER; - gridbag.setConstraints( trabalhadoresScroll, constraints ); - - add( empresasScroll ); - add( estabelecimentosScroll ); - add( trabalhadoresScroll ); - - 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() ) ) - { - carregarTrabalhadores(); - } - else if( source.equals( trabalhadoresTable.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 carregarTrabalhadores() - { - trabalhadoresTable.clearSelection(); - int selected = estabelecimentosTable.getSelectedRow(); - trabalhadoresModel.clearAll(); - if( selected > -1 ) - { - try - { - Integer estabelecimentoID = ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( selected ) ).getID(); - ColumnizedMappable trabalhadores[] = provider.getAllTrabalhadoresForEstabelecimento( estabelecimentoID ); - Vector values = trabalhadoresModel.getValues(); - values.addAll( Arrays.asList( trabalhadores ) ); - trabalhadoresModel.setValues( values ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar trabalhadores.", true ); - trabalhadoresModel.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; - } - } - - for( int n = 0; n < trabalhadoresTable.getRowCount(); n++ ) - { - if( ( ( ColumnizedMappable ) trabalhadoresModel.getRowAt( n ) ).getID().equals( ids[ 2 ] ) ) - { - trabalhadoresTable.setRowSelectionInterval( n, n ); - break; - } - } - } - - public Object save() - { - int empresaSelected = empresasTable.getSelectedRow(); - int estabelecimentoSelected = estabelecimentosTable.getSelectedRow(); - int trabalhadorSelected = trabalhadoresTable.getSelectedRow(); - return new Integer[]{ - empresaSelected == -1 ? null : ( ( ColumnizedMappable ) empresasModel.getRowAt( empresaSelected ) ).getID(), - estabelecimentoSelected == -1 ? null : ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( estabelecimentoSelected ) ).getID(), - trabalhadorSelected == -1 ? null : ( ( ColumnizedMappable ) trabalhadoresModel.getRowAt( trabalhadorSelected ) ).getID() - }; - } - - public void setEnabled( boolean enable ) - { - editing = !enable; - empresasTable.setEnabled( enable ); - estabelecimentosTable.setEnabled( enable ); - trabalhadoresTable.setEnabled( enable ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/MedicinaWindow.java b/trunk/SIPRPSoft/src/siprp/medicina/MedicinaWindow.java deleted file mode 100644 index fa827ed4..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/MedicinaWindow.java +++ /dev/null @@ -1,686 +0,0 @@ -/* - * MedicinaWindow.java - * - * Created on 17 de Janeiro de 2006, 19:43 - * - * To change this template, choose Tools | Options and locate the template under - * the Source Creation and Management node. Right-click the template and choose - * Open. You can then make changes to the template in the Source Editor. - */ - -package siprp.medicina; - -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.clientes.*; -import siprp.data.*; -/** - * - * @author fpalma - */ -public class MedicinaWindow extends TabbedWindow - implements ActionListener, ListSelectionListener -{ - private static int iPermissionArray[][] = - new int[][]{ {}, - { NEW_INDEX, EDIT_INDEX, SAVE_INDEX, DELETE_INDEX, CANCEL_INDEX }, - { NEW_INDEX, EDIT_INDEX, SAVE_INDEX, DELETE_INDEX, CANCEL_INDEX } }; - - private static final int TAB_CONSULTA = 0; - private static final int TAB_EXAME = 1; - - private static final int INDEX_MAIN = 0; - private static final int INDEX_CONSULTA = 1; - private static final int INDEX_EXAME = 2; - - private static final String tabNames[] = - new String[]{ "Consultas", "Exames" }; - - private static final DateFormat DATE_FORMAT = - DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "PT", "pt" ) ); - - protected MedicinaDataProvider provider; - protected FichaDataProvider fichaProvider; - protected JDOProvider JDO; - protected SIPRPTracker tracker; - - protected MedicinaUpperPanel upperPanel; - protected MarcacaoConsultaPanel marcacaoConsultaPanel; - protected TableEditorPanel marcacaoConsultaEditorPanel; - protected MarcacaoExamePanel marcacaoExamePanel; - protected TableEditorPanel marcacaoExameEditorPanel; - protected CheckBoxPanel detalhesExamePanel; - - protected Integer empresaID; - protected String empresa; - protected Integer estabelecimentoID; - protected String estabelecimento; - protected Integer trabalhadorID; - protected TrabalhadorData trabalhador; - protected boolean estado[] = new boolean[]{ false, false }; - - /** Creates a new instance of MedicinaWindow */ - public MedicinaWindow() - throws Exception - { - super( new MedicinaUpperPanel(), tabNames, 0.7, createPermissions( iPermissionArray ) ); - upperPanel = ( MedicinaUpperPanel ) getUpperPanel(); - provider = ( MedicinaDataProvider ) MedicinaDataProvider.getProvider(); - fichaProvider = ( FichaDataProvider ) FichaDataProvider.getProvider(); - JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); - setupComponents(); - maximizeOnNextActivate(); - } - - private void setupComponents() - throws Exception - { - setTitle( "Medicina" ); - setupConsultaComponents(); - setupExameComponents(); - upperPanel.addListSelectionListener( this ); - } - - private void setupConsultaComponents() - { - JPanel panel = getTab( TAB_CONSULTA ); - - panel.setBorder( - BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), "Consultas" ) ); - - changeGroupName( INDEX_CONSULTA, "Consultas" ); - setActionName( INDEX_CONSULTA, NEW_INDEX, "Nova" ); - setActionTooltip( INDEX_CONSULTA, NEW_INDEX, "Nova" ); - JPanel toolbar = getToolbarPanel( INDEX_CONSULTA ); - - GridBagLayout 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; - - gridbag.setConstraints( toolbar, constraints ); - panel.add( toolbar ); - - constraints.gridheight = 1; - constraints.weighty = 1.0; - try - { - marcacaoConsultaEditorPanel = - new TableEditorPanel( new String[]{ "Data", - "Estado" }, - new int[]{0,2}, new int[]{0,0}, - 0.0, 1.0, new Dimension( 350, 100 ) ); - marcacaoConsultaPanel = new MarcacaoConsultaPanel(); - new CopyPasteHandler( marcacaoConsultaPanel.getObservacoesText() ); - marcacaoConsultaEditorPanel.addComponent( marcacaoConsultaPanel, - new int[]{0,2}, new int[]{1,2}, - 1.0, 1.0 ); - marcacaoConsultaEditorPanel.addListSelectionListener( new ListSelectionListener(){ - public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent) - { - if( marcacaoConsultaEditorPanel.getID() != null ) - { - reload(INDEX_CONSULTA); - select(INDEX_CONSULTA); - } - else - { - clear( INDEX_CONSULTA ); - } - } - }); - }catch( Exception ex ) - { - DialogException.showException( ex ); - return; - } - gridbag.setConstraints( marcacaoConsultaEditorPanel, constraints ); - panel.add( marcacaoConsultaEditorPanel ); - marcacaoConsultaPanel.getEmailButton().addActionListener( this ); - } - - private void setupExameComponents() - { - JPanel panel = getTab( TAB_EXAME ); - - panel.setBorder( - BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), "Exames" ) ); - - changeGroupName( INDEX_EXAME, "Exames" ); - JPanel toolbar = getToolbarPanel( INDEX_EXAME ); - - GridBagLayout 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; - - gridbag.setConstraints( toolbar, constraints ); - panel.add( toolbar ); - - constraints.gridheight = 1; - constraints.weighty = 1.0; - try - { - marcacaoExameEditorPanel = - new TableEditorPanel( new String[]{ "Data", - "Estado" }, - new int[]{0,2}, new int[]{0,0}, - 0.0, 1.0, new Dimension( 350, 100 ) ); - marcacaoExamePanel = new MarcacaoExamePanel(); - new CopyPasteHandler( marcacaoExamePanel.getObservacoesText() ); - marcacaoExameEditorPanel.addComponent( marcacaoExamePanel, - new int[]{0,2}, new int[]{1,2}, - 1.0, 1.0 ); - marcacaoExameEditorPanel.addListSelectionListener( new ListSelectionListener(){ - public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent) - { - if( marcacaoExameEditorPanel.getID() != null ) - { - reload(INDEX_EXAME); - select(INDEX_EXAME); - } - else - { - clear( INDEX_EXAME ); - } - } - }); - }catch( Exception ex ) - { - DialogException.showException( ex ); - return; - } - gridbag.setConstraints( marcacaoExameEditorPanel, constraints ); - panel.add( marcacaoExameEditorPanel ); - marcacaoExamePanel.getEmailButton().addActionListener( this ); - } - - public boolean save(int index) - { - Date data; - switch( index ) - { - case INDEX_EXAME: - MarcacaoTrabalhadorData exame = ( MarcacaoTrabalhadorData ) marcacaoExamePanel.save(); - data = ( Date ) exame.get( MarcacaoTrabalhadorData.DATA ); - if( data == null ) - { - JOptionPane.showMessageDialog( this, "Tem de preencher uma data para os exames.", - "Erro", JOptionPane.ERROR_MESSAGE ); - return false; - } - exame.set( MarcacaoTrabalhadorData.TIPO, - new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ); - exame.set( MarcacaoTrabalhadorData.TRABALHADOR, trabalhador ); - try - { - exame.set( MarcacaoTrabalhadorData.REALIZADA, - ( ( Integer )exame.get( MarcacaoTrabalhadorData.ESTADO ) ).intValue() == - provider.ESTADO_REALIZADO ? "y" : "n" ); - exame.save(); - Integer exameID = ( Integer ) exame.get( MarcacaoTrabalhadorData.ID ); - Integer detalhesRealizados[] = detalhesExamePanel.getSelected(); - provider.setDetalhesRealziadosForMarcacao( exameID, detalhesRealizados ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a gravar", true ); - return false; - } - - break; - - case INDEX_CONSULTA: - MarcacaoTrabalhadorData consulta = ( MarcacaoTrabalhadorData ) marcacaoConsultaPanel.save(); - data = ( Date ) consulta.get( MarcacaoTrabalhadorData.DATA ); - if( data == null ) - { - JOptionPane.showMessageDialog( this, "Tem de preencher uma data para a consulta.", - "Erro", JOptionPane.ERROR_MESSAGE ); - return false; - } - consulta.set( MarcacaoTrabalhadorData.TIPO, - new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ); - consulta.set( MarcacaoTrabalhadorData.TRABALHADOR, trabalhador ); - try - { - consulta.set( MarcacaoTrabalhadorData.REALIZADA, - ( ( Integer )consulta.get( MarcacaoTrabalhadorData.ESTADO ) ).intValue() == - provider.ESTADO_REALIZADO ? "y" : "n" ); - consulta.save(); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a gravar", true ); - return false; - } - break; - } - reload( INDEX_MAIN ); - 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_CONSULTA: - MarcacaoTrabalhadorData consulta = ( MarcacaoTrabalhadorData ) marcacaoConsultaPanel.save(); - try - { - consulta.delete(); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a apagar.", true ); - return false; - } - break; - - case INDEX_EXAME: - MarcacaoTrabalhadorData exame = ( MarcacaoTrabalhadorData ) marcacaoExamePanel.save(); - try - { - exame.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; - trabalhadorID = null; - trabalhador = null; - upperPanel.clear(); - marcacaoExameEditorPanel.clear(); - marcacaoConsultaEditorPanel.clear(); -// marcacaoExamePanel.getDetalhesPanel().removeAll(); - detalhesExamePanel = null; - break; - - case INDEX_CONSULTA: - marcacaoConsultaPanel.clear(); - marcacaoConsultaPanel.getEmailButton().setText( "Enviar email" ); - break; - - case INDEX_EXAME: - marcacaoExamePanel.clear(); - marcacaoExamePanel.getEmailButton().setText( "Enviar email" ); - if( detalhesExamePanel != null ) - { - detalhesExamePanel.clear(); - } - break; - } - } - - public void enableComponents(int index, boolean enable) - { - switch( index ) - { - case INDEX_MAIN: - - break; - - case INDEX_EXAME: - marcacaoExamePanel.setEnabled( enable ); - marcacaoExamePanel.getEmailButton().setEnabled( enable ); - if( detalhesExamePanel != null ) - { - detalhesExamePanel.setEnabled( enable ); - } - upperPanel.setEnabled( !enable ); - estado[ 0 ] = enable; - break; - - case INDEX_CONSULTA: - marcacaoConsultaPanel.setEnabled( enable ); - marcacaoConsultaPanel.getEmailButton().setEnabled( enable ); - upperPanel.setEnabled( !enable ); - estado[ 1 ] = enable; - break; - } - if( tracker != null ) - { - tracker.getAvisosPanel().setEnabled( (!estado[ 0 ]) && (!estado[1]), - AvisoConstants.TIPO_TRABALHADOR ); - } - } - -// public boolean searchByName() -// { -// fichaProvider.setSearch( FichaDataProvider.SEARCH_EMPRESAS ); -// SearchDialog search; -// -// search = new SearchDialog( fichaProvider, null, false, null, true ); -// empresaID = ( Integer )search.getSelected(); -// -// if( empresaID == null ) -// { -// return false; -// } -// -// fichaProvider.setSearch( FichaDataProvider.SEARCH_ESTABELECIMENTOS ); -// fichaProvider.setSearchID( FichaDataProvider.SEARCH_EMPRESAS, empresaID.intValue() ); -// -// search = new SearchDialog( fichaProvider, null, false, null, true ); -// estabelecimentoID = ( Integer )search.getSelected(); -// -// if( estabelecimentoID == null ) -// { -// return false; -// } -// -// fichaProvider.setSearch( FichaDataProvider.SEARCH_TRABALHADORES ); -// fichaProvider.setSearchID( FichaDataProvider.SEARCH_ESTABELECIMENTOS, estabelecimentoID.intValue() ); -// search = new SearchDialog( fichaProvider, null, false, null, true ); -// trabalhadorID = ( Integer )search.getSelected(); -// -// if( trabalhadorID == null ) -// { -// return false; -// } -// reload(0); -// return true; -// } - - protected void enableSelect( int index, boolean select ) - { - switch( index ) - { - case INDEX_EXAME: - marcacaoExameEditorPanel.setEnabled( select ); - break; - - case INDEX_CONSULTA: - marcacaoConsultaEditorPanel.setEnabled( select ); - break; - } - } - - public void reload( int index ) - { - switch( index ) - { - case INDEX_MAIN: - try - { - String nomes[] = - provider.getEmpresaEstabelecimento( empresaID, estabelecimentoID ); - empresa = nomes[ 0 ]; - estabelecimento = nomes[ 1 ]; - trabalhador = ( TrabalhadorData ) JDO.load( TrabalhadorData.class, trabalhadorID ); -// upperPanel.getEmpresaText().setText( empresa ); -// upperPanel.getEstabelecimentoText().setText( estabelecimento ); -// upperPanel.getTrabalhadorText().setText( ( String ) trabalhador.get( TrabalhadorData.NOME ) ); - IDObject detalhesExame[] = provider.getDetalhesValidosTrabalhador( empresaID, trabalhadorID ); - detalhesExamePanel = new CheckBoxPanel( detalhesExame ); - JPanel detalhesExameOuterPanel = marcacaoExamePanel.getDetalhesPanel(); - detalhesExameOuterPanel.setLayout( new GridLayout( 1, 1 ) ); - detalhesExameOuterPanel.removeAll(); - detalhesExameOuterPanel.add( detalhesExamePanel ); - detalhesExameOuterPanel.validate(); - Object examesTrabalhador[][] = provider.getExamesTrabalhador( trabalhadorID ); - Object consultasTrabalhador[][] = provider.getConsultasTrabalhador( trabalhadorID ); - if( examesTrabalhador.length > 0 ) - { - marcacaoExameEditorPanel.setData( new Object2DArray( examesTrabalhador ) ); - } - else - { - marcacaoExameEditorPanel.clear(); - } - if( consultasTrabalhador.length > 0 ) - { - marcacaoConsultaEditorPanel.setData( new Object2DArray( consultasTrabalhador ) ); - } - else - { - marcacaoConsultaEditorPanel.clear(); - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar os dados.", true ); - } - break; - - case INDEX_EXAME: - Integer exameID = marcacaoExameEditorPanel.getID(); - if( exameID == null ) - { - return; - } - try - { - MarcacaoTrabalhadorData exame = - ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, exameID ); - marcacaoExamePanel.fill( exame ); - Date dataEmailExame = ( Date ) exame.get( MarcacaoTrabalhadorData.DATA_EMAIL ); - if( dataEmailExame != null ) - { - marcacaoExamePanel.getEmailButton().setText( "Enviar email (" + DATE_FORMAT.format( dataEmailExame ) + ")" ); - } - else - { - marcacaoExamePanel.getEmailButton().setText( "Enviar email" ); - } - Integer detalhesRealizados[] = provider.getDetalhesRealizadosForMarcacao( exameID ); - detalhesExamePanel.setSelected( detalhesRealizados ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar os dados do exame.", true ); - } - break; - - case INDEX_CONSULTA: - Integer consultaID = marcacaoConsultaEditorPanel.getID(); - if( consultaID == null ) - { - return; - } - try - { - MarcacaoTrabalhadorData consulta = - ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, consultaID ); - marcacaoConsultaPanel.fill( consulta ); - Date dataEmailConsulta = ( Date ) consulta.get( MarcacaoTrabalhadorData.DATA_EMAIL ); - if( dataEmailConsulta != null ) - { - marcacaoConsultaPanel.getEmailButton().setText( "Enviar email (" + DATE_FORMAT.format( dataEmailConsulta ) + ")" ); - } - else - { - marcacaoConsultaPanel.getEmailButton().setText( "Enviar email" ); - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar os dados da consulta.", true ); - } - break; - } - } - - public void actionPerformed( ActionEvent e ) - { - Object source = e.getSource(); - if( source.equals( marcacaoExamePanel.getEmailButton() ) ) - { - enviarEmailExame(); - } - else if( source.equals( marcacaoConsultaPanel.getEmailButton() ) ) - { - enviarEmailConsulta(); - } - } - - protected void enviarEmailConsulta() - { - MarcacaoTrabalhadorData consulta = ( MarcacaoTrabalhadorData ) marcacaoConsultaPanel.save(); - - String subject = ( String ) Singleton.getInstance( SingletonConstants.SUBJECT_CONSULTA ); - String texto = ( String ) Singleton.getInstance( SingletonConstants.LETTER_CONSULTA ); - - Date today = new Date(); - marcacaoConsultaPanel.getEmailButton().setText( "Enviar email (" + DATE_FORMAT.format( today ) + ")" ); - - try - { - enviarEmail( subject, texto, ( Date )consulta.get( MarcacaoTrabalhadorData.DATA ) ); - consulta.set( Marcacao.DATA_EMAIL, today ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a enviar mail", true ); - } - } - - protected void enviarEmailExame() - { - MarcacaoTrabalhadorData exame = ( MarcacaoTrabalhadorData ) marcacaoExamePanel.save(); - - String subject = ( String ) Singleton.getInstance( SingletonConstants.SUBJECT_EXAMES ); - String texto = ( String ) Singleton.getInstance( SingletonConstants.LETTER_EXAMES ); - - Date today = new Date(); - marcacaoExamePanel.getEmailButton().setText( "Enviar email (" + DATE_FORMAT.format( today ) + ")" ); - - try - { - enviarEmail( subject, texto, ( Date )exame.get( MarcacaoTrabalhadorData.DATA ) ); - exame.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 nome = ( String ) trabalhador.get( TrabalhadorData.NOME ); - String dataStr = DATE_FORMAT.format( data ); - - subject = subject.replaceAll( CompanyDataLoader.NOME, nome ); - texto = texto.replaceAll( CompanyDataLoader.DATA, dataStr ); - texto = texto.replaceAll( CompanyDataLoader.NOME, nome ); - - EstabelecimentoData estabelecimento = - ( EstabelecimentoData ) JDO.load( EstabelecimentoData.class, estabelecimentoID ); - 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 ]; - trabalhadorID = ids[ 2 ]; - if( ids[ 2 ] == null ) - { - clear( INDEX_MAIN ); - unselect( INDEX_MAIN ); - } - else - { - reload( INDEX_MAIN ); - select( INDEX_MAIN ); - } - } - } - - public void setEmpresaAndEstabelecimentoAndTrabalhador( Integer empresaID, Integer estabelecimentoID, Integer trabalhadorID ) - { - if( upperPanel.editing ) - { - JOptionPane.showMessageDialog( this, "Esta janela est\u00e1 em edi\u00e7\u00e3o.", "Erro...", - JOptionPane.ERROR_MESSAGE ); - } - else - { - upperPanel.fill( new Integer[]{ empresaID, estabelecimentoID, trabalhadorID } ); - } - } - - public void setTracker( SIPRPTracker tracker ) - { - this.tracker = tracker; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/Test.java b/trunk/SIPRPSoft/src/siprp/medicina/Test.java deleted file mode 100644 index 8305609e..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/Test.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Test.java - * - * Created on 17 de Janeiro de 2006, 18:37 - * - * To change this template, choose Tools | Options and locate the template under - * the Source Creation and Management node. Right-click the template and choose - * Open. You can then make changes to the template in the Source Editor. - */ - -package siprp.medicina; - -import java.awt.*; -import javax.swing.*; -/** - * - * @author fpalma - */ -public class Test -{ - - public static void main( String args[] ) - throws Exception - { - JFrame frm = new MedicinaWindow(); -// frm.getContentPane().setLayout( new GridLayout() ); -// frm.getContentPane().add( new MedicinaUpperPanel() ); -// frm.setSize( new Dimension( 600, 600 ) ); - frm.setVisible( true ); - frm.setExtendedState(frm.getExtendedState() | frm.MAXIMIZED_BOTH); - } - - /** Creates a new instance of Test */ - public Test() - { - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/alter.sql b/trunk/SIPRPSoft/src/siprp/medicina/alter.sql deleted file mode 100644 index 3549ed22..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/alter.sql +++ /dev/null @@ -1,159 +0,0 @@ -ALTER TABLE empresas ADD a_consultas char(1); -ALTER TABLE empresas ADD a_exames char(1); -ALTER TABLE empresas ADD b_consultas char(1); -ALTER TABLE empresas ADD b_exames char(1); -ALTER TABLE empresas ADD data_cancelamento DATE; - -ALTER TABLE marcacoes_trabalhador ADD motivo INT; -ALTER TABLE marcacoes_trabalhador ADD estado INT; -ALTER TABLE marcacoes_trabalhador ADD observacoes VARCHAR( 2048 ); -UPDATE marcacoes_trabalhador SET estado = 2 WHERE realizada = 'y'; - - --- PROTOCOLOS - -CREATE TABLE prt_grupos_protocolo -( - id int4 NOT NULL, - descricao varchar(255) NOT NULL, - descricao_plain varchar(255) NOT NULL, - CONSTRAINT grupos_protocolo_pkey PRIMARY KEY (id) -) -WITHOUT OIDS; -ALTER TABLE prt_grupos_protocolo OWNER TO postgres; - - - -CREATE TABLE prt_tipos_elementos_protocolo -( - id int4 NOT NULL, - descricao_plain varchar(255) NOT NULL, - descricao varchar(255) NOT NULL, - grupo_protocolo_id int4 NOT NULL, - CONSTRAINT prt_tipos_elementos_protocolo_pkey PRIMARY KEY (id), - CONSTRAINT prt_tipos_elementos_protocolo_grupo_protocolo_id_fkey FOREIGN KEY (grupo_protocolo_id) REFERENCES prt_grupos_protocolo (id) ON UPDATE RESTRICT ON DELETE RESTRICT -) -WITHOUT OIDS; -ALTER TABLE prt_tipos_elementos_protocolo OWNER TO postgres; - - -CREATE TABLE prt_elementos_protocolo -( - id serial NOT NULL, - tipo_elemento_protocolo_id int4 NOT NULL, - empresa_id int4 NOT NULL, - numero_perfil int4 NOT NULL, - CONSTRAINT prt_elementos_protocolo_pkey PRIMARY KEY (id), - CONSTRAINT prt_elementos_protocolo_empresa_id_fkey FOREIGN KEY (empresa_id) REFERENCES empresas (id) ON UPDATE RESTRICT ON DELETE RESTRICT, - CONSTRAINT prt_elementos_protocolo_tipo_elemento_protocolo_id_fkey FOREIGN KEY (tipo_elemento_protocolo_id) REFERENCES prt_tipos_elementos_protocolo (id) ON UPDATE RESTRICT ON DELETE RESTRICT -) -WITH OIDS; -ALTER TABLE prt_elementos_protocolo OWNER TO postgres; - - -CREATE TABLE marcacoes_grupos_realizados -( - id serial NOT NULL, - marcacao_trabalhador_id int4 NOT NULL, - grupo_protocolo_id int4 NOT NULL, - CONSTRAINT marcacoes_grupos_realizados_pkey PRIMARY KEY (id), - CONSTRAINT marcacoes_grupos_realizados_grupo_protocolo_id_fkey FOREIGN KEY (grupo_protocolo_id) REFERENCES prt_grupos_protocolo (id) ON UPDATE RESTRICT ON DELETE RESTRICT, - CONSTRAINT marcacoes_grupos_realizados_marcacao_trabalhador_id_fkey FOREIGN KEY (marcacao_trabalhador_id) REFERENCES marcacoes_trabalhador (id) ON UPDATE RESTRICT ON DELETE RESTRICT -) -WITH OIDS; -ALTER TABLE marcacoes_grupos_realizados OWNER TO postgres; - -INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) - VALUES( 1, 'Sangue', 'sangue' ); -INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) - VALUES( 2, 'Urina', 'urina' ); -INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) - VALUES( 3, 'RX T\\u00f3rax', 'rx torax' ); -INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) - VALUES( 4, 'Audiograma', 'audiograma' ); -INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) - VALUES( 5, 'Rastreio Visual', 'rastreio visual' ); -INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) - VALUES( 6, 'ECG', 'ecg' ); -INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) - VALUES( 7, 'Espirometria', 'espirometria' ); -INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) - VALUES( 8, 'Exsudado Nasofar\\u00edngeo', 'exsudado nasofaringeo' ); -INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) - VALUES( 9, 'Exame Bacteriol\\u00f3gico (Fezes)', 'exame bacteriologico (fezes)' ); -INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) - VALUES( 10, 'Coprocultura', 'coprocultura' ); -INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) - VALUES( 11, 'Outros ECDs', 'outros ecds' ); -INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) - VALUES( 12, 'Outras An\\u00e1lises', 'outras analises' ); - -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 1, 'Hemograma', 'hemograma', 1 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 2, 'Plaquetas', 'plaquetas', 1 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 3, 'VS', 'vs', 1 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 4, 'Glicemia', 'glicemia', 1 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 5, 'Creatinina', 'creatinina', 1 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 6, 'Colesterol Total', 'colesterol total', 1 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 7, 'colesterol hdl', 'Colesterol hdl', 1 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 8, 'Colesterol LDL', 'colesterol ldl', 1 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 9, 'Trigliceridos', 'trigliceridos', 1 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 10, 'Transaminases', 'transaminases', 1 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 11, 'Gama GT', 'gama gt', 1 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 12, 'Ureia', 'ureia', 1 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 13, '\\u00c1cido \\u00darico', 'acido urico', 1 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 14, 'MBE (Chumbo)', 'mbe (chumbo)', 1 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 15, 'MBE (Outros)', 'mbe (outros)', 1 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 16, 'Serologias Hepatite', 'serologias hepatite', 1 ); - -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 17, 'Urina II', 'urina ii', 2 ); - -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 18, 'RX T\\u00f3rax', 'rx torax', 3 ); - -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 19, 'Audiometria', 'audiometria', 4 ); - -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 20, 'Rastreio Visual', 'rastreio visual', 5 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 21, 'ECG', 'ecg', 6 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 22, 'Espirometria', 'espirometria', 7 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 23, 'Exsudado Nasofar\\u00edngeo', 'exsudado nasofaringeo', 8 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 24, 'Exame Bacteriol\\u00f3gico (Fezes)', 'exame bacteriologico (fezes)', 9 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 25, 'Coprocultura', 'coprocultura', 10 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 26, 'Outros ECDs', 'outros ecds', 11 ); -INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) - values( 27, 'Outras An\\u00e1lises', 'outras analises', 12 ); - - -ALTER TABLE prt_grupos_protocolo ADD grupo_real char(1); -UPDATE prt_grupos_protocolo SET grupo_real='y' WHERE id <= 4; -UPDATE prt_grupos_protocolo SET grupo_real='n' WHERE id > 4; - -ALTER TABLE prt_grupos_protocolo ADD ordem int4; -UPDATE prt_grupos_protocolo SET ordem=id; - -ALTER TABLE prt_tipos_elementos_protocolo ADD ordem int4; -UPDATE prt_tipos_elementos_protocolo SET ordem=id; \ No newline at end of file diff --git a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/FaxPrinter.java b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/FaxPrinter.java deleted file mode 100644 index 392f8f25..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/FaxPrinter.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * FaxPrinter.java - * - * Created on March 1, 2007, 3:26 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.locais_realizacao; - -import com.evolute.utils.data.IDObject; -import com.evolute.utils.data.MappableObject; -import com.evolute.utils.ui.CustomJDialog; -import com.evolute.utils.ui.panel.CheckBoxPanel; -import info.clearthought.layout.TableLayout; -import info.clearthought.layout.TableLayoutConstraints; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.JToggleButton; -import javax.swing.SwingUtilities; - -/** - * - * @author fpalma - */ -public class FaxPrinter extends CustomJDialog - implements ActionListener -{ - private JTextField deText; - private JTextField deEmailText; - private JTextField deFaxText; - private JTextField deTelefoneText; - private JTextField assuntoText; - private JTextField localText; - private JToggleButton localAutoButton; - private JTextField perfil1Text; - private CheckBoxPanel perfil1Panel; - private JTextField perfil2Text; - private CheckBoxPanel perfil2Panel; - private JTextField horaText; - - private JButton imprimirButton; - private JButton cancelarButton; - - public static void main( String args[] ) - { - FaxPrinter d = new FaxPrinter(); - d.setVisible( true ); - } - - /** Creates a new instance of FaxPrinter */ - public FaxPrinter() - { - super( null, true ); - setupComponents(); - } - - private void setupComponents() - { - setTitle( "Por favor preencha os detalhes do Fax" ); - setSize( 800, 600 ); - - JLabel deLabel = new JLabel( "De" ); - deText = new JTextField(); - JLabel deEmailLabel = new JLabel( "E-mail" ); - deEmailText = new JTextField(); - JLabel deFaxLabel = new JLabel( "Fax" ); - deFaxText = new JTextField(); - JLabel deTelefoneLabel = new JLabel( "N\u00famero de telefone" ); - deTelefoneText = new JTextField(); - JLabel assuntoLabel = new JLabel( "Assunto" ); - assuntoText = new JTextField(); - localAutoButton = new JToggleButton( "Local Autom\u00e1tico" ); - localText = new JTextField(); - JLabel perfil1Label = new JLabel( "Nome" ); - perfil1Text = new JTextField(); - perfil1Panel = new CheckBoxPanel( new IDObject[]{ new MappableObject( new Integer( 1 ), "teste1" ), - new MappableObject( new Integer( 3 ), "teste3" ) } ); - JLabel perfil2Label = new JLabel( "Nome" ); - perfil2Text = new JTextField(); - perfil2Panel = new CheckBoxPanel( new IDObject[]{ new MappableObject( new Integer( 2 ), "teste2" ) } ); - imprimirButton = new JButton( "Imprimir" ); - imprimirButton.addActionListener( this ); - cancelarButton = new JButton( "Cancelar" ); - cancelarButton.addActionListener( this ); - JPanel buttonPanel = new JPanel(); - JPanel perfil1OuterPanel = new JPanel(); - perfil1OuterPanel.setBorder( BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), "Perfil 1" ) ); - JPanel perfil2OuterPanel = new JPanel(); - perfil2OuterPanel.setBorder( BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), "Perfil 2" ) ); - - double cols[] = - new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, - TableLayout.FILL, }; - double rows[] = - new double[]{ TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, - TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED }; - - TableLayout tableLayout = new TableLayout( cols,rows ); - setLayout( tableLayout ); - - add( deLabel, new TableLayoutConstraints( 0, 0 ) ); - add( deText, new TableLayoutConstraints( 1, 0 ) ); - add( deEmailLabel, new TableLayoutConstraints( 2, 0 ) ); - add( deEmailText, new TableLayoutConstraints( 3, 0 ) ); - add( deFaxLabel, new TableLayoutConstraints( 0, 1 ) ); - add( deFaxText, new TableLayoutConstraints( 1, 1 ) ); - add( deTelefoneLabel, new TableLayoutConstraints( 2, 1 ) ); - add( deTelefoneText, new TableLayoutConstraints( 3, 1 ) ); - add( assuntoLabel, new TableLayoutConstraints( 0, 2 ) ); - add( assuntoText, new TableLayoutConstraints( 1, 2, 3, 2 ) ); - add( localAutoButton, new TableLayoutConstraints( 0, 3 ) ); - add( localText, new TableLayoutConstraints( 1, 3, 3, 3 ) ); - add( perfil1OuterPanel, new TableLayoutConstraints( 0, 4, 1, 4 ) ); - add( perfil2OuterPanel, new TableLayoutConstraints( 2, 4, 3, 4 ) ); - add( buttonPanel, new TableLayoutConstraints( 0, 5, 3, 5 ) ); - - cols = new double[]{ TableLayout.MINIMUM, TableLayout.FILL }; - rows = new double[]{ TableLayout.PREFERRED, TableLayout.FILL }; - - tableLayout = new TableLayout( cols,rows ); - perfil1OuterPanel.setLayout( tableLayout ); - - perfil1OuterPanel.add( perfil1Label, new TableLayoutConstraints( 0, 0 ) ); - perfil1OuterPanel.add( perfil1Text, new TableLayoutConstraints( 1, 0 ) ); - perfil1OuterPanel.add( perfil1Panel, new TableLayoutConstraints( 0, 1, 1, 1 ) ); - - tableLayout = new TableLayout( cols,rows ); - perfil2OuterPanel.setLayout( tableLayout ); - - perfil2OuterPanel.add( perfil2Label, new TableLayoutConstraints( 0, 0 ) ); - perfil2OuterPanel.add( perfil2Text, new TableLayoutConstraints( 1, 0 ) ); - perfil2OuterPanel.add( perfil2Panel, new TableLayoutConstraints( 0, 1, 1, 1 ) ); - - buttonPanel.setLayout( new FlowLayout( FlowLayout.CENTER ) ); - buttonPanel.add( imprimirButton ); - buttonPanel.add( cancelarButton ); - - } - - public void actionPerformed(ActionEvent e) - { - Object source = e.getSource(); - if( source.equals( imprimirButton ) ) - { - print(); - } - else if( source.equals( cancelarButton ) ) - { - close(); - } - } - - public void close() - { - SwingUtilities.invokeLater( new Runnable(){ - public void run() - { - setVisible( false ); - dispose(); - } - } ); - } - - public void print() - { - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoDataProvider.java b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoDataProvider.java deleted file mode 100644 index 75a4f86c..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoDataProvider.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * LocaisRealizacaoDataProvider.java - * - * Created on February 22, 2007, 10:44 AM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.locais_realizacao; - -import com.evolute.utils.Singleton; -import com.evolute.utils.arrays.Virtual2DArray; -import com.evolute.utils.db.DBManager; -import com.evolute.utils.db.Executer; -import com.evolute.utils.sql.Assignment; -import com.evolute.utils.sql.Expression; -import com.evolute.utils.sql.Field; -import com.evolute.utils.sql.Select; -import com.evolute.utils.sql.Select2; -import com.evolute.utils.sql.Update; -import com.evolute.utils.tables.ColumnizedMappable; -import java.util.Date; - -/** - * - * @author fpalma - */ -public class LocaisRealizacaoDataProvider -{ - private static final Object LOCK = new Object(); - private static LocaisRealizacaoDataProvider instance = null; - - private Executer EXECUTER; - - /** Creates a new instance of LocaisRealizacaoDataProvider */ - public LocaisRealizacaoDataProvider() - throws Exception - { - DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); - EXECUTER = dbm.getSharedExecuter( this ); - } - - public static LocaisRealizacaoDataProvider getProvider() - throws Exception - { - synchronized( LOCK ) - { - if( instance == null ) - { - instance = new LocaisRealizacaoDataProvider(); - } - } - return instance; - } - - public ColumnizedMappable[] getEmpresasComMarcacoes( Date data ) - throws Exception - { - Select select = - new Select2( - new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos", "empresas" }, - new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER }, - new Expression[]{ - new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ), - new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ), - new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) }, - new String[]{ "DISTINCT empresas.id", "empresas.designacao_social", "empresas.designacao_social_plain" }, - new Field( "marcacoes_trabalhador.data" ).isEqual( data ), - new String[]{ "empresas.designacao_social_plain" }, - null, - null, - 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[] getEstabelecimentosComMarcacoesByEmpresa( Integer empresaID, Date data ) - throws Exception - { - Select select = - new Select2( - new String[]{ "marcacoes_trabalhador", "trabalhadores", "estabelecimentos" }, - new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER }, - new Expression[]{ - new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ), - new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ) }, - new String[]{ "DISTINCT estabelecimentos.id", "estabelecimentos.nome", "estabelecimentos.nome_plain" }, - new Field( "marcacoes_trabalhador.data" ).isEqual( data ).and( - new Field( "estabelecimentos.empresa_id" ).isEqual( empresaID ) ), - new String[]{ "estabelecimentos.nome_plain" }, - null, - null, - 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 int getNumeroMarcacoesByEstabelecimentoAndTipo( Integer estabelecimentoID, int tipo, Date data ) - throws Exception - { - Select select = - new Select2( - new String[]{ "marcacoes_trabalhador", "trabalhadores" }, - new Integer[]{ Select2.JOIN_INNER }, - new Expression[]{ - new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) }, - new String[]{ "COUNT( * )" }, - new Field( "marcacoes_trabalhador.data" ).isEqual( data ).and( - new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and( - new Field( "marcacoes_trabalhador.tipo" ).isEqual( tipo ) ), - null, - null, - null, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - if( array.columnLength() == 0 || array.get( 0, 0 ) == null ) - { - return 0; - } - else - { - return ( ( Number ) array.get( 0, 0 ) ).intValue(); - } - } - - public Integer[] getPrestadoresIDByEstabelecimentoAndTipo( Integer estabelecimentoID, int tipo, Date data ) - throws Exception - { - Select select = - new Select2( - new String[]{ "marcacoes_trabalhador", "trabalhadores" }, - new Integer[]{ Select2.JOIN_INNER }, - new Expression[]{ - new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) }, - new String[]{ "DISTINCT prestador_id" }, - new Field( "marcacoes_trabalhador.data" ).isEqual( data ).and( - new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and( - new Field( "marcacoes_trabalhador.tipo" ).isEqual( tipo ) ), - null, - null, - null, - null ); - 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 ); - } - return ids; - } - - public void setPrestadorIDForEstabelecimentoAndTipo( Integer estabelecimentoID, int tipo, Date data, Integer prestadorID ) - throws Exception - { - Select select = - new Select2( - new String[]{ "marcacoes_trabalhador", "trabalhadores" }, - new Integer[]{ Select2.JOIN_INNER }, - new Expression[]{ - new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) }, - new String[]{ "marcacoes_trabalhador.id" }, - new Field( "marcacoes_trabalhador.data" ).isEqual( data ).and( - new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and( - new Field( "marcacoes_trabalhador.tipo" ).isEqual( tipo ) ), - null, - null, - null, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - for( int n = 0; n < array.columnLength(); n++ ) - { - Integer id = ( Integer ) array.get( n, 0 ); - Update update = - new Update( "marcacoes_trabalhador", - new Assignment[]{ - new Assignment( "prestador_id", prestadorID ) }, - new Field( "id" ).isEqual( id ) ); - EXECUTER.executeQuery( update ); - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoWindow.java b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoWindow.java deleted file mode 100644 index 0a7e7c89..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/LocaisRealizacaoWindow.java +++ /dev/null @@ -1,548 +0,0 @@ -/* - * LocaisRealizacaoWindow.java - * - * Created on February 22, 2007, 10:19 AM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.locais_realizacao; - -import com.evolute.utils.data.IDObject; -import com.evolute.utils.data.MappableObject; -import com.evolute.utils.tables.BaseTable; -import com.evolute.utils.tables.ColumnizedMappable; -import com.evolute.utils.tables.VectorTableModel; -import com.evolute.utils.tracker.TrackableWindow; -import com.evolute.utils.ui.DialogException; -import com.evolute.utils.ui.calendar.JCalendarPanel; -import info.clearthought.layout.TableLayout; -import info.clearthought.layout.TableLayoutConstraints; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.FlowLayout; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.util.Arrays; -import java.util.Date; -import java.util.Vector; -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.ListSelectionModel; -import javax.swing.SwingUtilities; -import javax.swing.WindowConstants; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import siprp.data.Marcacao; -import siprp.medicina.prestadores.PrestadoresDataProvider; - -/** - * - * @author fpalma - */ -public class LocaisRealizacaoWindow extends JFrame - implements ActionListener, TrackableWindow, ListSelectionListener -{ - protected static final Integer PRESTADOR_ID_SIPRP = new Integer( -1 ); - - protected static final IDObject PRESTADOR_SIPRP = new MappableObject( PRESTADOR_ID_SIPRP, "SIPRP" ); - - protected JCalendarPanel dataPanel; - protected JButton carregarButton; - protected JButton recarregarPrestadoresButton; - protected VectorTableModel empresasModel; - protected BaseTable empresasTable; - protected VectorTableModel estabelecimentosModel; - protected BaseTable estabelecimentosTable; - protected JLabel numeroConsultasLabel; - protected JComboBox prestadoresConsultasCombo; - protected JButton enviarConsultasButton; - protected JButton faxConsultasButton; - protected JLabel numeroECDsLabel; - protected JComboBox prestadoresECDsCombo; - protected JButton enviarECDsButton; - protected JButton faxECDsButton; - - - protected LocaisRealizacaoDataProvider provider; - protected PrestadoresDataProvider prestadoresProvider; - - /** - * Creates a new instance of LocaisRealizacaoWindow - */ - public LocaisRealizacaoWindow() - throws Exception - { - provider = LocaisRealizacaoDataProvider.getProvider(); - prestadoresProvider = PrestadoresDataProvider.getProvider(); - setupComponents(); - } - - private void setupComponents() - { - setTitle( "Locais de Realiza\u00e7\u00e3o" ); - setSize( 1000, 700 ); - JLabel dataLabel = new JLabel( "Data" ); - dataPanel = new JCalendarPanel( this ); - - carregarButton = new JButton( "Carregar" ); - carregarButton.addActionListener( this ); - recarregarPrestadoresButton = new JButton( "Recarregar Prestadores" ); - recarregarPrestadoresButton.addActionListener( this ); - empresasModel = new VectorTableModel( new String[]{ "empresa" } ); - empresasTable = new BaseTable( empresasModel ); - empresasTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - empresasTable.getSelectionModel().addListSelectionListener( this ); - JScrollPane empresasScp = new JScrollPane( empresasTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - estabelecimentosModel = new VectorTableModel( new String[]{ "estabelecimento" } ); - estabelecimentosTable = new BaseTable( estabelecimentosModel ); - estabelecimentosTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - estabelecimentosTable.getSelectionModel().addListSelectionListener( this ); - JScrollPane estabelecimentosScp = new JScrollPane( estabelecimentosTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - JPanel consultasPanel = new JPanel(); - consultasPanel.setBorder( BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), "Consultas" ) ); - JLabel consultasLabel = new JLabel( "Quantidade " ); - numeroConsultasLabel = new JLabel( " " ); - numeroConsultasLabel.setForeground( Color.green.darker() ); - prestadoresConsultasCombo = new JComboBox(); - enviarConsultasButton = new JButton( "Atribuir" ); - enviarConsultasButton.addActionListener( this ); - faxConsultasButton = new JButton( "Fax" ); - faxConsultasButton.addActionListener( this ); - JPanel ecdsPanel = new JPanel(); - ecdsPanel.setBorder( BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), "ECDs" ) ); - JLabel ecdsLabel = new JLabel( "Quantidade " ); - numeroECDsLabel = new JLabel( " " ); - numeroECDsLabel.setForeground( Color.green.darker() ); - prestadoresECDsCombo = new JComboBox(); - enviarECDsButton = new JButton( "Atribuir" ); - enviarECDsButton.addActionListener( this ); - faxECDsButton = new JButton( "Fax" ); - faxECDsButton.addActionListener( this ); - dataPanel.addChangeListener( new ChangeListener(){ - public void stateChanged(ChangeEvent e) - { - empresasTable.clearSelection(); - Vector values = empresasModel.getValues(); - values.clear(); - empresasModel.setValues( values ); - } - } ); - - getContentPane().setLayout( new BorderLayout( 5, 5 ) ); - JPanel upperPanel = new JPanel(); - getContentPane().add( upperPanel, BorderLayout.NORTH ); - JPanel centerPanel = new JPanel(); - getContentPane().add( centerPanel, BorderLayout.CENTER ); - - upperPanel.setLayout( new FlowLayout( FlowLayout.CENTER ) ); - upperPanel.add( dataLabel ); - upperPanel.add( dataPanel ); - upperPanel.add( carregarButton ); - upperPanel.add( recarregarPrestadoresButton ); - - centerPanel.setLayout( new GridLayout( 1, 3 ) ); - centerPanel.add( empresasScp ); - centerPanel.add( estabelecimentosScp ); - JPanel detalhesPanel = new JPanel(); - centerPanel.add( detalhesPanel ); - - double cols[] = - new double[]{ TableLayout.MINIMUM, TableLayout.FILL }; - double rows[] = - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM }; - - TableLayout tableLayout = new TableLayout( cols,rows ); - consultasPanel.setLayout( tableLayout ); - - consultasPanel.add( consultasLabel, new TableLayoutConstraints( 0, 0 ) ); - consultasPanel.add( numeroConsultasLabel, new TableLayoutConstraints( 1, 0 ) ); - consultasPanel.add( prestadoresConsultasCombo, new TableLayoutConstraints( 0, 1, 1, 1 ) ); - consultasPanel.add( enviarConsultasButton, new TableLayoutConstraints( 0, 2, 1, 2 ) ); -// consultasPanel.add( faxConsultasButton, new TableLayoutConstraints( 0, 3, 1, 3 ) ); - - rows = new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM }; - - tableLayout = new TableLayout( cols,rows ); - ecdsPanel.setLayout( tableLayout ); - - ecdsPanel.add( ecdsLabel, new TableLayoutConstraints( 0, 0 ) ); - ecdsPanel.add( numeroECDsLabel, new TableLayoutConstraints( 1, 0 ) ); - ecdsPanel.add( prestadoresECDsCombo, new TableLayoutConstraints( 0, 1, 1, 1 ) ); - ecdsPanel.add( enviarECDsButton, new TableLayoutConstraints( 0, 2, 1, 2 ) ); - ecdsPanel.add( faxECDsButton, new TableLayoutConstraints( 0, 3, 1, 3 ) ); - - cols = new double[]{ TableLayout.FILL }; - rows = new double[]{ TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL }; - - tableLayout = new TableLayout( cols,rows ); - detalhesPanel.setLayout( tableLayout ); - - detalhesPanel.add( consultasPanel, new TableLayoutConstraints( 0, 0 ) ); - detalhesPanel.add( ecdsPanel, new TableLayoutConstraints( 0, 1 ) ); - - setDefaultCloseOperation( WindowConstants.DO_NOTHING_ON_CLOSE ); - addWindowListener( new WindowAdapter(){ - public void windowClosing( WindowEvent e ) - { - close(); - } - - public void windowOpened( WindowEvent e ) - { -// setExtendedState( getExtendedState() | MAXIMIZED_BOTH ); - } - - } ); - dataPanel.setDate( new Date() ); - recarregarPrestadores(); - carregar(); - } - - public void refresh() - { - } - - public void open() - { - setVisible( true ); - } - - public void close() - { - SwingUtilities.invokeLater( new Runnable() { - public void run() - { - setVisible( false ); - dispose(); - } - } ); - } - - public boolean closeIfPossible() - { - close(); - return true; - } - - public void actionPerformed(ActionEvent e) - { - Object source = e.getSource(); - if( source.equals( carregarButton ) ) - { - carregar(); - } - else if( source.equals( recarregarPrestadoresButton ) ) - { - recarregarPrestadores(); - } - else if( source.equals( enviarConsultasButton ) ) - { - enviarConsultas(); - } - else if( source.equals( faxConsultasButton ) ) - { - faxConsultas(); - } - else if( source.equals( enviarECDsButton ) ) - { - enviarECDs(); - } - else if( source.equals( faxECDsButton ) ) - { - faxECDs(); - } - - } - - public void valueChanged(ListSelectionEvent e) - { - Object source = e.getSource(); - if( e.getValueIsAdjusting() ) - { - return; - } - if( source.equals( empresasTable.getSelectionModel() ) ) - { - mudarEmpresa(); - } - else if( source.equals( estabelecimentosTable.getSelectionModel() ) ) - { - mudarEstabelecimento(); - } - } - - protected void carregar() - { - empresasTable.clearSelection(); - Date data = dataPanel.getDate(); - if( data == null ) - { - empresasModel.clearAll(); - return; - } - try - { - ColumnizedMappable empresas[] = provider.getEmpresasComMarcacoes( data ); - Vector values = empresasModel.getValues(); - values.clear(); - values.addAll( Arrays.asList( empresas ) ); - empresasModel.setValues( values ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar empresas", true ); - } - } - - protected void mudarEmpresa() - { - estabelecimentosTable.clearSelection(); - Date data = dataPanel.getDate(); - int selected = empresasTable.getSelectedRow(); - if( data == null || selected == -1 ) - { - estabelecimentosModel.clearAll(); - return; - } - Integer empresaID = ( ( ColumnizedMappable ) empresasModel.getRowAt( selected ) ).getID(); - try - { - ColumnizedMappable estabelecimentos[] = - provider.getEstabelecimentosComMarcacoesByEmpresa( empresaID, data ); - Vector values = estabelecimentosModel.getValues(); - values.clear(); - values.addAll( Arrays.asList( estabelecimentos ) ); - estabelecimentosModel.setValues( values ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar estabelecimentos", true ); - } - } - - protected void mudarEstabelecimento() - { - Date data = dataPanel.getDate(); - int selectedEstabelecimento = estabelecimentosTable.getSelectedRow(); - numeroConsultasLabel.setText( " " ); - numeroECDsLabel.setText( " " ); - enviarConsultasButton.setEnabled( false ); - enviarECDsButton.setEnabled( false ); - if( data == null || selectedEstabelecimento == -1 ) - { - return; - } - Integer estabelecimentoID = ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( selectedEstabelecimento ) ).getID(); - try - { - int countConsultas = - provider.getNumeroMarcacoesByEstabelecimentoAndTipo( estabelecimentoID, - Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA, data ); - int countECDs = - provider.getNumeroMarcacoesByEstabelecimentoAndTipo( estabelecimentoID, - Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES, data ); - if( countConsultas > 0 ) - { - numeroConsultasLabel.setText( "" + countConsultas ); - enviarConsultasButton.setEnabled( true ); - Integer[] escolhidos = - provider.getPrestadoresIDByEstabelecimentoAndTipo( estabelecimentoID, - Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA, data ); - if( escolhidos.length == 1 ) - { - numeroConsultasLabel.setForeground( Color.green.darker() ); - } - else - { - numeroConsultasLabel.setForeground( Color.red.darker() ); - } - int e; - for( e = 0; e < escolhidos.length; e++ ) - { - if( escolhidos[ e ] != null ) - { - break; - } - } - if( e == escolhidos.length || escolhidos[ e ] == null ) - { - prestadoresConsultasCombo.setSelectedIndex( 0 ); - } - else - { - for( int p = 0; p < prestadoresConsultasCombo.getItemCount(); p++ ) - { - IDObject prestador = ( IDObject ) prestadoresConsultasCombo.getItemAt( p ); - if( prestador.getID().equals( escolhidos[ e ] ) ) - { - prestadoresConsultasCombo.setSelectedIndex( p ); - } - } - } - } - if( countECDs > 0 ) - { - numeroECDsLabel.setText( "" + countECDs ); - enviarECDsButton.setEnabled( true ); - Integer[] escolhidos = - provider.getPrestadoresIDByEstabelecimentoAndTipo( estabelecimentoID, - Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES, data ); - if( escolhidos.length == 1 ) - { - numeroECDsLabel.setForeground( Color.green.darker() ); - } - else - { - numeroECDsLabel.setForeground( Color.red.darker() ); - } - int e; - for( e = 0; e < escolhidos.length; e++ ) - { - if( escolhidos[ e ] != null ) - { - break; - } - } - if( e == escolhidos.length || escolhidos[ e ] == null ) - { - prestadoresECDsCombo.setSelectedIndex( 0 ); - } - else - { - for( int p = 0; p < prestadoresECDsCombo.getItemCount(); p++ ) - { - IDObject prestador = ( IDObject ) prestadoresECDsCombo.getItemAt( p ); - if( prestador.getID().equals( escolhidos[ e ] ) ) - { - prestadoresECDsCombo.setSelectedIndex( p ); - } - } - } - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar detalhes", true ); - } - } - - protected void recarregarPrestadores() - { - try - { - IDObject prestadoresConsultas[] = prestadoresProvider.getPrestadoresConsultasActivos(); - IDObject prestadoresECDs[] = prestadoresProvider.getPrestadoresECDsActivos(); - prestadoresConsultasCombo.removeAllItems(); - prestadoresConsultasCombo.addItem( PRESTADOR_SIPRP ); - for( int n = 0; n < prestadoresConsultas.length; n++ ) - { - prestadoresConsultasCombo.addItem( prestadoresConsultas[ n ] ); - } - prestadoresECDsCombo.removeAllItems(); - prestadoresECDsCombo.addItem( PRESTADOR_SIPRP ); - for( int n = 0; n < prestadoresECDs.length; n++ ) - { - prestadoresECDsCombo.addItem( prestadoresECDs[ n ] ); - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar prestadores", true ); - } - } - - protected void enviarECDs() - { - Date data = dataPanel.getDate(); - int selectedEstabelecimento = estabelecimentosTable.getSelectedRow(); - if( data == null || selectedEstabelecimento == -1 ) - { - return; - } - Integer estabelecimentoID = ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( selectedEstabelecimento ) ).getID(); - try - { - Integer prestadorID = ( ( IDObject ) prestadoresECDsCombo.getSelectedItem() ).getID(); - if( PRESTADOR_ID_SIPRP.equals( prestadorID ) ) - { - prestadorID = null; - } - provider.setPrestadorIDForEstabelecimentoAndTipo( estabelecimentoID, - Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES, data, prestadorID ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a atribuir", true ); - } - } - - protected void faxECDs() - { - Date data = dataPanel.getDate(); - int selectedEstabelecimento = estabelecimentosTable.getSelectedRow(); - if( data == null || selectedEstabelecimento == -1 ) - { - return; - } - Integer estabelecimentoID = ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( selectedEstabelecimento ) ).getID(); - try - { - Integer prestadorID = ( ( IDObject ) prestadoresECDsCombo.getSelectedItem() ).getID(); - if( PRESTADOR_ID_SIPRP.equals( prestadorID ) ) - { - prestadorID = null; - } - provider.setPrestadorIDForEstabelecimentoAndTipo( estabelecimentoID, - Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES, data, prestadorID ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a atribuir", true ); - } - } - - protected void enviarConsultas() - { - Date data = dataPanel.getDate(); - int selectedEstabelecimento = estabelecimentosTable.getSelectedRow(); - if( data == null || selectedEstabelecimento == -1 ) - { - return; - } - Integer estabelecimentoID = ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( selectedEstabelecimento ) ).getID(); - try - { - Integer prestadorID = ( ( IDObject ) prestadoresConsultasCombo.getSelectedItem() ).getID(); - if( PRESTADOR_ID_SIPRP.equals( prestadorID ) ) - { - prestadorID = null; - } - provider.setPrestadorIDForEstabelecimentoAndTipo( estabelecimentoID, - Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA, data, prestadorID ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a atribuir", true ); - } - } - - protected void faxConsultas() - { - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/fax_ecds.xsl b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/fax_ecds.xsl deleted file mode 100644 index 2559b0c2..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/fax_ecds.xsl +++ /dev/null @@ -1,313 +0,0 @@ - - - - - - - - - - - - - - - FAX - - - Nº de Páginas (incluíndo esta) - / Number of pages (including this one): - - - - - - - - - - - - - - Data - / Date: - - - - - - - - - - - - - Para - / To: - - - - - - - - - - - - - Empresa - / Company: - - - - - - - - - - - - - Nº Fax - / Fax number: - - - - - - - - - - - - - De - / From: - - - - - - - - - - E-mail: - - - - - - - - - - - - - Nº Fax - / Fax number: - - - - - - - - - - Nº Tel. - / Phone number: - - - - - - - - - - - - - - - - - - - - - - - - - - Assunto - / Subject: - - - - - - - - - - - - - - - - - - - - Cliente: - - - - - - - - - - Local: - - - - - - - - - - - - - Data: - - - - - - - - - - Hora: - - - - - - - - - - - - - Exmos. Senhores, - - - Informo que os - seguintes - colaboradores - irão - irá - comparecer nas vossas instalações para colheita: - - - - - - - - - - - NOME DO FUNCIONÁRIO - - - - - DATA_NASCIMENTO - - - - - PERFIL - - - - - - - - - - - - - - - - - - - - - - - - - - - - PERFIL - : - - , - - - - - - - - - - - - AGRADEÇO QUE ESTA LISTAGEM NOS SEJA REENVIADA COM INDICAÇÃO DAS - EVENTUAIS FALTAS OCORRIDAS - - - - - - - - Sem outro assunto de momento, aproveitamos para apresentar os nossos melhores cumprimentos, - - - - - - - - - - - - diff --git a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/fax_ecds_teste.xml b/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/fax_ecds_teste.xml deleted file mode 100644 index 8e0366c2..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/locais_realizacao/fax_ecds_teste.xml +++ /dev/null @@ -1,234 +0,0 @@ - - - - - - 24-01-2007 - Pedro Manuel Silva Bento - Laboratorio ao lado da mercearia - 21 351 45 67 - Paula Dias - pdias@siprp.pt - (+351) 21 789 88 32 - (+351) 21 789 88 32 - Marcação de Colheitas para Análise - Evolute - Laboratorio ao lado da mercearia - 28-01-2007 - 08H00 - 1 - - Frederico Alexandre de Matos Monge Palma - 02-10-1976 - 1 - - - Pedro da Silva Antonio - 02-10-1973 - 2 - - - Joao Pedro Silva - 02-10-1976 - 1 - - - Frederico Alexandre de Matos Monge Palma - 02-10-1976 - 1 - - - Pedro da Silva Antonio - 02-10-1973 - 2 - - - Joao Pedro Silva - 02-10-1976 - 1 - - - Frederico Alexandre de Matos Monge Palma - 02-10-1976 - 1 - - - Pedro da Silva Antonio - 02-10-1973 - 2 - - - Joao Pedro Silva - 02-10-1976 - 1 - - - Frederico Alexandre de Matos Monge Palma - 02-10-1976 - 1 - - - Pedro da Silva Antonio - 02-10-1973 - 2 - - - Joao Pedro Silva - 02-10-1976 - 1 - - - Frederico Alexandre de Matos Monge Palma - 02-10-1976 - 1 - - - Pedro da Silva Antonio - 02-10-1973 - 2 - - - Joao Pedro Silva - 02-10-1976 - 1 - - - Frederico Alexandre de Matos Monge Palma - 02-10-1976 - 1 - - - Pedro da Silva Antonio - 02-10-1973 - 2 - - - Joao Pedro Silva - 02-10-1976 - 1 - - - Frederico Alexandre de Matos Monge Palma - 02-10-1976 - 1 - - - Pedro da Silva Antonio - 02-10-1973 - 2 - - - Joao Pedro Silva - 02-10-1976 - 1 - - - Frederico Alexandre de Matos Monge Palma - 02-10-1976 - 1 - - - Pedro da Silva Antonio - 02-10-1973 - 2 - - - Joao Pedro Silva - 02-10-1976 - 1 - - - Frederico Alexandre de Matos Monge Palma - 02-10-1976 - 1 - - - Pedro da Silva Antonio - 02-10-1973 - 2 - - - Joao Pedro Silva - 02-10-1976 - 1 - - - Frederico Alexandre de Matos Monge Palma - 02-10-1976 - 1 - - - Pedro da Silva Antonio - 02-10-1973 - 2 - - - Joao Pedro Silva - 02-10-1976 - 1 - - - Frederico Alexandre de Matos Monge Palma - 02-10-1976 - 1 - - - Pedro da Silva Antonio - 02-10-1973 - 2 - - - Joao Pedro Silva - 02-10-1976 - 1 - - - Frederico Alexandre de Matos Monge Palma - 02-10-1976 - 1 - - - Pedro da Silva Antonio - 02-10-1973 - 2 - - - Joao Pedro Silva - 02-10-1976 - 1 - - - - GENÉRICO - Hemograma - Vel. Sedimentação - Glicemia em Jejum - Creatinina - Colesterol Total - Colesterol HDL - Triglicéridos - Transaminases - Gama GT - Urina II - - - MANIPULADORES - Hemograma - Vel. Sedimentação - Glicemia em Jejum - Creatinina - Colesterol Total - Colesterol HDL - Triglicéridos - Transaminases - Gama GT - Urina II - Quistos - - diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/DetalhesRealizacaoDialog.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/DetalhesRealizacaoDialog.java deleted file mode 100644 index 6b939411..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/presencas/DetalhesRealizacaoDialog.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * DetalhesRealizacaoDialog.java - * - * Created on February 1, 2007, 11:19 AM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.presencas; - -import com.evolute.utils.data.IDObject; -import com.evolute.utils.ui.CustomJDialog; -import com.evolute.utils.ui.panel.CheckBoxPanel; -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.*; - -/** - * - * @author fpalma - */ -public class DetalhesRealizacaoDialog extends CustomJDialog - implements ActionListener -{ - protected JButton okButton; - protected JButton cancelButton; - protected CheckBoxPanel opcoesPanel; - - protected IDObject opcoes[]; - - protected Integer selected[]; - - /** Creates a new instance of DetalhesRealizacaoDialog */ - public DetalhesRealizacaoDialog( JFrame owner, IDObject opcoes[] ) - { - super( owner, true ); - this.opcoes = opcoes; - setupComponents(); - if( owner != null ) - { - centerSuper(); - } - else - { - center(); - } - setVisible( true ); - } - - private void setupComponents() - { - setTitle( "Escolha os ECD's realizados" ); - okButton = new JButton( "OK" ); - okButton.addActionListener( this ); - cancelButton = new JButton( "Cancelar" ); - cancelButton.addActionListener( this ); - opcoesPanel = new CheckBoxPanel( opcoes ); - - setLayout( new BorderLayout() ); - add( opcoesPanel, BorderLayout.CENTER ); - JPanel buttonPanel = new JPanel(); - add( buttonPanel, BorderLayout.SOUTH ); - - buttonPanel.setLayout( new FlowLayout( FlowLayout.RIGHT ) ); - buttonPanel.add( okButton ); - buttonPanel.add( cancelButton ); - - setSize( 250, 300 ); - } - - public void actionPerformed(ActionEvent e) - { - Object source = e.getSource(); - if( source.equals( okButton ) ) - { - selected = opcoesPanel.getSelected(); - close(); - } - else if( source.equals( cancelButton ) ) - { - close(); - } - } - - public void close() - { - SwingUtilities.invokeLater( new Runnable(){ - public void run() - { - setVisible( false ); - dispose(); - } - } ); - } - - public Integer[] getSelected() - { - return selected; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/ImpressaoAuxiliaresWindow.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/ImpressaoAuxiliaresWindow.java deleted file mode 100644 index 022449ce..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/presencas/ImpressaoAuxiliaresWindow.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * ImpressaoAuxiliaresWindow.java - * - * Created on 7 de Dezembro de 2006, 16:13 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.presencas; - -import java.awt.*; -import javax.swing.*; - -import com.evolute.utils.ui.*; -import com.evolute.utils.ui.calendar.*; - -/** - * - * @author fpalma - */ -public class ImpressaoAuxiliaresWindow extends JFrame -{ - protected JCalendarPanel calendarPanel; - protected JButton imprimirButton; - - /** Creates a new instance of ImpressaoAuxiliaresWindow */ - public ImpressaoAuxiliaresWindow() - { - setupComponents(); - } - - private void setupComponents() - { - setTitle( "Imprimir" ); - JLabel dataLabel = new JLabel( "Data" ); - calendarPanel = new JCalendarPanel( this ); - imprimirButton = new JButton( "Imprimir" ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/Presenca.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/Presenca.java deleted file mode 100644 index 8398bcf9..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/presencas/Presenca.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Presenca.java - * - * Created on February 1, 2007, 4:54 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.presencas; - -import com.evolute.utils.data.IDObject; -import siprp.data.Marcacao; - -/** - * - * @author fpalma - */ -public class Presenca - implements IDObject, Comparable -{ - protected Integer id; - protected String nome; - protected String nomePlain; - protected String nomeEmpresa; - protected Integer tipo; - - /** Creates a new instance of Presenca */ - public Presenca( Integer id, String nome, String nomePlain, String nomeEmpresa, - Integer tipo ) - { - this.setId(id); - this.setNome(nome); - this.setNomePlain(nomePlain); - this.setNomeEmpresa(nomeEmpresa); - this.setTipo(tipo); - } - - public Integer getID() - { - return getId(); - } - - public int compareTo( Object other ) - { - return getNomePlain().compareTo( ( ( Presenca ) other ).getNomePlain() ); - } - - public String toString() - { - String empresa = getNomeEmpresa(); - return "" + getNome() + "
" - + "    (" + empresa.substring( 0, empresa.length() > 50 ? 50 : empresa.length() ) - + ")" + ""; - } - - public Integer getId() - { - return id; - } - - public void setId(Integer id) - { - this.id = id; - } - - public String getNome() - { - return nome; - } - - public void setNome(String nome) - { - this.nome = nome; - } - - public String getNomePlain() - { - return nomePlain; - } - - public void setNomePlain(String nomePlain) - { - this.nomePlain = nomePlain; - } - - public String getNomeEmpresa() - { - return nomeEmpresa; - } - - public void setNomeEmpresa(String nomeEmpresa) - { - this.nomeEmpresa = nomeEmpresa; - } - - public Integer getTipo() - { - return tipo; - } - - public void setTipo(Integer tipo) - { - this.tipo = tipo; - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/PresencasActionFactory.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/PresencasActionFactory.java deleted file mode 100644 index a9faca2e..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/presencas/PresencasActionFactory.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * PresencasActionFactory.java - * - * Created on January 31, 2007, 6:37 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.presencas; - -import com.evolute.utils.data.IDObject; -import com.evolute.utils.ui.panel.multipleactionlist.ActionFactory; -import javax.swing.Action; -import siprp.medicina.presencas.actions.DesmarcadoSHSTAction; -import siprp.medicina.presencas.actions.DesmarcadoTrabalhadorAction; -import siprp.medicina.presencas.actions.FaltouAction; -import siprp.medicina.presencas.actions.RealizouAction; -import siprp.medicina.presencas.actions.RealizouParcialmenteAction; - -/** - * - * @author fpalma - */ -public class PresencasActionFactory implements ActionFactory -{ - public static final int REALIZOU = 0; - public static final int REALIZOU_PARCIALMENTE = 1; - public static final int TRABALHADOR_DESMARCOU = 2; - public static final int SHST_DESMARCOU = 3; - public static final int FALTOU = 4; - - protected final int TIPO; - - /** Creates a new instance of PresencasActionFactory */ - public PresencasActionFactory( int tipo ) - { - TIPO = tipo; - } - - public Action createAction(Presenca[] objects) - { - switch( TIPO ) - { - case SHST_DESMARCOU: - return new DesmarcadoSHSTAction( DesmarcadoSHSTAction.MULTIPLE, objects ); - - case FALTOU: - return new FaltouAction( FaltouAction.MULTIPLE, objects ); - - default: - return null; - } - } - - public Action createAction(Presenca object) - { - switch( TIPO ) - { - case REALIZOU: - return new RealizouAction( object ); - - case REALIZOU_PARCIALMENTE: - return new RealizouParcialmenteAction( object ); - - case TRABALHADOR_DESMARCOU: - return new DesmarcadoTrabalhadorAction( object ); - - case SHST_DESMARCOU: - return new DesmarcadoSHSTAction( DesmarcadoSHSTAction.SINGLE, new Presenca[]{ object } ); - - case FALTOU: - return new FaltouAction( FaltouAction.SINGLE, new Presenca[]{ object } ); - - default: - return null; - } - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/PresencasDataProvider.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/PresencasDataProvider.java deleted file mode 100644 index eb5521b2..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/presencas/PresencasDataProvider.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * PresencasDataProvider.java - * - * Created on February 5, 2007, 5:51 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.presencas; - -import com.evolute.utils.Singleton; -import com.evolute.utils.db.DBManager; -import com.evolute.utils.db.Executer; -import com.evolute.utils.sql.Assignment; -import com.evolute.utils.sql.Field; -import com.evolute.utils.sql.Update; -import java.util.Date; -import siprp.lembretes.LembretesConstants; -import siprp.lembretes.LembretesDataProvider; -import siprp.medicina.MedicinaConstants; -import siprp.medicina.MedicinaDataProvider; - -/** - * - * @author lflores - */ -public class PresencasDataProvider - implements MedicinaConstants, LembretesConstants -{ - private static final Object LOCK = new Object(); - private static PresencasDataProvider instance = null; - - private MedicinaDataProvider medicinaProvider; - private LembretesDataProvider lembretesProvider; - private Executer EXECUTER; - - /** Creates a new instance of PresencasDataProvider */ - public PresencasDataProvider() - throws Exception - { - DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); - EXECUTER = dbm.getSharedExecuter( this ); - medicinaProvider = ( MedicinaDataProvider ) MedicinaDataProvider.getProvider(); - lembretesProvider = LembretesDataProvider.getProvider(); - } - - public static PresencasDataProvider getProvider() - throws Exception - { - synchronized( LOCK ) - { - if( instance == null ) - { - instance = new PresencasDataProvider(); - } - } - return instance; - } - - protected void apagarDetalhesRealizacao( Integer marcacaoID ) - throws Exception - { - medicinaProvider.deleteDetalhesRealizadosForMarcacao( marcacaoID ); - } - - public void marcarFaltou( Integer id ) - throws Exception - { - apagarDetalhesRealizacao( id ); - Update update = - new Update( "marcacoes_trabalhador", - new Assignment[]{ - new Assignment( new Field( "realizada" ), "n" ), - new Assignment( new Field( "estado" ), new Integer( ESTADO_FALTOU ) ) - }, - new Field( "id" ).isEqual( id ) ); - EXECUTER.executeQuery( update ); - lembretesProvider.apagarLembreteByMarcacaoTrabalhadorID( id ); - lembretesProvider.criarLembrete( lembretesProvider.getTipoLembreteByCodigo( CODE_REMARCACOES ).getID(), - new Date(), - "Trabalhador Faltou", - null, - null, - null, - null, - null, - id, - false, - null, - null ); - } - - public void marcarDesmarcadoSHST( Integer id ) - throws Exception - { - apagarDetalhesRealizacao( id ); - Update update = - new Update( "marcacoes_trabalhador", - new Assignment[]{ - new Assignment( new Field( "realizada" ), "n" ), - new Assignment( new Field( "estado" ), new Integer( ESTADO_DESMARCADO_EMPRESA ) ) - }, - new Field( "id" ).isEqual( id ) ); - EXECUTER.executeQuery( update ); - lembretesProvider.apagarLembreteByMarcacaoTrabalhadorID( id ); - lembretesProvider.criarLembrete( lembretesProvider.getTipoLembreteByCodigo( CODE_REMARCACOES ).getID(), - new Date(), - "SIPRP Desmarcou", - null, - null, - null, - null, - null, - id, - false, - null, - null ); - } - - public void marcarDesmarcadoTrabalhador( Integer id ) - throws Exception - { - apagarDetalhesRealizacao( id ); - Update update = - new Update( "marcacoes_trabalhador", - new Assignment[]{ - new Assignment( new Field( "realizada" ), "n" ), - new Assignment( new Field( "estado" ), new Integer( ESTADO_DESMARCADO_TRABALHADOR ) ) - }, - new Field( "id" ).isEqual( id ) ); - EXECUTER.executeQuery( update ); - lembretesProvider.apagarLembreteByMarcacaoTrabalhadorID( id ); - lembretesProvider.criarLembrete( lembretesProvider.getTipoLembreteByCodigo( CODE_REMARCACOES ).getID(), - new Date(), - "Trabalhador Desmarcou", - null, - null, - null, - null, - null, - id, - false, - null, - null ); - } - - public void marcarRealizado( Integer id, Integer grupos[] ) - throws Exception - { - apagarDetalhesRealizacao( id ); - medicinaProvider.setDetalhesRealziadosForMarcacao( id, grupos ); - Update update = - new Update( "marcacoes_trabalhador", - new Assignment[]{ - new Assignment( new Field( "realizada" ), "y" ), - new Assignment( new Field( "estado" ), new Integer( ESTADO_REALIZADO ) ) - }, - new Field( "id" ).isEqual( id ) ); - EXECUTER.executeQuery( update ); - lembretesProvider.apagarLembreteByMarcacaoTrabalhadorID( id ); - } - - public void marcarParcialmenteRealizado( Integer id, Integer grupos[] ) - throws Exception - { - apagarDetalhesRealizacao( id ); - medicinaProvider.setDetalhesRealziadosForMarcacao( id, grupos ); - Update update = - new Update( "marcacoes_trabalhador", - new Assignment[]{ - new Assignment( new Field( "realizada" ), "n" ), - new Assignment( new Field( "estado" ), new Integer( ESTADO_PARCIALMENTE_REALIZADO ) ) - }, - new Field( "id" ).isEqual( id ) ); - EXECUTER.executeQuery( update ); - lembretesProvider.apagarLembreteByMarcacaoTrabalhadorID( id ); - lembretesProvider.criarLembrete( lembretesProvider.getTipoLembreteByCodigo( CODE_REMARCACOES ).getID(), - new Date(), - "ECDs por realizar", - null, - null, - null, - null, - null, - id, - false, - null, - null ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/RegistarPresencasWindow.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/RegistarPresencasWindow.java deleted file mode 100644 index 7dab5005..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/presencas/RegistarPresencasWindow.java +++ /dev/null @@ -1,360 +0,0 @@ -/* - * RegistarPresencasWindow.java - * - * Created on January 31, 2007, 3:09 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.presencas; - -import com.evolute.utils.data.IDObject; -import com.evolute.utils.data.MappableObject; -import com.evolute.utils.fop.FOPCreator; -import com.evolute.utils.fop.FOPPrinter; -import com.evolute.utils.tracker.TrackableWindow; -import com.evolute.utils.ui.DialogException; -import com.evolute.utils.ui.calendar.JCalendarPanel; -import com.evolute.utils.ui.panel.multipleactionlist.MultipleActionListPanel; -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.text.DateFormat; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.Hashtable; -import java.util.List; -import java.util.Locale; -import java.util.Vector; -import javax.swing.*; -import org.jdom.*; -import org.jdom.output.*; -import siprp.clientes.ClientesDataProvider; -import siprp.medicina.MedicinaDataProvider; -import siprp.medicina.prestadores.PrestadoresDataProvider; - -/** - * - * @author fpalma - */ -public class RegistarPresencasWindow extends JFrame - implements ActionListener, TrackableWindow -{ - protected static final String PRINT_TEMPLATE = "/siprp/medicina/presencas/auxiliares.xsl"; - protected static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) ); - - protected static final Integer PRESTADOR_ID_SIPRP = new Integer( -1 ); - protected static final Integer PRESTADOR_ID_TODOS = new Integer( -2 ); - - protected static final IDObject PRESTADOR_SIPRP = new MappableObject( PRESTADOR_ID_SIPRP, "SIPRP" ); - protected static final IDObject PRESTADOR_TODOS = new MappableObject( PRESTADOR_ID_TODOS, "Todos" ); - - protected JCalendarPanel dataPanel; - protected JButton carregarButton; - protected JComboBox prestadoresCombo; - protected JButton recarregarPrestadoresButton; - protected JButton imprimirAuxiliaresButton; - protected JScrollPane listECDsScroll; - protected JScrollPane listConsultasScroll; - protected MultipleActionListPanel listECDsPanel; - protected MultipleActionListPanel listConsultasPanel; - - protected MedicinaDataProvider provider; - protected PrestadoresDataProvider prestadoresProvider; - - protected Presenca ECDS[]; - - /** Creates a new instance of RegistarPresencasWindow */ - public RegistarPresencasWindow() - throws Exception - { - provider = ( MedicinaDataProvider ) MedicinaDataProvider.getProvider(); - prestadoresProvider = PrestadoresDataProvider.getProvider(); - setupComponents(); - - } - - private void setupComponents() - { - setTitle( "Presen\u00e7as" ); - setSize( 1000, 700 ); - JLabel dataLabel = new JLabel( "Data" ); - dataPanel = new JCalendarPanel( this ); - carregarButton = new JButton( "Carregar" ); - carregarButton.addActionListener( this ); - JLabel prestadoresLabel = new JLabel( "Prestador" ); - prestadoresCombo = new JComboBox (); - recarregarPrestadoresButton = new JButton( "Recarregar Prestadores" ); - recarregarPrestadoresButton.addActionListener( this ); - imprimirAuxiliaresButton = new JButton( "Imprimir" ); - imprimirAuxiliaresButton.addActionListener( this ); - - PresencasActionFactory realizouFactory = new PresencasActionFactory( PresencasActionFactory.REALIZOU ); - PresencasActionFactory realizouParcialmenteFactory = new PresencasActionFactory( PresencasActionFactory.REALIZOU_PARCIALMENTE ); - PresencasActionFactory trabalhadorDesmarcouFactory = new PresencasActionFactory( PresencasActionFactory.TRABALHADOR_DESMARCOU ); - PresencasActionFactory shstDesmarcouFactory = new PresencasActionFactory( PresencasActionFactory.SHST_DESMARCOU ); - PresencasActionFactory faltouFactory = new PresencasActionFactory( PresencasActionFactory.FALTOU ); - - getContentPane().setLayout( new BorderLayout( 5, 5 ) ); - JPanel upperPanel = new JPanel(); - getContentPane().add( upperPanel, BorderLayout.NORTH ); - JTabbedPane tabbedPane = new JTabbedPane(); - getContentPane().add( tabbedPane, BorderLayout.CENTER ); - - listECDsPanel = - new MultipleActionListPanel( - new PresencasActionFactory[]{ /*shstDesmarcouFactory, faltouFactory*/ }, - new PresencasActionFactory[]{ realizouFactory, realizouParcialmenteFactory, - trabalhadorDesmarcouFactory, shstDesmarcouFactory, - faltouFactory } ); - listECDsScroll = new JScrollPane( listECDsPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - - listConsultasPanel = - new MultipleActionListPanel( - new PresencasActionFactory[]{ /*shstDesmarcouFactory, faltouFactory*/ }, - new PresencasActionFactory[]{ realizouFactory, trabalhadorDesmarcouFactory, - shstDesmarcouFactory, faltouFactory } ); - listConsultasScroll = new JScrollPane( listConsultasPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - - tabbedPane.add( "ECDs", listECDsScroll ); - tabbedPane.add( "Consultas", listConsultasScroll ); - - upperPanel.setLayout( new FlowLayout( FlowLayout.CENTER ) ); - upperPanel.add( dataLabel ); - upperPanel.add( dataPanel ); - upperPanel.add( carregarButton ); - upperPanel.add( prestadoresLabel ); - upperPanel.add( prestadoresCombo ); - upperPanel.add( recarregarPrestadoresButton ); - upperPanel.add( imprimirAuxiliaresButton ); - - setDefaultCloseOperation( WindowConstants.DO_NOTHING_ON_CLOSE ); - addWindowListener( new WindowAdapter(){ - public void windowClosing( WindowEvent e ) - { - close(); - } - - public void windowOpened( WindowEvent e ) - { -// setExtendedState( getExtendedState() | MAXIMIZED_BOTH ); - } - - } ); - dataPanel.setDate( new Date() ); - recarregarPrestadores(); - carregar(); - } - - public void actionPerformed( ActionEvent e ) - { - Object source = e.getSource(); - if( source.equals( carregarButton ) ) - { - carregar(); - } - else if( source.equals( recarregarPrestadoresButton ) ) - { - recarregarPrestadores(); - } - else if( source.equals( imprimirAuxiliaresButton ) ) - { - imprimirAuxiliares(); - } - } - - public void refresh() - { - } - - public void open() - { - setVisible( true ); - } - - public void close() - { - SwingUtilities.invokeLater( new Runnable() { - public void run() - { - setVisible( false ); - dispose(); - } - } ); - } - - public boolean closeIfPossible() - { - close(); - return true; - } - - protected void carregar() - { - ECDS = null; - IDObject prestador = ( IDObject ) prestadoresCombo.getSelectedItem(); - boolean filtrar = true; - Integer prestadorID = null; - if( PRESTADOR_TODOS.equals( prestador ) ) - { - filtrar = false; - } - else if( !PRESTADOR_SIPRP.equals( prestador ) ) - { - prestadorID = prestador.getID(); - } - try - { - Date data = dataPanel.getDate(); - Object ecdsArray[][] = provider.getListaECDsByData( data ); - List ecds = new Vector(); - for( int n = 0; n < ecdsArray.length; n++ ) - { - Integer id = ( Integer ) ecdsArray[ n ][ 0 ]; - String nome = ( String ) ecdsArray[ n ][ 1 ]; - String nomePlain = ( String ) ecdsArray[ n ][ 2 ]; - String empresa = ( String ) ecdsArray[ n ][ 3 ]; - int tipo = ( ( Integer )ecdsArray[ n ][ 4 ] ).intValue(); - Integer prestadorMarcacao = ( Integer )ecdsArray[ n ][ 5 ]; - if( ( !filtrar ) || - ( prestadorID == null ? prestadorMarcacao == null : prestadorID.equals( prestadorMarcacao ) ) ) - { - ecds.add( new Presenca( id, nome, nomePlain, empresa, tipo ) ); - } - } - Collections.sort( ecds ); - ECDS = ecds.toArray( new Presenca[ ecds.size() ] ); - listECDsPanel.showList( ECDS ); - listECDsScroll.setViewportView( listECDsPanel ); - - Object consultasArray[][] = provider.getListaConsultasByData( data ); - List consultas = new Vector(); - for( int n = 0; n < consultasArray.length; n++ ) - { - Integer id = ( Integer ) consultasArray[ n ][ 0 ]; - String nome = ( String ) consultasArray[ n ][ 1 ]; - String nomePlain = ( String ) consultasArray[ n ][ 2 ]; - String empresa = ( String ) consultasArray[ n ][ 3 ]; - int tipo = ( ( Integer )consultasArray[ n ][ 4 ] ).intValue(); - Integer prestadorMarcacao = ( Integer )consultasArray[ n ][ 5 ]; - if( ( !filtrar ) || - ( prestadorID == null ? prestadorMarcacao == null : prestadorID.equals( prestadorMarcacao ) ) ) - { - consultas.add( new Presenca( id, nome, nomePlain, empresa, tipo ) ); - } - } - Collections.sort( consultas ); - listConsultasPanel.showList( consultas.toArray( new Presenca[ ecds.size() ] ) ); - listConsultasScroll.setViewportView( listConsultasPanel ); -// setExtendedState( getExtendedState() | MAXIMIZED_BOTH ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar dados", true ); - } - } - - protected void recarregarPrestadores() - { - try - { - IDObject prestadores[] = prestadoresProvider.getPrestadoresActivos(); - prestadoresCombo.removeAllItems(); - prestadoresCombo.addItem( PRESTADOR_SIPRP ); - prestadoresCombo.addItem( PRESTADOR_TODOS ); - for( int n = 0; n < prestadores.length; n++ ) - { - prestadoresCombo.addItem( prestadores[ n ] ); - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar prestadores", true ); - } - } - - protected void imprimirAuxiliares() - { - try - { - Date data = dataPanel.getDate(); - if( ECDS == null || data == null || ECDS.length == 0 ) - { - return; - } - ClientesDataProvider clientesProvider = - ( ClientesDataProvider ) ClientesDataProvider.getProvider(); - MedicinaDataProvider medicinaProvider = - ( MedicinaDataProvider ) MedicinaDataProvider.getProvider(); - - String dataStr = D_F.format( data ); - - Element rootElement = new Element( "lista-presencas" ); - - for( int n = 0; n < ECDS.length; n++ ) - { - Element presencaElement = new Element( "presenca" ); - - Element trabalhadorElement = new Element( "trabalhador" ); - trabalhadorElement.setText( ECDS[ n ].getNome() ); - presencaElement.addContent( trabalhadorElement ); - - Element empresaElement = new Element( "empresa" ); - empresaElement.setText( ECDS[ n ].getNomeEmpresa() ); - presencaElement.addContent( empresaElement ); - - Element dataElement = new Element( "data" ); - dataElement.setText( dataStr ); - presencaElement.addContent( dataElement ); - - Integer trabalhadorID = medicinaProvider.getTrabalhadorIDByMarcacaoID( ECDS[ n ].getID() ); - Integer empresaID = clientesProvider.getEmpresaIDByTrabalhadorID( trabalhadorID ); - Integer realizados[] = medicinaProvider.getDetalhesRealizadosForEstadosMarcacao( ECDS[ n ].getID() ); - Vector realizadosVector = new Vector(); - realizadosVector.addAll( Arrays.asList( realizados ) ); - IDObject validos[] = medicinaProvider.getDetalhesValidosTrabalhador( empresaID, trabalhadorID ); - for( int v = 0; v < validos.length; v++ ) - { - Integer id = validos[ v ].getID(); - if( !realizadosVector.contains( id ) ) - { - Element ecdElement = new Element( "ecd" ); - ecdElement.setText( validos[ v ].toString() ); - presencaElement.addContent( ecdElement ); - } - } - - rootElement.addContent( presencaElement ); - } - - Document doc = new Document( rootElement ); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - //new XMLOutputter().output( doc, System.out ); - new XMLOutputter().output( doc, baos ); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - FOPCreator creator = FOPCreator.getFOPCreator(); - InputStream xmlIn = new ByteArrayInputStream( baos.toByteArray() ); - creator.createFOfromXML( xmlIn, - getClass().getResourceAsStream( PRINT_TEMPLATE ), - out ); - ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() ); - Hashtable printOptions = new Hashtable(); - FOPPrinter.getFOPPrinter().printFO( in, true, true, printOptions ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a imprimir", true ); - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/DesmarcadoSHSTAction.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/DesmarcadoSHSTAction.java deleted file mode 100644 index 7cf7717a..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/DesmarcadoSHSTAction.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * DesmarcadoSHSTAction.java - * - * Created on January 31, 2007, 6:21 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.presencas.actions; - -import com.evolute.utils.ui.DialogException; -import java.awt.event.ActionEvent; -import javax.swing.AbstractAction; -import siprp.medicina.presencas.Presenca; -import siprp.medicina.presencas.PresencasDataProvider; - -/** - * - * @author fpalma - */ -public class DesmarcadoSHSTAction extends AbstractAction -{ - public static final int SINGLE = 0; - public static final int MULTIPLE = 1; - - protected int cardinality; - protected Presenca presencas[]; - - /** Creates a new instance of DesmarcadoSHSTAction */ - public DesmarcadoSHSTAction( int cardinality, Presenca presencas[] ) - { - super( cardinality == SINGLE ? "SIPRP Desmarcou" : "Marcar restantes como \"SIPRP desmarcou\"" ); - this.cardinality = cardinality; - this.presencas = presencas; - } - - public void actionPerformed(ActionEvent e) - { - try - { - PresencasDataProvider provider = PresencasDataProvider.getProvider(); - for( int n = 0; n < presencas.length; n++ ) - { - provider.marcarDesmarcadoSHST( presencas[ n ].getID() ); - } - if( cardinality == SINGLE ) - { - setEnabled( false ); - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a marcar", true ); - } - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/DesmarcadoTrabalhadorAction.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/DesmarcadoTrabalhadorAction.java deleted file mode 100644 index 93085547..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/DesmarcadoTrabalhadorAction.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * DesmarcadoTrabalhadorAction.java - * - * Created on January 31, 2007, 6:21 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.presencas.actions; - -import com.evolute.utils.ui.DialogException; -import java.awt.event.ActionEvent; -import javax.swing.AbstractAction; -import siprp.medicina.presencas.Presenca; -import siprp.medicina.presencas.PresencasDataProvider; - -/** - * - * @author fpalma - */ -public class DesmarcadoTrabalhadorAction extends AbstractAction -{ - protected Presenca presenca; - - /** Creates a new instance of DesmarcadoTrabalhadorAction */ - public DesmarcadoTrabalhadorAction( Presenca presenca ) - { - super( "Desmarcou" ); - this.presenca = presenca; - } - - public void actionPerformed(ActionEvent e) - { - try - { - PresencasDataProvider provider = PresencasDataProvider.getProvider(); - provider.marcarDesmarcadoTrabalhador( presenca.getID() ); - setEnabled( false ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a marcar", true ); - } - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/FaltouAction.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/FaltouAction.java deleted file mode 100644 index 035c8dd5..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/FaltouAction.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * FaltouAction.java - * - * Created on January 31, 2007, 6:21 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.presencas.actions; - -import com.evolute.utils.ui.DialogException; -import java.awt.event.ActionEvent; -import javax.swing.AbstractAction; -import siprp.medicina.presencas.Presenca; -import siprp.medicina.presencas.PresencasDataProvider; - -/** - * - * @author fpalma - */ -public class FaltouAction extends AbstractAction -{ - public static final int SINGLE = 0; - public static final int MULTIPLE = 1; - - protected int cardinality; - protected Presenca presencas[]; - - /** Creates a new instance of FaltouAction */ - public FaltouAction( int cardinality, Presenca presencas[] ) - { - super( cardinality == SINGLE ? "Faltou" : "Marcar restantes como \"Faltou\"" ); - this.cardinality = cardinality; - this.presencas = presencas; - } - - public void actionPerformed(ActionEvent e) - { - try - { - PresencasDataProvider provider = PresencasDataProvider.getProvider(); - for( int n = 0; n < presencas.length; n++ ) - { - provider.marcarFaltou( presencas[ n ].getID() ); - } - if( cardinality == SINGLE ) - { - setEnabled( false ); - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a marcar", true ); - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/RealizouAction.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/RealizouAction.java deleted file mode 100644 index 105b4ac0..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/RealizouAction.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * RealizouAction.java - * - * Created on January 31, 2007, 6:20 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.presencas.actions; - -import com.evolute.utils.data.IDObject; -import com.evolute.utils.ui.DialogException; -import java.awt.event.ActionEvent; -import java.util.Arrays; -import java.util.Vector; -import javax.swing.AbstractAction; -import siprp.clientes.ClientesDataProvider; -import siprp.medicina.MedicinaDataProvider; -import siprp.medicina.presencas.DetalhesRealizacaoDialog; -import siprp.medicina.presencas.Presenca; -import siprp.medicina.presencas.PresencasDataProvider; - -/** - * - * @author fpalma - */ -public class RealizouAction extends AbstractAction -{ - protected Presenca presenca; - - /** Creates a new instance of RealizouAction */ - public RealizouAction( Presenca presenca ) - { - super( "Realizou" ); - this.presenca = presenca; - } - - public void actionPerformed(ActionEvent e) - { - try - { - PresencasDataProvider provider = PresencasDataProvider.getProvider(); - ClientesDataProvider clientesProvider = - ( ClientesDataProvider ) ClientesDataProvider.getProvider(); - MedicinaDataProvider medicinaProvider = - ( MedicinaDataProvider ) MedicinaDataProvider.getProvider(); - Integer trabalhadorID = medicinaProvider.getTrabalhadorIDByMarcacaoID( presenca.getID() ); - Integer empresaID = clientesProvider.getEmpresaIDByTrabalhadorID( trabalhadorID ); - Integer realizados[] = medicinaProvider.getDetalhesRealizadosForEstadosMarcacao( presenca.getID() ); - Vector realizadosVector = new Vector(); - realizadosVector.addAll( Arrays.asList( realizados ) ); - IDObject validos[] = medicinaProvider.getDetalhesValidosTrabalhador( empresaID, trabalhadorID ); - Vector aRealizar = new Vector(); - for( int n = 0; n < validos.length; n++ ) - { - Integer id = validos[ n ].getID(); - if( !realizadosVector.contains( id ) ) - { - aRealizar.add( validos[ n ] ); - } - } - DetalhesRealizacaoDialog dialog = - new DetalhesRealizacaoDialog( null, ( IDObject[] ) aRealizar.toArray( new IDObject[ aRealizar.size() ] ) ); - Integer escolhidos[] = dialog.getSelected(); - if( escolhidos != null ) - { - provider.marcarParcialmenteRealizado( presenca.getID(), escolhidos ); - setEnabled( false ); - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a marcar", true ); - } -// try -// { -// PresencasDataProvider provider = PresencasDataProvider.getProvider(); -// ClientesDataProvider clientesProvider = -// ( ClientesDataProvider ) ClientesDataProvider.getProvider(); -// MedicinaDataProvider medicinaProvider = -// ( MedicinaDataProvider ) MedicinaDataProvider.getProvider(); -// Integer trabalhadorID = medicinaProvider.getTrabalhadorIDByMarcacaoID( presenca.getID() ); -// Integer empresaID = clientesProvider.getEmpresaIDByTrabalhadorID( trabalhadorID ); -// Integer realizados[] = medicinaProvider.getDetalhesRealizadosForEstadosMarcacao( presenca.getID() ); -// Vector realizadosVector = new Vector(); -// realizadosVector.addAll( Arrays.asList( realizados ) ); -// IDObject validos[] = medicinaProvider.getDetalhesValidosTrabalhador( empresaID, trabalhadorID ); -// Vector aRealizar = new Vector(); -// for( int n = 0; n < validos.length; n++ ) -// { -// Integer id = validos[ n ].getID(); -// if( !realizadosVector.contains( id ) ) -// { -// aRealizar.add( id ); -// } -// } -// provider.marcarRealizado( presenca.getID(), ( Integer[] ) aRealizar.toArray( new Integer[ aRealizar.size() ] ) ); -// setEnabled( false ); -// } -// catch( Exception ex ) -// { -// DialogException.showExceptionMessage( ex, "Erro a marcar", true ); -// } - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/RealizouParcialmenteAction.java b/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/RealizouParcialmenteAction.java deleted file mode 100644 index 5384d787..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/presencas/actions/RealizouParcialmenteAction.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * RealizouParcialmenteAction.java - * - * Created on January 31, 2007, 6:20 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.presencas.actions; - -import com.evolute.utils.data.IDObject; -import com.evolute.utils.ui.DialogException; -import java.awt.event.ActionEvent; -import java.util.Arrays; -import java.util.Vector; -import javax.swing.AbstractAction; -import javax.swing.JOptionPane; -import siprp.clientes.ClientesDataProvider; -import siprp.data.Marcacao; -import siprp.medicina.MedicinaDataProvider; -import siprp.medicina.presencas.DetalhesRealizacaoDialog; -import siprp.medicina.presencas.Presenca; -import siprp.medicina.presencas.PresencasDataProvider; - -/** - * - * @author fpalma - */ -public class RealizouParcialmenteAction extends AbstractAction -{ - protected Presenca presenca; - - /** Creates a new instance of RealizouParcialmenteAction */ - public RealizouParcialmenteAction( Presenca presenca ) - { - super( "Parcialmente" ); - this.presenca = presenca; - if( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA == presenca.getTipo().intValue() ) - { - setEnabled( false ); - } - } - - public void actionPerformed(ActionEvent e) - { - try - { - PresencasDataProvider provider = PresencasDataProvider.getProvider(); - ClientesDataProvider clientesProvider = - ( ClientesDataProvider ) ClientesDataProvider.getProvider(); - MedicinaDataProvider medicinaProvider = - ( MedicinaDataProvider ) MedicinaDataProvider.getProvider(); - Integer trabalhadorID = medicinaProvider.getTrabalhadorIDByMarcacaoID( presenca.getID() ); - Integer empresaID = clientesProvider.getEmpresaIDByTrabalhadorID( trabalhadorID ); - Integer realizados[] = medicinaProvider.getDetalhesRealizadosForEstadosMarcacao( presenca.getID() ); - Vector realizadosVector = new Vector(); - realizadosVector.addAll( Arrays.asList( realizados ) ); - IDObject validos[] = medicinaProvider.getDetalhesValidosTrabalhador( empresaID, trabalhadorID ); - Vector aRealizar = new Vector(); - for( int n = 0; n < validos.length; n++ ) - { - Integer id = validos[ n ].getID(); - if( !realizadosVector.contains( id ) ) - { - aRealizar.add( validos[ n ] ); - } - } - DetalhesRealizacaoDialog dialog = - new DetalhesRealizacaoDialog( null, ( IDObject[] ) aRealizar.toArray( new IDObject[ aRealizar.size() ] ) ); - Integer escolhidos[] = dialog.getSelected(); - if( escolhidos != null ) - { - provider.marcarParcialmenteRealizado( presenca.getID(), escolhidos ); - setEnabled( false ); - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a marcar", true ); - } - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/auxiliares.xml b/trunk/SIPRPSoft/src/siprp/medicina/presencas/auxiliares.xml deleted file mode 100644 index f4372ba8..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/presencas/auxiliares.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - Frederico Palma - Evolute - 2007/02/21 - RX - ECD - Sangue - Acuidade Visual - - - Luis Flores - Evolute - 2007/02/21 - RX - ECD - Acuidade Visual - - - Smeagol - Evolute - 2007/02/21 - RX - - diff --git a/trunk/SIPRPSoft/src/siprp/medicina/presencas/auxiliares.xsl b/trunk/SIPRPSoft/src/siprp/medicina/presencas/auxiliares.xsl deleted file mode 100644 index ae96ca3c..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/presencas/auxiliares.xsl +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Realização de ECDs - - - - - - ( ) - - - data: - - - hora de entrada: __h__m - - - - - - - - - - - ECD - - - - - Rúbrica - - - - - Motivo de não realização - - - - - - - - - - - - - - - - - - - - - - - - - - - hora de saída: __h__m - - - assinatura do trabalhador:________________________________________ - - - - - - - - diff --git a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresDataProvider.java b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresDataProvider.java deleted file mode 100644 index 2538eeab..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresDataProvider.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * PrestadoresDataProvider.java - * - * Created on February 2, 2007, 9:53 AM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.prestadores; - -import com.evolute.utils.Singleton; -import com.evolute.utils.arrays.Object2DArray; -import com.evolute.utils.arrays.Virtual2DArray; -import com.evolute.utils.data.IDObject; -import com.evolute.utils.data.MappableObject; -import com.evolute.utils.db.DBManager; -import com.evolute.utils.db.Executer; -import com.evolute.utils.jdo.JDOProvider; -import com.evolute.utils.sql.Assignment; -import com.evolute.utils.sql.Begin; -import com.evolute.utils.sql.Commit; -import com.evolute.utils.sql.Delete; -import com.evolute.utils.sql.Field; -import com.evolute.utils.sql.Insert; -import com.evolute.utils.sql.Rollback; -import com.evolute.utils.sql.Select; -import com.evolute.utils.ui.search.SearchDialog; -import com.evolute.utils.ui.search.SearchExecuter; -import siprp.data.ContactoData; -import siprp.medicina.prestadores.data.PrestadoresData; - -/** - * - * @author fpalma - */ -public class PrestadoresDataProvider - implements SearchExecuter -{ - private static final Object LOCK = new Object(); - private static PrestadoresDataProvider instance = null; - - private static final String SEARCH_TITLE = "Procurar prestadores"; - private static final String SEARCH_COLUMNS[] = - new String[]{ "Designa\u00e7\u00e3o", "Servi\u00e7os" }; - - private Executer EXECUTER; - - private JDOProvider JDO; - - /** Creates a new instance of PrestadoresDataProvider */ - public PrestadoresDataProvider() - throws Exception - { - DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); - EXECUTER = dbm.getSharedExecuter( this ); - JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); - } - - public static PrestadoresDataProvider getProvider() - throws Exception - { - synchronized( LOCK ) - { - if( instance == null ) - { - instance = new PrestadoresDataProvider(); - } - } - return instance; - } - - public boolean hasDetails() - { - return false; - } - - public String getSearchTitle() - { - return SEARCH_TITLE; - } - - public String[] getColumnNames() - { - return SEARCH_COLUMNS; - } - - public void showDetails(SearchDialog dialog, Object o) throws Exception - { - } - - public Virtual2DArray search(String pattern) throws Exception - { - pattern = pattern.trim().toLowerCase(); - pattern = pattern.replace( ' ', '%' ); - Select select = - new Select( new String[]{ "prestadores" }, - new String[]{ "id", "nome", "faz_consultas", "faz_ecds", "nome_plain" }, - new Field( "nome_plain" ).isLike( "%" + pattern + "%" ), - new String[]{ "nome_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, 0 ); - data[ n ][ 1 ] = array.get( n, 1 ); - String str = ""; - if( "y".equals( array.get( n, 2 ) ) ) - { - str += "consultas"; - } - if( "y".equals( array.get( n, 3 ) ) ) - { - str += ( str.length() > 0 ? ", " : "" ) + "ecds"; - } - data[ n ][ 2 ] = str; - } - return new Object2DArray( data ); - } - - public void setGruposProtocoloForPrestador( Integer prestadorID, Integer gruposProtocoloID[] ) - throws Exception - { - EXECUTER.executeQuery( Begin.BEGIN ); - try - { - Delete delete = new Delete( "prestadores_grupos_protocolo", - new Field( "prestador_id" ).isEqual( prestadorID ) ); - EXECUTER.executeQuery( delete ); - Insert insert = - new Insert( "prestadores_grupos_protocolo", - new Assignment[]{ - new Assignment( new Field( "prestador_id" ), prestadorID ), - new Assignment( new Field( "grupo_protocolo_id" ), gruposProtocoloID ) } ); - EXECUTER.executeQuery( insert ); - } - catch( Exception ex ) - { - EXECUTER.executeQuery( Rollback.ROLLBACK ); - } - EXECUTER.executeQuery( Commit.COMMIT ); - } - - public Integer []getGruposProtocoloIDByPrestadorID( Integer prestadorID ) - throws Exception - { - Select select = - new Select( new String[]{ "prestadores_grupos_protocolo" }, - new String[]{ "grupo_protocolo_id" }, - new Field( "prestador_id" ).isEqual( prestadorID ) ); - 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 ); - } - return ids; - } - - public PrestadoresData getPrestadorByID( Integer id ) - throws Exception - { - return ( PrestadoresData ) JDO.load( PrestadoresData.class, id ); - } - - public void savePrestador( PrestadoresData prestador ) - throws Exception - { - if( prestador.get( PrestadoresData.CONTACTO_ID ) instanceof ContactoData ) - { - ContactoData contacto = ( ContactoData )prestador.get( PrestadoresData.CONTACTO_ID ); - contacto.save(); - prestador.set( PrestadoresData.CONTACTO_ID, contacto.get( ContactoData.ID ) ); - } - prestador.save(); - } - - public IDObject[] getPrestadoresActivos() - throws Exception - { - Select select = - new Select( new String[]{ "prestadores" }, - new String[]{ "id", "nome", "nome_plain" }, - new Field( "activo" ).isEqual( "y" ), - new String[]{ "nome_plain" }, null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - IDObject prestadores[] = new IDObject[ array.columnLength() ]; - for( int n = 0; n < prestadores.length; n++ ) - { - Integer id = ( Integer ) array.get( n, 0 ); - String nome = ( String ) array.get( n, 1 ); - prestadores[ n ] = new MappableObject( id, nome ); - } - return prestadores; - } - - public IDObject[] getPrestadoresConsultasActivos() - throws Exception - { - Select select = - new Select( new String[]{ "prestadores" }, - new String[]{ "id", "nome", "nome_plain" }, - new Field( "activo" ).isEqual( "y" ).and( - new Field( "faz_consultas" ).isEqual( "y" ) ), - new String[]{ "nome_plain" }, null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - IDObject prestadores[] = new IDObject[ array.columnLength() ]; - for( int n = 0; n < prestadores.length; n++ ) - { - Integer id = ( Integer ) array.get( n, 0 ); - String nome = ( String ) array.get( n, 1 ); - prestadores[ n ] = new MappableObject( id, nome ); - } - return prestadores; - } - - public IDObject[] getPrestadoresECDsActivos() - throws Exception - { - Select select = - new Select( new String[]{ "prestadores" }, - new String[]{ "id", "nome", "nome_plain" }, - new Field( "activo" ).isEqual( "y" ).and( - new Field( "faz_ecds" ).isEqual( "y" ) ), - new String[]{ "nome_plain" }, null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - IDObject prestadores[] = new IDObject[ array.columnLength() ]; - for( int n = 0; n < prestadores.length; n++ ) - { - Integer id = ( Integer ) array.get( n, 0 ); - String nome = ( String ) array.get( n, 1 ); - prestadores[ n ] = new MappableObject( id, nome ); - } - return prestadores; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresWindow.java b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresWindow.java deleted file mode 100644 index 5a2de314..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresWindow.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * PrestadoresWindow.java - * - * Created on February 2, 2007, 9:44 AM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.prestadores; - -import com.evolute.utils.Singleton; -import com.evolute.utils.data.IDObject; -import com.evolute.utils.dataui.ComponentController; -import com.evolute.utils.dataui.ComponentsHashtable; -import com.evolute.utils.dataui.JDOControllable; -import com.evolute.utils.dataui.JTextComponentPlainFillerSaver; -import com.evolute.utils.jdo.JDOProvider; -import com.evolute.utils.ui.DialogException; -import com.evolute.utils.ui.panel.CheckBoxPanel; -import com.evolute.utils.ui.search.SearchDialog; -import com.evolute.utils.ui.window.EditorWindow; -import info.clearthought.layout.TableLayout; -import info.clearthought.layout.TableLayoutConstraints; -import java.awt.Dimension; -import java.util.Arrays; -import java.util.Hashtable; -import java.util.List; -import java.util.Vector; -import javax.swing.BorderFactory; -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; -import javax.swing.JTextField; -import siprp.clientes.ClientesDataProvider; -import siprp.clientes.ContactoPanel; -import siprp.data.ContactoData; -import siprp.medicina.prestadores.data.PrestadoresData; - -/** - * - * @author fpalma - */ -public class PrestadoresWindow extends EditorWindow -{ - public static final String TITLE = "Prestadores"; - - protected JTextField nomeText; - protected JCheckBox activoCheck; - protected JCheckBox consultasCheck; - protected JCheckBox ecdsCheck; - protected CheckBoxPanel ecdsPanel; - protected JTextArea moradaText; - protected JTextField codigoPostalText; - protected JTextField localidadeCodigoPostalText; - protected JTextField localidadeText; - protected ContactoPanel contactoPanel; - protected JTextField contribuinteText; - - - protected PrestadoresDataProvider provider; - protected ClientesDataProvider clientesProvider; - - protected ComponentsHashtable components; - - protected PrestadoresData prestador; - protected Integer gruposProtocolo[]; - - /** Creates a new instance of PrestadoresWindow */ - public PrestadoresWindow() - throws Exception - { - super( new int[][]{{ NEW_INDEX, EDIT_INDEX, CANCEL_INDEX, SAVE_INDEX, DELETE_INDEX, - SELECT_BYNAME_INDEX }} ); - provider = PrestadoresDataProvider.getProvider(); - clientesProvider = ( ClientesDataProvider ) ClientesDataProvider.getProvider(); - setupComponents(); - setupComponentsHashtable(); - } - - private void setupComponents() - throws Exception - { - setTitle( TITLE ); - JLabel nomeLabel = new JLabel( "Designa\u00e7\u00e3o" ); - nomeText = new JTextField(); - nomeText.setPreferredSize( new Dimension( 500, 20 ) ); - activoCheck = new JCheckBox( "Activo (actualmente fornece servi\u00e7os \u00e0 SIPRP)" ); - consultasCheck = new JCheckBox( "Faz consultas" ); - ecdsCheck = new JCheckBox( "Faz ecds" ); - List gruposProtocolo = new Vector(); - IDObject gruposProtocoloReais[] = clientesProvider.getAllGruposProtocoloReais(); - if( gruposProtocoloReais != null && gruposProtocoloReais.length > 0 ) - { - gruposProtocolo.addAll( Arrays.asList( gruposProtocoloReais ) ); - } - IDObject gruposProtocoloFalsos[] = clientesProvider.getAllGruposProtocoloFalsos(); - if( gruposProtocoloFalsos != null && gruposProtocoloFalsos.length > 0 ) - { - gruposProtocolo.addAll( Arrays.asList( gruposProtocoloFalsos ) ); - } - ecdsPanel = new CheckBoxPanel( gruposProtocolo.toArray( new IDObject[ gruposProtocolo.size() ] ) ); - JLabel contactoLabel = new JLabel( "Contacto" ); - contactoPanel = new ContactoPanel(); - contactoPanel.setPreferredSize( new Dimension( 350, 120 ) ); - contactoPanel.setBorder( BorderFactory.createEtchedBorder() ); - JLabel moradaLabel = new JLabel( "Morada" ); - moradaText = new JTextArea(); - moradaText.setLineWrap( true ); - moradaText.setWrapStyleWord( true ); - JScrollPane moradaScroll = new JScrollPane( moradaText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - moradaScroll.setPreferredSize( new Dimension( 500, 50 ) ); - JLabel codigoPostalLabel = new JLabel( "C\u00f3digo Postal" ); - codigoPostalText = new JTextField(); - codigoPostalText.setPreferredSize( new Dimension( 100, 50 ) ); - localidadeCodigoPostalText = new JTextField(); - localidadeCodigoPostalText.setPreferredSize( new Dimension( 150, 50 ) ); - JLabel localidadeLabel = new JLabel( "Localidade" ); - localidadeText = new JTextField(); - JLabel contribuinteLabel = new JLabel( "Contribuinte" ); - contribuinteText = new JTextField(); - contribuinteText.setPreferredSize( new Dimension( 100, 50 ) ); - - double cols[] = - new double[]{ TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL }; - double rows[] = - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, - TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED, - TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM }; - TableLayout tableLayout = new TableLayout( cols,rows ); - getContentPane().setLayout( tableLayout ); - - getContentPane().add( nomeLabel, new TableLayoutConstraints( 0, 0 ) ); - getContentPane().add( nomeText, new TableLayoutConstraints( 1, 0, 3, 0 ) ); - getContentPane().add( activoCheck, new TableLayoutConstraints( 0, 1, 2, 1 ) ); - getContentPane().add( consultasCheck, new TableLayoutConstraints( 0, 2 ) ); - getContentPane().add( ecdsCheck, new TableLayoutConstraints( 0, 3 ) ); - getContentPane().add( ecdsPanel, new TableLayoutConstraints( 1, 3, 2, 3 ) ); - getContentPane().add( contactoLabel, new TableLayoutConstraints( 0, 4 ) ); - getContentPane().add( contactoPanel, new TableLayoutConstraints( 1, 4, 2, 4 ) ); - getContentPane().add( moradaLabel, new TableLayoutConstraints( 0, 5 ) ); - getContentPane().add( moradaScroll, new TableLayoutConstraints( 1, 5, 3, 5 ) ); - getContentPane().add( codigoPostalLabel, new TableLayoutConstraints( 0, 6 ) ); - getContentPane().add( codigoPostalText, new TableLayoutConstraints( 1, 6 ) ); - getContentPane().add( localidadeCodigoPostalText, new TableLayoutConstraints( 2, 6, 3, 6 ) ); - getContentPane().add( localidadeLabel, new TableLayoutConstraints( 0, 7 ) ); - getContentPane().add( localidadeText, new TableLayoutConstraints( 1, 7, 3, 7 ) ); - getContentPane().add( contribuinteLabel, new TableLayoutConstraints( 0, 8 ) ); - getContentPane().add( contribuinteText, new TableLayoutConstraints( 1, 8 ) ); - pack(); - } - - private void setupComponentsHashtable() - { - components = new ComponentsHashtable(); - components.putComponent( PrestadoresData.NOME, nomeText ); - components.putComponent( PrestadoresData.NOME_PLAIN, new JTextComponentPlainFillerSaver( nomeText ) ); - components.putComponent( PrestadoresData.MORADA, moradaText ); - components.putComponent( PrestadoresData.CODIGO_POSTAL, codigoPostalText ); - components.putComponent( PrestadoresData.LOCALIDADE_CP, localidadeCodigoPostalText ); - components.putComponent( PrestadoresData.LOCALIDADE, localidadeText ); - components.putComponent( PrestadoresData.CONTRIBUINTE, contribuinteText ); - components.putComponent( PrestadoresData.ACTIVO, activoCheck ); - components.putComponent( PrestadoresData.FAZ_CONSULTAS, consultasCheck ); - components.putComponent( PrestadoresData.FAZ_ECDS, ecdsCheck ); - components.putComponent( PrestadoresData.CONTACTO_ID, - new JDOControllable( ( JDOProvider )Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ), - ContactoData.class, new String[]{ ContactoData.ID }, - contactoPanel ) ); - } - - - public boolean searchByName() - { - SearchDialog search = new SearchDialog( provider ); - Integer id = ( Integer )search.getSelected(); - if( id == null ) - { - return false; - } - clear( 0 ); - try - { - prestador = provider.getPrestadorByID( id ); - gruposProtocolo = provider.getGruposProtocoloIDByPrestadorID( id ); - reload( 0 ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Ocorreu um erro a carregar o prestador.", true ); - return false; - } - - return true; - } - - public void enableComponents( int index, boolean enable ) - { - String names[] = (String[])components.keySet().toArray( new String[0] ); - ComponentController.setEnabled( names, enable, components ); - ecdsPanel.setEnabled( enable ); - } - - public void reload( int index ) - { - try - { - String names[] = (String[])components.keySet().toArray( new String[0] ); - ComponentController.fill( names, prestador.getHashData(), components ); - ecdsPanel.setSelected( gruposProtocolo ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar dados", true ); - - } - } - - public void clear( int index ) - { - String names[] = (String[])components.keySet().toArray( new String[0] ); - ComponentController.clear( names, components ); - ecdsPanel.clear(); - prestador = null; - gruposProtocolo = null; - } - - public boolean newItem( int index ) - { - return true; - } - - public boolean save( int index ) - { - if( prestador == null ) - { - prestador = new PrestadoresData(); - } - String names[] = (String[])components.keySet().toArray( new String[0] ); - Hashtable data = prestador.getHashData(); - ComponentController.save( names, data, components ); - prestador.setHashData( data ); - gruposProtocolo = ecdsPanel.getSelected(); - try - { - provider.savePrestador( prestador ); - provider.setGruposProtocoloForPrestador( ( Integer ) prestador.get( PrestadoresData.ID ), - gruposProtocolo ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a guardar dados", true ); - return false; - } - return true; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/Prestadores.java b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/Prestadores.java deleted file mode 100644 index 196bf5b8..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/Prestadores.java +++ /dev/null @@ -1,236 +0,0 @@ -/* -* Prestadores.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on Feb 21, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.prestadores.data; - -import com.evolute.utils.jdo.*; - -public final class Prestadores implements JDOInnerObject -{ - private Integer id; - private String nome; - private String nome_plain; - private String morada; - private String codigo_postal; - private String localidade; - private String localidade_cp; - private Integer contacto_id; - private String activo; - private String faz_consultas; - private String faz_ecds; - private String contribuinte; - - public Prestadores() - { - } - - public Object getField( String fieldName ) - { - if( fieldName == PrestadoresData.ID ) - { - return id; - } - else if( fieldName == PrestadoresData.NOME ) - { - return nome; - } - else if( fieldName == PrestadoresData.NOME_PLAIN ) - { - return nome_plain; - } - else if( fieldName == PrestadoresData.MORADA ) - { - return morada; - } - else if( fieldName == PrestadoresData.CODIGO_POSTAL ) - { - return codigo_postal; - } - else if( fieldName == PrestadoresData.LOCALIDADE ) - { - return localidade; - } - else if( fieldName == PrestadoresData.LOCALIDADE_CP ) - { - return localidade_cp; - } - else if( fieldName == PrestadoresData.CONTACTO_ID ) - { - return contacto_id; - } - else if( fieldName == PrestadoresData.ACTIVO ) - { - return activo; - } - else if( fieldName == PrestadoresData.FAZ_CONSULTAS ) - { - return faz_consultas; - } - else if( fieldName == PrestadoresData.FAZ_ECDS ) - { - return faz_ecds; - } - else if( fieldName == PrestadoresData.CONTRIBUINTE ) - { - return contribuinte; - } - else if( fieldName.equals( PrestadoresData.ID ) ) - { - return id; - } - else if( fieldName.equals( PrestadoresData.NOME ) ) - { - return nome; - } - else if( fieldName.equals( PrestadoresData.NOME_PLAIN ) ) - { - return nome_plain; - } - else if( fieldName.equals( PrestadoresData.MORADA ) ) - { - return morada; - } - else if( fieldName.equals( PrestadoresData.CODIGO_POSTAL ) ) - { - return codigo_postal; - } - else if( fieldName.equals( PrestadoresData.LOCALIDADE ) ) - { - return localidade; - } - else if( fieldName.equals( PrestadoresData.LOCALIDADE_CP ) ) - { - return localidade_cp; - } - else if( fieldName.equals( PrestadoresData.CONTACTO_ID ) ) - { - return contacto_id; - } - else if( fieldName.equals( PrestadoresData.ACTIVO ) ) - { - return activo; - } - else if( fieldName.equals( PrestadoresData.FAZ_CONSULTAS ) ) - { - return faz_consultas; - } - else if( fieldName.equals( PrestadoresData.FAZ_ECDS ) ) - { - return faz_ecds; - } - else if( fieldName.equals( PrestadoresData.CONTRIBUINTE ) ) - { - return contribuinte; - } - return null; - } - - public void setField( String fieldName, Object value ) - { - if( fieldName == PrestadoresData.ID ) - { - id = ( Integer ) value; - } - else if( fieldName == PrestadoresData.NOME ) - { - nome = ( String ) value; - } - else if( fieldName == PrestadoresData.NOME_PLAIN ) - { - nome_plain = ( String ) value; - } - else if( fieldName == PrestadoresData.MORADA ) - { - morada = ( String ) value; - } - else if( fieldName == PrestadoresData.CODIGO_POSTAL ) - { - codigo_postal = ( String ) value; - } - else if( fieldName == PrestadoresData.LOCALIDADE ) - { - localidade = ( String ) value; - } - else if( fieldName == PrestadoresData.LOCALIDADE_CP ) - { - localidade_cp = ( String ) value; - } - else if( fieldName == PrestadoresData.CONTACTO_ID ) - { - contacto_id = ( Integer ) value; - } - else if( fieldName == PrestadoresData.ACTIVO ) - { - activo = ( String ) value; - } - else if( fieldName == PrestadoresData.FAZ_CONSULTAS ) - { - faz_consultas = ( String ) value; - } - else if( fieldName == PrestadoresData.FAZ_ECDS ) - { - faz_ecds = ( String ) value; - } - else if( fieldName == PrestadoresData.CONTRIBUINTE ) - { - contribuinte = ( String ) value; - } - else if( fieldName.equals( PrestadoresData.ID ) ) - { - id = ( Integer ) value; - } - else if( fieldName.equals( PrestadoresData.NOME ) ) - { - nome = ( String ) value; - } - else if( fieldName.equals( PrestadoresData.NOME_PLAIN ) ) - { - nome_plain = ( String ) value; - } - else if( fieldName.equals( PrestadoresData.MORADA ) ) - { - morada = ( String ) value; - } - else if( fieldName.equals( PrestadoresData.CODIGO_POSTAL ) ) - { - codigo_postal = ( String ) value; - } - else if( fieldName.equals( PrestadoresData.LOCALIDADE ) ) - { - localidade = ( String ) value; - } - else if( fieldName.equals( PrestadoresData.LOCALIDADE_CP ) ) - { - localidade_cp = ( String ) value; - } - else if( fieldName.equals( PrestadoresData.CONTACTO_ID ) ) - { - contacto_id = ( Integer ) value; - } - else if( fieldName.equals( PrestadoresData.ACTIVO ) ) - { - activo = ( String ) value; - } - else if( fieldName.equals( PrestadoresData.FAZ_CONSULTAS ) ) - { - faz_consultas = ( String ) value; - } - else if( fieldName.equals( PrestadoresData.FAZ_ECDS ) ) - { - faz_ecds = ( String ) value; - } - else if( fieldName.equals( PrestadoresData.CONTRIBUINTE ) ) - { - contribuinte = ( String ) value; - } - } - - public Class getOuterClass() - { - return PrestadoresData.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/PrestadoresData.java b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/PrestadoresData.java deleted file mode 100644 index 0afbd770..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/PrestadoresData.java +++ /dev/null @@ -1,70 +0,0 @@ -/* -* PrestadoresData.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on Feb 21, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.prestadores.data; - -import java.util.HashMap; -import com.evolute.utils.jdo.*; - -public final class PrestadoresData extends JDOObject -{ - 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 LOCALIDADE_CP = "localidade_cp"; - public static final String CONTACTO_ID = "contacto_id"; - public static final String ACTIVO = "activo"; - public static final String FAZ_CONSULTAS = "faz_consultas"; - public static final String FAZ_ECDS = "faz_ecds"; - public static final String CONTRIBUINTE = "contribuinte"; - - public static final String FIELD_NAMES[] = new String[]{ - NOME, NOME_PLAIN, MORADA, CODIGO_POSTAL, LOCALIDADE, LOCALIDADE_CP, CONTACTO_ID, - ACTIVO, FAZ_CONSULTAS, FAZ_ECDS, CONTRIBUINTE, }; - - - protected static final String ALL_FIELD_NAMES[] = new String[]{ - ID, NOME, NOME_PLAIN, MORADA, CODIGO_POSTAL, LOCALIDADE, LOCALIDADE_CP, CONTACTO_ID, - ACTIVO, FAZ_CONSULTAS, FAZ_ECDS, CONTRIBUINTE, }; - - private HashMap dataHash; - - public PrestadoresData() - { - 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 Prestadores.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/PrestadoresID.java b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/PrestadoresID.java deleted file mode 100644 index 63ad6666..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/PrestadoresID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* PrestadoresID.java -* -* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on Feb 21, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.prestadores.data; - -import java.io.*; - -import com.evolute.utils.jdo.jpox.*; - -public final class PrestadoresID extends IntegerID - implements Serializable -{ - public PrestadoresID() - { - } - - public PrestadoresID( String str ) - { - super( str ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/package.jdo b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/package.jdo deleted file mode 100644 index a901197b..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/data/package.jdo +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/EscolherMotivoDialog.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/EscolherMotivoDialog.java deleted file mode 100644 index 1f9f83c5..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/EscolherMotivoDialog.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * EscolherMotivoDialog.java - * - * Created on 13 de Maio de 2007, 22:16 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo; - -import com.evolute.utils.data.IDObject; -import com.evolute.utils.data.MappableObject; -import com.evolute.utils.ui.CustomJDialog; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.HashMap; -import javax.swing.AbstractButton; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.JToggleButton; -import javax.swing.SwingUtilities; -import siprp.medicina.MedicinaConstants; - -/** - * - * @author Frederico - */ -public class EscolherMotivoDialog extends CustomJDialog - implements ActionListener, MedicinaConstants -{ - protected IDObject MOTIVOS[] = - new IDObject[]{ - new MappableObject( MOTIVO_ADMISSAO_INTEGER, MOTIVO_ADMISSAO_STR ), - new MappableObject( MOTIVO_PERIODICO_INTEGER, MOTIVO_PERIODICO_STR ), - new MappableObject( MOTIVO_PERIODICO_INICIAL_INTEGER, MOTIVO_PERIODICO_INICIAL_STR ), - new MappableObject( MOTIVO_OCASIONAL_INTEGER, MOTIVO_OCASIONAL_STR ) - }; - - protected IDObject SUB_MOTIVOS[][] = - new IDObject[][]{ - {}, - {}, - {}, - { new MappableObject( SUB_MOTIVO_APOS_DOENCA_INTEGER, SUB_MOTIVO_APOS_DOENCA_STR ), - new MappableObject( SUB_MOTIVO_APOS_ACIDENTE_INTEGER, SUB_MOTIVO_APOS_ACIDENTE_STR ), - new MappableObject( SUB_MOTIVO_PEDIDO_TRABALHADOR_INTEGER, SUB_MOTIVO_PEDIDO_TRABALHADOR_STR ), - new MappableObject( SUB_MOTIVO_PEDIDO_SERVICO_INTEGER, SUB_MOTIVO_PEDIDO_SERVICO_STR ), - new MappableObject( SUB_MOTIVO_MUDANCA_FUNCAO_INTEGER, SUB_MOTIVO_MUDANCA_FUNCAO_STR ), - new MappableObject( SUB_MOTIVO_ALTERACAO_CONDICOES_INTEGER, SUB_MOTIVO_ALTERACAO_CONDICOES_STR ), - new MappableObject( SUB_MOTIVO_OUTRO_INTEGER, SUB_MOTIVO_OUTRO_STR ) - } - }; - - protected AbstractButton motivoButtons[]; - protected HashMap subMotivoButtons; - protected HashMap motivoButtonIDs; - protected HashMap subMotivoButtonIDs; - protected JPanel motivoPanel; - protected JPanel subMotivoPanel; - - protected Integer motivoTemp; - protected Integer motivo; - protected Integer subMotivo; - - /** Creates a new instance of EscolherMotivoDialog */ - public EscolherMotivoDialog( JFrame owner ) - { - super( owner, true ); - setupComponents(); - - if( owner != null ) - { - centerSuper(); - } - else - { - center(); - } - } - - private void setupComponents() - { - setTitle( "Escolher Motivo" ); - setLayout( new FlowLayout( FlowLayout.LEFT ) ); - motivoButtons = new JToggleButton[ MOTIVOS.length ]; - subMotivoButtons = new HashMap(); - motivoButtonIDs = new HashMap(); - subMotivoButtonIDs = new HashMap(); - for( int m = 0; m < MOTIVOS.length; m++ ) - { - JToggleButton motivoButton = new JToggleButton( MOTIVOS[ m ].toString() ); - motivoButton.addActionListener( this ); - motivoButtonIDs.put( motivoButton, MOTIVOS[ m ].getID() ); - motivoButton.setPreferredSize( new Dimension( 250, 20 ) ); - motivoButtons[ m ] = motivoButton; - if( SUB_MOTIVOS[ m ].length > 0 ) - { - JButton subButtons[] = new JButton[ SUB_MOTIVOS[ m ].length ]; - for( int sm = 0; sm < SUB_MOTIVOS[ m ].length; sm++ ) - { - JButton subButton = new JButton( SUB_MOTIVOS[ m ][ sm ].toString() ); - subMotivoButtonIDs.put( subButton, SUB_MOTIVOS[ m ][ sm ].getID() ); - subButtons[ sm ] = subButton; - subButton.setPreferredSize( new Dimension( 300, 20 ) ); - subButton.addActionListener( this ); - } - subMotivoButtons.put( motivoButton, subButtons ); - } - else - { - subMotivoButtons.put( motivoButton, null ); - } - } - motivoPanel = new JPanel(); - subMotivoPanel = new JPanel(); - - motivoPanel.setLayout( new GridLayout( motivoButtons.length + 1, 1 ) ); - for( int n = 0; n < motivoButtons.length; n++ ) - { - motivoPanel.add( motivoButtons[ n ] ); - } - - add( motivoPanel ); - add( subMotivoPanel ); - - pack(); - } - - public void actionPerformed(ActionEvent e) - { - AbstractButton source = ( AbstractButton ) e.getSource(); - if( motivoButtonIDs.containsKey( source ) ) - { - motivoTemp = motivoButtonIDs.get( source ); - } - else if( subMotivoButtonIDs.containsKey( source ) ) - { - motivo = motivoTemp; - subMotivo = subMotivoButtonIDs.get( source ); - close(); - } - if( subMotivoButtons.containsKey( source ) ) - { - JButton subButtons[] = subMotivoButtons.get( source ); - if( subButtons == null || subButtons.length == 0 ) - { - motivo = motivoTemp; - close(); - } - else - { - subMotivoPanel.removeAll(); - subMotivoPanel.setLayout( new GridLayout( 0, 1 ) ); - for( int n = 0; n < subButtons.length; n++ ) - { - subMotivoPanel.add( subButtons[ n ] ); - } - pack(); - } - } - } - - protected void close() - { - SwingUtilities.invokeLater( new Runnable(){ - public void run() - { - setVisible( false ); - dispose(); - } - } ); - } - - public Integer[] getMotivo() - { - return new Integer[]{ motivo, subMotivo }; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoConstants.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoConstants.java deleted file mode 100644 index a915de30..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoConstants.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * ProcessoConstants.java - * - * Created on May 14, 2007, 10:08 AM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo; - -/** - * - * @author fpalma - */ -public interface ProcessoConstants -{ - public static final int TIPO_ECDS = 0; - public static final int TIPO_CONSULTA = 1; - public static final int TIPO_FICHA_APTIDAO = 2; - - public static final String PROCESSO_ABERTO_CODE = "a"; - public static final String PROCESSO_FECHADO_CODE = "f"; - public static final String PROCESSO_CANCELADO_CODE = "c"; - - public static final String PROCESSO_ABERTO_DESCRIPTION = "Aberto"; - public static final String PROCESSO_FECHADO_DESCRIPTION = "Fechado"; - public static final String PROCESSO_CANCELADO_DESCRIPTION = "Cancelado"; - public static final String PROCESSO_POR_ABRIR_DESCRIPTION = "Por Abrir"; -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoController.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoController.java deleted file mode 100644 index ee9f22bf..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoController.java +++ /dev/null @@ -1,405 +0,0 @@ - /* - * ProcessoController.java - * - * Created on 25 de Abril de 2007, 15:10 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo; - -import com.evolute.utils.Singleton; -import com.evolute.utils.data.MappableObject; -import com.evolute.utils.jdo.JDOProvider; -import com.evolute.utils.ui.DialogException; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import siprp.data.TrabalhadorData; -import siprp.medicina.processo.detalhes.DetalhesProcessoPanel; -import siprp.medicina.processo.estrutura.EstruturaProcessoPanel; - -/** - * - * @author Frederico - */ -public class ProcessoController - implements ProcessoListener, ListSelectionListener -{ - protected ProcessoUpperPanel processoUpperPanel; - protected EstruturaProcessoPanel estruturaProcessoPanel; - protected ProcessoPanel processoPanel; - protected DetalhesProcessoPanel detalhesProcessoPanel; - protected ProcessoDataProvider provider; - - protected JDOProvider JDO; - - protected Integer idProcesso; - protected Integer idMarcacao; - protected Integer idData; - - /** Creates a new instance of ProcessoController */ - public ProcessoController( ProcessoUpperPanel processoUpperPanel, EstruturaProcessoPanel estruturaProcessoPanel, - ProcessoPanel processoPanel, DetalhesProcessoPanel detalhesProcessoPanel ) - throws Exception - { - this.processoUpperPanel = processoUpperPanel; - this.estruturaProcessoPanel = estruturaProcessoPanel; - this.processoPanel = processoPanel; - this.detalhesProcessoPanel = detalhesProcessoPanel; - processoUpperPanel.addListSelectionListener( this ); - estruturaProcessoPanel.addProcessoListener( this ); - processoPanel.addProcessoListener( this ); - detalhesProcessoPanel.addProcessoListener( this ); - - provider = ProcessoDataProvider.getProvider(); - JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); - } - - public void processoStateChanged(ProcessoEvent e) - { - int accao = e.getAccao(); - switch( accao ) - { - case ProcessoEvent.ACCAO_RECARREGAR_TRABALHADOR: - recarregarTrabalhador( e ); - break; - - case ProcessoEvent.ACCAO_ESCOLHER_PROCESSO: - escolherProcesso( e ); - break; - - case ProcessoEvent.ACCAO_ESCOLHER_CONSULTA: - escolherConsulta( e ); - break; - - case ProcessoEvent.ACCAO_ESCOLHER_ECDS: - escolherECDs( e ); - break; - - case ProcessoEvent.ACCAO_ESCOLHER_FA: - escolherFichaAptidao( e ); - break; - - case ProcessoEvent.ACCAO_ESCOLHER_DATA: - escolherData( e ); - break; - - case ProcessoEvent.ACCAO_ESCOLHER_OBSERVACOES: - escolherObservacoes( e ); - break; - - case ProcessoEvent.ACCAO_ESCOLHER_MAIL: - escolherMail( e ); - break; - - case ProcessoEvent.ACCAO_ESCOLHER_MOTIVO: - escolherMotivo( e ); - break; - - case ProcessoEvent.ACCAO_MARCAR_CONSULTA: - marcarConsulta( e ); - break; - - case ProcessoEvent.ACCAO_MARCAR_ECDS: - marcarECDs( e ); - break; - - case ProcessoEvent.ACCAO_EMITIR_FA: - emitirFichaAptidao( e ); - break; - - case ProcessoEvent.ACCAO_FECHAR: - fecharProcesso( e ); - break; - - case ProcessoEvent.ACCAO_MUDAR_ESTADO_MARCACAO: - mudarEstadoMarcacao( e ); - break; - - case ProcessoEvent.ACCAO_MUDAR_DATA_MARCACAO: - mudarDataMarcacao( e ); - break; - - case ProcessoEvent.ACCAO_ESCREVER_OBSERVACOES: - escreverObservacoes( e ); - break; - - case ProcessoEvent.ACCAO_ESCREVER_MAIL: - escreverMail( e ); - break; - - } - } - - public void recarregarTrabalhador( ProcessoEvent e ) - { - idProcesso = null; - estruturaProcessoPanel.reload(); - } - - public void escolherProcesso( ProcessoEvent e ) - { - try - { - idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO ); - processoPanel.fill( idProcesso ); - detalhesProcessoPanel.setProcessoID( idProcesso ); - detalhesProcessoPanel.clear(); - } - catch( Exception ex ) - { - } - } - - public void escolherConsulta( ProcessoEvent e ) - { - try - { - Integer idProcessoAntigo = idProcesso; - idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO ); - processoPanel.fill( idProcesso ); - detalhesProcessoPanel.setProcessoID( idProcesso ); - idMarcacao = e.getObjecto( ProcessoEvent.TIPO_CONSULTA ); - detalhesProcessoPanel.setConsulta( idMarcacao ); - } - catch( Exception ex ) - { - } - } - - public void escolherECDs( ProcessoEvent e ) - { - try - { - Integer idProcessoAntigo = idProcesso; - idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO ); - processoPanel.fill( idProcesso ); - detalhesProcessoPanel.setProcessoID( idProcesso ); - - idMarcacao = e.getObjecto( ProcessoEvent.TIPO_ECDS ); - detalhesProcessoPanel.setECDs( idMarcacao ); - } - catch( Exception ex ) - { - } - } - - public void escolherFichaAptidao( ProcessoEvent e ) - { - try - { - idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO ); - Integer idFichaAptidao = e.getObjecto( ProcessoEvent.TIPO_FICHA_APTIDAO ); - } - catch( Exception ex ) - { - } - } - - public void escolherData( ProcessoEvent e ) - { - try - { - Integer idProcessoAntigo = idProcesso; - idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO ); - processoPanel.fill( idProcesso ); - detalhesProcessoPanel.setProcessoID( idProcesso ); - Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA ); - Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS ); - Integer idData = e.getObjecto( ProcessoEvent.TIPO_DATA ); - if( idConsulta != null ) - { - idMarcacao = idConsulta; - detalhesProcessoPanel.setConsulta( idConsulta ); - } - else if( idECDs != null ) - { - idMarcacao = idECDs; - detalhesProcessoPanel.setECDs( idECDs ); - } - else - { - idMarcacao = null; - detalhesProcessoPanel.clear(); - } - } - catch( Exception ex ) - { - } - } - - public void escolherObservacoes( ProcessoEvent e ) - { - try - { - escolherData( e ); - Integer idObservacoes = e.getObjecto( ProcessoEvent.TIPO_OBSERVACOES ); - } - catch( Exception ex ) - { - } - } - - public void escolherMail( ProcessoEvent e ) - { - try - { - escolherData( e ); - Integer idMail = e.getObjecto( ProcessoEvent.TIPO_MAIL ); - } - catch( Exception ex ) - { - } - } - - public void escolherMotivo( ProcessoEvent e ) - { - try - { - idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO ); - estruturaProcessoPanel.actualizarProcessoEscolhido( idProcesso ); - detalhesProcessoPanel.setProcessoID( idProcesso ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a actualizar dados", true ); - } - } - - public void marcarConsulta( ProcessoEvent e ) - { - try - { - idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO ); - detalhesProcessoPanel.setConsulta( null ); - - } - catch( Exception ex ) - { - } - } - - public void marcarECDs( ProcessoEvent e ) - { - try - { - idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO ); - detalhesProcessoPanel.setECDs( null ); - } - catch( Exception ex ) - { - } - } - - public void emitirFichaAptidao( ProcessoEvent e ) - { - try - { - idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO ); - estruturaProcessoPanel.actualizarProcessoEscolhido( idProcesso ); - } - catch( Exception ex ) - { - } - } - - public void fecharProcesso( ProcessoEvent e ) - { - try - { - idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO ); - estruturaProcessoPanel.actualizarProcessoEscolhido( idProcesso ); - } - catch( Exception ex ) - { - } - } - - public void mudarEstadoMarcacao( ProcessoEvent e ) - { - try - { - idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO ); - Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA ); - Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS ); - idMarcacao = idConsulta != null ? idConsulta : idECDs; - estruturaProcessoPanel.actualizarMarcacaoEscolhida( idProcesso, idMarcacao ); - } - catch( Exception ex ) - { - } - } - - public void mudarDataMarcacao( ProcessoEvent e ) - { - try - { - idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO ); - Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA ); - Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS ); - idMarcacao = idConsulta != null ? idConsulta : idECDs; - estruturaProcessoPanel.actualizarMarcacaoEscolhida( idProcesso, idMarcacao ); - } - catch( Exception ex ) - { - } - } - - public void escreverObservacoes( ProcessoEvent e ) - { - try - { - idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO ); - Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA ); - Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS ); - idMarcacao = idConsulta != null ? idConsulta : idECDs; - estruturaProcessoPanel.actualizarMarcacaoEscolhida( idProcesso, idMarcacao ); - } - catch( Exception ex ) - { - } - } - - public void escreverMail( ProcessoEvent e ) - { - try - { - idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO ); - Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA ); - Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS ); - idMarcacao = idConsulta != null ? idConsulta : idECDs; - estruturaProcessoPanel.actualizarMarcacaoEscolhida( idProcesso, idMarcacao ); - } - catch( Exception ex ) - { - } - } - - public void valueChanged(ListSelectionEvent e) - { - try - { - Integer ids[] = ( Integer [] ) processoUpperPanel.save(); - Integer trabalhadorID = ids[ 2 ]; - processoPanel.setTrabalhadorID( trabalhadorID ); - if( trabalhadorID != null ) - { - TrabalhadorData trabalhador = ( TrabalhadorData ) JDO.load( TrabalhadorData.class, trabalhadorID ); - estruturaProcessoPanel.setTrabalhador( new MappableObject( trabalhadorID, trabalhador.get( TrabalhadorData.NOME ) ) ); - } - else - { - estruturaProcessoPanel.clear(); - } - processoPanel.clear(); - detalhesProcessoPanel.clear(); - processoPanel.setTrabalhadorID( trabalhadorID ); - detalhesProcessoPanel.setTrabalhadorID( trabalhadorID ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar trabalhador", true ); - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoDataProvider.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoDataProvider.java deleted file mode 100644 index 75eafc8d..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoDataProvider.java +++ /dev/null @@ -1,616 +0,0 @@ -/* - * ProcessoDataProvider.java - * - * Created on March 20, 2007, 5:14 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo; - -import com.evolute.utils.Singleton; -import com.evolute.utils.arrays.Virtual2DArray; -import com.evolute.utils.data.IDObject; -import com.evolute.utils.data.MappableObject; -import com.evolute.utils.db.DBManager; -import com.evolute.utils.db.Executer; -import com.evolute.utils.jdo.JDOProvider; -import com.evolute.utils.sql.Assignment; -import com.evolute.utils.sql.Expression; -import com.evolute.utils.sql.Field; -import com.evolute.utils.sql.Insert; -import com.evolute.utils.sql.Select; -import com.evolute.utils.sql.Select2; -import com.evolute.utils.sql.Update; -import java.text.DateFormat; -import java.util.Arrays; -import java.util.Comparator; -import java.util.Date; -import java.util.HashMap; -import java.util.Locale; -import java.util.Vector; -import siprp.medicina.MedicinaConstants; -import siprp.medicina.processo.data.TrabalhadoresConsultasData; -import siprp.medicina.processo.data.TrabalhadoresConsultasDatasData; -import siprp.medicina.processo.data.TrabalhadoresEcdsData; -import siprp.medicina.processo.data.TrabalhadoresEcdsDatasData; -import siprp.medicina.processo.data.TrabalhadoresProcessoData; - -/** - * - * @author fpalma - */ -public class ProcessoDataProvider - implements MedicinaConstants, ProcessoConstants -{ - private static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) ); - - public static final HashMap ESTADO_PROCESSO_BY_CODE = - new HashMap(); - - static - { - ESTADO_PROCESSO_BY_CODE.put( PROCESSO_ABERTO_CODE, PROCESSO_ABERTO_DESCRIPTION ); - ESTADO_PROCESSO_BY_CODE.put( PROCESSO_FECHADO_CODE, PROCESSO_FECHADO_DESCRIPTION ); - ESTADO_PROCESSO_BY_CODE.put( PROCESSO_CANCELADO_CODE, PROCESSO_CANCELADO_DESCRIPTION ); - } - - private static final Object LOCK = new Object(); - private static ProcessoDataProvider instance = null; - private Executer EXECUTER; - private JDOProvider JDO; - - /** Creates a new instance of ProcessoDataProvider */ - public ProcessoDataProvider() - throws Exception - { - DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); - EXECUTER = dbm.getSharedExecuter( this ); - JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); - } - - public static ProcessoDataProvider getProvider() - throws Exception - { - synchronized( LOCK ) - { - if( instance == null ) - { - instance = new ProcessoDataProvider(); - } - } - return instance; - } - - public Integer[] getIDsProcessosByTrabalhador( Integer trabalhadorID ) - throws Exception - { - Select select = - new Select2( new String[]{ "trabalhadores_processo" }, - new Integer[ 0 ], - new Expression[ 0 ], - new String[]{ "id", "data_inicio" }, - new Field( "trabalhadores_processo.trabalhador_id" ).isEqual( trabalhadorID ), - new String[]{ "data_inicio DESC" }, - null, - null, - null ); - 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 ); - } - return ids; - } - - public TrabalhadoresProcessoData getProcessoByID( Integer id ) - throws Exception - { - return ( TrabalhadoresProcessoData ) JDO.load( TrabalhadoresProcessoData.class, id ); - } - - public void saveProcesso( TrabalhadoresProcessoData processo ) - throws Exception - { - processo.save(); - } - - public String getDescricaoEstadoProcessoByCodigo( String codigo ) - throws Exception - { - return ESTADO_PROCESSO_BY_CODE.get( codigo ); - } - - public Object[][] getElementosProcesso( Integer processoID ) - throws Exception - { - Vector elementosVector = new Vector(); - - Select select = - new Select2( new String[]{ "trabalhadores_ecds" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "id", "data", "estado", "" + TIPO_ECDS }, - new Field( "processo_id" ).isEqual( processoID ), - new String[]{ "data", "id" }, - null, - null, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - elementosVector.addAll( Arrays.asList( array.getObjects() ) ); - - select = - new Select2( new String[]{ "trabalhadores_consultas" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "id", "data", "estado", "" + TIPO_CONSULTA }, - new Field( "processo_id" ).isEqual( processoID ), - new String[]{ "data", "id" }, - null, - null, - null ); - array = EXECUTER.executeQuery( select ); - elementosVector.addAll( Arrays.asList( array.getObjects() ) ); - - select = - new Select2( new String[]{ "trabalhadores_fichas_aptidao", "exames" }, - new Integer[]{ Select2.JOIN_INNER }, - new Expression[]{ new Field( "trabalhadores_fichas_aptidao.exame_id" ).isEqual( new Field( "exames.id" ) ) }, - new String[]{ "exames.id", "exames.data", "resultado", "" + TIPO_FICHA_APTIDAO }, - new Field( "trabalhadores_fichas_aptidao.processo_id" ).isEqual( processoID ).and( - new Field( "exames.inactivo" ).isDifferent( "y" ) ), - new String[]{ "exames.data", "exames.id" }, - null, - null, - null ); - array = EXECUTER.executeQuery( select ); - elementosVector.addAll( Arrays.asList( array.getObjects() ) ); - - Object elementos[][] = elementosVector.toArray( new Object[ elementosVector.size() ][] ); - Arrays.sort( elementos, new Comparator(){ - public int compare( Object o1, Object o2 ) - { - return ( (Date)( ( Object[] ) o1 )[ 1 ] ).compareTo( ( (Date)( ( Object[] ) o2 )[ 1 ] ) ); - } - } ); - return elementos; - } - - public Object[][] getDatasConsulta( Integer consultaID ) - throws Exception - { - Select select = - new Select2( new String[]{ "trabalhadores_consultas_datas" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "id", "data", "estado" }, - new Field( "trabalhadores_consultas_id" ).isEqual( consultaID ), - new String[]{ "data DESC" }, - null, - null, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - return array.getObjects(); - } - - public Object[][] getDatasECDs( Integer consultaID ) - throws Exception - { - Select select = - new Select2( new String[]{ "trabalhadores_ecds_datas" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "id", "data", "estado" }, - new Field( "consulta_id" ).isEqual( consultaID ), - new String[]{ "data DESC" }, - null, - null, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - return array.getObjects(); - } - - public IDObject getObservacoesConsultaData( Integer consultaDataID ) - throws Exception - { - Select select = - new Select2( new String[]{ "trabalhadores_consultas_datas_observacoes" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "id", "observacao" }, - new Field( "trabalhadores_consultas_datas_id" ).isEqual( consultaDataID ), - null, - null, - null, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - if( array.columnLength() == 0 || array.get( 0, 0 ) == null ) - { - return null; - } - else - { - return new MappableObject( ( Integer ) array.get( 0, 0 ), ( String ) array.get( 0, 1 ) ); - } - } - - public void saveObservacoesConsultaData( Integer consultaDataID, String observacao ) - throws Exception - { - IDObject observacaoAntiga = getObservacoesConsultaData( consultaDataID ); - if( observacaoAntiga != null ) - { - Update update = - new Update( "trabalhadores_consultas_datas_observacoes", - new Assignment[]{ - new Assignment( "observacao", observacao ) }, - new Field( "id" ).isEqual( observacaoAntiga.getID() ) ); - EXECUTER.executeQuery( update ); - } - else - { - Insert insert = - new Insert( "trabalhadores_consultas_datas_observacoes", - new Assignment[]{ - new Assignment( "observacao", observacao ), - new Assignment( "trabalhadores_consultas_datas_id", consultaDataID ) } ); - EXECUTER.executeQuery( insert ); - } - } - - public IDObject[] getEmailConsultaData( Integer consultaDataID ) - throws Exception - { - Select select = - new Select2( new String[]{ "trabalhadores_consultas_datas_emails" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "id", "data", "subject" }, - new Field( "trabalhadores_consultas_datas_id" ).isEqual( consultaDataID ), - new String[]{ "data DESC" }, - null, - null, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - IDObject mails[] = new IDObject[ array.columnLength() ]; - for( int n = 0; n < mails.length; n++ ) - { - Date data = ( Date ) array.get( n, 1 ); - String desc = D_F.format( data ) + " : " + array.get( n, 2 ); - mails[ n ] = new MappableObject( ( Integer ) array.get( n, 0 ), desc ); - } - return mails; - } - - public void saveEmailConsultaData( Integer consultaDataID, String destination, - String subject, String body ) - throws Exception - { - Insert insert = - new Insert( "trabalhadores_consultas_datas_emails", - new Assignment[]{ - new Assignment( "destination", destination ), - new Assignment( "subject", subject ), - new Assignment( "body", body ), - new Assignment( "data", new Date() ), - new Assignment( "trabalhadores_consultas_datas_id", consultaDataID ) } ); - EXECUTER.executeQuery( insert ); - } - - public Integer getLastConsultaDataIDForConsulta( Integer consultaID ) - throws Exception - { - Select select = - new Select2( new String[]{ "trabalhadores_consultas_datas" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "MAX( id )" }, - new Field( "trabalhadores_consultas_id" ).isEqual( consultaID ), - null, - null, - null, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - if( array.columnLength() == 0 || array.get( 0, 0 ) == null ) - { - return null; - } - else - { - return ( Integer ) array.get( 0, 0 ); - } - } - - public IDObject getObservacoesECDsData( Integer ecdsDataID ) - throws Exception - { - Select select = - new Select2( new String[]{ "trabalhadores_consultas_datas_observacoes" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "id", "observacao" }, - new Field( "trabalhadores_ecds_datas_id" ).isEqual( ecdsDataID ), - null, - null, - null, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - if( array.columnLength() == 0 || array.get( 0, 0 ) == null ) - { - return null; - } - else - { - return new MappableObject( ( Integer ) array.get( 0, 0 ), ( String ) array.get( 0, 1 ) ); - } - } - - public void saveObservacoesECDsData( Integer ecdsDataID, String observacao ) - throws Exception - { - IDObject observacaoAntiga = getObservacoesECDsData( ecdsDataID ); - if( observacaoAntiga != null ) - { - Update update = - new Update( "trabalhadores_ecds_datas_observacoes", - new Assignment[]{ - new Assignment( "observacao", observacao ) }, - new Field( "id" ).isEqual( observacaoAntiga.getID() ) ); - EXECUTER.executeQuery( update ); - } - else - { - Insert insert = - new Insert( "trabalhadores_ecds_datas_observacoes", - new Assignment[]{ - new Assignment( "observacao", observacao ), - new Assignment( "trabalhadores_ecds_datas_id", ecdsDataID ) } ); - EXECUTER.executeQuery( insert ); - } - } - - public Integer getLastECDsDataIDForECDs( Integer ecdsID ) - throws Exception - { - Select select = - new Select2( new String[]{ "trabalhadores_ecds_datas" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "MAX( id )" }, - new Field( "trabalhadores_ecds_id" ).isEqual( ecdsID ), - null, - null, - null, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - if( array.columnLength() == 0 || array.get( 0, 0 ) == null ) - { - return null; - } - else - { - return ( Integer ) array.get( 0, 0 ); - } - } - - public boolean getProcessoTemConsultasPorRealizar( Integer processoID ) - throws Exception - { - Select select = - new Select2( new String[]{ "trabalhadores_consultas" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "id", "estado" }, - new Field( "processo_id" ).isEqual( processoID ), - new String[]{ "estado" }, - null, - null, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - return ( array.columnLength() > 0 ) && ( new Integer( ESTADO_POR_REALIZAR ).equals( array.get( 0, 1 ) ) ); - } - - public boolean getProcessoTemECDsPorRealizar( Integer processoID ) - throws Exception - { - Select select = - new Select2( new String[]{ "trabalhadores_ecds" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "id", "estado" }, - new Field( "processo_id" ).isEqual( processoID ), - new String[]{ "estado" }, - null, - null, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - return ( array.columnLength() > 0 ) && ( new Integer( ESTADO_POR_REALIZAR ).equals( array.get( 0, 1 ) ) ); - } - - public Integer[] getConsultaIDsForProcesso( Integer processoID ) - throws Exception - { - Select select = - new Select2( new String[]{ "trabalhadores_consultas" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "id" }, - new Field( "processo_id" ).isEqual( processoID ), - null, - null, - null, - null ); - 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 ); - } - return ids; - } - - public Integer[] getECDsIDsForProcesso( Integer processoID ) - throws Exception - { - Select select = - new Select2( new String[]{ "trabalhadores_ecds" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "id" }, - new Field( "processo_id" ).isEqual( processoID ), - null, - null, - null, - null ); - 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 ); - } - return ids; - } - - public Integer getConsultaEmAbertoForProcesso( Integer processoID ) - throws Exception - { - Select select = - new Select2( new String[]{ "trabalhadores_consultas" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "id" }, - new Field( "processo_id" ).isEqual( processoID ).and( - new Field( "estado" ).isDifferent( new Integer( ESTADO_REALIZADO ) ) ), - null, - null, - null, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - if( array.columnLength() == 0 ) - { - return null; - } - else - { - return ( Integer ) array.get( 0, 0 ); - } - } - - public Integer getECDsEmAbertoForProcesso( Integer processoID ) - throws Exception - { - Select select = - new Select2( new String[]{ "trabalhadores_ecds" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "id" }, - new Field( "processo_id" ).isEqual( processoID ).and( - new Field( "estado" ).isDifferent( new Integer( ESTADO_POR_REALIZAR ) ) ), - null, - null, - null, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - if( array.columnLength() == 0 ) - { - return null; - } - else - { - return ( Integer ) array.get( 0, 0 ); - } - } - - public TrabalhadoresConsultasData getConsultaByID( Integer id ) - throws Exception - { - return ( TrabalhadoresConsultasData ) JDO.load( TrabalhadoresConsultasData.class, id ); - } - - public void saveConsulta( TrabalhadoresConsultasData consulta ) - throws Exception - { - consulta.save(); - } - - public TrabalhadoresConsultasDatasData getConsultaDataByID( Integer id ) - throws Exception - { - return ( TrabalhadoresConsultasDatasData ) JDO.load( TrabalhadoresConsultasDatasData.class, id ); - } - - public void saveConsultaData( TrabalhadoresConsultasDatasData consultaData ) - throws Exception - { - consultaData.save(); - } - - public TrabalhadoresEcdsData getEcdsByID( Integer id ) - throws Exception - { - return ( TrabalhadoresEcdsData ) JDO.load( TrabalhadoresEcdsData.class, id ); - } - - public void saveEcds( TrabalhadoresEcdsData ecds ) - throws Exception - { - ecds.save(); - } - - public TrabalhadoresEcdsDatasData getEcdsDataByID( Integer id ) - throws Exception - { - return ( TrabalhadoresEcdsDatasData ) JDO.load( TrabalhadoresEcdsDatasData.class, id ); - } - - public void saveEcdsData( TrabalhadoresEcdsDatasData EcdsData ) - throws Exception - { - EcdsData.save(); - } - - public boolean verificarDataValidaForConsulta( Integer consultaID, Date data ) - throws Exception - { - Select select = - new Select2( new String[]{ "trabalhadores_consultas_datas" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "id" }, - new Field( "trabalhadores_consultas_id" ).isEqual( consultaID ).and( - new Field( "estado" ).isDifferent( new Integer( ESTADO_POR_REALIZAR ) ) ).and( - new Field( "data" ).isGreater( data ) ), - null, - null, - null, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - return array.columnLength() == 0; - } - - public boolean verificarDataValidaForECDs( Integer ecdsID, Date data ) - throws Exception - { - Select select = - new Select2( new String[]{ "trabalhadores_ecds_datas" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "id" }, - new Field( "trabalhadores_ecdss_id" ).isEqual( ecdsID ).and( - new Field( "estado" ).isDifferent( new Integer( ESTADO_POR_REALIZAR ) ) ).and( - new Field( "data" ).isGreater( data ) ), - null, - null, - null, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - return array.columnLength() == 0; - } - - public void saveLigacaoProcessoFichaAptidao( Integer processoID, Integer fichaID ) - throws Exception - { - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoEvent.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoEvent.java deleted file mode 100644 index aa7ba004..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoEvent.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * ProcessoEvent.java - * - * Created on 25 de Abril de 2007, 10:53 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo; - -import java.util.HashMap; - -/** - * - * @author Frederico - */ -public class ProcessoEvent -{ - public static final int ACCAO_RECARREGAR_TRABALHADOR = 0; - public static final int ACCAO_ESCOLHER_PROCESSO = 1; - public static final int ACCAO_ESCOLHER_CONSULTA = 2; - public static final int ACCAO_ESCOLHER_ECDS = 3; - public static final int ACCAO_ESCOLHER_FA = 4; - public static final int ACCAO_ESCOLHER_DATA = 5; - public static final int ACCAO_ESCOLHER_OBSERVACOES = 6; - public static final int ACCAO_ESCOLHER_MAIL = 7; - public static final int ACCAO_ESCOLHER_MOTIVO = 8; - public static final int ACCAO_MARCAR_CONSULTA = 9; - public static final int ACCAO_MARCAR_ECDS = 10; - public static final int ACCAO_EMITIR_FA = 11; - public static final int ACCAO_FECHAR = 12; - public static final int ACCAO_MUDAR_ESTADO_MARCACAO = 13; - public static final int ACCAO_MUDAR_DATA_MARCACAO = 14; - public static final int ACCAO_ESCREVER_OBSERVACOES = 15; - public static final int ACCAO_ESCREVER_MAIL = 16; - - public static final Integer TIPO_ANY = new Integer( 0 ); - public static final Integer TIPO_PROCESSO = new Integer( 1 ); - public static final Integer TIPO_CONSULTA = new Integer( 2 ); - public static final Integer TIPO_ECDS = new Integer( 3 ); - public static final Integer TIPO_DATA = new Integer( 4 ); - public static final Integer TIPO_OBSERVACOES = new Integer( 5 ); - public static final Integer TIPO_MAIL = new Integer( 6 ); - public static final Integer TIPO_FICHA_APTIDAO = new Integer( 7 ); - - protected final Object source; - protected final int accao; - protected final HashMap idsObjectos; - - /** Creates a new instance of ProcessoEvent */ - public ProcessoEvent( Object source, int accao, HashMap idsObjectos ) - { - this.source = source; - this.accao = accao; - this.idsObjectos = idsObjectos; - } - - public Object getSource() - { - return source; - } - - public int getAccao() - { - return accao; - } - - public Integer getObjecto( Integer tipo ) - { - return idsObjectos.get( tipo ); - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoListener.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoListener.java deleted file mode 100644 index db1d821a..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoListener.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * ProcessoListener.java - * - * Created on 25 de Abril de 2007, 10:55 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo; - -/** - * - * @author Frederico - */ -public interface ProcessoListener -{ - public void processoStateChanged( ProcessoEvent e ); -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoPanel.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoPanel.java deleted file mode 100644 index 8da79937..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoPanel.java +++ /dev/null @@ -1,415 +0,0 @@ -/* - * ProcessoPanel.java - * - * Created on March 21, 2007, 9:11 AM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo; - -import com.evolute.utils.dataui.ControllableComponent; -import com.evolute.utils.images.ImageIconLoader; -import com.evolute.utils.ui.DialogException; -import info.clearthought.layout.TableLayout; -import info.clearthought.layout.TableLayoutConstraints; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.text.DateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Locale; -import java.util.Vector; -import javax.swing.*; -import siprp.ficha.FichaWindow; -import siprp.ficha.SaveExameListener; -import siprp.medicina.MedicinaConstants; -import siprp.medicina.MedicinaDataProvider; -import siprp.medicina.processo.data.TrabalhadoresProcessoData; - -/** - * - * @author fpalma - */ -public class ProcessoPanel extends JPanel - implements ActionListener, ControllableComponent, - MedicinaConstants, ProcessoConstants, SaveExameListener -{ - private static final String ECDS_ICON_PATH = "siprp/medicina/processo/icons/ecds.png"; - private static final String CONSULTA_ICON_PATH = "siprp/medicina/processo/icons/consulta.png"; - private static final String FICHA_APTIDAO_ICON_PATH = "siprp/medicina/processo/icons/fichaaptidao.png"; - private static final String FECHAR_ICON_PATH = "siprp/medicina/processo/icons/lock.png"; - - private static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) ); - - private JTextField estadoText; - private JTextField inicioText; - private JTextField fimText; - private JButton motivoButton; - private JButton novoECDButton; - private JButton novaConsultaButton; - private JButton emitirFAButton; - private JButton fecharButton; - - protected JFrame owner; - - private final Vector PROCESSO_LISTENERS = new Vector(); - - private ProcessoDataProvider provider; - - private Integer trabalhadorID = null; - private TrabalhadoresProcessoData processo; - - /** Creates a new instance of ProcessoPanel */ - public ProcessoPanel( JFrame owner ) - throws Exception - { - this.owner = owner; - provider = ProcessoDataProvider.getProvider(); - setupComponents(); - enableButtons(); - } - - - private void setupComponents() - { - motivoButton = new JButton( "Motivo" ); - motivoButton.addActionListener( this ); - JLabel estadoLabel = new JLabel( "Estado" ); - estadoText = new JTextField(); - estadoText.setPreferredSize( new Dimension( 120, 20 ) ); - estadoText.setEditable( false ); - JLabel inicioLabel = new JLabel( "In\u00edcio" ); - inicioText = new JTextField(); - inicioText.setPreferredSize( new Dimension( 120, 20 ) ); - inicioText.setEditable( false ); - JLabel fimLabel = new JLabel( "Fim" ); - fimText = new JTextField(); - fimText.setPreferredSize( new Dimension( 120, 20 ) ); - fimText.setEditable( false ); - novoECDButton = new JButton( "Marcar ECDs" ); - novoECDButton.setIcon( getIcon( ECDS_ICON_PATH ) ); - novoECDButton.addActionListener( this ); - novaConsultaButton = new JButton( "Marcar Consulta" ); - novaConsultaButton.setIcon( getIcon( CONSULTA_ICON_PATH ) ); - novaConsultaButton.addActionListener( this ); - emitirFAButton = new JButton( "Ficha de Aptid\u00e3o" ); - emitirFAButton.setIcon( getIcon( FICHA_APTIDAO_ICON_PATH ) ); - emitirFAButton.addActionListener( this ); - fecharButton = new JButton( "Fechar Processo" ); - fecharButton.setIcon( getIcon( FECHAR_ICON_PATH ) ); - fecharButton.addActionListener( this ); - JPanel buttonPanel = new JPanel(); - - double cols[] = - new double[]{ TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL }; - double rows[] = - new double[]{ TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, - TableLayout.PREFERRED, TableLayout.FILL }; - - TableLayout tableLayout = new TableLayout( cols, rows ); - setLayout( tableLayout ); - - add( motivoButton, new TableLayoutConstraints( 0, 0, 2, 0 ) ); - add( estadoLabel, new TableLayoutConstraints( 0, 1 ) ); - add( estadoText, new TableLayoutConstraints( 1, 1 ) ); - add( inicioLabel, new TableLayoutConstraints( 0, 2 ) ); - add( inicioText, new TableLayoutConstraints( 1, 2 ) ); - add( fimLabel, new TableLayoutConstraints( 0, 3 ) ); - add( fimText, new TableLayoutConstraints( 1, 3 ) ); - add( buttonPanel, new TableLayoutConstraints( 2, 1, 2, 3 ) ); - - buttonPanel.setLayout( new GridLayout( 2, 2 ) ); - buttonPanel.add( novoECDButton ); - buttonPanel.add( novaConsultaButton ); - buttonPanel.add( emitirFAButton ); - buttonPanel.add( fecharButton ); - } - - public void actionPerformed(ActionEvent e) - { - Object source = e.getSource(); - if( source.equals( motivoButton ) ) - { - escolherMotivo(); - } - else if( source.equals( novoECDButton ) ) - { - novoECD(); - } - else if( source.equals( novaConsultaButton ) ) - { - novaConsulta(); - } - else if( source.equals( emitirFAButton ) ) - { - emitirFA(); - } - else if( source.equals( fecharButton ) ) - { - fecharProcesso(); - } - } - - protected boolean gravarProcesso() - { - if( processo.get( TrabalhadoresProcessoData.ESTADO ) == null ) - { - processo.set( TrabalhadoresProcessoData.ESTADO, PROCESSO_ABERTO_CODE ); - processo.set( TrabalhadoresProcessoData.DATA_INICIO, new Date() ); - } - try - { - provider.saveProcesso( processo ); - - return true; - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a gravar processo", true ); - return false; - } - } - - protected void escolherMotivo() - { - EscolherMotivoDialog dialog = new EscolherMotivoDialog( owner ); - dialog.setVisible( true ); - Integer motivo[] = dialog.getMotivo(); - if( motivo != null && motivo[ 0 ] != null ) - { - processo.set( TrabalhadoresProcessoData.MOTIVO, motivo[ 0 ] ); - processo.set( TrabalhadoresProcessoData.SUB_MOTIVO, motivo[ 1 ] ); - if( gravarProcesso() ) - { - reload(); - HashMap ids = new HashMap(); - ids.put( ProcessoEvent.TIPO_PROCESSO, ( Integer ) processo.get( TrabalhadoresProcessoData.ID ) ); - ProcessoEvent event = new ProcessoEvent( this, ProcessoEvent.ACCAO_ESCOLHER_MOTIVO, ids ); - for( int n = 0; n < PROCESSO_LISTENERS.size(); n++ ) - { - PROCESSO_LISTENERS.get( n ).processoStateChanged( event ); - } - } - } - } - - protected void novoECD() - { - } - - protected void novaConsulta() - { - notifyListeners( ProcessoEvent.ACCAO_MARCAR_CONSULTA ); - } - - protected void emitirFA() - { - if( trabalhadorID != null ) - { - try - { - FichaWindow.getWindow().editTrabalhador( trabalhadorID, this ); - } - catch( Exception ex ) - { - DialogException.showException( ex ); - } - } - } - - protected void fecharProcesso() - { - String options[] = new String[]{ "N\u00e3o", "Sim" }; - int option = JOptionPane.showOptionDialog( owner, - "Tem a certeza que quer fechar o processo sem Ficha de Aptid\u00e3o?", - "Fechar", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, - getIcon( FECHAR_ICON_PATH ), options, options[ 0 ] ); - if( option == 1 ) - { - processo.set( TrabalhadoresProcessoData.ESTADO, PROCESSO_FECHADO_CODE ); - processo.set( TrabalhadoresProcessoData.DATA_FIM, new Date() ); - if( gravarProcesso() ) - { - enableButtons(); - notifyListeners( ProcessoEvent.ACCAO_FECHAR ); - reload(); - } - } - } - - public void clear() - { - processo = null; - estadoText.setText( "" ); - inicioText.setText( "" ); - fimText.setText( "" ); - motivoButton.setText( "Motivo" ); - enableButtons(); - } - - protected void enableButtons() - { - String estado = null; - Integer motivo = null; - boolean consultasPorRealizar = false; - boolean ecdsPorRealizar = false; - if( processo != null ) - { - Integer id = ( Integer ) processo.get( TrabalhadoresProcessoData.ID ); - estado = ( String ) processo.get( TrabalhadoresProcessoData.ESTADO ); - motivo = ( Integer ) processo.get( TrabalhadoresProcessoData.MOTIVO ); - try - { - if( id != null ) - { - consultasPorRealizar = provider.getProcessoTemConsultasPorRealizar( id ); - ecdsPorRealizar = provider.getProcessoTemECDsPorRealizar( id ); - } - } - catch( Exception ex ) - { - ex.printStackTrace(); - } - } -// novoECDButton.setEnabled( processo != null && motivo != null ); - novoECDButton.setEnabled( false ); - novaConsultaButton.setEnabled( processo != null && motivo != null && !consultasPorRealizar ); - emitirFAButton.setEnabled( processo != null && motivo != null ); - fecharButton.setEnabled( processo != null && motivo != null && PROCESSO_ABERTO_CODE.equals( estado ) ); - motivoButton.setEnabled( processo != null ); - } - - public void addProcessoListener( ProcessoListener listener ) - { - PROCESSO_LISTENERS.add( listener ); - } - - public void removeProcessoListener( ProcessoListener listener ) - { - PROCESSO_LISTENERS.remove( listener ); - } - - public Icon getIcon( String path ) - { - try - { - return ImageIconLoader.loadImageIcon( getClass(), path ); - } - catch( Exception ex ) - { - ex.printStackTrace(); - return null; - } - } - - public Object save() - { - return null; - } - - public void enableComponents( boolean enable ) - { - - } - - public void fill( Object value ) - { - clear(); - if( trabalhadorID == null ) - { - return; - } - if( value != null ) - { - try - { - processo = provider.getProcessoByID( ( Integer ) value ); - if( processo == null ) - { - processo = new TrabalhadoresProcessoData(); - processo.set( TrabalhadoresProcessoData.TRABALHADOR_ID, trabalhadorID ); - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar dados do processo", true ); - } - } - reload(); - } - - public void reload() - { - enableButtons(); - if( processo != null ) - { - String estado = null; - Date dataInicio = ( Date ) processo.get( TrabalhadoresProcessoData.DATA_INICIO ); - if( dataInicio != null ) - { - inicioText.setText( D_F.format( dataInicio ) ); - } - Date dataFim = ( Date ) processo.get( TrabalhadoresProcessoData.DATA_FIM ); - if( dataFim != null ) - { - fimText.setText( D_F.format( dataFim ) ); - } - estado = ( String ) processo.get( TrabalhadoresProcessoData.ESTADO ); - if( estado == null ) - { - estadoText.setText( ProcessoDataProvider.PROCESSO_POR_ABRIR_DESCRIPTION ); - } - else - { - estadoText.setText( ProcessoDataProvider.ESTADO_PROCESSO_BY_CODE.get( estado ) ); - } - Integer motivo = ( Integer ) processo.get( TrabalhadoresProcessoData.MOTIVO ); - Integer subMotivo = ( Integer ) processo.get( TrabalhadoresProcessoData.SUB_MOTIVO ); - String motivoStr = "Motivo"; - if( motivo != null ) - { - motivoStr = MedicinaDataProvider.MOTIVOS_BY_ID.get( motivo ); - if( subMotivo != null ) - { - motivoStr += " > " + MedicinaDataProvider.SUB_MOTIVOS_BY_ID.get( subMotivo ); - } - } - motivoButton.setText( motivoStr ); - } - } - - public void setTrabalhadorID( Integer trabalhadorID ) - { - this.trabalhadorID = trabalhadorID; - } - - public void exameSaved( Integer trabalhadorID, Integer exameID ) - { - if( trabalhadorID.equals( this.trabalhadorID ) ) - { - processo.set( TrabalhadoresProcessoData.ESTADO, PROCESSO_FECHADO_CODE ); - processo.set( TrabalhadoresProcessoData.DATA_FIM, new Date() ); - if( gravarProcesso() ) - { - enableButtons(); - notifyListeners( ProcessoEvent.ACCAO_EMITIR_FA ); - reload(); - } - System.out.println( "NOTIFIED EXAME: " + exameID ); - } - } - - protected void notifyListeners( int accao ) - { - HashMap ids = new HashMap(); - ids.put( ProcessoEvent.TIPO_PROCESSO, ( Integer ) processo.get( TrabalhadoresProcessoData.ID ) ); - ProcessoEvent event = new ProcessoEvent( this, accao, ids ); - for( int n = 0; n < PROCESSO_LISTENERS.size(); n++ ) - { - PROCESSO_LISTENERS.get( n ).processoStateChanged( event ); - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoUpperPanel.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoUpperPanel.java deleted file mode 100644 index 1c08a592..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoUpperPanel.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * ProcessoUpperPanel.java - * - * Created on February 1, 2006, 6:48 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo; - -import java.awt.*; -import javax.swing.*; -import javax.swing.event.*; -import java.util.*; -import com.evolute.utils.dataui.*; -import com.evolute.utils.tables.*; -import com.evolute.utils.ui.*; -import siprp.medicina.MedicinaDataProvider; - -/** - * - * @author fpalma - */ -public class ProcessoUpperPanel extends JPanel - implements ListSelectionListener, ControllableComponent -{ - protected BaseTable empresasTable; - protected VectorTableModel empresasModel; - protected BaseTable estabelecimentosTable; - protected VectorTableModel estabelecimentosModel; - protected BaseTable trabalhadoresTable; - protected VectorTableModel trabalhadoresModel; - - protected MedicinaDataProvider provider; - - protected final Vector listeners; - - protected boolean editing = false; - - /** - * Creates a new instance of ProcessoUpperPanel - */ - public ProcessoUpperPanel() - throws Exception - { - provider = ( MedicinaDataProvider ) MedicinaDataProvider.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 ); - trabalhadoresModel = new VectorTableModel( new String[]{ "trabalhadores" } ); - trabalhadoresTable = new BaseTable( trabalhadoresModel ); - trabalhadoresTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - trabalhadoresTable.setNonResizableNorReordable(); - JScrollPane trabalhadoresScroll = - new JScrollPane( trabalhadoresTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - trabalhadoresTable.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 = 1; - constraints.weightx = 0.3; - constraints.weighty = 1; - - gridbag.setConstraints( empresasScroll, constraints ); - - gridbag.setConstraints( estabelecimentosScroll, constraints ); - - constraints.weightx = 0.4; - constraints.gridheight = GridBagConstraints.REMAINDER; - gridbag.setConstraints( trabalhadoresScroll, constraints ); - - add( empresasScroll ); - add( estabelecimentosScroll ); - add( trabalhadoresScroll ); - - 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() ) ) - { - carregarTrabalhadores(); - } - else if( source.equals( trabalhadoresTable.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 carregarTrabalhadores() - { - trabalhadoresTable.clearSelection(); - int selected = estabelecimentosTable.getSelectedRow(); - trabalhadoresModel.clearAll(); - if( selected > -1 ) - { - try - { - Integer estabelecimentoID = ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( selected ) ).getID(); - ColumnizedMappable trabalhadores[] = provider.getAllTrabalhadoresForEstabelecimento( estabelecimentoID ); - Vector values = trabalhadoresModel.getValues(); - values.addAll( Arrays.asList( trabalhadores ) ); - trabalhadoresModel.setValues( values ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar trabalhadores.", true ); - trabalhadoresModel.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; - } - } - - for( int n = 0; n < trabalhadoresTable.getRowCount(); n++ ) - { - if( ( ( ColumnizedMappable ) trabalhadoresModel.getRowAt( n ) ).getID().equals( ids[ 2 ] ) ) - { - trabalhadoresTable.setRowSelectionInterval( n, n ); - break; - } - } - } - - public Object save() - { - int empresaSelected = empresasTable.getSelectedRow(); - int estabelecimentoSelected = estabelecimentosTable.getSelectedRow(); - int trabalhadorSelected = trabalhadoresTable.getSelectedRow(); - return new Integer[]{ - empresaSelected == -1 ? null : ( ( ColumnizedMappable ) empresasModel.getRowAt( empresaSelected ) ).getID(), - estabelecimentoSelected == -1 ? null : ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( estabelecimentoSelected ) ).getID(), - trabalhadorSelected == -1 ? null : ( ( ColumnizedMappable ) trabalhadoresModel.getRowAt( trabalhadorSelected ) ).getID() - }; - } - - public void setEnabled( boolean enable ) - { - editing = !enable; - empresasTable.setEnabled( enable ); - estabelecimentosTable.setEnabled( enable ); - trabalhadoresTable.setEnabled( enable ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoWindow.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoWindow.java deleted file mode 100644 index 28f8a52f..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/ProcessoWindow.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * ProcessoWindow.java - * - * Created on March 21, 2007, 9:06 AM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo; - -import com.evolute.utils.tracker.TrackableWindow; -import info.clearthought.layout.TableLayout; -import info.clearthought.layout.TableLayoutConstraints; -import java.awt.Dimension; -import javax.swing.BorderFactory; -import javax.swing.JFrame; -import javax.swing.SwingUtilities; -import siprp.medicina.processo.detalhes.DetalhesProcessoPanel; -import siprp.medicina.processo.estrutura.EstruturaProcessoPanel; - -/** - * - * @author fpalma - */ -public class ProcessoWindow extends JFrame - implements TrackableWindow -{ - public static final String TITLE = "Processos de trabalhadores"; - - private ProcessoUpperPanel upperPanel; - private EstruturaProcessoPanel estruturaPanel; - private ProcessoPanel processoPanel; - private DetalhesProcessoPanel detalhesPanel; - - /** Creates a new instance of ProcessoWindow */ - public ProcessoWindow() - throws Exception - { - setupComponents(); - } - - private void setupComponents() - throws Exception - { - setSize( 1024, 700 ); - setTitle( TITLE ); - - upperPanel = new ProcessoUpperPanel(); - upperPanel.setPreferredSize( new Dimension( 1024, 200 ) ); - estruturaPanel = new EstruturaProcessoPanel(); - processoPanel = new ProcessoPanel( this ); - processoPanel.setBorder( BorderFactory.createEtchedBorder() ); - detalhesPanel = new DetalhesProcessoPanel( this ); - detalhesPanel.setBorder( BorderFactory.createEtchedBorder() ); - double cols[] = - new double[]{ TableLayout.FILL, TableLayout.PREFERRED }; - double rows[] = - new double[]{ TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL }; - - TableLayout tableLayout = new TableLayout( cols, rows ); - setLayout( tableLayout ); - - add( upperPanel, new TableLayoutConstraints( 0, 0, 1, 0 ) ); - add( estruturaPanel, new TableLayoutConstraints( 0, 1, 0, 2 ) ); - add( processoPanel, new TableLayoutConstraints( 1, 1 ) ); - add( detalhesPanel, new TableLayoutConstraints( 1, 2 ) ); - - new ProcessoController( upperPanel, estruturaPanel, processoPanel, detalhesPanel ); - } - - public void refresh() - { - } - - public void open() - { - setVisible( true ); - } - - public void close() - { - SwingUtilities.invokeLater( new Runnable() { - public void run() - { - setVisible( false ); - dispose(); - } - } ); - } - - public boolean closeIfPossible() - { - close(); - return true; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultas.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultas.java deleted file mode 100644 index ac08da85..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultas.java +++ /dev/null @@ -1,135 +0,0 @@ -/* -* TrabalhadoresConsultas.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.util.Date; -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresConsultas implements JDOInnerObject -{ - private Integer id; - private Integer trabalhador_id; - private Date data; - private Integer estado; - private Integer prestador_id; - private Integer processo_id; - - public TrabalhadoresConsultas() - { - } - - public Object getField( String fieldName ) - { - if( fieldName == TrabalhadoresConsultasData.ID ) - { - return id; - } - else if( fieldName == TrabalhadoresConsultasData.TRABALHADOR_ID ) - { - return trabalhador_id; - } - else if( fieldName == TrabalhadoresConsultasData.DATA ) - { - return data; - } - else if( fieldName == TrabalhadoresConsultasData.ESTADO ) - { - return estado; - } - else if( fieldName == TrabalhadoresConsultasData.PRESTADOR_ID ) - { - return prestador_id; - } - else if( fieldName == TrabalhadoresConsultasData.PROCESSO_ID ) - { - return processo_id; - } - else if( fieldName.equals( TrabalhadoresConsultasData.ID ) ) - { - return id; - } - else if( fieldName.equals( TrabalhadoresConsultasData.TRABALHADOR_ID ) ) - { - return trabalhador_id; - } - else if( fieldName.equals( TrabalhadoresConsultasData.DATA ) ) - { - return data; - } - else if( fieldName.equals( TrabalhadoresConsultasData.ESTADO ) ) - { - return estado; - } - else if( fieldName.equals( TrabalhadoresConsultasData.PRESTADOR_ID ) ) - { - return prestador_id; - } - else if( fieldName.equals( TrabalhadoresConsultasData.PROCESSO_ID ) ) - { - return processo_id; - } - return null; - } - - public void setField( String fieldName, Object value ) - { - if( fieldName == TrabalhadoresConsultasData.ID ) - { - id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresConsultasData.TRABALHADOR_ID ) - { - trabalhador_id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresConsultasData.DATA ) - { - data = ( Date ) value; - } - else if( fieldName == TrabalhadoresConsultasData.ESTADO ) - { - estado = ( Integer ) value; - } - else if( fieldName == TrabalhadoresConsultasData.PRESTADOR_ID ) - { - prestador_id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresConsultasData.PROCESSO_ID ) - { - processo_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasData.ID ) ) - { - id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasData.TRABALHADOR_ID ) ) - { - trabalhador_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasData.DATA ) ) - { - data = ( Date ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasData.ESTADO ) ) - { - estado = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasData.PRESTADOR_ID ) ) - { - prestador_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasData.PROCESSO_ID ) ) - { - processo_id = ( Integer ) value; - } - } - - public Class getOuterClass() - { - return TrabalhadoresConsultasData.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasData.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasData.java deleted file mode 100644 index 5b695370..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasData.java +++ /dev/null @@ -1,62 +0,0 @@ -/* -* TrabalhadoresConsultasData.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.util.HashMap; -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresConsultasData extends JDOObject -{ - public static final String ID = "id"; - public static final String TRABALHADOR_ID = "trabalhador_id"; - public static final String DATA = "data"; - public static final String ESTADO = "estado"; - public static final String PRESTADOR_ID = "prestador_id"; - public static final String PROCESSO_ID = "processo_id"; - - public static final String FIELD_NAMES[] = new String[]{ - TRABALHADOR_ID, DATA, ESTADO, PRESTADOR_ID, PROCESSO_ID, }; - - - protected static final String ALL_FIELD_NAMES[] = new String[]{ - ID, TRABALHADOR_ID, DATA, ESTADO, PRESTADOR_ID, PROCESSO_ID, }; - - private HashMap dataHash; - - public TrabalhadoresConsultasData() - { - 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 TrabalhadoresConsultas.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatas.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatas.java deleted file mode 100644 index 7bdd5e3e..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatas.java +++ /dev/null @@ -1,101 +0,0 @@ -/* -* TrabalhadoresConsultasDatas.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.util.Date; -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresConsultasDatas implements JDOInnerObject -{ - private Integer id; - private Date data; - private Integer trabalhadores_consultas_id; - private Integer estado; - - public TrabalhadoresConsultasDatas() - { - } - - public Object getField( String fieldName ) - { - if( fieldName == TrabalhadoresConsultasDatasData.ID ) - { - return id; - } - else if( fieldName == TrabalhadoresConsultasDatasData.DATA ) - { - return data; - } - else if( fieldName == TrabalhadoresConsultasDatasData.TRABALHADORES_CONSULTAS_ID ) - { - return trabalhadores_consultas_id; - } - else if( fieldName == TrabalhadoresConsultasDatasData.ESTADO ) - { - return estado; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasData.ID ) ) - { - return id; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasData.DATA ) ) - { - return data; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasData.TRABALHADORES_CONSULTAS_ID ) ) - { - return trabalhadores_consultas_id; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasData.ESTADO ) ) - { - return estado; - } - return null; - } - - public void setField( String fieldName, Object value ) - { - if( fieldName == TrabalhadoresConsultasDatasData.ID ) - { - id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresConsultasDatasData.DATA ) - { - data = ( Date ) value; - } - else if( fieldName == TrabalhadoresConsultasDatasData.TRABALHADORES_CONSULTAS_ID ) - { - trabalhadores_consultas_id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresConsultasDatasData.ESTADO ) - { - estado = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasData.ID ) ) - { - id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasData.DATA ) ) - { - data = ( Date ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasData.TRABALHADORES_CONSULTAS_ID ) ) - { - trabalhadores_consultas_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasData.ESTADO ) ) - { - estado = ( Integer ) value; - } - } - - public Class getOuterClass() - { - return TrabalhadoresConsultasDatasData.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasData.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasData.java deleted file mode 100644 index c70731d7..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasData.java +++ /dev/null @@ -1,60 +0,0 @@ -/* -* TrabalhadoresConsultasDatasData.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.util.HashMap; -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresConsultasDatasData extends JDOObject -{ - public static final String ID = "id"; - public static final String DATA = "data"; - public static final String TRABALHADORES_CONSULTAS_ID = "trabalhadores_consultas_id"; - public static final String ESTADO = "estado"; - - public static final String FIELD_NAMES[] = new String[]{ - DATA, TRABALHADORES_CONSULTAS_ID, ESTADO, }; - - - protected static final String ALL_FIELD_NAMES[] = new String[]{ - ID, DATA, TRABALHADORES_CONSULTAS_ID, ESTADO, }; - - private HashMap dataHash; - - public TrabalhadoresConsultasDatasData() - { - 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 TrabalhadoresConsultasDatas.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasEmails.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasEmails.java deleted file mode 100644 index d510eb27..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasEmails.java +++ /dev/null @@ -1,135 +0,0 @@ -/* -* TrabalhadoresConsultasDatasEmails.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.util.Date; -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresConsultasDatasEmails implements JDOInnerObject -{ - private Integer id; - private Integer trabalhadores_consultas_datas_id; - private String destination; - private Date data; - private String subject; - private String body; - - public TrabalhadoresConsultasDatasEmails() - { - } - - public Object getField( String fieldName ) - { - if( fieldName == TrabalhadoresConsultasDatasEmailsData.ID ) - { - return id; - } - else if( fieldName == TrabalhadoresConsultasDatasEmailsData.TRABALHADORES_CONSULTAS_DATAS_ID ) - { - return trabalhadores_consultas_datas_id; - } - else if( fieldName == TrabalhadoresConsultasDatasEmailsData.DESTINATION ) - { - return destination; - } - else if( fieldName == TrabalhadoresConsultasDatasEmailsData.DATA ) - { - return data; - } - else if( fieldName == TrabalhadoresConsultasDatasEmailsData.SUBJECT ) - { - return subject; - } - else if( fieldName == TrabalhadoresConsultasDatasEmailsData.BODY ) - { - return body; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasEmailsData.ID ) ) - { - return id; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasEmailsData.TRABALHADORES_CONSULTAS_DATAS_ID ) ) - { - return trabalhadores_consultas_datas_id; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasEmailsData.DESTINATION ) ) - { - return destination; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasEmailsData.DATA ) ) - { - return data; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasEmailsData.SUBJECT ) ) - { - return subject; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasEmailsData.BODY ) ) - { - return body; - } - return null; - } - - public void setField( String fieldName, Object value ) - { - if( fieldName == TrabalhadoresConsultasDatasEmailsData.ID ) - { - id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresConsultasDatasEmailsData.TRABALHADORES_CONSULTAS_DATAS_ID ) - { - trabalhadores_consultas_datas_id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresConsultasDatasEmailsData.DESTINATION ) - { - destination = ( String ) value; - } - else if( fieldName == TrabalhadoresConsultasDatasEmailsData.DATA ) - { - data = ( Date ) value; - } - else if( fieldName == TrabalhadoresConsultasDatasEmailsData.SUBJECT ) - { - subject = ( String ) value; - } - else if( fieldName == TrabalhadoresConsultasDatasEmailsData.BODY ) - { - body = ( String ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasEmailsData.ID ) ) - { - id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasEmailsData.TRABALHADORES_CONSULTAS_DATAS_ID ) ) - { - trabalhadores_consultas_datas_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasEmailsData.DESTINATION ) ) - { - destination = ( String ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasEmailsData.DATA ) ) - { - data = ( Date ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasEmailsData.SUBJECT ) ) - { - subject = ( String ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasEmailsData.BODY ) ) - { - body = ( String ) value; - } - } - - public Class getOuterClass() - { - return TrabalhadoresConsultasDatasEmailsData.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasEmailsData.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasEmailsData.java deleted file mode 100644 index 5bd509c2..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasEmailsData.java +++ /dev/null @@ -1,62 +0,0 @@ -/* -* TrabalhadoresConsultasDatasEmailsData.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.util.HashMap; -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresConsultasDatasEmailsData extends JDOObject -{ - public static final String ID = "id"; - public static final String TRABALHADORES_CONSULTAS_DATAS_ID = "trabalhadores_consultas_datas_id"; - public static final String DESTINATION = "destination"; - public static final String DATA = "data"; - public static final String SUBJECT = "subject"; - public static final String BODY = "body"; - - public static final String FIELD_NAMES[] = new String[]{ - TRABALHADORES_CONSULTAS_DATAS_ID, DESTINATION, DATA, SUBJECT, BODY, }; - - - protected static final String ALL_FIELD_NAMES[] = new String[]{ - ID, TRABALHADORES_CONSULTAS_DATAS_ID, DESTINATION, DATA, SUBJECT, BODY, }; - - private HashMap dataHash; - - public TrabalhadoresConsultasDatasEmailsData() - { - 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 TrabalhadoresConsultasDatasEmails.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasEmailsID.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasEmailsID.java deleted file mode 100644 index 97f99787..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasEmailsID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* TrabalhadoresConsultasDatasEmailsID.java -* -* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.io.*; - -import com.evolute.utils.jdo.jpox.*; - -public final class TrabalhadoresConsultasDatasEmailsID extends IntegerID - implements Serializable -{ - public TrabalhadoresConsultasDatasEmailsID() - { - } - - public TrabalhadoresConsultasDatasEmailsID( String str ) - { - super( str ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasID.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasID.java deleted file mode 100644 index 19881a66..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* TrabalhadoresConsultasDatasID.java -* -* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.io.*; - -import com.evolute.utils.jdo.jpox.*; - -public final class TrabalhadoresConsultasDatasID extends IntegerID - implements Serializable -{ - public TrabalhadoresConsultasDatasID() - { - } - - public TrabalhadoresConsultasDatasID( String str ) - { - super( str ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasObservacoes.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasObservacoes.java deleted file mode 100644 index 25cc7125..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasObservacoes.java +++ /dev/null @@ -1,83 +0,0 @@ -/* -* TrabalhadoresConsultasDatasObservacoes.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresConsultasDatasObservacoes implements JDOInnerObject -{ - private Integer id; - private Integer trabalhadores_consultas_datas_id; - private String observacao; - - public TrabalhadoresConsultasDatasObservacoes() - { - } - - public Object getField( String fieldName ) - { - if( fieldName == TrabalhadoresConsultasDatasObservacoesData.ID ) - { - return id; - } - else if( fieldName == TrabalhadoresConsultasDatasObservacoesData.TRABALHADORES_CONSULTAS_DATAS_ID ) - { - return trabalhadores_consultas_datas_id; - } - else if( fieldName == TrabalhadoresConsultasDatasObservacoesData.OBSERVACAO ) - { - return observacao; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasObservacoesData.ID ) ) - { - return id; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasObservacoesData.TRABALHADORES_CONSULTAS_DATAS_ID ) ) - { - return trabalhadores_consultas_datas_id; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasObservacoesData.OBSERVACAO ) ) - { - return observacao; - } - return null; - } - - public void setField( String fieldName, Object value ) - { - if( fieldName == TrabalhadoresConsultasDatasObservacoesData.ID ) - { - id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresConsultasDatasObservacoesData.TRABALHADORES_CONSULTAS_DATAS_ID ) - { - trabalhadores_consultas_datas_id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresConsultasDatasObservacoesData.OBSERVACAO ) - { - observacao = ( String ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasObservacoesData.ID ) ) - { - id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasObservacoesData.TRABALHADORES_CONSULTAS_DATAS_ID ) ) - { - trabalhadores_consultas_datas_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresConsultasDatasObservacoesData.OBSERVACAO ) ) - { - observacao = ( String ) value; - } - } - - public Class getOuterClass() - { - return TrabalhadoresConsultasDatasObservacoesData.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasObservacoesData.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasObservacoesData.java deleted file mode 100644 index 5326c26a..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasObservacoesData.java +++ /dev/null @@ -1,59 +0,0 @@ -/* -* TrabalhadoresConsultasDatasObservacoesData.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.util.HashMap; -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresConsultasDatasObservacoesData extends JDOObject -{ - public static final String ID = "id"; - public static final String TRABALHADORES_CONSULTAS_DATAS_ID = "trabalhadores_consultas_datas_id"; - public static final String OBSERVACAO = "observacao"; - - public static final String FIELD_NAMES[] = new String[]{ - TRABALHADORES_CONSULTAS_DATAS_ID, OBSERVACAO, }; - - - protected static final String ALL_FIELD_NAMES[] = new String[]{ - ID, TRABALHADORES_CONSULTAS_DATAS_ID, OBSERVACAO, }; - - private HashMap dataHash; - - public TrabalhadoresConsultasDatasObservacoesData() - { - 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 TrabalhadoresConsultasDatasObservacoes.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasObservacoesID.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasObservacoesID.java deleted file mode 100644 index 038405bd..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasDatasObservacoesID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* TrabalhadoresConsultasDatasObservacoesID.java -* -* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.io.*; - -import com.evolute.utils.jdo.jpox.*; - -public final class TrabalhadoresConsultasDatasObservacoesID extends IntegerID - implements Serializable -{ - public TrabalhadoresConsultasDatasObservacoesID() - { - } - - public TrabalhadoresConsultasDatasObservacoesID( String str ) - { - super( str ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasID.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasID.java deleted file mode 100644 index 9aa31d50..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresConsultasID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* TrabalhadoresConsultasID.java -* -* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.io.*; - -import com.evolute.utils.jdo.jpox.*; - -public final class TrabalhadoresConsultasID extends IntegerID - implements Serializable -{ - public TrabalhadoresConsultasID() - { - } - - public TrabalhadoresConsultasID( String str ) - { - super( str ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcd.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcd.java deleted file mode 100644 index d20de925..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcd.java +++ /dev/null @@ -1,151 +0,0 @@ -/* -* TrabalhadoresEcd.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresEcd implements JDOInnerObject -{ - private Integer id; - private Integer ecd_id; - private Integer ecd_oficial_id; - private Integer prestador_id; - private Integer estado; - private Integer trabalhadores_ecds_id; - private Integer trabalhadores_ecds_datas_id; - - public TrabalhadoresEcd() - { - } - - public Object getField( String fieldName ) - { - if( fieldName == TrabalhadoresEcdData.ID ) - { - return id; - } - else if( fieldName == TrabalhadoresEcdData.ECD_ID ) - { - return ecd_id; - } - else if( fieldName == TrabalhadoresEcdData.ECD_OFICIAL_ID ) - { - return ecd_oficial_id; - } - else if( fieldName == TrabalhadoresEcdData.PRESTADOR_ID ) - { - return prestador_id; - } - else if( fieldName == TrabalhadoresEcdData.ESTADO ) - { - return estado; - } - else if( fieldName == TrabalhadoresEcdData.TRABALHADORES_ECDS_ID ) - { - return trabalhadores_ecds_id; - } - else if( fieldName == TrabalhadoresEcdData.TRABALHADORES_ECDS_DATAS_ID ) - { - return trabalhadores_ecds_datas_id; - } - else if( fieldName.equals( TrabalhadoresEcdData.ID ) ) - { - return id; - } - else if( fieldName.equals( TrabalhadoresEcdData.ECD_ID ) ) - { - return ecd_id; - } - else if( fieldName.equals( TrabalhadoresEcdData.ECD_OFICIAL_ID ) ) - { - return ecd_oficial_id; - } - else if( fieldName.equals( TrabalhadoresEcdData.PRESTADOR_ID ) ) - { - return prestador_id; - } - else if( fieldName.equals( TrabalhadoresEcdData.ESTADO ) ) - { - return estado; - } - else if( fieldName.equals( TrabalhadoresEcdData.TRABALHADORES_ECDS_ID ) ) - { - return trabalhadores_ecds_id; - } - else if( fieldName.equals( TrabalhadoresEcdData.TRABALHADORES_ECDS_DATAS_ID ) ) - { - return trabalhadores_ecds_datas_id; - } - return null; - } - - public void setField( String fieldName, Object value ) - { - if( fieldName == TrabalhadoresEcdData.ID ) - { - id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresEcdData.ECD_ID ) - { - ecd_id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresEcdData.ECD_OFICIAL_ID ) - { - ecd_oficial_id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresEcdData.PRESTADOR_ID ) - { - prestador_id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresEcdData.ESTADO ) - { - estado = ( Integer ) value; - } - else if( fieldName == TrabalhadoresEcdData.TRABALHADORES_ECDS_ID ) - { - trabalhadores_ecds_id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresEcdData.TRABALHADORES_ECDS_DATAS_ID ) - { - trabalhadores_ecds_datas_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresEcdData.ID ) ) - { - id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresEcdData.ECD_ID ) ) - { - ecd_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresEcdData.ECD_OFICIAL_ID ) ) - { - ecd_oficial_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresEcdData.PRESTADOR_ID ) ) - { - prestador_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresEcdData.ESTADO ) ) - { - estado = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresEcdData.TRABALHADORES_ECDS_ID ) ) - { - trabalhadores_ecds_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresEcdData.TRABALHADORES_ECDS_DATAS_ID ) ) - { - trabalhadores_ecds_datas_id = ( Integer ) value; - } - } - - public Class getOuterClass() - { - return TrabalhadoresEcdData.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdData.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdData.java deleted file mode 100644 index 5ad8c4e7..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdData.java +++ /dev/null @@ -1,65 +0,0 @@ -/* -* TrabalhadoresEcdData.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.util.HashMap; -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresEcdData extends JDOObject -{ - public static final String ID = "id"; - public static final String ECD_ID = "ecd_id"; - public static final String ECD_OFICIAL_ID = "ecd_oficial_id"; - public static final String PRESTADOR_ID = "prestador_id"; - public static final String ESTADO = "estado"; - public static final String TRABALHADORES_ECDS_ID = "trabalhadores_ecds_id"; - public static final String TRABALHADORES_ECDS_DATAS_ID = "trabalhadores_ecds_datas_id"; - - public static final String FIELD_NAMES[] = new String[]{ - ECD_ID, ECD_OFICIAL_ID, PRESTADOR_ID, ESTADO, TRABALHADORES_ECDS_ID, - TRABALHADORES_ECDS_DATAS_ID, }; - - - protected static final String ALL_FIELD_NAMES[] = new String[]{ - ID, ECD_ID, ECD_OFICIAL_ID, PRESTADOR_ID, ESTADO, TRABALHADORES_ECDS_ID, - TRABALHADORES_ECDS_DATAS_ID, }; - - private HashMap dataHash; - - public TrabalhadoresEcdData() - { - 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 TrabalhadoresEcd.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdID.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdID.java deleted file mode 100644 index 8d47d9d1..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* TrabalhadoresEcdID.java -* -* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.io.*; - -import com.evolute.utils.jdo.jpox.*; - -public final class TrabalhadoresEcdID extends IntegerID - implements Serializable -{ - public TrabalhadoresEcdID() - { - } - - public TrabalhadoresEcdID( String str ) - { - super( str ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcds.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcds.java deleted file mode 100644 index f741cb74..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcds.java +++ /dev/null @@ -1,118 +0,0 @@ -/* -* TrabalhadoresEcds.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.util.Date; -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresEcds implements JDOInnerObject -{ - private Integer id; - private Integer trabalhador_id; - private Integer estado; - private Date data; - private Integer processo_id; - - public TrabalhadoresEcds() - { - } - - public Object getField( String fieldName ) - { - if( fieldName == TrabalhadoresEcdsData.ID ) - { - return id; - } - else if( fieldName == TrabalhadoresEcdsData.TRABALHADOR_ID ) - { - return trabalhador_id; - } - else if( fieldName == TrabalhadoresEcdsData.ESTADO ) - { - return estado; - } - else if( fieldName == TrabalhadoresEcdsData.DATA ) - { - return data; - } - else if( fieldName == TrabalhadoresEcdsData.PROCESSO_ID ) - { - return processo_id; - } - else if( fieldName.equals( TrabalhadoresEcdsData.ID ) ) - { - return id; - } - else if( fieldName.equals( TrabalhadoresEcdsData.TRABALHADOR_ID ) ) - { - return trabalhador_id; - } - else if( fieldName.equals( TrabalhadoresEcdsData.ESTADO ) ) - { - return estado; - } - else if( fieldName.equals( TrabalhadoresEcdsData.DATA ) ) - { - return data; - } - else if( fieldName.equals( TrabalhadoresEcdsData.PROCESSO_ID ) ) - { - return processo_id; - } - return null; - } - - public void setField( String fieldName, Object value ) - { - if( fieldName == TrabalhadoresEcdsData.ID ) - { - id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresEcdsData.TRABALHADOR_ID ) - { - trabalhador_id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresEcdsData.ESTADO ) - { - estado = ( Integer ) value; - } - else if( fieldName == TrabalhadoresEcdsData.DATA ) - { - data = ( Date ) value; - } - else if( fieldName == TrabalhadoresEcdsData.PROCESSO_ID ) - { - processo_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresEcdsData.ID ) ) - { - id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresEcdsData.TRABALHADOR_ID ) ) - { - trabalhador_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresEcdsData.ESTADO ) ) - { - estado = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresEcdsData.DATA ) ) - { - data = ( Date ) value; - } - else if( fieldName.equals( TrabalhadoresEcdsData.PROCESSO_ID ) ) - { - processo_id = ( Integer ) value; - } - } - - public Class getOuterClass() - { - return TrabalhadoresEcdsData.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsData.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsData.java deleted file mode 100644 index 7460f772..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsData.java +++ /dev/null @@ -1,61 +0,0 @@ -/* -* TrabalhadoresEcdsData.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.util.HashMap; -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresEcdsData extends JDOObject -{ - public static final String ID = "id"; - public static final String TRABALHADOR_ID = "trabalhador_id"; - public static final String ESTADO = "estado"; - public static final String DATA = "data"; - public static final String PROCESSO_ID = "processo_id"; - - public static final String FIELD_NAMES[] = new String[]{ - TRABALHADOR_ID, ESTADO, DATA, PROCESSO_ID, }; - - - protected static final String ALL_FIELD_NAMES[] = new String[]{ - ID, TRABALHADOR_ID, ESTADO, DATA, PROCESSO_ID, }; - - private HashMap dataHash; - - public TrabalhadoresEcdsData() - { - 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 TrabalhadoresEcds.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatas.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatas.java deleted file mode 100644 index 6112c215..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatas.java +++ /dev/null @@ -1,101 +0,0 @@ -/* -* TrabalhadoresEcdsDatas.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.util.Date; -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresEcdsDatas implements JDOInnerObject -{ - private Integer id; - private Integer trabalhadores_ecds_id; - private Date data; - private Integer estado; - - public TrabalhadoresEcdsDatas() - { - } - - public Object getField( String fieldName ) - { - if( fieldName == TrabalhadoresEcdsDatasData.ID ) - { - return id; - } - else if( fieldName == TrabalhadoresEcdsDatasData.TRABALHADORES_ECDS_ID ) - { - return trabalhadores_ecds_id; - } - else if( fieldName == TrabalhadoresEcdsDatasData.DATA ) - { - return data; - } - else if( fieldName == TrabalhadoresEcdsDatasData.ESTADO ) - { - return estado; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasData.ID ) ) - { - return id; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasData.TRABALHADORES_ECDS_ID ) ) - { - return trabalhadores_ecds_id; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasData.DATA ) ) - { - return data; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasData.ESTADO ) ) - { - return estado; - } - return null; - } - - public void setField( String fieldName, Object value ) - { - if( fieldName == TrabalhadoresEcdsDatasData.ID ) - { - id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresEcdsDatasData.TRABALHADORES_ECDS_ID ) - { - trabalhadores_ecds_id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresEcdsDatasData.DATA ) - { - data = ( Date ) value; - } - else if( fieldName == TrabalhadoresEcdsDatasData.ESTADO ) - { - estado = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasData.ID ) ) - { - id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasData.TRABALHADORES_ECDS_ID ) ) - { - trabalhadores_ecds_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasData.DATA ) ) - { - data = ( Date ) value; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasData.ESTADO ) ) - { - estado = ( Integer ) value; - } - } - - public Class getOuterClass() - { - return TrabalhadoresEcdsDatasData.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasData.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasData.java deleted file mode 100644 index 0b0ff21c..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasData.java +++ /dev/null @@ -1,60 +0,0 @@ -/* -* TrabalhadoresEcdsDatasData.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.util.HashMap; -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresEcdsDatasData extends JDOObject -{ - public static final String ID = "id"; - public static final String TRABALHADORES_ECDS_ID = "trabalhadores_ecds_id"; - public static final String DATA = "data"; - public static final String ESTADO = "estado"; - - public static final String FIELD_NAMES[] = new String[]{ - TRABALHADORES_ECDS_ID, DATA, ESTADO, }; - - - protected static final String ALL_FIELD_NAMES[] = new String[]{ - ID, TRABALHADORES_ECDS_ID, DATA, ESTADO, }; - - private HashMap dataHash; - - public TrabalhadoresEcdsDatasData() - { - 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 TrabalhadoresEcdsDatas.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasEmails.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasEmails.java deleted file mode 100644 index 2dae2f2a..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasEmails.java +++ /dev/null @@ -1,135 +0,0 @@ -/* -* TrabalhadoresEcdsDatasEmails.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.util.Date; -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresEcdsDatasEmails implements JDOInnerObject -{ - private Integer id; - private Integer trabalhadores_ecds_datas_id; - private String destination; - private Date data; - private String subject; - private String body; - - public TrabalhadoresEcdsDatasEmails() - { - } - - public Object getField( String fieldName ) - { - if( fieldName == TrabalhadoresEcdsDatasEmailsData.ID ) - { - return id; - } - else if( fieldName == TrabalhadoresEcdsDatasEmailsData.TRABALHADORES_ECDS_DATAS_ID ) - { - return trabalhadores_ecds_datas_id; - } - else if( fieldName == TrabalhadoresEcdsDatasEmailsData.DESTINATION ) - { - return destination; - } - else if( fieldName == TrabalhadoresEcdsDatasEmailsData.DATA ) - { - return data; - } - else if( fieldName == TrabalhadoresEcdsDatasEmailsData.SUBJECT ) - { - return subject; - } - else if( fieldName == TrabalhadoresEcdsDatasEmailsData.BODY ) - { - return body; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasEmailsData.ID ) ) - { - return id; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasEmailsData.TRABALHADORES_ECDS_DATAS_ID ) ) - { - return trabalhadores_ecds_datas_id; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasEmailsData.DESTINATION ) ) - { - return destination; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasEmailsData.DATA ) ) - { - return data; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasEmailsData.SUBJECT ) ) - { - return subject; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasEmailsData.BODY ) ) - { - return body; - } - return null; - } - - public void setField( String fieldName, Object value ) - { - if( fieldName == TrabalhadoresEcdsDatasEmailsData.ID ) - { - id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresEcdsDatasEmailsData.TRABALHADORES_ECDS_DATAS_ID ) - { - trabalhadores_ecds_datas_id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresEcdsDatasEmailsData.DESTINATION ) - { - destination = ( String ) value; - } - else if( fieldName == TrabalhadoresEcdsDatasEmailsData.DATA ) - { - data = ( Date ) value; - } - else if( fieldName == TrabalhadoresEcdsDatasEmailsData.SUBJECT ) - { - subject = ( String ) value; - } - else if( fieldName == TrabalhadoresEcdsDatasEmailsData.BODY ) - { - body = ( String ) value; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasEmailsData.ID ) ) - { - id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasEmailsData.TRABALHADORES_ECDS_DATAS_ID ) ) - { - trabalhadores_ecds_datas_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasEmailsData.DESTINATION ) ) - { - destination = ( String ) value; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasEmailsData.DATA ) ) - { - data = ( Date ) value; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasEmailsData.SUBJECT ) ) - { - subject = ( String ) value; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasEmailsData.BODY ) ) - { - body = ( String ) value; - } - } - - public Class getOuterClass() - { - return TrabalhadoresEcdsDatasEmailsData.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasEmailsData.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasEmailsData.java deleted file mode 100644 index 7a40d563..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasEmailsData.java +++ /dev/null @@ -1,62 +0,0 @@ -/* -* TrabalhadoresEcdsDatasEmailsData.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.util.HashMap; -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresEcdsDatasEmailsData extends JDOObject -{ - public static final String ID = "id"; - public static final String TRABALHADORES_ECDS_DATAS_ID = "trabalhadores_ecds_datas_id"; - public static final String DESTINATION = "destination"; - public static final String DATA = "data"; - public static final String SUBJECT = "subject"; - public static final String BODY = "body"; - - public static final String FIELD_NAMES[] = new String[]{ - TRABALHADORES_ECDS_DATAS_ID, DESTINATION, DATA, SUBJECT, BODY, }; - - - protected static final String ALL_FIELD_NAMES[] = new String[]{ - ID, TRABALHADORES_ECDS_DATAS_ID, DESTINATION, DATA, SUBJECT, BODY, }; - - private HashMap dataHash; - - public TrabalhadoresEcdsDatasEmailsData() - { - 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 TrabalhadoresEcdsDatasEmails.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasEmailsID.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasEmailsID.java deleted file mode 100644 index 65da8c7c..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasEmailsID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* TrabalhadoresEcdsDatasEmailsID.java -* -* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.io.*; - -import com.evolute.utils.jdo.jpox.*; - -public final class TrabalhadoresEcdsDatasEmailsID extends IntegerID - implements Serializable -{ - public TrabalhadoresEcdsDatasEmailsID() - { - } - - public TrabalhadoresEcdsDatasEmailsID( String str ) - { - super( str ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasID.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasID.java deleted file mode 100644 index cee0df85..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* TrabalhadoresEcdsDatasID.java -* -* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.io.*; - -import com.evolute.utils.jdo.jpox.*; - -public final class TrabalhadoresEcdsDatasID extends IntegerID - implements Serializable -{ - public TrabalhadoresEcdsDatasID() - { - } - - public TrabalhadoresEcdsDatasID( String str ) - { - super( str ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasObservacoes.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasObservacoes.java deleted file mode 100644 index 4c18ca74..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasObservacoes.java +++ /dev/null @@ -1,83 +0,0 @@ -/* -* TrabalhadoresEcdsDatasObservacoes.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresEcdsDatasObservacoes implements JDOInnerObject -{ - private Integer id; - private Integer trabalhadores_ecds_datas_id; - private String observacao; - - public TrabalhadoresEcdsDatasObservacoes() - { - } - - public Object getField( String fieldName ) - { - if( fieldName == TrabalhadoresEcdsDatasObservacoesData.ID ) - { - return id; - } - else if( fieldName == TrabalhadoresEcdsDatasObservacoesData.TRABALHADORES_ECDS_DATAS_ID ) - { - return trabalhadores_ecds_datas_id; - } - else if( fieldName == TrabalhadoresEcdsDatasObservacoesData.OBSERVACAO ) - { - return observacao; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasObservacoesData.ID ) ) - { - return id; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasObservacoesData.TRABALHADORES_ECDS_DATAS_ID ) ) - { - return trabalhadores_ecds_datas_id; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasObservacoesData.OBSERVACAO ) ) - { - return observacao; - } - return null; - } - - public void setField( String fieldName, Object value ) - { - if( fieldName == TrabalhadoresEcdsDatasObservacoesData.ID ) - { - id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresEcdsDatasObservacoesData.TRABALHADORES_ECDS_DATAS_ID ) - { - trabalhadores_ecds_datas_id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresEcdsDatasObservacoesData.OBSERVACAO ) - { - observacao = ( String ) value; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasObservacoesData.ID ) ) - { - id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasObservacoesData.TRABALHADORES_ECDS_DATAS_ID ) ) - { - trabalhadores_ecds_datas_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresEcdsDatasObservacoesData.OBSERVACAO ) ) - { - observacao = ( String ) value; - } - } - - public Class getOuterClass() - { - return TrabalhadoresEcdsDatasObservacoesData.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasObservacoesData.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasObservacoesData.java deleted file mode 100644 index ff22c3f3..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasObservacoesData.java +++ /dev/null @@ -1,59 +0,0 @@ -/* -* TrabalhadoresEcdsDatasObservacoesData.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.util.HashMap; -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresEcdsDatasObservacoesData extends JDOObject -{ - public static final String ID = "id"; - public static final String TRABALHADORES_ECDS_DATAS_ID = "trabalhadores_ecds_datas_id"; - public static final String OBSERVACAO = "observacao"; - - public static final String FIELD_NAMES[] = new String[]{ - TRABALHADORES_ECDS_DATAS_ID, OBSERVACAO, }; - - - protected static final String ALL_FIELD_NAMES[] = new String[]{ - ID, TRABALHADORES_ECDS_DATAS_ID, OBSERVACAO, }; - - private HashMap dataHash; - - public TrabalhadoresEcdsDatasObservacoesData() - { - 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 TrabalhadoresEcdsDatasObservacoes.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasObservacoesID.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasObservacoesID.java deleted file mode 100644 index 6c6e46c3..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsDatasObservacoesID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* TrabalhadoresEcdsDatasObservacoesID.java -* -* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.io.*; - -import com.evolute.utils.jdo.jpox.*; - -public final class TrabalhadoresEcdsDatasObservacoesID extends IntegerID - implements Serializable -{ - public TrabalhadoresEcdsDatasObservacoesID() - { - } - - public TrabalhadoresEcdsDatasObservacoesID( String str ) - { - super( str ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsID.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsID.java deleted file mode 100644 index 6f885514..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresEcdsID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* TrabalhadoresEcdsID.java -* -* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.io.*; - -import com.evolute.utils.jdo.jpox.*; - -public final class TrabalhadoresEcdsID extends IntegerID - implements Serializable -{ - public TrabalhadoresEcdsID() - { - } - - public TrabalhadoresEcdsID( String str ) - { - super( str ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresFichasAptidao.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresFichasAptidao.java deleted file mode 100644 index c1cab253..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresFichasAptidao.java +++ /dev/null @@ -1,83 +0,0 @@ -/* -* TrabalhadoresFichasAptidao.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresFichasAptidao implements JDOInnerObject -{ - private Integer id; - private Integer processo_id; - private Integer exame_id; - - public TrabalhadoresFichasAptidao() - { - } - - public Object getField( String fieldName ) - { - if( fieldName == TrabalhadoresFichasAptidaoData.ID ) - { - return id; - } - else if( fieldName == TrabalhadoresFichasAptidaoData.PROCESSO_ID ) - { - return processo_id; - } - else if( fieldName == TrabalhadoresFichasAptidaoData.EXAME_ID ) - { - return exame_id; - } - else if( fieldName.equals( TrabalhadoresFichasAptidaoData.ID ) ) - { - return id; - } - else if( fieldName.equals( TrabalhadoresFichasAptidaoData.PROCESSO_ID ) ) - { - return processo_id; - } - else if( fieldName.equals( TrabalhadoresFichasAptidaoData.EXAME_ID ) ) - { - return exame_id; - } - return null; - } - - public void setField( String fieldName, Object value ) - { - if( fieldName == TrabalhadoresFichasAptidaoData.ID ) - { - id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresFichasAptidaoData.PROCESSO_ID ) - { - processo_id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresFichasAptidaoData.EXAME_ID ) - { - exame_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresFichasAptidaoData.ID ) ) - { - id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresFichasAptidaoData.PROCESSO_ID ) ) - { - processo_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresFichasAptidaoData.EXAME_ID ) ) - { - exame_id = ( Integer ) value; - } - } - - public Class getOuterClass() - { - return TrabalhadoresFichasAptidaoData.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresFichasAptidaoData.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresFichasAptidaoData.java deleted file mode 100644 index 335c430d..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresFichasAptidaoData.java +++ /dev/null @@ -1,59 +0,0 @@ -/* -* TrabalhadoresFichasAptidaoData.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.util.HashMap; -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresFichasAptidaoData extends JDOObject -{ - public static final String ID = "id"; - public static final String PROCESSO_ID = "processo_id"; - public static final String EXAME_ID = "exame_id"; - - public static final String FIELD_NAMES[] = new String[]{ - PROCESSO_ID, EXAME_ID, }; - - - protected static final String ALL_FIELD_NAMES[] = new String[]{ - ID, PROCESSO_ID, EXAME_ID, }; - - private HashMap dataHash; - - public TrabalhadoresFichasAptidaoData() - { - 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 TrabalhadoresFichasAptidao.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresFichasAptidaoID.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresFichasAptidaoID.java deleted file mode 100644 index 0ae452ad..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresFichasAptidaoID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* TrabalhadoresFichasAptidaoID.java -* -* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.io.*; - -import com.evolute.utils.jdo.jpox.*; - -public final class TrabalhadoresFichasAptidaoID extends IntegerID - implements Serializable -{ - public TrabalhadoresFichasAptidaoID() - { - } - - public TrabalhadoresFichasAptidaoID( String str ) - { - super( str ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresProcesso.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresProcesso.java deleted file mode 100644 index 2a598679..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresProcesso.java +++ /dev/null @@ -1,152 +0,0 @@ -/* -* TrabalhadoresProcesso.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.util.Date; -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresProcesso implements JDOInnerObject -{ - private Integer id; - private Integer trabalhador_id; - private String estado; - private Date data_inicio; - private Date data_fim; - private Integer motivo; - private Integer sub_motivo; - - public TrabalhadoresProcesso() - { - } - - public Object getField( String fieldName ) - { - if( fieldName == TrabalhadoresProcessoData.ID ) - { - return id; - } - else if( fieldName == TrabalhadoresProcessoData.TRABALHADOR_ID ) - { - return trabalhador_id; - } - else if( fieldName == TrabalhadoresProcessoData.ESTADO ) - { - return estado; - } - else if( fieldName == TrabalhadoresProcessoData.DATA_INICIO ) - { - return data_inicio; - } - else if( fieldName == TrabalhadoresProcessoData.DATA_FIM ) - { - return data_fim; - } - else if( fieldName == TrabalhadoresProcessoData.MOTIVO ) - { - return motivo; - } - else if( fieldName == TrabalhadoresProcessoData.SUB_MOTIVO ) - { - return sub_motivo; - } - else if( fieldName.equals( TrabalhadoresProcessoData.ID ) ) - { - return id; - } - else if( fieldName.equals( TrabalhadoresProcessoData.TRABALHADOR_ID ) ) - { - return trabalhador_id; - } - else if( fieldName.equals( TrabalhadoresProcessoData.ESTADO ) ) - { - return estado; - } - else if( fieldName.equals( TrabalhadoresProcessoData.DATA_INICIO ) ) - { - return data_inicio; - } - else if( fieldName.equals( TrabalhadoresProcessoData.DATA_FIM ) ) - { - return data_fim; - } - else if( fieldName.equals( TrabalhadoresProcessoData.MOTIVO ) ) - { - return motivo; - } - else if( fieldName.equals( TrabalhadoresProcessoData.SUB_MOTIVO ) ) - { - return sub_motivo; - } - return null; - } - - public void setField( String fieldName, Object value ) - { - if( fieldName == TrabalhadoresProcessoData.ID ) - { - id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresProcessoData.TRABALHADOR_ID ) - { - trabalhador_id = ( Integer ) value; - } - else if( fieldName == TrabalhadoresProcessoData.ESTADO ) - { - estado = ( String ) value; - } - else if( fieldName == TrabalhadoresProcessoData.DATA_INICIO ) - { - data_inicio = ( Date ) value; - } - else if( fieldName == TrabalhadoresProcessoData.DATA_FIM ) - { - data_fim = ( Date ) value; - } - else if( fieldName == TrabalhadoresProcessoData.MOTIVO ) - { - motivo = ( Integer ) value; - } - else if( fieldName == TrabalhadoresProcessoData.SUB_MOTIVO ) - { - sub_motivo = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresProcessoData.ID ) ) - { - id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresProcessoData.TRABALHADOR_ID ) ) - { - trabalhador_id = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresProcessoData.ESTADO ) ) - { - estado = ( String ) value; - } - else if( fieldName.equals( TrabalhadoresProcessoData.DATA_INICIO ) ) - { - data_inicio = ( Date ) value; - } - else if( fieldName.equals( TrabalhadoresProcessoData.DATA_FIM ) ) - { - data_fim = ( Date ) value; - } - else if( fieldName.equals( TrabalhadoresProcessoData.MOTIVO ) ) - { - motivo = ( Integer ) value; - } - else if( fieldName.equals( TrabalhadoresProcessoData.SUB_MOTIVO ) ) - { - sub_motivo = ( Integer ) value; - } - } - - public Class getOuterClass() - { - return TrabalhadoresProcessoData.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresProcessoData.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresProcessoData.java deleted file mode 100644 index 91b89335..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresProcessoData.java +++ /dev/null @@ -1,63 +0,0 @@ -/* -* TrabalhadoresProcessoData.java -* -* Generated by com.evutils.codegen.JDOObjectGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.util.HashMap; -import com.evolute.utils.jdo.*; - -public final class TrabalhadoresProcessoData extends JDOObject -{ - public static final String ID = "id"; - public static final String TRABALHADOR_ID = "trabalhador_id"; - public static final String ESTADO = "estado"; - public static final String DATA_INICIO = "data_inicio"; - public static final String DATA_FIM = "data_fim"; - public static final String MOTIVO = "motivo"; - public static final String SUB_MOTIVO = "sub_motivo"; - - public static final String FIELD_NAMES[] = new String[]{ - TRABALHADOR_ID, ESTADO, DATA_INICIO, DATA_FIM, MOTIVO, SUB_MOTIVO, }; - - - protected static final String ALL_FIELD_NAMES[] = new String[]{ - ID, TRABALHADOR_ID, ESTADO, DATA_INICIO, DATA_FIM, MOTIVO, SUB_MOTIVO, }; - - private HashMap dataHash; - - public TrabalhadoresProcessoData() - { - 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 TrabalhadoresProcesso.class; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresProcessoID.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresProcessoID.java deleted file mode 100644 index 7690a0d9..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/TrabalhadoresProcessoID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* -* TrabalhadoresProcessoID.java -* -* Generated by com.evolute.codegen.jdo.idclassgenerators.JPOXIDClassGenerator on May 14, 2007 -* -* Use but DON'T TOUCH -*/ -package siprp.medicina.processo.data; - -import java.io.*; - -import com.evolute.utils.jdo.jpox.*; - -public final class TrabalhadoresProcessoID extends IntegerID - implements Serializable -{ - public TrabalhadoresProcessoID() - { - } - - public TrabalhadoresProcessoID( String str ) - { - super( str ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/package.jdo b/trunk/SIPRPSoft/src/siprp/medicina/processo/data/package.jdo deleted file mode 100644 index 25ee315f..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/data/package.jdo +++ /dev/null @@ -1,304 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/detalhes/ConsultaPanel.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/detalhes/ConsultaPanel.java deleted file mode 100644 index 87a6b492..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/detalhes/ConsultaPanel.java +++ /dev/null @@ -1,360 +0,0 @@ -/* - * ConsultaPanel.java - * - * Created on March 22, 2007, 10:58 AM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo.detalhes; - -import com.evolute.utils.Singleton; -import com.evolute.utils.data.IDObject; -import com.evolute.utils.jdo.JDOProvider; -import com.evolute.utils.ui.DialogException; -import com.evolute.utils.ui.calendar.JCalendarPanel; -import info.clearthought.layout.TableLayout; -import info.clearthought.layout.TableLayoutConstraints; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Date; -import java.util.HashMap; -import java.util.Vector; -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import siprp.medicina.MedicinaConstants; -import siprp.medicina.processo.ProcessoConstants; -import siprp.medicina.processo.ProcessoDataProvider; -import siprp.medicina.processo.ProcessoEvent; -import siprp.medicina.processo.ProcessoListener; -import siprp.medicina.processo.data.TrabalhadoresConsultasData; -import siprp.medicina.processo.data.TrabalhadoresConsultasDatasData; - -/** - * - * @author fpalma - */ -public class ConsultaPanel extends JPanel - implements ActionListener, MedicinaConstants, ChangeListener -{ - protected JFrame owner; - protected JCalendarPanel dataConsultaPanel; - protected JButton estadoButton; - protected JButton emailButton; - protected JButton observacoesButton; - protected ObservacoesDialog observacoesDialog; - - protected final Vector PROCESSO_LISTENERS = new Vector(); - protected JDOProvider JDO; - protected ProcessoDataProvider provider; - - protected Integer trabalhadorID; - protected Integer processoID; - protected TrabalhadoresConsultasData consulta; - protected TrabalhadoresConsultasDatasData consultaData; - - /** Creates a new instance of ConsultaPanel */ - public ConsultaPanel( JFrame owner ) - throws Exception - { - this.owner = owner; - JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); - provider = ProcessoDataProvider.getProvider(); - setupComponents(); - } - - private void setupComponents() - { - JLabel dataLabel = new JLabel( "Data" ); - dataConsultaPanel = new JCalendarPanel( null ); - dataConsultaPanel.addChangeListener( this ); - estadoButton = new JButton( " " ); - estadoButton.addActionListener( this ); - emailButton = new JButton( "Email" ); - emailButton.addActionListener( this ); - observacoesButton = new JButton( "Coment\u00e1rio" ); - observacoesButton.addActionListener( this ); - - double cols[] = - new double[]{ TableLayout.MINIMUM, TableLayout.FILL }; - double rows[] = - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, - TableLayout.MINIMUM, TableLayout.MINIMUM }; - - TableLayout tableLayout = new TableLayout( cols, rows ); - tableLayout.setVGap( 5 ); - setLayout( tableLayout ); - - add( dataLabel, new TableLayoutConstraints( 0, 0 ) ); - add( dataConsultaPanel, new TableLayoutConstraints( 1, 0 ) ); - add( estadoButton, new TableLayoutConstraints( 0, 1, 1, 1 ) ); - add( emailButton, new TableLayoutConstraints( 0, 2, 1, 2 ) ); - add( observacoesButton, new TableLayoutConstraints( 0, 3, 1, 3 ) ); - } - - public void actionPerformed(ActionEvent e) - { - Object source = e.getSource(); - if( source.equals( observacoesButton ) ) - { - editarObservacoes(); - } - else if( source.equals( emailButton ) ) - { - enviarEmail(); - } - else if( source.equals( estadoButton ) ) - { - mudarEstado(); - } - } - - public void stateChanged(ChangeEvent e) - { - Object source = e.getSource(); - - if( source.equals( dataConsultaPanel ) ) - { - Date data = dataConsultaPanel.getDate(); - if( data == null ) - { - return; - } - try - { - boolean nova = false; - if( consulta == null ) - { - nova = true; - Integer consultaID = provider.getConsultaEmAbertoForProcesso( processoID ); - if( consultaID == null ) - { - consulta = new TrabalhadoresConsultasData(); - consulta.set( TrabalhadoresConsultasData.TRABALHADOR_ID, trabalhadorID ); - consulta.set( TrabalhadoresConsultasData.PROCESSO_ID, processoID ); - consulta.set( TrabalhadoresConsultasData.ESTADO, new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) ); - } - else - { - consulta = provider.getConsultaByID( consultaID ); - consulta.set( TrabalhadoresConsultasData.ESTADO, new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) ); - } - } - consulta.set( TrabalhadoresConsultasData.DATA, data ); - provider.saveConsulta( consulta ); - if( consultaData == null ) - { - Integer consultaID = ( Integer )consulta.get( TrabalhadoresConsultasData.ID ); - Integer consultaDataID = provider.getLastConsultaDataIDForConsulta( consultaID ); - if( consultaDataID == null || nova ) - { - consultaData = new TrabalhadoresConsultasDatasData(); - consultaData.set( TrabalhadoresConsultasDatasData.TRABALHADORES_CONSULTAS_ID, consultaID ); - consultaData.set( TrabalhadoresConsultasDatasData.ESTADO, new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) ); - } - else - { - consultaData = provider.getConsultaDataByID( consultaDataID ); - } - } - consultaData.set( TrabalhadoresConsultasDatasData.DATA, data ); - provider.saveConsultaData( consultaData ); - - notifyListeners( ProcessoEvent.ACCAO_MUDAR_DATA_MARCACAO ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a gravar dados da consulta", true ); - return; - } - } - } - - protected void editarObservacoes() - { - if( observacoesDialog == null ) - { - observacoesDialog = new ObservacoesDialog( owner ); - } - String texto = ""; - try - { - Integer dataID = provider.getLastConsultaDataIDForConsulta( ( Integer ) consulta.get( TrabalhadoresConsultasData.ID ) ); - IDObject observacoes = provider.getObservacoesConsultaData( dataID ); - if( observacoes != null ) - { - texto = observacoes.toString(); - } - texto = observacoesDialog.editarObservacao( texto ); - if( texto != null ) - { - provider.saveObservacoesConsultaData( dataID, texto ); - notifyListeners( ProcessoEvent.ACCAO_ESCREVER_OBSERVACOES ); - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar dados", true ); - return; - } - } - - protected void enviarEmail() - { - if( consulta == null ) - { - return; - } - try - { - Integer consultaDataID; - if( consultaData == null ) - { - Integer consultaID = ( Integer )consulta.get( TrabalhadoresConsultasDatasData.ID ); - consultaDataID = provider.getLastConsultaDataIDForConsulta( consultaID ); - consultaData = provider.getConsultaDataByID( consultaDataID ); - } - consultaDataID = ( Integer ) consultaData.get( TrabalhadoresConsultasDatasData.ID ); - provider.saveEmailConsultaData( consultaDataID, "teste@siprp.pt", "Email de teste.", "" ); - notifyListeners( ProcessoEvent.ACCAO_ESCREVER_MAIL ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a gravar dados da consulta", true ); - return; - } - } - - protected void mudarEstado() - { - if( consulta == null ) - { - return; - } - Integer estado = ( Integer ) consulta.get( TrabalhadoresConsultasData.ESTADO ); - EstadoChooser chooser = - new EstadoChooser( owner, ProcessoConstants.TIPO_CONSULTA, - estado != null ? estado.intValue() : MedicinaConstants.ESTADO_POR_REALIZAR ); - chooser.setVisible( true ); - int novoEstado = chooser.getEstado(); - if( estado == null || estado.intValue() != novoEstado ) - { - try - { - consulta.set( TrabalhadoresConsultasData.ESTADO, new Integer( novoEstado ) ); - provider.saveConsulta( consulta ); - if( consultaData == null ) - { - Integer consultaID = ( Integer )consulta.get( TrabalhadoresConsultasDatasData.ID ); - Integer consultaDataID = provider.getLastConsultaDataIDForConsulta( consultaID ); - consultaData = provider.getConsultaDataByID( consultaDataID ); - } - consultaData.set( TrabalhadoresConsultasDatasData.ESTADO, new Integer( novoEstado ) ); - provider.saveConsultaData( consultaData ); - - notifyListeners( ProcessoEvent.ACCAO_MUDAR_ESTADO_MARCACAO ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a gravar dados da consulta", true ); - return; - } - } - } - - public void addProcessoListener( ProcessoListener listener ) - { - PROCESSO_LISTENERS.add( listener ); - } - - public void removeProcessoListener( ProcessoListener listener ) - { - PROCESSO_LISTENERS.remove( listener ); - } - - public void clear() - { - dataConsultaPanel.setDate( null ); - estadoButton.setText( " " ); - consulta = null; - consultaData = null; - } - - public void fill( Object value ) - { - clear(); - if( value != null ) - { - try - { - consulta = ( TrabalhadoresConsultasData ) JDO.load( TrabalhadoresConsultasData.class, ( Integer ) value ); - Date data = ( Date ) consulta.get( TrabalhadoresConsultasData.DATA ); - Integer estado = ( Integer ) consulta.get( TrabalhadoresConsultasData.ESTADO ); - dataConsultaPanel.setDate( data ); - if( estado != null ) - { - estadoButton.setText( ESTADOS_CONSULTA_STR[ estado.intValue() ] ); - } - else - { - estadoButton.setText( " " ); - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar dados da consulta", true ); - } - } - enableButtons(); - } - - protected void enableButtons() - { - if( consulta != null ) - { - Integer estado = ( Integer ) consulta.get( TrabalhadoresConsultasData.ESTADO ); - dataConsultaPanel.setEnabled( estado == null || estado.intValue() == ESTADO_POR_REALIZAR ); - estadoButton.setEnabled( consulta.get( TrabalhadoresConsultasData.DATA ) != null ); - emailButton.setEnabled( consulta.get( TrabalhadoresConsultasData.DATA ) != null ); - observacoesButton.setEnabled( consulta.get( TrabalhadoresConsultasData.DATA ) != null ); - } - else - { - dataConsultaPanel.setEnabled( true ); - estadoButton.setEnabled( false ); - emailButton.setEnabled( false ); - observacoesButton.setEnabled( false ); - } - } - - public void setTrabalhadorID( Integer trabalhadorID ) - { - this.trabalhadorID = trabalhadorID; - } - - public void setProcessoID( Integer processoID ) - { - this.processoID = processoID; - } - - protected void notifyListeners( int accao ) - { - HashMap ids = new HashMap(); - ids.put( ProcessoEvent.TIPO_PROCESSO, processoID ); - if( consulta != null ) - { - ids.put( ProcessoEvent.TIPO_CONSULTA, ( Integer ) consulta.get( TrabalhadoresConsultasData.ID ) ); - } - if( consultaData != null ) - { - ids.put( ProcessoEvent.TIPO_DATA, ( Integer ) consulta.get( TrabalhadoresConsultasDatasData.ID ) ); - } - ProcessoEvent event = new ProcessoEvent( this, accao, ids ); - for( int n = 0; n < PROCESSO_LISTENERS.size(); n++ ) - { - PROCESSO_LISTENERS.get( n ).processoStateChanged( event ); - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/detalhes/DetalhesProcessoPanel.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/detalhes/DetalhesProcessoPanel.java deleted file mode 100644 index 2170f4f9..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/detalhes/DetalhesProcessoPanel.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * DetalhesProcessoPanel.java - * - * Created on 25 de Abril de 2007, 17:34 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo.detalhes; - -import java.awt.CardLayout; -import java.util.Vector; -import javax.swing.JFrame; -import javax.swing.JPanel; -import siprp.medicina.processo.*; - -/** - * - * @author Frederico - */ -public class DetalhesProcessoPanel extends JPanel -{ - private final Vector PROCESSO_LISTENERS = new Vector(); - - private static final String CARD_BLANK = ""; - private static final String CARD_CONSULTA = "CONSULTA"; - private static final String CARD_ECDS = "ECDS"; - - protected JFrame owner; - - protected JPanel blankPanel; - protected ConsultaPanel consultaPanel; - protected ECDsPanel ecdsPanel; - - protected CardLayout cardLayout; - - /** - * Creates a new instance of DetalhesProcessoPanel - */ - public DetalhesProcessoPanel( JFrame owner ) - throws Exception - { - this.owner = owner; - setupComponents(); - } - - private void setupComponents() - throws Exception - { - blankPanel = new JPanel(); - consultaPanel = new ConsultaPanel( owner ); - ecdsPanel = new ECDsPanel( owner ); - - cardLayout = new CardLayout(); - setLayout( cardLayout ); - add( blankPanel, CARD_BLANK ); - add( consultaPanel, CARD_CONSULTA ); - add( ecdsPanel, CARD_ECDS ); - } - - public void addProcessoListener( ProcessoListener listener ) - { - PROCESSO_LISTENERS.add( listener ); - consultaPanel.addProcessoListener( listener ); - ecdsPanel.addProcessoListener( listener ); - } - - public void removeProcessoListener( ProcessoListener listener ) - { - PROCESSO_LISTENERS.remove( listener ); - consultaPanel.removeProcessoListener( listener ); - ecdsPanel.removeProcessoListener( listener ); - } - - public void clear() - { - cardLayout.first( this ); - } - - public void setTrabalhadorID( Integer trabalhadorID ) - { - consultaPanel.setTrabalhadorID( trabalhadorID ); - } - - public void setProcessoID( Integer processoID ) - { - consultaPanel.setProcessoID( processoID ); - } - - public void setConsulta( Integer consultaID ) - { - cardLayout.show( this, CARD_CONSULTA ); - consultaPanel.fill( consultaID ); - } - - public void setECDs( Integer ecdsID ) - { - cardLayout.show( this, CARD_ECDS ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/detalhes/ECDsPanel.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/detalhes/ECDsPanel.java deleted file mode 100644 index f516aa45..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/detalhes/ECDsPanel.java +++ /dev/null @@ -1,366 +0,0 @@ -/* - * ECDsPanel.java - * - * Created on 13 de Maio de 2007, 17:07 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo.detalhes; - -import com.evolute.utils.Singleton; -import com.evolute.utils.data.IDObject; -import com.evolute.utils.jdo.JDOProvider; -import com.evolute.utils.ui.DialogException; -import com.evolute.utils.ui.calendar.JCalendarPanel; -import info.clearthought.layout.TableLayout; -import info.clearthought.layout.TableLayoutConstraints; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Date; -import java.util.HashMap; -import java.util.Vector; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import siprp.medicina.MedicinaConstants; -import siprp.medicina.processo.ProcessoConstants; -import siprp.medicina.processo.ProcessoDataProvider; -import siprp.medicina.processo.ProcessoEvent; -import siprp.medicina.processo.ProcessoListener; -import siprp.medicina.processo.data.TrabalhadoresConsultasData; -import siprp.medicina.processo.data.TrabalhadoresEcdsData; -import siprp.medicina.processo.data.TrabalhadoresEcdsDatasData; - -/** - * - * @author Frederico - */ -public class ECDsPanel extends JPanel - implements ActionListener, MedicinaConstants, ChangeListener -{ - protected JFrame owner; - protected JCalendarPanel dataEcdsPanel; - protected JButton estadoButton; - protected JButton emailButton; - protected JButton observacoesButton; - protected ObservacoesDialog observacoesDialog; - - protected final Vector PROCESSO_LISTENERS = new Vector(); - protected JDOProvider JDO; - protected ProcessoDataProvider provider; - - protected Integer trabalhadorID; - protected Integer processoID; - protected TrabalhadoresEcdsData ecds; - protected TrabalhadoresEcdsDatasData ecdsData; - - /** - * Creates a new instance of ECDsPanel - */ - public ECDsPanel( JFrame owner ) - throws Exception - { - this.owner = owner; - JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); - provider = ProcessoDataProvider.getProvider(); - setupComponents(); - } - - private void setupComponents() - { - JLabel dataLabel = new JLabel( "Data" ); - dataConsultaPanel = new JCalendarPanel( null ); - dataConsultaPanel.addChangeListener( this ); - estadoButton = new JButton( " " ); - estadoButton.addActionListener( this ); - emailButton = new JButton( "Email" ); - emailButton.addActionListener( this ); - observacoesButton = new JButton( "Coment\u00e1rio" ); - observacoesButton.addActionListener( this ); - - double cols[] = - new double[]{ TableLayout.MINIMUM, TableLayout.FILL }; - double rows[] = - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, - TableLayout.MINIMUM, TableLayout.MINIMUM }; - - TableLayout tableLayout = new TableLayout( cols, rows ); - tableLayout.setVGap( 5 ); - setLayout( tableLayout ); - - add( dataLabel, new TableLayoutConstraints( 0, 0 ) ); - add( dataEcdsPanel, new TableLayoutConstraints( 1, 0 ) ); - add( estadoButton, new TableLayoutConstraints( 0, 1, 1, 1 ) ); - add( emailButton, new TableLayoutConstraints( 0, 2, 1, 2 ) ); - add( observacoesButton, new TableLayoutConstraints( 0, 3, 1, 3 ) ); - } - - public void actionPerformed(ActionEvent e) - { - Object source = e.getSource(); - if( source.equals( observacoesButton ) ) - { - editarObservacoes(); - } - else if( source.equals( emailButton ) ) - { - enviarEmail(); - } - else if( source.equals( estadoButton ) ) - { - mudarEstado(); - } - } - - public void stateChanged(ChangeEvent e) - { - Object source = e.getSource(); - - if( source.equals( dataConsultaPanel ) ) - { - Date data = dataConsultaPanel.getDate(); - if( data == null ) - { - return; - } - try - { - boolean nova = false; - if( ecds == null ) - { - nova = true; - Integer ecdsID = provider.getEcdsEmAbertoForProcesso( processoID ); - if( ecdsID == null ) - { - ecds = new TrabalhadoresEcdsData(); - ecds.set( TrabalhadoresEcdsData.TRABALHADOR_ID, trabalhadorID ); - ecds.set( TrabalhadoresEcdsData.PROCESSO_ID, processoID ); - ecds.set( TrabalhadoresEcdsData.ESTADO, new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) ); - } - else - { - ecds = provider.getEcdsByID( ecdsID ); - ecds.set( TrabalhadoresEcdsData.ESTADO, new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) ); - } - } - ecds.set( TrabalhadoresConsultasData.DATA, data ); - provider.saveEcds( ecds ); - if( ecdsData == null ) - { - Integer ecdsID = ( Integer )ecds.get( TrabalhadoresEcdsData.ID ); - Integer ecdsDataID = provider.getLastEcdsDataIDForEcds( ecdsID ); - if( ecdsDataID == null || nova ) - { - ecdsData = new TrabalhadoresEcdsDatasData(); - ecdsData.set( TrabalhadoresEcdsDatasData.TRABALHADORES_ECDS_ID, ecdsID ); - ecdsData.set( TrabalhadoresEcdssDatasData.ESTADO, new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) ); - } - else - { - ecdsData = provider.getEcdsDataByID( ecdsDataID ); - } - } - ecdsData.set( TrabalhadoresEcdsDatasData.DATA, data ); - provider.saveEcdsData( ecdsData ); - - notifyListeners( ProcessoEvent.ACCAO_MUDAR_DATA_MARCACAO ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a gravar dados dos ECDs", true ); - return; - } - } - } - - protected void editarObservacoes() - { - if( observacoesDialog == null ) - { - observacoesDialog = new ObservacoesDialog( owner ); - } - String texto = ""; - try - { - Integer dataID = provider.getLastEcdsDataIDForEcds( ( Integer ) ecds.get( TrabalhadoresEcdssData.ID ) ); - IDObject observacoes = provider.getObservacoesEcdsData( dataID ); - if( observacoes != null ) - { - texto = observacoes.toString(); - } - texto = observacoesDialog.editarObservacao( texto ); - if( texto != null ) - { - provider.saveObservacoesEcdsData( dataID, texto ); - notifyListeners( ProcessoEvent.ACCAO_ESCREVER_OBSERVACOES ); - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar dados", true ); - return; - } - } - - protected void enviarEmail() - { - if( ecds == null ) - { - return; - } - try - { - Integer ecdsDataID; - if( ecdsData == null ) - { - Integer ecdsID = ( Integer )ecds.get( TrabalhadoresEcdsData.ID ); - ecdsDataID = provider.getLastEcdsDataIDForEcds( ecdsID ); - ecdsData = provider.getEcdsDataByID( ecdsDataID ); - } - ecdsDataID = ( Integer ) ecdsData.get( TrabalhadoresEcdsDatasData.ID ); - provider.saveEmailEcdsData( ecdsDataID, "teste@siprp.pt", "Email de teste.", "" ); - notifyListeners( ProcessoEvent.ACCAO_ESCREVER_MAIL ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a gravar dados", true ); - return; - } - } - - protected void mudarEstado() - { - if( ecds == null ) - { - return; - } - Integer estado = ( Integer ) ecds.get( TrabalhadoresEcdsData.ESTADO ); - EstadoChooser chooser = - new EstadoChooser( owner, ProcessoConstants.TIPO_ECDS, - estado != null ? estado.intValue() : MedicinaConstants.ESTADO_POR_REALIZAR ); - chooser.setVisible( true ); - int novoEstado = chooser.getEstado(); - if( estado == null || estado.intValue() != novoEstado ) - { - try - { - ecds.set( TrabalhadoresEcdsData.ESTADO, new Integer( novoEstado ) ); - provider.saveEcds( ecds ); - if( ecdsData == null ) - { - Integer ecdsID = ( Integer )ecds.get( TrabalhadoresEcdsData.ID ); - Integer ecdsDataID = provider.getLastEcdsDataIDForEcds( ecdsID ); - ecdsData = provider.getEcdsDataByID( ecdsDataID ); - } - ecdsData.set( TrabalhadoresEcdsDatasData.ESTADO, new Integer( novoEstado ) ); - provider.saveEcdsData( ecdsData ); - - notifyListeners( ProcessoEvent.ACCAO_MUDAR_ESTADO_MARCACAO ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a gravar dados", true ); - return; - } - } - } - - public void addProcessoListener( ProcessoListener listener ) - { - PROCESSO_LISTENERS.add( listener ); - } - - public void removeProcessoListener( ProcessoListener listener ) - { - PROCESSO_LISTENERS.remove( listener ); - } - - public void clear() - { - dataConsultaPanel.setDate( null ); - estadoButton.setText( " " ); - ecds = null; - ecdsData = null; - } - - public void fill( Object value ) - { - clear(); - if( value != null ) - { - try - { - ecds = ( TrabalhadoresEcdsData ) JDO.load( TrabalhadoresEcdsData.class, ( Integer ) value ); - Date data = ( Date ) ecds.get( TrabalhadoresEcdsData.DATA ); - Integer estado = ( Integer ) ecds.get( TrabalhadoresEcdsData.ESTADO ); - dataConsultaPanel.setDate( data ); - if( estado != null ) - { - estadoButton.setText( ESTADOS_EXAME_STR[ estado.intValue() ] ); - } - else - { - estadoButton.setText( " " ); - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar dados", true ); - } - } - enableButtons(); - } - - protected void enableButtons() - { - if( ecds != null ) - { - Integer estado = ( Integer ) ecds.get( TrabalhadoresEcdsData.ESTADO ); - dataEcdsPanel.setEnabled( estado == null || estado.intValue() == ESTADO_POR_REALIZAR ); - estadoButton.setEnabled( ecds.get( TrabalhadoresEcdsData.DATA ) != null ); - emailButton.setEnabled( ecds.get( TrabalhadoresEcdsData.DATA ) != null ); - observacoesButton.setEnabled( ecds.get( TrabalhadoresEcdsData.DATA ) != null ); - } - else - { - dataConsultaPanel.setEnabled( true ); - estadoButton.setEnabled( false ); - emailButton.setEnabled( false ); - observacoesButton.setEnabled( false ); - } - } - - public void setTrabalhadorID( Integer trabalhadorID ) - { - this.trabalhadorID = trabalhadorID; - } - - public void setProcessoID( Integer processoID ) - { - this.processoID = processoID; - } - - protected void notifyListeners( int accao ) - { - HashMap ids = new HashMap(); - ids.put( ProcessoEvent.TIPO_PROCESSO, processoID ); - if( ecds != null ) - { - ids.put( ProcessoEvent.TIPO_CONSULTA, ( Integer ) ecds.get( TrabalhadoresEcdsData.ID ) ); - } - if( ecdsData != null ) - { - ids.put( ProcessoEvent.TIPO_DATA, ( Integer ) ecds.get( TrabalhadoresEcdsData.ID ) ); - } - ProcessoEvent event = new ProcessoEvent( this, accao, ids ); - for( int n = 0; n < PROCESSO_LISTENERS.size(); n++ ) - { - PROCESSO_LISTENERS.get( n ).processoStateChanged( event ); - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/detalhes/EstadoChooser.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/detalhes/EstadoChooser.java deleted file mode 100644 index 2816eec1..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/detalhes/EstadoChooser.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * EstadoChooser.java - * - * Created on 13 de Maio de 2007, 11:54 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo.detalhes; - -import com.evolute.utils.ui.CustomJDialog; -import java.awt.Color; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.HashMap; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.SwingUtilities; -import siprp.medicina.MedicinaConstants; - -/** - * - * @author Frederico - */ -public class EstadoChooser extends CustomJDialog - implements MedicinaConstants, ActionListener -{ - protected int tipo; - protected int estado; - protected HashMap buttonMap = new HashMap(); - - /** Creates a new instance of EstadoChooser */ - public EstadoChooser( JFrame owner, int tipo, int estadoActual ) - { - super( owner, true ); - this.tipo = tipo; - estado = estadoActual; - setupComponents(); - - if( owner != null ) - { - centerSuper(); - } - else - { - center(); - } - } - - private void setupComponents() - { - setTitle( "Escolha o novo estado" ); - setLayout( new GridLayout( ESTADOS_STR[ tipo ].length, 1 ) ); - for( int n = 0; n < ESTADOS_STR[ tipo ].length; n++ ) - { - if( ESTADOS_STR[ tipo ][ n ] == null ) - { - continue; - } - JButton button = new JButton( ESTADOS_STR[ tipo ][ n ] ); - if( n == estado ) - { - button.setForeground( Color.green ); - } - buttonMap.put( button, new Integer( n ) ); - add( button ); - button.addActionListener( this ); - } - pack(); - } - - public void actionPerformed( ActionEvent e ) - { - JButton source = ( JButton ) e.getSource(); - estado = buttonMap.get( source ).intValue(); - close(); - } - - public void close() - { - SwingUtilities.invokeLater( new Runnable(){ - public void run() - { - setVisible( false ); - dispose(); - } - } ); - } - - public int getEstado() - { - return estado; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/detalhes/ObservacoesDialog.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/detalhes/ObservacoesDialog.java deleted file mode 100644 index 64e314a9..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/detalhes/ObservacoesDialog.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * ObservacoesDialog.java - * - * Created on 13 de Maio de 2007, 13:13 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo.detalhes; - -import com.evolute.utils.ui.CustomJDialog; -import java.awt.BorderLayout; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; -import javax.swing.SwingUtilities; - -/** - * - * @author Frederico - */ -public class ObservacoesDialog extends CustomJDialog - implements ActionListener -{ - protected JTextArea observacoesText; - protected JButton okButton; - protected JButton cancelButton; - - protected boolean ok = false; - - public static void main( String args[] ) - { - ObservacoesDialog dialog = new ObservacoesDialog( null ); - dialog.editarObservacao( "ISto e a observba" ); - System.exit( 0 ); - } - - /** Creates a new instance of ObservacoesDialog */ - public ObservacoesDialog( JFrame owner ) - { - super( owner, true ); - setupComponents(); - - if( owner != null ) - { - centerSuper(); - } - else - { - center(); - } - } - - private void setupComponents() - { - setTitle( "Coment\u00e1rio" ); - setSize( 400, 200 ); - observacoesText = new JTextArea(); - observacoesText.setLineWrap( true ); - observacoesText.setWrapStyleWord( true ); - JScrollPane scp = new JScrollPane( observacoesText, - JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - okButton = new JButton( "Ok" ); - okButton.addActionListener( this ); - cancelButton = new JButton( "Cancelar" ); - cancelButton.addActionListener( this ); - JPanel buttonPanel = new JPanel(); - - setLayout( new BorderLayout() ); - add( scp, BorderLayout.CENTER ); - add( buttonPanel, BorderLayout.SOUTH ); - - buttonPanel.setLayout( new GridLayout( 1, 2 ) ); - buttonPanel.add( okButton ); - buttonPanel.add( cancelButton ); - } - - public void actionPerformed( ActionEvent e ) - { - Object source = e.getSource(); - if( source.equals( okButton ) ) - { - ok = true; - close(); - } - else - { - ok = false; - close(); - } - } - - public String editarObservacao( String observacao ) - { - observacoesText.setText( observacao ); - setVisible( true ); - return ok ? observacoesText.getText() : null; - } - - public void close() - { - SwingUtilities.invokeLater( new Runnable(){ - public void run() - { - setVisible( false ); - dispose(); - } - } ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/ConsultaMutableTreeNode.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/ConsultaMutableTreeNode.java deleted file mode 100644 index f1f6f0c8..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/ConsultaMutableTreeNode.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * ConsultaMutableTreeNode.java - * - * Created on 29 de Abril de 2007, 19:31 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo.estrutura; - -/** - * - * @author Frederico - */ -public class ConsultaMutableTreeNode extends MarcacaoMutableTreeNode -{ - public static final String ICON_PATH = "siprp/medicina/processo/estrutura/icons/consulta.png"; - - /** Creates a new instance of ConsultaMutableTreeNode */ - public ConsultaMutableTreeNode( Integer id, String descricao ) - { - super( id, descricao ); - } - - protected String getIconPath() - { - return ICON_PATH; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/DataMutableTreeNode.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/DataMutableTreeNode.java deleted file mode 100644 index 838cc67d..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/DataMutableTreeNode.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * DataMutableTreeNode.java - * - * Created on 29 de Abril de 2007, 19:32 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo.estrutura; - -/** - * - * @author Frederico - */ -public class DataMutableTreeNode extends EstruturaProcessoMutableTreeNode -{ - public static final String ICON_PATH = "siprp/medicina/processo/estrutura/icons/data.png"; - - /** Creates a new instance of DataMutableTreeNode */ - public DataMutableTreeNode( Integer id, String descricao ) - { - super( id, descricao ); - } - - protected String getIconPath() - { - return ICON_PATH; - } -} \ No newline at end of file diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/ECDsMutableTreeNode.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/ECDsMutableTreeNode.java deleted file mode 100644 index 331c1c13..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/ECDsMutableTreeNode.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * ECDsMutableTreeNode.java - * - * Created on 29 de Abril de 2007, 19:31 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo.estrutura; - -/** - * - * @author Frederico - */ -public class ECDsMutableTreeNode extends MarcacaoMutableTreeNode -{ - public static final String ICON_PATH = "siprp/medicina/processo/estrutura/icons/ecds.png"; - - /** Creates a new instance of ECDsMutableTreeNode */ - public ECDsMutableTreeNode( Integer id, String descricao ) - { - super( id, descricao ); - } - - protected String getIconPath() - { - return ICON_PATH; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/EstruturaProcessoMutableTreeNode.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/EstruturaProcessoMutableTreeNode.java deleted file mode 100644 index 2961d479..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/EstruturaProcessoMutableTreeNode.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * EstruturaProcessoMutableTreeNode.java - * - * Created on 29 de Abril de 2007, 18:57 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo.estrutura; - -import com.evolute.utils.data.IDObject; -import com.evolute.utils.images.ImageIconLoader; -import javax.swing.Icon; -import javax.swing.tree.DefaultMutableTreeNode; - -/** - * - * @author Frederico - */ -abstract public class EstruturaProcessoMutableTreeNode extends DefaultMutableTreeNode - implements IDObject -{ - protected Icon icon; - protected Integer id; - protected String descricao; - - /** Creates a new instance of EstruturaProcessoMutableTreeNode */ - public EstruturaProcessoMutableTreeNode( Integer id, String descricao ) - { - super( descricao ); - this.id = id; - this.descricao = descricao; - } - - public Integer getID() - { - return id; - } - - public void setID( Integer id ) - { - this.id = id; - } - - public String getDescricao() - { - return descricao; - } - - public void setDescricao( String descricao ) - { - this.descricao = descricao; - setUserObject( descricao ); - } - - abstract protected String getIconPath(); - - public Icon getIcon() - { - loadIcon(); - return icon; - } - - protected void loadIcon() - { - if( icon == null && getIconPath() != null ) - { - try - { - icon = ImageIconLoader.loadImageIcon( getClass(), getIconPath() ); - } - catch( Exception ex ) - { - ex.printStackTrace(); - } - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/EstruturaProcessoPanel.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/EstruturaProcessoPanel.java deleted file mode 100644 index a3a291d3..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/EstruturaProcessoPanel.java +++ /dev/null @@ -1,421 +0,0 @@ -/* - * EstruturaProcessoPanel.java - * - * Created on March 20, 2007, 12:07 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo.estrutura; - -import com.evolute.utils.data.IDObject; -import com.evolute.utils.ui.DialogException; -import java.awt.*; -import java.text.DateFormat; -import java.util.Arrays; -import java.util.Date; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Locale; -import java.util.Vector; -import javax.swing.*; -import javax.swing.event.TreeSelectionEvent; -import javax.swing.event.TreeSelectionListener; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreePath; -import siprp.medicina.MedicinaConstants; -import siprp.medicina.MedicinaDataProvider; -import siprp.medicina.processo.*; -import siprp.medicina.processo.data.TrabalhadoresConsultasData; -import siprp.medicina.processo.data.TrabalhadoresProcessoData; - -/** - * - * @author fpalma - */ -public class EstruturaProcessoPanel extends JPanel - implements TreeSelectionListener -{ - protected static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) ); - - protected JScrollPane mainScroll; - protected TrabalhadorMutableTreeNode rootNode; - protected JTree mainTree; - - protected ProcessoDataProvider provider; - - protected IDObject trabalhador; - protected final HashMap PROCESSOS_POR_ID = - new HashMap(); - - private final Vector PROCESSO_LISTENERS = new Vector(); - - /** Creates a new instance of EstruturaProcessoPanel */ - public EstruturaProcessoPanel() - throws Exception - { - provider = ProcessoDataProvider.getProvider(); - setupComponents(); -// setTrabalhador( new MappableObject( new Integer( 12 ), "Alexandre de Matos Monge" ) ); - } - - private void setupComponents() - { - mainScroll = new JScrollPane(); - mainScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED ); - mainScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED ); -// rootNode = new DefaultMutableTreeNode( new MappableObject( new Integer( 12 ), "Frederico Palma" ) ); - rootNode = new TrabalhadorMutableTreeNode( new Integer( -1 ), "" ); - mainTree = new JTree( rootNode ); - mainTree.addTreeSelectionListener( this ); - mainTree.setCellRenderer( new EstruturaProcessoRenderer() ); - mainScroll.setViewportView( mainTree ); - setLayout( new GridLayout( 1, 1 ) ); - add( mainScroll ); - - } - - public void setTrabalhador( IDObject trabalhador ) - { - clear(); - if( trabalhador == null ) - { - return; - } - this.trabalhador = trabalhador; -// rootNode.removeAllChildren(); -// PROCESSOS_POR_ID.clear(); - rootNode.setID( trabalhador.getID() ); - rootNode.setDescricao( trabalhador.toString() ); - DefaultMutableTreeNode nodes[] = - loadProcessos( trabalhador.getID() ); - rootNode.add( criarProcessoVazio() ); - for( int n = 0; n < nodes.length; n++ ) - { - rootNode.add( nodes[ n ] ); - } - int count = mainTree.getRowCount(); - for( int n = count - 1; n >= 0; n-- ) - { - mainTree.expandRow( n ); - } - } - - protected DefaultMutableTreeNode[] loadProcessos( Integer trabalhadorID ) - { - try - { - Integer ids[] = provider.getIDsProcessosByTrabalhador( trabalhadorID ); - DefaultMutableTreeNode nodes[] = new DefaultMutableTreeNode[ ids.length ]; - for( int n = 0; n < ids.length; n++ ) - { - nodes[ n ] = loadProcesso( ids[ n ], null ); - } -//System.out.println( "nl: " + nodes.length ); - return nodes; - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar dados", true ); - return new DefaultMutableTreeNode[ 0 ]; - } - } - - protected ProcessoMutableTreeNode loadProcesso( Integer id, ProcessoMutableTreeNode node ) - throws Exception - { - TrabalhadoresProcessoData processo = provider.getProcessoByID( id ); - Date dataInicio = ( Date ) processo.get( TrabalhadoresProcessoData.DATA_INICIO ); - Date dataFim = ( Date ) processo.get( TrabalhadoresProcessoData.DATA_FIM ); - String codigoEstado = ( String ) processo.get( TrabalhadoresProcessoData.ESTADO ); - String estado = provider.getDescricaoEstadoProcessoByCodigo( codigoEstado ); - String desc = D_F.format( dataInicio ); - Integer motivo = ( Integer ) processo.get( TrabalhadoresProcessoData.MOTIVO ); - desc += ": " + MedicinaDataProvider.MOTIVOS_BY_ID.get( motivo ) + " : " + estado; - PROCESSOS_POR_ID.put( id, processo ); - ProcessoMutableTreeNode processoNode; - if( node == null ) - { - processoNode = new ProcessoMutableTreeNode( id, desc ); - } - else - { - processoNode = node; - processoNode.setID( id ); - processoNode.setDescricao( desc ); - } - processoNode.removeAllChildren(); - MarcacaoMutableTreeNode marcacoes[] = loadMarcacoes( id ); -// processoNode.add( new ECDsMutableTreeNode( new Integer( 35 ), "ECDS de 2006/01/01 : Realizado" ) ); - for( int n = 0; n < marcacoes.length; n++ ) - { - processoNode.add( marcacoes[ n ] ); - } - -// processoNode.add( new FichaAptidaoMutableTreeNode( new Integer( 35 ), "Ficha de Aptid\u00e3o de 2006/01/01 : Apto" ) ); - ( ( DefaultTreeModel ) mainTree.getModel() ).nodeStructureChanged( processoNode ); - return processoNode; - } - - public MarcacaoMutableTreeNode[] loadMarcacoes( Integer processoID ) - { - try - { - Integer consultaIDs[] = provider.getConsultaIDsForProcesso( processoID ); - Vector nodesVector = new Vector(); - for( int n = 0; n < consultaIDs.length; n++ ) - { - nodesVector.add( loadConsulta( consultaIDs[ n ], null ) ); - } - - MarcacaoMutableTreeNode nodes[] = nodesVector.toArray( new MarcacaoMutableTreeNode[ nodesVector.size() ] ); - Arrays.sort( nodes ); - return nodes; - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar dados", true ); - return new MarcacaoMutableTreeNode[ 0 ]; - } - } - - public ConsultaMutableTreeNode loadConsulta( Integer id, ConsultaMutableTreeNode node ) - throws Exception - { - TrabalhadoresConsultasData consulta = provider.getConsultaByID( id ); - Date data = ( Date ) consulta.get( TrabalhadoresConsultasData.DATA ); - Integer estado = ( Integer ) consulta.get( TrabalhadoresConsultasData.ESTADO ); - String estadoStr = MedicinaConstants.ESTADOS_CONSULTA_STR[ estado != null ? estado.intValue() : 0 ]; - - String desc = "Consulta de " + ( data != null ? D_F.format( data ) : "--" ); - desc += ": " + estadoStr; - ConsultaMutableTreeNode consultaNode; - if( node == null ) - { - consultaNode = new ConsultaMutableTreeNode( id, desc ); - consultaNode.setData( data ); - } - else - { - consultaNode = node; - consultaNode.setID( id ); - consultaNode.setDescricao( desc ); - consultaNode.setData( data ); - } - consultaNode.removeAllChildren(); - Object datas[][] = provider.getDatasConsulta( id ); - for( int n = 0; n < datas.length; n++ ) - { - Integer dataID = ( Integer ) datas[ n ][ 0 ]; - Date dataData = ( Date ) datas[ n ][ 1 ]; - Integer dataEstado = ( Integer ) datas[ n ][ 2 ]; - String dataEstadoStr = MedicinaConstants.ESTADOS_CONSULTA_STR[ dataEstado != null ? dataEstado.intValue() : 0 ]; - String dataDesc = D_F.format( dataData ) + ": " + dataEstadoStr; - DataMutableTreeNode dataNode = new DataMutableTreeNode( dataID, dataDesc ); - IDObject observacoes = provider.getObservacoesConsultaData( dataID ); - if( observacoes != null ) - { - ObservacoesMutableTreeNode observacoesNode = new ObservacoesMutableTreeNode( observacoes.getID(), observacoes.toString() ); - dataNode.add( observacoesNode ); - } - IDObject emails[] = provider.getEmailConsultaData( dataID ); - for( int em = 0; em < emails.length; em++ ) - { - MailMutableTreeNode mailNode = new MailMutableTreeNode( emails[ em ].getID(), emails[ em ].toString() ); - dataNode.add( mailNode ); - } - consultaNode.add( dataNode ); - } - - ( ( DefaultTreeModel ) mainTree.getModel() ).nodeStructureChanged( consultaNode ); - return consultaNode; - } - - public void valueChanged( TreeSelectionEvent e ) - { - Object components[] = e.getPath().getPath(); - int tipo = ProcessoEvent.ACCAO_ESCOLHER_PROCESSO; - if( components == null || components.length == 0 || - components[ components.length - 1 ] instanceof TrabalhadorMutableTreeNode || - components[ components.length - 1 ] instanceof ProcessoMutableTreeNode ) - { - tipo = ProcessoEvent.ACCAO_ESCOLHER_PROCESSO; - } - else if( components[ components.length - 1 ] instanceof ConsultaMutableTreeNode ) - { - tipo = ProcessoEvent.ACCAO_ESCOLHER_CONSULTA; - } - else if( components[ components.length - 1 ] instanceof ECDsMutableTreeNode ) - { - tipo = ProcessoEvent.ACCAO_ESCOLHER_ECDS; - } - else if( components[ components.length - 1 ] instanceof FichaAptidaoMutableTreeNode ) - { - tipo = ProcessoEvent.ACCAO_ESCOLHER_FA; - } - else if( components[ components.length - 1 ] instanceof DataMutableTreeNode ) - { - tipo = ProcessoEvent.ACCAO_ESCOLHER_DATA; - } - else if( components[ components.length - 1 ] instanceof ObservacoesMutableTreeNode ) - { - tipo = ProcessoEvent.ACCAO_ESCOLHER_OBSERVACOES; - } - else if( components[ components.length - 1 ] instanceof MailMutableTreeNode ) - { - tipo = ProcessoEvent.ACCAO_ESCOLHER_MAIL; - } - HashMap ids = new HashMap(); - for( int n = 0; components != null && n < components.length; n++ ) - { - Integer id = ( ( EstruturaProcessoMutableTreeNode ) components[ n ] ).getID(); - if( components[ n ] instanceof ProcessoMutableTreeNode ) - { - ids.put( ProcessoEvent.TIPO_PROCESSO, id ); - } - else if( components[ n ] instanceof ConsultaMutableTreeNode ) - { - ids.put( ProcessoEvent.TIPO_CONSULTA, id ); - } - else if( components[ n ] instanceof ECDsMutableTreeNode ) - { - ids.put( ProcessoEvent.TIPO_ECDS, id ); - } - else if( components[ n ] instanceof FichaAptidaoMutableTreeNode ) - { - ids.put( ProcessoEvent.TIPO_FICHA_APTIDAO, id ); - } - else if( components[ n ] instanceof DataMutableTreeNode ) - { - ids.put( ProcessoEvent.TIPO_DATA, id ); - } - else if( components[ n ] instanceof ObservacoesMutableTreeNode ) - { - ids.put( ProcessoEvent.TIPO_OBSERVACOES, id ); - } - else if( components[ n ] instanceof MailMutableTreeNode ) - { - ids.put( ProcessoEvent.TIPO_MAIL, id ); - } - } - ProcessoEvent event = new ProcessoEvent( this, tipo, ids ); - for( int n = 0; n < PROCESSO_LISTENERS.size(); n++ ) - { - PROCESSO_LISTENERS.get( n ).processoStateChanged( event ); - } - } -// -// public TrabalhadoresProcessoData getProcessoEscolhido() -// { -// TreePath path = mainTree.getSelectionPath(); -// TrabalhadoresProcessoData processo = null; -// if( path != null ) -// { -// EstruturaProcessoMutableTreeNode escolhido = ( EstruturaProcessoMutableTreeNode ) path.getLastPathComponent(); -// if( escolhido != null ) -// { -// processo = PROCESSOS_POR_ID.get( escolhido.getID() ); -// if( processo == null ) -// { -// processo = new TrabalhadoresProcessoData(); -// PROCESSOS_POR_ID.put( escolhido.getID(), processo ); -// } -// } -// } -// -// return processo; -// } - - public void addProcessoListener( ProcessoListener listener ) - { - PROCESSO_LISTENERS.add( listener ); - } - - public void removeProcessoListener( ProcessoListener listener ) - { - PROCESSO_LISTENERS.remove( listener ); - } - - public IDObject getTrabalhador() - { - return trabalhador; - } - - public void actualizarProcessoEscolhido( Integer id ) - throws Exception - { - TreePath path = mainTree.getSelectionPath(); - Enumeration expandedDescendants = mainTree.getExpandedDescendants( path ); - ProcessoMutableTreeNode processoNode = ( ProcessoMutableTreeNode ) path.getPathComponent( 1 ); - boolean vazio = processoNode.getID().intValue() == -1; - loadProcesso( id, processoNode ); - ( ( DefaultTreeModel ) mainTree.getModel() ).nodeChanged( processoNode ) ; - if( vazio ) - { - ProcessoMutableTreeNode novo = criarProcessoVazio(); - rootNode.insert( novo, 0 ); - ( ( DefaultTreeModel ) mainTree.getModel() ).nodesWereInserted( rootNode, new int[]{ 0 } ) ; - } - mainTree.expandPath( path ); - mainTree.setSelectionPath( path ); -// while( expandedDescendants.hasMoreElements() ) -// { -// mainTree.expandPath( expandedDescendants.nextElement() ); -// } - } - - public void actualizarMarcacaoEscolhida( Integer processoID, Integer marcacaoID ) - throws Exception - { - TreePath path = mainTree.getSelectionPath(); - Enumeration expandedDescendants = mainTree.getExpandedDescendants( path ); - ProcessoMutableTreeNode processoNode = ( ProcessoMutableTreeNode ) path.getPathComponent( 1 ); - int countOld = processoNode.getChildCount(); - actualizarProcessoEscolhido( processoID ); - int count = processoNode.getChildCount(); - if( count > countOld ) - { - ( ( DefaultTreeModel ) mainTree.getModel() ).nodesWereInserted( processoNode, new int[]{ countOld } ) ; - } - mainTree.expandPath( path ); -// mainTree.expandPath( path ); -// while( expandedDescendants.hasMoreElements() ) -// { -// mainTree.expandPath( expandedDescendants.nextElement() ); -// } -// TreePath path = mainTree.getSelectionPath(); -// MarcacaoMutableTreeNode processoNode = ( ProcessoMutableTreeNode ) path.getPathComponent( 1 ); -// boolean vazio = processoNode.getID().intValue() == -1; -// loadProcesso( id, processoNode ); -// ( ( DefaultTreeModel ) mainTree.getModel() ).nodeChanged( processoNode ) ; -// if( vazio ) -// { -// ProcessoMutableTreeNode novo = criarProcessoVazio(); -// rootNode.insert( novo, 0 ); -// ( ( DefaultTreeModel ) mainTree.getModel() ).nodesWereInserted( rootNode, new int[]{ 0 } ) ; -// } - } - - public ProcessoMutableTreeNode criarProcessoVazio() - { - return new ProcessoMutableTreeNode( new Integer( -1 ), "Novo Processo..." ); - } - - public void reload() - { - } - - public void clear() - { - mainTree.clearSelection(); - mainTree.setRootVisible( true ); - this.trabalhador = null; - rootNode.removeAllChildren(); - PROCESSOS_POR_ID.clear(); - rootNode.setID( null ); - rootNode.setDescricao( "" ); - ( ( DefaultTreeModel ) mainTree.getModel() ).nodeStructureChanged( rootNode ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/EstruturaProcessoRenderer.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/EstruturaProcessoRenderer.java deleted file mode 100644 index fcd50509..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/EstruturaProcessoRenderer.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * EstruturaProcessoRenderer.java - * - * Created on 29 de Abril de 2007, 18:52 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo.estrutura; - -import java.awt.Component; -import javax.swing.*; -import javax.swing.tree.*; - -/** - * - * @author Frederico - */ -public class EstruturaProcessoRenderer extends DefaultTreeCellRenderer -{ - - /** Creates a new instance of EstruturaProcessoRenderer */ - public EstruturaProcessoRenderer() - { - } - - public Component getTreeCellRendererComponent( - JTree tree, - Object value, - boolean sel, - boolean expanded, - boolean leaf, - int row, - boolean hasFocus) { - - super.getTreeCellRendererComponent( - tree, value, sel, - expanded, leaf, row, - hasFocus); - EstruturaProcessoMutableTreeNode node = ( EstruturaProcessoMutableTreeNode ) value; -//System.out.println( node.getICon() ); - Icon icon = node.getIcon(); - if( icon != null ) - { - setIcon( icon ); - } - - return this; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/FichaAptidaoMutableTreeNode.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/FichaAptidaoMutableTreeNode.java deleted file mode 100644 index 7547aef2..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/FichaAptidaoMutableTreeNode.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * FichaAptidaoMutableTreeNode.java - * - * Created on 29 de Abril de 2007, 19:32 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo.estrutura; - -/** - * - * @author Frederico - */ -public class FichaAptidaoMutableTreeNode extends EstruturaProcessoMutableTreeNode -{ - public static final String ICON_PATH = "siprp/medicina/processo/estrutura/icons/fichaaptidao.png"; - - /** Creates a new instance of FichaAptidaoMutableTreeNode */ - public FichaAptidaoMutableTreeNode( Integer id, String descricao ) - { - super( id, descricao ); - } - - protected String getIconPath() - { - return ICON_PATH; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/MailMutableTreeNode.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/MailMutableTreeNode.java deleted file mode 100644 index a73ee050..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/MailMutableTreeNode.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * MailMutableTreeNode.java - * - * Created on 29 de Abril de 2007, 19:32 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo.estrutura; - -/** - * - * @author Frederico - */ -public class MailMutableTreeNode extends EstruturaProcessoMutableTreeNode -{ - public static final String ICON_PATH = "siprp/medicina/processo/estrutura/icons/mail.png"; - - /** Creates a new instance of MailMutableTreeNode */ - public MailMutableTreeNode( Integer id, String descricao ) - { - super( id, descricao ); - } - - protected String getIconPath() - { - return ICON_PATH; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/MarcacaoMutableTreeNode.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/MarcacaoMutableTreeNode.java deleted file mode 100644 index 4a7ed64a..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/MarcacaoMutableTreeNode.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * MarcacaoMutableTreeNode.java - * - * Created on 18 de Maio de 2007, 7:02 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo.estrutura; - -import java.util.Date; - -/** - * - * @author Frederico - */ -public abstract class MarcacaoMutableTreeNode extends EstruturaProcessoMutableTreeNode - implements Comparable -{ - protected Date data; - - /** Creates a new instance of MarcacaoMutableTreeNode */ - public MarcacaoMutableTreeNode( Integer id, String descricao ) - { - super( id, descricao ); - } - - public void setData( Date data ) - { - this.data = data; - } - - public Date getData() - { - return data; - } - - public int compareTo( Object other ) - { - if( !( other instanceof MarcacaoMutableTreeNode ) ) - { - return 0; - } - MarcacaoMutableTreeNode om = ( MarcacaoMutableTreeNode ) other; - if( data == null ) - { - return 1; - } - else if( om == null || om.getData() == null ) - { - return -1; - } - else - { - return -1 * getData().compareTo( om.getData() ); - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/ObservacoesMutableTreeNode.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/ObservacoesMutableTreeNode.java deleted file mode 100644 index 22b358c5..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/ObservacoesMutableTreeNode.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * ObservacoesMutableTreeNode.java - * - * Created on 29 de Abril de 2007, 19:32 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo.estrutura; - -/** - * - * @author Frederico - */ -public class ObservacoesMutableTreeNode extends EstruturaProcessoMutableTreeNode -{ - public static final String ICON_PATH = "siprp/medicina/processo/estrutura/icons/observacoes.png"; - - /** Creates a new instance of ObservacoesMutableTreeNode */ - public ObservacoesMutableTreeNode( Integer id, String descricao ) - { - super( id, descricao ); - } - - protected String getIconPath() - { - return ICON_PATH; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/ProcessoMutableTreeNode.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/ProcessoMutableTreeNode.java deleted file mode 100644 index a065184d..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/ProcessoMutableTreeNode.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * ProcessoMutableTreeNode.java - * - * Created on 29 de Abril de 2007, 19:31 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo.estrutura; - -/** - * - * @author Frederico - */ -public class ProcessoMutableTreeNode extends EstruturaProcessoMutableTreeNode -{ - public static final String ICON_PATH = "siprp/medicina/processo/estrutura/icons/processo.png"; - - /** Creates a new instance of ProcessoMutableTreeNode */ - public ProcessoMutableTreeNode( Integer id, String descricao ) - { - super( id, descricao ); - } - - protected String getIconPath() - { - return ICON_PATH; - } -} \ No newline at end of file diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/TrabalhadorMutableTreeNode.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/TrabalhadorMutableTreeNode.java deleted file mode 100644 index 2a0342ea..00000000 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/TrabalhadorMutableTreeNode.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * TrabalhadorMutableTreeNode.java - * - * Created on 29 de Abril de 2007, 23:53 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.medicina.processo.estrutura; - -/** - * - * @author Frederico - */ -public class TrabalhadorMutableTreeNode extends EstruturaProcessoMutableTreeNode -{ - public static final String ICON_PATH = "siprp/medicina/processo/estrutura/icons/trabalhador.png"; - - /** Creates a new instance of TrabalhadorMutableTreeNode */ - public TrabalhadorMutableTreeNode( Integer id, String descricao ) - { - super( id, descricao ); - } - - protected String getIconPath() - { - return null; -// return ICON_PATH; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/consulta.png b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/consulta.png deleted file mode 100644 index f07be69b..00000000 Binary files a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/consulta.png and /dev/null differ diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/data.png b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/data.png deleted file mode 100644 index 59f184fc..00000000 Binary files a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/data.png and /dev/null differ diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/ecds.png b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/ecds.png deleted file mode 100644 index 4aa424d1..00000000 Binary files a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/ecds.png and /dev/null differ diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/fichaaptidao.png b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/fichaaptidao.png deleted file mode 100644 index ce2d52a5..00000000 Binary files a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/fichaaptidao.png and /dev/null differ diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/mail.png b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/mail.png deleted file mode 100644 index 8f65c5ac..00000000 Binary files a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/mail.png and /dev/null differ diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/observacoes.png b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/observacoes.png deleted file mode 100644 index 1f0856fb..00000000 Binary files a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/observacoes.png and /dev/null differ diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/processo.png b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/processo.png deleted file mode 100644 index f8ea33ee..00000000 Binary files a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/processo.png and /dev/null differ diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/trabalhador.png b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/trabalhador.png deleted file mode 100644 index 96ac6bfa..00000000 Binary files a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/icons/trabalhador.png and /dev/null differ diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/icons/consulta.png b/trunk/SIPRPSoft/src/siprp/medicina/processo/icons/consulta.png deleted file mode 100644 index f07be69b..00000000 Binary files a/trunk/SIPRPSoft/src/siprp/medicina/processo/icons/consulta.png and /dev/null differ diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/icons/ecds.png b/trunk/SIPRPSoft/src/siprp/medicina/processo/icons/ecds.png deleted file mode 100644 index 4aa424d1..00000000 Binary files a/trunk/SIPRPSoft/src/siprp/medicina/processo/icons/ecds.png and /dev/null differ diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/icons/fichaaptidao.png b/trunk/SIPRPSoft/src/siprp/medicina/processo/icons/fichaaptidao.png deleted file mode 100644 index ce2d52a5..00000000 Binary files a/trunk/SIPRPSoft/src/siprp/medicina/processo/icons/fichaaptidao.png and /dev/null differ diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/icons/lock.png b/trunk/SIPRPSoft/src/siprp/medicina/processo/icons/lock.png deleted file mode 100644 index 46cc6b58..00000000 Binary files a/trunk/SIPRPSoft/src/siprp/medicina/processo/icons/lock.png and /dev/null differ diff --git a/trunk/SIPRPSoft/src/siprp/pesquisas/PesquisasProvider.java b/trunk/SIPRPSoft/src/siprp/pesquisas/PesquisasProvider.java deleted file mode 100644 index 632d8b18..00000000 --- a/trunk/SIPRPSoft/src/siprp/pesquisas/PesquisasProvider.java +++ /dev/null @@ -1,751 +0,0 @@ -/* - * 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; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/pesquisas/PesquisasWindow.java b/trunk/SIPRPSoft/src/siprp/pesquisas/PesquisasWindow.java deleted file mode 100644 index c08d21b1..00000000 --- a/trunk/SIPRPSoft/src/siprp/pesquisas/PesquisasWindow.java +++ /dev/null @@ -1,578 +0,0 @@ -/* - * 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( "" + ano + "
" ); - buff.append( "
EMPRESA
" ); - try - { - Integer idEmpresa = ( (IDObject)empresasModel.getRowAt( sEmpresa ) ).getID(); - EmpresaData empresa = (EmpresaData)JDO.load( EmpresaData.class, idEmpresa ); - buff.append( " DESIGNA\u00C7\u00C3O SOCIAL: " ); - String designacao = (String)empresa.get( EmpresaData.DESIGNACAO_SOCIAL ); - buff.append( "" + ( designacao == null ? "" : designacao.trim() ) + "
" ); - buff.append( " MORADA: " ); - String morada = (String)empresa.get( EmpresaData.MORADA ); - buff.append( "" + ( morada == null ? "" : morada.trim() ) + "
" ); - buff.append( " LOCALIDADE: " ); - String localidade = ( String ) empresa.get( EmpresaData.LOCALIDADE ); - buff.append( "" + ( localidade == null ? "" : localidade.trim() ) + "
" ); - buff.append( " C\u00D3DIGO POSTAL: " ); - String codigoPostal = ( String ) empresa.get( EmpresaData.CODIGO_POSTAL ); - buff.append( "" + ( codigoPostal == null ? "" : codigoPostal.trim() ) + "
" ); - ContactoData contacto = (ContactoData)empresa.get( EmpresaData.CONTACTO_2 ); - if( contacto == null ) - { - buff.append( " TELEFONE:
" ); - buff.append( " FAX:
" ); - } - else - { - buff.append( " TELEFONE: " ); - String telefone = ( String ) contacto.get( ContactoData.TELEFONE ); - buff.append( "" + ( telefone == null ? "" : telefone.trim() ) + "
" ); - buff.append( " FAX: " ); - String fax = ( String ) contacto.get( ContactoData.TELEFONE ); - buff.append( "" + ( fax == null ? "" : fax.trim() ) + "
" ); - } - buff.append( " DISTRITO: " ); - String distrito = ( String ) empresa.get( EmpresaData.DISTRITO ); - buff.append( "" + ( distrito == null ? "" : distrito ) + "
" ); - buff.append( " CONCELHO: " ); - String concelho = ( String ) empresa.get( EmpresaData.CONCELHO ); - buff.append( "" + ( concelho == null ? "" : concelho ) + "
" ); - buff.append( " N\u00DAMERO PESSOA COLECTIVA: " ); - String contribuinte = ( String ) empresa.get( EmpresaData.CONTRIBUINTE ); - buff.append( "" + ( contribuinte == null ? "" : contribuinte ) + "
" ); - buff.append( " N\u00DAMERO SEGURAN\u00C7A SOCIAL: " ); - String segSocial = ( String ) empresa.get( EmpresaData.SEGURANCA_SOCIAL ); - buff.append( "" + ( segSocial == null ? "" : segSocial ) + "
" ); - buff.append( " CAE: " ); - String CAE = ( String ) empresa.get( EmpresaData.CAE ); - buff.append( "" + ( CAE == null ? "" : CAE ) + "
" ); - buff.append( "
 N\u00DAMERO M\u00C9DIO DE TRABALHADORES DURANTE O ANO" ); - double contagemMedia[] = provider.countNumeroMedioTrabalhadoresEmpresa( idEmpresa, ano ); - buff.append( "" ); - buff.append( "" ); - buff.append( "" ); - buff.append( "" ); - buff.append( ""); - buff.append( "" ); - buff.append( "" ); - buff.append( "" ); - buff.append( "
    TOTAL HOMENS MULHERES
  TOTAL " + (int)( Math.round( contagemMedia[0] ) + Math.round( contagemMedia[1] ) ) + " " + ( (int)Math.round( contagemMedia[0] ) ) + " " + ( (int)Math.round( contagemMedia[1] ) ) + "
" ); - buff.append( "
 N\u00DAMERO TOTAL DE TRABALHADORES DURANTE O ANO" ); - double contagemTotal[] = provider.countNumeroTotalTrabalhadoresEmpresa( idEmpresa, ano ); - buff.append( "" ); - buff.append( "" ); - buff.append( "" ); - buff.append( "" ); - buff.append( ""); - buff.append( "" ); - buff.append( "" ); - buff.append( "" ); - buff.append( "
    TOTAL HOMENS MULHERES
  TOTAL " + (int)( Math.round( contagemTotal[0] ) + Math.round( contagemTotal[1] ) ) + " " + ( (int)Math.round( contagemTotal[0] ) ) + " " + ( (int)Math.round( contagemTotal[1] ) ) + "
" ); - - 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( "
" ); - buff.append( "
 ESTABELECIMENTOS
" ); - buff.append( "
" ); - for( int n = 0; n < estabelecimentos.length; n++ ) - { - EstabelecimentoData estabelecimento = (EstabelecimentoData)JDO.load( EstabelecimentoData.class, estabelecimentos[ n ].getID() ); - buff.append( "  NOME: " ); - String nome = (String)estabelecimento.get( EstabelecimentoData.NOME ); - buff.append( "" + ( nome == null ? "" : nome.trim() ) + "
" ); - buff.append( "  MORADA: " ); - morada = (String)estabelecimento.get( EstabelecimentoData.MORADA ); - buff.append( "" + ( morada == null ? "" : morada.trim() ) + "
" ); - buff.append( "  LOCALIDADE: " ); - localidade = (String)estabelecimento.get( EstabelecimentoData.LOCALIDADE ); - buff.append( "" + ( localidade == null ? "" : localidade.trim() ) + "
" ); - buff.append( "  C\u00D3DIGO POSTAL: " ); - codigoPostal = (String)estabelecimento.get( EstabelecimentoData.CODIGO_POSTAL ); - buff.append( "" + ( codigoPostal == null ? "" : codigoPostal.trim() ) + "
" ); - contacto = (ContactoData)estabelecimento.get( EstabelecimentoData.CONTACTO ); - if( contacto == null ) - { - buff.append( "  TELEFONE:
" ); - buff.append( "  FAX:
" ); - } - else - { - buff.append( "  TELEFONE: " ); - String telefone = ( String ) contacto.get( ContactoData.TELEFONE ); - buff.append( "" + ( telefone == null ? "" : telefone.trim() ) + "
" ); - buff.append( "  FAX: " ); - String fax = ( String ) contacto.get( ContactoData.TELEFONE ); - buff.append( "" + ( fax == null ? "" : fax.trim() ) + "
" ); - } - int countTrabalhadores[] = provider.countTrabalhadoresEstabelecimentoDezembro( estabelecimentos[ n ].getID(), ano ); - buff.append( "
" ); - buff.append( "  TRABALHADORES A 31 DE DEZEMBRO DE " + ano + ": " ); - buff.append( "
" ); - buff.append( "" ); - buff.append( "" ); - buff.append( "" ); - buff.append( "" ); - buff.append( "" ); - buff.append( "" - + "" - + "" - + "" ); - buff.append( "" ); - int countTrabalhadoresEtario[][] = provider.countTrabalhadoresEstabelecimentoDezembroPorGrupoEtario( estabelecimentos[ n ].getID(), ano ); - buff.append( "" ); - buff.append( "" - + "" - + "" - + "" ); - buff.append( "" ); - buff.append( "" ); - buff.append( "" - + "" - + "" - + "" ); - buff.append( "" ); - buff.append( "" ); - buff.append( "" - + "" - + "" - + "" ); - buff.append( "" ); - buff.append( "
   TOTALHOMENSMULHERES
  TOTAL " + ( countTrabalhadores[0] + countTrabalhadores[1] ) + " " + ( countTrabalhadores[0] ) + " " + ( countTrabalhadores[1] ) + "
  MENOS DE 18 ANOS " + ( countTrabalhadoresEtario[0][0] + countTrabalhadoresEtario[0][1] ) + " " + ( countTrabalhadoresEtario[0][0] ) + " " + ( countTrabalhadoresEtario[0][1] ) + "
  18 A 49 ANOS " + ( countTrabalhadoresEtario[1][0] + countTrabalhadoresEtario[1][1] ) + " " + ( countTrabalhadoresEtario[1][0] ) + " " + ( countTrabalhadoresEtario[1][1] ) + "
  MAIS DE 50 ANOS " + ( countTrabalhadoresEtario[2][0] + countTrabalhadoresEtario[2][1] ) + " " + ( countTrabalhadoresEtario[2][0] ) + " " + ( countTrabalhadoresEtario[2][1] ) + "
" ); - buff.append( "
" ); - 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( "
" ); - buff.append( "  N\u00DAMERO DE EXAMES DE ADMISS\u00C3O, PERI\u00D3DICOS E OCASIONAIS EFECTUADOS" ); - buff.append( "
" ); - buff.append( "" ); - buff.append( "" - + "" ); - buff.append( "" ); - buff.append( "" ); - for( int t = 0; t < 3; t++ ) - { - buff.append( "" ); - } - buff.append( "" ); - buff.append( "" ); - buff.append( "" ); - for( int t = 3; t < 6; t++ ) - { - buff.append( "" ); - } - buff.append( "" ); - String sexos[] = new String[]{ "H", "M" }; - for( int t = 0; t < provider.DESCRICAO_TIPOS_EXAME.length; t++ ) - { - buff.append( "" ); - - for( int s = 0; s < 2; s++ ) - { - buff.append( "" ); - buff.append( "" ); - for( int d = 0; d < 3; d++ ) - { - buff.append( "" ); - } - if( s == 0 ) - { - buff.append( "" ); - } - else - { - buff.append( "" ); - } - } - } - int countExamesOcasionais[][] = provider.countExamesOcasionaisEstabelecimentoDezembroPorGrupoEtario( estabelecimentos[ n ].getID(), ano ); - for( int t = 0; t < provider.DESCRICAO_TIPOS_OCASIONAL.length; t++ ) - { - buff.append( "" ); - - for( int s = 0; s < 2; s++ ) - { - buff.append( "" ); - int sum = countExamesOcasionais[t][s*3]+countExamesOcasionais[t][s*3+1]+countExamesOcasionais[t][s*3+2]; - buff.append( "" ); - 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( "" ); - } - if( s == 0 ) - { - buff.append( "" ); - } - else - { - buff.append( "" ); - } - } - } - buff.append( "
      TOTAL INFERIOR A 18 ANOS 18 A 49 ANOS 50 E MAIS ANOS 
   TOTAL DE EXAMES H" + ( totais[0] + totais[1] + totais[2] ) + " " + totais[t] + " 
     M" + ( totais[3] + totais[4] + totais[5] ) + " " + totais[t] + " 
    "+provider.DESCRICAO_TIPOS_EXAME[t]+" " + sexos[ s ] + "" + (countExames[t][s*3]+countExames[t][s*3+1]+countExames[t][s*3+2]) + " " + countExames[t][s*3+d] + " 
    
       "+provider.DESCRICAO_TIPOS_OCASIONAL[t]+" " + sexos[ s ] + "" + ( sum < 0 ? "-" : "" + sum ) + " " + ( val < 0 ? "-" : "" + val ) + " 
       
" ); - buff.append( "
" ); - buff.append( "  EXAMES COMPLEMENTARES REALIZADOS" ); - buff.append( "
" ); - buff.append( "" ); - buff.append( "" ); - buff.append( "" ); - 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( "" ); - buff.append( "" ); - buff.append( "" ); - buff.append( "" ); - } - buff.append( "
   TIPO DE EXAME N\u00BA TOTAL DE EXAMES
   " + nomesExamesComp[nec] + " " + countExamesComp[nec] + "
" ); - buff.append("


"); - } - - 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érica de Prevenção de Riscos Profissionais"; - String style = ""; - text = text.replace( "", "\n\t\t" + title + "\n" + style ); - text = text.replace( "", "
" ); - text = text.replace( "", "
" ); - text = text.replace( "", "\n
Relatório Anual
" ); -// String title = "S.I.P.R.P. - Sociedade Ibérica de Prevenção de Riscos Profissionais"; -// text = text.replace( "", "\n\t\t" + 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; - } - } - } -} - diff --git a/trunk/SIPRPSoft/src/siprp/update/Update.java b/trunk/SIPRPSoft/src/siprp/update/Update.java deleted file mode 100644 index a3298852..00000000 --- a/trunk/SIPRPSoft/src/siprp/update/Update.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Update.java - * - * Created on 26 de Setembro de 2006, 12:13 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.update; - -/** - * - * @author fpalma - */ -public interface Update -{ - public double getStartVersion(); - public double getEndVersion(); - public String[] listChanges(); - public void doUpdate() throws Exception; -} diff --git a/trunk/SIPRPSoft/src/siprp/update/UpdateList.java b/trunk/SIPRPSoft/src/siprp/update/UpdateList.java deleted file mode 100644 index 8556a30f..00000000 --- a/trunk/SIPRPSoft/src/siprp/update/UpdateList.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Updater.java - * - * Created on 26 de Setembro de 2006, 11:49 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.update; - -import java.util.*; - -import com.evolute.utils.*; -import com.evolute.utils.arrays.*; -import com.evolute.utils.db.*; -import com.evolute.utils.sql.*; - - -/** - * - * @author fpalma - */ -public class UpdateList -{ - protected static final Update UPDATE_LIST[] = - new Update[]{ new siprp.update.updates.V6_1_To_V7_0(), new siprp.update.updates.V7_0_To_V7_2(), - new siprp.update.updates.V7_2_To_V7_4(), new siprp.update.updates.V7_4_To_V7_5(), - new siprp.update.updates.V7_5_To_V7_6(), new siprp.update.updates.V7_6_To_V7_7() }; - - protected static Executer EXECUTER; - protected static double version = -1; - - /** Creates a new instance of Updater */ - private UpdateList() - { - } - - public static double getCurrentVersion() - throws Exception - { - if( version < 0 ) - { - version = getVersion(); - } - return version; - } - - public static Update []getUpdates() - throws Exception - { - if( version < 0 ) - { - version = getVersion(); - } - Vector validUpdates = new Vector(); - for( int n = 0; n < UPDATE_LIST.length; n++ ) - { - if( version <= UPDATE_LIST[ n ].getStartVersion() ) - { - validUpdates.add( UPDATE_LIST[ n ] ); - } - } - return ( Update [] ) validUpdates.toArray( new Update[ validUpdates.size() ] ); - } - - protected static double getVersion() - throws Exception - { - DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); - EXECUTER = dbm.getSharedExecuter(); - try - { - return readVersion(); - } - catch( Exception ex ) - { - createVersionTable(); - } - return readVersion(); - } - - protected static double readVersion() - throws Exception - { - Select select = - new Select( new String[]{ "version" }, - new String[]{ "MAX(current_version)" }, - null ); - Virtual2DArray array = EXECUTER.executeQuery( select ); - return ( ( Number ) array.get( 0, 0 ) ).doubleValue(); - } - - protected static void createVersionTable() - throws Exception - { - com.evolute.utils.sql.Update update = - new com.evolute.utils.sql.Update( "CREATE TABLE version( current_version float );" ); - EXECUTER.executeQuery( update ); - Insert insert = - new Insert( "version", - new Assignment[]{ - new Assignment( new Field( "current_version" ), new Double( 0.1 ) ) } ); - EXECUTER.executeQuery( insert ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/update/UpdateWindow.java b/trunk/SIPRPSoft/src/siprp/update/UpdateWindow.java deleted file mode 100644 index c432a9e7..00000000 --- a/trunk/SIPRPSoft/src/siprp/update/UpdateWindow.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * UpdateWindow.java - * - * Created on 26 de Setembro de 2006, 11:54 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.update; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import java.util.*; - -import com.evolute.utils.*; -import com.evolute.utils.date.*; -import com.evolute.utils.db.*; -import com.evolute.utils.sql.*; -import com.evolute.utils.ui.*; - - -/** - * - * @author fpalma - */ -public class UpdateWindow extends JFrame - implements ActionListener -{ - protected JTextArea logText; - protected JButton closeButton; - - protected Update updates[]; - protected String filename; - - public static void main( String args[] ) - { - UpdateWindow updateWindow = new UpdateWindow(); - updateWindow.update(); - } - - /** Creates a new instance of UpdateWindow */ - public UpdateWindow() - { - setupComponents(); - } - - private void setupComponents() - { - setTitle( "Actualiza\u00e7\u00e3o do Software" ); - setSize( 800, 600 ); - logText = new JTextArea(); - logText.setLineWrap( true ); - logText.setWrapStyleWord( true ); - logText.setEditable( true ); - JScrollPane scp = - new JScrollPane( logText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - closeButton = new JButton( "Fechar" ); - - setLayout( new BorderLayout() ); - add( scp, BorderLayout.CENTER ); - add( closeButton, BorderLayout.SOUTH ); - - closeButton.setEnabled( false ); - closeButton.addActionListener( this ); - - setDefaultCloseOperation( WindowConstants.DO_NOTHING_ON_CLOSE ); - } - - public void actionPerformed( ActionEvent e ) - { - Object source = e.getSource(); - if( source.equals( closeButton ) ) - { - close(); - } - } - - public void close() - { - SwingUtilities.invokeLater( new Runnable(){ - public void run() - { - setVisible( false ); - dispose(); - } - } ); - } - - public void update() - { - log( "A verificar a exist\u00eancia de actualiza\u00e7\u00f5es...\n" ); - try - { - double version = UpdateList.getCurrentVersion(); - log( "Vers\u00e3o actual: " + ( version < 6.1 ? 6.1 : version ) + "\n" ); - updates = UpdateList.getUpdates(); - } - catch( Exception ex ) - { - setVisible( true ); - log( "Erro a verificar actualiza\u00e7\u00f5es!!!" ); - ex.printStackTrace(); - updates = new Update[ 0 ]; - } - if( updates.length > 0 ) - { - setVisible( true ); - log( "Existe " + ( updates.length > 1 ? "m " : " " ) + updates.length + - " actualiza\u00e7" + ( updates.length > 1 ? "\u00f5es... " : "\u00e3o\n" ) ); - boolean ok = doUpdates(); - if( ok ) - { - log( "**** Actualiza\u00e7\u00f5es terminadas ****\n" ); - } - else - { - log( "**** Actualiza\u00e7\u00f5es abortadas ****\n" ); - log( "\nPode favor contacte a EVOLUTE\n" ); - } - - } - closeButton.setEnabled( true ); - } - - protected void log( final String newLog ) - { - SwingUtilities.invokeLater( new Runnable(){ - public void run() - { - logText.append( newLog ); - } - } ); - } - - protected boolean doUpdates() - { - double last = 0.1; - log( "**** A realizar actualiza\u00e7\u00f5es... **** \n" ); - for( int n = 0; n < updates.length; n++ ) - { - last = updates[ n ].getEndVersion(); - String msg = " " + updates[ n ] + "... \n"; - String changes[] = updates[ n ].listChanges(); - for( int c = 0; c < changes.length; c++ ) - { - msg += " " + changes[ c ] + "\n"; - } - log( msg ); - try - { - updates[ n ].doUpdate(); - } - catch( Exception ex ) - { - log( "ERRO ! ! !\nA abortar actualiza\u00e7\u00f5es\n" ); - ex.printStackTrace(); - return false; - } - } - try - { - DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); - Executer executer = dbm.getSharedExecuter(); - com.evolute.utils.sql.Update update = - new com.evolute.utils.sql.Update( "version", - new Assignment[]{ - new Assignment( new Field( "current_version" ), new Double( last ) ) }, - null ); - executer.executeQuery( update ); - log( "Vers\u00e3o actualizada para: " + last + "\n" ); - return true; - } - catch( Exception ex ) - { - log( "ERRO ! ! !\nA abortar actualiza\u00e7\u00f5es\n" ); - ex.printStackTrace(); - return false; - } - } - - public int getUpdateCount() - { - return updates.length; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/update/updates/V6_1_To_V7_0.java b/trunk/SIPRPSoft/src/siprp/update/updates/V6_1_To_V7_0.java deleted file mode 100644 index b6a7d176..00000000 --- a/trunk/SIPRPSoft/src/siprp/update/updates/V6_1_To_V7_0.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * V6_1_To_V7_0.java - * - * Created on 26 de Setembro de 2006, 11:48 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.update.updates; - -import com.evolute.utils.*; -import com.evolute.utils.arrays.*; -import com.evolute.utils.db.*; -import com.evolute.utils.sql.*; - - -/** - * - * @author fpalma - */ -public class V6_1_To_V7_0 - implements siprp.update.Update -{ - - /** - * Creates a new instance of V6_1_To_V7_0 - */ - public V6_1_To_V7_0() - { - } - - public String []listChanges() - { - return new String[]{ "Acrescentar campo de contribuinte nos prestadores", - "Acrescentar campo de prestador nas marca\u00e7\u00f5es", - "Acrescentar campo de prestador no hist\u00f3rico das marca\u00e7\u00f5es"}; - } - - public double getStartVersion() - { - return 6.1; - } - - public double getEndVersion() - { - return 7.0; - } - - public void doUpdate() - throws Exception - { - DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); - Executer executer = dbm.getSharedExecuter(); - com.evolute.utils.sql.Update update = - new com.evolute.utils.sql.Update( "ALTER TABLE prestadores ADD contribuinte VARCHAR(64);" ); - executer.executeQuery( update ); - update = new com.evolute.utils.sql.Update( "ALTER TABLE marcacoes_trabalhador ADD prestador_id int4 REFERENCES prestadores( id );" ); - executer.executeQuery( update ); - update = new com.evolute.utils.sql.Update( "ALTER TABLE marcacoes_trabalhador_estados ADD prestador_id int4 REFERENCES prestadores( id );" ); - executer.executeQuery( update ); - } - - public String toString() - { - return "v6.1 para v7.0"; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/update/updates/V7_0_To_V7_2.java b/trunk/SIPRPSoft/src/siprp/update/updates/V7_0_To_V7_2.java deleted file mode 100644 index 19f7986a..00000000 --- a/trunk/SIPRPSoft/src/siprp/update/updates/V7_0_To_V7_2.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * V7_0_To_V7_2.java - * - * Created on 26 de Setembro de 2006, 11:48 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.update.updates; - -import com.evolute.utils.*; -import com.evolute.utils.arrays.*; -import com.evolute.utils.db.*; -import com.evolute.utils.sql.*; - - -/** - * - * @author fpalma - */ -public class V7_0_To_V7_2 - implements siprp.update.Update -{ - - /** - * Creates a new instance of V7_0_To_V7_2 - */ - public V7_0_To_V7_2() - { - } - - public String []listChanges() - { - return new String[]{ "Criar tabela dos processos" }; - } - - public double getStartVersion() - { - return 7.0; - } - - public double getEndVersion() - { - return 7.2; - } - - public void doUpdate() - throws Exception - { - DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); - Executer executer = dbm.getSharedExecuter(); - com.evolute.utils.sql.Update update = - new com.evolute.utils.sql.Update( - "CREATE TABLE marcacoes_processo " - + "( " - + "id serial NOT NULL, " - + "trabalhador_id int4 NOT NULL, " - + "estado char(1) NOT NULL DEFAULT 'a'::bpchar, " - + "data_inicio date, " - + "data_fim date, " - + "CONSTRAINT marcacoes_processo_pkey PRIMARY KEY (id), " - + "CONSTRAINT marcacoes_processo_trabalhador_id_fkey FOREIGN KEY (trabalhador_id) " - + "REFERENCES trabalhadores (id) MATCH SIMPLE " - + "ON UPDATE NO ACTION ON DELETE NO ACTION " - + ") " - + "WITHOUT OIDS;" ); - executer.executeQuery( update ); - } - - public String toString() - { - return "v7.0 para v7.2"; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/update/updates/V7_2_To_V7_4.java b/trunk/SIPRPSoft/src/siprp/update/updates/V7_2_To_V7_4.java deleted file mode 100644 index 02dcc720..00000000 --- a/trunk/SIPRPSoft/src/siprp/update/updates/V7_2_To_V7_4.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * V7_2_To_V7_4.java - * - * Created on 26 de Setembro de 2006, 11:48 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.update.updates; - -import com.evolute.utils.*; -import com.evolute.utils.arrays.*; -import com.evolute.utils.db.*; -import com.evolute.utils.sql.*; - - -/** - * - * @author fpalma - */ -public class V7_2_To_V7_4 - implements siprp.update.Update -{ - - /** - * Creates a new instance of V7_2_To_V7_4 - */ - public V7_2_To_V7_4() - { - } - - public String []listChanges() - { - return new String[]{ "Acrescentar campo de motivo ao processo", - "Criar tabelas de suporte aos processos"}; - } - - public double getStartVersion() - { - return 7.2; - } - - public double getEndVersion() - { - return 7.4; - } - - public void doUpdate() - throws Exception - { - DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); - Executer executer = dbm.getSharedExecuter(); - com.evolute.utils.sql.Update update = - new com.evolute.utils.sql.Update( - "ALTER TABLE marcacoes_processo RENAME TO trabalhadores_processo;" ); - executer.executeQuery( update ); - update = - new com.evolute.utils.sql.Update( - "ALTER TABLE trabalhadores_processo ADD motivo int4;" ); - executer.executeQuery( update ); - update = - new com.evolute.utils.sql.Update( - "CREATE TABLE trabalhadores_consultas" - +"(" - +" id serial," - +" trabalhador_id int4 NOT NULL," - +" data date," - +" estado int4," - +" prestador_id int4," - +" processo_id int4," - +" CONSTRAINT trabalhadores_consultas_pkey PRIMARY KEY (id)," - +" CONSTRAINT trabalhadores_consultas_prestador_id_fkey FOREIGN KEY (prestador_id) REFERENCES prestadores (id) ON UPDATE RESTRICT ON DELETE RESTRICT," - +" CONSTRAINT trabalhadores_consultas_processo_id_fkey FOREIGN KEY (processo_id) REFERENCES trabalhadores_processo (id) ON UPDATE RESTRICT ON DELETE RESTRICT," - +" CONSTRAINT trabalhadores_consultas_trabalhador_id_fkey FOREIGN KEY (trabalhador_id) REFERENCES trabalhadores (id) ON UPDATE RESTRICT ON DELETE RESTRICT" - +") " - +"WITHOUT OIDS;" - +"ALTER TABLE trabalhadores_consultas OWNER TO postgres;" ); - executer.executeQuery( update ); - update = - new com.evolute.utils.sql.Update( - "CREATE TABLE trabalhadores_consultas_datas" - +"(" - +" id serial," - +" data date," - +" trabalhadores_consultas_id int4," - +" estado int4," - +" CONSTRAINT trabalhadores_consultas_datas_pkey PRIMARY KEY (id)," - +" CONSTRAINT trabalhadores_consultas_datas_trabalhadores_consultas_id_fkey FOREIGN KEY (trabalhadores_consultas_id) REFERENCES trabalhadores_consultas (id) ON UPDATE RESTRICT ON DELETE RESTRICT" - +") " - +"WITHOUT OIDS;" - +"ALTER TABLE trabalhadores_consultas_datas OWNER TO postgres;" ); - executer.executeQuery( update ); - update = - new com.evolute.utils.sql.Update( - "CREATE TABLE trabalhadores_consultas_datas_emails" - +"(" - +" id serial," - +" trabalhadores_consultas_datas_id int4," - +" destination varchar(512)," - +" data date," - +" subject varchar(512)," - +" body varchar(32768)," - +" CONSTRAINT trabalhadores_consultas_datas_emails_pkey PRIMARY KEY (id)," - +" CONSTRAINT trabalhadores_consultas_data_trabalhadores_consultas_data_fkey1 FOREIGN KEY (trabalhadores_consultas_datas_id) REFERENCES trabalhadores_consultas_datas (id) ON UPDATE RESTRICT ON DELETE RESTRICT" - +") " - +"WITHOUT OIDS;" - +"ALTER TABLE trabalhadores_consultas_datas_emails OWNER TO postgres;" ); - executer.executeQuery( update ); - update = - new com.evolute.utils.sql.Update( - "CREATE TABLE trabalhadores_consultas_datas_observacoes" - +"(" - +" id serial," - +" trabalhadores_consultas_datas_id int4," - +" observacao varchar(4096)," - +" CONSTRAINT trabalhadores_consultas_datas_observacoes_pkey PRIMARY KEY (id)," - +" CONSTRAINT trabalhadores_consultas_datas_trabalhadores_consultas_data_fkey FOREIGN KEY (trabalhadores_consultas_datas_id) REFERENCES trabalhadores_consultas_datas (id) ON UPDATE RESTRICT ON DELETE RESTRICT" - +") " - +"WITHOUT OIDS;" - +"ALTER TABLE trabalhadores_consultas_datas_observacoes OWNER TO postgres;" ); - executer.executeQuery( update ); - update = - new com.evolute.utils.sql.Update( - "CREATE TABLE trabalhadores_ecds" - +"(" - +" id serial," - +" trabalhador_id int4," - +" estado int4," - +" data date," - +" processo_id int4," - +" CONSTRAINT trabalhadores_ecgs_pkey PRIMARY KEY (id)," - +" CONSTRAINT trabalhadores_ecds_processo_id_fkey FOREIGN KEY (processo_id) REFERENCES trabalhadores_processo (id) ON UPDATE RESTRICT ON DELETE RESTRICT," - +" CONSTRAINT trabalhadores_ecgs_trabalhador_id_fkey FOREIGN KEY (trabalhador_id) REFERENCES trabalhadores (id) ON UPDATE RESTRICT ON DELETE RESTRICT" - +") " - +"WITHOUT OIDS;" - +"ALTER TABLE trabalhadores_ecds OWNER TO postgres;" ); - executer.executeQuery( update ); - update = - new com.evolute.utils.sql.Update( - "CREATE TABLE trabalhadores_ecds_datas" - +"(" - +" id serial," - +" trabalhadores_ecds_id int4," - +" data date," - +" estado int4," - +" CONSTRAINT trabalhadores_ecds_datas_pkey PRIMARY KEY (id)," - +" CONSTRAINT trabalhadores_ecds_datas_trabalhadores_ecds_id_fkey FOREIGN KEY (trabalhadores_ecds_id) REFERENCES trabalhadores_ecds (id) ON UPDATE RESTRICT ON DELETE RESTRICT" - +") " - +"WITHOUT OIDS;" - +"ALTER TABLE trabalhadores_ecds_datas OWNER TO postgres;" ); - executer.executeQuery( update ); - update = - new com.evolute.utils.sql.Update( - "CREATE TABLE trabalhadores_ecd" - +"(" - +" id int4 NOT NULL," - +" ecd_id int4," - +" ecd_oficial_id int4," - +" prestador_id int4," - +" estado int4," - +" trabalhadores_ecds_id int4," - +" trabalhadores_ecds_datas_id int4," - +" CONSTRAINT trabalhadores_ecg_pkey PRIMARY KEY (id)," - +" CONSTRAINT trabalhadores_ecd_trabalhadores_ecds_datas_id_fkey FOREIGN KEY (trabalhadores_ecds_datas_id) REFERENCES trabalhadores_ecds_datas (id) ON UPDATE RESTRICT ON DELETE RESTRICT," - +" CONSTRAINT trabalhadores_ecd_trabalhadores_ecds_id_fkey FOREIGN KEY (trabalhadores_ecds_id) REFERENCES trabalhadores_ecds (id) ON UPDATE RESTRICT ON DELETE RESTRICT," - +" CONSTRAINT trabalhadores_ecg_ecd_id_fkey FOREIGN KEY (ecd_id) REFERENCES prt_tipos_elementos_protocolo (id) ON UPDATE RESTRICT ON DELETE RESTRICT," - +" CONSTRAINT trabalhadores_ecg_ecd_oficial_id_fkey FOREIGN KEY (ecd_oficial_id) REFERENCES ecd_oficial (id) ON UPDATE RESTRICT ON DELETE RESTRICT," - +" CONSTRAINT trabalhadores_ecg_prestador_id_fkey FOREIGN KEY (prestador_id) REFERENCES prestadores (id) ON UPDATE RESTRICT ON DELETE RESTRICT" - +") " - +"WITHOUT OIDS;" - +"ALTER TABLE trabalhadores_ecd OWNER TO postgres;" ); - executer.executeQuery( update ); - update = - new com.evolute.utils.sql.Update( - "CREATE TABLE trabalhadores_ecds_datas_emails" - +"(" - +" id serial," - +" trabalhadores_ecds_datas_id int4," - +" destination varchar(512)," - +" data date," - +" subject varchar(512)," - +" body varchar(32768)," - +" CONSTRAINT trabalhadores_ecds_datas_emails_pkey PRIMARY KEY (id)," - +" CONSTRAINT trabalhadores_ecds_datas_email_trabalhadores_ecds_datas_id_fkey FOREIGN KEY (trabalhadores_ecds_datas_id) REFERENCES trabalhadores_ecds_datas (id) ON UPDATE RESTRICT ON DELETE RESTRICT" - +") " - +"WITHOUT OIDS;" - +"ALTER TABLE trabalhadores_ecds_datas_emails OWNER TO postgres;" ); - executer.executeQuery( update ); - update = - new com.evolute.utils.sql.Update( - "CREATE TABLE trabalhadores_ecds_datas_observacoes" - +"(" - +" id serial," - +" trabalhadores_ecds_datas_id int4," - +" observacao varchar(4096)," - +" CONSTRAINT trabalhadores_ecds_datas_observacoes_pkey PRIMARY KEY (id)," - +" CONSTRAINT trabalhadores_ecds_datas_obser_trabalhadores_ecds_datas_id_fkey FOREIGN KEY (trabalhadores_ecds_datas_id) REFERENCES trabalhadores_ecds_datas (id) ON UPDATE RESTRICT ON DELETE RESTRICT" - +") " - +"WITHOUT OIDS;" - +"ALTER TABLE trabalhadores_ecds_datas_observacoes OWNER TO postgres;" ); - executer.executeQuery( update ); - - } - - public String toString() - { - return "v7.2 para v7.4"; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/update/updates/V7_4_To_V7_5.java b/trunk/SIPRPSoft/src/siprp/update/updates/V7_4_To_V7_5.java deleted file mode 100644 index 792157d0..00000000 --- a/trunk/SIPRPSoft/src/siprp/update/updates/V7_4_To_V7_5.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * V7_4_To_V7_5.java - * - * Created on 26 de Setembro de 2006, 11:48 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.update.updates; - -import com.evolute.utils.*; -import com.evolute.utils.arrays.*; -import com.evolute.utils.db.*; -import com.evolute.utils.sql.*; - - -/** - * - * @author fpalma - */ -public class V7_4_To_V7_5 - implements siprp.update.Update -{ - - /** - * Creates a new instance of V7_4_To_V7_5 - */ - public V7_4_To_V7_5() - { - } - - public String []listChanges() - { - return new String[]{ "Ligar processo a ficha de aptid\u00e3o" }; - } - - public double getStartVersion() - { - return 7.4; - } - - public double getEndVersion() - { - return 7.5; - } - - public void doUpdate() - throws Exception - { - DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); - Executer executer = dbm.getSharedExecuter(); - com.evolute.utils.sql.Update update = - new com.evolute.utils.sql.Update( - "CREATE TABLE trabalhadores_fichas_aptidao" - +"(" - +" id serial," - +" processo_id int4," - +" exame_id int4," - +" CONSTRAINT trabalhadores_fichas_aptidao_pkey PRIMARY KEY (id)," - +" CONSTRAINT trabalhadores_fichas_aptidao_exame_id_fkey FOREIGN KEY (exame_id) REFERENCES exames (id) ON UPDATE RESTRICT ON DELETE RESTRICT," - +" CONSTRAINT trabalhadores_fichas_aptidao_processo_id_fkey FOREIGN KEY (processo_id) REFERENCES trabalhadores_processo (id) ON UPDATE RESTRICT ON DELETE RESTRICT" - +")" - +"WITHOUT OIDS;" - +"ALTER TABLE trabalhadores_fichas_aptidao OWNER TO postgres;" ); - executer.executeQuery( update ); - } - - public String toString() - { - return "v7.4 para v7.5"; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/update/updates/V7_5_To_V7_6.java b/trunk/SIPRPSoft/src/siprp/update/updates/V7_5_To_V7_6.java deleted file mode 100644 index af850998..00000000 --- a/trunk/SIPRPSoft/src/siprp/update/updates/V7_5_To_V7_6.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * V7_5_To_V7_6.java - * - * Created on 26 de Setembro de 2006, 11:48 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.update.updates; - -import com.evolute.utils.*; -import com.evolute.utils.arrays.*; -import com.evolute.utils.db.*; -import com.evolute.utils.sql.*; - - -/** - * - * @author fpalma - */ -public class V7_5_To_V7_6 - implements siprp.update.Update -{ - - /** - * Creates a new instance of V7_5_To_V7_6 - */ - public V7_5_To_V7_6() - { - } - - public String []listChanges() - { - return new String[]{ "Alterar tabela dos processos" }; - } - - public double getStartVersion() - { - return 7.5; - } - - public double getEndVersion() - { - return 7.6; - } - - public void doUpdate() - throws Exception - { - DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); - Executer executer = dbm.getSharedExecuter(); - com.evolute.utils.sql.Update update = - new com.evolute.utils.sql.Update( - "ALTER TABLE trabalhadores_processo ADD sub_motivo int4;" ); - executer.executeQuery( update ); - } - - public String toString() - { - return "v7.5 para v7.6"; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/update/updates/V7_6_To_V7_7.java b/trunk/SIPRPSoft/src/siprp/update/updates/V7_6_To_V7_7.java deleted file mode 100644 index f393c465..00000000 --- a/trunk/SIPRPSoft/src/siprp/update/updates/V7_6_To_V7_7.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * V7_6_To_V7_7.java - * - * Created on May 15, 2007, 3:12 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.update.updates; - -import com.evolute.utils.Singleton; -import com.evolute.utils.db.DBManager; -import com.evolute.utils.db.Executer; -import com.evolute.utils.sql.Assignment; -import com.evolute.utils.sql.Field; - -/** - * - * @author lflores - */ -public class V7_6_To_V7_7 - implements siprp.update.Update -{ - - /** - * Creates a new instance of V7_6_To_V7_7 - */ - public V7_6_To_V7_7() - { - } - - public String []listChanges() - { - return new String[]{ "Alterar tabela dos exames e criar tabela exames_portaria" }; - } - - public double getStartVersion() - { - return 7.6; - } - - public double getEndVersion() - { - return 7.7; - } - - public void doUpdate() - throws Exception - { - DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); - Executer executer = dbm.getSharedExecuter(); - com.evolute.utils.sql.Update update = - new com.evolute.utils.sql.Update( - "ALTER TABLE exames ADD fo BYTEA;" ); - executer.executeQuery( update ); - update = new com.evolute.utils.sql.Update( - "CREATE TABLE exames_portaria ( id SERIAL NOT NULL, portaria VARCHAR(255) NOT NULL, " - + "data_entrada timestamp without time zone NOT NULL DEFAULT now(), PRIMARY KEY( id ) );" ); - executer.executeQuery( update ); - com.evolute.utils.sql.Insert insert = - new com.evolute.utils.sql.Insert( "exames_portaria", - new Assignment[]{ new Assignment( new Field( "portaria" ), "Portaria n. 299/2007, de 16 de Mar\u00e7o" ) } ); - executer.executeQuery( insert ); - } - - public String toString() - { - return "v" + getStartVersion() + " para v" + getEndVersion(); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/web/WebUpdater.java b/trunk/SIPRPSoft/src/siprp/web/WebUpdater.java deleted file mode 100644 index cf84448f..00000000 --- a/trunk/SIPRPSoft/src/siprp/web/WebUpdater.java +++ /dev/null @@ -1,1210 +0,0 @@ -/* - * WebUpdater.java - * - * Created on 27 de Outubro de 2004, 15:54 - */ - -package siprp.web; - -import java.awt.*; -import java.awt.event.*; -import java.io.*; -import java.sql.*; -import javax.swing.*; -import javax.swing.event.*; -import java.util.*; - -//import siprp.*; -//import siprp.clientes.*; - -/** - * - * @author fpalma - */ -public class WebUpdater extends JFrame - implements ActionListener, Runnable, DocumentListener -{ - private Connection softwareConnection; - private Connection webConnection; - - public static final String GET_ULTIMA_ACTUALIZACAO = "SELECT stamp FROM actualizacao"; - - public static final String GET_EMPRESAS = - "SELECT id, designacao_social, perfil_1, perfil_2, codigo_1, codigo_2, " - + "codigo_3, cae, contribuinte, seguranca_social, actividade, servicos, morada, " - + "localidade, codigo_postal, distrito, concelho, inactivo, contacto_1 " - + "FROM empresas WHERE actualizacao >= "; - - public static final String GET_EMAIL = - "SELECT email FROM contactos WHERE id = "; - - public static final String GET_ESTABELECIMENTOS = - "SELECT id, empresa_id, nome, contacto, morada, localidade, codigo_postal, inactivo " - + "FROM estabelecimentos WHERE actualizacao >= "; - - public static final String GET_TRABALHADORES = - "SELECT id, nome, sexo, data_nascimento, numero_mecanografico, categoria, estabelecimento_id, data_demissao, inactivo " - + "FROM trabalhadores WHERE actualizacao >= "; - - public static final String GET_CONTACTO = - "SELECT nome, telefone, telemovel, fax, email, cargo FROM contactos WHERE id = "; - - public static final String GET_MARCACOES_ESTABELECIMENTO = - "SELECT id, data, realizada, data_relatorio FROM marcacoes_estabelecimento " - + "WHERE estabelecimento_id = "; - - public static final String GET_EXAMES_TRABALHADOR = - "SELECT id, data, realizada, data_relatorio FROM marcacoes_trabalhador " - + "WHERE tipo = 0 and trabalhador_id = ?trabalhador_id " - + "ORDER BY data"; - - public static final String GET_CONSULTAS_TRABALHADOR = - "SELECT id, data, realizada, data_relatorio FROM marcacoes_trabalhador " - + "WHERE tipo = 1 and trabalhador_id = ?trabalhador_id " - + "ORDER BY data"; - - public static final String GET_ID_FICHA_APTIDAO = - "SELECT MAX(id) FROM exames WHERE trabalhador_id = ?trabalhador_id AND inactivo <> 'y'"; - - public static final String GET_DADOS_FICHA_APTIDAO = - "SELECT data, resultado FROM exames WHERE id = ?id"; - - public static final String DELETE_TRABALHADOR = - "DELETE FROM trabalhadores WHERE id = "; - - public static final String DELETE_TRABALHADORES_BY_ESTABELECIMENTO = - "DELETE FROM trabalhadores WHERE estabelecimento_id = "; - - public static final String DELETE_ESTABELECIMENTO = - "DELETE FROM estabelecimentos WHERE id = "; - - public static final String DELETE_ESTABELECIMENTOS_BY_EMPRESA = - "DELETE FROM estabelecimentos WHERE empresa_id = "; - - public static final String DELETE_TRABALHADORES_BY_EMPRESA = - "DELETE FROM trabalhadores WHERE estabelecimento_id IN ( SELECT id FROM estabelecimentos WHERE empresa_id = ?empresa_id )"; - - public static final String DELETE_EMPRESA = - "DELETE FROM empresas WHERE id = "; - - public static final String CREATE_EMPRESA = - "INSERT INTO empresas(id) VALUES( ?id )"; - - public static final String CREATE_ESTABELECIMENTO = - "INSERT INTO estabelecimentos(id) VALUES( ?id )"; - - public static final String CREATE_TRABALHADOR = - "INSERT INTO trabalhadores(id) VALUES( ?id )"; - - public static final String UPDATE_EMPRESA = - "UPDATE empresas SET morada = ?morada, codigo_postal = ?codigo_postal, " - + "localidade = ?localidade, distrito = ?distrito, concelho = ?concelho, " - + "perfil_1 = ?perfil_1, perfil_2 = ?perfil_2, codigo = ?codigo, cae = ?cae, " - + "contribuinte = ?contribuinte, seguranca_social = ?seguranca_social, " - + "actividade = ?actividade, servicos = ?servicos, designacao_social = ?designacao_social, " - + "email = ?email " - + "WHERE id = ?id"; - - public static final String UPDATE_ESTABELECIMENTO = - "UPDATE estabelecimentos SET empresa_id = ?empresa_id, morada = ?morada, " - + "codigo_postal = ?codigo_postal, localidade = ?localidade, " - + "ultima_visita = ?ultima_visita, realizada = ?realizada, " - + "proxima_visita = ?proxima_visita, nome = ?nome " - + "WHERE id = ?id"; - - public static final String UPDATE_TRABALHADOR = - "UPDATE trabalhadores SET sexo = ?sexo, data_nascimento = ?data_nascimento, " - + "numero_mecanografico = ?numero_mecanografico, categoria = ?categoria, " - + "ultimo_exame = ?ultimo_exame, realizado = ?realizado, proximo_exame = ?proximo_exame, " - + "ultima_consulta = ?ultima_consulta, realizada = ?realizada, " - + "proxima_consulta = ?proxima_consulta, nome = ?nome, " - + "resultado = ?resultado, data_ficha = ?data_ficha, " - + "estabelecimento_id = ?estabelecimento_id " - + "WHERE id = ?id"; - - public static final String UPDATE_ACTUALIZACAO = "UPDATE actualizacao SET stamp = "; - - - public static final String PROPERTIES_FILE = "updtprop.txt"; - public static final String PROP_LOCAL = "interno"; - public static final String PROP_LOCAL_U = "iuser"; - public static final String PROP_LOCAL_P = "ipasswd"; - public static final String PROP_REMOTE = "externo"; - public static final String PROP_REMOTE_U = "euser"; - public static final String PROP_REMOTE_P = "epasswd"; - public static final String PROP_INTERVAL = "intervalo"; - - - protected Vector deletes; - protected Vector updates; - - protected Thread updateThread; - - protected JTextField servidorInternoText; - protected JTextField servidorExternoText; - protected JTextField intervaloText; - protected JTextField ultimaActualizacaoText; - protected JTextField proximaActualizacaoText; - protected JButton actionButton; - protected JButton saveButton; - protected JButton cancelButton; - protected JLabel stateLabel; - - protected boolean running; - protected String servidorInterno; - protected String servidorExterno; - protected String internalUser; - protected String internalPassword; - protected String externalUser; - protected String externalPassword; - protected long intervalo; - - /** Creates a new instance of WebUpdater */ - public WebUpdater() - { - deletes = new Vector(); - updates = new Vector(); - running = false; - servidorInterno = "ws_fpalma"; - servidorExterno = "localhost:5436"; - intervalo = 10; - setupComponents(); - } - - protected void setupComponents() - { - setSize( 500, 200 ); - setResizable( false ); - setTitle( "Actualiza\u00e7\u00e3o do Site" ); - JLabel servidorInternoLabel = new JLabel( "Servidor Interno" ); - servidorInternoText = new JTextField(); - servidorInternoText.setPreferredSize( new Dimension( 120, 20 ) ); - servidorInternoText.setForeground( Color.red ); - JLabel servidorExternoLabel = new JLabel( "Servidor Externo" ); - servidorExternoText = new JTextField(); - servidorExternoText.setPreferredSize( new Dimension( 120, 20 ) ); - servidorExternoText.setForeground( Color.red ); - JLabel intervaloLabel = new JLabel( "Intervalo de Actualiza\u00e7\u00e3o (minutos)" ); - intervaloText = new JTextField(); - intervaloText.setPreferredSize( new Dimension( 50, 20 ) ); - JLabel ultimaActualizacaoLabel = new JLabel( "\u00daltima Actualiza\u00e7\u00e3o" ); - ultimaActualizacaoText = new JTextField(); - ultimaActualizacaoText.setPreferredSize( new Dimension( 120, 20 ) ); - ultimaActualizacaoText.setEditable( false ); - JLabel proximaActualizacaoLabel = new JLabel( "Pr\u00f3xima Actualiza\u00e7\u00e3o" ); - proximaActualizacaoText = new JTextField(); - proximaActualizacaoText.setPreferredSize( new Dimension( 120, 20 ) ); - proximaActualizacaoText.setEditable( false ); - actionButton = new JButton( "Executar" ); - saveButton = new JButton( "Guardar Altera\u00e7\u00f5es" ); - saveButton.setEnabled( false ); - cancelButton = new JButton( "Cancelar Altera\u00e7\u00f5es" ); - cancelButton.setEnabled( false ); - stateLabel = new JLabel( " " ); - JPanel buttonPanel = new JPanel(); - JPanel pad = new JPanel(); - pad.setPreferredSize( new Dimension( 120, 20 ) ); - - Container container = getContentPane(); - GridBagLayout gridbag = new GridBagLayout(); - container.setLayout( gridbag ); - GridBagConstraints constraints = new GridBagConstraints(); - constraints.insets = new Insets( 1, 1, 1, 1 ); -// constraints.anchor = GridBagConstraints.EAST; - constraints.fill = GridBagConstraints.BOTH; - constraints.weighty = 0; - constraints.gridheight = 1; - - constraints.weightx = 0; - constraints.gridwidth = 1; - gridbag.setConstraints( servidorInternoLabel, constraints ); - gridbag.setConstraints( servidorExternoLabel, constraints ); - gridbag.setConstraints( intervaloLabel, constraints ); - gridbag.setConstraints( ultimaActualizacaoLabel, constraints ); - gridbag.setConstraints( proximaActualizacaoLabel, constraints ); - - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( servidorInternoText, constraints ); - gridbag.setConstraints( servidorExternoText, constraints ); - gridbag.setConstraints( ultimaActualizacaoText, constraints ); - gridbag.setConstraints( proximaActualizacaoText, constraints ); - gridbag.setConstraints( buttonPanel, constraints ); - gridbag.setConstraints( stateLabel, constraints ); - - constraints.weightx = 0.5; - constraints.gridwidth = 1; - gridbag.setConstraints( intervaloText, constraints ); - - constraints.weightx = 0.5; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( pad, constraints ); - - container.add( servidorInternoLabel ); - container.add( servidorInternoText ); - container.add( servidorExternoLabel ); - container.add( servidorExternoText ); - container.add( intervaloLabel ); - container.add( intervaloText ); - container.add( pad ); - container.add( ultimaActualizacaoLabel ); - container.add( ultimaActualizacaoText ); - container.add( proximaActualizacaoLabel ); - container.add( proximaActualizacaoText ); - container.add( buttonPanel ); - container.add( stateLabel ); - - buttonPanel.setLayout( new FlowLayout( FlowLayout.RIGHT ) ); - buttonPanel.add( saveButton ); - buttonPanel.add( cancelButton ); - buttonPanel.add( actionButton ); - - actionButton.addActionListener( this ); - stateLabel.setText( "Parado" ); - stateLabel.setForeground( Color.red ); - -// servidorInternoText.setText( servidorInterno ); -// servidorExternoText.setText( servidorExterno ); -// intervaloText.setText( "" + intervalo ); - reload(); - - servidorInternoText.getDocument().addDocumentListener( this ); - servidorExternoText.getDocument().addDocumentListener( this ); - intervaloText.getDocument().addDocumentListener( this ); - saveButton.addActionListener( this ); - cancelButton.addActionListener( this ); - } - - public void actionPerformed(java.awt.event.ActionEvent actionEvent) - { - Object source = actionEvent.getSource(); - if( actionButton.equals( source ) ) - { - if( running ) - { - running = false; - updateThread.interrupt(); - actionButton.setText( "Executar" ); - stateLabel.setText( "Parado" ); - stateLabel.setBackground( Color.red ); - } - else - { - updateThread = new Thread( this ); - updateThread.start(); - actionButton.setText( "Parar" ); - } - } - else if( saveButton.equals( source ) ) - { - save(); - saveButton.setEnabled( false ); - cancelButton.setEnabled( false ); - } - else if( cancelButton.equals( source ) ) - { - reload(); - saveButton.setEnabled( false ); - cancelButton.setEnabled( false ); - } - } - - - public void changedUpdate(javax.swing.event.DocumentEvent documentEvent) - { - saveButton.setEnabled( true ); - cancelButton.setEnabled( true ); - } - - public void insertUpdate(javax.swing.event.DocumentEvent documentEvent) - { - saveButton.setEnabled( true ); - cancelButton.setEnabled( true ); - } - - public void removeUpdate(javax.swing.event.DocumentEvent documentEvent) - { - saveButton.setEnabled( true ); - cancelButton.setEnabled( true ); - } - - protected void save() - { - Properties props = new Properties(); - try - { - OutputStream out = new FileOutputStream( PROPERTIES_FILE ); - String auxSI = servidorInternoText.getText(); - String auxSE = servidorExternoText.getText(); - String auxI = intervaloText.getText();; - if( auxSI == null || auxSI.length() == 0 || - auxSE == null || auxSE.length() == 0 || - auxI == null || auxI.length() == 0 ) - { - throw new Exception( "" ); - } - intervalo = Long.parseLong( auxI ); - servidorInterno = auxSI; - servidorExterno = auxSE; - props.setProperty( PROP_LOCAL, servidorInterno ); - props.setProperty( PROP_LOCAL_U, internalUser ); - props.setProperty( PROP_LOCAL_P, internalPassword ); - props.setProperty( PROP_REMOTE, servidorExterno ); - props.setProperty( PROP_REMOTE_U, externalUser ); - props.setProperty( PROP_REMOTE_P, externalPassword ); - props.setProperty( PROP_INTERVAL, "" + intervalo ); - props.store( out, "Configura\u00e7\u00e3o da Ferramenta de Actualiza\u00e7\u00e3o da SIPRP" ); - out.close(); - } - catch( Exception ex ) - { - JOptionPane.showMessageDialog( this, "Erro a gravar altera\u00e7\u00f5es", "Erro", - JOptionPane.ERROR_MESSAGE ); - } - } - - protected void reload() - { - Properties props = new Properties(); - try - { - -System.out.println( new File( PROPERTIES_FILE ) ); - InputStream in = new FileInputStream( PROPERTIES_FILE ); - props.load( in ); - internalUser = props.getProperty( PROP_LOCAL_U ); - internalPassword = props.getProperty( PROP_LOCAL_P ); - externalUser = props.getProperty( PROP_REMOTE_U ); - externalPassword = props.getProperty( PROP_REMOTE_P ); - - String aux; - aux = props.getProperty( PROP_LOCAL ); - if( aux != null && aux.length() > 0 ) - { - servidorInterno = aux; - } - aux = props.getProperty( PROP_REMOTE ); - if( aux != null && aux.length() > 0 ) - { - servidorExterno = aux; - } - aux = props.getProperty( PROP_INTERVAL ); - if( aux != null && aux.length() > 0 ) - { - try - { - intervalo = Long.parseLong( aux ); - } - catch( NumberFormatException nfe ) - { - } - } - - } - catch( Exception ex ) - { - JOptionPane.showMessageDialog( this, "Erro a carregar os dados", "Erro", - JOptionPane.ERROR_MESSAGE ); - } - servidorInternoText.setText( servidorInterno ); - servidorExternoText.setText( servidorExterno ); - intervaloText.setText( "" + intervalo ); - } - - public void run() - { - running = true; - while( true ) - { - boolean erro = false; - if( !running ) - { - return; - } - proximaActualizacaoText.setText( "" ); - try - { - stateLabel.setText( "A Actualizar" ); - stateLabel.setForeground( Color.green ); - doUpdates(); - java.util.Date date = new java.util.Date(); - ultimaActualizacaoText.setText( date.toString() ); - } - catch( Exception ex ) - { - erro = true; - stateLabel.setText( "ERRO A ACTUALIZAR!!!" ); - stateLabel.setForeground( Color.red ); - } - if( !running ) - { - return; - } - try - { - if( !erro ) - { - stateLabel.setText( "Em Intervalo (" + intervalo + " minuto" + ( intervalo > 1 ? "s" : "" ) + ")" ); - stateLabel.setForeground( Color.black ); - } - Calendar cal = Calendar.getInstance(); - cal.add( Calendar.MINUTE, (int)intervalo ); - proximaActualizacaoText.setText( "" + cal.getTime() ); - Thread.sleep( intervalo * 60000 ); - } - catch( InterruptedException iex ) - { - } - } - } - - protected void doUpdates() - throws Exception - { - try - { - connect(); - getData(); - updateData(); - } - catch( Exception ex ) - { - ex.printStackTrace(); - throw ex; - } - - } - - /** - * @param args the command line arguments - */ - public static void main( String[] args ) - throws Exception - { - WebUpdater updater = new WebUpdater(); - updater.show(); - } - - protected void connect() - throws Exception - { - Class.forName( "org.postgresql.Driver" ); - Class.forName( "com.mysql.jdbc.Driver" ); - webConnection = DriverManager.getConnection( "jdbc:postgresql://" + servidorExterno + "/siprp", externalUser, externalPassword ); - webConnection.setAutoCommit( true ); - softwareConnection = DriverManager.getConnection( "jdbc:mysql://" + servidorInterno + "/siprp", internalUser, internalPassword ); -// softwareConnection = DriverManager.getConnection( "jdbc:postgresql://" + servidorInterno + "/siprp", internalUser, internalPassword ); - softwareConnection.setAutoCommit( true ); - } - - protected void getData() - throws Exception - { - Object r[][]; - r = doQuery( webConnection, GET_ULTIMA_ACTUALIZACAO ); - String actualizacao = "'" + r[0][0] + "'"; - Calendar cal = Calendar.getInstance(); - //int hour = cal.get( Calendar.HOUR_OF_DAY ); - //if( hour < 3 && hour > 1 ) - //{ - // actualizacao = "'1970-01-01 00:00:00'"; - //} - doQuery(softwareConnection, "DELETE FROM actualizacao;", true); - doQuery(softwareConnection, "INSERT INTO actualizacao(hora) VALUES(now());", true); - readTrabalhadores( actualizacao ); - readEstabelecimentos( actualizacao ); - readEmpresas( actualizacao ); - } - - protected void updateData() - throws Exception - { - System.out.println( "DELETES" ); - for( int d = 0; d < deletes.size(); d++ ) - { - try - { - System.out.println( deletes.elementAt( d ).toString() ); - doQuery( webConnection, deletes.elementAt( d ).toString(), true ); - } - catch( Exception ex ) - { - ex.printStackTrace(); - } - } - System.out.println( "" ); - System.out.println( "UPDATES" ); - for( int u = 0; u < updates.size(); u++ ) - { - String queries[] = ( String[] ) updates.elementAt( u ); - System.out.println( queries[ 0 ] + "\n " + queries[ 1 ] ); - try - { - doQuery( webConnection, queries[ 0 ], true ); - } - catch( Exception ex ) - { - System.out.println( " ERRO DE INSERT" ); - } - try - { - doQuery( webConnection, queries[ 1 ], true ); - } - catch( Exception ex ) - { - ex.printStackTrace(); - } - } - Object r[][] = doQuery( softwareConnection, "SELECT hora FROM actualizacao;" ); - String actualizacao = "'" + r[0][0] + "'"; - doQuery( webConnection, UPDATE_ACTUALIZACAO + actualizacao, true ); - } - - protected void readTrabalhadores( String actualizacao ) - throws Exception - { - Object trabalhadores[][] = doQuery( softwareConnection, GET_TRABALHADORES + actualizacao ); - for( int t = 0; t < trabalhadores.length; t++ ) - { - for( int c = 0; c < trabalhadores[ t ].length; c++ ) - { - if( trabalhadores[ t ][ c ] instanceof String ) - { - trabalhadores[ t ][ c ] = unicodeToHTML( (String) trabalhadores[ t ][ c ] ); - } - } - int id = ( ( Number ) trabalhadores[t][0] ).intValue(); - boolean inactivo = "y".equals( trabalhadores[ t ][ trabalhadores[ t ].length - 1 ] ) || - trabalhadores[ t ][ trabalhadores[ t ].length - 2 ] != null; - if( inactivo ) - { - deletes.add( DELETE_TRABALHADOR + id ); - continue; - } - String queries[] = new String[ 2 ]; - updates.insertElementAt( queries, 0 ); - queries[ 0 ] = CREATE_TRABALHADOR.replaceFirst( "[?]id", "" + id ); - String update = UPDATE_TRABALHADOR.replaceFirst( "[?]id", "" + id ); - - String nome = "'" + trabalhadores[ t ][ 1 ] + "'"; - update = update.replaceFirst( "[?]nome", nome ); - String sexo = "'" + trabalhadores[ t ][ 2 ] + "'"; - update = update.replaceFirst( "[?]sexo", sexo ); - String dataNasc; - if( trabalhadores[ t ][ 3 ] != null ) - { - dataNasc = "'" + trabalhadores[ t ][ 3 ] + "'"; - } - else - { - dataNasc = "''"; - } - update = update.replaceFirst( "[?]data_nascimento", dataNasc ); - String numeroMecanografico; - if( trabalhadores[ t ][ 4 ] != null ) - { - numeroMecanografico = "'" + trabalhadores[ t ][ 4 ] + "'"; - } - else - { - numeroMecanografico = "''"; - } - update = update.replaceFirst( "[?]numero_mecanografico", numeroMecanografico ); - String categoria; - if( trabalhadores[ t ][ 5 ] != null ) - { - categoria = "'" + trabalhadores[ t ][ 5 ] + "'"; - } - else - { - categoria = "''"; - } - update = update.replaceFirst( "[?]categoria", categoria ); - int estabelecimentoID = ( ( Number ) trabalhadores[t][6] ).intValue(); - update = update.replaceFirst( "[?]estabelecimento_id", "" + estabelecimentoID ); - Object exames[][] = doQuery( softwareConnection, - GET_EXAMES_TRABALHADOR.replaceFirst( "[?]trabalhador_id", ""+id ) ); - - if( exames != null && exames.length > 0 ) - { - java.util.Date dataExame2 = ( java.util.Date ) exames[ exames.length - 1 ] [ 1 ]; - String realizado2 = ( String ) exames[ exames.length - 1 ][ 2 ]; - java.util.Date dataExame1; - String realizado1; - if( exames.length >= 2 ) - { - dataExame1 = ( java.util.Date ) exames[ exames.length - 2 ] [ 1 ]; - realizado1 = ( String ) exames[ exames.length - 2 ][ 2 ]; - } - else - { - dataExame1 = dataExame2; - realizado1 = realizado2; - } - if( "y".equals( realizado2 ) ) - { - update = update.replaceFirst( "[?]ultimo_exame", "'" + dataExame2 + "'" ); - update = update.replaceFirst( "[?]realizado", "'" + realizado2 + "'" ); - update = update.replaceFirst( "[?]proximo_exame", "null" ); - } - else if( new java.util.Date().after( dataExame2 ) ) - { - update = update.replaceFirst( "[?]ultimo_exame", "'" + dataExame2 + "'" ); - update = update.replaceFirst( "[?]realizado", "'" + realizado2 + "'" ); - update = update.replaceFirst( "[?]proximo_exame", "null" ); - } - else - { - update = update.replaceFirst( "[?]proximo_exame", "'" + dataExame2 + "'" ); - if( !dataExame2.equals( dataExame1 ) ) - { - update = update.replaceFirst( "[?]ultimo_exame", "'" + dataExame1 + "'" ); - update = update.replaceFirst( "[?]realizado", "'" + realizado1 + "'" ); - } - else - { - update = update.replaceFirst( "[?]ultimo_exame", "null" ); - update = update.replaceFirst( "[?]realizado", "null" ); - } - } - } - else - { - update = update.replaceFirst( "[?]ultimo_exame", "null" ); - update = update.replaceFirst( "[?]realizado", "null" ); - update = update.replaceFirst( "[?]proximo_exame", "null" ); - } - Object consultas[][] = doQuery( softwareConnection, - GET_CONSULTAS_TRABALHADOR.replaceFirst( "[?]trabalhador_id", ""+id ) ); - - if( consultas != null && consultas.length > 0 ) - { - java.util.Date dataConsulta2 = ( java.util.Date ) consultas[ consultas.length - 1 ] [ 1 ]; - String realizada2 = ( String ) consultas[ consultas.length - 1 ][ 2 ]; - java.util.Date dataConsulta1; - java.util.Date dataRelatorio1; - java.util.Date dataRelatorio2 = (java.util.Date) consultas[ consultas.length - 1 ][ 3 ]; - String realizada1; - if( consultas.length >= 2 ) - { - dataConsulta1 = ( java.util.Date ) consultas[ consultas.length - 2 ] [ 1 ]; - realizada1 = ( String ) consultas[ consultas.length - 2 ][ 2 ]; - dataRelatorio1 = (java.util.Date) consultas[ consultas.length - 2 ][ 3 ]; - } - else - { - dataConsulta1 = dataConsulta2; - realizada1 = realizada2; - dataRelatorio1 = dataRelatorio2; - } - if( "y".equals( realizada2 ) ) - { - update = update.replaceFirst( "[?]ultima_consulta", "'" + dataConsulta2 + "'" ); - update = update.replaceFirst( "[?]realizada", "'" + realizada2 + "'" ); - update = update.replaceFirst( "[?]proxima_consulta", "null" ); - if( dataRelatorio2 != null ) - { - update = update.replaceFirst( "[?]data_ficha", "'" + dataRelatorio2 + "'" ); - } - else - { - update = update.replaceFirst( "[?]data_ficha", "null" ); - } - } - else if( new java.util.Date().after( dataConsulta2 ) ) - { - update = update.replaceFirst( "[?]ultima_consulta", "'" + dataConsulta2 + "'" ); - update = update.replaceFirst( "[?]realizada", "'" + realizada2 + "'" ); - update = update.replaceFirst( "[?]proxima_consulta", "null" ); - if( dataRelatorio2 != null ) - { - update = update.replaceFirst( "[?]data_ficha", "'" + dataRelatorio2 + "'" ); - } - else - { - update = update.replaceFirst( "[?]data_ficha", "null" ); - } - } - else - { - update = update.replaceFirst( "[?]proxima_consulta", "'" + dataConsulta2 + "'" ); - if( !dataConsulta2.equals( dataConsulta1 ) ) - { - update = update.replaceFirst( "[?]ultima_consulta", "'" + dataConsulta1 + "'" ); - update = update.replaceFirst( "[?]realizada", "'" + realizada1 + "'" ); - if( dataRelatorio1 != null ) - { - update = update.replaceFirst( "[?]data_ficha", "'" + dataRelatorio1 + "'" ); - } - else - { - update = update.replaceFirst( "[?]data_ficha", "null" ); - } - } - else - { - update = update.replaceFirst( "[?]ultima_consulta", "null" ); - update = update.replaceFirst( "[?]realizada", "null" ); - update = update.replaceFirst( "[?]data_ficha", "null" ); - } - } - } - else - { - update = update.replaceFirst( "[?]ultima_consulta", "null" ); - update = update.replaceFirst( "[?]realizada", "null" ); - update = update.replaceFirst( "[?]proxima_consulta", "null" ); - update = update.replaceFirst( "[?]data_ficha", "null" ); - - } - Object fichas[][] = doQuery( softwareConnection, - GET_ID_FICHA_APTIDAO.replaceFirst( "[?]trabalhador_id", ""+id ) ); - if( fichas != null && fichas.length > 0 && fichas[0].length > 0 && fichas[0][0] != null ) - { - Integer idFicha = (Integer)fichas[0][0]; - fichas = doQuery( softwareConnection, - GET_DADOS_FICHA_APTIDAO.replaceFirst( "[?]id", "" + idFicha ) ); - java.util.Date dataFicha = ( java.util.Date ) fichas[ 0 ][ 0 ]; - /*if( dataFicha != null ) - { - update = update.replaceFirst( "[?]data_ficha", "null" ); - } - else - { - update = update.replaceFirst( "[?]data_ficha", "'" + dataFicha + "'" ); - }*/ - Integer resultadoFicha = (Integer) fichas[ 0 ][ 1 ]; - if( resultadoFicha != null ) - { - switch( resultadoFicha.intValue() ) - { - case 1: - update = update.replaceFirst( "[?]resultado", "'Apto'" ); - break; - case 2: - update = update.replaceFirst( "[?]resultado", "'Apto Condicionalmente'" ); - break; - case 3: - update = update.replaceFirst( "[?]resultado", "'Inapto Temporariamente'" ); - break; - case 4: - update = update.replaceFirst( "[?]resultado", "'Inapto Definitivamente'" ); - break; - default: - update = update.replaceFirst( "[?]resultado", "null" ); - } - } - else - { - update = update.replaceFirst( "[?]resultado", "null" ); - } - } - else - { - update = update.replaceFirst( "[?]data_ficha", "null" ); - update = update.replaceFirst( "[?]resultado", "null" ); - } - - queries[ 1 ] = update; - - } - } - - protected void readEstabelecimentos( String actualizacao ) - throws Exception - { - Object estabelecimentos[][] = doQuery( softwareConnection, GET_ESTABELECIMENTOS + actualizacao ); - //id, empresa_id, nome, contacto, inactivo - for( int t = 0; t < estabelecimentos.length; t++ ) - { - for( int c = 0; c < estabelecimentos[ t ].length; c++ ) - { - if( estabelecimentos[ t ][ c ] instanceof String ) - { - estabelecimentos[ t ][ c ] = unicodeToHTML( (String) estabelecimentos[ t ][ c ] ); - } - } - int id = ( ( Number ) estabelecimentos[t][0] ).intValue(); - boolean inactivo = "y".equals( estabelecimentos[ t ][ estabelecimentos[ t ].length - 1 ] ); - if( inactivo ) - { - deletes.add( DELETE_TRABALHADORES_BY_ESTABELECIMENTO + id ); - deletes.add( DELETE_ESTABELECIMENTO + id ); - continue; - } - String queries[] = new String[ 2 ]; - updates.insertElementAt( queries, 0 ); - queries[ 0 ] = CREATE_ESTABELECIMENTO.replaceFirst( "[?]id", "" + id ); - String update = UPDATE_ESTABELECIMENTO.replaceFirst( "[?]id", "" + id ); - - int empresaID = ( ( Number ) estabelecimentos[t][1] ).intValue(); - update = update.replaceFirst( "[?]empresa_id", "" + empresaID ); - String nome = "'" + estabelecimentos[ t ][ 2 ] + "'"; - update = update.replaceFirst( "[?]nome", nome ); - String morada; - if( estabelecimentos[ t ][ 4 ] != null ) - { - morada = "'" + estabelecimentos[ t ][ 4 ] + "'"; - } - else - { - morada = "''"; - } - update = update.replaceFirst( "[?]morada", morada ); - String localidade; - if( estabelecimentos[ t ][ 5 ] != null ) - { - localidade = "'" + estabelecimentos[ t ][ 5 ] + "'"; - } - else - { - localidade = "''"; - } - update = update.replaceFirst( "[?]localidade", localidade ); - String codigoPostal; - if( estabelecimentos[ t ][ 6 ] != null ) - { - codigoPostal = "'" + estabelecimentos[ t ][ 6 ] + "'"; - } - else - { - codigoPostal = "''"; - } - update = update.replaceFirst( "[?]codigo_postal", codigoPostal ); - - Object marcacoes[][] = doQuery( softwareConnection, - GET_MARCACOES_ESTABELECIMENTO +id ); - - if( marcacoes != null && marcacoes.length > 0 ) - { - java.util.Date dataConsulta2 = ( java.util.Date ) marcacoes[ marcacoes.length - 1 ] [ 1 ]; - String realizada2 = ( String ) marcacoes[ marcacoes.length - 1 ][ 2 ]; - java.util.Date dataConsulta1; - String realizada1; - if( marcacoes.length >= 2 ) - { - dataConsulta1 = ( java.util.Date ) marcacoes[ marcacoes.length - 2 ] [ 1 ]; - realizada1 = ( String ) marcacoes[ marcacoes.length - 2 ][ 2 ]; - } - else - { - dataConsulta1 = dataConsulta2; - realizada1 = realizada2; - } - if( "y".equals( realizada2 ) ) - { - update = update.replaceFirst( "[?]ultima_visita", "'" + dataConsulta2 + "'" ); - update = update.replaceFirst( "[?]realizada", "'" + realizada2 + "'" ); - update = update.replaceFirst( "[?]proxima_visita", "null" ); - } - else if( new java.util.Date().after( dataConsulta2 ) ) - { - update = update.replaceFirst( "[?]ultima_visita", "'" + dataConsulta2 + "'" ); - update = update.replaceFirst( "[?]realizada", "'" + realizada2 + "'" ); - update = update.replaceFirst( "[?]proxima_visita", "null" ); - } - else - { - update = update.replaceFirst( "[?]proxima_visita", "'" + dataConsulta2 + "'" ); - if( !dataConsulta2.equals( dataConsulta1 ) ) - { - update = update.replaceFirst( "[?]ultima_visita", "'" + dataConsulta1 + "'" ); - update = update.replaceFirst( "[?]realizada", "'" + realizada2 + "'" ); - } - else - { - update = update.replaceFirst( "[?]ultima_visita", "null" ); - update = update.replaceFirst( "[?]realizada", "null" ); - } - } - } - else - { - update = update.replaceFirst( "[?]ultima_visita", "null" ); - update = update.replaceFirst( "[?]realizada", "null" ); - update = update.replaceFirst( "[?]proxima_visita", "null" ); - } - - queries[ 1 ] = update; - } - } - - protected void readEmpresas( String actualizacao ) - throws Exception - { - Object empresas[][] = doQuery( softwareConnection, GET_EMPRESAS + actualizacao ); - //id, empresa_id, nome, contacto, inactivo - for( int t = 0; t < empresas.length; t++ ) - { - for( int c = 0; c < empresas[ t ].length; c++ ) - { - if( empresas[ t ][ c ] instanceof String ) - { - empresas[ t ][ c ] = unicodeToHTML( (String) empresas[ t ][ c ] ); - } - } - int id = ( ( Number ) empresas[t][0] ).intValue(); - boolean inactivo = "y".equals( empresas[ t ][ 17 ] ); - if( inactivo ) - { - String str = DELETE_TRABALHADORES_BY_EMPRESA.replaceFirst( "[?]empresa_id", "" + id ); - deletes.add( str ); - deletes.add( DELETE_ESTABELECIMENTOS_BY_EMPRESA + id ); - deletes.add( DELETE_EMPRESA + id ); - continue; - } - String queries[] = new String[ 2 ]; - updates.insertElementAt( queries, 0 ); - queries[ 0 ] = CREATE_EMPRESA.replaceFirst( "[?]id", "" + id ); - String update = UPDATE_EMPRESA.replaceFirst( "[?]id", "" + id ); - - String designacaoSocial = "'" + empresas[ t ][ 1 ] + "'"; - update = update.replaceFirst( "[?]designacao_social", designacaoSocial ); - String cae; - if( empresas[ t ][ 7 ] != null ) - { - cae = "'" + empresas[ t ][ 7 ] + "'"; - } - else - { - cae = "''"; - } - update = update.replaceFirst( "[?]cae", cae ); - String contribuinte; - if( empresas[ t ][ 8 ] != null ) - { - contribuinte = "'" + empresas[ t ][ 8 ] + "'"; - } - else - { - contribuinte = "''"; - } - update = update.replaceFirst( "[?]contribuinte", contribuinte ); - String segurancaSocial; - if( empresas[ t ][ 9 ] != null ) - { - segurancaSocial = "'" + empresas[ t ][ 9 ] + "'"; - } - else - { - segurancaSocial = "''"; - } - update = update.replaceFirst( "[?]seguranca_social", segurancaSocial ); - String actividade; - if( empresas[ t ][ 10 ] != null ) - { - actividade = "'" + empresas[ t ][ 10 ] + "'"; - } - else - { - actividade = "''"; - } - update = update.replaceFirst( "[?]actividade", actividade ); - String morada; - if( empresas[ t ][ 12 ] != null ) - { - morada = "'" + empresas[ t ][ 12 ] + "'"; - } - else - { - morada = "''"; - } - update = update.replaceFirst( "[?]morada", morada ); - String localidade; - if( empresas[ t ][ 13 ] != null ) - { - localidade = "'" + empresas[ t ][ 13 ] + "'"; - } - else - { - localidade = "''"; - } - update = update.replaceFirst( "[?]localidade", localidade ); - String codigoPostal; - if( empresas[ t ][ 14 ] != null ) - { - codigoPostal = "'" + empresas[ t ][ 14 ] + "'"; - } - else - { - codigoPostal = "''"; - } - update = update.replaceFirst( "[?]codigo_postal", codigoPostal ); - String distrito; - if( empresas[ t ][ 15 ] != null ) - { - distrito = "'" + empresas[ t ][ 15 ] + "'"; - } - else - { - distrito = "''"; - } - update = update.replaceFirst( "[?]distrito", distrito ); - String concelho; - if( empresas[ t ][ 16 ] != null ) - { - concelho = "'" + empresas[ t ][ 16 ] + "'"; - } - else - { - concelho = "''"; - } - update = update.replaceFirst( "[?]concelho", concelho ); - String email = null; - if( empresas[ t ][ 18 ] != null ) - { - try - { - Object em[][] = doQuery( softwareConnection, GET_EMAIL + empresas[ t ][ 18 ] ); - if( em != null && em.length > 0 && em[ 0 ][ 0 ] != null ) - { - email = "'" + (String)em[ 0 ][ 0 ] + "'"; - } - } - catch( Exception ex ) - { - } - } - if( email == null ) - { - email = "''"; - } - update = update.replaceFirst( "[?]email", email ); - - String codigo1 = (String) empresas[ t ][ 4 ]; - String codigo2 = (String) empresas[ t ][ 5 ]; - String codigo3 = (String) empresas[ t ][ 6 ]; - String codigo = "'" + ( codigo1 != null ? codigo1 : "_" ) + "/" - + ( codigo2 != null ? codigo2 : "_" ) + "/" - + ( codigo3 != null ? codigo3 : "_" ) + "'"; - update = update.replaceFirst( "[?]codigo", codigo ); - update = update.replaceFirst( "[?]perfil_1", "null" ); - update = update.replaceFirst( "[?]perfil_2", "null" ); - update = update.replaceFirst( "[?]perfil_3", "null" ); - update = update.replaceFirst( "[?]servicos", "null" ); - - queries[ 1 ] = update; - } - } - - protected Object [][]doQuery( Connection con, String query ) - throws Exception - { - return doQuery( con, query, false ); - } - - protected Object [][]doQuery( Connection con, String query, boolean isUpdate ) - throws Exception - { -// if( con == webConnection ) -// { -// System.out.println( "WEB" ); -// } -// else -// { -// System.out.println( "LOCAL" ); -// } -// if( query.indexOf( "INSERT" ) != -1 || query.indexOf( "UPDATE" ) != -1 ) -// { -//// System.out.println( "AAAAAAAAAAAAAHHHHHHH" + query ); -// return new Object[0][0]; -// } - Statement stm = null; - stm = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, - ResultSet.CONCUR_READ_ONLY ); - if( isUpdate ) - { - stm.executeUpdate( query ); - return null; - } - ResultSet rs = stm.executeQuery( query ); - - if( rs == null ) - { - return null; - } - ResultSetMetaData rsmd = rs.getMetaData(); - int columns = rsmd.getColumnCount(); - rs.last(); - int rows = rs.getRow(); - Object data[][] = new Object[ rows ][ columns ]; - for( int i = 0; i < rows; ++i ) - { - rs.absolute( i + 1 ); - for( int j = 0; j < columns; j++ ) - { - data[ i ][ j ] = rs.getObject( j + 1 ); - } - } - return data; - } - - protected static String unicodeToHTML( String text ) - { - if( text == null || text.length() == 0 ) - { - return ""; - } - - String output = text; - - output = output.replaceAll( "\\\\u0009", " " ); - output = output.replaceAll( "\\\\u000a", "
" ); - - output = output.replaceAll( "\\\\u00a0", " " ); - - output = output.replaceAll( "\\\\u00c0", "À" ); - output = output.replaceAll( "\\\\u00c1", "Á" ); - output = output.replaceAll( "\\\\u00c2", "Â" ); - output = output.replaceAll( "\\\\u00c3", "Ã" ); - output = output.replaceAll( "\\\\u00c7", "Ç" ); - output = output.replaceAll( "\\\\u00c8", "È" ); - output = output.replaceAll( "\\\\u00c9", "É" ); - output = output.replaceAll( "\\\\u00ca", "Ê" ); - output = output.replaceAll( "\\\\u00cc", "Ì" ); - output = output.replaceAll( "\\\\u00cd", "Í" ); - output = output.replaceAll( "\\\\u00ce", "Î" ); - output = output.replaceAll( "\\\\u00d2", "Ò" ); - output = output.replaceAll( "\\\\u00d3", "Ó" ); - output = output.replaceAll( "\\\\u00d4", "Ô" ); - output = output.replaceAll( "\\\\u00d5", "Õ" ); - output = output.replaceAll( "\\\\u00d9", "Ù" ); - output = output.replaceAll( "\\\\u00da", "Ú" ); - output = output.replaceAll( "\\\\u00db", "Û" ); - - output = output.replaceAll( "\\\\u00e0", "à" ); - output = output.replaceAll( "\\\\u00e1", "á" ); - output = output.replaceAll( "\\\\u00e2", "â" ); - output = output.replaceAll( "\\\\u00e3", "ã" ); - output = output.replaceAll( "\\\\u00e7", "ç" ); - output = output.replaceAll( "\\\\u00e8", "è" ); - output = output.replaceAll( "\\\\u00e9", "é" ); - output = output.replaceAll( "\\\\u00ea", "ê" ); - output = output.replaceAll( "\\\\u00ec", "ì" ); - output = output.replaceAll( "\\\\u00ed", "í" ); - output = output.replaceAll( "\\\\u00ee", "î" ); - output = output.replaceAll( "\\\\u00f2", "ò" ); - output = output.replaceAll( "\\\\u00f3", "ó" ); - output = output.replaceAll( "\\\\u00f4", "ô" ); - output = output.replaceAll( "\\\\u00f5", "õ" ); - output = output.replaceAll( "\\\\u00f9", "ù" ); - output = output.replaceAll( "\\\\u00fa", "ú" ); - output = output.replaceAll( "\\\\u00fb", "û" ); - output = output.replaceAll( "\\\\u00aa", "ª" ); - output = output.replaceAll( "\\\\u00ba", "º" ); - - output = output.replaceAll( "\\\\u0153", "œ" ); - - output = output.replaceAll( "\\\\u2013", "-" ); - output = output.replaceAll( "\\\\u2014", "-" ); - output = output.replaceAll( "\\\\u2018|\\\\u2019", "'" ); - output = output.replaceAll( "\\\\u201c|\\\\u201d", "\"" ); - - output = output.replaceAll( "\\\\u2022", "*" ); - output = output.replaceAll( "\\\\u2026", "..." ); - - return output; - } - - -} diff --git a/trunk/SIPRPSoft/src/siprp_create.sql b/trunk/SIPRPSoft/src/siprp_create.sql deleted file mode 100644 index 56b89f27..00000000 --- a/trunk/SIPRPSoft/src/siprp_create.sql +++ /dev/null @@ -1,569 +0,0 @@ --- --- PostgreSQL database dump --- - -SET client_encoding = 'LATIN1'; -SET check_function_bodies = false; -SET client_min_messages = warning; - - --- --- Name: actualizacao; Type: TABLE; Schema: public; Owner: postgres; Tablespace: --- - -CREATE TABLE actualizacao ( - hora timestamp without time zone, - id serial NOT NULL -); - - -ALTER TABLE public.actualizacao OWNER TO postgres; - --- --- Name: avisos; Type: TABLE; Schema: public; Owner: postgres; Tablespace: --- - -CREATE TABLE avisos ( - id integer NOT NULL, - tipo integer DEFAULT 0 NOT NULL, - empresa_id integer, - estabelecimento_id integer, - trabalhador_id integer, - evento_id integer, - data_aviso date NOT NULL, - data_evento date, - descricao character varying(255) -); - - -ALTER TABLE public.avisos OWNER TO postgres; - --- --- Name: contactos; Type: TABLE; Schema: public; Owner: postgres; Tablespace: --- - -CREATE TABLE contactos ( - id integer NOT NULL, - nome character varying(255), - telefone character varying(255), - telemovel character varying(255), - fax character varying(255), - email character varying(255), - cargo character varying(255) -); - - -ALTER TABLE public.contactos OWNER TO postgres; - --- --- Name: empresas; Type: TABLE; Schema: public; Owner: postgres; Tablespace: --- - -CREATE TABLE empresas ( - id integer NOT NULL, - designacao_social character varying(255) DEFAULT ''::character varying NOT NULL, - servico_saude_tipo integer, - servico_saude_designacao character varying(255) DEFAULT 'Sociedade Ibu00e9rica de Prevenu00e7u00e3o de Riscos Profissionais'::character varying, - servico_higiene_tipo integer, - servico_higiene_designacao character varying(255), - inactivo character(1) DEFAULT 'n'::bpchar NOT NULL, - morada character varying(255), - codigo_postal character varying(8), - localidade character varying(255), - distrito character varying(255), - concelho character varying(255), - numero_trabalhadores integer, - data_proposta date, - data_aceitacao date, - perfil_1 character varying(255), - perfil_2 character varying(255), - data_envio_contrato date, - data_recepcao_contrato date, - data_envio_idict date, - cae character varying(255), - contribuinte character varying(255), - seguranca_social character varying(255), - codigo_1 character varying(255), - codigo_2 character varying(255), - codigo_3 character varying(255), - servicos integer, - contacto_1 integer, - contacto_2 integer, - data_relatorio_anual date, - preco_higiene double precision, - preco_medicina double precision, - periodicidade character varying(255), - actividade character varying(255), - actualizacao timestamp without time zone, - designacao_social_plain character varying(255) -); - - -ALTER TABLE public.empresas OWNER TO postgres; - --- --- Name: errors; Type: TABLE; Schema: public; Owner: postgres; Tablespace: --- - -CREATE TABLE errors ( - id integer NOT NULL, - date timestamp without time zone, - "type" character varying(20), - environment character varying(255), - description character varying(65535) -); - - -ALTER TABLE public.errors OWNER TO postgres; - --- --- Name: estabelecimentos; Type: TABLE; Schema: public; Owner: postgres; Tablespace: --- - -CREATE TABLE estabelecimentos ( - id integer NOT NULL, - nome character varying(255) DEFAULT ''::character varying NOT NULL, - localidade character varying(255), - inactivo character(1) DEFAULT 'n'::bpchar NOT NULL, - empresa_id integer DEFAULT 0 NOT NULL, - morada character varying(255), - codigo_postal character varying(255), - contacto character varying(255), - historico character varying(65535), - actualizacao timestamp without time zone, - nome_plain character varying(255) -); - - -ALTER TABLE public.estabelecimentos OWNER TO postgres; - --- --- Name: exames; Type: TABLE; Schema: public; Owner: postgres; Tablespace: --- - -CREATE TABLE exames ( - id integer NOT NULL, - data date, - tipo integer DEFAULT 0 NOT NULL, - ocasional integer, - outro_tipo character varying(255), - resultado integer, - outra_funcao_1 character varying(255), - outra_funcao_2 character varying(255), - outra_funcao_3 character varying(255), - outra_funcao_4 character varying(255), - proximo_exame date, - outras_recomendacoes character varying(65535), - inactivo character(1) DEFAULT 'n'::bpchar NOT NULL, - trabalhador_id integer DEFAULT 0 NOT NULL, - medico_id integer DEFAULT 0 NOT NULL, - pdf bytea -); - - -ALTER TABLE public.exames OWNER TO postgres; - --- --- Name: exames_perfis; Type: TABLE; Schema: public; Owner: postgres; Tablespace: --- - -CREATE TABLE exames_perfis ( - id integer NOT NULL, - perfil integer DEFAULT 0 NOT NULL, - tipo integer DEFAULT 0 NOT NULL, - multiplicador integer DEFAULT 0 NOT NULL -); - - -ALTER TABLE public.exames_perfis OWNER TO postgres; - --- --- Name: historico_estabelecimento; Type: TABLE; Schema: public; Owner: postgres; Tablespace: --- - -CREATE TABLE historico_estabelecimento ( - id integer NOT NULL, - estabelecimento_id integer DEFAULT 0 NOT NULL, - data date, - texto character varying(65535) -); - - -ALTER TABLE public.historico_estabelecimento OWNER TO postgres; - --- --- Name: ids; Type: TABLE; Schema: public; Owner: postgres; Tablespace: --- - -CREATE TABLE ids ( - id integer NOT NULL -); - - -ALTER TABLE public.ids OWNER TO postgres; - --- --- Name: marcacoes_empresa; Type: TABLE; Schema: public; Owner: postgres; Tablespace: --- - -CREATE TABLE marcacoes_empresa ( - id integer NOT NULL, - data date NOT NULL, - texto character varying(65535), - empresa_id integer DEFAULT 0 NOT NULL, - realizada character(1) -); - - -ALTER TABLE public.marcacoes_empresa OWNER TO postgres; - --- --- Name: marcacoes_estabelecimento; Type: TABLE; Schema: public; Owner: postgres; Tablespace: --- - -CREATE TABLE marcacoes_estabelecimento ( - id integer NOT NULL, - data date NOT NULL, - realizada character(1) DEFAULT 'n'::bpchar NOT NULL, - data_email date, - data_relatorio date, - estabelecimento_id integer DEFAULT 0 NOT NULL -); - - -ALTER TABLE public.marcacoes_estabelecimento OWNER TO postgres; - --- --- Name: marcacoes_trabalhador; Type: TABLE; Schema: public; Owner: postgres; Tablespace: --- - -CREATE TABLE marcacoes_trabalhador ( - id integer NOT NULL, - data date, - realizada character(1) DEFAULT 'n'::bpchar NOT NULL, - data_email date, - data_relatorio date, - tipo integer, - trabalhador_id integer -); - - -ALTER TABLE public.marcacoes_trabalhador OWNER TO postgres; - --- --- Name: medicos; Type: TABLE; Schema: public; Owner: postgres; Tablespace: --- - -CREATE TABLE medicos ( - id integer NOT NULL, - nome character varying(255) DEFAULT ''::character varying NOT NULL, - numero_cedula character varying(255) DEFAULT ''::character varying NOT NULL, - inactivo character(1) DEFAULT 'n'::bpchar NOT NULL -); - - -ALTER TABLE public.medicos OWNER TO postgres; - --- --- Name: tipos_exames_comp; Type: TABLE; Schema: public; Owner: postgres; Tablespace: --- - -CREATE TABLE tipos_exames_comp ( - id integer NOT NULL, - ordem integer DEFAULT 0 NOT NULL, - descricao character varying(255) DEFAULT ''::character varying NOT NULL -); - - -ALTER TABLE public.tipos_exames_comp OWNER TO postgres; - --- --- Name: trabalhadores; Type: TABLE; Schema: public; Owner: postgres; Tablespace: --- - -CREATE TABLE trabalhadores ( - id integer NOT NULL, - nome character varying(255) DEFAULT ''::character varying NOT NULL, - sexo character(1), - data_nascimento date, - nacionalidade character varying(255), - numero_mecanografico character varying(255), - data_admissao date, - categoria character varying(255), - local_trabalho character varying(255), - funcao_proposta character varying(255), - data_admissao_funcao date, - observacoes character varying(65535), - inactivo character(1) DEFAULT 'n'::bpchar NOT NULL, - estabelecimento_id integer DEFAULT 0 NOT NULL, - data_demissao date, - observacoes_gestao character varying(65535), - perfil integer, - actualizacao timestamp without time zone, - nome_plain character varying(255) -); - - -ALTER TABLE public.trabalhadores OWNER TO postgres; - --- --- Name: actualizacao_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: --- - -ALTER TABLE ONLY actualizacao - ADD CONSTRAINT actualizacao_pkey PRIMARY KEY (id); - - -ALTER INDEX public.actualizacao_pkey OWNER TO postgres; - --- --- Name: avisos_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: --- - -ALTER TABLE ONLY avisos - ADD CONSTRAINT avisos_pkey PRIMARY KEY (id); - - -ALTER INDEX public.avisos_pkey OWNER TO postgres; - --- --- Name: contactos_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: --- - -ALTER TABLE ONLY contactos - ADD CONSTRAINT contactos_pkey PRIMARY KEY (id); - - -ALTER INDEX public.contactos_pkey OWNER TO postgres; - --- --- Name: empresas_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: --- - -ALTER TABLE ONLY empresas - ADD CONSTRAINT empresas_pkey PRIMARY KEY (id); - - -ALTER INDEX public.empresas_pkey OWNER TO postgres; - --- --- Name: errors_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: --- - -ALTER TABLE ONLY errors - ADD CONSTRAINT errors_pkey PRIMARY KEY (id); - - -ALTER INDEX public.errors_pkey OWNER TO postgres; - --- --- Name: estabelecimentos_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: --- - -ALTER TABLE ONLY estabelecimentos - ADD CONSTRAINT estabelecimentos_pkey PRIMARY KEY (id); - - -ALTER INDEX public.estabelecimentos_pkey OWNER TO postgres; - --- --- Name: exames_perfis_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: --- - -ALTER TABLE ONLY exames_perfis - ADD CONSTRAINT exames_perfis_pkey PRIMARY KEY (id); - - -ALTER INDEX public.exames_perfis_pkey OWNER TO postgres; - --- --- Name: exames_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: --- - -ALTER TABLE ONLY exames - ADD CONSTRAINT exames_pkey PRIMARY KEY (id); - - -ALTER INDEX public.exames_pkey OWNER TO postgres; - --- --- Name: historico_estabelecimento_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: --- - -ALTER TABLE ONLY historico_estabelecimento - ADD CONSTRAINT historico_estabelecimento_pkey PRIMARY KEY (id); - - -ALTER INDEX public.historico_estabelecimento_pkey OWNER TO postgres; - --- --- Name: ids_pk; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: --- - -ALTER TABLE ONLY ids - ADD CONSTRAINT ids_pk PRIMARY KEY (id); - - -ALTER INDEX public.ids_pk OWNER TO postgres; - --- --- Name: marcacoes_empresa_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: --- - -ALTER TABLE ONLY marcacoes_empresa - ADD CONSTRAINT marcacoes_empresa_pkey PRIMARY KEY (id); - - -ALTER INDEX public.marcacoes_empresa_pkey OWNER TO postgres; - --- --- Name: marcacoes_estabelecimento_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: --- - -ALTER TABLE ONLY marcacoes_estabelecimento - ADD CONSTRAINT marcacoes_estabelecimento_pkey PRIMARY KEY (id); - - -ALTER INDEX public.marcacoes_estabelecimento_pkey OWNER TO postgres; - --- --- Name: marcacoes_trabalhador_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: --- - -ALTER TABLE ONLY marcacoes_trabalhador - ADD CONSTRAINT marcacoes_trabalhador_pkey PRIMARY KEY (id); - - -ALTER INDEX public.marcacoes_trabalhador_pkey OWNER TO postgres; - --- --- Name: medicos_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: --- - -ALTER TABLE ONLY medicos - ADD CONSTRAINT medicos_pkey PRIMARY KEY (id); - - -ALTER INDEX public.medicos_pkey OWNER TO postgres; - --- --- Name: tipos_exames_comp_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: --- - -ALTER TABLE ONLY tipos_exames_comp - ADD CONSTRAINT tipos_exames_comp_pkey PRIMARY KEY (id); - - -ALTER INDEX public.tipos_exames_comp_pkey OWNER TO postgres; - --- --- Name: trabalhadores_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: --- - -ALTER TABLE ONLY trabalhadores - ADD CONSTRAINT trabalhadores_pkey PRIMARY KEY (id); - - -ALTER INDEX public.trabalhadores_pkey OWNER TO postgres; - - --- --- Name: avisos_empresa_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres --- - -ALTER TABLE ONLY avisos - ADD CONSTRAINT avisos_empresa_id_fkey FOREIGN KEY (empresa_id) REFERENCES empresas(id); - - --- --- Name: avisos_estabelecimento_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres --- - -ALTER TABLE ONLY avisos - ADD CONSTRAINT avisos_estabelecimento_id_fkey FOREIGN KEY (estabelecimento_id) REFERENCES estabelecimentos(id); - - --- --- Name: empresas_contacto_1_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres --- - -ALTER TABLE ONLY empresas - ADD CONSTRAINT empresas_contacto_1_fkey FOREIGN KEY (contacto_1) REFERENCES contactos(id); - - --- --- Name: empresas_contacto_2_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres --- - -ALTER TABLE ONLY empresas - ADD CONSTRAINT empresas_contacto_2_fkey FOREIGN KEY (contacto_2) REFERENCES contactos(id); - - --- --- Name: estabelecimentos_empresa_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres --- - -ALTER TABLE ONLY estabelecimentos - ADD CONSTRAINT estabelecimentos_empresa_id_fkey FOREIGN KEY (empresa_id) REFERENCES empresas(id); - - --- --- Name: exames_medico_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres --- - -ALTER TABLE ONLY exames - ADD CONSTRAINT exames_medico_id_fkey FOREIGN KEY (medico_id) REFERENCES medicos(id); - - --- --- Name: exames_perfis_tipo_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres --- - -ALTER TABLE ONLY exames_perfis - ADD CONSTRAINT exames_perfis_tipo_fkey FOREIGN KEY (tipo) REFERENCES tipos_exames_comp(id); - - --- --- Name: historico_estabelecimento_estabelecimento_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres --- - -ALTER TABLE ONLY historico_estabelecimento - ADD CONSTRAINT historico_estabelecimento_estabelecimento_id_fkey FOREIGN KEY (estabelecimento_id) REFERENCES estabelecimentos(id); - - --- --- Name: marcacoes_empresa_empresa_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres --- - -ALTER TABLE ONLY marcacoes_empresa - ADD CONSTRAINT marcacoes_empresa_empresa_id_fkey FOREIGN KEY (empresa_id) REFERENCES empresas(id); - - --- --- Name: marcacoes_estabelecimento_estabelecimento_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres --- - -ALTER TABLE ONLY marcacoes_estabelecimento - ADD CONSTRAINT marcacoes_estabelecimento_estabelecimento_id_fkey FOREIGN KEY (estabelecimento_id) REFERENCES estabelecimentos(id); - - --- --- Name: trabalhadores_estabelecimento_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres --- - -ALTER TABLE ONLY trabalhadores - ADD CONSTRAINT trabalhadores_estabelecimento_id_fkey FOREIGN KEY (estabelecimento_id) REFERENCES estabelecimentos(id); - - - --- --- Name: public; Type: ACL; Schema: -; Owner: postgres --- - -REVOKE ALL ON SCHEMA public FROM PUBLIC; -REVOKE ALL ON SCHEMA public FROM postgres; -GRANT ALL ON SCHEMA public TO postgres; -GRANT ALL ON SCHEMA public TO PUBLIC; - - - diff --git a/trunk/SIPRPSoft/src/speedo.properties b/trunk/SIPRPSoft/src/speedo.properties deleted file mode 100644 index 314b2c4f..00000000 --- a/trunk/SIPRPSoft/src/speedo.properties +++ /dev/null @@ -1,259 +0,0 @@ -############################################################################### -# Speedo: an implementation of JDO compliant personality on top of JORM generic -# I/O sub-system. -# Copyright (C) 2001-2003 France Telecom R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# Contact: speedo@objectweb.org (users list) -# or sebastien.chassande-barrioz@rd.francetelecom.com (project chief) -# -############################################################################### -# This file is the configuration file of Speedo. -VendorName ObjectWeb Consortium -VersionNumber 1.0 - - -############################################################################### -# PersistenceManagerFactory # -############################################################################### -# Class implementing the PersistenceManagerFactory interface. -# Note: The real role of this class is to initialize the component architecture -# (http://fractal.objectweb.org) of Speedo with the initial properies specified -# in this file. The PersistenceManagerFactory role is delegated to the real -# implementation (the SpeedoPersistenceManagerFactory class). -# -# This property must not be changed. It is used by the JDOHelper to knwon the -# PersistenceManagerFactory class of the JDO driver. -# -javax.jdo.PersistenceManagerFactoryClass org.objectweb.speedo.Speedo - - -############################################################################### -# Data Access # -############################################################################### -# This section contains the configuration of the access to the data support. -# -# The first property (org.objectweb.speedo.mapperName) MUST be defined for the -# enhancement time and the runtime. It characterizes the data source type. -# -# In a second part of this data access section, you must choose the way for -# Speedo to reach the data support. The first mean is through a JDBC -# driver and the second is through a connection factory. - -#==============================# -# Data source type # -#==============================# -#mapper name corresponding to your data support type -#org.objectweb.speedo.mapperName rdb.postgres -#org.objectweb.speedo.mapperName rdb.oracle -org.objectweb.speedo.mapperName rdb.mysql -#Other possible values: -# rdb.oracle8, rdb.sqlserver, rdb.firebird, rdb.mckoi, rdb.sapdb, rdb.sybase - -#===============================================# -# JDBC Driver directly (local transaction only) # -#===============================================# -#Driver class name -#javax.jdo.option.DriverName org.postgresql.Driver -#javax.jdo.option.DriverName oracle.jdbc.driver.OracleDriver -javax.jdo.option.DriverName com.mysql.jdbc.Driver -#javax.jdo.option.DriverName com.p6spy.engine.spy.P6SpyDriver - -#url of the database -#javax.jdo.option.ConnectionURL jdbc:postgresql:speedoTest -#javax.jdo.option.ConnectionURL jdbc:oracle:thin:@10.194.3.226:1521:test1 -javax.jdo.option.ConnectionURL jdbc\:mysql\://127.0.0.1/siprp - -#user name -javax.jdo.option.ConnectionUserName root - -#password of the user -javax.jdo.option.ConnectionPassword UNIXLuvsU - -# connection pool size -org.objectweb.speedo.connection.pool.min 0 -org.objectweb.speedo.connection.pool.max 20 -# TTL of the unused connection in term of seconds -# 0 => no TTL (default) -org.objectweb.speedo.connection.pool.ttl 300 -#the max time to wait a free connection in millisecond -org.objectweb.speedo.connection.pool.timeout 500 - - -#======================================# -# Connection factory registred in JNDI # -#======================================# - -# This property is the jndi name of a registered connection factory. A -# connection factory must an implementation of one of these interfaces: -# - javax.sql.Datasource -# - javax.resource.cci.ConnectionFactory -# -#javax.jdo.option.ConnectionFactoryName connFacJndiName - -############################################################################### -# Transaction management # -############################################################################### -# Speedo can be used in stand alone mode or integrated into an application -# server. In the first case (stand alone), the user must demarcates transactions -# in its application code. In the second case (into an application server) the -# transaction can be dermacated by the container of Session bean. Then the -# transactions are potentialy distributed and therefore managed by a -# transactional monitor. -# -# To use speedo in an application server with transactions demarcated by the -# EJB container, the transaction manager instance (implements -# javax.transaction.TransactionManager) MUST be registered into JNDI. If no -# name is specified several attempts are done with classical jndi names used -# in some application servers: -# -# ----------------------------------------------------------- -# | Apps Server | JNDI Name of TransactionManager instance | -# |--------------|------------------------------------------| -# | JOnAS | javax.transaction.UserTransaction | -# | JBoss | java:/TransactionManager | -# | WebLogic | javax.transaction.TransactionManager | -# | WebSphere | ??? | -# | Orion | java:comp/UserTransaction | -# ----------------------------------------------------------- -# -# The default value is the one used in JOnAS, our objectweb partners. -# -#org.objectweb.speedo.jca.TMName javax.transaction.UserTransaction - -# Indicates if transaction are optimisitic or pessimitic. In the optimisitic -# case several threads can use a same persistent object. In case of optimistic -# transaction, each persistent object has several state: one for each user -# (thread). The default case is pessimistic (false). -# -#javax.jdo.option.Optimistic true - - -############################################################################### -# Others JDO Options # -############################################################################### -# Indicates if queries and extends must ingore the instance modified in memory -# and not yet committed into the support. The default value is false (the -# modified instance are flushed into the support before queries). -# -javax.jdo.option.IgnoreCache false - - -# Indicates if several threads can manipulate a same PersistenceManager instance -# in same time (concurrency). The default value is false (no additionnal -# synchronization for concurrent access to a PersistentManager instance). -# -#javax.jdo.option.Multithreaded false - -# when a transaction is commit this property specifies if the modified -# persistent object must be kept in the memory cache. The default value is true -# (persistent objects are kept). -#javax.jdo.option.RetainValues false - - -############################################################################### -# Unsupported JDO Options # -############################################################################### -#javax.jdo.option.RestoreValues false -#javax.jdo.option.NontransactionalRead -#javax.jdo.option.NontransactionalWrite - -############################################################################### -# Speedo Tunning # -############################################################################### -# To active the debug mode -#org.objectweb.speedo.debug true - -#Activation of the data prefetching on each query -#default value is 'on' -#org.objectweb.speedo.query.prefetch off - -# This property permits to the user to listen the transaction life cycle in -# implementing the TransactionListener interface provided in Speedo. However -# Speedo provides a simple implementation calculating statistics. To active the -# use of a listener, you simply have to specify the implementation of the -# interface. -#org.objectweb.speedo.txListener org.objectweb.speedo.workingset.lib.WorkingSetStatistic - -#===========================# -# Data structure Management # -#===========================# -# Specify the mapping structure (ex SQL tables) management. The possibles -# values are the following: -# DO_NOTHING : nothing is done. Then the mapping structures already exist at -# the Speedo starting -# CREATE_IF_REQUIRED : The mapping structures are created if they are not -# already present (default). -# FORCE_CREATE: The mapping structures are removed (if they already exist), and -# and created. -# DELETE_DATA: The data present in the mapping structure are removed. Of course -# if the mapping structure do not exist, they are created. -# -#org.objectweb.speedo.mappingStructure CREATE_IF_REQUIRED - -#=========================# -# Memory Cache Management # -#=========================# -# Memory cache size -#org.objectweb.speedo.cache.size noLimit - -# When the cache is full or when the treshold is reached this property indicates -# how many entry must be tried to free. The possible values are absolute -# value (234) or a percent of the maximal cache size (12%). The default -# value is 7%. -#org.objectweb.speedo.cache.autoCleanSize 7% - -# Is the number of entries since the cache must try to evict entries. The number -# of entries to evict is specified by the 'autoCleanSize' property. The possible -# values are absolute value (234) or a percent of the maximal cache size (75%). -# By default there is no threshold, then there is no auto cleaning process. -org.objectweb.speedo.cache.autoCleanThreshold 0 - -# Replacement politic of the cache: LRU, MRU or FIFO -# The default value is LRU -#org.objectweb.speedo.cache.policy LRU - -#========================================# -# PersistenceManager Pools configuration # -#========================================# -# Size of the pool of PersistenceManager instances -#org.objectweb.speedo.persistencemanager.pool.min 0 -#org.objectweb.speedo.persistencemanager.pool.max 20 -#org.objectweb.speedo.persitencemanager.pool.ttl 300 -#the max time to wait a free persistence manager in millisecond -org.objectweb.speedo.persitencemanager.pool.timeout 1000 - -#=================================# -# Compiled query Cache Management # -#=================================# -# Memory cache size in term of number of persistent objects -#org.objectweb.speedo.compiledquery.cache.size nolimit - -# When the cache is full or when the treshold is reached this property indicates -# how many entry must be tried to free. The possible values are absolute -# value (234) or a percent of the maximal cache size (12%). The default -# value is 7%. -#org.objectweb.speedo.compiledquery.cache.autoCleanSize 7% - -# Is the number of entries since the cache must try to evict entries. The number -# of entries to evict is specified by the 'autoCleanSize' property. The possible -# values are absolute value (234) or a percent of the maximal cache size (75%). -# By default there is no threshold, then there is no auto cleaning process. -#org.objectweb.speedo.compiledquery.cache.autoCleanThreshold 80% - -# Replacement politic of the cache: LRU, MRU or FIFO -# The default value is LRU -#org.objectweb.speedo.compiledquery.cache.policy LRU diff --git a/trunk/SIPRPSoft/src/updtprop.txt b/trunk/SIPRPSoft/src/updtprop.txt deleted file mode 100644 index 6153dbeb..00000000 --- a/trunk/SIPRPSoft/src/updtprop.txt +++ /dev/null @@ -1,7 +0,0 @@ -interno=localhost:5432 -iuser=postgres -ipasswd=Typein -externo=www.evolute.pt:5436 -euser=siprp -epasswd=rg2h-opksiprp -intervalo=10 diff --git a/trunk/web/src/missing b/trunk/web/src/missing deleted file mode 100644 index efd71a22..00000000 --- a/trunk/web/src/missing +++ /dev/null @@ -1,4 +0,0 @@ -/trunk/html/images/ -/trunk/html/html/conteudos/Images/ -/trunk/html/html/images/ -/trunk/html/conteudos/Images/