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