Revision 84e04ed3
Added by Katja Luther over 2 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/agent/AgentDaoImpl.java | ||
---|---|---|
31 | 31 |
import eu.etaxonomy.cdm.model.agent.InstitutionalMembership; |
32 | 32 |
import eu.etaxonomy.cdm.model.agent.Person; |
33 | 33 |
import eu.etaxonomy.cdm.model.agent.Team; |
34 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
|
35 | 34 |
import eu.etaxonomy.cdm.model.view.AuditEvent; |
36 | 35 |
import eu.etaxonomy.cdm.persistence.dao.agent.IAgentDao; |
37 | 36 |
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBase; |
... | ... | |
181 | 180 |
String clazzString = ""; |
182 | 181 |
|
183 | 182 |
if (clazz == null){ |
184 |
clazzString = ""; |
|
185 |
}else if (clazz.equals(Team.class)){ |
|
186 |
clazzString = "dtype like 'Team'"; |
|
187 |
} else if (clazz.equals(Person.class)){ |
|
188 |
clazzString = "dtype like 'Person'"; |
|
189 |
} else if (clazz.equals(Institution.class)){ |
|
190 |
clazzString = "dtype like 'Institution'"; |
|
191 |
} else if (clazz.equals(TeamOrPersonBase.class)){ |
|
192 |
clazzString = "dtype NOT LIKE 'Institution'"; |
|
183 |
clazzString = " FROM " + type.getSimpleName(); |
|
184 |
}else { |
|
185 |
clazzString = " FROM " + clazz.getSimpleName(); |
|
193 | 186 |
} |
194 | 187 |
|
195 | 188 |
Query query = null; |
... | ... | |
199 | 192 |
if (pattern.startsWith("*")){ |
200 | 193 |
whereClause += " OR titleCache LIKE :pattern"; |
201 | 194 |
} |
202 |
if (clazzString != ""){ |
|
203 |
whereClause += " AND " + clazzString; |
|
204 |
} |
|
205 |
query = session.createQuery("SELECT DISTINCT uuid, id, nomenclaturalTitle, titleCache FROM " + type.getSimpleName() + whereClause); |
|
195 |
|
|
196 |
query = session.createQuery("SELECT DISTINCT uuid, id, nomenclaturalTitle, titleCache " + clazzString + whereClause); |
|
206 | 197 |
pattern = pattern + "%"; |
207 | 198 |
pattern = pattern.replace("*", "%"); |
208 | 199 |
pattern = pattern.replace("?", "_"); |
209 | 200 |
query.setParameter("pattern", pattern); |
210 | 201 |
} else { |
211 |
if (clazzString != ""){ |
|
212 |
query = session.createQuery("SELECT DISTINCT uuid, id, nomenclaturalTitle, titleCache FROM " + type.getSimpleName() + " WHERE " + clazzString); |
|
213 |
} else{ |
|
214 |
query = session.createQuery("SELECT DISTINCT uuid, id, nomenclaturalTitle, titleCache FROM " + type.getSimpleName()); |
|
215 |
} |
|
202 |
query = session.createQuery("SELECT DISTINCT uuid, id, nomenclaturalTitle, titleCache " + clazzString); |
|
216 | 203 |
} |
217 | 204 |
if (limit != null){ |
218 | 205 |
query.setMaxResults(limit); |
Also available in: Unified diff
ref #9142: use clazz for FROM statement in getUuidAndAbbrevTitleCache for agents