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.
		
		
		
		
		
			
		
			
				
					
					
						
							109 lines
						
					
					
						
							3.3 KiB
						
					
					
				
			
		
		
	
	
							109 lines
						
					
					
						
							3.3 KiB
						
					
					
				/*
 | 
						|
 * LembretesDataProvider.java
 | 
						|
 *
 | 
						|
 * Created on February 5, 2007, 6:09 PM
 | 
						|
 *
 | 
						|
 * To change this template, choose Tools | Template Manager
 | 
						|
 * and open the template in the editor.
 | 
						|
 */
 | 
						|
 | 
						|
package siprp.lembretes;
 | 
						|
 | 
						|
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.Field;
 | 
						|
import com.evolute.utils.sql.Insert;
 | 
						|
import com.evolute.utils.sql.Select;
 | 
						|
import java.util.Date;
 | 
						|
 | 
						|
/**
 | 
						|
 *
 | 
						|
 * @author lflores
 | 
						|
 */
 | 
						|
public class LembretesDataProvider
 | 
						|
{
 | 
						|
	private static final Object LOCK = new Object();
 | 
						|
	private static LembretesDataProvider instance = null;
 | 
						|
	
 | 
						|
	private Executer EXECUTER;
 | 
						|
	
 | 
						|
	/** Creates a new instance of LembretesDataProvider */
 | 
						|
	public LembretesDataProvider()
 | 
						|
		throws Exception
 | 
						|
	{
 | 
						|
		DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
 | 
						|
		EXECUTER = dbm.getSharedExecuter( this );
 | 
						|
	}
 | 
						|
	
 | 
						|
	public static LembretesDataProvider getProvider()
 | 
						|
		throws Exception
 | 
						|
	{
 | 
						|
		synchronized( LOCK )
 | 
						|
		{
 | 
						|
			if( instance == null )
 | 
						|
			{
 | 
						|
				instance = new LembretesDataProvider();
 | 
						|
			}
 | 
						|
		}
 | 
						|
		return instance;
 | 
						|
	}
 | 
						|
	
 | 
						|
	public TipoLembrete[] getTiposLembrete()
 | 
						|
		throws Exception
 | 
						|
	{
 | 
						|
		Select select = 
 | 
						|
				new Select( new String[]{ "lembretes_tipos" },
 | 
						|
							new String[]{ "id", "codigo", "descricao", "ordem" },
 | 
						|
							new Field( "activo" ).isEqual( "y" ),
 | 
						|
							new String[]{ "ordem" },
 | 
						|
							null );
 | 
						|
		Virtual2DArray array = EXECUTER.executeQuery( select );
 | 
						|
		TipoLembrete tipos[] = new TipoLembrete[ array.columnLength() ];
 | 
						|
		for( int n = 0; n < tipos.length; n++ )
 | 
						|
		{
 | 
						|
			Integer id = ( Integer ) array.get( n, 0 );
 | 
						|
			String codigo = ( String ) array.get( n, 1 );
 | 
						|
			String descricao = ( String ) array.get( n, 2 );
 | 
						|
			Integer ordem = ( Integer ) array.get( n, 3 );
 | 
						|
			tipos[ n ] = new TipoLembrete( id, codigo, descricao, ordem );
 | 
						|
		}
 | 
						|
		return tipos;
 | 
						|
	} 
 | 
						|
	
 | 
						|
	public void criarLembrete( Integer tipoID,
 | 
						|
								Date data,
 | 
						|
								String descricao,
 | 
						|
								String texto,
 | 
						|
								Integer empresaID,
 | 
						|
								Integer estabelecimentoID,
 | 
						|
								Integer trabalhadorID,
 | 
						|
								Integer marcacaoEstabelecimentoID,
 | 
						|
								Integer marcacaoTrabalhadorID,
 | 
						|
								boolean enviarEmail,
 | 
						|
								Integer periodicidadeDias,
 | 
						|
								Integer periodicidadeMeses )
 | 
						|
		throws Exception
 | 
						|
	{
 | 
						|
		Insert insert = 
 | 
						|
			new Insert( "lembretes",
 | 
						|
						new Assignment[]{
 | 
						|
							new Assignment( new Field( "tipo_id" ), tipoID ),
 | 
						|
							new Assignment( new Field( "data" ), data ),
 | 
						|
							new Assignment( new Field( "descricao" ), descricao ),
 | 
						|
							new Assignment( new Field( "texto" ), texto ),
 | 
						|
							new Assignment( new Field( "empresa_id" ), empresaID ),
 | 
						|
							new Assignment( new Field( "estabelecimento_id" ), estabelecimentoID ),
 | 
						|
							new Assignment( new Field( "trabalhador_id" ), trabalhadorID ),
 | 
						|
							new Assignment( new Field( "marcacao_estabelecimento_id" ), marcacaoEstabelecimentoID ),
 | 
						|
							new Assignment( new Field( "marcacao_trabalhador_id" ), marcacaoTrabalhadorID ),
 | 
						|
							new Assignment( new Field( "enviar_email" ), enviarEmail ? "y" : "n" ),
 | 
						|
							new Assignment( new Field( "periodicidade_dias" ), periodicidadeDias ),
 | 
						|
							new Assignment( new Field( "periodicidade_meses" ), periodicidadeMeses ) } );
 | 
						|
		EXECUTER.executeQuery( insert );
 | 
						|
	}
 | 
						|
	
 | 
						|
}
 |