/* ===================================================================
 * UserDao.java
 * 
 * Created Sep 29, 2004 1:13:33 PM
 * 
 * Copyright (c) 2004 Matt Magoffin (spamsqr@msqr.us)
 * 
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public License as 
 * published by the Free Software Foundation; either version 2 of 
 * the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License 
 * along with this program; if not, write to the Free Software 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 
 * 02111-1307 USA
 * ===================================================================
 * $Id: UserDao.java 4 2009-05-01 03:27:53Z msqr $
 * ===================================================================
 */

package magoffin.matt.ieat.dao;

import java.util.Calendar;
import java.util.List;

import magoffin.matt.dao.GenericDao;
import magoffin.matt.ieat.domain.User;

/**
 * DAO for User objects.
 * 
 * @author Matt Magoffin (spamsqr@msqr.us)
 * @version $Revision: 4 $ $Date: 2009-05-01 15:27:53 +1200 (Fri, 01 May 2009) $
 */

public interface UserDao extends GenericDao<User,Integer> {
	
	/**
	 * Get a User based on its unique login.
	 * @param login the login of the User to get
	 * @return the User
	 */
	public User getUser(String login);
	
	/**
	 * Get a User based on its email.
	 * @param email the email of the User to get
	 * @return the User
	 */
	public User getUserByEmail(String email);
	
	/**
	 * Get all User objects with at least the specified access level.
	 * @param accessLevel the access level
	 * @return list of Users (or empty List if none found)
	 */
	public List<User> getUsersForAccessLevel(int accessLevel);
	
	/**
	 * Delete users from the system that have registered but not 
	 * confirmed that registration.
	 * 
	 * @return the number of users deleted
	 */
	public int removeStaleUserRegistrations();

	/**
	 * Index using a callback.
	 * @param callback the callback
	 */
	public void index(UserIndexCallback callback);

	/**
	 * Callback for indexing users.
	 */
	public static interface UserIndexCallback {

		/**
		 * Handle indexing a single User.
		 * @param data the user data to index
		 */
		public void handle(UserIndexCallbackData data);
	}
	
	/**
	 * The API for user data for indexing.
	 */
	public static interface UserIndexCallbackData {
		
		/**
		 * Get the user ID.
		 * @return the ID
		 */
		public Integer getUserId();
		
		/**
		 * Get the user's name.
		 * @return the name
		 */
		public String getName();
		
		/**
		 * Get the user's email.
		 * @return the email
		 */
		public String getEmail();
		
		/**
		 * Get the user's login.
		 * @return the login
		 */
		public String getLogin();
		
		/**
		 * Get the user's access level.
		 * @return the access level
		 */
		public Integer getAccessLevel();
		
		/**
		 * Get the user's creation date.
		 * @return the creation date
		 */
		public Calendar getCreatedDate();
		
		/**
		 * Get the user's last login date.
		 * @return last login date
		 */
		public Calendar getLastLoginDate();
	}
	
}
