forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@977 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
14dd99e131
commit
87c95b9bee
@ -0,0 +1,17 @@
|
|||||||
|
package siprp.higiene.relatorio.print;
|
||||||
|
|
||||||
|
public interface DBConstants
|
||||||
|
{
|
||||||
|
|
||||||
|
// 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 LOCAL_DBMANAGER = "LOCAL DBMANAGER";
|
||||||
|
}
|
||||||
@ -1,33 +0,0 @@
|
|||||||
package siprp.higiene.relatorio.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 = RelatorioPrintDataProvider.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.higiene.relatorio.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 ] );
|
|
||||||
|
|
||||||
RelatorioPrintDataProvider.getProvider( true ).updateLogotipo( id, data );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
package siprp.higiene.relatorio.print;
|
||||||
|
|
||||||
|
import siprp.SingletonConstants;
|
||||||
|
|
||||||
|
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 RelatorioDBInit
|
||||||
|
{
|
||||||
|
public static void initDB()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
// if( web )
|
||||||
|
// {
|
||||||
|
String url = DBConstants.LOCAL_URL;
|
||||||
|
String user = DBConstants.LOCAL_USER;
|
||||||
|
String pwd = DBConstants.LOCAL_PASSWORD;
|
||||||
|
DBManager localManager = new JDBCManager( url, user, pwd, 10, 8, 8, null );
|
||||||
|
Singleton.setInstance( DBConstants.LOCAL_DBMANAGER, localManager );
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// Singleton.setInstance( DBConstants.LOCAL_DBMANAGER, Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ) );
|
||||||
|
// }
|
||||||
|
|
||||||
|
Insert.setDefaultKeyRetriever( PostgresqlAutoKeyRetriever.RETRIEVER );
|
||||||
|
UnicodeChecker.setUseDoubleSlash( true );
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue