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