// Path: src/main/java/info/interactivesystems/gamificationengine/entities/rewards/Reward.java
// @Entity
// @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
// @DiscriminatorColumn(name = "REWARD_TYPE", discriminatorType = DiscriminatorType.STRING)
// @JsonIgnoreProperties({ "belongsTo", "goals" })
// public abstract class Reward {
// 
// 	@Id
// 	@GeneratedValue(strategy = GenerationType.IDENTITY)
// 	private int id;
// 
// 	@NotNull
// 	@ManyToOne
// 	private Organisation belongsTo;
// 
// 	private String name;
// 	
// 	private String description;
// 	
// 	private int timeToLive;
// 
// 	@ManyToMany(fetch = FetchType.EAGER, mappedBy = "rewards")
// 	@JsonManagedReference
// 	private List<Goal> goals;
// 
// 	public abstract void addReward(Player player, GoalDAO goalDao, RuleDAO ruleDao);
// 	public abstract void addReward(PlayerGroup group, GoalDAO goalDao, RuleDAO ruleDao);
// 
// 	
// 	/**
// 	 * Gets the id of the reward which was generated by the creation.
// 	 * 
// 	 * @return The reward's id as int.
// 	 */
// 	public int getId() {
// 		return id;
// 	}
// 
// 	/**
// 	 * Sets the id of the reward.
// 	 * 
// 	 * @param id
// 	 *            The id of the reward.
// 	 */
// 	public void setId(int id) {
// 		this.id = id;
// 	}
// 
// 	/**
// 	 * Gets the organisation the reward belongs to.
// 	 * 
// 	 * @return The organisation of the reward as an object. The organisation must not be
// 	 * null.
// 	 */
// 	public Organisation getBelongsTo() {
// 		return belongsTo;
// 	}
// 
// 	/**
// 	 * Sets the organisation to which this reward belongs to.
// 	 * 
// 	 * @param belongsTo
// 	 *            The reward's organisation. This parameter must not be null.
// 	 */
// 	public void setBelongsTo(Organisation belongsTo) {
// 		this.belongsTo = belongsTo;
// 	}
// 
// 	/**
// 	 * Gets the information about how long the reward can exist.
// 	 * 
// 	 * @return The value for how long the reward exist.
// 	 */
// 	public int getTimeToLive() {
// 		return timeToLive;
// 	}
// 
// 	/**
// 	 * Sets the information about how long the reward can exist.
// 	 * 
// 	 * @param timeToLive
// 	 * 			Time how long the reward can exist as int.
// 	 */			
// 	public void setTimeToLive(int timeToLive) {
// 		this.timeToLive = timeToLive;
// 	}
// 
// 	/**
// 	 * This method tests if a reward belongs to a specific organisation. Therefore
// 	 * it is tested if the organisation's API key matchs the reward's API key of the 
// 	 * assigned organisation. 
// 	 * 
// 	 * @param organisation
// 	 * 			The organisation object a reward may belongs to.
// 	 * @return
// 	 *  		Boolean value if the API key of the group is the same 
// 	 * 			of the tested organisation (true) or not (false).
// 	 */
// 	public boolean belongsTo(Organisation organisation) {
// 		return getBelongsTo().getApiKey().equals(organisation.getApiKey());
// 	}
// 
// 	/**
// 	 * Gets the description of an achievement. This could contains for example the 
// 	 * different tasks which have to be completed to get this achievement.
// 	 * 
// 	 * @return the achievement's description
// 	 */
// 	public String getDescription() {
// 		return description;
// 	}
// 
// 	/**
// 	 * Sets the description of an achievement. This contains for example further 
// 	 * information about how the achievement can be earned, like all requirements to 
// 	 * get the achievement or the process to award the achievement.
// 	 * 
// 	 * @param description
// 	 *            of the achievement
// 	 */
// 	public void setDescription(String description) {
// 		this.description = description;
// 	}
// 
// 	/**
// 	 * Gets the name of an achievement which can describe the success in a short
// 	 * way and can be displayed in the application.
// 	 * 
// 	 * @return The achievement's name as String.
// 	 */
// 	public String getName() {
// 		return name;
// 	}
// 
// 	/**
// 	 * Sets the name of an achievement, which can describe the success in a short
// 	 * way and can be displayed in the application.
// 	 * 
// 	 * @param name
// 	 *            The name of the achievement as a String.
// 	 */
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 	
// 	/**
// 	 * Gets the list of goals to which this reward is assigned.
// 	 * 
// 	 * @return All goals with this reward as List of Goals.
// 	 */
// 	public List<Goal> getGoals() {
// 		return goals;
// 	}
// 	
// 	/**
// 	 * Sets the list of goals to which this reward is assigned.
// 	 * 
// 	 * @param goals
// 	 * 			The goals to which this reward should be assigned.
// 	 */
// 	public void setGoals(List<Goal> goals) {
// 		this.goals = goals;
// 	}
// }


import info.interactivesystems.gamificationengine.entities.rewards.Reward;
import java.util.List;
import javax.ejb.Stateless;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
package info.interactivesystems.gamificationengine.dao;




@Named
@Stateless
public class RewardDAO {
	@PersistenceContext(unitName = PersistenceUnit.PROJECT)
	private EntityManager em;

	/**
	 * Stores a new reward in the data base.
	 * 
	 * @param reward
	 * 			The reward which should be stored in the data base.
	 * @return The generated id of the reward. 
	 */
// Path: src/main/java/info/interactivesystems/gamificationengine/entities/rewards/Reward.java
// @Entity
// @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
// @DiscriminatorColumn(name = "REWARD_TYPE", discriminatorType = DiscriminatorType.STRING)
// @JsonIgnoreProperties({ "belongsTo", "goals" })
// public abstract class Reward {
// 
// 	@Id
// 	@GeneratedValue(strategy = GenerationType.IDENTITY)
// 	private int id;
// 
// 	@NotNull
// 	@ManyToOne
// 	private Organisation belongsTo;
// 
// 	private String name;
// 	
// 	private String description;
// 	
// 	private int timeToLive;
// 
// 	@ManyToMany(fetch = FetchType.EAGER, mappedBy = "rewards")
// 	@JsonManagedReference
// 	private List<Goal> goals;
// 
// 	public abstract void addReward(Player player, GoalDAO goalDao, RuleDAO ruleDao);
// 	public abstract void addReward(PlayerGroup group, GoalDAO goalDao, RuleDAO ruleDao);
// 
// 	
// 	/**
// 	 * Gets the id of the reward which was generated by the creation.
// 	 * 
// 	 * @return The reward's id as int.
// 	 */
// 	public int getId() {
// 		return id;
// 	}
// 
// 	/**
// 	 * Sets the id of the reward.
// 	 * 
// 	 * @param id
// 	 *            The id of the reward.
// 	 */
// 	public void setId(int id) {
// 		this.id = id;
// 	}
// 
// 	/**
// 	 * Gets the organisation the reward belongs to.
// 	 * 
// 	 * @return The organisation of the reward as an object. The organisation must not be
// 	 * null.
// 	 */
// 	public Organisation getBelongsTo() {
// 		return belongsTo;
// 	}
// 
// 	/**
// 	 * Sets the organisation to which this reward belongs to.
// 	 * 
// 	 * @param belongsTo
// 	 *            The reward's organisation. This parameter must not be null.
// 	 */
// 	public void setBelongsTo(Organisation belongsTo) {
// 		this.belongsTo = belongsTo;
// 	}
// 
// 	/**
// 	 * Gets the information about how long the reward can exist.
// 	 * 
// 	 * @return The value for how long the reward exist.
// 	 */
// 	public int getTimeToLive() {
// 		return timeToLive;
// 	}
// 
// 	/**
// 	 * Sets the information about how long the reward can exist.
// 	 * 
// 	 * @param timeToLive
// 	 * 			Time how long the reward can exist as int.
// 	 */			
// 	public void setTimeToLive(int timeToLive) {
// 		this.timeToLive = timeToLive;
// 	}
// 
// 	/**
// 	 * This method tests if a reward belongs to a specific organisation. Therefore
// 	 * it is tested if the organisation's API key matchs the reward's API key of the 
// 	 * assigned organisation. 
// 	 * 
// 	 * @param organisation
// 	 * 			The organisation object a reward may belongs to.
// 	 * @return
// 	 *  		Boolean value if the API key of the group is the same 
// 	 * 			of the tested organisation (true) or not (false).
// 	 */
// 	public boolean belongsTo(Organisation organisation) {
// 		return getBelongsTo().getApiKey().equals(organisation.getApiKey());
// 	}
// 
// 	/**
// 	 * Gets the description of an achievement. This could contains for example the 
// 	 * different tasks which have to be completed to get this achievement.
// 	 * 
// 	 * @return the achievement's description
// 	 */
// 	public String getDescription() {
// 		return description;
// 	}
// 
// 	/**
// 	 * Sets the description of an achievement. This contains for example further 
// 	 * information about how the achievement can be earned, like all requirements to 
// 	 * get the achievement or the process to award the achievement.
// 	 * 
// 	 * @param description
// 	 *            of the achievement
// 	 */
// 	public void setDescription(String description) {
// 		this.description = description;
// 	}
// 
// 	/**
// 	 * Gets the name of an achievement which can describe the success in a short
// 	 * way and can be displayed in the application.
// 	 * 
// 	 * @return The achievement's name as String.
// 	 */
// 	public String getName() {
// 		return name;
// 	}
// 
// 	/**
// 	 * Sets the name of an achievement, which can describe the success in a short
// 	 * way and can be displayed in the application.
// 	 * 
// 	 * @param name
// 	 *            The name of the achievement as a String.
// 	 */
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 	
// 	/**
// 	 * Gets the list of goals to which this reward is assigned.
// 	 * 
// 	 * @return All goals with this reward as List of Goals.
// 	 */
// 	public List<Goal> getGoals() {
// 		return goals;
// 	}
// 	
// 	/**
// 	 * Sets the list of goals to which this reward is assigned.
// 	 * 
// 	 * @param goals
// 	 * 			The goals to which this reward should be assigned.
// 	 */
// 	public void setGoals(List<Goal> goals) {
// 		this.goals = goals;
// 	}
// }


// Path: src/main/java/info/interactivesystems/gamificationengine/dao/RewardDAO.java
import info.interactivesystems.gamificationengine.entities.rewards.Reward;
import java.util.List;
import javax.ejb.Stateless;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

package info.interactivesystems.gamificationengine.dao;




@Named
@Stateless
public class RewardDAO {
	@PersistenceContext(unitName = PersistenceUnit.PROJECT)
	private EntityManager em;

	/**
	 * Stores a new reward in the data base.
	 * 
	 * @param reward
	 * 			The reward which should be stored in the data base.
	 * @return The generated id of the reward. 
	 */
	public int insertReward(Reward reward) {