It should be possible to specify if you want deleted keywords or not in the panel showing unmatched project ideas..

This commit is contained in:
Tom Vahlman 2012-03-21 19:39:07 +01:00
parent eab085f589
commit 86acd6d422
2 changed files with 13 additions and 3 deletions
src/main/java/se/su/dsv/scipro/match/dao

@ -18,9 +18,10 @@ public interface KeywordDao extends LazyDeleteDao<Keyword>{
* Returns the keyword if it is found
* @param keywordType the keyword can be of a specific type i.e. regular, research area or unit, is never NULL
* @param keywordName the search term, can only be a part of the keyword name, but must start with the same characters
* @param includeDeleted if deleted keywords should be included the search
* @return List<Keyword> the keyword list
*/
public List<Keyword> getAutoCompleteCapableSupervisors(final KeywordType keywordType, final String keywordName);
public List<Keyword> getAutoCompleteCapableSupervisors(final KeywordType keywordType, final String keywordName, boolean includeDeleted);
public List<Keyword> findAllFromType(KeywordType kt, boolean includeDeleted);

@ -138,11 +138,20 @@ public class KeywordDaoJPAImp extends LazyDeleteAbstractDaoJPAImp<Keyword> imple
}
@Override
public List<Keyword> getAutoCompleteCapableSupervisors(final KeywordType keywordType, final String keywordName) {
public List<Keyword> getAutoCompleteCapableSupervisors(final KeywordType keywordType, final String keywordName, final boolean includeDeleted) {
return getJpaTemplate().execute(new JpaCallback<List<Keyword>>() {
public List<Keyword> doInJpa(EntityManager em) throws PersistenceException {
TypedQuery<Keyword> query;
query = em.createQuery("SELECT x FROM "+domainClassString+" x WHERE x.type = :type AND x.keyword LIKE :keywordName ORDER BY keyword", domainClass);
StringBuilder sqlBuilder = new StringBuilder();
sqlBuilder.append("SELECT x FROM ").append(domainClassString).append(" x ")
.append("WHERE x.type = :type AND x.keyword LIKE :keywordName AND ");
if(includeDeleted) {
sqlBuilder.append("(x.deleted = 1 OR x.deleted = 0) ");
} else {
sqlBuilder.append("x.deleted = 0 ");
}
sqlBuilder.append("ORDER BY keyword ");
query = em.createQuery(sqlBuilder.toString(), domainClass);
query.setParameter("type", keywordType);
String keyWordNameString = "%" + keywordName + "%";
query.setParameter("keywordName", keyWordNameString);