001    /*
002     * Copyright 2011 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.kfs.coa.service;
017    
018    import java.util.Iterator;
019    import java.util.List;
020    
021    import org.kuali.kfs.coa.businessobject.AccountDelegate;
022    import org.kuali.kfs.coa.document.AccountDelegateGlobalMaintainableImpl;
023    import org.kuali.kfs.coa.document.AccountDelegateMaintainableImpl;
024    import org.kuali.kfs.sys.document.FinancialSystemMaintainable;
025    import org.kuali.rice.kim.bo.Person;
026    import org.kuali.rice.kns.bo.PersistableBusinessObject;
027    
028    /**
029     * An interface of services to support account delegate logic
030     */
031    public interface AccountDelegateService {
032        
033        /**
034         * 
035         * This method checks for any MaintenanceLocks that would block the creation of this document
036         * @param global The AccountDelegateGlobalMaintainableImpl to check against.
037         * @param docNumber The document number of the AccountDelegateGlobalMaintainableImpl in question.
038         * @return the documentNumber of the locking record or null if none.
039         */
040        
041        public String getLockingDocumentId(AccountDelegateGlobalMaintainableImpl global, String docNumber);
042        
043        /**
044         * 
045         * This method checks for any MaintenanceLocks that would block the creation of this document
046         * @param delegate The AccountDelegateMaintainableImpl to check against.
047         * @param docNumber The document number of the AccountDelegateMaintainableImpl in question.
048         * @return the documentNumber of the locking record or null if none.
049         */
050        public String getLockingDocumentId(AccountDelegateMaintainableImpl delegate, String docNumber);
051        
052        /**
053         * Builds an appropriate maintainable with the given account delegate as the business object
054         * @param delegate the account delegate to wrap in a maintainable
055         * @return an appropriate maintainable
056         */
057        public abstract FinancialSystemMaintainable buildMaintainableForAccountDelegate(AccountDelegate delegate);
058        
059        /**
060         * Retrieves all active account delegations which delegate to the given Person
061         * @param principalId a principal id of the person to find account delegations for
062         * @param primary whether the account delegates returned should be primary or not
063         * @return a List of AccountDelegate business objects, representing that person's delegations
064         */
065        public abstract Iterator<AccountDelegate> retrieveAllActiveDelegationsForPerson(String principalId, boolean primary);
066    
067        /**
068         * Determines if the given principal is an active delegate for any non-closed account
069         * @param principalId the principal ID to check primary account delegations for
070         * @return true if the principal is a primary account delegate, false otherwise
071         */
072        public abstract boolean isPrincipalInAnyWayShapeOrFormPrimaryAccountDelegate(String principalId);
073        
074        /**
075         * 
076         * Determines if the given principal is an active delegate for any non-closed account
077         * @param principalId the principal ID to check secondary account delegations for
078         * @return true if the principal is a secondary account delegate, false otherwise
079         */
080        public abstract boolean isPrincipalInAnyWayShapeOrFormSecondaryAccountDelegate(String principalId);
081        
082        /**
083         * Saves the given account delegate to the persistence store
084         * @param accountDelegate the account delegate to save
085         */
086        public abstract void saveForMaintenanceDocument(AccountDelegate accountDelegate);
087        
088        /**
089         * Persists the given account delegate global maintenance document inactivations
090         * @param delegatesToInactivate the List of delegates to inactivate
091         */
092        public abstract void saveInactivationsForGlobalMaintenanceDocument(List<PersistableBusinessObject> delegatesToInactivate);
093        
094        /**
095         * Persists the given account delegate global maintenance document changes
096         * @param delegatesToChange the List of delegates to change
097         */
098        public abstract void saveChangesForGlobalMaintenanceDocument(List<PersistableBusinessObject> delegatesToChange);
099        
100        /**
101         * Updates the role that this delegate is part of, to account for the changes in this delegate
102         */
103        public abstract void updateDelegationRole();
104        
105    }