- Action/Rule decoupling work

- Updated web services, SDK and web client where appropraite
- Patch added to migrate existing rules
- Entire rule service can now be disabled programmatically
- Rule service is now disabled during the patching process
- StoreEnum and languageEnum types removed from web service interfaces
- Multiple rule types now supported in the repo (but not in the UI)
- Removed owning node ref from action and rule .. now calculated from methods on the rule service

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3464 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2006-08-07 15:53:45 +00:00
parent df21ad9f8b
commit df7f1062df
33 changed files with 964 additions and 555 deletions

View File

@@ -29,6 +29,14 @@ import org.alfresco.service.cmr.repository.NodeRef;
*/
public interface Action extends ParameterizedItem
{
/**
* Gets the node ref that represents the saved action node.
* Returns null id unsaved.
*
* @return the action node reference
*/
NodeRef getNodeRef();
/**
* Get the name of the action definition that relates to this action
*
@@ -63,16 +71,6 @@ public interface Action extends ParameterizedItem
* @param description the description of the action
*/
void setDescription(String description);
/**
* Get the node reference of the node that 'owns' this action.
* <p>
* The node that 'owns' the action is th one that stores it via its
* actionable aspect association.
*
* @return node reference
*/
NodeRef getOwningNodeRef();
/**
* Gets a value indicating whether the action should be executed asychronously or not.

View File

@@ -14,43 +14,186 @@
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.service.cmr.rule;
import org.alfresco.service.cmr.action.CompositeAction;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Rule Interface
* Rule class.
* <p>
* Encapsulates all the information about a rule. Can be creted or editied and
* then passed to the rule service to create/update a rule instance.
*
* @author Roy Wetherall
*/
public interface Rule extends CompositeAction
public class Rule implements Serializable
{
/**
* Indicates that the rule is applied to the children of the associated
* node, not just the node itself.
* <p>
* By default this will be set to false.
*
* @return true if the rule is applied to the children of the associated node,
* false otherwise
*/
boolean isAppliedToChildren();
/**
* Set whether the rule is applied to all children of the associated node
* rather than just the node itself.
*
* @param isAppliedToChildren true if the rule should be applied to the children, false
* otherwise
*/
void applyToChildren(boolean isAppliedToChildren);
/**
* Serial version UID
*/
private static final long serialVersionUID = 3544385898889097524L;
/**
* Get the rule type name
*
* @return the rule type name
* The rule node reference
*/
String getRuleTypeName();
}
private NodeRef nodeRef;
/**
* The title of the rule
*/
private String title;
/**
* The description of the rule
*/
private String description;
/**
* The rule types
*/
private List<String> ruleTypes;
/**
* The associated action
*/
private Action action;
/**
* Indicates whether the rule should execute the action asynchronously or not
*/
private boolean executeAsynchronously = false;
/**
* Indicates whether the rule is applied to all the children of the associated node
* rather than just the node itself.
*/
private boolean isAppliedToChildren = false;
public Rule()
{
}
public Rule(NodeRef nodeRef)
{
this.nodeRef = nodeRef;
}
public void setAction(Action action)
{
this.action = action;
}
public Action getAction()
{
return action;
}
public void setNodeRef(NodeRef nodeRef)
{
this.nodeRef = nodeRef;
}
public NodeRef getNodeRef()
{
return nodeRef;
}
public void setTitle(String title)
{
this.title = title;
}
public String getTitle()
{
return title;
}
public void setDescription(String description)
{
this.description = description;
}
public String getDescription()
{
return description;
}
/**
* @see org.alfresco.service.cmr.rule.Rule#isAppliedToChildren()
*/
public boolean isAppliedToChildren()
{
return this.isAppliedToChildren;
}
/**
*@see org.alfresco.service.cmr.rule.Rule#applyToChildren(boolean)
*/
public void applyToChildren(boolean isAppliedToChildren)
{
this.isAppliedToChildren = isAppliedToChildren;
}
public void setRuleType(String ruleType)
{
List<String> ruleTypes = new ArrayList<String>(1);
ruleTypes.add(ruleType);
this.ruleTypes = ruleTypes;
}
public void setRuleTypes(List<String> ruleTypes)
{
this.ruleTypes = ruleTypes;
}
public List<String> getRuleTypes()
{
return ruleTypes;
}
public void setExecuteAsynchronously(boolean executeAsynchronously)
{
this.executeAsynchronously = executeAsynchronously;
}
public boolean getExecuteAsynchronously()
{
return this.executeAsynchronously;
}
/**
* Hash code implementation
*/
@Override
public int hashCode()
{
return this.nodeRef.hashCode();
}
/**
* Equals implementation
*/
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj instanceof Rule)
{
Rule that = (Rule) obj;
return (this.nodeRef.equals(that.nodeRef));
}
else
{
return false;
}
}
}

View File

@@ -19,6 +19,7 @@ package org.alfresco.service.cmr.rule;
import java.util.List;
import org.alfresco.service.Auditable;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.NodeRef;
/**
@@ -45,6 +46,26 @@ public interface RuleService
@Auditable(parameters = {"name"})
public RuleType getRuleType(String name);
/**
* Enable rules for the current thread
*/
@Auditable
public void enableRules();
/**
* Diable rules for the current thread
*/
@Auditable
public void disableRules();
/**
* Indicates whether rules are currently enabled or not
*
* @return true if rules are enabled, false otherwise
*/
@Auditable
public boolean isEnabled();
/**
* Indicates wether the rules for a given node are enabled or not. If the
* rules are not enabled then they will not be executed.
@@ -150,26 +171,13 @@ public interface RuleService
public int countRules(NodeRef nodeRef);
/**
* Get the rule given its id.
* Get the rule given its node reference
*
* @param nodeRef the node reference
* @param ruleId the rule id
* @return the rule corresponding ot the id
* @return the rule corresponding to the node reference
*/
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "ruleId"})
public Rule getRule(NodeRef nodeRef, String ruleId);
/**
* Helper method to create a new rule.
* <p>
* Call add rule once the details of the rule have been specified in order
* to associate the rule with a node reference.
*
* @param ruleTypeName the name of the rule type
* @return the created rule
*/
@Auditable(parameters = {"ruleTypeName"})
public Rule createRule(String ruleTypeName);
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef"})
public Rule getRule(NodeRef nodeRef);
/**
* Saves the details of the rule to the specified node reference.
@@ -198,4 +206,25 @@ public interface RuleService
*/
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef"})
public void removeAllRules(NodeRef nodeRef);
/**
* Returns the owning node reference for a rule.
*
* @param rule the rule
* @return the owning node reference
*/
@Auditable(key = Auditable.Key.ARG_0, parameters = {"rule"})
public NodeRef getOwningNodeRef(Rule rule);
/**
* Returns the owning node reference for an action. Returns null for an unsaved action or one that is not
* parented by a rule.
*
* NOTE: this method is temporary and will be removed in future versions. It should only be used with good reason.
*
* @param action the action
* @return the owning node reference
*/
@Auditable(key = Auditable.Key.ARG_0, parameters = {"action"})
public NodeRef getOwningNodeRef(Action action);
}