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.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  }