|
|
/*
|
|
|
* 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 db.entidades.Area;
|
|
|
import db.entidades.Medida;
|
|
|
import db.entidades.PlanoActuacao;
|
|
|
import db.entidades.PostoTrabalho;
|
|
|
import db.entidades.Risco;
|
|
|
import db.entidades.Utilizador;
|
|
|
import db.entidades.Valor;
|
|
|
import db.providers.PlanosDataProvider;
|
|
|
import global.Global;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
import java.util.Vector;
|
|
|
import javax.el.MethodExpression;
|
|
|
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.ActionEvent;
|
|
|
import javax.faces.event.MethodExpressionActionListener;
|
|
|
import javax.faces.event.ValueChangeEvent;
|
|
|
import mail.Mail;
|
|
|
import pagination.Pagina;
|
|
|
import pagination.Pagination;
|
|
|
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>
|
|
|
PlanosDataProvider pdp = new PlanosDataProvider();
|
|
|
HtmlPanelGrid grid;
|
|
|
PanelGroup pg;
|
|
|
StaticText st;
|
|
|
private HtmlPanelGrid gridLayout = new HtmlPanelGrid();
|
|
|
|
|
|
//Plano actuacao
|
|
|
PlanoActuacao plano;
|
|
|
|
|
|
HtmlPanelGrid gridPlano = new HtmlPanelGrid();
|
|
|
HtmlPanelGrid gridArea;
|
|
|
HtmlPanelGrid gridRisco;
|
|
|
HtmlPanelGrid gridValor;
|
|
|
HtmlPanelGrid gridMedida;
|
|
|
HtmlPanelGrid gridPosto;
|
|
|
HtmlPanelGrid gridResponsavel;
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
private StaticText lblTop = new StaticText();
|
|
|
|
|
|
public StaticText getLblTop() {
|
|
|
return lblTop;
|
|
|
}
|
|
|
|
|
|
public void setLblTop(StaticText st) {
|
|
|
this.lblTop = st;
|
|
|
}
|
|
|
private PanelGroup grpPagination = new PanelGroup();
|
|
|
|
|
|
public PanelGroup getGrpPagination() {
|
|
|
return grpPagination;
|
|
|
}
|
|
|
|
|
|
public void setGrpPagination(PanelGroup pg) {
|
|
|
this.grpPagination = pg;
|
|
|
}
|
|
|
private HtmlPanelGrid gridPagination = new HtmlPanelGrid();
|
|
|
|
|
|
public HtmlPanelGrid getGridPagination() {
|
|
|
return gridPagination;
|
|
|
}
|
|
|
|
|
|
public void setGridPagination(HtmlPanelGrid hpg) {
|
|
|
this.gridPagination = hpg;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* <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() {
|
|
|
FacesContext fc = getFacesContext();
|
|
|
//boolean isPostback = JSFUtils.isPostBack12(fc);
|
|
|
//boolean isPostback = JSFUtils.isPostBack(fc);
|
|
|
boolean isPostback = JSFUtils.isPostback();
|
|
|
System.out.println("POSTBACK : " + isPostback);
|
|
|
PlanoActuacao p = getSessionBean1().getPlanoActuacao();
|
|
|
getRiscosByPlano(p);
|
|
|
if(!isPostback)
|
|
|
{
|
|
|
//initializePlano();
|
|
|
initialize(p);
|
|
|
showPlano(p);
|
|
|
//fillPlano();
|
|
|
}
|
|
|
//setPagination(p);
|
|
|
setPagination();
|
|
|
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 initialize(PlanoActuacao p)
|
|
|
{
|
|
|
//getSessionBean1().setPaginationPageNr(1);
|
|
|
Pagination pagination = new Pagination(p);
|
|
|
getSessionBean1().setPagination(pagination);
|
|
|
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");
|
|
|
|
|
|
if(u.getTipo().intValue() != Global.DIRECTOR_LOJA && u.getTipo().intValue() != Global.DIRECTOR_NACIONAL_SEGURANCA && u.getTipo().intValue() != Global.TECNICO_HS)
|
|
|
{
|
|
|
//gridValidar.setStyleClass("visible");
|
|
|
gridValidar.setRendered(false);
|
|
|
//txtParecer.setStyleClass("hidden");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//txtParecer.setRendered(false);
|
|
|
if(u.getTipo().intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA)
|
|
|
{
|
|
|
gridParecer.setStyleClass("");
|
|
|
}
|
|
|
else if(u.getTipo().intValue() == Global.DIRECTOR_LOJA || u.getTipo().intValue() == Global.TECNICO_HS)
|
|
|
{
|
|
|
gridParecer.setStyleClass("hidden");
|
|
|
}
|
|
|
}
|
|
|
// else
|
|
|
// {
|
|
|
// if(u.getTipo().intValue() != Global.DIRECTOR_NACIONAL_SEGURANCA)
|
|
|
// {
|
|
|
// //txtParecer.setStyleClass("visible");
|
|
|
// txtParecer.setRendered(false);
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
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");
|
|
|
if(p.getValidacao_director_loja().booleanValue() == true)
|
|
|
{
|
|
|
chkValidacao.setSelected(new Boolean(true));
|
|
|
}
|
|
|
butEnviar.setText("Enviar para Respons<6E>vel de Seguran<61>a>>");
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DNS_PARECER:
|
|
|
System.out.println("VALIDACAO 1 : " + p.getValidacao_dns().booleanValue());
|
|
|
if(p.getValidacao_dns().booleanValue() == true)
|
|
|
{
|
|
|
chkValidacao.setSelected(new Boolean(true));
|
|
|
System.out.println("VALIDACAO 2 : " + chkValidacao.getSelected().toString());
|
|
|
txtParecer.setText(p.getParecer_dns());
|
|
|
gridParecer.setStyleClass("");
|
|
|
drpIrPara.setStyleClass("hidden");
|
|
|
stIrPara.setStyleClass("hidden");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
gridParecer.setStyleClass("hidden");
|
|
|
drpIrPara.setStyleClass("");
|
|
|
stIrPara.setStyleClass("");
|
|
|
|
|
|
}
|
|
|
|
|
|
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:
|
|
|
if(p.getValidacao_hs().booleanValue() == true)
|
|
|
{
|
|
|
chkValidacao.setSelected(new Boolean(true));
|
|
|
}
|
|
|
butEnviar.setText("Concluir");
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
gridPlano.setId("gridPlano");
|
|
|
gridPlano.setWidth("100%");
|
|
|
gridPlano.setColumns(1);
|
|
|
gridPlano.setColumnClasses("gridColCenter");
|
|
|
//plano
|
|
|
lblTop.setText("Plano de actuação da auditoria " + p.getData_visita_str());
|
|
|
gridLayout.getChildren().add(gridPlano);
|
|
|
}
|
|
|
|
|
|
private void showPlano(PlanoActuacao p)
|
|
|
{
|
|
|
gridArea = new HtmlPanelGrid();
|
|
|
gridArea.setId("gridArea");
|
|
|
gridArea.setColumns(1);
|
|
|
gridArea.setColumnClasses("gridColLeft");
|
|
|
gridArea.setWidth("100%");
|
|
|
gridArea.setStyle("border: solid 1px #000000");
|
|
|
gridPlano.getChildren().add(gridArea);
|
|
|
|
|
|
Area a = p.getAreas().get(0);
|
|
|
showArea(a);
|
|
|
Risco r = a.getRiscos().get(0);
|
|
|
showRisco(r);
|
|
|
showValores(r);
|
|
|
showResponsavel(r);
|
|
|
}
|
|
|
|
|
|
private void showArea(Area a)
|
|
|
{
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(a.getDescricao());
|
|
|
pg.getChildren().add(st);
|
|
|
gridArea.getChildren().add(pg);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
private void showRisco(Risco r)
|
|
|
{
|
|
|
getSessionBean1().setCurrentRisco(r);
|
|
|
HtmlPanelGrid grd = new HtmlPanelGrid();
|
|
|
grd.setColumns(1);
|
|
|
grd.setWidth("100%");
|
|
|
grd.setStyleClass("centerBlock");
|
|
|
gridArea.getChildren().add(grd);
|
|
|
|
|
|
gridRisco = new HtmlPanelGrid();
|
|
|
gridRisco.setStyleClass("centerBlock");
|
|
|
gridRisco.setWidth("98%");
|
|
|
gridRisco.setColumns(1);
|
|
|
gridRisco.setColumnClasses("gridColLeft");
|
|
|
grd.getChildren().add(gridRisco);
|
|
|
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(r.getDescricao());
|
|
|
pg.getChildren().add(st);
|
|
|
gridRisco.getChildren().add(pg);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void showValores(Risco r)
|
|
|
{
|
|
|
List<Valor> valores = r.getValores();
|
|
|
|
|
|
for(Valor v : valores)
|
|
|
{
|
|
|
HtmlPanelGrid grd = new HtmlPanelGrid();
|
|
|
grd.setColumns(1);
|
|
|
grd.setWidth("100%");
|
|
|
grd.setStyleClass("centerBlock");
|
|
|
gridRisco.getChildren().add(grd);
|
|
|
|
|
|
gridValor = new HtmlPanelGrid();
|
|
|
gridValor.setStyleClass("centerBlock");
|
|
|
gridValor.setWidth("98%");
|
|
|
gridValor.setColumns(1);
|
|
|
gridValor.setColumnClasses("gridColLeft");
|
|
|
grd.getChildren().add(gridValor);
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText("Valor : " + v.getValor().toString());
|
|
|
pg.getChildren().add(st);
|
|
|
gridValor.getChildren().add(pg);
|
|
|
|
|
|
showMedidas(v);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void showMedidas(Valor v)
|
|
|
{
|
|
|
List<Medida> medidas = v.getMedidas();
|
|
|
|
|
|
for(Medida m : medidas)
|
|
|
{
|
|
|
HtmlPanelGrid grd = new HtmlPanelGrid();
|
|
|
grd.setColumns(1);
|
|
|
grd.setWidth("100%");
|
|
|
grd.setStyleClass("centerBlock");
|
|
|
gridValor.getChildren().add(grd);
|
|
|
|
|
|
gridMedida = new HtmlPanelGrid();
|
|
|
gridMedida.setStyleClass("centerBlock");
|
|
|
gridMedida.setWidth("98%");
|
|
|
gridMedida.setColumns(1);
|
|
|
gridMedida.setColumnClasses("gridColLeft");
|
|
|
grd.getChildren().add(gridMedida);
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(m.getDescricao());
|
|
|
pg.getChildren().add(st);
|
|
|
gridMedida.getChildren().add(pg);
|
|
|
|
|
|
showPostos(m);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private void showPostos(Medida m)
|
|
|
{
|
|
|
List<PostoTrabalho> postos = m.getPostos();
|
|
|
|
|
|
for(PostoTrabalho p : postos)
|
|
|
{
|
|
|
HtmlPanelGrid grd = new HtmlPanelGrid();
|
|
|
grd.setColumns(1);
|
|
|
grd.setWidth("100%");
|
|
|
grd.setStyleClass("centerBlock");
|
|
|
gridMedida.getChildren().add(grd);
|
|
|
|
|
|
gridPosto = new HtmlPanelGrid();
|
|
|
gridPosto.setStyleClass("centerBlock");
|
|
|
gridPosto.setWidth("98%");
|
|
|
gridPosto.setColumns(1);
|
|
|
gridPosto.setColumnClasses("gridColLeft");
|
|
|
grd.getChildren().add(gridPosto);
|
|
|
pg = new PanelGroup();
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(p.getDescricao());
|
|
|
pg.getChildren().add(st);
|
|
|
gridPosto.getChildren().add(pg);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void showResponsavel(Risco r)
|
|
|
{
|
|
|
gridResponsavel = new HtmlPanelGrid();
|
|
|
gridResponsavel.setId("gridResponsavel");
|
|
|
gridResponsavel.setWidth("100%");
|
|
|
gridResponsavel.setColumns(1);
|
|
|
gridResponsavel.setColumnClasses("gridColLeft");
|
|
|
gridArea.getChildren().add(gridResponsavel);
|
|
|
|
|
|
pg = new PanelGroup();
|
|
|
pg.setId("pgResponsavel");
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setStyleClass("label");
|
|
|
st.setText("Responsável de execução:");
|
|
|
pg.getChildren().add(st);
|
|
|
txtResponsavelExecucao = new TextField();
|
|
|
txtResponsavelExecucao.setId("txtResponsavel");
|
|
|
txtResponsavelExecucao.setColumns(100);
|
|
|
txtResponsavelExecucao.setText(r.getResponsavel_execucao());
|
|
|
pg.getChildren().add(txtResponsavelExecucao);
|
|
|
gridResponsavel.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);
|
|
|
gridResponsavel.getChildren().add(pg);
|
|
|
txtRecursos = new TextArea();
|
|
|
txtRecursos.setId("txtRecursos");
|
|
|
txtRecursos.setColumns(200);
|
|
|
txtRecursos.setText(r.getRecursos_necessarios());
|
|
|
gridResponsavel.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();
|
|
|
dtInicio.setId("dtInicio");
|
|
|
|
|
|
dtInicio.setDateFormatPattern("dd-MM-yyyy");
|
|
|
dtInicio.setValue(r.getData_inicio());
|
|
|
java.util.GregorianCalendar gcalendar = new java.util.GregorianCalendar();
|
|
|
gcalendar.set(2000,1,1);
|
|
|
dtInicio.setMinDate(gcalendar.getTime());
|
|
|
grd.getChildren().add(dtInicio);
|
|
|
gridResponsavel.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();
|
|
|
dtFim.setId("dtFim");
|
|
|
dtFim.setDateFormatPattern("dd-MM-yyyy");
|
|
|
java.util.GregorianCalendar gcalendar1 = new java.util.GregorianCalendar();
|
|
|
gcalendar1.set(2099,1,1);
|
|
|
dtFim.setMaxDate(gcalendar1.getTime());
|
|
|
dtFim.setValue(r.getData_fim());
|
|
|
grd.getChildren().add(dtFim);
|
|
|
gridResponsavel.getChildren().add(grd);
|
|
|
}
|
|
|
|
|
|
private void setPagination()
|
|
|
{
|
|
|
StaticText st = null;
|
|
|
|
|
|
Class[] argtypes = new Class[1];
|
|
|
argtypes[0] = ActionEvent.class;
|
|
|
MethodExpression me = (MethodExpression)this.getApplication().getExpressionFactory().createMethodExpression(
|
|
|
getFacesContext().getELContext(), "#{EditarPlano.paginacao_actionListener}", null,argtypes);
|
|
|
|
|
|
if(grpPagination.getChildCount() > 0)
|
|
|
{
|
|
|
grpPagination.getChildren().clear();
|
|
|
}
|
|
|
|
|
|
Pagination pagination = getSessionBean1().getPagination();
|
|
|
Vector<Pagina> paginas = pagination.getPaginas();
|
|
|
for(Pagina pagina : paginas)
|
|
|
{
|
|
|
if(pagina.isPrevious())
|
|
|
{
|
|
|
pagina.addActionListener(new MethodExpressionActionListener(me));
|
|
|
grpPagination.getChildren().add(pagina);
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(" ");
|
|
|
grpPagination.getChildren().add(st);
|
|
|
}
|
|
|
else if(pagina.isNext())
|
|
|
{
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(" ");
|
|
|
grpPagination.getChildren().add(st);
|
|
|
pagina.addActionListener(new MethodExpressionActionListener(me));
|
|
|
grpPagination.getChildren().add(pagina);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
pagina.addActionListener(new MethodExpressionActionListener(me));
|
|
|
grpPagination.getChildren().add(pagina);
|
|
|
if(pagina.getPage_nr().intValue() < pagination.totalPaginas() )
|
|
|
{
|
|
|
st = new StaticText();
|
|
|
st.setEscape(false);
|
|
|
st.setText(" | ");
|
|
|
grpPagination.getChildren().add(st);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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.
|
|
|
|
|
|
try
|
|
|
{
|
|
|
Risco r = getSessionBean1().getCurrentRisco();
|
|
|
r = fillRiscoFields(r);
|
|
|
pdp.updateRisco(r);
|
|
|
|
|
|
Pagination pagination = getSessionBean1().getPagination();
|
|
|
r = pagination.nextRisco();
|
|
|
if(r != null)
|
|
|
{
|
|
|
gridPlano = (HtmlPanelGrid) gridLayout.findComponent("form1:gridPlano");
|
|
|
gridArea = (HtmlPanelGrid) gridPlano.findComponent("form1:gridArea");
|
|
|
if(gridArea.getChildren() != null)
|
|
|
{
|
|
|
gridArea.getChildren().clear();
|
|
|
}
|
|
|
Area a = getSessionBean1().getAreasHash().get( r.getArea_id() );
|
|
|
showArea(a);
|
|
|
showRisco(r);
|
|
|
showValores(r);
|
|
|
showResponsavel(r);
|
|
|
}
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Risco r = getNextRisco(getSessionBean1().getPlanoId());
|
|
|
//fillRisco(r);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
private Risco fillRiscoFields(Risco r)
|
|
|
{
|
|
|
gridPlano = (HtmlPanelGrid) gridLayout.findComponent("form1:gridPlano");
|
|
|
gridArea = (HtmlPanelGrid) gridPlano.findComponent("form1:gridArea");
|
|
|
gridResponsavel = (HtmlPanelGrid) gridArea.findComponent("form1:gridResponsavel");
|
|
|
|
|
|
TextField txtResponsavel = (TextField) gridResponsavel.findComponent("form1:pgResponsavel:txtResponsavel");
|
|
|
if(txtResponsavel != null)
|
|
|
{
|
|
|
if(txtResponsavel.getText() != null)
|
|
|
{
|
|
|
r.setResponsavel_execucao((String) txtResponsavel.getText());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
TextArea txtRecursos = (TextArea) gridResponsavel.findComponent("form1:txtRecursos");
|
|
|
if(txtRecursos != null)
|
|
|
{
|
|
|
if(txtRecursos.getText() != null)
|
|
|
{
|
|
|
r.setRecursos_necessarios((String) txtRecursos.getText());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Calendar dtInicio = (Calendar) gridResponsavel.findComponent("form1:dtInicio:");
|
|
|
if(dtInicio != null)
|
|
|
{
|
|
|
r.setData_inicio(dtInicio.getSelectedDate());
|
|
|
}
|
|
|
|
|
|
Calendar dtFim = (Calendar) gridResponsavel.findComponent("form1:dtFim");
|
|
|
if(dtFim != null)
|
|
|
{
|
|
|
r.setData_fim(dtFim.getSelectedDate());
|
|
|
}
|
|
|
|
|
|
return r;
|
|
|
}
|
|
|
|
|
|
public String butEnviar_action() {
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
// case name where null will return to the same page.
|
|
|
PlanoActuacao p = getSessionBean1().getPlanoActuacao();
|
|
|
|
|
|
if(planoValidationOk(p))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
processEnviar(p);
|
|
|
return "lista_planos";
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
getSessionBean1().setMsg("Erro no envio do Plano");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
private boolean planoValidationOk(PlanoActuacao p)
|
|
|
{
|
|
|
boolean ok = true;
|
|
|
boolean processo_validado = true;
|
|
|
int dns_next_fase = 2;
|
|
|
|
|
|
int fase = p.getFase().intValue();
|
|
|
switch(fase)
|
|
|
{
|
|
|
// case Global.FASE_SIPRP_EMISSAO:
|
|
|
// break;
|
|
|
|
|
|
case Global.FASE_SEGURANCA_PREENCHIMENTO:
|
|
|
fase++;
|
|
|
break;
|
|
|
case Global.FASE_SIPRP_CONCLUSAO:
|
|
|
Boolean validacao = (Boolean)chkValidacao.getSelected();
|
|
|
if(validacao == null)
|
|
|
{
|
|
|
processo_validado = false;
|
|
|
ok = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
processo_validado = false;
|
|
|
if(validacao.booleanValue())
|
|
|
{
|
|
|
processo_validado = true;
|
|
|
p.setValidacao_hs(new Boolean(true));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(processo_validado)
|
|
|
{
|
|
|
fase++;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
getSessionBean1().setMsg("Tem de validar o processo!");
|
|
|
ok = false;
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case Global.FASE_DIR_LOJA_VALIDACAO:
|
|
|
validacao = (Boolean)chkValidacao.getSelected();
|
|
|
if(validacao == null)
|
|
|
{
|
|
|
processo_validado = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
processo_validado = false;
|
|
|
if(validacao.booleanValue())
|
|
|
{
|
|
|
processo_validado = true;
|
|
|
p.setValidacao_director_loja(new Boolean(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;
|
|
|
p.setValidacao_dns(new Boolean(true));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(processo_validado)
|
|
|
{
|
|
|
if(txtParecer.getText() == null)
|
|
|
{
|
|
|
getSessionBean1().setMsg("Tem de preencher parecer!");
|
|
|
ok = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
String parecer = (String) txtParecer.getText();
|
|
|
if(parecer.trim().length() == 0)
|
|
|
{
|
|
|
getSessionBean1().setMsg("Tem de preencher parecer!");
|
|
|
ok = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
p.setParecer_dns(parecer);
|
|
|
fase++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Integer irPara = (Integer)drpIrPara.getSelected();
|
|
|
dns_next_fase = irPara.intValue();
|
|
|
fase = dns_next_fase;
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
p.setFase(new Integer(fase));
|
|
|
return ok;
|
|
|
}
|
|
|
|
|
|
|
|
|
private void processEnviar(PlanoActuacao p) throws Exception
|
|
|
{
|
|
|
PlanosDataProvider pdp = new PlanosDataProvider();
|
|
|
pdp.updatePlano(p);
|
|
|
enviarMail(p.getFase().intValue());
|
|
|
}
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
private void getRiscosByPlano(PlanoActuacao p)
|
|
|
{
|
|
|
HashMap areasHash = new HashMap();
|
|
|
HashMap riscosHash = new HashMap();
|
|
|
|
|
|
for(Area a : p.getAreas())
|
|
|
{
|
|
|
areasHash.put(a.getId(), a);
|
|
|
for(Risco r : a.getRiscos())
|
|
|
{
|
|
|
riscosHash.put(r.getId(), r);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
getSessionBean1().setAreasHash(areasHash);
|
|
|
getSessionBean1().setRiscosHash(riscosHash);
|
|
|
}
|
|
|
|
|
|
public void paginacao_actionListener(ActionEvent e)
|
|
|
{
|
|
|
gridPlano = (HtmlPanelGrid) gridLayout.findComponent("form1:gridPlano");
|
|
|
gridArea = (HtmlPanelGrid) gridPlano.findComponent("form1:gridArea");
|
|
|
if(gridArea.getChildren() != null)
|
|
|
{
|
|
|
gridArea.getChildren().clear();
|
|
|
}
|
|
|
Pagina pagina = (Pagina) e.getSource();
|
|
|
Pagination pagination = getSessionBean1().getPagination();
|
|
|
Risco r = pagination.getRisco(pagina);
|
|
|
Area a = getSessionBean1().getAreasHash().get( r.getArea_id() );
|
|
|
showArea(a);
|
|
|
showRisco(r);
|
|
|
showValores(r);
|
|
|
showResponsavel(r);
|
|
|
}
|
|
|
|
|
|
public String butCancelar_action() {
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
// case name where null will return to the same page.
|
|
|
return "lista_planos";
|
|
|
}
|
|
|
|
|
|
public String butLimparDados_action() {
|
|
|
// TODO: Process the action. Return value is a navigation
|
|
|
// case name where null will return to the same page.
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|