use of org.jbei.ice.storage.hibernate.dao.ShotgunSequenceDAO in project ice by JBEI.
the class PartResource method getShotgunSequences.
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/shotgunsequences")
public ArrayList<ShotgunSequenceDTO> getShotgunSequences(@Context final UriInfo info, @PathParam("id") final long partId, @DefaultValue("100") @QueryParam("limit") int limit, @DefaultValue("0") @QueryParam("start") int start) {
getUserId();
ShotgunSequenceDAO dao = DAOFactory.getShotgunSequenceDAO();
final EntryDAO entryDAO = DAOFactory.getEntryDAO();
final Entry entry = entryDAO.get(partId);
if (entry == null) {
return null;
}
ArrayList<ShotgunSequenceDTO> returns = new ArrayList<>();
List<ShotgunSequence> results = dao.getByEntry(entry);
for (ShotgunSequence ret : results) {
returns.add(new ShotgunSequenceDTO(ret));
}
Logger.info("Shotgun Sequences requested for entry " + partId);
return returns;
}
use of org.jbei.ice.storage.hibernate.dao.ShotgunSequenceDAO in project ice by JBEI.
the class PartResource method addShotgunSequence.
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/shotgunsequences")
public Response addShotgunSequence(@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 EntryDAO entryDAO = DAOFactory.getEntryDAO();
final Entry entry = entryDAO.get(partId);
ShotgunSequenceDAO dao = DAOFactory.getShotgunSequenceDAO();
try {
String storageName = Utils.generateUUID();
dao.writeSequenceFileToDisk(storageName, fileInputStream);
dao.create(fileName, userId, entry, storageName, new Date());
} catch (Exception e) {
Logger.error(e);
return respond(Response.Status.INTERNAL_SERVER_ERROR);
}
Logger.info("Uploaded shotgun sequence for entry " + entry.getId());
return respond(Response.Status.OK);
}
use of org.jbei.ice.storage.hibernate.dao.ShotgunSequenceDAO in project ice by JBEI.
the class FileResource method getShotgunSequenceFile.
@GET
@Path("shotgunsequence/{fileId}")
public Response getShotgunSequenceFile(@PathParam("fileId") String fileId, @QueryParam("sid") String sid) {
ShotgunSequenceDAO dao = DAOFactory.getShotgunSequenceDAO();
ShotgunSequence shotgunSequence = dao.getByFileId(fileId);
try {
final File file = dao.getFile(fileId);
return addHeaders(Response.ok(file), shotgunSequence.getFilename());
} catch (Exception e) {
Logger.error(e);
return Response.serverError().build();
}
}
Aggregations