You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SIPRP/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/GestaoUtilizadores.java

1317 lines
36 KiB

/*
* GestaoUtilizadores.java
*
* Created on November 30, 2007, 1:34 PM
* Copyright lluis
*/
package analiseacidentestrabalho;
import beans.Utilizador;
import com.evolute.utils.error.ErrorLogger;
import com.sun.data.provider.RowKey;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.rave.web.ui.component.Body;
import com.sun.rave.web.ui.component.Button;
import com.sun.rave.web.ui.component.DropDown;
import com.sun.rave.web.ui.component.Form;
import com.sun.rave.web.ui.component.Head;
import com.sun.rave.web.ui.component.Html;
import com.sun.rave.web.ui.component.Hyperlink;
import com.sun.rave.web.ui.component.ImageComponent;
import com.sun.rave.web.ui.component.Link;
import com.sun.rave.web.ui.component.Page;
import com.sun.rave.web.ui.component.PanelGroup;
import com.sun.rave.web.ui.component.StaticText;
import com.sun.rave.web.ui.component.Table;
import com.sun.rave.web.ui.component.TableColumn;
import com.sun.rave.web.ui.component.TableRowGroup;
import com.sun.rave.web.ui.component.TextField;
import com.sun.rave.web.ui.model.SingleSelectOptionsList;
import db.providers.AnalisesDataProvider;
import db.providers.UtilizadoresActivosListDataProvider;
import db.providers.UtilizadoresDataProvider;
import db.providers.UtilizadoresInactivosListDataProvider;
import global.Global;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.faces.FacesException;
import javax.faces.component.html.HtmlPanelGrid;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
import javax.servlet.http.HttpServletRequest;
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>
*/
public class GestaoUtilizadores extends AbstractPageBean
{
// <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
private int __placeholder;
/**
* <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 Page page1 = new Page();
public Page getPage1() {
return page1;
}
public void setPage1(Page p) {
this.page1 = p;
}
private Html html1 = new Html();
public Html getHtml1() {
return html1;
}
public void setHtml1(Html h) {
this.html1 = h;
}
private Head head1 = new Head();
public Head getHead1() {
return head1;
}
public void setHead1(Head h) {
this.head1 = h;
}
private Link link1 = new Link();
public Link getLink1() {
return link1;
}
public void setLink1(Link l) {
this.link1 = l;
}
private Body body1 = new Body();
public Body getBody1() {
return body1;
}
public void setBody1(Body b) {
this.body1 = b;
}
private Form form1 = new Form();
public Form getForm1() {
return form1;
}
public void setForm1(Form f) {
this.form1 = f;
}
private HtmlPanelGrid gridBase1 = new HtmlPanelGrid();
public HtmlPanelGrid getGridBase1() {
return gridBase1;
}
public void setGridBase1(HtmlPanelGrid hpg) {
this.gridBase1 = hpg;
}
private HtmlPanelGrid gridLayout1 = new HtmlPanelGrid();
public HtmlPanelGrid getGridLayout1() {
return gridLayout1;
}
public void setGridLayout1(HtmlPanelGrid hpg) {
this.gridLayout1 = hpg;
}
private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid();
public HtmlPanelGrid getGridPanel1() {
return gridPanel1;
}
public void setGridPanel1(HtmlPanelGrid hpg) {
this.gridPanel1 = hpg;
}
private PanelGroup groupPanel1 = new PanelGroup();
public PanelGroup getGroupPanel1() {
return groupPanel1;
}
public void setGroupPanel1(PanelGroup pg) {
this.groupPanel1 = pg;
}
private ImageComponent image1 = new ImageComponent();
public ImageComponent getImage1() {
return image1;
}
public void setImage1(ImageComponent ic) {
this.image1 = ic;
}
private ImageComponent image2 = new ImageComponent();
public ImageComponent getImage2() {
return image2;
}
public void setImage2(ImageComponent ic) {
this.image2 = ic;
}
private HtmlPanelGrid gridConcluidos1 = new HtmlPanelGrid();
public HtmlPanelGrid getGridConcluidos1() {
return gridConcluidos1;
}
public void setGridConcluidos1(HtmlPanelGrid hpg) {
this.gridConcluidos1 = hpg;
}
private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid();
public HtmlPanelGrid getGridPanel6() {
return gridPanel6;
}
public void setGridPanel6(HtmlPanelGrid hpg) {
this.gridPanel6 = hpg;
}
private StaticText staticText5 = new StaticText();
public StaticText getStaticText5() {
return staticText5;
}
public void setStaticText5(StaticText st) {
this.staticText5 = st;
}
private HtmlPanelGrid gridPanel7 = new HtmlPanelGrid();
public HtmlPanelGrid getGridPanel7() {
return gridPanel7;
}
public void setGridPanel7(HtmlPanelGrid hpg) {
this.gridPanel7 = hpg;
}
private PanelGroup groupPanel6 = new PanelGroup();
public PanelGroup getGroupPanel6() {
return groupPanel6;
}
public void setGroupPanel6(PanelGroup pg) {
this.groupPanel6 = pg;
}
private StaticText staticText7 = new StaticText();
public StaticText getStaticText7() {
return staticText7;
}
public void setStaticText7(StaticText st) {
this.staticText7 = st;
}
private TextField txtPor = new TextField();
public TextField getTxtPor() {
return txtPor;
}
public void setTxtPor(TextField tf) {
this.txtPor = tf;
}
private PanelGroup groupPanel7 = new PanelGroup();
public PanelGroup getGroupPanel7() {
return groupPanel7;
}
public void setGroupPanel7(PanelGroup pg) {
this.groupPanel7 = pg;
}
private PanelGroup groupPanelLogin = new PanelGroup();
public PanelGroup getGroupPanelLogin() {
return groupPanelLogin;
}
public void setGroupPanelLogin(PanelGroup groupPanelLogin) {
this.groupPanelLogin = groupPanelLogin;
}
private TextField txtLogin = new TextField();
public TextField getTxtLogin() {
return txtLogin;
}
public void setTxtLogin(TextField txtLogin) {
this.txtLogin = txtLogin;
}
private StaticText staticTextLogin = new StaticText();
public StaticText getStaticTextLogin() {
return staticTextLogin;
}
public void setStaticTextLogin(StaticText staticTextLogin) {
this.staticTextLogin = staticTextLogin;
}
private StaticText staticText8 = new StaticText();
public StaticText getStaticText8() {
return staticText8;
}
public void setStaticText8(StaticText st) {
this.staticText8 = st;
}
private TextField txtNome = new TextField();
public TextField getTxtNome() {
return txtNome;
}
public void setTxtNome(TextField tf) {
this.txtNome = tf;
}
private Button butPesquisar = new Button();
public Button getButPesquisar() {
return butPesquisar;
}
public void setButPesquisar(Button b) {
this.butPesquisar = b;
}
private HtmlPanelGrid gridPanel8 = new HtmlPanelGrid();
public HtmlPanelGrid getGridPanel8() {
return gridPanel8;
}
public void setGridPanel8(HtmlPanelGrid hpg) {
this.gridPanel8 = hpg;
}
private Table table3 = new Table();
public Table getTable3() {
return table3;
}
public void setTable3(Table t) {
this.table3 = t;
}
private TableRowGroup tableRowGroup3 = new TableRowGroup();
public TableRowGroup getTableRowGroup3() {
return tableRowGroup3;
}
public void setTableRowGroup3(TableRowGroup trg) {
this.tableRowGroup3 = trg;
}
private TableColumn tableColumn11 = new TableColumn();
public TableColumn getTableColumn11() {
return tableColumn11;
}
public void setTableColumn11(TableColumn tc) {
this.tableColumn11 = tc;
}
private Hyperlink lnkCategoriaActivos = new Hyperlink();
public Hyperlink getLnkCategoriaActivos() {
return lnkCategoriaActivos;
}
public void setLnkCategoriaActivos(Hyperlink h) {
this.lnkCategoriaActivos = h;
}
private TableColumn tableColumn13 = new TableColumn();
public TableColumn getTableColumn13() {
return tableColumn13;
}
public void setTableColumn13(TableColumn tc) {
this.tableColumn13 = tc;
}
private Hyperlink lnkPorActivos = new Hyperlink();
public Hyperlink getLnkPorActivos() {
return lnkPorActivos;
}
public void setLnkPorActivos(Hyperlink h) {
this.lnkPorActivos = h;
}
private TableColumn tableColumn14 = new TableColumn();
public TableColumn getTableColumn14() {
return tableColumn14;
}
public void setTableColumn14(TableColumn tc) {
this.tableColumn14 = tc;
}
private TableColumn tableColumnLogin = new TableColumn();
public TableColumn getTableColumnLogin() {
return tableColumnLogin;
}
public void setTableColumnLogin(TableColumn tableColumnLogin) {
this.tableColumnLogin = tableColumnLogin;
}
private Hyperlink lnkLoginActivos = new Hyperlink();
public Hyperlink getLnkLoginActivos() {
return lnkLoginActivos;
}
private TableColumn tableColumnLoginInactivos = new TableColumn();
public TableColumn getTableColumnLoginInactivos() {
return tableColumnLoginInactivos;
}
public void setTableColumnLoginInactivos(TableColumn tableColumnLoginInactivos) {
this.tableColumnLoginInactivos = tableColumnLoginInactivos;
}
private Hyperlink lnkLoginInactivos = new Hyperlink();
public Hyperlink getLnkLoginInactivos() {
return lnkLoginInactivos;
}
public void setLnkLoginInactivos(Hyperlink lnkLoginInactivos) {
this.lnkLoginInactivos = lnkLoginInactivos;
}
public void setLnkLoginActivos(Hyperlink lnkLoginActivos) {
this.lnkLoginActivos = lnkLoginActivos;
}
private Hyperlink lnkNomeActivos = new Hyperlink();
public Hyperlink getLnkNomeActivos() {
return lnkNomeActivos;
}
public void setLnkNomeActivos(Hyperlink h) {
this.lnkNomeActivos = h;
}
private TableColumn tableColumn15 = new TableColumn();
public TableColumn getTableColumn15() {
return tableColumn15;
}
public void setTableColumn15(TableColumn tc) {
this.tableColumn15 = tc;
}
private Hyperlink lnkEstabelecimentoActivos = new Hyperlink();
public Hyperlink getLnkEstabelecimentoActivos() {
return lnkEstabelecimentoActivos;
}
public void setLnkEstabelecimentoActivos(Hyperlink h) {
this.lnkEstabelecimentoActivos = h;
}
private StaticText txtSearchMsg1 = new StaticText();
public StaticText getTxtSearchMsg1() {
return txtSearchMsg1;
}
public void setTxtSearchMsg1(StaticText st) {
this.txtSearchMsg1 = st;
}
private HtmlPanelGrid gridPanel9 = new HtmlPanelGrid();
public HtmlPanelGrid getGridPanel9() {
return gridPanel9;
}
public void setGridPanel9(HtmlPanelGrid hpg) {
this.gridPanel9 = hpg;
}
private PanelGroup groupPanel8 = new PanelGroup();
public PanelGroup getGroupPanel8() {
return groupPanel8;
}
public void setGroupPanel8(PanelGroup pg) {
this.groupPanel8 = pg;
}
private StaticText staticText9 = new StaticText();
public StaticText getStaticText9() {
return staticText9;
}
public void setStaticText9(StaticText st) {
this.staticText9 = st;
}
private ImageComponent image3 = new ImageComponent();
public ImageComponent getImage3() {
return image3;
}
public void setImage3(ImageComponent ic) {
this.image3 = ic;
}
private StaticText staticText10 = new StaticText();
public StaticText getStaticText10() {
return staticText10;
}
public void setStaticText10(StaticText st) {
this.staticText10 = st;
}
private PanelGroup groupPanel3 = new PanelGroup();
public PanelGroup getGroupPanel3() {
return groupPanel3;
}
public void setGroupPanel3(PanelGroup pg) {
this.groupPanel3 = pg;
}
private StaticText staticText2 = new StaticText();
public StaticText getStaticText2() {
return staticText2;
}
public void setStaticText2(StaticText st) {
this.staticText2 = st;
}
private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid();
public HtmlPanelGrid getGridPanel2() {
return gridPanel2;
}
public void setGridPanel2(HtmlPanelGrid hpg) {
this.gridPanel2 = hpg;
}
private Table table1 = new Table();
public Table getTable1() {
return table1;
}
public void setTable1(Table t) {
this.table1 = t;
}
private TableRowGroup tableRowGroup1 = new TableRowGroup();
public TableRowGroup getTableRowGroup1() {
return tableRowGroup1;
}
public void setTableRowGroup1(TableRowGroup trg) {
this.tableRowGroup1 = trg;
}
private TableColumn tableColumn1 = new TableColumn();
public TableColumn getTableColumn1() {
return tableColumn1;
}
public void setTableColumn1(TableColumn tc) {
this.tableColumn1 = tc;
}
private Hyperlink lnkPorInactivos = new Hyperlink();
public Hyperlink getLnkPorInactivos() {
return lnkPorInactivos;
}
public void setLnkPorInactivos(Hyperlink h) {
this.lnkPorInactivos = h;
}
private TableColumn tableColumn2 = new TableColumn();
public TableColumn getTableColumn2() {
return tableColumn2;
}
public void setTableColumn2(TableColumn tc) {
this.tableColumn2 = tc;
}
private Hyperlink lnkNomeInactivos = new Hyperlink();
public Hyperlink getLnkNomeInactivos() {
return lnkNomeInactivos;
}
public void setLnkNomeInactivos(Hyperlink h) {
this.lnkNomeInactivos = h;
}
private TableColumn tableColumn3 = new TableColumn();
public TableColumn getTableColumn3() {
return tableColumn3;
}
public void setTableColumn3(TableColumn tc) {
this.tableColumn3 = tc;
}
private Hyperlink lnkCategoriaInactivos = new Hyperlink();
public Hyperlink getLnkCategoriaInactivos() {
return lnkCategoriaInactivos;
}
public void setLnkCategoriaInactivos(Hyperlink h) {
this.lnkCategoriaInactivos = h;
}
private TableColumn tableColumn4 = new TableColumn();
public TableColumn getTableColumn4() {
return tableColumn4;
}
public void setTableColumn4(TableColumn tc) {
this.tableColumn4 = tc;
}
private Hyperlink lnkEstabelecimentoInactivos = new Hyperlink();
public Hyperlink getLnkEstabelecimentoInactivos() {
return lnkEstabelecimentoInactivos;
}
public void setLnkEstabelecimentoInactivos(Hyperlink h) {
this.lnkEstabelecimentoInactivos = h;
}
private StaticText txtSearchMsg2 = new StaticText();
public StaticText getTxtSearchMsg2() {
return txtSearchMsg2;
}
public void setTxtSearchMsg2(StaticText st) {
this.txtSearchMsg2 = st;
}
private DropDown drpEstabelecimentos = new DropDown();
public DropDown getDrpEstabelecimentos() {
return drpEstabelecimentos;
}
public void setDrpEstabelecimentos(DropDown dd) {
this.drpEstabelecimentos = dd;
}
private SingleSelectOptionsList drpEstabelecimentosDefaultOptions = new SingleSelectOptionsList();
public SingleSelectOptionsList getDrpEstabelecimentosDefaultOptions() {
return drpEstabelecimentosDefaultOptions;
}
public void setDrpEstabelecimentosDefaultOptions(SingleSelectOptionsList ssol) {
this.drpEstabelecimentosDefaultOptions = ssol;
}
// </editor-fold>
boolean isPostback = false;
private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid();
public HtmlPanelGrid getGridPanel3() {
return gridPanel3;
}
public void setGridPanel3(HtmlPanelGrid hpg) {
this.gridPanel3 = hpg;
}
private StaticText staticText3 = new StaticText();
public StaticText getStaticText3() {
return staticText3;
}
public void setStaticText3(StaticText st) {
this.staticText3 = st;
}
private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid();
public HtmlPanelGrid getGridPanel5() {
return gridPanel5;
}
public void setGridPanel5(HtmlPanelGrid hpg) {
this.gridPanel5 = hpg;
}
private Button butNovoUtilizador = new Button();
public Button getButNovoUtilizador() {
return butNovoUtilizador;
}
public void setButNovoUtilizador(Button b) {
this.butNovoUtilizador = b;
}
private HtmlPanelGrid gridMsg1 = new HtmlPanelGrid();
public HtmlPanelGrid getGridMsg1() {
return gridMsg1;
}
public void setGridMsg1(HtmlPanelGrid hpg) {
this.gridMsg1 = hpg;
}
private StaticText txtMsg = new StaticText();
public StaticText getTxtMsg() {
return txtMsg;
}
public void setTxtMsg(StaticText st) {
this.txtMsg = st;
}
private StaticText lblUser = new StaticText();
public StaticText getLblUser() {
return lblUser;
}
public void setLblUser(StaticText st) {
this.lblUser = st;
}
private Hyperlink lnkPlanosActuacao = new Hyperlink();
public Hyperlink getLnkPlanosActuacao() {
return lnkPlanosActuacao;
}
public void setLnkPlanosActuacao(Hyperlink h) {
this.lnkPlanosActuacao = h;
}
/**
* <p>Construct a new Page bean instance.</p>
*/
public GestaoUtilizadores() {
}
/**
* <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
// <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("GestaoUtilizadores 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
if ( ! getSessionBean1().isLoggedIn() )
{
try
{
getExternalContext().redirect("Login.jsp");
}
catch ( Exception e )
{
// . . . handle exception . . .
}
}
else
{
lblUser.setText( getSessionBean1().getCurrentUser().getLogin() );
HttpServletRequest request = (HttpServletRequest) getExternalContext().getRequest();
String referer = request.getRequestURI();
String pageFrom = Utils.getPageFrom(referer);
boolean userDeleted = getSessionBean1().isUserDeleted();
if(userDeleted)
{
getSessionBean1().setUserDeleted(false);
}
FacesContext fc = getFacesContext();
Map parameters = fc.getCurrentInstance().getExternalContext().getRequestParameterMap();
if(!pageFrom.matches("GestaoUtilizadores.jsp") || userDeleted || parameters.size() > 0)
{
isPostback = false;
}
else
{
isPostback = true;
}
}
}
/**
* <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>
*/
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()
{
Utilizador u = getSessionBean1().getCurrentUser();
if(u.getTipo().intValue() != Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP)
{
lnkPlanosActuacao.setDisabled(true);
}
System.out.println("POSTBACK : " + isPostback);
if ( ! isPostback )
{
try
{
AnalisesDataProvider adp = AnalisesDataProvider.getInstance();
com.sun.rave.web.ui.model.Option[] listOptions = adp.getEstabelecimentosList( getSessionBean1().getCurrentUser().getEmpresa_id(), new Boolean(false));
listOptions[0].setLabel("-Todos-");
getSessionBean1().setEstabelecimentosOptions( listOptions );
drpEstabelecimentos.setSelected(new Integer(-1));
}
catch(Exception ex)
{
ErrorLogger.logException( ex );
}
if ( ! getSessionBean1().getIsSearchingUtilizadores() )
{
String isDirRh = "n";
if(getSessionBean1().getCurrentUser().getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_GERAL_RH) // Director geral rh
{
isDirRh = "y";
}
try
{
UtilizadoresDataProvider udp = UtilizadoresDataProvider.getInstance();
List< Utilizador > listUtilizadores = udp.getUtilizadoresList( null, null, null, null, "y", isDirRh );
// List< Utilizador > listUtilizadores = udp.getUtilizadoresList( null, null, null, "y", isDirRh );
getSessionBean1().getUtilizadoresActivosListDataProvider().setList( listUtilizadores );
}
catch(Exception ex)
{
ErrorLogger.logException( ex );
}
try
{
UtilizadoresDataProvider udp = UtilizadoresDataProvider.getInstance();
List< Utilizador > listUtilizadores = udp.getUtilizadoresList( null, null, null, null, "n", isDirRh );
// List< Utilizador > listUtilizadores = udp.getUtilizadoresList( null, null, null, "n", isDirRh );
getSessionBean1().getUtilizadoresInactivosListDataProvider().setList( listUtilizadores );
}
catch(Exception ex)
{
ErrorLogger.logException( ex );
getSessionBean1().getUtilizadoresInactivosListDataProvider().setList( new LinkedList() );
table1.setRendered(false);
}
}
}
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>
*/
public void destroy() {
}
/**
* <p>Return a reference to the scoped data bean.</p>
*/
protected RequestBean1 getRequestBean1() {
return (RequestBean1)getBean("RequestBean1");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*/
protected SessionBean1 getSessionBean1() {
return (SessionBean1)getBean("SessionBean1");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*/
protected ApplicationBean1 getApplicationBean1()
{
return (ApplicationBean1)getBean("ApplicationBean1");
}
public String lnkEditUser_action()
{
getSessionBean1().setNavFrom("GestaoUtilizadores");
getSessionBean1().setModoEdicaoUtilizador("edit");
return "user";
}
public String lnkLogout_action()
{
Utils.doLogout( getExternalContext(), true );
return null;
}
public String butNovaAnalise_action()
{
return null;
}
public String lnkDataAcidente_action()
{
return null;
}
public String lnkNr_action()
{
return null;
}
public String lnkPor_action()
{
return null;
}
public String lnkNomeAcidentado_action()
{
return null;
}
public String lnkFase_action()
{
return null;
}
public String lnkDataAcidenteSeg_action()
{
return null;
}
public String lnkNrSeg_action()
{
return null;
}
public String lnkPorSeg_action()
{
return null;
}
public String lnkNomeAcidentadoSeg_action()
{
return null;
}
public String lnkFaseSeg_action()
{
return null;
}
public void drpAno_processValueChange(ValueChangeEvent event)
{
}
public void drpMes_processValueChange(ValueChangeEvent event)
{
}
public void drpDia_processValueChange(ValueChangeEvent event)
{
}
public String butPesquisar_action()
{
String por = null;
String nome = null;
Integer estabelecimento_id = null;
String login = null;
if(txtPor.getText() != null)
{
por = (String) txtPor.getText();
if(por.trim().length() == 0)
{
por = null;
}
else
{
por = por.toLowerCase();
}
}
if(txtNome.getText() != null)
{
nome = (String) txtNome.getText();
if(nome.trim().length() == 0)
{
nome = null;
}
else
{
nome = nome.toLowerCase();
}
}
if ( txtLogin.getText() != null )
{
login = ( String ) txtLogin.getText();
if ( login == null || "".equals( login.trim() ) )
{
login = null;
}
else
{
login = login.toLowerCase();
}
}
estabelecimento_id = (Integer) drpEstabelecimentos.getSelected();
if(estabelecimento_id.intValue() == -1)
{
estabelecimento_id = null;
}
String isDirRh = "n";
if(getSessionBean1().getCurrentUser().getTipo().intValue() == 7) //director geral rh
{
isDirRh = "y";
}
try
{
UtilizadoresDataProvider udp = UtilizadoresDataProvider.getInstance();
getSessionBean1().setIsSearchingUtilizadores( true );
List< Utilizador > listUtilizadores = udp.getUtilizadoresList( por, nome, login, estabelecimento_id, "y", isDirRh );
// List< Utilizador > listUtilizadores = udp.getUtilizadoresList( por, nome, estabelecimento_id, "y", isDirRh );
getSessionBean1().getUtilizadoresActivosListDataProvider().setList( listUtilizadores );
}
catch(Exception ex)
{
ErrorLogger.logException( ex );
getSessionBean1().getUtilizadoresActivosListDataProvider().setList( new LinkedList< Utilizador >() );
}
try
{
UtilizadoresDataProvider udp = UtilizadoresDataProvider.getInstance();
getSessionBean1().setIsSearchingUtilizadores( true );
List< Utilizador > listUtilizadores = udp.getUtilizadoresList( por, nome, login, estabelecimento_id, "n", isDirRh );
// List< Utilizador > listUtilizadores = udp.getUtilizadoresList( por, nome, estabelecimento_id, "n", isDirRh );
getSessionBean1().getUtilizadoresInactivosListDataProvider().setList( listUtilizadores );
}
catch(Exception ex)
{
ErrorLogger.logException( ex );
getSessionBean1().getUtilizadoresInactivosListDataProvider().setList( new LinkedList< Utilizador >() );
}
return null;
}
public String lnkPorActivos_action()
{
Utilizador u = getUtilizadorActivoRowData();
getSessionBean1().setEditUser(u);
getSessionBean1().setModoEdicaoUtilizador("edit");
getSessionBean1().setNavFrom("GestaoUtilizadores");
return "user_fields";
}
public String lnkNomeActivos_action()
{
Utilizador u = getUtilizadorActivoRowData();
System.out.println("UTILIZADOR ID : " + u.getId());
getSessionBean1().setEditUser(u);
getSessionBean1().setModoEdicaoUtilizador("edit");
getSessionBean1().setNavFrom("GestaoUtilizadores");
return "user_fields";
}
public String lnkLoginActivos_action()
{
Utilizador u = getUtilizadorActivoRowData();
getSessionBean1().setEditUser( u );
getSessionBean1().setModoEdicaoUtilizador( "edit" );
getSessionBean1().setNavFrom( "GestaoUtilizadores" );
return "user_fields";
}
public String lnkCategoriaActivos_action()
{
Utilizador u = getUtilizadorActivoRowData();
getSessionBean1().setEditUser(u);
getSessionBean1().setModoEdicaoUtilizador("edit");
getSessionBean1().setNavFrom("GestaoUtilizadores");
return "user_fields";
}
public String lnkEstabelecimentosActivos_action()
{
Utilizador u = getUtilizadorActivoRowData();
getSessionBean1().setEditUser(u);
getSessionBean1().setModoEdicaoUtilizador("edit");
getSessionBean1().setNavFrom("GestaoUtilizadores");
return "user_fields";
}
private Utilizador getUtilizadorActivoRowData()
{
RowKey rk = tableRowGroup3.getRowKey();
int k = Integer.parseInt(rk.getRowId());
UtilizadoresActivosListDataProvider provider = (UtilizadoresActivosListDataProvider) tableRowGroup3.getSourceData();
List< Utilizador > list = ( List< Utilizador > ) provider.getList();
Utilizador u = list.get( k );
return u;
}
public String lnkPorInactivos_action()
{
Utilizador u = getUtilizadorInactivoRowData();
getSessionBean1().setEditUser(u);
getSessionBean1().setModoEdicaoUtilizador("edit");
getSessionBean1().setNavFrom("GestaoUtilizadores");
return "user_fields";
}
public String lnkNomeInactivos_action()
{
Utilizador u = getUtilizadorInactivoRowData();
getSessionBean1().setEditUser(u);
getSessionBean1().setModoEdicaoUtilizador("edit");
getSessionBean1().setNavFrom("GestaoUtilizadores");
return "user_fields";
}
public String lnkLoginInactivos_action()
{
Utilizador u = getUtilizadorInactivoRowData();
getSessionBean1().setEditUser(u);
getSessionBean1().setModoEdicaoUtilizador("edit");
getSessionBean1().setNavFrom("GestaoUtilizadores");
return "user_fields";
}
public String lnkCategoriaInactivos_action()
{
Utilizador u = getUtilizadorInactivoRowData();
getSessionBean1().setEditUser(u);
getSessionBean1().setModoEdicaoUtilizador("edit");
getSessionBean1().setNavFrom("GestaoUtilizadores");
return "user_fields";
}
public String lnkEstabelecimentoInactivos_action()
{
Utilizador u = getUtilizadorInactivoRowData();
getSessionBean1().setEditUser(u);
getSessionBean1().setModoEdicaoUtilizador("edit");
getSessionBean1().setNavFrom("GestaoUtilizadores");
return "user_fields";
}
private Utilizador getUtilizadorInactivoRowData()
{
RowKey rk = tableRowGroup1.getRowKey();
int k = Integer.parseInt(rk.getRowId());
UtilizadoresInactivosListDataProvider provider = (UtilizadoresInactivosListDataProvider) tableRowGroup1.getSourceData();
List< Utilizador > list = ( List< Utilizador > ) provider.getList();
Utilizador u = list.get( k );
return u;
}
public String lnkNewUser_action()
{
return null;
}
public String butNovoUtilizador_action()
{
return "novo_utilizador";
}
public String lnkAnalisesAcidente_action()
{
String nav_from = getSessionBean1().getNavFrom();
Integer tipo_utilizador = getSessionBean1().getCurrentUser().getTipo();
if(tipo_utilizador.intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP)
{
return "form_dir_siprp";
}
else if( tipo_utilizador.intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_GERAL_RH )
{
return "form_dir_ger_rh";
}
return null;
}
public String lnkAjuda_action()
{
// ServletContext theApplicationsServletContext =
// (ServletContext) this.getExternalContext().getContext();
// String pdfFolderPath = theApplicationsServletContext.getRealPath(Global.PDF_FOLDER_URL);
// String pdfFilePath = pdfFolderPath + "/Ajuda.pdf";
//
// Global global = new Global();
// try
// {
// global.showPdf(pdfFilePath);
// }
// catch(Exception ex)
// {
// ErrorLogger.logException( ex );
// }
return null;
}
public String lnkPlanosActuacao_action()
{
Utilizador u = getSessionBean1().getCurrentUser();
// String curUser = "?user=" + u.getId().toString();
FacesContext fc = getFacesContext().getCurrentInstance();
Global.redirectToPlanos(fc, u);
return null;
}
}