Search in sources :

Example 1 with TraceSequence

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

the class TraceSequenceDAO method getByEntry.

/**
     * Retrieve all {@link TraceSequence} objects associated with the given {@link Entry} object
     * using the paging parameters, ordered by creation time in ascending order
     *
     * @param entry entry whose trace sequences are being retrieved
     * @param start start for traces retrieval
     * @param limit maximum number of trace records to retrieve
     * @return List of TraceSequence objects.
     * @throws DAOException
     */
public List<TraceSequence> getByEntry(Entry entry, int start, int limit) {
    try {
        CriteriaQuery<TraceSequence> query = getBuilder().createQuery(TraceSequence.class);
        Root<TraceSequence> from = query.from(TraceSequence.class);
        query.where(getBuilder().equal(from.get("entry"), entry));
        query.orderBy(getBuilder().asc(from.get("creationTime")));
        return currentSession().createQuery(query).setMaxResults(limit).setFirstResult(start).list();
    } catch (HibernateException he) {
        Logger.error(he);
        throw new DAOException(he);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) TraceSequence(org.jbei.ice.storage.model.TraceSequence) HibernateException(org.hibernate.HibernateException)

Example 2 with TraceSequence

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

the class TraceSequenceDAO method getByFileId.

/**
     * Retrieve the {@link TraceSequence} object by its fileId.
     *
     * @param fileId unique file identifier
     * @return {@link Optional} container that contains the trace sequence if found.
     * @throws DAOException
     */
public Optional<TraceSequence> getByFileId(String fileId) {
    try {
        CriteriaQuery<TraceSequence> query = getBuilder().createQuery(TraceSequence.class);
        Root<TraceSequence> from = query.from(TraceSequence.class);
        query.where(getBuilder().equal(from.get("fileId"), fileId));
        return currentSession().createQuery(query).uniqueResultOptional();
    } catch (HibernateException e) {
        throw new DAOException("Failed to retrieve entry by fileId: " + fileId, e);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) TraceSequence(org.jbei.ice.storage.model.TraceSequence) HibernateException(org.hibernate.HibernateException)

Example 3 with TraceSequence

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

the class TraceSequenceDAO method getCountByEntry.

/**
     * Get number of trace sequences available for specified entry
     *
     * @param entry entry whose entry count is being retrieved
     * @return number of traces available for the specified entry
     */
public int getCountByEntry(Entry entry) {
    try {
        CriteriaQuery<Long> query = getBuilder().createQuery(Long.class);
        Root<TraceSequence> from = query.from(TraceSequence.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) TraceSequence(org.jbei.ice.storage.model.TraceSequence) HibernateException(org.hibernate.HibernateException)

Example 4 with TraceSequence

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

the class FileResource method getTraceSequenceFile.

@GET
@Path("trace/{fileId}")
public Response getTraceSequenceFile(@PathParam("fileId") String fileId, @QueryParam("sid") String sid) {
    final SequenceAnalysisController sequenceAnalysisController = new SequenceAnalysisController();
    final TraceSequence traceSequence = sequenceAnalysisController.getTraceSequenceByFileId(fileId);
    if (traceSequence != null) {
        final File file = sequenceAnalysisController.getFile(traceSequence);
        return addHeaders(Response.ok(file), traceSequence.getFilename());
    }
    return Response.serverError().build();
}
Also used : TraceSequence(org.jbei.ice.storage.model.TraceSequence) SequenceAnalysisController(org.jbei.ice.lib.entry.sequence.SequenceAnalysisController)

Aggregations

TraceSequence (org.jbei.ice.storage.model.TraceSequence)4 HibernateException (org.hibernate.HibernateException)3 DAOException (org.jbei.ice.storage.DAOException)3 SequenceAnalysisController (org.jbei.ice.lib.entry.sequence.SequenceAnalysisController)1