Revision b6d3c69f
Added by Patrick Plitzner about 5 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/FeatureTreeDaoImpl.java | ||
---|---|---|
15 | 15 |
|
16 | 16 |
import org.apache.log4j.Logger; |
17 | 17 |
import org.hibernate.Criteria; |
18 |
import org.hibernate.Query; |
|
19 |
import org.hibernate.Session; |
|
18 | 20 |
import org.springframework.beans.factory.annotation.Autowired; |
19 | 21 |
import org.springframework.stereotype.Repository; |
20 | 22 |
|
23 |
import eu.etaxonomy.cdm.model.common.TermType; |
|
21 | 24 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
22 | 25 |
import eu.etaxonomy.cdm.model.common.VocabularyEnum; |
23 | 26 |
import eu.etaxonomy.cdm.model.description.Feature; |
... | ... | |
26 | 29 |
import eu.etaxonomy.cdm.persistence.dao.common.ITermVocabularyDao; |
27 | 30 |
import eu.etaxonomy.cdm.persistence.dao.description.IFeatureTreeDao; |
28 | 31 |
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBase; |
32 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
29 | 33 |
|
30 | 34 |
/** |
31 | 35 |
* @author a.mueller |
... | ... | |
104 | 108 |
return featureTree; |
105 | 109 |
} |
106 | 110 |
|
111 |
@Override |
|
112 |
public <S extends FeatureTree> List<UuidAndTitleCache<S>> getUuidAndTitleCacheByTermType(Class<S> clazz, TermType termType, Integer limit, |
|
113 |
String pattern) { |
|
114 |
Session session = getSession(); |
|
115 |
Query query = session.createQuery( |
|
116 |
" SELECT uuid, id, titleCache " |
|
117 |
+ " FROM " + clazz.getSimpleName() |
|
118 |
+ (pattern!=null?" WHERE titleCache LIKE :pattern":" WHERE 1 = 1 ") |
|
119 |
+ (termType!=null?" AND termType = :termType ":"") |
|
120 |
); |
|
121 |
if(pattern!=null){ |
|
122 |
pattern = pattern.replace("*", "%"); |
|
123 |
pattern = pattern.replace("?", "_"); |
|
124 |
pattern = pattern + "%"; |
|
125 |
query.setParameter("pattern", pattern); |
|
126 |
} |
|
127 |
if(termType!=null){ |
|
128 |
query.setParameter("termType", termType); |
|
129 |
} |
|
130 |
if (limit != null){ |
|
131 |
query.setMaxResults(limit); |
|
132 |
} |
|
133 |
return getUuidAndTitleCache(query); |
|
134 |
} |
|
135 |
|
|
107 | 136 |
|
108 | 137 |
} |
Also available in: Unified diff
ref #8146 Add service method for UuidAndTitleCache by termType for trees