Merged V2.2 to HEAD 7461: Reapply rules to children and other rule related fixes

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8385 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2008-02-26 16:35:04 +00:00
parent 71d11e9d79
commit 218cb33e75
3 changed files with 59 additions and 36 deletions

View File

@@ -347,7 +347,8 @@ add_multiple_files=Add Multiple Files
import_directory=Import Directory
advanced_space_wizard=Advanced Space Wizard
create_rule=Create Rule
reapply_rules=Reapply Rules
reapply_rules=Reapply Rules In Space
reapply_rules_to_children=Reapply Rules in Space and Children
reapply_rules_success=The rules have been successfully reapplied.
ignore_inherited_rules=Ignore Inherited Rules
include_inherited_rules=Include Inherited Rules

View File

@@ -638,7 +638,19 @@
<action id="reapply-rules">
<label-id>reapply_rules</label-id>
<image>/images/icons/reapply_rules.gif</image>
<action-listener>#{RulesDialog.reapplyRules}</action-listener>
<action-listener>#{RulesDialog.reapplyRules}</action-listener>
<params>
<param name="toChildren">False</param>
</params>
</action>
<action id="reapply-rules-to-children">
<label-id>reapply_rules_to_children</label-id>
<image>/images/icons/reapply_rules.gif</image>
<action-listener>#{RulesDialog.reapplyRules}</action-listener>
<params>
<param name="toChildren">True</param>
</params>
</action>
<!-- Ignore Inherited Rules -->
@@ -728,22 +740,7 @@
<label-id>create_rule</label-id>
<image>/images/icons/new_rule.gif</image>
<action>wizard:createRule</action>
</action>
<!-- ReApply Rules -->
<action id="reapply-rules">
<label-id>reapply_rules</label-id>
<image>/images/icons/reapply_rules.gif</image>
<action-listener>#{RulesDialog.reapplyRules}</action-listener>
</action>
<!-- Ignore Inherited Rules -->
<action id="ignore-inherited-rules">
<label>#{RulesDialog.ignoreInheritedRulesLabelId}</label>
<image>/images/icons/reapply_rules.gif</image>
<action-listener>#{RulesDialog.ignoreInheritedRules}</action-listener>
</action>
</action>
<!-- Create a category -->
<action id="add_category">
@@ -1034,7 +1031,8 @@
<!-- Actions Menu for Manage Rules screen -->
<action-group id="rules_actions_menu">
<action idref="reapply-rules" />
<action idref="reapply-rules" />
<action idref="reapply-rules-to-children" />
<action idref="ignore-inherited-rules" />
</action-group>
@@ -1085,12 +1083,6 @@
<action idref="create_rule"/>
</action-group>
<!-- Actions Menu for Manage Rules screen -->
<action-group id="rules_actions_menu">
<action idref="reapply-rules" />
<action idref="ignore-inherited-rules" />
</action-group>
<!-- Actions Menu for Manage Deleted Items screen -->
<action-group id="manage_deleted_items_menu">
<action idref="recover_all_items" />

View File

@@ -41,9 +41,12 @@ 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.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.rule.Rule;
import org.alfresco.service.cmr.rule.RuleService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.context.IContextListener;
import org.alfresco.web.app.context.UIContextService;
@@ -85,8 +88,7 @@ public class RulesDialog extends BaseDialogBean implements IContextListener, Fil
private List<WrappedRule> rules;
transient private Rule currentRule;
private UIRichList richList;
transient private ActionService actionService;
transient private ActionService actionService;
/**
* Default constructor
@@ -176,8 +178,16 @@ public class RulesDialog extends BaseDialogBean implements IContextListener, Fil
*/
public void reapplyRules(ActionEvent event)
{
FacesContext fc = FacesContext.getCurrentInstance();
boolean toChildren = false;
UIActionLink link = (UIActionLink)event.getComponent();
Map<String, String> params = link.getParameterMap();
String toChildrenStr = params.get("toChildren");
if (toChildrenStr != null)
{
toChildren = new Boolean(toChildrenStr).booleanValue();
}
FacesContext fc = FacesContext.getCurrentInstance();
UserTransaction tx = null;
try
@@ -185,19 +195,15 @@ public class RulesDialog extends BaseDialogBean implements IContextListener, Fil
tx = Repository.getUserTransaction(fc);
tx.begin();
// Create the the apply rules action
Action action = this.getActionService().createAction(ExecuteAllRulesActionExecuter.NAME);
// Set the include inherited parameter to match the current filter value
boolean executeInherited = true;
if (LOCAL.equals(this.getFilterMode()) == true)
if (this.filterModeMode.equals(LOCAL))
{
executeInherited = false;
}
action.setParameterValue(ExecuteAllRulesActionExecuter.PARAM_EXECUTE_INHERITED_RULES, executeInherited);
// Execute the action
this.getActionService().executeAction(action, this.getSpace().getNodeRef());
// Reapply the rules
reapplyRules(this.getSpace().getNodeRef(), executeInherited, toChildren);
// TODO how do I get the message here ...
String msg = Application.getMessage(fc, MSG_REAPPLY_RULES_SUCCESS);
@@ -217,6 +223,30 @@ public class RulesDialog extends BaseDialogBean implements IContextListener, Fil
}
}
private void reapplyRules(NodeRef space, boolean executeInherited, boolean toChildren)
{
// Create the the apply rules action
Action action = this.getActionService().createAction(ExecuteAllRulesActionExecuter.NAME);
action.setParameterValue(ExecuteAllRulesActionExecuter.PARAM_EXECUTE_INHERITED_RULES, executeInherited);
// Execute the action
this.getActionService().executeAction(action, space);
if (toChildren == true)
{
List <ChildAssociationRef> assocs = getNodeService().getChildAssocs(space, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef assoc : assocs)
{
NodeRef nodeRef = assoc.getChildRef();
QName className = getNodeService().getType(nodeRef);
if (getDictionaryService().isSubClass(className, ContentModel.TYPE_FOLDER) == true)
{
reapplyRules(nodeRef, executeInherited, toChildren);
}
}
}
}
/**
* Gets the label id from the ignore inhertied action
*