forked from Coded/SIPRP
				
			no message
	
		
	
				
					
				
			git-svn-id: https://svn.coded.pt/svn/SIPRP@336 bb69d46d-e84e-40c8-a05a-06db0d6337410'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
							parent
							
								
									eef9ba9686
								
							
						
					
					
						commit
						249fade295
					
				| @ -0,0 +1,90 @@ | |||||||
|  | /* | ||||||
|  |  * ProcessoDataProvider.java | ||||||
|  |  * | ||||||
|  |  * Created on March 20, 2007, 5:14 PM | ||||||
|  |  * | ||||||
|  |  * To change this template, choose Tools | Template Manager | ||||||
|  |  * and open the template in the editor. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package siprp.medicina.processo; | ||||||
|  | 
 | ||||||
|  | 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.jdo.JDOProvider; | ||||||
|  | import com.evolute.utils.sql.Expression; | ||||||
|  | import com.evolute.utils.sql.Field; | ||||||
|  | import com.evolute.utils.sql.Select; | ||||||
|  | import com.evolute.utils.sql.Select2; | ||||||
|  | import siprp.medicina.processo.data.MarcacoesProcessoData; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * | ||||||
|  |  * @author fpalma | ||||||
|  |  */ | ||||||
|  | public class ProcessoDataProvider | ||||||
|  | { | ||||||
|  | 	private static final Object LOCK = new Object(); | ||||||
|  | 	private static ProcessoDataProvider instance = null; | ||||||
|  | 	private Executer EXECUTER; | ||||||
|  | 	private JDOProvider JDO; | ||||||
|  | 	 | ||||||
|  | 	/** Creates a new instance of ProcessoDataProvider */ | ||||||
|  | 	public ProcessoDataProvider() | ||||||
|  | 		throws Exception | ||||||
|  | 	{ | ||||||
|  | 		DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); | ||||||
|  | 		EXECUTER = dbm.getSharedExecuter( this ); | ||||||
|  | 		JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public static ProcessoDataProvider getProvider() | ||||||
|  | 		throws Exception | ||||||
|  | 	{ | ||||||
|  | 		synchronized( LOCK ) | ||||||
|  | 		{ | ||||||
|  | 			if( instance == null ) | ||||||
|  | 			{ | ||||||
|  | 				instance = new ProcessoDataProvider(); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return instance; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public Integer[] getIDsProcessosByTrabalhador( Integer trabalhadorID ) | ||||||
|  | 		throws Exception | ||||||
|  | 	{ | ||||||
|  | 		Select select = | ||||||
|  | 				new Select2( new String[]{ "marcacoes_processo" }, | ||||||
|  | 								new Integer[ 0 ], | ||||||
|  | 								new Expression[ 0 ], | ||||||
|  | 								new String[]{ "id", "data_inicio" }, | ||||||
|  | 								new Field( "marcacoes_processo.trabalhador_id" ).isEqual( trabalhadorID ), | ||||||
|  | 								new String[]{ "data_inicio" }, | ||||||
|  | 								null, | ||||||
|  | 								null, | ||||||
|  | 								null ); | ||||||
|  | 		Virtual2DArray array = EXECUTER.executeQuery( select ); | ||||||
|  | 		Integer ids[] = new Integer[ array.columnLength() ]; | ||||||
|  | 		for( int n = 0; n < ids.length; n++ ) | ||||||
|  | 		{ | ||||||
|  | 			ids[ n ] = ( Integer ) array.get( n, 0 ); | ||||||
|  | 		} | ||||||
|  | 		return ids; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public MarcacoesProcessoData getProcessoByID( Integer id ) | ||||||
|  | 		throws Exception | ||||||
|  | 	{ | ||||||
|  | 		return ( MarcacoesProcessoData ) JDO.load( MarcacoesProcessoData.class, id ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public void saveProcesso( MarcacoesProcessoData processo ) | ||||||
|  | 		throws Exception | ||||||
|  | 	{ | ||||||
|  | 		processo.save(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
					Loading…
					
					
				
		Reference in new issue