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

lxbfYeaa
Frederico Palma 12 years ago
parent 9f9508298b
commit a832906e01

@ -0,0 +1,151 @@
/*
* ApplicationBean1.java
*
* Created on Aug 25, 2008, 11:20:16 AM
*/
package planosactuacao;
import com.evolute.utils.error.ErrorLogger;
import com.sun.rave.web.ui.appbase.AbstractApplicationBean;
import java.sql.Connection;
import javax.faces.FacesException;
/**
* <p>Application scope data bean for your application. Create properties
* here to represent cached data that should be made available to all users
* and pages in the application.</p>
*
* <p>An instance of this class will be created for you automatically,
* the first time your application evaluates a value binding expression
* or method binding expression that references a managed bean using
* this class.</p>
*
* @author lluis
*/
public class ApplicationBean1 extends AbstractApplicationBean {
// <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>
private boolean timerStarted = false;
private Connection localConnection = null;
private Connection connection = null;
/**
* <p>Construct a new application data bean instance.</p>
*/
public ApplicationBean1() {
}
/**
* <p>This method is called when this bean is initially added to
* application scope. Typically, this occurs as a result of evaluating
* a value binding or method binding expression, which utilizes the
* managed bean facility to instantiate this bean and store it into
* application scope.</p>
*
* <p>You may customize this method to initialize and cache application wide
* data values (such as the lists of valid options for dropdown list
* components), or to allocate resources that are required for the
* lifetime of the application.</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) {
ErrorLogger.logException( e );
log("ApplicationBean1 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
}
/**
* <p>This method is called when this bean is removed from
* application scope. Typically, this occurs as a result of
* the application being shut down by its owning container.</p>
*
* <p>You may customize this method to clean up resources allocated
* during the execution of the <code>init()</code> method, or
* at any later time during the lifetime of the application.</p>
*/
@Override
public void destroy() {
}
/**
* <p>Return an appropriate character encoding based on the
* <code>Locale</code> defined for the current JavaServer Faces
* view. If no more suitable encoding can be found, return
* "UTF-8" as a general purpose default.</p>
*
* <p>The default implementation uses the implementation from
* our superclass, <code>AbstractApplicationBean</code>.</p>
*/
@Override
public String getLocaleCharacterEncoding() {
return super.getLocaleCharacterEncoding();
}
/**
* @return the timerStarted
*/
public boolean isTimerStarted() {
return timerStarted;
}
/**
* @param timerStarted the timerStarted to set
*/
public void setTimerStarted(boolean timerStarted) {
this.timerStarted = timerStarted;
}
/**
* @return the connection
*/
public Connection getConnection() {
return connection;
}
/**
* @param connection the connection to set
*/
public void setConnection(Connection connection) {
this.connection = connection;
}
public Connection getLocalConnection() {
return localConnection;
}
/**
* @param connection the connection to set
*/
public void setLocalConnection(Connection connection) {
this.localConnection = connection;
}
}

@ -0,0 +1,3 @@
# To change this template, choose Tools | Templates
# and open the template in the editor.

@ -0,0 +1,254 @@
/*
* Dummy.java
*
* Created on Oct 6, 2008, 10:43:13 AM
*/
package planosactuacao;
import com.evolute.utils.error.ErrorLogger;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Hyperlink;
import db.entidades.Utilizador;
import db.providers.UtilizadoresDataProvider;
import java.util.List;
import java.util.ListIterator;
import javax.faces.FacesException;
import javax.faces.event.ActionEvent;
/**
* <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 Dummy 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 {
}
private Hyperlink hyperlink1 = new Hyperlink();
public Hyperlink getHyperlink1() {
return hyperlink1;
}
public void setHyperlink1(Hyperlink h) {
this.hyperlink1 = h;
}
private Hyperlink link = new Hyperlink();
public Hyperlink getLink() {
return link;
}
public void setLink(Hyperlink h) {
this.link = h;
}
// </editor-fold>
/**
* <p>Construct a new Page bean instance.</p>
*/
public Dummy()
{
// connect();
}
/**
* <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) {
ErrorLogger.logException( e );
log("Dummy 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
}
/**
* <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() {
//Verbatim verbatim = new Verbatim();
//printUsers();
}
/**
* <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 ApplicationBean1 getApplicationBean1() {
return (ApplicationBean1) getBean("ApplicationBean1");
}
/**
* <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");
}
public String lnkAnaliseAcidentes_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
return null;
}
public void lnk_actionListener(ActionEvent e) {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
System.out.print("DUMMY LINK");
}
private void printUsers()
{
// UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
try
{
UtilizadoresDataProvider udp = UtilizadoresDataProvider.getInstance();
List< Utilizador > list = udp.getUtilizadoresList();
ListIterator iter = list.listIterator();
System.out.println("==================================================================================");
System.out.println("LOGIN\tEMAIL\tTIPO\tESTABELECIMENTO\tRESP. LOJA\tACTIVO\tAPAGADO");
while(iter.hasNext())
{
Utilizador u = (Utilizador) iter.next();
System.out.print(u.getLogin() + "\t");
System.out.print(u.getEmail() + "\t");
System.out.print(u.getTipo() + "\t");
System.out.print(u.getEstabelecimento_id() + "\t");
System.out.print(u.getResponsavel_loja() + "\t");
System.out.print(u.getActivo() + "\t");
System.out.print(u.getApagado() + "\t\n");
}
System.out.println("");
System.out.println("==================================================================================");
}
catch(Exception ex)
{
ErrorLogger.logException( ex );
}
}
// private void connect()
// {
// db.Db db = new db.Db();
// try
// {
// Connection connection = db.connect();
// }
// catch(Exception ex)
// {
// getSessionBean1().setMsg("Erro na liga&ccedil;&atilde;o &agrave; Base de Dados");
// //***** terminate session
// try {
// getExternalContext().redirect("faces/Erro.jsp");
// } catch(Exception e) {
// // . . . handle exception . . .
// ErrorLogger.logException( e );
// }
// ErrorLogger.logException( ex );
// }
// }
public String butImage_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
// FacesContext fc = getFacesContext();
// Logos logos = new Logos();
// String logourl = logos.getLogo(fc);
// if(logourl != null)
// {
// image1.setUrl(logourl);
// }
return null;
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,384 @@
/*
* EnviarCorrecao.java
*
* Created on Nov 13, 2008, 11:26:00 AM
*/
package planosactuacao;
import com.evolute.utils.error.ErrorLogger;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Button;
import com.sun.webui.jsf.component.DropDown;
import com.sun.webui.jsf.component.StaticText;
import com.sun.webui.jsf.component.TextArea;
import com.sun.webui.jsf.model.Option;
import db.entidades.PlanoActuacao;
import db.entidades.Utilizador;
import db.providers.PlanosDataProvider;
import db.providers.UtilizadoresDataProvider;
import utils.Global;
import java.util.List;
import java.util.ListIterator;
import javax.faces.FacesException;
import javax.faces.event.ValueChangeEvent;
import mail.Mail;
/**
* <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 EnviarCorrecao 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
{
}
private StaticText lblMsg = new StaticText();
public StaticText getLblMsg()
{
return lblMsg;
}
public void setLblMsg(StaticText st)
{
this.lblMsg = st;
}
private TextArea txtObservacoes = new TextArea();
public TextArea getTxtObservacoes()
{
return txtObservacoes;
}
public void setTxtObservacoes(TextArea ta)
{
this.txtObservacoes = ta;
}
private DropDown drpIrPara = new DropDown();
public DropDown getDrpIrPara()
{
return drpIrPara;
}
public void setDrpIrPara(DropDown dd)
{
this.drpIrPara = dd;
}
private Button butCancelar = new Button();
public Button getButCancelar()
{
return butCancelar;
}
public void setButCancelar(Button b)
{
this.butCancelar = b;
}
private Button butEnviar = new Button();
public Button getButEnviar()
{
return butEnviar;
}
public void setButEnviar(Button b)
{
this.butEnviar = b;
}
// </editor-fold>
/**
* <p>Construct a new Page bean instance.</p>
*/
public EnviarCorrecao()
{
}
/**
* <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)
{
ErrorLogger.logException( e );
log("EnviarCorrecao 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
}
/**
* <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()
{
initialize();
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 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");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected RequestBean1 getRequestBean1()
{
return (RequestBean1) getBean("RequestBean1");
}
public void drpIrPara_processValueChange(ValueChangeEvent event)
{
}
private void initialize()
{
Utilizador u = getSessionBean1().getCurrentUser();
com.sun.webui.jsf.model.Option[] listOptions = null;
if(u.getTipo().intValue() == Global.DIRECTOR_LOJA)
{
listOptions = new com.sun.webui.jsf.model.Option[1];
listOptions[0] = new Option(new Integer(Global.FASE_SEGURANCA_PREENCHIMENTO), "Responsavel de seguranca");
}
else if(u.getTipo().intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA)
{
listOptions = new com.sun.webui.jsf.model.Option[2];
listOptions[0] = new Option(new Integer(Global.FASE_SEGURANCA_PREENCHIMENTO), "Responsavel de seguranca");
listOptions[1] = new Option(new Integer(Global.FASE_DIR_LOJA_VALIDACAO), "Director de loja");
}
getSessionBean1().setIrParaOptions(listOptions);
getSessionBean1().setIrParaChoice(new Integer( Global.FASE_SEGURANCA_PREENCHIMENTO ));
//drpIrPara.setItems(listOptions);
//drpIrPara.setSelected(new Integer( Global.FASE_SEGURANCA_PREENCHIMENTO ));
}
public String butCancelar_action()
{
return "editar_plano";
}
public String butEnviar_action()
{
Utilizador u = getSessionBean1().getCurrentUser();
// PlanosDataProvider pdp = new PlanosDataProvider();
PlanoActuacao p = getSessionBean1().getPlanoActuacao();
p.setFase_anterior( p.getFase() );
int dns_next_fase = 0;
int fase = 0;
Integer irPara = ( Integer ) drpIrPara.getSelected();
fase = irPara.intValue();
if ( u.getTipo().intValue() == Global.DIRECTOR_LOJA )
{
p.setValidacao_director_loja( new Boolean( false ) );
}
else if ( u.getTipo().intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA )
{
p.setValidacao_dns( new Boolean( false ) );
}
p.setCorrecao( "y" );
p.setFase_antes_correcao( p.getFase() );
p.setFase( new Integer( fase ) );
String observacoes = "";
if ( txtObservacoes.getText() != null )
{
if ( u.getTipo().intValue() == Global.DIRECTOR_LOJA )
{
observacoes = "Observa&ccedil;&otilde;es do Director de Loja:&nbsp;";
}
else if ( u.getTipo().intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA )
{
observacoes = "Observa&ccedil;&otilde;es do Director Nacional de Seguran&ccedil;a:&nbsp;";
}
observacoes += ( String ) txtObservacoes.getText();
p.setObs_correcao( observacoes );
}
try
{
PlanosDataProvider pdp = PlanosDataProvider.getInstance();
pdp.updatePlano( p );
enviarMail( p );
return "lista_planos";
}
catch ( Exception ex )
{
ErrorLogger.logException( ex );
getSessionBean1().setMsg( "Erro no envio do plano para a fase " + Global.FASES_TEXTO[ fase - 1 ] );
}
return null;
}
private void enviarMail( PlanoActuacao p )
{
String assunto = "";
String mail_text = "";
int fase = p.getFase().intValue();
int tipo_utilizador = 0;
switch( fase )
{
case Global.FASE_SEGURANCA_PREENCHIMENTO : // enviar para correccao para responsavel de seguranca
tipo_utilizador = Global.RESPONSAVEL_SEGURANCA;
assunto = "Plano de Actuacao da Avaliacao de Riscos de " + p.getData_visita_str() + " - " + p.getNome_estabelecimento() + " - Pedido de Correcao";
mail_text = "<p>Exmo. (a) Senhor (a),</p>";
mail_text += "<p>O Plano de Actua&ccedil;&atilde;o referente &agrave; auditoria de Avalia&ccedil;&atilde;o de Riscos Laborais realizada no passado dia " + p.getData_visita_str() + " foi devolvido para correc&ccedil;&atilde;o.</p>";
mail_text += "<p>Proceda, por favor, em www.siprp.com &agrave;(s) respectiva(s) correc&ccedil;&atilde;o(&otilde;es) de acordo com as indica&ccedil;&otilde;es e volte a reenviar o processo para a fase seguinte.</p>";
mail_text += "<p>Caso tenha alguma d&uacute;vida ou necessite de qualquer esclarecimento, contacte, por favor, a &Aacute;rea T&eacute;cnica da SIPRP atrav&eacute;s do telefone 213 504 540.</p>";
mail_text += "<p>Cumprimentos,</p>";
mail_text += "<p>A equipa da SIPRP</p>";
mail_text += "<p><center><b>Por favor n&atilde;o responda a esta mensagem, dado tratar-se de um e-mail autom&aacute;tico</b></center></p>";
break;
case Global.FASE_DIR_LOJA_VALIDACAO : // enviar para correccao para director de loja
tipo_utilizador = Global.DIRECTOR_LOJA;
assunto = "Plano de Actuacao da Avaliacao de Riscos de " + p.getData_visita_str() + " - " + p.getNome_estabelecimento() + " - Pedido de Correccao";
mail_text = "<p>Exmo. (a) Senhor (a),</p>";
mail_text += "<p>O Plano de Actua&ccedil;&atilde;o referente &agrave; auditoria de Avalia&ccedil;&atilde;o de Riscos Laborais realizada no passado dia " + p.getData_visita_str() + " foi devolvido para correc&ccedil;&atilde;o.</p>";
mail_text += "<p>Proceda, por favor, em www.siprp.com &agrave;(s) respectiva(s) correc&ccedil;&atilde;o(&otilde;es) de acordo com as indica&ccedil;&otilde;es do Director Nacional de Seguran&ccedil;a e volte a reenviar o processo para a fase seguinte.</p>";
mail_text += "<p>Cumprimentos.</p>";
mail_text += "<p><center><b>Por favor n&atilde;o responda a esta mensagem, dado tratar-se de um e-mail autom&aacute;tico</b></center></p>";
break;
}
String responsavel_loja = "n";
if ( tipo_utilizador == Global.RESPONSAVEL_SEGURANCA )
{
responsavel_loja = "y";
}
try
{
Mail mail = new Mail();
UtilizadoresDataProvider udp = UtilizadoresDataProvider.getInstance();
List< Utilizador > list = udp.getUtilizadoresListByTipo( tipo_utilizador, responsavel_loja, p.getEstabelecimento_id() );
ListIterator iter = list.listIterator();
while ( iter.hasNext() )
{
Utilizador u = ( Utilizador ) iter.next();
System.out.println( "USER MAIL NEXT FASE : " + u.getLogin() + " ; " + u.getEmail() );
try
{
mail.send( u.getEmail(), Mail.ENDERECO_ENVIO, assunto, mail_text );
System.out.println( "EMAIL ENVIADO !!" );
}
catch ( Exception ex1 )
{
ErrorLogger.logException( ex1 );
System.out.println( "MAIL ERROR : " + ex1.getMessage() );
}
}
}
catch ( Exception ex )
{
ErrorLogger.logException( ex );
}
}
}

@ -0,0 +1,153 @@
/*
* Erro.java
*
* Created on Aug 26, 2008, 10:54:11 AM
*/
package planosactuacao;
import com.evolute.utils.error.ErrorLogger;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.StaticText;
import javax.faces.FacesException;
/**
* <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 Erro 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 {
}
private StaticText txtMsg = new StaticText();
public StaticText getTxtMsg() {
return txtMsg;
}
public void setTxtMsg(StaticText st) {
this.txtMsg = st;
}
// </editor-fold>
/**
* <p>Construct a new Page bean instance.</p>
*/
public Erro() {
}
/**
* <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) {
ErrorLogger.logException( e );
log("Erro 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
}
/**
* <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() {
txtMsg.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");
}
}

@ -0,0 +1,300 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package planosactuacao;
import com.evolute.utils.data.Mappable;
import com.evolute.utils.strings.UnicodeChecker;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Button;
import com.sun.webui.jsf.component.DropDown;
import com.sun.webui.jsf.component.Table;
import com.sun.webui.jsf.component.TableRowGroup;
import com.sun.webui.jsf.model.Option;
import db.entidades.LinhaEstatistica;
import db.providers.PlanosDataProvider;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.faces.FacesException;
/**
* <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>
*
* @version Estatistica.java
* @version Created on Mar 27, 2012, 2:22:42 PM
* @author fpalma
*/
public class Estatistica extends AbstractPageBean {
// <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
private DropDown dropEstabelecimento = new DropDown();
private Date calInicioDate = null;
private Date calFimDate = null;
private Button buttonPesquisar;// = new Button();
private Table tableEstatistica = new Table();
private TableRowGroup tableRowGroupEstatisticas = new TableRowGroup();
/**
* <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>
/**
* <p>Construct a new Page bean instance.</p>
*/
public Estatistica() {
}
/**
* <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();
fillEstabelecimentosDrop();
} catch (Exception e) {
log("Estatistica 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
}
/**
* <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() {
}
/**
* <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 ApplicationBean1 getApplicationBean1()
{
return ( ApplicationBean1 ) getBean( "ApplicationBean1" );
}
/**
* <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 RequestBean1 getRequestBean1()
{
return ( RequestBean1 ) getBean( "RequestBean1" );
}
public Button getButtonPesquisar()
{
return buttonPesquisar;
}
public void setButtonPesquisar( Button buttonPesquisar )
{
this.buttonPesquisar = buttonPesquisar;
}
public Date getCalFimDate()
{
return calFimDate;
}
public void setCalFimDate( Date calFimDate )
{
this.calFimDate = calFimDate;
}
public Date getCalInicioDate()
{
return calInicioDate;
}
public void setCalInicioDate( Date calInicioDate )
{
this.calInicioDate = calInicioDate;
}
public DropDown getDropEstabelecimento()
{
return dropEstabelecimento;
}
public void setDropEstabelecimento( DropDown dropEstabelecimento )
{
this.dropEstabelecimento = dropEstabelecimento;
}
public Table getTableEstatistica()
{
return tableEstatistica;
}
public void setTableEstatistica( Table tableEstatistica )
{
this.tableEstatistica = tableEstatistica;
}
public TableRowGroup getTableRowGroupEstatisticas()
{
return tableRowGroupEstatisticas;
}
public void setTableRowGroupEstatisticas( TableRowGroup tableRowGroupEstatisticas )
{
this.tableRowGroupEstatisticas = tableRowGroupEstatisticas;
}
public String buttonPesquisar_action()
{
System.out.println( "ACTION" );
List<LinhaEstatistica> linhasEstatistica = null;
try
{
Integer estabelecimentoId = null;
if ( dropEstabelecimento.getSelected() != null )
{
String estabelecimento = ( String ) dropEstabelecimento.getSelected();
if ( estabelecimento != null )
{
try {
estabelecimentoId = Integer.parseInt( estabelecimento );
}
catch ( Exception e )
{
e.printStackTrace();
}
}
}
linhasEstatistica = PlanosDataProvider.getInstance().getEstatisticaForEstabelecimentoIdAndDateInterval( estabelecimentoId, calInicioDate, calFimDate );
System.out.println( "LINHAS: " + linhasEstatistica.size() );
}
catch( Exception ex )
{
System.out.println( "EXCEPTION" );
ex.printStackTrace();
linhasEstatistica = new ArrayList<LinhaEstatistica>();
}
getSessionBean1().getEstatisticaPlanoDataProvider().setList( linhasEstatistica );
return null;
}
protected void fillEstabelecimentosDrop()
{
// List<EstabelecimentosData> estabelecimentos = null;
List<Mappable> estabelecimentos = null;
try
{
estabelecimentos = PlanosDataProvider.getInstance().getEstabelecimentosForEstatistica( getSessionBean1().getCurrentUser() );
}
catch( Exception ex )
{
ex.printStackTrace();
return;
}
// Option[] options = new Option[ estabelecimentos.size() > 1 ? estabelecimentos.size() + 1 : 1 ];
Option[] options = new Option[ estabelecimentos.size() ];
int off = 0;
// if( options.length > 1 )
// {
// options[ 0 ] = new Option( null, "Todos" );
// off = 1;
// }
for( int i = 0; i + off < options.length; i++ )
{
options[ i + off ] = new Option( estabelecimentos.get( i ).getID(), ( String ) estabelecimentos.get( i ).getValue() );
}
if ( estabelecimentos != null )
{
dropEstabelecimento.setItems( options );
}
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected EditarPlano getEditarPlano()
{
return ( EditarPlano ) getBean( "EditarPlano" );
}
}

@ -0,0 +1,141 @@
/*
* Footer.java
*
* Created on Oct 6, 2008, 3:01:32 PM
*/
package planosactuacao;
import com.evolute.utils.error.ErrorLogger;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import javax.faces.FacesException;
/**
* <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 Footer 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>
/**
* <p>Construct a new Page bean instance.</p>
*/
public Footer() {
}
/**
* <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) {
ErrorLogger.logException( e );
log("Footer 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
}
/**
* <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() {
}
/**
* <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 ApplicationBean1 getApplicationBean1() {
return (ApplicationBean1) getBean("ApplicationBean1");
}
/**
* <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");
}
}

@ -0,0 +1,253 @@
/*
* Header.java
*
* Created on Oct 6, 2008, 10:35:36 AM
*/
package planosactuacao;
import com.evolute.utils.error.ErrorLogger;
import com.sun.rave.web.ui.appbase.AbstractFragmentBean;
import com.sun.webui.jsf.component.ImageComponent;
import com.sun.webui.jsf.component.StaticText;
import db.entidades.Utilizador;
import utils.Global;
import javax.faces.FacesException;
import javax.faces.context.FacesContext;
import utils.JSFHTTPUtils;
import utils.JSFUtils;
/**
* <p>Fragment bean that corresponds to a similarly named JSP page
* fragment. This class contains component definitions (and initialization
* code) for all components that you have defined on this fragment, as well as
* lifecycle methods and event handlers where you may add behavior
* to respond to incoming events.</p>
*
* @author lluis
*/
public class Header extends AbstractFragmentBean {
// <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 {
}
private StaticText stDataPlano = new StaticText();
public StaticText getStDataPlano() {
return stDataPlano;
}
public void setStDataPlano(StaticText st) {
this.stDataPlano = st;
}
private ImageComponent imgLogoEmpresa = new ImageComponent();
public ImageComponent getImgLogoEmpresa() {
return imgLogoEmpresa;
}
public void setImgLogoEmpresa(ImageComponent ic) {
this.imgLogoEmpresa = ic;
}
// </editor-fold>
public Header() {
}
/**
* <p>Callback method that is called whenever a page containing
* this page fragment is navigated to, either directly via a URL,
* or indirectly via page navigation. Override this method to acquire
* resources that will be needed for event handlers and lifecycle methods.</p>
*
* <p>The default implementation does nothing.</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
FacesContext fc = getFacesContext();
String referer = JSFHTTPUtils.getReferer(fc);
System.out.println("HEADER - REFERER : " + referer);
// <editor-fold defaultstate="collapsed" desc="Visual-Web-managed Component Initialization">
// Initialize automatically managed components
// *Note* - this logic should NOT be modified
try {
_init();
} catch (Exception e) {
ErrorLogger.logException( e );
log("Page1 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
}
/**
* <p>Callback method that is called after rendering is completed for
* this request, if <code>init()</code> was called. Override this
* method to release resources acquired in the <code>init()</code>
* resources that will be needed for event handlers and lifecycle methods.</p>
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void destroy() {
}
public String lnkLogout_action()
{
FacesContext fc = getFacesContext();
try
{
JSFUtils.logout( fc );
try
{
JSFUtils.redirect( fc, Global.ANALISE_ACIDENTES_URL + "Login.jsp" );
}
catch ( Exception ex )
{
ErrorLogger.logException( ex );
}
}
catch ( Exception ex )
{
ErrorLogger.logException( ex );
}
return null;
}
public String lnkAnaliseAcidentes_action()
{
FacesContext fc = getFacesContext();
SessionBean1 session = JSFUtils.getSessionBean(fc);
Utilizador u = session.getCurrentUser();
String url = Global.ANALISE_ACIDENTES_URL;
int tipo = u.getTipo().intValue();
switch(tipo)
{
case Global.RESPONSAVEL_SEGURANCA:
url += "FormSeguranca.jsp?user=" + u.getId().intValue();
break;
case Global.RH:
url += "FormRH.jsp?user=" + u.getId().intValue();
break;
case Global.TECNICO_HS:
url += "FormHS.jsp?user=" + u.getId().intValue();
break;
case Global.GESTOR:
url += "FormGestor.jsp?user=" + u.getId().intValue();
break;
case Global.DIRECTOR_LOJA:
url += "FormGestor.jsp?user=" + u.getId().intValue();
break;
case Global.DIRECTOR_GERAL_RH:
url += "FormDirGerRh.jsp?user=" + u.getId().intValue();
break;
case Global.DIRECTOR_SIPRP:
url += "FormDirSiprp.jsp?user=" + u.getId().intValue();
// url += "Acesso.jsp";
break;
case Global.DIRECTOR_NACIONAL_SEGURANCA:
url += "FormGestor.jsp?user=" + u.getId().intValue();
break;
}
try
{
JSFUtils.redirect(fc.getCurrentInstance(), url);
}
catch(Exception ex)
{
ErrorLogger.logException( ex );
}
return null;
}
public String lnkPlanosActuacao1_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 lnkGerirUtilizadores1_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
FacesContext fc = getFacesContext();
SessionBean1 session = JSFUtils.getSessionBean(fc);
Utilizador u = session.getCurrentUser();
String url = Global.ANALISE_ACIDENTES_URL;
//int tipo = u.getTipo().intValue();
url += "GestaoUtilizadores.jsp?user=" + u.getId().intValue();
try
{
JSFUtils.redirect(fc.getCurrentInstance(), url);
}
catch(Exception ex)
{
ErrorLogger.logException( ex );
}
return null;
}
public String lnkDadosUtilizador1_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
FacesContext fc = getFacesContext();
SessionBean1 session = JSFUtils.getSessionBean(fc);
Utilizador u = session.getCurrentUser();
String url = Global.ANALISE_ACIDENTES_URL;
int tipo = u.getTipo().intValue();
url += "FichaUtilizador.jsp?user=" + u.getId().intValue() + "&mode=edit";
try
{
JSFUtils.redirect(fc.getCurrentInstance(), url);
}
catch(Exception ex)
{
ErrorLogger.logException( ex );
}
return null;
}
public String lnkAjuda_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
return "planos_actuacao_ajuda.pdf";
}
public String lnkEstatisticas_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
return "estatistica";
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,271 @@
/*
* Login.java
*
* Created on Aug 26, 2008, 11:21:02 AM
*/
package planosactuacao;
import com.evolute.utils.error.ErrorLogger;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Button;
import com.sun.webui.jsf.component.PasswordField;
import com.sun.webui.jsf.component.TextField;
import db.entidades.Utilizador;
import db.providers.UtilizadoresDataProvider;
import javax.faces.FacesException;
import utils.Utils;
/**
* <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 Login 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 {
}
private TextField txtUtilizador = new TextField();
public TextField getTxtUtilizador() {
return txtUtilizador;
}
public void setTxtUtilizador(TextField tf) {
this.txtUtilizador = tf;
}
private PasswordField txtPassword = new PasswordField();
public PasswordField getTxtPassword() {
return txtPassword;
}
public void setTxtPassword(PasswordField pf) {
this.txtPassword = pf;
}
private Button butLogin = new Button();
public Button getButLogin() {
return butLogin;
}
public void setButLogin(Button b) {
this.butLogin = b;
}
// </editor-fold>
/**
* <p>Construct a new Page bean instance.</p>
*/
public Login()
{
// connect();
}
/**
* <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) {
ErrorLogger.logException( e );
log("Login 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
}
/**
* <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() {
}
/**
* <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");
}
// private void connect()
// {
// Db db = Db.getInstance();
// try
// {
// Connection connection = db.connect();
// }
// catch ( Exception ex )
// {
// getSessionBean1().setMsg("Erro na liga&ccedil;&atilde;o &agrave; Base de Dados");
// //***** terminate session
// try {
// getExternalContext().redirect("faces/Erro.jsp");
// } catch(Exception e) {
// // . . . handle exception . . .
// ErrorLogger.logException( e );
// }
// ErrorLogger.logException( ex );
// }
// }
public String lnkPasswordRecovery_action()
{
return null;
}
public String butLogin_action()
{
String sRet = null;
if(txtUtilizador.getText() != null)
{
String utilizador = (String) txtUtilizador.getText();
if(utilizador.trim().length() > 0)
{
if(txtPassword.getText() != null)
{
String password = (String) txtPassword.getText();
if( password.trim().length() > 0 )
{
try
{
UtilizadoresDataProvider udp = UtilizadoresDataProvider.getInstance();
Utilizador u = udp.getUtilizador( utilizador );
if( u != null && "y".equals( u.getActivo() ) )
{
if ( ! password.equals( u.getPassword() ) )
{
getSessionBean1().setMsg( "Palavra-chave inv&aacute;lida !" );
}
else
{
Utils.doLogin( u );
getSessionBean1().setCurrentUser( u );
getSessionBean1().setLoggedIn( true );
sRet = "lista_planos";
}
}
else
{
getSessionBean1().setMsg("Utilizador inv&aacute;lido ! ");
}
}
catch(Exception ex)
{
ErrorLogger.logException( ex );
getSessionBean1().setMsg("Utilizador inv&aacute;lido ! ");
}
}
else
{
getSessionBean1().setMsg("Falta palavra-chave !");
}
}
else
{
getSessionBean1().setMsg("Falta palavra-chave !");
}
}
else
{
getSessionBean1().setMsg("Falta utilizador !");
}
}
else
{
getSessionBean1().setMsg("Falta utilizador !");
}
return sRet;
}
}

@ -0,0 +1,110 @@
/*
* RequestBean1.java
*
* Created on Aug 25, 2008, 11:20:16 AM
*/
package planosactuacao;
import com.evolute.utils.error.ErrorLogger;
import com.sun.rave.web.ui.appbase.AbstractRequestBean;
import javax.faces.FacesException;
/**
* <p>Request scope data bean for your application. Create properties
* here to represent data that should be made available across different
* pages in the same HTTP request, so that the page bean classes do not
* have to be directly linked to each other.</p>
*
* <p>An instance of this class will be created for you automatically,
* the first time your application evaluates a value binding expression
* or method binding expression that references a managed bean using
* this class.</p>
*
* @author lluis
*/
public class RequestBean1 extends AbstractRequestBean {
// <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>
/**
* <p>Construct a new request data bean instance.</p>
*/
public RequestBean1() {
}
/**
* <p>This method is called when this bean is initially added to
* request scope. Typically, this occurs as a result of evaluating
* a value binding or method binding expression, which utilizes the
* managed bean facility to instantiate this bean and store it into
* request scope.</p>
*
* <p>You may customize this method to allocate resources that are required
* for the lifetime of the current request.</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) {
ErrorLogger.logException( e );
log("RequestBean1 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
}
/**
* <p>This method is called when this bean is removed from
* request scope. This occurs automatically when the corresponding
* HTTP response has been completed and sent to the client.</p>
*
* <p>You may customize this method to clean up resources allocated
* during the execution of the <code>init()</code> method, or
* at any later time during the lifetime of the request.</p>
*/
@Override
public void destroy() {
}
/**
* <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");
}
}

@ -0,0 +1,485 @@
/*
* SessionBean1.java
*
* Created on Aug 25, 2008, 11:20:16 AM
*/
package planosactuacao;
import com.evolute.utils.error.ErrorLogger;
import com.sun.rave.web.ui.appbase.AbstractSessionBean;
import db.entidades.Area;
import db.entidades.PlanoActuacao;
import db.entidades.Risco;
import db.entidades.Utilizador;
import db.entidades.Valor;
import java.util.HashMap;
import java.util.Map;
import javax.faces.FacesException;
import pagination.Pagination;
/**
* <p>Session scope data bean for your application. Create properties
* here to represent cached data that should be made available across
* multiple HTTP requests for an individual user.</p>
*
* <p>An instance of this class will be created for you automatically,
* the first time your application evaluates a value binding expression
* or method binding expression that references a managed bean using
* this class.</p>
*
* @author lluis
*/
public class SessionBean1 extends AbstractSessionBean {
private boolean loggedIn = false;
private Utilizador currentUser = null;
private String msg;
private String aatSessionID = null;
private Integer planoId;
private PlanoActuacao planoActuacao = null;
private Risco currentRisco = null;
private Valor currentValor = null;
private tabledataproviders.PlanosActualDataProvider planosActualDataProvider;
private tabledataproviders.PlanosSeguimentoDataProvider planosSeguimentoDataProvider;
private tabledataproviders.PlanosConcluidosDataProvider planosConcluidosDataProvider;
private tabledataproviders.EstatisticaPlanoDataProvider estatisticaPlanoDataProvider;
// <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>
//menu
private boolean disableMenu = false;
private boolean disableMenuAnalises = false;
private boolean disableMenuPlanos = false;
private boolean disableMenuUtilizadores = false;
private boolean disableMenuDadosUtilizador = false;
private boolean disableMenuEstatisticas = false;
private boolean renderSubHeader = false;
private boolean renderTopMenuImages = true;
//fase
private int fase = 1;
private HashMap<Integer, Valor> valoresHash;
private HashMap<Integer, Area> areasHash;
private HashMap<Integer, Risco> riscosHash;
private Integer anoChoice;
public enum PAGINATION_ENUM
{
NORMAL( 0, "Normal" ),
PATRIMONIAIS( 1, "Patrimoniais" )
;
private Integer code = null;
private String type = null;
PAGINATION_ENUM( Integer code, String type )
{
this.code = code;
this.type = type;
}
public Integer getCode()
{
return code;
}
public String getType()
{
return type;
}
}
private Map< PAGINATION_ENUM, Pagination > paginationMap = null;
// private Pagination pagination = null;
private String logoEmpresaUrl = "";
private Boolean isSearchingPlanosActuacao = Boolean.FALSE;
/**
* <p>Construct a new session data bean instance.</p>
*/
public SessionBean1() {
msg = "";
planosActualDataProvider = new tabledataproviders.PlanosActualDataProvider();
planosSeguimentoDataProvider = new tabledataproviders.PlanosSeguimentoDataProvider();
planosConcluidosDataProvider = new tabledataproviders.PlanosConcluidosDataProvider();
estatisticaPlanoDataProvider = new tabledataproviders.EstatisticaPlanoDataProvider();
planoId = null;
}
/**
* <p>This method is called when this bean is initially added to
* session scope. Typically, this occurs as a result of evaluating
* a value binding or method binding expression, which utilizes the
* managed bean facility to instantiate this bean and store it into
* session scope.</p>
*
* <p>You may customize this method to initialize and cache data values
* or resources that are required for the lifetime of a particular
* user session.</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) {
ErrorLogger.logException( e );
log("SessionBean1 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
}
/**
* <p>This method is called when the session containing it is about to be
* passivated. Typically, this occurs in a distributed servlet container
* when the session is about to be transferred to a different
* container instance, after which the <code>activate()</code> method
* will be called to indicate that the transfer is complete.</p>
*
* <p>You may customize this method to release references to session data
* or resources that can not be serialized with the session itself.</p>
*/
@Override
public void passivate() {
}
/**
* <p>This method is called when the session containing it was
* reactivated.</p>
*
* <p>You may customize this method to reacquire references to session
* data or resources that could not be serialized with the
* session itself.</p>
*/
@Override
public void activate() {
}
/**
* <p>This method is called when this bean is removed from
* session scope. Typically, this occurs as a result of
* the session timing out or being terminated by the application.</p>
*
* <p>You may customize this method to clean up resources allocated
* during the execution of the <code>init()</code> method, or
* at any later time during the lifetime of the application.</p>
*/
@Override
public void destroy() {
}
/**
* <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 getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public boolean isLoggedIn() {
return loggedIn;
}
public void setLoggedIn(boolean loggedIn) {
this.loggedIn = loggedIn;
}
public tabledataproviders.PlanosActualDataProvider getPlanosActualDataProvider() {
return planosActualDataProvider;
}
public void setPlanosActualDataProvider(tabledataproviders.PlanosActualDataProvider planosActualDataProvider) {
this.planosActualDataProvider = planosActualDataProvider;
}
public tabledataproviders.PlanosSeguimentoDataProvider getPlanosSeguimentoDataProvider() {
return planosSeguimentoDataProvider;
}
public void setPlanosSeguimentoDataProvider(tabledataproviders.PlanosSeguimentoDataProvider planosSeguimentoDataProvider) {
this.planosSeguimentoDataProvider = planosSeguimentoDataProvider;
}
public tabledataproviders.PlanosConcluidosDataProvider getPlanosConcluidosDataProvider() {
return planosConcluidosDataProvider;
}
public void setPlanosConcluidosDataProvider(tabledataproviders.PlanosConcluidosDataProvider planosConcluidosDataProvider) {
this.planosConcluidosDataProvider = planosConcluidosDataProvider;
}
public tabledataproviders.EstatisticaPlanoDataProvider getEstatisticaPlanoDataProvider() {
return estatisticaPlanoDataProvider;
}
public void setEstatisticaPlanoDataProvider(tabledataproviders.EstatisticaPlanoDataProvider estatisticaPlanoDataProvider) {
this.estatisticaPlanoDataProvider = estatisticaPlanoDataProvider;
}
public Integer getPlanoId() {
return planoId;
}
public void setPlanoId(Integer planoId) {
this.planoId = planoId;
}
public Utilizador getCurrentUser() {
return currentUser;
}
public void setCurrentUser(Utilizador currentUser) {
this.currentUser = currentUser;
}
public boolean isDisableMenu() {
return disableMenu;
}
public void setDisableMenu(boolean disableMenu) {
System.out.println("DISABLE MENU : " + disableMenu);
setDisableMenuAnalises(disableMenu);
//setDisableMenuPlanos(disableMenu);
setDisableMenuUtilizadores(disableMenu);
setDisableMenuDadosUtilizador(disableMenu);
this.disableMenu = disableMenu;
}
public boolean isDisableMenuAnalises() {
return disableMenuAnalises;
}
public void setDisableMenuAnalises(boolean disableMenuAnalises) {
this.disableMenuAnalises = disableMenuAnalises;
}
public boolean isDisableMenuPlanos() {
return disableMenuPlanos;
}
public void setDisableMenuPlanos(boolean disableMenuPlanos) {
this.disableMenuPlanos = disableMenuPlanos;
}
public boolean isDisableMenuUtilizadores() {
return disableMenuUtilizadores;
}
public void setDisableMenuUtilizadores(boolean disableMenuUtilizadores) {
this.disableMenuUtilizadores = disableMenuUtilizadores;
}
public boolean isDisableMenuDadosUtilizador() {
return disableMenuDadosUtilizador;
}
public void setDisableMenuDadosUtilizador(boolean disableMenuDadosUtilizador) {
this.disableMenuDadosUtilizador = disableMenuDadosUtilizador;
}
public boolean isDisableMenuEstatisticas() {
return disableMenuEstatisticas;
}
public void setDisableMenuEstatisticas(boolean disableMenuEstatisticas) {
this.disableMenuEstatisticas = disableMenuEstatisticas;
}
public int getFase() {
return fase;
}
public void setFase(int fase) {
this.fase = fase;
}
public PlanoActuacao getPlanoActuacao() {
return planoActuacao;
}
public void setPlanoActuacao(PlanoActuacao planoActuacao) {
this.planoActuacao = planoActuacao;
}
private Integer irParaChoice;
public Integer getIrParaChoice() {
return irParaChoice;
}
public void setIrParaChoice(Integer irParaChoice) {
this.irParaChoice = irParaChoice;
}
private com.sun.webui.jsf.model.Option[] irParaOptions;
public com.sun.webui.jsf.model.Option[] getIrParaOptions() {
return irParaOptions;
}
public void setIrParaOptions(com.sun.webui.jsf.model.Option[] irParaOptions) {
this.irParaOptions = irParaOptions;
}
public HashMap<Integer, Area> getAreasHash() {
return areasHash;
}
public void setAreasHash(HashMap<Integer, Area> areasHash) {
this.areasHash = areasHash;
}
public HashMap<Integer, Risco> getRiscosHash() {
return riscosHash;
}
public void setRiscosHash(HashMap<Integer, Risco> riscosHash) {
this.riscosHash = riscosHash;
}
public void addPagination( PAGINATION_ENUM type, Pagination pagination )
{
if ( paginationMap == null )
{
paginationMap = new HashMap< PAGINATION_ENUM, Pagination >();
}
paginationMap.put( type, pagination );
}
public Pagination getPagination( PAGINATION_ENUM type )
{
Pagination pagination = null;
if ( paginationMap != null )
{
pagination = paginationMap.get( type );
}
return pagination;
}
// public Pagination getPagination() {
// return pagination;
// }
//
// public void setPagination(Pagination pagination) {
// this.pagination = pagination;
// }
public Risco getCurrentRisco() {
return currentRisco;
}
public void setCurrentRisco(Risco currentRisco) {
this.currentRisco = currentRisco;
}
public boolean isRenderSubHeader() {
return renderSubHeader;
}
public void setRenderSubHeader(boolean renderSubHeader) {
this.renderSubHeader = renderSubHeader;
}
public boolean isRenderTopMenuImages() {
return renderTopMenuImages;
}
public void setRenderTopMenuImages(boolean renderTopMenuImages) {
this.renderTopMenuImages = renderTopMenuImages;
}
public Valor getCurrentValor() {
return currentValor;
}
public void setCurrentValor(Valor currentValor) {
this.currentValor = currentValor;
}
public HashMap<Integer, Valor> getValoresHash() {
return valoresHash;
}
public void setValoresHash(HashMap<Integer, Valor> valoresHash) {
this.valoresHash = valoresHash;
}
public String getLogoEmpresaUrl() {
return logoEmpresaUrl;
}
public void setLogoEmpresaUrl(String logoEmpresaUrl) {
this.logoEmpresaUrl = logoEmpresaUrl;
}
public Boolean getIsSearchingPlanosActuacao() {
return isSearchingPlanosActuacao;
}
public void setIsSearchingPlanosActuacao(Boolean isSearchingPlanosActuacao) {
this.isSearchingPlanosActuacao = isSearchingPlanosActuacao;
}
public String getAatSessionID() {
return aatSessionID;
}
public void setAatSessionID(String aatSessionID) {
this.aatSessionID = aatSessionID;
}
public Integer getAnoChoice()
{
return anoChoice;
}
public void setAnoChoice( Integer anoChoice )
{
this.anoChoice = anoChoice;
}
}

@ -0,0 +1,74 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package planosactuacao;
import db.entidades.Area;
import db.entidades.Medida;
import db.entidades.PlanoActuacao;
import db.entidades.PostoTrabalho;
import db.entidades.Risco;
import db.entidades.Valor;
import java.util.List;
/**
*
* @author lluis
*/
public class Test {
private PlanoActuacao p;
public static void showPlanoTree(PlanoActuacao p)
{
System.out.println("=====================================================");
System.out.println(" PLANO : " + p.getData_visita_str());
showAreas(p.getAreas());
System.out.println("=====================================================");
}
private static void showAreas(List<Area> areas)
{
for(Area a : areas)
{
System.out.println("\t" + a.getDescricao());
showRiscos(a.getRiscos());
}
}
private static void showRiscos(List<Risco> riscos)
{
for(Risco r : riscos)
{
System.out.println("\t\t" + r.getDescricao());
showValores(r.getValores());
}
}
private static void showValores(List<Valor> valores)
{
for(Valor v : valores)
{
System.out.println("\t\t\t" + v.getValorQuantitativo());
// showMedidas(v.getMedidas());
}
}
private static void showMedidas(List<Medida> medidas)
{
for(Medida m : medidas)
{
System.out.println("\t\t\t" + m.getDescricao());
showPostos(m.getPostos());
}
}
private static void showPostos(List<PostoTrabalho> postos)
{
for(PostoTrabalho p : postos)
{
System.out.println("\t\t\t\t" + p.getDescricao());
}
}
}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save