|
|
/*
|
|
|
* PlanoActuacao.java
|
|
|
*
|
|
|
* Created on Aug 26, 2008, 3:10:59 PM
|
|
|
*/
|
|
|
|
|
|
package planosactuacao;
|
|
|
|
|
|
import com.sun.rave.web.ui.appbase.AbstractPageBean;
|
|
|
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 com.sun.webui.jsf.model.SingleSelectOptionsList;
|
|
|
import db.entidades.Medida;
|
|
|
import db.entidades.PlanoActuacao;
|
|
|
import db.entidades.PostoTrabalho;
|
|
|
import db.entidades.Risco;
|
|
|
import db.entidades.Utilizador;
|
|
|
import db.providers.PlanosDataProvider;
|
|
|
import global.Global;
|
|
|
import java.util.Vector;
|
|
|
import javax.faces.FacesException;
|
|
|
import javax.faces.component.html.HtmlInputHidden;
|
|
|
import javax.faces.component.html.HtmlPanelGrid;
|
|
|
import javax.faces.context.FacesContext;
|
|
|
import javax.faces.event.ValueChangeEvent;
|
|
|
import mail.Mail;
|
|
|
import utils.JSFUtils;
|
|
|
|
|
|
/**
|
|
|
* <p>Page bean that corresponds to a similarly named JSP page. This
|
|
|
* class contains component definitions (and initialization code) for
|
|
|
* all components that you have defined on this page, as well as
|
|
|
* lifecycle methods and event handlers where you may add behavior
|
|
|
* to respond to incoming events.</p>
|
|
|
*
|
|
|
* @author lluis
|
|
|
*/
|
|
|
public class EditarPlano extends AbstractPageBean {
|
|
|
// <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
|
|
|
|
|
|
/**
|
|
|
* <p>Automatically managed component initialization. <strong>WARNING:</strong>
|
|
|
* This method is automatically generated, so any user-specified code inserted
|
|
|
* here is subject to being replaced.</p>
|
|
|
*/
|
|
|
private void _init() throws Exception {
|
|
|
}
|
|
|
|
|
|
// </editor-fold>
|
|
|
HtmlPanelGrid grid;
|
|
|
PanelGroup pg;
|
|
|
StaticText st;
|
|
|
private HtmlPanelGrid gridLayout = new HtmlPanelGrid();
|
|
|
|
|
|
//Plano actuacao
|
|
|
PlanoActuacao plano;
|
|
|
Vector<Medida> medidas = new Vector<Medida>();
|
|
|
Vector<Risco> riscos = new Vector<Risco>();
|
|
|
Vector<PostoTrabalho> postos = new Vector<PostoTrabalho>();
|
|
|
|
|
|
HtmlPanelGrid gridPlano = new HtmlPanelGrid();
|
|
|
HtmlPanelGrid gridRisco;
|
|
|
|
|
|
|
|
|
|
|
|
int risco_id = 0;
|
|
|
int medida_id = 0;
|
|
|
int posto_id = 0;
|
|
|
|
|
|
//page components
|
|
|
TextField txtResponsavelExecucao;
|
|
|
TextArea txtRecursos;
|
|
|
Calendar dtInicio;
|
|
|
Calendar dtFim;
|
|
|
|
|
|
public HtmlPanelGrid getGridLayout() {
|
|
|
return gridLayout;
|
|
|
}
|
|
|
|
|
|
public void setGridLayout(HtmlPanelGrid hpg) {
|
|
|
this.gridLayout = hpg;
|
|
|
}
|
|
|
private Button butGravarPlano = new Button();
|
|
|
|
|
|
public Button getButGravarPlano() {
|
|
|
return butGravarPlano;
|
|
|
}
|
|
|
|
|
|
public void setButGravarPlano(Button b) {
|
|
|
this.butGravarPlano = b;
|
|
|
}
|
|
|
private Button butGravarRisco = new Button();
|
|
|
|
|
|
public Button getButGravarRisco() {
|
|
|
return butGravarRisco;
|
|
|
}
|
|
|
|
|
|
public void setButGravarRisco(Button b) {
|
|
|
this.butGravarRisco = b;
|
|
|
}
|
|
|
private Button butEnviar = new Button();
|
|
|
|
|
|
public Button getButEnviar() {
|
|
|
return butEnviar;
|
|
|
}
|
|
|
|
|
|
public void setButEnviar(Button b) {
|
|
|
this.butEnviar = b;
|
|
|
}
|
|
|
private Button butLimparDados = new Button();
|
|
|
|
|
|
public Button getButLimparDados() {
|
|
|
return butLimparDados;
|
|
|
}
|
|
|
|
|
|
public void setButLimparDados(Button b) {
|
|
|
this.butLimparDados = b;
|
|
|
}
|
|
|
private Button butCancelar = new Button();
|
|
|
|
|
|
public Button getButCancelar() {
|
|
|
return butCancelar;
|
|
|
}
|
|
|
|
|
|
public void setButCancelar(Button b) {
|
|
|
this.butCancelar = b;
|
|
|
}
|
|
|
private StaticText lblMsg = new StaticText();
|
|
|
|
|
|
public StaticText getLblMsg() {
|
|
|
return lblMsg;
|
|
|
}
|
|
|
|
|
|
public void setLblMsg(StaticText st) {
|
|
|
this.lblMsg = st;
|
|
|
}
|
|
|
private HtmlPanelGrid gridValidar = new HtmlPanelGrid();
|
|
|
|
|
|
public HtmlPanelGrid getGridValidar() {
|
|
|
return gridValidar;
|
|
|
}
|
|
|
|
|
|
public void setGridValidar(HtmlPanelGrid hpg) {
|
|
|
this.gridValidar = hpg;
|
|
|
}
|
|
|
private Checkbox chkValidacao = new Checkbox();
|
|
|
|
|
|
public Checkbox getChkValidacao() {
|
|
|
return chkValidacao;
|
|
|
}
|
|
|
|
|
|
public void setChkValidacao(Checkbox c) {
|
|
|
this.chkValidacao = c;
|
|
|
}
|
|
|
private HtmlPanelGrid gridParecer = new HtmlPanelGrid();
|
|
|
|
|
|
public HtmlPanelGrid getGridParecer() {
|
|
|
return gridParecer;
|
|
|
}
|
|
|
|
|
|
public void setGridParecer(HtmlPanelGrid hpg) {
|
|
|
this.gridParecer = hpg;
|
|
|
}
|
|
|
private TextArea txtParecer = new TextArea();
|
|
|
|
|
|
public TextArea getTxtParecer() {
|
|
|
return txtParecer;
|
|
|
}
|
|
|
|
|
|
public void setTxtParecer(TextArea ta) {
|
|
|
this.txtParecer = ta;
|
|
|
}
|
|
|
private HtmlInputHidden hidValidacao = new HtmlInputHidden();
|
|
|
|
|
|
public HtmlInputHidden getHidValidacao() {
|
|
|
return hidValidacao;
|
|
|
}
|
|
|
|
|
|
public void setHidValidacao(HtmlInputHidden hih) {
|
|
|
this.hidValidacao = hih;
|
|
|
}
|
|
|
private StaticText stIrPara = new StaticText();
|
|
|
|
|
|
public StaticText getStIrPara() {
|
|
|
return stIrPara;
|
|
|
}
|
|
|
|
|
|
public void setStIrPara(StaticText st) {
|
|
|
this.stIrPara = st;
|
|
|
}
|
|
|
private DropDown drpIrPara = new DropDown();
|
|
|
|
|
|
public DropDown getDrpIrPara() {
|
|
|
return drpIrPara;
|
|
|
}
|
|
|
|
|
|
public void setDrpIrPara(DropDown dd) {
|
|
|
this.drpIrPara = dd;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* <p>Construct a new Page bean instance.</p>
|
|
|
*/
|
|
|
public EditarPlano() {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* <p>Callback method that is called whenever a page is navigated to,
|
|
|
* either directly via a URL, or indirectly via page navigation.
|
|
|
* Customize this method to acquire resources that will be needed
|
|
|
* for event handlers and lifecycle methods, whether or not this
|
|
|
* page is performing post back processing.</p>
|
|
|
*
|
|
|
* <p>Note that, if the current request is a postback, the property
|
|
|
* values of the components do <strong>not</strong> represent any
|
|
|
* values submitted with this request. Instead, they represent the
|
|
|
* property values that were saved for this view when it was rendered.</p>
|
|
|
*/
|
|
|
@Override
|
|
|
public void init() {
|
|
|
// Perform initializations inherited from our superclass
|
|
|
super.init();
|
|
|
// Perform application initialization that must complete
|
|
|
// *before* managed components are initialized
|
|
|
// TODO - add your own initialiation code here
|
|
|
|
|
|
// <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
|
|
|
// Initialize automatically managed components
|
|
|
// *Note* - this logic should NOT be modified
|
|
|
try {
|
|
|
_init();
|
|
|
} catch (Exception e) {
|
|
|
log("PlanoActuacao Initialization Failure", e);
|
|
|
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
|
|
|
}
|
|
|
|
|
|
// </editor-fold>
|
|
|
// Perform application initialization that must complete
|
|
|
// *after* managed components are initialized
|
|
|
// TODO - add your own initialization code here
|
|
|
Utilizador u = getSessionBean1().getCurrentUser();
|
|
|
if(u.getTipo().intValue() != Global.DIRECTOR_NACIONAL_SEGURANCA)
|
|
|
{
|
|
|
stIrPara.setStyleClass("hidden");
|
|
|
drpIrPara.setStyleClass("hidden");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* <p>Callback method that is called after the component tree has been
|
|
|
* restored, but before any event processing takes place. This method
|
|
|
* will <strong>only</strong> be called on a postback request that
|
|
|
* is processing a form submit. Customize this method to allocate
|
|
|
* resources that will be required in your event handlers.</p>
|
|
|
*/
|
|
|
@Override
|
|
|
public void preprocess() {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* <p>Callback method that is called just before rendering takes place.
|
|
|
* This method will <strong>only</strong> be called for the page that
|
|
|
* will actually be rendered (and not, for example, on a page that
|
|
|
* handled a postback and then navigated to a different page). Customize
|
|
|
* this method to allocate resources that will be required for rendering
|
|
|
* this page.</p>
|
|
|
*/
|
|
|
@Override
|
|
|
public void prerender() {
|
|
|
System.out.println("PRERENDER");
|
|
|
FacesContext fc = getFacesContext();
|
|
|
//boolean isPostback = JSFUtils.isPostBack12(fc);
|
|
|
//boolean isPostback = JSFUtils.isPostBack(fc);
|
|
|
boolean isPostback = JSFUtils.isPostback();
|
|
|
System.out.println("POSTBACK : " + isPostback);
|
|
|
if(!isPostback)
|
|
|
{
|
|
|
initializePlano();
|
|
|
initialize();
|
|
|
fillPlano();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
riscos = getSessionBean1().getRiscos();
|
|
|
medidas = getSessionBean1().getMedidas();
|
|
|
postos = getSessionBean1().getPostos();
|
|
|
}
|
|
|
|
|
|
lblMsg.setText(getSessionBean1().getMsg());
|
|
|
getSessionBean1().setMsg("");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* <p>Callback method that is called after rendering is completed for
|
|
|
* this request, if <code>init()</code> was called (regardless of whether
|
|
|
* or not this was the page that was actually rendered). Customize this
|
|
|
* method to release resources acquired in the <code>init()</code>,
|
|
|
* <code>preprocess()</code>, or <code>prerender()</code> methods (or
|
|
|
* acquired during execution of an event handler).</p>
|
|
|
*/
|
|
|
@Override
|
|
|
public void destroy() {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* <p>Return a reference to the scoped data bean.</p>
|
|
|
*
|
|
|
* @return reference to the scoped data bean
|
|
|
*/
|
|
|
protected RequestBean1 getRequestBean1() {
|
|
|
return (RequestBean1) getBean("RequestBean1");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* <p>Return a reference to the scoped data bean.</p>
|
|
|
*
|
|
|
* @return reference to the scoped data bean
|
|
|
*/
|
|
|
protected SessionBean1 getSessionBean1() {
|
|
|
return (SessionBean1) getBean("SessionBean1");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* <p>Return a reference to the scoped data bean.</p>
|
|
|
*
|
|
|
* @return reference to the scoped data bean
|
|
|
*/
|
|
|
protected ApplicationBean1 getApplicationBean1() {
|
|
|
return (ApplicationBean1) getBean("ApplicationBean1");
|
|
|
}
|
|
|
|
|
|
public String hyperlink1_action() {
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
// case name where null will return to the same page.
|
|
|
return "lista_planos";
|
|
|
}
|
|
|
|
|
|
private void fillPlano()
|
|
|
{
|
|
|
String indent = " ";
|
|
|
Risco r = getNextRisco(plano.getId());
|
|
|
fillRisco(r);
|
|
|
}
|
|
|
|
|
|
private void fillRisco(Risco r)
|
|
|
{
|
|
|
String indent = " ";
|
|
|
if(gridLayout.getChildren().size() > 0)
|
|
|
{
|
|
|
gridLayout.getChildren().clear();
|
|
|
}
|
|
|
gridRisco = new HtmlPanelGrid();
|
|
|
gridRisco.setWidth("100%");
|
|
|
gridRisco.setStyle("border: solid 1px #000000");
|
|
|
gridRisco.setColumns(1);
|
|
|
gridRisco.setColumnClasses("gridColLeft");
|
|
|
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setStyle("color: #2c4d7a");
|
|
|
st.setText("RISCO 1" + ": ");
|
|
|
pg.getChildren().add(st);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(r.getDescricao());
|
|
|
pg.getChildren().add(st);
|
|
|
gridRisco.getChildren().add(pg);
|
|
|
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(" ");
|
|
|
gridRisco.getChildren().add(st);
|
|
|
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Valor:" + " ");
|
|
|
pg.getChildren().add(st);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(r.getValor().toString());
|
|
|
pg.getChildren().add(st);
|
|
|
gridRisco.getChildren().add(pg);
|
|
|
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(" ");
|
|
|
gridRisco.getChildren().add(st);
|
|
|
|
|
|
//medidas
|
|
|
Vector<Medida> meds = getMedidas(r.getId());
|
|
|
for(int i = 0; i < meds.size(); i++)
|
|
|
{
|
|
|
Medida m = medidas.get(i);
|
|
|
if(m.getRisco_id().intValue() == r.getId().intValue())
|
|
|
{
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText(indent + "Medida" + ": ");
|
|
|
pg.getChildren().add(st);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(m.getDescricao());
|
|
|
pg.getChildren().add(st);
|
|
|
gridRisco.getChildren().add(pg);
|
|
|
|
|
|
//postos trabalho
|
|
|
Vector<PostoTrabalho> posts = getPostosTrabalho(m.getId());
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText(indent + indent + "Postos de trabalho afectados" + ": ");
|
|
|
pg.getChildren().add(st);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
String spostos = "";
|
|
|
for(int j = 0; j < posts.size(); j++)
|
|
|
{
|
|
|
PostoTrabalho p = posts.get(j);
|
|
|
spostos += p.getDescricao(); // + " ";
|
|
|
if(j < (posts.size() -1) )
|
|
|
{
|
|
|
spostos += "; ";
|
|
|
}
|
|
|
}
|
|
|
st.setText(spostos);
|
|
|
pg.getChildren().add(st);
|
|
|
gridRisco.getChildren().add(pg);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(" ");
|
|
|
gridRisco.getChildren().add(st);
|
|
|
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Responsável de execução:");
|
|
|
pg.getChildren().add(st);
|
|
|
txtResponsavelExecucao = new TextField();
|
|
|
txtResponsavelExecucao.setColumns(100);
|
|
|
pg.getChildren().add(txtResponsavelExecucao);
|
|
|
gridRisco.getChildren().add(pg);
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Recursos necessários à implementação da medida:");
|
|
|
pg.getChildren().add(st);
|
|
|
gridRisco.getChildren().add(pg);
|
|
|
txtRecursos = new TextArea();
|
|
|
txtRecursos.setColumns(200);
|
|
|
gridRisco.getChildren().add(txtRecursos);
|
|
|
|
|
|
HtmlPanelGrid grd = new HtmlPanelGrid();
|
|
|
grd.setColumns(2);
|
|
|
grd.setColumnClasses("gridCol15, gridCol85");
|
|
|
grd.setId("pgDtInicio");
|
|
|
grd.setStyle("width: 100%");
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Data prevista de início:");
|
|
|
grd.getChildren().add(st);
|
|
|
dtInicio = new Calendar();
|
|
|
grd.getChildren().add(dtInicio);
|
|
|
gridRisco.getChildren().add(grd);
|
|
|
|
|
|
grd = new HtmlPanelGrid();
|
|
|
grd.setColumns(2);
|
|
|
grd.setColumnClasses("gridCol15, gridCol85");
|
|
|
grd.setId("pgDtFim");
|
|
|
grd.setStyle("width: 100%");
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Data prevista de conclusão:");
|
|
|
grd.getChildren().add(st);
|
|
|
dtFim = new Calendar();
|
|
|
|
|
|
grd.getChildren().add(dtFim);
|
|
|
gridRisco.getChildren().add(grd);
|
|
|
|
|
|
gridLayout.getChildren().add(gridRisco);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void initializePlano()
|
|
|
{
|
|
|
getSessionBean1().setRiscosIdx(0);
|
|
|
//plano
|
|
|
plano = new PlanoActuacao();
|
|
|
plano.setId(new Integer(1));
|
|
|
plano.setEstabelecimento_id(new Integer(1));
|
|
|
plano.setFase(new Integer(1));
|
|
|
getSessionBean1().setPlanoId(new Integer(1));
|
|
|
plano.setDescricao("Plano 1");
|
|
|
|
|
|
//riscos
|
|
|
Risco r = new Risco();
|
|
|
r.setId(new Integer(1));
|
|
|
r.setPlano_id(new Integer(1));
|
|
|
r.setDescricao("Risco A");
|
|
|
r.setValor(new Integer(4));
|
|
|
riscos.add(r);
|
|
|
|
|
|
r = new Risco();
|
|
|
r.setId(new Integer(2));
|
|
|
r.setPlano_id(new Integer(1));
|
|
|
r.setDescricao("Risco B");
|
|
|
r.setValor(new Integer(6));
|
|
|
riscos.add(r);
|
|
|
|
|
|
r = new Risco();
|
|
|
r.setId(new Integer(3));
|
|
|
r.setPlano_id(new Integer(1));
|
|
|
r.setDescricao("Risco C");
|
|
|
r.setValor(new Integer(12));
|
|
|
riscos.add(r);
|
|
|
|
|
|
//medidas
|
|
|
Medida m = new Medida();
|
|
|
m.setId(new Integer(1));
|
|
|
m.setRisco_id(new Integer(1));
|
|
|
m.setDescricao("Medida a");
|
|
|
medidas.add(m);
|
|
|
|
|
|
m = new Medida();
|
|
|
m.setId(new Integer(2));
|
|
|
m.setRisco_id(new Integer(1));
|
|
|
m.setDescricao("Medida b");
|
|
|
medidas.add(m);
|
|
|
|
|
|
m = new Medida();
|
|
|
m.setId(new Integer(3));
|
|
|
m.setRisco_id(new Integer(2));
|
|
|
m.setDescricao("Medida c");
|
|
|
medidas.add(m);
|
|
|
|
|
|
m = new Medida();
|
|
|
m.setId(new Integer(4));
|
|
|
m.setRisco_id(new Integer(2));
|
|
|
m.setDescricao("Medida d");
|
|
|
medidas.add(m);
|
|
|
|
|
|
m = new Medida();
|
|
|
m.setId(new Integer(5));
|
|
|
m.setRisco_id(new Integer(2));
|
|
|
m.setDescricao("Medida e");
|
|
|
medidas.add(m);
|
|
|
|
|
|
m = new Medida();
|
|
|
m.setId(new Integer(6));
|
|
|
m.setRisco_id(new Integer(3));
|
|
|
m.setDescricao("Medida f");
|
|
|
medidas.add(m);
|
|
|
|
|
|
m = new Medida();
|
|
|
m.setId(new Integer(7));
|
|
|
m.setRisco_id(new Integer(3));
|
|
|
m.setDescricao("Medida g");
|
|
|
medidas.add(m);
|
|
|
|
|
|
//postos trabalho
|
|
|
PostoTrabalho p = new PostoTrabalho();
|
|
|
p.setId(new Integer(1));
|
|
|
p.setMedida_id(new Integer(1));
|
|
|
p.setDescricao("posto 1");
|
|
|
postos.add(p);
|
|
|
|
|
|
p = new PostoTrabalho();
|
|
|
p.setId(new Integer(2));
|
|
|
p.setMedida_id(new Integer(1));
|
|
|
p.setDescricao("posto 2");
|
|
|
postos.add(p);
|
|
|
|
|
|
p = new PostoTrabalho();
|
|
|
p.setId(new Integer(3));
|
|
|
p.setMedida_id(new Integer(1));
|
|
|
p.setDescricao("posto 3");
|
|
|
postos.add(p);
|
|
|
|
|
|
p = new PostoTrabalho();
|
|
|
p.setId(new Integer(4));
|
|
|
p.setMedida_id(new Integer(2));
|
|
|
p.setDescricao("posto 4");
|
|
|
postos.add(p);
|
|
|
|
|
|
p = new PostoTrabalho();
|
|
|
p.setId(new Integer(5));
|
|
|
p.setMedida_id(new Integer(2));
|
|
|
p.setDescricao("posto 5");
|
|
|
postos.add(p);
|
|
|
|
|
|
p = new PostoTrabalho();
|
|
|
p.setId(new Integer(6));
|
|
|
p.setMedida_id(new Integer(3));
|
|
|
p.setDescricao("posto 6");
|
|
|
postos.add(p);
|
|
|
|
|
|
p = new PostoTrabalho();
|
|
|
p.setId(new Integer(7));
|
|
|
p.setMedida_id(new Integer(3));
|
|
|
p.setDescricao("posto 7");
|
|
|
postos.add(p);
|
|
|
|
|
|
p = new PostoTrabalho();
|
|
|
p.setId(new Integer(8));
|
|
|
p.setMedida_id(new Integer(4));
|
|
|
p.setDescricao("posto 8");
|
|
|
postos.add(p);
|
|
|
|
|
|
p = new PostoTrabalho();
|
|
|
p.setId(new Integer(9));
|
|
|
p.setMedida_id(new Integer(4));
|
|
|
p.setDescricao("posto 9");
|
|
|
postos.add(p);
|
|
|
|
|
|
p = new PostoTrabalho();
|
|
|
p.setId(new Integer(10));
|
|
|
p.setMedida_id(new Integer(5));
|
|
|
p.setDescricao("posto 10");
|
|
|
postos.add(p);
|
|
|
|
|
|
p = new PostoTrabalho();
|
|
|
p.setId(new Integer(11));
|
|
|
p.setMedida_id(new Integer(5));
|
|
|
p.setDescricao("posto 11");
|
|
|
postos.add(p);
|
|
|
|
|
|
p = new PostoTrabalho();
|
|
|
p.setId(new Integer(12));
|
|
|
p.setMedida_id(new Integer(6));
|
|
|
p.setDescricao("posto 12");
|
|
|
postos.add(p);
|
|
|
|
|
|
p = new PostoTrabalho();
|
|
|
p.setId(new Integer(13));
|
|
|
p.setMedida_id(new Integer(6));
|
|
|
p.setDescricao("posto 13");
|
|
|
postos.add(p);
|
|
|
|
|
|
p = new PostoTrabalho();
|
|
|
p.setId(new Integer(14));
|
|
|
p.setMedida_id(new Integer(7));
|
|
|
p.setDescricao("posto 14");
|
|
|
postos.add(p);
|
|
|
|
|
|
p = new PostoTrabalho();
|
|
|
p.setId(new Integer(15));
|
|
|
p.setMedida_id(new Integer(7));
|
|
|
p.setDescricao("posto 15");
|
|
|
postos.add(p);
|
|
|
getSessionBean1().setRiscos(riscos);
|
|
|
getSessionBean1().setMedidas(medidas);
|
|
|
getSessionBean1().setPostos(postos);
|
|
|
}
|
|
|
|
|
|
private Risco getNextRisco(Integer planoId)
|
|
|
{
|
|
|
System.out.println("GET NEXT RISCO");
|
|
|
System.out.println("RISCOS SIZE : " + riscos.size());
|
|
|
riscos = getSessionBean1().getRiscos();
|
|
|
risco_id = getSessionBean1().getRiscosIdx();
|
|
|
Risco r = riscos.get(risco_id);
|
|
|
if(r != null)
|
|
|
{
|
|
|
if(r.getPlano_id().intValue() != planoId.intValue())
|
|
|
{
|
|
|
r = null;
|
|
|
risco_id = 0;
|
|
|
}
|
|
|
}
|
|
|
risco_id++;
|
|
|
getSessionBean1().setRiscosIdx(risco_id);
|
|
|
return r;
|
|
|
}
|
|
|
|
|
|
private Vector<Medida> getMedidas(Integer riscoId)
|
|
|
{
|
|
|
Vector<Medida> meds = new Vector<Medida>();
|
|
|
medidas = getSessionBean1().getMedidas();
|
|
|
for(int i = 0; i < medidas.size(); i++)
|
|
|
{
|
|
|
Medida m = medidas.get(i);
|
|
|
if(m.getRisco_id().intValue() == riscoId.intValue())
|
|
|
{
|
|
|
meds.add(m);
|
|
|
}
|
|
|
}
|
|
|
return meds;
|
|
|
}
|
|
|
|
|
|
private Vector<PostoTrabalho> getPostosTrabalho(Integer medidaId)
|
|
|
{
|
|
|
Vector<PostoTrabalho> posts = new Vector<PostoTrabalho>();
|
|
|
postos = getSessionBean1().getPostos();
|
|
|
for(int i = 0; i < postos.size(); i++)
|
|
|
{
|
|
|
PostoTrabalho p = postos.get(i);
|
|
|
if(p.getMedida_id().intValue() == medidaId.intValue())
|
|
|
{
|
|
|
posts.add(p);
|
|
|
}
|
|
|
}
|
|
|
return posts;
|
|
|
}
|
|
|
|
|
|
private void initialize()
|
|
|
{
|
|
|
Utilizador u = getSessionBean1().getCurrentUser();
|
|
|
if(u.getTipo().intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA)
|
|
|
{
|
|
|
hidValidacao.setValue("dns");
|
|
|
}
|
|
|
else if(u.getTipo().intValue() == Global.DIRECTOR_LOJA)
|
|
|
{
|
|
|
hidValidacao.setValue("dir_loja");
|
|
|
}
|
|
|
|
|
|
//gridValidar.setStyleClass("hidden");
|
|
|
|
|
|
//System.out.println("VISIBILITY : " + gridValidar.getStyleClass());
|
|
|
//System.out.println("USER TYPE : " + u.getTipo().intValue());
|
|
|
if(u.getTipo().intValue() != Global.DIRECTOR_LOJA && u.getTipo().intValue() != Global.DIRECTOR_NACIONAL_SEGURANCA)
|
|
|
{
|
|
|
//gridValidar.setStyleClass("visible");
|
|
|
//System.out.println("VISIBILITY B : " + gridValidar.getStyleClass());
|
|
|
gridValidar.setRendered(false);
|
|
|
//txtParecer.setStyleClass("hidden");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//txtParecer.setRendered(false);
|
|
|
gridParecer.setStyleClass("hidden");
|
|
|
}
|
|
|
// else
|
|
|
// {
|
|
|
// if(u.getTipo().intValue() != Global.DIRECTOR_NACIONAL_SEGURANCA)
|
|
|
// {
|
|
|
// //txtParecer.setStyleClass("visible");
|
|
|
// txtParecer.setRendered(false);
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
PlanoActuacao p = getSessionBean1().getPlanoActuacao();
|
|
|
int fase = p.getFase().intValue();
|
|
|
|
|
|
switch(fase)
|
|
|
{
|
|
|
case Global.FASE_SEGURANCA_PREENCHIMENTO:
|
|
|
butEnviar.setText("Enviar a Director de Loja>>");
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DIR_LOJA_VALIDACAO:
|
|
|
//butEnviar.setText("Enviar a Director de Loja");
|
|
|
butEnviar.setText("Enviar para Respons<6E>vel de Seguran<61>a>>");
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DNS_PARECER:
|
|
|
com.sun.webui.jsf.model.Option[] listOptions = new com.sun.webui.jsf.model.Option[2];
|
|
|
|
|
|
listOptions[0] = new Option(new Integer(Global.FASE_SEGURANCA_PREENCHIMENTO), "Respons<6E>vel de seguran<61>a");
|
|
|
listOptions[1] = new Option(new Integer(Global.FASE_DIR_LOJA_VALIDACAO), "Director de loja");
|
|
|
drpIrPara.setItems(listOptions);
|
|
|
drpIrPara.setSelected(new Integer( Global.FASE_SEGURANCA_PREENCHIMENTO ));
|
|
|
butEnviar.setText("Enviar para Respons<6E>vel de seguran<61>a>>");
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_SIPRP_CONCLUSAO:
|
|
|
butEnviar.setText("Concluir");
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
gridPlano.setWidth("100%");
|
|
|
gridPlano.setColumns(1);
|
|
|
gridPlano.setColumnClasses("gridColCenter");
|
|
|
//plano
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setStyle("font-size: 16px");
|
|
|
st.setText(plano.getDescricao());
|
|
|
gridPlano.getChildren().add(st);
|
|
|
|
|
|
gridLayout.getChildren().add(gridPlano);
|
|
|
}
|
|
|
|
|
|
public String butGravarPlano_action() {
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
// case name where null will return to the same page.
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
public String butGravarRisco_action() {
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
// case name where null will return to the same page.
|
|
|
System.out.println("BUT NEXT RISCO");
|
|
|
Risco r = getNextRisco(getSessionBean1().getPlanoId());
|
|
|
fillRisco(r);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
public String butEnviar_action() {
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
// case name where null will return to the same page.
|
|
|
try
|
|
|
{
|
|
|
processEnviar();
|
|
|
return "lista_planos";
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
getSessionBean1().setMsg("Erro no envio do Plano");
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
private void processEnviar() throws Exception
|
|
|
{
|
|
|
boolean processo_validado = true;
|
|
|
int dns_next_fase = 2;
|
|
|
|
|
|
PlanoActuacao p = getSessionBean1().getPlanoActuacao();
|
|
|
//dummy : later on get fase from plano
|
|
|
//int fase = getSessionBean1().getFase();
|
|
|
int fase = p.getFase().intValue();
|
|
|
switch(fase)
|
|
|
{
|
|
|
// case Global.FASE_SIPRP_EMISSAO:
|
|
|
// break;
|
|
|
|
|
|
case Global.FASE_SEGURANCA_PREENCHIMENTO:
|
|
|
case Global.FASE_SIPRP_CONCLUSAO:
|
|
|
fase++;
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DIR_LOJA_VALIDACAO:
|
|
|
Boolean validacao = (Boolean)chkValidacao.getSelected();
|
|
|
if(validacao == null)
|
|
|
{
|
|
|
processo_validado = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
processo_validado = false;
|
|
|
if(validacao.booleanValue())
|
|
|
{
|
|
|
processo_validado = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(processo_validado)
|
|
|
{
|
|
|
fase++;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
fase = Global.FASE_SEGURANCA_PREENCHIMENTO; //fase 2
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DNS_PARECER:
|
|
|
validacao = (Boolean)chkValidacao.getSelected();
|
|
|
if(validacao == null)
|
|
|
{
|
|
|
processo_validado = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
processo_validado = false;
|
|
|
if(validacao.booleanValue())
|
|
|
{
|
|
|
processo_validado = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(processo_validado)
|
|
|
{
|
|
|
fase++;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Integer irPara = (Integer)drpIrPara.getSelected();
|
|
|
dns_next_fase = irPara.intValue();
|
|
|
fase = dns_next_fase;
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
//dummy : later on will update db with new fase
|
|
|
//getSessionBean1().setFase(fase);
|
|
|
PlanosDataProvider pdp = new PlanosDataProvider();
|
|
|
p.setFase(new Integer(fase));
|
|
|
pdp.updatePlano(p);
|
|
|
|
|
|
enviarMail(fase);
|
|
|
}
|
|
|
|
|
|
public void enviarMail(int fase)
|
|
|
{
|
|
|
String assunto = "";
|
|
|
String mail_text = "";
|
|
|
|
|
|
switch(fase)
|
|
|
{
|
|
|
// case Global.FASE_SIPRP_EMISSAO:
|
|
|
// break;
|
|
|
|
|
|
case Global.FASE_SEGURANCA_PREENCHIMENTO:
|
|
|
assunto = "PLANOS - SEGURAN<41>A (PREENCHIMENTO)";
|
|
|
mail_text = "Notifica-se que o Plano passou para a fase Seguran<61>a(Preenchimento)";
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DIR_LOJA_VALIDACAO:
|
|
|
assunto = "PLANOS - DIRECTOR LOJA (VALIDA<44><41>O)";
|
|
|
mail_text = "Notifica-se que o Plano passou para a fase Director de Loja(Valida<64><61>o)";
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DNS_PARECER:
|
|
|
assunto = "PLANOS - DNS (PARECER)";
|
|
|
mail_text = "Notifica-se que o Plano passou para a fase Dns(Parecer)";
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_SIPRP_CONCLUSAO:
|
|
|
assunto = "PLANOS - TSHS SIPRP (CONCLUS<55>O)";
|
|
|
mail_text = "Notifica-se que o Plano passou para a fase TSHS(Conclus<75>o)";
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if(fase < Global.FASE_CONCLUIDO) // nao envia para ninguem na fase Concluido
|
|
|
{
|
|
|
Mail mail = new Mail();
|
|
|
try
|
|
|
{
|
|
|
mail.send("lluis@evolute.pt", Mail.ENDERECO_ENVIO, assunto, mail_text);
|
|
|
System.out.println("EMAIL ENVIADO !!");
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
ex.printStackTrace();
|
|
|
System.out.println("ERRO NO ENVIO DO EMAIL !!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public void chkValidacao_processValueChange(ValueChangeEvent event) {
|
|
|
if(chkValidacao.getSelected() != null)
|
|
|
{
|
|
|
Boolean selected = (Boolean) chkValidacao.getSelected();
|
|
|
if(selected.booleanValue())
|
|
|
{
|
|
|
//txtParecer.setRendered(true);
|
|
|
gridParecer.setStyleClass("visible");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//txtParecer.setRendered(false);
|
|
|
gridParecer.setStyleClass("hidden");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//txtParecer.setRendered(false);
|
|
|
gridParecer.setStyleClass("hidden");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void drpIrPara_processValueChange(ValueChangeEvent event) {
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|