changed keyword dao method to recieve boolean to specify whether deleted/inactivated keywords should be included in the result or not

This commit is contained in:
Fredrik Friis 2012-02-15 12:13:48 +09:00
parent a4bd37d837
commit 3122c686a1
2 changed files with 16 additions and 4 deletions
src/main/java/se/su/dsv/scipro/match/dao

@ -9,7 +9,7 @@ import se.su.dsv.scipro.match.dataobject.KeywordType;
public interface KeywordDao extends LazyDeleteDao<Keyword>{
Set<Keyword> getKeywords(KeywordType type);
Set<Keyword> getKeywords(KeywordType type, boolean includeDeleted);
public List<Keyword> findAllFromType(KeywordType kt, boolean includeDeleted);

@ -30,9 +30,15 @@ public class KeywordDaoJPAImp extends LazyDeleteAbstractDaoJPAImp<Keyword> imple
}
@Override
public Set<Keyword> getKeywords(KeywordType type) {
return new HashSet<Keyword>(getJpaTemplate().execute(
new QuerySet().type(type).fetchCallback()));
public Set<Keyword> getKeywords(KeywordType type, boolean includeDeleted) {
if (includeDeleted){
return new HashSet<Keyword>(getJpaTemplate().execute(
new QuerySet().type(type).fetchCallback()));
}
else {
return new HashSet<Keyword>(getJpaTemplate().execute(
new QuerySet().type(type).noDeleted().fetchCallback()));
}
}
private static class QuerySet extends AbstractSortableQuerySet<Keyword> {
@ -48,6 +54,12 @@ public class KeywordDaoJPAImp extends LazyDeleteAbstractDaoJPAImp<Keyword> imple
}
return this;
}
public QuerySet noDeleted() {
getQuery().combine(
new Query().where("k.deleted = false"));
return this;
}
@Override
public Query initQuery() {