Files
alfresco-community-repo/source/java/org/alfresco/repo/rating/AbstractRatingRollupAlgorithm.java
Alan Davis 91eb2644ad Merged 5.2.N (5.2.1) to HEAD (5.2)
125781 rmunteanu: Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
      125603 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2)
         125484 slanglois: MNT-16155 Update source headers - remove old Copyrights from Java and JSP dource files


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@127808 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2016-06-03 16:40:56 +00:00

83 lines
2.6 KiB
Java

package org.alfresco.repo.rating;
import java.io.Serializable;
import org.alfresco.api.AlfrescoPublicApi;
import org.alfresco.service.cmr.rating.RatingService;
import org.alfresco.service.cmr.rating.RatingServiceException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
import org.springframework.beans.factory.InitializingBean;
/**
* This class provides the basic implementation of a rating property rollup.
* By providing an implementation of this class (or reusing an existing one),
* injecting the object into the {@link org.alfresco.service.cmr.rating.RatingScheme} and following the content
* model naming conventions, it
* should be possible to have new rating property rollups automatically calculated
* and persisted into the Alfresco content model, thereby enabling indexing, searching
* and sorting of rating-related properties.
*
* @author Neil McErlean
* @since 3.5
*/
@AlfrescoPublicApi
public abstract class AbstractRatingRollupAlgorithm implements InitializingBean
{
protected String ratingSchemeName;
protected NamespaceService namespaceService;
protected NodeService nodeService;
protected RatingServiceImpl ratingServiceImpl;
protected final String rollupName;
public AbstractRatingRollupAlgorithm(String rollupName)
{
this.rollupName = rollupName;
}
public void setRatingSchemeName(String ratingScheme)
{
this.ratingSchemeName = ratingScheme;
}
public void setNamespaceService(NamespaceService namespaceService)
{
this.namespaceService = namespaceService;
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setRatingService(RatingService ratingService)
{
this.ratingServiceImpl = (RatingServiceImpl)ratingService;
}
@Override
public void afterPropertiesSet() throws Exception
{
if (ratingSchemeName == null)
{
throw new RatingServiceException("Illegal null ratingSchemeName in " + this.getClass().getSimpleName());
}
}
public abstract Serializable recalculate(NodeRef ratedNode);
/**
* This method returns the rollup name, for example "Total" or "Count".
* This rollup name is used as part of the convention-based naming of content model
* property names.
* @return String
*/
public String getRollupName()
{
return this.rollupName;
}
}