use of org.jbei.ice.lib.entry.sequence.PartTraceSequences in project ice by JBEI.
the class PartResource method getTraces.
/**
* @return traces for the part
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/traces")
public Response getTraces(@PathParam("id") final long partId, @DefaultValue("100") @QueryParam("limit") int limit, @DefaultValue("0") @QueryParam("start") int start) {
final String userId = getUserId();
PartTraceSequences partTraceSequences = new PartTraceSequences(userId, partId);
Results<TraceSequenceAnalysis> results = partTraceSequences.getTraces(start, limit);
// hack for trace sequence viewer without having to modify it
if (StringUtils.isEmpty(sessionId))
return super.respond(new ArrayList<>(results.getData()));
return super.respond(results);
}
use of org.jbei.ice.lib.entry.sequence.PartTraceSequences in project ice by JBEI.
the class PartResource method addTraceSequence.
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/traces")
public Response addTraceSequence(@PathParam("id") final long partId, @FormDataParam("file") final InputStream fileInputStream, @FormDataParam("file") final FormDataContentDisposition contentDispositionHeader) {
final String userId = getUserId();
final String fileName = contentDispositionHeader.getFileName();
final String tmpDir = Utils.getConfigValue(ConfigurationKey.TEMPORARY_DIRECTORY);
final File file = Paths.get(tmpDir, fileName).toFile();
try {
FileUtils.copyInputStreamToFile(fileInputStream, file);
} catch (final IOException e) {
Logger.error(e);
return respond(Response.Status.INTERNAL_SERVER_ERROR);
}
PartTraceSequences partTraceSequences = new PartTraceSequences(userId, partId);
final boolean success = partTraceSequences.addTraceSequence(file, fileName);
return respond(success);
}
use of org.jbei.ice.lib.entry.sequence.PartTraceSequences in project ice by JBEI.
the class PartResource method getAllTraces.
@GET
@Path("/{id}/traces/all")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response getAllTraces(@PathParam("id") final long partId, @QueryParam("sid") String sid) {
if (StringUtils.isEmpty(sessionId))
sessionId = sid;
final String userId = requireUserId();
PartTraceSequences partTraceSequences = new PartTraceSequences(userId, partId);
try (ByteArrayOutputStream outputStream = partTraceSequences.getAll()) {
StreamingOutput stream = outputStream::writeTo;
return Response.ok(stream).header("Content-Disposition", "attachment;filename=\"data.zip\"").build();
} catch (IOException e) {
Logger.error(e);
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
}
}
Aggregations