KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > rule > ruletrigger > OnPropertyUpdateRuleTrigger


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.rule.ruletrigger;
18
19 import java.io.Serializable JavaDoc;
20 import java.util.List JavaDoc;
21 import java.util.Map JavaDoc;
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 /**
31  * On propety update trigger
32  *
33  * @author Roy Wetherall
34  */

35 public class OnPropertyUpdateRuleTrigger extends RuleTriggerAbstractBase
36                                         implements NodeServicePolicies.OnUpdatePropertiesPolicy
37 {
38     /** True trigger parent rules, false otherwier */
39     private boolean triggerParentRules = true;
40     
41     /**
42      * Indicates whether the parent rules should be triggered or the rules on the node itself
43      *
44      * @param triggerParentRules true trigger parent rules, false otherwise
45      */

46     public void setTriggerParentRules(boolean triggerParentRules)
47     {
48         this.triggerParentRules = triggerParentRules;
49     }
50     
51     /*
52      * @see org.alfresco.repo.rule.ruletrigger.RuleTrigger#registerRuleTrigger()
53      */

54     public void registerRuleTrigger()
55     {
56         // Bind behaviour
57
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 JavaDoc<QName, Serializable JavaDoc> before, Map JavaDoc<QName, Serializable JavaDoc> after)
64     {
65         if (triggerParentRules == true)
66         {
67             List JavaDoc<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