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);
}
}
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);
}
}
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);
}
}
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();
}
Aggregations