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

lxbfYeaa
Diogo Neves 16 years ago
parent 875bc8ccb0
commit f10107c04f

@ -0,0 +1,39 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package db.entidades;
/**
*
* @author dneves
*/
public class EstadoMedida
{
private Integer id;
private String descricao;
public Integer getId()
{
return this.id;
}
public void setId( Integer id )
{
this.id = id;
}
public String getDescricao()
{
return this.descricao;
}
public void setDescricao( String desc )
{
this.descricao = desc;
}
}

@ -6,7 +6,6 @@
package db.entidades;
import java.util.List;
import java.util.Vector;
/**
*
@ -19,6 +18,7 @@ public class Medida {
private Integer risco_id;
private String descricao;
private String activa;
private Integer validarMedidaId = null;
private List<PostoTrabalho> postos;
public Integer getId() {
@ -76,4 +76,14 @@ public class Medida {
public void setMedida_id(Integer medida_id) {
this.medida_id = medida_id;
}
public Integer getValidarMedidaId()
{
return validarMedidaId;
}
public void setValidarMedidaId( Integer validarMedId )
{
validarMedidaId = validarMedId;
}
}

@ -6,6 +6,7 @@
package db.providers;
import db.entidades.Area;
import db.entidades.EstadoMedida;
import db.entidades.Medida;
import db.entidades.PlanoActuacao;
import db.entidades.PostoTrabalho;
@ -17,8 +18,8 @@ import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Vector;
import utils.Utils;
/**
@ -164,7 +165,7 @@ public class PlanosDataProvider extends GenericDataProvider{
sql += "WHERE id = " + p.getId();
System.out.println("SQL UPDATE PLANO : " + sql);
st.execute(sql);
st.execute(sql);
}
public void updateRisco(Risco r) throws Exception
@ -225,8 +226,28 @@ public class PlanosDataProvider extends GenericDataProvider{
sql += "verificacao_siprp = '" + r.getVerificacao_siprp() + "' ";
sql += "WHERE id = " + r.getId();
System.out.println("SQL UPDATE RISCO : " + sql);
st.execute(sql);
st.execute(sql);
}
public void updateMedidas( Risco risco ) throws Exception
{
Statement st = createStatement();
List< Medida > medidas = risco.getMedidas();
for ( Medida m : medidas )
{
Integer emID = null;
if ( m.getValidarMedidaId() != null && m.getValidarMedidaId().intValue() != 0 )
{
emID = m.getValidarMedidaId();
}
String sql = "UPDATE plano_medidas SET estado_medidas_id = " + emID +
" WHERE id = " + m.getId() + " AND risco_id = " + risco.getId();
System.out.println( "SQL UPDATE MEDIDAS : " + sql );
st.execute( sql );
}
}
public void updateValor(Valor v) throws Exception
{
@ -336,11 +357,12 @@ public class PlanosDataProvider extends GenericDataProvider{
{
Statement st = createStatement();
Integer newId = getMaxTableId("plano_medidas");
String sql = "insert into plano_medidas (id, medida_id, risco_id, descricao) values (";
String sql = "insert into plano_medidas (id, medida_id, risco_id, descricao, estado_medidas_id) values (";
sql += newId + ", ";
sql += m.getMedida_id() + ", ";
sql += m.getRisco_id() + ", '";
sql += m.getDescricao() + "' ";
sql += m.getDescricao() + "', ";
sql += m.getValidarMedidaId();
sql += ")";
System.out.println("SQL CREATE MEDIDA : " + sql);
@ -693,6 +715,7 @@ public class PlanosDataProvider extends GenericDataProvider{
//m.setValor_id(new Integer( rs.getInt("valor_id") ));
m.setDescricao(Utils.unicodeToHTML(rs.getString("descricao")));
m.setPostos(getPostosByMedida(m));
m.setValidarMedidaId( rs.getInt( "estado_medidas_id" ) );
medidas.add(m);
}while(rs.next());
}
@ -896,7 +919,29 @@ public class PlanosDataProvider extends GenericDataProvider{
System.out.println("SQL CREATE MEDIDA BY RISCO : " + sql);
st.execute(sql);
}
public List< EstadoMedida > getEstadoMedidas() throws Exception
{
Statement st = createStatement();
String sql = "SELECT * FROM estado_medidas WHERE activo = 'y' ORDER BY ordem ASC";
ResultSet rs = st.executeQuery( sql );
List< EstadoMedida > list = new Vector< EstadoMedida >();
while( rs.next() )
{
Integer ID = rs.getInt( "id" );
String desc = Utils.unicodeToHTML( rs.getString( "descricao" ) );
EstadoMedida estado = new EstadoMedida();
estado.setId( ID );
estado.setDescricao( desc );
list.add( estado );
}
return list;
}
public Medida getMedida(Integer medidaId) throws Exception
{
Medida m= null;

@ -7,16 +7,19 @@
package planosactuacao;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Anchor;
import com.sun.webui.jsf.component.Button;
import com.sun.webui.jsf.component.Calendar;
import com.sun.webui.jsf.component.Checkbox;
import com.sun.webui.jsf.component.DropDown;
import com.sun.webui.jsf.component.PanelGroup;
import com.sun.webui.jsf.component.StaticText;
import com.sun.webui.jsf.component.TextArea;
import com.sun.webui.jsf.component.TextField;
import com.sun.webui.jsf.model.Option;
import db.entidades.Area;
import db.entidades.EstadoMedida;
import db.entidades.Medida;
import db.entidades.PlanoActuacao;
import db.entidades.PostoTrabalho;
@ -101,7 +104,7 @@ public class EditarPlano extends AbstractPageBean {
TextArea txtParecerDns;
TextArea txtParecerDl;
TextArea txtVerificacaoSiprp;
public HtmlPanelGrid getGridLayout() {
return gridLayout;
@ -445,7 +448,7 @@ public class EditarPlano extends AbstractPageBean {
private void initialize(PlanoActuacao p)
{
{
//Test.showPlanoTree(p);
//getSessionBean1().setPaginationPageNr(1);
Pagination pagination = new Pagination(p);
@ -931,7 +934,8 @@ public class EditarPlano extends AbstractPageBean {
gridValor.getChildren().add(grd);
gridMedida = new HtmlPanelGrid();
gridMedida.setStyleClass("centerBlock");
gridMedida.setId( "gridMedida_" + m.getId() );
gridMedida.setStyleClass("centerBlock");
gridMedida.setWidth("98%");
gridMedida.setColumns(1);
gridMedida.setColumnClasses("gridColLeft");
@ -948,7 +952,53 @@ public class EditarPlano extends AbstractPageBean {
pg.getChildren().add(st);
gridMedida.getChildren().add(pg);
showPostos(m);
showPostos(m);
Utilizador u = getSessionBean1().getCurrentUser();
PlanoActuacao planoActual = getSessionBean1().getPlanoActuacao();
if ( planoActual.getFase().intValue() == Global.FASE_SIPRP_CONCLUSAO )
{
List< EstadoMedida > opts = null;
try
{
opts = pdp.getEstadoMedidas();
}
catch ( Exception e )
{
e.printStackTrace();
}
DropDown drop = new DropDown();
Option opt[] = null;
if ( opts != null )
{
opt = new Option[ (opts.size() + 1) ];
opt[ 0 ] = new Option( 0, "" );
for ( int i = 0; i < opts.size(); i++ )
{
EstadoMedida em = opts.get( i );
opt[ (i+1) ] = new Option( em.getId(), em.getDescricao() );
}
}
else
{
opt = new Option[ 1 ];
opt[ 0 ] = new Option( 0, "" );
}
drop.setItems( opt );
drop.setId( "drop_" + r.getId() + "_" + m.getId() );
drop.setSelected( m.getValidarMedidaId() == null ? 0 : m.getValidarMedidaId() );
StaticText dropLabel = new StaticText();
dropLabel.setText( "Validar Medida: " );
PanelGroup valPG = new PanelGroup();
valPG.setId( "valPG_" + m.getId() );
valPG.getChildren().add( dropLabel );
valPG.getChildren().add( drop );
gridMedida.getChildren().add( valPG );
}
}
}
@ -1099,7 +1149,7 @@ public class EditarPlano extends AbstractPageBean {
java.util.GregorianCalendar gcalendar = new java.util.GregorianCalendar();
gcalendar.set(2000,1,1);
dtInicio.setMinDate(gcalendar.getTime());
grd.getChildren().add(dtInicio);
grd.getChildren().add(dtInicio);
}
else
{
@ -1519,15 +1569,15 @@ public class EditarPlano extends AbstractPageBean {
{
p.setValidacao_hs(new Boolean(true));
}
}
}
}
pdp.updatePlano(p);
//Valor curValor = getSessionBean1().getCurrentValor();
Risco curValor = getSessionBean1().getCurrentRisco();
Risco curValor = getSessionBean1().getCurrentRisco();
curValor = fillValorFields(curValor);
// getSessionBean1().getValoresHash().remove(curValor.getId());
// getSessionBean1().getValoresHash().put(curValor.getId(), curValor);
// getSessionBean1().getValoresHash().put(curValor.getId(), curValor);
getSessionBean1().getRiscosHash().remove(curValor.getId());
getSessionBean1().getRiscosHash().put(curValor.getId(), curValor);
@ -1547,6 +1597,11 @@ public class EditarPlano extends AbstractPageBean {
Integer id = iter.next();
Risco r = valores.get(id);
pdp.updateRisco(r);
if ( fase == Global.FASE_SIPRP_CONCLUSAO )
{
pdp.updateMedidas( r );
}
}
}
@ -1617,7 +1672,7 @@ public class EditarPlano extends AbstractPageBean {
{
p.setValidacao_hs(new Boolean(true));
}
}
}
}
try
{
@ -1628,7 +1683,7 @@ public class EditarPlano extends AbstractPageBean {
ex.printStackTrace();
}
try
{
// Risco r = getSessionBean1().getCurrentRisco();
@ -1639,7 +1694,11 @@ public class EditarPlano extends AbstractPageBean {
Risco r = getSessionBean1().getCurrentRisco();
r = fillValorFields(r);
//pdp.updateValor(r);
pdp.updateRisco(r);
pdp.updateRisco(r);
if ( fase == Global.FASE_SIPRP_CONCLUSAO )
{
pdp.updateMedidas( r );
}
// getSessionBean1().getValoresHash().remove(r.getId());
// getSessionBean1().getValoresHash().put(r.getId(), r);
getSessionBean1().getRiscosHash().remove(r.getId());
@ -1792,8 +1851,22 @@ public class EditarPlano extends AbstractPageBean {
{
r.setVerificacao_siprp((String) txtVerificacaoSiprp.getText());
}
}
}
for( Medida m: r.getMedidas() )
{
gridMedida = (HtmlPanelGrid) gridArea.findComponent("form1:gridMedida_" + m.getId() );
PanelGroup gridValPG = ( PanelGroup ) gridMedida.findComponent( "valPG_" + m.getId() );
DropDown drop = ( DropDown ) gridValPG.findComponent("drop_" + r.getId() + "_" + m.getId());
if( drop != null )
{
Integer optID = ( Integer ) drop.getSelected();
m.setValidarMedidaId( optID.intValue() == 0 ? null : optID );
}
}
return r;
}

Loading…
Cancel
Save