use of eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache in project cdmlib by cybertaxonomy.
the class OccurrenceDaoHibernateImpl method getFieldUnitUuidAndTitleCache.
@Override
public List<UuidAndTitleCache<FieldUnit>> getFieldUnitUuidAndTitleCache() {
List<UuidAndTitleCache<FieldUnit>> list = new ArrayList<>();
Session session = getSession();
Query query = session.createQuery("select uuid, id, titleCache from " + type.getSimpleName() + " where dtype = " + FieldUnit.class.getSimpleName());
@SuppressWarnings("unchecked") List<Object[]> result = query.list();
for (Object[] object : result) {
list.add(new UuidAndTitleCache<FieldUnit>(FieldUnit.class, (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 OccurrenceDaoHibernateImpl method getDerivedUnitUuidAndTitleCache.
@Override
public List<UuidAndTitleCache<DerivedUnit>> getDerivedUnitUuidAndTitleCache(Integer limit, String pattern) {
List<UuidAndTitleCache<DerivedUnit>> list = new ArrayList<>();
Session session = getSession();
String hql = "SELECT uuid, id, titleCache " + " FROM " + type.getSimpleName() + " WHERE NOT dtype = " + FieldUnit.class.getSimpleName();
Query query;
if (pattern != null) {
pattern = pattern.replace("*", "%");
pattern = pattern.replace("?", "_");
pattern = pattern + "%";
query = session.createQuery(hql + " AND titleCache like :pattern");
query.setParameter("pattern", pattern);
} else {
query = session.createQuery(hql);
}
if (limit != null) {
query.setMaxResults(limit);
}
@SuppressWarnings("unchecked") List<Object[]> result = query.list();
for (Object[] object : result) {
list.add(new UuidAndTitleCache<DerivedUnit>(DerivedUnit.class, (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 TermNodeDaoImpl method getUuidAndTitleCache.
protected List<UuidAndTitleCache<TermNode>> getUuidAndTitleCache(Query query) {
List<UuidAndTitleCache<TermNode>> list = new ArrayList<>();
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;
}
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;
}
use of eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache in project cdmlib by cybertaxonomy.
the class ReferenceDaoHibernateImpl method getUuidAndTitle.
@Override
public List<UuidAndTitleCache<Reference>> getUuidAndTitle() {
List<UuidAndTitleCache<Reference>> list = new ArrayList<UuidAndTitleCache<Reference>>();
Session session = getSession();
Query query = session.createQuery("select uuid, id, titleCache from " + type.getSimpleName());
@SuppressWarnings("unchecked") List<Object[]> result = query.list();
for (Object[] object : result) {
list.add(new UuidAndTitleCache<Reference>(type, (UUID) object[0], (Integer) object[1], (String) object[2]));
}
return list;
}
Aggregations