package org.yacos.core.conferences;

import java.util.Date;
import java.util.List;

import javax.ejb.Remote;

import org.yacos.core.evaluation.Criterion;
import org.yacos.core.exceptions.ConferenceDoesntExistException;
import org.yacos.core.exceptions.NoConferenceCreationTokenLeftException;
import org.yacos.core.system.InvitationToken;
import org.yacos.core.system.InvitationTokenPK;
import org.yacos.core.users.Role;
import org.yacos.core.users.User;
import org.yacos.core.users.Role.RoleType;

@Remote
public interface IConferenceManager {
    
	// CRUD methods
	public Conference addConference(
			String titre,
			String chairmanLogin,
			String description,
			String complementaryInfo,
			Date dataAbstract,
			Date dateArticle,
			Date dateEvaluation,
			Date dateStart,
			Date dateEnd) throws NoConferenceCreationTokenLeftException;
	public Conference getConference(Integer id);
	public void addCriterionToConference(Integer conferenceId,String name,Integer minRating, Integer maxRating);
	public void removeCriterionToConference(Integer conferenceId);
	public void removeOneCriterionToConference(Criterion criterion);
	public void addPCMemberToConference(Integer conferenceId, String userLogin);
	public void removePCMemberForConf(Integer confId);
	
	public void remove(Integer conferenceId);
	public void update(Conference conf);
	
	//article methodes
	//FIXME 
	//methode a gicler ?
	//public void addArticle(User user);
	//public Collection<Article> getArticles(Integer id);
	
	// Listing methods
	public List<Conference> getConferences();
	public List<Conference> getConferences(User user);
	
		
	// Role and User management methods
	public Role addRole(Role.RoleType roleType, String login, Integer confId);
	public void removeRole(Role role);
	public List<Role> getRoles(Conference conf);
	public List<Role> getRoles(String userLogin, Integer confId);
	public void updateRole(Role role);
	public boolean exists(Integer conferenceId);
	
	// Invitation management methods
	public InvitationToken getInvitationToken(InvitationTokenPK tokenId);
	public List<InvitationToken> getInvitationTokensForConference(Integer conferenceId);
	public InvitationToken addInvitationToken(String email, RoleType role, Integer conferenceId) throws ConferenceDoesntExistException;
	public void removeInvitationToken(InvitationToken tokenId);

	// Conference creation tokens handling methods
	/**
	 * @return True if the given user has a conference creation token left, false otherwise
	 */
	public boolean canCreateConference(String userLogin);
	/**
	 * Use (remove) a conference creation token for the given user
	 * @param userLogin The user from which to remove a token
	 */
	public void useConferenceCreationToken(String userLogin) throws NoConferenceCreationTokenLeftException;
	/**
	 * Gets the number of conference creation token left for a given user
	 * @param userLogin The user
	 * @return The number of token the user has left
	 */
	public Integer conferenceCreationTokens(String userLogin);
	/**
	 * Adds a conference creation token to the given user
	 * @param userLogin The user to which we grant the token
	 */
	public void addConferenceCreationToken(String userLogin);
}
