org.kuali.kfs.coa.document.validation.impl
Class OrgRule

java.lang.Object
  extended by org.kuali.rice.kns.rules.DocumentRuleBase
      extended by org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase
          extended by org.kuali.kfs.coa.document.validation.impl.OrgRule
All Implemented Interfaces:
org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRule, org.kuali.rice.kns.rule.AddAdHocRoutePersonRule, org.kuali.rice.kns.rule.AddAdHocRouteWorkgroupRule, org.kuali.rice.kns.rule.AddCollectionLineRule, org.kuali.rice.kns.rule.AddNoteRule, org.kuali.rice.kns.rule.ApproveDocumentRule, org.kuali.rice.kns.rule.BusinessRule, org.kuali.rice.kns.rule.RouteDocumentRule, org.kuali.rice.kns.rule.SaveDocumentRule, org.kuali.rice.kns.rule.SendAdHocRequestsRule

public class OrgRule
extends org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase

This class implements the business rules specific to the Org Maintenance Document.


Field Summary
protected  boolean isHrmsOrgActivated
           
protected static org.apache.log4j.Logger LOG
           
protected  Organization newOrg
           
protected  Organization oldOrg
           
protected static OrganizationService orgService
           
 
Fields inherited from class org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase
boDictionaryService, boService, businessObjectAuthorizationService, configService, ddService, dictionaryValidationService, DOCUMENT_ERROR_PREFIX, documentHelperService, MAINTAINABLE_ERROR_PATH, MAINTAINABLE_ERROR_PREFIX, maintDocDictionaryService, persistenceService, persistenceStructureService, personService, priorErrorPath, roleService, workflowDocumentService
 
Constructor Summary
OrgRule()
          Constructs a OrgRule and pseudo-injects services
 
Method Summary
protected  boolean checkDefaultAccountNumber(org.kuali.rice.kns.document.MaintenanceDocument document)
          This checks that defaultAccount is present unless ( (orgType = U or C) and ( document is a "create new" or "edit" ))
protected  boolean checkExistenceAndActive()
          This checks to see if the org is active
protected  boolean checkHrmsOrgRules(org.kuali.rice.kns.document.MaintenanceDocument document)
          This checks to see if the org is active and if it the HRMS org is active
protected  boolean checkOrgClosureRules(org.kuali.rice.kns.document.MaintenanceDocument document)
          This method enforces the business rules surrounding when an Org becomes closed/inactive.
protected  boolean checkPlantAttributes()
          This checks to see if a user is authorized for plant fields modification.
protected  boolean checkSimpleRules(org.kuali.rice.kns.document.MaintenanceDocument document)
          This checks the following conditions: begin date must be greater than or equal to end date start date must be greater than or equal to today if new Document Reports To Chart/Org should not be same as this Chart/Org
protected  boolean fieldsHaveChanged(String oldValue, String newValue)
          This method compares an old and new value, and determines if they've changed.
protected  boolean getOrgMustReportToSelf(Organization organization)
          This checks our Parameter rules to see if this org needs to report to itself
protected  boolean isHrmsOrgActivated()
          This method looks up in the ParameterService whether ther HRMS Org system is turned on.
protected  boolean isPlantAuthorized(org.kuali.rice.kim.bo.Person user)
          This method tests whether the specified user is part of the group that grants authorization to the Plant fields.
protected  boolean processCustomApproveDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument document)
          This performs the following checks on document approve: checkExistenceAndActive() checkOrgClosureRules(MaintenanceDocument) checkSimpleRules(MaintenanceDocument) checkDefaultAccountNumber(MaintenanceDocument) This rule fails on rule failure
protected  boolean processCustomRouteDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument document)
          This performs the following checks on document route: checkExistenceAndActive() checkOrgClosureRules(MaintenanceDocument) checkSimpleRules(MaintenanceDocument) checkDefaultAccountNumber(MaintenanceDocument) This rule fails on rule failure
protected  boolean processCustomSaveDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument document)
          This performs the following checks on document save: checkExistenceAndActive() checkOrgClosureRules(MaintenanceDocument) checkSimpleRules(MaintenanceDocument) checkDefaultAccountNumber(MaintenanceDocument) This rule does not fail on rule failure
 void setupConvenienceObjects()
          This method sets the convenience objects like newOrg and oldOrg, so you have short and easy handles to the new and old objects contained in the maintenance document.
 
Methods inherited from class org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase
apcRuleFails, applyApcRule, checkEmptyBOField, checkEmptyDocumentField, checkEmptyValue, checkForPartiallyFilledOutReferenceForeignKeys, clearErrorPath, consolidateFieldNames, dataDictionaryValidate, errorAlreadyExists, getBoDictionaryService, getBoService, getBusinessObjectAuthorizationService, getConfigService, getDateTimeService, getDdService, getDictionaryValidationService, getDocumentHelperService, getFieldLabel, getFieldLabel, getHumanReadablePrimaryKeyFieldNames, getMaintDocDictionaryService, getNewBo, getOldBo, getPersistenceService, getPersistenceStructureService, getPersonService, getRoleService, getWorkflowDocumentService, isCorrectMaintenanceClass, isDocumentInactivatingBusinessObject, isDocumentValidForSave, primaryKeyCheck, processAddCollectionLineBusinessRules, processApproveDocument, processCustomAddCollectionLineBusinessRules, processGlobalApproveDocumentBusinessRules, processGlobalRouteDocumentBusinessRules, processGlobalSaveDocumentBusinessRules, processInactivationBlockChecking, processInactivationBlockChecking, processRouteDocument, processSaveDocument, putDocumentError, putDocumentError, putFieldError, putFieldError, putFieldError, putFieldErrorWithShortLabel, putGlobalError, putGlobalError, putGlobalError, putGlobalsError, putGlobalsError, putInactivationBlockingErrorOnPage, resumeErrorPath, setBoDictionaryService, setBoService, setBusinessObjectAuthorizationService, setConfigService, setDdService, setDictionaryValidationService, setDocumentHelperService, setMaintDocDictionaryService, setNewBo, setPersistenceService, setPersistenceStructureService, setPersonService, setupBaseConvenienceObjects, setWorkflowDocumentService, showErrorMap, validateDocumentStructure, validateDuplicateIdentifierInDataDictionary, validateGlobalBusinessObjectPersistable, validateMaintenanceDocument
 
Methods inherited from class org.kuali.rice.kns.rules.DocumentRuleBase
getDataDictionaryService, getIdentityManagementService, getKualiConfigurationService, getMaxDictionaryValidationDepth, getWorkflowInfoService, isAddHocRoutePersonValid, isAddHocRouteWorkgroupValid, isAdHocRouteRecipientsValid, isDocumentAttributesValid, isDocumentOverviewValid, isNoteValid, processAddAdHocRoutePerson, processAddAdHocRouteWorkgroup, processAddNote, processCustomAddAdHocRoutePersonBusinessRules, processCustomAddAdHocRouteWorkgroupBusinessRules, processCustomAddNoteBusinessRules, processCustomApproveDocumentBusinessRules, processCustomRouteDocumentBusinessRules, processCustomSaveDocumentBusinessRules, processCustomSendAdHocRequests, processSendAdHocRequests, setMaxDictionaryValidationDepth, validateSensitiveDataValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static org.apache.log4j.Logger LOG

orgService

protected static OrganizationService orgService

oldOrg

protected Organization oldOrg

newOrg

protected Organization newOrg

isHrmsOrgActivated

protected boolean isHrmsOrgActivated
Constructor Detail

OrgRule

public OrgRule()
Constructs a OrgRule and pseudo-injects services

Method Detail

processCustomApproveDocumentBusinessRules

protected boolean processCustomApproveDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument document)
This performs the following checks on document approve: This rule fails on rule failure

Overrides:
processCustomApproveDocumentBusinessRules in class org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase
See Also:
MaintenanceDocumentRuleBase.processCustomApproveDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument)

processCustomRouteDocumentBusinessRules

protected boolean processCustomRouteDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument document)
This performs the following checks on document route: This rule fails on rule failure

Overrides:
processCustomRouteDocumentBusinessRules in class org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase
See Also:
MaintenanceDocumentRuleBase.processCustomRouteDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument)

processCustomSaveDocumentBusinessRules

protected boolean processCustomSaveDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument document)
This performs the following checks on document save: This rule does not fail on rule failure

Overrides:
processCustomSaveDocumentBusinessRules in class org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase
See Also:
MaintenanceDocumentRuleBase.processCustomSaveDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument)

checkExistenceAndActive

protected boolean checkExistenceAndActive()
This checks to see if the org is active

Returns:
true if the org is inactive or false otherwise

checkPlantAttributes

protected boolean checkPlantAttributes()
This checks to see if a user is authorized for plant fields modification. If not then it returns true (without activating fields). If the org does not have to report to itself then it checks to see if the plant fields have been filled out correctly and fails if they haven't

Returns:
false if user can edit plant fields but they have not been filled out correctly

checkOrgClosureRules

protected boolean checkOrgClosureRules(org.kuali.rice.kns.document.MaintenanceDocument document)
This method enforces the business rules surrounding when an Org becomes closed/inactive. If we are editing and switching the org to inactive or if it is a new doc and it is marked as inactive then we assume we are closing the org. If we are not then we return true. If we are then we return false if there are still active accounts tied to the org

Parameters:
document -
Returns:
false if trying to close org but it still has accounts that are active linked to it

checkHrmsOrgRules

protected boolean checkHrmsOrgRules(org.kuali.rice.kns.document.MaintenanceDocument document)
This checks to see if the org is active and if it the HRMS org is active

Parameters:
document -
Returns:
true if either the org is inactive or isHrmsOrgActivated is false

getOrgMustReportToSelf

protected boolean getOrgMustReportToSelf(Organization organization)
This checks our Parameter rules to see if this org needs to report to itself

Parameters:
organization -
Returns:
true if it does

checkSimpleRules

protected boolean checkSimpleRules(org.kuali.rice.kns.document.MaintenanceDocument document)
This checks the following conditions:

Parameters:
document -
Returns:
true if it passes all the rules, false otherwise

checkDefaultAccountNumber

protected boolean checkDefaultAccountNumber(org.kuali.rice.kns.document.MaintenanceDocument document)
This checks that defaultAccount is present unless ( (orgType = U or C) and ( document is a "create new" or "edit" ))

Parameters:
document -
Returns:
false if missing default account number and it is not an exempt type code

fieldsHaveChanged

protected boolean fieldsHaveChanged(String oldValue,
                                    String newValue)
This method compares an old and new value, and determines if they've changed. If the old was null/blank, and the new is not, return true. If the old had a value, and the new is null/blank, return true. If both old and new had a value, and the values are different (excluding trailing or leading whitespaces, and excluding case changes), return true. If none of the above, return false.

Parameters:
oldValue - - Old value to test.
newValue - - New value to test.
Returns:
true or false, based on the algorithm described above.

isHrmsOrgActivated

protected boolean isHrmsOrgActivated()
This method looks up in the ParameterService whether ther HRMS Org system is turned on.

Returns:
true or false depending on the app configuration

setupConvenienceObjects

public void setupConvenienceObjects()
This method sets the convenience objects like newOrg and oldOrg, so you have short and easy handles to the new and old objects contained in the maintenance document. It also calls the BusinessObjectBase.refresh(), which will attempt to load all sub-objects from the DB by their primary keys, if available.

Specified by:
setupConvenienceObjects in interface org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRule
Overrides:
setupConvenienceObjects in class org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase
Parameters:
document - - the maintenanceDocument being evaluated

isPlantAuthorized

protected boolean isPlantAuthorized(org.kuali.rice.kim.bo.Person user)
This method tests whether the specified user is part of the group that grants authorization to the Plant fields.

Parameters:
user - - the user to test
Returns:
true if user is part of the group, false otherwise


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