// Path: src/main/java/info/interactivesystems/gamificationengine/entities/Organisation.java
// @Entity
// public class Organisation implements Serializable {
// 
// 	private static final long serialVersionUID = -6830220885028070098L;
// 
// 	@Id
// 	@GeneratedValue(strategy = GenerationType.IDENTITY)
// 	private int id;
// 
// 	@NotNull
// 	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
// 	private Collection<Account> managers;
// 
// 	private String name;
// 
// 	@NotNull
// 	@Column(unique = true)
// 	private String apiKey;
// 
// 	public Organisation(String name) {
// 		super();
// 		this.name = name;
// 		managers = new HashSet<Account>();
// 	}
// 
// 	public Organisation() {
// 		super();
// 		managers = new HashSet<Account>();
// 	}
// 
// 	/**
// 	 * Sets the id of the created organisation.
// 	 * 
// 	 * @param id 
// 	 *           The new id of the organisation
// 	 */
// 	public void setId(int id) {
// 		this.id = id;
// 	}
// 
// 	/**
// 	 * Gets the organisation's id.
// 	 * 
// 	 * @return organisation's id as int
// 	 */
// 	public int getId() {
// 		return id;
// 	}
// 
// 	/**
// 	 * Gets all accounts of the organisation which are associated to this organisation. 
// 	 * Each account belongs to a manager.
// 	 * 
// 	 * @return Collection of all organisation's manager accounts
// 	 */
// 	public Collection<Account> getManagers() {
// 		return managers;
// 	}
// 
// 	/**
// 	 * Sets the list of the organisation's accounts. Each account belongs to a
// 	 * manager.
// 	 * 
// 	 * @param managers
// 	 *             List of all organisation's accounts
// 	 */
// 	public void setManagers(Collection<Account> managers) {
// 		this.managers = managers;
// 	}
// 
// 	/**
// 	 * Gets the organisation's name and returns it as a String.
// 	 * 
// 	 * @return name of the organisation as String.
// 	 */
// 	public String getName() {
// 		return name;
// 	}
// 
// 	/**
// 	 * Sets the name of an organisation.
// 	 * 
// 	 * @param name
// 	 *            The name of the organisation.
// 	 * 
// 	 */
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	/**
// 	 * Gets the organisation's unique API key and returns it.
// 	 * 
// 	 * @return the apiKey as a String
// 	 */
// 	public String getApiKey() {
// 		return apiKey;
// 	}
// 
// 	/**
// 	 * Sets the organisation's API key.
// 	 * 
// 	 * @param apiKey
// 	 *		 	 The API key which is unique and specific for one organisation.
// 	 */
// 	public void setApiKey(@NotNull String apiKey) {
// 		this.apiKey = apiKey;
// 	}
// 
// 	/**
// 	 * Adds a new manager's account to the organisation's list of accounts.
// 	 * 
// 	 * @param account
// 	 *            which should be added to the list
// 	 */
// 	public void addManager(@NotNull Account account) {
// 		this.managers.add(account);
// 	}
// }


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




/**
 * Data access for developer organisations.
 */
@Named
@Stateless
public class OrganisationDAO {

	@PersistenceContext(unitName = PersistenceUnit.PROJECT)
	private EntityManager em;

	/**
	 * Stores a new organisation in the data base.
	 * 
	 * @param organisation
	 *            The {@link Organisation} that should be stored in the data base.
	 */
// Path: src/main/java/info/interactivesystems/gamificationengine/entities/Organisation.java
// @Entity
// public class Organisation implements Serializable {
// 
// 	private static final long serialVersionUID = -6830220885028070098L;
// 
// 	@Id
// 	@GeneratedValue(strategy = GenerationType.IDENTITY)
// 	private int id;
// 
// 	@NotNull
// 	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
// 	private Collection<Account> managers;
// 
// 	private String name;
// 
// 	@NotNull
// 	@Column(unique = true)
// 	private String apiKey;
// 
// 	public Organisation(String name) {
// 		super();
// 		this.name = name;
// 		managers = new HashSet<Account>();
// 	}
// 
// 	public Organisation() {
// 		super();
// 		managers = new HashSet<Account>();
// 	}
// 
// 	/**
// 	 * Sets the id of the created organisation.
// 	 * 
// 	 * @param id 
// 	 *           The new id of the organisation
// 	 */
// 	public void setId(int id) {
// 		this.id = id;
// 	}
// 
// 	/**
// 	 * Gets the organisation's id.
// 	 * 
// 	 * @return organisation's id as int
// 	 */
// 	public int getId() {
// 		return id;
// 	}
// 
// 	/**
// 	 * Gets all accounts of the organisation which are associated to this organisation. 
// 	 * Each account belongs to a manager.
// 	 * 
// 	 * @return Collection of all organisation's manager accounts
// 	 */
// 	public Collection<Account> getManagers() {
// 		return managers;
// 	}
// 
// 	/**
// 	 * Sets the list of the organisation's accounts. Each account belongs to a
// 	 * manager.
// 	 * 
// 	 * @param managers
// 	 *             List of all organisation's accounts
// 	 */
// 	public void setManagers(Collection<Account> managers) {
// 		this.managers = managers;
// 	}
// 
// 	/**
// 	 * Gets the organisation's name and returns it as a String.
// 	 * 
// 	 * @return name of the organisation as String.
// 	 */
// 	public String getName() {
// 		return name;
// 	}
// 
// 	/**
// 	 * Sets the name of an organisation.
// 	 * 
// 	 * @param name
// 	 *            The name of the organisation.
// 	 * 
// 	 */
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	/**
// 	 * Gets the organisation's unique API key and returns it.
// 	 * 
// 	 * @return the apiKey as a String
// 	 */
// 	public String getApiKey() {
// 		return apiKey;
// 	}
// 
// 	/**
// 	 * Sets the organisation's API key.
// 	 * 
// 	 * @param apiKey
// 	 *		 	 The API key which is unique and specific for one organisation.
// 	 */
// 	public void setApiKey(@NotNull String apiKey) {
// 		this.apiKey = apiKey;
// 	}
// 
// 	/**
// 	 * Adds a new manager's account to the organisation's list of accounts.
// 	 * 
// 	 * @param account
// 	 *            which should be added to the list
// 	 */
// 	public void addManager(@NotNull Account account) {
// 		this.managers.add(account);
// 	}
// }


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

package info.interactivesystems.gamificationengine.dao;




/**
 * Data access for developer organisations.
 */
@Named
@Stateless
public class OrganisationDAO {

	@PersistenceContext(unitName = PersistenceUnit.PROJECT)
	private EntityManager em;

	/**
	 * Stores a new organisation in the data base.
	 * 
	 * @param organisation
	 *            The {@link Organisation} that should be stored in the data base.
	 */
	public void insertOrganisation(Organisation organisation) {