use of org.jbei.ice.storage.model.Feature in project ice by JBEI.
the class FeatureDAO method getFeaturesGroupBy.
public Map<String, List<Feature>> getFeaturesGroupBy(int offset, int size) {
Map<String, List<Feature>> results = new HashMap<>();
try {
CriteriaQuery<String> query = getBuilder().createQuery(String.class);
Root<Feature> from = query.from(Feature.class);
query.select(from.get("name")).distinct(true);
query.where(getBuilder().isNotNull(from.get("name")), getBuilder().notEqual(from.get("name"), ""));
query.orderBy(getBuilder().asc(from.get("name")));
List<String> names = currentSession().createQuery(query).setFirstResult(offset).setMaxResults(size).list();
for (String name : names) {
CriteriaQuery<Feature> featureQuery = getBuilder().createQuery(Feature.class);
Root<Feature> root = featureQuery.from(Feature.class);
featureQuery.where(getBuilder().equal(getBuilder().lower(root.get("name")), name.toLowerCase()));
List<Feature> result = currentSession().createQuery(featureQuery).list();
results.put(name, result);
}
return results;
} catch (HibernateException he) {
Logger.error(he);
throw new DAOException(he);
}
}
use of org.jbei.ice.storage.model.Feature in project ice by JBEI.
the class FeatureDAO method getFeatureCount.
public long getFeatureCount(String filter) {
try {
CriteriaQuery<Long> query = getBuilder().createQuery(Long.class);
Root<Feature> from = query.from(Feature.class);
query.select(getBuilder().countDistinct(from.get("id")));
buildFilter(query, from, filter);
return currentSession().createQuery(query).uniqueResult();
} catch (HibernateException he) {
Logger.error(he);
throw new DAOException(he);
}
}
use of org.jbei.ice.storage.model.Feature in project ice by JBEI.
the class FeatureDAO method getFeatures.
public List<Feature> getFeatures(int offset, int size, String filter) {
try {
CriteriaQuery<Feature> query = getBuilder().createQuery(Feature.class);
Root<Feature> from = query.from(Feature.class);
buildFilter(query, from, filter);
return currentSession().createQuery(query).setFirstResult(offset).setMaxResults(size).list();
} catch (HibernateException he) {
Logger.error(he);
throw new DAOException(he);
}
}
use of org.jbei.ice.storage.model.Feature in project ice by JBEI.
the class FeatureDAO method getFeaturesGroupByCount.
public long getFeaturesGroupByCount() {
try {
CriteriaQuery<Long> query = getBuilder().createQuery(Long.class);
Root<Feature> from = query.from(Feature.class);
query.select(getBuilder().countDistinct(from.get("name"))).where(getBuilder().isNotNull(from.get("name")), getBuilder().notEqual(from.get("name"), ""));
return currentSession().createQuery(query).uniqueResult();
} catch (HibernateException he) {
Logger.error(he);
throw new DAOException(he);
}
}
use of org.jbei.ice.storage.model.Feature in project ice by JBEI.
the class AnnotationsTest method testCurate.
@Test
public void testCurate() throws Exception {
Account account = AccountCreator.createTestAccount("AnnotationsTest.testCurate", true);
Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
Assert.assertNotNull(plasmid);
SequenceDAO sequenceDAO = new SequenceDAO();
Assert.assertFalse(sequenceDAO.hasSequence(plasmid.getId()));
FeaturedDNASequence dnaSequence = GeneralParser.parse(sequenceString);
PartSequence partSequence = new PartSequence(account.getEmail(), plasmid.getRecordId());
partSequence.save(dnaSequence);
SequenceFeatureDAO sequenceFeatureDAO = new SequenceFeatureDAO();
List<SequenceFeature> sequenceFeatures = sequenceFeatureDAO.getEntrySequenceFeatures(plasmid);
Assert.assertEquals(1, sequenceFeatures.size());
Feature feature = sequenceFeatures.get(0).getFeature();
DNAFeature dnaFeature = feature.toDataTransferObject();
Curation curation = new Curation();
curation.setExclude(true);
dnaFeature.setCuration(curation);
List<DNAFeature> features = new ArrayList<>();
features.add(dnaFeature);
Annotations annotations = new Annotations(account.getEmail());
annotations.curate(features);
sequenceFeatures = sequenceFeatureDAO.getEntrySequenceFeatures(plasmid);
feature = sequenceFeatures.get(0).getFeature();
Assert.assertTrue(feature.getCuration().isExclude());
}
Aggregations