forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@778 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
11056acbde
commit
87cdbf82bf
@ -0,0 +1,80 @@
|
|||||||
|
package siprp.update.updates;
|
||||||
|
|
||||||
|
import com.evolute.utils.Singleton;
|
||||||
|
import com.evolute.utils.db.DBManager;
|
||||||
|
import com.evolute.utils.db.Executer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author fpalma
|
||||||
|
*/
|
||||||
|
public class V9_4_To_V9_5
|
||||||
|
implements siprp.update.Update
|
||||||
|
{
|
||||||
|
|
||||||
|
public V9_4_To_V9_5()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public String []listChanges()
|
||||||
|
{
|
||||||
|
return new String[]{
|
||||||
|
"Refactorizacao do relatorio"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getStartVersion()
|
||||||
|
{
|
||||||
|
return 9.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getEndVersion()
|
||||||
|
{
|
||||||
|
return 9.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doUpdate()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
|
||||||
|
Executer executer = dbm.getSharedExecuter();
|
||||||
|
com.evolute.utils.sql.Update update =
|
||||||
|
new com.evolute.utils.sql.Update(
|
||||||
|
"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)" +
|
||||||
|
");"
|
||||||
|
);
|
||||||
|
executer.executeQuery( update );
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "v" + getStartVersion() + " para v" + getEndVersion();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
package siprp.update.updates;
|
||||||
|
|
||||||
|
import com.evolute.utils.Singleton;
|
||||||
|
import com.evolute.utils.db.DBManager;
|
||||||
|
import com.evolute.utils.db.Executer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author fpalma
|
||||||
|
*/
|
||||||
|
public class V9_5_To_V9_6
|
||||||
|
implements siprp.update.Update
|
||||||
|
{
|
||||||
|
|
||||||
|
public V9_5_To_V9_6()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public String []listChanges()
|
||||||
|
{
|
||||||
|
return new String[]{
|
||||||
|
"Relacao postoDeTrabalho <-> estabelecimento"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getStartVersion()
|
||||||
|
{
|
||||||
|
return 9.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getEndVersion()
|
||||||
|
{
|
||||||
|
return 9.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doUpdate()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
|
||||||
|
Executer executer = dbm.getSharedExecuter();
|
||||||
|
com.evolute.utils.sql.Update update =
|
||||||
|
new com.evolute.utils.sql.Update(
|
||||||
|
"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)" +
|
||||||
|
");"
|
||||||
|
);
|
||||||
|
executer.executeQuery( update );
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "v" + getStartVersion() + " para v" + getEndVersion();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,62 @@
|
|||||||
|
package siprp.update.updates;
|
||||||
|
|
||||||
|
import com.evolute.utils.Singleton;
|
||||||
|
import com.evolute.utils.db.DBManager;
|
||||||
|
import com.evolute.utils.db.Executer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author fpalma
|
||||||
|
*/
|
||||||
|
public class V9_6_To_V9_7
|
||||||
|
implements siprp.update.Update
|
||||||
|
{
|
||||||
|
|
||||||
|
public V9_6_To_V9_7()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public String []listChanges()
|
||||||
|
{
|
||||||
|
return new String[]{
|
||||||
|
"Relacao postoDeTrabalho <-> medida"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getStartVersion()
|
||||||
|
{
|
||||||
|
return 9.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getEndVersion()
|
||||||
|
{
|
||||||
|
return 9.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doUpdate()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
|
||||||
|
Executer executer = dbm.getSharedExecuter();
|
||||||
|
com.evolute.utils.sql.Update update =
|
||||||
|
new com.evolute.utils.sql.Update(
|
||||||
|
"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)" +
|
||||||
|
");"
|
||||||
|
);
|
||||||
|
executer.executeQuery( update );
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "v" + getStartVersion() + " para v" + getEndVersion();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,64 @@
|
|||||||
|
package siprp.update.updates;
|
||||||
|
|
||||||
|
import com.evolute.utils.Singleton;
|
||||||
|
import com.evolute.utils.db.DBManager;
|
||||||
|
import com.evolute.utils.db.Executer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author fpalma
|
||||||
|
*/
|
||||||
|
public class V9_7_To_V9_8
|
||||||
|
implements siprp.update.Update
|
||||||
|
{
|
||||||
|
|
||||||
|
public V9_7_To_V9_8()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public String []listChanges()
|
||||||
|
{
|
||||||
|
return new String[]{
|
||||||
|
"Relacao postoDeTrabalho <-> risco"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getStartVersion()
|
||||||
|
{
|
||||||
|
return 9.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getEndVersion()
|
||||||
|
{
|
||||||
|
return 9.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doUpdate()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
|
||||||
|
Executer executer = dbm.getSharedExecuter();
|
||||||
|
com.evolute.utils.sql.Update update =
|
||||||
|
new com.evolute.utils.sql.Update(
|
||||||
|
"create table 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');"
|
||||||
|
);
|
||||||
|
executer.executeQuery( update );
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "v" + getStartVersion() + " para v" + getEndVersion();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue