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.INTERNET_5f_EXPLORER=false
auxiliary.org-netbeans-modules-web-client-tools-api.serverdebug=true auxiliary.org-netbeans-modules-web-client-tools-api.serverdebug=true
deploy.ant.properties.file=/home/dneves/.netbeans/6.7/tomcat60.properties 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.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.33 j2ee.server.instance=tomcat60:home=/home/dneves/Software/apache-tomcat-6.0.18:base=apache-tomcat-6.0.18_base
javac.debug=true javac.debug=true
javadoc.preview=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 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

@ -366,6 +366,10 @@ public class PlanosActuacaoImporter
private void enviarMail( PlanoActuacao p ) private void enviarMail( PlanoActuacao p )
{
Boolean isDebug = SIPRPPropertiesLoader.getInstance().findProperty( "debug", false );
if ( ! isDebug )
{ {
MailNextPhase nextPhase = null; MailNextPhase nextPhase = null;
@ -416,3 +420,4 @@ public class PlanosActuacaoImporter
} }
} }
} }
}

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

@ -3,7 +3,6 @@
* *
* Created on Oct 20, 2008, 10:39:31 AM * Created on Oct 20, 2008, 10:39:31 AM
*/ */
package planosactuacao; package planosactuacao;
import com.evolute.utils.error.ErrorLogger; import com.evolute.utils.error.ErrorLogger;
@ -19,7 +18,6 @@ import db.entidades.PostoTrabalho;
import db.entidades.Risco; import db.entidades.Risco;
import db.providers.RiscoLogic; import db.providers.RiscoLogic;
import db.providers.UtilizadoresLogic; import db.providers.UtilizadoresLogic;
import utils.Global;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
@ -36,8 +34,7 @@ import javax.faces.component.html.HtmlPanelGrid;
* *
* @author lluis * @author lluis
*/ */
public class ViewPlano extends AbstractPageBean public class ViewPlano extends AbstractPageBean {
{
// <editor-fold defaultstate="collapsed" desc="Managed Component Definition"> // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
/** /**
@ -65,7 +62,6 @@ public class ViewPlano extends AbstractPageBean
public void setGridLayout(HtmlPanelGrid hpg) { public void setGridLayout(HtmlPanelGrid hpg) {
this.gridLayout = hpg; this.gridLayout = hpg;
} }
// </editor-fold> // </editor-fold>
HtmlPanelGrid gridPlano; HtmlPanelGrid gridPlano;
HtmlPanelGrid gridArea; HtmlPanelGrid gridArea;
@ -81,9 +77,7 @@ public class ViewPlano extends AbstractPageBean
/** /**
* <p>Construct a new Page bean instance.</p> * <p>Construct a new Page bean instance.</p>
*/ */
public ViewPlano() public ViewPlano() {
{
} }
/** /**
@ -99,8 +93,7 @@ public class ViewPlano extends AbstractPageBean
* property values that were saved for this view when it was rendered.</p> * property values that were saved for this view when it was rendered.</p>
*/ */
@Override @Override
public void init() public void init() {
{
// Perform initializations inherited from our superclass // Perform initializations inherited from our superclass
super.init(); super.init();
// Perform application initialization that must complete // Perform application initialization that must complete
@ -132,9 +125,7 @@ public class ViewPlano extends AbstractPageBean
* resources that will be required in your event handlers.</p> * resources that will be required in your event handlers.</p>
*/ */
@Override @Override
public void preprocess() public void preprocess() {
{
} }
/** /**
@ -146,8 +137,7 @@ public class ViewPlano extends AbstractPageBean
* this page.</p> * this page.</p>
*/ */
@Override @Override
public void prerender() public void prerender() {
{
PlanoActuacao p = getSessionBean1().getPlanoActuacao(); PlanoActuacao p = getSessionBean1().getPlanoActuacao();
showPlano(p); showPlano(p);
} }
@ -161,9 +151,7 @@ public class ViewPlano extends AbstractPageBean
* acquired during execution of an event handler).</p> * acquired during execution of an event handler).</p>
*/ */
@Override @Override
public void destroy() public void destroy() {
{
} }
/** /**
@ -171,8 +159,7 @@ public class ViewPlano extends AbstractPageBean
* *
* @return reference to the scoped data bean * @return reference to the scoped data bean
*/ */
protected SessionBean1 getSessionBean1() protected SessionBean1 getSessionBean1() {
{
return (SessionBean1) getBean("SessionBean1"); return (SessionBean1) getBean("SessionBean1");
} }
@ -181,8 +168,7 @@ public class ViewPlano extends AbstractPageBean
* *
* @return reference to the scoped data bean * @return reference to the scoped data bean
*/ */
protected ApplicationBean1 getApplicationBean1() protected ApplicationBean1 getApplicationBean1() {
{
return (ApplicationBean1) getBean("ApplicationBean1"); return (ApplicationBean1) getBean("ApplicationBean1");
} }
@ -191,13 +177,11 @@ public class ViewPlano extends AbstractPageBean
* *
* @return reference to the scoped data bean * @return reference to the scoped data bean
*/ */
protected RequestBean1 getRequestBean1() protected RequestBean1 getRequestBean1() {
{
return (RequestBean1) getBean("RequestBean1"); return (RequestBean1) getBean("RequestBean1");
} }
private void showPlano( PlanoActuacao p ) private void showPlano(PlanoActuacao p) {
{
System.out.println("\nViewPlano . showPlano( " + p.getId() + " ) : \n"); System.out.println("\nViewPlano . showPlano( " + p.getId() + " ) : \n");
gridPlano = new HtmlPanelGrid(); gridPlano = new HtmlPanelGrid();
@ -208,8 +192,7 @@ public class ViewPlano extends AbstractPageBean
gridPlano.setColumnClasses("gridColCenter"); gridPlano.setColumnClasses("gridColCenter");
//lblTop.setText("Plano de actua&ccedil;&atilde;o da auditoria " + p.getData_visita_str()); //lblTop.setText("Plano de actua&ccedil;&atilde;o da auditoria " + p.getData_visita_str());
if ( p.getConcluidoPorDesactivacao() ) if (p.getConcluidoPorDesactivacao()) {
{
StaticText st = new StaticText(); StaticText st = new StaticText();
st.setText("N\u00E3o realizado por falta de cumprimento do prazo."); st.setText("N\u00E3o realizado por falta de cumprimento do prazo.");
st.setStyle("color: #FF0000; font-weight: bold; font-size: 13px;"); st.setStyle("color: #FF0000; font-weight: bold; font-size: 13px;");
@ -220,11 +203,9 @@ public class ViewPlano extends AbstractPageBean
showValidacoes(gridPlano, p); showValidacoes(gridPlano, p);
} }
private void showAreas( List< Area > areas ) private void showAreas(List<Area> areas) {
{
int i = 0; int i = 0;
for( Area area : areas ) for (Area area : areas) {
{
i++; i++;
gridArea = new HtmlPanelGrid(); gridArea = new HtmlPanelGrid();
gridArea.setColumns(1); gridArea.setColumns(1);
@ -265,20 +246,18 @@ public class ViewPlano extends AbstractPageBean
} }
} }
private void showRiscos( List< Risco > riscos ) private void showRiscos(List<Risco> riscos) {
{
int rCount = 0; int rCount = 0;
Collections.sort( riscos, new Comparator< Risco >() Collections.sort(riscos, new Comparator<Risco>() {
{
public int compare( Risco o1, Risco o2 ) @Override
{ public int compare(Risco o1, Risco o2) {
// false first, true after // false first, true after
return o1.getIsPatrimonial().compareTo(o2.getIsPatrimonial()); return o1.getIsPatrimonial().compareTo(o2.getIsPatrimonial());
} }
}); });
for ( Risco risco : riscos ) for (Risco risco : riscos) {
{
boolean isPatrimonial = risco.getIsPatrimonial(); boolean isPatrimonial = risco.getIsPatrimonial();
String riscoTitle = "Risco" + (isPatrimonial ? " Patrimonial" : "") + ":&nbsp;"; String riscoTitle = "Risco" + (isPatrimonial ? " Patrimonial" : "") + ":&nbsp;";
@ -316,8 +295,7 @@ public class ViewPlano extends AbstractPageBean
showValor(risco); showValor(risco);
//showMedidas(risco.getMedidas()); //showMedidas(risco.getMedidas());
if ( rCount < riscos.size() - 1 ) if (rCount < riscos.size() - 1) {
{
showSeparator(); showSeparator();
} }
@ -325,8 +303,7 @@ public class ViewPlano extends AbstractPageBean
} }
} }
private void showValor( Risco r ) private void showValor(Risco r) {
{
HtmlPanelGrid grd = new HtmlPanelGrid(); HtmlPanelGrid grd = new HtmlPanelGrid();
grd.setColumns(1); grd.setColumns(1);
grd.setWidth("100%"); grd.setWidth("100%");
@ -370,10 +347,8 @@ public class ViewPlano extends AbstractPageBean
gridParecer.setColumnClasses("gridColLeft"); gridParecer.setColumnClasses("gridColLeft");
grd.getChildren().add(gridParecer); grd.getChildren().add(gridParecer);
if ( r.getResponsavel_execucao() != null ) if (r.getResponsavel_execucao() != null) {
{ if (r.getResponsavel_execucao().trim().length() > 0) {
if ( r.getResponsavel_execucao().trim().length() > 0 )
{
pg = new PanelGroup(); pg = new PanelGroup();
st = new StaticText(); st = new StaticText();
@ -386,10 +361,8 @@ public class ViewPlano extends AbstractPageBean
st.setText(r.getResponsavel_execucao().toString()); st.setText(r.getResponsavel_execucao().toString());
pg.getChildren().add(st); pg.getChildren().add(st);
if ( r.getPor() != null ) if (r.getPor() != null) {
{ if (r.getPor().trim().length() > 0) {
if ( r.getPor().trim().length() > 0 )
{
st = new StaticText(); st = new StaticText();
st.setEscape(false); st.setEscape(false);
st.setText("&nbsp;"); st.setText("&nbsp;");
@ -411,10 +384,8 @@ public class ViewPlano extends AbstractPageBean
} }
} }
if ( r.getRecursos_necessarios() != null ) if (r.getRecursos_necessarios() != null) {
{ if (r.getRecursos_necessarios().trim().length() > 0) {
if ( r.getRecursos_necessarios().trim().length() > 0 )
{
pg = new PanelGroup(); pg = new PanelGroup();
st = new StaticText(); st = new StaticText();
st.setEscape(false); st.setEscape(false);
@ -429,8 +400,7 @@ public class ViewPlano extends AbstractPageBean
} }
} }
if ( r.getData_inicio() != null ) if (r.getData_inicio() != null) {
{
pg = new PanelGroup(); pg = new PanelGroup();
st = new StaticText(); st = new StaticText();
st.setEscape(false); st.setEscape(false);
@ -447,8 +417,7 @@ public class ViewPlano extends AbstractPageBean
gridParecer.getChildren().add(pg); gridParecer.getChildren().add(pg);
} }
if ( r.getData_fim() != null ) if (r.getData_fim() != null) {
{
pg = new PanelGroup(); pg = new PanelGroup();
st = new StaticText(); st = new StaticText();
st.setEscape(false); st.setEscape(false);
@ -465,10 +434,8 @@ public class ViewPlano extends AbstractPageBean
gridParecer.getChildren().add(pg); gridParecer.getChildren().add(pg);
} }
if ( r.getParecer_dl() != null ) if (r.getParecer_dl() != null) {
{ if (r.getParecer_dl().trim().length() > 0) {
if ( r.getParecer_dl().trim().length() > 0 )
{
pg = new PanelGroup(); pg = new PanelGroup();
st = new StaticText(); st = new StaticText();
st.setEscape(false); st.setEscape(false);
@ -483,10 +450,8 @@ public class ViewPlano extends AbstractPageBean
} }
} }
if ( r.getParecer_dns() != null ) if (r.getParecer_dns() != null) {
{ if (r.getParecer_dns().trim().length() > 0) {
if ( r.getParecer_dns().trim().length() > 0 )
{
pg = new PanelGroup(); pg = new PanelGroup();
st = new StaticText(); st = new StaticText();
st.setEscape(false); st.setEscape(false);
@ -502,10 +467,8 @@ public class ViewPlano extends AbstractPageBean
} }
} }
if ( r.getVerificacao_siprp() != null ) if (r.getVerificacao_siprp() != null) {
{ if (r.getVerificacao_siprp().trim().length() > 0) {
if ( r.getVerificacao_siprp().trim().length() > 0 )
{
pg = new PanelGroup(); pg = new PanelGroup();
st = new StaticText(); st = new StaticText();
st.setEscape(false); st.setEscape(false);
@ -702,11 +665,8 @@ public class ViewPlano extends AbstractPageBean
// // // //
// } // }
// } // }
private void showMedidas(List<Medida> medidas) {
private void showMedidas( List< Medida > medidas ) for (Medida medida : medidas) {
{
for( Medida medida : medidas )
{
HtmlPanelGrid grd = new HtmlPanelGrid(); HtmlPanelGrid grd = new HtmlPanelGrid();
grd.setColumns(1); grd.setColumns(1);
grd.setWidth("100%"); grd.setWidth("100%");
@ -738,10 +698,8 @@ public class ViewPlano extends AbstractPageBean
} }
} }
private void showPostos( List< PostoTrabalho > postos ) private void showPostos(List<PostoTrabalho> postos) {
{ for (PostoTrabalho posto : postos) {
for ( PostoTrabalho posto : postos )
{
HtmlPanelGrid grd = new HtmlPanelGrid(); HtmlPanelGrid grd = new HtmlPanelGrid();
grd.setColumns(1); grd.setColumns(1);
grd.setStyle("display: block"); grd.setStyle("display: block");
@ -768,8 +726,7 @@ public class ViewPlano extends AbstractPageBean
} }
} }
private void showValidacoes( HtmlPanelGrid grid, PlanoActuacao p ) private void showValidacoes(HtmlPanelGrid grid, PlanoActuacao p) {
{
SimpleDateFormat DF = new SimpleDateFormat("dd-MM-yyyy"); SimpleDateFormat DF = new SimpleDateFormat("dd-MM-yyyy");
HtmlPanelGrid gridValidacoes = new HtmlPanelGrid(); HtmlPanelGrid gridValidacoes = new HtmlPanelGrid();
@ -779,8 +736,7 @@ public class ViewPlano extends AbstractPageBean
// 1 // 1
System.out.println("showValidacoes() : 1. (Auditoria) " + p.getData_visita()); System.out.println("showValidacoes() : 1. (Auditoria) " + p.getData_visita());
if ( p.getData_visita() != null ) if (p.getData_visita() != null) {
{
StaticText visitaText = new StaticText(); StaticText visitaText = new StaticText();
visitaText.setEscape(false); visitaText.setEscape(false);
visitaText.setText("Data da auditoria: " + (p.getData_visita() == null ? "" : DF.format(p.getData_visita()))); visitaText.setText("Data da auditoria: " + (p.getData_visita() == null ? "" : DF.format(p.getData_visita())));
@ -789,8 +745,7 @@ public class ViewPlano extends AbstractPageBean
// 2 // 2
System.out.println("showValidacoes() : 2. (Disponibilizacao) " + p.getData_disponibilizacao()); System.out.println("showValidacoes() : 2. (Disponibilizacao) " + p.getData_disponibilizacao());
if ( p.getData_disponibilizacao() != null ) if (p.getData_disponibilizacao() != null) {
{
StaticText dispText = new StaticText(); StaticText dispText = new StaticText();
dispText.setEscape(false); dispText.setEscape(false);
dispText.setText("Data de disponibilizacao online: " + (p.getData_disponibilizacao() == null ? "" : DF.format(p.getData_disponibilizacao()))); dispText.setText("Data de disponibilizacao online: " + (p.getData_disponibilizacao() == null ? "" : DF.format(p.getData_disponibilizacao())));
@ -799,8 +754,7 @@ public class ViewPlano extends AbstractPageBean
// 3 // 3
System.out.println("showValidacoes() : 3. (Validacao Seg) " + p.getData_validacao_seg()); System.out.println("showValidacoes() : 3. (Validacao Seg) " + p.getData_validacao_seg());
if ( p.getData_validacao_seg() != null ) if (p.getData_validacao_seg() != null) {
{
StaticText segText = new StaticText(); StaticText segText = new StaticText();
segText.setEscape(false); segText.setEscape(false);
String nome = UtilizadoresLogic.getInstance().getNomeUtilizadorByID(p.getUser_seg()); String nome = UtilizadoresLogic.getInstance().getNomeUtilizadorByID(p.getUser_seg());
@ -810,8 +764,7 @@ public class ViewPlano extends AbstractPageBean
// 4 // 4
System.out.println("showValidacoes() : 4. (Validacao DL) " + p.getValidacao_director_loja()); System.out.println("showValidacoes() : 4. (Validacao DL) " + p.getValidacao_director_loja());
if ( p.getValidacao_director_loja() ) if (p.getValidacao_director_loja()) {
{
StaticText valDirLojaText = new StaticText(); StaticText valDirLojaText = new StaticText();
valDirLojaText.setEscape(false); valDirLojaText.setEscape(false);
String nome = UtilizadoresLogic.getInstance().getNomeUtilizadorByID(p.getUser_dir_loja()); String nome = UtilizadoresLogic.getInstance().getNomeUtilizadorByID(p.getUser_dir_loja());
@ -822,8 +775,7 @@ public class ViewPlano extends AbstractPageBean
valDirLojaText.setText(validacaoText); valDirLojaText.setText(validacaoText);
gridValidacoes.getChildren().add(valDirLojaText); gridValidacoes.getChildren().add(valDirLojaText);
if ( p.getObservacoes_dl() != null && ! "".equals( p.getObservacoes_dl().trim() ) ) if (p.getObservacoes_dl() != null && !"".equals(p.getObservacoes_dl().trim())) {
{
StaticText obsTitleText = new StaticText(); StaticText obsTitleText = new StaticText();
obsTitleText.setEscape(false); obsTitleText.setEscape(false);
obsTitleText.setText("Observa&ccedil;&otilde;es gerais DL:&nbsp;"); obsTitleText.setText("Observa&ccedil;&otilde;es gerais DL:&nbsp;");
@ -839,16 +791,14 @@ public class ViewPlano extends AbstractPageBean
// 5 // 5
System.out.println("showValidacoes() : 5. (Validacao DNS) " + p.getValidacao_dns()); System.out.println("showValidacoes() : 5. (Validacao DNS) " + p.getValidacao_dns());
if ( p.getValidacao_dns() ) if (p.getValidacao_dns()) {
{
StaticText valDnsText = new StaticText(); StaticText valDnsText = new StaticText();
valDnsText.setEscape(false); valDnsText.setEscape(false);
String nome = UtilizadoresLogic.getInstance().getNomeUtilizadorByID(p.getUser_dns()); String nome = UtilizadoresLogic.getInstance().getNomeUtilizadorByID(p.getUser_dns());
valDnsText.setText("Validado por " + nome + " (Director Nacional de Seguran&ccedil;a)" + (p.getData_validacao_dns() == null ? "" : " a " + DF.format(p.getData_validacao_dns()))); valDnsText.setText("Validado por " + nome + " (Director Nacional de Seguran&ccedil;a)" + (p.getData_validacao_dns() == null ? "" : " a " + DF.format(p.getData_validacao_dns())));
gridValidacoes.getChildren().add(valDnsText); gridValidacoes.getChildren().add(valDnsText);
if ( p.getObservacoes_dns() != null && ! "".equals( p.getObservacoes_dns().trim() ) ) if (p.getObservacoes_dns() != null && !"".equals(p.getObservacoes_dns().trim())) {
{
StaticText obsTitleText = new StaticText(); StaticText obsTitleText = new StaticText();
obsTitleText.setEscape(false); obsTitleText.setEscape(false);
obsTitleText.setText("Observa&ccedil;&otilde;es gerais DNS:&nbsp;"); obsTitleText.setText("Observa&ccedil;&otilde;es gerais DNS:&nbsp;");
@ -864,8 +814,7 @@ public class ViewPlano extends AbstractPageBean
// 6 // 6
System.out.println("showValidacoes() : 6. (Validacao HS) " + p.getValidacao_hs()); System.out.println("showValidacoes() : 6. (Validacao HS) " + p.getValidacao_hs());
if ( p.getValidacao_hs() ) if (p.getValidacao_hs()) {
{
StaticText valHsText = new StaticText(); StaticText valHsText = new StaticText();
valHsText.setEscape(false); valHsText.setEscape(false);
String nome = UtilizadoresLogic.getInstance().getNomeUtilizadorByID(p.getUser_hs()); String nome = UtilizadoresLogic.getInstance().getNomeUtilizadorByID(p.getUser_hs());
@ -1002,19 +951,14 @@ public class ViewPlano extends AbstractPageBean
// grid.getChildren().add(grd); // grid.getChildren().add(grd);
// } // }
// } // }
private void showSeparator() {
private void showSeparator()
{
PageSeparator separator = new PageSeparator(); PageSeparator separator = new PageSeparator();
// separator.setStyle( "margin-bottom: 50px;" ); // separator.setStyle( "margin-bottom: 50px;" );
gridAreaContainer.getChildren().add(separator); gridAreaContainer.getChildren().add(separator);
} }
public String butVoltar_action() public String butVoltar_action() {
{
return "lista_planos"; return "lista_planos";
} }
} }

@ -4,7 +4,7 @@ import com.evolute.module.updater.AbstractUpdate;
import com.evolute.module.updater.UpdaterListProvider; import com.evolute.module.updater.UpdaterListProvider;
import updates.updates.Update1; import updates.updates.Update1;
import updates.updates.Update2; import updates.updates.Update2;
import updates.updates.Update3; import updates.updates.FixPlanoImportedUnicode;
/** /**
* User: dneves * User: dneves
@ -16,7 +16,7 @@ public class PAUpdatesListProvider extends UpdaterListProvider
private static final AbstractUpdate[] UPDATES_LIST = new AbstractUpdate[] { private static final AbstractUpdate[] UPDATES_LIST = new AbstractUpdate[] {
new Update1( 0, 1 ), // support for valor qualitativo (@ riscos) new Update1( 0, 1 ), // support for valor qualitativo (@ riscos)
new Update2( 1, 2 ), // update valor qualitativo new Update2( 1, 2 ), // update valor qualitativo
// new Update3( 2, 3 ), // corrigir enconde planos importados 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.Singleton;
import com.evolute.utils.error.ErrorLogger; import com.evolute.utils.error.ErrorLogger;
import com.evolute.utils.strings.UnicodeChecker;
import db.entidades.Utilizador; import db.entidades.Utilizador;
import java.util.Map; import java.util.Map;
import javax.faces.context.ExternalContext; import javax.faces.context.ExternalContext;
@ -19,7 +20,18 @@ import planosactuacao.SessionBean1;
* *
* @author lluis * @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 ) public static String unicodeToHTML( String text )
{ {

Loading…
Cancel
Save