1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.dao.orm.hibernate;
24  
25  import com.liferay.portal.kernel.dao.orm.Conjunction;
26  import com.liferay.portal.kernel.dao.orm.Criterion;
27  import com.liferay.portal.kernel.dao.orm.Disjunction;
28  import com.liferay.portal.kernel.dao.orm.RestrictionsFactory;
29  
30  import java.util.Collection;
31  import java.util.Map;
32  
33  /**
34   * <a href="RestrictionsFactoryImpl.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Raymond Augé
37   */
38  public class RestrictionsFactoryImpl implements RestrictionsFactory {
39  
40      public Criterion allEq(Map propertyNameValues) {
41          return new CriterionImpl(
42              org.hibernate.criterion.Restrictions.allEq(propertyNameValues));
43      }
44  
45      public Criterion and(Criterion lhs, Criterion rhs) {
46          CriterionImpl lhsImpl = (CriterionImpl)lhs;
47          CriterionImpl rhsImpl = (CriterionImpl)rhs;
48  
49          return new CriterionImpl(
50              org.hibernate.criterion.Restrictions.and(
51                  lhsImpl.getWrappedCriterion(), rhsImpl.getWrappedCriterion()));
52      }
53  
54      public Criterion between(String propertyName, Object lo, Object hi) {
55          return new CriterionImpl(
56              org.hibernate.criterion.Restrictions.between(propertyName, lo, hi));
57      }
58  
59      public Conjunction conjunction() {
60          return new ConjunctionImpl(
61              org.hibernate.criterion.Restrictions.conjunction());
62      }
63  
64      public Disjunction disjunction() {
65          return new DisjunctionImpl(
66              org.hibernate.criterion.Restrictions.disjunction());
67      }
68  
69      public Criterion eq(String propertyName, Object value) {
70          return new CriterionImpl(
71              org.hibernate.criterion.Restrictions.eq(propertyName, value));
72      }
73  
74      public Criterion eqProperty(String propertyName, String otherPropertyName) {
75          return new CriterionImpl(
76              org.hibernate.criterion.Restrictions.eqProperty(
77                  propertyName, otherPropertyName));
78      }
79  
80      public Criterion ge(String propertyName, Object value) {
81          return new CriterionImpl(
82              org.hibernate.criterion.Restrictions.ge(propertyName, value));
83      }
84  
85      public Criterion geProperty(String propertyName, String otherPropertyName) {
86          return new CriterionImpl(
87              org.hibernate.criterion.Restrictions.geProperty(
88                  propertyName, otherPropertyName));
89      }
90  
91      public Criterion gt(String propertyName, Object value) {
92          return new CriterionImpl(
93              org.hibernate.criterion.Restrictions.gt(propertyName, value));
94      }
95  
96      public Criterion gtProperty(String propertyName, String otherPropertyName) {
97          return new CriterionImpl(
98              org.hibernate.criterion.Restrictions.gtProperty(
99                  propertyName, otherPropertyName));
100     }
101 
102     public Criterion ilike(String propertyName, Object value) {
103         return new CriterionImpl(
104             org.hibernate.criterion.Restrictions.ilike(propertyName, value));
105     }
106 
107     public Criterion in(String propertyName, Collection values) {
108         return new CriterionImpl(
109             org.hibernate.criterion.Restrictions.in(propertyName, values));
110     }
111 
112     public Criterion in(String propertyName, Object[] values) {
113         return new CriterionImpl(
114             org.hibernate.criterion.Restrictions.in(propertyName, values));
115     }
116 
117     public Criterion isEmpty(String propertyName) {
118         return new CriterionImpl(
119             org.hibernate.criterion.Restrictions.isEmpty(propertyName));
120     }
121 
122     public Criterion isNotEmpty(String propertyName) {
123         return new CriterionImpl(
124             org.hibernate.criterion.Restrictions.isNotEmpty(propertyName));
125     }
126 
127     public Criterion isNotNull(String propertyName) {
128         return new CriterionImpl(
129             org.hibernate.criterion.Restrictions.isNotNull(propertyName));
130     }
131 
132     public Criterion isNull(String propertyName) {
133         return new CriterionImpl(
134             org.hibernate.criterion.Restrictions.isNull(propertyName));
135     }
136 
137     public Criterion le(String propertyName, Object value) {
138         return new CriterionImpl(
139             org.hibernate.criterion.Restrictions.le(propertyName, value));
140     }
141 
142     public Criterion leProperty(String propertyName, String otherPropertyName) {
143         return new CriterionImpl(
144             org.hibernate.criterion.Restrictions.leProperty(
145                 propertyName, otherPropertyName));
146     }
147 
148     public Criterion like(String propertyName, Object value) {
149         return new CriterionImpl(
150             org.hibernate.criterion.Restrictions.like(propertyName, value));
151     }
152 
153     public Criterion lt(String propertyName, Object value) {
154         return new CriterionImpl(
155             org.hibernate.criterion.Restrictions.lt(propertyName, value));
156     }
157 
158     public Criterion ltProperty(String propertyName, String otherPropertyName) {
159         return new CriterionImpl(
160             org.hibernate.criterion.Restrictions.ltProperty(
161                 propertyName, otherPropertyName));
162     }
163 
164     public Criterion ne(String propertyName, Object value) {
165         return new CriterionImpl(
166             org.hibernate.criterion.Restrictions.ne(propertyName, value));
167     }
168 
169     public Criterion neProperty(String propertyName, String otherPropertyName) {
170         return new CriterionImpl(
171             org.hibernate.criterion.Restrictions.neProperty(
172                 propertyName, otherPropertyName));
173     }
174 
175     public Criterion not(Criterion expression) {
176         CriterionImpl expressionImpl = (CriterionImpl)expression;
177 
178         return new CriterionImpl(
179             org.hibernate.criterion.Restrictions.not(
180                 expressionImpl.getWrappedCriterion()));
181     }
182 
183     public Criterion or(Criterion lhs, Criterion rhs) {
184         CriterionImpl lhsImpl = (CriterionImpl)lhs;
185         CriterionImpl rhsImpl = (CriterionImpl)rhs;
186 
187         return new CriterionImpl(
188             org.hibernate.criterion.Restrictions.or(
189                 lhsImpl.getWrappedCriterion(), rhsImpl.getWrappedCriterion()));
190     }
191 
192     public Criterion sizeEq(String propertyName, int size) {
193         return new CriterionImpl(
194             org.hibernate.criterion.Restrictions.sizeEq(propertyName, size));
195     }
196 
197     public Criterion sizeGe(String propertyName, int size) {
198         return new CriterionImpl(
199             org.hibernate.criterion.Restrictions.sizeGe(propertyName, size));
200     }
201 
202     public Criterion sizeGt(String propertyName, int size) {
203         return new CriterionImpl(
204             org.hibernate.criterion.Restrictions.sizeGe(propertyName, size));
205     }
206 
207     public Criterion sizeLe(String propertyName, int size) {
208         return new CriterionImpl(
209             org.hibernate.criterion.Restrictions.sizeLe(propertyName, size));
210     }
211 
212     public Criterion sizeLt(String propertyName, int size) {
213         return new CriterionImpl(
214             org.hibernate.criterion.Restrictions.sizeLt(propertyName, size));
215     }
216 
217     public Criterion sizeNe(String propertyName, int size) {
218         return new CriterionImpl(
219             org.hibernate.criterion.Restrictions.sizeNe(propertyName, size));
220     }
221 
222 }