001 /** 002 * Copyright 2005-2013 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.kew.rule.service; 017 018 import java.sql.Timestamp; 019 import java.util.Collection; 020 import java.util.List; 021 import java.util.Map; 022 023 import org.kuali.rice.core.framework.impex.xml.XmlExporter; 024 import org.kuali.rice.core.framework.impex.xml.XmlLoader; 025 import org.kuali.rice.kew.api.rule.Rule; 026 import org.kuali.rice.kew.rule.RuleBaseValues; 027 import org.kuali.rice.kew.rule.RuleDelegationBo; 028 import org.kuali.rice.kew.rule.RuleResponsibilityBo; 029 import org.kuali.rice.kim.api.identity.principal.PrincipalContract; 030 import org.springframework.cache.annotation.CacheEvict; 031 032 /** 033 * A service which provides data access and functions for the KEW Rules engine. 034 * 035 * @see RuleBaseValues 036 * @see org.kuali.rice.kew.rule.RuleResponsibilityBo 037 * 038 * @author Kuali Rice Team (rice.collab@kuali.org) 039 */ 040 public interface RuleServiceInternal extends XmlLoader, XmlExporter { 041 042 /** 043 * Returns a Rule based on unique name. Returns null if name is null. 044 * @param name the rule name 045 * @return the Rule if found, null if not found or null name 046 */ 047 public RuleBaseValues getRuleByName(String name); 048 049 public String routeRuleWithDelegate(String documentId, RuleBaseValues parentRule, RuleBaseValues delegateRule, PrincipalContract principal, String annotation, boolean blanketApprove) throws Exception; 050 //public void save(RuleBaseValues ruleBaseValues) throws Exception; 051 @CacheEvict(value={Rule.Cache.NAME}, allEntries = true) 052 public void save2(RuleBaseValues ruleBaseValues) throws Exception; 053 public void validate2(RuleBaseValues ruleBaseValues, RuleDelegationBo ruleDelegation, List errors) throws Exception; 054 @CacheEvict(value={Rule.Cache.NAME}, allEntries = true) 055 public void delete(String ruleBaseValuesId); 056 public RuleBaseValues findRuleBaseValuesById(String ruleBaseValuesId); 057 public List<RuleBaseValues> search(String docTypeName, String ruleId, String ruleTemplateId, String ruleDescription, String groupId, String principalId, Boolean delegateRule, Boolean activeInd, Map extensionValues, String workflowIdDirective); 058 public List<RuleBaseValues> searchByTemplate(String docTypeName, String ruleTemplateName, String ruleDescription, String groupId, String principalId, Boolean workgroupMember, Boolean delegateRule, Boolean activeInd, Map extensionValues, Collection<String> actionRequestCodes); 059 public RuleResponsibilityBo findRuleResponsibility(String responsibilityId); 060 public void deleteRuleResponsibilityById(String ruleResponsibilityId); 061 public RuleResponsibilityBo findByRuleResponsibilityId(String ruleResponsibilityId); 062 public List<RuleBaseValues> fetchAllCurrentRulesForTemplateDocCombination(String ruleTemplateName, String documentType); 063 public List<RuleBaseValues> fetchAllCurrentRulesForTemplateDocCombination(String ruleTemplateName, String documentType, Timestamp effectiveDate); 064 public List<RuleBaseValues> findByDocumentId(String documentId); 065 @CacheEvict(value={Rule.Cache.NAME}, allEntries = true) 066 public void makeCurrent(String documentId); 067 @CacheEvict(value={Rule.Cache.NAME}, allEntries = true) 068 public void makeCurrent(RuleBaseValues rule, boolean isRetroactiveUpdatePermitted); 069 @CacheEvict(value={Rule.Cache.NAME}, allEntries = true) 070 public void makeCurrent(RuleDelegationBo ruleDelegation, boolean isRetroactiveUpdatePermitted); 071 public List<RuleBaseValues> findRuleBaseValuesByResponsibilityReviewer(String reviewerName, String type); 072 public List<RuleBaseValues> findRuleBaseValuesByResponsibilityReviewerTemplateDoc(String ruleTemplateName, String documentType, String reviewerName, String type); 073 public String isLockedForRouting(String currentRuleBaseValuesId); 074 public List<RuleBaseValues> fetchAllRules(boolean currentRules); 075 public RuleBaseValues findDefaultRuleByRuleTemplateId(String ruleTemplateId); 076 public RuleBaseValues getParentRule(String ruleBaseValuesId); 077 078 /** 079 * Returns the name of the document type definition that should be used to route the given List of rules. This method will never 080 * return a null value, as it will default to the default Rule document type name if not custom document type is configured for 081 * the given rules. 082 */ 083 public String getRuleDocumentTypeName(List<RuleBaseValues> rules); 084 085 /** 086 * Checks if the Rule with the given value is a duplicate of an existing rule in the system. 087 * 088 * @return the id of the duplicate rule if one exists, null otherwise 089 */ 090 public String getDuplicateRuleId(RuleBaseValues rule); 091 @CacheEvict(value={Rule.Cache.NAME}, allEntries = true) 092 public RuleBaseValues saveRule(RuleBaseValues rule, boolean isRetroactiveUpdatePermitted); 093 @CacheEvict(value={Rule.Cache.NAME}, allEntries = true) 094 public List<RuleBaseValues> saveRules(List<RuleBaseValues> rulesToSave, boolean isRetroactiveUpdatePermitted); 095 096 public RuleDelegationBo saveRuleDelegation(RuleDelegationBo ruleDelegation, boolean isRetroactiveUpdatePermitted); 097 098 public List<RuleDelegationBo> saveRuleDelegations(List<RuleDelegationBo> ruleDelegationsToSave, boolean isRetroactiveUpdatePermitted); 099 100 public String findResponsibilityIdForRule(String ruleName, String ruleResponsibilityName, String ruleResponsibilityType); 101 }