postos = new ArrayList();
+ if(rs.isBeforeFirst())
+ {
+ rs.first();
+ do
+ {
+ PostoTrabalho p = new PostoTrabalho();
+ p.setId(new Integer( rs.getInt("posto_id") ));
+ p.setPosto_id(p.getId());
+ p.setDescricao(Utils.unicodeToHTML(rs.getString("descricao")));
+ postos.add(p);
+ }while(rs.next());
+ }
+ return postos;
+ }
+
+
+
+ private boolean existemMedidasByArea(Integer area_id) throws Exception
+ {
+ Statement st = createLocalStatement();
+ String sql = "select distinct medida_id, valor, descricao ";
+ sql += "from ( select distinct hs_relatorio_posto_medida.medida_id, hs_relatorio_posto_risco.risco_id, hs_relatorio_medida.description as descricao, ";
+ sql += "case when hs_relatorio_posto_risco.valor_qualitativo_id isnull and hs_relatorio_posto_risco.probabilidade isnull and hs_relatorio_posto_risco.severidade isnull then null ";
+ sql += "when hs_relatorio_posto_risco.valor_qualitativo_id isnull then hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade else hs_relatorio_posto_risco.valor_qualitativo_id end as valor from hs_relatorio_posto ";
+ sql += "inner join hs_relatorio_posto_medida on hs_relatorio_posto_medida.posto_id = hs_relatorio_posto.id ";
+ sql += "inner join hs_relatorio_medida on hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id ";
+ sql += "inner join hs_relatorio_risco on hs_relatorio_risco.id = hs_relatorio_medida.risco_id ";
+ sql += "inner join hs_relatorio_posto_risco on (hs_relatorio_posto_risco.posto_id = hs_relatorio_posto.id and hs_relatorio_posto_risco.risco_id = hs_relatorio_risco.id) ";
+ sql += "inner join hs_relatorio on hs_relatorio.id = hs_relatorio_risco.relatorio_id ";
+ sql += "inner join hs_relatorio_area on hs_relatorio_area.id = area_id ";
+ sql += "where area_id = " + area_id + " and hs_relatorio_posto_medida.is_plano_actuacao = true) subquery order by subquery.medida_id, valor";
+ System.out.println("EXISTEM MEDIDAS BY AREA SQL : " + sql);
+ ResultSet rs = st.executeQuery(sql);
+ if(rs.isBeforeFirst())
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ private boolean existemMedidasByRisco(Integer risco_id) throws Exception
+ {
+ Statement st = createLocalStatement();
+ String sql = "select distinct medida_id ";
+ sql += "from ( select distinct hs_relatorio_posto_medida.medida_id, hs_relatorio_posto_risco.risco_id, hs_relatorio_medida.description as descricao, ";
+ sql += "case when hs_relatorio_posto_risco.valor_qualitativo_id isnull and hs_relatorio_posto_risco.probabilidade isnull and hs_relatorio_posto_risco.severidade isnull then null ";
+ sql += "when hs_relatorio_posto_risco.valor_qualitativo_id isnull then hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade else hs_relatorio_posto_risco.valor_qualitativo_id end as valor from hs_relatorio_posto ";
+ sql += "inner join hs_relatorio_posto_medida on hs_relatorio_posto_medida.posto_id = hs_relatorio_posto.id ";
+ sql += "inner join hs_relatorio_medida on hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id ";
+ sql += "inner join hs_relatorio_risco on hs_relatorio_risco.id = hs_relatorio_medida.risco_id ";
+ sql += "inner join hs_relatorio_posto_risco on (hs_relatorio_posto_risco.posto_id = hs_relatorio_posto.id and hs_relatorio_posto_risco.risco_id = hs_relatorio_risco.id) ";
+ sql += "inner join hs_relatorio on hs_relatorio.id = hs_relatorio_risco.relatorio_id ";
+ sql += "inner join hs_relatorio_area on hs_relatorio_area.id = area_id ";
+ sql += "where hs_relatorio_posto_risco.risco_id = " + risco_id + " and hs_relatorio_posto_medida.is_plano_actuacao = true) subquery order by medida_id";
+ System.out.println("EXISTEM MEDIDAS BY RISCO SQL : " + sql);
+ ResultSet rs = st.executeQuery(sql);
+ if(rs.isBeforeFirst())
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+
+
+ public Integer createPlano(PlanoActuacao p) throws Exception
+ {
+ Statement st = createStatement();
+ Integer newId = getMaxTableId("planos_actuacao");
+ String sql = "insert into planos_actuacao (id, estabelecimento_id, fase, data_visita, data_relatorio, nome_estabelecimento, empresa_id, nome_empresa, data_controlo, tecnico_hs_id, tecnico_hs_nome) values (";
+ sql += newId + ", ";
+ sql += p.getEstabelecimento_id() + ", ";
+ sql += p.getFase() + ", '";
+ java.sql.Date sqlDate = new java.sql.Date(p.getData_visita().getTime());
+ sql += sqlDate + "', '";
+ sqlDate = new java.sql.Date(p.getData_relatorio().getTime());
+ sql += sqlDate + "', '";
+ sql += p.getNome_estabelecimento() + "', ";
+ sql += p.getEmpresa_id() + ", '";
+ sql += p.getNome_empresa() + "', '";
+ Date today = new Date();
+ sqlDate = new java.sql.Date(today.getTime());
+ sql += sqlDate + "', ";
+ sql += p.getTecnico_hs_id() + ", ";
+ if(p.getTecnico_hs_nome() == null)
+ {
+ sql += null;
+ }
+ else
+ {
+ sql += "'" + p.getTecnico_hs_nome() + "'";
+ }
+
+ sql += ")";
+
+ System.out.println("SQL CREATE PLANO : " + sql);
+ st.execute(sql);
+
+ return newId;
+ }
+
+
+ public Integer createArea(Area a) throws Exception
+ {
+ Statement st = createStatement();
+ Integer newId = getMaxTableId("plano_areas");
+ String sql = "insert into plano_areas (id, area_id, plano_id, descricao) values (";
+ sql += newId + ", ";
+ sql += a.getArea_id() + ", ";
+ sql += a.getPlano_id() + ", '";
+ sql += a.getDescricao() + "' ";
+ sql += ")";
+
+ System.out.println("SQL CREATE AREA : " + sql);
+ st.execute(sql);
+ return newId;
+ }
+
+ public Integer createRisco(Risco r) throws Exception
+ {
+ Statement st = createStatement();
+ Integer newId = getMaxTableId("plano_riscos");
+ String sql = "insert into plano_riscos (id, area_id, descricao, valor, risco_id) values (";
+ sql += newId + ", ";
+ sql += r.getArea_id() + ", '";
+ sql += r.getDescricao() + "', ";
+ sql += r.getValor() + ", ";
+ sql += r.getId();
+ sql += ")";
+
+ System.out.println("SQL CREATE RISCO : " + sql);
+ st.execute(sql);
+ return newId;
+ }
+
+ public Integer createValor(Valor v) throws Exception
+ {
+ Statement st = createStatement();
+ Integer newId = getMaxTableId("plano_valores");
+ String sql = "insert into plano_valores (id, risco_id, valor) values (";
+ sql += newId + ", ";
+ sql += v.getRisco_id() + ", ";
+ sql += v.getValor() + "";
+ sql += ")";
+
+ System.out.println("SQL CREATE VALOR : " + sql);
+ st.execute(sql);
+ return newId;
+ }
+
+ public Integer createMedida(Medida m) throws Exception
+ {
+ Statement st = createStatement();
+ Integer newId = getMaxTableId("plano_medidas");
+ String sql = "insert into plano_medidas (id, medida_id, risco_id, descricao) values (";
+ sql += newId + ", ";
+ sql += m.getMedida_id() + ", ";
+ sql += m.getRisco_id() + ", '";
+ sql += m.getDescricao() + "' ";
+ sql += ")";
+
+ System.out.println("SQL CREATE MEDIDA : " + sql);
+ st.execute(sql);
+ return newId;
+ }
+
+ public void createPostoTrabalho(PostoTrabalho p) throws Exception
+ {
+ Statement st = createStatement();
+ Integer newId = getMaxTableId("plano_postos_trabalho");
+ String sql = "insert into plano_postos_trabalho (id, posto_id, medida_id, descricao) values (";
+ sql += newId + ", ";
+ sql += p.getPosto_id() + ", ";
+ sql += p.getMedida_id() + ", '";
+ sql += p.getDescricao() + "' ";
+ sql += ")";
+
+ System.out.println("SQL CREATE POSTO : " + sql);
+ st.execute(sql);
+ }
+
+
+
+ //====================
+
+
+
+ public String getEmpresaNome(Integer empresa_id) throws Exception
+ {
+ Statement st = createLocalStatement();
+ String sql ="SELECT designacao_social FROM empresas WHERE id = " + empresa_id;
+ ResultSet rslocal = st.executeQuery(sql);
+ rslocal.first();
+ String nome = Utils.unicodeToHTML(rslocal.getString("designacao_social"));
+ return nome;
+ }
+
+
+ protected Statement createStatement()
+ {
+
+ return db.createStatement();
+ }
+
+ protected Statement createLocalStatement()
+ {
+
+ return dblocal.createStatement();
+ }
+}
diff --git a/trunk/PlanosActuacao/src/java/db/providers/GenericDataProvider.java b/trunk/PlanosActuacao/src/java/db/providers/GenericDataProvider.java
index e32962c7..91213754 100644
--- a/trunk/PlanosActuacao/src/java/db/providers/GenericDataProvider.java
+++ b/trunk/PlanosActuacao/src/java/db/providers/GenericDataProvider.java
@@ -5,6 +5,9 @@
package db.providers;
+import com.evolute.utils.timer.TimedEvent;
+import com.evolute.utils.timer.Timer;
+import planosactuacao.PlanosActuacao;
import db.Db;
import java.sql.ResultSet;
import java.sql.Statement;
@@ -22,7 +25,8 @@ public class GenericDataProvider {
{
try
{
- db.connect();
+ db.connect();
+
}
catch(Exception ex)
{
diff --git a/trunk/PlanosActuacao/src/java/db/providers/PlanosDataProvider.java b/trunk/PlanosActuacao/src/java/db/providers/PlanosDataProvider.java
index 763b41ff..0a00b4da 100644
--- a/trunk/PlanosActuacao/src/java/db/providers/PlanosDataProvider.java
+++ b/trunk/PlanosActuacao/src/java/db/providers/PlanosDataProvider.java
@@ -444,13 +444,35 @@ public class PlanosDataProvider extends GenericDataProvider{
case Global.DIRECTOR_SIPRP:
sql += "WHERE fase > 1 AND fase < 6";
- break;
+ break;
+
+ case Global.RH:
+ sql += "WHERE fase > 1 AND fase < 6";
+ break;
+
+ case Global.DIRECTOR_GERAL_RH:
+ sql += "WHERE fase > 1 AND fase < 6";
+ break;
+
+ case Global.GESTOR:
+ sql += "WHERE fase > 1 AND fase < 6";
+ break;
}
- if(userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS && userType != Global.DIRECTOR_NACIONAL_SEGURANCA)
+ if(userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS && userType != Global.DIRECTOR_NACIONAL_SEGURANCA && userType != Global.DIRECTOR_GERAL_RH && userType != Global.GESTOR)
{
sql += " and estabelecimento_id = " + u.getEstabelecimento_id();
}
+ //System.out.println("USER ESTABELECIMENTO GESTOR : " + u.getEstabelecimento_gestor().intValue());
+ if(userType == Global.GESTOR)
+ {
+ if(u.getEstabelecimento_gestor().intValue() > 0)
+ {
+ sql += " and estabelecimento_id = " + u.getEstabelecimento_gestor();
+ }
+ }
+
+ System.out.println("PLANOS SEGUIMENTO SQL : " + sql);
ResultSet rs = st.executeQuery(sql);
ArrayList list = getFullPlanos(rs);
return list;
@@ -461,11 +483,12 @@ public class PlanosDataProvider extends GenericDataProvider{
int userType = u.getTipo().intValue();
Statement st = createStatement();
String sql = "select * from planos_actuacao where fase = 6";
- if(userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS && userType != Global.DIRECTOR_NACIONAL_SEGURANCA)
+ if(userType != Global.DIRECTOR_SIPRP && userType != Global.TECNICO_HS && userType != Global.DIRECTOR_NACIONAL_SEGURANCA && userType != Global.DIRECTOR_GERAL_RH)
{
sql += " and estabelecimento_id = " + u.getEstabelecimento_id();
}
-
+
+ System.out.println("PLANOS CONCLUIDOS SQL : " + sql);
ResultSet rs = st.executeQuery(sql);
ArrayList list = getFullPlanos(rs);
return list;
diff --git a/trunk/PlanosActuacao/src/java/phaselistener/MainPhaseListener.java b/trunk/PlanosActuacao/src/java/phaselistener/MainPhaseListener.java
index 343da0c3..aba044ff 100644
--- a/trunk/PlanosActuacao/src/java/phaselistener/MainPhaseListener.java
+++ b/trunk/PlanosActuacao/src/java/phaselistener/MainPhaseListener.java
@@ -151,6 +151,7 @@ public class MainPhaseListener implements PhaseListener{
session.setDisableMenuPlanos(false);
if(sview.matches("/ViewPlano.jsp"))
{
+
if(u.getTipo().intValue() == Global.DIRECTOR_SIPRP)
{
//session.setDisableMenu(false);
@@ -178,6 +179,10 @@ public class MainPhaseListener implements PhaseListener{
session.setDisableMenu(false);
if(sview.matches("/ListaPlanos.jsp"))
{
+ if(u.getTipo().intValue() == Global.RH || u.getTipo().intValue() == Global.GESTOR)
+ {
+ session.setDisableMenuUtilizadores(true);
+ }
session.setDisableMenuPlanos(true);
}
}
diff --git a/trunk/PlanosActuacao/src/java/planosactuacao/ApplicationBean1.java b/trunk/PlanosActuacao/src/java/planosactuacao/ApplicationBean1.java
index 1bc2e261..d0aa545c 100644
--- a/trunk/PlanosActuacao/src/java/planosactuacao/ApplicationBean1.java
+++ b/trunk/PlanosActuacao/src/java/planosactuacao/ApplicationBean1.java
@@ -7,6 +7,7 @@
package planosactuacao;
import com.sun.rave.web.ui.appbase.AbstractApplicationBean;
+import java.sql.Connection;
import javax.faces.FacesException;
/**
@@ -33,6 +34,10 @@ public class ApplicationBean1 extends AbstractApplicationBean {
}
//
+ private boolean timerStarted = false;
+ private Connection localConnection = null;
+ private Connection connection = null;
+
/**
* Construct a new application data bean instance.
*/
@@ -101,4 +106,44 @@ public class ApplicationBean1 extends AbstractApplicationBean {
public String getLocaleCharacterEncoding() {
return super.getLocaleCharacterEncoding();
}
+
+ /**
+ * @return the timerStarted
+ */
+ public boolean isTimerStarted() {
+ return timerStarted;
+ }
+
+ /**
+ * @param timerStarted the timerStarted to set
+ */
+ public void setTimerStarted(boolean timerStarted) {
+ this.timerStarted = timerStarted;
+ }
+
+ /**
+ * @return the connection
+ */
+ public Connection getConnection() {
+ return connection;
+ }
+
+ /**
+ * @param connection the connection to set
+ */
+ public void setConnection(Connection connection) {
+ this.connection = connection;
+ }
+
+ public Connection getLocalConnection() {
+ return localConnection;
+ }
+
+ /**
+ * @param connection the connection to set
+ */
+ public void setLocalConnection(Connection connection) {
+ this.localConnection = connection;
+ }
+
}
diff --git a/trunk/PlanosActuacao/src/java/planosactuacao/ListaPlanos.java b/trunk/PlanosActuacao/src/java/planosactuacao/ListaPlanos.java
index faf06ab0..fd326798 100644
--- a/trunk/PlanosActuacao/src/java/planosactuacao/ListaPlanos.java
+++ b/trunk/PlanosActuacao/src/java/planosactuacao/ListaPlanos.java
@@ -6,17 +6,18 @@
package planosactuacao;
+import com.evolute.utils.timer.TimedEvent;
+import com.evolute.utils.timer.Timer;
import com.sun.data.provider.RowKey;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Table;
import com.sun.webui.jsf.component.TableRowGroup;
+import db.Dblocal;
import db.entidades.PlanoActuacao;
import db.providers.UtilizadoresDataProvider;
import db.entidades.Utilizador;
import db.providers.PlanosDataProvider;
import global.Global;
-import java.io.File;
-import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
@@ -24,7 +25,6 @@ import java.util.List;
import javax.faces.FacesException;
import javax.faces.component.html.HtmlPanelGrid;
import javax.faces.context.FacesContext;
-import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletResponse;
import siprp.database.cayenne.providers.PlanoActuacaoDAO;
import siprp.planoactuacao.print.PlanoActuacaoPDFCreator;
@@ -169,6 +169,7 @@ public class ListaPlanos extends AbstractPageBean {
FacesContext fc = getFacesContext();
String user_id = JSFUtils.getRequestParameter(fc, "user");
+ String estab_gestor = JSFUtils.getRequestParameter(fc, "estab_gestor");
System.out.println("LISTA PLANOS - USER ID : " + user_id);
Utilizador u = null;
if(user_id != null)
@@ -183,6 +184,20 @@ public class ListaPlanos extends AbstractPageBean {
UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
udp.checkConnection();
u = udp.getUtilizador(userId);
+ if(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)
+ {
+ ex2.printStackTrace();
+ }
+
+ }
getSessionBean1().setCurrentUser(u);
@@ -200,14 +215,14 @@ public class ListaPlanos extends AbstractPageBean {
}
u = getSessionBean1().getCurrentUser();
- if(u.getTipo().intValue() == Global.DIRECTOR_SIPRP)
+ 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)
+ if(u.getTipo().intValue() != Global.DIRECTOR_SIPRP && u.getTipo().intValue() != Global.RH && u.getTipo().intValue() != Global.DIRECTOR_GERAL_RH)
{
getSessionBean1().setDisableMenuUtilizadores(true);
tableRowGroup1.setEmptyDataMsg("Sem registos");
@@ -384,6 +399,38 @@ FacesContext context = FacesContext.getCurrentInstance();
private void initialize()
{
+ try
+ {
+ Dblocal dblocal = new Dblocal();
+ dblocal.connect();
+ }
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ if(!getApplicationBean1().isTimerStarted())
+ {
+ Timer.scheduleEvent(new TimedEvent(){
+ public void executeAction() throws Exception
+ {
+ try
+ {
+ PlanosActuacao planos = new PlanosActuacao();
+ }
+ catch( Exception ex )
+ {
+ }
+ Timer.resetEvent( this );
+ }
+ }, 3600);
+ getApplicationBean1().setTimerStarted(true);
+
+ }
+
+
+
+
Utilizador u = getSessionBean1().getCurrentUser();
Integer estabelecimento_id = null;
@@ -420,15 +467,15 @@ FacesContext context = FacesContext.getCurrentInstance();
//// Integer id = es.getId(); // estabelecimento id ??
// }
- PlanosActuacao planos = new PlanosActuacao(u);
+ ////PlanosActuacao planos = new PlanosActuacao(u);
- List listPlanosActivos = planos.getPlanosActivos(u);
+ List listPlanosActivos = getPlanosActivos(u);
getSessionBean1().getPlanosActualDataProvider().setList(listPlanosActivos);
- List listPlanosSeguimento = planos.getPlanosSeguimento(u);
+ List listPlanosSeguimento = getPlanosSeguimento(u);
getSessionBean1().getPlanosSeguimentoDataProvider().setList(listPlanosSeguimento);
- List listPlanosConcluidos = planos.getPlanosConcluidos(u);
+ List listPlanosConcluidos = getPlanosConcluidos(u);
getSessionBean1().getPlanosConcluidosDataProvider().setList(listPlanosConcluidos);
//checkPlanosDelayed();
@@ -525,7 +572,53 @@ FacesContext context = FacesContext.getCurrentInstance();
// {
// System.out.println(" " + p.getDescricao());
// }
-// }
+// }
+
+ public List getPlanosActivos(Utilizador u)
+ {
+ ArrayList list = new ArrayList();
+ try
+ {
+ if(u.getTipo().intValue() != Global.DIRECTOR_SIPRP && u.getTipo().intValue() != Global.GESTOR && u.getTipo().intValue() != Global.DIRECTOR_GERAL_RH)
+ {
+ list = pdp.getPlanosActivos(u);
+ }
+ }
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ return list;
+ }
+
+ public List getPlanosSeguimento(Utilizador u)
+ {
+ ArrayList list = new ArrayList();
+ try
+ {
+ list = pdp.getPlanosSeguimento(u);
+
+ }
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ return list;
+ }
+
+ public List getPlanosConcluidos(Utilizador u)
+ {
+ ArrayList list = new ArrayList();
+ try
+ {
+ list = pdp.getPlanosConcluidos(u);
+ }
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ return list;
+ }
}
diff --git a/trunk/PlanosActuacao/src/java/planosactuacao/PlanosActuacao.java b/trunk/PlanosActuacao/src/java/planosactuacao/PlanosActuacao.java
index 3a8c7b54..5f3d89a5 100644
--- a/trunk/PlanosActuacao/src/java/planosactuacao/PlanosActuacao.java
+++ b/trunk/PlanosActuacao/src/java/planosactuacao/PlanosActuacao.java
@@ -12,6 +12,7 @@ import db.entidades.PostoTrabalho;
import db.entidades.Risco;
import db.entidades.Utilizador;
import db.entidades.Valor;
+import db.providers.CreatePlanosDataProvider;
import db.providers.PlanosDataProvider;
import db.providers.RelatoriosDataProvider;
import db.providers.UtilizadoresDataProvider;
@@ -30,17 +31,45 @@ import siprp.database.cayenne.providers.PlanoActuacaoDAO;
* @author lluis
*/
public class PlanosActuacao {
- PlanosDataProvider pdp = new PlanosDataProvider();
- RelatoriosDataProvider rdp;
+ //PlanosDataProvider pdp = new PlanosDataProvider();
+ CreatePlanosDataProvider cpdp = new CreatePlanosDataProvider();
+ //RelatoriosDataProvider rdp;
List planosList;
List planosOnlineList;
- PlanoActuacaoDAO pa = new PlanoActuacaoDAO();
-
+ PlanoActuacaoDAO pa = new PlanoActuacaoDAO();
+
+
+ //DB
+
+
+
+
+ public PlanosActuacao()
+ {
+ try
+ {
+ //rdp = new RelatoriosDataProvider();
+ Integer estabelecimentoId = null;
+// if(u.getTipo().intValue() != Global.TECNICO_HS && u.getTipo().intValue() != Global.DIRECTOR_SIPRP)
+// {
+// estabelecimentoId = u.getEstabelecimento_id();
+// }
+ List planosOnlineList = getPlanosOnline();
+ System.out.println("PLANOS ONLINE LIST : " + planosOnlineList.size());
+ List listRelatorios = getRelatorios(planosOnlineList, estabelecimentoId);
+ System.out.println("LIST RELATORIOS : " + listRelatorios.size());
+ putPlanosOnline(listRelatorios);
+ }
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
public PlanosActuacao(Utilizador u){
try
{
- rdp = new RelatoriosDataProvider();
+ //rdp = new RelatoriosDataProvider();
Integer estabelecimentoId = null;
if(u.getTipo().intValue() != Global.TECNICO_HS && u.getTipo().intValue() != Global.DIRECTOR_SIPRP)
{
@@ -63,7 +92,7 @@ public class PlanosActuacao {
List list = null;
try
{
- list = pdp.getPlanosOnline();
+ list = cpdp.getPlanosOnline();
}
catch(Exception ex)
@@ -125,7 +154,8 @@ public class PlanosActuacao {
p.setEmpresa_id(relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos().getToEmpresas().getId());
try
{
- p.setNome_empresa(utils.Utils.unicodeToHTML(rdp.getEmpresaNome(p.getEmpresa_id())));
+ //p.setNome_empresa(utils.Utils.unicodeToHTML(rdp.getEmpresaNome(p.getEmpresa_id())));
+ p.setNome_empresa(utils.Utils.unicodeToHTML(cpdp.getEmpresaNome(p.getEmpresa_id())));
}
catch(Exception ex)
{
@@ -133,13 +163,14 @@ public class PlanosActuacao {
}
p.setNome_estabelecimento(relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos().getNome());
p.setData_relatorio(relatorio.getData());
- p = rdp.getFullPlano(p, relatorio.getId());
+ //p = rdp.getFullPlano(p, relatorio.getId());
+ p = cpdp.getFullPlano(p, relatorio.getId());
if(p.getAreas() != null)
{
if(p.getAreas().size() > 0)
{
- p.setId(pdp.createPlano(p));
+ p.setId(cpdp.createPlano(p));
System.out.println("CREATE PLANO - PLANO ID : " + p.getId().toString());
if(p.getAreas() != null)
{
@@ -166,7 +197,7 @@ public class PlanosActuacao {
for(Area a : areas)
{
a.setPlano_id(plano_id);
- a.setId(pdp.createArea(a));
+ a.setId(cpdp.createArea(a));
System.out.println("AREA =: " + a.getId().toString());
if(a.getRiscos() != null)
{
@@ -190,7 +221,7 @@ public class PlanosActuacao {
{
//System.out.println("RISCO -> " + r.getRisco_id().toString() + "VALOR -> " + v.getValor().toString());
r.setValor(v.getValor());
- r.setId(pdp.createRisco(r));
+ r.setId(cpdp.createRisco(r));
}
}
@@ -225,7 +256,7 @@ public class PlanosActuacao {
for(Medida m : medidas)
{
m.setRisco_id(risco_id);
- m.setId(pdp.createMedida(m));
+ m.setId(cpdp.createMedida(m));
if(m.getPostos() != null)
{
createPostos(m.getId(), m.getPostos());
@@ -239,55 +270,11 @@ public class PlanosActuacao {
for(PostoTrabalho p : postos)
{
p.setMedida_id(medida_id);
- pdp.createPostoTrabalho(p);
+ cpdp.createPostoTrabalho(p);
}
}
- public List getPlanosActivos(Utilizador u)
- {
- ArrayList list = new ArrayList();
- try
- {
- if(u.getTipo().intValue() != Global.DIRECTOR_SIPRP)
- {
- list = pdp.getPlanosActivos(u);
- }
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- }
- return list;
- }
-
- public List getPlanosSeguimento(Utilizador u)
- {
- ArrayList list = new ArrayList();
- try
- {
- list = pdp.getPlanosSeguimento(u);
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- }
- return list;
- }
-
- public List getPlanosConcluidos(Utilizador u)
- {
- ArrayList list = new ArrayList();
- try
- {
- list = pdp.getPlanosConcluidos(u);
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- }
- return list;
- }
diff --git a/trunk/PlanosActuacao/src/java/utils/JSFUtils.java b/trunk/PlanosActuacao/src/java/utils/JSFUtils.java
index 7f1bead4..1dd087f9 100644
--- a/trunk/PlanosActuacao/src/java/utils/JSFUtils.java
+++ b/trunk/PlanosActuacao/src/java/utils/JSFUtils.java
@@ -13,6 +13,7 @@ import javax.faces.context.FacesContext;
import javax.faces.render.ResponseStateManager;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import planosactuacao.ApplicationBean1;
import planosactuacao.SessionBean1;
/**
@@ -28,6 +29,15 @@ public class JSFUtils {
SessionBean1 session = (SessionBean1) context.getApplication().getELResolver().getValue(context.getELContext(), null, "SessionBean1");
return session;
}
+
+ public static ApplicationBean1 getApplicationBean(FacesContext fc)
+ {
+ FacesContext context = fc.getCurrentInstance();
+ System.out.println("CONTEXT : " + context);
+ ApplicationBean1 application = (ApplicationBean1) context.getApplication().getELResolver().getValue(context.getELContext(), null, "ApplicationBean1");
+ return application;
+ }
+
//
// isPostBack - JSF 1.1 implementation