001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.dao.orm.hibernate;
016    
017    import com.liferay.portal.kernel.dao.orm.Conjunction;
018    import com.liferay.portal.kernel.dao.orm.Criterion;
019    import com.liferay.portal.kernel.dao.orm.Disjunction;
020    import com.liferay.portal.kernel.dao.orm.RestrictionsFactory;
021    
022    import java.util.Collection;
023    import java.util.Map;
024    
025    /**
026     * @author Raymond Augé
027     */
028    public class RestrictionsFactoryImpl implements RestrictionsFactory {
029    
030            public Criterion allEq(Map<String, Criterion> propertyNameValues) {
031                    return new CriterionImpl(
032                            org.hibernate.criterion.Restrictions.allEq(propertyNameValues));
033            }
034    
035            public Criterion and(Criterion lhs, Criterion rhs) {
036                    CriterionImpl lhsImpl = (CriterionImpl)lhs;
037                    CriterionImpl rhsImpl = (CriterionImpl)rhs;
038    
039                    return new CriterionImpl(
040                            org.hibernate.criterion.Restrictions.and(
041                                    lhsImpl.getWrappedCriterion(), rhsImpl.getWrappedCriterion()));
042            }
043    
044            public Criterion between(String propertyName, Object lo, Object hi) {
045                    return new CriterionImpl(
046                            org.hibernate.criterion.Restrictions.between(propertyName, lo, hi));
047            }
048    
049            public Conjunction conjunction() {
050                    return new ConjunctionImpl(
051                            org.hibernate.criterion.Restrictions.conjunction());
052            }
053    
054            public Disjunction disjunction() {
055                    return new DisjunctionImpl(
056                            org.hibernate.criterion.Restrictions.disjunction());
057            }
058    
059            public Criterion eq(String propertyName, Object value) {
060                    return new CriterionImpl(
061                            org.hibernate.criterion.Restrictions.eq(propertyName, value));
062            }
063    
064            public Criterion eqProperty(String propertyName, String otherPropertyName) {
065                    return new CriterionImpl(
066                            org.hibernate.criterion.Restrictions.eqProperty(
067                                    propertyName, otherPropertyName));
068            }
069    
070            public Criterion ge(String propertyName, Object value) {
071                    return new CriterionImpl(
072                            org.hibernate.criterion.Restrictions.ge(propertyName, value));
073            }
074    
075            public Criterion geProperty(String propertyName, String otherPropertyName) {
076                    return new CriterionImpl(
077                            org.hibernate.criterion.Restrictions.geProperty(
078                                    propertyName, otherPropertyName));
079            }
080    
081            public Criterion gt(String propertyName, Object value) {
082                    return new CriterionImpl(
083                            org.hibernate.criterion.Restrictions.gt(propertyName, value));
084            }
085    
086            public Criterion gtProperty(String propertyName, String otherPropertyName) {
087                    return new CriterionImpl(
088                            org.hibernate.criterion.Restrictions.gtProperty(
089                                    propertyName, otherPropertyName));
090            }
091    
092            public Criterion ilike(String propertyName, Object value) {
093                    return new CriterionImpl(
094                            org.hibernate.criterion.Restrictions.ilike(propertyName, value));
095            }
096    
097            public Criterion in(String propertyName, Collection<Object> values) {
098                    return new CriterionImpl(
099                            org.hibernate.criterion.Restrictions.in(propertyName, values));
100            }
101    
102            public Criterion in(String propertyName, Object[] values) {
103                    return new CriterionImpl(
104                            org.hibernate.criterion.Restrictions.in(propertyName, values));
105            }
106    
107            public Criterion isEmpty(String propertyName) {
108                    return new CriterionImpl(
109                            org.hibernate.criterion.Restrictions.isEmpty(propertyName));
110            }
111    
112            public Criterion isNotEmpty(String propertyName) {
113                    return new CriterionImpl(
114                            org.hibernate.criterion.Restrictions.isNotEmpty(propertyName));
115            }
116    
117            public Criterion isNotNull(String propertyName) {
118                    return new CriterionImpl(
119                            org.hibernate.criterion.Restrictions.isNotNull(propertyName));
120            }
121    
122            public Criterion isNull(String propertyName) {
123                    return new CriterionImpl(
124                            org.hibernate.criterion.Restrictions.isNull(propertyName));
125            }
126    
127            public Criterion le(String propertyName, Object value) {
128                    return new CriterionImpl(
129                            org.hibernate.criterion.Restrictions.le(propertyName, value));
130            }
131    
132            public Criterion leProperty(String propertyName, String otherPropertyName) {
133                    return new CriterionImpl(
134                            org.hibernate.criterion.Restrictions.leProperty(
135                                    propertyName, otherPropertyName));
136            }
137    
138            public Criterion like(String propertyName, Object value) {
139                    return new CriterionImpl(
140                            org.hibernate.criterion.Restrictions.like(propertyName, value));
141            }
142    
143            public Criterion lt(String propertyName, Object value) {
144                    return new CriterionImpl(
145                            org.hibernate.criterion.Restrictions.lt(propertyName, value));
146            }
147    
148            public Criterion ltProperty(String propertyName, String otherPropertyName) {
149                    return new CriterionImpl(
150                            org.hibernate.criterion.Restrictions.ltProperty(
151                                    propertyName, otherPropertyName));
152            }
153    
154            public Criterion ne(String propertyName, Object value) {
155                    return new CriterionImpl(
156                            org.hibernate.criterion.Restrictions.ne(propertyName, value));
157            }
158    
159            public Criterion neProperty(String propertyName, String otherPropertyName) {
160                    return new CriterionImpl(
161                            org.hibernate.criterion.Restrictions.neProperty(
162                                    propertyName, otherPropertyName));
163            }
164    
165            public Criterion not(Criterion expression) {
166                    CriterionImpl expressionImpl = (CriterionImpl)expression;
167    
168                    return new CriterionImpl(
169                            org.hibernate.criterion.Restrictions.not(
170                                    expressionImpl.getWrappedCriterion()));
171            }
172    
173            public Criterion or(Criterion lhs, Criterion rhs) {
174                    CriterionImpl lhsImpl = (CriterionImpl)lhs;
175                    CriterionImpl rhsImpl = (CriterionImpl)rhs;
176    
177                    return new CriterionImpl(
178                            org.hibernate.criterion.Restrictions.or(
179                                    lhsImpl.getWrappedCriterion(), rhsImpl.getWrappedCriterion()));
180            }
181    
182            public Criterion sizeEq(String propertyName, int size) {
183                    return new CriterionImpl(
184                            org.hibernate.criterion.Restrictions.sizeEq(propertyName, size));
185            }
186    
187            public Criterion sizeGe(String propertyName, int size) {
188                    return new CriterionImpl(
189                            org.hibernate.criterion.Restrictions.sizeGe(propertyName, size));
190            }
191    
192            public Criterion sizeGt(String propertyName, int size) {
193                    return new CriterionImpl(
194                            org.hibernate.criterion.Restrictions.sizeGe(propertyName, size));
195            }
196    
197            public Criterion sizeLe(String propertyName, int size) {
198                    return new CriterionImpl(
199                            org.hibernate.criterion.Restrictions.sizeLe(propertyName, size));
200            }
201    
202            public Criterion sizeLt(String propertyName, int size) {
203                    return new CriterionImpl(
204                            org.hibernate.criterion.Restrictions.sizeLt(propertyName, size));
205            }
206    
207            public Criterion sizeNe(String propertyName, int size) {
208                    return new CriterionImpl(
209                            org.hibernate.criterion.Restrictions.sizeNe(propertyName, size));
210            }
211    
212    }