forked from Coded/SIPRP
				
			git-svn-id: https://svn.coded.pt/svn/SIPRP@1186 bb69d46d-e84e-40c8-a05a-06db0d633741
	
		
	
				
					
				
			
							parent
							
								
									33109332ff
								
							
						
					
					
						commit
						5ee49556d6
					
				| @ -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(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
| After Width: | Height: | Size: 11 KiB | 
					Loading…
					
					
				
		Reference in new issue