diff --git a/trunk/PlanosActuacao/src/java/db/providers/UtilizadoresDataProvider.java b/trunk/PlanosActuacao/src/java/db/providers/UtilizadoresDataProvider.java index 83e332f7..c5a43068 100644 --- a/trunk/PlanosActuacao/src/java/db/providers/UtilizadoresDataProvider.java +++ b/trunk/PlanosActuacao/src/java/db/providers/UtilizadoresDataProvider.java @@ -136,24 +136,28 @@ public class UtilizadoresDataProvider extends GenericDataProvider throws Exception { List< Utilizador > list = new LinkedList< Utilizador >(); - int type = tipo.intValue(); - Expression where = new Field( UtilizadoresData.ACTIVO_FULL ).isEqual( "y" ).and( - new Field( UtilizadoresData.APAGADO_FULL ).isEqual( "n" ) ).and( - new Field( UtilizadoresData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento_id ) - ); - + Expression where = new Field( UtilizadoresData.ACTIVO_FULL ).isEqual( "y" ); + where = where.and( new Field( UtilizadoresData.APAGADO_FULL ).isEqual( "n" ) ); + where = where.and( new Field( UtilizadoresData.TIPO_FULL ).isEqual( type ) ); + if ( type == Global.RESPONSAVEL_SEGURANCA || type == Global.DIRECTOR_LOJA ) + { + where = where.and( new Field( UtilizadoresData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento_id ) ); + } if ( type == Global.RESPONSAVEL_SEGURANCA && "y".equals( responsavel_loja ) ) { where = where.and( new Field( UtilizadoresData.RESPONSAVEL_LOJA_FULL ).isEqual( "y" ) ); } - if ( type == Global.DIRECTOR_LOJA || type == Global.RESPONSAVEL_SEGURANCA || type == Global.DIRECTOR_NACIONAL_SEGURANCA || type == Global.TECNICO_HS ) + if ( type == Global.DIRECTOR_LOJA || type == Global.TECNICO_HS || type == Global.DIRECTOR_NACIONAL_SEGURANCA + || ( type == Global.RESPONSAVEL_SEGURANCA && "y".equals( responsavel_loja ) ) ) { - System.out.println( "UtilizadoresDataProvider . getUtilizadoresListByTipo() : " + where.toString() ); + System.out.println( "\nUtilizadoresDataProvider . getUtilizadoresListByTipo( " + tipo + ", " + responsavel_loja + ", " + estabelecimento_id + " ) : " ); + System.out.println( "\tSQL : SELECT * FROM utilizadores WHERE " + where.toString() ); - List< UtilizadoresData > listData = getProvider().listLoad( UtilizadoresData.class, where, new String[] { UtilizadoresData.NOME }, null ); + List< UtilizadoresData > listData = getProvider().listLoad( + UtilizadoresData.class, where, new String[] { UtilizadoresData.NOME }, null ); for ( UtilizadoresData userData : listData ) { list.add( copyFrom( userData ) ); @@ -161,50 +165,50 @@ public class UtilizadoresDataProvider extends GenericDataProvider } - -// Statement st = createStatement(); // String sql = ""; // String estabelecimento_constraint = ""; -// if(tipo.intValue() == Global.DIRECTOR_LOJA || tipo.intValue() == Global.RESPONSAVEL_SEGURANCA || tipo.intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA) +// if ( type == Global.DIRECTOR_LOJA || type == Global.RESPONSAVEL_SEGURANCA || type == Global.DIRECTOR_NACIONAL_SEGURANCA ) // { // estabelecimento_constraint = " AND estabelecimento_id = " + estabelecimento_id; // } -// if(tipo.intValue() == Global.RESPONSAVEL_SEGURANCA && responsavel_loja.matches("y")) +// if ( type == Global.RESPONSAVEL_SEGURANCA && responsavel_loja.matches( "y" ) ) // { -// sql = "SELECT * FROM utilizadores WHERE activo = 'y' AND apagado = 'n' AND responsavel_loja = 'y' AND tipo = " + tipo + estabelecimento_constraint; +// sql = "SELECT * FROM utilizadores WHERE activo = 'y' AND apagado = 'n' AND tipo = " + tipo + estabelecimento_constraint + " AND responsavel_loja = 'y'"; // } -// else if(tipo.intValue() == Global.DIRECTOR_LOJA || tipo.intValue() == Global.TECNICO_HS || tipo.intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA) +// else if ( type == Global.DIRECTOR_LOJA || type == Global.TECNICO_HS || type == Global.DIRECTOR_NACIONAL_SEGURANCA ) // { // sql = "SELECT * FROM utilizadores WHERE activo = 'y' AND apagado = 'n' AND tipo = " + tipo + estabelecimento_constraint; // } // -// System.out.println("UTILIZADORES LIST BY TIPO SQL : " + sql); -// ResultSet rs = st.executeQuery(sql); -// if(rs.isBeforeFirst()) -// { -// rs.first(); -// do -// { -// Utilizador u = new Utilizador(); -// u.setId(new Integer(rs.getInt("id"))); -// u.setLogin(rs.getString("login")); -// u.setPassword(rs.getString("password")); -// u.setData_password(rs.getDate("data_password")); -// u.setEmail(rs.getString("email")); -// u.setEmpresa_id(new Integer(rs.getInt("empresa_id"))); -// u.setEstabelecimento_id(new Integer(rs.getInt("estabelecimento_id"))); -// u.setAdministrador(rs.getString("administrador")); -// u.setTipo(new Integer(rs.getInt("tipo"))); -// u.setNumero_cedula(rs.getString("numero_cedula")); -// u.setCap(rs.getString("cap")); -// u.setNome(rs.getString("nome")); -// u.setMedico_id(new Integer(rs.getInt("medico_id"))); -// u.setFuncionario_hst_id(new Integer(rs.getInt("funcionario_hst_id"))); -// u.setActivo(rs.getString("activo")); -// u.setResponsavel_loja(rs.getString("responsavel_loja")); -// list.add(u); -// }while(rs.next()); -// } +// System.out.println( "UTILIZADORES LIST BY TIPO SQL : " + sql ); +// Statement st = createStatement(); +// ResultSet rs = st.executeQuery( sql ); +// if ( rs.isBeforeFirst() ) +// { +// rs.first(); +// do +// { +// Utilizador u = new Utilizador(); +// u.setId( new Integer( rs.getInt( "id" ) ) ); +// u.setLogin( rs.getString( "login" ) ); +// u.setPassword( rs.getString( "password" ) ); +// u.setData_password( rs.getDate( "data_password" ) ); +// u.setEmail( rs.getString( "email" ) ); +// u.setEmpresa_id( new Integer( rs.getInt( "empresa_id" ) ) ); +// u.setEstabelecimento_id( new Integer( rs.getInt( "estabelecimento_id" ) ) ); +// u.setAdministrador( rs.getString( "administrador" ) ); +// u.setTipo( new Integer( rs.getInt( "tipo" ) ) ); +// u.setNumero_cedula( rs.getString( "numero_cedula" ) ); +// u.setCap( rs.getString( "cap" ) ); +// u.setNome( rs.getString( "nome" ) ); +// u.setMedico_id( new Integer( rs.getInt( "medico_id" ) ) ); +// u.setFuncionario_hst_id( new Integer( rs.getInt( "funcionario_hst_id" ) ) ); +// u.setActivo( rs.getString( "activo" ) ); +// u.setResponsavel_loja( rs.getString( "responsavel_loja" ) ); +// list.add( u ); +// } +// while ( rs.next() ); +// } return list; } diff --git a/trunk/PlanosActuacao/src/java/global/Global.java b/trunk/PlanosActuacao/src/java/global/Global.java index 8e2d5d20..ddc83805 100644 --- a/trunk/PlanosActuacao/src/java/global/Global.java +++ b/trunk/PlanosActuacao/src/java/global/Global.java @@ -5,6 +5,8 @@ package global; +import com.sun.webui.jsf.component.TextArea; + /** * * @author lluis @@ -58,4 +60,7 @@ public class Global public static final int ESTADO_MEDIDA_IMPLEMENTADA = 1; public static final int ESTADO_MEDIDA_NAO_IMPLEMENTADA = 2; public static final int ESTADO_MEDIDA_EM_IMPLEMENTACAO = 3; + + + public static final int MAX_TEXTAREA_CHARS = 100; } diff --git a/trunk/PlanosActuacao/src/java/planosactuacao/EditarPlano.java b/trunk/PlanosActuacao/src/java/planosactuacao/EditarPlano.java index 19eb670d..01a2d1d0 100644 --- a/trunk/PlanosActuacao/src/java/planosactuacao/EditarPlano.java +++ b/trunk/PlanosActuacao/src/java/planosactuacao/EditarPlano.java @@ -3,7 +3,6 @@ * * Created on Aug 26, 2008, 3:10:59 PM */ - package planosactuacao; import com.evolute.utils.error.ErrorLogger; @@ -66,415 +65,454 @@ import utils.Utils; */ public class EditarPlano extends AbstractPageBean { - // + // + + /** + *

Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.

+ */ + private void _init() throws Exception + { + } + //
+// PlanosDataProvider pdp = new PlanosDataProvider(); + HtmlPanelGrid grid; + PanelGroup pg; + StaticText st; + private HtmlPanelGrid gridLayout = new HtmlPanelGrid(); + //Plano actuacao + PlanoActuacao plano; + //HtmlPanelGrid gridPlano = new HtmlPanelGrid(); + HtmlPanelGrid gridArea; + HtmlPanelGrid gridRisco; + HtmlPanelGrid gridValor; + HtmlPanelGrid gridMedida; + HtmlPanelGrid gridPosto; + HtmlPanelGrid gridResponsavel; + int risco_id = 0; + int medida_id = 0; + int posto_id = 0; + //page components + TextField txtResponsavelExecucao; + TextField txtPor; + TextArea txtRecursos; + Calendar dtInicio; + Calendar dtFim; + TextArea txtParecerDns; + TextArea txtParecerDl; + TextArea txtVerificacaoSiprp; + + public HtmlPanelGrid getGridLayout() + { + return gridLayout; + } - /** - *

Automatically managed component initialization. WARNING: - * This method is automatically generated, so any user-specified code inserted - * here is subject to being replaced.

- */ - private void _init() throws Exception { - } + public void setGridLayout( HtmlPanelGrid hpg ) + { + this.gridLayout = hpg; + } + private Button butGravarPlano = new Button(); - //
-// PlanosDataProvider pdp = new PlanosDataProvider(); - HtmlPanelGrid grid; - PanelGroup pg; - StaticText st; - private HtmlPanelGrid gridLayout = new HtmlPanelGrid(); - - //Plano actuacao - PlanoActuacao plano; - - //HtmlPanelGrid gridPlano = new HtmlPanelGrid(); - HtmlPanelGrid gridArea; - HtmlPanelGrid gridRisco; - HtmlPanelGrid gridValor; - HtmlPanelGrid gridMedida; - HtmlPanelGrid gridPosto; - HtmlPanelGrid gridResponsavel; - - int risco_id = 0; - int medida_id = 0; - int posto_id = 0; - - //page components - TextField txtResponsavelExecucao; - TextField txtPor; - TextArea txtRecursos; - Calendar dtInicio; - Calendar dtFim; - TextArea txtParecerDns; - TextArea txtParecerDl; - TextArea txtVerificacaoSiprp; - - - public HtmlPanelGrid getGridLayout() { - return gridLayout; - } - - public void setGridLayout(HtmlPanelGrid hpg) { - this.gridLayout = hpg; - } - private Button butGravarPlano = new Button(); - - public Button getButGravarPlano() { - return butGravarPlano; - } - - public void setButGravarPlano(Button b) { - this.butGravarPlano = b; - } - private Button butGravarRisco = new Button(); - - public Button getButGravarRisco() { - return butGravarRisco; - } - - public void setButGravarRisco(Button b) { - this.butGravarRisco = b; - } - private Button butEnviar = new Button(); - - public Button getButEnviar() { - return butEnviar; - } - - public void setButEnviar(Button b) { - this.butEnviar = b; - } - private Button butLimparDados = new Button(); - - public Button getButLimparDados() { - return butLimparDados; - } - - public void setButLimparDados(Button b) { - this.butLimparDados = b; - } - private Button butCancelar = new Button(); - - public Button getButCancelar() { - return butCancelar; - } - - public void setButCancelar(Button b) { - this.butCancelar = b; - } - private StaticText lblMsg = new StaticText(); - - public StaticText getLblMsg() { - return lblMsg; - } - - public void setLblMsg(StaticText st) { - this.lblMsg = st; - } - private HtmlPanelGrid gridValidar = new HtmlPanelGrid(); - - public HtmlPanelGrid getGridValidar() { - return gridValidar; - } - - public void setGridValidar(HtmlPanelGrid hpg) { - this.gridValidar = hpg; - } - private Checkbox chkValidacao = new Checkbox(); - - public Checkbox getChkValidacao() { - return chkValidacao; - } - - public void setChkValidacao(Checkbox c) { - this.chkValidacao = c; - } + public Button getButGravarPlano() + { + return butGravarPlano; + } + + public void setButGravarPlano( Button b ) + { + this.butGravarPlano = b; + } + private Button butGravarRisco = new Button(); + public Button getButGravarRisco() + { + return butGravarRisco; + } + + public void setButGravarRisco( Button b ) + { + this.butGravarRisco = b; + } + private Button butEnviar = new Button(); + + public Button getButEnviar() + { + return butEnviar; + } + + public void setButEnviar( Button b ) + { + this.butEnviar = b; + } + private Button butLimparDados = new Button(); + + public Button getButLimparDados() + { + return butLimparDados; + } + + public void setButLimparDados( Button b ) + { + this.butLimparDados = b; + } + private Button butCancelar = new Button(); + + public Button getButCancelar() + { + return butCancelar; + } + + public void setButCancelar( Button b ) + { + this.butCancelar = b; + } + private StaticText lblMsg = new StaticText(); + + public StaticText getLblMsg() + { + return lblMsg; + } + + public void setLblMsg( StaticText st ) + { + this.lblMsg = st; + } + private HtmlPanelGrid gridValidar = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridValidar() + { + return gridValidar; + } + + public void setGridValidar( HtmlPanelGrid hpg ) + { + this.gridValidar = hpg; + } + private Checkbox chkValidacao = new Checkbox(); + + public Checkbox getChkValidacao() + { + return chkValidacao; + } + + public void setChkValidacao( Checkbox c ) + { + this.chkValidacao = c; + } private Checkbox chkDesactivar = new Checkbox(); - public Checkbox getChkDesactivar() { + public Checkbox getChkDesactivar() + { return chkDesactivar; } - public void setChkDesactivar( Checkbox c ) { + public void setChkDesactivar( Checkbox c ) + { this.chkDesactivar = c; } - private HtmlInputHidden hidValidacao = new HtmlInputHidden(); - - public HtmlInputHidden getHidValidacao() { - return hidValidacao; - } - - public void setHidValidacao(HtmlInputHidden hih) { - this.hidValidacao = hih; - } - private PanelGroup grpPagination = new PanelGroup(); - - public PanelGroup getGrpPagination() { - return grpPagination; - } - - public void setGrpPagination(PanelGroup pg) { - this.grpPagination = pg; - } - private HtmlPanelGrid gridPagination = new HtmlPanelGrid(); - - public HtmlPanelGrid getGridPagination() { - return gridPagination; - } - - public void setGridPagination(HtmlPanelGrid hpg) { - this.gridPagination = hpg; - } - private Button butEnviarCorrecao = new Button(); - - public Button getButEnviarCorrecao() { - return butEnviarCorrecao; - } - - public void setButEnviarCorrecao(Button b) { - this.butEnviarCorrecao = b; - } - private StaticText lblObs = new StaticText(); - - public StaticText getLblObs() { - return lblObs; - } - - public void setLblObs(StaticText st) { - this.lblObs = st; - } - private HtmlPanelGrid gridPlano2 = new HtmlPanelGrid(); - - public HtmlPanelGrid getgridPlano2() { - return gridPlano2; - } - - public void setgridPlano2(HtmlPanelGrid hpg) { - this.gridPlano2 = hpg; - } - private HtmlPanelGrid gridPlano = new HtmlPanelGrid(); - - public HtmlPanelGrid getGridPlano() { - return gridPlano; - } - - public void setGridPlano(HtmlPanelGrid hpg) { - this.gridPlano = hpg; - } - private HtmlPanelGrid gridValidacoes = new HtmlPanelGrid(); - - public HtmlPanelGrid getGridValidacoes() { - return gridValidacoes; - } - - public void setGridValidacoes(HtmlPanelGrid hpg) { - this.gridValidacoes = hpg; - } - private HtmlPanelGrid gridValidar2 = new HtmlPanelGrid(); - - public HtmlPanelGrid getGridValidar2() { - return gridValidar2; - } - - public void setGridValidar2(HtmlPanelGrid hpg) { - this.gridValidar2 = hpg; - } - private HtmlPanelGrid gridObservacoes = new HtmlPanelGrid(); - - public HtmlPanelGrid getGridObservacoes() { - return gridObservacoes; - } - - public void setGridObservacoes(HtmlPanelGrid hpg) { - this.gridObservacoes = hpg; - } - private StaticText stNomeEmpresa = new StaticText(); - - public StaticText getStNomeEmpresa() { - return stNomeEmpresa; - } - - public void setStNomeEmpresa(StaticText st) { - this.stNomeEmpresa = st; - } - - /** - *

Construct a new Page bean instance.

- */ - public EditarPlano() { - } - - /** - *

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.

- * - *

Note that, if the current request is a postback, the property - * values of the components do not represent any - * values submitted with this request. Instead, they represent the - * property values that were saved for this view when it was rendered.

- */ - @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 - - // - // Initialize automatically managed components - // *Note* - this logic should NOT be modified - try - { - _init(); - } + private HtmlInputHidden hidValidacao = new HtmlInputHidden(); + + public HtmlInputHidden getHidValidacao() + { + return hidValidacao; + } + + public void setHidValidacao( HtmlInputHidden hih ) + { + this.hidValidacao = hih; + } + private PanelGroup grpPagination = new PanelGroup(); + + public PanelGroup getGrpPagination() + { + return grpPagination; + } + + public void setGrpPagination( PanelGroup pg ) + { + this.grpPagination = pg; + } + private HtmlPanelGrid gridPagination = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPagination() + { + return gridPagination; + } + + public void setGridPagination( HtmlPanelGrid hpg ) + { + this.gridPagination = hpg; + } + private Button butEnviarCorrecao = new Button(); + + public Button getButEnviarCorrecao() + { + return butEnviarCorrecao; + } + + public void setButEnviarCorrecao( Button b ) + { + this.butEnviarCorrecao = b; + } + private StaticText lblObs = new StaticText(); + + public StaticText getLblObs() + { + return lblObs; + } + + public void setLblObs( StaticText st ) + { + this.lblObs = st; + } + private HtmlPanelGrid gridPlano2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getgridPlano2() + { + return gridPlano2; + } + + public void setgridPlano2( HtmlPanelGrid hpg ) + { + this.gridPlano2 = hpg; + } + private HtmlPanelGrid gridPlano = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridPlano() + { + return gridPlano; + } + + public void setGridPlano( HtmlPanelGrid hpg ) + { + this.gridPlano = hpg; + } + private HtmlPanelGrid gridValidacoes = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridValidacoes() + { + return gridValidacoes; + } + + public void setGridValidacoes( HtmlPanelGrid hpg ) + { + this.gridValidacoes = hpg; + } + private HtmlPanelGrid gridValidar2 = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridValidar2() + { + return gridValidar2; + } + + public void setGridValidar2( HtmlPanelGrid hpg ) + { + this.gridValidar2 = hpg; + } + private HtmlPanelGrid gridObservacoes = new HtmlPanelGrid(); + + public HtmlPanelGrid getGridObservacoes() + { + return gridObservacoes; + } + + public void setGridObservacoes( HtmlPanelGrid hpg ) + { + this.gridObservacoes = hpg; + } + private StaticText stNomeEmpresa = new StaticText(); + + public StaticText getStNomeEmpresa() + { + return stNomeEmpresa; + } + + public void setStNomeEmpresa( StaticText st ) + { + this.stNomeEmpresa = st; + } + + /** + *

Construct a new Page bean instance.

+ */ + public EditarPlano() + { + } + + /** + *

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.

+ * + *

Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.

+ */ + @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 + + // + // Initialize automatically managed components + // *Note* - this logic should NOT be modified + try + { + _init(); + } catch ( Exception e ) { ErrorLogger.logException( e ); - log("PlanoActuacao Initialization Failure", e); - throw e instanceof FacesException ? (FacesException) e: new FacesException(e); - } - - // - // Perform application initialization that must complete - // *after* managed components are initialized - // TODO - add your own initialization code here - Utilizador u = getSessionBean1().getCurrentUser(); - if ( u.getTipo().intValue() != Global.DIRECTOR_NACIONAL_SEGURANCA && u.getTipo().intValue() != Global.DIRECTOR_LOJA ) - { - butEnviarCorrecao.setStyleClass( "hidden" ); - } - - } - - /** - *

Callback method that is called after the component tree has been - * restored, but before any event processing takes place. This method - * will only 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.

- */ - @Override - public void preprocess() - { - - } - - /** - *

Callback method that is called just before rendering takes place. - * This method will only 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.

- */ - @Override - public void prerender() - { - FacesContext fc = getFacesContext(); - //boolean isPostback = JSFUtils.isPostBack12(fc); - //boolean isPostback = JSFUtils.isPostBack(fc); - boolean isPostback = JSFUtils.isPostback(); - System.out.println("POSTBACK : " + isPostback); - PlanoActuacao p = getSessionBean1().getPlanoActuacao(); - - System.out.println( "\nEditarPlano . prerender() : " + p.getId() + "\n"); - - getRiscosByPlano( p ); - if ( ! isPostback ) - { - //initializePlano(); - fillValoresHash( p ); - initialize( p ); - showPlano( p ); - //fillPlano(); - } - else - { - Boolean validacao = ( Boolean ) chkValidacao.getSelected(); - if ( validacao != null ) - { - if ( validacao.booleanValue() == true ) - { - butEnviarCorrecao.setDisabled( true ); - butEnviar.setDisabled( false ); - } - else - { - butEnviarCorrecao.setDisabled( false ); - butEnviar.setDisabled( true ); - } - } - } + log( "PlanoActuacao Initialization Failure", e ); + throw e instanceof FacesException ? ( FacesException ) e : new FacesException( e ); + } + + //
+ // Perform application initialization that must complete + // *after* managed components are initialized + // TODO - add your own initialization code here + Utilizador u = getSessionBean1().getCurrentUser(); + if ( u.getTipo().intValue() != Global.DIRECTOR_NACIONAL_SEGURANCA && u.getTipo().intValue() != Global.DIRECTOR_LOJA ) + { + butEnviarCorrecao.setStyleClass( "hidden" ); + } + + } + + /** + *

Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only 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.

+ */ + @Override + public void preprocess() + { + } + + /** + *

Callback method that is called just before rendering takes place. + * This method will only 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.

+ */ + @Override + public void prerender() + { + FacesContext fc = getFacesContext(); + //boolean isPostback = JSFUtils.isPostBack12(fc); + //boolean isPostback = JSFUtils.isPostBack(fc); + boolean isPostback = JSFUtils.isPostback(); + System.out.println( "POSTBACK : " + isPostback ); + PlanoActuacao p = getSessionBean1().getPlanoActuacao(); + + System.out.println( "\nEditarPlano . prerender() : " + p.getId() + "\n" ); + + getRiscosByPlano( p ); + if ( !isPostback ) + { + //initializePlano(); + fillValoresHash( p ); + initialize( p ); + showPlano( p ); + //fillPlano(); + } + else + { + Boolean validacao = ( Boolean ) chkValidacao.getSelected(); + if ( validacao != null ) + { + if ( validacao.booleanValue() == true ) + { + butEnviarCorrecao.setDisabled( true ); + butEnviar.setDisabled( false ); + } + else + { + butEnviarCorrecao.setDisabled( false ); + butEnviar.setDisabled( true ); + } + } + } if ( gridPagination.getChildCount() > 0 ) { gridPagination.getChildren().clear(); } - setPagination( PAGINATION_ENUM.NORMAL ); + setPagination( PAGINATION_ENUM.NORMAL ); setPagination( PAGINATION_ENUM.PATRIMONIAIS ); - if ( p.getCorrecao().matches( "y" ) ) - { - lblObs.setText( p.getObs_correcao() ); - } - lblMsg.setText( getSessionBean1().getMsg() ); - getSessionBean1().setMsg( "" ); - } - - /** - *

Callback method that is called after rendering is completed for - * this request, if init() was called (regardless of whether - * or not this was the page that was actually rendered). Customize this - * method to release resources acquired in the init(), - * preprocess(), or prerender() methods (or - * acquired during execution of an event handler).

- */ - @Override - public void destroy() { - } - - /** - *

Return a reference to the scoped data bean.

- * - * @return reference to the scoped data bean - */ - protected RequestBean1 getRequestBean1() { - return (RequestBean1) getBean("RequestBean1"); - } - - /** - *

Return a reference to the scoped data bean.

- * - * @return reference to the scoped data bean - */ - protected SessionBean1 getSessionBean1() { - return (SessionBean1) getBean("SessionBean1"); - } - - /** - *

Return a reference to the scoped data bean.

- * - * @return reference to the scoped data bean - */ - protected ApplicationBean1 getApplicationBean1() - { - return (ApplicationBean1) getBean("ApplicationBean1"); - } - - public String hyperlink1_action() - { - // TODO: Process the action. Return value is a navigation - // case name where null will return to the same page. - return "lista_planos"; - } - - private void initialize( PlanoActuacao p ) - { + if ( p.getCorrecao().matches( "y" ) ) + { + lblObs.setText( p.getObs_correcao() ); + } + lblMsg.setText( getSessionBean1().getMsg() ); + getSessionBean1().setMsg( "" ); + } + + /** + *

Callback method that is called after rendering is completed for + * this request, if init() was called (regardless of whether + * or not this was the page that was actually rendered). Customize this + * method to release resources acquired in the init(), + * preprocess(), or prerender() methods (or + * acquired during execution of an event handler).

+ */ + @Override + public void destroy() + { + } + + /** + *

Return a reference to the scoped data bean.

+ * + * @return reference to the scoped data bean + */ + protected RequestBean1 getRequestBean1() + { + return ( RequestBean1 ) getBean( "RequestBean1" ); + } + + /** + *

Return a reference to the scoped data bean.

+ * + * @return reference to the scoped data bean + */ + protected SessionBean1 getSessionBean1() + { + return ( SessionBean1 ) getBean( "SessionBean1" ); + } + + /** + *

Return a reference to the scoped data bean.

+ * + * @return reference to the scoped data bean + */ + protected ApplicationBean1 getApplicationBean1() + { + return ( ApplicationBean1 ) getBean( "ApplicationBean1" ); + } + + public String hyperlink1_action() + { + // TODO: Process the action. Return value is a navigation + // case name where null will return to the same page. + return "lista_planos"; + } + + private void initialize( PlanoActuacao p ) + { Utilizador u = getSessionBean1().getCurrentUser(); Pagination paginationNormal = new PaginationNormais( p, u ); @@ -482,23 +520,23 @@ public class EditarPlano extends AbstractPageBean getSessionBean1().addPagination( PAGINATION_ENUM.NORMAL, paginationNormal ); getSessionBean1().addPagination( PAGINATION_ENUM.PATRIMONIAIS, paginationPatrimoniais ); - if ( u.getTipo().intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA ) - { - hidValidacao.setValue( "dns" ); - } - else if ( u.getTipo().intValue() == Global.DIRECTOR_LOJA ) - { - hidValidacao.setValue( "dir_loja" ); - } - if ( u.getTipo().intValue() == Global.TECNICO_HS ) - { - hidValidacao.setValue( "hs" ); - } - - if ( u.getTipo().intValue() != Global.DIRECTOR_LOJA && u.getTipo().intValue() != Global.DIRECTOR_NACIONAL_SEGURANCA && u.getTipo().intValue() != Global.TECNICO_HS ) - { - gridValidar.setRendered( false ); - } + if ( u.getTipo().intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA ) + { + hidValidacao.setValue( "dns" ); + } + else if ( u.getTipo().intValue() == Global.DIRECTOR_LOJA ) + { + hidValidacao.setValue( "dir_loja" ); + } + if ( u.getTipo().intValue() == Global.TECNICO_HS ) + { + hidValidacao.setValue( "hs" ); + } + + if ( u.getTipo().intValue() != Global.DIRECTOR_LOJA && u.getTipo().intValue() != Global.DIRECTOR_NACIONAL_SEGURANCA && u.getTipo().intValue() != Global.TECNICO_HS ) + { + gridValidar.setRendered( false ); + } // else // { // if ( u.getTipo().intValue() == Global.DIRECTOR_NACIONAL_SEGURANCA ) @@ -510,250 +548,249 @@ public class EditarPlano extends AbstractPageBean // // } // } - - int fase = p.getFase().intValue(); - switch( fase ) - { - case Global.FASE_SEGURANCA_PREENCHIMENTO : - if ( p.getObservacoes_dl() != null ) - { - if ( p.getObservacoes_dl().trim().length() > 0 ) - { - pg = new PanelGroup(); - gridObservacoes.getChildren().add( pg ); - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); - st.setText( "Observações gerais DL: " ); - pg.getChildren().add( st ); - st = new StaticText(); - st.setEscape( false ); - st.setText( p.getObservacoes_dl() ); - pg.getChildren().add( st ); - } - } - - if ( p.getObservacoes_dns() != null ) - { - if ( p.getObservacoes_dns().trim().length() > 0 ) - { - pg = new PanelGroup(); - gridObservacoes.getChildren().add( pg ); - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); - st.setText( "Observações gerais DNS: " ); - pg.getChildren().add( st ); - st = new StaticText(); - st.setEscape( false ); - st.setText( p.getObservacoes_dns() ); - pg.getChildren().add( st ); - } - } - - if ( p.getCorrecao().matches( "n" ) ) - { - butEnviar.setText( "Enviar a Director de Loja>>" ); - } - else - { - if ( p.getFase_antes_correcao().intValue() == Global.FASE_DIR_LOJA_VALIDACAO ) - { - butEnviar.setText( "Enviar a Director de Loja>>" ); - } - else if ( p.getFase_antes_correcao().intValue() == Global.FASE_DNS_PARECER ) - { - butEnviar.setText( "Enviar a Director Nacional Segurança>>" ); - } - } - - break; - - case Global.FASE_DIR_LOJA_VALIDACAO: - //butEnviar.setText("Enviar a Director de Loja"); - pg = new PanelGroup(); - pg.setId( "pgObsDl" ); - gridObservacoes.getChildren().add( pg ); - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); - st.setText( "Observações gerais DL: " ); - pg.getChildren().add( st ); - TextArea txtObservacoesDl = new TextArea(); - txtObservacoesDl.setId( "txtObservacoesDl" ); - txtObservacoesDl.setColumns( 200 ); - txtObservacoesDl.setText( p.getObservacoes_dl() ); - pg.getChildren().add( txtObservacoesDl ); - - if ( p.getObservacoes_dns() != null ) - { - if ( p.getObservacoes_dns().trim().length() > 0 ) - { - pg = new PanelGroup(); - gridObservacoes.getChildren().add( pg ); - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); - st.setText( "Observações gerais DNS: " ); - pg.getChildren().add( st ); - st = new StaticText(); - st.setEscape( false ); - st.setText( p.getObservacoes_dns() ); - pg.getChildren().add( st ); - } - } - - if ( p.getValidacao_director_loja().booleanValue() == true ) - { - chkValidacao.setSelected( new Boolean( true ) ); - butEnviarCorrecao.setDisabled( true ); - butEnviar.setDisabled( false ); - } - else - { - butEnviarCorrecao.setDisabled( false ); - butEnviar.setDisabled( true ); - } - butEnviar.setText( "Enviar a Director Nacional Segurança>>" ); - - if ( p.getCorrecao().matches( "y" ) ) - { - butEnviar.setText( "Enviar a Director Nacional Segurança>>" ); - } - - break; - - case Global.FASE_DNS_PARECER: - if ( p.getObservacoes_dl() != null ) - { - if ( p.getObservacoes_dl().trim().length() > 0 ) - { - pg = new PanelGroup(); - pg.setId( "pgObsDl" ); - gridObservacoes.getChildren().add( pg ); - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); - st.setText( "Observações gerais DL: " ); - pg.getChildren().add( st ); - st = new StaticText(); - st.setEscape( false ); - st.setText( p.getObservacoes_dl() ); - pg.getChildren().add( st ); - } - } - - pg = new PanelGroup(); - pg.setId( "pgObsDns" ); - gridObservacoes.getChildren().add( pg ); - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); - st.setText( "Observações gerais DNS: " ); - pg.getChildren().add( st ); - TextArea txtObservacoesDns = new TextArea(); - txtObservacoesDns.setId( "txtObservacoesDns" ); - txtObservacoesDns.setColumns( 200 ); - txtObservacoesDns.setText( p.getObservacoes_dns() ); - pg.getChildren().add( txtObservacoesDns ); - if ( p.getValidacao_dns().booleanValue() == true ) - { - chkValidacao.setSelected( new Boolean( true ) ); - butEnviarCorrecao.setDisabled( true ); - butEnviar.setDisabled( false ); - } - else - { - butEnviarCorrecao.setDisabled( false ); - butEnviar.setDisabled( true ); - } - - butEnviar.setText( "Enviar para Técnico de HS>>" ); - break; - - case Global.FASE_SIPRP_CONCLUSAO: - if ( p.getObservacoes_dl() != null ) - { - if ( p.getObservacoes_dl().trim().length() > 0 ) - { - pg = new PanelGroup(); - gridObservacoes.getChildren().add( pg ); - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); - st.setText( "Observações gerais DL: " ); - pg.getChildren().add( st ); - st = new StaticText(); - st.setEscape( false ); - st.setText( p.getObservacoes_dl() ); - pg.getChildren().add( st ); - } - } - - - if ( p.getObservacoes_dns() != null ) - { - if ( p.getObservacoes_dns().trim().length() > 0 ) - { - pg = new PanelGroup(); - gridObservacoes.getChildren().add( pg ); - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); - st.setText( "Observações gerais DNS: " ); - pg.getChildren().add( st ); - st = new StaticText(); - st.setEscape( false ); - st.setText( p.getObservacoes_dns() ); - pg.getChildren().add( st ); - } - } - - if ( p.getValidacao_hs().booleanValue() == true ) - { - chkValidacao.setSelected( new Boolean( true ) ); - butEnviar.setDisabled( false ); - } - else - { - butEnviar.setDisabled( true ); - } - butEnviar.setText( "Concluir" ); - break; - } - + + int fase = p.getFase().intValue(); + switch ( fase ) + { + case Global.FASE_SEGURANCA_PREENCHIMENTO: + if ( p.getObservacoes_dl() != null ) + { + if ( p.getObservacoes_dl().trim().length() > 0 ) + { + pg = new PanelGroup(); + gridObservacoes.getChildren().add( pg ); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Observações gerais DL: " ); + pg.getChildren().add( st ); + st = new StaticText(); + st.setEscape( false ); + st.setText( p.getObservacoes_dl() ); + pg.getChildren().add( st ); + } + } + + if ( p.getObservacoes_dns() != null ) + { + if ( p.getObservacoes_dns().trim().length() > 0 ) + { + pg = new PanelGroup(); + gridObservacoes.getChildren().add( pg ); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Observações gerais DNS: " ); + pg.getChildren().add( st ); + st = new StaticText(); + st.setEscape( false ); + st.setText( p.getObservacoes_dns() ); + pg.getChildren().add( st ); + } + } + + if ( p.getCorrecao().matches( "n" ) ) + { + butEnviar.setText( "Enviar a Director de Loja>>" ); + } + else + { + if ( p.getFase_antes_correcao().intValue() == Global.FASE_DIR_LOJA_VALIDACAO ) + { + butEnviar.setText( "Enviar a Director de Loja>>" ); + } + else if ( p.getFase_antes_correcao().intValue() == Global.FASE_DNS_PARECER ) + { + butEnviar.setText( "Enviar a Director Nacional Segurança>>" ); + } + } + + break; + + case Global.FASE_DIR_LOJA_VALIDACAO: + //butEnviar.setText("Enviar a Director de Loja"); + pg = new PanelGroup(); + pg.setId( "pgObsDl" ); + gridObservacoes.getChildren().add( pg ); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Observações gerais DL: " ); + pg.getChildren().add( st ); + TextArea txtObservacoesDl = new TextArea(); + txtObservacoesDl.setId( "txtObservacoesDl" ); + txtObservacoesDl.setColumns( Global.MAX_TEXTAREA_CHARS ); + txtObservacoesDl.setText( p.getObservacoes_dl() ); + pg.getChildren().add( txtObservacoesDl ); + + if ( p.getObservacoes_dns() != null ) + { + if ( p.getObservacoes_dns().trim().length() > 0 ) + { + pg = new PanelGroup(); + gridObservacoes.getChildren().add( pg ); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Observações gerais DNS: " ); + pg.getChildren().add( st ); + st = new StaticText(); + st.setEscape( false ); + st.setText( p.getObservacoes_dns() ); + pg.getChildren().add( st ); + } + } + + if ( p.getValidacao_director_loja().booleanValue() == true ) + { + chkValidacao.setSelected( new Boolean( true ) ); + butEnviarCorrecao.setDisabled( true ); + butEnviar.setDisabled( false ); + } + else + { + butEnviarCorrecao.setDisabled( false ); + butEnviar.setDisabled( true ); + } + butEnviar.setText( "Enviar a Director Nacional Segurança>>" ); + + if ( p.getCorrecao().matches( "y" ) ) + { + butEnviar.setText( "Enviar a Director Nacional Segurança>>" ); + } + + break; + + case Global.FASE_DNS_PARECER: + if ( p.getObservacoes_dl() != null ) + { + if ( p.getObservacoes_dl().trim().length() > 0 ) + { + pg = new PanelGroup(); + pg.setId( "pgObsDl" ); + gridObservacoes.getChildren().add( pg ); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Observações gerais DL: " ); + pg.getChildren().add( st ); + st = new StaticText(); + st.setEscape( false ); + st.setText( p.getObservacoes_dl() ); + pg.getChildren().add( st ); + } + } + + pg = new PanelGroup(); + pg.setId( "pgObsDns" ); + gridObservacoes.getChildren().add( pg ); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Observações gerais DNS: " ); + pg.getChildren().add( st ); + TextArea txtObservacoesDns = new TextArea(); + txtObservacoesDns.setId( "txtObservacoesDns" ); + txtObservacoesDns.setColumns( Global.MAX_TEXTAREA_CHARS ); + txtObservacoesDns.setText( p.getObservacoes_dns() ); + pg.getChildren().add( txtObservacoesDns ); + if ( p.getValidacao_dns().booleanValue() == true ) + { + chkValidacao.setSelected( new Boolean( true ) ); + butEnviarCorrecao.setDisabled( true ); + butEnviar.setDisabled( false ); + } + else + { + butEnviarCorrecao.setDisabled( false ); + butEnviar.setDisabled( true ); + } + + butEnviar.setText( "Enviar para Técnico de HS>>" ); + break; + + case Global.FASE_SIPRP_CONCLUSAO: + if ( p.getObservacoes_dl() != null ) + { + if ( p.getObservacoes_dl().trim().length() > 0 ) + { + pg = new PanelGroup(); + gridObservacoes.getChildren().add( pg ); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Observações gerais DL: " ); + pg.getChildren().add( st ); + st = new StaticText(); + st.setEscape( false ); + st.setText( p.getObservacoes_dl() ); + pg.getChildren().add( st ); + } + } + + + if ( p.getObservacoes_dns() != null ) + { + if ( p.getObservacoes_dns().trim().length() > 0 ) + { + pg = new PanelGroup(); + gridObservacoes.getChildren().add( pg ); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Observações gerais DNS: " ); + pg.getChildren().add( st ); + st = new StaticText(); + st.setEscape( false ); + st.setText( p.getObservacoes_dns() ); + pg.getChildren().add( st ); + } + } + + if ( p.getValidacao_hs().booleanValue() == true ) + { + chkValidacao.setSelected( new Boolean( true ) ); + butEnviar.setDisabled( false ); + } + else + { + butEnviar.setDisabled( true ); + } + butEnviar.setText( "Concluir" ); + break; + } + chkDesactivar.setSelected( Boolean.FALSE ); - gridLayout.getChildren().add( gridPlano ); - } - - private void showPlano( PlanoActuacao p ) - { - gridArea = new HtmlPanelGrid(); - gridArea.setId( "gridArea" ); - gridArea.setColumns( 1 ); - gridArea.setColumnClasses( "gridColCenter" ); - gridArea.setWidth( "100%" ); - gridArea.setStyle( "background-color: #f6f4e8; border: solid 1px #766c6c" ); - - gridPlano.getChildren().add( gridArea ); - - if ( p.getAreas().size() > 0 ) - { - Area a = p.getAreas().get( 0 ); - showArea( a ); - if ( a.getRiscos().size() > 0 ) - { + gridLayout.getChildren().add( gridPlano ); + } + + private void showPlano( PlanoActuacao p ) + { + gridArea = new HtmlPanelGrid(); + gridArea.setId( "gridArea" ); + gridArea.setColumns( 1 ); + gridArea.setColumnClasses( "gridColCenter" ); + gridArea.setWidth( "100%" ); + gridArea.setStyle( "background-color: #f6f4e8; border: solid 1px #766c6c" ); + + gridPlano.getChildren().add( gridArea ); + + if ( p.getAreas().size() > 0 ) + { + Area a = p.getAreas().get( 0 ); + showArea( a ); + if ( a.getRiscos().size() > 0 ) + { Risco r = a.getRiscos().get( 0 ); showRisco( r ); showValor( r ); showResponsavel( r ); - } - } - showPreviousValidacoes( p ); + } + } + showPreviousValidacoes( p ); Utilizador currentUser = getSessionBean1().getCurrentUser(); - if ( currentUser.getTipo().intValue() == Global.TECNICO_HS - || currentUser.getTipo().intValue() == Global.DIRECTOR_SIPRP ) + if ( currentUser.getTipo().intValue() == Global.TECNICO_HS || currentUser.getTipo().intValue() == Global.DIRECTOR_SIPRP ) { chkDesactivar.setId( "chkDesactivarPlano" ); chkDesactivar.setLabel( "Desactivar Plano" ); @@ -761,160 +798,160 @@ public class EditarPlano extends AbstractPageBean chkDesactivar.setStyle( "float: left;" ); gridPlano.getChildren().add( chkDesactivar ); } - } - - private void showArea( Area a ) - { - pg = new PanelGroup(); - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); - st.setText( "Área: " ); - pg.getChildren().add( st ); - st = new StaticText(); - st.setEscape( false ); - st.setText( Utils.unicodeToHTML( a.getDescricao() ) ); - pg.getChildren().add( st ); - gridArea.getChildren().add( pg ); - } - - private void showRisco( Risco r ) - { + } + + private void showArea( Area a ) + { + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Área: " ); + pg.getChildren().add( st ); + st = new StaticText(); + st.setEscape( false ); + st.setText( Utils.unicodeToHTML( a.getDescricao() ) ); + pg.getChildren().add( st ); + gridArea.getChildren().add( pg ); + } + + private void showRisco( Risco r ) + { System.out.println( "\nEditarPlano . showRisco() : " + r.getId() + " - " + r.getDescricao() ); - getSessionBean1().setCurrentRisco( r ); + getSessionBean1().setCurrentRisco( r ); String riscoText = "Risco" + ( r.getIsPatrimonial() ? " Patrimonial: " : ": " ); - HtmlPanelGrid grd = new HtmlPanelGrid(); - grd.setColumns( 1 ); - grd.setWidth( "100%" ); - - gridRisco = new HtmlPanelGrid(); - gridRisco.setWidth( "98%" ); - gridRisco.setColumns( 1 ); - gridRisco.setColumnClasses( "gridColLeft" ); - gridArea.getChildren().add( gridRisco ); - - pg = new PanelGroup(); - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); + HtmlPanelGrid grd = new HtmlPanelGrid(); + grd.setColumns( 1 ); + grd.setWidth( "100%" ); + + gridRisco = new HtmlPanelGrid(); + gridRisco.setWidth( "98%" ); + gridRisco.setColumns( 1 ); + gridRisco.setColumnClasses( "gridColLeft" ); + gridArea.getChildren().add( gridRisco ); + + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); st.setText( riscoText ); - pg.getChildren().add( st ); - st = new StaticText(); - st.setEscape( false ); - st.setText( r.getDescricao() ); - pg.getChildren().add( st ); - gridRisco.getChildren().add( pg ); - } - - private void showValores(Risco r) - { - List valores = r.getValores(); - - for(Valor v : valores) - { - HtmlPanelGrid grd = new HtmlPanelGrid(); - grd.setColumns(1); - grd.setColumnClasses("gridColLeft"); - grd.setWidth("100%"); - - gridValor = new HtmlPanelGrid(); - gridRisco.getChildren().add(gridValor); - gridValor.setWidth("100%"); - gridValor.setColumns(1); - gridValor.setColumnClasses("gridColLeft"); - pg = new PanelGroup(); - st = new StaticText(); - st.setEscape(false); - st.setStyleClass("label"); - st.setText("Valor: "); - pg.getChildren().add(st); - st = new StaticText(); - st.setEscape(false); - st.setText(v.getValor().toString()); - pg.getChildren().add(st); - gridValor.getChildren().add(pg); - - showMedidas(r); - } - } - - private void showValor(Risco r) - { - getSessionBean1().setCurrentRisco(r); - HtmlPanelGrid grd = new HtmlPanelGrid(); - grd.setColumns(1); - grd.setColumnClasses("gridColLeft"); - grd.setWidth("100%"); - - gridValor = new HtmlPanelGrid(); - gridRisco.getChildren().add(gridValor); - gridValor.setWidth("100%"); - gridValor.setColumns(1); - gridValor.setColumnClasses("gridColLeft"); - - pg = new PanelGroup(); - st = new StaticText(); - st.setEscape(false); - st.setStyleClass("label"); - st.setText("Valor: "); - pg.getChildren().add(st); - st = new StaticText(); - st.setEscape(false); - if ( r.getValor() == null ) - { - st.setText("IND"); - } - else - { - st.setText(r.getValor().toString()); - } - - pg.getChildren().add( st ); - gridValor.getChildren().add( pg ); - - showMedidas( r ); - } - - private void showMedidas( Risco r ) - { - List< Medida > medidas = r.getMedidas(); - for ( Medida m : medidas ) - { - HtmlPanelGrid grd = new HtmlPanelGrid(); - grd.setColumns( 1 ); - grd.setWidth( "100%" ); - grd.setStyleClass( "centerBlock" ); - gridValor.getChildren().add( grd ); - - gridMedida = new HtmlPanelGrid(); + pg.getChildren().add( st ); + st = new StaticText(); + st.setEscape( false ); + st.setText( r.getDescricao() ); + pg.getChildren().add( st ); + gridRisco.getChildren().add( pg ); + } + + private void showValores( Risco r ) + { + List valores = r.getValores(); + + for ( Valor v : valores ) + { + HtmlPanelGrid grd = new HtmlPanelGrid(); + grd.setColumns( 1 ); + grd.setColumnClasses( "gridColLeft" ); + grd.setWidth( "100%" ); + + gridValor = new HtmlPanelGrid(); + gridRisco.getChildren().add( gridValor ); + gridValor.setWidth( "100%" ); + gridValor.setColumns( 1 ); + gridValor.setColumnClasses( "gridColLeft" ); + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Valor: " ); + pg.getChildren().add( st ); + st = new StaticText(); + st.setEscape( false ); + st.setText( v.getValor().toString() ); + pg.getChildren().add( st ); + gridValor.getChildren().add( pg ); + + showMedidas( r ); + } + } + + private void showValor( Risco r ) + { + getSessionBean1().setCurrentRisco( r ); + HtmlPanelGrid grd = new HtmlPanelGrid(); + grd.setColumns( 1 ); + grd.setColumnClasses( "gridColLeft" ); + grd.setWidth( "100%" ); + + gridValor = new HtmlPanelGrid(); + gridRisco.getChildren().add( gridValor ); + gridValor.setWidth( "100%" ); + gridValor.setColumns( 1 ); + gridValor.setColumnClasses( "gridColLeft" ); + + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Valor: " ); + pg.getChildren().add( st ); + st = new StaticText(); + st.setEscape( false ); + if ( r.getValor() == null ) + { + st.setText( "IND" ); + } + else + { + st.setText( r.getValor().toString() ); + } + + pg.getChildren().add( st ); + gridValor.getChildren().add( pg ); + + showMedidas( r ); + } + + private void showMedidas( Risco r ) + { + List medidas = r.getMedidas(); + for ( Medida m : medidas ) + { + HtmlPanelGrid grd = new HtmlPanelGrid(); + grd.setColumns( 1 ); + grd.setWidth( "100%" ); + grd.setStyleClass( "centerBlock" ); + gridValor.getChildren().add( grd ); + + gridMedida = new HtmlPanelGrid(); gridMedida.setId( "gridMedida_" + m.getId() ); - gridMedida.setStyleClass("centerBlock"); - gridMedida.setWidth("98%"); - gridMedida.setColumns(1); - gridMedida.setColumnClasses("gridColLeft"); - grd.getChildren().add( gridMedida ); - pg = new PanelGroup(); - st = new StaticText(); - st.setEscape(false); - st.setStyleClass("label"); - st.setText("Medida:  "); - pg.getChildren().add(st); - st = new StaticText(); - st.setEscape(false); - st.setText(m.getDescricao()); - pg.getChildren().add(st); - gridMedida.getChildren().add(pg); - - showPostos( m ); - - Utilizador u = getSessionBean1().getCurrentUser(); - PlanoActuacao planoActual = getSessionBean1().getPlanoActuacao(); - if ( planoActual.getFase().intValue() == Global.FASE_SIPRP_CONCLUSAO ) - { - List< EstadoMedida > opts = null; + gridMedida.setStyleClass( "centerBlock" ); + gridMedida.setWidth( "98%" ); + gridMedida.setColumns( 1 ); + gridMedida.setColumnClasses( "gridColLeft" ); + grd.getChildren().add( gridMedida ); + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Medida:  " ); + pg.getChildren().add( st ); + st = new StaticText(); + st.setEscape( false ); + st.setText( m.getDescricao() ); + pg.getChildren().add( st ); + gridMedida.getChildren().add( pg ); + + showPostos( m ); + + Utilizador u = getSessionBean1().getCurrentUser(); + PlanoActuacao planoActual = getSessionBean1().getPlanoActuacao(); + if ( planoActual.getFase().intValue() == Global.FASE_SIPRP_CONCLUSAO ) + { + List opts = null; try { PlanosDataProvider pdp = PlanosDataProvider.getInstance(); @@ -929,18 +966,18 @@ public class EditarPlano extends AbstractPageBean Option opt[] = null; if ( opts != null ) { - opt = new Option[ (opts.size() + 1) ]; - opt[ 0 ] = new Option( 0, "" ); + opt = new Option[ ( opts.size() + 1 ) ]; + opt[ 0] = new Option( 0, "" ); for ( int i = 0; i < opts.size(); i++ ) { EstadoMedida em = opts.get( i ); - opt[ (i+1) ] = new Option( em.getId(), em.getDescricao() ); + opt[( i + 1 )] = new Option( em.getId(), em.getDescricao() ); } } else { opt = new Option[ 1 ]; - opt[ 0 ] = new Option( 0, "" ); + opt[ 0] = new Option( 0, "" ); } drop.setItems( opt ); @@ -955,318 +992,318 @@ public class EditarPlano extends AbstractPageBean valPG.getChildren().add( dropLabel ); valPG.getChildren().add( drop ); gridMedida.getChildren().add( valPG ); - } - } - - } - - private void showPostos( Medida m ) - { - List< PostoTrabalho > postos = m.getPostos(); - for ( PostoTrabalho p : postos ) - { - HtmlPanelGrid grd = new HtmlPanelGrid(); - grd.setColumns(1); - grd.setWidth("100%"); - grd.setStyleClass("centerBlock"); - gridMedida.getChildren().add(grd); - - gridPosto = new HtmlPanelGrid(); - gridPosto.setStyleClass("centerBlock"); - gridPosto.setWidth("98%"); - gridPosto.setColumns(1); - gridPosto.setColumnClasses("gridColLeft"); - grd.getChildren().add(gridPosto); - pg = new PanelGroup(); - st = new StaticText(); - st.setEscape(false); - st.setStyleClass("label"); - st.setText("Posto de trabalho:  "); - pg.getChildren().add(st); - st = new StaticText(); - st.setEscape(false); - st.setText(p.getDescricao()); - pg.getChildren().add( st ); - gridPosto.getChildren().add( pg ); - } - } - - private void showResponsavel( Risco r ) - { - System.out.println( "RISCO : " + r.getDescricao() + " RESPONSAVEL : " + r.getResponsavel_execucao() ); - - Utilizador u = getSessionBean1().getCurrentUser(); - gridResponsavel = new HtmlPanelGrid(); - gridResponsavel.setId( "gridResponsavel" ); - gridResponsavel.setWidth( "100%" ); - gridResponsavel.setColumns( 1 ); - gridResponsavel.setColumnClasses( "gridColLeft" ); - gridArea.getChildren().add( gridResponsavel ); - - pg = new PanelGroup(); - pg.setId( "pgResponsavel" ); - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); - st.setText( "Responsável de execução:" ); - pg.getChildren().add( st ); - if ( u.getTipo().intValue() == Global.RESPONSAVEL_SEGURANCA ) - { - txtResponsavelExecucao = new TextField(); - txtResponsavelExecucao.setId( "txtResponsavel" ); - txtResponsavelExecucao.setColumns( 100 ); - txtResponsavelExecucao.setText( r.getResponsavel_execucao() ); - pg.getChildren().add( txtResponsavelExecucao ); - } - else - { - st = new StaticText(); - st.setEscape( false ); - st.setText( r.getResponsavel_execucao() ); - pg.getChildren().add( st ); - } - - st = new StaticText(); - st.setEscape( false ); - st.setText( " " ); - pg.getChildren().add( st ); - - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); - st.setText( "POR:" ); - pg.getChildren().add( st ); - - if ( u.getTipo().intValue() == Global.RESPONSAVEL_SEGURANCA ) - { - txtPor = new TextField(); - txtPor.setId( "txtPor" ); - txtPor.setColumns( 20 ); - txtPor.setText( r.getPor() ); - pg.getChildren().add( txtPor ); - } - else - { - st = new StaticText(); - st.setEscape( false ); - st.setText( r.getPor() ); - pg.getChildren().add( st ); - } - - gridResponsavel.getChildren().add( pg ); - pg = new PanelGroup(); - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); - st.setText( "Recursos necessários à implementação da medida: " ); - pg.getChildren().add( st ); - gridResponsavel.getChildren().add( pg ); - if ( u.getTipo().intValue() == Global.RESPONSAVEL_SEGURANCA ) - { - txtRecursos = new TextArea(); - txtRecursos.setId( "txtRecursos" ); - txtRecursos.setColumns( 200 ); - txtRecursos.setText( r.getRecursos_necessarios() ); - gridResponsavel.getChildren().add( txtRecursos ); - } - else - { - st = new StaticText(); - st.setEscape( false ); - st.setText( r.getRecursos_necessarios() ); - pg.getChildren().add( st ); - } - - HtmlPanelGrid grd = new HtmlPanelGrid(); - grd.setColumns(2); - grd.setColumnClasses( "gridCol15, gridCol85" ); - grd.setId( "gridDtInicio" ); - grd.setStyle( "width: 100%" ); - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); - st.setText( "Data prevista de início:" ); - grd.getChildren().add( st ); - if ( u.getTipo().intValue() == Global.RESPONSAVEL_SEGURANCA ) - { - dtInicio = new Calendar(); - dtInicio.setId( "dtInicio" ); - - dtInicio.setDateFormatPattern( "dd-MM-yyyy" ); - dtInicio.setValue( r.getData_inicio() ); - java.util.GregorianCalendar gcalendar = new java.util.GregorianCalendar(); - gcalendar.set( 2000, 1, 1 ); - dtInicio.setMinDate( gcalendar.getTime() ); - grd.getChildren().add( dtInicio ); - } - else - { - if ( r.getData_inicio() != null ) - { - st = new StaticText(); - st.setEscape( false ); - SimpleDateFormat formatter = new SimpleDateFormat( "dd/MM/yyyy" ); - String data_str = formatter.format( r.getData_inicio() ); - st.setText( data_str ); - grd.getChildren().add( st ); - } - } - - gridResponsavel.getChildren().add( grd ); - - grd = new HtmlPanelGrid(); - grd.setColumns( 2 ); - grd.setColumnClasses( "gridCol15, gridCol85" ); - grd.setId( "gridDtFim" ); - grd.setStyle( "width: 100%" ); - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); - st.setText( "Data prevista de conclusão:" ); - grd.getChildren().add( st ); - if ( u.getTipo().intValue() == Global.RESPONSAVEL_SEGURANCA ) - { - dtFim = new Calendar(); - dtFim.setId("dtFim"); - dtFim.setDateFormatPattern("dd-MM-yyyy"); - java.util.GregorianCalendar gcalendar1 = new java.util.GregorianCalendar(); - gcalendar1.set(2099,1,1); - dtFim.setMaxDate(gcalendar1.getTime()); - dtFim.setValue(r.getData_fim()); - grd.getChildren().add(dtFim); - } - else - { - if(r.getData_fim() != null) - { - st = new StaticText(); - st.setEscape(false); - SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); - String data_str = formatter.format(r.getData_fim()); - st.setText(data_str); - grd.getChildren().add(st); - } - } - - gridResponsavel.getChildren().add(grd); - - if ( u.getTipo().intValue() != Global.DIRECTOR_LOJA ) - { - if ( r.getParecer_dl() != null ) - { - if ( r.getParecer_dl().trim().length() > 0 ) - { - pg = new PanelGroup(); - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); - st.setText( "Parecer Director de Loja: " ); - pg.getChildren().add( st ); - gridResponsavel.getChildren().add( pg ); + } + } + + } + + private void showPostos( Medida m ) + { + List postos = m.getPostos(); + for ( PostoTrabalho p : postos ) + { + HtmlPanelGrid grd = new HtmlPanelGrid(); + grd.setColumns( 1 ); + grd.setWidth( "100%" ); + grd.setStyleClass( "centerBlock" ); + gridMedida.getChildren().add( grd ); + + gridPosto = new HtmlPanelGrid(); + gridPosto.setStyleClass( "centerBlock" ); + gridPosto.setWidth( "98%" ); + gridPosto.setColumns( 1 ); + gridPosto.setColumnClasses( "gridColLeft" ); + grd.getChildren().add( gridPosto ); + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Posto de trabalho:  " ); + pg.getChildren().add( st ); + st = new StaticText(); + st.setEscape( false ); + st.setText( p.getDescricao() ); + pg.getChildren().add( st ); + gridPosto.getChildren().add( pg ); + } + } + + private void showResponsavel( Risco r ) + { + System.out.println( "RISCO : " + r.getDescricao() + " RESPONSAVEL : " + r.getResponsavel_execucao() ); + + Utilizador u = getSessionBean1().getCurrentUser(); + gridResponsavel = new HtmlPanelGrid(); + gridResponsavel.setId( "gridResponsavel" ); + gridResponsavel.setWidth( "100%" ); + gridResponsavel.setColumns( 1 ); + gridResponsavel.setColumnClasses( "gridColLeft" ); + gridArea.getChildren().add( gridResponsavel ); + + pg = new PanelGroup(); + pg.setId( "pgResponsavel" ); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Responsável de execução:" ); + pg.getChildren().add( st ); + if ( u.getTipo().intValue() == Global.RESPONSAVEL_SEGURANCA ) + { + txtResponsavelExecucao = new TextField(); + txtResponsavelExecucao.setId( "txtResponsavel" ); + txtResponsavelExecucao.setColumns( 100 ); + txtResponsavelExecucao.setText( r.getResponsavel_execucao() ); + pg.getChildren().add( txtResponsavelExecucao ); + } + else + { + st = new StaticText(); + st.setEscape( false ); + st.setText( r.getResponsavel_execucao() ); + pg.getChildren().add( st ); + } + + st = new StaticText(); + st.setEscape( false ); + st.setText( " " ); + pg.getChildren().add( st ); + + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( (u.getTipo().intValue() == Global.RESPONSAVEL_SEGURANCA ? "
" : "") + "POR:" ); + pg.getChildren().add( st ); + + if ( u.getTipo().intValue() == Global.RESPONSAVEL_SEGURANCA ) + { + txtPor = new TextField(); + txtPor.setId( "txtPor" ); + txtPor.setColumns( 20 ); + txtPor.setText( r.getPor() ); + pg.getChildren().add( txtPor ); + } + else + { + st = new StaticText(); + st.setEscape( false ); + st.setText( r.getPor() ); + pg.getChildren().add( st ); + } + + gridResponsavel.getChildren().add( pg ); + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Recursos necessários à implementação da medida: " ); + pg.getChildren().add( st ); + gridResponsavel.getChildren().add( pg ); + if ( u.getTipo().intValue() == Global.RESPONSAVEL_SEGURANCA ) + { + txtRecursos = new TextArea(); + txtRecursos.setId( "txtRecursos" ); + txtRecursos.setColumns( Global.MAX_TEXTAREA_CHARS ); + txtRecursos.setText( r.getRecursos_necessarios() ); + gridResponsavel.getChildren().add( txtRecursos ); + } + else + { + st = new StaticText(); + st.setEscape( false ); + st.setText( r.getRecursos_necessarios() ); + pg.getChildren().add( st ); + } + + HtmlPanelGrid grd = new HtmlPanelGrid(); + grd.setColumns( 2 ); + grd.setColumnClasses( "gridCol15, gridCol85" ); + grd.setId( "gridDtInicio" ); + grd.setStyle( "width: 100%" ); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Data prevista de início:" ); + grd.getChildren().add( st ); + if ( u.getTipo().intValue() == Global.RESPONSAVEL_SEGURANCA ) + { + dtInicio = new Calendar(); + dtInicio.setId( "dtInicio" ); + + dtInicio.setDateFormatPattern( "dd-MM-yyyy" ); + dtInicio.setValue( r.getData_inicio() ); + java.util.GregorianCalendar gcalendar = new java.util.GregorianCalendar(); + gcalendar.set( 2000, 1, 1 ); + dtInicio.setMinDate( gcalendar.getTime() ); + grd.getChildren().add( dtInicio ); + } + else + { + if ( r.getData_inicio() != null ) + { + st = new StaticText(); + st.setEscape( false ); + SimpleDateFormat formatter = new SimpleDateFormat( "dd/MM/yyyy" ); + String data_str = formatter.format( r.getData_inicio() ); + st.setText( data_str ); + grd.getChildren().add( st ); + } + } + + gridResponsavel.getChildren().add( grd ); + + grd = new HtmlPanelGrid(); + grd.setColumns( 2 ); + grd.setColumnClasses( "gridCol15, gridCol85" ); + grd.setId( "gridDtFim" ); + grd.setStyle( "width: 100%" ); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Data prevista de conclusão:" ); + grd.getChildren().add( st ); + if ( u.getTipo().intValue() == Global.RESPONSAVEL_SEGURANCA ) + { + dtFim = new Calendar(); + dtFim.setId( "dtFim" ); + dtFim.setDateFormatPattern( "dd-MM-yyyy" ); + java.util.GregorianCalendar gcalendar1 = new java.util.GregorianCalendar(); + gcalendar1.set( 2099, 1, 1 ); + dtFim.setMaxDate( gcalendar1.getTime() ); + dtFim.setValue( r.getData_fim() ); + grd.getChildren().add( dtFim ); + } + else + { + if ( r.getData_fim() != null ) + { + st = new StaticText(); + st.setEscape( false ); + SimpleDateFormat formatter = new SimpleDateFormat( "dd/MM/yyyy" ); + String data_str = formatter.format( r.getData_fim() ); + st.setText( data_str ); + grd.getChildren().add( st ); + } + } + + gridResponsavel.getChildren().add( grd ); + + if ( u.getTipo().intValue() != Global.DIRECTOR_LOJA ) + { + if ( r.getParecer_dl() != null ) + { + if ( r.getParecer_dl().trim().length() > 0 ) + { + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Parecer Director de Loja: " ); + pg.getChildren().add( st ); + gridResponsavel.getChildren().add( pg ); st = new StaticText(); st.setEscape( false ); st.setText( r.getParecer_dl() ); pg.getChildren().add( st ); - } - } - } - else - { - pg = new PanelGroup(); - st = new StaticText(); - st.setEscape(false); - st.setStyleClass("label"); - st.setText("Parecer Director de Loja: "); - pg.getChildren().add(st); - gridResponsavel.getChildren().add(pg); - - txtParecerDl = new TextArea(); - txtParecerDl.setId("txtParecerDl"); - txtParecerDl.setColumns(200); - txtParecerDl.setText(r.getParecer_dl()); - gridResponsavel.getChildren().add(txtParecerDl); - } - - - if(u.getTipo().intValue() != Global.DIRECTOR_NACIONAL_SEGURANCA) - { - if(r.getParecer_dns() != null) - { - if(r.getParecer_dns().trim().length() > 0) - { - pg = new PanelGroup(); - st = new StaticText(); - st.setEscape(false); - st.setStyleClass("label"); - st.setText("Parecer Director Nacional de Segurança: "); - pg.getChildren().add( st ); - gridResponsavel.getChildren().add( pg ); + } + } + } + else + { + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Parecer Director de Loja: " ); + pg.getChildren().add( st ); + gridResponsavel.getChildren().add( pg ); + + txtParecerDl = new TextArea(); + txtParecerDl.setId( "txtParecerDl" ); + txtParecerDl.setColumns( Global.MAX_TEXTAREA_CHARS ); + txtParecerDl.setText( r.getParecer_dl() ); + gridResponsavel.getChildren().add( txtParecerDl ); + } + + + if ( u.getTipo().intValue() != Global.DIRECTOR_NACIONAL_SEGURANCA ) + { + if ( r.getParecer_dns() != null ) + { + if ( r.getParecer_dns().trim().length() > 0 ) + { + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Parecer Director Nacional de Segurança: " ); + pg.getChildren().add( st ); + gridResponsavel.getChildren().add( pg ); st = new StaticText(); st.setEscape( false ); st.setText( r.getParecer_dns() ); pg.getChildren().add( st ); - } - } - } - else - { - pg = new PanelGroup(); - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); - st.setText( "Parecer Director Nacional de Segurança: " ); - pg.getChildren().add( st ); - gridResponsavel.getChildren().add( pg ); - - txtParecerDns = new TextArea(); - txtParecerDns.setId( "txtParecerDns" ); - txtParecerDns.setColumns( 200 ); - txtParecerDns.setText( r.getParecer_dns() ); - gridResponsavel.getChildren().add( txtParecerDns ); - } - - //Verificacao SIPRP - if ( u.getTipo().intValue() != Global.TECNICO_HS ) - { - if ( r.getVerificacao_siprp() != null ) - { - if ( r.getVerificacao_siprp().trim().length() > 0 ) - { - pg = new PanelGroup(); - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); - st.setText( "Verificação SIPRP: " ); - pg.getChildren().add( st ); - gridResponsavel.getChildren().add( pg ); + } + } + } + else + { + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Parecer Director Nacional de Segurança: " ); + pg.getChildren().add( st ); + gridResponsavel.getChildren().add( pg ); + + txtParecerDns = new TextArea(); + txtParecerDns.setId( "txtParecerDns" ); + txtParecerDns.setColumns( Global.MAX_TEXTAREA_CHARS ); + txtParecerDns.setText( r.getParecer_dns() ); + gridResponsavel.getChildren().add( txtParecerDns ); + } + + //Verificacao SIPRP + if ( u.getTipo().intValue() != Global.TECNICO_HS ) + { + if ( r.getVerificacao_siprp() != null ) + { + if ( r.getVerificacao_siprp().trim().length() > 0 ) + { + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Verificação SIPRP: " ); + pg.getChildren().add( st ); + gridResponsavel.getChildren().add( pg ); st = new StaticText(); st.setEscape( false ); st.setText( r.getVerificacao_siprp() ); pg.getChildren().add( st ); - } - } - } - else - { - pg = new PanelGroup(); - st = new StaticText(); - st.setEscape( false ); - st.setStyleClass( "label" ); - st.setText( "Verificação SIPRP: " ); - pg.getChildren().add( st ); - gridResponsavel.getChildren().add( pg ); - - txtVerificacaoSiprp = new TextArea(); - txtVerificacaoSiprp.setId( "txtVerificacaoSiprp" ); - txtVerificacaoSiprp.setColumns( 200 ); - txtVerificacaoSiprp.setText( r.getVerificacao_siprp() ); - gridResponsavel.getChildren().add( txtVerificacaoSiprp ); - } - - } + } + } + } + else + { + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape( false ); + st.setStyleClass( "label" ); + st.setText( "Verificação SIPRP: " ); + pg.getChildren().add( st ); + gridResponsavel.getChildren().add( pg ); + + txtVerificacaoSiprp = new TextArea(); + txtVerificacaoSiprp.setId( "txtVerificacaoSiprp" ); + txtVerificacaoSiprp.setColumns( Global.MAX_TEXTAREA_CHARS ); + txtVerificacaoSiprp.setText( r.getVerificacao_siprp() ); + gridResponsavel.getChildren().add( txtVerificacaoSiprp ); + } + + } private void showPreviousValidacoes( PlanoActuacao p ) { @@ -1275,7 +1312,7 @@ public class EditarPlano extends AbstractPageBean switch ( tipo ) { - case Global.DIRECTOR_NACIONAL_SEGURANCA : + case Global.DIRECTOR_NACIONAL_SEGURANCA: if ( p.getValidacao_director_loja().booleanValue() ) { StaticText st = new StaticText(); @@ -1285,7 +1322,7 @@ public class EditarPlano extends AbstractPageBean gridValidacoes.getChildren().add( st ); } break; - case Global.TECNICO_HS : + case Global.TECNICO_HS: if ( p.getValidacao_director_loja().booleanValue() ) { StaticText st = new StaticText(); @@ -1306,15 +1343,14 @@ public class EditarPlano extends AbstractPageBean break; } } - private static final int MAX_PAGES_PER_LINE = 20; private void setPagination( PAGINATION_ENUM type ) { Class[] argtypes = new Class[ 1 ]; - argtypes[ 0 ] = ActionEvent.class; - MethodExpression me = ( MethodExpression ) this.getApplication().getExpressionFactory().createMethodExpression( - getFacesContext().getELContext(), "#{EditarPlano.paginacao_actionListener}", null, argtypes ); + argtypes[ 0] = ActionEvent.class; + MethodExpression me = ( MethodExpression ) this.getApplication().getExpressionFactory().createMethodExpression( + getFacesContext().getELContext(), "#{EditarPlano.paginacao_actionListener}", null, argtypes ); StaticText typeLabel = new StaticText(); typeLabel.setText( type.getType() + ":" ); @@ -1324,7 +1360,7 @@ public class EditarPlano extends AbstractPageBean Risco currentRisco = getSessionBean1().getCurrentRisco(); Pagination pagination = getSessionBean1().getPagination( type ); - List< Pagina > paginas = pagination.getPages( currentRisco ); + List paginas = pagination.getPages( currentRisco ); for ( int p = 0; p < paginas.size(); p++ ) { @@ -1340,21 +1376,21 @@ public class EditarPlano extends AbstractPageBean { pagina.addActionListener( new MethodExpressionActionListener( me ) ); pagina.setPaginationType( type ); - group.getChildren().add( pagina ); - st = new StaticText(); - st.setEscape( false ); - st.setText( " " ); - group.getChildren().add( st ); + group.getChildren().add( pagina ); + st = new StaticText(); + st.setEscape( false ); + st.setText( " " ); + group.getChildren().add( st ); } else if ( pagina.isNext() ) { - st = new StaticText(); - st.setEscape( false ); - st.setText( " " ); - group.getChildren().add( st ); - pagina.addActionListener( new MethodExpressionActionListener( me ) ); + st = new StaticText(); + st.setEscape( false ); + st.setText( " " ); + group.getChildren().add( st ); + pagina.addActionListener( new MethodExpressionActionListener( me ) ); pagina.setPaginationType( type ); - group.getChildren().add( pagina ); + group.getChildren().add( pagina ); } else { @@ -1367,103 +1403,102 @@ public class EditarPlano extends AbstractPageBean st.setEscape( false ); st.setText( " | " ); group.getChildren().add( st ); - } + } } } gridPagination.getChildren().add( group ); } - - public String butGravarPlano_action() + + public String butGravarPlano_action() { String page = null; - try - { - page = gravarPlano(); - getSessionBean1().setMsg("Os dados do Plano de Actuação foram guardados"); - } - catch ( Exception ex ) - { + try + { + page = gravarPlano(); + getSessionBean1().setMsg( "Os dados do Plano de Actuação foram guardados" ); + } + catch ( Exception ex ) + { ErrorLogger.logException( new Exception( "Erro na gravacao do plano!" ) ); - ErrorLogger.logException( ex ); - getSessionBean1().setMsg("Erro na gravação do plano!"); - } - - return page; - } - - private String gravarPlano() throws Exception - { + ErrorLogger.logException( ex ); + getSessionBean1().setMsg( "Erro na gravação do plano!" ); + } + + return page; + } + + private String gravarPlano() throws Exception + { String returnToPage = null; - PlanoActuacao p = getSessionBean1().getPlanoActuacao(); - int fase = p.getFase().intValue(); - switch ( fase ) - { - case Global.FASE_DIR_LOJA_VALIDACAO: - PanelGroup pg = (PanelGroup) gridObservacoes.findComponent("pgObsDl"); - if(pg != null) - { - TextArea txtObs = (TextArea) pg.findComponent("txtObservacoesDl"); - if(txtObs != null) - { - p.setObservacoes_dl(""); - if(txtObs.getText() != null) - { - p.setObservacoes_dl((String) txtObs.getText()); - } - } - } - - - Boolean validacao = (Boolean)chkValidacao.getSelected(); - if(validacao != null) - { - if(validacao.booleanValue()) - { - p.setValidacao_director_loja(new Boolean(true)); - } - } - break; - - case Global.FASE_DNS_PARECER: - pg = (PanelGroup) gridObservacoes.findComponent("pgObsDns"); - if(pg != null) - { - TextArea txtObs = (TextArea) pg.findComponent("txtObservacoesDns"); - if(txtObs != null) - { - p.setObservacoes_dns(""); - if(txtObs.getText() != null) - { - p.setObservacoes_dns((String) txtObs.getText()); - } - } - } - - validacao = (Boolean)chkValidacao.getSelected(); - if(validacao != null) - { - if(validacao.booleanValue()) - { - p.setValidacao_dns(new Boolean(true)); - } - } - break; - - case Global.FASE_SIPRP_CONCLUSAO: - validacao = (Boolean)chkValidacao.getSelected(); - if(validacao != null) - { - if(validacao.booleanValue()) - { - p.setValidacao_hs(new Boolean(true)); - } - } - } - + PlanoActuacao p = getSessionBean1().getPlanoActuacao(); + int fase = p.getFase().intValue(); + switch ( fase ) + { + case Global.FASE_DIR_LOJA_VALIDACAO: + PanelGroup pg = ( PanelGroup ) gridObservacoes.findComponent( "pgObsDl" ); + if ( pg != null ) + { + TextArea txtObs = ( TextArea ) pg.findComponent( "txtObservacoesDl" ); + if ( txtObs != null ) + { + p.setObservacoes_dl( "" ); + if ( txtObs.getText() != null ) + { + p.setObservacoes_dl( ( String ) txtObs.getText() ); + } + } + } + + + Boolean validacao = ( Boolean ) chkValidacao.getSelected(); + if ( validacao != null ) + { + if ( validacao.booleanValue() ) + { + p.setValidacao_director_loja( new Boolean( true ) ); + } + } + break; + + case Global.FASE_DNS_PARECER: + pg = ( PanelGroup ) gridObservacoes.findComponent( "pgObsDns" ); + if ( pg != null ) + { + TextArea txtObs = ( TextArea ) pg.findComponent( "txtObservacoesDns" ); + if ( txtObs != null ) + { + p.setObservacoes_dns( "" ); + if ( txtObs.getText() != null ) + { + p.setObservacoes_dns( ( String ) txtObs.getText() ); + } + } + } + + validacao = ( Boolean ) chkValidacao.getSelected(); + if ( validacao != null ) + { + if ( validacao.booleanValue() ) + { + p.setValidacao_dns( new Boolean( true ) ); + } + } + break; + + case Global.FASE_SIPRP_CONCLUSAO: + validacao = ( Boolean ) chkValidacao.getSelected(); + if ( validacao != null ) + { + if ( validacao.booleanValue() ) + { + p.setValidacao_hs( new Boolean( true ) ); + } + } + } + Utilizador currentUser = getSessionBean1().getCurrentUser(); - if ( currentUser.getTipo().intValue() == Global.TECNICO_HS - || currentUser.getTipo().intValue() == Global.DIRECTOR_SIPRP ) + if ( currentUser.getTipo().intValue() == Global.TECNICO_HS || currentUser.getTipo().intValue() == Global.DIRECTOR_SIPRP ) { Checkbox chkD = ( Checkbox ) gridPlano.findComponent( "form1:chkDesactivarPlano" ); if ( chkD != null ) @@ -1479,16 +1514,16 @@ public class EditarPlano extends AbstractPageBean } PlanosDataProvider pdp = PlanosDataProvider.getInstance(); - pdp.updatePlano( p ); - - //Valor curValor = getSessionBean1().getCurrentValor(); - Risco curValor = getSessionBean1().getCurrentRisco(); - curValor = fillValorFields(curValor); + pdp.updatePlano( p ); + + //Valor curValor = getSessionBean1().getCurrentValor(); + Risco curValor = getSessionBean1().getCurrentRisco(); + curValor = fillValorFields( curValor ); // getSessionBean1().getValoresHash().remove(curValor.getId()); // getSessionBean1().getValoresHash().put(curValor.getId(), curValor); - getSessionBean1().getRiscosHash().remove(curValor.getId()); - getSessionBean1().getRiscosHash().put(curValor.getId(), curValor); - + getSessionBean1().getRiscosHash().remove( curValor.getId() ); + getSessionBean1().getRiscosHash().put( curValor.getId(), curValor ); + // HashMap valores = getSessionBean1().getValoresHash(); // Iterator iter = valores.keySet().iterator(); // while(iter.hasNext()) @@ -1497,140 +1532,140 @@ public class EditarPlano extends AbstractPageBean // Valor v = valores.get(id); // pdp.updateValor(v); // } - - HashMap valores = getSessionBean1().getRiscosHash(); - Iterator iter = valores.keySet().iterator(); - while(iter.hasNext()) - { - Integer id = iter.next(); - Risco r = valores.get(id); - pdp.updateRisco(r); + + HashMap valores = getSessionBean1().getRiscosHash(); + Iterator iter = valores.keySet().iterator(); + while ( iter.hasNext() ) + { + Integer id = iter.next(); + Risco r = valores.get( id ); + pdp.updateRisco( r ); if ( fase == Global.FASE_SIPRP_CONCLUSAO ) { pdp.updateMedidas( r ); } - } + } return returnToPage; - } - - public String butGravarRisco_action() - { - PlanoActuacao p = getSessionBean1().getPlanoActuacao(); - int fase = p.getFase().intValue(); - switch ( fase ) - { - case Global.FASE_DIR_LOJA_VALIDACAO : - PanelGroup pg = ( PanelGroup ) gridObservacoes.findComponent( "pgObsDl" ); - if ( pg != null ) - { - TextArea txtObs = ( TextArea ) pg.findComponent( "txtObservacoesDl" ); - if ( txtObs != null ) - { - p.setObservacoes_dl( "" ); - if ( txtObs.getText() != null ) - { - p.setObservacoes_dl( ( String ) txtObs.getText() ); - } - } - } - - Boolean validacao = ( Boolean ) chkValidacao.getSelected(); - if ( validacao != null ) - { - if ( validacao.booleanValue() ) - { - p.setValidacao_director_loja( new Boolean( true ) ); - } - } - break; - - case Global.FASE_DNS_PARECER : - pg = ( PanelGroup ) gridObservacoes.findComponent( "pgObsDns" ); - if ( pg != null ) - { - TextArea txtObs = ( TextArea ) pg.findComponent( "txtObservacoesDns" ); - if ( txtObs != null ) - { - p.setObservacoes_dns( "" ); - if ( txtObs.getText() != null ) - { - p.setObservacoes_dns( ( String ) txtObs.getText() ); - } - } - } - - validacao = ( Boolean ) chkValidacao.getSelected(); - if ( validacao != null ) - { - if ( validacao.booleanValue() ) - { - p.setValidacao_dns( new Boolean( true ) ); - } - } - break; - - case Global.FASE_SIPRP_CONCLUSAO : - validacao = ( Boolean ) chkValidacao.getSelected(); - if ( validacao != null ) - { - if ( validacao.booleanValue() ) - { - p.setValidacao_hs( new Boolean( true ) ); - } - } - } - - try - { + } + + public String butGravarRisco_action() + { + PlanoActuacao p = getSessionBean1().getPlanoActuacao(); + int fase = p.getFase().intValue(); + switch ( fase ) + { + case Global.FASE_DIR_LOJA_VALIDACAO: + PanelGroup pg = ( PanelGroup ) gridObservacoes.findComponent( "pgObsDl" ); + if ( pg != null ) + { + TextArea txtObs = ( TextArea ) pg.findComponent( "txtObservacoesDl" ); + if ( txtObs != null ) + { + p.setObservacoes_dl( "" ); + if ( txtObs.getText() != null ) + { + p.setObservacoes_dl( ( String ) txtObs.getText() ); + } + } + } + + Boolean validacao = ( Boolean ) chkValidacao.getSelected(); + if ( validacao != null ) + { + if ( validacao.booleanValue() ) + { + p.setValidacao_director_loja( new Boolean( true ) ); + } + } + break; + + case Global.FASE_DNS_PARECER: + pg = ( PanelGroup ) gridObservacoes.findComponent( "pgObsDns" ); + if ( pg != null ) + { + TextArea txtObs = ( TextArea ) pg.findComponent( "txtObservacoesDns" ); + if ( txtObs != null ) + { + p.setObservacoes_dns( "" ); + if ( txtObs.getText() != null ) + { + p.setObservacoes_dns( ( String ) txtObs.getText() ); + } + } + } + + validacao = ( Boolean ) chkValidacao.getSelected(); + if ( validacao != null ) + { + if ( validacao.booleanValue() ) + { + p.setValidacao_dns( new Boolean( true ) ); + } + } + break; + + case Global.FASE_SIPRP_CONCLUSAO: + validacao = ( Boolean ) chkValidacao.getSelected(); + if ( validacao != null ) + { + if ( validacao.booleanValue() ) + { + p.setValidacao_hs( new Boolean( true ) ); + } + } + } + + try + { PlanosDataProvider pdp = PlanosDataProvider.getInstance(); - pdp.updatePlano( p ); - } - catch ( Exception ex ) - { - ErrorLogger.logException( ex ); - } - - try - { - Risco r = getSessionBean1().getCurrentRisco(); - r = fillValorFields( r ); + pdp.updatePlano( p ); + } + catch ( Exception ex ) + { + ErrorLogger.logException( ex ); + } + + try + { + Risco r = getSessionBean1().getCurrentRisco(); + r = fillValorFields( r ); PlanosDataProvider pdp = PlanosDataProvider.getInstance(); - pdp.updateRisco( r ); + pdp.updateRisco( r ); if ( fase == Global.FASE_SIPRP_CONCLUSAO ) { pdp.updateMedidas( r ); } - getSessionBean1().getRiscosHash().remove( r.getId() ); - getSessionBean1().getRiscosHash().put( r.getId(), r ); - + getSessionBean1().getRiscosHash().remove( r.getId() ); + getSessionBean1().getRiscosHash().put( r.getId(), r ); + // Pagination pagination = getSessionBean1().getPagination(); Pagination pagination = getSessionBean1().getPagination( r.getIsPatrimonial() ? PAGINATION_ENUM.PATRIMONIAIS : PAGINATION_ENUM.NORMAL ); - r = pagination.getNextRisco(); - Area a = getSessionBean1().getAreasHash().get( r.getArea_id() ); - if ( r != null ) - { - gridArea = ( HtmlPanelGrid ) gridPlano.findComponent( "form1:gridArea" ); - if ( gridArea.getChildren() != null ) - { - gridArea.getChildren().clear(); - } - showArea( a ); - showRisco( r ); - showValor( r ); - showResponsavel( r ); - } - } - catch ( Exception ex ) - { - ErrorLogger.logException( ex ); - } - return null; - } - + r = pagination.getNextRisco(); + Area a = getSessionBean1().getAreasHash().get( r.getArea_id() ); + if ( r != null ) + { + gridArea = ( HtmlPanelGrid ) gridPlano.findComponent( "form1:gridArea" ); + if ( gridArea.getChildren() != null ) + { + gridArea.getChildren().clear(); + } + showArea( a ); + showRisco( r ); + showValor( r ); + showResponsavel( r ); + } + } + catch ( Exception ex ) + { + ErrorLogger.logException( ex ); + } + return null; + } + // private void fillPlanoFields() // { // PlanoActuacao p = getSessionBean1().getPlanoActuacao(); @@ -1674,94 +1709,92 @@ public class EditarPlano extends AbstractPageBean // // } // } +// private Valor fillValorFields(Valor v) + private Risco fillValorFields( Risco r ) + { + //gridPlano = (HtmlPanelGrid) gridLayout.findComponent("form1:gridPlano"); + gridArea = ( HtmlPanelGrid ) gridPlano.findComponent( "form1:gridArea" ); + gridResponsavel = ( HtmlPanelGrid ) gridArea.findComponent( "form1:gridResponsavel" ); + + TextField txtResponsavel = ( TextField ) gridResponsavel.findComponent( "form1:pgResponsavel:txtResponsavel" ); + if ( txtResponsavel != null ) + { + if ( txtResponsavel.getText() != null ) + { + r.setResponsavel_execucao( ( String ) txtResponsavel.getText() ); + } + } + + TextField txtPor = ( TextField ) gridResponsavel.findComponent( "form1:pgResponsavel:txtPor" ); + if ( txtPor != null ) + { + if ( txtPor.getText() != null ) + { + r.setPor( ( String ) txtPor.getText() ); + } + } + + TextArea txtRecursos = ( TextArea ) gridResponsavel.findComponent( "form1:txtRecursos" ); + if ( txtRecursos != null ) + { + if ( txtRecursos.getText() != null ) + { + r.setRecursos_necessarios( ( String ) txtRecursos.getText() ); + } + } + + Calendar dtInicio = ( Calendar ) gridResponsavel.findComponent( "form1:dtInicio:" ); + if ( dtInicio != null ) + { + r.setData_inicio( dtInicio.getSelectedDate() ); + } + + Calendar dtFim = ( Calendar ) gridResponsavel.findComponent( "form1:dtFim" ); + if ( dtFim != null ) + { + r.setData_fim( dtFim.getSelectedDate() ); + } + TextArea txtParecerDl = ( TextArea ) gridResponsavel.findComponent( "form1:txtParecerDl" ); + if ( txtParecerDl != null ) + { + if ( txtParecerDl.getText() != null ) + { + r.setParecer_dl( ( String ) txtParecerDl.getText() ); + } + } -// private Valor fillValorFields(Valor v) - private Risco fillValorFields( Risco r ) - { - //gridPlano = (HtmlPanelGrid) gridLayout.findComponent("form1:gridPlano"); - gridArea = (HtmlPanelGrid) gridPlano.findComponent("form1:gridArea"); - gridResponsavel = (HtmlPanelGrid) gridArea.findComponent("form1:gridResponsavel"); - - TextField txtResponsavel = (TextField) gridResponsavel.findComponent("form1:pgResponsavel:txtResponsavel"); - if(txtResponsavel != null) - { - if(txtResponsavel.getText() != null) - { - r.setResponsavel_execucao((String) txtResponsavel.getText()); - } - } - - TextField txtPor = (TextField) gridResponsavel.findComponent("form1:pgResponsavel:txtPor"); - if(txtPor != null) - { - if(txtPor.getText() != null) - { - r.setPor((String) txtPor.getText()); - } - } - - TextArea txtRecursos = (TextArea) gridResponsavel.findComponent("form1:txtRecursos"); - if(txtRecursos != null) - { - if(txtRecursos.getText() != null) - { - r.setRecursos_necessarios((String) txtRecursos.getText()); - } - } - - Calendar dtInicio = (Calendar) gridResponsavel.findComponent("form1:dtInicio:"); - if(dtInicio != null) - { - r.setData_inicio(dtInicio.getSelectedDate()); - } - - Calendar dtFim = (Calendar) gridResponsavel.findComponent("form1:dtFim"); - if(dtFim != null) - { - r.setData_fim(dtFim.getSelectedDate()); - } - - TextArea txtParecerDl = (TextArea) gridResponsavel.findComponent("form1:txtParecerDl"); - if(txtParecerDl != null) - { - if(txtParecerDl.getText() != null) - { - r.setParecer_dl((String) txtParecerDl.getText()); - } - } - - TextArea txtParecerDns = (TextArea) gridResponsavel.findComponent("form1:txtParecerDns"); - if(txtParecerDns != null) - { - if(txtParecerDns.getText() != null) - { - r.setParecer_dns((String) txtParecerDns.getText()); - } - } - - TextArea txtVerificacaoSiprp = (TextArea) gridResponsavel.findComponent("form1:txtVerificacaoSiprp"); - if(txtVerificacaoSiprp != null) - { - if(txtVerificacaoSiprp.getText() != null) - { - r.setVerificacao_siprp((String) txtVerificacaoSiprp.getText()); - } - } + TextArea txtParecerDns = ( TextArea ) gridResponsavel.findComponent( "form1:txtParecerDns" ); + if ( txtParecerDns != null ) + { + if ( txtParecerDns.getText() != null ) + { + r.setParecer_dns( ( String ) txtParecerDns.getText() ); + } + } + + TextArea txtVerificacaoSiprp = ( TextArea ) gridResponsavel.findComponent( "form1:txtVerificacaoSiprp" ); + if ( txtVerificacaoSiprp != null ) + { + if ( txtVerificacaoSiprp.getText() != null ) + { + r.setVerificacao_siprp( ( String ) txtVerificacaoSiprp.getText() ); + } + } PlanoActuacao planoActual = getSessionBean1().getPlanoActuacao(); if ( planoActual.getFase().intValue() == Global.FASE_SIPRP_CONCLUSAO ) - { - for( Medida m: r.getMedidas() ) + { + for ( Medida m : r.getMedidas() ) { - gridMedida = (HtmlPanelGrid) gridArea.findComponent("form1:gridMedida_" + m.getId() ); + gridMedida = ( HtmlPanelGrid ) gridArea.findComponent( "form1:gridMedida_" + m.getId() ); if ( gridMedida != null ) { PanelGroup gridValPG = ( PanelGroup ) gridMedida.findComponent( "valPG_" + m.getId() ); if ( gridValPG != null ) { - DropDown drop = ( DropDown ) gridValPG.findComponent("drop_" + r.getId() + "_" + m.getId()); - if( drop != null ) + DropDown drop = ( DropDown ) gridValPG.findComponent( "drop_" + r.getId() + "_" + m.getId() ); + if ( drop != null ) { Integer optID = ( Integer ) drop.getSelected(); m.setValidarMedidaId( optID.intValue() == 0 ? null : optID ); @@ -1771,476 +1804,454 @@ public class EditarPlano extends AbstractPageBean } } - return r; - } + return r; + } - public String butEnviar_action() + public String butEnviar_action() { - PlanoActuacao p = getSessionBean1().getPlanoActuacao(); + PlanoActuacao p = getSessionBean1().getPlanoActuacao(); - if ( planoValidationOk( p ) ) - { - //Valor curValor = getSessionBean1().getCurrentValor(); - Risco curValor = getSessionBean1().getCurrentRisco(); - curValor = fillValorFields(curValor); - getSessionBean1().getRiscosHash().remove(curValor.getId()); - getSessionBean1().getRiscosHash().put(curValor.getId(), curValor); - if(!checkCamposObrigatorios()) - { - getSessionBean1().setMsg("Faltam preencher alguns riscos/valor. Por favor preencha todos os campos antes de prosseguir"); - return null; - } - try //save current valor - { + if ( planoValidationOk( p ) ) + { + //Valor curValor = getSessionBean1().getCurrentValor(); + Risco curValor = getSessionBean1().getCurrentRisco(); + curValor = fillValorFields( curValor ); + getSessionBean1().getRiscosHash().remove( curValor.getId() ); + getSessionBean1().getRiscosHash().put( curValor.getId(), curValor ); + if ( !checkCamposObrigatorios() ) + { + getSessionBean1().setMsg( "Faltam preencher alguns riscos/valor. Por favor preencha todos os campos antes de prosseguir" ); + return null; + } + try //save current valor + { // Valor v = getSessionBean1().getCurrentValor(); // v = fillValorFields(v); // pdp.updateValor(v); PlanosDataProvider pdp = PlanosDataProvider.getInstance(); - HashMap valores = getSessionBean1().getRiscosHash(); - Iterator iter = valores.keySet().iterator(); - while(iter.hasNext()) - { - Integer id = iter.next(); - Risco r = valores.get(id); - pdp.updateRisco( r ); - } - } - catch(Exception ex) - { - ErrorLogger.logException( ex ); - } - try - { - processEnviar(p); - return "lista_planos"; - } - catch(Exception ex) - { - getSessionBean1().setMsg("Erro no envio do Plano"); - ErrorLogger.logException( ex ); - } - } - - return null; - } - - private boolean planoValidationOk( PlanoActuacao p ) - { - boolean ok = true; - boolean processo_validado = true; - int dns_next_fase = 2; - - int fase = p.getFase().intValue(); - p.setFase_anterior(new Integer(fase)); - switch ( fase ) - { - case Global.FASE_SEGURANCA_PREENCHIMENTO : - gridArea = (HtmlPanelGrid) gridPlano.findComponent("form1:gridArea"); - gridResponsavel = (HtmlPanelGrid) gridArea.findComponent("form1:gridResponsavel"); - HtmlPanelGrid gridDtInicio = (HtmlPanelGrid) gridResponsavel.findComponent("form1:gridDtInicio"); - Calendar calDtInicio = (Calendar) gridDtInicio.findComponent("form1:dtInicio"); - HtmlPanelGrid gridDtFim = (HtmlPanelGrid) gridResponsavel.findComponent("form1:gridDtFim"); - Calendar calDtFim = (Calendar) gridDtFim.findComponent("form1:dtFim"); - Date dtInicio = calDtInicio.getSelectedDate(); - Date dtFim = calDtFim.getSelectedDate(); - if(dtInicio != null && dtFim != null) - { - if ( dtInicio.after( dtFim ) ) - { - getSessionBean1().setMsg("Data Início não pode ser superior à data fim!"); - ok = false; - } - else - { - fase++; - } - } + HashMap valores = getSessionBean1().getRiscosHash(); + Iterator iter = valores.keySet().iterator(); + while ( iter.hasNext() ) + { + Integer id = iter.next(); + Risco r = valores.get( id ); + pdp.updateRisco( r ); + } + } + catch ( Exception ex ) + { + ErrorLogger.logException( ex ); + } + try + { + processEnviar( p ); + return "lista_planos"; + } + catch ( Exception ex ) + { + getSessionBean1().setMsg( "Erro no envio do Plano" ); + ErrorLogger.logException( ex ); + } + } + + return null; + } + + private boolean planoValidationOk( PlanoActuacao p ) + { + boolean ok = true; + boolean processo_validado = true; + int dns_next_fase = 2; + + int fase = p.getFase().intValue(); + p.setFase_anterior( new Integer( fase ) ); + switch ( fase ) + { + case Global.FASE_SEGURANCA_PREENCHIMENTO: + gridArea = ( HtmlPanelGrid ) gridPlano.findComponent( "form1:gridArea" ); + gridResponsavel = ( HtmlPanelGrid ) gridArea.findComponent( "form1:gridResponsavel" ); + HtmlPanelGrid gridDtInicio = ( HtmlPanelGrid ) gridResponsavel.findComponent( "form1:gridDtInicio" ); + Calendar calDtInicio = ( Calendar ) gridDtInicio.findComponent( "form1:dtInicio" ); + HtmlPanelGrid gridDtFim = ( HtmlPanelGrid ) gridResponsavel.findComponent( "form1:gridDtFim" ); + Calendar calDtFim = ( Calendar ) gridDtFim.findComponent( "form1:dtFim" ); + Date dtInicio = calDtInicio.getSelectedDate(); + Date dtFim = calDtFim.getSelectedDate(); + if ( dtInicio != null && dtFim != null ) + { + if ( dtInicio.after( dtFim ) ) + { + getSessionBean1().setMsg( "Data Início não pode ser superior à data fim!" ); + ok = false; + } + else + { + fase++; + } + } if ( ok ) { p.setData_validacao_seg( new Date() ); - p.setUser_seg( getSessionBean1().getCurrentUser().getId() ); - } - - break; - - case Global.FASE_SIPRP_CONCLUSAO : - Boolean validacao = ( Boolean ) chkValidacao.getSelected(); - if ( validacao == null ) - { - processo_validado = false; - ok = false; - } - else - { - processo_validado = false; - if ( validacao.booleanValue() ) - { - processo_validado = true; - p.setValidacao_hs( new Boolean( true ) ); - Date today = new Date(); - p.setData_validacao_hs( today ); - p.setUser_hs( getSessionBean1().getCurrentUser().getId() ); - } - } - - if ( processo_validado ) - { - fase++; - } - else - { - getSessionBean1().setMsg("É necessário validar o processo antes de dar seguimento para a fase seguinte!"); - ok = false; - } - break; - - case Global.FASE_DIR_LOJA_VALIDACAO : - validacao = (Boolean)chkValidacao.getSelected(); - if(validacao == null) - { - processo_validado = false; - } - else - { - processo_validado = false; - if(validacao.booleanValue()) - { - processo_validado = true; - p.setValidacao_director_loja(new Boolean(true)); - p.setData_validacao_dir_loja( new Date() ); - p.setUser_dir_loja(getSessionBean1().getCurrentUser().getId()); - - PanelGroup pg = (PanelGroup) gridObservacoes.findComponent("pgObsDl"); - if(pg != null) - { - TextArea txtObs = (TextArea) pg.findComponent("txtObservacoesDl"); - if(txtObs != null) - { - p.setObservacoes_dl(""); - if(txtObs.getText() != null) - { - p.setObservacoes_dl((String) txtObs.getText()); - } - } - } - - } - } - - if(processo_validado) - { - fase++; - } - else - { - fase = Global.FASE_SEGURANCA_PREENCHIMENTO; //fase 2 - } - break; - - case Global.FASE_DNS_PARECER: - validacao = (Boolean)chkValidacao.getSelected(); - if(validacao == null) - { - processo_validado = false; - } - else - { - processo_validado = false; - if(validacao.booleanValue()) - { - processo_validado = true; - p.setValidacao_dns(new Boolean(true)); - Date today = new Date(); - p.setData_validacao_dns(today); - p.setUser_dns(getSessionBean1().getCurrentUser().getId()); - - PanelGroup pg = (PanelGroup) gridObservacoes.findComponent("pgObsDns"); - if(pg != null) - { - TextArea txtObs = (TextArea) pg.findComponent("txtObservacoesDns"); - if(txtObs != null) - { - p.setObservacoes_dns(""); - if(txtObs.getText() != null) - { - p.setObservacoes_dns((String) txtObs.getText()); - } - } - } - } - } - - if ( processo_validado ) - { - fase++; - } - else - { - getSessionBean1().setMsg("É necessário validar o processo antes de dar seguimento para a fase seguinte!"); - ok = false; - } - break; - } - - if ( ok ) - { - if ( p.getCorrecao().matches( "y" ) ) - { - fase = p.getFase_antes_correcao().intValue(); - p.setCorrecao( "n" ); - p.setObs_correcao( "" ); - } - p.setFase( new Integer( fase ) ); - } - - return ok; - } - - private boolean checkCamposObrigatorios() - { - boolean res = true; - HashMap valores = getSessionBean1().getRiscosHash(); - Iterator iter = valores.keySet().iterator(); - while(iter.hasNext()) - { - Integer id = iter.next(); + p.setUser_seg( getSessionBean1().getCurrentUser().getId() ); + } + + break; + + case Global.FASE_SIPRP_CONCLUSAO: + Boolean validacao = ( Boolean ) chkValidacao.getSelected(); + if ( validacao == null ) + { + processo_validado = false; + ok = false; + } + else + { + processo_validado = false; + if ( validacao.booleanValue() ) + { + processo_validado = true; + p.setValidacao_hs( new Boolean( true ) ); + Date today = new Date(); + p.setData_validacao_hs( today ); + p.setUser_hs( getSessionBean1().getCurrentUser().getId() ); + } + } + + if ( processo_validado ) + { + fase++; + } + else + { + getSessionBean1().setMsg( "É necessário validar o processo antes de dar seguimento para a fase seguinte!" ); + ok = false; + } + break; + + case Global.FASE_DIR_LOJA_VALIDACAO: + validacao = ( Boolean ) chkValidacao.getSelected(); + if ( validacao == null ) + { + processo_validado = false; + } + else + { + processo_validado = false; + if ( validacao.booleanValue() ) + { + processo_validado = true; + p.setValidacao_director_loja( new Boolean( true ) ); + p.setData_validacao_dir_loja( new Date() ); + p.setUser_dir_loja( getSessionBean1().getCurrentUser().getId() ); + + PanelGroup pg = ( PanelGroup ) gridObservacoes.findComponent( "pgObsDl" ); + if ( pg != null ) + { + TextArea txtObs = ( TextArea ) pg.findComponent( "txtObservacoesDl" ); + if ( txtObs != null ) + { + p.setObservacoes_dl( "" ); + if ( txtObs.getText() != null ) + { + p.setObservacoes_dl( ( String ) txtObs.getText() ); + } + } + } + + } + } + + if ( processo_validado ) + { + fase++; + } + else + { + fase = Global.FASE_SEGURANCA_PREENCHIMENTO; //fase 2 + } + break; + + case Global.FASE_DNS_PARECER: + validacao = ( Boolean ) chkValidacao.getSelected(); + if ( validacao == null ) + { + processo_validado = false; + } + else + { + processo_validado = false; + if ( validacao.booleanValue() ) + { + processo_validado = true; + p.setValidacao_dns( new Boolean( true ) ); + Date today = new Date(); + p.setData_validacao_dns( today ); + p.setUser_dns( getSessionBean1().getCurrentUser().getId() ); + + PanelGroup pg = ( PanelGroup ) gridObservacoes.findComponent( "pgObsDns" ); + if ( pg != null ) + { + TextArea txtObs = ( TextArea ) pg.findComponent( "txtObservacoesDns" ); + if ( txtObs != null ) + { + p.setObservacoes_dns( "" ); + if ( txtObs.getText() != null ) + { + p.setObservacoes_dns( ( String ) txtObs.getText() ); + } + } + } + } + } + + if ( processo_validado ) + { + fase++; + } + else + { + getSessionBean1().setMsg( "É necessário validar o processo antes de dar seguimento para a fase seguinte!" ); + ok = false; + } + break; + } + + if ( ok ) + { + if ( p.getCorrecao().matches( "y" ) ) + { + fase = p.getFase_antes_correcao().intValue(); + p.setCorrecao( "n" ); + p.setObs_correcao( "" ); + } + p.setFase( new Integer( fase ) ); + } + + return ok; + } + + private boolean checkCamposObrigatorios() + { + boolean res = true; + HashMap valores = getSessionBean1().getRiscosHash(); + Iterator iter = valores.keySet().iterator(); + while ( iter.hasNext() ) + { + Integer id = iter.next(); // Valor v = valores.get(id); - Risco r = valores.get(id); - if(r.getResponsavel_execucao() == null) - { - res = false; - break; - } - else if(r.getResponsavel_execucao().trim().length() == 0) - { - res = false; - break; - } - - if(r.getPor() == null) - { - res = false; - break; - } - else if(r.getPor().trim().length() == 0) - { - res = false; - break; - } - - if(r.getRecursos_necessarios() == null) - { - res = false; - break; - } - else if(r.getRecursos_necessarios().trim().length() == 0) - { - res = false; - break; - } - - if(r.getData_inicio() == null) - { - res = false; - break; - } - - if(r.getData_fim() == null) - { - res = false; - break; - } - } - return res; - } - - - private void processEnviar(PlanoActuacao p) throws Exception - { -// PlanosDataProvider pdp = new PlanosDataProvider(); - p.setObs_correcao(""); + Risco r = valores.get( id ); + if ( r.getResponsavel_execucao() == null ) + { + res = false; + break; + } + else if ( r.getResponsavel_execucao().trim().length() == 0 ) + { + res = false; + break; + } + + if ( r.getPor() == null ) + { + res = false; + break; + } + else if ( r.getPor().trim().length() == 0 ) + { + res = false; + break; + } + + if ( r.getRecursos_necessarios() == null ) + { + res = false; + break; + } + else if ( r.getRecursos_necessarios().trim().length() == 0 ) + { + res = false; + break; + } + + if ( r.getData_inicio() == null ) + { + res = false; + break; + } + + if ( r.getData_fim() == null ) + { + res = false; + break; + } + } + return res; + } + + private void processEnviar( PlanoActuacao p ) throws Exception + { + p.setObs_correcao( "" ); PlanosDataProvider pdp = PlanosDataProvider.getInstance(); - pdp.updatePlano( p ); - enviarMail( p ); - } - - - public void enviarMail(PlanoActuacao p) - { -// UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); - Mail mail = new Mail(); - String assunto = ""; - String mail_text = ""; - - int fase = p.getFase().intValue(); - int tipo_utilizador = 0; - switch(fase) - { + pdp.updatePlano( p ); + enviarMail( p ); + } + + public void enviarMail( PlanoActuacao p ) + { + Mail mail = new Mail(); + String assunto = ""; + String mail_text = ""; + + int fase = p.getFase().intValue(); + int tipo_utilizador = 0; + switch ( fase ) + { // case Global.FASE_SIPRP_EMISSAO: // break; - - case Global.FASE_SEGURANCA_PREENCHIMENTO: - if(p.getFase_anterior() == null ) - { - assunto = "PLANOS - SEGURANÇA (PREENCHIMENTO)"; - mail_text = "Notifica-se que o Plano passou para a fase Segurança(Preenchimento)"; - } - else - { - switch(p.getFase_anterior().intValue()) - { - case Global.FASE_DIR_LOJA_VALIDACAO: - tipo_utilizador = Global.DIRECTOR_LOJA; - assunto = "Plano de Actuação da Avaliação de Riscos de " + p.getData_visita_str() + " - Pedido de Correcção"; - mail_text = "

Exmo. (a) Senhor (a),

"; - mail_text += "

O Plano de Actuação referente à auditoria de Avaliação de Riscos Laborais realizada no passado dia " + p.getData_visita_str() + " foi devolvido para correcção.

"; - mail_text += "

Proceda, por favor, em www.siprp.com à(s) respectiva(s) correcção(ões) de acordo com as indicações e volte a reenviar o processo para a fase seguinte.

"; - mail_text += "

Caso tenha alguma dúvida ou necessite de qualquer esclarecimento, contacte, por favor, a Área Técnica da SIPRP através do telefone 213 504 540.

"; - mail_text += "

Cumprimentos,

"; - mail_text += "

A equipa da SIPRP

"; - mail_text += "

Por favor não responda a esta mensagem, dado tratar-se de um e-mail automático

"; - break; - } - } - break; - - case Global.FASE_DIR_LOJA_VALIDACAO: - tipo_utilizador = Global.DIRECTOR_LOJA; - assunto = "Plano de Actuação da Avaliação de Riscos de " + p.getData_visita_str(); - mail_text = "

Exmo. (a) Senhor (a),

"; - mail_text += "

Encontra-se disponível em www.siprp.com o Plano de Actuação referente à auditoria de "; - mail_text += "Avaliação de Riscos Laborais realizada no passado dia " + p.getData_visita_str() + " para que possa "; - mail_text += "validar a informação preenchida.

"; - mail_text += "

Cumprimentos.

"; - mail_text += "

Por favor não responda a esta mensagem, dado tratar-se de um e-mail automático

"; - - break; - - case Global.FASE_DNS_PARECER: - tipo_utilizador = Global.DIRECTOR_NACIONAL_SEGURANCA; - assunto = "Plano de Actuação da Avaliação de Riscos de " + p.getData_visita_str() + " - " + p.getNome_estabelecimento(); - mail_text = "

Exmo. Senhor Silvestre Machado,

"; - mail_text += "

Encontra-se disponível em www.siprp.com o Plano de Actuação referente à auditoria de Avaliação de Riscos Laborais realizada no passado dia " + p.getData_visita_str() + " para que o possa validar.

"; - mail_text += "

Cumprimentos.

"; - mail_text += "

Por favor não responda a esta mensagem, dado tratar-se de um e-mail automático

"; - break; - - case Global.FASE_SIPRP_CONCLUSAO: - tipo_utilizador = Global.TECNICO_HS; - assunto = "Plano de Actuação da Avaliação de Riscos de " + p.getData_visita_str() + " - " + p.getNome_estabelecimento(); - mail_text = "

Exmo. (a) Senhor (a),

"; - mail_text += "

Encontra-se disponível em www.siprp.com o Plano de Actuação referente à auditoria de Avaliação de Riscos Laborais realizada no passado dia " + p.getData_visita_str() + " para que possa efectuar a sua verificação.

"; - mail_text += "

Por favor não responda a esta mensagem, dado tratar-se de um e-mail automático

"; - break; - - case Global.FASE_CONCLUIDO: - assunto = "Plano de Actuação da Avaliação de Riscos de " + p.getData_visita_str() + " - " + p.getNome_estabelecimento() + " - Processo finalizado"; - mail_text = "

Exmo. (a) Senhor (a),

"; - mail_text += "

Encontra-se disponível em www.siprp.com o Plano de Actuação referente à auditoria de Avaliação de Riscos Laborais realizada no passado dia " + p.getData_visita_str() + " finalizado após verificação pelos Técnicos Superiores de Higiene e Segurança da SIPRP.

"; - mail_text += "

Aproveitamos para agradecer toda a disponibilidade e ficamos ao vosso dispor, caso tenha alguma dúvida ou necessite de qualquer esclarecimento, através do telefone 213 504 540.

"; - mail_text += "

Cumprimentos,

"; - mail_text += "

Por favor não responda a esta mensagem, dado tratar-se de um e-mail automático

"; - break; - } - - if(fase < Global.FASE_CONCLUIDO) // nao envia para ninguem na fase Concluido - { - String responsavel_loja = "n"; - if(tipo_utilizador == Global.RESPONSAVEL_SEGURANCA) - { - responsavel_loja = "y"; - } - try - { + + case Global.FASE_SEGURANCA_PREENCHIMENTO: + if ( p.getFase_anterior() == null ) + { + assunto = "PLANOS - SEGURANÇA (PREENCHIMENTO)"; + mail_text = "Notifica-se que o Plano passou para a fase Segurança(Preenchimento)"; + } + else + { + switch ( p.getFase_anterior().intValue() ) + { + case Global.FASE_DIR_LOJA_VALIDACAO: + tipo_utilizador = Global.DIRECTOR_LOJA; + assunto = "Plano de Actuação da Avaliação de Riscos de " + p.getData_visita_str() + " - Pedido de Correcção"; + mail_text = "

Exmo. (a) Senhor (a),

"; + mail_text += "

O Plano de Actuação referente à auditoria de Avaliação de Riscos Laborais realizada no passado dia " + p.getData_visita_str() + " foi devolvido para correcção.

"; + mail_text += "

Proceda, por favor, em www.siprp.com à(s) respectiva(s) correcção(ões) de acordo com as indicações e volte a reenviar o processo para a fase seguinte.

"; + mail_text += "

Caso tenha alguma dúvida ou necessite de qualquer esclarecimento, contacte, por favor, a Área Técnica da SIPRP através do telefone 213 504 540.

"; + mail_text += "

Cumprimentos,

"; + mail_text += "

A equipa da SIPRP

"; + mail_text += "

Por favor não responda a esta mensagem, dado tratar-se de um e-mail automático

"; + break; + } + } + break; + + case Global.FASE_DIR_LOJA_VALIDACAO: + tipo_utilizador = Global.DIRECTOR_LOJA; + assunto = "Plano de Actuação da Avaliação de Riscos de " + p.getData_visita_str(); + mail_text = "

Exmo. (a) Senhor (a),

"; + mail_text += "

Encontra-se disponível em www.siprp.com o Plano de Actuação referente à auditoria de "; + mail_text += "Avaliação de Riscos Laborais realizada no passado dia " + p.getData_visita_str() + " para que possa "; + mail_text += "validar a informação preenchida.

"; + mail_text += "

Cumprimentos.

"; + mail_text += "

Por favor não responda a esta mensagem, dado tratar-se de um e-mail automático

"; + + break; + + case Global.FASE_DNS_PARECER: + tipo_utilizador = Global.DIRECTOR_NACIONAL_SEGURANCA; + assunto = "Plano de Actuação da Avaliação de Riscos de " + p.getData_visita_str() + " - " + p.getNome_estabelecimento(); + mail_text = "

Exmo. Senhor Silvestre Machado,

"; + mail_text += "

Encontra-se disponível em www.siprp.com o Plano de Actuação referente à auditoria de Avaliação de Riscos Laborais realizada no passado dia " + p.getData_visita_str() + " para que o possa validar.

"; + mail_text += "

Cumprimentos.

"; + mail_text += "

Por favor não responda a esta mensagem, dado tratar-se de um e-mail automático

"; + break; + + case Global.FASE_SIPRP_CONCLUSAO: + tipo_utilizador = Global.TECNICO_HS; + assunto = "Plano de Actuação da Avaliação de Riscos de " + p.getData_visita_str() + " - " + p.getNome_estabelecimento(); + mail_text = "

Exmo. (a) Senhor (a),

"; + mail_text += "

Encontra-se disponível em www.siprp.com o Plano de Actuação referente à auditoria de Avaliação de Riscos Laborais realizada no passado dia " + p.getData_visita_str() + " para que possa efectuar a sua verificação.

"; + mail_text += "

Por favor não responda a esta mensagem, dado tratar-se de um e-mail automático

"; + break; + + case Global.FASE_CONCLUIDO: + assunto = "Plano de Actuação da Avaliação de Riscos de " + p.getData_visita_str() + " - " + p.getNome_estabelecimento() + " - Processo finalizado"; + mail_text = "

Exmo. (a) Senhor (a),

"; + mail_text += "

Encontra-se disponível em www.siprp.com o Plano de Actuação referente à auditoria de Avaliação de Riscos Laborais realizada no passado dia " + p.getData_visita_str() + " finalizado após verificação pelos Técnicos Superiores de Higiene e Segurança da SIPRP.

"; + mail_text += "

Aproveitamos para agradecer toda a disponibilidade e ficamos ao vosso dispor, caso tenha alguma dúvida ou necessite de qualquer esclarecimento, através do telefone 213 504 540.

"; + mail_text += "

Cumprimentos,

"; + mail_text += "

Por favor não responda a esta mensagem, dado tratar-se de um e-mail automático

"; + break; + } + + if ( fase < Global.FASE_CONCLUIDO ) + { + String responsavel_loja = "n"; + if ( tipo_utilizador == Global.RESPONSAVEL_SEGURANCA ) + { + responsavel_loja = "y"; + } + try + { 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) - { + List 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( "\nUSER MAIL NEXT FASE : " + u.getLogin() + " ; " + u.getEmail() ); + try + { + mail.send( u.getEmail(), Mail.ENDERECO_ENVIO, assunto, mail_text ); + System.out.println( "\tEMAIL ENVIADO !!" ); + } + catch ( Exception ex1 ) + { + ErrorLogger.logException( ex1 ); + System.out.println( "\tMAIL ERROR : " + ex1.getMessage() ); + } + + } + } + catch ( Exception ex ) + { ErrorLogger.logException( ex ); - } - } - else //fase concluido - { - int[] users = new int[]{Global.RESPONSAVEL_SEGURANCA, Global.DIRECTOR_LOJA, Global.DIRECTOR_NACIONAL_SEGURANCA}; - for(int i=0; i < users.length; i++) - { - tipo_utilizador = users[i]; - - String responsavel_loja = "n"; - if(tipo_utilizador == Global.RESPONSAVEL_SEGURANCA) - { - responsavel_loja = "y"; - } - try - { + } + } + else //fase concluido + { + int[] users = new int[] { Global.RESPONSAVEL_SEGURANCA, Global.DIRECTOR_LOJA, Global.DIRECTOR_NACIONAL_SEGURANCA }; + for ( int i = 0; i < users.length; i++ ) + { + tipo_utilizador = users[i]; + + String responsavel_loja = "n"; + if ( tipo_utilizador == Global.RESPONSAVEL_SEGURANCA ) + { + responsavel_loja = "y"; + } + try + { 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 ); - } - - } - } - -// catch(Exception ex) -// { -// //ErrorLogger.logException( ex ); -// } -// Mail mail = new Mail(); -// try -// { -// mail.send("lluis@evolute.pt", Mail.ENDERECO_ENVIO, assunto, mail_text); -// System.out.println("EMAIL ENVIADO !!"); -// } -// catch(Exception ex) -// { -// ErrorLogger.logException( ex ); -// System.out.println("ERRO NO ENVIO DO EMAIL !!"); -// } -// } + List 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( "\nUSER MAIL NEXT FASE : " + u.getLogin() + " ; " + u.getEmail() ); + try + { + mail.send( u.getEmail(), Mail.ENDERECO_ENVIO, assunto, mail_text ); + System.out.println( "\tEMAIL ENVIADO !!" ); + } + catch ( Exception ex1 ) + { + ErrorLogger.logException( ex1 ); + System.out.println( "\tMAIL ERROR : " + ex1.getMessage() ); + } + } + } + catch ( Exception ex ) + { + ErrorLogger.logException( ex ); + } - } + } + } + } - public void chkValidacao_processValueChange(ValueChangeEvent event) { + public void chkValidacao_processValueChange( ValueChangeEvent event ) + { // if(chkValidacao.getSelected() != null) // { // Boolean selected = (Boolean) chkValidacao.getSelected(); @@ -2260,63 +2271,62 @@ public class EditarPlano extends AbstractPageBean // //txtParecer.setRendered(false); // gridParecer.setStyleClass("hidden"); // } - } - - public void drpIrPara_processValueChange( ValueChangeEvent event ) - { - - } - - - private void getRiscosByPlano( PlanoActuacao p ) - { - HashMap areasHash = new HashMap(); - HashMap riscosHash = new HashMap(); - - for( Area a : p.getAreas() ) - { - areasHash.put( a.getId(), a ); - for ( Risco r : a.getRiscos() ) - { - riscosHash.put( r.getId(), r ); - } - } - - getSessionBean1().setAreasHash( areasHash ); - getSessionBean1().setRiscosHash( riscosHash ); - } - - private void fillValoresHash( PlanoActuacao p ) - { - HashMap< Integer, Risco > riscosHash = new HashMap< Integer, Risco >(); - for ( Area a : p.getAreas() ) - { - for ( Risco r : a.getRiscos() ) - { + } + + public void drpIrPara_processValueChange( ValueChangeEvent event ) + { + + } + + private void getRiscosByPlano( PlanoActuacao p ) + { + HashMap areasHash = new HashMap(); + HashMap riscosHash = new HashMap(); + + for ( Area a : p.getAreas() ) + { + areasHash.put( a.getId(), a ); + for ( Risco r : a.getRiscos() ) + { + riscosHash.put( r.getId(), r ); + } + } + + getSessionBean1().setAreasHash( areasHash ); + getSessionBean1().setRiscosHash( riscosHash ); + } + + private void fillValoresHash( PlanoActuacao p ) + { + HashMap riscosHash = new HashMap(); + for ( Area a : p.getAreas() ) + { + for ( Risco r : a.getRiscos() ) + { // for(Valor v : r.getValores()) // { // valoresHash.put(v.getId(), v); // } - riscosHash.put( r.getId(), r ); - } - } - //getSessionBean1().setValoresHash(valoresHash); - getSessionBean1().setRiscosHash( riscosHash ); - } - - public void paginacao_actionListener( ActionEvent e ) - { - Risco curValor = getSessionBean1().getCurrentRisco(); - curValor = fillValorFields( curValor ); - getSessionBean1().getRiscosHash().remove( curValor.getId() ); - getSessionBean1().getRiscosHash().put( curValor.getId(), curValor ); - - gridArea = ( HtmlPanelGrid ) gridPlano.findComponent( "form1:gridArea" ); - if ( gridArea.getChildren() != null ) - { - gridArea.getChildren().clear(); - } - Pagina pagina = ( Pagina ) e.getSource(); + riscosHash.put( r.getId(), r ); + } + } + //getSessionBean1().setValoresHash(valoresHash); + getSessionBean1().setRiscosHash( riscosHash ); + } + + public void paginacao_actionListener( ActionEvent e ) + { + Risco curValor = getSessionBean1().getCurrentRisco(); + curValor = fillValorFields( curValor ); + getSessionBean1().getRiscosHash().remove( curValor.getId() ); + getSessionBean1().getRiscosHash().put( curValor.getId(), curValor ); + + gridArea = ( HtmlPanelGrid ) gridPlano.findComponent( "form1:gridArea" ); + if ( gridArea.getChildren() != null ) + { + gridArea.getChildren().clear(); + } + Pagina pagina = ( Pagina ) e.getSource(); PAGINATION_ENUM type = pagina.getPaginationType(); // Pagination pagination = getSessionBean1().getPagination(); @@ -2332,68 +2342,67 @@ public class EditarPlano extends AbstractPageBean showValor( r ); showResponsavel( r ); } - } - - public String butCancelar_action() - { - return "lista_planos"; - } - - public String butLimparDados_action() - { - gridArea = (HtmlPanelGrid) gridPlano.findComponent("form1:gridArea"); - gridResponsavel = (HtmlPanelGrid) gridArea.findComponent("form1:gridResponsavel"); - PlanoActuacao p = getSessionBean1().getPlanoActuacao(); - int fase = p.getFase().intValue(); - switch(fase) - { - case Global.FASE_SEGURANCA_PREENCHIMENTO: - TextField txtResponsavel = (TextField) gridResponsavel.findComponent("form1:pgResponsavel:txtResponsavel"); - TextArea txtRecursos = (TextArea) gridResponsavel.findComponent("form1:txtRecursos"); - Calendar dtInicio = (Calendar) gridResponsavel.findComponent("form1:dtInicio:"); - Calendar dtFim = (Calendar) gridResponsavel.findComponent("form1:dtFim"); - txtResponsavel.setText(""); - txtRecursos.setText(""); - dtInicio.setValue(null); - dtFim.setValue(null); - break; - - case Global.FASE_DIR_LOJA_VALIDACAO: - TextArea txtParecerDl = (TextArea) gridResponsavel.findComponent("form1:txtParecerDl"); - txtParecerDl.setText(""); - PanelGroup pg = (PanelGroup) gridObservacoes.findComponent("pgObsDl"); - if(pg != null) - { - TextArea txtObs = (TextArea) pg.findComponent("txtObservacoesDl"); - txtObs.setText(""); - } - break; - - case Global.FASE_DNS_PARECER: - TextArea txtParecerDns = (TextArea) gridResponsavel.findComponent("form1:txtParecerDns"); - txtParecerDns.setText(""); - pg = (PanelGroup) gridObservacoes.findComponent("pgObsDns"); - if(pg != null) - { - TextArea txtObs = (TextArea) pg.findComponent("txtObservacoesDns"); - txtObs.setText(""); - } - break; - - case Global.FASE_SIPRP_CONCLUSAO: - TextArea txtVerificacaoSiprp = (TextArea) gridResponsavel.findComponent("form1:txtVerificacaoSiprp"); - txtVerificacaoSiprp.setText(""); - break; - } - - return null; - } - - public String butEnviarCorrecao_action() - { - System.out.println( "BUT ENVIAR CORRECAO" ); - return "enviar_correcao"; - } + } + + public String butCancelar_action() + { + return "lista_planos"; + } + + public String butLimparDados_action() + { + gridArea = ( HtmlPanelGrid ) gridPlano.findComponent( "form1:gridArea" ); + gridResponsavel = ( HtmlPanelGrid ) gridArea.findComponent( "form1:gridResponsavel" ); + PlanoActuacao p = getSessionBean1().getPlanoActuacao(); + int fase = p.getFase().intValue(); + switch ( fase ) + { + case Global.FASE_SEGURANCA_PREENCHIMENTO: + TextField txtResponsavel = ( TextField ) gridResponsavel.findComponent( "form1:pgResponsavel:txtResponsavel" ); + TextArea txtRecursos = ( TextArea ) gridResponsavel.findComponent( "form1:txtRecursos" ); + Calendar dtInicio = ( Calendar ) gridResponsavel.findComponent( "form1:dtInicio:" ); + Calendar dtFim = ( Calendar ) gridResponsavel.findComponent( "form1:dtFim" ); + txtResponsavel.setText( "" ); + txtRecursos.setText( "" ); + dtInicio.setValue( null ); + dtFim.setValue( null ); + break; + + case Global.FASE_DIR_LOJA_VALIDACAO: + TextArea txtParecerDl = ( TextArea ) gridResponsavel.findComponent( "form1:txtParecerDl" ); + txtParecerDl.setText( "" ); + PanelGroup pg = ( PanelGroup ) gridObservacoes.findComponent( "pgObsDl" ); + if ( pg != null ) + { + TextArea txtObs = ( TextArea ) pg.findComponent( "txtObservacoesDl" ); + txtObs.setText( "" ); + } + break; + + case Global.FASE_DNS_PARECER: + TextArea txtParecerDns = ( TextArea ) gridResponsavel.findComponent( "form1:txtParecerDns" ); + txtParecerDns.setText( "" ); + pg = ( PanelGroup ) gridObservacoes.findComponent( "pgObsDns" ); + if ( pg != null ) + { + TextArea txtObs = ( TextArea ) pg.findComponent( "txtObservacoesDns" ); + txtObs.setText( "" ); + } + break; + + case Global.FASE_SIPRP_CONCLUSAO: + TextArea txtVerificacaoSiprp = ( TextArea ) gridResponsavel.findComponent( "form1:txtVerificacaoSiprp" ); + txtVerificacaoSiprp.setText( "" ); + break; + } + return null; + } + + public String butEnviarCorrecao_action() + { + System.out.println( "BUT ENVIAR CORRECAO" ); + return "enviar_correcao"; + } } diff --git a/trunk/PlanosActuacao/src/java/planosactuacao/ListaPlanos.java b/trunk/PlanosActuacao/src/java/planosactuacao/ListaPlanos.java index 758b2bd5..8f3d7655 100644 --- a/trunk/PlanosActuacao/src/java/planosactuacao/ListaPlanos.java +++ b/trunk/PlanosActuacao/src/java/planosactuacao/ListaPlanos.java @@ -3,7 +3,6 @@ * * Created on Aug 29, 2008, 2:57:16 PM */ - package planosactuacao; import com.evolute.utils.date.DateUtils; @@ -46,63 +45,71 @@ import utils.JSFUtils; */ public class ListaPlanos extends AbstractPageBean { - // - - /** - *

Automatically managed component initialization. WARNING: - * This method is automatically generated, so any user-specified code inserted - * here is subject to being replaced.

- */ - private void _init() throws Exception { - } - 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; - } + // + + /** + *

Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.

+ */ + private void _init() throws Exception + { + } + private Table table1 = new Table(); - public void setTableRowGroup1(TableRowGroup trg) { - this.tableRowGroup1 = trg; - } - private TableRowGroup tableRowGroup2 = new TableRowGroup(); + public Table getTable1() + { + return table1; + } - public TableRowGroup getTableRowGroup2() { - return tableRowGroup2; - } + public void setTable1( Table t ) + { + this.table1 = t; + } + private TableRowGroup tableRowGroup1 = new TableRowGroup(); - public void setTableRowGroup2(TableRowGroup trg) { - this.tableRowGroup2 = trg; - } - private TableRowGroup tableRowGroup3 = new TableRowGroup(); + public TableRowGroup getTableRowGroup1() + { + return tableRowGroup1; + } - public TableRowGroup getTableRowGroup3() { - return tableRowGroup3; - } + public void setTableRowGroup1( TableRowGroup trg ) + { + this.tableRowGroup1 = trg; + } + private TableRowGroup tableRowGroup2 = new TableRowGroup(); - public void setTableRowGroup3(TableRowGroup trg) { - this.tableRowGroup3 = trg; - } + public TableRowGroup getTableRowGroup2() + { + return tableRowGroup2; + } + public void setTableRowGroup2( TableRowGroup trg ) + { + this.tableRowGroup2 = trg; + } + private TableRowGroup tableRowGroup3 = new TableRowGroup(); - private HtmlPanelGrid gridActual = new HtmlPanelGrid(); + public TableRowGroup getTableRowGroup3() + { + return tableRowGroup3; + } - public HtmlPanelGrid getGridActual() { - return gridActual; - } + public void setTableRowGroup3( TableRowGroup trg ) + { + this.tableRowGroup3 = trg; + } + private HtmlPanelGrid gridActual = new HtmlPanelGrid(); - public void setGridActual(HtmlPanelGrid hpg) { - this.gridActual = hpg; - } + public HtmlPanelGrid getGridActual() + { + return gridActual; + } + public void setGridActual( HtmlPanelGrid hpg ) + { + this.gridActual = hpg; + } private TableColumn tableColumn55 = new TableColumn(); public TableColumn getTableColumn55() @@ -114,18 +121,17 @@ public class ListaPlanos extends AbstractPageBean { this.tableColumn55 = c; } - private Button buttonDesactivar = new Button(); - public Button getButtonDesactivar() { + public Button getButtonDesactivar() + { return buttonDesactivar; } - public void setButtonDesactivar( Button b ) { + public void setButtonDesactivar( Button b ) + { this.buttonDesactivar = b; } - - private TableColumn tableColumn56 = new TableColumn(); public TableColumn getTableColumn56() @@ -137,360 +143,399 @@ public class ListaPlanos extends AbstractPageBean { this.tableColumn56 = c; } - private Button buttonDesactivarSeguimento = new Button(); - public Button getButtonDesactivarSeguimento() { + public Button getButtonDesactivarSeguimento() + { return buttonDesactivarSeguimento; } - public void setButtonDesactivarSeguimento( Button b ) { + public void setButtonDesactivarSeguimento( Button b ) + { this.buttonDesactivarSeguimento = b; } - private HtmlPanelGrid gridPanelFilterActual = new HtmlPanelGrid(); + public HtmlPanelGrid getGridPanelFilterActual() { return this.gridPanelFilterActual; } + public void setGridPanelFilterActual( HtmlPanelGrid pg ) { this.gridPanelFilterActual = pg; } - private PanelGroup groupPanelFilterActual = new PanelGroup(); + public PanelGroup getGroupPanelFilterActual() { return this.groupPanelFilterActual; } + public void setGroupPanelFilterActual( PanelGroup pg ) { this.groupPanelFilterActual = pg; } - private TextField textFilterNameActual = new TextField(); + public TextField getTextFilterNameActual() { return this.textFilterNameActual; } + public void setTextFilterNameActual( TextField tf ) { this.textFilterNameActual = tf; } - private TextField textFilterEstabelecimentoActual = new TextField(); - public TextField getTextFilterEstabelecimentoActual() { + public TextField getTextFilterEstabelecimentoActual() + { return textFilterEstabelecimentoActual; } - public void setTextFilterEstabelecimentoActual(TextField textFilterEstabelecimentoActual) { + + public void setTextFilterEstabelecimentoActual( TextField textFilterEstabelecimentoActual ) + { this.textFilterEstabelecimentoActual = textFilterEstabelecimentoActual; } - private com.sun.webui.jsf.component.Calendar calFilterDateActual = new com.sun.webui.jsf.component.Calendar(); - public com.sun.webui.jsf.component.Calendar getCalFilterDateActual() { + + public com.sun.webui.jsf.component.Calendar getCalFilterDateActual() + { return calFilterDateActual; } - public void setCalFilterDateActual(com.sun.webui.jsf.component.Calendar calFilterDateActual) { + + public void setCalFilterDateActual( com.sun.webui.jsf.component.Calendar calFilterDateActual ) + { this.calFilterDateActual = calFilterDateActual; } - private Button buttonFilterActual = new Button(); + public Button getButtonFilterActual() { return this.buttonFilterActual; } + public void setButtonFilterActual( Button b ) { this.buttonFilterActual = b; } - - - private HtmlPanelGrid gridPanelFilterSeg = new HtmlPanelGrid(); + public HtmlPanelGrid getGridPanelFilterSeg() { return this.gridPanelFilterSeg; } + public void setGridPanelFilterSeg( HtmlPanelGrid pg ) { this.gridPanelFilterSeg = pg; } - private PanelGroup groupPanelFilterSeg = new PanelGroup(); + public PanelGroup getGroupPanelFilterSeg() { return this.groupPanelFilterSeg; } + public void setGroupPanelFilterSeg( PanelGroup pg ) { this.groupPanelFilterSeg = pg; } - private TextField textFilterNameSeg = new TextField(); + public TextField getTextFilterNameSeg() { return this.textFilterNameSeg; } + public void setTextFilterNameSeg( TextField tf ) { this.textFilterNameSeg = tf; } - private TextField textFilterEstabelecimentoSeg = new TextField(); - public TextField getTextFilterEstabelecimentoSeg() { + public TextField getTextFilterEstabelecimentoSeg() + { return textFilterEstabelecimentoSeg; } - public void setTextFilterEstabelecimentoSeg(TextField textFilterEstabelecimentoSeg) { + + public void setTextFilterEstabelecimentoSeg( TextField textFilterEstabelecimentoSeg ) + { this.textFilterEstabelecimentoSeg = textFilterEstabelecimentoSeg; } - private com.sun.webui.jsf.component.Calendar calFilterDateSeg = new com.sun.webui.jsf.component.Calendar(); - public com.sun.webui.jsf.component.Calendar getCalFilterDateSeg() { + + public com.sun.webui.jsf.component.Calendar getCalFilterDateSeg() + { return calFilterDateSeg; } - public void setCalFilterDateSeg(com.sun.webui.jsf.component.Calendar calFilterDateSeg) { + + public void setCalFilterDateSeg( com.sun.webui.jsf.component.Calendar calFilterDateSeg ) + { this.calFilterDateSeg = calFilterDateSeg; } - private Button buttonFilterSeg = new Button(); + public Button getButtonFilterSeg() { return this.buttonFilterSeg; } + public void setButtonFilterSeg( Button b ) { this.buttonFilterSeg = b; } - - private HtmlPanelGrid gridPanelFilterConc = new HtmlPanelGrid(); + public HtmlPanelGrid getGridPanelFilterConc() { return this.gridPanelFilterConc; } + public void setGridPanelFilterConc( HtmlPanelGrid pg ) { this.gridPanelFilterConc = pg; } - private PanelGroup groupPanelFilterConc = new PanelGroup(); + public PanelGroup getGroupPanelFilterConc() { return this.groupPanelFilterConc; } + public void setGroupPanelFilterConc( PanelGroup pg ) { this.groupPanelFilterConc = pg; } - private TextField textFilterNameConc = new TextField(); + public TextField getTextFilterNameConc() { return this.textFilterNameConc; } + public void setTextFilterNameConc( TextField tf ) { this.textFilterNameConc = tf; } - private TextField textFilterEstabelecimentoConc = new TextField(); - public TextField getTextFilterEstabelecimentoConc() { + public TextField getTextFilterEstabelecimentoConc() + { return textFilterEstabelecimentoConc; } - public void setTextFilterEstabelecimentoConc(TextField textFilterEstabelecimentoConc) { + + public void setTextFilterEstabelecimentoConc( TextField textFilterEstabelecimentoConc ) + { this.textFilterEstabelecimentoConc = textFilterEstabelecimentoConc; } - private com.sun.webui.jsf.component.Calendar calFilterDateConc = new com.sun.webui.jsf.component.Calendar(); - public com.sun.webui.jsf.component.Calendar getCalFilterDateConc() { + + public com.sun.webui.jsf.component.Calendar getCalFilterDateConc() + { return calFilterDateConc; } - public void setCalFilterDateConc(com.sun.webui.jsf.component.Calendar calFilterDateConc) { + + public void setCalFilterDateConc( com.sun.webui.jsf.component.Calendar calFilterDateConc ) + { this.calFilterDateConc = calFilterDateConc; } - private Button buttonFilterConc = new Button(); + public Button getButtonFilterConc() { return this.buttonFilterConc; } + public void setButtonFilterConc( Button b ) { this.buttonFilterConc = b; } - private static final DateFormat D_F = new SimpleDateFormat( "yyyy-MM-dd" ); - //
- - - /** - *

Construct a new Page bean instance.

- */ - public ListaPlanos() { - } - - /** - *

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.

- * - *

Note that, if the current request is a postback, the property - * values of the components do not represent any - * values submitted with this request. Instead, they represent the - * property values that were saved for this view when it was rendered.

- */ - @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 - - // - // Initialize automatically managed components - // *Note* - this logic should NOT be modified - try { - _init(); - } catch (Exception e) { + // + + /** + *

Construct a new Page bean instance.

+ */ + public ListaPlanos() + { + } + + /** + *

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.

+ * + *

Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.

+ */ + @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 + + // + // Initialize automatically managed components + // *Note* - this logic should NOT be modified + try + { + _init(); + } + catch ( Exception e ) + { ErrorLogger.logException( e ); - log("ListaPlanos Initialization Failure", e); - throw e instanceof FacesException ? (FacesException) e: new FacesException(e); - } - - // - // Perform application initialization that must complete - // *after* managed components are initialized - // TODO - add your own initialization code here - } - - /** - *

Callback method that is called after the component tree has been - * restored, but before any event processing takes place. This method - * will only 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.

- */ - @Override - public void preprocess() { - } - - /** - *

Callback method that is called just before rendering takes place. - * This method will only 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.

- */ - @Override - public void prerender() - { - System.out.println("LISTA PLANOS - PRERENDER"); - - Utilizador u = getSessionBean1().getCurrentUser(); - System.out.println( "\tUser Logged In : " + ( u == null ? "NONE !" : "[" + u.getId() + "] : " + u.getLogin() ) ); - - FacesContext fc = getFacesContext(); - String estab_gestor = JSFUtils.getRequestParameter( fc, "estab_gestor" ); - - if ( u != null ) - { - if ( u.getTipo() != null && u.getTipo().intValue() == Global.GESTOR ) - { - try - { - Integer estabelecimento_gestor = new Integer(Integer.parseInt(estab_gestor)); - System.out.println("ESTABELECIMENTO GESTOR : " + estabelecimento_gestor.intValue()); - u.setEstabelecimento_gestor(estabelecimento_gestor); - } catch (Exception ex2) - { - ErrorLogger.logException(ex2); - } - } - - if (u.getTipo().intValue() == Global.DIRECTOR_SIPRP || u.getTipo().intValue() == Global.RH || u.getTipo().intValue() == Global.DIRECTOR_GERAL_RH || u.getTipo().intValue() == Global.GESTOR) + log( "ListaPlanos Initialization Failure", e ); + throw e instanceof FacesException ? ( FacesException ) e : new FacesException( e ); + } + + //
+ // Perform application initialization that must complete + // *after* managed components are initialized + // TODO - add your own initialization code here + } + + /** + *

Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only 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.

+ */ + @Override + public void preprocess() + { + } + + /** + *

Callback method that is called just before rendering takes place. + * This method will only 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.

+ */ + @Override + public void prerender() + { + System.out.println( "LISTA PLANOS - PRERENDER" ); + + Utilizador u = getSessionBean1().getCurrentUser(); + System.out.println( "\tUser Logged In : " + ( u == null ? "NONE !" : "[" + u.getId() + "] : " + u.getLogin() ) ); + + FacesContext fc = getFacesContext(); + String estab_gestor = JSFUtils.getRequestParameter( fc, "estab_gestor" ); + + boolean renderOrNot = false; + + if ( u != null ) + { + if ( u.getTipo() != null && u.getTipo().intValue() == Global.GESTOR ) + { + try + { + Integer estabelecimento_gestor = new Integer( Integer.parseInt( estab_gestor ) ); + System.out.println( "ESTABELECIMENTO GESTOR : " + estabelecimento_gestor.intValue() ); + u.setEstabelecimento_gestor( estabelecimento_gestor ); + } + catch ( Exception ex2 ) + { + ErrorLogger.logException( ex2 ); + } + } + + if ( u.getTipo().intValue() == Global.DIRECTOR_SIPRP || u.getTipo().intValue() == Global.RH || u.getTipo().intValue() == Global.DIRECTOR_GERAL_RH || u.getTipo().intValue() == Global.GESTOR ) + { + gridActual.setRendered( false ); + tableRowGroup2.setEmptyDataMsg( "Sem registos" ); + tableRowGroup3.setEmptyDataMsg( "Sem registos" ); + } + + if ( u.getTipo().intValue() != Global.DIRECTOR_SIPRP && u.getTipo().intValue() != Global.RH && u.getTipo().intValue() != Global.DIRECTOR_GERAL_RH ) { - gridActual.setRendered( false ); - tableRowGroup2.setEmptyDataMsg( "Sem registos" ); - tableRowGroup3.setEmptyDataMsg( "Sem registos" ); - } + getSessionBean1().setDisableMenuUtilizadores( true ); + tableRowGroup1.setEmptyDataMsg( "Sem registos" ); + tableRowGroup2.setEmptyDataMsg( "Sem registos" ); + tableRowGroup3.setEmptyDataMsg( "Sem registos" ); + } - if (u.getTipo().intValue() != Global.DIRECTOR_SIPRP && u.getTipo().intValue() != Global.RH && u.getTipo().intValue() != Global.DIRECTOR_GERAL_RH) + //Column para desactivar plano - mostra se o utilizador for DIRECTOR SIPRP + if ( u.getTipo() != null ) { - getSessionBean1().setDisableMenuUtilizadores( true ); - tableRowGroup1.setEmptyDataMsg( "Sem registos" ); - tableRowGroup2.setEmptyDataMsg( "Sem registos" ); - tableRowGroup3.setEmptyDataMsg( "Sem registos" ); - } - - //Column para desactivar plano - mostra se o utilizador for DIRECTOR SIPRP - int uType = u.getTipo().intValue(); - boolean renderOrNot = uType == Global.DIRECTOR_SIPRP || uType == Global.TECNICO_HS; - tableColumn55.setRendered(renderOrNot); - buttonDesactivar.setRendered(renderOrNot); - - tableColumn56.setRendered(renderOrNot); - buttonDesactivarSeguimento.setRendered(renderOrNot); - - initialize(); - } - else - { - getSessionBean1().setMsg("Utilizador inválido."); - } - - } - - /** - *

Callback method that is called after rendering is completed for - * this request, if init() was called (regardless of whether - * or not this was the page that was actually rendered). Customize this - * method to release resources acquired in the init(), - * preprocess(), or prerender() methods (or - * acquired during execution of an event handler).

- */ - @Override - public void destroy() { - } - - /** - *

Return a reference to the scoped data bean.

- * - * @return reference to the scoped data bean - */ - protected RequestBean1 getRequestBean1() { - return (RequestBean1) getBean("RequestBean1"); - } - - /** - *

Return a reference to the scoped data bean.

- * - * @return reference to the scoped data bean - */ - protected ApplicationBean1 getApplicationBean1() { - return (ApplicationBean1) getBean("ApplicationBean1"); - } - - /** - *

Return a reference to the scoped data bean.

- * - * @return reference to the scoped data bean - */ - protected SessionBean1 getSessionBean1() { - return (SessionBean1) getBean("SessionBean1"); - } - - public String hyperlink1_action() { - // TODO: Process the action. Return value is a navigation - // case name where null will return to the same page. - return "editar_plano"; - } + int uType = u.getTipo(); + renderOrNot = uType == Global.DIRECTOR_SIPRP || uType == Global.TECNICO_HS; + } + + initialize(); + } + else + { + getSessionBean1().setMsg( "Utilizador inválido." ); + } + + tableColumn55.setRendered( renderOrNot ); + buttonDesactivar.setRendered( renderOrNot ); + tableColumn56.setRendered( renderOrNot ); + buttonDesactivarSeguimento.setRendered( renderOrNot ); + } + + /** + *

Callback method that is called after rendering is completed for + * this request, if init() was called (regardless of whether + * or not this was the page that was actually rendered). Customize this + * method to release resources acquired in the init(), + * preprocess(), or prerender() methods (or + * acquired during execution of an event handler).

+ */ + @Override + public void destroy() + { + } + + /** + *

Return a reference to the scoped data bean.

+ * + * @return reference to the scoped data bean + */ + protected RequestBean1 getRequestBean1() + { + return ( RequestBean1 ) getBean( "RequestBean1" ); + } + + /** + *

Return a reference to the scoped data bean.

+ * + * @return reference to the scoped data bean + */ + protected ApplicationBean1 getApplicationBean1() + { + return ( ApplicationBean1 ) getBean( "ApplicationBean1" ); + } + + /** + *

Return a reference to the scoped data bean.

+ * + * @return reference to the scoped data bean + */ + protected SessionBean1 getSessionBean1() + { + return ( SessionBean1 ) getBean( "SessionBean1" ); + } + + public String hyperlink1_action() + { + // TODO: Process the action. Return value is a navigation + // case name where null will return to the same page. + return "editar_plano"; + } public String goDesactivarPlano_action() { @@ -530,60 +575,61 @@ public class ListaPlanos extends AbstractPageBean } } + public String goEditarPlano_action() + { + // TODO: Process the action. Return value is a navigation + // case name where null will return to the same page. + PlanoActuacao p = getTableActivosRowData(); + getSessionBean1().setPlanoActuacao( p ); + - public String goEditarPlano_action() { - // TODO: Process the action. Return value is a navigation - // case name where null will return to the same page. - PlanoActuacao p = getTableActivosRowData(); - getSessionBean1().setPlanoActuacao(p); - - - //showPlano(p); - //dummy - //getSessionBean1().setFase(2); - return "editar_plano"; - } - - public String goVerPlanoFromSeguimento_action(){ - PlanoActuacao p = getTableSeguimentoRowData(); - getSessionBean1().setPlanoActuacao(p); - return "ver_plano"; - } - - public String goVerPlanoFromConcluidos_action(){ - PlanoActuacao p = getTableConcluidosRowData(); - getSessionBean1().setPlanoActuacao(p); - return "ver_plano"; - } + //showPlano(p); + //dummy + //getSessionBean1().setFase(2); + return "editar_plano"; + } + + public String goVerPlanoFromSeguimento_action() + { + PlanoActuacao p = getTableSeguimentoRowData(); + getSessionBean1().setPlanoActuacao( p ); + return "ver_plano"; + } + + public String goVerPlanoFromConcluidos_action() + { + PlanoActuacao p = getTableConcluidosRowData(); + getSessionBean1().setPlanoActuacao( p ); + return "ver_plano"; + } //**** IMPRIMIR PLANO SEM RISCOS PATRIMONIAIS ****// - public String goImprimirPlano_action() + public String goImprimirPlano_action() { - PlanoActuacao p = getTableActivosRowData(); - createPdf( p.getId() ); - return null; + PlanoActuacao p = getTableActivosRowData(); + createPdf( p.getId() ); + return null; } - - public String goImprimirPlanoFromSeguimento_action() + + public String goImprimirPlanoFromSeguimento_action() { - PlanoActuacao p = getTableSeguimentoRowData(); - createPdf( p.getId() ); - return null; - } - - public String goImprimirPlanoFromConcluidos_action() + PlanoActuacao p = getTableSeguimentoRowData(); + createPdf( p.getId() ); + return null; + } + + public String goImprimirPlanoFromConcluidos_action() { Utilizador currentUser = getSessionBean1().getCurrentUser(); int userType = currentUser == null ? -1 : currentUser.getTipo(); PlanoActuacao p = getTableConcluidosRowData(); - if ( ! p.getConcluidoPorDesactivacao() || ( userType == Global.DIRECTOR_SIPRP ) ) + if ( !p.getConcluidoPorDesactivacao() || ( userType == Global.DIRECTOR_SIPRP ) ) { createPdf( p.getId() ); } - return null; - } - + return null; + } //*** IMPRIMIR PLANO COM RISCOS PATRIMONIAIS ***// public String goImprimirPlanoPatrimoniais_action() @@ -606,15 +652,13 @@ public class ListaPlanos extends AbstractPageBean int userType = currentUser == null ? -1 : currentUser.getTipo(); PlanoActuacao p = getTableConcluidosRowData(); - if ( ! p.getConcluidoPorDesactivacao() || ( userType == Global.DIRECTOR_SIPRP ) ) + if ( !p.getConcluidoPorDesactivacao() || ( userType == Global.DIRECTOR_SIPRP ) ) { createPdf( p.getId(), true ); } return null; } - - private void createPdf( Integer pID ) { createPdf( pID, false ); @@ -622,124 +666,119 @@ public class ListaPlanos extends AbstractPageBean private void createPdf( Integer pID, boolean withPatrimoniais ) { - try - { + try + { PlanoActuacaoPDFCreator pdfCreator = new PlanoActuacaoPDFCreator(); System.out.println( "CREATING PDF ..." ); byte[] pdf = pdfCreator.createPDF( pID, true, withPatrimoniais ); System.out.println( "\t.. DONE !" ); - showPdf( pdf, withPatrimoniais ); - } - catch ( Exception ex ) - { - ErrorLogger.logException( ex ); + showPdf( pdf, withPatrimoniais ); + } + catch ( Exception ex ) + { + ErrorLogger.logException( ex ); System.out.println( "\n\tError creating PDF : " + ex.getMessage() ); - } + } } - private void showPdf( byte[] pdf, boolean isPatrimoniais ) throws Exception - { + private void showPdf( byte[] pdf, boolean isPatrimoniais ) throws Exception + { String filename = isPatrimoniais ? "Plano_Patrimoniais.pdf" : "Plano.pdf"; - System.out.println( "\nPDF LEN : " + pdf.length ); + System.out.println( "\nPDF LEN : " + pdf.length ); System.out.println( "FileName : " + filename ); - + FacesContext context = FacesContext.getCurrentInstance(); - HttpServletResponse response = ( HttpServletResponse ) context.getExternalContext().getResponse(); - - response.setHeader( "Expires", "0" ); - response.setHeader( "Cache-Control", "must-revalidate, post-check=0, pre-check=0" ); - response.setHeader( "Pragma", "public" ); - response.setContentType( "application/pdf" ); - response.addHeader( "Content-disposition", "attachment;filename=\"" + filename + "\"" ); - response.setContentLength( pdf.length ); + HttpServletResponse response = ( HttpServletResponse ) context.getExternalContext().getResponse(); + + response.setHeader( "Expires", "0" ); + response.setHeader( "Cache-Control", "must-revalidate, post-check=0, pre-check=0" ); + response.setHeader( "Pragma", "public" ); + response.setContentType( "application/pdf" ); + response.addHeader( "Content-disposition", "attachment;filename=\"" + filename + "\"" ); + response.setContentLength( pdf.length ); response.getOutputStream().write( pdf ); response.getOutputStream().flush(); response.getOutputStream().close(); context.responseComplete(); - + System.out.println( "SHOW PDF done." ); - } - - - private void initialize() - { - Utilizador u = getSessionBean1().getCurrentUser(); - - Integer estabelecimento_id = null; - if(u.getTipo().intValue() != Global.TECNICO_HS) - { - estabelecimento_id = u.getEstabelecimento_id(); - } + } + + private void initialize() + { + Utilizador u = getSessionBean1().getCurrentUser(); + +// Integer estabelecimento_id = null; +// if ( u.getTipo().intValue() != Global.TECNICO_HS ) +// { +// estabelecimento_id = u.getEstabelecimento_id(); +// } System.out.println( "INITIALIZE:" ); - if ( ! getSessionBean1().getIsSearchingPlanosActuacao() ) + if ( !getSessionBean1().getIsSearchingPlanosActuacao() ) { System.out.println( "\tGETTING INITIAL VALUES FOR EACH TABLE." ); long startedTime = System.currentTimeMillis(); - List listPlanosActivos = getPlanosActivos(u); - getSessionBean1().getPlanosActualDataProvider().setList(listPlanosActivos); + List listPlanosActivos = getPlanosActivos( u ); + getSessionBean1().getPlanosActualDataProvider().setList( listPlanosActivos ); - List listPlanosSeguimento = getPlanosSeguimento(u); - getSessionBean1().getPlanosSeguimentoDataProvider().setList(listPlanosSeguimento); + List listPlanosSeguimento = getPlanosSeguimento( u ); + getSessionBean1().getPlanosSeguimentoDataProvider().setList( listPlanosSeguimento ); - List listPlanosConcluidos = getPlanosConcluidos(u); - getSessionBean1().getPlanosConcluidosDataProvider().setList(listPlanosConcluidos); + List listPlanosConcluidos = getPlanosConcluidos( u ); + getSessionBean1().getPlanosConcluidosDataProvider().setList( listPlanosConcluidos ); long endedTime = System.currentTimeMillis(); System.out.println( "\nGot Planos List in : " + getTime( startedTime, endedTime ) ); //2010-11-12 : user scampos : 1 min (debug mode) } - //checkPlanosDelayed(); - } + //checkPlanosDelayed(); + } private String getTime( long start, long end ) { return DateUtils.getTimePassed( start, end ); } - - - private PlanoActuacao getTableActivosRowData() - { - RowKey rk = tableRowGroup1.getRowKey(); - int k = Integer.parseInt(rk.getRowId()); - PlanosActualDataProvider provider = (PlanosActualDataProvider) tableRowGroup1.getSourceData(); - ArrayList list = (ArrayList) provider.getList(); - PlanoActuacao p = (PlanoActuacao)list.get(k); - return p; - } - - private PlanoActuacao getTableSeguimentoRowData() - { - RowKey rk = tableRowGroup2.getRowKey(); - int k = Integer.parseInt(rk.getRowId()); - PlanosSeguimentoDataProvider provider = (PlanosSeguimentoDataProvider) tableRowGroup2.getSourceData(); - ArrayList list = (ArrayList) provider.getList(); - PlanoActuacao p = (PlanoActuacao)list.get(k); - - return p; - } - - private PlanoActuacao getTableConcluidosRowData() - { - RowKey rk = tableRowGroup3.getRowKey(); - int k = Integer.parseInt(rk.getRowId()); - PlanosConcluidosDataProvider provider = (PlanosConcluidosDataProvider) tableRowGroup3.getSourceData(); - ArrayList list = (ArrayList) provider.getList(); - PlanoActuacao p = (PlanoActuacao)list.get(k); - return p; - } - - private void checkPlanosDelayed() - { - - } - - - + + private PlanoActuacao getTableActivosRowData() + { + RowKey rk = tableRowGroup1.getRowKey(); + int k = Integer.parseInt( rk.getRowId() ); + PlanosActualDataProvider provider = ( PlanosActualDataProvider ) tableRowGroup1.getSourceData(); + ArrayList list = ( ArrayList ) provider.getList(); + PlanoActuacao p = ( PlanoActuacao ) list.get( k ); + return p; + } + + private PlanoActuacao getTableSeguimentoRowData() + { + RowKey rk = tableRowGroup2.getRowKey(); + int k = Integer.parseInt( rk.getRowId() ); + PlanosSeguimentoDataProvider provider = ( PlanosSeguimentoDataProvider ) tableRowGroup2.getSourceData(); + ArrayList list = ( ArrayList ) provider.getList(); + PlanoActuacao p = ( PlanoActuacao ) list.get( k ); + + return p; + } + + private PlanoActuacao getTableConcluidosRowData() + { + RowKey rk = tableRowGroup3.getRowKey(); + int k = Integer.parseInt( rk.getRowId() ); + PlanosConcluidosDataProvider provider = ( PlanosConcluidosDataProvider ) tableRowGroup3.getSourceData(); + ArrayList list = ( ArrayList ) provider.getList(); + PlanoActuacao p = ( PlanoActuacao ) list.get( k ); + return p; + } + + private void checkPlanosDelayed() + { + } + // private void showPlano(PlanoActuacao p) // { // System.out.println("PLANO : " + p.getData_visita_str() + " | " + p.getFase_nome() + " | " + p.getNome_estabelecimento()); @@ -791,15 +830,12 @@ public class ListaPlanos extends AbstractPageBean // System.out.println(" " + p.getDescricao()); // } // } - - public List< PlanoActuacao > searchPlanosActivos( Utilizador u, String nome, String estabelecimento, String dataVisita ) + public List searchPlanosActivos( Utilizador u, String nome, String estabelecimento, String dataVisita ) { - List< PlanoActuacao > list = new ArrayList< PlanoActuacao >(); + List list = new ArrayList(); try { - if ( u.getTipo().intValue() != Global.DIRECTOR_SIPRP - && u.getTipo().intValue() != Global.GESTOR - && u.getTipo().intValue() != Global.DIRECTOR_GERAL_RH ) + if ( u.getTipo().intValue() != Global.DIRECTOR_SIPRP && u.getTipo().intValue() != Global.GESTOR && u.getTipo().intValue() != Global.DIRECTOR_GERAL_RH ) { PlanosDataProvider pdp = PlanosDataProvider.getInstance(); list = pdp.searchPlanosActivos( u, nome, estabelecimento, dataVisita ); @@ -812,8 +848,8 @@ public class ListaPlanos extends AbstractPageBean return list; } - public List getPlanosActivos(Utilizador u) - { + public List getPlanosActivos( Utilizador u ) + { return searchPlanosActivos( u, null, null, null ); // List< PlanoActuacao > list = new ArrayList(); // try @@ -831,25 +867,25 @@ public class ListaPlanos extends AbstractPageBean // ErrorLogger.logException( ex ); // } // return list; - } + } - public List< PlanoActuacao > searchPlanosSeguimento( Utilizador u, String nome, String estabelecimento, String dataVisita ) + public List searchPlanosSeguimento( Utilizador u, String nome, String estabelecimento, String dataVisita ) { - List< PlanoActuacao > list = new ArrayList(); - try - { + List list = new ArrayList(); + try + { PlanosDataProvider pdp = PlanosDataProvider.getInstance(); list = pdp.searchPlanosSeguimento( u, nome, estabelecimento, dataVisita ); - } - catch(Exception ex) - { - ErrorLogger.logException( ex ); - } - return list; + } + catch ( Exception ex ) + { + ErrorLogger.logException( ex ); + } + return list; } - public List getPlanosSeguimento(Utilizador u) - { + public List getPlanosSeguimento( Utilizador u ) + { return searchPlanosSeguimento( u, null, null, null ); // List< PlanoActuacao > list = new ArrayList(); // try @@ -862,25 +898,25 @@ public class ListaPlanos extends AbstractPageBean // ErrorLogger.logException( ex ); // } // return list; - } + } - public List< PlanoActuacao > searchPlanosConcluidos( Utilizador u, String nome, String estabelecimento, String dataVisita ) + public List searchPlanosConcluidos( Utilizador u, String nome, String estabelecimento, String dataVisita ) { - List< PlanoActuacao > list = new ArrayList(); - try - { + List list = new ArrayList(); + try + { PlanosDataProvider pdp = PlanosDataProvider.getInstance(); list = pdp.searchPlanosConcluidos( u, nome, estabelecimento, dataVisita ); - } - catch(Exception ex) - { - ErrorLogger.logException( ex ); - } - return list; + } + catch ( Exception ex ) + { + ErrorLogger.logException( ex ); + } + return list; } - public List getPlanosConcluidos(Utilizador u) - { + public List getPlanosConcluidos( Utilizador u ) + { return searchPlanosConcluidos( u, null, null, null ); // List< PlanoActuacao > list = new ArrayList(); // try @@ -893,31 +929,29 @@ public class ListaPlanos extends AbstractPageBean // ErrorLogger.logException( ex ); // } // return list; - } - - + } public String buttonFilterActual_action() { - String nome = null; - if ( textFilterNameActual.getText() != null ) - { - nome = (( String ) textFilterNameActual.getText()).trim(); - if( nome.length() == 0 ) - { - nome = null; - } - } + String nome = null; + if ( textFilterNameActual.getText() != null ) + { + nome = ( ( String ) textFilterNameActual.getText() ).trim(); + if ( nome.length() == 0 ) + { + nome = null; + } + } String estabelecimento = null; - if ( textFilterEstabelecimentoActual.getText() != null ) - { - estabelecimento = (( String ) textFilterEstabelecimentoActual.getText()).trim(); - if( estabelecimento.length() == 0 ) - { - estabelecimento = null; - } - } + if ( textFilterEstabelecimentoActual.getText() != null ) + { + estabelecimento = ( ( String ) textFilterEstabelecimentoActual.getText() ).trim(); + if ( estabelecimento.length() == 0 ) + { + estabelecimento = null; + } + } Date visitaDate = ( Date ) calFilterDateActual.getValue(); String visitaDateStr = null; @@ -927,7 +961,7 @@ public class ListaPlanos extends AbstractPageBean } getSessionBean1().setIsSearchingPlanosActuacao( Boolean.TRUE ); - getSessionBean1().getPlanosActualDataProvider().setList( + getSessionBean1().getPlanosActualDataProvider().setList( searchPlanosActivos( getSessionBean1().getCurrentUser(), nome, estabelecimento, visitaDateStr ) ); return null; @@ -935,25 +969,25 @@ public class ListaPlanos extends AbstractPageBean public String buttonFilterSeg_action() { - String nome = null; - if ( textFilterNameSeg.getText() != null ) - { - nome = (( String ) textFilterNameSeg.getText()).trim(); - if( nome.length() == 0 ) - { - nome = null; - } - } + String nome = null; + if ( textFilterNameSeg.getText() != null ) + { + nome = ( ( String ) textFilterNameSeg.getText() ).trim(); + if ( nome.length() == 0 ) + { + nome = null; + } + } String estabelecimento = null; - if ( textFilterEstabelecimentoSeg.getText() != null ) - { - estabelecimento = (( String ) textFilterEstabelecimentoSeg.getText()).trim(); - if( estabelecimento.length() == 0 ) - { - estabelecimento = null; - } - } + if ( textFilterEstabelecimentoSeg.getText() != null ) + { + estabelecimento = ( ( String ) textFilterEstabelecimentoSeg.getText() ).trim(); + if ( estabelecimento.length() == 0 ) + { + estabelecimento = null; + } + } Date visitaDate = ( Date ) calFilterDateSeg.getValue(); String visitaDateStr = null; @@ -969,28 +1003,27 @@ public class ListaPlanos extends AbstractPageBean return null; } - public String buttonFilterConc_action() { - String nome = null; - if ( textFilterNameConc.getText() != null ) - { - nome = (( String ) textFilterNameConc.getText()).trim(); - if( nome.length() == 0 ) - { - nome = null; - } - } + String nome = null; + if ( textFilterNameConc.getText() != null ) + { + nome = ( ( String ) textFilterNameConc.getText() ).trim(); + if ( nome.length() == 0 ) + { + nome = null; + } + } String estabelecimento = null; - if ( textFilterEstabelecimentoConc.getText() != null ) - { - estabelecimento = (( String ) textFilterEstabelecimentoConc.getText()).trim(); - if( estabelecimento.length() == 0 ) - { - estabelecimento = null; - } - } + if ( textFilterEstabelecimentoConc.getText() != null ) + { + estabelecimento = ( ( String ) textFilterEstabelecimentoConc.getText() ).trim(); + if ( estabelecimento.length() == 0 ) + { + estabelecimento = null; + } + } Date visitaDate = ( Date ) calFilterDateConc.getValue(); String visitaDateStr = null; @@ -1005,6 +1038,5 @@ public class ListaPlanos extends AbstractPageBean return null; } - } diff --git a/trunk/PlanosActuacao/web/ListaPlanos.jsp b/trunk/PlanosActuacao/web/ListaPlanos.jsp index 3b004caa..d6137a61 100644 --- a/trunk/PlanosActuacao/web/ListaPlanos.jsp +++ b/trunk/PlanosActuacao/web/ListaPlanos.jsp @@ -101,9 +101,10 @@ - + + actionExpression="#{ListaPlanos.goDesactivarPlano_action}" binding="#{ListaPlanos.buttonDesactivar}" + />