1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.tuigwaa.database.function;
17
18 import org.seasar.tuigwaa.database.function.criteria.CriteriaFunction;
19 import org.seasar.tuigwaa.database.function.criteria.CriteriaListFunction;
20 import org.seasar.tuigwaa.database.function.criteria.ICriteria;
21 import org.seasar.tuigwaa.database.function.criteria.SearchCriteriaFunction;
22
23 import com.isenshi.util.functor.UnaryFunction;
24
25 public class SearchExeFunction extends AbstractCriteriaExeFunction implements
26 UnaryFunction {
27
28 private CriteriaListFunction criteriaListFunction;
29
30 public void setCriteriaListFunction(
31 CriteriaListFunction criteriaListFunction) {
32 this.criteriaListFunction = criteriaListFunction;
33 }
34
35 public CriteriaListFunction getCriteriaListFunction() {
36 return criteriaListFunction;
37 }
38
39 public SearchCriteriaFunction createCriteriaFunction(Object dto){
40 return new SearchCriteriaFunction(criteriaListFunction, dto);
41 }
42
43 public Object evaluate(Object dto) {
44 return evaluate(dto, null);
45 }
46
47 public Object evaluate(Object dto, Object extraCriteria) {
48 ICriteria criteria = createHibernateCriteria();
49 criteria = (ICriteria) getCriteriaListFunction()
50 .evaluate(criteria, dto);
51 if (extraCriteria != null) {
52 criteria = (ICriteria) ((CriteriaFunction) extraCriteria)
53 .evaluate(criteria);
54 }
55 return criteria.list();
56 }
57
58
59 }