git-svn-id: https://svn.coded.pt/svn/SIPRP@1734 bb69d46d-e84e-40c8-a05a-06db0d633741

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Diogo Neves 14 years ago
parent 49ad4d0cf2
commit b1673156b1

@ -4,8 +4,8 @@ auxiliary.org-netbeans-modules-web-client-tools-api.FIREFOX=true
auxiliary.org-netbeans-modules-web-client-tools-api.INTERNET_5f_EXPLORER=false
auxiliary.org-netbeans-modules-web-client-tools-api.serverdebug=true
deploy.ant.properties.file=/home/dneves/.netbeans/6.7/tomcat60.properties
j2ee.platform.classpath=/home/dneves/Software/apache-tomcat-6.0.33/lib/jasper-el.jar:/home/dneves/Software/apache-tomcat-6.0.33/lib/ecj-3.3.1.jar:/home/dneves/Software/apache-tomcat-6.0.33/lib/el-api.jar:/home/dneves/Software/apache-tomcat-6.0.33/lib/tomcat-i18n-fr.jar:/home/dneves/Software/apache-tomcat-6.0.33/lib/tomcat-dbcp.jar:/home/dneves/Software/apache-tomcat-6.0.33/lib/tomcat-i18n-ja.jar:/home/dneves/Software/apache-tomcat-6.0.33/lib/catalina-ant.jar:/home/dneves/Software/apache-tomcat-6.0.33/lib/jsp-api.jar:/home/dneves/Software/apache-tomcat-6.0.33/lib/servlet-api.jar:/home/dneves/Software/apache-tomcat-6.0.33/lib/annotations-api.jar:/home/dneves/Software/apache-tomcat-6.0.33/lib/catalina-tribes.jar:/home/dneves/Software/apache-tomcat-6.0.33/lib/catalina-ha.jar:/home/dneves/Software/apache-tomcat-6.0.33/lib/tomcat-i18n-es.jar:/home/dneves/Software/apache-tomcat-6.0.33/lib/jasper.jar:/home/dneves/Software/apache-tomcat-6.0.33/lib/catalina.jar:/home/dneves/Software/apache-tomcat-6.0.33/lib/tomcat-coyote.jar:/home/dneves/Software/apache-tomcat-6.0.33/bin/tomcat-juli.jar
j2ee.server.instance=tomcat60:home=/home/dneves/Software/apache-tomcat-6.0.33
j2ee.platform.classpath=/home/dneves/Software/apache-tomcat-6.0.18/lib/jasper.jar:/home/dneves/Software/apache-tomcat-6.0.18/lib/jsp-api.jar:/home/dneves/Software/apache-tomcat-6.0.18/lib/catalina-ant.jar:/home/dneves/Software/apache-tomcat-6.0.18/lib/tomcat-i18n-es.jar:/home/dneves/Software/apache-tomcat-6.0.18/lib/tomcat-i18n-ja.jar:/home/dneves/Software/apache-tomcat-6.0.18/lib/catalina-ha.jar:/home/dneves/Software/apache-tomcat-6.0.18/lib/servlet-api.jar:/home/dneves/Software/apache-tomcat-6.0.18/lib/tomcat-i18n-fr.jar:/home/dneves/Software/apache-tomcat-6.0.18/lib/catalina.jar:/home/dneves/Software/apache-tomcat-6.0.18/lib/tomcat-coyote.jar:/home/dneves/Software/apache-tomcat-6.0.18/lib/el-api.jar:/home/dneves/Software/apache-tomcat-6.0.18/lib/annotations-api.jar:/home/dneves/Software/apache-tomcat-6.0.18/lib/tomcat-dbcp.jar:/home/dneves/Software/apache-tomcat-6.0.18/lib/jasper-el.jar:/home/dneves/Software/apache-tomcat-6.0.18/lib/catalina-tribes.jar:/home/dneves/Software/apache-tomcat-6.0.18/bin/tomcat-juli.jar
j2ee.server.instance=tomcat60:home=/home/dneves/Software/apache-tomcat-6.0.18:base=apache-tomcat-6.0.18_base
javac.debug=true
javadoc.preview=true
jaxws.endorsed.dir=/home/dneves/Software/netbeans-6.7.1/java2/modules/ext/jaxws21/api:/home/dneves/Software/netbeans-6.7.1/ide11/modules/ext/jaxb/api

@ -367,52 +367,57 @@ public class PlanosActuacaoImporter
private void enviarMail( PlanoActuacao p )
{
MailNextPhase nextPhase = null;
Boolean isDebug = SIPRPPropertiesLoader.getInstance().findProperty( "debug", false );
int fase = p.getFase().intValue();
int tipo_utilizador = 0;
switch ( fase )
if ( ! isDebug )
{
case Global.FASE_SEGURANCA_PREENCHIMENTO : // SIPRP para RS
tipo_utilizador = Global.RESPONSAVEL_SEGURANCA;
nextPhase = new SIPRP_TO_RESPONSAVEL_SEGURANCA( p );
break;
}
MailNextPhase nextPhase = null;
if ( nextPhase != null )
{
String responsavel_loja = "n";
if ( tipo_utilizador == Global.RESPONSAVEL_SEGURANCA )
{
responsavel_loja = "y";
}
try
{
Mail mail = new Mail();
int fase = p.getFase().intValue();
int tipo_utilizador = 0;
switch ( fase )
{
case Global.FASE_SEGURANCA_PREENCHIMENTO : // SIPRP para RS
tipo_utilizador = Global.RESPONSAVEL_SEGURANCA;
nextPhase = new SIPRP_TO_RESPONSAVEL_SEGURANCA( p );
break;
}
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( "\t\tUSER MAIL NEXT FASE : " + u.getLogin() + " ; " + u.getEmail() );
try
{
mail.send( u.getEmail(), Mail.ENDERECO_ENVIO, nextPhase );
System.out.println( "\t\t\tEMAIL ENVIADO !!" );
}
catch ( Exception ex1 )
{
ErrorLogger.logException( ex1 );
System.out.println("\t\t\tMAIL ERROR : " + ex1.getMessage());
}
}
}
catch ( Exception ex )
{
ErrorLogger.logException( ex );
}
}
if ( nextPhase != null )
{
String responsavel_loja = "n";
if ( tipo_utilizador == Global.RESPONSAVEL_SEGURANCA )
{
responsavel_loja = "y";
}
try
{
Mail mail = new Mail();
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( "\t\tUSER MAIL NEXT FASE : " + u.getLogin() + " ; " + u.getEmail() );
try
{
mail.send( u.getEmail(), Mail.ENDERECO_ENVIO, nextPhase );
System.out.println( "\t\t\tEMAIL ENVIADO !!" );
}
catch ( Exception ex1 )
{
ErrorLogger.logException( ex1 );
System.out.println("\t\t\tMAIL ERROR : " + ex1.getMessage());
}
}
}
catch ( Exception ex )
{
ErrorLogger.logException( ex );
}
}
}
}
}

@ -507,7 +507,7 @@ public class PlanosActuacaoImporterProvider extends GenericDataProvider
PlanoAreasData areaData = new PlanoAreasData();
areaData.setArea_id( a.getArea_id() );
areaData.setPlano_id( a.getPlano_id() );
areaData.setDescricao( a.getDescricao() );
areaData.setDescricao( Utils.parseToInsert( a.getDescricao() ) );
System.out.println( "\nCREATE AREA : " );
areaData.setProvider( EvoBaseProvider.getInstance().getProvider( DB.SIPRP ) );
@ -523,7 +523,7 @@ public class PlanosActuacaoImporterProvider extends GenericDataProvider
Integer newRiscoID = null;
PlanoRiscosData riscoData = new PlanoRiscosData();
riscoData.setDescricao( r.getDescricao() );
riscoData.setDescricao( Utils.parseToInsert( r.getDescricao() ) );
riscoData.setActivo( r.getActivo() == null ? "y" : r.getActivo() );
riscoData.setArea_id( r.getArea_id() );
riscoData.setValor( r.getValorQuantitativo() );
@ -547,7 +547,7 @@ public class PlanosActuacaoImporterProvider extends GenericDataProvider
PlanoMedidasData medidaData = new PlanoMedidasData();
medidaData.setMedida_id( m.getMedida_id() );
medidaData.setRisco_id( m.getRisco_id() );
medidaData.setDescricao( m.getDescricao() );
medidaData.setDescricao( Utils.parseToInsert( m.getDescricao() ) );
System.out.println( "\nCREATE MEDIDA : " );
medidaData.setProvider( EvoBaseProvider.getInstance().getProvider( DB.SIPRP ) );
@ -563,7 +563,7 @@ public class PlanosActuacaoImporterProvider extends GenericDataProvider
PlanoPostosTrabalhoData postoData = new PlanoPostosTrabalhoData();
postoData.setPosto_id( p.getPosto_id() );
postoData.setMedida_id( p.getMedida_id() );
postoData.setDescricao( p.getDescricao() );
postoData.setDescricao( Utils.parseToInsert( p.getDescricao() ) );
System.out.println( "\nCREATE POSTO TRABALHO : " );
postoData.setProvider( EvoBaseProvider.getInstance().getProvider( DB.SIPRP ) );

File diff suppressed because it is too large Load Diff

@ -4,7 +4,7 @@ import com.evolute.module.updater.AbstractUpdate;
import com.evolute.module.updater.UpdaterListProvider;
import updates.updates.Update1;
import updates.updates.Update2;
import updates.updates.Update3;
import updates.updates.FixPlanoImportedUnicode;
/**
* User: dneves
@ -15,8 +15,8 @@ public class PAUpdatesListProvider extends UpdaterListProvider
private static final AbstractUpdate[] UPDATES_LIST = new AbstractUpdate[] {
new Update1( 0, 1 ), // support for valor qualitativo (@ riscos)
new Update2( 1, 2 ), // update valor qualitativo
// new Update3( 2, 3 ), // corrigir enconde planos importados
new Update2( 1, 2 ), // update valor qualitativo
new FixPlanoImportedUnicode( 2, 3, new Integer( 81 ) ), // corrigir enconde planos importados
};

@ -0,0 +1,160 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package updates.updates;
import com.evolute.entity.ProviderInterface;
import com.evolute.entity.evo.EvoDataException;
import com.evolute.entity.evo.EvoDataObject;
import com.evolute.module.updater.AbstractUpdate;
import com.evolute.utils.Singleton;
import db.DBConstants.DB;
import db.data.siprp.outer.PlanoAreasData;
import db.data.siprp.outer.PlanoMedidasData;
import db.data.siprp.outer.PlanoPostosTrabalhoData;
import db.data.siprp.outer.PlanoRiscosData;
import db.data.siprp.outer.PlanosActuacaoData;
import db.data.siprp_local.outer.HsRelatorioAreaData;
import db.data.siprp_local.outer.HsRelatorioMedidaData;
import db.data.siprp_local.outer.HsRelatorioPostoData;
import db.data.siprp_local.outer.HsRelatorioRiscoData;
import db.providers.EvoBaseProvider;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import utils.Utils;
/**
*
* @author dneves
*/
public class FixPlanoImportedUnicode extends AbstractUpdate
{
private ProviderInterface< EvoDataObject< ? >, EvoDataException > SIPRP = null;
private ProviderInterface< EvoDataObject< ? >, EvoDataException > LOCAL = null;
private final Integer planoID;
public FixPlanoImportedUnicode( double start, double end, Integer planoID )
{
super( start, end, "Corrigir encoding de planos importados" );
this.planoID = planoID;
}
@Override
public void doUpdate() throws Exception
{
SIPRP = EvoBaseProvider.getInstance().getProvider( DB.SIPRP );
LOCAL = EvoBaseProvider.getInstance().getProvider( DB.SIPRP_LOCAL );
PlanosActuacaoData planoActuacao = SIPRP.load( PlanosActuacaoData.class, planoID, PlanosActuacaoData.ID );
System.out.println( "\nFixing planoActuacao ID : " + planoID + " = " + ( planoActuacao == null ? "null" : planoActuacao.getNome_estabelecimento() ) );
fixAreas( planoActuacao );
}
private void fixAreas( PlanosActuacaoData planoActuacao ) throws Exception
{
if ( planoActuacao != null )
{
List<PlanoAreasData> areas = planoActuacao.fromPlanoAreas_plano_id();
for ( PlanoAreasData area : areas )
{
Integer hsRelatorioAreaID = area.getArea_id();
HsRelatorioAreaData relatorioArea = LOCAL.load( HsRelatorioAreaData.class, hsRelatorioAreaID );
if ( relatorioArea != null )
{
System.out.println( "\n\tAreaID : " + area.getId() + " = " + area.getDescricao() );
System.out.println( "\tLocalAreaID : " + relatorioArea.getId() + " = " + relatorioArea.getDescription() );
area.setDescricao( Utils.parseToInsert( relatorioArea.getDescription() ) );
area.save();
}
fixRiscos(area);
}
}
}
private void fixRiscos(PlanoAreasData area) throws Exception
{
List<PlanoRiscosData> riscos = area.fromPlanoRiscos_area_id();
for (PlanoRiscosData risco : riscos)
{
Integer hsRelatorioRiscoID = risco.getRisco_id();
HsRelatorioRiscoData relatorioRisco = LOCAL.load( HsRelatorioRiscoData.class, hsRelatorioRiscoID );
if ( relatorioRisco != null )
{
System.out.println( "\n\t\tRiscoID : " + risco.getId() + " = " + risco.getDescricao() );
System.out.println( "\t\tLocalRiscoID : " + relatorioRisco.getId() + " = " + relatorioRisco.getDescription() );
risco.setDescricao( Utils.parseToInsert( relatorioRisco.getDescription() ) );
risco.save();
}
fixMedidas(risco);
}
}
private void fixMedidas(PlanoRiscosData risco) throws Exception
{
List<PlanoMedidasData> medidas = risco.fromPlanoMedidas_risco_id();
for (PlanoMedidasData medida : medidas)
{
Integer hsRelatorioMedidaID = medida.getMedida_id();
HsRelatorioMedidaData relatorioMedida = LOCAL.load( HsRelatorioMedidaData.class, hsRelatorioMedidaID );
if ( relatorioMedida != null )
{
System.out.println( "\n\t\t\tMedidaID : " + medida.getId() + " = " + medida.getDescricao() );
System.out.println( "\t\t\tLocalMedidaID : " + relatorioMedida.getId() + " = " + relatorioMedida.getDescription() );
medida.setDescricao( Utils.parseToInsert( relatorioMedida.getDescription() ) );
medida.save();
}
fixPostosTrabalho(medida);
}
}
private void fixPostosTrabalho(PlanoMedidasData medida) throws Exception
{
List<PlanoPostosTrabalhoData> postosTrabalho = medida.fromPlanoPostosTrabalho_medida_id();
for (PlanoPostosTrabalhoData posto : postosTrabalho)
{
Integer hsRelatorioPostoID = posto.getPosto_id();
HsRelatorioPostoData relatorioPosto = LOCAL.load( HsRelatorioPostoData.class, hsRelatorioPostoID );
if ( relatorioPosto != null )
{
System.out.println( "\n\t\t\t\tPostoID : " + posto.getId() + " = " + posto.getDescricao() );
System.out.println( "\t\t\t\tLocalPostoID : " + relatorioPosto.getId() + " = " + relatorioPosto.getDescription() );
posto.setDescricao( Utils.parseToInsert( relatorioPosto.getDescription() ) );
posto.save();
}
}
}
public static void main( String ... args ) throws Exception
{
FixPlanoImportedUnicode update = new FixPlanoImportedUnicode( 0, 1, new Integer( 81 ) );
Properties props = new Properties();
props.load( update.getClass().getClassLoader().getResourceAsStream( "app.properties" ) );
Set< Object > keySet = props.keySet();
Iterator< Object > it = keySet.iterator();
while ( it.hasNext() )
{
Object key = it.next();
Object value = props.getProperty( ( String ) key );
Singleton.setInstance( ( String ) key, value );
}
EvoBaseProvider.getInstance();
update.doUpdate();
}
}

@ -1,28 +0,0 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package updates.updates;
import com.evolute.module.updater.AbstractUpdate;
/**
*
* @author dneves
*/
public class Update3 extends AbstractUpdate
{
public Update3( double start, double end )
{
super( start, end, "Corrigir encoding de planos importados" );
}
@Override
public void doUpdate() throws Exception
{
// TODO : fix db unicode
}
}

@ -7,6 +7,7 @@ package utils;
import com.evolute.utils.Singleton;
import com.evolute.utils.error.ErrorLogger;
import com.evolute.utils.strings.UnicodeChecker;
import db.entidades.Utilizador;
import java.util.Map;
import javax.faces.context.ExternalContext;
@ -19,7 +20,18 @@ import planosactuacao.SessionBean1;
*
* @author lluis
*/
public class Utils {
public class Utils
{
public static String parseToInsert( String str )
{
String result = str;
if ( result != null )
{
result = UnicodeChecker.parseToUnicode( result, true, true );
}
return result;
}
public static String unicodeToHTML( String text )
{

Loading…
Cancel
Save