diff --git a/trunk/SIPRPSoft/src/siprp/update/updates/V11_8_To_V11_9.java b/trunk/SIPRPSoft/src/siprp/update/updates/V11_8_To_V11_9.java new file mode 100644 index 00000000..2853623f --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/update/updates/V11_8_To_V11_9.java @@ -0,0 +1,83 @@ +package siprp.update.updates; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; + +import javax.imageio.ImageIO; + +import com.evolute.utils.Singleton; +import com.evolute.utils.arrays.Virtual2DArray; +import com.evolute.utils.db.DBManager; +import com.evolute.utils.db.Executer; +import com.evolute.utils.sql.Assignment; +import com.evolute.utils.sql.BlobUpdate; +import com.evolute.utils.sql.Field; +import com.evolute.utils.sql.Insert; +import com.evolute.utils.sql.Select2; + +public class V11_8_To_V11_9 implements siprp.update.Update +{ + + public V11_8_To_V11_9() + { + } + + public String []listChanges() + { + return new String[]{ + "A actualizar informacao dos tecnicos de higiene e seguranca" + }; + } + + public double getStartVersion() + { + return 11.8; + } + + public double getEndVersion() + { + return 11.9; + } + + public void doUpdate() throws Exception + { + DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); + Executer executer = dbm.getSharedExecuter(); + + Integer assDavidID = null; + String assDavid = "Assinatura(David Afonso)"; + BufferedImage assDavidImage = ImageIO.read( getClass().getClassLoader().getResourceAsStream( "siprp/update/updates/V11_8_To_V11_9_David_Afonso.png" ) ); + ByteArrayOutputStream assDavidBytesStream = new ByteArrayOutputStream(); + ImageIO.write( assDavidImage, "PNG", assDavidBytesStream ); + if( assDavidImage == null || assDavidBytesStream.size() == 0 ) + { + throw new Exception("Erro ao ler assinatura: " + assDavid ); + } + Insert insertQuery = new Insert( "image", new Assignment[]{ + new Assignment(new Field("name"),assDavid) + } ); + Virtual2DArray array = executer.executeQuery( insertQuery ); + Select2 selectQuery = new Select2(new String[]{"image"},null,null,new String[]{"id"},new Field("name").isEqual( assDavid ),null,null,null,null); + array = executer.executeQuery( selectQuery ); + if( array.columnLength() == 1 ) + { + assDavidID = (Integer) array.get( 0, 0 ); + } + if( assDavidID == null ) + { + throw new Exception("Erro ao inserir assinatura: " + assDavid ); + } + BlobUpdate blobUpdate = new BlobUpdate("image","image_data",assDavidBytesStream.toByteArray(),new Field("id").isEqual( assDavidID ) ); + executer.executeQuery( blobUpdate ); + com.evolute.utils.sql.Update update = new com.evolute.utils.sql.Update( + "update marcacoes_tecnicos_hst set cap='em emiss\u00e3o', formacao='', assinatura=" + assDavidID + " where id = 3; " + ); + executer.executeQuery( update ); + } + + public String toString() + { + return "v" + getStartVersion() + " para v" + getEndVersion(); + } + +} diff --git a/trunk/SIPRPSoft/src/siprp/update/updates/V11_8_To_V11_9_David_Afonso.png b/trunk/SIPRPSoft/src/siprp/update/updates/V11_8_To_V11_9_David_Afonso.png new file mode 100644 index 00000000..7e2eb05b Binary files /dev/null and b/trunk/SIPRPSoft/src/siprp/update/updates/V11_8_To_V11_9_David_Afonso.png differ