use of org.jbei.ice.storage.model.Sample in project ice by JBEI.
the class SampleCreator method createSampleObject.
/**
* Create a {@link Sample} object.
* <p/>
* Generates the UUID and the time stamps.
*
* @param label display label for sample
* @param depositor name of the depositor
* @param notes associated notes
* @return {@link Sample}
*/
public static Sample createSampleObject(String label, String depositor, String notes) {
String uuid = Utils.generateUUID();
Date creationTime = Calendar.getInstance().getTime();
Sample sample = new Sample();
sample.setLabel(label);
sample.setDepositor(depositor);
sample.setNotes(notes);
sample.setUuid(uuid);
sample.setCreationTime(creationTime);
sample.setModificationTime(null);
return sample;
}
use of org.jbei.ice.storage.model.Sample in project ice by JBEI.
the class SampleDAO method getSampleCount.
public int getSampleCount(Entry entry) {
try {
CriteriaQuery<Long> query = getBuilder().createQuery(Long.class);
Root<Sample> from = query.from(Sample.class);
query.select(getBuilder().countDistinct(from.get("id")));
query.where(getBuilder().equal(from.get("entry"), entry));
return currentSession().createQuery(query).uniqueResult().intValue();
} catch (HibernateException e) {
Logger.error(e);
throw new DAOException(e);
}
}
use of org.jbei.ice.storage.model.Sample in project ice by JBEI.
the class SampleDAO method getSamplesByStorage.
/**
* Retrieve {@link Sample} objects associated with the given {@link Storage} object.
*
* @param storage
* @return ArrayList of Sample objects.
* @throws DAOException
*/
public List<Sample> getSamplesByStorage(Storage storage) {
try {
CriteriaQuery<Sample> query = getBuilder().createQuery(Sample.class);
Root<Sample> from = query.from(Sample.class);
query.where(getBuilder().equal(from.get("storage"), storage));
return currentSession().createQuery(query).list();
} catch (HibernateException e) {
Logger.error(e);
throw new DAOException("Failed to retrieve sample by storage id: " + storage.getId(), e);
}
}
use of org.jbei.ice.storage.model.Sample in project ice by JBEI.
the class SampleDAO method getSamplesByEntry.
public List<Sample> getSamplesByEntry(Entry entry) {
try {
CriteriaQuery<Sample> query = getBuilder().createQuery(Sample.class);
Root<Sample> from = query.from(Sample.class);
query.where(getBuilder().equal(from.get("entry"), entry));
return currentSession().createQuery(query).list();
} catch (HibernateException e) {
Logger.error(e);
throw new DAOException(e);
}
}
use of org.jbei.ice.storage.model.Sample in project ice by JBEI.
the class SampleDAO method hasSample.
public boolean hasSample(Entry entry) {
try {
CriteriaQuery<Long> query = getBuilder().createQuery(Long.class);
Root<Sample> from = query.from(Sample.class);
query.select(getBuilder().countDistinct(from.get("id")));
query.where(getBuilder().equal(from.get("entry"), entry));
return currentSession().createQuery(query).setMaxResults(1).uniqueResult() > 0;
} catch (HibernateException e) {
Logger.error(e);
throw new DAOException(e);
}
}
Aggregations