Commit aed28266 authored by Adam Kucera's avatar Adam Kucera
Browse files

trends endpoint changes

parent b73d9b55
......@@ -9,7 +9,6 @@ import java.util.Arrays;
import javax.annotation.security.RolesAllowed;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
......@@ -34,14 +33,9 @@ import cz.muni.fi.lasaris.sbms.data.entities.Address;
import cz.muni.fi.lasaris.sbms.data.entities.AggregationFunction;
import cz.muni.fi.lasaris.sbms.data.entities.AggregationWindow;
import cz.muni.fi.lasaris.sbms.data.entities.Interpolation;
import cz.muni.fi.lasaris.sbms.data.entities.Sampling;
import cz.muni.fi.lasaris.sbms.data.entities.SeriesSpecs;
import cz.muni.fi.lasaris.sbms.data.entities.containers.Trend;
import cz.muni.fi.lasaris.sbms.data.entities.values.RawValue;
import cz.muni.fi.lasaris.sbms.data.logic.DPDataCollector;
import cz.muni.fi.lasaris.sbms.data.logic.ProviderManager;
import cz.muni.fi.lasaris.sbms.data.logic.TrendsDataCollector;
import cz.muni.fi.lasaris.sbms.data.util.Aggregator;
public class TrendsEndpoint {
final static Logger logger = Logger.getLogger(TrendsEndpoint.class);
......@@ -97,21 +91,46 @@ public class TrendsEndpoint {
return new SeriesOfValuesResponse(r.getAddress(), v);
}
// Method 16
@RolesAllowed({"user","admin"})
@POST
@Path("/mias")
@Produces(MediaType.APPLICATION_JSON)
public SeriesOfValuesResponse getMIAS(
@QueryParam("ids") String ids,
@QueryParam("grouping") boolean grouping,
@QueryParam("start") String start,
@QueryParam("end") String end,
@QueryParam("sampling.cron") String samplingCron,
@QueryParam("sampling.duration") Long samplingDur,
@QueryParam("sampling.interpolation") Interpolation interpolation,
@QueryParam("aggregation.function") AggregationFunction aggregation
) {
try {
TrendsRequest r = getReadSpecsMulti(ids, grouping, start, end, samplingCron, samplingDur, interpolation, aggregation, null);
Trend v = dc.getTrend(r);
return new SeriesOfValuesResponse(r.getAddress(), v);
} catch(Exception e) {
return SeriesOfValuesResponse.getErrorResponse(e.getMessage());
}
}
private TrendsRequest getReadSpecsSingle(String id, String start, String end, String samplingCron,
Long samplingDur, Interpolation interpolation, AggregationFunction aggregation, AggregationWindow window) {
TrendsRequest readSpecs = getReadSpecsBase(start, end, samplingCron, samplingDur, interpolation, aggregation, window);
AddressRequest ar = new AddressRequest();
ar.setAddresses(Arrays.asList(new Address[] { new Address(id)}));
readSpecs.setAddressSpecs(ar);
readSpecs.setAddressSpecs(new Address(id));
return readSpecs;
}
private TrendsRequest getReadSpecsMulti(String json, boolean grouping, String start, String end, String samplingCron,
Long samplingDur, Interpolation interpolation, AggregationFunction aggregation, AggregationWindow window) throws JsonParseException, JsonMappingException, IOException {
TrendsRequest readSpecs = getReadSpecsBase(start, end, samplingCron, samplingDur, interpolation, aggregation, window);
if(grouping) {
readSpecs.setAddressSpecs(m.readValue(json, AddressRequest.class));
} else {
readSpecs.setAddressSpecs(m.readValue(json, GroupedAddressRequest.class));
}
return readSpecs;
}
......
package cz.muni.fi.lasaris.sbms.data.api.request;
import java.util.Arrays;
import cz.muni.fi.lasaris.sbms.data.entities.Address;
import cz.muni.fi.lasaris.sbms.data.entities.AggregationFunction;
import cz.muni.fi.lasaris.sbms.data.entities.AggregationWindow;
......@@ -7,10 +9,7 @@ import cz.muni.fi.lasaris.sbms.data.entities.SeriesSpecs;
public class TrendsRequest {
public void setAddressSpecs(AddressRequest ar) {
// TODO Auto-generated method stub
}
public Address getAddress() {
// TODO Auto-generated method stub
......@@ -27,4 +26,21 @@ public class TrendsRequest {
}
public void setAddressSpecs(Address a) {
AddressRequest ar = new AddressRequest();
ar.setAddresses(Arrays.asList(new Address[] { a }));
setAddressSpecs(ar);
}
public void setAddressSpecs(AddressRequest ar) {
// TODO Auto-generated method stub
}
public void setAddressSpecs(GroupedAddressRequest readValue) {
// TODO Auto-generated method stub
}
}
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