001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.ratings.transformer;
016    
017    import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
018    import com.liferay.portal.kernel.exception.PortalException;
019    import com.liferay.portlet.ratings.RatingsType;
020    
021    /**
022     * Provides an interface defining the transformations to be applied to the
023     * ratings data when the ratings type used by an entity is changed to use a
024     * different ratings type.
025     *
026     * <p>
027     * Implementations must be registered in the OSGI Registry. The portal invokes
028     * the highest ranking OSGI component implementing this interface when the
029     * ratings type of an entity is changed.
030     * </p>
031     *
032     * @author Roberto D??az
033     * @author Sergio Gonz??lez
034     */
035    public interface RatingsDataTransformer {
036    
037            /**
038             * Defines the transformations to be applied on a ratings entry when the
039             * ratings type is changed from the previous ratings type to the new ratings
040             * type.
041             *
042             * <p>
043             * This method returns an {@link ActionableDynamicQuery.PerformActionMethod}
044             * for operating on a {@link com.liferay.portlet.ratings.model.RatingsEntry}
045             * entity to transform its values based on when the ratings type is changed.
046             * </p>
047             *
048             * @param  fromRatingsType the previous ratings type
049             * @param  toRatingsType the final ratings type
050             * @return an {@link ActionableDynamicQuery.PerformActionMethod} with the
051             *         actions to be applied to the ratings entry when the ratings type
052             *         changes.
053             * @throws PortalException if the transformation could not be applied
054             *         successfully
055             */
056            public ActionableDynamicQuery.PerformActionMethod transformRatingsData(
057                            final RatingsType fromRatingsType, final RatingsType toRatingsType)
058                    throws PortalException;
059    
060    }