Search in sources :

Example 1 with CsvBuilder

use of org.traccar.web.CsvBuilder in project traccar by tananaev.

the class PositionResource method getCsv.

@GET
@Produces(TEXT_CSV)
public Response getCsv(@QueryParam("deviceId") long deviceId, @QueryParam("from") String from, @QueryParam("to") String to) throws SQLException {
    Context.getPermissionsManager().checkDevice(getUserId(), deviceId);
    CsvBuilder csv = new CsvBuilder();
    csv.addHeaderLine(new Position());
    csv.addArray(Context.getDataManager().getPositions(deviceId, DateUtil.parseDate(from), DateUtil.parseDate(to)));
    return Response.ok(csv.build()).header(HttpHeaders.CONTENT_DISPOSITION, CONTENT_DISPOSITION_VALUE_CSV).build();
}
Also used : Position(org.traccar.model.Position) CsvBuilder(org.traccar.web.CsvBuilder) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 Position (org.traccar.model.Position)1 CsvBuilder (org.traccar.web.CsvBuilder)1