package com.wasu.cs.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import com.wasu.cs.model.SpecialColumnModel.VideoModel;

public class Swith2DemandPrograme {
	// private ArrayList<VideoModel> vmList = new ArrayList<VideoModel>();
	// private DemandProgram dp;

	public static DemandProgram VideoModel2DemandPrograme(ArrayList<VideoModel> vmList) {
		if (vmList == null || vmList.size() == 0) {
			return null;
		}
		long rate;
		String tag;
		String datetime;
		int episode;
		String itemId;
		String title;
		ArrayList<String> playUrls = new ArrayList<String>();
		DemandProgram dp = new DemandProgram();

		DemandSeries ds = new DemandSeries();
		Map<Long, DemandPlayinfo> mPlayinfoList = new HashMap<Long, DemandPlayinfo>();
		ArrayList<DemandSeries> mSeriesList = new ArrayList<DemandSeries>();
		for (int i = 0; i < vmList.size(); i++) {
			tag = vmList.get(i).getTag();
			rate = vmList.get(i).getRate();

			title = vmList.get(i).getTitle();
			datetime = vmList.get(i).getDatetime();
			episode = vmList.get(i).getEpisode();
			itemId = Integer.toString(vmList.get(i).getItemId());
			playUrls = (ArrayList<String>) vmList.get(i).getPlayUrls();

			ds.setTitle(title);
			ds.setDatetime(datetime);
			ds.setEpisode(episode);
			ds.setItemId(itemId);
			ds.setPlayUrls(playUrls);
			mSeriesList.clear();
			mSeriesList.add(ds);
			DemandPlayinfo dpInfo = new DemandPlayinfo();
			dpInfo.setmSeriesList(mSeriesList);
			dpInfo.setRate(rate);
			dpInfo.setTag(tag);
			mPlayinfoList.put(rate, dpInfo);

		}

		dp.setmPlayinfoList(mPlayinfoList);
		return dp;
	}

}
