package be.ac.ulb.code.wit;

import be.ac.ulb.code.wit.contacts.Contact;
import be.ac.ulb.code.wit.contacts.Contacts;
import be.ac.ulb.code.wit.contacts.Contacts.IdentifiedContact;
import be.ac.ulb.code.wit.resources.ServicePaths;

/**
 * Contains the static configuration of the server, including a reference to
 * the model instance.
 * 
 * @author fpicalausa
 */
public final class ServiceConfiguration {
	private ServiceConfiguration() { /* Do not instantiate */ }
	
	/**
	 * The URI at which the server can be found
	 */
	public static final String    BASE_URI = ServicePaths.BASE_URI;
	
	/**
	 * A static instance of the model, to be used when handling requests.
	 */
	private static Contacts contactsModel = new Contacts();
	
	static {
		/* Setup a few predefined contacts */
        final Contact francois = new Contact("fpicalau@ulb.ac.be");
        final Contact stijn =  new Contact(Contact.computeDisplayName("Stijn", "Vansummeren"));

        francois.setEmail("fpicalau@ulb.ac.be");

        stijn.setEmail("svsummer@ulb.ac.be");
        stijn.setFirstName("Stijn");
        stijn.setLastName("Vansummeren");

        final IdentifiedContact idFrancois = contactsModel.addContact(francois);
        final IdentifiedContact idStijn = contactsModel.addContact(stijn);

		contactsModel.addContactToGroup(idFrancois, "ULB");
		contactsModel.addContactToGroup(idStijn, "ULB");
		contactsModel.addContactToGroup(idStijn, "Professors");
	}
	
	/**
	 * Get the service underlying model
	 * @return The backing contacts list 
	 */
	public static Contacts getContacts() {
		return contactsModel;
	}
}
