Big honkin' merge from head. Sheesh!

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3617 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-08-27 01:01:30 +00:00
parent 465ae145be
commit b0d02fa6be
241 changed files with 12379 additions and 1061 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.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;
@@ -67,6 +68,7 @@ public class CreateRuleWizard extends BaseActionWizard
protected boolean runInBackground;
protected boolean applyToSubSpaces;
protected boolean editingCondition;
protected boolean ruleDisabled;
private static final Log logger = LogFactory.getLog(CreateRuleWizard.class);
@@ -84,6 +86,7 @@ public class CreateRuleWizard extends BaseActionWizard
this.condition = null;
this.applyToSubSpaces = false;
this.runInBackground = false;
this.ruleDisabled = false;
this.conditions = null;
this.allConditionsProperties = new ArrayList<Map<String, Serializable>>();
@@ -100,7 +103,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);
@@ -189,12 +194,13 @@ public class CreateRuleWizard extends BaseActionWizard
String backgroundYesNo = this.runInBackground ? bundle.getString("yes") : bundle.getString("no");
String subSpacesYesNo = this.applyToSubSpaces ? bundle.getString("yes") : bundle.getString("no");
String ruleDisabledYesNo = this.ruleDisabled ? bundle.getString("yes") : bundle.getString("no");
return buildSummary(
new String[] {bundle.getString("rule_type"), bundle.getString("name"), bundle.getString("description"),
bundle.getString("apply_to_sub_spaces"), bundle.getString("run_in_background"),
bundle.getString("apply_to_sub_spaces"), bundle.getString("run_in_background"), bundle.getString("rule_disabled"),
bundle.getString("conditions"), bundle.getString("actions")},
new String[] {this.type, this.title, this.description, subSpacesYesNo, backgroundYesNo,
new String[] {this.type, this.title, this.description, subSpacesYesNo, backgroundYesNo, ruleDisabledYesNo,
conditionsSummary.toString(), actionsSummary.toString()});
}
@@ -203,6 +209,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
@@ -437,6 +458,22 @@ public class CreateRuleWizard extends BaseActionWizard
this.applyToSubSpaces = applyToSubSpaces;
}
/**
* @return Returns whether the rule is disabled or not.
*/
public boolean getRuleDisabled()
{
return this.ruleDisabled;
}
/**
* @param ruleDisabled Sets whether the rule is disabled or not
*/
public void setRuleDisabled(boolean ruleDisabled)
{
this.ruleDisabled = ruleDisabled;
}
/**
* @return Returns the type.
*/
@@ -650,6 +687,10 @@ public class CreateRuleWizard extends BaseActionWizard
rule.setDescription(this.description);
rule.applyToChildren(this.applyToSubSpaces);
rule.setExecuteAsynchronously(this.runInBackground);
rule.setRuleDisabled(this.ruleDisabled);
CompositeAction compositeAction = this.actionService.createCompositeAction();
rule.setAction(compositeAction);
// add all the conditions to the rule
for (Map<String, Serializable> condParams : this.allConditionsProperties)
@@ -674,7 +715,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 +737,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;

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.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,20 @@ 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();
this.ruleDisabled = rule.getRuleDisabled();
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 +95,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 +140,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);

View File

@@ -27,10 +27,13 @@ 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.repo.rule.RuleModel;
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;
@@ -55,6 +58,8 @@ public class RulesBean implements IContextListener
{
private static final String MSG_ERROR_DELETE_RULE = "error_delete_rule";
private static final String MSG_REAPPLY_RULES_SUCCESS = "reapply_rules_success";
private static final String MSG_IGNORE_INHERTIED_RULES = "ignore_inherited_rules";
private static final String MSG_INCLUDE_INHERITED_RULES = "include_inherited_rules";
private static final String LOCAL = "local";
private static final String INHERITED = "inherited";
@@ -67,6 +72,7 @@ public class RulesBean implements IContextListener
private Rule currentRule;
private UIRichList richList;
private ActionService actionService;
private NodeService nodeService;
/**
@@ -116,7 +122,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 +148,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
@@ -193,6 +203,52 @@ public class RulesBean implements IContextListener
}
}
/**
* Gets the label id from the ignore inhertied action
*
* @return the message id
*/
public String getIgnoreInheritedRulesLabelId()
{
FacesContext fc = FacesContext.getCurrentInstance();
String result = Application.getMessage(fc, MSG_IGNORE_INHERTIED_RULES);
if (this.nodeService.hasAspect(this.getSpace().getNodeRef(), RuleModel.ASPECT_IGNORE_INHERITED_RULES) == true)
{
result = Application.getMessage(fc, MSG_INCLUDE_INHERITED_RULES);
}
return result;
}
public boolean getIgnoreInheritedRules()
{
return this.nodeService.hasAspect(this.getSpace().getNodeRef(), RuleModel.ASPECT_IGNORE_INHERITED_RULES);
}
/**
* Action listener to ignore (or include) inherited rules.
*
* @param event the action event object
*/
public void ignoreInheritedRules(ActionEvent event)
{
NodeRef nodeRef = this.getSpace().getNodeRef();
if (this.nodeService.hasAspect(nodeRef, RuleModel.ASPECT_IGNORE_INHERITED_RULES) == true)
{
this.nodeService.removeAspect(nodeRef, RuleModel.ASPECT_IGNORE_INHERITED_RULES);
}
else
{
this.nodeService.addAspect(nodeRef, RuleModel.ASPECT_IGNORE_INHERITED_RULES, null);
}
// force the list to be re-queried when the page is refreshed
if (this.richList != null)
{
this.richList.setValue(null);
}
}
/**
* Returns the current rule
*
@@ -306,6 +362,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 +396,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 +406,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 +432,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 +444,7 @@ public class RulesBean implements IContextListener
*/
public String getId()
{
return this.rule.getId();
return this.rule.getNodeRef().toString();
}
/**
@@ -404,7 +474,7 @@ public class RulesBean implements IContextListener
*/
public Date getCreatedDate()
{
return this.rule.getCreatedDate();
return this.createdDate;
}
/**
@@ -414,7 +484,7 @@ public class RulesBean implements IContextListener
*/
public Date getModifiedDate()
{
return this.rule.getModifiedDate();
return this.modifiedDate;
}
}
}

View File

@@ -49,7 +49,7 @@ public class HasAspectHandler extends BaseConditionHandler
String label = null;
String aspectName = (String)conditionProps.get(PROP_ASPECT);
for (SelectItem item : ((CreateRuleWizard)wizard).getAspects())
for (SelectItem item : ((CreateRuleWizard)wizard).getTestableAspects())
{
if (item.getValue().equals(aspectName))
{