package cz.muni.fi.lasaris.sbms.data.api.response;

import java.util.LinkedHashMap;
import java.util.Map;

import cz.muni.fi.lasaris.sbms.data.entities.Address;
import cz.muni.fi.lasaris.sbms.data.entities.containers.Series;
import cz.muni.fi.lasaris.sbms.data.entities.values.Value;

public class SeriesOfValuesResponse {
	private static final String DEFAULT_GROUPING = "noGrouping";
	
	private String error;
	private Map<String, Map<Address, Series<? extends Value>>> results;
	
	public Map<String, Map<Address, Series<? extends Value>>> getResults() {
		return this.results;
	}
	
	public static SeriesOfValuesResponse getErrorResponse(String error) {
		SeriesOfValuesResponse r = new SeriesOfValuesResponse();
		r.setError(error);
		return r;
	}
	
	private SeriesOfValuesResponse() {
		this.results = null;
	}
	
	public SeriesOfValuesResponse(Map<String, Map<Address, Series<? extends Value>>> data, boolean groups) {
		this.results = data;
	}
	
	
	public SeriesOfValuesResponse(Map<Address, Series<? extends Value>> data) {
		this.results = new LinkedHashMap<String, Map<Address, Series<? extends Value>>>();
		this.results.put(DEFAULT_GROUPING, data);
	}
	
	public SeriesOfValuesResponse(Address a, Series<? extends Value> v) {
		this(new LinkedHashMap<String, Map<Address, Series<? extends Value>>>(), true);
		this.results.put(DEFAULT_GROUPING, new LinkedHashMap<Address, Series<? extends Value>>());
		this.results.get(DEFAULT_GROUPING).put(a, v);
	}
	
	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error = error;
	}
}
