use of org.jbei.ice.storage.DAOException 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.DAOException in project ice by JBEI.
the class StorageDAO method retrieveStorageByIndex.
/**
* Retrieve a {@link Storage} object by its index and {@link SampleType} fields.
*
* @param index index value
* @param type storage type
* @return List of Storage objects
*/
public List<Storage> retrieveStorageByIndex(String index, SampleType type) {
try {
CriteriaQuery<Storage> query = getBuilder().createQuery(Storage.class);
Root<Storage> from = query.from(Storage.class);
query.where(getBuilder().equal(from.get("index"), index), getBuilder().equal(from.get("storageType"), type));
return currentSession().createQuery(query).list();
} catch (Exception e) {
String msg = "Could not get Storage by index: " + index + " " + e.toString();
Logger.error(msg, e);
throw new DAOException(msg);
}
}
use of org.jbei.ice.storage.DAOException in project ice by JBEI.
the class SequenceFeatureDAO method getEntryIdsByFeature.
public List<Long> getEntryIdsByFeature(Feature feature) {
try {
CriteriaQuery<Long> query = getBuilder().createQuery(Long.class);
Root<SequenceFeature> from = query.from(SequenceFeature.class);
Join<SequenceFeature, Sequence> sequence = from.join("sequence");
Join<Sequence, Entry> entry = sequence.join("entry");
query.select(entry.get("id")).where(getBuilder().equal(from.get("feature"), feature));
return currentSession().createQuery(query).list();
} catch (HibernateException he) {
Logger.error(he);
throw new DAOException(he);
}
}
use of org.jbei.ice.storage.DAOException in project ice by JBEI.
the class ShotgunSequenceDAO method delete.
public void delete(Path dir, ShotgunSequence shotgunSequence) {
try {
super.delete(shotgunSequence);
Files.deleteIfExists(Paths.get(dir.toString(), shotgunSequence.getFileId()));
} catch (IOException e) {
throw new DAOException("Failed to delete Shotgun Sequence file!", e);
}
}
use of org.jbei.ice.storage.DAOException in project ice by JBEI.
the class RequestRetriever method removeSampleFromCart.
public SampleRequest removeSampleFromCart(String userId, long requestId) {
try {
Request request = dao.get(requestId);
if (request == null)
return null;
if (!request.getAccount().getEmail().equalsIgnoreCase(userId))
return null;
Logger.info(userId + ": Removing sample from cart for entry " + request.getEntry().getId());
dao.delete(request);
return request.toDataTransferObject();
} catch (DAOException de) {
Logger.error(de);
return null;
}
}
Aggregations