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.Projection;
018    import com.liferay.portal.kernel.dao.orm.ProjectionFactory;
019    import com.liferay.portal.kernel.dao.orm.ProjectionList;
020    
021    import org.hibernate.criterion.Projections;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     */
026    public class ProjectionFactoryImpl implements ProjectionFactory {
027    
028            public Projection alias(Projection projection, String alias) {
029                    ProjectionImpl projectionImpl = (ProjectionImpl)projection;
030    
031                    return new ProjectionImpl(
032                            Projections.alias(projectionImpl.getWrappedProjection(), alias));
033            }
034    
035            public Projection avg(String propertyName) {
036                    return new ProjectionImpl(Projections.avg(propertyName));
037            }
038    
039            public Projection count(String propertyName) {
040                    return new ProjectionImpl(Projections.count(propertyName));
041            }
042    
043            public Projection countDistinct(String propertyName) {
044                    return new ProjectionImpl(Projections.countDistinct(propertyName));
045            }
046    
047            public Projection distinct(Projection projection) {
048                    ProjectionImpl projectionImpl = (ProjectionImpl)projection;
049    
050                    return new ProjectionImpl(
051                            Projections.distinct(projectionImpl.getWrappedProjection()));
052            }
053    
054            public Projection groupProperty(String propertyName) {
055                    return new ProjectionImpl(Projections.groupProperty(propertyName));
056            }
057    
058            public Projection max(String propertyName) {
059                    return new ProjectionImpl(Projections.max(propertyName));
060            }
061    
062            public Projection min(String propertyName) {
063                    return new ProjectionImpl(Projections.min(propertyName));
064            }
065    
066            public ProjectionList projectionList() {
067                    return new ProjectionListImpl(Projections.projectionList());
068            }
069    
070            public Projection property(String propertyName) {
071                    return new ProjectionImpl(Projections.property(propertyName));
072            }
073    
074            public Projection rowCount() {
075                    return new ProjectionImpl(Projections.rowCount());
076            }
077    
078            public Projection sum(String propertyName) {
079                    return new ProjectionImpl(Projections.sum(propertyName));
080            }
081    
082    }