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.Map;
019    import java.util.Set;
020    
021    import org.kuali.rice.kns.bo.PersistableBusinessObject;
022    import org.kuali.rice.kns.service.PersistenceStructureService;
023    
024    /**
025     * Provides facilities to obtain chartofAccountsCode-accountNumber foreign key fields 
026     * and the corresponding account or account-involved reference objects.
027     */
028    public interface AccountPersistenceStructureService extends PersistenceStructureService {
029        
030        /**
031         * Decides if the specified class is an account related class, i.e. whether it contains chartOfAccountsCode and accountNumber as part of the primary keys.
032         * @param clazz the specified class
033         * @return true if the class contains chartOfAccountsCode and accountNumber as part of the primary keys; false otherwise.
034         */
035        public boolean isAccountRelatedClass(Class clazz);
036    
037        /**
038         * Determines the list of collection accounts (or other account-involved BOs) contained within the specified parent object. 
039         * For example, an Award object contains awardAccounts.
040         * Note: these do not include the following cases
041         *      - nested collection accounts
042         *      - non-maintainable collection accounts
043         *      
044         * @param bo BusinessObject (or subclass) instance that would like to be analyzed for collection accounts.
045         * @return Map containing the collection account names (key) and class type (value) or empty map if the BO contains no collection accounts.
046         */
047        public Map<String, Class> listCollectionAccountFields(PersistableBusinessObject bo);
048        
049        /**
050         * Determines the list of chartOfAccountsCode fields as one of the primary keys in the collection accounts 
051         * (or other account-involved BOs) contained within the specified parent object. 
052         * For example, an Award object contains awardAccounts with chartOfAccountsCode as one of the primary keys.
053         * Note: these do not include the following cases
054         *      - nested collection accounts
055         *      - non-maintainable collection accounts
056         *       
057         * @param bo BusinessObject (or subclass) instance that would like to be analyzed for collection accounts.
058         * @return Set containing the chartOfAccountsCode field names in collection accounts or empty set if the BO contains no collection accounts.
059         */
060        public Set<String> listCollectionChartOfAccountsCodeNames(PersistableBusinessObject bo);
061    
062        /**
063         * Determines the list of reference accounts (or other account-involved BOs) contained within the specified parent object. 
064         * For example, an Account object contains reportsToAccount etc.
065         * Note: these do not include the following cases:
066         *      - nested reference accounts
067         *      - reference accounts in collections
068         *      - reference accounts whose PKs are also PKs of the BO
069         *      - reference accounts whose PKs don't exist in the BO as foreign keys but are referred by the maintenance page in a nested way 
070         *      - non-existing reference accounts whose PKs exist in the BO as foreign keys (this should never happen)
071         *      - non-maintainable reference accounts
072         * 
073         * @param bo BusinessObject (or subclass) instance that would like to be analyzed for reference accounts.
074         * @return Map containing the reference account names (key) and class type (value) or empty map if the BO contains no reference accounts.
075         */
076        public Map<String, Class> listReferenceAccountFields(PersistableBusinessObject bo);
077    
078        /**
079         * Determines the list of chartOfAccountsCode-accountNumber pairs as (part of) the foreign keys of the reference accounts 
080         * (or other account-involved BOs) contained within the specified parent object. 
081         * For example, an Account object contains reportsToAccount with reportsToChartOfAccountsCode-reportsToAccountNumber as the foreign keys.
082         * Note: these do not include the following cases:
083         *      - nested reference accounts
084         *      - reference accounts in collections
085         *      - reference accounts whose PKs are also PKs of the BO
086         *      - reference accounts whose PKs don't exist in the BO as foreign keys but are referred by the maintainance page in a nested way 
087         *      - non-existing reference accounts whose PKs exist in the BO as foreign keys (this should never happen)
088         *      - non-maintainable reference accounts
089         *      
090         * @param bo BusinessObject (or subclass) instance that would like to be analyzed for reference accounts.
091         * @return Map containing the chartOfAccountsCode-accountNumber (key-value) foreign key pairs for all reference accounts or empty map if the BO contains no reference accounts.
092         */
093        public Map<String, String> listChartCodeAccountNumberPairs(PersistableBusinessObject bo);
094    
095        /**
096         * Determines the list of accountNumber-chartOfAccountsCode pairs as (part of) the foreign keys of the reference accounts 
097         * (or other account-involved BOs) contained within the specified parent object. 
098         * For example, an Account object contains reportsToAccount with reportsToAccountNumber-reportsToChartOfAccountsCode as the foreign keys.
099         * Note: these do not include the following cases:
100         *      - nested reference accounts
101         *      - reference accounts in collections
102         *      - reference accounts whose PKs are also PKs of the BO
103         *      - reference accounts whose PKs don't exist in the BO as foreign keys but are referred by the maintainance page in a nested way 
104         *      - non-existing reference accounts whose PKs exist in the BO as foreign keys (this should never happen)
105         *      - non-maintainable reference accounts
106         * 
107         * @param bo BusinessObject (or subclass) instance that would like to be analyzed for reference accounts.
108         * @return Map containing the accountNumber-chartOfAccountsCode (key-value) foreign key pairs for all reference accounts or empty map if the BO contains no reference accounts.
109         */
110        public Map<String, String> listAccountNumberChartCodePairs(PersistableBusinessObject bo);
111    
112        /**
113         * Determines the list of chartOfAccountsCode fields as one of the foreign keys of the reference accounts 
114         * (or other account-involved BOs) contained within the specified parent object. 
115         * For example, an Account object contains reportsToAccount with reportsToChartOfAccountsCode as one of the foreign keys.
116         * Note: these do not include the following cases:
117         *      - nested reference accounts
118         *      - reference accounts in collections
119         *      - reference accounts whose PKs are also PKs of the BO
120         *      - reference accounts whose PKs don't exist in the BO as foreign keys but are referred by the maintainance page in a nested way 
121         *      - non-existing reference accounts whose PKs exist in the BO as foreign keys (this should never happen)
122         *      - non-maintainable reference accounts
123         * 
124         * @param bo BusinessObject (or subclass) instance that would like to be analyzed for reference accounts.
125         * @return Set containing the chartOfAccountsCode foreign key names for all reference accounts or empty set if the BO contains no reference accounts.
126         */
127        public Set<String> listChartOfAccountsCodeNames(PersistableBusinessObject bo);
128        
129        /**
130         * Determines the list of accountNumber fields as one of the foreign keys of the reference accounts 
131         * (or other account-involved BOs) contained within the specified parent object. 
132         * For example, an Account object contains reportsToAccount with reportsToAccountNumber as one of the foreign keys.
133         * Note: these do not include the following cases:
134         *      - nested reference accounts
135         *      - reference accounts in collections
136         *      - reference accounts whose PKs are also PKs of the BO
137         *      - reference accounts whose PKs don't exist in the BO as foreign keys but are referred by the maintainance page in a nested way 
138         *      - non-existing reference accounts whose PKs exist in the BO as foreign keys (this should never happen)
139         *      - non-maintainable reference accounts
140         * 
141         * @param bo BusinessObject (or subclass) instance that would like to be analyzed for reference accounts.
142         * @return Set containing the accountNumber foreign key names for all reference accounts or empty set if the BO contains no reference accounts.
143         */
144        public Set<String> listAccountNumberNames(PersistableBusinessObject bo);
145    
146        /**
147         * Gets the name of the chartOfAccountsCode field as one foreign key, paired with the specified accountNumber field 
148         * as the other, of the reference account (or other account-involved BO) contained within the specified parent object. 
149         * For example, an Account object contains reportsToAccount with reportsToChartOfAccountsCode and reportsToAccountNumber as the foreign key pair.
150         * 
151         * @param bo BusinessObject (or subclass) instance that would like to be analyzed for reference accounts.
152         * @param accountNumberFieldName the name of the foreign key corresponding to the primary key accountNumber of the reference account. 
153         * @return the chartOfAccountsCode field name of the reference account identified by foreign key accountNumberFieldName, or empty string if the BO contains no such reference account.
154         */
155        public String getChartOfAccountsCodeName(PersistableBusinessObject bo, String accountNumberFieldName);
156    
157        /**
158         * Gets the name of the accountNumber field as one foreign key, paired with the specified chartOfAccountsCode field 
159         * as the other, of the reference account (or other account-involved BO) contained within the specified parent object. 
160         * For example, an Account object contains reportsToAccount with reportsToAccountNumber and reportsToChartOfAccountsCode as the foreign key pair.
161         * 
162         * @param bo BusinessObject (or subclass) instance that would like to be analyzed for reference accounts.
163         * @param chartOfAccountsCodeFieldName the name of the foreign key corresponding to the primary key chartOfAccountsCode of the reference account. 
164         * @return the accountNumber field name of the reference account identified by foreign key chartOfAccountsCode, or empty string if the BO contains no such reference account.
165         */
166        public String getAccountNumberName(PersistableBusinessObject bo, String chartOfAccountsCodeFieldName);
167    
168    }
169