Search in sources :

Example 1 with ShotgunSequenceDAO

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;
}
Also used : Entry(org.jbei.ice.storage.model.Entry) ShotgunSequence(org.jbei.ice.storage.model.ShotgunSequence) ArrayList(java.util.ArrayList) ShotgunSequenceDAO(org.jbei.ice.storage.hibernate.dao.ShotgunSequenceDAO) EntryDAO(org.jbei.ice.storage.hibernate.dao.EntryDAO) ShotgunSequenceDTO(org.jbei.ice.lib.dto.ShotgunSequenceDTO)

Example 2 with ShotgunSequenceDAO

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);
}
Also used : Entry(org.jbei.ice.storage.model.Entry) ShotgunSequenceDAO(org.jbei.ice.storage.hibernate.dao.ShotgunSequenceDAO) Date(java.util.Date) IOException(java.io.IOException) PermissionException(org.jbei.ice.lib.access.PermissionException) EntryDAO(org.jbei.ice.storage.hibernate.dao.EntryDAO)

Example 3 with ShotgunSequenceDAO

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();
    }
}
Also used : ShotgunSequence(org.jbei.ice.storage.model.ShotgunSequence) ShotgunSequenceDAO(org.jbei.ice.storage.hibernate.dao.ShotgunSequenceDAO)

Aggregations

ShotgunSequenceDAO (org.jbei.ice.storage.hibernate.dao.ShotgunSequenceDAO)3 EntryDAO (org.jbei.ice.storage.hibernate.dao.EntryDAO)2 Entry (org.jbei.ice.storage.model.Entry)2 ShotgunSequence (org.jbei.ice.storage.model.ShotgunSequence)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 PermissionException (org.jbei.ice.lib.access.PermissionException)1 ShotgunSequenceDTO (org.jbei.ice.lib.dto.ShotgunSequenceDTO)1