Search in sources :

Example 31 with UuidAndTitleCache

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

the class ReferenceDaoHibernateImpl method getUuidAndTitle.

@Override
public List<UuidAndTitleCache<Reference>> getUuidAndTitle(Set<UUID> uuids, ReferenceType refType) {
    List<Reference> result = getReferenceListForUuids(uuids, refType);
    List<UuidAndTitleCache<Reference>> list = new ArrayList<>();
    for (Reference object : result) {
        list.add(new UuidAndTitleCache<Reference>(type, object.getUuid(), object.getId(), object.getTitleCache()));
    }
    return list;
}
Also used : Reference(eu.etaxonomy.cdm.model.reference.Reference) ArrayList(java.util.ArrayList) UuidAndTitleCache(eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache)

Example 32 with UuidAndTitleCache

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

the class OccurrenceDaoHibernateImpl method listUuidAndTitleCacheByAssociatedTaxon.

@Override
public <T extends SpecimenOrObservationBase> List<UuidAndTitleCache<SpecimenOrObservationBase>> listUuidAndTitleCacheByAssociatedTaxon(Class<T> clazz, Taxon associatedTaxon, Integer limit, Integer start, List<OrderHint> orderHints) {
    Query query = createSpecimenQuery("sob.uuid, sob.id, sob.titleCache", clazz, associatedTaxon, limit, start, orderHints);
    if (query == null) {
        return Collections.emptyList();
    }
    List<UuidAndTitleCache<SpecimenOrObservationBase>> list = new ArrayList<>();
    @SuppressWarnings("unchecked") List<Object[]> result = query.list();
    for (Object[] object : result) {
        list.add(new UuidAndTitleCache<>((UUID) object[0], (Integer) object[1], (String) object[2]));
    }
    return list;
}
Also used : Query(org.hibernate.Query) AuditQuery(org.hibernate.envers.query.AuditQuery) ArrayList(java.util.ArrayList) UuidAndTitleCache(eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache) UUID(java.util.UUID)

Example 33 with UuidAndTitleCache

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

the class TaxonNameDaoHibernateImpl method getUuidAndTitleCacheOfNames.

@Override
public List<UuidAndTitleCache> getUuidAndTitleCacheOfNames(Integer limit, String pattern) {
    String queryString = "SELECT uuid, id, fullTitleCache FROM TaxonName LIMIT " + limit;
    @SuppressWarnings("unchecked") List<Object[]> result = getSession().createSQLQuery(queryString).list();
    if (result.size() == 0) {
        return null;
    } else {
        List<UuidAndTitleCache> list = new ArrayList<>(result.size());
        for (Object object : result) {
            Object[] objectArray = (Object[]) object;
            UUID uuid = UUID.fromString((String) objectArray[0]);
            Integer id = (Integer) objectArray[1];
            String titleCache = (String) objectArray[2];
            list.add(new UuidAndTitleCache(type, uuid, id, titleCache));
        }
        return list;
    }
}
Also used : ArrayList(java.util.ArrayList) UuidAndTitleCache(eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache) UUID(java.util.UUID)

Example 34 with UuidAndTitleCache

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

the class ClassificationServiceImpl method groupTaxaByMarkedParents.

@Override
public List<GroupedTaxonDTO> groupTaxaByMarkedParents(List<UUID> originalTaxonUuids, UUID classificationUuid, MarkerType markerType, Boolean flag) {
    List<GroupedTaxonDTO> result = new ArrayList<>();
    // get treeindex for each taxonUUID
    Map<UUID, TreeIndex> taxonIdTreeIndexMap = dao.treeIndexForTaxonUuids(classificationUuid, originalTaxonUuids);
    // get all marked tree indexes
    Set<TreeIndex> markedTreeIndexes = dao.getMarkedTreeIndexes(markerType, flag);
    Map<TreeIndex, TreeIndex> groupedMap = TreeIndex.group(markedTreeIndexes, taxonIdTreeIndexMap.values());
    Set<TreeIndex> notNullGroups = new HashSet<>(groupedMap.values());
    notNullGroups.remove(null);
    // get taxonInfo for treeIndexes
    Map<TreeIndex, UuidAndTitleCache<?>> treeIndexTaxonIdMap = taxonNodeDao.taxonUuidsForTreeIndexes(notNullGroups);
    // fill result list
    for (UUID originalTaxonUuid : originalTaxonUuids) {
        GroupedTaxonDTO item = new GroupedTaxonDTO();
        result.add(item);
        item.setTaxonUuid(originalTaxonUuid);
        TreeIndex toBeGroupedTreeIndex = taxonIdTreeIndexMap.get(originalTaxonUuid);
        TreeIndex groupTreeIndex = groupedMap.get(toBeGroupedTreeIndex);
        UuidAndTitleCache<?> uuidAndLabel = treeIndexTaxonIdMap.get(groupTreeIndex);
        if (uuidAndLabel != null) {
            item.setGroupTaxonUuid(uuidAndLabel.getUuid());
            item.setGroupTaxonName(uuidAndLabel.getTitleCache());
        }
    }
    return result;
}
Also used : TreeIndex(eu.etaxonomy.cdm.model.common.TreeIndex) GroupedTaxonDTO(eu.etaxonomy.cdm.api.service.dto.GroupedTaxonDTO) ArrayList(java.util.ArrayList) UuidAndTitleCache(eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache) UUID(java.util.UUID) HashSet(java.util.HashSet)

Example 35 with UuidAndTitleCache

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

the class IdentifiableDaoBase method getUuidAndTitleCache.

protected <E extends IAnnotatableEntity> List<UuidAndTitleCache<E>> getUuidAndTitleCache(Query query) {
    List<UuidAndTitleCache<E>> list = new ArrayList<>();
    @SuppressWarnings("unchecked") List<Object> result = query.list();
    for (Object obj : result) {
        if (obj instanceof SortableTaxonNodeQueryResult) {
            SortableTaxonNodeQueryResult stnqr = (SortableTaxonNodeQueryResult) obj;
            list.add(new UuidAndTitleCache<>(stnqr.getTaxonNodeUuid(), stnqr.getTaxonNodeId(), stnqr.getTaxonTitleCache()));
        } else {
            Object[] object = (Object[]) obj;
            list.add(new UuidAndTitleCache<>((UUID) object[0], (Integer) object[1], (String) object[2]));
        }
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) UuidAndTitleCache(eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache) UUID(java.util.UUID) SortableTaxonNodeQueryResult(eu.etaxonomy.cdm.persistence.dto.SortableTaxonNodeQueryResult)

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