package uk.org.adamretter.webexample.service.impl;

import java.util.Calendar;
import java.util.Date;
import java.util.List;
import uk.org.adamretter.webexample.dao.ConferenceDao;
import uk.org.adamretter.webexample.model.Conference;
import uk.org.adamretter.webexample.service.ConferenceService;

/**
 *
 * @author aretter
 */
public class ConferenceServiceImpl implements ConferenceService {

    private ConferenceDao dao;

    public ConferenceDao getDao() {
        return dao;
    }

    public void setDao(ConferenceDao dao) {
        this.dao = dao;
    }
    
    public List<Conference> getFutureConferences() {
        
        final Date now = Calendar.getInstance().getTime();
        
        return getDao().getConferencesAfter(now);
    }

    public void save(Conference conference) {
        
        final Date now = Calendar.getInstance().getTime();
        
        conference.setTimestamp(now);
        
        getDao().persist(conference);
    }
    
}
