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

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Frederico Palma 17 years ago
parent a04cf32b40
commit 5cb2ad1eca

@ -9,7 +9,7 @@ public interface DBConstants
public static final String WEB_USER = "postgres";
public static final String WEB_PASSWORD = "Typein";
public static final String LOCAL_URL = "jdbc:postgresql://localhost:5436/siprp_local";
public static final String LOCAL_URL = "jdbc:postgresql://localhost:5436/siprp_local_3";
public static final String LOCAL_USER = "postgres";
public static final String LOCAL_PASSWORD = "Typein";

@ -11,7 +11,7 @@ import com.evolute.utils.strings.UnicodeChecker;
public class PlanoActuacaoDBInit
{
public static void initDB( String username, String password )
public static void initDB()
throws Exception
{
DBManager webManager = new JDBCManager( DBConstants.WEB_URL,

@ -0,0 +1,39 @@
package siprp.planoactuacao.print;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import org.jdom.Document;
import org.jdom.output.XMLOutputter;
import com.evolute.utils.fop.PDFCreator;
import com.evolute.utils.xml.XSLTransformer;
public class PlanoActuacaoPDFCreator
{
public byte[] createPDF( Integer planoId )
throws Exception
{
PlanoActuacaoToPrint plano = PlanoActuacaoPrintDataProvider.getProvider().getPlanoToPrint( 6 );
Document foDoc = new Document( plano.toJdomElement() );
XMLOutputter outputter = new XMLOutputter();
ByteArrayOutputStream foBaos = new ByteArrayOutputStream();
outputter.output( foDoc, foBaos );
byte fo[] =
applyTemplate(
getClass().getClassLoader().getResourceAsStream( "siprp/planoactuacao/print/plano_actuacao.xsl" ),
new ByteArrayInputStream( foBaos.toByteArray() ) );
byte pdf[] = PDFCreator.getPDFCreator().createPdfFromFo( fo );
return pdf;
}
public byte[] applyTemplate( InputStream xsl, InputStream dataStream )
throws Exception
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XSLTransformer.getXSLTransformer().transform( dataStream, xsl, baos );
return baos.toByteArray();
}
}

@ -4,6 +4,7 @@ import java.util.Date;
import java.util.Vector;
import siprp.planoactuacao.SingletonConstants;
import siprp.planoactuacao.db.PlanoActuacaoDBInit;
import com.evolute.utils.Singleton;
import com.evolute.utils.arrays.Virtual2DArray;
@ -26,6 +27,10 @@ public class PlanoActuacaoPrintDataProvider
public PlanoActuacaoPrintDataProvider()
throws Exception
{
if( Singleton.getInstance( SingletonConstants.WEB_DBMANAGER ) == null )
{
PlanoActuacaoDBInit.initDB();
}
DBManager WEB_DBMANAGER = ( DBManager ) Singleton.getInstance( SingletonConstants.WEB_DBMANAGER );
WEB_EXECUTER = WEB_DBMANAGER.getSharedExecuter( this );
DBManager LOCAL_DBMANAGER = ( DBManager ) Singleton.getInstance( SingletonConstants.LOCAL_DBMANAGER );
@ -57,7 +62,8 @@ public class PlanoActuacaoPrintDataProvider
new String[]{ "empresa_id", "nome_empresa",
"estabelecimento_id", "nome_estabelecimento",
"data_relatorio", "data_visita", "observacoes_dl",
"observacoes_dns" },
"observacoes_dns", "validacao_director_loja",
"validacao_dns" },
new Field( "id" ).isEqual( id ),
null,
null,
@ -73,7 +79,11 @@ public class PlanoActuacaoPrintDataProvider
Date dataVisita = ( Date ) array.get( 0, 5 );
String observacoesDl = ( String ) array.get( 0, 6 );
String observacoesDns = ( String ) array.get( 0, 7 );
EmpresaToPrint empresa = new EmpresaToPrint( nomeEmpresa, "http://apdp/siprp/auchan_jumbo_lado.jpg",
Boolean validacaoDl = ( Boolean ) array.get( 0, 8 );
Boolean validacaoDns = ( Boolean ) array.get( 0, 9 );
EmpresaToPrint empresa = new EmpresaToPrint( nomeEmpresa,
// "www.evolute.pt:13080/SIPRPImages/image?id=1",
"http://apdp/siprp/auchan_jumbo_lado.jpg",
nomeEstabelecimento );
PlanoActuacaoToPrint plano =
new PlanoActuacaoToPrint(
@ -81,7 +91,7 @@ public class PlanoActuacaoPrintDataProvider
dataRelatorio != null ? new DataToPrint( "data-relatorio", dataRelatorio ) : null,
dataVisita != null ? new DataToPrint( "data-hs", dataVisita ) : null,
getLegislacaoAplicavel( empresaId, estabelecimentoId ),
getAreasToPrintByPlanoId( id ),
getAreasToPrintByPlanoId( id, validacaoDl, validacaoDns ),
observacoesDl,
observacoesDns );
return plano;
@ -112,7 +122,7 @@ public class PlanoActuacaoPrintDataProvider
return legislacao;
}
public Vector<AreaToPrint> getAreasToPrintByPlanoId( Integer planoId )
public Vector<AreaToPrint> getAreasToPrintByPlanoId( Integer planoId, boolean validacaoDl, boolean validacaoDns )
throws Exception
{
Vector<AreaToPrint> areas = new Vector<AreaToPrint>();
@ -132,12 +142,12 @@ public class PlanoActuacaoPrintDataProvider
{
Integer areaId = ( Integer ) array.get( n, 0 );
String areaDescricao = ( String ) array.get( n, 1 );
areas.add( new AreaToPrint( areaDescricao, getRiscosToPrintByAreaId( areaId ) ) );
areas.add( new AreaToPrint( areaDescricao, getRiscosToPrintByAreaId( areaId, validacaoDl, validacaoDns ) ) );
}
return areas;
}
public Vector<RiscoToPrint> getRiscosToPrintByAreaId( Integer areaId )
public Vector<RiscoToPrint> getRiscosToPrintByAreaId( Integer areaId, boolean validacaoDl, boolean validacaoDns )
throws Exception
{
Vector<RiscoToPrint> riscos = new Vector<RiscoToPrint>();
@ -166,7 +176,17 @@ public class PlanoActuacaoPrintDataProvider
Date dataInicio = ( Date ) array.get( n, 5 );
Date dataFim = ( Date ) array.get( n, 6 );
String parecerDl = ( String ) array.get( n, 7 );
if( ( parecerDl == null || parecerDl.trim().length() == 0 )
&& validacaoDl )
{
parecerDl = "De acordo";
}
String parecerDns = ( String ) array.get( n, 8 );
if( ( parecerDns == null || parecerDns.trim().length() == 0 )
&& validacaoDns )
{
parecerDns = "De acordo";
}
String verificacaoSiprp = ( String ) array.get( n, 9 );
riscos.add(
new RiscoToPrint(

@ -104,10 +104,10 @@ public class PlanoActuacaoToPrint
}
Element observacoesDlElement = new Element( "observacoes-dl" );
observacoesDlElement.setText( observacoesDl );
planoElement.addContent( observacoesDl );
planoElement.addContent( observacoesDlElement );
Element observacoesDnsElement = new Element( "observacoes-dns" );
observacoesDnsElement.setText( observacoesDns );
planoElement.addContent( observacoesDns );
planoElement.addContent( observacoesDnsElement );
return planoElement;
}

@ -25,30 +25,35 @@ public class TestPrint
public void test()
throws Exception
{
PlanoActuacaoDBInit.initDB( "postgres", "Typein" );
PlanoActuacaoToPrint plano = PlanoActuacaoPrintDataProvider.getProvider().getPlanoToPrint( 6 );
Document foDoc = new Document( plano.toJdomElement() );
Format pretty = Format.getPrettyFormat();
pretty.setIndent("\t");
XMLOutputter outputter = new XMLOutputter(pretty);
ByteArrayOutputStream foBaos = new ByteArrayOutputStream();
outputter.output( foDoc, foBaos );
FileOutputStream fos = new FileOutputStream( "/home/fpalma/Desktop/in.xml" );
fos.write( foBaos.toByteArray() );
fos.close();
byte fo[] = applyTemplate(
// "siprp/planoactuacao/print/plano_actuacao.xsl",
getClass().getClassLoader().getResourceAsStream( "siprp/planoactuacao/print/plano_actuacao.xsl" ),
// "siprp/planoactuacao/print/teste_input.xml" );
new ByteArrayInputStream( foBaos.toByteArray() ) );
// new ByteArrayInputStream( "<?xml version=\"1.0\" encoding=\"UTF-8\"?><plano></plano>".getBytes() ) );
// System.out.println( new String( fo ) );
createPDFFile( fo, "/home/fpalma/Desktop/out.pdf" );
// createPDFFile( fo, "c:/Documents and Settings/Frederico/Ambiente de Trabalho/out.pdf" );
// PlanoActuacaoDBInit.initDB();
// PlanoActuacaoToPrint plano = PlanoActuacaoPrintDataProvider.getProvider().getPlanoToPrint( 6 );
// Document foDoc = new Document( plano.toJdomElement() );
// Format pretty = Format.getPrettyFormat();
// pretty.setIndent("\t");
// XMLOutputter outputter = new XMLOutputter(pretty);
// ByteArrayOutputStream foBaos = new ByteArrayOutputStream();
// outputter.output( foDoc, foBaos );
// FileOutputStream fos = new FileOutputStream( "/home/fpalma/Desktop/in.xml" );
// fos.write( foBaos.toByteArray() );
// fos.close();
//
// byte fo[] = applyTemplate(
//// "siprp/planoactuacao/print/plano_actuacao.xsl",
// getClass().getClassLoader().getResourceAsStream( "siprp/planoactuacao/print/plano_actuacao.xsl" ),
//// "siprp/planoactuacao/print/teste_input.xml" );
// new ByteArrayInputStream( foBaos.toByteArray() ) );
//// new ByteArrayInputStream( "<?xml version=\"1.0\" encoding=\"UTF-8\"?><plano></plano>".getBytes() ) );
//// System.out.println( new String( fo ) );
// createPDFFile( fo, "/home/fpalma/Desktop/out.pdf" );
//// createPDFFile( fo, "c:/Documents and Settings/Frederico/Ambiente de Trabalho/out.pdf" );
//
// fos = new FileOutputStream( "/home/fpalma/Desktop/out.xml" );
// fos.write( fo );
// fos.close();
fos = new FileOutputStream( "/home/fpalma/Desktop/out.xml" );
fos.write( fo );
byte pdf[] = new PlanoActuacaoPDFCreator().createPDF( 6 );
FileOutputStream fos = new FileOutputStream( "/home/fpalma/Desktop/pdf.pdf" );
fos.write( pdf );
fos.close();
}

@ -52,6 +52,21 @@
master-reference="pm1_2" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
<fo:simple-page-master master-name="pm1_3"
page-height="8.2701in" page-width="11.6902in" margin-top="0.4917in"
margin-right="1.3in" margin-left="0.6in">
<fo:region-body margin-top="1in"
margin-bottom="0.6201in" />
<fo:region-before extent="1in" margin-bottom="0in" />
<fo:region-after extent="0.6201in"
margin-top="0.4201in" />
</fo:simple-page-master>
<fo:page-sequence-master master-name="Standard_3">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference
master-reference="pm1_3" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="Standard_0"
initial-page-number="auto" force-page-count="no-force">
@ -59,13 +74,13 @@
<fo:block-container position="absolute"
top="-1.521cm" left="-3.373cm" height="9.899cm" width="9.899cm">
<fo:external-graphic
src="url('http://apdp/siprp/roda.png')" height="9.899cm"
src="url('http://www.evolute.pt/~siprp/planoactuacao/roda.png')" height="9.899cm"
width="9.899cm" />
</fo:block-container>
<fo:block-container position="absolute" top="0cm"
left="18cm" height="11.007cm" width="2.941cm">
<fo:external-graphic
src="url('http://apdp/siprp/siprp_land.png')" height="11.007cm"
src="url('http://www.evolute.pt/~siprp/planoactuacao/siprp_land.png')" height="11.007cm"
width="2.941cm" />
</fo:block-container>
<fo:block font-size="12pt" color="#606060"
@ -133,18 +148,18 @@
<fo:flow flow-name="xsl-region-body">
<fo:block text-align="center">
<fo:external-graphic
src="url('http://apdp/siprp/capa1.png')" height="4.211cm"
src="url('http://www.evolute.pt/~siprp/planoactuacao/capa1.png')" height="4.211cm"
width="6.279cm" />
<fo:external-graphic
src="url('http://apdp/siprp/capa2.png')" height="4.211cm"
src="url('http://www.evolute.pt/~siprp/planoactuacao/capa2.png')" height="4.211cm"
width="6.279cm" />
</fo:block>
<fo:block text-align="center">
<fo:external-graphic
src="url('http://apdp/siprp/capa3.png')" height="4.211cm"
src="url('http://www.evolute.pt/~siprp/planoactuacao/capa3.png')" height="4.211cm"
width="6.279cm" />
<fo:external-graphic
src="url('http://apdp/siprp/capa4.png')" height="4.211cm"
src="url('http://www.evolute.pt/~siprp/planoactuacao/capa4.png')" height="4.211cm"
width="6.279cm" />
</fo:block>
<fo:block font-size="16pt" color="#606060"
@ -168,7 +183,7 @@
<fo:block font-size="12pt"> </fo:block>
<fo:block font-size="12pt" text-align="center">
<!-- <fo:external-graphic-->
<!-- src="url('http://apdp/siprp/auchan_jumbo_lado.jpg')"-->
<!-- src="url('http://www.evolute.pt/~siprp/planoactuacao/auchan_jumbo_lado.jpg')"-->
<!-- height="1.398cm" width="8.273cm" />-->
<xsl:variable name="logotipo"
select="empresa/logotipo" />
@ -202,14 +217,14 @@
<fo:block font-size="13pt"
text-align="left">
<fo:external-graphic
src="url('http://apdp/siprp/siprp_logo.jpg')" height="2cm" />
src="url('http://www.evolute.pt/~siprp/planoactuacao/siprp_logo.jpg')" height="2cm" />
</fo:block>
</fo:table-cell>
<fo:table-cell display-align="after">
<fo:block font-size="13pt"
text-align="right">
<fo:external-graphic
src="url('http://apdp/siprp/auchan_jumbo_lado.jpg')"
src="url('http://www.evolute.pt/~siprp/planoactuacao/auchan_jumbo_lado.jpg')"
height="2cm" />
</fo:block>
</fo:table-cell>
@ -2419,7 +2434,7 @@
margin-bottom="0in" margin-right="-0.0484in"
text-indent="0in" margin-left="0in">
<fo:external-graphic
src="url('http://apdp/siprp/siprp_logo.jpg')" height="2cm" />
src="url('http://www.evolute.pt/~siprp/planoactuacao/siprp_logo.jpg')" height="2cm" />
</fo:block>
</fo:table-cell>
<fo:table-cell
@ -2433,7 +2448,7 @@
margin-left="1.2307in">
 
<fo:external-graphic
src="url('http://apdp/siprp/auchan_jumbo_lado.jpg')"
src="url('http://www.evolute.pt/~siprp/planoactuacao/auchan_jumbo_lado.jpg')"
height="2cm" />
</fo:block>
</fo:table-cell>
@ -2706,7 +2721,8 @@
border-bottom="0.0139in solid #000000" padding-top="0in"
border-top="0.0139in solid #000000" display-align="center"
background-color="#ccffff" writing-mode="lr-tb"
padding-right="0.0493in" border-right="0.0139in solid #000000">
padding-right="0.0493in"
border-right="0.0139in solid #000000">
<fo:block font-size="9pt"
text-align="justify" line-height="115%" margin-top="0in"
margin-bottom="0.139in" font-weight="bold">
@ -3006,6 +3022,161 @@
line-height="150%" margin-top="0in" margin-bottom="0in">
 
</fo:block>
</fo:flow>
</fo:page-sequence>
<fo:page-sequence master-reference="Standard_3"
initial-page-number="auto">
<fo:static-content flow-name="xsl-region-before">
<fo:table table-layout="fixed"
width="10.7153in">
<xsl:if test="position()&gt;1">
<xsl:attribute name="break-before">page</xsl:attribute>
</xsl:if>
<fo:table-column column-width="0.8368in" />
<fo:table-column column-width="1.2799in" />
<fo:table-column column-width="0.4785in" />
<fo:table-column column-width="1.9826in" />
<fo:table-column column-width="0.7875in" />
<fo:table-column column-width="0.9847in" />
<fo:table-column column-width="0.7875in" />
<fo:table-column column-width="0.6889in" />
<fo:table-column column-width="0.5903in" />
<fo:table-column column-width="0.9063in" />
<fo:table-column column-width="1.3813in" />
<fo:table-body>
<fo:table-row>
<fo:table-cell
number-columns-spanned="5" padding-bottom="0in"
padding-left="0.0486in" padding-top="0in"
display-align="after" border="none" writing-mode="lr-tb"
padding-right="0.0486in">
<fo:block font-size="11pt"
text-align="start" line-height="100%" margin-top="0in"
margin-bottom="0in" margin-right="-0.0484in"
text-indent="0in" margin-left="0in">
<fo:external-graphic
src="url('http://www.evolute.pt/~siprp/planoactuacao/siprp_logo.jpg')" height="2cm" />
</fo:block>
</fo:table-cell>
<fo:table-cell
number-columns-spanned="6" padding-bottom="0in"
padding-left="0.0486in" padding-top="0in"
display-align="after" border="none" writing-mode="lr-tb"
padding-right="0.0486in">
<fo:block font-size="9pt"
text-align="end" line-height="100%" margin-top="0in"
margin-bottom="0in" margin-right="0in" text-indent="0in"
margin-left="1.2307in">
 
<fo:external-graphic
src="url('http://www.evolute.pt/~siprp/planoactuacao/auchan_jumbo_lado.jpg')"
height="2cm" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after">
<fo:block font-size="11pt" text-align="right"
line-height="130%" margin-top="0in" margin-bottom="0in">
<fo:inline font-size="10pt">
<fo:page-number />
</fo:inline>
</fo:block>
<fo:block font-size="11pt" text-align="start"
line-height="100%" margin-top="0in" margin-bottom="0in">
 
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:table border="0.0139in solid #000000"
table-layout="fixed" width="10.7153in"
space-before="20pt">
<fo:table-column />
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block font-size="9pt"
text-align="left" line-height="130%" margin-top="0in"
margin-bottom="0in" font-weight="bold">
Observações Gerais DL:
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row height="50pt">
<fo:table-cell>
<fo:block font-size="9pt"
text-align="left" line-height="130%" margin-top="0in"
margin-bottom="0in" font-weight="bold">
<xsl:value-of
select="observacoes-dl" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:table border="0.0139in solid #000000"
table-layout="fixed" width="10.7153in" space-before="20pt">
<fo:table-column />
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block font-size="9pt"
text-align="left" line-height="130%" margin-top="0in"
margin-bottom="0in" font-weight="bold">
Observações Gerais DNS:
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row height="50pt">
<fo:table-cell>
<fo:block font-size="9pt"
text-align="left" line-height="130%" margin-top="0in"
margin-bottom="0in" font-weight="bold">
<xsl:value-of
select="observacoes-dns" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:table table-layout="fixed" width="10.7153in"
space-before="20pt">
<fo:table-column />
<fo:table-column column-width="2in" />
<fo:table-column column-width="3in" />
<fo:table-body>
<fo:table-row height="50pt">
<fo:table-cell></fo:table-cell>
<fo:table-cell
border-top="0.0139in solid #000000"
border-bottom="0.0139in solid #000000"
border-right="0.01in solid #000000"
border-left="0.0139in solid #000000">
<fo:block font-size="9pt"
text-align="left" line-height="130%" margin-top="0in"
margin-bottom="0in" font-weight="bold">
</fo:block>
</fo:table-cell>
<fo:table-cell
border-top="0.0139in solid #000000"
border-bottom="0.0139in solid #000000"
border-right="0.0139in solid #000000">
<fo:block font-size="9pt"
text-align="left" line-height="130%" margin-top="0in"
margin-bottom="0in" font-weight="bold">
NOME DO COORDENADOR DO PLANO
DE ACTUAÇÃO:
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:block id="evolute_endofdoc" />
</fo:flow>
</fo:page-sequence>

Loading…
Cancel
Save