mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
- 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:
@@ -19,6 +19,7 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionCondition;
|
||||
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.rule.Rule;
|
||||
import org.alfresco.service.cmr.rule.RuleService;
|
||||
@@ -100,7 +101,9 @@ public class CreateRuleWizard extends BaseActionWizard
|
||||
Node currentSpace = this.browseBean.getActionSpace();
|
||||
|
||||
// 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
|
||||
outcome = setupRule(context, rule, outcome);
|
||||
@@ -203,6 +206,21 @@ public class CreateRuleWizard extends BaseActionWizard
|
||||
{
|
||||
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
|
||||
@@ -651,6 +669,9 @@ public class CreateRuleWizard extends BaseActionWizard
|
||||
rule.applyToChildren(this.applyToSubSpaces);
|
||||
rule.setExecuteAsynchronously(this.runInBackground);
|
||||
|
||||
CompositeAction compositeAction = this.actionService.createCompositeAction();
|
||||
rule.setAction(compositeAction);
|
||||
|
||||
// add all the conditions to the rule
|
||||
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);
|
||||
condition.setInvertCondition(((Boolean)not).booleanValue());
|
||||
|
||||
rule.addActionCondition(condition);
|
||||
compositeAction.addActionCondition(condition);
|
||||
}
|
||||
|
||||
// add all the actions to the rule
|
||||
@@ -696,7 +717,7 @@ public class CreateRuleWizard extends BaseActionWizard
|
||||
// add the action to the rule
|
||||
Action action = this.actionService.createAction(actionName);
|
||||
action.setParameterValues(repoActionParams);
|
||||
rule.addAction(action);
|
||||
compositeAction.addAction(action);
|
||||
}
|
||||
|
||||
return outcome;
|
||||
|
@@ -12,6 +12,7 @@ import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionCondition;
|
||||
import org.alfresco.service.cmr.action.ActionConditionDefinition;
|
||||
import org.alfresco.service.cmr.action.ActionDefinition;
|
||||
import org.alfresco.service.cmr.action.CompositeAction;
|
||||
import org.alfresco.service.cmr.rule.Rule;
|
||||
import org.alfresco.web.bean.actions.IHandler;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
@@ -46,16 +47,19 @@ public class EditRuleWizard extends CreateRuleWizard
|
||||
}
|
||||
|
||||
// populate the bean with current values
|
||||
this.type = rule.getRuleTypeName();
|
||||
this.type = rule.getRuleTypes().get(0);
|
||||
this.title = rule.getTitle();
|
||||
this.description = rule.getDescription();
|
||||
this.applyToSubSpaces = rule.isAppliedToChildren();
|
||||
this.runInBackground = rule.getExecuteAsychronously();
|
||||
this.runInBackground = rule.getExecuteAsynchronously();
|
||||
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
|
||||
// Get the composite action
|
||||
CompositeAction compositeAction = getCompositeAction(rule);
|
||||
|
||||
// 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)
|
||||
{
|
||||
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
|
||||
List<Action> actions = rule.getActions();
|
||||
List<Action> actions = compositeAction.getActions();
|
||||
for (Action action : actions)
|
||||
{
|
||||
this.currentActionProperties = new HashMap<String, Serializable>(3);
|
||||
@@ -135,10 +139,13 @@ public class EditRuleWizard extends CreateRuleWizard
|
||||
|
||||
// get the existing rule
|
||||
Rule rule = this.rulesBean.getCurrentRule();
|
||||
|
||||
// Get the composite action
|
||||
CompositeAction compositeAction = getCompositeAction(rule);
|
||||
|
||||
// remove all the conditions and actions from the current rule
|
||||
rule.removeAllActionConditions();
|
||||
rule.removeAllActions();
|
||||
compositeAction.removeAllActionConditions();
|
||||
compositeAction.removeAllActions();
|
||||
|
||||
// re-setup the rule
|
||||
outcome = setupRule(context, rule, outcome);
|
||||
|
@@ -27,10 +27,12 @@ import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.action.executer.ExecuteAllRulesActionExecuter;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
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.RuleService;
|
||||
import org.alfresco.web.app.Application;
|
||||
@@ -67,6 +69,7 @@ public class RulesBean implements IContextListener
|
||||
private Rule currentRule;
|
||||
private UIRichList richList;
|
||||
private ActionService actionService;
|
||||
private NodeService nodeService;
|
||||
|
||||
|
||||
/**
|
||||
@@ -116,7 +119,11 @@ public class RulesBean implements IContextListener
|
||||
// wrap them all passing the current space
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -138,13 +145,13 @@ public class RulesBean implements IContextListener
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Rule clicked, it's id is: " + id);
|
||||
|
||||
this.currentRule = this.ruleService.getRule(
|
||||
getSpace().getNodeRef(), id);
|
||||
this.currentRule = this.ruleService.getRule(new NodeRef(id));
|
||||
//getSpace().getNodeRef(), id);
|
||||
|
||||
// refresh list
|
||||
contextUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reapply the currently defines rules to the
|
||||
@@ -306,6 +313,16 @@ public class RulesBean implements IContextListener
|
||||
{
|
||||
this.actionService = actionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the node service to use
|
||||
*
|
||||
* @param nodeService the node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
@@ -330,7 +347,9 @@ public class RulesBean implements IContextListener
|
||||
public static class WrappedRule
|
||||
{
|
||||
private Rule rule;
|
||||
private NodeRef ruleNode;
|
||||
private boolean isLocal;
|
||||
private Date createdDate;
|
||||
private Date modifiedDate;
|
||||
|
||||
/**
|
||||
* Constructs a RuleWrapper object
|
||||
@@ -338,10 +357,12 @@ public class RulesBean implements IContextListener
|
||||
* @param rule The rule we are wrapping
|
||||
* @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.ruleNode = ruleNode;
|
||||
this.isLocal = isLocal;
|
||||
this.createdDate = createdDate;
|
||||
this.modifiedDate = modifiedDate;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,7 +383,7 @@ public class RulesBean implements IContextListener
|
||||
*/
|
||||
public boolean getLocal()
|
||||
{
|
||||
return ruleNode.equals(this.rule.getOwningNodeRef());
|
||||
return this.isLocal;
|
||||
}
|
||||
|
||||
/** Methods to support sorting of the rules list in a table */
|
||||
@@ -374,7 +395,7 @@ public class RulesBean implements IContextListener
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return this.rule.getId();
|
||||
return this.rule.getNodeRef().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -404,7 +425,7 @@ public class RulesBean implements IContextListener
|
||||
*/
|
||||
public Date getCreatedDate()
|
||||
{
|
||||
return this.rule.getCreatedDate();
|
||||
return this.createdDate;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -414,7 +435,7 @@ public class RulesBean implements IContextListener
|
||||
*/
|
||||
public Date getModifiedDate()
|
||||
{
|
||||
return this.rule.getModifiedDate();
|
||||
return this.modifiedDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1009,6 +1009,10 @@
|
||||
<property-name>actionService</property-name>
|
||||
<value>#{ActionService}</value>
|
||||
</managed-property>
|
||||
<managed-property>
|
||||
<property-name>nodeService</property-name>
|
||||
<value>#{NodeService}</value>
|
||||
</managed-property>
|
||||
</managed-bean>
|
||||
|
||||
<managed-bean>
|
||||
|
Reference in New Issue
Block a user