package com.wasu.cs.model;

import org.json.JSONObject;

/**
 * filter data
 */
public class FilterModel extends SearchModel {
	/**
	 * 
	 */
	private int page;
	private int total;
	private Assets assets=null;
	private String jsonUrl;
	private static final long serialVersionUID = -8440387881455471989L;
	@Override
	public boolean from(JSONObject json) {
		if(super.from(json)){
			if(getAssetes()!=null&&!getAssetes().isEmpty()){
				assets=getAssetes().get(0);//最多只会返回一条
				this.page=assets.getPage();
				this.total=assets.getTotal();
				this.jsonUrl=assets.getJsonUrl();
			}
			return true;
		};
		return false;
	}
	/*public List<AssetsItem> getAllResults() {
		List<Assets> assetes = getAssetes();
		if (null == assetes || assetes.isEmpty()) {
			return null;
		}
		List<AssetsItem> result = new ArrayList<AssetsItem>();

		List<AssetsItem> temp;
		for (Assets assets : assetes) {
			temp = assets.getAssetsItems();
			if (null != temp && !temp.isEmpty()) {
				result.addAll(temp);
			}
		}
		return result;
	}*/
	public int getPage(){
		return page;
	}
	public int getTotal(){
		return total;
	}
	public void setPage(int page){
		this.page=page;
	}
	public String getJsonUrl(){
		return jsonUrl;
	}
	public void setJsonUrl(String jsonUrl){
		this.jsonUrl=jsonUrl;
	}
	public Assets getFilterAsset(){
		return assets;
	}
}
