|
|
|
|
@ -46,11 +46,8 @@ public class V12_0_To_V12_1 implements siprp.update.Update
|
|
|
|
|
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
|
|
|
|
|
Executer executer = dbm.getSharedExecuter();
|
|
|
|
|
|
|
|
|
|
String nomes[] = new String[]{
|
|
|
|
|
"B\u00e1rbara Gon\u00e7alves",
|
|
|
|
|
};
|
|
|
|
|
Integer ids[] = new Integer[]{
|
|
|
|
|
4,
|
|
|
|
|
129,
|
|
|
|
|
};
|
|
|
|
|
String assinaturas[] = new String[]{
|
|
|
|
|
"siprp/update/updates/V12_0_To_V12_1_Barbara_Goncalves.png"
|
|
|
|
|
@ -62,38 +59,16 @@ public class V12_0_To_V12_1 implements siprp.update.Update
|
|
|
|
|
if( assinaturas[ n ] != null )
|
|
|
|
|
{
|
|
|
|
|
Integer assinaturaID = null;
|
|
|
|
|
String assinatura = "Assinatura(" + nomes[ n ] + ")";
|
|
|
|
|
BufferedImage assinaturaImage = ImageIO.read( getClass().getClassLoader().getResourceAsStream(
|
|
|
|
|
assinaturas[ n ] ) );
|
|
|
|
|
ByteArrayOutputStream assinaturaBytesStream = new ByteArrayOutputStream();
|
|
|
|
|
ImageIO.write( assinaturaImage, "PNG", assinaturaBytesStream );
|
|
|
|
|
if( assinaturaImage == null || assinaturaBytesStream.size() == 0 )
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Erro ao ler assinatura: " + assinatura );
|
|
|
|
|
}
|
|
|
|
|
Insert insertQuery = new Insert( "image", new Assignment[]{
|
|
|
|
|
new Assignment(new Field("name"),assinatura)
|
|
|
|
|
} );
|
|
|
|
|
Virtual2DArray array = executer.executeQuery( insertQuery );
|
|
|
|
|
Select2 selectQuery = new Select2(new String[]{"image"},null,null,new String[]{"id"},new Field("name").isEqual( assinatura ),null,null,null,null);
|
|
|
|
|
array = executer.executeQuery( selectQuery );
|
|
|
|
|
if( array.columnLength() == 1 )
|
|
|
|
|
{
|
|
|
|
|
assinaturaID = (Integer) array.get( 0, 0 );
|
|
|
|
|
}
|
|
|
|
|
if( assinaturaID == null )
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Erro ao inserir assinatura: " + assinatura );
|
|
|
|
|
}
|
|
|
|
|
BlobUpdate blobUpdate = new BlobUpdate("image","image_data",assinaturaBytesStream.toByteArray(),new Field("id").isEqual( assinaturaID ) );
|
|
|
|
|
|
|
|
|
|
BlobUpdate blobUpdate = new BlobUpdate("image","image_data",assinaturaBytesStream.toByteArray(),new Field("id").isEqual( ids[ n ] ) );
|
|
|
|
|
executer.executeQuery( blobUpdate );
|
|
|
|
|
assignments.add( new Assignment( "assinatura", assinaturaID ) );
|
|
|
|
|
}
|
|
|
|
|
Update update =
|
|
|
|
|
new Update( "marcacoes_tecnicos_hst",
|
|
|
|
|
assignments.toArray( new Assignment[ assignments.size() ] ),
|
|
|
|
|
new Field( "id" ).isEqual( ids[ n ] ) );
|
|
|
|
|
executer.executeQuery( update );
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|