Search in sources :

Example 1 with ShotgunSequence

use of org.jbei.ice.storage.model.ShotgunSequence 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 ShotgunSequence

use of org.jbei.ice.storage.model.ShotgunSequence 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)

Example 3 with ShotgunSequence

use of org.jbei.ice.storage.model.ShotgunSequence in project ice by JBEI.

the class ShotgunSequenceDAO method getShotgunSequenceCount.

public int getShotgunSequenceCount(Entry entry) {
    try {
        CriteriaQuery<Long> query = getBuilder().createQuery(Long.class);
        Root<ShotgunSequence> from = query.from(ShotgunSequence.class);
        query.select(getBuilder().countDistinct(from.get("id"))).where(getBuilder().equal(from.get("entry"), entry));
        return currentSession().createQuery(query).uniqueResult().intValue();
    } catch (HibernateException he) {
        Logger.error(he);
        throw new DAOException(he);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) ShotgunSequence(org.jbei.ice.storage.model.ShotgunSequence) HibernateException(org.hibernate.HibernateException)

Example 4 with ShotgunSequence

use of org.jbei.ice.storage.model.ShotgunSequence in project ice by JBEI.

the class ShotgunSequenceDAO method getByFileId.

public ShotgunSequence getByFileId(String fileId) {
    try {
        CriteriaQuery<ShotgunSequence> query = getBuilder().createQuery(ShotgunSequence.class);
        Root<ShotgunSequence> from = query.from(ShotgunSequence.class);
        query.where(getBuilder().equal(from.get("fileId"), fileId));
        return currentSession().createQuery(query).uniqueResult();
    } catch (HibernateException he) {
        Logger.error(he);
        throw new DAOException(he);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) ShotgunSequence(org.jbei.ice.storage.model.ShotgunSequence) HibernateException(org.hibernate.HibernateException)

Example 5 with ShotgunSequence

use of org.jbei.ice.storage.model.ShotgunSequence in project ice by JBEI.

the class ShotgunSequenceDAO method getByEntry.

public List<ShotgunSequence> getByEntry(Entry entry) {
    try {
        CriteriaQuery<ShotgunSequence> query = getBuilder().createQuery(ShotgunSequence.class);
        Root<ShotgunSequence> from = query.from(ShotgunSequence.class);
        query.where(getBuilder().equal(from.get("entry"), entry));
        query.orderBy(getBuilder().asc(from.get("creationTime")));
        return currentSession().createQuery(query).list();
    } catch (HibernateException he) {
        Logger.error(he);
        throw new DAOException(he);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) ShotgunSequence(org.jbei.ice.storage.model.ShotgunSequence) HibernateException(org.hibernate.HibernateException)

Aggregations

ShotgunSequence (org.jbei.ice.storage.model.ShotgunSequence)5 HibernateException (org.hibernate.HibernateException)3 DAOException (org.jbei.ice.storage.DAOException)3 ShotgunSequenceDAO (org.jbei.ice.storage.hibernate.dao.ShotgunSequenceDAO)2 ArrayList (java.util.ArrayList)1 ShotgunSequenceDTO (org.jbei.ice.lib.dto.ShotgunSequenceDTO)1 EntryDAO (org.jbei.ice.storage.hibernate.dao.EntryDAO)1 Entry (org.jbei.ice.storage.model.Entry)1