package org.jerrymouse.chineseCalendar.service.impl;

import java.util.List;

import org.jerrymouse.chineseCalendar.model.atom.BirthdayAtom;
import org.jerrymouse.chineseCalendar.model.atom.BirthdayEntity;
import org.jerrymouse.chineseCalendar.model.atom.SystemInfo;
import org.jerrymouse.chineseCalendar.model.birthday.Birthday;
import org.jerrymouse.chineseCalendar.model.birthday.BirthdayEncoder;
import org.jerrymouse.chineseCalendar.model.birthday.SimpleCalendar;
import org.jerrymouse.chineseCalendar.service.AtomService;
import org.jerrymouse.chineseCalendar.service.SiteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.sun.syndication.feed.synd.SyndFeed;

@Component
public class AtomServiceImpl implements AtomService {
	@Autowired
	BirthdayEncoder birthdayEncoder;

	@Autowired
	SiteService siteService;

	@Override
	public SyndFeed creatWeekFeed(SimpleCalendar begin,
			List<BirthdayEntity> birthdayEntities, List<Birthday> birthdays) {
		BirthdayAtom atom = new BirthdayAtom(begin, siteService
				.encodeMainURL(birthdays), siteService.encodeFeedURL(birthdays));
		for (BirthdayEntity birthdayEntity : birthdayEntities) {
			atom.add(birthdayEntity);
		}
		return atom.getFeed();
	}

}
