git-svn-id: https://svn.coded.pt/svn/SIPRP@1468 bb69d46d-e84e-40c8-a05a-06db0d633741
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 33 KiB |
@ -1,27 +0,0 @@
|
||||
package siprp.planoactuacao.db;
|
||||
|
||||
public interface DBConstants
|
||||
{
|
||||
public static final String WEB_URL = "jdbc:postgresql://localhost:5436/siprp";
|
||||
// public static final String WEB_URL = "jdbc:postgresql://storage:5432/siprp";
|
||||
public static final String WEB_USER = "postgres";
|
||||
// public static final String WEB_PASSWORD = "Typein";
|
||||
public static final String WEB_PASSWORD = null;
|
||||
|
||||
// public static final String WEB_URL = "jdbc:postgresql://www.evolute.pt:5436/siprp";
|
||||
// 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_3";
|
||||
// public static final String LOCAL_URL = "jdbc:postgresql://storage/siprp_local";
|
||||
public static final String LOCAL_USER = "postgres";
|
||||
// public static final String LOCAL_PASSWORD = "Typein";
|
||||
public static final String LOCAL_PASSWORD = null;
|
||||
|
||||
// public static final String LOCAL_URL = "jdbc:postgresql://www.evolute.pt:5436/siprp_local_3";
|
||||
// public static final String LOCAL_USER = "postgres";
|
||||
// public static final String LOCAL_PASSWORD = "Typein";
|
||||
|
||||
public static final String WEB_DBMANAGER = "WEB DBMANAGER";
|
||||
public static final String LOCAL_DBMANAGER = "LOCAL DBMANAGER";
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
package siprp.planoactuacao.db;
|
||||
|
||||
import shst.SHSTPropertiesConstants;
|
||||
|
||||
import com.evolute.utils.Singleton;
|
||||
import com.evolute.utils.db.DBManager;
|
||||
import com.evolute.utils.db.JDBCManager;
|
||||
import com.evolute.utils.db.keyretrievers.PostgresqlAutoKeyRetriever;
|
||||
import com.evolute.utils.sql.Insert;
|
||||
import com.evolute.utils.strings.UnicodeChecker;
|
||||
|
||||
public class PlanoActuacaoDBInit
|
||||
{
|
||||
public static void initDB( boolean web )
|
||||
throws Exception
|
||||
{
|
||||
if( web )
|
||||
{
|
||||
String url = DBConstants.WEB_URL;
|
||||
String user = DBConstants.WEB_USER;
|
||||
String pwd = DBConstants.WEB_PASSWORD;
|
||||
DBManager webManager = new JDBCManager( url, user, pwd, 10, 8, 8, null );
|
||||
Singleton.setInstance( DBConstants.WEB_DBMANAGER, webManager );
|
||||
|
||||
url = DBConstants.LOCAL_URL;
|
||||
user = DBConstants.LOCAL_USER;
|
||||
pwd = DBConstants.LOCAL_PASSWORD;
|
||||
DBManager localManager = new JDBCManager( url, user, pwd, 10, 8, 8, null );
|
||||
Singleton.setInstance( DBConstants.LOCAL_DBMANAGER, localManager );
|
||||
}
|
||||
else
|
||||
{
|
||||
String url = ( String ) Singleton.getInstance( SHSTPropertiesConstants.WEB_URL_PREFIX );
|
||||
url += ( String ) Singleton.getInstance( SHSTPropertiesConstants.WEB_URL ) + "/";
|
||||
url += ( String ) Singleton.getInstance( SHSTPropertiesConstants.WEB_DB_NAME ) + "/";
|
||||
String user = ( String ) Singleton.getInstance( SHSTPropertiesConstants.WEB_USER );
|
||||
String pwd = ( String ) Singleton.getInstance( SHSTPropertiesConstants.WEB_PASSWORD );
|
||||
DBManager webManager = new JDBCManager( url, user, pwd, 10, 8, 8, null );
|
||||
Singleton.setInstance( DBConstants.WEB_DBMANAGER, webManager );
|
||||
Singleton.setInstance( DBConstants.LOCAL_DBMANAGER, Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ) );
|
||||
}
|
||||
|
||||
Insert.setDefaultKeyRetriever( PostgresqlAutoKeyRetriever.RETRIEVER );
|
||||
UnicodeChecker.setUseDoubleSlash( true );
|
||||
}
|
||||
}
|
||||
@ -1,89 +0,0 @@
|
||||
package siprp.planoactuacao.print;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
public class AreaToPrint
|
||||
implements PrintableInterface, Comparable< Object >
|
||||
{
|
||||
protected String designacao;
|
||||
protected Vector<RiscoToPrint> riscos;
|
||||
protected Integer ordem;
|
||||
protected boolean generico;
|
||||
|
||||
public AreaToPrint( String designacao, Vector<RiscoToPrint> riscos, Integer ordem, boolean generico )
|
||||
{
|
||||
super();
|
||||
this.designacao = designacao;
|
||||
this.riscos = riscos;
|
||||
this.ordem = ordem;
|
||||
this.generico = generico;
|
||||
}
|
||||
|
||||
public String getDesignacao()
|
||||
{
|
||||
return designacao;
|
||||
}
|
||||
|
||||
public void setDesignacao( String designacao )
|
||||
{
|
||||
this.designacao = designacao;
|
||||
}
|
||||
|
||||
public Vector<RiscoToPrint> getRiscos()
|
||||
{
|
||||
return riscos;
|
||||
}
|
||||
|
||||
public void setRiscos( Vector<RiscoToPrint> riscos )
|
||||
{
|
||||
this.riscos = riscos;
|
||||
}
|
||||
|
||||
public void addRisco( RiscoToPrint risco )
|
||||
{
|
||||
riscos.add( risco );
|
||||
}
|
||||
|
||||
protected boolean isGenerico()
|
||||
{
|
||||
return generico;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toJdomElement() throws Exception
|
||||
{
|
||||
Element areaElement = new Element( "area" );
|
||||
Element designacaoElement = new Element( "designacao" );
|
||||
designacaoElement.setText( designacao );
|
||||
areaElement.addContent( designacaoElement );
|
||||
for( RiscoToPrint risco : riscos )
|
||||
{
|
||||
areaElement.addContent( risco.toJdomElement() );
|
||||
}
|
||||
return areaElement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o)
|
||||
{
|
||||
if( o instanceof AreaToPrint )
|
||||
{
|
||||
if( generico && !( ( AreaToPrint ) o ).generico )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if( !generico && ( ( AreaToPrint ) o ).generico )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if( ordem != null )
|
||||
{
|
||||
return ( ( ( AreaToPrint ) o ).ordem == null ) ? -1 : ordem.compareTo( ( ( AreaToPrint ) o ).ordem );
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,66 +0,0 @@
|
||||
package siprp.planoactuacao.print;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
import com.evolute.utils.date.DateUtils;
|
||||
|
||||
public class DataToPrint
|
||||
implements PrintableInterface
|
||||
{
|
||||
protected String tag;
|
||||
protected Date data;
|
||||
|
||||
public DataToPrint( String tag, Date data )
|
||||
{
|
||||
super();
|
||||
this.tag = tag;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toJdomElement() throws Exception
|
||||
{
|
||||
Element dataElement = new Element( tag );
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime( data );
|
||||
int ano = cal.get( Calendar.YEAR );
|
||||
int mes = cal.get( Calendar.MONTH );
|
||||
int dia = cal.get( Calendar.DAY_OF_MONTH );
|
||||
Element anoElement = new Element( "ano" );
|
||||
anoElement.setText( "" + ano );
|
||||
dataElement.addContent( anoElement );
|
||||
Element mesElement = new Element( "mes" );
|
||||
mesElement.setText( "" + ( mes + 1 ) );
|
||||
dataElement.addContent( mesElement );
|
||||
Element mesExtensoElement = new Element( "mes-extenso" );
|
||||
mesExtensoElement.setText( DateUtils.MONTHS_FULL_PT[ mes ] );
|
||||
dataElement.addContent( mesExtensoElement );
|
||||
Element diaElement = new Element( "dia" );
|
||||
diaElement.setText( "" + dia );
|
||||
dataElement.addContent( diaElement );
|
||||
return dataElement;
|
||||
}
|
||||
|
||||
public String getTag()
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag( String tag )
|
||||
{
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public Date getData()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData( Date data )
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@ -1,67 +0,0 @@
|
||||
package siprp.planoactuacao.print;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
public class EmpresaToPrint
|
||||
implements PrintableInterface
|
||||
{
|
||||
protected String designacaoSocial;
|
||||
protected String logotipo;
|
||||
protected String estabelecimento;
|
||||
|
||||
public EmpresaToPrint( String designacaoSocial, String logotipo,
|
||||
String estabelecimento )
|
||||
{
|
||||
super();
|
||||
this.designacaoSocial = designacaoSocial;
|
||||
this.logotipo = logotipo;
|
||||
this.estabelecimento = estabelecimento;
|
||||
}
|
||||
|
||||
public String getDesignacaoSocial()
|
||||
{
|
||||
return designacaoSocial;
|
||||
}
|
||||
|
||||
public void setDesignacaoSocial( String designacaoSocial )
|
||||
{
|
||||
this.designacaoSocial = designacaoSocial;
|
||||
}
|
||||
|
||||
public String getLogotipo()
|
||||
{
|
||||
return logotipo;
|
||||
}
|
||||
|
||||
public void setLogotipo( String logotipo )
|
||||
{
|
||||
this.logotipo = logotipo;
|
||||
}
|
||||
|
||||
public String getEstabelecimento()
|
||||
{
|
||||
return estabelecimento;
|
||||
}
|
||||
|
||||
public void setEstabelecimento( String estabelecimento )
|
||||
{
|
||||
this.estabelecimento = estabelecimento;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toJdomElement() throws Exception
|
||||
{
|
||||
Element empresaElement = new Element( "empresa" );
|
||||
Element designacaoSocialElement = new Element( "designacao-social" );
|
||||
designacaoSocialElement.setText( designacaoSocial );
|
||||
empresaElement.addContent( designacaoSocialElement );
|
||||
Element logotipoElement = new Element( "logotipo" );
|
||||
logotipoElement.setText( logotipo );
|
||||
empresaElement.addContent( logotipoElement );
|
||||
Element estabelecimentoElement = new Element( "estabelecimento" );
|
||||
estabelecimentoElement.setText( estabelecimento );
|
||||
empresaElement.addContent( estabelecimentoElement );
|
||||
return empresaElement;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
package siprp.planoactuacao.print;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
public class LegislacaoAplicavelToPrint
|
||||
implements PrintableInterface
|
||||
{
|
||||
protected Vector<String> diplomasGerais;
|
||||
protected String[] nomesGruposEspecificos;
|
||||
protected Vector<String>[] diplomasEspecificos;
|
||||
|
||||
public LegislacaoAplicavelToPrint( Vector<String> diplomasGerais,
|
||||
String[] nomesGruposEspecificos, Vector<String>[] diplomasEspecificos )
|
||||
{
|
||||
super();
|
||||
this.diplomasGerais = diplomasGerais;
|
||||
this.nomesGruposEspecificos = nomesGruposEspecificos;
|
||||
this.diplomasEspecificos = diplomasEspecificos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toJdomElement() throws Exception
|
||||
{
|
||||
Element legislacaoAplicavelElement = new Element( "legislacao-aplicavel" );
|
||||
Element legislacaoGeralElement = new Element( "legislacao-geral" );
|
||||
for( String diploma : diplomasGerais )
|
||||
{
|
||||
Element diplomaElement = new Element( "diploma" );
|
||||
diplomaElement.setText( diploma );
|
||||
legislacaoGeralElement.addContent( diplomaElement );
|
||||
}
|
||||
legislacaoAplicavelElement.addContent( legislacaoGeralElement );
|
||||
|
||||
for( int e = 0; e < nomesGruposEspecificos.length; e++ )
|
||||
{
|
||||
Element legislacaoEspecificaElement = new Element( "legislacao-especifica" );
|
||||
Element designacaoElement = new Element( "designacao" );
|
||||
designacaoElement.setText( nomesGruposEspecificos[ e ] );
|
||||
legislacaoEspecificaElement.addContent( designacaoElement );
|
||||
for( String diploma : diplomasEspecificos[ e ] )
|
||||
{
|
||||
Element diplomaElement = new Element( "diploma" );
|
||||
diplomaElement.setText( diploma );
|
||||
legislacaoEspecificaElement.addContent( diplomaElement );
|
||||
}
|
||||
legislacaoAplicavelElement.addContent( legislacaoEspecificaElement );
|
||||
}
|
||||
return legislacaoAplicavelElement;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
package siprp.planoactuacao.print;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.Date;
|
||||
|
||||
import com.evolute.utils.data.Mappable;
|
||||
|
||||
public class LogotiposDumper
|
||||
{
|
||||
public static void main( String args[] )
|
||||
throws Exception
|
||||
{
|
||||
System.out.println( "Dumper: " + new Date() );
|
||||
dump( args[ 0 ] );
|
||||
}
|
||||
|
||||
public static void dump( String path )
|
||||
throws Exception
|
||||
{
|
||||
Mappable[] logotipos = PlanoActuacaoPrintDataProvider.getProvider( true ).getLogotipos();
|
||||
for( Mappable logotipo : logotipos )
|
||||
{
|
||||
File file = new File( path, "" + logotipo.getID() + ".png" );
|
||||
file.createNewFile();
|
||||
FileOutputStream fos = new FileOutputStream( file );
|
||||
fos.write( ( byte[] ) logotipo.getValue() );
|
||||
fos.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,64 +0,0 @@
|
||||
package siprp.planoactuacao.print;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.util.Date;
|
||||
import java.util.Vector;
|
||||
|
||||
public class LogotiposImporter
|
||||
{
|
||||
public static void main( String args[] )
|
||||
throws Exception
|
||||
{
|
||||
System.out.println( "Importer: " + new Date() );
|
||||
load( args[ 0 ] );
|
||||
}
|
||||
|
||||
public static void load( String path )
|
||||
throws Exception
|
||||
{
|
||||
File dir = new File( path );
|
||||
File files[] = dir.listFiles( new FilenameFilter(){
|
||||
|
||||
@Override
|
||||
public boolean accept( File dir, String name )
|
||||
{
|
||||
return name.length() >= 4 && ".jpg".equals( name.substring( name.length() - 4, name.length() ) );
|
||||
}
|
||||
} );
|
||||
for( File file : files )
|
||||
{
|
||||
FileInputStream fis = new FileInputStream( file );
|
||||
int ret = 0;
|
||||
Vector<byte[]> buffers = new Vector<byte[]>();
|
||||
Vector<Integer> sizes = new Vector<Integer>();
|
||||
byte data[];
|
||||
int size = 0;
|
||||
do
|
||||
{
|
||||
byte buff[] = new byte[ 1024 ];
|
||||
ret = fis.read( buff, 0, buff.length );
|
||||
if( ret > 0 )
|
||||
{
|
||||
size += ret;
|
||||
buffers.add( buff );
|
||||
sizes.add( ret );
|
||||
}
|
||||
} while( ret >= 0 );
|
||||
fis.close();
|
||||
data = new byte[ size ];
|
||||
int off = 0;
|
||||
for( int n = 0; n < buffers.size(); n++ )
|
||||
{
|
||||
byte buff[] = buffers.get( n );
|
||||
int s = sizes.get( n );
|
||||
System.arraycopy( buff, 0, data, off, s );
|
||||
off += s;
|
||||
}
|
||||
Integer id = new Integer( file.getName().split( "[.]" )[ 0 ] );
|
||||
|
||||
PlanoActuacaoPrintDataProvider.getProvider( true ).updateLogotipo( id, data );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,80 +0,0 @@
|
||||
package siprp.planoactuacao.print;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
public class MedidaToPrint implements PrintableInterface
|
||||
{
|
||||
protected String descricao;
|
||||
protected String estado;
|
||||
protected Vector< PostoToPrint > postos;
|
||||
|
||||
|
||||
public MedidaToPrint( String descricao, Vector< PostoToPrint > postos )
|
||||
{
|
||||
this( descricao, "", postos );
|
||||
// super();
|
||||
// this.descricao = descricao;
|
||||
// this.postos = postos;
|
||||
}
|
||||
|
||||
public MedidaToPrint( String descricao, String estado, Vector< PostoToPrint > postos )
|
||||
{
|
||||
super();
|
||||
this.descricao = descricao;
|
||||
this.estado = estado;
|
||||
this.postos = postos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toJdomElement() throws Exception
|
||||
{
|
||||
Element medidaElement = new Element( "medida" );
|
||||
Element descricaoElement = new Element( "descricao" );
|
||||
descricaoElement.setText( descricao );
|
||||
medidaElement.addContent( descricaoElement );
|
||||
Element estadoElement = new Element( "estado" );
|
||||
estadoElement.setText( estado );
|
||||
medidaElement.addContent( estadoElement );
|
||||
for( PostoToPrint posto : postos )
|
||||
{
|
||||
medidaElement.addContent( posto.toJdomElement() );
|
||||
}
|
||||
return medidaElement;
|
||||
}
|
||||
|
||||
public String getDescricao()
|
||||
{
|
||||
return descricao;
|
||||
}
|
||||
|
||||
public void setDescricao( String descricao )
|
||||
{
|
||||
this.descricao = descricao;
|
||||
}
|
||||
|
||||
public Vector<PostoToPrint> getPostos()
|
||||
{
|
||||
return postos;
|
||||
}
|
||||
|
||||
public void setPostos( Vector<PostoToPrint> postos )
|
||||
{
|
||||
this.postos = postos;
|
||||
}
|
||||
|
||||
public void addPosto( PostoToPrint posto )
|
||||
{
|
||||
postos.add( posto );
|
||||
}
|
||||
|
||||
public String getEstado() {
|
||||
return estado;
|
||||
}
|
||||
|
||||
public void setEstado(String estado) {
|
||||
this.estado = estado;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
package siprp.planoactuacao.print;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.jdom.Document;
|
||||
import org.jdom.output.Format;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
|
||||
import shst.util.fop.PDFCreator;
|
||||
import siprp.Main;
|
||||
|
||||
import com.evolute.utils.xml.XSLTransformer;
|
||||
|
||||
public class PlanoActuacaoPDFCreator
|
||||
{
|
||||
|
||||
public byte[] createPDF( Integer planoId, boolean web ) throws Exception
|
||||
{
|
||||
PlanoActuacaoToPrint plano = PlanoActuacaoPrintDataProvider.getProvider( web ).getPlanoToPrint( planoId );
|
||||
Document foDoc = new Document( plano.toJdomElement() );
|
||||
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
|
||||
ByteArrayOutputStream foBaos = new ByteArrayOutputStream();
|
||||
outputter.output( foDoc, foBaos );
|
||||
|
||||
// String xml = new String( foBaos.toByteArray() );
|
||||
// System.out.println( "\n\nXML :\n" + xml );
|
||||
|
||||
byte fo[] = applyTemplate(
|
||||
getClass().getClassLoader().getResourceAsStream(
|
||||
PlanoActuacaoPrintDataProvider.getProvider( web ).empresaUsaPlanoAlargadoPorPlanoId( planoId ) ?
|
||||
"siprp/planoactuacao/print/plano_actuacao_alargado.xsl"
|
||||
: "siprp/planoactuacao/print/plano_actuacao.xsl" ),
|
||||
new ByteArrayInputStream( foBaos.toByteArray() ) );
|
||||
|
||||
|
||||
// FileOutputStream fos = new FileOutputStream("/home/jneto/Desktop/a.fo");
|
||||
// fos.write(fo);
|
||||
|
||||
|
||||
PDFCreator.setUserConfig(Main.fopConfigFile);
|
||||
PDFCreator pdfCreator = PDFCreator.getPDFCreator();
|
||||
|
||||
byte pdf[] = pdfCreator.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();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,825 +0,0 @@
|
||||
package siprp.planoactuacao.print;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Vector;
|
||||
|
||||
import siprp.planoactuacao.db.DBConstants;
|
||||
import siprp.planoactuacao.db.PlanoActuacaoDBInit;
|
||||
|
||||
import com.evolute.utils.Singleton;
|
||||
import com.evolute.utils.arrays.Virtual2DArray;
|
||||
import com.evolute.utils.data.Mappable;
|
||||
import com.evolute.utils.data.MappableObject;
|
||||
import com.evolute.utils.db.DBManager;
|
||||
import com.evolute.utils.db.Executer;
|
||||
import com.evolute.utils.sql.BlobUpdate;
|
||||
import com.evolute.utils.sql.Expression;
|
||||
import com.evolute.utils.sql.Field;
|
||||
import com.evolute.utils.sql.Select;
|
||||
import com.evolute.utils.sql.Select2;
|
||||
|
||||
|
||||
public class PlanoActuacaoPrintDataProvider
|
||||
{
|
||||
private static final Object LOCK = new Object();
|
||||
private static PlanoActuacaoPrintDataProvider instance = null;
|
||||
protected static final Object UNCONTROLLED = "Incontrolado";
|
||||
protected static final Object CONTROLLED = "Controlado";
|
||||
protected static final Object INDETERMINATE = "Indeterminado";
|
||||
|
||||
protected final Executer WEB_EXECUTER;
|
||||
protected final Executer LOCAL_EXECUTER;
|
||||
|
||||
protected final boolean web;
|
||||
|
||||
public PlanoActuacaoPrintDataProvider( boolean web )
|
||||
throws Exception
|
||||
{
|
||||
this.web = web;
|
||||
if( Singleton.getInstance( DBConstants.WEB_DBMANAGER ) == null )
|
||||
{
|
||||
PlanoActuacaoDBInit.initDB( web );
|
||||
}
|
||||
DBManager WEB_DBMANAGER = ( DBManager ) Singleton.getInstance( DBConstants.WEB_DBMANAGER );
|
||||
WEB_EXECUTER = WEB_DBMANAGER.getSharedExecuter( this );
|
||||
DBManager LOCAL_DBMANAGER = ( DBManager ) Singleton.getInstance( DBConstants.LOCAL_DBMANAGER );
|
||||
LOCAL_EXECUTER = LOCAL_DBMANAGER.getSharedExecuter( this );
|
||||
}
|
||||
|
||||
public static PlanoActuacaoPrintDataProvider getProvider( boolean web )
|
||||
throws Exception
|
||||
{
|
||||
synchronized( LOCK )
|
||||
{
|
||||
if( instance == null )
|
||||
{
|
||||
instance = new PlanoActuacaoPrintDataProvider( web );
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public boolean empresaUsaPlanoAlargadoPorPlanoId( Integer planoId )
|
||||
throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
Select select =
|
||||
new Select2(
|
||||
new String[]{ "hs_relatorio", "marcacoes_estabelecimento", "estabelecimentos", "empresas" },
|
||||
new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER },
|
||||
new Expression[]{
|
||||
new Field( "hs_relatorio.marcacao_id" ).isEqual( new Field( "marcacoes_estabelecimento.id" ) ),
|
||||
new Field( "marcacoes_estabelecimento.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ),
|
||||
new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) )
|
||||
},
|
||||
new String[]{ "imprimir_tabela_alargada" },
|
||||
new Field( "hs_relatorio.id" ).isEqual( planoId ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = LOCAL_EXECUTER.executeQuery( select );
|
||||
|
||||
return array.get( 0, 0 ) != null ? ( ( Boolean ) array.get( 0, 0 ) ).booleanValue() : false;
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public PlanoActuacaoToPrint getPlanoToPrint( Integer id )
|
||||
throws Exception
|
||||
{
|
||||
Virtual2DArray array;
|
||||
if( web )
|
||||
{
|
||||
Select select =
|
||||
new Select2(
|
||||
new String[]{ "planos_actuacao" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "empresa_id", "nome_empresa",
|
||||
"estabelecimento_id", "nome_estabelecimento",
|
||||
"data_relatorio", "data_visita", "observacoes_dl",
|
||||
"observacoes_dns", "validacao_director_loja",
|
||||
"validacao_dns" },
|
||||
new Field( "id" ).isEqual( id ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
array = WEB_EXECUTER.executeQuery( select );
|
||||
}
|
||||
else
|
||||
{
|
||||
Select select =
|
||||
new Select2(
|
||||
new String[]{ "hs_relatorio", "marcacoes_estabelecimento", "estabelecimentos", "empresas" },
|
||||
new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER },
|
||||
new Expression[]{
|
||||
new Field( "hs_relatorio.marcacao_id" ).isEqual( new Field( "marcacoes_estabelecimento.id" ) ),
|
||||
new Field( "marcacoes_estabelecimento.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ),
|
||||
new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) )
|
||||
},
|
||||
new String[]{ "empresas.id", "empresas.designacao_social",
|
||||
"estabelecimentos.id", "estabelecimentos.nome",
|
||||
"hs_relatorio.data", "marcacoes_estabelecimento.data", "''",
|
||||
"''", "false",
|
||||
"false" },
|
||||
new Field( "hs_relatorio.id" ).isEqual( id ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
array = LOCAL_EXECUTER.executeQuery( select );
|
||||
}
|
||||
Integer empresaId = ( Integer ) array.get( 0, 0 );
|
||||
String nomeEmpresa = ( String ) array.get( 0, 1 );
|
||||
Integer estabelecimentoId = ( Integer ) array.get( 0, 2 );
|
||||
String nomeEstabelecimento = ( String ) array.get( 0, 3 );
|
||||
Integer logoId = getLogotipoIdForEmpresaId( empresaId );
|
||||
Date dataRelatorio = ( Date ) array.get( 0, 4 );
|
||||
Date dataVisita = ( Date ) array.get( 0, 5 );
|
||||
String observacoesDl = ( String ) array.get( 0, 6 );
|
||||
String observacoesDns = ( String ) array.get( 0, 7 );
|
||||
Boolean validacaoDl = ( Boolean ) array.get( 0, 8 );
|
||||
Boolean validacaoDns = ( Boolean ) array.get( 0, 9 );
|
||||
EmpresaToPrint empresa = new EmpresaToPrint( nomeEmpresa,
|
||||
"http://www.evolute.pt:13080/SIPRPImages/image?id=" + logoId,
|
||||
// "http://apdp/siprp/auchan_jumbo_lado.jpg",
|
||||
nomeEstabelecimento );
|
||||
PlanoActuacaoToPrint plano =
|
||||
new PlanoActuacaoToPrint(
|
||||
empresa,
|
||||
dataRelatorio != null ? new DataToPrint( "data-relatorio", dataRelatorio ) : null,
|
||||
dataVisita != null ? new DataToPrint( "data-hs", dataVisita ) : null,
|
||||
getLegislacaoAplicavel( id ),
|
||||
getAreasToPrintByPlanoId( id, validacaoDl, validacaoDns ),
|
||||
observacoesDl,
|
||||
observacoesDns,
|
||||
getTecnicoHS( id ),
|
||||
getTecnicoSuperiorHS( id ) );
|
||||
return plano;
|
||||
}
|
||||
|
||||
public Integer getLogotipoIdForEmpresaId( Integer empresaId )
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select2(
|
||||
new String[]{ "empresas" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "empresa_logo_id" },
|
||||
new Field( "id" ).isEqual( empresaId ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = LOCAL_EXECUTER.executeQuery( select );
|
||||
return array.columnLength() > 0 ? ( Integer ) array.get( 0, 0 ) : null;
|
||||
}
|
||||
|
||||
protected Integer getRelatorioIdForPlanoId( Integer planoId )
|
||||
throws Exception
|
||||
{
|
||||
Integer relatorioId = null;
|
||||
Select areaSelect =
|
||||
new Select2( new String[]{ "plano_areas" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "plano_areas.area_id" },
|
||||
new Field( "plano_areas.plano_id" ).isEqual( planoId ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray areaArray = WEB_EXECUTER.executeQuery( areaSelect );
|
||||
if( areaArray.columnLength() > 0 )
|
||||
{
|
||||
Select relatorioSelect =
|
||||
new Select2( new String[]{ "hs_relatorio_area" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "hs_relatorio_area.relatorio_id" },
|
||||
new Field( "hs_relatorio_area.id" ).isEqual( areaArray.get(0, 0) ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
relatorioId = ( Integer ) LOCAL_EXECUTER.executeQuery( relatorioSelect ).get(0, 0);
|
||||
}
|
||||
|
||||
return relatorioId;
|
||||
}
|
||||
|
||||
public LegislacaoAplicavelToPrint getLegislacaoAplicavel( Integer relatorioId )
|
||||
throws Exception
|
||||
{
|
||||
if( web )
|
||||
{
|
||||
relatorioId = getRelatorioIdForPlanoId( relatorioId );
|
||||
}
|
||||
Vector<String> diplomasGerais = new Vector<String>();
|
||||
Vector<String> nomes = new Vector<String>();
|
||||
Vector<Vector<String>> diplomas = new Vector<Vector<String>>();
|
||||
if( relatorioId != null )
|
||||
{
|
||||
Select select =
|
||||
new Select2(
|
||||
new String[]{ "hs_relatorio_legislacao" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "hs_relatorio_legislacao.categoria", "hs_relatorio_legislacao.descricao",
|
||||
"COALESCE(hs_relatorio_legislacao.categoria,'A')"},
|
||||
new Field( "hs_relatorio_legislacao.hs_relatorio_id" ).isEqual( relatorioId ),
|
||||
new String[]{ "COALESCE(hs_relatorio_legislacao.categoria,'A')", "ordem" },
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = LOCAL_EXECUTER.executeQuery( select );
|
||||
|
||||
String last = null;
|
||||
for( int n = 0; n < array.columnLength(); n++ )
|
||||
{
|
||||
String categoria = ( String ) array.get( n, 0 );
|
||||
String descricao = ( String ) array.get( n, 1 );
|
||||
if( categoria == null || categoria.trim().length() == 0 )
|
||||
{
|
||||
diplomasGerais.add( descricao );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !categoria.equals( last ) )
|
||||
{
|
||||
nomes.add( categoria );
|
||||
diplomas.add( new Vector<String>() );
|
||||
}
|
||||
last = categoria;
|
||||
diplomas.lastElement().add( descricao );
|
||||
}
|
||||
}
|
||||
}
|
||||
LegislacaoAplicavelToPrint legislacao =
|
||||
new LegislacaoAplicavelToPrint( diplomasGerais, nomes.toArray( new String[ nomes.size() ] ),
|
||||
diplomas.toArray( new Vector[ diplomas.size() ] ));
|
||||
return legislacao;
|
||||
}
|
||||
|
||||
public Vector<AreaToPrint> getAreasToPrintByPlanoId( Integer planoId, boolean validacaoDl, boolean validacaoDns )
|
||||
throws Exception
|
||||
{
|
||||
Virtual2DArray array;
|
||||
Vector<AreaToPrint> areas = new Vector<AreaToPrint>();
|
||||
HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
|
||||
if( web )
|
||||
{
|
||||
Select select =
|
||||
new Select2(
|
||||
new String[]{ "plano_areas" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "area_id", "id" },
|
||||
new Field( "plano_id" ).isEqual( planoId ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray arrayTemp = WEB_EXECUTER.executeQuery( select );
|
||||
Vector<Integer> ids = new Vector<Integer>();
|
||||
for( int n = 0; n < arrayTemp.columnLength(); n++ )
|
||||
{
|
||||
ids.add( ( Integer ) arrayTemp.get(n, 0) );
|
||||
map.put( ( Integer ) arrayTemp.get(n, 0), ( Integer ) arrayTemp.get(n, 1) );
|
||||
}
|
||||
select =
|
||||
new Select2(
|
||||
new String[]{ "hs_relatorio_area" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id", "description", "ordem" },
|
||||
new Field( "id" ).in( ids.toArray( new Integer[ ids.size() ] ) ).and(
|
||||
new Field( "deleted_date" ).isEqual( null ) ),
|
||||
new String[]{ "id" },
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
array = LOCAL_EXECUTER.executeQuery( select );
|
||||
}
|
||||
else
|
||||
{
|
||||
Select select =
|
||||
new Select2(
|
||||
new String[]{ "hs_relatorio_area" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id", "description", "ordem" },
|
||||
new Field( "relatorio_id" ).isEqual( planoId ).and(
|
||||
new Field( "deleted_date" ).isEqual( null ) ),
|
||||
new String[]{ "id" },
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
array = LOCAL_EXECUTER.executeQuery( select );
|
||||
}
|
||||
for( int n = 0; n < array.columnLength(); n++ )
|
||||
{
|
||||
Integer areaId = ( Integer ) array.get( n, 0 );
|
||||
String areaDescricao = ( String ) array.get( n, 1 );
|
||||
Integer ordem = ( Integer ) array.get( n, 2 );
|
||||
boolean generico = false;
|
||||
if( !web )
|
||||
{
|
||||
Select selectGen =
|
||||
new Select2(
|
||||
new String[]{ "hs_relatorio_posto" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "COUNT( hs_relatorio_posto.id )" },
|
||||
new Field( "hs_relatorio_posto.area_id" ).isEqual( areaId ).and(
|
||||
new Field( "hs_relatorio_posto.is_principal" ).isEqual( true ) ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray genArray = LOCAL_EXECUTER.executeQuery( selectGen );
|
||||
if( genArray.columnLength() > 0 && genArray.get( 0, 0 ) != null )
|
||||
{
|
||||
generico = ( ( Number ) genArray.get( 0, 0 ) ).intValue() > 0;
|
||||
}
|
||||
}
|
||||
Vector<RiscoToPrint> riscos =
|
||||
getRiscosToPrintByAreaId( map.containsKey( areaId ) ? map.get( areaId ) : areaId, validacaoDl, validacaoDns );
|
||||
if( riscos.size() > 0 )
|
||||
{
|
||||
areas.add( new AreaToPrint( areaDescricao, riscos, ordem, generico ) );
|
||||
}
|
||||
}
|
||||
Collections.sort( areas );
|
||||
return areas;
|
||||
}
|
||||
|
||||
public Vector<RiscoToPrint> getRiscosToPrintByAreaId( Integer areaId, boolean validacaoDl, boolean validacaoDns )
|
||||
throws Exception
|
||||
{
|
||||
Virtual2DArray array;
|
||||
Vector<RiscoToPrint> riscos = new Vector<RiscoToPrint>();
|
||||
if( web )
|
||||
{
|
||||
Select select =
|
||||
new Select2(
|
||||
new String[]{ "plano_riscos" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id", "descricao", "valor", "responsavel_execucao",
|
||||
"recursos_necessarios", "data_inicio", "data_fim",
|
||||
"parecer_dl", "parecer_dns", "verificacao_siprp"},
|
||||
new Field( "area_id" ).isEqual( areaId ).and(
|
||||
new Field( "activo" ).isEqual( "y" ) ),
|
||||
new String[]{ "id" },
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
array = WEB_EXECUTER.executeQuery( select );
|
||||
for( int n = 0; n < array.columnLength(); n++ )
|
||||
{
|
||||
Integer id = ( Integer ) array.get( n, 0 );
|
||||
String descricao = ( String ) array.get( n, 1 );
|
||||
Integer valor = ( Integer ) array.get( n, 2 );
|
||||
String responsavelExecucao = ( String ) array.get( n, 3 );
|
||||
String recursosNecessarios = ( String ) array.get( n, 4 );
|
||||
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(
|
||||
descricao,
|
||||
valor != null ? valor.toString() : "IND",
|
||||
getMedidasToPrintByRiscoId( id ),
|
||||
responsavelExecucao,
|
||||
recursosNecessarios,
|
||||
dataInicio != null ? new DataToPrint( "data-prevista-inicio", dataInicio ) : null,
|
||||
dataFim != null ? new DataToPrint( "data-prevista-conclusao", dataFim ) : null,
|
||||
parecerDl,
|
||||
parecerDns,
|
||||
verificacaoSiprp, valor, valor != null ? null : "IND" ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Select select =
|
||||
new Select2(
|
||||
new String[]{ "hs_relatorio_risco", "hs_relatorio_posto_risco", "hs_relatorio_posto", "hs_relatorio_risco_valor_qualitativo" },
|
||||
new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_LEFT_OUTER },
|
||||
new Expression[]{
|
||||
new Field( "hs_relatorio_risco.id" ).isEqual( new Field( "hs_relatorio_posto_risco.risco_id" ) ),
|
||||
new Field( "hs_relatorio_posto_risco.posto_id" ).isEqual( new Field( "hs_relatorio_posto.id" ) ),
|
||||
new Field( "hs_relatorio_posto_risco.valor_qualitativo_id" ).isEqual(new Field("hs_relatorio_risco_valor_qualitativo.id"))
|
||||
},
|
||||
new String[]{ "hs_relatorio_risco.id",
|
||||
"hs_relatorio_risco.description",
|
||||
"hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade",
|
||||
"hs_relatorio_risco_valor_qualitativo.description",
|
||||
"hs_relatorio_posto.id",
|
||||
"null",
|
||||
"null",
|
||||
"null",
|
||||
"null",
|
||||
"null" },
|
||||
new Field( "hs_relatorio_posto.area_id" ).isEqual( areaId ).and(
|
||||
new Field( "hs_relatorio_risco.deleted_date" ).isEqual( null ) ).and(
|
||||
new Field( "hs_relatorio_posto.deleted_date" ).isEqual( null ) ),
|
||||
new String[]{ "hs_relatorio_risco.id" },
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
array = LOCAL_EXECUTER.executeQuery( select );
|
||||
Vector<String> riscosVector = new Vector<String>();
|
||||
HashMap<String,Vector<Integer>> riscosIdMap = new HashMap<String,Vector<Integer>>();
|
||||
HashMap<Integer,Integer> riscoPostoMap = new HashMap<Integer, Integer>();
|
||||
HashMap<String,Integer> valoresQuantitativos = new HashMap<String,Integer>();
|
||||
HashMap<String,String> valoresQualitativos = new HashMap<String,String>();
|
||||
for( int n = 0; n < array.columnLength(); n++ )
|
||||
{
|
||||
Integer id = ( Integer ) array.get( n, 0 );
|
||||
String descricao = ( String ) array.get( n, 1 );
|
||||
Integer risco = ( Integer ) array.get( n, 2 );
|
||||
String risco_qual = ((String) array.get( n, 3));
|
||||
if(risco_qual!=null){
|
||||
risco_qual = risco_qual.substring(0, 3).toUpperCase();
|
||||
}
|
||||
Integer posto = ( Integer ) array.get( n, 4 );
|
||||
|
||||
String finalRisco;
|
||||
|
||||
if(risco!=null){
|
||||
finalRisco = ""+risco;
|
||||
}else if(risco_qual!=null){
|
||||
finalRisco = ""+risco_qual;
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
|
||||
String key = descricao + "_" + finalRisco;
|
||||
if( !riscosIdMap.containsKey( key ) )
|
||||
{
|
||||
riscosIdMap.put( key, new Vector<Integer>() );
|
||||
riscosVector.add( key );
|
||||
}
|
||||
riscosIdMap.get( key ).add( id );
|
||||
riscoPostoMap.put(id, posto);
|
||||
valoresQuantitativos.put( key, risco );
|
||||
valoresQualitativos.put( key, ((String) array.get( n, 3)) );
|
||||
}
|
||||
for( String risco : riscosVector )
|
||||
{
|
||||
int index = risco.lastIndexOf( "_" );
|
||||
String descricao = risco.substring( 0, index );
|
||||
String valor = risco.substring( index + 1, risco.length() ) ;
|
||||
Vector<MedidaToPrint> medidas = new Vector<MedidaToPrint>();
|
||||
for( Integer id : riscosIdMap.get( risco ) )
|
||||
{
|
||||
Integer posto = riscoPostoMap.get(id);
|
||||
medidas.addAll( getMedidasToPrintByRiscoId( id , posto) );
|
||||
}
|
||||
if( medidas.size() > 0 )
|
||||
{
|
||||
riscos.add(
|
||||
new RiscoToPrint(
|
||||
descricao,
|
||||
valor,
|
||||
medidas,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
valoresQuantitativos.get( risco ),
|
||||
valoresQualitativos.get( risco ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(riscos, new Comparator<RiscoToPrint>(){
|
||||
|
||||
@Override
|
||||
public int compare(RiscoToPrint o1, RiscoToPrint o2) {
|
||||
Integer o1Value = 1000;
|
||||
Integer o2Value = 1000;
|
||||
if( o1.valorQuantitativo != null )
|
||||
{
|
||||
o1Value = -o1.valorQuantitativo;
|
||||
}
|
||||
else if(o1.valorQualitativo == null)
|
||||
{
|
||||
o1Value = 300;
|
||||
}
|
||||
else if(o1.valorQualitativo.equals(UNCONTROLLED))
|
||||
{
|
||||
o1Value = 100;
|
||||
}
|
||||
else if(o1.valorQualitativo.equals(CONTROLLED))
|
||||
{
|
||||
o1Value = 200;
|
||||
}
|
||||
else if(o1.valorQualitativo.equals(INDETERMINATE))
|
||||
{
|
||||
o1Value = 300;
|
||||
}
|
||||
if( o2.valorQuantitativo != null )
|
||||
{
|
||||
o2Value = -o2.valorQuantitativo;
|
||||
}
|
||||
else if(o2.valorQualitativo == null )
|
||||
{
|
||||
o2Value = 300;
|
||||
}
|
||||
else if(o2.valorQualitativo.equals(UNCONTROLLED))
|
||||
{
|
||||
o2Value = 100;
|
||||
}
|
||||
else if(o2.valorQualitativo.equals(CONTROLLED))
|
||||
{
|
||||
o2Value = 200;
|
||||
}
|
||||
else if(o2.valorQualitativo.equals(INDETERMINATE))
|
||||
{
|
||||
o2Value = 300;
|
||||
}
|
||||
return o1Value.compareTo(o2Value);
|
||||
}
|
||||
});
|
||||
return riscos;
|
||||
}
|
||||
|
||||
public Vector<MedidaToPrint> getMedidasToPrintByRiscoId( Integer riscoId) throws Exception{
|
||||
return getMedidasToPrintByRiscoId(riscoId, null);
|
||||
}
|
||||
|
||||
public Vector<MedidaToPrint> getMedidasToPrintByRiscoId( Integer riscoId, Integer posto )
|
||||
throws Exception
|
||||
{
|
||||
Vector<MedidaToPrint> medidas = new Vector<MedidaToPrint>();
|
||||
Virtual2DArray array;
|
||||
if( web )
|
||||
{
|
||||
Select select = new Select2(
|
||||
new String[]{ "plano_medidas", "estado_medidas" },
|
||||
new Integer[] { Select2.JOIN_LEFT_OUTER },
|
||||
new Expression[]{
|
||||
new Field( "plano_medidas.estado_medidas_id" ).isEqual( new Field( "estado_medidas.id" ) )
|
||||
},
|
||||
new String[]{ "plano_medidas.id", "plano_medidas.descricao", "true", "estado_medidas.descricao" },
|
||||
new Field( "plano_medidas.risco_id" ).isEqual( riscoId ),
|
||||
new String[]{ "plano_medidas.id" },
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
array = WEB_EXECUTER.executeQuery( select );
|
||||
}
|
||||
else
|
||||
{
|
||||
Expression filter = new Field( "hs_relatorio_medida.risco_id" ).isEqual( riscoId ).and(
|
||||
new Field( "hs_relatorio_medida.deleted_date" ).isEqual( null ) )
|
||||
.and(new Field("hs_relatorio_medida.description").isDifferent(""));
|
||||
|
||||
if(posto!=null){
|
||||
filter = filter.and(new Field("hs_relatorio_posto_medida.posto_id").isEqual(posto));
|
||||
}
|
||||
|
||||
Select select =
|
||||
new Select2(
|
||||
new String[]{"hs_relatorio_medida", "hs_relatorio_posto_medida"},
|
||||
new Integer[]{Select2.JOIN_INNER},
|
||||
new Expression[]{new Field("hs_relatorio_medida.id").isEqual(new Field("hs_relatorio_posto_medida.medida_id"))},
|
||||
new String[]{
|
||||
"hs_relatorio_medida.id", "hs_relatorio_medida.description", "hs_relatorio_posto_medida.is_plano_actuacao"
|
||||
, "'' AS estado_medidas_descricao"
|
||||
},
|
||||
filter,
|
||||
new String[]{ "hs_relatorio_medida.id" },
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
array = LOCAL_EXECUTER.executeQuery( select );
|
||||
}
|
||||
for( int n = 0; n < array.columnLength(); n++ )
|
||||
{
|
||||
Integer id = ( Integer ) array.get( n, 0 );
|
||||
String descricao = ( String ) array.get( n, 1 );
|
||||
Boolean isPlanoActuacao = ( Boolean ) array.get( n, 2 );
|
||||
String estado_medidas = ( String ) array.get( n, 3 );
|
||||
Vector< PostoToPrint > postos = getPostosToPrintByMedidaId( id );
|
||||
if( postos.size() > 0 && isPlanoActuacao )
|
||||
{
|
||||
if ( web )
|
||||
{
|
||||
descricao = StringConverterUtils.convertHTMLToText( descricao );
|
||||
descricao = StringConverterUtils.stripHTMLTags( descricao );
|
||||
if ( estado_medidas != null )
|
||||
{
|
||||
estado_medidas = StringConverterUtils.convertHTMLToText( estado_medidas );
|
||||
estado_medidas = StringConverterUtils.stripHTMLTags( estado_medidas );
|
||||
}
|
||||
else
|
||||
{
|
||||
estado_medidas = "";
|
||||
}
|
||||
}
|
||||
medidas.add( new MedidaToPrint( descricao, estado_medidas, postos ) );
|
||||
}
|
||||
}
|
||||
return medidas;
|
||||
}
|
||||
|
||||
public Vector<PostoToPrint> getPostosToPrintByMedidaId( Integer medidaId )
|
||||
throws Exception
|
||||
{
|
||||
Vector<PostoToPrint> postos = new Vector<PostoToPrint>();
|
||||
Virtual2DArray array;
|
||||
if( web )
|
||||
{
|
||||
Select select =
|
||||
new Select2(
|
||||
new String[]{ "plano_postos_trabalho" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id", "descricao" },
|
||||
new Field( "medida_id" ).isEqual( medidaId ),
|
||||
new String[]{ "id" },
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
array = WEB_EXECUTER.executeQuery( select );
|
||||
}
|
||||
else
|
||||
{
|
||||
Select select =
|
||||
new Select2(
|
||||
new String[]{ "hs_relatorio_posto", "hs_relatorio_posto_medida" },
|
||||
new Integer[]{ Select2.JOIN_INNER },
|
||||
new Expression[]{
|
||||
new Field( "hs_relatorio_posto.id" ).isEqual( new Field( "hs_relatorio_posto_medida.posto_id" ) )
|
||||
},
|
||||
new String[]{ "hs_relatorio_posto.id", "hs_relatorio_posto.description" },
|
||||
new Field( "hs_relatorio_posto_medida.medida_id" ).isEqual( medidaId ),
|
||||
new String[]{ "hs_relatorio_posto.id" },
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
array = LOCAL_EXECUTER.executeQuery( select );
|
||||
}
|
||||
for( int n = 0; n < array.columnLength(); n++ )
|
||||
{
|
||||
String descricao = ( String ) array.get( n, 1 );
|
||||
postos.add( new PostoToPrint( descricao ) );
|
||||
}
|
||||
return postos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Para fazer dump dos logotipos para converter para jpeg
|
||||
*/
|
||||
public Mappable[] getLogotipos()
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select2(
|
||||
new String[]{ "image" },
|
||||
new Integer[]{},
|
||||
new Expression[]{},
|
||||
new String[]{ "id", "image_data" },
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = LOCAL_EXECUTER.executeQuery( select );
|
||||
Mappable logotipos[] = new Mappable[ array.columnLength() ];
|
||||
for( int n = 0; n < logotipos.length; n++ )
|
||||
{
|
||||
Integer id = ( Integer ) array.get( n, 0 );
|
||||
byte data[] = ( byte[] ) array.get( n, 1 );
|
||||
logotipos[ n ] =
|
||||
new MappableObject( id, data );
|
||||
}
|
||||
return logotipos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Para fazer import dos logotipos convertidos para jpeg
|
||||
*/
|
||||
public void updateLogotipo( Integer id, byte[] data )
|
||||
throws Exception
|
||||
{
|
||||
BlobUpdate update =
|
||||
new BlobUpdate( "image", "image_data", data, new Field( "id" ).isEqual( id ) );
|
||||
LOCAL_EXECUTER.executeQuery( update );
|
||||
}
|
||||
|
||||
public TecnicoHSToPrint getTecnicoHS( Integer relatorioId )
|
||||
throws Exception
|
||||
{
|
||||
if( web )
|
||||
{
|
||||
relatorioId = getRelatorioIdForPlanoId( relatorioId );
|
||||
}
|
||||
Select select =
|
||||
new Select2(
|
||||
new String[]{ "hs_relatorio", "marcacoes_estabelecimento", "marcacoes_tecnicos_hst" },
|
||||
new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER },
|
||||
new Expression[]{
|
||||
new Field( "hs_relatorio.marcacao_id" ).isEqual( new Field( "marcacoes_estabelecimento.id" ) ),
|
||||
new Field( "marcacoes_estabelecimento.tecnico_hst" ).isEqual( new Field( "marcacoes_tecnicos_hst.id" ) ),
|
||||
},
|
||||
new String[]{
|
||||
"marcacoes_tecnicos_hst.id",
|
||||
"marcacoes_tecnicos_hst.nome",
|
||||
"marcacoes_tecnicos_hst.cap",
|
||||
"marcacoes_tecnicos_hst.formacao",
|
||||
"marcacoes_tecnicos_hst.assinatura",},
|
||||
new Field( "hs_relatorio.id" ).isEqual( relatorioId ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = LOCAL_EXECUTER.executeQuery( select );
|
||||
|
||||
if( array.columnLength() == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Integer id = ( Integer ) array.get( 0, 0 );
|
||||
String nome = ( String ) array.get( 0, 1 );
|
||||
String cap = ( String ) array.get( 0, 2 );
|
||||
String formacao = ( String ) array.get( 0, 3 );
|
||||
Integer assinatura = ( Integer ) array.get( 0, 4 );
|
||||
return new TecnicoHSToPrint( id, nome, cap, formacao, "http://www.evolute.pt:13080/SIPRPImages/image?id=" + assinatura, false );
|
||||
}
|
||||
}
|
||||
|
||||
public TecnicoHSToPrint getTecnicoSuperiorHS( Integer relatorioId )
|
||||
throws Exception
|
||||
{
|
||||
if( web )
|
||||
{
|
||||
relatorioId = getRelatorioIdForPlanoId( relatorioId );
|
||||
}
|
||||
Select select =
|
||||
new Select2(
|
||||
new String[]{ "hs_relatorio", "marcacoes_estabelecimento", "marcacoes_tecnicos_hst" },
|
||||
new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER },
|
||||
new Expression[]{
|
||||
new Field( "hs_relatorio.marcacao_id" ).isEqual( new Field( "marcacoes_estabelecimento.id" ) ),
|
||||
new Field( "marcacoes_estabelecimento.tecnico_superior_hst" ).isEqual( new Field( "marcacoes_tecnicos_hst.id" ) ),
|
||||
},
|
||||
new String[]{
|
||||
"marcacoes_tecnicos_hst.id",
|
||||
"marcacoes_tecnicos_hst.nome",
|
||||
"marcacoes_tecnicos_hst.cap",
|
||||
"marcacoes_tecnicos_hst.formacao",
|
||||
"marcacoes_tecnicos_hst.assinatura",},
|
||||
new Field( "hs_relatorio.id" ).isEqual( relatorioId ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null );
|
||||
Virtual2DArray array = LOCAL_EXECUTER.executeQuery( select );
|
||||
|
||||
if( array.columnLength() == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Integer id = ( Integer ) array.get( 0, 0 );
|
||||
String nome = ( String ) array.get( 0, 1 );
|
||||
String cap = ( String ) array.get( 0, 2 );
|
||||
String formacao = ( String ) array.get( 0, 3 );
|
||||
Integer assinatura = ( Integer ) array.get( 0, 4 );
|
||||
return new TecnicoHSToPrint( id, nome, cap, formacao, "http://www.evolute.pt:13080/SIPRPImages/image?id=" + assinatura, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,165 +0,0 @@
|
||||
package siprp.planoactuacao.print;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
public class PlanoActuacaoToPrint
|
||||
implements PrintableInterface
|
||||
{
|
||||
protected EmpresaToPrint empresa;
|
||||
protected DataToPrint dataRelatorio;
|
||||
protected DataToPrint dataHs;
|
||||
protected LegislacaoAplicavelToPrint legislacaoAplicavel;
|
||||
protected Vector<AreaToPrint> areas;
|
||||
protected String observacoesDl;
|
||||
protected String observacoesDns;
|
||||
protected TecnicoHSToPrint tecnico;
|
||||
protected TecnicoHSToPrint tecnicoSuperior;
|
||||
|
||||
public PlanoActuacaoToPrint( EmpresaToPrint empresa, DataToPrint dataRelatorio,
|
||||
DataToPrint dataHs, LegislacaoAplicavelToPrint legislacaoAplicavel,
|
||||
Vector<AreaToPrint> areas, String observacoesDl, String observacoesDns,
|
||||
TecnicoHSToPrint tecnico, TecnicoHSToPrint tecnicoSuperior )
|
||||
{
|
||||
super();
|
||||
this.empresa = empresa;
|
||||
this.dataRelatorio = dataRelatorio;
|
||||
this.dataHs = dataHs;
|
||||
this.legislacaoAplicavel = legislacaoAplicavel;
|
||||
this.areas = areas;
|
||||
this.observacoesDl = observacoesDl;
|
||||
this.observacoesDns = observacoesDns;
|
||||
this.tecnico = tecnico;
|
||||
this.tecnicoSuperior = tecnicoSuperior;
|
||||
}
|
||||
|
||||
public EmpresaToPrint getEmpresa()
|
||||
{
|
||||
return empresa;
|
||||
}
|
||||
|
||||
public void setEmpresa( EmpresaToPrint empresa )
|
||||
{
|
||||
this.empresa = empresa;
|
||||
}
|
||||
|
||||
public DataToPrint getDataRelatorio()
|
||||
{
|
||||
return dataRelatorio;
|
||||
}
|
||||
|
||||
public void setDataRelatorio( DataToPrint dataRelatorio )
|
||||
{
|
||||
this.dataRelatorio = dataRelatorio;
|
||||
}
|
||||
|
||||
public DataToPrint getDataHs()
|
||||
{
|
||||
return dataHs;
|
||||
}
|
||||
|
||||
public void setDataHs( DataToPrint dataHs )
|
||||
{
|
||||
this.dataHs = dataHs;
|
||||
}
|
||||
|
||||
public LegislacaoAplicavelToPrint getLegislacaoAplicavel()
|
||||
{
|
||||
return legislacaoAplicavel;
|
||||
}
|
||||
|
||||
public void setLegislacaoAplicavel(
|
||||
LegislacaoAplicavelToPrint legislacaoAplicavel )
|
||||
{
|
||||
this.legislacaoAplicavel = legislacaoAplicavel;
|
||||
}
|
||||
|
||||
public Vector<AreaToPrint> getAreas()
|
||||
{
|
||||
return areas;
|
||||
}
|
||||
|
||||
public void setAreas( Vector<AreaToPrint> areas )
|
||||
{
|
||||
this.areas = areas;
|
||||
}
|
||||
|
||||
public void addArea( AreaToPrint area )
|
||||
{
|
||||
areas.add( area );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toJdomElement() throws Exception
|
||||
{
|
||||
Element planoElement = new Element( "plano" );
|
||||
planoElement.addContent( empresa.toJdomElement() );
|
||||
planoElement.addContent( dataRelatorio.toJdomElement() );
|
||||
planoElement.addContent( dataHs.toJdomElement() );
|
||||
planoElement.addContent( legislacaoAplicavel.toJdomElement() );
|
||||
if( areas.size() > 0 )
|
||||
{
|
||||
Element conclusoesElement = new Element( "conclusoes" );
|
||||
for( AreaToPrint area : areas )
|
||||
{
|
||||
conclusoesElement.addContent( area.toJdomElement() );
|
||||
}
|
||||
planoElement.addContent( conclusoesElement );
|
||||
}
|
||||
Element observacoesDlElement = new Element( "observacoes-dl" );
|
||||
observacoesDlElement.setText( observacoesDl );
|
||||
planoElement.addContent( observacoesDlElement );
|
||||
Element observacoesDnsElement = new Element( "observacoes-dns" );
|
||||
observacoesDnsElement.setText( observacoesDns );
|
||||
planoElement.addContent( observacoesDnsElement );
|
||||
if( tecnico != null )
|
||||
{
|
||||
planoElement.addContent( tecnico.toJdomElement() );
|
||||
}
|
||||
if( tecnicoSuperior != null )
|
||||
{
|
||||
planoElement.addContent( tecnicoSuperior.toJdomElement() );
|
||||
}
|
||||
return planoElement;
|
||||
}
|
||||
|
||||
public String getObservacoesDl()
|
||||
{
|
||||
return observacoesDl;
|
||||
}
|
||||
|
||||
public void setObservacoesDl( String observacoesDl )
|
||||
{
|
||||
this.observacoesDl = observacoesDl;
|
||||
}
|
||||
|
||||
public String getObservacoesDns()
|
||||
{
|
||||
return observacoesDns;
|
||||
}
|
||||
|
||||
public void setObservacoesDns( String observacoesDns )
|
||||
{
|
||||
this.observacoesDns = observacoesDns;
|
||||
}
|
||||
|
||||
public TecnicoHSToPrint getTecnico()
|
||||
{
|
||||
return tecnico;
|
||||
}
|
||||
|
||||
public void setTecnico(TecnicoHSToPrint tecnico)
|
||||
{
|
||||
this.tecnico = tecnico;
|
||||
}
|
||||
|
||||
public TecnicoHSToPrint getTecnicoSuperior() {
|
||||
return tecnicoSuperior;
|
||||
}
|
||||
|
||||
public void setTecnicoSuperior(TecnicoHSToPrint tecnicoSuperior) {
|
||||
this.tecnicoSuperior = tecnicoSuperior;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
package siprp.planoactuacao.print;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
|
||||
public class PostoToPrint
|
||||
implements PrintableInterface
|
||||
{
|
||||
protected String designacao;
|
||||
|
||||
public PostoToPrint( String designacao )
|
||||
{
|
||||
this.designacao = designacao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toJdomElement()
|
||||
throws Exception
|
||||
{
|
||||
Element postoElement = new Element( "posto" );
|
||||
Element designacaoElement = new Element( "designacao" );
|
||||
designacaoElement.setText( designacao );
|
||||
postoElement.addContent( designacaoElement );
|
||||
return postoElement;
|
||||
}
|
||||
|
||||
public String getDesignacao()
|
||||
{
|
||||
return designacao;
|
||||
}
|
||||
|
||||
public void setDesignacao( String designacao )
|
||||
{
|
||||
this.designacao = designacao;
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
package siprp.planoactuacao.print;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
public interface PrintableInterface
|
||||
{
|
||||
public Element toJdomElement() throws Exception;
|
||||
}
|
||||
@ -1,188 +0,0 @@
|
||||
package siprp.planoactuacao.print;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
public class RiscoToPrint
|
||||
implements PrintableInterface
|
||||
{
|
||||
protected String descricao;
|
||||
protected String valor;
|
||||
protected Vector<MedidaToPrint> medidas;
|
||||
protected String responsavel;
|
||||
protected String recursos;
|
||||
protected DataToPrint dataPrevistaInicio;
|
||||
protected DataToPrint dataPrevistaConclusao;
|
||||
protected String parecerDl;
|
||||
protected String parecerDns;
|
||||
protected String verificacaoSiprp;
|
||||
protected Integer valorQuantitativo;
|
||||
protected String valorQualitativo;
|
||||
|
||||
public RiscoToPrint( String descricao, String valor,
|
||||
Vector<MedidaToPrint> medidas, String responsavel, String recursos,
|
||||
DataToPrint dataPrevistaInicio, DataToPrint dataPrevistaConclusao,
|
||||
String parecerDl, String parecerDns, String verificacaoSiprp, Integer valorQuantitativo, String valorQualitativo )
|
||||
{
|
||||
super();
|
||||
this.descricao = descricao;
|
||||
this.valor = valor;
|
||||
this.medidas = medidas;
|
||||
this.responsavel = responsavel;
|
||||
this.recursos = recursos;
|
||||
this.dataPrevistaInicio = dataPrevistaInicio;
|
||||
this.dataPrevistaConclusao = dataPrevistaConclusao;
|
||||
this.parecerDl = parecerDl;
|
||||
this.parecerDns = parecerDns;
|
||||
this.verificacaoSiprp = verificacaoSiprp;
|
||||
this.valorQuantitativo = valorQuantitativo;
|
||||
this.valorQualitativo = valorQualitativo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toJdomElement() throws Exception
|
||||
{
|
||||
Element riscoElement = new Element( "risco" );
|
||||
Element descricaoElement = new Element( "descricao" );
|
||||
descricaoElement.setText( descricao );
|
||||
riscoElement.addContent( descricaoElement );
|
||||
Element valorElement = new Element( "valor" );
|
||||
valorElement.setText( valor != null ? valor.toString() : " " );
|
||||
riscoElement.addContent( valorElement );
|
||||
for( MedidaToPrint medida : medidas )
|
||||
{
|
||||
riscoElement.addContent( medida.toJdomElement() );
|
||||
}
|
||||
Element responsavelElement = new Element( "responsavel" );
|
||||
responsavelElement.setText( responsavel );
|
||||
riscoElement.addContent( responsavelElement );
|
||||
Element recursosElement = new Element( "recursos" );
|
||||
recursosElement.setText( recursos );
|
||||
riscoElement.addContent( recursosElement );
|
||||
if( dataPrevistaInicio != null )
|
||||
{
|
||||
riscoElement.addContent( dataPrevistaInicio.toJdomElement() );
|
||||
}
|
||||
if( dataPrevistaConclusao != null )
|
||||
{
|
||||
riscoElement.addContent( dataPrevistaConclusao.toJdomElement() );
|
||||
}
|
||||
Element parecerDlElement = new Element( "parecer-dl" );
|
||||
parecerDlElement.setText( parecerDl );
|
||||
riscoElement.addContent( parecerDlElement );
|
||||
Element parecerDnsElement = new Element( "parecer-dns" );
|
||||
parecerDnsElement.setText( parecerDns );
|
||||
riscoElement.addContent( parecerDnsElement );
|
||||
Element verificacaoSiprpElement = new Element( "verificacao-siprp" );
|
||||
verificacaoSiprpElement.setText( verificacaoSiprp );
|
||||
riscoElement.addContent( verificacaoSiprpElement );
|
||||
return riscoElement;
|
||||
}
|
||||
|
||||
public String getDescricao()
|
||||
{
|
||||
return descricao;
|
||||
}
|
||||
|
||||
public void setDescricao( String descricao )
|
||||
{
|
||||
this.descricao = descricao;
|
||||
}
|
||||
|
||||
public String getValor()
|
||||
{
|
||||
return valor;
|
||||
}
|
||||
|
||||
public void setValor( String valor )
|
||||
{
|
||||
this.valor = valor;
|
||||
}
|
||||
|
||||
public Vector<MedidaToPrint> getMedidas()
|
||||
{
|
||||
return medidas;
|
||||
}
|
||||
|
||||
public void setMedidas( Vector<MedidaToPrint> medidas )
|
||||
{
|
||||
this.medidas = medidas;
|
||||
}
|
||||
|
||||
public void addMedida( MedidaToPrint medida )
|
||||
{
|
||||
medidas.add( medida );
|
||||
}
|
||||
|
||||
public String getResponsavel()
|
||||
{
|
||||
return responsavel;
|
||||
}
|
||||
|
||||
public void setResponsavel( String responsavel )
|
||||
{
|
||||
this.responsavel = responsavel;
|
||||
}
|
||||
|
||||
public String getRecursos()
|
||||
{
|
||||
return recursos;
|
||||
}
|
||||
|
||||
public void setRecursos( String recursos )
|
||||
{
|
||||
this.recursos = recursos;
|
||||
}
|
||||
|
||||
public DataToPrint getDataPrevistaInicio()
|
||||
{
|
||||
return dataPrevistaInicio;
|
||||
}
|
||||
|
||||
public void setDataPrevistaInicio( DataToPrint dataPrevistaInicio )
|
||||
{
|
||||
this.dataPrevistaInicio = dataPrevistaInicio;
|
||||
}
|
||||
|
||||
public DataToPrint getDataPrevistaConclusao()
|
||||
{
|
||||
return dataPrevistaConclusao;
|
||||
}
|
||||
|
||||
public void setDataPrevistaConclusao( DataToPrint dataPrevistaConclusao )
|
||||
{
|
||||
this.dataPrevistaConclusao = dataPrevistaConclusao;
|
||||
}
|
||||
|
||||
public String getParecerDl()
|
||||
{
|
||||
return parecerDl;
|
||||
}
|
||||
|
||||
public void setParecerDl( String parecerDl )
|
||||
{
|
||||
this.parecerDl = parecerDl;
|
||||
}
|
||||
|
||||
public String getParecerDns()
|
||||
{
|
||||
return parecerDns;
|
||||
}
|
||||
|
||||
public void setParecerDns( String parecerDns )
|
||||
{
|
||||
this.parecerDns = parecerDns;
|
||||
}
|
||||
|
||||
public String getVerificacaoSiprp()
|
||||
{
|
||||
return verificacaoSiprp;
|
||||
}
|
||||
|
||||
public void setVerificacaoSiprp( String verificacaoSiprp )
|
||||
{
|
||||
this.verificacaoSiprp = verificacaoSiprp;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,63 +0,0 @@
|
||||
package siprp.planoactuacao.print;
|
||||
|
||||
public class StringConverterUtils
|
||||
{
|
||||
public static String stripHTMLTags( String text )
|
||||
{
|
||||
String output = text;
|
||||
|
||||
output = output.replaceAll( "<br>", "" );
|
||||
output = output.replaceAll( "<p>", "" );
|
||||
output = output.replaceAll( "</p>", "" );
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
public static String convertHTMLToText( String text )
|
||||
{
|
||||
String output = text;
|
||||
|
||||
output = output.replaceAll( "À", "À" );
|
||||
output = output.replaceAll( "Á", "Á" );
|
||||
output = output.replaceAll( "Â", "Â" );
|
||||
output = output.replaceAll( "Ã", "Ã" );
|
||||
output = output.replaceAll( "Ç", "Ç" );
|
||||
output = output.replaceAll( "È", "È" );
|
||||
output = output.replaceAll( "É", "É" );
|
||||
output = output.replaceAll( "Ó", "Ó" );
|
||||
output = output.replaceAll( "Ò", "Ò" );
|
||||
|
||||
output = output.replaceAll( "Ê", "Ê" );
|
||||
output = output.replaceAll( "Ì", "Ì" );
|
||||
output = output.replaceAll( "Í", "Í" );
|
||||
output = output.replaceAll( "Î", "Î" );
|
||||
output = output.replaceAll( "Ô", "Ô" );
|
||||
output = output.replaceAll( "Õ", "Õ" );
|
||||
output = output.replaceAll( "Ù", "Ù" );
|
||||
output = output.replaceAll( "Ú", "Ú" );
|
||||
output = output.replaceAll( "Û", "Û" );
|
||||
|
||||
output = output.replaceAll( "à", "à" );
|
||||
output = output.replaceAll( "á", "á" );
|
||||
output = output.replaceAll( "â", "â" );
|
||||
output = output.replaceAll( "ã", "ã" );
|
||||
output = output.replaceAll( "ç", "ç" );
|
||||
output = output.replaceAll( "è", "è" );
|
||||
output = output.replaceAll( "é", "é" );
|
||||
output = output.replaceAll( "ê", "ê" );
|
||||
output = output.replaceAll( "ì", "ì" );
|
||||
output = output.replaceAll( "í", "í" );
|
||||
output = output.replaceAll( "î", "î" );
|
||||
output = output.replaceAll( "ò", "ò" );
|
||||
output = output.replaceAll( "ó", "ó" );
|
||||
output = output.replaceAll( "ô", "ô" );
|
||||
output = output.replaceAll( "õ", "õ" );
|
||||
output = output.replaceAll( "ù", "ù" );
|
||||
output = output.replaceAll( "ú", "ú" );
|
||||
output = output.replaceAll( "û", "û" );
|
||||
|
||||
output = output.replaceAll( " ", " " );
|
||||
return output;
|
||||
}
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
package siprp.planoactuacao.print;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
public class TecnicoHSToPrint
|
||||
implements PrintableInterface
|
||||
{
|
||||
protected Integer id;
|
||||
protected String nome;
|
||||
protected String cap;
|
||||
protected String formacao;
|
||||
protected String assinatura;
|
||||
protected boolean superior;
|
||||
|
||||
public TecnicoHSToPrint( Integer id, String nome, String cap,
|
||||
String formacao, String assinatura, boolean superior )
|
||||
{
|
||||
super();
|
||||
this.id = id;
|
||||
this.nome = nome;
|
||||
this.cap = cap;
|
||||
this.formacao = formacao;
|
||||
this.assinatura = assinatura;
|
||||
this.superior = superior;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toJdomElement() throws Exception
|
||||
{
|
||||
Element tecnicoHSElement = new Element( "tecnico" + ( superior ? "-superior" : "" ) + "-hs" );
|
||||
Element nomeElement = new Element( "nome" );
|
||||
nomeElement.setText( nome );
|
||||
tecnicoHSElement.addContent( nomeElement );
|
||||
Element capElement = new Element( "cap" );
|
||||
capElement.setText( cap );
|
||||
tecnicoHSElement.addContent( capElement );
|
||||
Element formacaoElement = new Element( "formacao" );
|
||||
formacaoElement.setText( formacao );
|
||||
tecnicoHSElement.addContent( formacaoElement );
|
||||
Element assinaturaElement = new Element( "assinatura" );
|
||||
assinaturaElement.setText( "" + assinatura );
|
||||
tecnicoHSElement.addContent( assinaturaElement );
|
||||
return tecnicoHSElement;
|
||||
}
|
||||
}
|
||||
@ -1,81 +0,0 @@
|
||||
package siprp.planoactuacao.print;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import shst.util.fop.PDFCreator;
|
||||
|
||||
import com.evolute.utils.xml.XSLTransformer;
|
||||
|
||||
public class TestPrint
|
||||
{
|
||||
public static void main( String args[] )
|
||||
throws Exception
|
||||
{
|
||||
new TestPrint().test();
|
||||
}
|
||||
|
||||
public void test()
|
||||
throws Exception
|
||||
{
|
||||
// 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();
|
||||
|
||||
for( int n = 1; n <= 7; n++ )
|
||||
{
|
||||
byte pdf[] = new PlanoActuacaoPDFCreator().createPDF( n, false );
|
||||
FileOutputStream fos = new FileOutputStream( "/home/fpalma/Desktop/" + n + ".pdf" );
|
||||
fos.write( pdf );
|
||||
fos.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void createPDFFile( byte fo[], String path )
|
||||
throws Exception
|
||||
{
|
||||
byte pdf[] = PDFCreator.getPDFCreator().createPdfFromFo( fo );
|
||||
FileOutputStream fos = new FileOutputStream( path );
|
||||
fos.write( pdf );
|
||||
fos.close();
|
||||
}
|
||||
|
||||
public byte[] applyTemplate( String template, String data )
|
||||
throws Exception
|
||||
{
|
||||
InputStream xsl = getClass().getClassLoader().getResourceAsStream( template );
|
||||
InputStream xml = getClass().getClassLoader().getResourceAsStream( data );
|
||||
return( applyTemplate( xsl, xml ) );
|
||||
}
|
||||
|
||||
public byte[] applyTemplate( InputStream xsl, InputStream dataStream )
|
||||
throws Exception
|
||||
{
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
XSLTransformer.getXSLTransformer().transform( dataStream, xsl, baos );
|
||||
return baos.toByteArray();
|
||||
}
|
||||
}
|
||||