1 /* 2 * The Kuali Financial System, a comprehensive financial management system for higher education. 3 * 4 * Copyright 2005-2014 The Kuali Foundation 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU Affero General Public License as 8 * published by the Free Software Foundation, either version 3 of the 9 * License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Affero General Public License for more details. 15 * 16 * You should have received a copy of the GNU Affero General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 package org.kuali.kfs.coa.service; 20 21 import java.util.Map; 22 import java.util.Set; 23 24 import org.kuali.rice.krad.bo.PersistableBusinessObject; 25 import org.kuali.rice.krad.service.PersistenceStructureService; 26 27 /** 28 * Provides facilities to obtain chartofAccountsCode-accountNumber foreign key fields 29 * and the corresponding account or account-involved reference objects. 30 */ 31 public interface AccountPersistenceStructureService extends PersistenceStructureService { 32 33 /** 34 * Decides if the specified class is an account related class, i.e. whether it contains chartOfAccountsCode and accountNumber as part of the primary keys. 35 * @param clazz the specified class 36 * @return true if the class contains chartOfAccountsCode and accountNumber as part of the primary keys; false otherwise. 37 */ 38 public boolean isAccountRelatedClass(Class clazz); 39 40 /** 41 * Determines the list of collection accounts (or other account-involved BOs) contained within the specified parent object. 42 * For example, an Award object contains awardAccounts. 43 * Note: these do not include the following cases 44 * - nested collection accounts 45 * - non-maintainable collection accounts 46 * 47 * @param bo BusinessObject (or subclass) instance that would like to be analyzed for collection accounts. 48 * @return Map containing the collection account names (key) and class type (value) or empty map if the BO contains no collection accounts. 49 */ 50 public Map<String, Class> listCollectionAccountFields(PersistableBusinessObject bo); 51 52 /** 53 * Determines the list of chartOfAccountsCode fields as one of the primary keys in the collection accounts 54 * (or other account-involved BOs) contained within the specified parent object. 55 * For example, an Award object contains awardAccounts with chartOfAccountsCode as one of the primary keys. 56 * Note: these do not include the following cases 57 * - nested collection accounts 58 * - non-maintainable collection accounts 59 * 60 * @param bo BusinessObject (or subclass) instance that would like to be analyzed for collection accounts. 61 * @return Set containing the chartOfAccountsCode field names in collection accounts or empty set if the BO contains no collection accounts. 62 */ 63 public Set<String> listCollectionChartOfAccountsCodeNames(PersistableBusinessObject bo); 64 65 /** 66 * Determines the list of reference accounts (or other account-involved BOs) contained within the specified parent object. 67 * For example, an Account object contains reportsToAccount etc. 68 * Note: these do not include the following cases: 69 * - nested reference accounts 70 * - reference accounts in collections 71 * - reference accounts whose PKs are also PKs of the BO 72 * - reference accounts whose PKs don't exist in the BO as foreign keys but are referred by the maintenance page in a nested way 73 * - non-existing reference accounts whose PKs exist in the BO as foreign keys (this should never happen) 74 * - non-maintainable reference accounts 75 * 76 * @param bo BusinessObject (or subclass) instance that would like to be analyzed for reference accounts. 77 * @return Map containing the reference account names (key) and class type (value) or empty map if the BO contains no reference accounts. 78 */ 79 public Map<String, Class> listReferenceAccountFields(PersistableBusinessObject bo); 80 81 /** 82 * Determines the list of chartOfAccountsCode-accountNumber pairs as (part of) the foreign keys of the reference accounts 83 * (or other account-involved BOs) contained within the specified parent object. 84 * For example, an Account object contains reportsToAccount with reportsToChartOfAccountsCode-reportsToAccountNumber as the foreign keys. 85 * Note: these do not include the following cases: 86 * - nested reference accounts 87 * - reference accounts in collections 88 * - reference accounts whose PKs are also PKs of the BO 89 * - reference accounts whose PKs don't exist in the BO as foreign keys but are referred by the maintainance page in a nested way 90 * - non-existing reference accounts whose PKs exist in the BO as foreign keys (this should never happen) 91 * - non-maintainable reference accounts 92 * 93 * @param bo BusinessObject (or subclass) instance that would like to be analyzed for reference accounts. 94 * @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. 95 */ 96 public Map<String, String> listChartCodeAccountNumberPairs(PersistableBusinessObject bo); 97 98 /** 99 * Determines the list of accountNumber-chartOfAccountsCode pairs as (part of) the foreign keys of the reference accounts 100 * (or other account-involved BOs) contained within the specified parent object. 101 * For example, an Account object contains reportsToAccount with reportsToAccountNumber-reportsToChartOfAccountsCode as the foreign keys. 102 * Note: these do not include the following cases: 103 * - nested reference accounts 104 * - reference accounts in collections 105 * - reference accounts whose PKs are also PKs of the BO 106 * - reference accounts whose PKs don't exist in the BO as foreign keys but are referred by the maintainance page in a nested way 107 * - non-existing reference accounts whose PKs exist in the BO as foreign keys (this should never happen) 108 * - non-maintainable reference accounts 109 * 110 * @param bo BusinessObject (or subclass) instance that would like to be analyzed for reference accounts. 111 * @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. 112 */ 113 public Map<String, String> listAccountNumberChartCodePairs(PersistableBusinessObject bo); 114 115 /** 116 * Determines the list of chartOfAccountsCode fields as one of the foreign keys of the reference accounts 117 * (or other account-involved BOs) contained within the specified parent object. 118 * For example, an Account object contains reportsToAccount with reportsToChartOfAccountsCode as one of the foreign keys. 119 * Note: these do not include the following cases: 120 * - nested reference accounts 121 * - reference accounts in collections 122 * - reference accounts whose PKs are also PKs of the BO 123 * - reference accounts whose PKs don't exist in the BO as foreign keys but are referred by the maintainance page in a nested way 124 * - non-existing reference accounts whose PKs exist in the BO as foreign keys (this should never happen) 125 * - non-maintainable reference accounts 126 * 127 * @param bo BusinessObject (or subclass) instance that would like to be analyzed for reference accounts. 128 * @return Set containing the chartOfAccountsCode foreign key names for all reference accounts or empty set if the BO contains no reference accounts. 129 */ 130 public Set<String> listChartOfAccountsCodeNames(PersistableBusinessObject bo); 131 132 /** 133 * Determines the list of accountNumber fields as one of the foreign keys of the reference accounts 134 * (or other account-involved BOs) contained within the specified parent object. 135 * For example, an Account object contains reportsToAccount with reportsToAccountNumber as one of the foreign keys. 136 * Note: these do not include the following cases: 137 * - nested reference accounts 138 * - reference accounts in collections 139 * - reference accounts whose PKs are also PKs of the BO 140 * - reference accounts whose PKs don't exist in the BO as foreign keys but are referred by the maintainance page in a nested way 141 * - non-existing reference accounts whose PKs exist in the BO as foreign keys (this should never happen) 142 * - non-maintainable reference accounts 143 * 144 * @param bo BusinessObject (or subclass) instance that would like to be analyzed for reference accounts. 145 * @return Set containing the accountNumber foreign key names for all reference accounts or empty set if the BO contains no reference accounts. 146 */ 147 public Set<String> listAccountNumberNames(PersistableBusinessObject bo); 148 149 /** 150 * Gets the name of the chartOfAccountsCode field as one foreign key, paired with the specified accountNumber field 151 * as the other, of the reference account (or other account-involved BO) contained within the specified parent object. 152 * For example, an Account object contains reportsToAccount with reportsToChartOfAccountsCode and reportsToAccountNumber as the foreign key pair. 153 * 154 * @param bo BusinessObject (or subclass) instance that would like to be analyzed for reference accounts. 155 * @param accountNumberFieldName the name of the foreign key corresponding to the primary key accountNumber of the reference account. 156 * @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. 157 */ 158 public String getChartOfAccountsCodeName(PersistableBusinessObject bo, String accountNumberFieldName); 159 160 /** 161 * Gets the name of the accountNumber field as one foreign key, paired with the specified chartOfAccountsCode field 162 * as the other, of the reference account (or other account-involved BO) contained within the specified parent object. 163 * For example, an Account object contains reportsToAccount with reportsToAccountNumber and reportsToChartOfAccountsCode as the foreign key pair. 164 * 165 * @param bo BusinessObject (or subclass) instance that would like to be analyzed for reference accounts. 166 * @param chartOfAccountsCodeFieldName the name of the foreign key corresponding to the primary key chartOfAccountsCode of the reference account. 167 * @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. 168 */ 169 public String getAccountNumberName(PersistableBusinessObject bo, String chartOfAccountsCodeFieldName); 170 171 } 172