Source Code Cross Referenced for ObjectCodeGlobalRule.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » chart » 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.module.chart.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.module.chart.rules;
017:
018:        import java.util.List;
019:
020:        import org.kuali.core.bo.PersistableBusinessObject;
021:        import org.kuali.core.document.MaintenanceDocument;
022:        import org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase;
023:        import org.kuali.core.util.GlobalVariables;
024:        import org.kuali.core.util.ObjectUtils;
025:        import org.kuali.kfs.KFSConstants;
026:        import org.kuali.kfs.KFSKeyConstants;
027:        import org.kuali.kfs.KFSPropertyConstants;
028:        import org.kuali.kfs.context.SpringContext;
029:        import org.kuali.module.chart.bo.ObjLevel;
030:        import org.kuali.module.chart.bo.ObjectCode;
031:        import org.kuali.module.chart.bo.ObjectCodeGlobal;
032:        import org.kuali.module.chart.bo.ObjectCodeGlobalDetail;
033:        import org.kuali.module.chart.service.ObjectCodeService;
034:        import org.kuali.module.chart.service.ObjectLevelService;
035:
036:        /**
037:         * This class represents the business rules for the maintenance of {@link ObjectCodeGlobal} business objects
038:         */
039:        public class ObjectCodeGlobalRule extends MaintenanceDocumentRuleBase {
040:            private ObjectCodeGlobal objectCodeGlobal;
041:            private ObjectCodeService objectCodeService;
042:            private ObjectLevelService objectLevelService;
043:
044:            public ObjectCodeGlobalRule() {
045:                super ();
046:                setObjectCodeService(SpringContext
047:                        .getBean(ObjectCodeService.class));
048:                setObjectLevelService(SpringContext
049:                        .getBean(ObjectLevelService.class));
050:            }
051:
052:            /**
053:             * This method sets the convenience objects like objectCodeGlobal, so you have short and easy handles to the new and
054:             * old objects contained in the maintenance document. It also calls the BusinessObjectBase.refresh(), which will attempt to load
055:             * all sub-objects from the DB by their primary keys, if available.
056:             * 
057:             * @param document - the maintenanceDocument being evaluated
058:             */
059:            @Override
060:            public void setupConvenienceObjects() {
061:
062:                // setup ObjectCodeGlobal convenience objects,
063:                // make sure all possible sub-objects are populated
064:                objectCodeGlobal = (ObjectCodeGlobal) super .getNewBo();
065:
066:                // forces refreshes on all the sub-objects in the lists
067:                for (ObjectCodeGlobalDetail objectCodeGlobalDetail : objectCodeGlobal
068:                        .getObjectCodeGlobalDetails()) {
069:                    objectCodeGlobalDetail.refreshNonUpdateableReferences();
070:                }
071:            }
072:
073:            /**
074:             * This performs rules checks on document approve
075:             * <ul>
076:             * <li>{@link ObjectCodeGlobalRule#checkSimpleRulesAllLines()}</li>
077:             * </ul>
078:             * This rule fails on business rule failures
079:             * @see org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase#processCustomApproveDocumentBusinessRules(org.kuali.core.document.MaintenanceDocument)
080:             */
081:            @Override
082:            protected boolean processCustomApproveDocumentBusinessRules(
083:                    MaintenanceDocument document) {
084:                boolean success = true;
085:                setupConvenienceObjects();
086:                // check simple rules
087:                success &= checkSimpleRulesAllLines();
088:                return success;
089:            }
090:
091:            /**
092:             * This performs rules checks on document route
093:             * <ul>
094:             * <li>{@link ObjectCodeGlobalRule#checkSimpleRulesAllLines()}</li>
095:             * </ul>
096:             * This rule fails on business rule failures
097:             * @see org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase#processCustomRouteDocumentBusinessRules(org.kuali.core.document.MaintenanceDocument)
098:             */
099:            @Override
100:            protected boolean processCustomRouteDocumentBusinessRules(
101:                    MaintenanceDocument document) {
102:                boolean success = true;
103:                setupConvenienceObjects();
104:                // check simple rules
105:                success &= checkSimpleRulesAllLines();
106:                return success;
107:            }
108:
109:            /**
110:             * This performs rules checks on document save
111:             * <ul>
112:             * <li>{@link ObjectCodeGlobalRule#checkSimpleRulesAllLines()}</li>
113:             * </ul>
114:             * This rule does not fail on business rule failures
115:             * @see org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase#processCustomSaveDocumentBusinessRules(org.kuali.core.document.MaintenanceDocument)
116:             */
117:            @Override
118:            protected boolean processCustomSaveDocumentBusinessRules(
119:                    MaintenanceDocument document) {
120:                setupConvenienceObjects();
121:                // check simple rules
122:                checkSimpleRulesAllLines();
123:
124:                return true;
125:            }
126:
127:            /**
128:             * This method checks to make sure that each new {@link ObjectCodeGlobalDetail} has: 
129:             * <ul>
130:             * <li>valid chart of accounts code</li>
131:             * <li>valid fiscal year</li>
132:             * <li>unique identifiers (not currently implemented)</li>
133:             * </ul>
134:             * @see org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase#processCustomAddCollectionLineBusinessRules(org.kuali.core.document.MaintenanceDocument, java.lang.String, org.kuali.core.bo.PersistableBusinessObject)
135:             */
136:            @Override
137:            public boolean processCustomAddCollectionLineBusinessRules(
138:                    MaintenanceDocument document, String collectionName,
139:                    PersistableBusinessObject bo) {
140:                boolean success = true;
141:                if (bo instanceof  ObjectCodeGlobalDetail) {
142:                    ObjectCodeGlobalDetail detail = (ObjectCodeGlobalDetail) bo;
143:                    if (!checkEmptyValue(detail.getChartOfAccountsCode())) {
144:                        // put an error about chart code
145:                        GlobalVariables.getErrorMap().putError(
146:                                "chartOfAccountsCode",
147:                                KFSKeyConstants.ERROR_REQUIRED,
148:                                "Chart of Accounts Code");
149:                        success &= false;
150:                    }
151:                    if (!checkEmptyValue(detail.getUniversityFiscalYear())) {
152:                        // put an error about fiscal year
153:                        GlobalVariables.getErrorMap().putError(
154:                                "universityFiscalYear",
155:                                KFSKeyConstants.ERROR_REQUIRED,
156:                                "University Fiscal Year");
157:                        success &= false;
158:                    }
159:                    if (!checkUniqueIdentifiers(detail)) {
160:                        // TODO: put an error about unique identifier fields must not exist more than once.
161:                        success &= false;
162:                    }
163:                    // both keys are present and satisfy the unique identifiers requirement, go ahead and proces the rest of the rules
164:                    if (success) {
165:                        success &= checkObjectCodeDetails(detail);
166:                    }
167:
168:                }
169:                return success;
170:            }
171:
172:            /**
173:             * 
174:             * This method (will)put an error about unique identifier fields must not exist more than once.
175:             * @param dtl
176:             * @return true (not currently implemented fully)
177:             */
178:            private boolean checkUniqueIdentifiers(ObjectCodeGlobalDetail dtl) {
179:                boolean success = true;
180:                return success;
181:
182:            }
183:
184:            /**
185:             * 
186:             * This checks the following conditions:
187:             * <ul>
188:             * <li>{@link ObjectCodeGlobalRule#checkObjectLevelCode(ObjectCodeGlobal, ObjectCodeGlobalDetail, int, boolean)} </li>
189:             * <li>{@link ObjectCodeGlobalRule#checkNextYearObjectCode(ObjectCodeGlobal, ObjectCodeGlobalDetail, int, boolean)} </li>
190:             * <li>{@link ObjectCodeGlobalRule#checkReportsToObjectCode(ObjectCodeGlobal, ObjectCodeGlobalDetail, int, boolean)}</li>
191:             * </ul>
192:             * @param dtl
193:             * @return true if sub-rules succeed
194:             */
195:            public boolean checkObjectCodeDetails(ObjectCodeGlobalDetail dtl) {
196:                boolean success = true;
197:                int originalErrorCount = GlobalVariables.getErrorMap()
198:                        .getErrorCount();
199:                getDictionaryValidationService().validateBusinessObject(dtl);
200:                dtl.refreshNonUpdateableReferences();
201:                // here is where we need our checks for level code nd next year object code
202:                success &= checkObjectLevelCode(objectCodeGlobal, dtl, 0, true);
203:                success &= checkNextYearObjectCode(objectCodeGlobal, dtl, 0,
204:                        true);
205:                success &= checkReportsToObjectCode(objectCodeGlobal, dtl, 0,
206:                        true);
207:                success &= GlobalVariables.getErrorMap().getErrorCount() == originalErrorCount;
208:
209:                return success;
210:            }
211:
212:            /**
213:             * This method checks that the reports to object code input on the top level of the global document is valid for a given chart's
214:             * reportToChart in the detail section
215:             * 
216:             * @param dtl
217:             * @return true if the reports to object is valid for the given reports to chart
218:             */
219:            private boolean checkReportsToObjectCode(
220:                    ObjectCodeGlobal objectCodeGlobal,
221:                    ObjectCodeGlobalDetail dtl, int lineNum, boolean add) {
222:                boolean success = true;
223:                String errorPath = KFSConstants.EMPTY_STRING;
224:                if (checkEmptyValue(objectCodeGlobal
225:                        .getReportsToFinancialObjectCode())) {
226:                    // objectCodeGlobal.refreshReferenceObject("reportsToFinancialObject");
227:                    String reportsToObjectCode = objectCodeGlobal
228:                            .getReportsToFinancialObjectCode();
229:                    String reportsToChartCode = dtl.getChartOfAccounts()
230:                            .getReportsToChartOfAccountsCode();
231:                    Integer fiscalYear = dtl.getUniversityFiscalYear();
232:
233:                    // verify that this combination exists in the db
234:                    ObjectCode objCode = objectCodeService
235:                            .getByPrimaryId(fiscalYear, reportsToChartCode,
236:                                    reportsToObjectCode);
237:                    if (ObjectUtils.isNull(objCode)) {
238:                        success &= false;
239:                        String[] errorParameters = { reportsToObjectCode,
240:                                reportsToChartCode, fiscalYear.toString() };
241:                        if (add) {
242:                            errorPath = KFSConstants.MAINTENANCE_ADD_PREFIX
243:                                    + KFSPropertyConstants.OBJECT_CODE_GLOBAL_DETAILS
244:                                    + "." + "chartOfAccountsCode";
245:                            putFieldError(
246:                                    errorPath,
247:                                    KFSKeyConstants.ERROR_DOCUMENT_GLOBAL_OBJECTMAINT_INVALID_RPTS_TO_OBJ_CODE,
248:                                    errorParameters);
249:                        } else {
250:                            errorPath = KFSPropertyConstants.OBJECT_CODE_GLOBAL_DETAILS
251:                                    + "["
252:                                    + lineNum
253:                                    + "]."
254:                                    + "chartOfAccountsCode";
255:                            putFieldError(
256:                                    errorPath,
257:                                    KFSKeyConstants.ERROR_DOCUMENT_GLOBAL_OBJECTMAINT_INVALID_RPTS_TO_OBJ_CODE,
258:                                    errorParameters);
259:                        }
260:                    }
261:                    return success;
262:
263:                } else {
264:                    GlobalVariables.getErrorMap().putError(
265:                            "reportsToFinancialObjectCode",
266:                            KFSKeyConstants.ERROR_REQUIRED,
267:                            "Reports to Object Code");
268:                    success &= false;
269:                }
270:
271:                return success;
272:            }
273:
274:            /**
275:             * This method checks that the next year object code specified in the change document is a valid object code for a given chart
276:             * and year
277:             * 
278:             * @param dtl
279:             * @return false if this object code doesn't exist in the next fiscal year
280:             */
281:            private boolean checkNextYearObjectCode(
282:                    ObjectCodeGlobal objectCodeGlobal,
283:                    ObjectCodeGlobalDetail dtl, int lineNum, boolean add) {
284:                boolean success = true;
285:                String errorPath = KFSConstants.EMPTY_STRING;
286:                // first check to see if the Next Year object code was filled in
287:                if (checkEmptyValue(objectCodeGlobal
288:                        .getNextYearFinancialObjectCode())) {
289:                    // then this value must also exist as a regular financial object code currently
290:                    ObjectCode objCode = objectCodeService.getByPrimaryId(dtl
291:                            .getUniversityFiscalYear(), dtl
292:                            .getChartOfAccountsCode(), objectCodeGlobal
293:                            .getNextYearFinancialObjectCode());
294:                    if (ObjectUtils.isNull(objCode)) {
295:                        success &= false;
296:                        String[] errorParameters = {
297:                                objectCodeGlobal
298:                                        .getNextYearFinancialObjectCode(),
299:                                dtl.getChartOfAccountsCode(),
300:                                dtl.getUniversityFiscalYear().toString() };
301:                        if (add) {
302:                            errorPath = KFSConstants.MAINTENANCE_ADD_PREFIX
303:                                    + KFSPropertyConstants.OBJECT_CODE_GLOBAL_DETAILS
304:                                    + "." + "chartOfAccountsCode";
305:                            putFieldError(
306:                                    errorPath,
307:                                    KFSKeyConstants.ERROR_DOCUMENT_GLOBAL_OBJECTMAINT_INVALID_NEXT_YEAR_OBJ_CODE,
308:                                    errorParameters);
309:                        } else {
310:                            errorPath = KFSPropertyConstants.OBJECT_CODE_GLOBAL_DETAILS
311:                                    + "["
312:                                    + lineNum
313:                                    + "]."
314:                                    + "chartOfAccountsCode";
315:                            putFieldError(
316:                                    errorPath,
317:                                    KFSKeyConstants.ERROR_DOCUMENT_GLOBAL_OBJECTMAINT_INVALID_NEXT_YEAR_OBJ_CODE,
318:                                    errorParameters);
319:                        }
320:                    }
321:                    return success;
322:                }
323:
324:                return success;
325:            }
326:
327:            /**
328:             * This method checks that the object level code from the object code change document actually exists for the chart object
329:             * specified in the detail
330:             * 
331:             * @param dtl
332:             * @return false if object level doesn't exist for the chart, and level code filled in
333:             */
334:            private boolean checkObjectLevelCode(
335:                    ObjectCodeGlobal objectCodeGlobal,
336:                    ObjectCodeGlobalDetail dtl, int lineNum, boolean add) {
337:                boolean success = true;
338:                String errorPath = KFSConstants.EMPTY_STRING;
339:                // first check to see if the level code is filled in
340:                if (checkEmptyValue(objectCodeGlobal
341:                        .getFinancialObjectLevelCode())) {
342:                    ObjLevel objLevel = objectLevelService.getByPrimaryId(dtl
343:                            .getChartOfAccountsCode(), objectCodeGlobal
344:                            .getFinancialObjectLevelCode());
345:                    if (ObjectUtils.isNull(objLevel)) {
346:                        success &= false;
347:                        String[] errorParameters = {
348:                                objectCodeGlobal.getFinancialObjectLevelCode(),
349:                                dtl.getChartOfAccountsCode() };
350:                        if (add) {
351:                            errorPath = KFSConstants.MAINTENANCE_ADD_PREFIX
352:                                    + KFSPropertyConstants.OBJECT_CODE_GLOBAL_DETAILS
353:                                    + "." + "chartOfAccountsCode";
354:                            putFieldError(
355:                                    errorPath,
356:                                    KFSKeyConstants.ERROR_DOCUMENT_GLOBAL_OBJECTMAINT_INVALID_OBJ_LEVEL,
357:                                    errorParameters);
358:                        } else {
359:                            errorPath = KFSPropertyConstants.OBJECT_CODE_GLOBAL_DETAILS
360:                                    + "["
361:                                    + lineNum
362:                                    + "]."
363:                                    + "chartOfAccountsCode";
364:                            putFieldError(
365:                                    errorPath,
366:                                    KFSKeyConstants.ERROR_DOCUMENT_GLOBAL_OBJECTMAINT_INVALID_OBJ_LEVEL,
367:                                    errorParameters);
368:                        }
369:                    }
370:                    return success;
371:
372:                } else {
373:                    GlobalVariables.getErrorMap()
374:                            .putError("financialObjectLevelCode",
375:                                    KFSKeyConstants.ERROR_REQUIRED,
376:                                    "Object Level Code");
377:                    success &= false;
378:                }
379:                return success;
380:            }
381:
382:            /**
383:             * This method checks the simple rules for all lines at once and gets called on save, submit, etc. but not on add
384:             * 
385:             * <ul>
386:             * <li>{@link ObjectCodeGlobalRule#checkFiscalYearAllLines(ObjectCodeGlobal)} </li>
387:             * <li>{@link ObjectCodeGlobalRule#checkChartAllLines(ObjectCodeGlobal)} </li>
388:             * <li>{@link ObjectCodeGlobalRule#checkObjectLevelCodeAllLines(ObjectCodeGlobal)} </li>
389:             * <li>{@link ObjectCodeGlobalRule#checkNextYearObjectCodeAllLines(ObjectCodeGlobal)} </li>
390:             * <li>{@link ObjectCodeGlobalRule#checkReportsToObjectCodeAllLines(ObjectCodeGlobal)} </li>
391:             * </ul>
392:             * @return
393:             */
394:            protected boolean checkSimpleRulesAllLines() {
395:                boolean success = true;
396:                // check if there are any object codes and accounts, if either fails this should fail
397:                if (!checkForObjectCodeGlobalDetails(objectCodeGlobal
398:                        .getObjectCodeGlobalDetails())) {
399:                    success = false;
400:                } else {
401:                    // check object codes
402:                    success &= checkFiscalYearAllLines(objectCodeGlobal);
403:
404:                    // check chart code
405:                    success &= checkChartAllLines(objectCodeGlobal);
406:
407:                    // check object level code
408:                    success &= checkObjectLevelCodeAllLines(objectCodeGlobal);
409:
410:                    // check next year object code
411:                    success &= checkNextYearObjectCodeAllLines(objectCodeGlobal);
412:
413:                    // check reports to object code
414:                    success &= checkReportsToObjectCodeAllLines(objectCodeGlobal);
415:
416:                }
417:                return success;
418:            }
419:
420:            /**
421:             * 
422:             * This checks to make sure that there is at least one {@link ObjectCodeGlobalDetail} in the collection
423:             * @param objectCodeGlobalDetails
424:             * @return false if the collection is empty or null
425:             */
426:            protected boolean checkForObjectCodeGlobalDetails(
427:                    List<ObjectCodeGlobalDetail> objectCodeGlobalDetails) {
428:                if (objectCodeGlobalDetails == null
429:                        || objectCodeGlobalDetails.size() == 0) {
430:                    putFieldError(
431:                            KFSConstants.MAINTENANCE_ADD_PREFIX
432:                                    + KFSPropertyConstants.OBJECT_CODE_GLOBAL_DETAILS
433:                                    + "."
434:                                    + KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE,
435:                            KFSKeyConstants.ERROR_DOCUMENT_GLOBAL_OBJECTMAINT_NO_CHART_FISCAL_YEAR);
436:                    return false;
437:                }
438:                return true;
439:            }
440:
441:            /**
442:             * 
443:             * This method calls {@link ObjectCodeGlobalRule#checkFiscalYear(ObjectCodeGlobal, ObjectCodeGlobalDetail, int, boolean)} on each detail object
444:             * @param objectCodeGlobal
445:             * @return true if all lines pass
446:             */
447:            protected boolean checkFiscalYearAllLines(
448:                    ObjectCodeGlobal objectCodeGlobal) {
449:                boolean success = true;
450:                int i = 0;
451:                for (ObjectCodeGlobalDetail objectCodeGlobalDetail : objectCodeGlobal
452:                        .getObjectCodeGlobalDetails()) {
453:
454:                    // check fiscal year first
455:                    success &= checkFiscalYear(objectCodeGlobal,
456:                            objectCodeGlobalDetail, i, false);
457:
458:                    // increment counter for sub object changes list
459:                    i++;
460:                }
461:
462:                return success;
463:            }
464:
465:            /**
466:             * 
467:             * This method calls {@link ObjectCodeGlobalRule#checkChartOnObjCodeDetails(ObjectCodeGlobal, ObjectCodeGlobalDetail, int, boolean)} on each detail object
468:             * 
469:             * @param ocChangeDocument
470:             * @return true if all lines pass
471:             */
472:            protected boolean checkChartAllLines(
473:                    ObjectCodeGlobal ocChangeDocument) {
474:                boolean success = true;
475:                int i = 0;
476:                for (ObjectCodeGlobalDetail objectCodeGlobalDetail : ocChangeDocument
477:                        .getObjectCodeGlobalDetails()) {
478:
479:                    // check chart
480:                    success &= checkChartOnObjCodeDetails(ocChangeDocument,
481:                            objectCodeGlobalDetail, i, false);
482:                    // increment counter for sub object changes list
483:                    i++;
484:                }
485:
486:                return success;
487:            }
488:
489:            /**
490:             * 
491:             * This method calls {@link ObjectCodeGlobalRule#checkReportsToObjectCode(ObjectCodeGlobal, ObjectCodeGlobalDetail, int, boolean)} on each detail object
492:             * 
493:             * @param objectCodeGlobalDocument2
494:             * @return true if all lines pass
495:             */
496:            private boolean checkReportsToObjectCodeAllLines(
497:                    ObjectCodeGlobal objectCodeGlobalDocument2) {
498:                boolean success = true;
499:                int i = 0;
500:                for (ObjectCodeGlobalDetail objectCodeGlobalDetail : objectCodeGlobal
501:                        .getObjectCodeGlobalDetails()) {
502:
503:                    // check fiscal year first
504:                    success &= checkReportsToObjectCode(objectCodeGlobal,
505:                            objectCodeGlobalDetail, i, false);
506:
507:                    // increment counter for sub object changes list
508:                    i++;
509:                }
510:
511:                return success;
512:            }
513:
514:            /**
515:             * 
516:             * This method calls {@link ObjectCodeGlobalRule#checkNextYearObjectCode(ObjectCodeGlobal, ObjectCodeGlobalDetail, int, boolean)} on each detail object
517:             * 
518:             * @param objectCodeGlobalDocument2
519:             * @return true if all lines pass
520:             */
521:            private boolean checkNextYearObjectCodeAllLines(
522:                    ObjectCodeGlobal objectCodeGlobalDocument2) {
523:                boolean success = true;
524:                int i = 0;
525:                for (ObjectCodeGlobalDetail objectCodeGlobalDetail : objectCodeGlobal
526:                        .getObjectCodeGlobalDetails()) {
527:
528:                    // check fiscal year first
529:                    success &= checkNextYearObjectCode(objectCodeGlobal,
530:                            objectCodeGlobalDetail, i, false);
531:
532:                    // increment counter for sub object changes list
533:                    i++;
534:                }
535:
536:                return success;
537:            }
538:
539:            /**
540:             * 
541:             * This method calls {@link ObjectCodeGlobalRule#checkObjectLevelCode(ObjectCodeGlobal, ObjectCodeGlobalDetail, int, boolean)} on each detail object
542:             * 
543:             * @param objectCodeGlobalDocument2
544:             * @return true if all lines pass
545:             */
546:            private boolean checkObjectLevelCodeAllLines(
547:                    ObjectCodeGlobal objectCodeGlobalDocument2) {
548:                boolean success = true;
549:                int i = 0;
550:                for (ObjectCodeGlobalDetail objectCodeGlobalDetail : objectCodeGlobal
551:                        .getObjectCodeGlobalDetails()) {
552:
553:                    // check fiscal year first
554:                    success &= checkObjectLevelCode(objectCodeGlobal,
555:                            objectCodeGlobalDetail, i, false);
556:
557:                    // increment counter for sub object changes list
558:                    i++;
559:                }
560:
561:                return success;
562:            }
563:
564:            /**
565:             * 
566:             * This checks to make sure that the fiscal year has been entered
567:             * @param objectCodeGlobal
568:             * @param objectCodeGlobalDetail
569:             * @param lineNum
570:             * @param add
571:             * @return false if no fiscal year value
572:             */
573:            protected boolean checkFiscalYear(
574:                    ObjectCodeGlobal objectCodeGlobal,
575:                    ObjectCodeGlobalDetail objectCodeGlobalDetail, int lineNum,
576:                    boolean add) {
577:                boolean success = true;
578:                String errorPath = KFSConstants.EMPTY_STRING;
579:                // first must have an actual fiscal year
580:                if (objectCodeGlobalDetail.getUniversityFiscalYear() == null) {
581:                    if (add) {
582:                        errorPath = KFSConstants.MAINTENANCE_ADD_PREFIX
583:                                + KFSPropertyConstants.OBJECT_CODE_GLOBAL_DETAILS
584:                                + "." + "universityFiscalYear";
585:                        putFieldError(
586:                                errorPath,
587:                                KFSKeyConstants.ERROR_DOCUMENT_GLOBAL_OBJECTMAINT_FISCAL_YEAR_MUST_EXIST);
588:                    } else {
589:                        errorPath = KFSPropertyConstants.OBJECT_CODE_GLOBAL_DETAILS
590:                                + "[" + lineNum + "]." + "universityFiscalYear";
591:                        putFieldError(
592:                                errorPath,
593:                                KFSKeyConstants.ERROR_DOCUMENT_GLOBAL_OBJECTMAINT_FISCAL_YEAR_MUST_EXIST);
594:                    }
595:                    success &= false;
596:                    return success;
597:                }
598:
599:                return success;
600:            }
601:
602:            /**
603:             * 
604:             * This checks to make sure that the chart of accounts for the detail object has been filled in
605:             * @param objectCodeGlobal
606:             * @param objectCodeGlobalDetail
607:             * @param lineNum
608:             * @param add
609:             * @return false if chart of accounts code null
610:             */
611:            protected boolean checkChartOnObjCodeDetails(
612:                    ObjectCodeGlobal objectCodeGlobal,
613:                    ObjectCodeGlobalDetail objectCodeGlobalDetail, int lineNum,
614:                    boolean add) {
615:                boolean success = true;
616:                String errorPath = KFSConstants.EMPTY_STRING;
617:                // first must have an actual fiscal year
618:                if (objectCodeGlobalDetail.getChartOfAccounts() == null) {
619:                    if (add) {
620:                        errorPath = KFSConstants.MAINTENANCE_ADD_PREFIX
621:                                + KFSPropertyConstants.OBJECT_CODE_GLOBAL_DETAILS
622:                                + "." + "chartOfAccountsCode";
623:                        putFieldError(
624:                                errorPath,
625:                                KFSKeyConstants.ERROR_DOCUMENT_GLOBAL_OBJECTMAINT_CHART_MUST_EXIST);
626:                    } else {
627:                        errorPath = KFSPropertyConstants.OBJECT_CODE_GLOBAL_DETAILS
628:                                + "[" + lineNum + "]." + "chartOfAccountsCode";
629:                        putFieldError(
630:                                errorPath,
631:                                KFSKeyConstants.ERROR_DOCUMENT_GLOBAL_OBJECTMAINT_CHART_MUST_EXIST);
632:                    }
633:                    success &= false;
634:                    return success;
635:                }
636:
637:                return success;
638:            }
639:
640:            private void setObjectCodeService(
641:                    ObjectCodeService objectCodeService) {
642:                this .objectCodeService = objectCodeService;
643:
644:            }
645:
646:            private void setObjectLevelService(
647:                    ObjectLevelService objectLevelService) {
648:                this.objectLevelService = objectLevelService;
649:
650:            }
651:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.