1 17 package org.alfresco.repo.rule.ruletrigger; 18 19 import java.io.Serializable ; 20 import java.util.List ; 21 import java.util.Map ; 22 23 import org.alfresco.repo.node.NodeServicePolicies; 24 import org.alfresco.repo.policy.JavaBehaviour; 25 import org.alfresco.service.cmr.repository.ChildAssociationRef; 26 import org.alfresco.service.cmr.repository.NodeRef; 27 import org.alfresco.service.namespace.NamespaceService; 28 import org.alfresco.service.namespace.QName; 29 30 35 public class OnPropertyUpdateRuleTrigger extends RuleTriggerAbstractBase 36 implements NodeServicePolicies.OnUpdatePropertiesPolicy 37 { 38 39 private boolean triggerParentRules = true; 40 41 46 public void setTriggerParentRules(boolean triggerParentRules) 47 { 48 this.triggerParentRules = triggerParentRules; 49 } 50 51 54 public void registerRuleTrigger() 55 { 56 this.policyComponent.bindClassBehaviour( 58 QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), 59 this, 60 new JavaBehaviour(this, "onUpdateProperties")); 61 } 62 63 public void onUpdateProperties(NodeRef nodeRef, Map <QName, Serializable > before, Map <QName, Serializable > after) 64 { 65 if (triggerParentRules == true) 66 { 67 List <ChildAssociationRef> parentsAssocRefs = this.nodeService.getParentAssocs(nodeRef); 68 for (ChildAssociationRef parentAssocRef : parentsAssocRefs) 69 { 70 triggerRules(parentAssocRef.getParentRef(), nodeRef); 71 } 72 } 73 else 74 { 75 triggerRules(nodeRef, nodeRef); 76 } 77 } 78 79 80 81 } 82 | Popular Tags |