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   */
39  public class RestrictionsFactoryImpl implements RestrictionsFactory {
40  
41      public Criterion allEq(Map propertyNameValues) {
42          return new CriterionImpl(
43              org.hibernate.criterion.Restrictions.allEq(propertyNameValues));
44      }
45  
46      public Criterion and(Criterion lhs, Criterion rhs) {
47          CriterionImpl lhsImpl = (CriterionImpl)lhs;
48          CriterionImpl rhsImpl = (CriterionImpl)rhs;
49  
50          return new CriterionImpl(
51              org.hibernate.criterion.Restrictions.and(
52                  lhsImpl.getWrappedCriterion(), rhsImpl.getWrappedCriterion()));
53      }
54  
55      public Criterion between(String propertyName, Object lo, Object hi) {
56          return new CriterionImpl(
57              org.hibernate.criterion.Restrictions.between(propertyName, lo, hi));
58      }
59  
60      public Conjunction conjunction() {
61          return new ConjunctionImpl(
62              org.hibernate.criterion.Restrictions.conjunction());
63      }
64  
65      public Disjunction disjunction() {
66          return new DisjunctionImpl(
67              org.hibernate.criterion.Restrictions.disjunction());
68      }
69  
70      public Criterion eq(String propertyName, Object value) {
71          return new CriterionImpl(
72              org.hibernate.criterion.Restrictions.eq(propertyName, value));
73      }
74  
75      public Criterion eqProperty(String propertyName, String otherPropertyName) {
76          return new CriterionImpl(
77              org.hibernate.criterion.Restrictions.eqProperty(
78                  propertyName, otherPropertyName));
79      }
80  
81      public Criterion ge(String propertyName, Object value) {
82          return new CriterionImpl(
83              org.hibernate.criterion.Restrictions.ge(propertyName, value));
84      }
85  
86      public Criterion geProperty(String propertyName, String otherPropertyName) {
87          return new CriterionImpl(
88              org.hibernate.criterion.Restrictions.geProperty(
89                  propertyName, otherPropertyName));
90      }
91  
92      public Criterion gt(String propertyName, Object value) {
93          return new CriterionImpl(
94              org.hibernate.criterion.Restrictions.gt(propertyName, value));
95      }
96  
97      public Criterion gtProperty(String propertyName, String otherPropertyName) {
98          return new CriterionImpl(
99              org.hibernate.criterion.Restrictions.gtProperty(
100                 propertyName, otherPropertyName));
101     }
102 
103     public Criterion ilike(String propertyName, Object value) {
104         return new CriterionImpl(
105             org.hibernate.criterion.Restrictions.ilike(propertyName, value));
106     }
107 
108     public Criterion in(String propertyName, Collection values) {
109         return new CriterionImpl(
110             org.hibernate.criterion.Restrictions.in(propertyName, values));
111     }
112 
113     public Criterion in(String propertyName, Object[] values) {
114         return new CriterionImpl(
115             org.hibernate.criterion.Restrictions.in(propertyName, values));
116     }
117 
118     public Criterion isEmpty(String propertyName) {
119         return new CriterionImpl(
120             org.hibernate.criterion.Restrictions.isEmpty(propertyName));
121     }
122 
123     public Criterion isNotEmpty(String propertyName) {
124         return new CriterionImpl(
125             org.hibernate.criterion.Restrictions.isNotEmpty(propertyName));
126     }
127 
128     public Criterion isNotNull(String propertyName) {
129         return new CriterionImpl(
130             org.hibernate.criterion.Restrictions.isNotNull(propertyName));
131     }
132 
133     public Criterion isNull(String propertyName) {
134         return new CriterionImpl(
135             org.hibernate.criterion.Restrictions.isNull(propertyName));
136     }
137 
138     public Criterion le(String propertyName, Object value) {
139         return new CriterionImpl(
140             org.hibernate.criterion.Restrictions.le(propertyName, value));
141     }
142 
143     public Criterion leProperty(String propertyName, String otherPropertyName) {
144         return new CriterionImpl(
145             org.hibernate.criterion.Restrictions.leProperty(
146                 propertyName, otherPropertyName));
147     }
148 
149     public Criterion like(String propertyName, Object value) {
150         return new CriterionImpl(
151             org.hibernate.criterion.Restrictions.like(propertyName, value));
152     }
153 
154     public Criterion lt(String propertyName, Object value) {
155         return new CriterionImpl(
156             org.hibernate.criterion.Restrictions.lt(propertyName, value));
157     }
158 
159     public Criterion ltProperty(String propertyName, String otherPropertyName) {
160         return new CriterionImpl(
161             org.hibernate.criterion.Restrictions.ltProperty(
162                 propertyName, otherPropertyName));
163     }
164 
165     public Criterion ne(String propertyName, Object value) {
166         return new CriterionImpl(
167             org.hibernate.criterion.Restrictions.ne(propertyName, value));
168     }
169 
170     public Criterion neProperty(String propertyName, String otherPropertyName) {
171         return new CriterionImpl(
172             org.hibernate.criterion.Restrictions.neProperty(
173                 propertyName, otherPropertyName));
174     }
175 
176     public Criterion not(Criterion expression) {
177         CriterionImpl expressionImpl = (CriterionImpl)expression;
178 
179         return new CriterionImpl(
180             org.hibernate.criterion.Restrictions.not(
181                 expressionImpl.getWrappedCriterion()));
182     }
183 
184     public Criterion or(Criterion lhs, Criterion rhs) {
185         CriterionImpl lhsImpl = (CriterionImpl)lhs;
186         CriterionImpl rhsImpl = (CriterionImpl)rhs;
187 
188         return new CriterionImpl(
189             org.hibernate.criterion.Restrictions.or(
190                 lhsImpl.getWrappedCriterion(), rhsImpl.getWrappedCriterion()));
191     }
192 
193     public Criterion sizeEq(String propertyName, int size) {
194         return new CriterionImpl(
195             org.hibernate.criterion.Restrictions.sizeEq(propertyName, size));
196     }
197 
198     public Criterion sizeGe(String propertyName, int size) {
199         return new CriterionImpl(
200             org.hibernate.criterion.Restrictions.sizeGe(propertyName, size));
201     }
202 
203     public Criterion sizeGt(String propertyName, int size) {
204         return new CriterionImpl(
205             org.hibernate.criterion.Restrictions.sizeGe(propertyName, size));
206     }
207 
208     public Criterion sizeLe(String propertyName, int size) {
209         return new CriterionImpl(
210             org.hibernate.criterion.Restrictions.sizeLe(propertyName, size));
211     }
212 
213     public Criterion sizeLt(String propertyName, int size) {
214         return new CriterionImpl(
215             org.hibernate.criterion.Restrictions.sizeLt(propertyName, size));
216     }
217 
218     public Criterion sizeNe(String propertyName, int size) {
219         return new CriterionImpl(
220             org.hibernate.criterion.Restrictions.sizeNe(propertyName, size));
221     }
222 
223 }