1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.dao.orm.hibernate;
16  
17  import com.liferay.portal.kernel.dao.orm.Conjunction;
18  import com.liferay.portal.kernel.dao.orm.Criterion;
19  import com.liferay.portal.kernel.dao.orm.Disjunction;
20  import com.liferay.portal.kernel.dao.orm.RestrictionsFactory;
21  
22  import java.util.Collection;
23  import java.util.Map;
24  
25  /**
26   * <a href="RestrictionsFactoryImpl.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Raymond Augé
29   */
30  public class RestrictionsFactoryImpl implements RestrictionsFactory {
31  
32      public Criterion allEq(Map<String, Criterion> propertyNameValues) {
33          return new CriterionImpl(
34              org.hibernate.criterion.Restrictions.allEq(propertyNameValues));
35      }
36  
37      public Criterion and(Criterion lhs, Criterion rhs) {
38          CriterionImpl lhsImpl = (CriterionImpl)lhs;
39          CriterionImpl rhsImpl = (CriterionImpl)rhs;
40  
41          return new CriterionImpl(
42              org.hibernate.criterion.Restrictions.and(
43                  lhsImpl.getWrappedCriterion(), rhsImpl.getWrappedCriterion()));
44      }
45  
46      public Criterion between(String propertyName, Object lo, Object hi) {
47          return new CriterionImpl(
48              org.hibernate.criterion.Restrictions.between(propertyName, lo, hi));
49      }
50  
51      public Conjunction conjunction() {
52          return new ConjunctionImpl(
53              org.hibernate.criterion.Restrictions.conjunction());
54      }
55  
56      public Disjunction disjunction() {
57          return new DisjunctionImpl(
58              org.hibernate.criterion.Restrictions.disjunction());
59      }
60  
61      public Criterion eq(String propertyName, Object value) {
62          return new CriterionImpl(
63              org.hibernate.criterion.Restrictions.eq(propertyName, value));
64      }
65  
66      public Criterion eqProperty(String propertyName, String otherPropertyName) {
67          return new CriterionImpl(
68              org.hibernate.criterion.Restrictions.eqProperty(
69                  propertyName, otherPropertyName));
70      }
71  
72      public Criterion ge(String propertyName, Object value) {
73          return new CriterionImpl(
74              org.hibernate.criterion.Restrictions.ge(propertyName, value));
75      }
76  
77      public Criterion geProperty(String propertyName, String otherPropertyName) {
78          return new CriterionImpl(
79              org.hibernate.criterion.Restrictions.geProperty(
80                  propertyName, otherPropertyName));
81      }
82  
83      public Criterion gt(String propertyName, Object value) {
84          return new CriterionImpl(
85              org.hibernate.criterion.Restrictions.gt(propertyName, value));
86      }
87  
88      public Criterion gtProperty(String propertyName, String otherPropertyName) {
89          return new CriterionImpl(
90              org.hibernate.criterion.Restrictions.gtProperty(
91                  propertyName, otherPropertyName));
92      }
93  
94      public Criterion ilike(String propertyName, Object value) {
95          return new CriterionImpl(
96              org.hibernate.criterion.Restrictions.ilike(propertyName, value));
97      }
98  
99      public Criterion in(String propertyName, Collection<Object> values) {
100         return new CriterionImpl(
101             org.hibernate.criterion.Restrictions.in(propertyName, values));
102     }
103 
104     public Criterion in(String propertyName, Object[] values) {
105         return new CriterionImpl(
106             org.hibernate.criterion.Restrictions.in(propertyName, values));
107     }
108 
109     public Criterion isEmpty(String propertyName) {
110         return new CriterionImpl(
111             org.hibernate.criterion.Restrictions.isEmpty(propertyName));
112     }
113 
114     public Criterion isNotEmpty(String propertyName) {
115         return new CriterionImpl(
116             org.hibernate.criterion.Restrictions.isNotEmpty(propertyName));
117     }
118 
119     public Criterion isNotNull(String propertyName) {
120         return new CriterionImpl(
121             org.hibernate.criterion.Restrictions.isNotNull(propertyName));
122     }
123 
124     public Criterion isNull(String propertyName) {
125         return new CriterionImpl(
126             org.hibernate.criterion.Restrictions.isNull(propertyName));
127     }
128 
129     public Criterion le(String propertyName, Object value) {
130         return new CriterionImpl(
131             org.hibernate.criterion.Restrictions.le(propertyName, value));
132     }
133 
134     public Criterion leProperty(String propertyName, String otherPropertyName) {
135         return new CriterionImpl(
136             org.hibernate.criterion.Restrictions.leProperty(
137                 propertyName, otherPropertyName));
138     }
139 
140     public Criterion like(String propertyName, Object value) {
141         return new CriterionImpl(
142             org.hibernate.criterion.Restrictions.like(propertyName, value));
143     }
144 
145     public Criterion lt(String propertyName, Object value) {
146         return new CriterionImpl(
147             org.hibernate.criterion.Restrictions.lt(propertyName, value));
148     }
149 
150     public Criterion ltProperty(String propertyName, String otherPropertyName) {
151         return new CriterionImpl(
152             org.hibernate.criterion.Restrictions.ltProperty(
153                 propertyName, otherPropertyName));
154     }
155 
156     public Criterion ne(String propertyName, Object value) {
157         return new CriterionImpl(
158             org.hibernate.criterion.Restrictions.ne(propertyName, value));
159     }
160 
161     public Criterion neProperty(String propertyName, String otherPropertyName) {
162         return new CriterionImpl(
163             org.hibernate.criterion.Restrictions.neProperty(
164                 propertyName, otherPropertyName));
165     }
166 
167     public Criterion not(Criterion expression) {
168         CriterionImpl expressionImpl = (CriterionImpl)expression;
169 
170         return new CriterionImpl(
171             org.hibernate.criterion.Restrictions.not(
172                 expressionImpl.getWrappedCriterion()));
173     }
174 
175     public Criterion or(Criterion lhs, Criterion rhs) {
176         CriterionImpl lhsImpl = (CriterionImpl)lhs;
177         CriterionImpl rhsImpl = (CriterionImpl)rhs;
178 
179         return new CriterionImpl(
180             org.hibernate.criterion.Restrictions.or(
181                 lhsImpl.getWrappedCriterion(), rhsImpl.getWrappedCriterion()));
182     }
183 
184     public Criterion sizeEq(String propertyName, int size) {
185         return new CriterionImpl(
186             org.hibernate.criterion.Restrictions.sizeEq(propertyName, size));
187     }
188 
189     public Criterion sizeGe(String propertyName, int size) {
190         return new CriterionImpl(
191             org.hibernate.criterion.Restrictions.sizeGe(propertyName, size));
192     }
193 
194     public Criterion sizeGt(String propertyName, int size) {
195         return new CriterionImpl(
196             org.hibernate.criterion.Restrictions.sizeGe(propertyName, size));
197     }
198 
199     public Criterion sizeLe(String propertyName, int size) {
200         return new CriterionImpl(
201             org.hibernate.criterion.Restrictions.sizeLe(propertyName, size));
202     }
203 
204     public Criterion sizeLt(String propertyName, int size) {
205         return new CriterionImpl(
206             org.hibernate.criterion.Restrictions.sizeLt(propertyName, size));
207     }
208 
209     public Criterion sizeNe(String propertyName, int size) {
210         return new CriterionImpl(
211             org.hibernate.criterion.Restrictions.sizeNe(propertyName, size));
212     }
213 
214 }