forked from Coded/SIPRP
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							108 lines
						
					
					
						
							2.6 KiB
						
					
					
				
			
		
		
	
	
							108 lines
						
					
					
						
							2.6 KiB
						
					
					
				/*
 | 
						|
 * PrestadoresDataProvider.java
 | 
						|
 *
 | 
						|
 * Created on February 2, 2007, 9:53 AM
 | 
						|
 *
 | 
						|
 * To change this template, choose Tools | Template Manager
 | 
						|
 * and open the template in the editor.
 | 
						|
 */
 | 
						|
 | 
						|
package siprp.medicina.prestadores;
 | 
						|
 | 
						|
import com.evolute.utils.Singleton;
 | 
						|
import com.evolute.utils.arrays.Object2DArray;
 | 
						|
import com.evolute.utils.arrays.Virtual2DArray;
 | 
						|
import com.evolute.utils.db.DBManager;
 | 
						|
import com.evolute.utils.db.Executer;
 | 
						|
import com.evolute.utils.sql.Field;
 | 
						|
import com.evolute.utils.sql.Select;
 | 
						|
import com.evolute.utils.ui.search.SearchDialog;
 | 
						|
import com.evolute.utils.ui.search.SearchExecuter;
 | 
						|
 | 
						|
/**
 | 
						|
 *
 | 
						|
 * @author fpalma
 | 
						|
 */
 | 
						|
public class PrestadoresDataProvider
 | 
						|
		implements SearchExecuter
 | 
						|
{
 | 
						|
	private static final Object LOCK = new Object();
 | 
						|
	private static PrestadoresDataProvider instance = null;
 | 
						|
	
 | 
						|
	private static final String SEARCH_TITLE = "Procurar prestadores";
 | 
						|
	private static final String SEARCH_COLUMNS[] = 
 | 
						|
			new String[]{ "Designa\u00e7\u00e3o", "Servi\u00e7os" };
 | 
						|
	
 | 
						|
	private Executer EXECUTER;
 | 
						|
	
 | 
						|
	/** Creates a new instance of PrestadoresDataProvider */
 | 
						|
	public PrestadoresDataProvider()
 | 
						|
		throws Exception
 | 
						|
	{
 | 
						|
		DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
 | 
						|
		EXECUTER = dbm.getSharedExecuter( this );
 | 
						|
	}
 | 
						|
	
 | 
						|
	public static PrestadoresDataProvider getProvider()
 | 
						|
		throws Exception
 | 
						|
	{
 | 
						|
		synchronized( LOCK )
 | 
						|
		{
 | 
						|
			if( instance == null )
 | 
						|
			{
 | 
						|
				instance = new PrestadoresDataProvider();
 | 
						|
			}
 | 
						|
		}
 | 
						|
		return instance;
 | 
						|
	}
 | 
						|
 | 
						|
	public boolean hasDetails()
 | 
						|
	{
 | 
						|
		return false;
 | 
						|
	}
 | 
						|
 | 
						|
	public String getSearchTitle()
 | 
						|
	{
 | 
						|
		return SEARCH_TITLE;
 | 
						|
	}
 | 
						|
 | 
						|
	public String[] getColumnNames()
 | 
						|
	{
 | 
						|
		return SEARCH_COLUMNS;
 | 
						|
	}
 | 
						|
 | 
						|
	public void showDetails(SearchDialog dialog, Object o) throws Exception
 | 
						|
	{
 | 
						|
	}
 | 
						|
 | 
						|
	public Virtual2DArray search(String pattern) throws Exception
 | 
						|
	{
 | 
						|
		pattern = pattern.trim().toLowerCase();
 | 
						|
		pattern = pattern.replace( ' ', '%' );
 | 
						|
		Select select = 
 | 
						|
				new Select( new String[]{ "prestadores" },
 | 
						|
							new String[]{ "id", "nome", "faz_consultas", "faz_ecds", "nome_plain" },
 | 
						|
							new Field( "nome_plain" ).isLike( "%" + pattern + "%" ),
 | 
						|
							new String[]{ "nome_plain" },
 | 
						|
							null );
 | 
						|
		Virtual2DArray array = EXECUTER.executeQuery( select );
 | 
						|
		Object data[][] = new Object[ array.columnLength() ][ 3 ];
 | 
						|
		for( int n = 0; n < data.length; n++ )
 | 
						|
		{
 | 
						|
			data[ n ][ 0 ] = array.get( n, 0 );
 | 
						|
			data[ n ][ 1 ] = array.get( n, 1 );
 | 
						|
			String str = "";
 | 
						|
			if( "y".equals( array.get( n, 2 ) ) )
 | 
						|
			{
 | 
						|
				str += "consultas";
 | 
						|
			}
 | 
						|
			if( "y".equals( array.get( n, 3 ) ) )
 | 
						|
			{
 | 
						|
				str += ( str.length() > 0 ? ", " : "" ) + "ecds";
 | 
						|
			}
 | 
						|
			data[ n ][ 2 ] = str;
 | 
						|
		}
 | 
						|
		return new Object2DArray( data );
 | 
						|
	}
 | 
						|
}
 |