From 5459a8bb3666baa67ff9d269a4de476a5c302598 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Thu, 23 Feb 2006 10:13:05 +0000 Subject: [PATCH] . First pass of a new style for the header area in the web-client UI - Reclaims a large ammount of unused vertical space at the top of the application git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2474 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../org/alfresco/repo/rule/RuleCache.java | 40 --- .../alfresco/repo/rule/RuleServiceImpl.java | 227 +++++++----------- .../service/cmr/rule/RuleService.java | 10 +- 3 files changed, 96 insertions(+), 181 deletions(-) delete mode 100644 source/java/org/alfresco/repo/rule/RuleCache.java diff --git a/source/java/org/alfresco/repo/rule/RuleCache.java b/source/java/org/alfresco/repo/rule/RuleCache.java deleted file mode 100644 index 2efbfca7cb..0000000000 --- a/source/java/org/alfresco/repo/rule/RuleCache.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2005 Alfresco, Inc. - * - * Licensed under the Mozilla Public License version 1.1 - * with a permitted attribution clause. You may obtain a - * copy of the License at - * - * http://www.alfresco.org/legal/license.txt - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - */ -package org.alfresco.repo.rule; - -import java.util.List; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.rule.Rule; - -/** - * Rule cache interface - * - * @author Roy Wetherall - */ -public interface RuleCache -{ - List getRules(NodeRef nodeRef); - - List getInheritedRules(NodeRef nodeRef); - - void setRules(NodeRef nodeRef, List rules); - - void setInheritedRules(NodeRef nodeRef, List rules); - - void dirtyRules(NodeRef nodeRef); -} diff --git a/source/java/org/alfresco/repo/rule/RuleServiceImpl.java b/source/java/org/alfresco/repo/rule/RuleServiceImpl.java index ec72eb7e08..0ea76b39ec 100644 --- a/source/java/org/alfresco/repo/rule/RuleServiceImpl.java +++ b/source/java/org/alfresco/repo/rule/RuleServiceImpl.java @@ -103,11 +103,6 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService * The action service implementation which we need for some things. */ RuntimeActionService runtimeActionService; - - /** - * The rule cahce (set by default to an inactive rule cache) - */ - private RuleCache ruleCache = new InactiveRuleCache(); /** * List of disabled node refs. The rules associated with these nodes will node be added to the pending list, and @@ -181,16 +176,6 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService this.searchService = searchService; } - /** - * Set the rule cache - * - * @param ruleCache the rule cache - */ - public void setRuleCache(RuleCache ruleCache) - { - this.ruleCache = ruleCache; - } - /** * Set the dictionary service * @@ -314,64 +299,83 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService */ public List getRules(NodeRef nodeRef, boolean includeInherited, String ruleTypeName) { - List rules = new ArrayList(); - - if (this.runtimeNodeService.exists(nodeRef) == true && checkNodeType(nodeRef) == true) - { - if (includeInherited == true) - { - // Get any inherited rules - for (Rule rule : getInheritedRules(nodeRef, ruleTypeName, null)) - { - // Ensure rules are not duplicated in the list - if (rules.contains(rule) == false) - { - rules.add(rule); - } - } - } - - if (this.runtimeNodeService.hasAspect(nodeRef, RuleModel.ASPECT_RULES) == true) - { + List rules = new ArrayList(); + + if (this.runtimeNodeService.exists(nodeRef) == true && checkNodeType(nodeRef) == true) + { + if (includeInherited == true) + { + // Get any inherited rules + for (Rule rule : getInheritedRules(nodeRef, ruleTypeName, null)) + { + // Ensure rules are not duplicated in the list + if (rules.contains(rule) == false) + { + rules.add(rule); + } + } + } + + if (this.runtimeNodeService.hasAspect(nodeRef, RuleModel.ASPECT_RULES) == true) + { NodeRef ruleFolder = getSavedRuleFolderRef(nodeRef); if (ruleFolder != null) { - List allRules = this.ruleCache.getRules(nodeRef); - if (allRules == null) - { - allRules = new ArrayList(); - - // Get the rules for this node - List ruleChildAssocRefs = - this.runtimeNodeService.getChildAssocs(ruleFolder, RegexQNamePattern.MATCH_ALL, ASSOC_NAME_RULES); - for (ChildAssociationRef ruleChildAssocRef : ruleChildAssocRefs) - { - // Create the rule and add to the list - NodeRef ruleNodeRef = ruleChildAssocRef.getChildRef(); - Rule rule = createRule(nodeRef, ruleNodeRef); - allRules.add(rule); - } - - // Add the list to the cache - this.ruleCache.setRules(nodeRef, allRules); - } - - // Build the list of rules that is returned to the client - for (Rule rule : allRules) - { - if ((rules.contains(rule) == false) && - (ruleTypeName == null || ruleTypeName.equals(rule.getRuleTypeName()) == true)) - { - rules.add(rule); - } - } + List allRules = new ArrayList(); + + // Get the rules for this node + List ruleChildAssocRefs = + this.runtimeNodeService.getChildAssocs(ruleFolder, RegexQNamePattern.MATCH_ALL, ASSOC_NAME_RULES); + for (ChildAssociationRef ruleChildAssocRef : ruleChildAssocRefs) + { + // Create the rule and add to the list + NodeRef ruleNodeRef = ruleChildAssocRef.getChildRef(); + Rule rule = createRule(nodeRef, ruleNodeRef); + allRules.add(rule); + } + + // Build the list of rules that is returned to the client + for (Rule rule : allRules) + { + if ((rules.contains(rule) == false) && + (ruleTypeName == null || ruleTypeName.equals(rule.getRuleTypeName()) == true)) + { + rules.add(rule); + } + } } - } - } - - return rules; + } + } + + return rules; } + /** + * @see org.alfresco.service.cmr.rule.RuleService#countRules(org.alfresco.service.cmr.repository.NodeRef) + */ + public int countRules(NodeRef nodeRef) + { + int ruleCount = 0; + + if (this.runtimeNodeService.exists(nodeRef) == true && checkNodeType(nodeRef) == true) + { + if (this.runtimeNodeService.hasAspect(nodeRef, RuleModel.ASPECT_RULES) == true) + { + NodeRef ruleFolder = getSavedRuleFolderRef(nodeRef); + if (ruleFolder != null) + { + // Get the rules for this node + List ruleChildAssocRefs = + this.runtimeNodeService.getChildAssocs(ruleFolder, RegexQNamePattern.MATCH_ALL, ASSOC_NAME_RULES); + + ruleCount = ruleChildAssocRefs.size(); + } + } + } + + return ruleCount; + } + /** * Looks at the type of the node and indicates whether the node can have rules associated with it * @@ -421,35 +425,28 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService { visitedNodeRefs.add(nodeRef); - List allInheritedRules = this.ruleCache.getInheritedRules(nodeRef); - if (allInheritedRules == null) + List allInheritedRules = new ArrayList(); + List parents = this.runtimeNodeService.getParentAssocs(nodeRef); + for (ChildAssociationRef parent : parents) { - allInheritedRules = new ArrayList(); - List parents = this.runtimeNodeService.getParentAssocs(nodeRef); - for (ChildAssociationRef parent : parents) + List rules = getRules(parent.getParentRef(), false); + for (Rule rule : rules) { - List rules = getRules(parent.getParentRef(), false); - for (Rule rule : rules) + // Add is we hanvn't already added and it should be applied to the children + if (rule.isAppliedToChildren() == true && allInheritedRules.contains(rule) == false) { - // Add is we hanvn't already added and it should be applied to the children - if (rule.isAppliedToChildren() == true && allInheritedRules.contains(rule) == false) - { - allInheritedRules.add(rule); - } - } - - for (Rule rule : getInheritedRules(parent.getParentRef(), ruleTypeName, visitedNodeRefs)) - { - // Ensure that we don't get any rule duplication (don't use a set cos we want to preserve order) - if (allInheritedRules.contains(rule) == false) - { - allInheritedRules.add(rule); - } + allInheritedRules.add(rule); } } - // Add the list of inherited rules to the cache - this.ruleCache.setInheritedRules(nodeRef, allInheritedRules); + for (Rule rule : getInheritedRules(parent.getParentRef(), ruleTypeName, visitedNodeRefs)) + { + // Ensure that we don't get any rule duplication (don't use a set cos we want to preserve order) + if (allInheritedRules.contains(rule) == false) + { + allInheritedRules.add(rule); + } + } } if (ruleTypeName == null) @@ -902,55 +899,5 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService return false; } } - } - - /** - * Inactive rule cache - * - * @author Roy Wetherall - */ - private class InactiveRuleCache implements RuleCache - { - /** - * @see org.alfresco.repo.rule.RuleCache#getRules(org.alfresco.service.cmr.repository.NodeRef) - */ - public List getRules(NodeRef nodeRef) - { - // do nothing - return null; - } - - /** - * @see org.alfresco.repo.rule.RuleCache#setRules(org.alfresco.service.cmr.repository.NodeRef, List) - */ - public void setRules(NodeRef nodeRef, List rules) - { - // do nothing - } - - /** - * @see org.alfresco.repo.rule.RuleCache#dirtyRules(org.alfresco.service.cmr.repository.NodeRef) - */ - public void dirtyRules(NodeRef nodeRef) - { - // do nothing - } - - /** - * @see org.alfresco.repo.rule.RuleCache#getInheritedRules(org.alfresco.service.cmr.repository.NodeRef) - */ - public List getInheritedRules(NodeRef nodeRef) - { - // do nothing - return null; - } - - /** - * @see org.alfresco.repo.rule.RuleCache#setInheritedRules(org.alfresco.service.cmr.repository.NodeRef, List) - */ - public void setInheritedRules(NodeRef nodeRef, List rules) - { - // do nothing - } } } diff --git a/source/java/org/alfresco/service/cmr/rule/RuleService.java b/source/java/org/alfresco/service/cmr/rule/RuleService.java index ed3b94ef50..06fe3a9adc 100644 --- a/source/java/org/alfresco/service/cmr/rule/RuleService.java +++ b/source/java/org/alfresco/service/cmr/rule/RuleService.java @@ -117,7 +117,7 @@ public interface RuleService public List getRules(NodeRef nodeRef, boolean includeInhertied); /** - * Get the rules associatied with an actionable node that are of a specific rule type. + * Get the rules associated with an actionable node that are of a specific rule type. * * @param nodeRef the node reference * @param includeInhertiedRuleType indicates whether the inherited rules should be included in @@ -128,6 +128,14 @@ public interface RuleService */ public List getRules(NodeRef nodeRef, boolean includeInhertiedRuleType, String ruleTypeName); + /** + * Count the number of rules associated with an actionable node. + * + * @param nodeRef the node reference + * @return a list of the rules associated with the node + */ + public int countRules(NodeRef nodeRef); + /** * Get the rule given its id. *