Commit 34a64cbe authored by Adam Kučera's avatar Adam Kučera
Browse files

response types completed

parent aed28266
......@@ -27,7 +27,7 @@ import cz.muni.fi.lasaris.sbms.data.api.request.GroupedAddressRequest;
import cz.muni.fi.lasaris.sbms.data.api.request.TrendsRequest;
import cz.muni.fi.lasaris.sbms.data.api.request.AddressRequest;
import cz.muni.fi.lasaris.sbms.data.api.response.AggregateResponse;
import cz.muni.fi.lasaris.sbms.data.api.response.SeriesOfValuesResponse;
import cz.muni.fi.lasaris.sbms.data.api.response.SetOfSeriesOfValuesResponse;
import cz.muni.fi.lasaris.sbms.data.api.response.SliceResponse;
import cz.muni.fi.lasaris.sbms.data.entities.Address;
import cz.muni.fi.lasaris.sbms.data.entities.AggregationFunction;
......@@ -80,7 +80,7 @@ public class TrendsEndpoint {
@POST
@Path("/si")
@Produces(MediaType.APPLICATION_JSON)
public SeriesOfValuesResponse getSI(
public SetOfSeriesOfValuesResponse getSI(
@QueryParam("id") String id,
@QueryParam("start") String start,
@QueryParam("end") String end
......@@ -88,7 +88,7 @@ public class TrendsEndpoint {
TrendsRequest r = getReadSpecsSingle(id, start, end, null, null, null, null, null);
Trend v = dc.getTrend(r);
return new SeriesOfValuesResponse(r.getAddress(), v);
return new SetOfSeriesOfValuesResponse(r.getAddress(), v);
}
// Method 16
......@@ -96,7 +96,7 @@ public class TrendsEndpoint {
@POST
@Path("/mias")
@Produces(MediaType.APPLICATION_JSON)
public SeriesOfValuesResponse getMIAS(
public SetOfSeriesOfValuesResponse getMIAS(
@QueryParam("ids") String ids,
@QueryParam("grouping") boolean grouping,
@QueryParam("start") String start,
......@@ -109,9 +109,9 @@ public class TrendsEndpoint {
try {
TrendsRequest r = getReadSpecsMulti(ids, grouping, start, end, samplingCron, samplingDur, interpolation, aggregation, null);
Trend v = dc.getTrend(r);
return new SeriesOfValuesResponse(r.getAddress(), v);
return new SetOfSeriesOfValuesResponse(r.getAddress(), v);
} catch(Exception e) {
return SeriesOfValuesResponse.getErrorResponse(e.getMessage());
return SetOfSeriesOfValuesResponse.getErrorResponse(e.getMessage());
}
}
......
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.containers.Series;
import cz.muni.fi.lasaris.sbms.data.entities.containers.Slice;
import cz.muni.fi.lasaris.sbms.data.entities.values.Value;
public class SeriesOfSlicesResponse {
private static final String DEFAULT_GROUPING = "noGrouping";
private String error;
private Map<String, Series<Slice>> results;
public Map<String, Series<Slice>> getResults() {
return this.results;
}
public static SeriesOfSlicesResponse getErrorResponse(String error) {
SeriesOfSlicesResponse r = new SeriesOfSlicesResponse();
r.setError(error);
return r;
}
private SeriesOfSlicesResponse() {
this.results = null;
}
public SeriesOfSlicesResponse(Map<String, Series<Slice>> data) {
this.results = data;
}
public SeriesOfSlicesResponse(Series<Slice> data) {
this.results = new LinkedHashMap<String, Series<Slice>>();
this.results.put(DEFAULT_GROUPING, data);
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
}
......@@ -3,17 +3,17 @@ 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;
private Map<String, Series<? extends Value>> results;
public Map<String, Map<Address, Series<? extends Value>>> getResults() {
public Map<String, Series<? extends Value>> getResults() {
return this.results;
}
......@@ -27,22 +27,16 @@ public class SeriesOfValuesResponse {
this.results = null;
}
public SeriesOfValuesResponse(Map<String, Map<Address, Series<? extends Value>>> data, boolean groups) {
public SeriesOfValuesResponse(Map<String, Series<? extends Value>> data) {
this.results = data;
}
public SeriesOfValuesResponse(Map<Address, Series<? extends Value>> data) {
this.results = new LinkedHashMap<String, Map<Address, Series<? extends Value>>>();
public SeriesOfValuesResponse(Series<? extends Value> data) {
this.results = new LinkedHashMap<String, 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;
}
......@@ -50,4 +44,5 @@ public class SeriesOfValuesResponse {
public void setError(String error) {
this.error = error;
}
}
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.Aggregation;
import cz.muni.fi.lasaris.sbms.data.entities.values.AggregatedValue;
public class SetOfAggregatesResponse {
private static final String DEFAULT_GROUPING = "noGrouping";
private String error;
private Map<String, Map<Address, AggregatedValue>> results;
public Map<String, Map<Address, AggregatedValue>> getResults() {
return this.results;
}
public static SetOfAggregatesResponse getErrorResponse(String error) {
SetOfAggregatesResponse r = new SetOfAggregatesResponse();
r.setError(error);
return r;
}
private SetOfAggregatesResponse() {
this.results = null;
}
public SetOfAggregatesResponse(Map<String, Map<Address, AggregatedValue>> data) {
this.results = data;
}
public SetOfAggregatesResponse(Address a, AggregatedValue v) {
this.results = new LinkedHashMap<String, Map<Address, AggregatedValue>>();
this.results.put(DEFAULT_GROUPING, new LinkedHashMap<Address, AggregatedValue>());
this.results.get(DEFAULT_GROUPING).put(a, v);
}
public SetOfAggregatesResponse(Aggregation<Address> a) {
this.results = new LinkedHashMap<String, Map<Address, AggregatedValue>>();
this.results.put(DEFAULT_GROUPING, new LinkedHashMap<Address, AggregatedValue>());
a.forEach((k,v) -> this.results.get(DEFAULT_GROUPING).put(k, v));
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
}
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;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment