package ca.ualberta.cs.oneclick_cookbook;

import java.util.List;

//import android.provider.MediaStore.Images;

public class Recipe {

	private String name = "";
	private Pantry ingredients = null;
	private String steps = "";
    // private List<Images> pictures = null;
	private int promotions = 0;
	private int demotions = 0;
	
	//for online IDing
	private String id;

	public Recipe() {
		
	}
	public Recipe(String name, Pantry ingredients, String steps) {
		this.name = name;
		this.ingredients = ingredients;
		this.steps = steps;
		this.promotions = 0;
		this.demotions = 0;
		
		//Auto-Generate ID tag. . . somehow.
		this.id = "5202";
	}
	
	/*
	 * 
	 */
	public String getID() {
		return this.id;
	}

	public void changeName(String newName) {
		this.name = newName;
		return;
	}

	public String getName() {
		return this.name;
	}

	public void changeSteps(String newSteps) {
		this.steps = newSteps;
		return;
	}

	public String getSteps() {
		return this.steps;
	}

	public void modifyIngredients(Pantry newIngredients) {
		this.ingredients = newIngredients;
		return;
	}

	public Pantry getIngredients() {
		return this.ingredients;
	}

	public void promote() {
		this.promotions += 1;
		return;
	}

	public void demote() {
		this.demotions += 1;
		return;
	}

	public int getRating() {
		int rating = this.promotions - this.demotions;
		return rating;
	}

	// Turns the recipe into a string
	public String toString() {
		String localName = this.name;
		String localIngredients = this.ingredients.toString();
		
		if (localIngredients.length() > 20) {
			localIngredients = localIngredients.substring(0, 20) + "...";
		}
		
		if (localName.length() > 20) {
			localName = localName.substring(0, 20) + "...";
		}
		
		return "Title: " + localName + "\nIngredients: " + localIngredients;
	}

	// Checks the recipe for valid info
	public int isValidInfo() {

		if (name == null || steps == null  || ingredients == null ) {
			return Constants.NULL_VALUE;
		}

		else if (name.equals("") || steps.equals("") || ingredients.isEmpty()) {
			return Constants.ZERO_VALUE;
		}

		else {
			return ingredients.isValidInfo();
		}
	}
	
	/**
	 * Posts 'this' recipe to elasticsearch
	 */
	public void postToES() {
		
	}
}

/**
 * @author	Chris Serafin, Peter Maidens, Ken "Mike" Armstrong, Kimberly Kramer
 * 
 * This class is the class that is used to store the recipes that are submitted
 * by users. It contains all the infromation that is needed for the recipes.
 */

package ca.ualberta.cs.oneclick_cookbook;

import java.util.List;

//import android.provider.MediaStore.Images;

public class Recipe {

	private String name = "";
	private Pantry ingredients = null;
	private String steps = "";
    // private List<Images> pictures = null;
	private int promotions = 0;
	private int demotions = 0;
	
	//for online IDing
	private String id;

	public Recipe() {
		
	}
	
	/**
	 * Constructor
	 * @param name Name of the recipe
	 * @param ingredients Actually a Pantry Class Object that is used as the list of ingredients
	 * @param steps A string that outlines the steps requried in cooking the recipe
	 */
	public Recipe(String name, Pantry ingredients, String steps) {
		this.name = name;
		this.ingredients = ingredients;
		this.steps = steps;
		this.promotions = 0;
		this.demotions = 0;
		
		//Auto-Generate ID tag. . . somehow.
		this.id = "5202";
	}
	
	public String getID() {
		return this.id;
	}

	public void changeName(String newName) {
		this.name = newName;
		return;
	}

	public String getName() {
		return this.name;
	}

	public void changeSteps(String newSteps) {
		this.steps = newSteps;
		return;
	}

	public String getSteps() {
		return this.steps;
	}

	public void modifyIngredients(Pantry newIngredients) {
		this.ingredients = newIngredients;
		return;
	}

	public Pantry getIngredients() {
		return this.ingredients;
	}

	public void promote() {
		this.promotions += 1;
		return;
	}

	public void demote() {
		this.demotions += 1;
		return;
	}

	public int getRating() {
		int rating = this.promotions - this.demotions;
		return rating;
	}

	/**
	 * Turns the recipe into a String.
	 * @return String The recipe that has been reformated into a string.
	 */
	public String toString() {
		String localName = this.name;
		String localIngredients = this.ingredients.toString();
		
		if (localIngredients.length() > 20) {
			localIngredients = localIngredients.substring(0, 20) + "...";
		}
		
		if (localName.length() > 20) {
			localName = localName.substring(0, 20) + "...";
		}
		
		return "Title: " + localName + "\nIngredients: " + localIngredients;
	}

	// Checks the recipe for valid info
	public int isValidInfo() {

		if (name == null || steps == null  || ingredients == null ) {
			return Constants.NULL_VALUE;
		}

		else if (name.equals("") || steps.equals("") || ingredients.isEmpty()) {
			return Constants.ZERO_VALUE;
		}

		else {
			return ingredients.isValidInfo();
		}
	}
	
	/**
	 * Posts 'this' recipe to elasticsearch
	 * <p>
	 * Not Currently Implemented
	 */
	public void postToES() {
		
	}
}

Update Recipe.java