KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > service > cmr > rule > RuleService


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.service.cmr.rule;
18
19 import java.util.List JavaDoc;
20
21 import org.alfresco.service.cmr.repository.NodeRef;
22
23 /**
24  * Rule service interface.
25  *
26  * @author Roy Wetherall
27  */

28 public interface RuleService
29 {
30     /**
31      * Get the rule types currently defined in the repository.
32      *
33      * @return a list of rule types
34      */

35     public List JavaDoc<RuleType> getRuleTypes();
36
37     /**
38      * Gets a rule type by name.
39      *
40      * @param name the name of the rule type
41      * @return the rule type, null if not found
42      */

43     public RuleType getRuleType(String JavaDoc name);
44     
45     /**
46      * Indicates wether the rules for a given node are enabled or not. If the
47      * rules are not enabled then they will not be executed.
48      *
49      * @param nodeRef the node reference
50      * @return true if the rules are enabled, false otherwise
51      */

52     public boolean rulesEnabled(NodeRef nodeRef);
53     
54     /**
55      * Disables the rules for a given node reference. When the rules are disabled they
56      * will not execute.
57      *
58      * @param nodeRef the node reference
59      */

60     public void disableRules(NodeRef nodeRef);
61     
62     /**
63      * Enables the rules for a given node reference. When the rules are enabled they
64      * will execute as usual. By default all rules are enabled.
65      *
66      * @param nodeRef the node reference
67      */

68     public void enableRules(NodeRef nodeRef);
69     
70     /**
71      * Disables a rule, preventing it from being fired.
72      *
73      * @param rule the rule to disable
74      */

75     public void disableRule(Rule rule);
76     
77     /**
78      * Enables a rule previously disabled.
79      *
80      * @param rule the rule to enable
81      */

82     public void enableRule(Rule rule);
83
84     /**
85      * Indicates whether the node in question has any rules associated with it.
86      *
87      * @param nodeRef the node reference
88      * @return true if the node has rules associated, false otherwise
89      */

90     public boolean hasRules(NodeRef nodeRef);
91
92     /**
93      * Get all the rules associated with an actionable node, including those
94      * inherited from parents.
95      * <p>
96      * An exception is raised if the actionable aspect is not present on the
97      * passed node.
98      *
99      * @param nodeRef the node reference
100      * @return a list of the rules associated with the node
101      */

102     public List JavaDoc<Rule> getRules(NodeRef nodeRef);
103
104     /**
105      * Get the rules associated with an actionable node.
106      * <p>
107      * Optionally this list includes rules inherited from its parents.
108      * <p>
109      * An exception is raised if the actionable aspect is not present on the
110      * passed node.
111      *
112      * @param nodeRef the node reference
113      * @param includeInhertied indicates whether the inherited rules should be included in
114      * the result list or not
115      * @return a list of the rules associated with the node
116      */

117     public List JavaDoc<Rule> getRules(NodeRef nodeRef, boolean includeInhertied);
118     
119     /**
120      * Get the rules associated with an actionable node that are of a specific rule type.
121      *
122      * @param nodeRef the node reference
123      * @param includeInhertiedRuleType indicates whether the inherited rules should be included in
124      * the result list or not
125      * @param ruleTypeName the name of the rule type, if null is passed all rule types
126      * are returned
127      * @return a list of the rules associated with the node
128      */

129     public List JavaDoc<Rule> getRules(NodeRef nodeRef, boolean includeInhertiedRuleType, String JavaDoc ruleTypeName);
130
131     /**
132      * Count the number of rules associated with an actionable node.
133      *
134      * @param nodeRef the node reference
135      * @return a list of the rules associated with the node
136      */

137     public int countRules(NodeRef nodeRef);
138     
139     /**
140      * Get the rule given its id.
141      *
142      * @param nodeRef the node reference
143      * @param ruleId the rule id
144      * @return the rule corresponding ot the id
145      */

146     public Rule getRule(NodeRef nodeRef, String JavaDoc ruleId);
147     
148     /**
149      * Helper method to create a new rule.
150      * <p>
151      * Call add rule once the details of the rule have been specified in order
152      * to associate the rule with a node reference.
153      *
154      * @param ruleTypeName the name of the rule type
155      * @return the created rule
156      */

157     public Rule createRule(String JavaDoc ruleTypeName);
158
159     /**
160      * Saves the details of the rule to the specified node reference.
161      * <p>
162      * If the rule is already associated with the node, the details are updated
163      * with those specified.
164      *
165      * @param nodeRef
166      * @param rule
167      */

168     public void saveRule(NodeRef nodeRef, Rule rule);
169         
170     /**
171      * Removes a rule from the given rule actionable node
172      *
173      * @param nodeRef the actionable node reference
174      */

175     public void removeRule(NodeRef nodeRef, Rule rule);
176     
177     /**
178      * Removes all the rules associated with an actionable node
179      *
180      * @param nodeRef the actionable node reference
181      */

182     public void removeAllRules(NodeRef nodeRef);
183 }
184
Popular Tags