/* ===================================================================
 * RecipeDao.java
 * 
 * Created Aug 4, 2004 10:30:00 AM
 * 
 * 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: RecipeDao.java 39 2009-05-06 03:30:47Z msqr $
 * ===================================================================
 */

package magoffin.matt.ieat.dao;

import java.util.List;

import magoffin.matt.dao.GenericDao;
import magoffin.matt.ieat.domain.Recipe;
import magoffin.matt.ieat.domain.UiSearchResults;

/**
 * DAO for recipe objects.
 * 
 * @author Matt Magoffin (spamsqr@msqr.us)
 * @version $Revision: 39 $ $Date: 2009-05-06 15:30:47 +1200 (Wed, 06 May 2009) $
 */
public interface RecipeDao extends GenericDao<Recipe, Long> {
	
	/**
	 * Find all recipes with pagination support.
	 * @param pageSize the size of the page for results, or <code>0</code>
	 * for unlimited results
	 * @param pageOffset the page offset, if paging enabled
	 * @return the search results
	 */
	UiSearchResults getAllRecipes(int pageSize, int pageOffset);
	
	/**
	 * Find all recipes using a particular recipe as an ingredient.
	 * 
	 * @param recipeId the recipe to search for
	 * @return list of recipes using the recipe as an ingredient
	 */
	List<Recipe> findRecipesUsingRecipeAsIngredient(Long recipeId);

	/**
	 * Reassign the base for all recipes using a given base.
	 * @param baseId the current baseId
	 * @param newBaseId the new baseId
	 */
	public void reassignBase(Integer baseId, Integer newBaseId);
		
	/**
	 * Reassign the course for all recipes using a given course.
	 * @param courseId the current courseId
	 * @param newCourseId the new courseId
	 */
	public void reassignCourse(Integer courseId, Integer newCourseId);
		
	/**
	 * Reassign the difficulty for all recipes using a given difficulty.
	 * @param difficultyId the current difficultyId
	 * @param newDifficultyId the new difficultyId
	 */
	public void reassignDifficulty(Integer difficultyId, Integer newDifficultyId);
		
	/**
	 * Reassign the ethnicity for all recipes using a given ethnicity.
	 * @param ethnicityId the current ethnicityId
	 * @param newEthnicityId the new ethnicityId
	 */
	public void reassignEthnicity(Integer ethnicityId, Integer newEthnicityId);
		
	/**
	 * Reassign the ingredient for all recipes using a given ingredient.
	 * @param ingredientId the current ingredientId
	 * @param newIngredientId the new ingredientId
	 */
	public void reassignIngredient(Integer ingredientId, Integer newIngredientId);
		
	/**
	 * Reassign the prepTime for all recipes using a given prepTime.
	 * @param prepTimeId the current prepTimeId
	 * @param newPrepTimeId the new prepTimeId
	 */
	public void reassignPrepTime(Integer prepTimeId, Integer newPrepTimeId);	
	
	/**
	 * Index all recipe data, using a callback.
	 * @param callback the callback to handle indexing the data
	 */
	public void index(RecipeIndexCallback callback);

	/**
	 * Callback interface for indexing a recipe object.
	 * 
	 * <p>The {@link RecipeDao#index(RecipeIndexCallback)} method will
	 * call the {@link #handle(RecipeIndexCallbackData)} method for every
	 * Recipe object retrieved to index, passing a {@link RecipeIndexCallbackData}
	 * object representing the data for each Recipe object.</p>
	 */
	public static interface RecipeIndexCallback {
		
		/**
		 * Handle indexing a single Recipe.
		 * @param data the ingredient data to index
		 */
		public void handle(RecipeIndexCallbackData data);
		
		/**
		 * Call when finished.
		 */
		public void finish();
	}
	
	/**
	 * Interface representing Recipe object data returned 
	 * during callback method invocations.
	 */
	public static interface RecipeIndexCallbackData {
		
		/**
		 * Get the Recipe ID.
		 * @return the ID
		 */
		public Long getRecipeId();
		
		/**
		 * Get the recipe's name.
		 * @return the name
		 */
		public String getName();
		
		/**
		 * Get the recipe's excerpt.
		 * @return the excerpt
		 */
		public String getExcerpt();
		
		/**
		 * Get the recipe overall directions.
		 * @return the directions
		 */
		public String getDirections();
		
		/**
		 * Get the recipe step.
		 * @return the step
		 */
		public String getStep();
		
		/**
		 * Get the ingredient ID.
		 * @return the ingredient ID
		 */
		public Integer getIngredientId();
		
		/**
		 * Get the recipe rating.
		 * @return the rating
		 */
		public Short getRating();
		
		/**
		 * Get the user ID of the recipe rating's owner.
		 * @return the rating user ID
		 */
		public Integer getRatingUserId();
		
		/**
		 * Get the recipe comment.
		 * @return the comment
		 */
		public String getComment();
		
		/**
		 * Get the user ID of the recipe comment's owner.
		 * @return the comment user ID
		 */
		public Integer getCommentUserId();
		
		/**
		 * Get the recipe owner's ID.
		 * @return the ID of the recipe owner
		 */
		public Integer getOwnerId();
	}

}
