org.kuali.rice.kew.rule.service.impl
Class RuleServiceInternalImpl

java.lang.Object
  extended by org.kuali.rice.kew.rule.service.impl.RuleServiceInternalImpl
All Implemented Interfaces:
XmlExporter, XmlLoader, RuleServiceInternal

public class RuleServiceInternalImpl
extends Object
implements RuleServiceInternal


Nested Class Summary
 class RuleServiceInternalImpl.RuleDelegationSorter
          A comparator implementation which compares RuleBaseValues and puts all delegate rules first.
 
Constructor Summary
RuleServiceInternalImpl()
           
 
Method Summary
protected  RuleBaseValues createNewRuleVersion(RuleBaseValues existingRule, String documentId)
           
 void delete(String ruleBaseValuesId)
           
 void deleteRuleResponsibilityById(String ruleResponsibilityId)
           
 org.jdom.Element export(ExportDataSet dataSet)
           
 List fetchAllCurrentRulesForTemplateDocCombination(String ruleTemplateName, String documentType)
           
 List fetchAllCurrentRulesForTemplateDocCombination(String ruleTemplateName, String documentType, Timestamp effectiveDate)
           
 List fetchAllRules(boolean currentRules)
           
 List<RuleBaseValues> findByDocumentId(String documentId)
           
 RuleResponsibilityBo findByRuleResponsibilityId(String ruleResponsibilityId)
           
 RuleBaseValues findDefaultRuleByRuleTemplateId(String ruleTemplateId)
           
 String findResponsibilityIdForRule(String ruleName, String ruleResponsibilityName, String ruleResponsibilityType)
           
 RuleBaseValues findRuleBaseValuesById(String ruleBaseValuesId)
           
 List findRuleBaseValuesByResponsibilityReviewer(String reviewerName, String type)
           
 List findRuleBaseValuesByResponsibilityReviewerTemplateDoc(String ruleTemplateName, String documentType, String reviewerName, String type)
           
 RuleResponsibilityBo findRuleResponsibility(String responsibilityId)
           
 ActionRequestService getActionRequestService()
           
 DocumentTypeService getDocumentTypeService()
           
 String getDuplicateRuleId(RuleBaseValues rule)
          Checks if the Rule with the given value is a duplicate of an existing rule in the system.
 GroupService getGroupService()
           
 RuleBaseValues getParentRule(RuleBaseValues rule)
           
 RuleBaseValues getParentRule(String ruleBaseValuesId)
           
 RuleBaseValues getRuleByName(String name)
          Returns a Rule based on unique name.
protected  String getRuleByTemplateAndDocTypeCacheKey(String ruleTemplateName, String docTypeName)
           
 RuleDAO getRuleDAO()
           
protected  RuleDelegationBo getRuleDelegationForDelegateRule(RuleBaseValues rule)
           
 String getRuleDocumentTypeName(List rules)
          This configuration is currently stored in a system parameter named "CUSTOM_DOCUMENT_TYPES ", long term we should come up with a better solution.
 RuleResponsibilityDAO getRuleResponsibilityDAO()
           
 RuleTemplateService getRuleTemplateService()
           
protected  void hookUpDelegateRuleToParentRule(RuleBaseValues newParentRule, RuleBaseValues newDelegationRule, RuleDelegationBo existingRuleDelegation)
           
 String isLockedForRouting(String currentRuleBaseValuesId)
          Determines if the given rule is locked for routing.
protected  List<RuleBaseValues> loadRules(List<String> ruleIds)
           
 void loadXml(InputStream inputStream, String principalId)
           
 void makeCurrent(List<RuleBaseValues> rules)
           
 void makeCurrent(RuleBaseValues rule, boolean isRetroactiveUpdatePermitted)
          makeCurrent(RuleBaseValues) is the version of makeCurrent which is initiated from the new Routing Rule Maintenance document.
 void makeCurrent(RuleDelegationBo ruleDelegation, boolean isRetroactiveUpdatePermitted)
           
protected  void makeCurrent(RuleDelegationBo ruleDelegation, RuleBaseValues rule, boolean isRetroactiveUpdatePermitted)
           
 void makeCurrent(String documentId)
           
 void makeCurrent2(List<RuleBaseValues> rules)
          TODO consolidate this method with makeCurrent.
 String routeRuleWithDelegate(String documentId, RuleBaseValues parentRule, RuleBaseValues delegateRule, PrincipalContract principal, String annotation, boolean blanketApprove)
           
 void save2(RuleBaseValues ruleBaseValues)
           
 void save2(RuleBaseValues ruleBaseValues, RuleDelegationBo ruleDelegation, boolean saveDelegations)
           
 RuleBaseValues saveRule(RuleBaseValues rule, boolean isRetroactiveUpdatePermitted)
           
 RuleDelegationBo saveRuleDelegation(RuleDelegationBo ruleDelegation, boolean isRetroactiveUpdatePermitted)
           
 List<RuleDelegationBo> saveRuleDelegations(List<RuleDelegationBo> ruleDelegationsToSave, boolean isRetroactiveUpdatePermitted)
           
 List<RuleBaseValues> saveRules(List<RuleBaseValues> rulesToSave, boolean isRetroactiveUpdatePermitted)
           
 List<RuleBaseValues> search(String docTypeName, String ruleId, String ruleTemplateId, String ruleDescription, String groupId, String principalId, Boolean delegateRule, Boolean activeInd, Map extensionValues, String workflowIdDirective)
           
 List<RuleBaseValues> searchByTemplate(String docTypeName, String ruleTemplateName, String ruleDescription, String groupId, String principalId, Boolean workgroupMember, Boolean delegateRule, Boolean activeInd, Map extensionValues, Collection<String> actionRequestCodes)
           
 void setRuleDAO(RuleDAO ruleDAO)
           
 void setRuleResponsibilityDAO(RuleResponsibilityDAO ruleResponsibilityDAO)
           
protected  boolean shouldChangeRuleInvolvement(String documentId, RuleBaseValues rule)
          If a rule has been modified and is no longer current since the original request was made, we need to be sure to NOT update the rule.
 boolean supportPrettyPrint()
           
 void validate(RuleBaseValues ruleBaseValues, List errors)
           
 void validate2(RuleBaseValues ruleBaseValues, RuleDelegationBo ruleDelegation, List errors)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RuleServiceInternalImpl

public RuleServiceInternalImpl()
Method Detail

getRuleResponsibilityDAO

public RuleResponsibilityDAO getRuleResponsibilityDAO()

getRuleByName

public RuleBaseValues getRuleByName(String name)
Description copied from interface: RuleServiceInternal
Returns a Rule based on unique name. Returns null if name is null.

Specified by:
getRuleByName in interface RuleServiceInternal
Parameters:
name - the rule name
Returns:
the Rule if found, null if not found or null name

findDefaultRuleByRuleTemplateId

public RuleBaseValues findDefaultRuleByRuleTemplateId(String ruleTemplateId)
Specified by:
findDefaultRuleByRuleTemplateId in interface RuleServiceInternal

setRuleResponsibilityDAO

public void setRuleResponsibilityDAO(RuleResponsibilityDAO ruleResponsibilityDAO)

save2

public void save2(RuleBaseValues ruleBaseValues)
           throws Exception
Specified by:
save2 in interface RuleServiceInternal
Throws:
Exception

save2

public void save2(RuleBaseValues ruleBaseValues,
                  RuleDelegationBo ruleDelegation,
                  boolean saveDelegations)
           throws Exception
Throws:
Exception

makeCurrent

public void makeCurrent(String documentId)
Specified by:
makeCurrent in interface RuleServiceInternal

makeCurrent

public void makeCurrent(List<RuleBaseValues> rules)

makeCurrent2

public void makeCurrent2(List<RuleBaseValues> rules)
TODO consolidate this method with makeCurrent. The reason there's a seperate implementation is because the original makeCurrent(...) could not properly handle versioning a List of multiple rules (including multiple delegates rules for a single parent. ALso, this work is being done for a patch so we want to mitigate the impact on the existing rule code.

This version will only work for remove/replace operations where rules aren't being added or removed. This is why it doesn't perform some of the functions like checking for delegation rules that were removed from a parent rule.


makeCurrent

public void makeCurrent(RuleBaseValues rule,
                        boolean isRetroactiveUpdatePermitted)
makeCurrent(RuleBaseValues) is the version of makeCurrent which is initiated from the new Routing Rule Maintenance document. Because of the changes in the data model and the front end here, this method can be much less complicated than the previous 2!

Specified by:
makeCurrent in interface RuleServiceInternal

makeCurrent

public void makeCurrent(RuleDelegationBo ruleDelegation,
                        boolean isRetroactiveUpdatePermitted)
Specified by:
makeCurrent in interface RuleServiceInternal

makeCurrent

protected void makeCurrent(RuleDelegationBo ruleDelegation,
                           RuleBaseValues rule,
                           boolean isRetroactiveUpdatePermitted)

getParentRule

public RuleBaseValues getParentRule(String ruleBaseValuesId)
Specified by:
getParentRule in interface RuleServiceInternal

routeRuleWithDelegate

public String routeRuleWithDelegate(String documentId,
                                    RuleBaseValues parentRule,
                                    RuleBaseValues delegateRule,
                                    PrincipalContract principal,
                                    String annotation,
                                    boolean blanketApprove)
                             throws Exception
Specified by:
routeRuleWithDelegate in interface RuleServiceInternal
Throws:
Exception

validate

public void validate(RuleBaseValues ruleBaseValues,
                     List errors)

validate2

public void validate2(RuleBaseValues ruleBaseValues,
                      RuleDelegationBo ruleDelegation,
                      List errors)
Specified by:
validate2 in interface RuleServiceInternal

findByDocumentId

public List<RuleBaseValues> findByDocumentId(String documentId)
Specified by:
findByDocumentId in interface RuleServiceInternal

search

public List<RuleBaseValues> search(String docTypeName,
                                   String ruleId,
                                   String ruleTemplateId,
                                   String ruleDescription,
                                   String groupId,
                                   String principalId,
                                   Boolean delegateRule,
                                   Boolean activeInd,
                                   Map extensionValues,
                                   String workflowIdDirective)
Specified by:
search in interface RuleServiceInternal

searchByTemplate

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)
Specified by:
searchByTemplate in interface RuleServiceInternal

delete

public void delete(String ruleBaseValuesId)
Specified by:
delete in interface RuleServiceInternal

findRuleBaseValuesById

public RuleBaseValues findRuleBaseValuesById(String ruleBaseValuesId)
Specified by:
findRuleBaseValuesById in interface RuleServiceInternal

findRuleResponsibility

public RuleResponsibilityBo findRuleResponsibility(String responsibilityId)
Specified by:
findRuleResponsibility in interface RuleServiceInternal

fetchAllCurrentRulesForTemplateDocCombination

public List fetchAllCurrentRulesForTemplateDocCombination(String ruleTemplateName,
                                                          String documentType)
Specified by:
fetchAllCurrentRulesForTemplateDocCombination in interface RuleServiceInternal

fetchAllCurrentRulesForTemplateDocCombination

public List fetchAllCurrentRulesForTemplateDocCombination(String ruleTemplateName,
                                                          String documentType,
                                                          Timestamp effectiveDate)
Specified by:
fetchAllCurrentRulesForTemplateDocCombination in interface RuleServiceInternal

fetchAllRules

public List fetchAllRules(boolean currentRules)
Specified by:
fetchAllRules in interface RuleServiceInternal

isLockedForRouting

public String isLockedForRouting(String currentRuleBaseValuesId)
Determines if the given rule is locked for routing. In the case of a root rule edit, this method will take the rule id of the rule being edited. In the case of a new delegate rule or a delegate rule edit, this method will take the id of it's parent.

Specified by:
isLockedForRouting in interface RuleServiceInternal

getParentRule

public RuleBaseValues getParentRule(RuleBaseValues rule)

getRuleDocumentTypeName

public String getRuleDocumentTypeName(List rules)
This configuration is currently stored in a system parameter named "CUSTOM_DOCUMENT_TYPES ", long term we should come up with a better solution. The format of this constant is a comma-separated list of entries of the following form: <>:<>:<>:<> Rule type indicates either main or delegation rules. A main rule is indicated by the character 'M' and a delegate rule is indicated by the character 'D'. So, if you wanted to route "main" rules made for the "MyDocType" document with the rule template name "MyRuleTemplate" using the "MyMainRuleDocType" doc type, it would be specified as follows: MyDocType:MyRuleTemplate:M:MyMainRuleDocType If you also wanted to route "delegate" rules made for the "MyDocType" document with rule template name "MyDelegateTemplate" using the "MyDelegateRuleDocType", you would then set the constant as follows: MyDocType:MyRuleTemplate:M:MyMainRuleDocType,MyDocType:MyDelegateTemplate:D:MyDelegateRuleDocType TODO this method ended up being a mess, we should get rid of this as soon as we can

Specified by:
getRuleDocumentTypeName in interface RuleServiceInternal

setRuleDAO

public void setRuleDAO(RuleDAO ruleDAO)

getRuleDAO

public RuleDAO getRuleDAO()

deleteRuleResponsibilityById

public void deleteRuleResponsibilityById(String ruleResponsibilityId)
Specified by:
deleteRuleResponsibilityById in interface RuleServiceInternal

findByRuleResponsibilityId

public RuleResponsibilityBo findByRuleResponsibilityId(String ruleResponsibilityId)
Specified by:
findByRuleResponsibilityId in interface RuleServiceInternal

findRuleBaseValuesByResponsibilityReviewer

public List findRuleBaseValuesByResponsibilityReviewer(String reviewerName,
                                                       String type)
Specified by:
findRuleBaseValuesByResponsibilityReviewer in interface RuleServiceInternal

findRuleBaseValuesByResponsibilityReviewerTemplateDoc

public List findRuleBaseValuesByResponsibilityReviewerTemplateDoc(String ruleTemplateName,
                                                                  String documentType,
                                                                  String reviewerName,
                                                                  String type)
Specified by:
findRuleBaseValuesByResponsibilityReviewerTemplateDoc in interface RuleServiceInternal

getRuleTemplateService

public RuleTemplateService getRuleTemplateService()

getDocumentTypeService

public DocumentTypeService getDocumentTypeService()

getGroupService

public GroupService getGroupService()

getActionRequestService

public ActionRequestService getActionRequestService()

loadXml

public void loadXml(InputStream inputStream,
                    String principalId)
Specified by:
loadXml in interface XmlLoader

export

public org.jdom.Element export(ExportDataSet dataSet)
Specified by:
export in interface XmlExporter

supportPrettyPrint

public boolean supportPrettyPrint()
Specified by:
supportPrettyPrint in interface XmlExporter

loadRules

protected List<RuleBaseValues> loadRules(List<String> ruleIds)

shouldChangeRuleInvolvement

protected boolean shouldChangeRuleInvolvement(String documentId,
                                              RuleBaseValues rule)
If a rule has been modified and is no longer current since the original request was made, we need to be sure to NOT update the rule.


getRuleDelegationForDelegateRule

protected RuleDelegationBo getRuleDelegationForDelegateRule(RuleBaseValues rule)

hookUpDelegateRuleToParentRule

protected void hookUpDelegateRuleToParentRule(RuleBaseValues newParentRule,
                                              RuleBaseValues newDelegationRule,
                                              RuleDelegationBo existingRuleDelegation)

createNewRuleVersion

protected RuleBaseValues createNewRuleVersion(RuleBaseValues existingRule,
                                              String documentId)
                                       throws Exception
Throws:
Exception

getDuplicateRuleId

public String getDuplicateRuleId(RuleBaseValues rule)
Description copied from interface: RuleServiceInternal
Checks if the Rule with the given value is a duplicate of an existing rule in the system.

Specified by:
getDuplicateRuleId in interface RuleServiceInternal
Returns:
the id of the duplicate rule if one exists, null otherwise

saveRule

public RuleBaseValues saveRule(RuleBaseValues rule,
                               boolean isRetroactiveUpdatePermitted)
Specified by:
saveRule in interface RuleServiceInternal

saveRules

public List<RuleBaseValues> saveRules(List<RuleBaseValues> rulesToSave,
                                      boolean isRetroactiveUpdatePermitted)
Specified by:
saveRules in interface RuleServiceInternal

saveRuleDelegation

public RuleDelegationBo saveRuleDelegation(RuleDelegationBo ruleDelegation,
                                           boolean isRetroactiveUpdatePermitted)
Specified by:
saveRuleDelegation in interface RuleServiceInternal

saveRuleDelegations

public List<RuleDelegationBo> saveRuleDelegations(List<RuleDelegationBo> ruleDelegationsToSave,
                                                  boolean isRetroactiveUpdatePermitted)
Specified by:
saveRuleDelegations in interface RuleServiceInternal

findResponsibilityIdForRule

public String findResponsibilityIdForRule(String ruleName,
                                          String ruleResponsibilityName,
                                          String ruleResponsibilityType)
Specified by:
findResponsibilityIdForRule in interface RuleServiceInternal

getRuleByTemplateAndDocTypeCacheKey

protected String getRuleByTemplateAndDocTypeCacheKey(String ruleTemplateName,
                                                     String docTypeName)


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.