package com.wasu.cs.model;

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

import org.json.JSONObject;


import com.wasu.util.StringUtils;

public class HomeColumnModel extends SpecialColumnModel {
	
	/** 
	 * @Fields serialVersionUID
	 */
	private static final long serialVersionUID = 1L;
	private int rowspan;
	private int colspan;
	private int carouselTime;
	private Map<String, String> cornerIconMap = new HashMap<String, String>();
	private String cornerIcon;
	private String parentLayout;

	private int aliRecommend;
	
	public int getAliRecommend() {
		return aliRecommend;
	}

	public void setAliRecommend(int aliRecommend) {
		this.aliRecommend = aliRecommend;
	}

	private String parentTitle;
	public String getParentLayout() {
		return parentLayout;
	}

	public void setParentLayout(String parentLayout) {
		this.parentLayout = parentLayout;
	}

	public String getParentTitle() {
		return parentTitle;
	}

	public void setParentTitle(String parentTitle) {
		this.parentTitle = parentTitle;
	}

	@Override
	public boolean from(JSONObject json) {
		boolean result = super.from(json);
		if(result) {
			String position = json.optString("position", "");
			if(!StringUtils.isBlank(position) && position.contains("*")) {
				String[] spanArr = position.split("\\*");
				
				if(spanArr != null && spanArr.length > 0) {
					rowspan = Integer.parseInt(spanArr[0]);
				}
				
				if(spanArr != null && spanArr.length > 1) {
					colspan = Integer.parseInt(spanArr[1]);
				}
			}
			aliRecommend=json.optInt("aliRecommend", 0);
		}
		
		return result;
	}

	public int getRowspan() {
		return rowspan;
	}

	public void setRowspan(int rowspan) {
		this.rowspan = rowspan;
	}

	public int getColspan() {
		return colspan;
	}

	public void setColspan(int colspan) {
		this.colspan = colspan;
	}

	public int getCarouselTime() {
		return carouselTime;
	}

	public void setCarouselTime(int carouselTime) {
		this.carouselTime = carouselTime;
	}

	public String getCornerIcon() {
		return cornerIcon;
	}

	public Map<String, String> getCornerIconMap() {
		return cornerIconMap;
	}

	public void setCornerIconMap(Map<String, String> cornerIconMap) {
		this.cornerIcon = cornerIconMap.get(getCmark());
		this.cornerIconMap = cornerIconMap;
	}

}
