package info.bukova.isspst.reporting;

import info.bukova.isspst.data.SignedDocumentItem;
import info.bukova.isspst.services.Service;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ReportDefinition implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 995511957163031085L;
	private Report report;
	private List<Object> dataSet;
	private Map<String, Object> params;
	private List<String> fieldsToPrint;
	private String reportTitle;
	private Service<Object>	service;
	private SignedDocumentItem signedDocItem;

 	public ReportDefinition() {
 		params = new HashMap<String, Object>();
 		fieldsToPrint = new ArrayList<String>();
 	}
	
	public List<Object> getDataSet() {
		return dataSet;
	}

	public void setDataSet(List<Object> dataSet) {
		this.dataSet = dataSet;
	}
	
	public void setSingleObject(Object o) {
		if (this.dataSet != null) {
			dataSet.clear();
		} else {
			dataSet = new ArrayList<Object>();
		}
	
		dataSet.add(o);
	}

	public Map<String, Object> getParams() {
		return params;
	}

	public void setParams(Map<String, Object> params) {
		this.params.clear();
		this.params.putAll(params);
	}
	
	public void setParam(String key, Object value) {
		this.params.put(key, value);
	}
	
	public Object getParam(String key) {
		return this.params.get(key);
	}

	public List<String> getFieldsToPrint() {
		return fieldsToPrint;
	}

	public void setFieldsToPrint(List<String> fieldsToPrint) {
		this.fieldsToPrint = fieldsToPrint;
	}
	
	public Report getReport() {
		return report;
	}

	public void setReport(Report report) {
		this.report = report;
	}
	
	public Class<?> gatDataClass() {
		if (dataSet != null && dataSet.size() > 0) {
			return dataSet.get(0).getClass();
		}
		
		return null;
	}

	public void clear() {
		report = null;
		fieldsToPrint.clear();
		dataSet = null;
		reportTitle = "";
		service = null;
		params.clear();
		signedDocItem = null;
	}

	public String getReportTitle() {
		return reportTitle;
	}

	public void setReportTitle(String reportTitle) {
		this.reportTitle = reportTitle;
	}

	public Service<Object> getService() {
		return service;
	}

	public void setService(Service<Object> service) {
		this.service = service;
	}

	public SignedDocumentItem getSignedDocItem() {
		return signedDocItem;
	}

	public void setSignedDocItem(SignedDocumentItem signedDocItem) {
		this.signedDocItem = signedDocItem;
	}
}
