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 import_directory=Import Directory
advanced_space_wizard=Advanced Space Wizard advanced_space_wizard=Advanced Space Wizard
create_rule=Create Rule 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. reapply_rules_success=The rules have been successfully reapplied.
ignore_inherited_rules=Ignore Inherited Rules ignore_inherited_rules=Ignore Inherited Rules
include_inherited_rules=Include Inherited Rules include_inherited_rules=Include Inherited Rules

View File

@@ -639,6 +639,18 @@
<label-id>reapply_rules</label-id> <label-id>reapply_rules</label-id>
<image>/images/icons/reapply_rules.gif</image> <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> </action>
<!-- Ignore Inherited Rules --> <!-- Ignore Inherited Rules -->
@@ -730,21 +742,6 @@
<action>wizard:createRule</action> <action>wizard:createRule</action>
</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>
<!-- Create a category --> <!-- Create a category -->
<action id="add_category"> <action id="add_category">
<label-id>add_category</label-id> <label-id>add_category</label-id>
@@ -1035,6 +1032,7 @@
<!-- Actions Menu for Manage Rules screen --> <!-- Actions Menu for Manage Rules screen -->
<action-group id="rules_actions_menu"> <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 idref="ignore-inherited-rules" />
</action-group> </action-group>
@@ -1085,12 +1083,6 @@
<action idref="create_rule"/> <action idref="create_rule"/>
</action-group> </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 --> <!-- Actions Menu for Manage Deleted Items screen -->
<action-group id="manage_deleted_items_menu"> <action-group id="manage_deleted_items_menu">
<action idref="recover_all_items" /> <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.repo.rule.RuleModel;
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.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
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.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.app.context.IContextListener; import org.alfresco.web.app.context.IContextListener;
import org.alfresco.web.app.context.UIContextService; import org.alfresco.web.app.context.UIContextService;
@@ -87,7 +90,6 @@ public class RulesDialog extends BaseDialogBean implements IContextListener, Fil
private UIRichList richList; private UIRichList richList;
transient private ActionService actionService; transient private ActionService actionService;
/** /**
* Default constructor * Default constructor
*/ */
@@ -176,8 +178,16 @@ public class RulesDialog extends BaseDialogBean implements IContextListener, Fil
*/ */
public void reapplyRules(ActionEvent event) 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; UserTransaction tx = null;
try try
@@ -185,19 +195,15 @@ public class RulesDialog extends BaseDialogBean implements IContextListener, Fil
tx = Repository.getUserTransaction(fc); tx = Repository.getUserTransaction(fc);
tx.begin(); 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 // Set the include inherited parameter to match the current filter value
boolean executeInherited = true; boolean executeInherited = true;
if (LOCAL.equals(this.getFilterMode()) == true) if (this.filterModeMode.equals(LOCAL))
{ {
executeInherited = false; executeInherited = false;
} }
action.setParameterValue(ExecuteAllRulesActionExecuter.PARAM_EXECUTE_INHERITED_RULES, executeInherited);
// Execute the action // Reapply the rules
this.getActionService().executeAction(action, this.getSpace().getNodeRef()); reapplyRules(this.getSpace().getNodeRef(), executeInherited, toChildren);
// TODO how do I get the message here ... // TODO how do I get the message here ...
String msg = Application.getMessage(fc, MSG_REAPPLY_RULES_SUCCESS); 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 * Gets the label id from the ignore inhertied action
* *