1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.dao.orm.hibernate;
16  
17  import com.liferay.portal.kernel.dao.orm.Projection;
18  import com.liferay.portal.kernel.dao.orm.ProjectionFactory;
19  import com.liferay.portal.kernel.dao.orm.ProjectionList;
20  
21  import org.hibernate.criterion.Projections;
22  
23  /**
24   * <a href="ProjectionFactoryImpl.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author Brian Wing Shun Chan
27   */
28  public class ProjectionFactoryImpl implements ProjectionFactory {
29  
30      public Projection alias(Projection projection, String alias) {
31          ProjectionImpl projectionImpl = (ProjectionImpl)projection;
32  
33          return new ProjectionImpl(
34              Projections.alias(projectionImpl.getWrappedProjection(), alias));
35      }
36  
37      public Projection avg(String propertyName) {
38          return new ProjectionImpl(Projections.avg(propertyName));
39      }
40  
41      public Projection count(String propertyName) {
42          return new ProjectionImpl(Projections.count(propertyName));
43      }
44  
45      public Projection countDistinct(String propertyName) {
46          return new ProjectionImpl(Projections.countDistinct(propertyName));
47      }
48  
49      public Projection distinct(Projection projection) {
50          ProjectionImpl projectionImpl = (ProjectionImpl)projection;
51  
52          return new ProjectionImpl(
53              Projections.distinct(projectionImpl.getWrappedProjection()));
54      }
55  
56      public Projection groupProperty(String propertyName) {
57          return new ProjectionImpl(Projections.groupProperty(propertyName));
58      }
59  
60      public Projection max(String propertyName) {
61          return new ProjectionImpl(Projections.max(propertyName));
62      }
63  
64      public Projection min(String propertyName) {
65          return new ProjectionImpl(Projections.min(propertyName));
66      }
67  
68      public ProjectionList projectionList() {
69          return new ProjectionListImpl(Projections.projectionList());
70      }
71  
72      public Projection property(String propertyName) {
73          return new ProjectionImpl(Projections.property(propertyName));
74      }
75  
76      public Projection rowCount() {
77          return new ProjectionImpl(Projections.rowCount());
78      }
79  
80      public Projection sum(String propertyName) {
81          return new ProjectionImpl(Projections.sum(propertyName));
82      }
83  
84  }