- 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 a4e8facbae
commit cbe407f6b1
4 changed files with 73 additions and 20 deletions

View File

@@ -19,6 +19,7 @@ import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionCondition; import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.action.ActionConditionDefinition; import org.alfresco.service.cmr.action.ActionConditionDefinition;
import org.alfresco.service.cmr.action.CompositeAction;
import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.cmr.dictionary.TypeDefinition;
import org.alfresco.service.cmr.rule.Rule; import org.alfresco.service.cmr.rule.Rule;
import org.alfresco.service.cmr.rule.RuleService; import org.alfresco.service.cmr.rule.RuleService;
@@ -100,7 +101,9 @@ public class CreateRuleWizard extends BaseActionWizard
Node currentSpace = this.browseBean.getActionSpace(); Node currentSpace = this.browseBean.getActionSpace();
// create the new rule // create the new rule
Rule rule = this.ruleService.createRule(this.getType()); //Rule rule = this.ruleService.createRule(this.getType());
Rule rule = new Rule();
rule.setRuleType(this.getType());
// setup the rule // setup the rule
outcome = setupRule(context, rule, outcome); outcome = setupRule(context, rule, outcome);
@@ -204,6 +207,21 @@ public class CreateRuleWizard extends BaseActionWizard
return "error_rule"; return "error_rule";
} }
protected CompositeAction getCompositeAction(Rule rule)
{
// Get the composite action
Action ruleAction = rule.getAction();
if (ruleAction == null)
{
throw new AlfrescoRuntimeException("Rule does not have associated action.");
}
else if ((ruleAction instanceof CompositeAction) == false)
{
throw new AlfrescoRuntimeException("Rules with non-composite actions are not currently supported by the UI");
}
return (CompositeAction)ruleAction;
}
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Bean Getters and Setters // Bean Getters and Setters
@@ -651,6 +669,9 @@ public class CreateRuleWizard extends BaseActionWizard
rule.applyToChildren(this.applyToSubSpaces); rule.applyToChildren(this.applyToSubSpaces);
rule.setExecuteAsynchronously(this.runInBackground); rule.setExecuteAsynchronously(this.runInBackground);
CompositeAction compositeAction = this.actionService.createCompositeAction();
rule.setAction(compositeAction);
// add all the conditions to the rule // add all the conditions to the rule
for (Map<String, Serializable> condParams : this.allConditionsProperties) for (Map<String, Serializable> condParams : this.allConditionsProperties)
{ {
@@ -674,7 +695,7 @@ public class CreateRuleWizard extends BaseActionWizard
Boolean not = (Boolean)condParams.get(BaseConditionHandler.PROP_CONDITION_NOT); Boolean not = (Boolean)condParams.get(BaseConditionHandler.PROP_CONDITION_NOT);
condition.setInvertCondition(((Boolean)not).booleanValue()); condition.setInvertCondition(((Boolean)not).booleanValue());
rule.addActionCondition(condition); compositeAction.addActionCondition(condition);
} }
// add all the actions to the rule // add all the actions to the rule
@@ -696,7 +717,7 @@ public class CreateRuleWizard extends BaseActionWizard
// add the action to the rule // add the action to the rule
Action action = this.actionService.createAction(actionName); Action action = this.actionService.createAction(actionName);
action.setParameterValues(repoActionParams); action.setParameterValues(repoActionParams);
rule.addAction(action); compositeAction.addAction(action);
} }
return outcome; return outcome;

View File

@@ -12,6 +12,7 @@ import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionCondition; import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.action.ActionConditionDefinition; import org.alfresco.service.cmr.action.ActionConditionDefinition;
import org.alfresco.service.cmr.action.ActionDefinition; import org.alfresco.service.cmr.action.ActionDefinition;
import org.alfresco.service.cmr.action.CompositeAction;
import org.alfresco.service.cmr.rule.Rule; import org.alfresco.service.cmr.rule.Rule;
import org.alfresco.web.bean.actions.IHandler; import org.alfresco.web.bean.actions.IHandler;
import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Node;
@@ -46,16 +47,19 @@ public class EditRuleWizard extends CreateRuleWizard
} }
// populate the bean with current values // populate the bean with current values
this.type = rule.getRuleTypeName(); this.type = rule.getRuleTypes().get(0);
this.title = rule.getTitle(); this.title = rule.getTitle();
this.description = rule.getDescription(); this.description = rule.getDescription();
this.applyToSubSpaces = rule.isAppliedToChildren(); this.applyToSubSpaces = rule.isAppliedToChildren();
this.runInBackground = rule.getExecuteAsychronously(); this.runInBackground = rule.getExecuteAsynchronously();
FacesContext context = FacesContext.getCurrentInstance(); FacesContext context = FacesContext.getCurrentInstance();
// Get the composite action
CompositeAction compositeAction = getCompositeAction(rule);
// populate the conditions list with maps of properties representing each condition // populate the conditions list with maps of properties representing each condition
List<ActionCondition> conditions = rule.getActionConditions(); List<ActionCondition> conditions = compositeAction.getActionConditions();
for (ActionCondition condition : conditions) for (ActionCondition condition : conditions)
{ {
this.currentConditionProperties = new HashMap<String, Serializable>(3); this.currentConditionProperties = new HashMap<String, Serializable>(3);
@@ -90,7 +94,7 @@ public class EditRuleWizard extends CreateRuleWizard
} }
// populate the actions list with maps of properties representing each action // populate the actions list with maps of properties representing each action
List<Action> actions = rule.getActions(); List<Action> actions = compositeAction.getActions();
for (Action action : actions) for (Action action : actions)
{ {
this.currentActionProperties = new HashMap<String, Serializable>(3); this.currentActionProperties = new HashMap<String, Serializable>(3);
@@ -136,9 +140,12 @@ public class EditRuleWizard extends CreateRuleWizard
// get the existing rule // get the existing rule
Rule rule = this.rulesBean.getCurrentRule(); Rule rule = this.rulesBean.getCurrentRule();
// Get the composite action
CompositeAction compositeAction = getCompositeAction(rule);
// remove all the conditions and actions from the current rule // remove all the conditions and actions from the current rule
rule.removeAllActionConditions(); compositeAction.removeAllActionConditions();
rule.removeAllActions(); compositeAction.removeAllActions();
// re-setup the rule // re-setup the rule
outcome = setupRule(context, rule, outcome); outcome = setupRule(context, rule, outcome);

View File

@@ -27,10 +27,12 @@ import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent; import javax.faces.event.ActionEvent;
import javax.transaction.UserTransaction; import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.ExecuteAllRulesActionExecuter; import org.alfresco.repo.action.executer.ExecuteAllRulesActionExecuter;
import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.rule.Rule; import org.alfresco.service.cmr.rule.Rule;
import org.alfresco.service.cmr.rule.RuleService; import org.alfresco.service.cmr.rule.RuleService;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
@@ -67,6 +69,7 @@ public class RulesBean implements IContextListener
private Rule currentRule; private Rule currentRule;
private UIRichList richList; private UIRichList richList;
private ActionService actionService; private ActionService actionService;
private NodeService nodeService;
/** /**
@@ -116,7 +119,11 @@ public class RulesBean implements IContextListener
// wrap them all passing the current space // wrap them all passing the current space
for (Rule rule : repoRules) for (Rule rule : repoRules)
{ {
WrappedRule wrapped = new WrappedRule(rule, getSpace().getNodeRef()); Date createdDate = (Date)this.nodeService.getProperty(rule.getNodeRef(), ContentModel.PROP_CREATED);
Date modifiedDate = (Date)this.nodeService.getProperty(rule.getNodeRef(), ContentModel.PROP_MODIFIED);
boolean isLocal = getSpace().getNodeRef().equals(this.ruleService.getOwningNodeRef(rule));
WrappedRule wrapped = new WrappedRule(rule, isLocal, createdDate, modifiedDate);
this.rules.add(wrapped); this.rules.add(wrapped);
} }
@@ -138,8 +145,8 @@ public class RulesBean implements IContextListener
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Rule clicked, it's id is: " + id); logger.debug("Rule clicked, it's id is: " + id);
this.currentRule = this.ruleService.getRule( this.currentRule = this.ruleService.getRule(new NodeRef(id));
getSpace().getNodeRef(), id); //getSpace().getNodeRef(), id);
// refresh list // refresh list
contextUpdated(); contextUpdated();
@@ -307,6 +314,16 @@ public class RulesBean implements IContextListener
this.actionService = actionService; this.actionService = actionService;
} }
/**
* Set the node service to use
*
* @param nodeService the node service
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// IContextListener implementation // IContextListener implementation
@@ -330,7 +347,9 @@ public class RulesBean implements IContextListener
public static class WrappedRule public static class WrappedRule
{ {
private Rule rule; private Rule rule;
private NodeRef ruleNode; private boolean isLocal;
private Date createdDate;
private Date modifiedDate;
/** /**
* Constructs a RuleWrapper object * Constructs a RuleWrapper object
@@ -338,10 +357,12 @@ public class RulesBean implements IContextListener
* @param rule The rule we are wrapping * @param rule The rule we are wrapping
* @param ruleNode The node the rules belong to * @param ruleNode The node the rules belong to
*/ */
public WrappedRule(Rule rule, NodeRef ruleNode) public WrappedRule(Rule rule, boolean isLocal, Date createdDate, Date modifiedDate)
{ {
this.rule = rule; this.rule = rule;
this.ruleNode = ruleNode; this.isLocal = isLocal;
this.createdDate = createdDate;
this.modifiedDate = modifiedDate;
} }
/** /**
@@ -362,7 +383,7 @@ public class RulesBean implements IContextListener
*/ */
public boolean getLocal() public boolean getLocal()
{ {
return ruleNode.equals(this.rule.getOwningNodeRef()); return this.isLocal;
} }
/** Methods to support sorting of the rules list in a table */ /** Methods to support sorting of the rules list in a table */
@@ -374,7 +395,7 @@ public class RulesBean implements IContextListener
*/ */
public String getId() public String getId()
{ {
return this.rule.getId(); return this.rule.getNodeRef().toString();
} }
/** /**
@@ -404,7 +425,7 @@ public class RulesBean implements IContextListener
*/ */
public Date getCreatedDate() public Date getCreatedDate()
{ {
return this.rule.getCreatedDate(); return this.createdDate;
} }
/** /**
@@ -414,7 +435,7 @@ public class RulesBean implements IContextListener
*/ */
public Date getModifiedDate() public Date getModifiedDate()
{ {
return this.rule.getModifiedDate(); return this.modifiedDate;
} }
} }
} }

View File

@@ -1009,6 +1009,10 @@
<property-name>actionService</property-name> <property-name>actionService</property-name>
<value>#{ActionService}</value> <value>#{ActionService}</value>
</managed-property> </managed-property>
<managed-property>
<property-name>nodeService</property-name>
<value>#{NodeService}</value>
</managed-property>
</managed-bean> </managed-bean>
<managed-bean> <managed-bean>