use of eu.etaxonomy.cdm.persistence.dto.TaxonNameParts in project cdmlib by cybertaxonomy.
the class TaxonNameDaoHibernateImplTest method testFindTaxonNameParts_rankBelowSpecies.
@Test
public void testFindTaxonNameParts_rankBelowSpecies() {
Integer pageSize = 10;
Integer pageIndex = 0;
// Cryptocoryne x purpurea nothovar borneoensis
// Cryptocoryne cordata var. zonata
List<TaxonNameParts> results = taxonNameDao.findTaxonNameParts(Optional.of("Cryptocoryne"), null, null, Optional.of("borneo*"), Rank.VARIETY(), null, pageSize, pageIndex, Arrays.asList(new OrderHint("specificEpithet", SortOrder.ASCENDING)));
assertEquals(1, results.size());
// now also with "infraGenericEpithet is null AND specificEpithet = purpurea"
results = taxonNameDao.findTaxonNameParts(Optional.of("Cryptocoryne"), Optional.empty(), Optional.of("purpurea"), Optional.of("borneo*"), Rank.VARIETY(), null, pageSize, pageIndex, Arrays.asList(new OrderHint("specificEpithet", SortOrder.ASCENDING)));
assertEquals(1, results.size());
}
use of eu.etaxonomy.cdm.persistence.dto.TaxonNameParts in project cdmlib by cybertaxonomy.
the class TaxonNameDaoHibernateImpl method findTaxonNameParts.
@Override
public List<TaxonNameParts> findTaxonNameParts(Optional<String> genusOrUninomial, Optional<String> infraGenericEpithet, Optional<String> specificEpithet, Optional<String> infraSpecificEpithet, Rank rank, Collection<UUID> excludedNamesUuids, Integer pageSize, Integer pageIndex, List<OrderHint> orderHints) {
StringBuilder hql = prepareFindTaxonNameParts(false, genusOrUninomial, infraGenericEpithet, specificEpithet, infraSpecificEpithet, rank, excludedNamesUuids);
addOrder(hql, "n", orderHints);
Query query = getSession().createQuery(hql.toString());
if (rank != null) {
query.setParameter("rank", rank);
}
if (excludedNamesUuids != null && excludedNamesUuids.size() > 0) {
query.setParameterList("excludedNamesUuids", excludedNamesUuids);
}
setPagingParameter(query, pageSize, pageIndex);
@SuppressWarnings("unchecked") List<TaxonNameParts> result = query.list();
return result;
}
use of eu.etaxonomy.cdm.persistence.dto.TaxonNameParts in project cdmlib by cybertaxonomy.
the class TaxonNameDaoHibernateImplTest method testFindTaxonNameParts_genusOrUninomial_wildcard.
@Test
public void testFindTaxonNameParts_genusOrUninomial_wildcard() {
Integer pageSize = 10;
Integer pageIndex = 0;
List<TaxonNameParts> results = taxonNameDao.findTaxonNameParts(Optional.of("Atro*"), null, null, null, Rank.GENUS(), null, pageSize, pageIndex, Arrays.asList(new OrderHint("genusOrUninomial", SortOrder.ASCENDING)));
assertNotNull(results);
assertFalse(results.isEmpty());
assertEquals(3, results.size());
TaxonName n_atropos_agassiz = taxonNameDao.load(atroposUuid);
results = taxonNameDao.findTaxonNameParts(Optional.of("Atro*"), null, null, null, Rank.GENUS(), Arrays.asList(n_atropos_agassiz.getUuid()), pageSize, pageIndex, Arrays.asList(new OrderHint("genusOrUninomial", SortOrder.ASCENDING)));
assertNotNull(results);
assertFalse(results.isEmpty());
assertEquals(2, results.size());
results = taxonNameDao.findTaxonNameParts(Optional.of("Atro*"), null, null, null, Rank.SPECIES(), null, pageSize, pageIndex, Arrays.asList(new OrderHint("genusOrUninomial", SortOrder.ASCENDING)));
assertNotNull(results);
assertTrue(results.isEmpty());
}
Aggregations