* a selection has been made.
*
* @return a list of <code>UuidAndTitleCache</code> instances
+ * @see #getUuidAndTitleCache(Class, Integer, String)
*/
public List<UuidAndTitleCache<T>> getUuidAndTitleCache(Integer limit, String pattern);
+
+ /**
+ * Like {@link #getUuidAndTitleCache(Integer, String)} but searching only on a subclass
+ * of the type handled by the DAO.
+ *
+ * @param clazz the (sub)class
+ * @param limit max number of results
+ * @param pattern search pattern
+
+ * @see #getUuidAndTitleCache(Integer, String)
+ */
+ public <S extends T> List<UuidAndTitleCache<S>> getUuidAndTitleCache(Class<S> clazz, Integer limit, String pattern);
+
+
/**
* Return a list of all uuids mapped to titleCache in the convenient <code>UuidAndTitleCache</code> object.
* Retrieving this list is considered to be significantly faster than initializing the fully fledged buiseness
@Override
public List<UuidAndTitleCache<T>> getUuidAndTitleCache(Integer limit, String pattern){
+ return getUuidAndTitleCache(type, limit, pattern);
+ }
+
+
+ @Override
+ public <S extends T> List<UuidAndTitleCache<S>> getUuidAndTitleCache(Class<S> clazz, Integer limit, String pattern){
Session session = getSession();
Query query = null;
if (pattern != null){
- query = session.createQuery("select uuid, id, titleCache from " + type.getSimpleName() +" where titleCache like :pattern");
+ query = session.createQuery("select uuid, id, titleCache from " + clazz.getSimpleName() +" where titleCache like :pattern");
pattern = pattern.replace("*", "%");
pattern = pattern.replace("?", "_");
pattern = pattern + "%";
query.setParameter("pattern", pattern);
} else {
- query = session.createQuery("select uuid, id, titleCache from " + type.getSimpleName() );
+ query = session.createQuery("select uuid, id, titleCache from " + clazz.getSimpleName() );
}
if (limit != null){
query.setMaxResults(limit);
@Override
public List<UuidAndTitleCache<T>> getUuidAndTitleCache(){
- return getUuidAndTitleCache(null, null);
+ return getUuidAndTitleCache(type, null, null);
}
protected <E extends IIdentifiableEntity> List<UuidAndTitleCache<E>> getUuidAndAbbrevTitleCache(Query query){
}
- public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCache(Integer limit, String pattern, boolean isTaxon) {
- String className;
- if (isTaxon){
- className = Taxon.class.getSimpleName();
- } else{
- className = Synonym.class.getSimpleName();
- }
- String queryString;
-
- if(pattern == null){
- queryString = String.format("select uuid, id, titleCache from %s where DTYPE = '%s' ", type.getSimpleName(), className );
- } else{
- queryString = String.format("select uuid, id, titleCache from %s where DTYPE = '%s' and titleCache like :pattern", type.getSimpleName(), className);
- }
- Query query = getSession().createQuery(queryString);
- if (pattern != null){
- pattern = pattern.replace("*", "%");
- pattern = pattern.replace("?", "_");
- pattern = pattern + "%";
- pattern = pattern.replace("?", "_");
- query.setParameter("pattern", pattern);
- }
- if (limit != null){
- query.setMaxResults(limit);
- }
-
- List<UuidAndTitleCache<TaxonBase>> result = getUuidAndTitleCache(query);
-
- return result;
- }
- @Override
- public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheSynonym(Integer limit, String pattern){
-
- return getUuidAndTitleCache(limit, pattern, false);
- }
-
- @Override
- public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheTaxon(Integer limit, String pattern){
-
- return getUuidAndTitleCache(limit, pattern, true);
- }
-
private String[] createHQLString(boolean doTaxa, boolean doSynonyms, boolean doIncludeMisappliedNames, Classification classification, Set<NamedArea> areasExpanded, MatchMode matchMode, String searchField){
boolean doAreaRestriction = areasExpanded.size() > 0;
List<OrderHint> orderHints, List<String> propertyPaths,
Direction relatedfrom);
- /**
- * @return
- */
- public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheTaxon(Integer limit, String pattern);
-
- /**
- * @return
- */
- public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheSynonym(Integer limit, String pattern);
-
public List<UuidAndTitleCache<IdentifiableEntity>> getTaxaByNameForEditor(boolean doTaxa, boolean doSynonyms, boolean doNamesWithoutTaxa, boolean doMisappliedNames, String queryString, Classification classification,
MatchMode matchMode, Set<NamedArea> namedAreas);
*/
public Pager<Rights> getRights(T t, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
-// /**
-// * Return a list of all uuids mapped to titleCache in the convenient <code>UuidAndTitleCache</code> object.
-// * @see #getUuidAndTitleCache(Integer, String)
-// */
-// public List<UuidAndTitleCache<T>> getUuidAndTitleCache();
-
/**
* Return a list of all uuids mapped to titleCache in the convenient <code>UuidAndTitleCache</code> object.
* Retrieving this list is considered to be significantly faster than initializing the fully fledged business
* a selection has been made.
*
* @return a list of <code>UuidAndTitleCache</code> instances
+ *
+ * @see #getUuidAndTitleCache(Class, Integer, String)
*/
public List<UuidAndTitleCache<T>> getUuidAndTitleCache(Integer limit, String pattern);
+ /**
+ * Like {@link #getUuidAndTitleCache(Integer, String)} but searching only on a subclass
+ * of the type handled by the DAO.
+ *
+ * @param clazz the (sub)class
+ * @param limit max number of results
+ * @param pattern search pattern
+
+ * @see #getUuidAndTitleCache(Integer, String)
+ */
+ public <S extends T> List<UuidAndTitleCache<S>> getUuidAndTitleCache(Class<S> clazz, Integer limit, String pattern);
+
/**
* Return a Pager of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
*
import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator;
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
import eu.etaxonomy.cdm.api.service.dto.IdentifiedEntityDTO;
-import eu.etaxonomy.cdm.api.service.dto.MarkedEntityDTO;
import eu.etaxonomy.cdm.api.service.dto.IncludedTaxaDTO;
+import eu.etaxonomy.cdm.api.service.dto.MarkedEntityDTO;
import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException;
import eu.etaxonomy.cdm.api.service.exception.HomotypicalGroupChangeException;
import eu.etaxonomy.cdm.api.service.pager.Pager;
public Synonym findBestMatchingSynonym(String taxonName);
- public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheTaxon(Integer limit, String pattern);
-
- public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheSynonym(Integer limit, String pattern);
-
- public List<UuidAndTitleCache<IdentifiableEntity>> findTaxaAndNamesForEditor(IFindTaxaAndNamesConfigurator configurator);
+ public List<UuidAndTitleCache<IdentifiableEntity>> findTaxaAndNamesForEditor(IFindTaxaAndNamesConfigurator configurator);
/**
* Creates the specified inferred synonyms for the taxon in the classification, but do not insert it to the database
}
return result;
}
-//
-// @Override
-// public List<UuidAndTitleCache<T>> getUuidAndTitleCache() {
-// return getUuidAndTitleCache(null, null);
-// }
-
@Transactional(readOnly = true)
@Override
return dao.getUuidAndTitleCache(limit, pattern);
}
+ @Transactional(readOnly = true)
+ @Override
+ public <S extends T> List<UuidAndTitleCache<S>> getUuidAndTitleCache(Class<S> clazz,Integer limit, String pattern) {
+ return dao.getUuidAndTitleCache(clazz, limit, pattern);
+ }
+
@Transactional(readOnly = true)
@Override
public Pager<T> findByTitle(Class<? extends T> clazz, String queryString,MatchMode matchmode, List<Criterion> criteria, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) {
}
newTaxon = HibernateProxyHelper.deproxy(newTaxon, Taxon.class);
fromTaxon = HibernateProxyHelper.deproxy(fromTaxon, Taxon.class);
- SynonymRelationship newSynRelation = newTaxon.addSynonym(syn, newSynonymRelationshipType, newReference, newRefDetail);
+ newTaxon.addSynonym(syn, newSynonymRelationshipType, newReference, newRefDetail);
fromTaxon.removeSynonymRelation(synRelation, false);
//
//change homotypic group of synonym if relType is 'homotypic'
result.addUpdatedObject(newTaxon);
saveOrUpdate(fromTaxon);
saveOrUpdate(newTaxon);
- //Assert that there is a result
- if (result == null){
- String message = "Old synonym relation could not be transformed into new relation. This should not happen.";
- throw new IllegalStateException(message);
- }
- return result;
- }
- @Override
- public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheTaxon(Integer limit, String pattern) {
- return dao.getUuidAndTitleCacheTaxon(limit, pattern);
+ return result;
}
@Override
- public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheSynonym(Integer limit, String pattern) {
- return dao.getUuidAndTitleCacheSynonym(limit, pattern);
+ public <T extends TaxonBase> List<UuidAndTitleCache<T>> getUuidAndTitleCache(Class<T> clazz, Integer limit, String pattern) {
+ return dao.getUuidAndTitleCache(clazz, limit, pattern);
}
@Override