Search in sources :

Example 11 with UuidAndTitleCache

use of eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache in project cdmlib by cybertaxonomy.

the class DescriptiveDataSetDao method getDescriptiveDataSetUuidAndTitleCache.

/**
 * {@inheritDoc}
 */
@Override
public List<UuidAndTitleCache<DescriptiveDataSet>> getDescriptiveDataSetUuidAndTitleCache(Integer limitOfInitialElements, String pattern) {
    Session session = getSession();
    String queryString = "SELECT uuid, id, label FROM DescriptiveDataSet ";
    if (pattern != null) {
        queryString += " WHERE ";
        queryString += " label LIKE :pattern";
    }
    Query query;
    query = session.createQuery(queryString);
    if (limitOfInitialElements != null) {
        query.setMaxResults(limitOfInitialElements);
    }
    if (pattern != null) {
        pattern = pattern.replace("*", "%");
        pattern = pattern.replace("?", "_");
        pattern = pattern + "%";
        query.setParameter("pattern", pattern);
    }
    @SuppressWarnings("unchecked") List<Object[]> result = query.list();
    List<UuidAndTitleCache<DescriptiveDataSet>> list = new ArrayList<>();
    for (Object[] object : result) {
        list.add(new UuidAndTitleCache<DescriptiveDataSet>(DescriptiveDataSet.class, (UUID) object[0], (Integer) object[1], (String) object[2]));
    }
    return list;
}
Also used : Query(org.hibernate.Query) ArrayList(java.util.ArrayList) UuidAndTitleCache(eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache) DescriptiveDataSet(eu.etaxonomy.cdm.model.description.DescriptiveDataSet) UUID(java.util.UUID) Session(org.hibernate.Session)

Example 12 with UuidAndTitleCache

use of eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache in project cdmlib by cybertaxonomy.

the class AmplificationDaoHibernateImpl method getAmplificationUuidAndLabelCache.

@Override
public List<UuidAndTitleCache<Amplification>> getAmplificationUuidAndLabelCache(Integer limit, String pattern) {
    List<UuidAndTitleCache<Amplification>> list = new ArrayList<UuidAndTitleCache<Amplification>>();
    Session session = getSession();
    Query query;
    if (pattern != null) {
        query = session.createQuery("select uuid, id, labelCache from Amplification where labelCache like :pattern");
        query.setParameter("pattern", pattern);
    } else {
        query = session.createQuery("select uuid, id, labelCache from Amplification");
    }
    if (limit != null) {
        query.setMaxResults(limit);
    }
    @SuppressWarnings("unchecked") List<Object[]> result = query.list();
    for (Object[] object : result) {
        list.add(new UuidAndTitleCache<Amplification>(Amplification.class, (UUID) object[0], (Integer) object[1], (String) object[2]));
    }
    return list;
}
Also used : Query(org.hibernate.Query) ArrayList(java.util.ArrayList) UuidAndTitleCache(eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache) Amplification(eu.etaxonomy.cdm.model.molecular.Amplification) UUID(java.util.UUID) Session(org.hibernate.Session)

Example 13 with UuidAndTitleCache

use of eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache in project cdmlib by cybertaxonomy.

the class PrimerDaoHibernateImpl method getPrimerUuidAndTitleCache.

@Override
public List<UuidAndTitleCache<Primer>> getPrimerUuidAndTitleCache() {
    List<UuidAndTitleCache<Primer>> list = new ArrayList<UuidAndTitleCache<Primer>>();
    Session session = getSession();
    Query query = session.createQuery("select uuid, id, label from Primer");
    @SuppressWarnings("unchecked") List<Object[]> result = query.list();
    for (Object[] object : result) {
        list.add(new UuidAndTitleCache<Primer>(Primer.class, (UUID) object[0], (Integer) object[1], (String) object[2]));
    }
    return list;
}
Also used : Query(org.hibernate.Query) ArrayList(java.util.ArrayList) Primer(eu.etaxonomy.cdm.model.molecular.Primer) UuidAndTitleCache(eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache) UUID(java.util.UUID) Session(org.hibernate.Session)

Example 14 with UuidAndTitleCache

use of eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache in project cdmlib by cybertaxonomy.

the class PrimerDaoHibernateImpl method getPrimerUuidAndTitleCache.

/**
 * {@inheritDoc}
 */
@Override
public List<UuidAndTitleCache<Primer>> getPrimerUuidAndTitleCache(Integer limitOfInitialElements, String pattern) {
    Session session = getSession();
    String queryString = "SELECT uuid, id, label FROM Prime ";
    if (pattern != null) {
        queryString += " WHERE ";
        queryString += " label LIKE :pattern";
    }
    Query query;
    query = session.createQuery(queryString);
    if (limitOfInitialElements != null) {
        query.setMaxResults(limitOfInitialElements);
    }
    if (pattern != null) {
        pattern = pattern.replace("*", "%");
        pattern = pattern.replace("?", "_");
        pattern = pattern + "%";
        query.setParameter("pattern", pattern);
    }
    @SuppressWarnings("unchecked") List<Object[]> result = query.list();
    List<UuidAndTitleCache<Primer>> list = new ArrayList<>();
    for (Object[] object : result) {
        list.add(new UuidAndTitleCache<Primer>(Primer.class, (UUID) object[0], (Integer) object[1], (String) object[2]));
    }
    return list;
}
Also used : Query(org.hibernate.Query) ArrayList(java.util.ArrayList) Primer(eu.etaxonomy.cdm.model.molecular.Primer) UuidAndTitleCache(eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache) UUID(java.util.UUID) Session(org.hibernate.Session)

Example 15 with UuidAndTitleCache

use of eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache in project cdmlib by cybertaxonomy.

the class TermServiceImpl method getUuidAndTitleCacheNamedArea.

@Override
@Transactional(readOnly = true)
public List<UuidAndTitleCache<NamedArea>> getUuidAndTitleCacheNamedArea(List<TermVocabulary> vocs, Integer limit, String pattern, Language lang) {
    List<NamedArea> areas = dao.list(NamedArea.class, vocs, limit, pattern);
    List<UuidAndTitleCache<NamedArea>> result = new ArrayList<>();
    UuidAndTitleCache<NamedArea> uuidAndTitleCache;
    for (NamedArea area : areas) {
        uuidAndTitleCache = new UuidAndTitleCache<>(area.getUuid(), area.getId(), NamedArea.labelWithLevel(area, lang));
        result.add(uuidAndTitleCache);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) NamedArea(eu.etaxonomy.cdm.model.location.NamedArea) UuidAndTitleCache(eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

UuidAndTitleCache (eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache)38 ArrayList (java.util.ArrayList)31 UUID (java.util.UUID)27 Query (org.hibernate.Query)17 Session (org.hibernate.Session)10 AuditQuery (org.hibernate.envers.query.AuditQuery)7 CdmTransactionalIntegrationTest (eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest)5 Test (org.junit.Test)5 IdentifiableEntity (eu.etaxonomy.cdm.model.common.IdentifiableEntity)4 Reference (eu.etaxonomy.cdm.model.reference.Reference)4 Taxon (eu.etaxonomy.cdm.model.taxon.Taxon)4 SortableTaxonNodeQueryResult (eu.etaxonomy.cdm.persistence.dto.SortableTaxonNodeQueryResult)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 FullTextSession (org.hibernate.search.FullTextSession)4 DataSet (org.unitils.dbunit.annotation.DataSet)4 LanguageString (eu.etaxonomy.cdm.model.common.LanguageString)3 TreeIndex (eu.etaxonomy.cdm.model.common.TreeIndex)3 Primer (eu.etaxonomy.cdm.model.molecular.Primer)3 TaxonName (eu.etaxonomy.cdm.model.name.TaxonName)3