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

lxbfYeaa
Tiago Simão 15 years ago
parent e05792039a
commit 5c646960bb

File diff suppressed because it is too large Load Diff

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<domains project-version="3.0.0.1">
<domain name="SIPRP">
<property name="cayenne.DataDomain.sharedCache" value="false"/>
<map name="SIPRPMap" location="SIPRPMap.map.xml"/>
</domain>
</domains>

@ -1,3 +0,0 @@
log4j.rootCategory=ERROR, dest1
log4j.appender.dest1=org.apache.log4j.ConsoleAppender
log4j.appender.dest1.layout=org.apache.log4j.PatternLayout

@ -1,27 +0,0 @@
package siprp.ui;
import com.evolute.utils.ui.window.EditorWindow;
public class SIPRPEditorWindow extends EditorWindow
{
private static final long serialVersionUID = 1L;
public SIPRPEditorWindow() throws Exception
{
super();
centerLater();
}
public SIPRPEditorWindow( boolean[][] permittedActions ) throws Exception
{
super( permittedActions );
centerLater();
}
public SIPRPEditorWindow( int[][] permittedActions ) throws Exception
{
super( permittedActions );
centerLater();
}
}

@ -22,52 +22,6 @@ import com.evolute.module.updater.AbstractUpdate;
*/
public class UpdateList
{
// OBSOLETE!
// private static final AbstractUpdate UPDATE_LIST[] =
// new AbstractUpdate[]{
// new V6_1_To_V7_0(), new V7_0_To_V7_2(),
// new V7_2_To_V7_4(), new V7_4_To_V7_5(),
// new V7_5_To_V7_6(), new V7_6_To_V7_7(),
// new V7_7_To_V7_8(), new V7_8_To_V7_9(),
// new V7_9_To_V8_0(), new V8_0_To_V8_1(),
// new V8_1_To_V8_2(), new V8_2_To_V8_3(),
// new V8_3_To_V8_4(), new V8_4_To_V8_5(),
// new V8_5_To_V8_6(), new V8_6_To_V8_7(),
// new V8_7_To_V8_8(), new V8_8_To_V8_9(),
// new V8_9_To_V9_0(), new V9_0_To_V9_1(),
// new V9_1_To_V9_2(), new V9_2_To_V9_3(),
// new V9_3_To_V9_4(), new V9_4_To_V9_5(),
// new V9_5_To_V9_6(), new V9_6_To_V9_7(),
// new V9_7_To_V9_8(), new V9_8_To_V9_9(),
// new V9_9_To_V10_0(), new V10_0_To_V10_1(),
// new V10_1_To_V10_2(), new V10_2_To_V10_3(),
// new V10_3_To_V10_4(), new V10_4_To_V10_5(),
// new V10_5_To_V10_6(), new V10_6_To_V10_7(),
// new V10_7_To_V10_8(), new V10_8_To_V10_9(),
// new V10_9_To_V11_0(), new V11_0_To_V11_1(),
// new V11_1_To_V11_2(), new V11_2_To_V11_3(),
// new V11_3_To_V11_4(), new V11_4_To_V11_5(),
// new V11_5_To_V11_6(), new V11_6_To_V11_7(),
// new V11_7_To_V11_8(), new V11_8_To_V11_9(),
// new V11_9_To_V12_0(), new V12_0_To_V12_1(),
// new V12_1_To_V12_2(), new V12_2_To_V12_3(),
// new V12_3_To_V12_4(), new V12_4_To_V12_5(),
// new V12_5_To_V12_6(), new V12_6_To_V12_7(),
// new V12_7_To_V12_8(), new V12_8_To_V12_9(),
// new V12_9_To_V13_0(), new V13_0_To_V13_1(),
// new V13_1_To_V13_2(), new V13_2_To_V13_3(),
// new V13_3_To_V13_4(),
// new EvoCursosInstallUpdate( 13.4, 13.5 ),
// new EvoCursosUpdate1( 13.5, 13.6 ),
// new EvoCursosUpdate2( 13.6, 13.7 ),
// new V13_7_To_V13_8(),
// new SHSTUpdate8( 13.8, 13.9 ),
// new SHSTUpdate9( 13.9, 14.1 ),
// new V14_1_To_V14_2(),
// new V14_2_To_V14_3(),
// new SHSTUpdate11( 14.3, 14.4 ), new SHSTUpdate12( 14.4, 14.5 ),
// // OBSOLETE! do not add updates -> use SHST instead
// };
public static List<AbstractUpdate> getUpdates()
{

@ -1,36 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
public class V10_0_To_V10_1 extends AbstractUpdate
{
public V10_0_To_V10_1()
{
super(10.0,10.1,"Adicionadas normalizacoes para estabelecimentos e empresas");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"CREATE TABLE hs_normalizacao_empresa " +
"( " +
" normalizacao_id int4 REFERENCES hs_normalizacao(id), " +
" empresa_id int4 REFERENCES empresas(id), " +
" CONSTRAINT hs_normalizacao_empresa_pkey PRIMARY KEY(normalizacao_id,empresa_id) " +
"); " +
"CREATE TABLE hs_normalizacao_estabelecimento " +
"( " +
" normalizacao_id int4 REFERENCES hs_normalizacao(id), " +
" estabelecimento_id int4 REFERENCES estabelecimentos(id), " +
" CONSTRAINT hs_normalizacao_estabelecimento_pkey PRIMARY KEY(normalizacao_id,estabelecimento_id) " +
");"
);
executer.executeQuery( update );
}
}

@ -1,43 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
public class V10_1_To_V10_2 extends AbstractUpdate
{
public V10_1_To_V10_2()
{
super(10.1,10.2,"Adicionadas normalizacoes para estabelecimentos e empresas");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"CREATE TABLE hs_equipamento( " +
"id SERIAL PRIMARY KEY, " +
"tipo VARCHAR(512) NOT NULL, " +
"marca VARCHAR(255), " +
"modelo VARCHAR(255), " +
"deleted_date TIMESTAMP " +
"); " +
"CREATE TABLE hs_relatorio_equipamento( " +
"hs_relatorio_id INT4 REFERENCES hs_relatorio(id), " +
"hs_equipamento INT4 REFERENCES hs_equipamento(id), " +
"CONSTRAINT hs_relatorio_equipamento_pkey PRIMARY KEY (hs_relatorio_id,hs_equipamento) " +
"); " +
"INSERT INTO hs_equipamento(id, tipo) " +
"SELECT id, nome FROM hs_equipamento_medico ; " +
"INSERT INTO hs_relatorio_equipamento(hs_relatorio_id, hs_equipamento) " +
"SELECT hs_relatorio_id, hs_equipamento_medico_id FROM hs_relatorio_equipamento_medico; " +
"DROP TABLE hs_relatorio_equipamento_medico; " +
"DROP TABLE hs_equipamento_medico; " +
"SELECT setval('hs_equipamento_id_seq',1000);"
);
executer.executeQuery( update );
}
}

@ -1,46 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
public class V10_2_To_V10_3 extends AbstractUpdate
{
public V10_2_To_V10_3()
{
super(10.2,10.3,"adicionadas normalizacoes duplicadas para planos de actuacao",
"adicionados campos aos tecnicos de higiene e seguranca");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"alter table hs_relatorio_equipamento drop constraint hs_relatorio_equipamento_hs_equipamento_fkey; " +
"alter table hs_relatorio_equipamento drop constraint hs_relatorio_equipamento_pkey; " +
"alter table hs_relatorio_equipamento add column id serial PRIMARY KEY; " +
"alter table hs_relatorio_equipamento add column tipo varchar(512); " +
"alter table hs_relatorio_equipamento add column marca varchar(256); " +
"alter table hs_relatorio_equipamento add column modelo varchar(256); " +
"select setval('hs_relatorio_equipamento_id_seq',1000);" +
"alter table hs_relatorio_legislacao drop constraint hs_relatorio_legislacao_hs_legislacao_id_fkey; " +
"alter table hs_relatorio_legislacao drop constraint hs_relatorio_legislacao_pkey; " +
"alter table hs_relatorio_legislacao add column id serial PRIMARY KEY; " +
"alter table hs_relatorio_legislacao add column categoria varchar(255); " +
"alter table hs_relatorio_legislacao add column descricao varchar(1024); " +
"alter table hs_relatorio_normalizacao drop constraint hs_relatorio_normalizacao_hs_normalizacao_id_fkey; " +
"alter table hs_relatorio_normalizacao drop constraint hs_relatorio_normalizacao_pkey; " +
"alter table hs_relatorio_normalizacao add column id serial PRIMARY KEY; " +
"alter table hs_relatorio_normalizacao add column codigo varchar(128) NOT NULL; " +
"alter table hs_relatorio_normalizacao add column descricao varchar(1024); " +
"alter table hs_relatorio_normalizacao add column portuguesa boolean NOT NULL; " +
"alter table marcacoes_tecnicos_hst add column cap varchar(128); " +
"alter table marcacoes_tecnicos_hst add column formacao varchar(128); " +
"alter table marcacoes_tecnicos_hst add column assinatura int4 REFERENCES image(id); "
);
executer.executeQuery( update );
}
}

@ -1,25 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
public class V10_3_To_V10_4 extends AbstractUpdate
{
public V10_3_To_V10_4()
{
super(10.3,10.4,"Adicionado campo a empresa (Imprimir tabela alargada)");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"alter table empresas add column imprimir_tabela_alargada boolean;"
);
executer.executeQuery( update );
}
}

@ -1,56 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
public class V10_4_To_V10_5 extends AbstractUpdate
{
public V10_4_To_V10_5()
{
super(10.4,10.5,"Remocao dos dados de teste dos relatorio de higiene e seguranca");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"delete from hs_relatorio_posto_risco; " +
"delete from hs_relatorio_posto_medida; " +
"delete from hs_relatorio_posto; " +
"delete from hs_relatorio_medida; " +
"delete from hs_relatorio_area; " +
"delete from hs_relatorio_risco; " +
"delete from hs_relatorio_risco_valor_qualitativo; " +
"delete from hs_relatorio_normalizacao; " +
"delete from hs_relatorio_legislacao; " +
"delete from hs_relatorio_equipamento; " +
"delete from hs_relatorio; " +
"delete from hs_email_estabelecimento; " +
"delete from hs_email_empresa; " +
"delete from hs_email; " +
"delete from hs_equipamento; " +
"delete from hs_posto_risco; " +
"delete from hs_posto_medida; " +
"delete from hs_posto_estabelecimento; " +
"delete from hs_posto; " +
"delete from hs_area; " +
"delete from hs_legislacao_estabelecimento; " +
"delete from hs_legislacao_empresa; " +
"delete from hs_legislacao; " +
"delete from hs_legislacao_categoria; " +
"delete from hs_risco_empresa; " +
"delete from hs_risco_medida; " +
"delete from hs_medida; " +
"delete from hs_risco; " +
"delete from hs_risco_tema; " +
"delete from hs_normalizacao_estabelecimento; " +
"delete from hs_normalizacao_empresa; " +
"delete from hs_normalizacao; "
);
executer.executeQuery( update );
}
}

@ -1,29 +0,0 @@
package siprp.update.updates;
import shst.higiene.gestao.importacao.Importador;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
public class V10_5_To_V10_6 extends AbstractUpdate
{
public V10_5_To_V10_6()
{
super(10.5,10.6,"Importa\u00e7\u00e3o de riscos e medidas");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update( "alter table hs_medida alter column description type character varying(8192);");
executer.executeQuery( update );
update = new com.evolute.utils.sql.Update( "alter table hs_medida alter column requesitos_legais type character varying(8192);");
executer.executeQuery( update );
new Importador( executer ).importar();
}
}

@ -1,34 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
public class V10_6_To_V10_7 extends AbstractUpdate
{
public V10_6_To_V10_7()
{
super(10.6,10.7,"Alteracao de tamanho maximo em campos de descricao");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"alter table hs_risco alter column description type varchar(8192); " +
"alter table hs_relatorio_risco alter column description type varchar(8192); " +
"alter table hs_normalizacao alter column descricao type varchar(8192); " +
"alter table hs_relatorio_normalizacao alter column descricao type varchar(8192); " +
"alter table hs_legislacao alter column description type varchar(8192); " +
"alter table hs_relatorio_legislacao alter column descricao type varchar(8192); " +
"alter table hs_area alter column description type varchar(1024); " +
"alter table hs_relatorio_area alter column description type varchar(1024); " +
"alter table hs_posto alter column description type varchar(1024); " +
"alter table hs_relatorio_posto alter column description type varchar(1024); "
);
executer.executeQuery( update );
}
}

@ -1,30 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
public class V10_7_To_V10_8 extends AbstractUpdate
{
public V10_7_To_V10_8()
{
super(10.7,10.8,"relatorio de higiene e seguranca: insercao de valores qualitativos");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"insert into hs_relatorio_risco_valor_qualitativo(description) " +
"values('Controlado'); " +
"insert into hs_relatorio_risco_valor_qualitativo(description) " +
"values('Incontrolado'); " +
"insert into hs_relatorio_risco_valor_qualitativo(description)" +
"values('Indeterminado'); "
);
executer.executeQuery( update );
}
}

@ -1,26 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
public class V10_8_To_V10_9 extends AbstractUpdate
{
public V10_8_To_V10_9()
{
super(10.8,10.9,"relatorio de higiene e seguranca: aumentada a capacidade de texto das requesitos(relatorio)");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"alter table hs_relatorio_medida alter column description type varchar(8192); " +
"alter table hs_relatorio_medida alter column requesitos_legais type varchar(8192);"
);
executer.executeQuery( update );
}
}

@ -1,25 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
public class V10_9_To_V11_0 extends AbstractUpdate
{
public V10_9_To_V11_0()
{
super(10.9,11.0,"relatorio de higiene e seguranca: adicionado campo 'funcionarios'");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"alter table hs_relatorio add column funcionarios varchar(8192); "
);
executer.executeQuery( update );
}
}

@ -1,98 +0,0 @@
package siprp.update.updates;
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
import static com.evolute.utils.strings.UnicodeLatin1Map.oacute;
import static com.evolute.utils.strings.UnicodeLatin1Map.uacute;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import javax.imageio.ImageIO;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.arrays.Virtual2DArray;
import com.evolute.utils.db.Executer;
import com.evolute.utils.sql.Assignment;
import com.evolute.utils.sql.BlobUpdate;
import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Insert;
import com.evolute.utils.sql.Select2;
import com.evolute.utils.sql.Update;
public class V11_0_To_V11_1 extends AbstractUpdate
{
public V11_0_To_V11_1()
{
super(11.0,11.1,"A actualizar informacao dos tecnicos de higiene e seguranca");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
Update update = new Update(
"alter table image alter column image_data drop not null; "
);
executer.executeQuery( update );
Integer assSoniaID = null;
Integer assCatarinaID = null;
String assSonia = "Assinatura(Sonia Filipa Dias Campos)";
String assCatarina = "Assinatura(Catarina Leonardo)";
BufferedImage assSoniaImage = ImageIO.read( getClass().getClassLoader().getResourceAsStream( "siprp/update/updates/V11_0_To_V11_1_Assinatura_Sonia.png" ) );
BufferedImage assCatarinaImage = ImageIO.read( getClass().getClassLoader().getResourceAsStream( "siprp/update/updates/V11_0_To_V11_1_Assinatura_Catarina.png" ) );
ByteArrayOutputStream assSoniaBytesStream = new ByteArrayOutputStream();
ByteArrayOutputStream assCatarinaBytesStream = new ByteArrayOutputStream();
ImageIO.write( assSoniaImage, "PNG", assSoniaBytesStream );
ImageIO.write( assCatarinaImage, "PNG", assCatarinaBytesStream );
if( assSoniaImage == null || assSoniaBytesStream.size() == 0 )
{
throw new Exception("Erro ao ler assinatura: " + assSonia );
}
if( assCatarinaImage == null || assCatarinaBytesStream.size() == 0 )
{
throw new Exception("Erro ao ler assinatura: " + assCatarina );
}
Insert insertQuery = new Insert( "image", new Assignment[]{
new Assignment(new Field("name"),assSonia)
} );
Virtual2DArray array = executer.executeQuery( insertQuery );
insertQuery = new Insert( "image", new Assignment[]{
new Assignment(new Field("name"), assCatarina)
} );
executer.executeQuery( insertQuery );
Select2 selectQuery = new Select2(new String[]{"image"},null,null,new String[]{"id"},new Field("name").isEqual( assSonia ),null,null,null,null);
array = executer.executeQuery( selectQuery );
if( array.columnLength() == 1 )
{
assSoniaID = (Integer) array.get( 0, 0 );
}
selectQuery = new Select2(new String[]{"image"},null,null,new String[]{"id"},new Field("name").isEqual( assCatarina ),null,null,null,null);
array = executer.executeQuery( selectQuery );
if( array.columnLength() == 1 )
{
assCatarinaID = (Integer) array.get( 0, 0 );
}
if( assSoniaID == null )
{
throw new Exception("Erro ao inserir assinatura: " + assSonia );
}
if( assCatarinaID == null )
{
throw new Exception("Erro ao inserir assinatura: " + assCatarina );
}
BlobUpdate blobUpdate = new BlobUpdate("image","image_data",assSoniaBytesStream.toByteArray(),new Field("id").isEqual( assSoniaID ) );
executer.executeQuery( blobUpdate );
blobUpdate = new BlobUpdate("image","image_data",assCatarinaBytesStream.toByteArray(),new Field("id").isEqual( assCatarinaID ) );
executer.executeQuery( blobUpdate );
update = new Update(
"update marcacoes_tecnicos_hst set cap='0601/6505/02', formacao='Ergonomia', assinatura=" + assSoniaID + " where id = 2; " +
"update marcacoes_tecnicos_hst set cap='0310/1156/02', formacao='Sa"+uacute+"de Ambiental, P"+oacute+"s Gradua"+ccedil+atilde+"o em Higiene e Seguran"+ccedil+"a do Trabalho e Mestrado em Ergonomia na Seguran"+ccedil+"a do Trabalho', assinatura=" + assCatarinaID + " where id = 1; "
);
executer.executeQuery( update );
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

@ -1,25 +0,0 @@
package siprp.update.updates;
import shst.higiene.gestao.importacao.Importador;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
public class V11_1_To_V11_2 extends AbstractUpdate
{
public V11_1_To_V11_2()
{
super(11.1,11.2,"Higiene e seguranca: a repor datas de submissao dos relatorios");
}
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update( "update hs_relatorio set is_submetido = null;" );
executer.executeQuery( update );
new Importador( executer ).importar();
}
}

@ -1,33 +0,0 @@
package siprp.update.updates;
import shst.higiene.gestao.importacao.Importador;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
public class V11_2_To_V11_3 extends AbstractUpdate
{
public V11_2_To_V11_3()
{
super(11.2,11.3,"Higiene e seguranca: restruturacao");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"alter table hs_posto add column is_principal boolean; " +
"alter table hs_relatorio_posto add column is_principal boolean; " +
"alter table hs_relatorio_area add column ordem int4; " +
"alter table hs_area add column ordem int4; " +
"alter table hs_relatorio_posto_risco add column ordem int4; " +
"alter table hs_posto_risco add column ordem int4; "
);
executer.executeQuery( update );
new Importador( executer ).importar();
}
}

@ -1,29 +0,0 @@
package siprp.update.updates;
import shst.higiene.gestao.importacao.Importador;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
public class V11_3_To_V11_4 extends AbstractUpdate
{
public V11_3_To_V11_4()
{
super(11.3,11.4,"Higiene e seguranca: restruturacao");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"alter table hs_legislacao_estabelecimento add column ordem int4; " +
"alter table hs_relatorio_legislacao add column ordem int4; "
);
executer.executeQuery( update );
new Importador( executer ).importar();
}
}

@ -1,27 +0,0 @@
package siprp.update.updates;
import shst.higiene.gestao.importacao.Importador;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
public class V11_4_To_V11_5 extends AbstractUpdate
{
public V11_4_To_V11_5()
{
super(11.4,11.5,"Correc\u00e7\u00e3o de submiss\u00f5es");
}
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"update hs_relatorio set is_submetido = '2009-09-17 15:21:35.208' where marcacao_id in (2006, 1911,2174);"
);
executer.executeQuery( update );
new Importador( executer ).importar();
}
}

@ -1,32 +0,0 @@
package siprp.update.updates;
import shst.higiene.gestao.importacao.Importador;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
public class V11_5_To_V11_6 extends AbstractUpdate
{
public V11_5_To_V11_6()
{
super(11.5,11.6,"Adicionadas soft-references aos itens dos relatorios de H&S");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"alter table hs_relatorio_risco add column hs_risco_id int4; " +
"alter table hs_relatorio_posto add column hs_posto_id int4; " +
"alter table hs_relatorio_medida add column hs_medida_id int4; " +
"alter table hs_relatorio_equipamento add column hs_equipamento_id int4; " +
"alter table hs_relatorio_area add column hs_area_id int4; "
);
executer.executeQuery( update );
new Importador( executer ).importar();
}
}

@ -1,32 +0,0 @@
package siprp.update.updates;
import shst.higiene.gestao.importacao.Importador;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
public class V11_6_To_V11_7 extends AbstractUpdate
{
public V11_6_To_V11_7()
{
super(11.6,11.7,"Adicionado suporte para tecnicos superiores de higiene e seguranca");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"alter table marcacoes_tecnicos_hst add column is_superior char(1); " +
"update marcacoes_tecnicos_hst set is_superior = 'n'; " +
"alter table marcacoes_tecnicos_hst alter column is_superior set not null; " +
"alter table marcacoes_tecnicos_hst add constraint check_is_superior check( is_superior = 'y' or is_superior = 'n' ); " +
"alter table marcacoes_tecnicos_hst alter column is_superior set default 'y'; "
);
executer.executeQuery( update );
new Importador( executer ).importar();
}
}

@ -1,29 +0,0 @@
package siprp.update.updates;
import shst.higiene.gestao.importacao.Importador;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
public class V11_7_To_V11_8 extends AbstractUpdate
{
public V11_7_To_V11_8()
{
super(11.7,11.8,"Adicionado suporte adicional para tecnicos superiores de higiene e seguranca");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"alter table marcacoes_estabelecimento add column tecnico_superior_hst int4 " +
"references marcacoes_tecnicos_hst(id); "
);
executer.executeQuery( update );
new Importador( executer ).importar();
}
}

@ -1,61 +0,0 @@
package siprp.update.updates;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import javax.imageio.ImageIO;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.arrays.Virtual2DArray;
import com.evolute.utils.db.Executer;
import com.evolute.utils.sql.Assignment;
import com.evolute.utils.sql.BlobUpdate;
import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Insert;
import com.evolute.utils.sql.Select2;
public class V11_8_To_V11_9 extends AbstractUpdate
{
public V11_8_To_V11_9()
{
super(11.8,11.9,"A actualizar informacao dos tecnicos de higiene e seguranca");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
Integer assDavidID = null;
String assDavid = "Assinatura(David Afonso)";
BufferedImage assDavidImage = ImageIO.read( getClass().getClassLoader().getResourceAsStream( "siprp/update/updates/V11_8_To_V11_9_David_Afonso.png" ) );
ByteArrayOutputStream assDavidBytesStream = new ByteArrayOutputStream();
ImageIO.write( assDavidImage, "PNG", assDavidBytesStream );
if( assDavidImage == null || assDavidBytesStream.size() == 0 )
{
throw new Exception("Erro ao ler assinatura: " + assDavid );
}
Insert insertQuery = new Insert( "image", new Assignment[]{
new Assignment(new Field("name"),assDavid)
} );
Virtual2DArray array = executer.executeQuery( insertQuery );
Select2 selectQuery = new Select2(new String[]{"image"},null,null,new String[]{"id"},new Field("name").isEqual( assDavid ),null,null,null,null);
array = executer.executeQuery( selectQuery );
if( array.columnLength() == 1 )
{
assDavidID = (Integer) array.get( 0, 0 );
}
if( assDavidID == null )
{
throw new Exception("Erro ao inserir assinatura: " + assDavid );
}
BlobUpdate blobUpdate = new BlobUpdate("image","image_data",assDavidBytesStream.toByteArray(),new Field("id").isEqual( assDavidID ) );
executer.executeQuery( blobUpdate );
com.evolute.utils.sql.Update update = new com.evolute.utils.sql.Update(
"update marcacoes_tecnicos_hst set cap='em emiss\u00e3o', formacao='', assinatura=" + assDavidID + " where id = 3; "
);
executer.executeQuery( update );
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

@ -1,93 +0,0 @@
package siprp.update.updates;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.util.Vector;
import javax.imageio.ImageIO;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.arrays.Virtual2DArray;
import com.evolute.utils.db.Executer;
import com.evolute.utils.sql.Assignment;
import com.evolute.utils.sql.BlobUpdate;
import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Insert;
import com.evolute.utils.sql.Select2;
import com.evolute.utils.sql.Update;
public class V11_9_To_V12_0 extends AbstractUpdate
{
public V11_9_To_V12_0()
{
super(11.9,12.0,"A actualizar informacao dos tecnicos de higiene e seguranca");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
String nomes[] = new String[]{
"David Afonso",
"B\u00e1rbara Gon\u00e7alves",
"Ana Sofia Jorge"
};
Integer ids[] = new Integer[]{
3,
4,
5
};
String caps[] = new String[]{
"28291002EC3",
"em emiss\u00e3o - A 100 60 1820 D",
"17050910EC5" };
String assinaturas[] = new String[]{
null,
"siprp/update/updates/V11_9_To_V11_10_Barbara_Goncalves.png",
"siprp/update/updates/V11_9_To_V11_10_Ana_Sofia_Jorge.png" };
for( int n = 0; n < ids.length; n++ )
{
Vector<Assignment> assignments = new Vector<Assignment>();
assignments.add( new Assignment( "cap", caps[ n ] ) );
if( assinaturas[ n ] != null )
{
Integer assinaturaID = null;
String assinatura = "Assinatura(" + nomes[ n ] + ")";
BufferedImage assinaturaImage = ImageIO.read( getClass().getClassLoader().getResourceAsStream(
assinaturas[ n ] ) );
ByteArrayOutputStream assinaturaBytesStream = new ByteArrayOutputStream();
ImageIO.write( assinaturaImage, "PNG", assinaturaBytesStream );
if( assinaturaImage == null || assinaturaBytesStream.size() == 0 )
{
throw new Exception("Erro ao ler assinatura: " + assinatura );
}
Insert insertQuery = new Insert( "image", new Assignment[]{
new Assignment(new Field("name"),assinatura)
} );
Virtual2DArray array = executer.executeQuery( insertQuery );
Select2 selectQuery = new Select2(new String[]{"image"},null,null,new String[]{"id"},new Field("name").isEqual( assinatura ),null,null,null,null);
array = executer.executeQuery( selectQuery );
if( array.columnLength() == 1 )
{
assinaturaID = (Integer) array.get( 0, 0 );
}
if( assinaturaID == null )
{
throw new Exception("Erro ao inserir assinatura: " + assinatura );
}
BlobUpdate blobUpdate = new BlobUpdate("image","image_data",assinaturaBytesStream.toByteArray(),new Field("id").isEqual( assinaturaID ) );
executer.executeQuery( blobUpdate );
assignments.add( new Assignment( "assinatura", assinaturaID ) );
}
Update update =
new Update( "marcacoes_tecnicos_hst",
assignments.toArray( new Assignment[ assignments.size() ] ),
new Field( "id" ).isEqual( ids[ n ] ) );
executer.executeQuery( update );
}
}
}

@ -1,54 +0,0 @@
package siprp.update.updates;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.util.Vector;
import javax.imageio.ImageIO;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
import com.evolute.utils.sql.Assignment;
import com.evolute.utils.sql.BlobUpdate;
import com.evolute.utils.sql.Field;
public class V12_0_To_V12_1 extends AbstractUpdate
{
public V12_0_To_V12_1()
{
super(12.0,12.1,"A actualizar assinatura de B\u00e1rbara Gon\u00e7alves");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
Integer ids[] = new Integer[]{
129,
};
String assinaturas[] = new String[]{
"siprp/update/updates/V12_0_To_V12_1_Barbara_Goncalves.png"
};
for( int n = 0; n < ids.length; n++ )
{
Vector<Assignment> assignments = new Vector<Assignment>();
if( assinaturas[ n ] != null )
{
Integer assinaturaID = null;
BufferedImage assinaturaImage = ImageIO.read( getClass().getClassLoader().getResourceAsStream(
assinaturas[ n ] ) );
ByteArrayOutputStream assinaturaBytesStream = new ByteArrayOutputStream();
ImageIO.write( assinaturaImage, "PNG", assinaturaBytesStream );
BlobUpdate blobUpdate = new BlobUpdate("image","image_data",assinaturaBytesStream.toByteArray(),new Field("id").isEqual( ids[ n ] ) );
executer.executeQuery( blobUpdate );
assignments.add( new Assignment( "assinatura", assinaturaID ) );
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

@ -1,25 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.sql.Update;
public class V12_1_To_V12_2 extends AbstractUpdate
{
public V12_1_To_V12_2()
{
super(12.1,12.2,
"A corrigir a tabela de marcacoes de trabalhadores",
"A corrigir a tabela de avisos",
"A corrigir a tabela de exames");
}
@Override
public void doUpdate() throws Exception
{
executeQuery( new Update( "ALTER TABLE marcacoes_trabalhador ADD CONSTRAINT marcacoes_trabalhador_trabalhador_id_fkey FOREIGN KEY (trabalhador_id) REFERENCES trabalhadores (id); " ) );
executeQuery( new Update( "ALTER TABLE avisos ADD CONSTRAINT avisos_trabalhador_id_fkey FOREIGN KEY (trabalhador_id) REFERENCES trabalhadores (id); " ) );
executeQuery( new Update( "ALTER TABLE exames ADD CONSTRAINT exames_trabalhador_id_fkey FOREIGN KEY (trabalhador_id) REFERENCES trabalhadores(id); " ) );
}
}

@ -1,45 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.PSQLSequenceUtils;
import com.evolute.utils.sql.Update;
public class V12_2_To_V12_3 extends AbstractUpdate
{
public V12_2_To_V12_3()
{
super( 12.2, 12.3, "A corrigir chaves primarias" );
}
@Override
public void doUpdate() throws Exception
{
fixIdColumn( "avisos", "id" );
fixIdColumn( "contactos", "id" );
fixIdColumn( "empresas", "id" );
fixIdColumn( "estabelecimentos", "id" );
fixIdColumn( "exames", "id" );
fixIdColumn( "exames_perfis", "id" );
fixIdColumn( "historico_estabelecimento", "id" );
fixIdColumn( "marcacoes_empresa", "id" );
fixIdColumn( "marcacoes_estabelecimento", "id" );
fixIdColumn( "marcacoes_tecnicos_hst", "id" );
fixIdColumn( "marcacoes_trabalhador", "id" );
fixIdColumn( "medicos", "id" );
fixIdColumn( "prt_grupos_protocolo", "id" );
fixIdColumn( "prt_tipos_elementos_protocolo", "id" );
fixIdColumn( "tipos_exames_comp", "id" );
fixIdColumn( "trabalhadores", "id" );
}
private void fixIdColumn( String columnName, String idField ) throws Exception
{
executeQuery( new Update(
"create sequence " + columnName + "_" + idField + "_seq; " +
"alter table " + columnName + " alter column " + idField + " set default nextval(('" + columnName + "_" + idField + "_seq'::text)::regclass); "
) );
PSQLSequenceUtils.fixSequence( columnName, idField );
}
}

@ -1,36 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.sql.Update;
public class V12_3_To_V12_4 extends AbstractUpdate
{
public V12_3_To_V12_4( )
{
super( 12.3, 12.4, "Adicionar campos em algumas tabelas." );
}
@Override
public void doUpdate() throws Exception
{
Update update = new Update(
"ALTER TABLE trabalhadores ADD COLUMN nif CHARACTER VARYING( 255 );" +
"ALTER TABLE trabalhadores ADD COLUMN numero_utente CHARACTER VARYING( 255 );"
);
executeQuery( update );
update = new Update(
"ALTER TABLE marcacoes_trabalhador ADD COLUMN medico_id INTEGER;" +
"ALTER TABLE marcacoes_trabalhador ADD COLUMN inserted_stamp TIMESTAMP WITHOUT TIME ZONE DEFAULT now();"
);
executeQuery( update );
update = new Update(
"ALTER TABLE empresas ADD COLUMN codigo_relatorio_unico CHARACTER VARYING( 64 );"
);
executeQuery( update );
}
}

@ -1,52 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.PSQLSequenceUtils;
import com.evolute.utils.sql.Update;
public class V12_4_To_V12_5 extends AbstractUpdate
{
public V12_4_To_V12_5()
{
super( 12.4, 12.5, "A adicionar novos pagamentos por empresa" );
}
@Override
public void doUpdate() throws Exception
{
Update update = new Update(
"begin; " +
"create table empresa_preco_periodicidade_tipo( " +
" id serial primary key, " +
" nome varchar(64) not null " +
"); " +
"insert into empresa_preco_periodicidade_tipo(id,nome) values(1,'Anual'); " +
"insert into empresa_preco_periodicidade_tipo(id,nome) values(2,'Semestral'); " +
"insert into empresa_preco_periodicidade_tipo(id,nome) values(3,'Trimestral'); " +
"insert into empresa_preco_periodicidade_tipo(id,nome) values(4,'Mensal'); " +
"insert into empresa_preco_periodicidade_tipo(id,nome) values(5,'Pontual'); " +
"create table empresa_preco_servico_tipo( " +
" id serial primary key, " +
" nome varchar(64) not null " +
"); " +
"insert into empresa_preco_servico_tipo(id,nome) values(1,'Medicina'); " +
"insert into empresa_preco_servico_tipo(id,nome) values(2,'Higiene e Seguran\\\\u00e7a'); " +
"insert into empresa_preco_servico_tipo(id,nome) values(3,'Outro'); " +
"create table empresa_preco_servico( " +
" id serial primary key, " +
" empresa_preco_servico_tipo_id int4 not null references empresa_preco_servico_tipo(id), " +
" empresa_preco_periodicidade_tipo_id int4 references empresa_preco_periodicidade_tipo(id), " +
" tipo_outro varchar(64), " +
" empresa_id int4 not null references empresas(id), " +
" valor double precision, " +
" iniciado timestamp, " +
" activo boolean not null " +
"); " +
"commit; " );
getExecuter().executeQuery( update );
PSQLSequenceUtils.fixSequence("empresa_preco_periodicidade_tipo", "id");
PSQLSequenceUtils.fixSequence("empresa_preco_servico_tipo", "id");
}
}

@ -1,23 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.sql.Update;
public class V12_5_To_V12_6 extends AbstractUpdate
{
public V12_5_To_V12_6()
{
super( 12.5, 12.6, "Adicionar campos em algumas tabelas." );
}
@Override
public void doUpdate() throws Exception
{
Update update = new Update(
"ALTER TABLE exames ADD COLUMN impresso_stamp timestamp without time zone;"
);
executeQuery( update );
}
}

@ -1,22 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.sql.CreateFunctionPlainUpdate;
public class V12_6_To_V12_7 extends AbstractUpdate
{
public V12_6_To_V12_7()
{
super( 12.6, 12.7, "Adicionar funcao plain()." );
}
@Override
public void doUpdate() throws Exception
{
CreateFunctionPlainUpdate update = new CreateFunctionPlainUpdate( 12.6, 12.7 );
update.doUpdate();
}
}

@ -1,23 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.sql.Update;
public class V12_7_To_V12_8 extends AbstractUpdate
{
public V12_7_To_V12_8()
{
super( 12.7, 12.8, "Adicionar campo departamento em contactos." );
}
@Override
public void doUpdate() throws Exception
{
Update update = new Update(
"ALTER TABLE contactos ADD COLUMN departamento character varying( 256 );"
);
executeQuery( update );
}
}

@ -1,69 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.DBException;
import com.evolute.utils.sql.EvoQuery;
import com.evolute.utils.sql.Insert;
import com.evolute.utils.sql.Select;
import com.evolute.utils.tables.ColumnizedIDObject;
public class V12_8_To_V12_9 extends AbstractUpdate
{
public V12_8_To_V12_9()
{
super( 12.8, 12.9, "A converter valores de pagamentos antigos" );
}
@Override
public void doUpdate() throws Exception
{
EvoQuery select = new EvoQuery( getExecuter(), new Select(
"SELECT id, preco_medicina, " +
"CASE " +
"WHEN preco_medicina IS NULL THEN false " +
"ELSE true " +
"END AS preco_medicina_activo, " +
"preco_higiene, " +
"CASE " +
"WHEN preco_higiene IS NULL THEN false " +
"ELSE true " +
"END AS preco_higiene_activo " +
"FROM empresas"
));
for( ColumnizedIDObject row : select )
{
Integer empresaId = row.getID();
// Number precoFormacao = row.getValue( 0 );
// Boolean activeFormacao = row.getValue( 1 );
Number precoMedicina = row.getValue( 0 );
// Boolean activeMedicina = row.getValue( 1 );
Boolean activeMedicina = true;
Number precoHigiene = row.getValue( 2 );
// Boolean activeHigiene = row.ge
Boolean activeHigiene = true;
insertPreco( empresaId, /*precoFormacao, activeFormacao == null ? false : activeFormacao, */precoMedicina, activeMedicina == null ? false : activeMedicina, precoHigiene, activeHigiene == null ? false : activeHigiene);
}
}
private void insertPreco(Integer empresaId, /*Number precoFormacao, boolean activeFormacao,*/ Number precoMedicina, boolean activeMedicina, Number precoHigiene, boolean activeHigiene) throws DBException
{
Insert insert = new Insert("insert into empresa_preco_servico(" +
"empresa_preco_servico_tipo_id,empresa_id,valor,activo) " +
"values("+1+","+empresaId+", round( cast( "+precoMedicina+" AS numeric ), 3 ),"+activeMedicina+"); ");
getExecuter().executeQuery(insert);
insert = new Insert("insert into empresa_preco_servico(" +
"empresa_preco_servico_tipo_id,empresa_id,valor,activo) " +
"values("+2+","+empresaId+", round( cast( "+precoHigiene+" AS numeric ), 3 ),"+activeHigiene+"); ");
getExecuter().executeQuery(insert);
// insert = new Insert("insert into empresa_preco_servico(" +
// "empresa_preco_servico_tipo_id,empresa_id,valor,activo) " +
// "values("+3+","+empresaId+","+precoFormacao+","+activeFormacao+"); ");
// getExecuter().executeQuery(insert);
}
}

@ -1,28 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.sql.Update;
public class V12_9_To_V13_0 extends AbstractUpdate
{
public V12_9_To_V13_0()
{
super( 12.9, 13.0, "A remover valores de pagamentos antigos" );
}
@Override
public void doUpdate() throws Exception
{
Update update = new Update(
//"alter table empresas drop column preco_formacao; " +
//"alter table empresas drop column preco_formacao_activo; " +
"alter table empresas drop column preco_higiene; " +
//"alter table empresas drop column preco_higiene_activo; " +
"alter table empresas drop column preco_medicina; "
//"alter table empresas drop column preco_medicina_activo; "
);
getExecuter().executeQuery( update );
}
}

@ -1,22 +0,0 @@
package siprp.update.updates;
import shst.update.updates.SHSTUpdate7;
import com.evolute.module.updater.AbstractUpdate;
public class V13_0_To_V13_1 extends AbstractUpdate
{
public V13_0_To_V13_1()
{
super( 13.0, 13.1, "Adicionar propriedade processo_motivo_id em trabalhadores." );
}
@Override
public void doUpdate() throws Exception
{
SHSTUpdate7 upd7 = new SHSTUpdate7( 13.0, 13.1 );
upd7.doUpdate();
}
}

@ -1,33 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.sql.Delete;
public class V13_1_To_V13_2 extends AbstractUpdate
{
public V13_1_To_V13_2()
{
super( 13.1, 13.2, "Corrigir relatorios." );
}
@Override
public void doUpdate() throws Exception
{
Delete queryDeleteRiscos = new Delete(
"DELETE FROM hs_relatorio_posto_risco " +
"WHERE hs_relatorio_posto_risco.risco_id IN ( " +
"SELECT hs_relatorio_risco.id FROM hs_relatorio_risco WHERE hs_relatorio_risco.deleted_date IS NOT NULL " +
")"
);
getExecuter().executeQuery( queryDeleteRiscos );
Delete queryDeleteMedidas = new Delete(
"DELETE FROM hs_relatorio_posto_medida WHERE hs_relatorio_posto_medida.medida_id IN (" +
"SELECT hs_relatorio_medida.id FROM hs_relatorio_medida WHERE hs_relatorio_medida.deleted_date IS NOT NULL" +
")"
);
getExecuter().executeQuery( queryDeleteMedidas );
}
}

@ -1,21 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.sql.Insert;
public class V13_2_To_V13_3 extends AbstractUpdate
{
public V13_2_To_V13_3()
{
super( 13.2, 13.3, "Adicionar tipo de Lembrete 'Trabalhador'." );
}
@Override
public void doUpdate() throws Exception
{
Insert insert = new Insert( "INSERT INTO lembretes_tipos ( codigo, descricao, ordem, activo ) VALUES ( 'TRABALHADOR', 'Trabalhador', 5, 'y' );" );
getExecuter().executeQuery( insert );
}
}

@ -1,33 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.sql.Delete;
public class V13_3_To_V13_4 extends AbstractUpdate
{
public V13_3_To_V13_4()
{
super( 13.3, 13.4, "Corrigir relatorios." );
}
@Override
public void doUpdate() throws Exception
{
Delete queryDeleteRiscos = new Delete(
"DELETE FROM hs_relatorio_posto_risco " +
"WHERE hs_relatorio_posto_risco.risco_id IN ( " +
"SELECT hs_relatorio_risco.id FROM hs_relatorio_risco WHERE hs_relatorio_risco.deleted_date IS NOT NULL " +
")"
);
getExecuter().executeQuery( queryDeleteRiscos );
Delete queryDeleteMedidas = new Delete(
"DELETE FROM hs_relatorio_posto_medida WHERE hs_relatorio_posto_medida.medida_id IN (" +
"SELECT hs_relatorio_medida.id FROM hs_relatorio_medida WHERE hs_relatorio_medida.deleted_date IS NOT NULL" +
")"
);
getExecuter().executeQuery( queryDeleteMedidas );
}
}

@ -1,19 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.sql.Insert;
public class V13_7_To_V13_8 extends AbstractUpdate
{
public V13_7_To_V13_8()
{
super( 13.7, 13.8, "Adicionar valor qualitativo : nao valoravel." );
}
@Override
public void doUpdate() throws Exception
{
Insert ins = new Insert( "INSERT INTO hs_relatorio_risco_valor_qualitativo ( description ) VALUES ( 'N\u00E3o Valor\u00E1vel' );" );
getExecuter().executeQuery( ins );
}
}

@ -1,52 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.sql.Delete;
import com.evolute.utils.sql.Update;
public class V14_1_To_V14_2 extends AbstractUpdate
{
public V14_1_To_V14_2( )
{
super( 14.1, 14.2, "Corrigir relatórios." );
}
@Override
public void doUpdate() throws Exception
{
Delete queryDeleteRiscos = new Delete(
"DELETE FROM hs_relatorio_posto_risco " +
"WHERE hs_relatorio_posto_risco.risco_id IN ( " +
"SELECT hs_relatorio_risco.id FROM hs_relatorio_risco WHERE hs_relatorio_risco.deleted_date IS NOT NULL " +
")"
);
getExecuter().executeQuery( queryDeleteRiscos );
Delete queryDeleteMedidas = new Delete(
"DELETE FROM hs_relatorio_posto_medida WHERE hs_relatorio_posto_medida.medida_id IN (" +
"SELECT hs_relatorio_medida.id FROM hs_relatorio_medida WHERE hs_relatorio_medida.deleted_date IS NOT NULL" +
")"
);
getExecuter().executeQuery( queryDeleteMedidas );
Update updateIndex = new Update( "create index hs_relatorio_posto_medida_medida_idx on hs_relatorio_posto_medida( posto_id );" );
getExecuter().executeQuery( updateIndex );
Update updateIndex2 = new Update( "create index hs_relatorio_posto_medida_posto_idx on hs_relatorio_posto_medida( medida_id );" );
getExecuter().executeQuery( updateIndex2 );
Update update = new Update(
"UPDATE hs_relatorio_medida " +
"SET deleted_date = now() " +
"WHERE hs_relatorio_medida.id IN ( " +
"SELECT hs_relatorio_medida.id " +
"FROM hs_relatorio_medida " +
"LEFT OUTER JOIN hs_relatorio_posto_medida ON ( hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id ) " +
"WHERE " +
"hs_relatorio_posto_medida.medida_id IS null " +
")"
);
getExecuter().executeQuery( update );
}
}

@ -1,26 +0,0 @@
package siprp.update.updates;
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
import static com.evolute.utils.strings.UnicodeLatin1Map.ecirc;
import static com.evolute.utils.strings.UnicodeLatin1Map.oacute;
import shst.data.outer.HsRelatorioNormalizacaoData;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.PSQLSequenceUtils;
public class V14_2_To_V14_3 extends AbstractUpdate
{
public V14_2_To_V14_3( )
{
super( 14.2, 14.3, "Correc" + ccedil + atilde + "o de sequ" + ecirc + "ncias na normaliza" + ccedil + atilde + "o (Relat" + oacute + "rios de H&S)" );
}
@Override
public void doUpdate() throws Exception
{
PSQLSequenceUtils.fixSequence( HsRelatorioNormalizacaoData.TABLENAME, HsRelatorioNormalizacaoData.ID );
}
}

@ -1,43 +0,0 @@
/*
* V6_1_To_V7_0.java
*
* Created on 26 de Setembro de 2006, 11:48
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
/**
*
* @author fpalma
*/
public class V6_1_To_V7_0 extends AbstractUpdate
{
public V6_1_To_V7_0()
{
super(6.1,7.0,"Acrescentar campo de contribuinte nos prestadores",
"Acrescentar campo de prestador nas marca\u00e7\u00f5es",
"Acrescentar campo de prestador no hist\u00f3rico das marca\u00e7\u00f5es");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update( "ALTER TABLE prestadores ADD contribuinte VARCHAR(64);" );
executer.executeQuery( update );
update = new com.evolute.utils.sql.Update( "ALTER TABLE marcacoes_trabalhador ADD prestador_id int4 REFERENCES prestadores( id );" );
executer.executeQuery( update );
update = new com.evolute.utils.sql.Update( "ALTER TABLE marcacoes_trabalhador_estados ADD prestador_id int4 REFERENCES prestadores( id );" );
executer.executeQuery( update );
}
}

@ -1,50 +0,0 @@
/*
* V7_0_To_V7_2.java
*
* Created on 26 de Setembro de 2006, 11:48
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
/**
*
* @author fpalma
*/
public class V7_0_To_V7_2 extends AbstractUpdate
{
public V7_0_To_V7_2()
{
super(7.0,7.2,"Criar tabela dos processos");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"CREATE TABLE marcacoes_processo "
+ "( "
+ "id serial NOT NULL, "
+ "trabalhador_id int4 NOT NULL, "
+ "estado char(1) NOT NULL DEFAULT 'a'::bpchar, "
+ "data_inicio date, "
+ "data_fim date, "
+ "CONSTRAINT marcacoes_processo_pkey PRIMARY KEY (id), "
+ "CONSTRAINT marcacoes_processo_trabalhador_id_fkey FOREIGN KEY (trabalhador_id) "
+ "REFERENCES trabalhadores (id) MATCH SIMPLE "
+ "ON UPDATE NO ACTION ON DELETE NO ACTION "
+ ") "
+ "WITHOUT OIDS;" );
executer.executeQuery( update );
}
}

@ -1,185 +0,0 @@
/*
* V7_2_To_V7_4.java
*
* Created on 26 de Setembro de 2006, 11:48
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
/**
*
* @author fpalma
*/
public class V7_2_To_V7_4 extends AbstractUpdate
{
public V7_2_To_V7_4()
{
super(7.2,7.4,"Acrescentar campo de motivo ao processo",
"Criar tabelas de suporte aos processos");
}
public void doUpdate()
throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"ALTER TABLE marcacoes_processo RENAME TO trabalhadores_processo;" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"ALTER TABLE trabalhadores_processo ADD motivo int4;" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"CREATE TABLE trabalhadores_consultas"
+"("
+" id serial,"
+" trabalhador_id int4 NOT NULL,"
+" data date,"
+" estado int4,"
+" prestador_id int4,"
+" processo_id int4,"
+" CONSTRAINT trabalhadores_consultas_pkey PRIMARY KEY (id),"
+" CONSTRAINT trabalhadores_consultas_prestador_id_fkey FOREIGN KEY (prestador_id) REFERENCES prestadores (id) ON UPDATE RESTRICT ON DELETE RESTRICT,"
+" CONSTRAINT trabalhadores_consultas_processo_id_fkey FOREIGN KEY (processo_id) REFERENCES trabalhadores_processo (id) ON UPDATE RESTRICT ON DELETE RESTRICT,"
+" CONSTRAINT trabalhadores_consultas_trabalhador_id_fkey FOREIGN KEY (trabalhador_id) REFERENCES trabalhadores (id) ON UPDATE RESTRICT ON DELETE RESTRICT"
+") "
+"WITHOUT OIDS;"
+"ALTER TABLE trabalhadores_consultas OWNER TO postgres;" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"CREATE TABLE trabalhadores_consultas_datas"
+"("
+" id serial,"
+" data date,"
+" trabalhadores_consultas_id int4,"
+" estado int4,"
+" CONSTRAINT trabalhadores_consultas_datas_pkey PRIMARY KEY (id),"
+" CONSTRAINT trabalhadores_consultas_datas_trabalhadores_consultas_id_fkey FOREIGN KEY (trabalhadores_consultas_id) REFERENCES trabalhadores_consultas (id) ON UPDATE RESTRICT ON DELETE RESTRICT"
+") "
+"WITHOUT OIDS;"
+"ALTER TABLE trabalhadores_consultas_datas OWNER TO postgres;" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"CREATE TABLE trabalhadores_consultas_datas_emails"
+"("
+" id serial,"
+" trabalhadores_consultas_datas_id int4,"
+" destination varchar(512),"
+" data date,"
+" subject varchar(512),"
+" body varchar(32768),"
+" CONSTRAINT trabalhadores_consultas_datas_emails_pkey PRIMARY KEY (id),"
+" CONSTRAINT trabalhadores_consultas_data_trabalhadores_consultas_data_fkey1 FOREIGN KEY (trabalhadores_consultas_datas_id) REFERENCES trabalhadores_consultas_datas (id) ON UPDATE RESTRICT ON DELETE RESTRICT"
+") "
+"WITHOUT OIDS;"
+"ALTER TABLE trabalhadores_consultas_datas_emails OWNER TO postgres;" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"CREATE TABLE trabalhadores_consultas_datas_observacoes"
+"("
+" id serial,"
+" trabalhadores_consultas_datas_id int4,"
+" observacao varchar(4096),"
+" CONSTRAINT trabalhadores_consultas_datas_observacoes_pkey PRIMARY KEY (id),"
+" CONSTRAINT trabalhadores_consultas_datas_trabalhadores_consultas_data_fkey FOREIGN KEY (trabalhadores_consultas_datas_id) REFERENCES trabalhadores_consultas_datas (id) ON UPDATE RESTRICT ON DELETE RESTRICT"
+") "
+"WITHOUT OIDS;"
+"ALTER TABLE trabalhadores_consultas_datas_observacoes OWNER TO postgres;" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"CREATE TABLE trabalhadores_ecds"
+"("
+" id serial,"
+" trabalhador_id int4,"
+" estado int4,"
+" data date,"
+" processo_id int4,"
+" CONSTRAINT trabalhadores_ecgs_pkey PRIMARY KEY (id),"
+" CONSTRAINT trabalhadores_ecds_processo_id_fkey FOREIGN KEY (processo_id) REFERENCES trabalhadores_processo (id) ON UPDATE RESTRICT ON DELETE RESTRICT,"
+" CONSTRAINT trabalhadores_ecgs_trabalhador_id_fkey FOREIGN KEY (trabalhador_id) REFERENCES trabalhadores (id) ON UPDATE RESTRICT ON DELETE RESTRICT"
+") "
+"WITHOUT OIDS;"
+"ALTER TABLE trabalhadores_ecds OWNER TO postgres;" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"CREATE TABLE trabalhadores_ecds_datas"
+"("
+" id serial,"
+" trabalhadores_ecds_id int4,"
+" data date,"
+" estado int4,"
+" CONSTRAINT trabalhadores_ecds_datas_pkey PRIMARY KEY (id),"
+" CONSTRAINT trabalhadores_ecds_datas_trabalhadores_ecds_id_fkey FOREIGN KEY (trabalhadores_ecds_id) REFERENCES trabalhadores_ecds (id) ON UPDATE RESTRICT ON DELETE RESTRICT"
+") "
+"WITHOUT OIDS;"
+"ALTER TABLE trabalhadores_ecds_datas OWNER TO postgres;" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"CREATE TABLE trabalhadores_ecd"
+"("
+" id int4 NOT NULL,"
+" ecd_id int4,"
+" ecd_oficial_id int4,"
+" prestador_id int4,"
+" estado int4,"
+" trabalhadores_ecds_id int4,"
+" trabalhadores_ecds_datas_id int4,"
+" CONSTRAINT trabalhadores_ecg_pkey PRIMARY KEY (id),"
+" CONSTRAINT trabalhadores_ecd_trabalhadores_ecds_datas_id_fkey FOREIGN KEY (trabalhadores_ecds_datas_id) REFERENCES trabalhadores_ecds_datas (id) ON UPDATE RESTRICT ON DELETE RESTRICT,"
+" CONSTRAINT trabalhadores_ecd_trabalhadores_ecds_id_fkey FOREIGN KEY (trabalhadores_ecds_id) REFERENCES trabalhadores_ecds (id) ON UPDATE RESTRICT ON DELETE RESTRICT,"
+" CONSTRAINT trabalhadores_ecg_ecd_id_fkey FOREIGN KEY (ecd_id) REFERENCES prt_tipos_elementos_protocolo (id) ON UPDATE RESTRICT ON DELETE RESTRICT,"
+" CONSTRAINT trabalhadores_ecg_ecd_oficial_id_fkey FOREIGN KEY (ecd_oficial_id) REFERENCES ecd_oficial (id) ON UPDATE RESTRICT ON DELETE RESTRICT,"
+" CONSTRAINT trabalhadores_ecg_prestador_id_fkey FOREIGN KEY (prestador_id) REFERENCES prestadores (id) ON UPDATE RESTRICT ON DELETE RESTRICT"
+") "
+"WITHOUT OIDS;"
+"ALTER TABLE trabalhadores_ecd OWNER TO postgres;" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"CREATE TABLE trabalhadores_ecds_datas_emails"
+"("
+" id serial,"
+" trabalhadores_ecds_datas_id int4,"
+" destination varchar(512),"
+" data date,"
+" subject varchar(512),"
+" body varchar(32768),"
+" CONSTRAINT trabalhadores_ecds_datas_emails_pkey PRIMARY KEY (id),"
+" CONSTRAINT trabalhadores_ecds_datas_email_trabalhadores_ecds_datas_id_fkey FOREIGN KEY (trabalhadores_ecds_datas_id) REFERENCES trabalhadores_ecds_datas (id) ON UPDATE RESTRICT ON DELETE RESTRICT"
+") "
+"WITHOUT OIDS;"
+"ALTER TABLE trabalhadores_ecds_datas_emails OWNER TO postgres;" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"CREATE TABLE trabalhadores_ecds_datas_observacoes"
+"("
+" id serial,"
+" trabalhadores_ecds_datas_id int4,"
+" observacao varchar(4096),"
+" CONSTRAINT trabalhadores_ecds_datas_observacoes_pkey PRIMARY KEY (id),"
+" CONSTRAINT trabalhadores_ecds_datas_obser_trabalhadores_ecds_datas_id_fkey FOREIGN KEY (trabalhadores_ecds_datas_id) REFERENCES trabalhadores_ecds_datas (id) ON UPDATE RESTRICT ON DELETE RESTRICT"
+") "
+"WITHOUT OIDS;"
+"ALTER TABLE trabalhadores_ecds_datas_observacoes OWNER TO postgres;" );
executer.executeQuery( update );
}
}

@ -1,48 +0,0 @@
/*
* V7_4_To_V7_5.java
*
* Created on 26 de Setembro de 2006, 11:48
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
/**
*
* @author fpalma
*/
public class V7_4_To_V7_5 extends AbstractUpdate
{
public V7_4_To_V7_5()
{
super( 7.4,7.5,"Ligar processo a ficha de aptid\u00e3o");
}
public void doUpdate()
throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"CREATE TABLE trabalhadores_fichas_aptidao"
+"("
+" id serial,"
+" processo_id int4,"
+" exame_id int4,"
+" CONSTRAINT trabalhadores_fichas_aptidao_pkey PRIMARY KEY (id),"
+" CONSTRAINT trabalhadores_fichas_aptidao_exame_id_fkey FOREIGN KEY (exame_id) REFERENCES exames (id) ON UPDATE RESTRICT ON DELETE RESTRICT,"
+" CONSTRAINT trabalhadores_fichas_aptidao_processo_id_fkey FOREIGN KEY (processo_id) REFERENCES trabalhadores_processo (id) ON UPDATE RESTRICT ON DELETE RESTRICT"
+")"
+"WITHOUT OIDS;"
+"ALTER TABLE trabalhadores_fichas_aptidao OWNER TO postgres;" );
executer.executeQuery( update );
}
}

@ -1,38 +0,0 @@
/*
* V7_5_To_V7_6.java
*
* Created on 26 de Setembro de 2006, 11:48
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
/**
*
* @author fpalma
*/
public class V7_5_To_V7_6 extends AbstractUpdate
{
public V7_5_To_V7_6()
{
super(7.5,7.6,"Alterar tabela dos processos");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"ALTER TABLE trabalhadores_processo ADD sub_motivo int4;" );
executer.executeQuery( update );
}
}

@ -1,47 +0,0 @@
/*
* V7_6_To_V7_7.java
*
* Created on May 15, 2007, 3:12 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
import com.evolute.utils.sql.Assignment;
import com.evolute.utils.sql.Field;
/**
*
* @author lflores
*/
public class V7_6_To_V7_7 extends AbstractUpdate
{
public V7_6_To_V7_7()
{
super(7.6,7.7,"Alterar tabela dos exames e criar tabela exames_portaria");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"ALTER TABLE exames ADD fo BYTEA;" );
executer.executeQuery( update );
update = new com.evolute.utils.sql.Update(
"CREATE TABLE exames_portaria ( id SERIAL NOT NULL, portaria VARCHAR(255) NOT NULL, "
+ "data_entrada timestamp without time zone NOT NULL DEFAULT now(), PRIMARY KEY( id ) );" );
executer.executeQuery( update );
com.evolute.utils.sql.Insert insert =
new com.evolute.utils.sql.Insert( "exames_portaria",
new Assignment[]{ new Assignment( new Field( "portaria" ), "Portaria n. 299/2007, de 16 de Mar\u00e7o" ) } );
executer.executeQuery( insert );
}
}

@ -1,41 +0,0 @@
/*
* V7_7_To_V7_8.java
*
* Created on May 15, 2007, 3:12 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
/**
*
* @author lflores
*/
public class V7_7_To_V7_8 extends AbstractUpdate
{
public V7_7_To_V7_8()
{
super(7.7,7.8,"Alterar tabela das datas de exames para incluir o prestador",
"Alterar tabela das datas de consulta para incluir o prestador");
}
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"ALTER TABLE trabalhadores_ecds_datas ADD prestador_id INTEGER REFERENCES prestadores( id );" );
executer.executeQuery( update );
update = new com.evolute.utils.sql.Update(
"ALTER TABLE trabalhadores_consultas_datas ADD prestador_id INTEGER REFERENCES prestadores( id );" );
executer.executeQuery( update );
}
}

@ -1,57 +0,0 @@
/*
* V7_8_To_V7_9.java
*
* Created on December 19, 2007, 3:12 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
/**
*
* @author fpalma
*/
public class V7_8_To_V7_9 extends AbstractUpdate
{
public V7_8_To_V7_9()
{
super(7.8,7.9,"Alterar tabela dos estabelecimentos para ter prestadores por defeito");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"ALTER TABLE estabelecimentos ADD prestador_consulta_id INTEGER REFERENCES prestadores( id );" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"ALTER TABLE estabelecimentos ADD prestador_ecds_id INTEGER REFERENCES prestadores( id );" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"ALTER TABLE estabelecimentos ADD aux INT REFERENCES contactos(id);" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"UPDATE estabelecimentos SET aux = CAST( contacto AS INTEGER);" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"ALTER TABLE estabelecimentos RENAME contacto TO contacto_backup;" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"ALTER TABLE estabelecimentos RENAME aux TO contacto_id;" );
executer.executeQuery( update );
}
}

@ -1,49 +0,0 @@
/*
* V7_9_To_V8_0.java
*
* Created on December 19, 2007, 3:12 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
/**
*
* @author fpalma
*/
public class V7_9_To_V8_0 extends AbstractUpdate
{
public V7_9_To_V8_0()
{
super(7.9,8.0,"Alterar tabela dos ecds");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"ALTER TABLE trabalhadores_ecd DROP CONSTRAINT trabalhadores_ecd_trabalhadores_ecds_id_fkey;" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"ALTER TABLE trabalhadores_ecd DROP trabalhadores_ecds_id;" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"ALTER TABLE trabalhadores_ecd DROP CONSTRAINT trabalhadores_ecg_prestador_id_fkey;" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"ALTER TABLE trabalhadores_ecd DROP prestador_id;" );
executer.executeQuery( update );
}
}

@ -1,39 +0,0 @@
/*
* V8_0_To_V8_1.java
*
* Created on December 19, 2007, 3:12 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
/**
*
* @author fpalma
*/
public class V8_0_To_V8_1 extends AbstractUpdate
{
public V8_0_To_V8_1()
{
super(8.0,8.1,"Alterar tabela dos ecds");
}
@Override
public void doUpdate() throws Exception
{
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"CREATE SEQUENCE trabalhadores_ecd_id_seq;" );
getExecuter().executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"ALTER TABLE trabalhadores_ecd ALTER COLUMN id SET DEFAULT NEXTVAL('trabalhadores_ecd_id_seq');" );
getExecuter().executeQuery( update );
}
}

@ -1,72 +0,0 @@
/*
* V8_1_To_V8_2.java
*
* Created on December 19, 2007, 3:12 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
import com.evolute.utils.sql.Delete;
/**
*
* @author fpalma
*/
public class V8_1_To_V8_2 extends AbstractUpdate
{
public V8_1_To_V8_2()
{
super(8.1,8.2,"Alterar tabela dos ecds", "Alterar tabela de marca\u00e7\u00e3o dos ecds");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"ALTER TABLE trabalhadores_ecd ADD enviado CHAR(1);" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"ALTER TABLE trabalhadores_ecds_datas ADD analisador_id INT REFERENCES prestadores( id );" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"ALTER TABLE trabalhadores_ecds_datas ADD data_envio DATE;" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"ALTER TABLE trabalhadores_ecds_datas ADD data_recepcao DATE;" );
executer.executeQuery( update );
Delete delete = new Delete( "trabalhadores_ecd", null );
executer.executeQuery( delete );
delete = new Delete( "trabalhadores_ecds_datas_emails", null );
executer.executeQuery( delete );
delete = new Delete( "trabalhadores_ecds_datas_observacoes", null );
executer.executeQuery( delete );
delete = new Delete( "trabalhadores_ecds_datas", null );
executer.executeQuery( delete );
delete = new Delete( "trabalhadores_ecds", null );
executer.executeQuery( delete );
delete = new Delete( "trabalhadores_consultas_datas_emails", null );
executer.executeQuery( delete );
delete = new Delete( "trabalhadores_consultas_datas_observacoes", null );
executer.executeQuery( delete );
delete = new Delete( "trabalhadores_consultas_datas", null );
executer.executeQuery( delete );
delete = new Delete( "trabalhadores_consultas", null );
executer.executeQuery( delete );
delete = new Delete( "trabalhadores_fichas_aptidao", null );
executer.executeQuery( delete );
delete = new Delete( "trabalhadores_processo", null );
executer.executeQuery( delete );
}
}

@ -1,41 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
/**
*
* @author fpalma
*/
public class V8_2_To_V8_3 extends AbstractUpdate
{
public V8_2_To_V8_3()
{
super(8.2,8.3,"Criar tabela para locais de an\u00e1lise");
}
@Override
public void doUpdate() throws Exception
{
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"CREATE TABLE trabalhadores_ecds_analise"
+ "("
+ "id serial, "
+ "data date NOT NULL, "
+ "prestador_id int4 NOT NULL, "
+ "grupo_ecds_id int4 NOT NULL, "
+ "CONSTRAINT trabalhadores_ecds_analise_pkey PRIMARY KEY (id), "
+ "CONSTRAINT trabalhadores_ecds_analise_grupo_ecds_id_fkey FOREIGN KEY (grupo_ecds_id) "
+ " REFERENCES prt_grupos_protocolo (id) MATCH SIMPLE "
+ " ON UPDATE NO ACTION ON DELETE NO ACTION, "
+ "CONSTRAINT trabalhadores_ecds_analise_prestador_id_fkey FOREIGN KEY (prestador_id) "
+ " REFERENCES prestadores (id) MATCH SIMPLE "
+ " ON UPDATE NO ACTION ON DELETE NO ACTION "
+ ") "
+ "WITHOUT OIDS; "
+ "ALTER TABLE trabalhadores_ecds_analise OWNER TO postgres;" );
getExecuter().executeQuery( update );
}
}

@ -1,24 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
/**
*
* @author tsimao
*
*/
public class V8_3_To_V8_4 extends AbstractUpdate
{
public V8_3_To_V8_4()
{
super(8.3,8.4,"Adicionado analisador [prestador] por TrabalhadorEcd");
}
@Override
public void doUpdate() throws Exception
{
com.evolute.utils.sql.Update update = new com.evolute.utils.sql.Update( "ALTER TABLE trabalhadores_ecd ADD COLUMN analisador_id int4;" + "ALTER TABLE trabalhadores_ecd ADD CONSTRAINT analisador_id_fkey FOREIGN KEY(analisador_id) REFERENCES prestadores(id);" );
getExecuter().executeQuery( update );
}
}

@ -1,25 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
/**
*
* @author tsimao
*
*/
public class V8_4_To_V8_5 extends AbstractUpdate
{
public V8_4_To_V8_5()
{
super(8.4,8.5,"Adicionado analisador [prestador] por PrtGruposProtocolo");
}
@Override
public void doUpdate() throws Exception
{
com.evolute.utils.sql.Update update = new com.evolute.utils.sql.Update( "ALTER TABLE prt_grupos_protocolo ADD COLUMN analisador_id int4;"
+ "ALTER TABLE prt_grupos_protocolo ADD CONSTRAINT analisador_id_fkey FOREIGN KEY(analisador_id) REFERENCES prestadores(id);" );
getExecuter().executeQuery( update );
}
}

@ -1,28 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
/**
*
* @author tsimao
*
*/
public class V8_5_To_V8_6 extends AbstractUpdate
{
public V8_5_To_V8_6()
{
super(8.5,8.6,"Adicionado campo 'activo' a TrabalhadoresProcesso\n"+
"Adicionada observacao a Prestadores\n"+
"Adicionado BI a Trabalhadores\n");
}
@Override
public void doUpdate() throws Exception
{
com.evolute.utils.sql.Update update = new com.evolute.utils.sql.Update( "ALTER TABLE trabalhadores_processo ADD COLUMN activo char default 'y';"
+ "ALTER TABLE prestadores ADD COLUMN observacoes character varying(65535);"
+ "ALTER TABLE trabalhadores ADD COLUMN bi character varying(255);");
getExecuter().executeQuery( update );
}
}

@ -1,30 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
/**
*
* @author fpalma
*/
public class V8_6_To_V8_7 extends AbstractUpdate
{
public V8_6_To_V8_7()
{
super(8.6,8.7,"Adicionados campos data_envio e data_recepcao a cada instancia de ECD");
}
@Override
public void doUpdate() throws Exception
{
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"ALTER TABLE trabalhadores_ecd ADD data_envio DATE;" );
getExecuter().executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"ALTER TABLE trabalhadores_ecd ADD data_recepcao DATE;" );
getExecuter().executeQuery( update );
}
}

@ -1,30 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
/**
*
* @author fpalma
*/
public class V8_7_To_V8_8 extends AbstractUpdate
{
public V8_7_To_V8_8()
{
super(8.7,8.8,"Adicionada coluna em 'lembretes' que referencia nova tabela das marcacoes (trabalhadores_consultas_datas)");
}
@Override
public void doUpdate() throws Exception
{
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"ALTER TABLE lembretes ADD COLUMN trabalhadores_consultas_datas_id int4 REFERENCES trabalhadores_consultas_datas(id);" );
getExecuter().executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"ALTER TABLE lembretes ADD COLUMN trabalhadores_ecds_datas_id int4 REFERENCES trabalhadores_ecds_datas(id);" );
getExecuter().executeQuery( update );
}
}

@ -1,26 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
/**
*
* @author fpalma
*/
public class V8_8_To_V8_9 extends AbstractUpdate
{
public V8_8_To_V8_9()
{
super(8.8,8.9,"Adicionada coluna em 'lembretes' para marcar lembretes já tratados");
}
@Override
public void doUpdate() throws Exception
{
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"alter table lembretes add column deleted_date timestamp;" );
getExecuter().executeQuery( update );
}
}

@ -1,79 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
/**
*
* @author fpalma
*/
public class V8_9_To_V9_0 extends AbstractUpdate
{
public V8_9_To_V9_0()
{
super(8.9,9.0, "Criar tabela 'posto_de_trabalho'",
"Criar tabela 'legislacao'",
"Criar tabela relacional 'posto_de_trabalho_estabelecimento'",
"Criar tabela relacional 'legislacao_estabelecimento'",
"Criar tabela 'medida'",
"Criar tabela 'risco'",
"Criar tabela 'medida'",
"Criar tabela relacional 'risco_medida'",
"Criar tabela 'image'",
"Adicionar logotipo a empresa");
}
@Override
public void doUpdate() throws Exception
{
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"create table email_plano_de_actuacao(" +
"id serial PRIMARY KEY," +
"description varchar(255) NOT NULL," +
"estabelecimento_id int4 REFERENCES estabelecimentos(id)" +
");" +
"create table posto_de_trabalho(" +
"id serial PRIMARY KEY," +
"description varchar(1024) NOT NULL" +
");" +
"create table legislacao(" +
"id serial PRIMARY KEY," +
"parent_id int4 REFERENCES legislacao(id)," +
"description varchar(8192) NOT NULL" +
");" +
"create table posto_de_trabalho_estabelecimento(" +
"posto_de_trabalho_id int4 REFERENCES posto_de_trabalho(id) NOT NULL," +
"estabelecimento_id int4 REFERENCES estabelecimentos(id) NOT NULL," +
"CONSTRAINT posto_de_trabalho_estabelecimento_pkey PRIMARY KEY(posto_de_trabalho_id, estabelecimento_id)" +
");" +
"create table legislacao_estabelecimento(" +
"legislacao_id int4 REFERENCES legislacao(id) NOT NULL," +
"estabelecimento_id int4 REFERENCES estabelecimentos(id) NOT NULL," +
"CONSTRAINT legislacao_estabelecimento_pkey PRIMARY KEY(legislacao_id, estabelecimento_id)" +
");" +
"create table risco(" +
"id serial PRIMARY KEY," +
"description varchar(255) NOT NULL," +
"value int4 NOT NULL" +
");" +
"create table medida(" +
"id serial PRIMARY KEY," +
"description varchar(255) NOT NULL" +
");" +
"create table risco_medida(" +
"risco_id int4 REFERENCES risco(id) NOT NULL," +
"medida_id int4 REFERENCES medida(id) NOT NULL," +
"CONSTRAINT risco_medida_pkey PRIMARY KEY(risco_id, medida_id)" +
");" +
"create table image(" +
"id serial PRIMARY KEY," +
"name varchar(255) NOT NULL," +
"image_data bytea NOT NULL" +
");" +
"alter table empresas add column empresa_logo_id int4 REFERENCES image(id);"
);
getExecuter().executeQuery( update );
}
}

@ -1,114 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
/**
*
* @author fpalma
*/
public class V9_0_To_V9_1 extends AbstractUpdate
{
public V9_0_To_V9_1()
{
super(9.0,9.1,"Refactorizar tabelas de higiene e seguranca","Criar novas tabelas de higiene e seguranca");
}
@Override
public void doUpdate() throws Exception
{
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"drop table risco_medida;" +
"drop table risco;" +
"drop table medida;" +
"drop table legislacao_estabelecimento;" +
"drop table legislacao;" +
"drop table posto_de_trabalho_estabelecimento;" +
"drop table posto_de_trabalho;" +
"CREATE TABLE hs_area(" +
" id serial PRIMARY KEY," +
" empresa_id int4 REFERENCES empresas(id)," +
" description varchar(256) NOT NULL" +
");" +
"CREATE TABLE hs_posto(" +
" id serial PRIMARY KEY," +
" area_id int4 REFERENCES hs_area(id)," +
" description varchar(256) NOT NULL" +
");" +
"CREATE TABLE hs_medida(" +
" id serial PRIMARY KEY," +
" description varchar(1024) NOT NULL," +
" requesitos_legais varchar(1024)" +
");" +
"CREATE TABLE hs_risco_tema(" +
" id serial PRIMARY KEY," +
" description varchar(256) NOT NULL" +
");" +
"CREATE TABLE hs_risco(" +
" id serial PRIMARY KEY," +
" tema_id int4 REFERENCES hs_risco_tema(id)," +
" description varchar(256) NOT NULL" +
");" +
"CREATE TABLE hs_risco_medida(" +
" risco_id int4 REFERENCES hs_risco(id)," +
" medida_id int4 REFERENCES hs_medida(id)," +
" CONSTRAINT hs_risco_medida_pkey PRIMARY KEY(risco_id, medida_id)" +
");" +
"create table hs_relatorio(" +
" id serial PRIMARY KEY," +
" data date NOT NULL," +
" deleted_date timestamp" +
");" +
"create table hs_medida_classificacao(" +
" id serial PRIMARY KEY," +
" description varchar(255) NOT NULL" +
");" +
"create table hs_relatorio_risco(" +
" id serial PRIMARY KEY," +
" relatorio_id int4 REFERENCES hs_relatorio NOT NULL," +
" description varchar(255) NOT NULL" +
");" +
"create table hs_relatorio_medida(" +
" id serial PRIMARY KEY," +
" risco_id int4 REFERENCES hs_relatorio_risco NOT NULL," +
" description varchar(1024) NOT NULL," +
" requesitos_legais varchar(1024) NOT NULL," +
" severidade int4," +
" probabilidade int4," +
" classificacao_id int4 REFERENCES hs_medida_classificacao" +
");" +
"create table hs_normalizacao(" +
" id serial PRIMARY KEY," +
" codigo varchar(128) NOT NULL," +
" descricao varchar(1024) NOT NULL," +
" portuguesa boolean NOT NULL" +
");" +
"create table hs_equipamento_medico(" +
" id serial PRIMARY KEY," +
" nome varchar(255) NOT NULL" +
");" +
"create table hs_legislacao_categoria(" +
" id serial PRIMARY KEY," +
" description varchar(255) NOT NULL" +
");" +
"create table hs_legislacao(" +
" id serial PRIMARY KEY," +
" description varchar(1024) NOT NULL," +
" categoria_id int4 REFERENCES hs_legislacao_categoria(id)" +
");" +
"create table hs_legislacao_empresa(" +
" legislacao_id int4 REFERENCES hs_legislacao(id)," +
" empresa_id int4 REFERENCES empresas(id)," +
" CONSTRAINT hs_legislacao_empresa_pkey PRIMARY KEY(legislacao_id, empresa_id)" +
");" +
"create table hs_legislacao_estabelecimento(" +
" legislacao_id int4 REFERENCES hs_legislacao(id)," +
" estabelecimento_id int4 REFERENCES estabelecimentos(id)," +
" CONSTRAINT hs_legislacao_estabelecimento_pkey PRIMARY KEY(legislacao_id, estabelecimento_id)" +
");"
);
getExecuter().executeQuery( update );
}
}

@ -1,37 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
/**
*
* @author fpalma
*/
public class V9_1_To_V9_2 extends AbstractUpdate
{
public V9_1_To_V9_2()
{
super(9.1,9.2,"Soft-delete nas tabelas de higiene e saude");
}
@Override
public void doUpdate() throws Exception
{
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"alter table hs_area add column deleted_date timestamp;" +
"alter table hs_equipamento_medico add column deleted_date timestamp;" +
"alter table hs_legislacao add column deleted_date timestamp;" +
"alter table hs_legislacao_categoria add column deleted_date timestamp;" +
"alter table hs_medida add column deleted_date timestamp;" +
"alter table hs_normalizacao add column deleted_date timestamp;" +
"alter table hs_posto add column deleted_date timestamp;" +
"alter table hs_relatorio_medida add column deleted_date timestamp;" +
"alter table hs_relatorio_risco add column deleted_date timestamp;" +
"alter table hs_risco add column deleted_date timestamp;" +
"alter table hs_risco_tema add column deleted_date timestamp;"
);
getExecuter().executeQuery( update );
}
}

@ -1,41 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
/**
*
* @author fpalma
*/
public class V9_2_To_V9_3 extends AbstractUpdate
{
public V9_2_To_V9_3()
{
super(9.2,9.3,"Adicionados campos ao relatorio");
}
@Override
public void doUpdate() throws Exception
{
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"alter table hs_relatorio_medida drop column severidade;" +
"alter table hs_relatorio_medida drop column probabilidade;" +
"alter table hs_relatorio_medida drop column classificacao_id;" +
"drop table hs_medida_classificacao;" +
"alter table hs_relatorio add column marcacao_id int4 REFERENCES marcacoes_estabelecimento;" +
"alter table hs_relatorio add column is_submetido timestamp;" +
"alter table hs_relatorio_risco add column probabilidade int4;" +
"alter table hs_relatorio_risco add column severidade int4;" +
"create table hs_relatorio_risco_valor_qualitativo" +
"(" +
" id serial PRIMARY KEY," +
" description varchar(64)" +
");" +
"alter table hs_relatorio_risco add column valor_qualitativo_id int4 REFERENCES hs_relatorio_risco_valor_qualitativo;" +
"alter table hs_relatorio_risco add column is_plano_actuacao char(1);"
);
getExecuter().executeQuery( update );
}
}

@ -1,37 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
/**
*
* @author fpalma
*/
public class V9_3_To_V9_4 extends AbstractUpdate
{
public V9_3_To_V9_4()
{
super(9.3,9.4,"Adicionados postos de trabalho relatorio");
}
@Override
public void doUpdate() throws Exception
{
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"create table hs_relatorio_medida_area" +
"(" +
" id serial PRIMARY KEY," +
" description varchar(256) NOT NULL" +
");" +
"create table hs_relatorio_medida_posto" +
"(" +
" id serial PRIMARY KEY," +
" description varchar(256) NOT NULL," +
" area_id int4 REFERENCES hs_relatorio_medida_area(id)" +
");"
);
getExecuter().executeQuery( update );
}
}

@ -1,54 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
/**
*
* @author fpalma
*/
public class V9_4_To_V9_5 extends AbstractUpdate
{
public V9_4_To_V9_5()
{
super(9.4,9.5,"Refactorizacao do relatorio");
}
public void doUpdate() throws Exception
{
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"drop table hs_relatorio_medida_posto;" +
"drop table hs_relatorio_medida_area;" +
"alter table hs_relatorio_risco drop column probabilidade;" +
"alter table hs_relatorio_risco drop column severidade;" +
"alter table hs_relatorio_risco drop column valor_qualitativo_id;" +
"create table hs_posto_risco(" +
" posto_id int4 REFERENCES hs_posto(id)," +
" risco_id int4 REFERENCES hs_risco(id)," +
" CONSTRAINT hs_posto_risco_pkey PRIMARY KEY (posto_id,risco_id)" +
");" +
"create table hs_relatorio_area(" +
" id serial PRIMARY KEY," +
" description varchar(256) NOT NULL," +
" deleted_date timestamp" +
");" +
"create table hs_relatorio_posto(" +
" id serial PRIMARY KEY," +
" description varchar(256) NOT NULL," +
" area_id int4 REFERENCES hs_relatorio_area(id)," +
" deleted_date timestamp" +
");" +
"create table hs_relatorio_posto_risco(" +
" posto_id int4 REFERENCES hs_relatorio_posto(id)," +
" risco_id int4 REFERENCES hs_relatorio_risco(id)," +
" probabilidade int4," +
" severidade int4," +
" valor_qualitativo_id int4 REFERENCES hs_relatorio_risco_valor_qualitativo(id)," +
" CONSTRAINT hs_relatorio_posto_risco_pkey PRIMARY KEY (posto_id,risco_id)" +
");"
);
getExecuter().executeQuery( update );
}
}

@ -1,31 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
/**
*
* @author fpalma
*/
public class V9_5_To_V9_6 extends AbstractUpdate
{
public V9_5_To_V9_6()
{
super(9.5,9.6,"Relacao postoDeTrabalho <-> estabelecimento");
}
@Override
public void doUpdate() throws Exception
{
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"create table hs_posto_estabelecimento(" +
" posto_id int4 REFERENCES hs_posto(id)," +
" estabelecimento_id int4 REFERENCES estabelecimentos(id)," +
" CONSTRAINT hs_posto_estabelecimento_pkey PRIMARY KEY(posto_id,estabelecimento_id)" +
");"
);
getExecuter().executeQuery( update );
}
}

@ -1,40 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
/**
*
* @author fpalma
*/
public class V9_6_To_V9_7 extends AbstractUpdate
{
public V9_6_To_V9_7()
{
super(9.6,9.7,"Relacao postoDeTrabalho <-> medida");
}
public void doUpdate() throws Exception
{
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"drop table hs_posto_risco;" +
"create table hs_posto_medida(" +
" posto_id int4 REFERENCES hs_posto(id)," +
" medida_id int4 REFERENCES hs_medida(id)," +
" CONSTRAINT hs_posto_medida_pkey PRIMARY KEY(posto_id,medida_id)" +
");" +
"create table hs_relatorio_posto_medida(" +
" posto_id int4 REFERENCES hs_relatorio_posto(id)," +
" medida_id int4 REFERENCES hs_relatorio_medida(id)," +
" CONSTRAINT hs_relatorio_posto_medida_pkey PRIMARY KEY(posto_id,medida_id)" +
");"
);
getExecuter().executeQuery( update );
}
public String toString()
{
return "v" + getStartVersion() + " para v" + getEndVersion();
}
}

@ -1,39 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
/**
*
* @author fpalma
*/
public class V9_7_To_V9_8 extends AbstractUpdate
{
public V9_7_To_V9_8()
{
super(9.7,9.8,"Relacao postoDeTrabalho <-> risco");
}
@Override
public void doUpdate() throws Exception
{
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"create table hs_posto_risco(" +
" posto_id int4 REFERENCES hs_posto(id)," +
" risco_id int4 REFERENCES hs_risco(id)," +
" probabilidade int4," +
" severidade int4," +
" valor_qualitativo int4 REFERENCES hs_relatorio_risco_valor_qualitativo," +
" CONSTRAINT hs_posto_risco_pkey PRIMARY KEY(posto_id, risco_id)" +
");" +
"ALTER TABLE hs_relatorio_risco DROP COLUMN is_plano_actuacao;" +
"ALTER TABLE hs_posto_risco ADD COLUMN is_plano_actuacao char(1);" +
"insert into hs_relatorio_risco_valor_qualitativo (description) values('Controlado');" +
"insert into hs_relatorio_risco_valor_qualitativo (description) values('Incontrolado');" +
"insert into hs_relatorio_risco_valor_qualitativo (description) values('Indeterminado');"
);
getExecuter().executeQuery( update );
}
}

@ -1,48 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
/**
*
* @author fpalma
*/
public class V9_8_To_V9_9 extends AbstractUpdate
{
public V9_8_To_V9_9()
{
super(9.8,9.9,"Criacao de tabelas para associacao de emails e riscos a empresas");
}
@Override
public void doUpdate() throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"alter table hs_posto_medida add column is_plano_actuacao char(1); " +
"create table hs_email( " +
" id serial PRIMARY KEY, " +
" email varchar(128) " +
"); " +
"create table hs_email_estabelecimento( " +
" email_id int4 REFERENCES hs_email(id), " +
" estabelecimento_id int4 REFERENCES estabelecimentos(id), " +
" constraint hs_email_estabelecimento_pkey PRIMARY KEY(email_id,estabelecimento_id) " +
"); " +
"create table hs_email_empresa( " +
" email_id int4 REFERENCES hs_email(id), " +
" empresa_id int4 REFERENCES empresas(id), " +
" constraint hs_email_empresa_pkey PRIMARY KEY(email_id,empresa_id) " +
"); " +
"create table hs_risco_empresa( " +
" risco_id int4 REFERENCES hs_risco(id), " +
" empresa_id int4 REFERENCES empresas(id), " +
" constraint hs_risco_empresa_pkey PRIMARY KEY(risco_id,empresa_id) " +
");"
);
executer.executeQuery( update );
}
}

@ -1,54 +0,0 @@
package siprp.update.updates;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.db.Executer;
/**
*
* @author fpalma
*/
public class V9_9_To_V10_0 extends AbstractUpdate
{
public V9_9_To_V10_0()
{
super(9.9,10.0,"extensao da definicao de 'relatorio de higiene e seguranca'");
}
@Override
public void doUpdate()
throws Exception
{
Executer executer = getExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"create table hs_relatorio_legislacao( " +
" hs_relatorio_id int4 REFERENCES hs_relatorio(id), " +
" hs_legislacao_id int4 REFERENCES hs_legislacao(id), " +
" CONSTRAINT hs_relatorio_legislacao_pkey PRIMARY KEY (hs_relatorio_id,hs_legislacao_id) " +
"); " +
"create table hs_relatorio_normalizacao( " +
" hs_relatorio_id int4 REFERENCES hs_relatorio(id), " +
" hs_normalizacao_id int4 REFERENCES hs_normalizacao(id), " +
" CONSTRAINT hs_relatorio_normalizacao_pkey PRIMARY KEY (hs_relatorio_id,hs_normalizacao_id) " +
"); " +
"create table hs_relatorio_equipamento_medico( " +
" hs_relatorio_id int4 REFERENCES hs_relatorio(id), " +
" hs_equipamento_medico_id int4 REFERENCES hs_equipamento_medico(id), " +
" CONSTRAINT hs_relatorio_equipamento_medico_pkey PRIMARY KEY (hs_relatorio_id,hs_equipamento_medico_id) " +
"); " +
"alter table hs_relatorio add column avaliacao_inicial boolean; " +
"alter table hs_relatorio add column acompanhante1 varchar(256); " +
"alter table hs_relatorio add column funcao_acompanhante1 varchar(128); " +
"alter table hs_relatorio add column acompanhante2 varchar(256); " +
"alter table hs_relatorio add column funcao_acompanhante2 varchar(128); " +
"alter table hs_relatorio add column acompanhante3 varchar(256); " +
"alter table hs_relatorio add column funcao_acompanhante3 varchar(128);" +
"alter table hs_relatorio_area add column relatorio_id int4 REFERENCES hs_relatorio(id) NOT NULL; " +
"alter table hs_posto_medida drop column is_plano_actuacao;" +
"alter table hs_relatorio_posto_medida add column is_plano_actuacao boolean; "
);
executer.executeQuery( update );
}
}
Loading…
Cancel
Save