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 SetOfSeriesOfValuesResponse {
	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 SetOfSeriesOfValuesResponse getErrorResponse(String error) {
		SetOfSeriesOfValuesResponse r = new SetOfSeriesOfValuesResponse();
		r.setError(error);
		return r;
	}
	
	private SetOfSeriesOfValuesResponse() {
		this.results = null;
	}
	
	public SetOfSeriesOfValuesResponse(Map<String, Map<Address, Series<? extends Value>>> data, boolean groups) {
		this.results = data;
	}
	
	
	public SetOfSeriesOfValuesResponse(Map<Address, Series<? extends Value>> data) {
		this.results = new LinkedHashMap<String, Map<Address, Series<? extends Value>>>();
		this.results.put(DEFAULT_GROUPING, data);
	}
	
	public SetOfSeriesOfValuesResponse(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;
	}
}
