// Path: behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/model/SomeCoRatingsModel.java
// public interface SomeCoRatingsModel {
//     // Namespaces
//     public static final String NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL  = "http://www.someco.com/model/ratings/1.0";
// 
//     // Types
//     public static final String TYPE_SCR_RATING = "rating";
// 
//     // Aspects
//     public static final String ASPECT_SCR_RATEABLE = "rateable";
// 
//     // Properties
//     public static final String PROP_RATING = "rating";
//     public static final String PROP_RATER = "rater";
//     public static final String PROP_AVERAGE_RATING= "averageRating";
//     public static final String PROP_TOTAL_RATING= "totalRating";
//     public static final String PROP_RATING_COUNT= "ratingCount";
// 
//     // Associations
//     public static final String ASSN_SCR_RATINGS = "ratings";
// }


import java.util.List;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.Behaviour;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.apache.log4j.Logger;
import com.someco.model.SomeCoRatingsModel;
package com.someco.behavior;




public class Rating
	implements NodeServicePolicies.OnDeleteNodePolicy,
			   NodeServicePolicies.OnCreateNodePolicy {

	// Dependencies
    private NodeService nodeService;
    private PolicyComponent policyComponent;

    // Behaviours
    private Behaviour onCreateNode;
    private Behaviour onDeleteNode;
    
    private Logger logger = Logger.getLogger(Rating.class);
    
    public void init() {
    	if (logger.isDebugEnabled()) logger.debug("Initializing rateable behaviors");
    	
        // Create behaviours
        this.onCreateNode = new JavaBehaviour(this, "onCreateNode", NotificationFrequency.EVERY_EVENT);
        this.onDeleteNode = new JavaBehaviour(this, "onDeleteNode", NotificationFrequency.EVERY_EVENT);

        // Bind behaviours to node policies
// Path: behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/model/SomeCoRatingsModel.java
// public interface SomeCoRatingsModel {
//     // Namespaces
//     public static final String NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL  = "http://www.someco.com/model/ratings/1.0";
// 
//     // Types
//     public static final String TYPE_SCR_RATING = "rating";
// 
//     // Aspects
//     public static final String ASPECT_SCR_RATEABLE = "rateable";
// 
//     // Properties
//     public static final String PROP_RATING = "rating";
//     public static final String PROP_RATER = "rater";
//     public static final String PROP_AVERAGE_RATING= "averageRating";
//     public static final String PROP_TOTAL_RATING= "totalRating";
//     public static final String PROP_RATING_COUNT= "ratingCount";
// 
//     // Associations
//     public static final String ASSN_SCR_RATINGS = "ratings";
// }


// Path: behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/behavior/Rating.java
import java.util.List;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.Behaviour;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.apache.log4j.Logger;
import com.someco.model.SomeCoRatingsModel;

package com.someco.behavior;




public class Rating
	implements NodeServicePolicies.OnDeleteNodePolicy,
			   NodeServicePolicies.OnCreateNodePolicy {

	// Dependencies
    private NodeService nodeService;
    private PolicyComponent policyComponent;

    // Behaviours
    private Behaviour onCreateNode;
    private Behaviour onDeleteNode;
    
    private Logger logger = Logger.getLogger(Rating.class);
    
    public void init() {
    	if (logger.isDebugEnabled()) logger.debug("Initializing rateable behaviors");
    	
        // Create behaviours
        this.onCreateNode = new JavaBehaviour(this, "onCreateNode", NotificationFrequency.EVERY_EVENT);
        this.onDeleteNode = new JavaBehaviour(this, "onDeleteNode", NotificationFrequency.EVERY_EVENT);

        // Bind behaviours to node policies
        this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), QName.createQName(SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL, SomeCoRatingsModel.TYPE_SCR_RATING), this.onCreateNode);