22/12/2008

git-svn-id: https://svn.coded.pt/svn/SIPRP@859 bb69d46d-e84e-40c8-a05a-06db0d633741
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
L Luís = 17 years ago
parent d10f7ee396
commit 67f565642b

@ -2,15 +2,15 @@
<Scene Scope="Project" version="2">
<Scope Scope="Faces Configuration Only"/>
<Scope Scope="Project">
<Node id="RecuperarPassword.jsp" x="900" y="300" zoom="true"/>
<Node id="GestaoUtilizadores.jsp" x="900" y="150" zoom="true"/>
<Node id="RecuperarPassword.jsp" x="900" y="300" zoom="true"/>
<Node id="FormDirGerRh.jsp" x="150" y="150" zoom="true"/>
<Node id="FormGestor.jsp" x="1150" y="150" zoom="true"/>
<Node id="Erro.jsp" x="650" y="450" zoom="true"/>
<Node id="Acesso.jsp" x="400" y="750" zoom="true"/>
<Node id="Erro.jsp" x="650" y="450" zoom="true"/>
<Node id="FormRH.jsp" x="400" y="150" zoom="true"/>
<Node id="FormSeguranca.jsp" x="1150" y="300" zoom="true"/>
<Node id="AnaliseAcidenteTrabalho.jsp" x="150" y="300" zoom="true"/>
<Node id="FormSeguranca.jsp" x="1150" y="300" zoom="true"/>
<Node id="NovoUtilizador.jsp" x="150" y="450" zoom="true"/>
<Node id="FormDirSiprp.jsp" x="650" y="150" zoom="true"/>
<Node id="FichaUtilizador.jsp" x="1400" y="150" zoom="true"/>
@ -20,8 +20,8 @@
<Node id="UtilizadorFields.jsp" x="150" y="600" zoom="true"/>
<Node id="Dummy.jsp" x="150" y="750" zoom="true"/>
<Node id="LoadImage.jsp" x="400" y="600" zoom="true"/>
<Node id="ViewAnaliseAcidenteTrabalho.jsp" x="650" y="300" zoom="true"/>
<Node id="Login.jsp" x="400" y="300" zoom="true"/>
<Node id="ViewAnaliseAcidenteTrabalho.jsp" x="650" y="300" zoom="true"/>
</Scope>
<Scope Scope="All Faces Configurations"/>
</Scene>

@ -32,7 +32,7 @@ public class SessionBean1 extends AbstractSessionBean {
private void _init() throws Exception {
}
// </editor-fold>
private String logoEmpresaUrl = "";
/**
* <p>Construct a new session data bean instance.</p>
*/
@ -708,4 +708,13 @@ public class SessionBean1 extends AbstractSessionBean {
this.correcao = correcao;
}
public String getLogoEmpresaUrl() {
return logoEmpresaUrl;
}
public void setLogoEmpresaUrl(String logoEmpresaUrl) {
this.logoEmpresaUrl = logoEmpresaUrl;
}
}

@ -2204,6 +2204,37 @@ public class AnalisesDataProvider {
return hash;
}
public byte[] getLogoByEmpresa(Integer empresaId) throws Exception
{
Dblocal dblocal = new Dblocal();
dblocal.connect();
Statement st = dblocal.createStatement();
String sql = "select empresa_logo_id from empresas where id = " + empresaId;
ResultSet rslocal = st.executeQuery(sql);
if(rslocal.isBeforeFirst())
{
rslocal.first();
Integer logoId = new Integer(rslocal.getInt("empresa_logo_id"));
byte[] logo = getLogo(logoId);
return logo;
}
return null;
}
public byte[] getLogo(Integer logoId) throws Exception
{
Dblocal dblocal = new Dblocal();
dblocal.connect();
Statement st = dblocal.createStatement();
String sql = "select image_data from image where id = " + logoId;
ResultSet rslocal = st.executeQuery(sql);
rslocal.first();
byte[] logo = rslocal.getBytes("image_data");
System.out.println("LOGO SIZE : " + logo.length);
return logo;
}
private Statement createStatement()
{
Db db = new Db();

@ -57,6 +57,7 @@ public class Dblocal {
}
}
public void close() throws Exception
{
connection.close();

@ -72,6 +72,9 @@ public class Global {
//public static final String PLANOS_ACTUACAO_URL = "http://localhost:8084/PlanosActuacao/faces/ListaPlanos.jsp"; //testes
//public static final String PLANOS_ACTUACAO_URL = "http://192.168.111.24:8084/PlanosActuacao/faces/ListaPlanos.jsp"; //testes portatil
public static final String PLANOS_ACTUACAO_URL = "https://www.siprp.pt/PlanosActuacao/faces/ListaPlanos.jsp"; //real
public static final String LOGOS_FOLDER = "/resources/images";
/** Creates a new instance of Global */
public Global() {
}

@ -0,0 +1,58 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package phaselistener;
import analiseacidentestrabalho.Utilizador;
import global.Global;
import javax.faces.application.NavigationHandler;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
import javax.servlet.http.HttpServletRequest;
import analiseacidentestrabalho.SessionBean1;
import utils.JSFUtils;
import utils.Logos;
/**
*
* @author lluis
*/
public class MainPhaseListener implements PhaseListener{
private boolean firstEntry = true;
public void afterPhase(PhaseEvent pe) {
}
public void beforePhase(PhaseEvent pe) {
if(pe.getPhaseId() == PhaseId.RENDER_RESPONSE)
{
FacesContext fc = pe.getFacesContext();
SessionBean1 session = JSFUtils.getSessionBean(fc);
Utilizador u = session.getCurrentUser();
//insert logos
Integer empresaId = u.getEmpresa_id();
//System.out.println("LOGO EMPRESA ID : " + empresaId.toString());
Logos logos = new Logos();
String logourl = logos.getLogo(fc, empresaId);
//System.out.println("LOGO URL : " + logourl);
session.setLogoEmpresaUrl(logourl);
}
}
public PhaseId getPhaseId() {
return PhaseId.ANY_PHASE;
}
}

@ -5,6 +5,7 @@
package utils;
import analiseacidentestrabalho.SessionBean1;
import java.util.Iterator;
import java.util.Map;
import javax.faces.application.Application;
@ -42,6 +43,23 @@ public class JSFUtils {
// return false;
// }
public static SessionBean1 getSessionBean(FacesContext fc)
{
FacesContext context = fc.getCurrentInstance();
//HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
//SessionBean1 session = (SessionBean1) context.getApplication().getELResolver().getValue(context.getELContext(), null, "SessionBean1");
//SessionBean1 session = (SessionBean1) context.getApplication().;
final StringBuffer valueBinding = new StringBuffer();
valueBinding.append('#');
valueBinding.append('{');
valueBinding.append("SessionBean1");
valueBinding.append('}');
SessionBean1 session = (SessionBean1) fc.getApplication().
createValueBinding(valueBinding.toString()).getValue(fc);
return session;
}
public static boolean isPostBack(FacesContext fc)
{
Map parameterMap = fc.getExternalContext().getRequestParameterMap();

@ -0,0 +1,55 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package utils;
import db.AnalisesDataProvider;
import global.Global;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;
/**
*
* @author lluis
*/
public class Logos {
public String getLogo(Integer empresaId)
{
return null;
}
public String getLogo(FacesContext fc, Integer empresaId)
{
try
{
//get image from db :
AnalisesDataProvider adp = new AnalisesDataProvider();
byte[] logo = adp.getLogoByEmpresa(empresaId);
int len = logo.length;
ServletContext context = (ServletContext) fc.getExternalContext().getContext();
File logoFolder = new File(context.getRealPath(Global.LOGOS_FOLDER));
String logoFilename = logoFolder + "/logo_empresa.jpg";
OutputStream outImej = new FileOutputStream(logoFilename);
outImej.write(logo, 0, len);
System.out.println("LOGO PATH : " + logoFilename);
outImej.close();
return Global.LOGOS_FOLDER + "/logo_empresa.jpg";
}
catch(Exception ex)
{
ex.printStackTrace();
return null;
}
}
}

@ -29,7 +29,7 @@
style="border: 1px solid black; background-color: #eeeeee; height: 24px; width: 100%" styleClass="centerBlock" width="360">
<h:panelGrid columnClasses="gridColCenter, gridColCenter" columns="2" id="gridLogos1" style="height: 48px; width: 96px" styleClass="centerBlock">
<ui:image id="image1" url="/resources/images/SIPRP_logo_small.jpg"/>
<ui:image height="40" id="image2" url="/resources/images/logo_auchan_small.jpg"/>
<ui:image height="40" id="image2" url="#{SessionBean1.logoEmpresaUrl}"/>
</h:panelGrid>
<ui:staticText binding="#{Acesso.stWelcome}" escape="false" id="stWelcome" style="font-size: 14px"/>
<ui:staticText escape="false" id="staticText4" style="font-size: xx-large" text="&amp;nbsp;"/>

@ -169,7 +169,7 @@
</ui:panelGroup>
</h:panelGrid>
</h:panelGrid>
<ui:image binding="#{AnaliseAcidenteTrabalho.image28}" id="image28" url="/resources/images/Logo_Auchan_novo.jpg"/>
<ui:image binding="#{AnaliseAcidenteTrabalho.image28}" id="image28" url="#{SessionBean1.logoEmpresaUrl}"/>
</h:panelGrid>
</h:panelGrid>
<h:panelGrid binding="#{AnaliseAcidenteTrabalho.gridMsg}" columnClasses="gridColCenter" columns="1" id="gridMsg"

@ -28,7 +28,7 @@
style="border-bottom: solid #000000 1px; height: 24px; width: 100%" width="312">
<ui:panelGroup binding="#{EnviarCorrecao.groupPanel1}" id="groupPanel1" style="height: 24px; width: 216px">
<ui:image binding="#{EnviarCorrecao.image1}" id="image1" url="/resources/images/SIPRP_logo_small.jpg"/>
<ui:image binding="#{EnviarCorrecao.image2}" id="image2" url="/resources/images/Logo_Auchan_novo.jpg"/>
<ui:image binding="#{EnviarCorrecao.image2}" id="image2" url="#{SessionBean1.logoEmpresaUrl}"/>
</ui:panelGroup>
<h:panelGrid columnClasses="gridColRight" columns="1" id="gridPanel4" style="height: 24px; width: 100%">
<ui:panelGroup id="groupPanel2">

@ -48,7 +48,7 @@
style="border-bottom: solid rgb(0, 0, 0) 1px; height: 24px; width: 100%" width="312">
<ui:panelGroup binding="#{FichaUtilizador.groupPanel1}" id="groupPanel1" style="height: 24px; width: 216px">
<ui:image binding="#{FichaUtilizador.image1}" id="image1" url="/resources/images/SIPRP_logo_small.jpg"/>
<ui:image binding="#{FichaUtilizador.image2}" id="image2" url="/resources/images/Logo_Auchan_novo.jpg"/>
<ui:image binding="#{FichaUtilizador.image2}" id="image2" url="#{SessionBean1.logoEmpresaUrl}"/>
</ui:panelGroup>
<h:panelGrid columnClasses="gridColRight" columns="1" id="gridPanel9" style="height: 24px; width: 100%">
<ui:panelGroup id="groupPanel2">

@ -28,7 +28,7 @@
style="border-bottom: solid #000000 1px; height: 24px; width: 100%" width="312">
<ui:panelGroup binding="#{FormDirGerRh.groupPanel1}" id="groupPanel1" style="height: 24px; width: 216px">
<ui:image binding="#{FormDirGerRh.image1}" id="image1" url="/resources/images/SIPRP_logo_small.jpg"/>
<ui:image binding="#{FormDirGerRh.image2}" id="image2" url="/resources/images/Logo_Auchan_novo.jpg"/>
<ui:image binding="#{FormDirGerRh.image2}" id="image2" url="#{SessionBean1.logoEmpresaUrl}"/>
</ui:panelGroup>
<h:panelGrid columnClasses="gridColRight" columns="1" id="gridPanel8" style="height: 24px; width: 100%">
<ui:panelGroup id="groupPanel2">

@ -28,7 +28,7 @@
style="border-bottom: solid #000000 1px; height: 24px; width: 100%" width="312">
<ui:panelGroup binding="#{FormDirSiprp.groupPanel1}" id="groupPanel1" style="height: 24px; width: 216px">
<ui:image binding="#{FormDirSiprp.image1}" id="image1" url="/resources/images/SIPRP_logo_small.jpg"/>
<ui:image binding="#{FormDirSiprp.image2}" id="image2" url="/resources/images/Logo_Auchan_novo.jpg"/>
<ui:image binding="#{FormDirSiprp.image2}" id="image2" url="#{SessionBean1.logoEmpresaUrl}"/>
</ui:panelGroup>
<h:panelGrid columnClasses="gridColRight" columns="1" id="gridPanel3" style="height: 24px; width: 100%">
<ui:panelGroup id="groupPanel2">

@ -28,7 +28,7 @@
style="border-bottom: solid #000000 1px; height: 24px; width: 100%" width="312">
<ui:panelGroup binding="#{FormGestor.groupPanel1}" id="groupPanel1" style="height: 24px; width: 216px">
<ui:image binding="#{FormGestor.image1}" id="image1" url="/resources/images/SIPRP_logo_small.jpg"/>
<ui:image binding="#{FormGestor.image2}" id="image2" url="/resources/images/Logo_Auchan_novo.jpg"/>
<ui:image binding="#{FormGestor.image2}" id="image2" url="#{SessionBean1.logoEmpresaUrl}"/>
</ui:panelGroup>
<h:panelGrid columnClasses="gridColRight" columns="1" id="gridPanel8" style="height: 24px; width: 100%">
<ui:panelGroup id="groupPanel2">

@ -28,7 +28,7 @@
style="border-bottom: solid #000000 1px; height: 24px; width: 100%" width="312">
<ui:panelGroup binding="#{FormHS.groupPanel1}" id="groupPanel1" style="height: 24px; width: 216px">
<ui:image binding="#{FormHS.image1}" id="image1" url="/resources/images/SIPRP_logo_small.jpg"/>
<ui:image binding="#{FormHS.image2}" id="image2" url="/resources/images/Logo_Auchan_novo.jpg"/>
<ui:image binding="#{FormHS.image2}" id="image2" url="#{SessionBean1.logoEmpresaUrl}"/>
</ui:panelGroup>
<h:panelGrid columnClasses="gridColRight" columns="1" id="gridPanel11" style="height: 24px; width: 100%">
<ui:panelGroup id="groupPanel2">

@ -28,7 +28,7 @@
style="border-bottom: solid #000000 1px; height: 24px; width: 100%" width="312">
<ui:panelGroup binding="#{FormRH.groupPanel1}" id="groupPanel1" style="height: 24px; width: 216px">
<ui:image binding="#{FormRH.image1}" id="image1" url="/resources/images/SIPRP_logo_small.jpg"/>
<ui:image binding="#{FormRH.image2}" id="image2" url="/resources/images/Logo_Auchan_novo.jpg"/>
<ui:image binding="#{FormRH.image2}" id="image2" url="#{SessionBean1.logoEmpresaUrl}"/>
</ui:panelGroup>
<h:panelGrid columnClasses="gridColRight" columns="1" id="gridPanel11" style="height: 24px; width: 100%">
<ui:panelGroup id="groupPanel2">

@ -29,7 +29,7 @@
style="border-bottom: solid #000000 1px; height: 24px; width: 100%" width="312">
<ui:panelGroup binding="#{FormSeguranca.groupPanel5}" id="groupPanel5" style="height: 24px; width: 216px">
<ui:image binding="#{FormSeguranca.image1}" id="image1" url="/resources/images/SIPRP_logo_small.jpg"/>
<ui:image binding="#{FormSeguranca.image2}" id="image2" url="/resources/images/Logo_Auchan_novo.jpg"/>
<ui:image binding="#{FormSeguranca.image2}" id="image2" url="#{SessionBean1.logoEmpresaUrl}"/>
</ui:panelGroup>
<h:panelGrid columnClasses="gridColRight" columns="1" id="gridPanel11" style="height: 24px; width: 100%">
<ui:panelGroup id="groupPanel6">

@ -44,7 +44,7 @@
id="gridPanel1" style="border-bottom: solid #000000 1px; height: 24px; width: 100%" width="312">
<ui:panelGroup binding="#{GestaoUtilizadores.groupPanel1}" id="groupPanel1" style="height: 24px; width: 216px">
<ui:image binding="#{GestaoUtilizadores.image1}" id="image1" url="/resources/images/SIPRP_logo_small.jpg"/>
<ui:image binding="#{GestaoUtilizadores.image2}" id="image2" url="/resources/images/Logo_Auchan_novo.jpg"/>
<ui:image binding="#{GestaoUtilizadores.image2}" id="image2" url="#{SessionBean1.logoEmpresaUrl}"/>
</ui:panelGroup>
<h:panelGrid columnClasses="gridColRight" columns="1" id="gridPanel4" style="height: 24px; width: 100%">
<ui:panelGroup id="groupPanel2">

@ -5,7 +5,7 @@
style="border-bottom: solid rgb(0, 0, 0) 1px; height: 24px; width: 100%" width="312">
<ui:panelGroup id="groupPanel1" style="height: 24px; width: 216px">
<ui:image id="imgLogoSiprp" url="/resources/images/SIPRP_logo_small.jpg"/>
<ui:image id="imgLogoAuchan" url="/resources/images/logo_auchan_small1.jpg"/>
<ui:image id="imgLogoAuchan" url="#{SessionBean1.logoEmpresaUrl}"/>
</ui:panelGroup>
<h:panelGrid columnClasses="gridColRight" columns="1" id="gridPanel2" style="height: 24px; width: 100%">
<ui:panelGroup id="groupPanel2">

@ -89,7 +89,7 @@
style="border-bottom: solid rgb(0, 0, 0) 1px; height: 24px; width: 100%" width="312">
<ui:panelGroup binding="#{NovoUtilizador.groupPanel1}" id="groupPanel1" style="height: 24px; width: 216px">
<ui:image binding="#{NovoUtilizador.image1}" id="image1" url="/resources/images/SIPRP_logo_small.jpg"/>
<ui:image binding="#{NovoUtilizador.image2}" id="image2" url="/resources/images/Logo_Auchan_novo.jpg"/>
<ui:image binding="#{NovoUtilizador.image2}" id="image2" url="#{SessionBean1.logoEmpresaUrl}"/>
</ui:panelGroup>
<h:panelGrid columnClasses="gridColRight" columns="1" id="gridPanel5" style="height: 24px; width: 100%">
<ui:panelGroup id="groupPanel2">

@ -48,7 +48,7 @@
id="gridPanel1" style="border-bottom: solid rgb(0, 0, 0) 1px; height: 24px; width: 100%" width="312">
<ui:panelGroup binding="#{UtilizadorFields.groupPanel1}" id="groupPanel1" style="height: 24px; width: 216px">
<ui:image binding="#{UtilizadorFields.image1}" id="image1" url="/resources/images/SIPRP_logo_small.jpg"/>
<ui:image binding="#{UtilizadorFields.image2}" id="image2" url="/resources/images/Logo_Auchan_novo.jpg"/>
<ui:image binding="#{UtilizadorFields.image2}" id="image2" url="#{SessionBean1.logoEmpresaUrl}"/>
</ui:panelGroup>
<h:panelGrid columnClasses="gridColRight" columns="1" id="gridPanel12" style="height: 24px; width: 100%">
<ui:panelGroup id="groupPanel2">

@ -87,7 +87,7 @@
</ui:panelGroup>
</h:panelGrid>
</h:panelGrid>
<ui:image binding="#{ViewAnaliseAcidenteTrabalho.image5}" id="image5" url="/resources/images/Logo_Auchan_novo.jpg"/>
<ui:image binding="#{ViewAnaliseAcidenteTrabalho.image5}" id="image5" url="#{SessionBean1.logoEmpresaUrl}"/>
</h:panelGrid>
</h:panelGrid>
<h:panelGrid binding="#{ViewAnaliseAcidenteTrabalho.gridMsg1}" columnClasses="gridColCenter" columns="1" id="gridMsg1"

@ -14,6 +14,9 @@
</locale-config>
</application>
-->
<lifecycle>
<phase-listener>phaselistener.MainPhaseListener</phase-listener>
</lifecycle>
<managed-bean>
<managed-bean-name>Acesso</managed-bean-name>
<managed-bean-class>analiseacidentestrabalho.Acesso</managed-bean-class>

Loading…
Cancel
Save