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;
}
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;
}
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;
}
}
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;
}
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;
}
Aggregations