forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@1829 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
b50614addd
commit
32b28d3f0c
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package utils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lluis
|
||||
*/
|
||||
public class Global
|
||||
{
|
||||
|
||||
//tipos utilizadores
|
||||
public static final int RESPONSAVEL_SEGURANCA = 1;
|
||||
public static final int RH = 2;
|
||||
public static final int TECNICO_HS = 3;
|
||||
public static final int GESTOR = 6;
|
||||
public static final int DIRECTOR_GERAL_RH = 7;
|
||||
public static final int DIRECTOR_SIPRP = 8;
|
||||
public static final int DIRECTOR_LOJA = 9;
|
||||
public static final int DIRECTOR_NACIONAL_SEGURANCA = 10;
|
||||
|
||||
//Fases do plano
|
||||
public static final int FASE_SIPRP_EMISSAO = 1;
|
||||
public static final int FASE_SEGURANCA_PREENCHIMENTO = 2;
|
||||
public static final int FASE_DIR_LOJA_VALIDACAO = 3;
|
||||
public static final int FASE_DNS_PARECER = 4;
|
||||
public static final int FASE_SIPRP_CONCLUSAO = 5;
|
||||
public static final int FASE_CONCLUIDO = 6;
|
||||
|
||||
//Fases do plano - texto
|
||||
public static final String FASE_SIPRP_EMISSAO_TXT = "SIPRP(Emiss\u00e3o)";
|
||||
public static final String FASE_SEGURANCA_PREENCHIMENTO_TXT = "Seguran\u00e7a Auchan(Preenchimento)";
|
||||
public static final String FASE_DIR_LOJA_VALIDACAO_TXT = "Director de loja(Valida\u00e7\u00e3o)";
|
||||
public static final String FASE_DNS_PARECER_TXT = "DNS(Parecer)";
|
||||
public static final String FASE_SIPRP_CONCLUSAO_TXT = "SIPRP(Verifica\u00e7\u00e3o/Conclus\u00e3o)";
|
||||
|
||||
public static final String[] FASES_TEXTO = new String[] {
|
||||
"SIPRP(Emiss\u00e3o)",
|
||||
"Seguran\u00e7a Auchan(Preenchimento)",
|
||||
"Director de loja(Valida\u00e7\u00e3o)",
|
||||
"DNS(Parecer)",
|
||||
"SIPRP(Verifica\u00e7\u00e3o/Conclus\u00e3o)",
|
||||
"Conclu\u00eddo"
|
||||
};
|
||||
|
||||
// public static final String ANALISE_ACIDENTES_URL = "http://localhost:8084/AnaliseAcidentesTrabalho/faces/"; //testes
|
||||
// public static final String PLANOS_ACTUACAO_URL = "http://localhost:8084/PlanosActuacao/faces/"; //testes
|
||||
// public static final String ANALISE_ACIDENTES_URL = "http://192.168.111.24:8084/AnaliseAcidentesTrabalho/faces/"; //testes portatil
|
||||
public static final String ANALISE_ACIDENTES_URL = "https://www.siprp.pt/AnaliseAcidentesTrabalho/faces/"; //real
|
||||
public static final String PLANOS_ACTUACAO_URL = "https://www.siprp.pt/PlanosActuacao/faces/";
|
||||
|
||||
public static final String LOGOS_FOLDER = "/resources/images";
|
||||
public static final String PDF_FOLDER_URL = "/resources/pdf";
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
public static final String VALOR_INDETERMINADO = "IND";
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package utils;
|
||||
|
||||
import java.util.Map;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lluis
|
||||
*/
|
||||
public class JSFHTTPUtils {
|
||||
|
||||
public static String getReferer(FacesContext context)
|
||||
{
|
||||
Map headerMap = context.getCurrentInstance().getExternalContext().getRequestHeaderMap();
|
||||
String referer = (String) headerMap.get("referer");
|
||||
return referer;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package utils;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.context.ExternalContext;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lluis
|
||||
*/
|
||||
public class JSFUtils {
|
||||
|
||||
|
||||
public static SessionBean1 getSessionBean(FacesContext fc)
|
||||
{
|
||||
FacesContext context = fc.getCurrentInstance();
|
||||
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
|
||||
//
|
||||
public static boolean isPostBack(FacesContext fc)
|
||||
{
|
||||
Map parameterMap = fc.getExternalContext().getRequestParameterMap();
|
||||
|
||||
if(parameterMap.size() > 0)
|
||||
{
|
||||
Iterator iter = parameterMap.keySet().iterator();
|
||||
while(iter.hasNext())
|
||||
{
|
||||
String par = (String) iter.next();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isPostback() {
|
||||
FacesContext facesContext = FacesContext.getCurrentInstance();
|
||||
Map requestScope = (Map) facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), "#{requestScope}", Map.class).getValue(facesContext.getELContext());
|
||||
//Map requestScope = (Map)facesContext.getApplication().createValueBinding(?#{requestScope}?).getValue(facesContext);
|
||||
boolean ispostback = ((Boolean)requestScope.get("ispostback")).booleanValue();
|
||||
System.out.println("JSFUtils . isPostback() : " + ispostback );
|
||||
return ispostback;
|
||||
}
|
||||
|
||||
//
|
||||
// isPostBack - JSF 1.2 implementation
|
||||
//
|
||||
public static boolean isPostBack12(FacesContext fc)
|
||||
{
|
||||
ResponseStateManager rsm = fc.getRenderKit().getResponseStateManager();
|
||||
if(rsm.isPostback(fc))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void logout(FacesContext fc) throws Exception
|
||||
{
|
||||
ExternalContext ectx = fc.getCurrentInstance().getExternalContext();
|
||||
|
||||
Utils.doLogout( fc );
|
||||
|
||||
HttpSession session = (HttpSession) ectx.getSession(false);
|
||||
session.invalidate();
|
||||
|
||||
}
|
||||
|
||||
public static void navigateTo(FacesContext fc, String outcome)
|
||||
{
|
||||
FacesContext context = fc.getCurrentInstance();
|
||||
Application app = context.getApplication();
|
||||
app.getNavigationHandler().handleNavigation(context, null, outcome);
|
||||
}
|
||||
|
||||
public static void redirect(FacesContext context, String url) throws Exception
|
||||
{
|
||||
HttpServletResponse response = (HttpServletResponse) context.getCurrentInstance().getExternalContext().getResponse();
|
||||
response.sendRedirect(url);
|
||||
context.responseComplete();
|
||||
}
|
||||
|
||||
public static String getRequestParameter(FacesContext fc, String parameter)
|
||||
{
|
||||
Map parameters = fc.getCurrentInstance().getExternalContext().getRequestParameterMap();
|
||||
return (String) parameters.get(parameter);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package utils;
|
||||
|
||||
import com.evolute.utils.error.ErrorLogger;
|
||||
import db.providers.RelatoriosDataProvider;
|
||||
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 )
|
||||
{
|
||||
String result = null;
|
||||
try
|
||||
{
|
||||
//get image from db :
|
||||
// RelatoriosDataProvider rdp = new RelatoriosDataProvider();
|
||||
RelatoriosDataProvider rdp = RelatoriosDataProvider.getInstance();
|
||||
|
||||
byte[] logo = rdp.getLogoByEmpresa( empresaId );
|
||||
if ( logo != null )
|
||||
{
|
||||
int len = logo.length;
|
||||
|
||||
ServletContext context = (ServletContext) fc.getExternalContext().getContext();
|
||||
File logoFolder = new File( context.getRealPath( Global.LOGOS_FOLDER ) );
|
||||
|
||||
String logoFilename = logoFolder + "/logo_empresa" + empresaId.toString() + ".jpg";
|
||||
|
||||
OutputStream outImej = new FileOutputStream(logoFilename);
|
||||
outImej.write(logo, 0, len);
|
||||
System.out.println("LOGO PATH : " + logoFilename);
|
||||
outImej.close();
|
||||
result = Global.LOGOS_FOLDER + "/logo_empresa" + empresaId.toString() + ".jpg";
|
||||
}
|
||||
}
|
||||
catch ( Exception ex )
|
||||
{
|
||||
ErrorLogger.logException( ex );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package utils;
|
||||
|
||||
import com.evolute.utils.error.ErrorLogger;
|
||||
import com.evolute.utils.error.Logger;
|
||||
import com.evolute.utils.error.LoggerProperties;
|
||||
import com.evolute.utils.error.ProjectsEnum;
|
||||
import com.evolute.utils.error.ws.WSLogger;
|
||||
import com.evolute.utils.network.proxy.EvoProxyObject;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author dneves
|
||||
*/
|
||||
public class PlanosActuacaoLogger
|
||||
{
|
||||
|
||||
public static void init() throws Exception
|
||||
{
|
||||
HashMap< LoggerProperties, String > properties = new HashMap< LoggerProperties, String >();
|
||||
properties.put( LoggerProperties.SOFTWARE_NAME, "SIPRP - Planos Actuacao" );
|
||||
properties.put( LoggerProperties.SOFTWARE_VERSION, "1" );
|
||||
properties.put( LoggerProperties.PROJECT, ProjectsEnum.PLANOS_ACTUACAO.toString() );
|
||||
properties.put( LoggerProperties.PROJECT_NAME, ProjectsEnum.PLANOS_ACTUACAO.toString() );
|
||||
properties.put( LoggerProperties.PROJECT_VERSION, "1" );
|
||||
|
||||
String user = "";
|
||||
String pass = "";
|
||||
String host = "";
|
||||
String port = "";
|
||||
|
||||
// EvoProxyObject.configSystemProxySelector();
|
||||
// EvoProxyObject.getProxy( user, pass, host, port );
|
||||
|
||||
Logger logger = new WSLogger( properties );
|
||||
ErrorLogger.initializeLogger( logger );
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package utils;
|
||||
|
||||
import com.evolute.utils.arrays.Virtual2DArray;
|
||||
import com.evolute.utils.db.Executer;
|
||||
import com.evolute.utils.sql.Assignment;
|
||||
import com.evolute.utils.sql.Expression;
|
||||
import com.evolute.utils.sql.Field;
|
||||
import com.evolute.utils.sql.Select2;
|
||||
import com.evolute.utils.sql.Update;
|
||||
import db.providers.EvoBaseProvider;
|
||||
import java.util.Date;
|
||||
import shst.companydataloaders.SIPRPPropertiesLoader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author dneves
|
||||
*/
|
||||
public class PlanosUpdater
|
||||
{
|
||||
|
||||
public static void main( String[] args )
|
||||
{
|
||||
try
|
||||
{
|
||||
SIPRPPropertiesLoader props = SIPRPPropertiesLoader.getInstance();
|
||||
props.load();
|
||||
|
||||
EvoBaseProvider provider = EvoBaseProvider.getInstance();
|
||||
Executer executer = provider.getExecuter();
|
||||
Executer localExecuter = provider.getLocalExecuter();
|
||||
|
||||
// Expression whereExpression = new Field( "planos_actuacao.deleted_date" ).isEqual( null );
|
||||
Expression whereExpression = null;
|
||||
Select2 query = new Select2(
|
||||
new String[] { "planos_actuacao" },
|
||||
new Integer[] {},
|
||||
new Expression[] {},
|
||||
new String[] { "planos_actuacao.id", "planos_actuacao.estabelecimento_id", "planos_actuacao.data_visita" },
|
||||
whereExpression,
|
||||
new String[] { "planos_actuacao.estabelecimento_id", "planos_actuacao.data_visita" },
|
||||
null, null, null
|
||||
);
|
||||
Virtual2DArray array = executer.executeQuery( query );
|
||||
if ( array != null )
|
||||
{
|
||||
System.out.println( array.columnLength() + " : " );
|
||||
|
||||
for ( int i = 0; i < array.columnLength(); i++ )
|
||||
{
|
||||
Integer planoID = array.get( i, 0 );
|
||||
Integer estabelecimentoID = array.get( i, 1 );
|
||||
Date dataVisita = array.get( i, 2 );
|
||||
|
||||
System.out.println( planoID + " : " + estabelecimentoID + " : " + dataVisita );
|
||||
|
||||
Integer relatorioID = null;
|
||||
Date dataDisponibilizacao = null;
|
||||
|
||||
Expression whereExpression2 = new Field( "marcacoes_estabelecimento.data" ).isEqual( dataVisita ).and(
|
||||
new Field( "marcacoes_estabelecimento.estabelecimento_id" ).isEqual( estabelecimentoID )
|
||||
);
|
||||
Select2 query2 = new Select2(
|
||||
new String[] { "hs_relatorio", "marcacoes_estabelecimento" },
|
||||
new Integer[] { Select2.JOIN_INNER },
|
||||
new Expression[] {
|
||||
new Field( "marcacoes_estabelecimento.id" ).isEqual( new Field( "hs_relatorio.marcacao_id" ) )
|
||||
},
|
||||
new String[] { "hs_relatorio.id", "hs_relatorio.is_submetido" },
|
||||
whereExpression2,
|
||||
null,
|
||||
null, null, null
|
||||
);
|
||||
Virtual2DArray array2 = localExecuter.executeQuery( query2 );
|
||||
if ( array2 != null && array2.columnLength() > 0 )
|
||||
{
|
||||
relatorioID = array2.get( 0, 0 );
|
||||
dataDisponibilizacao = array2.get( 0, 1 );
|
||||
}
|
||||
|
||||
System.out.println( "\tRelatorioID : " + relatorioID );
|
||||
|
||||
Update upd = new Update( "planos_actuacao", new Assignment[] {
|
||||
new Assignment( new Field( "hs_relatorio_id" ), relatorioID ),
|
||||
new Assignment( new Field( "data_disponibilizacao" ), dataDisponibilizacao )
|
||||
}, new Field( "id" ).isEqual( planoID ) );
|
||||
executer.executeQuery( upd );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
System.out.println( e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue