Source Code Cross Referenced for AccountingLineRuleUtil.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » kfs » rules » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Kuali Financial System » org.kuali.kfs.rules 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 The Kuali Foundation.
003:         * 
004:         * Licensed under the Educational Community License, Version 1.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/ecl1.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.rules;
017:
018:        import org.apache.commons.lang.StringUtils;
019:        import org.kuali.core.bo.DocumentType;
020:        import org.kuali.core.datadictionary.BusinessObjectEntry;
021:        import org.kuali.core.datadictionary.DataDictionary;
022:        import org.kuali.core.service.DataDictionaryService;
023:        import org.kuali.core.service.KualiConfigurationService;
024:        import org.kuali.core.util.GlobalVariables;
025:        import org.kuali.core.util.ObjectUtils;
026:        import org.kuali.kfs.KFSConstants;
027:        import org.kuali.kfs.KFSKeyConstants;
028:        import org.kuali.kfs.KFSPropertyConstants;
029:        import org.kuali.kfs.bo.AccountingLine;
030:        import org.kuali.kfs.bo.AccountingLineOverride;
031:        import org.kuali.kfs.bo.OriginationCode;
032:        import org.kuali.kfs.bo.SourceAccountingLine;
033:        import org.kuali.kfs.context.SpringContext;
034:        import org.kuali.module.chart.bo.Account;
035:        import org.kuali.module.chart.bo.Chart;
036:        import org.kuali.module.chart.bo.FundGroup;
037:        import org.kuali.module.chart.bo.ObjSubTyp;
038:        import org.kuali.module.chart.bo.ObjectCode;
039:        import org.kuali.module.chart.bo.ObjectType;
040:        import org.kuali.module.chart.bo.Org;
041:        import org.kuali.module.chart.bo.ProjectCode;
042:        import org.kuali.module.chart.bo.SubAccount;
043:        import org.kuali.module.chart.bo.SubFundGroup;
044:        import org.kuali.module.chart.bo.SubObjCd;
045:        import org.kuali.module.chart.service.AccountService;
046:
047:        /**
048:         * This utility class contains some common accounting line business rules, that can be used by many different parts of this
049:         * application.
050:         */
051:        public class AccountingLineRuleUtil {
052:            /**
053:             * This method validates that an accounting line object contains values that actually exist in the DB. SubAccount and SubObject
054:             * are only checked if there are values in them. The others throw errors if they area null.
055:             * 
056:             * @param accountingLine
057:             * @param dataDictionaryService
058:             * @return success or failure of validating the AccountingLine
059:             * @throws IllegalStateException
060:             */
061:            public static boolean validateAccountingLine(
062:                    AccountingLine accountingLine,
063:                    DataDictionaryService dataDictionaryService)
064:                    throws IllegalStateException {
065:                if (accountingLine == null) {
066:                    throw new IllegalStateException(
067:                            SpringContext
068:                                    .getBean(KualiConfigurationService.class)
069:                                    .getPropertyString(
070:                                            KFSKeyConstants.ERROR_DOCUMENT_NULL_ACCOUNTING_LINE));
071:                }
072:
073:                // grab the two service instances that will be needed by all the validate methods
074:                DataDictionary dd = dataDictionaryService.getDataDictionary();
075:
076:                BusinessObjectEntry accountingLineEntry = dd
077:                        .getBusinessObjectEntry(SourceAccountingLine.class
078:                                .getName());
079:
080:                // retrieve accounting line objects to validate
081:                Chart chart = accountingLine.getChart();
082:                Account account = accountingLine.getAccount();
083:                SubAccount subAccount = accountingLine.getSubAccount();
084:                ObjectCode objectCode = accountingLine.getObjectCode();
085:                SubObjCd subObjectCode = accountingLine.getSubObjectCode();
086:                ProjectCode projectCode = accountingLine.getProject();
087:                ObjectType objectTypeCode = accountingLine.getObjectType();
088:                OriginationCode referenceOrigin = accountingLine
089:                        .getReferenceOrigin();
090:                DocumentType referenceType = accountingLine.getReferenceType();
091:
092:                boolean valid = true;
093:                valid &= isValidChart(chart, dd);
094:                valid &= isValidAccount(account, dd);
095:                // sub account is not required
096:                if (StringUtils
097:                        .isNotBlank(accountingLine.getSubAccountNumber())) {
098:                    valid &= isValidSubAccount(subAccount, dd);
099:                }
100:                valid &= isValidObjectCode(objectCode, dd);
101:                // sub object is not required
102:                if (StringUtils.isNotBlank(accountingLine
103:                        .getFinancialSubObjectCode())) {
104:                    valid &= isValidSubObjectCode(subObjectCode, dd);
105:                }
106:                // project code is not required
107:                if (StringUtils.isNotBlank(accountingLine.getProjectCode())) {
108:                    valid &= isValidProjectCode(projectCode, dd);
109:                }
110:                // object type code is not required to be entered
111:                if (StringUtils.isNotBlank(accountingLine.getObjectTypeCode())) {
112:                    valid &= isValidObjectTypeCode(objectTypeCode, dd);
113:                }
114:                if (StringUtils.isNotBlank(accountingLine
115:                        .getReferenceOriginCode())) {
116:                    valid &= isValidReferenceOriginCode(referenceOrigin,
117:                            accountingLineEntry);
118:                }
119:                if (StringUtils.isNotBlank(accountingLine
120:                        .getReferenceTypeCode())) {
121:                    valid &= isValidReferenceTypeCode(referenceType,
122:                            accountingLineEntry);
123:                }
124:                valid &= hasRequiredOverrides(accountingLine, accountingLine
125:                        .getOverrideCode());
126:                return valid;
127:            }
128:
129:            /**
130:             * This method validates that the chart is active for use in the system.
131:             * 
132:             * @param chart
133:             * @param dataDictionary
134:             * @return boolean True if the Chart is valid.
135:             */
136:            public static boolean isValidChart(Chart chart,
137:                    DataDictionary dataDictionary) {
138:                return isValidChart(chart, dataDictionary,
139:                        KFSConstants.CHART_OF_ACCOUNTS_CODE_PROPERTY_NAME);
140:            }
141:
142:            /**
143:             * This method validates that the chart is active for use in the system.
144:             * 
145:             * @param chart
146:             * @param dataDictionary
147:             * @param errorPropertyName
148:             * @return boolean True if the Chart is valid.
149:             */
150:            public static boolean isValidChart(Chart chart,
151:                    DataDictionary dataDictionary, String errorPropertyName) {
152:                String label = getChartLabel();
153:
154:                // make sure it exists
155:                if (ObjectUtils.isNull(chart)) {
156:                    GlobalVariables.getErrorMap().putError(errorPropertyName,
157:                            KFSKeyConstants.ERROR_EXISTENCE, label);
158:                    return false;
159:                }
160:
161:                // make sure it's active for usage
162:                if (!chart.isFinChartOfAccountActiveIndicator()) {
163:                    GlobalVariables.getErrorMap().putError(errorPropertyName,
164:                            KFSKeyConstants.ERROR_INACTIVE, label);
165:                    return false;
166:                }
167:
168:                return true;
169:            }
170:
171:            /**
172:             * This method validates that the account is active for use in the system.
173:             * 
174:             * @param account
175:             * @param dataDictionary
176:             * @return boolean True if it is valid.
177:             */
178:            public static boolean isValidAccount(Account account,
179:                    DataDictionary dataDictionary) {
180:                return isValidAccount(account, dataDictionary,
181:                        KFSConstants.ACCOUNT_NUMBER_PROPERTY_NAME);
182:            }
183:
184:            /**
185:             * This method validates that the account is active for use in the system.
186:             * 
187:             * @param account
188:             * @param dataDictionary
189:             * @param errorPropertyName
190:             * @return boolean True if it is valid.
191:             */
192:            public static boolean isValidAccount(Account account,
193:                    DataDictionary dataDictionary, String errorPropertyName) {
194:                String label = getAccountLabel();
195:
196:                // make sure it exists
197:                if (ObjectUtils.isNull(account)) {
198:                    GlobalVariables.getErrorMap().putError(errorPropertyName,
199:                            KFSKeyConstants.ERROR_EXISTENCE, label);
200:                    return false;
201:                }
202:
203:                // make sure it's active for usage
204:                if (account.isAccountClosedIndicator()) {
205:                    GlobalVariables.getErrorMap().putError(errorPropertyName,
206:                            KFSKeyConstants.ERROR_DOCUMENT_ACCOUNT_CLOSED,
207:                            label);
208:                    return false;
209:                }
210:
211:                return true;
212:            }
213:
214:            /**
215:             * Checks that the given overrideCode is sufficient for the given BO, adding errors to the global map if not.
216:             * 
217:             * @param line
218:             * @param overrideCode
219:             * @return whether the given overrideCode is sufficient for the given BO.
220:             */
221:            public static boolean hasRequiredOverrides(AccountingLine line,
222:                    String overrideCode) {
223:                boolean retVal = true;
224:                AccountingLineOverride override = AccountingLineOverride
225:                        .valueOf(overrideCode);
226:                Account account = line.getAccount();
227:                if (AccountingLineOverride.needsExpiredAccountOverride(account)
228:                        && !override
229:                                .hasComponent(AccountingLineOverride.COMPONENT.EXPIRED_ACCOUNT)) {
230:                    Account continuation = getUnexpiredContinuationAccountOrNull(account);
231:                    if (continuation == null) {
232:                        GlobalVariables
233:                                .getErrorMap()
234:                                .putError(
235:                                        KFSConstants.ACCOUNT_NUMBER_PROPERTY_NAME,
236:                                        KFSKeyConstants.ERROR_DOCUMENT_ACCOUNT_EXPIRED_NO_CONTINUATION,
237:                                        new String[] { account
238:                                                .getAccountNumber() });
239:                    } else {
240:                        GlobalVariables.getErrorMap().putError(
241:                                KFSConstants.ACCOUNT_NUMBER_PROPERTY_NAME,
242:                                KFSKeyConstants.ERROR_DOCUMENT_ACCOUNT_EXPIRED,
243:                                new String[] { account.getAccountNumber(),
244:                                        continuation.getChartOfAccountsCode(),
245:                                        continuation.getAccountNumber() });
246:                        // todo: ... args in JDK 1.5
247:                    }
248:                    retVal = false;
249:                }
250:
251:                ObjectCode objectCode = line.getObjectCode();
252:                if (AccountingLineOverride.needsObjectBudgetOverride(account,
253:                        objectCode)
254:                        && !override
255:                                .hasComponent(AccountingLineOverride.COMPONENT.NON_BUDGETED_OBJECT)) {
256:                    GlobalVariables
257:                            .getErrorMap()
258:                            .putError(
259:                                    KFSConstants.FINANCIAL_OBJECT_CODE_PROPERTY_NAME,
260:                                    KFSKeyConstants.ERROR_DOCUMENT_ACCOUNT_PRESENCE_NON_BUDGETED_OBJECT_CODE,
261:                                    new String[] { account.getAccountNumber(),
262:                                            objectCode.getFinancialObjectCode() });
263:                    retVal = false;
264:                }
265:                return retVal;
266:            }
267:
268:            /**
269:             * This method...
270:             * 
271:             * @param account
272:             * @return Account
273:             */
274:            private static Account getUnexpiredContinuationAccountOrNull(
275:                    Account account) {
276:                int count = 0;
277:                while (count++ < 10) { // prevents infinite loops
278:                    String continuationChartCode = account
279:                            .getContinuationFinChrtOfAcctCd();
280:                    String continuationAccountNumber = account
281:                            .getContinuationAccountNumber();
282:                    // todo: does AccountService already handle blank keys this way?
283:                    if (StringUtils.isBlank(continuationChartCode)
284:                            || StringUtils.isBlank(continuationAccountNumber)) {
285:                        return null;
286:                    }
287:                    account = SpringContext.getBean(AccountService.class)
288:                            .getByPrimaryId(continuationChartCode,
289:                                    continuationAccountNumber);
290:                    if (ObjectUtils.isNull(account)) {
291:                        return null;
292:                    }
293:                    if (!account.isAccountClosedIndicator()
294:                            && !account.isExpired()) {
295:                        return account;
296:                    }
297:                }
298:                return null;
299:            }
300:
301:            /**
302:             * This method validates that a sub account is active.
303:             * 
304:             * @param subAccount
305:             * @param dataDictionary
306:             * @return true if it exists
307:             */
308:            public static boolean isValidSubAccount(SubAccount subAccount,
309:                    DataDictionary dataDictionary) {
310:                return isValidSubAccount(subAccount, dataDictionary,
311:                        KFSConstants.SUB_ACCOUNT_NUMBER_PROPERTY_NAME);
312:            }
313:
314:            /**
315:             * This method validates that a sub account is active.
316:             * 
317:             * @param subAccount
318:             * @param dataDictionary
319:             * @param errorPropertyName
320:             * @return true if it exists
321:             */
322:            public static boolean isValidSubAccount(SubAccount subAccount,
323:                    DataDictionary dataDictionary, String errorPropertyName) {
324:                String label = getSubAccountLabel();
325:
326:                // make sure it exists
327:                if (ObjectUtils.isNull(subAccount)) {
328:                    GlobalVariables.getErrorMap().putError(errorPropertyName,
329:                            KFSKeyConstants.ERROR_EXISTENCE, label);
330:                    return false;
331:                }
332:
333:                // check to make sure it is active
334:                if (!subAccount.isSubAccountActiveIndicator()) {
335:                    GlobalVariables
336:                            .getErrorMap()
337:                            .putError(
338:                                    errorPropertyName,
339:                                    KFSKeyConstants.ERROR_DOCUMENT_SUB_ACCOUNT_INACTIVE,
340:                                    label);
341:                    return false;
342:                }
343:
344:                return true;
345:            }
346:
347:            /**
348:             * This method validates that an object code is active.
349:             * 
350:             * @param objectCode
351:             * @param dataDictionary
352:             * @return boolean True if the object code is valid.
353:             */
354:            public static boolean isValidObjectCode(ObjectCode objectCode,
355:                    DataDictionary dataDictionary) {
356:                return isValidObjectCode(objectCode, dataDictionary,
357:                        KFSConstants.FINANCIAL_OBJECT_CODE_PROPERTY_NAME);
358:            }
359:
360:            /**
361:             * This method validates that an object code is active.
362:             * 
363:             * @param objectCode
364:             * @param dataDictionary
365:             * @param errorPropertyName
366:             * @return boolean True if the object code is valid.
367:             */
368:            public static boolean isValidObjectCode(ObjectCode objectCode,
369:                    DataDictionary dataDictionary, String errorPropertyName) {
370:                String label = getObjectCodeLabel();
371:
372:                // make sure it exists
373:                if (ObjectUtils.isNull(objectCode)) {
374:                    GlobalVariables.getErrorMap().putError(errorPropertyName,
375:                            KFSKeyConstants.ERROR_EXISTENCE, label);
376:                    return false;
377:                }
378:
379:                // check active status
380:                if (!objectCode.isFinancialObjectActiveCode()) {
381:                    GlobalVariables.getErrorMap().putError(errorPropertyName,
382:                            KFSKeyConstants.ERROR_INACTIVE, label);
383:                    return false;
384:                }
385:
386:                return true;
387:            }
388:
389:            /**
390:             * This method validates that a sub object code is active.
391:             * 
392:             * @param subObjectCode
393:             * @param dataDictionary
394:             * @return boolean True if it is valid.
395:             */
396:            public static boolean isValidSubObjectCode(SubObjCd subObjectCode,
397:                    DataDictionary dataDictionary) {
398:                return isValidSubObjectCode(subObjectCode, dataDictionary,
399:                        KFSConstants.FINANCIAL_SUB_OBJECT_CODE_PROPERTY_NAME);
400:            }
401:
402:            /**
403:             * This method validates that a sub object code is active.
404:             * 
405:             * @param subObjectCode
406:             * @param dataDictionary
407:             * @param errorPropertyName
408:             * @return boolean True if it is valid.
409:             */
410:            public static boolean isValidSubObjectCode(SubObjCd subObjectCode,
411:                    DataDictionary dataDictionary, String errorPropertyName) {
412:                String label = getSubObjectCodeLabel();
413:
414:                // make sure it exists
415:                if (ObjectUtils.isNull(subObjectCode)) {
416:                    GlobalVariables.getErrorMap().putError(errorPropertyName,
417:                            KFSKeyConstants.ERROR_EXISTENCE, label);
418:                    return false;
419:                }
420:
421:                // check active flag
422:                if (!subObjectCode.isFinancialSubObjectActiveIndicator()) {
423:                    GlobalVariables.getErrorMap().putError(errorPropertyName,
424:                            KFSKeyConstants.ERROR_INACTIVE, label);
425:                    return false;
426:                }
427:                return true;
428:            }
429:
430:            /**
431:             * This method validates that a project code is active.
432:             * 
433:             * @param projectCode
434:             * @param dataDictionary
435:             * @return boolean True if it is valid.
436:             */
437:            public static boolean isValidProjectCode(ProjectCode projectCode,
438:                    DataDictionary dataDictionary) {
439:                return isValidProjectCode(projectCode, dataDictionary,
440:                        KFSConstants.PROJECT_CODE_PROPERTY_NAME);
441:            }
442:
443:            /**
444:             * This method validates that a project code is active.
445:             * 
446:             * @param projectCode
447:             * @param dataDictionary
448:             * @param errorPropertyName
449:             * @return boolean True if it is valid.
450:             */
451:            public static boolean isValidProjectCode(ProjectCode projectCode,
452:                    DataDictionary dataDictionary, String errorPropertyName) {
453:                // note that the errorPropertyName does not match the actual attribute name
454:                String label = getProjectCodeLabel();
455:
456:                // make sure it exists
457:                if (ObjectUtils.isNull(projectCode)) {
458:                    GlobalVariables.getErrorMap().putError(errorPropertyName,
459:                            KFSKeyConstants.ERROR_EXISTENCE, label);
460:                    return false;
461:                }
462:
463:                // check activity
464:                if (!projectCode.isActive()) {
465:                    GlobalVariables.getErrorMap().putError(errorPropertyName,
466:                            KFSKeyConstants.ERROR_INACTIVE, label);
467:                    return false;
468:                }
469:
470:                return true;
471:            }
472:
473:            /**
474:             * For the most part, object type codes aren't required on an accounting line; however, in some situations (e.g. Journal
475:             * Voucher) they are entered directly into the accounting line and must be validated. In those cases, they must be validated for
476:             * activeness.
477:             * 
478:             * @param objectTypeCode
479:             * @param dataDictionary
480:             * @return boolean True if the object type code is valid, false otherwise.
481:             */
482:            public static boolean isValidObjectTypeCode(
483:                    ObjectType objectTypeCode, DataDictionary dataDictionary) {
484:                return isValidObjectTypeCode(objectTypeCode, dataDictionary,
485:                        KFSConstants.OBJECT_TYPE_CODE_PROPERTY_NAME);
486:            }
487:
488:            /**
489:             * For the most part, object type codes aren't required on an accounting line; however, in some situations (e.g. Journal
490:             * Voucher) they are entered directly into the accounting line and must be validated. In those cases, they must be validated for
491:             * activeness.
492:             * 
493:             * @param objectTypeCode
494:             * @param dataDictionary
495:             * @param errorPropertyName
496:             * @return boolean True if the object type code is valid, false otherwise.
497:             */
498:            public static boolean isValidObjectTypeCode(
499:                    ObjectType objectTypeCode, DataDictionary dataDictionary,
500:                    String errorPropertyName) {
501:                // note that the errorPropertyName does not match the actual attribute name
502:                String label = getObjectTypeCodeLabel();
503:
504:                // make sure it exists
505:                if (ObjectUtils.isNull(objectTypeCode)) {
506:                    GlobalVariables.getErrorMap().putError(errorPropertyName,
507:                            KFSKeyConstants.ERROR_EXISTENCE, label);
508:                    return false;
509:                }
510:
511:                // check activity
512:                if (!objectTypeCode.isActive()) {
513:                    GlobalVariables.getErrorMap().putError(errorPropertyName,
514:                            KFSKeyConstants.ERROR_INACTIVE, label);
515:                    return false;
516:                }
517:
518:                return true;
519:            }
520:
521:            /**
522:             * This method will check the reference origin code for existence in the system and whether it can actively be used.
523:             * 
524:             * @param referenceOriginCode
525:             * @param accountingLineEntry
526:             * @return boolean True if the object is valid; false otherwise.
527:             */
528:            private static boolean isValidReferenceOriginCode(
529:                    OriginationCode referenceOriginCode,
530:                    BusinessObjectEntry accountingLineEntry) {
531:                return checkExistence(referenceOriginCode, accountingLineEntry,
532:                        KFSPropertyConstants.REFERENCE_ORIGIN_CODE,
533:                        KFSPropertyConstants.REFERENCE_ORIGIN_CODE);
534:            }
535:
536:            /**
537:             * This method will check the reference type code for existence in the system and whether it can actively be used.
538:             * 
539:             * @param referenceType
540:             * @param accountingLineEntry
541:             * @return boolean True if the object is valid; false otherwise.
542:             */
543:            private static boolean isValidReferenceTypeCode(
544:                    DocumentType referenceType,
545:                    BusinessObjectEntry accountingLineEntry) {
546:                return checkExistence(referenceType, accountingLineEntry,
547:                        KFSPropertyConstants.REFERENCE_TYPE_CODE,
548:                        KFSPropertyConstants.REFERENCE_TYPE_CODE);
549:            }
550:
551:            /**
552:             * Checks for the existence of the given Object. This is doing an OJB-proxy-smart check, so assuming the given Object is not in
553:             * need of a refresh(), this method adds an ERROR_EXISTENCE to the global error map if the given Object is not in the database.
554:             * 
555:             * @param toCheck the Object to check for existence
556:             * @param accountingLineEntry to get the property's label for the error message parameter.
557:             * @param attributeName the name of the SourceAccountingLine attribute in the DataDictionary accountingLineEntry
558:             * @param propertyName the name of the property within the global error path.
559:             * @return whether the given Object exists or not
560:             */
561:            private static boolean checkExistence(Object toCheck,
562:                    BusinessObjectEntry accountingLineEntry,
563:                    String attributeName, String propertyName) {
564:                String label = accountingLineEntry.getAttributeDefinition(
565:                        attributeName).getShortLabel();
566:                if (ObjectUtils.isNull(toCheck)) {
567:                    GlobalVariables.getErrorMap().putError(propertyName,
568:                            KFSKeyConstants.ERROR_EXISTENCE, label);
569:                    return false;
570:                }
571:                return true;
572:            }
573:
574:            /**
575:             * @return short label for chart code defined in data dictionary
576:             */
577:            public static String getChartLabel() {
578:                return SpringContext
579:                        .getBean(DataDictionaryService.class)
580:                        .getDataDictionary()
581:                        .getBusinessObjectEntry(Chart.class.getName())
582:                        .getAttributeDefinition(
583:                                KFSConstants.CHART_OF_ACCOUNTS_CODE_PROPERTY_NAME)
584:                        .getShortLabel();
585:            }
586:
587:            /**
588:             * @return short label for account number defined in data dictionary
589:             */
590:            public static String getAccountLabel() {
591:                return SpringContext.getBean(DataDictionaryService.class)
592:                        .getDataDictionary().getBusinessObjectEntry(
593:                                Account.class.getName())
594:                        .getAttributeDefinition(
595:                                KFSConstants.ACCOUNT_NUMBER_PROPERTY_NAME)
596:                        .getShortLabel();
597:            }
598:
599:            /**
600:             * @return short label for sub account number defined in data dictionary
601:             */
602:            public static String getSubAccountLabel() {
603:                return SpringContext.getBean(DataDictionaryService.class)
604:                        .getDataDictionary().getBusinessObjectEntry(
605:                                SubAccount.class.getName())
606:                        .getAttributeDefinition(
607:                                KFSConstants.SUB_ACCOUNT_NUMBER_PROPERTY_NAME)
608:                        .getShortLabel();
609:            }
610:
611:            /**
612:             * @return short label for object code defined in data dictionary
613:             */
614:            public static String getObjectCodeLabel() {
615:                return SpringContext
616:                        .getBean(DataDictionaryService.class)
617:                        .getDataDictionary()
618:                        .getBusinessObjectEntry(ObjectCode.class.getName())
619:                        .getAttributeDefinition(
620:                                KFSConstants.FINANCIAL_OBJECT_CODE_PROPERTY_NAME)
621:                        .getShortLabel();
622:            }
623:
624:            /**
625:             * @return short label for sub object code defined in data dictionary
626:             */
627:            public static String getSubObjectCodeLabel() {
628:                return SpringContext
629:                        .getBean(DataDictionaryService.class)
630:                        .getDataDictionary()
631:                        .getBusinessObjectEntry(SubObjCd.class.getName())
632:                        .getAttributeDefinition(
633:                                KFSConstants.FINANCIAL_SUB_OBJECT_CODE_PROPERTY_NAME)
634:                        .getShortLabel();
635:            }
636:
637:            /**
638:             * @return short label for project code defined in data dictionary
639:             */
640:            public static String getProjectCodeLabel() {
641:                return SpringContext.getBean(DataDictionaryService.class)
642:                        .getDataDictionary().getBusinessObjectEntry(
643:                                ProjectCode.class.getName())
644:                        .getAttributeDefinition(KFSPropertyConstants.CODE)
645:                        .getShortLabel();
646:            }
647:
648:            /**
649:             * @return short label for object type code defined in data dictionary
650:             */
651:            public static String getObjectTypeCodeLabel() {
652:                return SpringContext.getBean(DataDictionaryService.class)
653:                        .getDataDictionary().getBusinessObjectEntry(
654:                                ObjectType.class.getName())
655:                        .getAttributeDefinition(
656:                                KFSConstants.GENERIC_CODE_PROPERTY_NAME)
657:                        .getShortLabel();
658:            }
659:
660:            /**
661:             * @return short label for object sub type code defined in data dictionary
662:             */
663:            public static String getObjectSubTypeCodeLabel() {
664:                return SpringContext.getBean(DataDictionaryService.class)
665:                        .getDataDictionary().getBusinessObjectEntry(
666:                                ObjSubTyp.class.getName())
667:                        .getAttributeDefinition(KFSPropertyConstants.CODE)
668:                        .getShortLabel();
669:            }
670:
671:            /**
672:             * @return short label for organization code defined in data dictionary
673:             */
674:            public static String getOrganizationCodeLabel() {
675:                return SpringContext.getBean(DataDictionaryService.class)
676:                        .getDataDictionary().getBusinessObjectEntry(
677:                                Org.class.getName()).getAttributeDefinition(
678:                                KFSPropertyConstants.ORGANIZATION_CODE)
679:                        .getShortLabel();
680:            }
681:
682:            /**
683:             * @return short label for fund group code defined in data dictionary
684:             */
685:            public static String getFundGroupCodeLabel() {
686:                return SpringContext.getBean(DataDictionaryService.class)
687:                        .getDataDictionary().getBusinessObjectEntry(
688:                                FundGroup.class.getName())
689:                        .getAttributeDefinition(KFSPropertyConstants.CODE)
690:                        .getShortLabel();
691:            }
692:
693:            /**
694:             * @return short label for sub fund group code defined in data dictionary
695:             */
696:            public static String getSubFundGroupCodeLabel() {
697:                return SpringContext.getBean(DataDictionaryService.class)
698:                        .getDataDictionary().getBusinessObjectEntry(
699:                                SubFundGroup.class.getName())
700:                        .getAttributeDefinition(
701:                                KFSPropertyConstants.SUB_FUND_GROUP_CODE)
702:                        .getShortLabel();
703:            }
704:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.