diff --git a/trunk/SIPRPSoft/lib/shst.jar b/trunk/SIPRPSoft/lib/shst.jar index d5f0ca65..70967fe9 100644 Binary files a/trunk/SIPRPSoft/lib/shst.jar and b/trunk/SIPRPSoft/lib/shst.jar differ diff --git a/trunk/SIPRPSoft/properties/1-development/app.properties b/trunk/SIPRPSoft/properties/1-development/app.properties index 39f7de25..af087734 100644 --- a/trunk/SIPRPSoft/properties/1-development/app.properties +++ b/trunk/SIPRPSoft/properties/1-development/app.properties @@ -22,7 +22,15 @@ shst.prestador.omissao.id = 35 shst.prestador.omissao.nome = SIPRP shst.prestador.analisador.tab = true -module_spellchecker = true +module_spellchecker=true +module_cursos=true +module_utilizadores=false +module_ficha=true +module_clientes=true +module_relatorio=true +module_listagens=true +module_medicina_controlo_fluxo_ecd=true +module_hs_trabalho_plano_actuacao=true app.icon.path=logo/icon.png diff --git a/trunk/SIPRPSoft/src/siprp/cursos/templates/certificado_empresas.xsl b/trunk/SIPRPSoft/properties/1-development/cursos/templates/certificado_empresas.xsl similarity index 100% rename from trunk/SIPRPSoft/src/siprp/cursos/templates/certificado_empresas.xsl rename to trunk/SIPRPSoft/properties/1-development/cursos/templates/certificado_empresas.xsl diff --git a/trunk/SIPRPSoft/src/siprp/cursos/templates/certificado_formador.xsl b/trunk/SIPRPSoft/properties/1-development/cursos/templates/certificado_formador.xsl similarity index 100% rename from trunk/SIPRPSoft/src/siprp/cursos/templates/certificado_formador.xsl rename to trunk/SIPRPSoft/properties/1-development/cursos/templates/certificado_formador.xsl diff --git a/trunk/SIPRPSoft/src/siprp/cursos/templates/certificado_formando.xsl b/trunk/SIPRPSoft/properties/1-development/cursos/templates/certificado_formando.xsl similarity index 100% rename from trunk/SIPRPSoft/src/siprp/cursos/templates/certificado_formando.xsl rename to trunk/SIPRPSoft/properties/1-development/cursos/templates/certificado_formando.xsl diff --git a/trunk/SIPRPSoft/src/siprp/ficha/ficha_aptidao.xsl b/trunk/SIPRPSoft/properties/1-development/ficha/ficha_aptidao.xsl similarity index 100% rename from trunk/SIPRPSoft/src/siprp/ficha/ficha_aptidao.xsl rename to trunk/SIPRPSoft/properties/1-development/ficha/ficha_aptidao.xsl diff --git a/trunk/SIPRPSoft/properties/2-testing/cursos/templates/certificado_empresas.xsl b/trunk/SIPRPSoft/properties/2-testing/cursos/templates/certificado_empresas.xsl new file mode 100644 index 00000000..c51d15e9 --- /dev/null +++ b/trunk/SIPRPSoft/properties/2-testing/cursos/templates/certificado_empresas.xsl @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + +   +   +   +   + Certificado +   +   +   +   + + A S.I.P.R.P – Sociedade Ibérica de Prevenção de Riscos Profissionais Unipessoal, certifica que + , + + é formadora certificada ( com CAP nº + + ), ministrou uma acção de formação relativa ao + + , com duração de no dia + + , aos seguintes trabalhadores: + + + + + + + Nome + + + Numero + + + + + + + + + + + + + + + + + + + + + +   + + Formadora +   +   +   +   + + Responsável de Formação + +   +   +   +   +   +   +   +   + +   +   +   +   +   +   +   +   +   +   +   + + Este certificado está registado no Livro de Registo de Formação nº + sob o nº +   +   + + + + + + + diff --git a/trunk/SIPRPSoft/properties/2-testing/cursos/templates/certificado_formador.xsl b/trunk/SIPRPSoft/properties/2-testing/cursos/templates/certificado_formador.xsl new file mode 100644 index 00000000..b5adeea7 --- /dev/null +++ b/trunk/SIPRPSoft/properties/2-testing/cursos/templates/certificado_formador.xsl @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + +   +   +   +   + + +   +   + +   + Certificado +   +   + + A S.I.P.R.P – Sociedade Ibérica de Prevenção de Riscos Profissionais Unipessoal, Lda ( localizada no Atrium do Saldanha – Praça Duque de Saldanha, 1 – 9ºG, Lisboa ), certifica que + , + + + + de sexo , + + + + ministrou uma acção de formação no dia , + com duração total de , + relativa a + +   +   + +   +   +   +   +   +   + + + + + + + + + + + + + + Responsável de Formação + + + Director + + + + +   +   +   +   +   +   +   + + + + + + + + +   + + + + + Formadora + + +   + + + + +   +   +   +   +   +   +   +   +   + Este certificado está registado no Livro de Registo de Formação nº sob o nº + + + + + + + diff --git a/trunk/SIPRPSoft/properties/2-testing/cursos/templates/certificado_formando.xsl b/trunk/SIPRPSoft/properties/2-testing/cursos/templates/certificado_formando.xsl new file mode 100644 index 00000000..7ecae65a --- /dev/null +++ b/trunk/SIPRPSoft/properties/2-testing/cursos/templates/certificado_formando.xsl @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + +   +   +   + Certificado de Frequência de Formação Profissional + (de acordo com o Dec. Reg. 35/2002 de 23 de Abril ) +   +   + + A S.I.P.R.P – Sociedade Ibérica de Prevenção de Riscos Profissionais Unipessoal, Lda ( localizada no Atrium do Saldanha – Praça Duque de Saldanha, 1 – 9ºG, Lisboa ), certifica que + + nascida em + a , + com nacionalidade , + de sexo , + + frequentou no dia , + com a duração total de , + o Curso de Formação Profissional de + +   +   + +   +   +   +   +   +   +   + + + + + + + + + + + + + + Formadora + + + Formadora e Responsável de Formação + + + + +   +   +   +   +   +   +   +   +   +   +   +   +   +   +   +   +   +   + Este certificado está registado no Livro de Registo de Formação nº sob o nº + + + + + + + diff --git a/trunk/SIPRPSoft/properties/2-testing/ficha/ficha_aptidao.xsl b/trunk/SIPRPSoft/properties/2-testing/ficha/ficha_aptidao.xsl new file mode 100644 index 00000000..55536878 --- /dev/null +++ b/trunk/SIPRPSoft/properties/2-testing/ficha/ficha_aptidao.xsl @@ -0,0 +1,487 @@ + + + + + + + + + + + + + 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: + + + + FUNÇÃO 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 DOENÇA + + + + + + + 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/properties/3-production/cursos/templates/certificado_empresas.xsl b/trunk/SIPRPSoft/properties/3-production/cursos/templates/certificado_empresas.xsl new file mode 100644 index 00000000..c51d15e9 --- /dev/null +++ b/trunk/SIPRPSoft/properties/3-production/cursos/templates/certificado_empresas.xsl @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + +   +   +   +   + Certificado +   +   +   +   + + A S.I.P.R.P – Sociedade Ibérica de Prevenção de Riscos Profissionais Unipessoal, certifica que + , + + é formadora certificada ( com CAP nº + + ), ministrou uma acção de formação relativa ao + + , com duração de no dia + + , aos seguintes trabalhadores: + + + + + + + Nome + + + Numero + + + + + + + + + + + + + + + + + + + + + +   + + Formadora +   +   +   +   + + Responsável de Formação + +   +   +   +   +   +   +   +   + +   +   +   +   +   +   +   +   +   +   +   + + Este certificado está registado no Livro de Registo de Formação nº + sob o nº +   +   + + + + + + + diff --git a/trunk/SIPRPSoft/properties/3-production/cursos/templates/certificado_formador.xsl b/trunk/SIPRPSoft/properties/3-production/cursos/templates/certificado_formador.xsl new file mode 100644 index 00000000..b5adeea7 --- /dev/null +++ b/trunk/SIPRPSoft/properties/3-production/cursos/templates/certificado_formador.xsl @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + +   +   +   +   + + +   +   + +   + Certificado +   +   + + A S.I.P.R.P – Sociedade Ibérica de Prevenção de Riscos Profissionais Unipessoal, Lda ( localizada no Atrium do Saldanha – Praça Duque de Saldanha, 1 – 9ºG, Lisboa ), certifica que + , + + + + de sexo , + + + + ministrou uma acção de formação no dia , + com duração total de , + relativa a + +   +   + +   +   +   +   +   +   + + + + + + + + + + + + + + Responsável de Formação + + + Director + + + + +   +   +   +   +   +   +   + + + + + + + + +   + + + + + Formadora + + +   + + + + +   +   +   +   +   +   +   +   +   + Este certificado está registado no Livro de Registo de Formação nº sob o nº + + + + + + + diff --git a/trunk/SIPRPSoft/properties/3-production/cursos/templates/certificado_formando.xsl b/trunk/SIPRPSoft/properties/3-production/cursos/templates/certificado_formando.xsl new file mode 100644 index 00000000..7ecae65a --- /dev/null +++ b/trunk/SIPRPSoft/properties/3-production/cursos/templates/certificado_formando.xsl @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + +   +   +   + Certificado de Frequência de Formação Profissional + (de acordo com o Dec. Reg. 35/2002 de 23 de Abril ) +   +   + + A S.I.P.R.P – Sociedade Ibérica de Prevenção de Riscos Profissionais Unipessoal, Lda ( localizada no Atrium do Saldanha – Praça Duque de Saldanha, 1 – 9ºG, Lisboa ), certifica que + + nascida em + a , + com nacionalidade , + de sexo , + + frequentou no dia , + com a duração total de , + o Curso de Formação Profissional de + +   +   + +   +   +   +   +   +   +   + + + + + + + + + + + + + + Formadora + + + Formadora e Responsável de Formação + + + + +   +   +   +   +   +   +   +   +   +   +   +   +   +   +   +   +   +   + Este certificado está registado no Livro de Registo de Formação nº sob o nº + + + + + + + diff --git a/trunk/SIPRPSoft/properties/3-production/ficha/ficha_aptidao.xsl b/trunk/SIPRPSoft/properties/3-production/ficha/ficha_aptidao.xsl new file mode 100644 index 00000000..55536878 --- /dev/null +++ b/trunk/SIPRPSoft/properties/3-production/ficha/ficha_aptidao.xsl @@ -0,0 +1,487 @@ + + + + + + + + + + + + + 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: + + + + FUNÇÃO 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 DOENÇA + + + + + + + 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/FichaDataProvider.java b/trunk/SIPRPSoft/src/siprp/FichaDataProvider.java deleted file mode 100644 index 65eb759d..00000000 --- a/trunk/SIPRPSoft/src/siprp/FichaDataProvider.java +++ /dev/null @@ -1,745 +0,0 @@ -/* - * FichaDataProvider.java - * - * Created on 30 de Marco de 2004, 11:31 - */ - -package siprp; - -import java.text.DateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import shst.data.AvisoConstants; -import shst.data.Marcacao; -import shst.data.outer.MarcacoesTrabalhadorData; - -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.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.strings.StringPlainer; -import com.evolute.utils.ui.search.SearchDialog; -import com.evolute.utils.ui.search.SearchExecuter; - -/** - * - * @author pars - */ -public class FichaDataProvider - 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 Map medicosEstabelecimentosHash = new HashMap(); - - /** Creates a new instance of FichaDataProvider */ - private 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 static FichaDataProvider 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( MarcacoesTrabalhadorData.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( MarcacoesTrabalhadorData.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( MarcacoesTrabalhadorData.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 = 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 ); - } - - public Long countTrabalhadoresActivosForEmpresa( Integer empresaID ) - throws Exception - { - Long result = 0L; - Select2 query = new Select2( new String[]{ "trabalhadores", "estabelecimentos", "empresas" }, - new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER }, - new Expression[]{ - new Field("estabelecimentos.id").isEqual(new Field("trabalhadores.estabelecimento_id")), - new Field("empresas.id").isEqual( new Field("estabelecimentos.empresa_id") ) }, - new String[]{"count(trabalhadores.id)" }, - new Field("empresas.id").isEqual( empresaID ). - and( new Field("trabalhadores.inactivo").isEqual( "n" ) ). - and( new Field("trabalhadores.data_demissao").isEqual( null ) ). - and( new Field("estabelecimentos.inactivo").isEqual( "n" ) ), - null, null, null, null ); - Virtual2DArray returned = executer.executeQuery( query ); - if( returned.columnLength() > 0 ) - { - result = (Long) returned.get( 0, 0 ); - } - return result; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/Main.java b/trunk/SIPRPSoft/src/siprp/Main.java index a9c5d3f1..53035b58 100644 --- a/trunk/SIPRPSoft/src/siprp/Main.java +++ b/trunk/SIPRPSoft/src/siprp/Main.java @@ -26,9 +26,9 @@ import shst.SHSTShutdownHook; import shst.SHSTTracker; import shst.companydataloaders.SIPRPPropertiesLoader; import shst.initializer.SHSTORMInitializer; +import shst.initializer.SHSTUIInitializer; import shst.lembretes.LembretesDaemon; import siprp.initializer.SIPRPLoggerInit; -import siprp.initializer.SIPRPUIInitializer; import siprp.update.UpdateList; import com.evolute.module.updater.UpdateListener; @@ -81,7 +81,7 @@ public class Main implements com.evolute.utils.ui.window.Connector new SHSTShutdownHook().init(); - new SIPRPUIInitializer().doInit(); + new SHSTUIInitializer().doInit(); SIPRPPropertiesLoader.getInstance().load(); @@ -141,8 +141,8 @@ public class Main implements com.evolute.utils.ui.window.Connector JPanel left = loginWindow.getLeftPanel(); left.setBackground( Color.white ); - loginWindow.setSize( 700, 510 ); - loginWindow.setExtendedState(loginWindow.getExtendedState() | LoginWindow.MAXIMIZED_BOTH); + loginWindow.setSize( 600, 500 ); + loginWindow.setExtendedState( loginWindow.getExtendedState() | LoginWindow.MAXIMIZED_BOTH ); loginWindow.setVisible( true ); SwingUtilities.invokeLater( new Runnable() { @@ -171,8 +171,7 @@ public class Main implements com.evolute.utils.ui.window.Connector } catch( Exception ex ) { - DialogException.showExceptionMessage( ex, "N\u00E3o foi poss\u00EDvel estabelecer" - + " a liga\u00E7\u00E3o \u00E0 base de dados.\n(" + url + ")", false ); + DialogException.showExceptionMessage( ex, "N\u00E3o foi poss\u00EDvel estabelecer a liga\u00E7\u00E3o \u00E0 base de dados.\n(" + url + ")", false ); } } diff --git a/trunk/SIPRPSoft/src/siprp/analise_acidentes_trabalho.xsl b/trunk/SIPRPSoft/src/siprp/analise_acidentes_trabalho.xsl deleted file mode 100644 index d98488f3..00000000 --- a/trunk/SIPRPSoft/src/siprp/analise_acidentes_trabalho.xsl +++ /dev/null @@ -1,797 +0,0 @@ - - - - - - - - - - - - - - - Página - - - - de - - - - - - - - - - - - - - - - - - - imagem1 - - - - ANÁLISE DE ACIDENTE DE TRABALHO - - - - - - - - - N.º - - - - - - DATA: - - / - - / - - - - - - - - - - - imagem2 - - - - - - - - - - - - - IDENTIFICAÇÃO DA - ENTIDADE EMPREGADORA - - - - - - Identificação - completa: - - - - - - - - Actividade desenvolvida: - - - - - - - - Loja: - - - - - - - - - - - - - EMPRESA SEGURADORA - - - - - - Identificação - completa: - - - - - - - - Nº de Apólice: - - - - - - - - - - - - - - EMPRESA PRESTADORA DE - SERVIÇOS DE - SEGURANÇA, HIGIENE E - SAÚDE DO TRABALHO - - - - - - Identificação - completa: - - - - - - - - Técnico(a) Superior - de HST: - - - - - - C.A.P. nº:: - - - - - - - - Médico(a) do - Trabalho: - - - - - - Cédula Prof. nº: - - - - - - - - - - - - - - ACIDENTADO (A) - - - - - - Nome: - - - - - - - - Estabelecimento de - origem: - - - - - - - - Data Nascimento: - - / - - / - - - - - - - - Bilhete de Identidade - N°: - - - - - - - - Morada - - - - - - - - Contacto - telefónico: - - - - - - - - Data admissão: - - / - - / - - - - - - - - Função: - - - - - - - - Turno de Trabalho: - - - - - - - Identificação do superior - hierárquico/Responsável do - posto de trabalho - - - - - - Nome: - - - - - - E-mail: - - - - - - - - - - - - - - DADOS DO ACIDENTE DE - TRABALHO - - - - - - Averiguador: - - - - - - - - Data da ocorrência: - - / - - / - - - - - - Hora do acidente: - - h - - m - - - - - - - Nº horas trabalhadas no - turno: - - - - - - - - Secção: - - - - - - Local específico: - - - - - - - - Tarefa/Actividade que se - encontrava a realizar: - - - - - - - - Substâncias, - equipamentos, - ferramentas e objectos - utilizados: - - - - - - - - Condições que - contribuíram para o - acidente e respectiva - explicação da - sua existência: - - - - - - - - Testemunhas: - - - - - - - - Causas do acidente: - - - - - - - - Descrição do - acidente: - - - - - - - - Fotografia(s) e/ou - croqui(s) do local do - acidente: - - - - - - - - - - Conclusões: - - - - - - - - Acções Imediatas - tomadas: - - - - - - - - - - O colaborador - teve formação em SHST - - - O colaborador não - teve formação em SHST - - - - - - - Motivo: - - - - - - - - - - - - Verificaram-se outras - ocorrências/incidências - no mesmo posto de - trabalho com o - colaborador acidentado. - - - Não se verificaram outras - ocorrências/incidências - no mesmo posto de - trabalho com o - colaborador acidentado. - - - - - - - Quantidade: - - Relatórios de acidente nº: - - - ; - - - - - - - - - - - - Verificaram-se - ocorrências/incidentes - semelhantes com outros - colaboradores. - - - Não se verificaram - ocorrências/incidentes - semelhantes com outros - colaboradores. - - - - - - - Quantidade: - - Relatórios de acidente nº: - - - ; - - - - - - - - - - LESÃO - - - - - - - Áreas corporais - específicas - lesionadas: - - - - - - - - - - Tipo de Lesão: - - - - - - - - - INCAPACIDADE - - - - - - - Tipo de Incapacidade: - - - - - - Coeficiente de - Incapacidade - - % - - - - - - - Avaliação de - Incapacidade realizada - em - - / - - / - - - - - - Revisão de - Incapacidade - - / - - / - - - - - - - - Período da Incapacidade - Temporária: de - - / - - / - - a - - / - - / - - - - - - - - - - - - - - RECOMENDAÇÕES PROPOSTAS - pela SIPRP - - - - - - - - - - . - - - - - - - - - - - - - - - - MEDIDAS A ADOPTAR PELA - ENTIDADE EMPREGADORA - - - - - - - - - - - - . - - - - - - - - - - - - - - - - - - TOMADA DE CONHECIMENTO / - TERMO DE - RESPONSABILIDADE - - - - - - - - - Averiguado por - - (Departamento de Segurança) - a - - / - - / - - . - - - Verificado por - - (Técnico - de HST) a - - / - - / - - . - - - Verificado por - - (Responsável de Segurança) a - - / - - / - - . - - - Verificado por - - (Responsável de RH) a - - / - - / - - . - - - Com conhecimento de - - (Superior hierárquico) a - - / - - / - - . - - - processamento informático - - acesso autenticado - - - - - - - - - - - - - diff --git a/trunk/SIPRPSoft/src/siprp/cursos/SIPRPCursosInit.java b/trunk/SIPRPSoft/src/siprp/cursos/SIPRPCursosInit.java deleted file mode 100644 index 2b5065dd..00000000 --- a/trunk/SIPRPSoft/src/siprp/cursos/SIPRPCursosInit.java +++ /dev/null @@ -1,20 +0,0 @@ -package siprp.cursos; - -import shst.cursos.CursosInit; -import siprp.cursos.provider.CursosTemplatesProvider; - -import com.evolute.genericpeople.TemplateProviderFactory; - -public class SIPRPCursosInit -{ - - public static void initFactory() throws Exception - { - //default init - CursosInit.initFactory(); - - //replace templates provider - TemplateProviderFactory.setProvider( new CursosTemplatesProvider() ); - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/cursos/provider/CursosTemplatesProvider.java b/trunk/SIPRPSoft/src/siprp/cursos/provider/CursosTemplatesProvider.java deleted file mode 100644 index d98c554b..00000000 --- a/trunk/SIPRPSoft/src/siprp/cursos/provider/CursosTemplatesProvider.java +++ /dev/null @@ -1,175 +0,0 @@ -package siprp.cursos.provider; - -import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; - -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.Locale; - -import javax.swing.JOptionPane; - -import shst.cursos.provider.PessoasProvider; - -import com.evolute.genericpeople.AutorizacaoProviderInterface; -import com.evolute.genericpeople.DefaultTemplateProvider; -import com.evolute.genericpeople.PessoaDocumentoConstants; -import com.evolute.genericpeople.PessoaDocumentoInterface; -import com.evolute.genericpeople.PessoaInterface; -import com.evolute.genericpeople.TemplateConstants; -import com.evolute.module.cursos.CursosDataProvider; -import com.evolute.module.cursos.CursosLogic; -import com.evolute.module.cursos.data.CurCursosData; -import com.evolute.module.cursos.data.CurFormandosData; -import com.evolute.swing.frame.EvoFrame; -import com.evolute.utils.Singleton; -import com.evolute.utils.error.ErrorLogger; -import com.evolute.utils.tables.ColumnizedObjectArray; -import com.evolute.utils.xml.SimpleXMLElement; - -public class CursosTemplatesProvider extends DefaultTemplateProvider -{ - private CursosDataProvider cursosProvider = CursosDataProvider.getProvider(); - - public CursosTemplatesProvider() - { - setTemplate( TemplateConstants.SUMARIOS, "com/evolute/module/cursos/templates/sumarios.xsl" ); - setTemplate( TemplateConstants.LISTA_PRESENCAS, "com/evolute/module/cursos/templates/lista_presencas.xsl" ); - setTemplate( TemplateConstants.TOPICOS_FILE, "com/evolute/module/cursos/templates/topicos.xsl" ); - - setTemplate( TemplateConstants.CERTIFICADO_FORMANDO, "siprp/cursos/templates/certificado_formando.xsl" ); - setTemplate( TemplateConstants.CERTIFICADO_FORMADOR, "siprp/cursos/templates/certificado_formador.xsl" ); - - setTemplate( TemplateConstants.INSCRICAO_ACEITE, "com/evolute/module/cursos/templates/inscricao_aceite.xsl" ); - setTemplate( TemplateConstants.INSCRICAO_ACEITE_POPH, "com/evolute/module/cursos/templates/inscricao_aceite_POPH.xsl" ); - setTemplate( TemplateConstants.INSCRICAO_REJEITADA, "com/evolute/module/cursos/templates/inscricao_rejeitada.xsl" ); - setTemplate( TemplateConstants.CONFIRMAR_INSCRICAO, "com/evolute/module/cursos/templates/confirmar_inscricao.xsl" ); - } - - @Override - public SimpleXMLElement getXMLForImpressaoFormador( boolean visualizar, CurCursosData curso, EvoFrame parent, List< ColumnizedObjectArray > formadores ) - throws Exception - { - return super.getXMLForImpressaoFormador( visualizar, curso, parent, formadores ); - } - - @Override - public SimpleXMLElement getXMLForImpressaoFormando( boolean visualizar, CurCursosData curso, EvoFrame parent, List< ColumnizedObjectArray > formandos ) - throws Exception - { - SimpleXMLElement xml = null; - if( formandos != null && !formandos.isEmpty() ) - { - CurFormandosData formando = cursosProvider.getFormandoByID( formandos.get( 0 ).getID() ); - PessoaInterface pessoa = cursosProvider.getPessoaFromFormando( formando ); - - Integer numero = super.getNumeroCertificado( formando.getId(), curso.getId() ); - if( numero == null ) - { - return null; - } - String numCertificado = numero.toString(); - Calendar cal = Calendar.getInstance(); - String year = "" + cal.get( Calendar.YEAR ); - year = year.substring( 2, year.length() ); - numCertificado += "/" + year; - - String nomePessoa = super.getNomePessoa( pessoa ); - if( nomePessoa == null ) - { - JOptionPane.showMessageDialog( parent, "O nome do formando tem de estar preenchido!", "Erro", JOptionPane.ERROR_MESSAGE, null ); - return null; - } - - String sexo = pessoa.getSexo(); - if( sexo == null ) - { - JOptionPane.showMessageDialog( parent, "O formador tem de ter o campo sexo preenchido", "Erro", JOptionPane.ERROR_MESSAGE, null); - return null; - } - - String profissao = pessoa.getProfissao(); - if( profissao == null ) - { - JOptionPane.showMessageDialog( parent, "A profiss" + atilde + "o do formando tem de estar preenchida!", "Erro", JOptionPane.ERROR_MESSAGE, null ); - return null; - } - - String naturalidade = pessoa.getNaturalidade(); - if( naturalidade == null ) - { - JOptionPane.showMessageDialog( parent, "A naturalidade do formando tem de estar preenchida!", "Erro", JOptionPane.ERROR_MESSAGE, null ); - return null; - } - - String dataNascimento = super.getDataNascimento( pessoa ); - if( dataNascimento == null ) - { - JOptionPane.showMessageDialog( parent, "A data de nascimento do formando tem de estar preenchida", "Erro", JOptionPane.ERROR_MESSAGE, null); - return null; - } - - String nacionalidade = super.getNacionalidade( pessoa ); - if( nacionalidade == null ) - { - JOptionPane.showMessageDialog( parent, "A nacionalidade do formando tem de estar preenchida", "Erro", JOptionPane.ERROR_MESSAGE, null); - return null; - } - - PessoaDocumentoInterface doc = PessoasProvider.getProvider().getDocumentoByPessoaID( pessoa.getId(), PessoaDocumentoConstants.TIPO_DOCUMENTO_BI ); - String bi_numero = doc == null || "".equals( doc.getNumero().trim() ) ? "" : "portadora do Bilhete de Identidade nº " + doc.getNumero() + ", "; - String bi_emissao = doc == null || "".equals( doc.getLocal_emissao().trim() ) ? "" : " emitido em " + doc.getLocal_emissao() + ", "; - String bi_data_emissao = doc == null ? "" : "em " + DefaultTemplateProvider.D_F.format( doc.getData_emissao() ) + ", "; -// String bi_numero = pessoa.getBINumero() == null || "".equals( pessoa.getBINumero().trim() ) ? "" : "portadora do Bilhete de Identidade nº " + pessoa.getBINumero() + ", "; -// String bi_emissao = pessoa.getBIArquivo() == null || "".equals( pessoa.getBIArquivo().trim() ) ? "" : " emitido em " + pessoa.getBIArquivo() + ", "; -// String bi_data_emissao = pessoa.getBIData() == null ? "" : "em " + DefaultTemplateProvider.D_F.format( pessoa.getBIData() ) + ", "; - - - xml = new SimpleXMLElement( CERTIFICADO_FORMANDO_XML_NAME ); - xml.addElement( new SimpleXMLElement( "numero_certificado", numCertificado ) ); - xml.addElement( new SimpleXMLElement( "signature_filename1", visualizar ? "": AutorizacaoProviderInterface.ASSINATURA1_FILENAME ) ); - - xml.addElement( new SimpleXMLElement( "nome_pessoa", nomePessoa ) ); - xml.addElement( new SimpleXMLElement( "profissao", profissao ) ); - xml.addElement( new SimpleXMLElement( "naturalidade", naturalidade ) ); - xml.addElement( new SimpleXMLElement( "data_nascimento", dataNascimento ) ); - xml.addElement( new SimpleXMLElement( "nacionalidade", nacionalidade ) ); - xml.addElement( new SimpleXMLElement( "sexo", sexo ) ); - xml.addElement( new SimpleXMLElement( "bi_numero", bi_numero ) ); - xml.addElement( new SimpleXMLElement( "bi_emissao", bi_emissao ) ); - xml.addElement( new SimpleXMLElement( "bi_data_emissao", bi_data_emissao ) ); - - xml.addElement( new SimpleXMLElement( "nome_formadora", "TODO - nome formadora" ) ); - xml.addElement( new SimpleXMLElement( "nome_formadora_e_responsavel", "TODO - nome formadora e responsavel" ) ); - - //TODO : numero de Livro de Registo de Formação - xml.addElement( new SimpleXMLElement( "nr_livro_registo", " " ) ); - xml.addElement( new SimpleXMLElement( "numero_certificado", numCertificado ) ); - try - { - if( CursosLogic.getInstance().fillDadosCurso( parent, xml, curso, null ) ) - { - Date today = (Date) Singleton.getInstance( Singleton.TODAY ); - SimpleXMLElement dataCorrenteElement = new SimpleXMLElement( "data_corrente", new SimpleDateFormat( "dd' de 'MMMM' de 'yyyy", new Locale( "pt", "PT" ) ).format( today ) ); - xml.addElement( dataCorrenteElement ); - System.out.println( xml ); - } - else - { - xml = null; - } - } - catch( Exception ex ) - { - ErrorLogger.logException( ex ); - } - } - else - { - xml = super.generateXMLTesteFormando( parent, curso ); - } - return xml; - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaDataProvider.java b/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaDataProvider.java deleted file mode 100644 index 6377fa32..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.DateFormat; -import java.util.Date; - -import shst.data.Marcacao; -import shst.data.outer.MarcacoesTrabalhadorData; - -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.metadb.MetaProvider; -import com.evolute.utils.sql.Field; -import com.evolute.utils.sql.Select; -/** - * - * @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[]{ MarcacoesTrabalhadorData.DATA, - "trabalhador_id", - MarcacoesTrabalhadorData.REALIZADA, - MarcacoesTrabalhadorData.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[]{ MarcacoesTrabalhadorData.DATA, - "trabalhador_id", - MarcacoesTrabalhadorData.REALIZADA, - MarcacoesTrabalhadorData.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 3d29f2f4..00000000 --- a/trunk/SIPRPSoft/src/siprp/estatistica/EstatisticaWindow.java +++ /dev/null @@ -1,1359 +0,0 @@ -/* - * EstatisticaWindow.java - * - * Created on 16 de Dezembro de 2004, 13:50 - */ - -package siprp.estatistica; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FileDialog; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.event.ActionListener; -import java.awt.event.ItemListener; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.text.DateFormat; -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.JEditorPane; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextField; -import javax.swing.ListSelectionModel; -import javax.swing.event.ListSelectionListener; - -import shst.data.outer.EmpresasData; -import shst.data.outer.EstabelecimentosData; -import siprp.pesquisas.PesquisasProvider; -import siprp.ui.SIPRPFrame; - -import com.evolute.entity.ProviderInterface; -import com.evolute.utils.Singleton; -import com.evolute.utils.data.IDObject; -import com.evolute.utils.data.MappableObject; -import com.evolute.utils.documents.YearDocument; -import com.evolute.utils.tables.BaseTable; -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 com.evolute.utils.ui.text.CopyPasteHandler; -/** - * - * @author fpalma - */ -public class EstatisticaWindow extends SIPRPFrame - 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 ProviderInterface 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 = ( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_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.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.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; - - JPanel empresasPanel = new JPanel( new BorderLayout() ); - empresasPanel.add( empresasScroll ); - empresasPanel.setBorder( BorderFactory.createTitledBorder( "Empresa" ) ); - - gridbag.setConstraints( empresasPanel, constraints ); - getContentPane().add( empresasPanel ); - - JPanel panel = new JPanel( new BorderLayout() ); - panel.setBorder( BorderFactory.createTitledBorder( "Estabelecimento" ) ); - panel.add( estabelecimentosScroll ); - - gridbag.setConstraints( panel, constraints ); - getContentPane().add( panel ); - - 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; - - JPanel resultadoPanel = new JPanel( new BorderLayout() ); - resultadoPanel.add( resultadoScroll ); - - gridbag.setConstraints( resultadoPanel, constraints ); - getContentPane().add( resultadoPanel ); - - 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(); - EmpresasData empresa = (EmpresasData)JDO.load( EmpresasData.class, idEmpresa ); - String designacao = (String)empresa.get( EmpresasData.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++ ) - { - EstabelecimentosData estabelecimento = (EstabelecimentosData)JDO.load( EstabelecimentosData.class, estabelecimentos[ e ].getID() ); - String nome = (String)estabelecimento.get( EstabelecimentosData.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(); - EmpresasData empresa = (EmpresasData)JDO.load( EmpresasData.class, idEmpresa ); - String designacao = (String)empresa.get( EmpresasData.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++ ) - { - EstabelecimentosData estabelecimento = (EstabelecimentosData)JDO.load( EstabelecimentosData.class, estabelecimentos[ e ].getID() ); - String nome = (String)estabelecimento.get( EstabelecimentosData.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(); - EmpresasData empresa = (EmpresasData)JDO.load( EmpresasData.class, idEmpresa ); - String designacao = (String)empresa.get( EmpresasData.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++ ) - { - EstabelecimentosData estabelecimento = (EstabelecimentosData)JDO.load( EstabelecimentosData.class, estabelecimentos[ e ].getID() ); - String nome = (String)estabelecimento.get( EstabelecimentosData.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/ficha/EmpresaPanel.java b/trunk/SIPRPSoft/src/siprp/ficha/EmpresaPanel.java deleted file mode 100644 index f4e6c2c5..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/EmpresaPanel.java +++ /dev/null @@ -1,505 +0,0 @@ -/* - * EmpresaPanel.java - * - * Created on 29 de Marco de 2004, 11:53 - */ - -package siprp.ficha; - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Map; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextField; - -import shst.SHSTPropertiesConstants; -import shst.data.outer.EmpresasData; -import shst.data.outer.EstabelecimentosData; -import siprp.FichaDataProvider; - -import com.evolute.entity.ProviderInterface; -import com.evolute.utils.Singleton; -import com.evolute.utils.data.IDObject; -import com.evolute.utils.data.MappableObject; -import com.evolute.utils.dataui.ComponentController; -import com.evolute.utils.dataui.ComponentsHashtable; -import com.evolute.utils.dataui.ControllableComponent; -import com.evolute.utils.ui.DialogException; -import com.evolute.utils.ui.panel.RadioButtonFixedPanel; -import com.evolute.utils.ui.panel.RadioButtonPanel; -import com.evolute.utils.ui.text.CopyPasteHandler; - -/** - * - * @author fpalma - */ -public class EmpresaPanel extends JPanel - implements ControllableComponent< Object > -{ - private ProviderInterface 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 EstabelecimentosData estabelecimento; - private EmpresasData empresa; - - - /** Creates a new instance of EmpresaPanel */ - public EmpresaPanel() - throws Exception - { - provider = (FichaDataProvider)FichaDataProvider.getProvider(); - JDO = ( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_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( SHSTPropertiesConstants.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( SHSTPropertiesConstants.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( EmpresasData.DESIGNACAO_SOCIAL, designacaoSocialText ); - empresaComponents.putComponent( EmpresasData.SERVICO_SAUDE_TIPO, servicoSaudeTipoPanel ); - empresaComponents.putComponent( EmpresasData.SERVICO_SAUDE_DESIGNACAO, designacaoServicoSaudeText ); - empresaComponents.putComponent( EmpresasData.SERVICO_HIGIENE_TIPO, servicoHigieneTipoPanel ); - empresaComponents.putComponent( EmpresasData.SERVICO_HIGIENE_DESIGNACAO, designacaoText ); - - empresaComponents.putDummy( EmpresasData.MORADA ); - empresaComponents.putDummy( EmpresasData.CODIGO_POSTAL ); - empresaComponents.putDummy( EmpresasData.LOCALIDADE ); - empresaComponents.putDummy( EmpresasData.DISTRITO ); - empresaComponents.putDummy( EmpresasData.CONCELHO ); - empresaComponents.putDummy( EmpresasData.DATA_PROPOSTA ); - empresaComponents.putDummy( EmpresasData.DATA_ACEITACAO ); - empresaComponents.putDummy( EmpresasData.PERFIL_1 ); - empresaComponents.putDummy( EmpresasData.PERFIL_2 ); - empresaComponents.putDummy( EmpresasData.DATA_ENVIO_CONTRATO ); - empresaComponents.putDummy( EmpresasData.DATA_RECEPCAO_CONTRATO ); - empresaComponents.putDummy( EmpresasData.DATA_ENVIO_IDICT ); - empresaComponents.putDummy( EmpresasData.DATA_RELATORIO_ANUAL ); - empresaComponents.putDummy( EmpresasData.CODIGO_1 ); - empresaComponents.putDummy( EmpresasData.CODIGO_2 ); - empresaComponents.putDummy( EmpresasData.CODIGO_3 ); - empresaComponents.putDummy( EmpresasData.CAE ); - empresaComponents.putDummy( EmpresasData.ACTIVIDADE ); - empresaComponents.putDummy( EmpresasData.CONTRIBUINTE ); - empresaComponents.putDummy( EmpresasData.SEGURANCA_SOCIAL ); - empresaComponents.putDummy( EmpresasData.CONTACTO_1 ); - empresaComponents.putDummy( EmpresasData.CONTACTO_2 ); - empresaComponents.putDummy( EmpresasData.SERVICOS ); -// empresaComponents.putDummy( EmpresasData.PRECO_HIGIENE ); -// empresaComponents.putDummy( EmpresasData.PRECO_MEDICINA ); - empresaComponents.putDummy( EmpresasData.PERIODICIDADE ); - empresaComponents.putDummy( EmpresasData.DESIGNACAO_SOCIAL_PLAIN ); - empresaComponents.putDummy( EmpresasData.DATA_CANCELAMENTO ); - empresaComponents.putDummy( EmpresasData.A_CONSULTAS ); - empresaComponents.putDummy( EmpresasData.A_EXAMES ); - empresaComponents.putDummy( EmpresasData.B_CONSULTAS ); - empresaComponents.putDummy( EmpresasData.B_EXAMES ); - empresaComponents.putDummy( EmpresasData.INICIO_CONTRATO ); - empresaComponents.putDummy( EmpresasData.DURACAO ); - - estabelecimentoComponents = new ComponentsHashtable(); - estabelecimentoComponents.putComponent( EstabelecimentosData.NOME, estabelecimentoText ); - estabelecimentoComponents.putComponent( EstabelecimentosData.LOCALIDADE, localidadeText ); - estabelecimentoComponents.putDummy( EstabelecimentosData.MORADA ); - estabelecimentoComponents.putDummy( EstabelecimentosData.CODIGO_POSTAL ); - estabelecimentoComponents.putDummy( EstabelecimentosData.CONTACTO_ID ); - estabelecimentoComponents.putDummy( EstabelecimentosData.HISTORICO ); - estabelecimentoComponents.putDummy( EstabelecimentosData.EMPRESA_ID ); - estabelecimentoComponents.putDummy( EstabelecimentosData.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 = (EmpresasData)JDO.load( EmpresasData.class, empresaID ); - String names[] = (String[])empresaComponents.keySet().toArray( new String[0] ); - ComponentController.fill( names, empresa.getHashData(), empresaComponents ); - - if( estabelecimentoID != null ) - { - estabelecimento = (EstabelecimentosData)JDO.load( EstabelecimentosData.class, estabelecimentoID ); - names = (String[])estabelecimentoComponents.keySet().toArray( new String[0] ); //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 EstabelecimentosData(); - } - if( empresa == null ) - { -// empresa = provider.createObject( provider.EMPRESAS ); - empresa = new EmpresasData(); - } -// 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[]{ EmpresasData.DESIGNACAO_SOCIAL, EmpresasData.SERVICO_SAUDE_TIPO, -// EmpresasData.SERVICO_SAUDE_DESIGNACAO, EmpresasData.SERVICO_HIGIENE_TIPO, -// EmpresasData.SERVICO_HIGIENE_DESIGNACAO }; - Map hash = empresa.getHashData(); - ComponentController.save( names, hash, empresaComponents ); - empresa.setHashData( hash ); - -// names = estabelecimento.getFieldNames(); - names = (String[])estabelecimentoComponents.keySet().toArray( new String[0] ); - hash = estabelecimento.getHashData(); - ComponentController.save( names, hash, estabelecimentoComponents ); - estabelecimento.setHashData( hash ); - estabelecimento.setToEmpresa_id( empresa ); - -// estabelecimento.setProperty( provider.R_ESTABELECIMENTO_EMPRESA, empresa ); - -// if( ((String)empresa.getProperty( provider.DESIGNACAO_SOCIAL )).trim().length() == 0 ) - if( ((String)empresa.get( EmpresasData.DESIGNACAO_SOCIAL )).trim().length() == 0 ) - { - msg.append( "A empresa tem de ter uma design\u00e7\u00e3o social\n" ); - hasMsg = true; - } - else - { - empresa.set( EmpresasData.DESIGNACAO_SOCIAL_PLAIN, - com.evolute.utils.strings.StringPlainer.convertString( ( String ) - empresa.get( EmpresasData.DESIGNACAO_SOCIAL ) ) ); - } -// if( empresa.getProperty( provider.SERVICO_SAUDE_TIPO ) == null ) - if( empresa.get( EmpresasData.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( EmpresasData.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( EstabelecimentosData.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 56dc759f..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/ExamePDF.java +++ /dev/null @@ -1,524 +0,0 @@ -package siprp.ficha; - -import java.awt.Color; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.HashMap; - -import shst.SHSTPropertiesConstants; - -import com.evolute.utils.Singleton; -import com.lowagie.text.Cell; -import com.lowagie.text.Chunk; -import com.lowagie.text.Document; -import com.lowagie.text.Element; -import com.lowagie.text.Font; -import com.lowagie.text.FontFactory; -import com.lowagie.text.PageSize; -import com.lowagie.text.Paragraph; -import com.lowagie.text.Phrase; -import com.lowagie.text.Table; -import com.lowagie.text.pdf.BaseFont; -import com.lowagie.text.pdf.PdfWriter; - -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 - { -// new PDFFilePrinter( pdf, false ); - -// if( true ) -// { -// return; -// } - - 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 = Runtime.getRuntime().exec( new String[]{ System.getProperty( "user.home" ) + "\\open.bat", System.getProperty( "user.home" ) + "\\" + 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 InterruptedException, IOException - // 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 ); -// try { - - - document.addTitle( "Ficha de Aptid\u00e3o" ); - String acronym = (String) Singleton.getInstance( SHSTPropertiesConstants.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( SHSTPropertiesConstants.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(); -// PdfWriter pdfw = PdfWriter.getInstance( document, bos ); -// PdfContentByte pdfcb = new PdfContentByte( pdfw ); -// -// PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); -// // Step 2: Obtain a print job. -// PrinterJob pj = PrinterJob.getPrinterJob(); -// Graphics2D graphics = pdfcb.createPrinterGraphics( 100.0F, 100.0F, pj ); -// // Step 3: Find print services. -// PrintService []services = PrinterJob.lookupPrintServices(); -// PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService(); -// if(services.length > 0) -// { -// System.out.println("selected printer: " + services[0]); -// try -// { -// PrintService service = defaultService; -//// PrintService service = ServiceUI.printDialog(null, 200, 200, -//// services, defaultService, DocFlavor.SERVICE_FORMATTED.PAGEABLE, aset); -// pj.setPrintService(service); -// // Step 2: Pass the settings to a page dialog and print dialog. -//// pj.pageDialog(aset); -//// if (pj.printDialog(aset)) -//// { -// // Step 4: Update the settings made by the user in the dialogs. -// // Step 5: Pass the final settings into the print request. -// pj.print(aset); -//// } -// } -// catch (PrinterException pe ) { -// System.err.println(pe); -// } -// } - - } - catch( Exception e ) { - e.printStackTrace(); - return null; - } - 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 ae8ff047..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/ExamePanel.java +++ /dev/null @@ -1,557 +0,0 @@ -/* - * ExamePanel.java - * - * Created on 29 de Marco de 2004, 11:57 - */ - -package siprp.ficha; - -import java.awt.BorderLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.util.Calendar; -import java.util.Date; -import java.util.Vector; - -import javax.swing.BorderFactory; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JRadioButton; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; -import javax.swing.JTextField; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.event.ListSelectionListener; - -import shst.MedicinaConstants; -import shst.SHSTPropertiesConstants; -import shst.data.Marcacao; -import shst.data.outer.ExamesData; -import shst.data.outer.MarcacoesTrabalhadorData; -import siprp.FichaDataProvider; - -import com.evolute.entity.ProviderInterface; -import com.evolute.utils.Singleton; -import com.evolute.utils.data.IDObject; -import com.evolute.utils.data.MappableObject; -import com.evolute.utils.dataui.ComponentController; -import com.evolute.utils.dataui.ComponentsHashtable; -import com.evolute.utils.dataui.ControllableComponent; -import com.evolute.utils.documents.MaximumLengthDocument; -import com.evolute.utils.ui.button.BetterButtonGroup; -import com.evolute.utils.ui.calendar.JCalendarPanel; -import com.evolute.utils.ui.panel.RadioButtonFixedPanel; -import com.evolute.utils.ui.text.CopyPasteHandler; -/** - * - * @author fpalma - */ -public class ExamePanel extends JPanel - implements ChangeListener, ControllableComponent, ListSelectionListener -{ - - private static final long serialVersionUID = 1L; - - private ProviderInterface 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 MarcacoesTrabalhadorData marcacao; - - /** Creates a new instance of ExamePanel */ - public ExamePanel() - throws Exception - { - provider = (FichaDataProvider)FichaDataProvider.getProvider(); - JDO = ( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_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 ); - - 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( SHSTPropertiesConstants.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 ); - JPanel recomendacoesPanel = new JPanel( new BorderLayout() ); - gridbag.setConstraints( recomendacoesPanel, constraints ); - recomendacoesPanel.add( recomendacoesScp, BorderLayout.CENTER ); - recomendacoesPanel.setBorder( BorderFactory.createTitledBorder( "Outras recomenda\u00e7\u00f5es" ) ); - rightPanel.add( recomendacoesPanel ); - - 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( ExamesData.TIPO ); - components.putComponent( ExamesData.DATA, dataExamePanel ); - components.putComponent( ExamesData.OCASIONAL, ocasionalPanel ); - components.putComponent( ExamesData.OUTRO_TIPO, especificarText ); - components.putComponent( ExamesData.PROXIMO_EXAME, proximoExamePanel ); - components.putComponent( ExamesData.RESULTADO, resultadoPanel ); - components.putComponent( ExamesData.OUTRA_FUNCAO_1, outrasFuncoesTexts[ 0 ] ); - components.putComponent( ExamesData.OUTRA_FUNCAO_2, outrasFuncoesTexts[ 1 ] ); - components.putComponent( ExamesData.OUTRA_FUNCAO_3, outrasFuncoesTexts[ 2 ] ); - components.putComponent( ExamesData.OUTRA_FUNCAO_4, outrasFuncoesTexts[ 3 ] ); - components.putComponent( ExamesData.OUTRAS_RECOMENDACOES, recomendacoesText ); - components.putDummy( ExamesData.INACTIVO ); - components.putDummy( ExamesData.TRABALHADOR_ID ); - components.putDummy( ExamesData.MEDICO_ID ); - components.putDummy( ExamesData.PDF ); - components.putDummy( ExamesData.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 = ( MarcacoesTrabalhadorData ) JDO.load( MarcacoesTrabalhadorData.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; - ExamesData 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 = new ExamesData(); - - - exame.setHashData( ComponentController.save( components ) ); - - 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( ExamesData.TIPO, new Integer( tipo ) ); - if( tipo != 3 ) - { -// exame.setProperty( FichaDataProvider.EXAMES.getFieldByName( FichaDataProvider.OCASIONAL ).FULL_NAME, null ); - exame.set( ExamesData.OCASIONAL, null ); -// exame.setProperty( FichaDataProvider.EXAMES.getFieldByName( FichaDataProvider.OUTRO_TIPO ).FULL_NAME, "" ); - exame.set( ExamesData.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( ExamesData.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(); - } - - public void setup( Date fichaDate, Integer motivoProcesso ) - { - if( fichaDate != null ) - { - dataExamePanel.setDate( fichaDate ); - Calendar proximo = Calendar.getInstance(); - proximo.setTime( fichaDate ); - proximo.add( Calendar.YEAR, 2 ); - proximoExamePanel.setDate( proximo.getTime() ); - } - if( motivoProcesso != null ) - { - switch( motivoProcesso.intValue() ) - { - case MedicinaConstants.MOTIVO_ADMISSAO: - admissaoRadio.setSelected( true ); - break; - case MedicinaConstants.MOTIVO_PERIODICO: - periodicoRadio.setSelected( true ); - break; - case MedicinaConstants.MOTIVO_PERIODICO_INICIAL: - periodicoRadio.setSelected( true ); - break; - case MedicinaConstants.MOTIVO_OCASIONAL: - ocasionalRadio.setSelected( true ); - break; - } - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoConstants.java b/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoConstants.java deleted file mode 100644 index a9cfaef7..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoConstants.java +++ /dev/null @@ -1,78 +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"; - - public static final int CODIGO_TIPO_ADMISSAO = 1; - public static final int CODIGO_TIPO_PERIODICO = 2; - public static final int CODIGO_TIPO_OCASIONAL = 3; -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoCreator.java b/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoCreator.java deleted file mode 100644 index 7cb534ca..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoCreator.java +++ /dev/null @@ -1,115 +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 java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; - -import com.evolute.utils.fop.FOPCreator; -import com.evolute.utils.fop.FOPPrinter; -import com.evolute.utils.fop.PDFCreator; - - -/** - * - * @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[] createFO( byte []xml ) - throws Exception - { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - InputStream xmlIn = new ByteArrayInputStream( xml ); - - 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 ba56bd15..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoEditorManager.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * FichaAptidaoEditorManager.java - * - * Created on 30 de Marco de 2004, 19:23 - */ - -package siprp.ficha; - -import com.evolute.utils.editormanager.Editor; -import com.evolute.utils.editormanager.EditorManager; -import com.evolute.utils.editormanager.EditorManagerFactory; -import com.evolute.utils.editormanager.EditorManagerInterface; - -/** - * - * @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 f6ec1512..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/FichaAptidaoEditorManagerFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * FichaAptidaoEditorManagerFactory.java - * - * Created on 30 de Marco de 2004, 20:48 - */ - -package siprp.ficha; - -import com.evolute.utils.editormanager.Editor; -import com.evolute.utils.editormanager.EditorManagerFactory; -import com.evolute.utils.editormanager.EditorManagerInterface; -/** - * - * @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 d7189fdc..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java +++ /dev/null @@ -1,1258 +0,0 @@ -/* - * FichaWindow.java - * - * Created on 29 de Marco de 2004, 11:50 - */ - -package siprp.ficha; - -import java.awt.FileDialog; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FilenameFilter; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Vector; - -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.JPanel; - -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.output.XMLOutputter; - -import shst.data.outer.EmpresasData; -import shst.data.outer.EstabelecimentosData; -import shst.data.outer.ExamesData; -import shst.data.outer.MedicosData; -import shst.data.outer.TrabalhadoresData; -import shst.importer.Importer; -import shst.lembretes.LembretesDataProvider; -import shst.medicina.MarcacoesMedicinaHandler; -import shst.printer.Printer; -import siprp.FichaDataProvider; -import siprp.ui.SIPRPTabbedWindow; - -import com.evolute.entity.ProviderInterface; -import com.evolute.utils.Singleton; -import com.evolute.utils.data.IDObject; -import com.evolute.utils.strings.StringPlainer; -import com.evolute.utils.ui.DialogException; -import com.evolute.utils.ui.dialog.ListAction; -import com.evolute.utils.ui.dialog.ListActionDialog; -import com.evolute.utils.ui.search.SearchDialog; -import com.evolute.utils.ui.window.ActionHandler; - -/** - * - * @author fpalma - */ -public class FichaWindow extends SIPRPTabbedWindow implements ListAction, FichaAptidaoConstants -{ - - private static final long serialVersionUID = 1L; - - private ProviderInterface JDO; - - private UpperPanel upperPanel; - private EmpresaPanel empresaPanel; - private TrabalhadorPanel trabalhadorPanel; - private ObservacoesPanel observacoesPanel; - private ExamePanel examePanel; - - private LembretesDataProvider lembretesProvider; - 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; - - private boolean useFO = false; - - /** 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 = ( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_PROVIDER ); - marcacoesHandler = new MarcacoesMedicinaHandler(); - lembretesProvider = LembretesDataProvider.getProvider(); - setupComponents(); - } - - public static FichaWindow getWindow() - throws Exception - { - if( window == null ) - { - window = new FichaWindow(); - } - return window; - } - - private void setupComponents() - throws Exception - { - setSize( 800, 700 ); - 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() -// { -// printOldFO(); -// } -// -// public boolean activate( boolean newAction, boolean editAction, -// boolean cancelAction, boolean saveAction, -// boolean deleteAction, boolean selectAction ) -// { -// return saveAction || editAction; -// } -// }, "Imprimir Fichas Anteriores (novo)", -// "Imprimir Fichas Anteriores (novo)", 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() - { - printToFile(); - } - - public boolean activate( boolean newAction, boolean editAction, - boolean cancelAction, boolean saveAction, - boolean deleteAction, boolean selectAction ) - { - return saveAction || editAction; - } - }, "Exportar", "Exportar para PDF", null, 0, true ); - -// 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 ) - { - StringBuilder msg = new StringBuilder(); - MedicosData medico; - try - { - medico = (MedicosData)upperPanel.save(); - } - catch( ValuesException vex ) - { - msg.append( vex.getMessage() ); - medico = null; - } - EstabelecimentosData estabelecimento; - try - { - estabelecimento = (EstabelecimentosData)empresaPanel.save(); - } - catch( ValuesException vex ) - { - msg.append( vex.getMessage() ); - estabelecimento = null; - } - TrabalhadoresData trabalhador; - try - { - trabalhador = (TrabalhadoresData)trabalhadorPanel.save(); - } - catch( ValuesException vex ) - { - msg.append( vex.getMessage() ); - trabalhador = null; - } - ExamesData exame; - try - { - exame = (ExamesData)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; - } - String observacoes = ( String ) observacoesPanel.save(); - - - estabelecimento.set( EstabelecimentosData.NOME_PLAIN, - com.evolute.utils.strings.StringPlainer.convertString( ( String ) - estabelecimento.get( EstabelecimentosData.NOME ) ) ); - - trabalhador.set( TrabalhadoresData.TO_ESTABELECIMENTO_ID, estabelecimento ); - trabalhador.set( TrabalhadoresData.OBSERVACOES, observacoes ); - trabalhador.set( TrabalhadoresData.NOME_PLAIN, - com.evolute.utils.strings.StringPlainer.convertString( ( String ) - trabalhador.get( TrabalhadoresData.NOME ) ) ); - exame.set( ExamesData.TO_MEDICO_ID, medico ); - exame.set( ExamesData.TO_TRABALHADOR_ID, trabalhador ); - - byte fo[] = null; - try - { - fo = createFO( exame ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a criar nova vers\u00e3o de ficha", true ); - } - - try - { - exame.set( ExamesData.FO, fo ); - exame.set( ExamesData.PDF, createPDF( exame ) ); - exame.save(); - trabalhador.save(); - try - { - if( medico != null ) - { - fdpProvider.setMedicoForEstabelecimento( ( Integer ) estabelecimento.get( EstabelecimentosData.ID ), - ( Integer ) medico.get( MedicosData.ID ) ); - } - } - catch( Exception mex ) - { - } - trabalhadorID = ( Integer ) trabalhador.get( TrabalhadoresData.ID ); - try - { - //Marcacao.saveMarcacaoConsultaForTrabalhadorID( trabalhadorID, (Date)exame.get( ExamesData.PROXIMO_EXAME ) ); - marcacoesHandler.ajustarMarcacoes( - trabalhadorID, (Integer)exame.get( ExamesData.TIPO ), - (Date)exame.get( ExamesData.DATA ), - examePanel.getMotivoProximoExame(), (Date)exame.get( ExamesData.PROXIMO_EXAME ) ); - } - catch( Exception iex ) - { - iex.printStackTrace(); - } -// Integer motivoProximoExame = (Integer) exame.get( ExamesData.TIPO ); -// if ( motivoProximoExame != null && motivoProximoExame.equals( new Integer( FichaAptidaoConstants.CODIGO_TIPO_OCASIONAL ) ) ) -// { -// Date proximoExameDate = (Date) exame.get( ExamesData.PROXIMO_EXAME ); -// if( proximoExameDate != null && proximoExameDate.getTime() > 0 ) -// { -// Calendar whenCal = Calendar.getInstance(); -// whenCal.setTime( proximoExameDate ); -// whenCal.add( Calendar.MONTH, -2 ); -// Date now = new Date(); -// Date when = whenCal.getTime(); -// lembretesProvider.criarLembreteFicha( exame, now.after( when ) ? now : when ); -// System.out.println(new Date() + ": A criar lembrete"); -// } -// } -// createPDF( exame ); -// print(); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a guardar", true ); - return false; - } - if( exameListener != null ) - { - exameListener.exameSaved( trabalhadorID, ( Integer )exame.get( ExamesData.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, false ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "N\u00e3o foi poss\u00edvel imprimir", true ); - } - } - - private void print( Integer exameID, boolean toFile ) - throws Exception - { -// MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) ); - ExamesData exame = (ExamesData) JDO.load( ExamesData.class, exameID ); - if( exame == null ) - { - throw new Exception( "N\u00e3o existe exame" ); - } - - byte fo[] = (byte []) exame.get( ExamesData.FO ); - byte pdf[] = (byte []) exame.get( ExamesData.PDF ); - - if( toFile ) - { - TrabalhadoresData trabalhadorExame = exame.toTrabalhador_id(); - String fileName = StringPlainer.convertString( ( String ) trabalhadorExame.get( TrabalhadoresData.NOME ) ); - SimpleDateFormat sdf = new SimpleDateFormat("_dd-MM-yyyy"); - Date date = new Date(); - fileName = fileName + sdf.format( date ); - fileName = fileName.replace( ' ', '_' ); - JFileChooser dialog = new JFileChooser(); - dialog.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY ); - int result = dialog.showSaveDialog( this ); - if( result == JFileChooser.APPROVE_OPTION ) - { - File selectedFile = dialog.getSelectedFile(); - if( selectedFile != null ) - { - String absolutePath = selectedFile.getAbsolutePath(); - if( absolutePath != null ) - { - if(absolutePath.charAt( absolutePath.length() - 1) != File.separatorChar ) - { - absolutePath = absolutePath + File.separatorChar; - } - fileName = absolutePath + fileName + ".pdf"; - } - -// if( fo != null ) -// { -// Printer.printFoToFile( fo, fileName, true ); -// } -// else -// { - Printer.printPDFToFile( pdf, fileName, true ); -// } - JOptionPane.showMessageDialog( this, "Ficha exportada para: " + fileName ); - } - } - } - else - { -// if( fo != null ) -// { -// FichaAptidaoCreator.getCreator().print( fo ); -// } -// else -// { - TrabalhadoresData trabalhadorExame = exame.toTrabalhador_id(); - String nomeFicheiro = StringPlainer.convertString( ( String ) trabalhadorExame.get( TrabalhadoresData.NOME ) ); - nomeFicheiro = nomeFicheiro.replaceAll( " ", "_" ); - ePDF.print( pdf, nomeFicheiro ); -// } - } - } - - private void printToFile() - { - try - { - if( trabalhadorID != null ) - { - Integer id = fdpProvider.getLastExameIDForTrabalhador( trabalhadorID ); - if( id != null ) - { - print(id, true); - } - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "N\u00e3o foi poss\u00edvel exportar", true ); - } - } - -// private void printFO( Integer exameID ) -// throws Exception -//{ -//// MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) ); -// ExamesData exame = (ExamesData) JDO.load( ExamesData.class, exameID ); -// if( exame == null ) -// { -// throw new Exception( "N\u00e3o existe exame" ); -// } -// -// // lflores - ignore FO (for now) -// byte fo[] = (byte []) exame.get( ExamesData.FO ); -// -// if( fo != null ) -// { -// byte pdf[] = FichaAptidaoCreator.getCreator().createPDF( fo ); -// new PDFFilePrinter( pdf, true ); -// } -//} - - public byte[] createFO( ExamesData exame ) - throws Exception - { - byte xml[] = createXmlFromExame( exame ); -// HashMap ht = createMapFromExame(exame); -// ExamePDF ePDF = new ExamePDF(); -// return ePDF.createPDF( ht ); - - return FichaAptidaoCreator.getCreator().createFO( xml ); - } - - public byte[] createPDF( ExamesData exame ) - throws Exception - { - // byte fo[] = exame.get( ExamesData.FO, fo ); - HashMap ht = createMapFromExame( exame ); - return ePDF.createPDF( ht ); -// return FichaAptidaoCreator.getCreator().createPDF( fo ); - } - - private HashMap createMapFromExame(final ExamesData exame) - { - MedicosData medico = exame.toMedico_id(); - TrabalhadoresData trabalhador = exame.toTrabalhador_id(); - EstabelecimentosData estabelecimento = trabalhador.toEstabelecimento_id(); - EmpresasData empresa = estabelecimento.toEmpresa_id(); -// empresa.load( empresa.getPrimaryKeyValue() ); - HashMap ht = new HashMap(); - ht.put( DESIGNACAO_SOCIAL, ( String )empresa.get( EmpresasData.DESIGNACAO_SOCIAL ) ); - ht.put( ESTABELECIMENTOS_NOME, ( String )estabelecimento.get( EstabelecimentosData.NOME ) ); - String aux = (String)estabelecimento.get( EstabelecimentosData.LOCALIDADE ); - ht.put( ESTABELECIMENTOS_LOCALIDADE, aux != null ? aux : "" ); - Integer tipo = (Integer)empresa.get( EmpresasData.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( EmpresasData.SERVICO_SAUDE_DESIGNACAO ) ); - tipo = (Integer)empresa.get( EmpresasData.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( EmpresasData.SERVICO_HIGIENE_DESIGNACAO ) ); - ht.put( TRABALHADORES_NOME, ( String )trabalhador.get( TrabalhadoresData.NOME ) ); - aux = (String)trabalhador.get( TrabalhadoresData.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( TrabalhadoresData.DATA_NASCIMENTO ); - ht.put( DATA_NASCIMENTO, data != null ? df.format( data ) : "" ); - aux = (String)trabalhador.get( TrabalhadoresData.NACIONALIDADE ); - ht.put( NACIONALIDADE, aux != null ? aux : "" ); - aux = (String)trabalhador.get( TrabalhadoresData.NUMERO_MECANOGRAFICO ); - ht.put( NUMERO_MECANOGRAFICO, aux != null ? aux : "" ); - data = ( Date )trabalhador.get( TrabalhadoresData.DATA_ADMISSAO ); - ht.put( DATA_ADMISSAO, data != null ? df.format( data ) : "" ); - aux = (String)trabalhador.get( TrabalhadoresData.CATEGORIA ); - ht.put( CATEGORIA, aux != null ? aux : "" ); - aux = (String)trabalhador.get( TrabalhadoresData.LOCAL_TRABALHO ); - ht.put( LOCAL_TRABALHO, aux != null ? aux : "" ); - aux = (String)trabalhador.get( TrabalhadoresData.FUNCAO_PROPOSTA ); - ht.put( FUNCAO_PROPOSTA, aux != null ? aux : "" ); - data = ( Date )trabalhador.get( TrabalhadoresData.DATA_ADMISSAO_FUNCAO ); - ht.put( DATA_ADMISSAO_FUNCAO, data != null ? df.format( data ) : "" ); - aux = (String)trabalhador.get( TrabalhadoresData.OBSERVACOES ); - ht.put( OBSERVACOES, aux != null ? aux : "" ); - data = ( Date )exame.get( ExamesData.DATA ); - ht.put( EXAMES_DATA, data != null ? df.format( data ) : "" ); - tipo = (Integer)exame.get( ExamesData.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( ExamesData.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( ExamesData.OUTRO_TIPO ); -// ht.put( "tipo_outro", aux != null ? aux : "" ); -// break; - } - aux = (String)exame.get( ExamesData.OUTRO_TIPO ); - ht.put( TIPO_OUTRO_TEXTO, aux != null ? aux : "" ); - tipo = (Integer)exame.get( ExamesData.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( ExamesData.OUTRA_FUNCAO_1 ); - ht.put( OUTRA_FUNCAO_1, aux != null ? aux : "" ); - aux = (String)exame.get( ExamesData.OUTRA_FUNCAO_2 ); - ht.put( OUTRA_FUNCAO_2, aux != null ? aux : "" ); - aux = (String)exame.get( ExamesData.OUTRA_FUNCAO_3 ); - ht.put( OUTRA_FUNCAO_3, aux != null ? aux : "" ); - aux = (String)exame.get( ExamesData.OUTRA_FUNCAO_4 ); - ht.put( OUTRA_FUNCAO_4, aux != null ? aux : "" ); - aux = (String)exame.get( ExamesData.OUTRAS_RECOMENDACOES ); - ht.put( OUTRAS_RECOMENDACOES, aux != null ? aux : "" ); - data = ( Date )exame.get( ExamesData.PROXIMO_EXAME ); - ht.put( PROXIMO_EXAME, data != null ? df.format( data ) : "n/d" ); - aux = (String)medico.get( MedicosData.NOME ); - ht.put( MEDICOS_NOME, aux != null ? aux : "" ); - aux = (String)medico.get( MedicosData.NUMERO_CEDULA ); - ht.put( NUMERO_CEDULA, aux != null ? aux : "" ); - return ht; - } - - private byte[] createXmlFromExame(final ExamesData exame) - throws Exception - { - MedicosData medico = exame.toMedico_id(); - TrabalhadoresData trabalhador = exame.toTrabalhador_id(); - EstabelecimentosData estabelecimento = trabalhador.toEstabelecimento_id(); - EmpresasData empresa = estabelecimento.toEmpresa_id(); - - Element rootElement = new Element( "FichaAptidao" ); - Element portariaElement = new Element( "portaria" ); - portariaElement.setText( "Portaria n. 299/2007, de 16 de Mar\u00e7o" ); - rootElement.addContent( portariaElement ); - - Element empresaElement = new Element( "empresa" ); - Element designacaoSocialEmpresaElement = new Element( "designacao-social" ); - designacaoSocialEmpresaElement.setText( ( String )empresa.get( EmpresasData.DESIGNACAO_SOCIAL ) ); - empresaElement.addContent( designacaoSocialEmpresaElement ); - rootElement.addContent( empresaElement ); - - Integer tipoServicoSaude = (Integer)empresa.get( EmpresasData.SERVICO_SAUDE_TIPO ); - Integer tipoServicoHigieneSeguranca = (Integer)empresa.get( EmpresasData.SERVICO_HIGIENE_TIPO ); - Element estabelecimentoElement = new Element( "estabelecimento" ); - Element nomeEstabelecimentoElement = new Element( "nome" ); - nomeEstabelecimentoElement.setText( ( String )estabelecimento.get( EstabelecimentosData.NOME ) ); - estabelecimentoElement.addContent( nomeEstabelecimentoElement ); - Element localidadeEstabelecimentoElement = new Element( "localidade" ); - localidadeEstabelecimentoElement.setText( ( String )estabelecimento.get( EstabelecimentosData.LOCALIDADE ) ); - estabelecimentoElement.addContent( localidadeEstabelecimentoElement ); - Element servicoSaudeEstabelecimentoElement = new Element( "servico-saude" ); - Element tipoServicoSaudeEstabelecimentoElement = new Element( "tipo" ); - Element internoTipoServicoSaudeEstabelecimentoElement = new Element( "interno" ); - internoTipoServicoSaudeEstabelecimentoElement.setText( tipoServicoSaude.intValue() == 1 ? "y" : "n" ); - tipoServicoSaudeEstabelecimentoElement.addContent( internoTipoServicoSaudeEstabelecimentoElement ); - Element interempresasTipoServicoSaudeEstabelecimentoElement = new Element( "interempresas" ); - interempresasTipoServicoSaudeEstabelecimentoElement.setText( tipoServicoSaude.intValue() == 2 ? "y" : "n" ); - tipoServicoSaudeEstabelecimentoElement.addContent( interempresasTipoServicoSaudeEstabelecimentoElement ); - Element externoTipoServicoSaudeEstabelecimentoElement = new Element( "externo" ); - externoTipoServicoSaudeEstabelecimentoElement.setText( tipoServicoSaude.intValue() == 3 ? "y" : "n" ); - tipoServicoSaudeEstabelecimentoElement.addContent( externoTipoServicoSaudeEstabelecimentoElement ); - Element snsTipoServicoSaudeEstabelecimentoElement = new Element( "sns" ); - snsTipoServicoSaudeEstabelecimentoElement.setText( tipoServicoSaude.intValue() == 4 ? "y" : "n" ); - tipoServicoSaudeEstabelecimentoElement.addContent( snsTipoServicoSaudeEstabelecimentoElement ); - servicoSaudeEstabelecimentoElement.addContent( tipoServicoSaudeEstabelecimentoElement ); - Element designacaoServicoSaudeEstabelecimentoElement = new Element( "designacao" ); - designacaoServicoSaudeEstabelecimentoElement.setText( ( String )empresa.get( EmpresasData.SERVICO_SAUDE_DESIGNACAO ) ); - servicoSaudeEstabelecimentoElement.addContent( designacaoServicoSaudeEstabelecimentoElement ); - estabelecimentoElement.addContent( servicoSaudeEstabelecimentoElement ); - Element servicoHigieneSegurancaEstabelecimentoElement = new Element( "servico-higiene-seguranca" ); - Element tipoServicoHigieneSegurancaEstabelecimentoElement = new Element( "tipo" ); - Element internoTipoServicoHigieneSegurancaEstabelecimentoElement = new Element( "interno" ); - internoTipoServicoHigieneSegurancaEstabelecimentoElement.setText( tipoServicoHigieneSeguranca.intValue() == 1 ? "y" : "n" ); - tipoServicoHigieneSegurancaEstabelecimentoElement.addContent( internoTipoServicoHigieneSegurancaEstabelecimentoElement ); - Element interempresasTipoServicoHigieneSegurancaEstabelecimentoElement = new Element( "interempresas" ); - interempresasTipoServicoHigieneSegurancaEstabelecimentoElement.setText( tipoServicoHigieneSeguranca.intValue() == 2 ? "y" : "n" ); - tipoServicoHigieneSegurancaEstabelecimentoElement.addContent( interempresasTipoServicoHigieneSegurancaEstabelecimentoElement ); - Element externoTipoServicoHigieneSegurancaEstabelecimentoElement = new Element( "externo" ); - externoTipoServicoHigieneSegurancaEstabelecimentoElement.setText( tipoServicoHigieneSeguranca.intValue() == 3 ? "y" : "n" ); - tipoServicoHigieneSegurancaEstabelecimentoElement.addContent( externoTipoServicoHigieneSegurancaEstabelecimentoElement ); - Element outroTipoServicoHigieneSegurancaEstabelecimentoElement = new Element( "outro" ); - outroTipoServicoHigieneSegurancaEstabelecimentoElement.setText( tipoServicoHigieneSeguranca.intValue() == 4 ? "y" : "n" ); - tipoServicoHigieneSegurancaEstabelecimentoElement.addContent( outroTipoServicoHigieneSegurancaEstabelecimentoElement ); - servicoHigieneSegurancaEstabelecimentoElement.addContent( tipoServicoHigieneSegurancaEstabelecimentoElement ); - Element designacaoServicoHigieneSegurancaEstabelecimentoElement = new Element( "designacao" ); - designacaoServicoHigieneSegurancaEstabelecimentoElement.setText( ( String )empresa.get( EmpresasData.SERVICO_HIGIENE_DESIGNACAO ) ); - servicoHigieneSegurancaEstabelecimentoElement.addContent( designacaoServicoHigieneSegurancaEstabelecimentoElement ); - estabelecimentoElement.addContent( servicoHigieneSegurancaEstabelecimentoElement ); - rootElement.addContent( estabelecimentoElement ); - - char sexo = ( (String)trabalhador.get( TrabalhadoresData.SEXO ) ).charAt( 0 ); - DateFormat df = DateFormat.getDateInstance( DateFormat.SHORT ); - Date dataNascimento = ( Date )trabalhador.get( TrabalhadoresData.DATA_NASCIMENTO ); - Date dataAdmissao = ( Date )trabalhador.get( TrabalhadoresData.DATA_ADMISSAO ); - Date dataAdmissaoFuncao = ( Date )trabalhador.get( TrabalhadoresData.DATA_ADMISSAO_FUNCAO ); - Element trabalhadorElement = new Element( "trabalhador" ); - Element nomeTrabalhadorElement = new Element( "nome" ); - nomeTrabalhadorElement.setText( ( String )trabalhador.get( TrabalhadoresData.NOME ) ); - Element sexoTrabalhadorElement = new Element( "sexo" ); - sexoTrabalhadorElement.setText( sexo == 'm' ? "Masculino" : "Feminino" ); - trabalhadorElement.addContent( sexoTrabalhadorElement ); - Element dataNascimentoTrabalhadorElement = new Element( "data-nascimento" ); - dataNascimentoTrabalhadorElement.setText( dataNascimento != null ? df.format( dataNascimento ) : "" ); - trabalhadorElement.addContent( dataNascimentoTrabalhadorElement ); - Element nacionalidadeTrabalhadorElement = new Element( "nacionalidade" ); - nacionalidadeTrabalhadorElement.setText( (String)trabalhador.get( TrabalhadoresData.NACIONALIDADE ) ); - trabalhadorElement.addContent( nacionalidadeTrabalhadorElement ); - trabalhadorElement.addContent( nomeTrabalhadorElement ); - Element numeroMecanograficoTrabalhadorElement = new Element( "numero-mecanografico" ); - numeroMecanograficoTrabalhadorElement.setText( (String)trabalhador.get( TrabalhadoresData.NUMERO_MECANOGRAFICO ) ); - trabalhadorElement.addContent( numeroMecanograficoTrabalhadorElement ); - Element dataAdmissaoTrabalhadorElement = new Element( "data-admissao" ); - dataAdmissaoTrabalhadorElement.setText( dataAdmissao != null ? df.format( dataAdmissao ) : "" ); - trabalhadorElement.addContent( dataAdmissaoTrabalhadorElement ); - Element categoriaProfissionalTrabalhadorElement = new Element( "categoria-profissional" ); - categoriaProfissionalTrabalhadorElement.setText( (String)trabalhador.get( TrabalhadoresData.CATEGORIA ) ); - trabalhadorElement.addContent( categoriaProfissionalTrabalhadorElement ); - Element localTrabalhoTrabalhadorElement = new Element( "local-trabalho" ); - localTrabalhoTrabalhadorElement.setText( (String)trabalhador.get( TrabalhadoresData.LOCAL_TRABALHO ) ); - trabalhadorElement.addContent( localTrabalhoTrabalhadorElement ); - Element funcaoPropostaTrabalhadorElement = new Element( "funcao-proposta" ); - funcaoPropostaTrabalhadorElement.setText( (String)trabalhador.get( TrabalhadoresData.FUNCAO_PROPOSTA ) ); - Element dataAdmissaoFuncaoTrabalhadorElement = new Element( "data-admissao-funcao" ); - dataAdmissaoFuncaoTrabalhadorElement.setText( dataAdmissaoFuncao != null ? df.format( dataAdmissaoFuncao ) : "" ); - trabalhadorElement.addContent( dataAdmissaoFuncaoTrabalhadorElement ); - trabalhadorElement.addContent( funcaoPropostaTrabalhadorElement ); - rootElement.addContent( trabalhadorElement ); - - Element observacoesElement = new Element( "observacoes" ); - observacoesElement.setText( (String)trabalhador.get( TrabalhadoresData.OBSERVACOES ) ); - rootElement.addContent( observacoesElement ); - - Date dataExameMedico = ( Date )exame.get( ExamesData.DATA ); - Integer tipoExameMedico = (Integer)exame.get( ExamesData.TIPO ); - Integer tipoOcasionalExameMedico = (Integer)exame.get( ExamesData.OCASIONAL ); - Integer resultadoExameMedico = (Integer)exame.get( ExamesData.RESULTADO ); - Element exameMedicoElement = new Element( "exame-medico" ); - Element dataExameMedicoElement = new Element( "data" ); - dataExameMedicoElement.setText( dataExameMedico != null ? df.format( dataExameMedico ) : "" ); - exameMedicoElement.addContent( dataExameMedicoElement ); - Element tipoExameMedicoElement = new Element( "tipo" ); - Element admissaoTipoExameMedicoElement = new Element( "admissao" ); - admissaoTipoExameMedicoElement.setText( tipoExameMedico.intValue() == 1 ? "y" : "n" ); - tipoExameMedicoElement.addContent( admissaoTipoExameMedicoElement ); - Element periodicoTipoExameMedicoElement = new Element( "periodico" ); - periodicoTipoExameMedicoElement.setText( tipoExameMedico.intValue() == 2 ? "y" : "n" ); - tipoExameMedicoElement.addContent( periodicoTipoExameMedicoElement ); - Element ocasionalTipoExameMedicoElement = new Element( "ocasional" ); - ocasionalTipoExameMedicoElement.setText( tipoExameMedico.intValue() == 3 ? "y" : "n" ); - tipoExameMedicoElement.addContent( ocasionalTipoExameMedicoElement ); - Element ocasionalDoencaTipoExameMedicoElement = new Element( "ocasional-doenca" ); - ocasionalDoencaTipoExameMedicoElement.setText( - ( tipoExameMedico.intValue() == 3 && tipoOcasionalExameMedico != null && tipoOcasionalExameMedico.intValue() == 1 ) ? "y" : "n" ); - tipoExameMedicoElement.addContent( ocasionalDoencaTipoExameMedicoElement ); - Element ocasionalAcidenteTipoExameMedicoElement = new Element( "ocasional-acidente" ); - ocasionalAcidenteTipoExameMedicoElement.setText( - ( tipoExameMedico.intValue() == 3 && tipoOcasionalExameMedico != null && tipoOcasionalExameMedico.intValue() == 2 ) ? "y" : "n" ); - tipoExameMedicoElement.addContent( ocasionalAcidenteTipoExameMedicoElement ); - Element ocasionalPedidoTrabalhadorTipoExameMedicoElement = new Element( "ocasional-pedido-trabalhador" ); - ocasionalPedidoTrabalhadorTipoExameMedicoElement.setText( - ( tipoExameMedico.intValue() == 3 && tipoOcasionalExameMedico != null && tipoOcasionalExameMedico.intValue() == 3 ) ? "y" : "n" ); - tipoExameMedicoElement.addContent( ocasionalPedidoTrabalhadorTipoExameMedicoElement ); - Element ocasionalPedidoServicoTipoExameMedicoElement = new Element( "ocasional-pedido-servico" ); - ocasionalPedidoServicoTipoExameMedicoElement.setText( - ( tipoExameMedico.intValue() == 3 && tipoOcasionalExameMedico != null && tipoOcasionalExameMedico.intValue() == 4 ) ? "y" : "n" ); - tipoExameMedicoElement.addContent( ocasionalPedidoServicoTipoExameMedicoElement ); - Element ocasionalMudancaoFuncaoTipoExameMedicoElement = new Element( "ocasional-mudanca-funcao" ); - ocasionalMudancaoFuncaoTipoExameMedicoElement.setText( - ( tipoExameMedico.intValue() == 3 && tipoOcasionalExameMedico != null && tipoOcasionalExameMedico.intValue() == 5 ) ? "y" : "n" ); - tipoExameMedicoElement.addContent( ocasionalMudancaoFuncaoTipoExameMedicoElement ); - Element ocasionalAlteracaoCondicoesTrabalhoTipoExameMedicoElement = new Element( "ocasional-alteracao-condicoes-trabalho" ); - ocasionalAlteracaoCondicoesTrabalhoTipoExameMedicoElement.setText( - ( tipoExameMedico.intValue() == 3 && tipoOcasionalExameMedico != null && tipoOcasionalExameMedico.intValue() == 6 ) ? "y" : "n" ); - tipoExameMedicoElement.addContent( ocasionalAlteracaoCondicoesTrabalhoTipoExameMedicoElement ); - Element ocasionalOutroTipoExameMedicoElement = new Element( "ocasional-outro" ); - ocasionalOutroTipoExameMedicoElement.setText( - ( tipoExameMedico.intValue() == 3 && tipoOcasionalExameMedico != null && tipoOcasionalExameMedico.intValue() == 10 ) ? "y" : "n" ); - tipoExameMedicoElement.addContent( ocasionalOutroTipoExameMedicoElement ); - Element ocasionalOutroDescricaoTipoExameMedicoElement = new Element( "ocasional-outro-descricao" ); - ocasionalOutroDescricaoTipoExameMedicoElement.setText( (String)exame.get( ExamesData.OUTRO_TIPO ) ); - tipoExameMedicoElement.addContent( ocasionalOutroDescricaoTipoExameMedicoElement ); - exameMedicoElement.addContent( tipoExameMedicoElement ); - Element resultadoExameMedicoElement = new Element( "resultado" ); - Element aptoResultadoExameMedicoElement = new Element( "apto" ); - aptoResultadoExameMedicoElement.setText( resultadoExameMedico.intValue() == 1 ? "y" : "n" ); - resultadoExameMedicoElement.addContent( aptoResultadoExameMedicoElement ); - Element aptoCondicionalmenteResultadoExameMedicoElement = new Element( "apto-condicionalmente" ); - aptoCondicionalmenteResultadoExameMedicoElement.setText( resultadoExameMedico.intValue() == 2 ? "y" : "n" ); - resultadoExameMedicoElement.addContent( aptoCondicionalmenteResultadoExameMedicoElement ); - Element inaptoTemporariamenteResultadoExameMedicoElement = new Element( "inapto-temporariamente" ); - inaptoTemporariamenteResultadoExameMedicoElement.setText( resultadoExameMedico.intValue() == 3 ? "y" : "n" ); - resultadoExameMedicoElement.addContent( inaptoTemporariamenteResultadoExameMedicoElement ); - Element inaptoDefinitivamenteResultadoExameMedicoElement = new Element( "inapto-definitivamente" ); - inaptoDefinitivamenteResultadoExameMedicoElement.setText( resultadoExameMedico.intValue() == 4 ? "y" : "n" ); - resultadoExameMedicoElement.addContent( inaptoDefinitivamenteResultadoExameMedicoElement ); - Element outrasFuncoes1ResultadoExameMedicoElement = new Element( "outras-funcoes-1" ); - outrasFuncoes1ResultadoExameMedicoElement.setText( (String)exame.get( ExamesData.OUTRA_FUNCAO_1 ) ); - resultadoExameMedicoElement.addContent( outrasFuncoes1ResultadoExameMedicoElement ); - Element outrasFuncoes2ResultadoExameMedicoElement = new Element( "outras-funcoes-2" ); - outrasFuncoes2ResultadoExameMedicoElement.setText( (String)exame.get( ExamesData.OUTRA_FUNCAO_2 ) ); - resultadoExameMedicoElement.addContent( outrasFuncoes2ResultadoExameMedicoElement ); - Element outrasFuncoes3ResultadoExameMedicoElement = new Element( "outras-funcoes-3" ); - outrasFuncoes3ResultadoExameMedicoElement.setText( (String)exame.get( ExamesData.OUTRA_FUNCAO_3 ) ); - resultadoExameMedicoElement.addContent( outrasFuncoes3ResultadoExameMedicoElement ); - Element outrasFuncoes4ResultadoExameMedicoElement = new Element( "outras-funcoes-4" ); - outrasFuncoes4ResultadoExameMedicoElement.setText( (String)exame.get( ExamesData.OUTRA_FUNCAO_4 ) ); - resultadoExameMedicoElement.addContent( outrasFuncoes4ResultadoExameMedicoElement ); - exameMedicoElement.addContent( resultadoExameMedicoElement ); - rootElement.addContent( exameMedicoElement ); - - Date dataProximoExame = ( Date )exame.get( ExamesData.PROXIMO_EXAME ); - Element proximoExameElement = new Element( "proximo-element" ); - proximoExameElement.setText( dataProximoExame != null ? df.format( dataProximoExame ) : "" ); - rootElement.addContent( proximoExameElement ); - - Element outrasRecomendacoesElement = new Element( "outras-recomendacoes" ); - outrasRecomendacoesElement.setText( (String)exame.get( ExamesData.OUTRAS_RECOMENDACOES ) ); - rootElement.addContent( outrasRecomendacoesElement ); - - Element medicoElement = new Element( "medico" ); - Element nomeMedicoElement = new Element( "nome" ); - nomeMedicoElement.setText( (String)medico.get( MedicosData.NOME ) ); - medicoElement.addContent( nomeMedicoElement ); - Element cedulaMedicoElement = new Element( "cedula" ); - cedulaMedicoElement.setText( (String)medico.get( MedicosData.NUMERO_CEDULA ) ); - medicoElement.addContent( cedulaMedicoElement ); - rootElement.addContent( medicoElement ); - - Document doc = new Document( rootElement ); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - new XMLOutputter().output( doc, baos ); - return baos.toByteArray(); - } - - 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 ); - useFO = false; - dialog.setVisible( true ); - } - } - -// private void printOldFO() -// { -// 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 ); -// useFO = true; -// dialog.setVisible( true ); -// } -// } - - public boolean executeListAction( int line, Object value ) - { - if( value != null ) - { - try - { -// if( useFO ) -// { -// ExamesData exame = (ExamesData) JDO.load( ExamesData.class, ( ( IDObject )value ).getID() ); -// if( exame == null ) -// { -// throw new Exception( "N\u00e3o existe exame" ); -// } -// byte fo[] = (byte[]) exame.get( ExamesData.FO ); -// Printer.printFO( fo ); -// } -// else -// { - print( ( ( IDObject )value ).getID(), false ); -// } - } - 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 ) ); - ExamesData exame = (ExamesData) JDO.load( ExamesData.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( ExamesData.DATA ) + "?", - "...", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null ) == 0 ) - { -// exame.set( ExamesData.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; - } - - public void editTrabalhador( Integer trabalhadorID, Date ultimaConsulta, Integer motivoProcesso, SaveExameListener listener ) - { - editTrabalhador(trabalhadorID,listener); - examePanel.setup( ultimaConsulta, motivoProcesso ); - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/MedicoColumnizedObject.java b/trunk/SIPRPSoft/src/siprp/ficha/MedicoColumnizedObject.java deleted file mode 100644 index f8d64bbd..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.ColumnizedObject; - -/** - * - * @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 769a6fd6..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/MedicoEditor.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * MedicoEditor.java - * - * Created on 10 de Abril de 2004, 20:50 - */ - -package siprp.ficha; - -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Vector; - -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextField; -import javax.swing.ListSelectionModel; -import javax.swing.event.ListSelectionListener; - -import shst.data.outer.MedicosData; -import siprp.FichaDataProvider; -import siprp.ui.SIPRPTabbedWindow; - -import com.evolute.entity.ProviderInterface; -import com.evolute.utils.Singleton; -import com.evolute.utils.tables.BaseTable; -import com.evolute.utils.tables.VectorTableModel; -import com.evolute.utils.ui.CustomJDialog; -import com.evolute.utils.ui.DialogException; -import com.evolute.utils.ui.text.CopyPasteHandler; - -/** - * - * @author Administrator - */ -public class MedicoEditor extends CustomJDialog - implements ActionListener, ListSelectionListener -{ - - private ProviderInterface 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( SIPRPTabbedWindow owner ) - throws Exception - { - super( owner, true ); - provider = (FichaDataProvider)FichaDataProvider.getProvider(); - JDO = ( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_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 - { - MedicosData medico; - if( id != null ) - { - medico = ( MedicosData ) JDO.load( MedicosData.class, id ); -// medico = provider.load( provider.MEDICOS, new DBKey( id ) ); - } - else - { - medico = new MedicosData(); -// medico = provider.createObject( provider.MEDICOS ); - } -// medico.setProperty( provider.NOME, nome ); -// medico.setProperty( provider.NUMERO_CEDULA, numero ); - medico.set( MedicosData.NOME, nome ); - medico.set( MedicosData.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( MedicosData.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 dce49b45..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/ObservacoesPanel.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * ObservacoesPanel.java - * - * Created on 29 de Marco de 2004, 11:56 - */ - -package siprp.ficha; - -import java.awt.GridLayout; - -import javax.swing.BorderFactory; -import javax.swing.JPanel; -import javax.swing.JTextField; - -import shst.data.outer.TrabalhadoresData; -import siprp.FichaDataProvider; - -import com.evolute.entity.ProviderInterface; -import com.evolute.utils.Singleton; -import com.evolute.utils.dataui.ControllableComponent; -import com.evolute.utils.documents.MaximumLengthDocument; -import com.evolute.utils.ui.text.CopyPasteHandler; -/** - * - * @author fpalma - */ -public class ObservacoesPanel extends JPanel - implements ControllableComponent -{ - private ProviderInterface JDO; - - private JTextField observacoesText; - - private FichaDataProvider provider; - - /** Creates a new instance of ObservacoesPanel */ - public ObservacoesPanel() - throws Exception - { - provider = (FichaDataProvider)FichaDataProvider.getProvider(); - JDO = ( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_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 - { - TrabalhadoresData trabalhador = (TrabalhadoresData)JDO.load( TrabalhadoresData.class, trabalhadorID ); - String observacoes = (String) trabalhador.get( TrabalhadoresData.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/PDFFilePrinter.java b/trunk/SIPRPSoft/src/siprp/ficha/PDFFilePrinter.java deleted file mode 100644 index a3e0b5ea..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/PDFFilePrinter.java +++ /dev/null @@ -1,57 +0,0 @@ -package siprp.ficha; - -import java.awt.Color; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.print.PageFormat; -import java.nio.ByteBuffer; - -import com.evolute.utils.print.A4ContinuoPage; -import com.evolute.utils.print.AbstractPrintHandler; -import com.sun.pdfview.PDFFile; -import com.sun.pdfview.PDFPage; -import com.sun.pdfview.PDFRenderer; - -public class PDFFilePrinter extends AbstractPrintHandler -{ - protected byte pdf[]; - protected PDFFile pdffile; - - public PDFFilePrinter(byte pdf[], boolean printDialog ) - throws Exception - { - super( new A4ContinuoPage(), printDialog ); - - this.pdf = pdf; - ByteBuffer buffer = ByteBuffer.allocate( pdf.length ); - buffer.put( pdf ); -// - -// File file = new File("/home/fpalma/Desktop/icons_op.pdf"); -// -// // set up the PDF reading -// RandomAccessFile raf = new RandomAccessFile(file, "r"); -// FileChannel channel = raf.getChannel(); -// ByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size()); - pdffile = new PDFFile(buffer); - setNumberOfPages( pdffile.getNumPages() ); - print(); - } - - protected void paintGraphics( Graphics g, PageFormat pf, int index ) - { - try - { - PDFPage page = pdffile.getPage( index ); - PDFRenderer renderer = new PDFRenderer(page, ( Graphics2D ) g, - new Rectangle(0, 0,(int) page.getWidth(), (int) page.getHeight()), null, Color.RED); - page.waitForFinish(); - renderer.run(); - } - catch( Exception ex ) - { - ex.printStackTrace(); - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/ficha/RecomendacoesPanel.java b/trunk/SIPRPSoft/src/siprp/ficha/RecomendacoesPanel.java deleted file mode 100644 index 2e387342..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/RecomendacoesPanel.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * RecomendacoesPanel.java - * - * Created on 29 de Marco de 2004, 11:58 - */ - -package siprp.ficha; - -import java.awt.BorderLayout; -import java.awt.GridLayout; - -import javax.swing.BorderFactory; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; - -import com.evolute.utils.documents.MaximumLengthDocument; -import com.evolute.utils.ui.calendar.JCalendarPanel; -import com.evolute.utils.ui.text.CopyPasteHandler; - -/** - * - * @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 0b260c80..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/TrabalhadorPanel.java +++ /dev/null @@ -1,470 +0,0 @@ -/* - * TrabalhadorPanel.java - * - * Created on 29 de Marco de 2004, 11:55 - */ - -package siprp.ficha; - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.util.Hashtable; - -import javax.swing.BorderFactory; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextField; - -import shst.data.outer.TrabalhadoresData; -import shst.importer.Importer; -import siprp.FichaDataProvider; - -import com.evolute.entity.ProviderInterface; -import com.evolute.utils.Singleton; -import com.evolute.utils.data.IDObject; -import com.evolute.utils.data.MappableObject; -import com.evolute.utils.dataui.ComponentController; -import com.evolute.utils.dataui.ComponentsHashtable; -import com.evolute.utils.dataui.ControllableComponent; -import com.evolute.utils.date.DateUtils; -import com.evolute.utils.ui.DialogException; -import com.evolute.utils.ui.calendar.JCalendarPanel; -import com.evolute.utils.ui.panel.RadioButtonFixedPanel; -import com.evolute.utils.ui.panel.RadioButtonPanel; -import com.evolute.utils.ui.text.CopyPasteHandler; -/** - * - * @author fpalma - */ -public class TrabalhadorPanel extends JPanel - implements ControllableComponent -{ - private ProviderInterface 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 TrabalhadoresData trabalhador; - - /** Creates a new instance of TrabalhadorPanel */ - - public TrabalhadorPanel() - throws Exception - { - provider = (FichaDataProvider)FichaDataProvider.getProvider(); - JDO = ( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_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( TrabalhadoresData.NOME, nomeText ); - components.putComponent( TrabalhadoresData.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( TrabalhadoresData.DATA_NASCIMENTO, dataNascimentoPanel ); - components.putComponent( TrabalhadoresData.NACIONALIDADE, nacionalidadeText ); - components.putComponent( TrabalhadoresData.NUMERO_MECANOGRAFICO, numeroMecanograficoText ); - components.putComponent( TrabalhadoresData.DATA_ADMISSAO, dataAdmissaoPanel ); - components.putComponent( TrabalhadoresData.CATEGORIA, categoriaText ); - components.putComponent( TrabalhadoresData.LOCAL_TRABALHO, localText ); - components.putComponent( TrabalhadoresData.FUNCAO_PROPOSTA, funcaoText ); - components.putComponent( TrabalhadoresData.DATA_ADMISSAO_FUNCAO, dataAdmissaoFuncaoPanel ); - components.putDummy( TrabalhadoresData.DATA_DEMISSAO ); - components.putDummy( TrabalhadoresData.OBSERVACOES ); - components.putDummy( TrabalhadoresData.OBSERVACOES_GESTAO ); - components.putDummy( TrabalhadoresData.PERFIL ); - components.putDummy( TrabalhadoresData.TO_ESTABELECIMENTO_ID ); - components.putDummy( TrabalhadoresData.NOME_PLAIN ); - components.putDummy( TrabalhadoresData.BI ); - -// 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 = ( TrabalhadoresData ) JDO.load( TrabalhadoresData.class, trabalhadorID ); -// String names[] = trabalhador.getFieldNames(); - ComponentController.fill( 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 TrabalhadoresData(); - trabalhador.set( TrabalhadoresData.PERFIL, new Integer( 1 ) ); - } - trabalhador.setHashData( ComponentController.save( components ) ); -// if( ((String)trabalhador.getProperty( FichaDataProvider.NOME )).trim().length() == 0 ) - if( ((String)trabalhador.get( TrabalhadoresData.NOME )).trim().length() == 0 ) - { - msg.append( "O trabalhador tem de ter nome\n" ); - hasMsg = true; - } -// if( trabalhador.getProperty( FichaDataProvider.SEXO ) == null ) - if( trabalhador.get( TrabalhadoresData.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 55b9eb89..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/UpperPanel.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * UpperPanel.java - * - * Created on 29 de Marco de 2004, 17:44 - */ - -package siprp.ficha; - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ItemListener; -import java.util.Hashtable; - -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; - -import shst.data.outer.EmpresasData; -import shst.data.outer.EstabelecimentosData; -import shst.data.outer.MedicosData; -import shst.data.outer.TrabalhadoresData; -import siprp.FichaDataProvider; -import siprp.ui.SIPRPTabbedWindow; - -import com.evolute.entity.ProviderInterface; -import com.evolute.utils.Singleton; -import com.evolute.utils.data.IDObject; -import com.evolute.utils.data.MappableObject; -import com.evolute.utils.dataui.ControllableComponent; -import com.evolute.utils.ui.DialogException; -import com.evolute.utils.ui.text.CopyPasteHandler; - -/** - * - * @author fpalma - */ -public class UpperPanel extends JPanel - implements ControllableComponent< Object >, ItemListener -{ - protected ProviderInterface JDO; - - protected SIPRPTabbedWindow 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 = ( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_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 - { - TrabalhadoresData trabalhador; - EstabelecimentosData estabelecimento; - EmpresasData empresa; - if( trabalhadorID != null ) - { - trabalhador = ( TrabalhadoresData ) JDO.load( TrabalhadoresData.class, trabalhadorID ); - String nome = (String) trabalhador.get( TrabalhadoresData.NOME ); - nomeText.setText( nome ); - } - String nomeEstabelecimento = ""; - if( estabelecimentoID != null ) - { - estabelecimento = ( EstabelecimentosData ) JDO.load( EstabelecimentosData.class, estabelecimentoID ); - nomeEstabelecimento = (String) estabelecimento.get( EstabelecimentosData.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 = ( EmpresasData ) JDO.load( EmpresasData.class, empresaID ); - String nomeEmpresa = (String) empresa.get( EmpresasData.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 - { - MedicosData medico = ( MedicosData )JDO.load( MedicosData.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.setVisible( true ); -// 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_teste.xml b/trunk/SIPRPSoft/src/siprp/ficha/ficha_aptidao_teste.xml deleted file mode 100644 index 0935d901..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/ficha_aptidao_teste.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - 111-21/12/2001 - - - Evolute - Consultoria Informatica - - - - - Sede - - - Lisboa - - - - y - n - n - n - - - SIPRP - - - - - n - n - n - y - - - SIPRP - - - - - Frederico Palma - Masculino - 30-12-1977 - Portuguesa - 32434234 - 01-10-2006 - Deus - Sede - Senhor do Universo - 01-01-10000AF - - - nada a observar - - - 03-12-2007 - - y - y - y - y - y - y - y - y - y - y - sdlfjk - - - y - y - y - y - outra-func-1 - outra-func-2 - outra-func-3 - outra-func-4 - - - 10-01-2010 - - Olho por Olho, Dente por Dente - - - Joao Antonio Pedro - 4234234 - - \ No newline at end of file diff --git a/trunk/SIPRPSoft/src/siprp/ficha/out.txt b/trunk/SIPRPSoft/src/siprp/ficha/out.txt deleted file mode 100644 index f853af5a..00000000 --- a/trunk/SIPRPSoft/src/siprp/ficha/out.txt +++ /dev/null @@ -1,6 +0,0 @@ -C:\Documents and Settings\Frederico\workspace\SIPRP\SIPRPSoft\src\siprp\ficha\ficha_aptidao_teste.xml -/home/fpalma/projectos2/SIPRP/SIPRPSoft/src/siprp/ficha/ficha_aptidao_teste.xml - -☐ -✓ - 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/initializer/SIPRPLoggerInit.java b/trunk/SIPRPSoft/src/siprp/initializer/SIPRPLoggerInit.java index fb18fb25..572a5e62 100644 --- a/trunk/SIPRPSoft/src/siprp/initializer/SIPRPLoggerInit.java +++ b/trunk/SIPRPSoft/src/siprp/initializer/SIPRPLoggerInit.java @@ -33,16 +33,6 @@ public class SIPRPLoggerInit ErrorLogger.logException( e ); } -// HashMap properties = new HashMap(); -// properties.put( LoggerProperties.PROJECT, ProjectsEnum.SIPRP.toString() ); -// properties.put( LoggerProperties.PROJECT_NAME, ProjectTools.getInstance().getProjectName() ); -// properties.put( LoggerProperties.SOFTWARE_VERSION, ProjectTools.getInstance().getVersion().toString() ); -// properties.put( LoggerProperties.SOFTWARE_NAME, "SIPRPSoft" ); -// properties.put(LoggerProperties.PASSWORD, "2DD-rg2hLOG" ); -// properties.put(LoggerProperties.USERNAME, "evo_logger" ); -// properties.put(LoggerProperties.URL, "jdbc:postgresql://www.evolute.pt:5436/evo_logging"); -// DBLogger logger = new DBLogger(properties); -// ErrorLogger.initializeLogger( logger ); } } diff --git a/trunk/SIPRPSoft/src/siprp/initializer/SIPRPUIInitializer.java b/trunk/SIPRPSoft/src/siprp/initializer/SIPRPUIInitializer.java deleted file mode 100644 index f65f3dc0..00000000 --- a/trunk/SIPRPSoft/src/siprp/initializer/SIPRPUIInitializer.java +++ /dev/null @@ -1,38 +0,0 @@ -package siprp.initializer; - -import java.awt.Color; - -import javax.swing.UIManager; - -import com.evolute.application.EvoAbstractAppInitializer; -import com.nilo.plaf.nimrod.NimRODLookAndFeel; -import com.nilo.plaf.nimrod.NimRODTheme; - -public class SIPRPUIInitializer extends EvoAbstractAppInitializer -{ - - public SIPRPUIInitializer() - { - super( "UI", false, false, false ); - } - - @Override - public boolean doInit() throws Exception - { - NimRODTheme nt = new NimRODTheme(); - - nt.setPrimary1( new Color( 150, 180, 200 ) ); // tab header highlight, scroll highlight - nt.setPrimary2( new Color( 150, 180, 200 ) ); // button highlight & progress bar & selected tab header background & selected row ... - nt.setPrimary3( new Color( 150, 150, 150 ) ); // tree's graph color - - nt.setSecondary1( new Color( 150, 150, 150 ) ); // Button contour - nt.setSecondary2( new Color( 200, 210, 220 ) ); // unselected tab header's background & border color (in tables too) - nt.setSecondary3( new Color( 235, 235, 235 ) ); // panel's background - - NimRODLookAndFeel NimRODLF = new NimRODLookAndFeel(); - NimRODLookAndFeel.setCurrentTheme( nt ); - UIManager.setLookAndFeel( NimRODLF ); - return true; - } - -} 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.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/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/paths b/trunk/SIPRPSoft/src/siprp/paths deleted file mode 100644 index f4c4fe58..00000000 --- a/trunk/SIPRPSoft/src/siprp/paths +++ /dev/null @@ -1,2 +0,0 @@ -/home/fpalma/projectos/SIPRP/SIPRPSoft/src/siprp/teste.xml -/home/fpalma/projectos2/SIPRP/SIPRPSoft/src/siprp/analise_acidentes_trabalho.xsl \ No newline at end of file diff --git a/trunk/SIPRPSoft/src/siprp/pesquisas/PesquisasProvider.java b/trunk/SIPRPSoft/src/siprp/pesquisas/PesquisasProvider.java deleted file mode 100644 index 0c7cc436..00000000 --- a/trunk/SIPRPSoft/src/siprp/pesquisas/PesquisasProvider.java +++ /dev/null @@ -1,922 +0,0 @@ -/* - * EstatisticasProvider.java - * - * Created on 3 de Junho de 2004, 18:23 - */ - -package siprp.pesquisas; - -import java.util.Calendar; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Vector; - -import shst.data.Marcacao; -import shst.data.outer.EmpresasData; -import shst.data.outer.MarcacoesTrabalhadorData; -import shst.data.outer.TrabalhadoresData; - -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.metadb.MetaProvider; -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.expression.Par; -/** - * - * @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[]{ EmpresasData.ID, EmpresasData.DESIGNACAO_SOCIAL, EmpresasData.DESIGNACAO_SOCIAL_PLAIN }, - new Field( EmpresasData.INACTIVO ).isDifferent( "y" ), - new String[]{ EmpresasData.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(" + TrabalhadoresData.ID + ")" }, - new Par( new Field( "YEAR(" + TrabalhadoresData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or( - new Field( TrabalhadoresData.DATA_ADMISSAO ).isEqual( null ) ) ).and( - new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and( - new Field( TrabalhadoresData.SEXO ).isEqual( "m" ) ).and( - new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and( - new Par( new Field( TrabalhadoresData.DATA_DEMISSAO ).isGreater( cal.getTime() ).or( - new Field( TrabalhadoresData.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(" + TrabalhadoresData.ID + ")" }, - new Par( new Field( "YEAR(" + TrabalhadoresData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or( - new Field( TrabalhadoresData.DATA_ADMISSAO ).isEqual( null ) ) ).and( - new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and( - new Field( TrabalhadoresData.SEXO ).isEqual( "f" ) ).and( - new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and( - new Par( new Field( TrabalhadoresData.DATA_DEMISSAO ).isGreater( cal.getTime() ).or( - new Field( TrabalhadoresData.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(" + TrabalhadoresData.ID + ")" }, - new Par( new Field( "YEAR(" + TrabalhadoresData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or( - new Field( TrabalhadoresData.DATA_ADMISSAO ).isEqual( null ) ) ).and( - new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and( - new Field( TrabalhadoresData.SEXO ).isEqual( "m" ) ).and( - new Field( TrabalhadoresData.DATA_NASCIMENTO ).isGreater( age18.getTime() ) ).and( - new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and( - new Par( new Field( TrabalhadoresData.DATA_DEMISSAO ).isGreater( eoy.getTime() ).or( - new Field( TrabalhadoresData.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(" + TrabalhadoresData.ID + ")" }, - new Par( new Field( "YEAR(" + TrabalhadoresData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or( - new Field( TrabalhadoresData.DATA_ADMISSAO ).isEqual( null ) ) ).and( - new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and( - new Field( TrabalhadoresData.SEXO ).isEqual( "f" ) ).and( - new Field( TrabalhadoresData.DATA_NASCIMENTO ).isGreater( age18.getTime() ) ).and( - new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and( - new Par( new Field( TrabalhadoresData.DATA_DEMISSAO ).isGreater( eoy.getTime() ).or( - new Field( TrabalhadoresData.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(" + TrabalhadoresData.ID + ")" }, - new Par( new Field( "YEAR(" + TrabalhadoresData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or( - new Field( TrabalhadoresData.DATA_ADMISSAO ).isEqual( null ) ) ).and( - new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and( - new Field( TrabalhadoresData.SEXO ).isEqual( "m" ) ).and( - new Field( TrabalhadoresData.DATA_NASCIMENTO ).isLessOrEqual( age18.getTime() ) ).and( - new Field( TrabalhadoresData.DATA_NASCIMENTO ).isGreater( age50.getTime() ) ).and( - new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and( - new Par( new Field( TrabalhadoresData.DATA_DEMISSAO ).isGreater( eoy.getTime() ).or( - new Field( TrabalhadoresData.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(" + TrabalhadoresData.ID + ")" }, - new Par( new Field( "YEAR(" + TrabalhadoresData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or( - new Field( TrabalhadoresData.DATA_ADMISSAO ).isEqual( null ) ) ).and( - new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and( - new Field( TrabalhadoresData.SEXO ).isEqual( "f" ) ).and( - new Field( TrabalhadoresData.DATA_NASCIMENTO ).isLessOrEqual( age18.getTime() ) ).and( - new Field( TrabalhadoresData.DATA_NASCIMENTO ).isGreater( age50.getTime() ) ).and( - new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and( - new Par( new Field( TrabalhadoresData.DATA_DEMISSAO ).isGreater( eoy.getTime() ).or( - new Field( TrabalhadoresData.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(" + TrabalhadoresData.ID + ")" }, - new Par( new Field( "YEAR(" + TrabalhadoresData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or( - new Field( TrabalhadoresData.DATA_ADMISSAO ).isEqual( null ) ) ).and( - new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and( - new Field( TrabalhadoresData.SEXO ).isEqual( "m" ) ).and( - new Field( TrabalhadoresData.DATA_NASCIMENTO ).isLessOrEqual( age50.getTime() ) ).and( - new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and( - new Par( new Field( TrabalhadoresData.DATA_DEMISSAO ).isGreater( eoy.getTime() ).or( - new Field( TrabalhadoresData.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(" + TrabalhadoresData.ID + ")" }, - new Par( new Field( "YEAR(" + TrabalhadoresData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or( - new Field( TrabalhadoresData.DATA_ADMISSAO ).isEqual( null ) ) ).and( - new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) ).and( - new Field( TrabalhadoresData.SEXO ).isEqual( "f" ) ).and( - new Field( TrabalhadoresData.DATA_NASCIMENTO ).isLessOrEqual( age50.getTime() ) ).and( - new Field( "trabalhadores.inactivo" ).isEqual( "n" ) ).and( - new Par( new Field( TrabalhadoresData.DATA_DEMISSAO ).isGreater( eoy.getTime() ).or( - new Field( TrabalhadoresData.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( TrabalhadoresData.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( TrabalhadoresData.DATA_NASCIMENTO ).isLessOrEqual( dates[ d ].getTime() ) ).and( - dates[ d + 1 ] == null ? new Field( "exames.id" ).isDifferent( null ) : - new Field( TrabalhadoresData.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( TrabalhadoresData.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( TrabalhadoresData.DATA_NASCIMENTO ).isLessOrEqual( dates[ d ].getTime() ) ).and( - dates[ d + 1 ] == null ? new Field( "exames.id" ).isDifferent( null ) : - new Field( TrabalhadoresData.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(" + TrabalhadoresData.DATA_ADMISSAO + ")" ).isLess( new Integer( ano ) ).or( - new Field( TrabalhadoresData.DATA_ADMISSAO ).isEqual( null ) ) ) ).and( - new Par( new Field( "YEAR(" + TrabalhadoresData.DATA_DEMISSAO + ")" ).isGreater( new Integer( ano ) ).or( - new Field( TrabalhadoresData.DATA_DEMISSAO ).isEqual( null ) ) ) ).and( - new Field( "empresa_id" ).isEqual( empresaID ) ).and( - new Field( TrabalhadoresData.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(" + TrabalhadoresData.DATA_ADMISSAO + ")" ).isLess( new Integer( ano ) ).or( - new Field( TrabalhadoresData.DATA_ADMISSAO ).isEqual( null ) ) ) ).and( - new Field( "YEAR(" + TrabalhadoresData.DATA_DEMISSAO + ")" ).isEqual( new Integer( ano ) ) ).and( - new Field( "empresa_id" ).isEqual( empresaID ) ).and( - new Field( TrabalhadoresData.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(" + TrabalhadoresData.DATA_ADMISSAO + ")" ).isEqual( new Integer( ano ) ) ).and( - new Par( new Field( "YEAR(" + TrabalhadoresData.DATA_DEMISSAO + ")" ).isGreater( new Integer( ano ) ).or( - new Field( TrabalhadoresData.DATA_DEMISSAO ).isEqual( null ) ) ) ).and( - new Field( "empresa_id" ).isEqual( empresaID ) ).and( - new Field( TrabalhadoresData.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(" + TrabalhadoresData.DATA_ADMISSAO + ")" ).isEqual( new Integer( ano ) ) ).and( - new Field( "YEAR(" + TrabalhadoresData.DATA_DEMISSAO + ")" ).isEqual( new Integer( ano ) ) ).and( - new Field( "empresa_id" ).isEqual( empresaID ) ).and( - new Field( TrabalhadoresData.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(" + TrabalhadoresData.DATA_ADMISSAO + ")" ).isLessOrEqual( new Integer( ano ) ).or( - new Field( TrabalhadoresData.DATA_ADMISSAO ).isEqual( null ) ) ) ).and( - new Par( new Field( "YEAR(" + TrabalhadoresData.DATA_DEMISSAO + ")" ).isGreaterOrEqual( new Integer( ano ) ).or( - new Field( TrabalhadoresData.DATA_DEMISSAO ).isEqual( null ) ) ) ).and( - new Field( "empresa_id" ).isEqual( empresaID ) ).and( - new Field( TrabalhadoresData.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)", TrabalhadoresData.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( MarcacoesTrabalhadorData.TIPO ).isEqual( new Integer( MarcacoesTrabalhadorData.TIPO_EXAMES ) ) ).and( -// new Field( "YEAR( marcacoes_trabalhador.data ) " ).isEqual( new Integer( ano ) ).and( -// new Field( MarcacoesTrabalhadorData.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)", TrabalhadoresData.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( MarcacoesTrabalhadorData.TIPO ).isEqual( new Integer( MarcacoesTrabalhadorData.TIPO_EXAMES ) ) ).and( - new Field( "YEAR( marcacoes_trabalhador.data ) " ).isEqual( new Integer( ano ) ).and( - new Field( Marcacao.REALIZADA ).isEqual( "y" ) ) ), - new String[]{ TrabalhadoresData.PERFIL }, - new String[]{ TrabalhadoresData.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 HashMap countExamesComplementaresEmpresaNovosProtocolos( Integer empresaId, int ano ) - throws Exception - { - HashMap> perfis = new HashMap>(); - HashMap contagens = null; - - Select select = - new Select2( new String[]{ "prt_elementos_protocolo", "prt_tipos_elementos_protocolo", "prt_grupos_protocolo" }, - new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER }, - new Expression[]{ - new Field( "prt_elementos_protocolo.tipo_elemento_protocolo_id" ).isEqual( new Field( "prt_tipos_elementos_protocolo.id" ) ), - new Field( "prt_tipos_elementos_protocolo.grupo_protocolo_id" ).isEqual( new Field( "prt_grupos_protocolo.id" ) ), - }, - new String[]{ "DISTINCT prt_elementos_protocolo.numero_perfil", "prt_grupos_protocolo.descricao" }, - new Field( "prt_elementos_protocolo.empresa_id" ).isEqual( empresaId ), - null, - null, - null, - null ); - Virtual2DArray array = executer.executeQuery( select ); - for( int n = 0; n < array.columnLength(); n++ ) - { - Integer perfil = ( Integer ) array.get( n, 0 ); - String tipo = ( String ) array.get( n, 1 ); - if( !perfis.containsKey( perfil ) ) - { - perfis.put( perfil, new Vector() ); - } - perfis.get( perfil ).add( tipo ); - } - - if( perfis.size() > 0 ) - { - contagens = new HashMap(); - select = new Select2( - new String[]{"trabalhadores", "marcacoes_trabalhador", "empresas"}, - new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER }, - new Expression[]{ - new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ), - new Field( "trabalhadores.estabelecimentos_id" ).isEqual( new Field( "estabelecimentos.id" ) ), - }, - new String[]{"COUNT(marcacoes_trabalhador.id)", TrabalhadoresData.PERFIL }, - new Field( "estabelecimentos.id.empresa_id" ).isEqual( empresaId ).and( - new Field( MarcacoesTrabalhadorData.TIPO ).isEqual( new Integer( MarcacoesTrabalhadorData.TIPO_EXAMES ) ) ).and( - new Field( "YEAR( marcacoes_trabalhador.data ) " ).isEqual( new Integer( ano ) ).and( - new Field( Marcacao.REALIZADA ).isEqual( "y" ) ) ), - null, - new String[]{ TrabalhadoresData.PERFIL }, - null, - null ); - array = executer.executeQuery( select ); - for( int n = 0; n < array.columnLength(); n++ ) - { - Integer perfil = (Integer)array.get( n, 1 ); - Integer count = ( ( Number ) array.get( n, 0 ) ).intValue(); - if( perfil == null ) - { - continue; - } - Vector tipos = perfis.get( perfil ); - for( String tipo : tipos ) - { - if( !contagens.containsKey( tipo ) ) - { - contagens.put( tipo, count ); - } - else - { - contagens.put( tipo, contagens.get( tipo ) + count ); - } - } - } - } - return contagens; - } - - public int []countExamesComplementaresEstabelecimento( Integer estabelecimentoID, int ano ) - throws Exception - { - int contagens[] = null; - 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)", TrabalhadoresData.PERFIL }, - new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).and( - new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and( - new Field( MarcacoesTrabalhadorData.TIPO ).isEqual( new Integer( MarcacoesTrabalhadorData.TIPO_EXAMES ) ) ).and( - new Field( "YEAR( marcacoes_trabalhador.data ) " ).isEqual( new Integer( ano ) ).and( - new Field( Marcacao.REALIZADA ).isEqual( "y" ) ) ), - new String[]{ TrabalhadoresData.PERFIL }, - new String[]{ TrabalhadoresData.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 HashMap countExamesComplementaresEstabelecimentoNovosProtocolos( Integer estabelecimentoID, int ano ) - throws Exception - { - HashMap> perfis = new HashMap>(); - HashMap contagens = null; - Select select = - new Select2( new String[]{ "estabelecimentos" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "empresa_id" }, - new Field( "id" ).isEqual( estabelecimentoID ), - null, - null, - null, - null ); - Virtual2DArray array = executer.executeQuery( select ); - Integer empresaId = ( Integer ) array.get( 0, 0 ); - select = - new Select2( new String[]{ "prt_elementos_protocolo", "prt_tipos_elementos_protocolo", "prt_grupos_protocolo" }, - new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER }, - new Expression[]{ - new Field( "prt_elementos_protocolo.tipo_elemento_protocolo_id" ).isEqual( new Field( "prt_tipos_elementos_protocolo.id" ) ), - new Field( "prt_tipos_elementos_protocolo.grupo_protocolo_id" ).isEqual( new Field( "prt_grupos_protocolo.id" ) ), - }, - new String[]{ "DISTINCT prt_elementos_protocolo.numero_perfil", "prt_grupos_protocolo.descricao" }, - new Field( "prt_elementos_protocolo.empresa_id" ).isEqual( empresaId ), - null, - null, - null, - null ); - array = executer.executeQuery( select ); - for( int n = 0; n < array.columnLength(); n++ ) - { - Integer perfil = ( Integer ) array.get( n, 0 ); - String tipo = ( String ) array.get( n, 1 ); - if( !perfis.containsKey( perfil ) ) - { - perfis.put( perfil, new Vector() ); - } - perfis.get( perfil ).add( tipo ); - } - - if( perfis.size() > 0 ) - { - contagens = new HashMap(); - select = new Select2( - new String[]{"trabalhadores", "marcacoes_trabalhador"}, - new Integer[]{ Select2.JOIN_INNER }, - new Expression[]{ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) }, - new String[]{"COUNT(marcacoes_trabalhador.id)", TrabalhadoresData.PERFIL }, - new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ).and( - new Field( MarcacoesTrabalhadorData.TIPO ).isEqual( new Integer( MarcacoesTrabalhadorData.TIPO_EXAMES ) ) ).and( - new Field( "YEAR( marcacoes_trabalhador.data ) " ).isEqual( new Integer( ano ) ).and( - new Field( Marcacao.REALIZADA ).isEqual( "y" ) ) ), - null, - new String[]{ TrabalhadoresData.PERFIL }, - null, - null ); - array = executer.executeQuery( select ); - for( int n = 0; n < array.columnLength(); n++ ) - { - Integer perfil = (Integer)array.get( n, 1 ); - Integer count = ( ( Number ) array.get( n, 0 ) ).intValue(); - if( perfil == null ) - { - continue; - } - Vector tipos = perfis.get( perfil ); - for( String tipo : tipos ) - { - if( !contagens.containsKey( tipo ) ) - { - contagens.put( tipo, count ); - } - else - { - contagens.put( tipo, contagens.get( tipo ) + count ); - } - } - } - } - return contagens; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/pesquisas/RelatorioAnualWindow.java b/trunk/SIPRPSoft/src/siprp/pesquisas/RelatorioAnualWindow.java deleted file mode 100644 index 1360f197..00000000 --- a/trunk/SIPRPSoft/src/siprp/pesquisas/RelatorioAnualWindow.java +++ /dev/null @@ -1,626 +0,0 @@ -/* - * PesquisasWindow.java - * - * Created on 3 de Junho de 2004, 18:13 - */ - -package siprp.pesquisas; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FileDialog; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Vector; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JEditorPane; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextField; -import javax.swing.ListSelectionModel; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import shst.data.outer.ContactosData; -import shst.data.outer.EmpresasData; -import shst.data.outer.EstabelecimentosData; -import siprp.ui.SIPRPFrame; - -import com.evolute.entity.ProviderInterface; -import com.evolute.utils.Singleton; -import com.evolute.utils.data.IDObject; -import com.evolute.utils.data.MappableObject; -import com.evolute.utils.documents.YearDocument; -import com.evolute.utils.tables.BaseTable; -import com.evolute.utils.tables.VectorTableModel; -import com.evolute.utils.tracker.TrackableWindow; -import com.evolute.utils.ui.DialogException; -import com.evolute.utils.ui.text.CopyPasteHandler; - -/** - * - * @author fpalma - */ -public class RelatorioAnualWindow extends SIPRPFrame - implements TrackableWindow, ListSelectionListener, ActionListener -{ - private ProviderInterface 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 RelatorioAnualWindow() - throws Exception - { - provider = (PesquisasProvider)PesquisasProvider.getProvider(); - JDO =( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_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.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.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; - - JPanel empresasPanel = new JPanel( new BorderLayout() ); - JPanel estabelecimentosPanel = new JPanel( new BorderLayout() ); - empresasPanel.setBorder( BorderFactory.createTitledBorder( "Empresa" ) ); - estabelecimentosPanel.setBorder( BorderFactory.createTitledBorder( "Estabelecimento" ) ); - empresasPanel.add( empresasScroll, BorderLayout.CENTER ); - estabelecimentosPanel.add( estabelecimentosScroll, BorderLayout.CENTER ); - - gridbag.setConstraints( empresasPanel, constraints ); - getContentPane().add( empresasPanel ); - - gridbag.setConstraints( estabelecimentosPanel, constraints ); - getContentPane().add( estabelecimentosPanel ); - - 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(); - EmpresasData empresa = (EmpresasData)JDO.load( EmpresasData.class, idEmpresa ); - buff.append( " DESIGNA\u00C7\u00C3O SOCIAL: " ); - String designacao = (String)empresa.get( EmpresasData.DESIGNACAO_SOCIAL ); - buff.append( "" + ( designacao == null ? "" : designacao.trim() ) + "
" ); - buff.append( " MORADA: " ); - String morada = (String)empresa.get( EmpresasData.MORADA ); - buff.append( "" + ( morada == null ? "" : morada.trim() ) + "
" ); - buff.append( " LOCALIDADE: " ); - String localidade = ( String ) empresa.get( EmpresasData.LOCALIDADE ); - buff.append( "" + ( localidade == null ? "" : localidade.trim() ) + "
" ); - buff.append( " C\u00D3DIGO POSTAL: " ); - String codigoPostal = ( String ) empresa.get( EmpresasData.CODIGO_POSTAL ); - buff.append( "" + ( codigoPostal == null ? "" : codigoPostal.trim() ) + "
" ); -// ContactosData contacto = (ContactosData)empresa.get( EmpresasData.CONTACTO_2 ); - ContactosData contacto = empresa.toContacto_2(); - if( contacto == null ) - { - buff.append( " TELEFONE:
" ); - buff.append( " FAX:
" ); - } - else - { - buff.append( " TELEFONE: " ); - String telefone = ( String ) contacto.get( ContactosData.TELEFONE ); - buff.append( "" + ( telefone == null ? "" : telefone.trim() ) + "
" ); - buff.append( " FAX: " ); - String fax = ( String ) contacto.get( ContactosData.TELEFONE ); - buff.append( "" + ( fax == null ? "" : fax.trim() ) + "
" ); - } - buff.append( " DISTRITO: " ); - String distrito = ( String ) empresa.get( EmpresasData.DISTRITO ); - buff.append( "" + ( distrito == null ? "" : distrito ) + "
" ); - buff.append( " CONCELHO: " ); - String concelho = ( String ) empresa.get( EmpresasData.CONCELHO ); - buff.append( "" + ( concelho == null ? "" : concelho ) + "
" ); - buff.append( " N\u00DAMERO PESSOA COLECTIVA: " ); - String contribuinte = ( String ) empresa.get( EmpresasData.CONTRIBUINTE ); - buff.append( "" + ( contribuinte == null ? "" : contribuinte ) + "
" ); - buff.append( " N\u00DAMERO SEGURAN\u00C7A SOCIAL: " ); - String segSocial = ( String ) empresa.get( EmpresasData.SEGURANCA_SOCIAL ); - buff.append( "" + ( segSocial == null ? "" : segSocial ) + "
" ); - buff.append( " CAE: " ); - String CAE = ( String ) empresa.get( EmpresasData.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++ ) - { - EstabelecimentosData estabelecimento = (EstabelecimentosData)JDO.load( EstabelecimentosData.class, estabelecimentos[ n ].getID() ); - buff.append( "  NOME: " ); - String nome = (String)estabelecimento.get( EstabelecimentosData.NOME ); - buff.append( "" + ( nome == null ? "" : nome.trim() ) + "
" ); - buff.append( "  MORADA: " ); - morada = (String)estabelecimento.get( EstabelecimentosData.MORADA ); - buff.append( "" + ( morada == null ? "" : morada.trim() ) + "
" ); - buff.append( "  LOCALIDADE: " ); - localidade = (String)estabelecimento.get( EstabelecimentosData.LOCALIDADE ); - buff.append( "" + ( localidade == null ? "" : localidade.trim() ) + "
" ); - buff.append( "  C\u00D3DIGO POSTAL: " ); - codigoPostal = (String)estabelecimento.get( EstabelecimentosData.CODIGO_POSTAL ); - buff.append( "" + ( codigoPostal == null ? "" : codigoPostal.trim() ) + "
" ); - contacto = estabelecimento.toContacto_id(); - if( contacto == null ) - { - buff.append( "  TELEFONE:
" ); - buff.append( "  FAX:
" ); - } - else - { - buff.append( "  TELEFONE: " ); - String telefone = ( String ) contacto.get( ContactosData.TELEFONE ); - buff.append( "" + ( telefone == null ? "" : telefone.trim() ) + "
" ); - buff.append( "  FAX: " ); - String fax = ( String ) contacto.get( ContactosData.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 ); - HashMap countExamesCompNovo = provider.countExamesComplementaresEstabelecimentoNovosProtocolos( estabelecimentos[ n ].getID(), ano ); - if( countExamesCompNovo != null ) - { - String nomesExames[] = countExamesCompNovo.keySet().toArray( new String[ countExamesCompNovo.size() ] ); - Arrays.sort( nomesExames ); - for( String nomeExame : nomesExames ) - { - buff.append( "" ); - buff.append( "" ); - buff.append( "" ); - buff.append( "" ); - } - } - else - { - 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
   " + nomeExame + " " + countExamesCompNovo.get( nomeExame ) + "
   " + nomesExamesComp[nec] + " " + countExamesComp[nec] + "
" ); - buff.append("


"); - } - - resultadoText.setText( buff.toString() ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar dados", false ); - 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/teste.xml b/trunk/SIPRPSoft/src/siprp/teste.xml deleted file mode 100644 index de26bcab..00000000 --- a/trunk/SIPRPSoft/src/siprp/teste.xml +++ /dev/null @@ -1,384 +0,0 @@ - - - - 1 - - - - 2008 - - - 01 - - - 01 - - - - - Companhia Portuguesa de Hipermercados, S.A., com sede na Travessa Teixeira - Júnior, 1 - 1300-553 Lisboa - - - Comércio a Retalho em Supermercados e Hipermercados - - - Jumbo Alfragide - - - - - Mapfre Seguros Gerais, S.A. - - - 1500591100500 - - - - - SIPRP - Sociedade Ibérica de Prevenção de Riscos Profissionais Lda., - com sede no Edifício Atrium Saldanha, Praça Duque de Saldanha, 1 - 9º G - - 1050-094 Lisboa - - - - Tecnico HST teste - - - C1A2P3 - - - - - Medico Trabalho teste - - - C123 - - - - - - Trablhador acidentado - - - - Jumbo de Alfragide - - - - - 1980 - - - 11 - - - 08 - - - - - 1112225585 - - - - Rua de Cima, 3º dto - - - 215465981 - - - - 2004 - - - 10 - - - 01 - - - - Varredor - - - Tarde - - - - António Pedro - - - apedro@hotmail.com - - - - - - - João António - - - - - 2007 - - - 12 - - - 23 - - - - - 12 - - - 35 - - - - 4 - - - - Congelados - - - Corredor Esquerdo - - - - - A varrer - - - Vassoura - - - Chão molhado - - - - Pedro Silva, Marco Pedro - - - Sono - - - Escorregou e caiu - - - - - - - - - Conclusao sem indicios nenhuns q a suportem - - - gritar. correr as voltas em panico - - - - y - - - - - - - 3 - - - - 3487 - - - 23424 - - - - - - 0 - - - - - - - - - - - - - Cabeça - - - - - Tronco - - - - - Membro Superior Direito - - - Mão - - - - - Grave - - - - - Permanente - - - 10 - - - - 2005 - - - 01 - - - 01 - - - - - 2007 - - - 01 - - - 01 - - - - - - - - - - - - - - - - - - - - - - - - - beber mta agua - - - fazer aerobica - - - - - despedir o trabalhador - - - lamber sabao - - - - - - Joao - - - - 2007 - - - 01 - - - 01 - - - - - - Pedro - - - - 2007 - - - 01 - - - 02 - - - - - - Simao - - - - 2007 - - - 01 - - - 03 - - - - - - Rafael - - - - 2007 - - - 01 - - - 04 - - - - - - - - - - - - - - - - - diff --git a/trunk/SIPRPSoft/src/siprp/ui/SIPRPFrame.java b/trunk/SIPRPSoft/src/siprp/ui/SIPRPFrame.java deleted file mode 100644 index 6f96d6b9..00000000 --- a/trunk/SIPRPSoft/src/siprp/ui/SIPRPFrame.java +++ /dev/null @@ -1,20 +0,0 @@ -package siprp.ui; - -import com.evolute.swing.frame.EvoFrame; - -public class SIPRPFrame extends EvoFrame -{ - private static final long serialVersionUID = 1L; - - public SIPRPFrame() - { - this( "" ); - } - - public SIPRPFrame( String title ) - { - super( title ); - centerLater(); - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/ui/SIPRPTabbedWindow.java b/trunk/SIPRPSoft/src/siprp/ui/SIPRPTabbedWindow.java deleted file mode 100644 index 5ae72572..00000000 --- a/trunk/SIPRPSoft/src/siprp/ui/SIPRPTabbedWindow.java +++ /dev/null @@ -1,32 +0,0 @@ -package siprp.ui; - -import javax.swing.JPanel; - -import com.evolute.utils.ui.window.TabbedWindow; - -public class SIPRPTabbedWindow extends TabbedWindow -{ - private static final long serialVersionUID = 1L; - - public SIPRPTabbedWindow( JPanel upperPanel, String[] tabNames, boolean[][] activeActions ) - throws Exception - { - super( upperPanel, tabNames, activeActions ); - centerLater(); - } - - public SIPRPTabbedWindow( boolean upperPanel, String[] tabNames, double weight, boolean[][] activeActions ) - throws Exception - { - super( upperPanel, tabNames, weight, activeActions ); - centerLater(); - } - - public SIPRPTabbedWindow( JPanel upperPanel, String[] tabNames, double weight, boolean[][] activeActions ) - throws Exception - { - super( upperPanel, tabNames, weight, activeActions ); - centerLater(); - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/web/WebUpdater.java b/trunk/SIPRPSoft/src/siprp/web/WebUpdater.java deleted file mode 100644 index 6ccb96e6..00000000 --- a/trunk/SIPRPSoft/src/siprp/web/WebUpdater.java +++ /dev/null @@ -1,1233 +0,0 @@ -/* - * WebUpdater.java - * - * Created on 27 de Outubro de 2004, 15:54 - */ - -package siprp.web; - -import java.awt.Color; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionListener; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.Statement; -import java.util.Calendar; -import java.util.Properties; -import java.util.Vector; - -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.event.DocumentListener; - -import siprp.ui.SIPRPFrame; - -//import siprp.*; -//import siprp.clientes.*; - -/** - * - * @author fpalma - */ -public class WebUpdater extends SIPRPFrame - 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.setVisible( true ); - } - - 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/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/SIPRPSoft/src/xml-apis-1.3.04.jar b/trunk/SIPRPSoft/src/xml-apis-1.3.04.jar deleted file mode 100644 index d42c0ea6..00000000 Binary files a/trunk/SIPRPSoft/src/xml-apis-1.3.04.jar and /dev/null differ diff --git a/trunk/SIPRPSoft/src/xml-apis-ext-1.3.04.jar b/trunk/SIPRPSoft/src/xml-apis-ext-1.3.04.jar deleted file mode 100644 index a7869d68..00000000 Binary files a/trunk/SIPRPSoft/src/xml-apis-ext-1.3.04.jar and /dev/null differ