/*
 * Aipo is a groupware program developed by Aimluck,Inc.
 * Copyright (C) 2004-2008 Aimluck,Inc.
 * http://aipostyle.com/
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package com.aimluck.eip.officecalendar;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import com.aimluck.eip.common.ALData;

/**
 * 月間スケジュールコンテナを取得します。
 * 
 */
public class OfficecalendarMonthContainer implements ALData {

	/** <code>weekList</code> 週間スケジュールリスト */
	private List weekList;

	/*
	 * @see com.aimluck.eip.common.ALData#initField()
	 */
	public void initField() {
		weekList = new ArrayList();
	}

	/**
	 * 表示する月を設定します。
	 * 
	 * @param cal
	 */
	/** Update 20110908 小濵 Start */
//    public void setViewMonth(Calendar cal, Calendar vcal) {
	public void setViewMonth(Calendar cal, Calendar vcal, Integer officeId) {
	/** Update 20110908 小濵 End   */
		for (int i = 1; i <= 6; i++) {
			if ((i == 5 || i == 6)
					&& (cal.get(Calendar.MONTH) != vcal.get(Calendar.MONTH)))
				break;
			// 日付を7日ずつずらす
			OfficecalendarWeekContainer con = new OfficecalendarWeekContainer();
			con.initField();
		    /** Update 20110908 小濵 Start */
//			con.setViewStartDate(cal);
            con.setViewStartDate(cal, officeId);
		    /** Update 20110908 小濵 End   */
			weekList.add(con);
			// cal.add(Calendar.DATE, 7);
		}
	}

	/**
	 * スケジュールを追加します。
	 * 
	 * @param rd
	 */
	public boolean addResultData(OfficecalendarResultData rd) {
		int size = weekList.size();
		for (int i = 0; i < size; i++) {
			OfficecalendarWeekContainer con = (OfficecalendarWeekContainer) weekList
					.get(i);
			if (con.addResultData(rd)) {
				return true;
			}
		}
		return false;
	}

	/**
	 * 週間スケジュールリストを取得します。
	 * 
	 * @return
	 */
	public List getWeekList() {
		return weekList;
	}

}
