Search in sources :

Example 1 with TaxonNameParts

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());
}
Also used : OrderHint(eu.etaxonomy.cdm.persistence.query.OrderHint) TaxonNameParts(eu.etaxonomy.cdm.persistence.dto.TaxonNameParts) CdmIntegrationTest(eu.etaxonomy.cdm.test.integration.CdmIntegrationTest) Test(org.junit.Test)

Example 2 with TaxonNameParts

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;
}
Also used : TaxonNameParts(eu.etaxonomy.cdm.persistence.dto.TaxonNameParts) Query(org.hibernate.Query) AuditQuery(org.hibernate.envers.query.AuditQuery)

Example 3 with TaxonNameParts

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());
}
Also used : OrderHint(eu.etaxonomy.cdm.persistence.query.OrderHint) TaxonNameParts(eu.etaxonomy.cdm.persistence.dto.TaxonNameParts) TaxonName(eu.etaxonomy.cdm.model.name.TaxonName) CdmIntegrationTest(eu.etaxonomy.cdm.test.integration.CdmIntegrationTest) Test(org.junit.Test)

Aggregations

TaxonNameParts (eu.etaxonomy.cdm.persistence.dto.TaxonNameParts)3 OrderHint (eu.etaxonomy.cdm.persistence.query.OrderHint)2 CdmIntegrationTest (eu.etaxonomy.cdm.test.integration.CdmIntegrationTest)2 Test (org.junit.Test)2 TaxonName (eu.etaxonomy.cdm.model.name.TaxonName)1 Query (org.hibernate.Query)1 AuditQuery (org.hibernate.envers.query.AuditQuery)1