Source Code Cross Referenced for TransactionFieldValidator.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » labor » 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.labor.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.labor.rules;
017:
018:        import java.util.List;
019:
020:        import org.apache.commons.lang.ArrayUtils;
021:        import org.apache.commons.lang.StringUtils;
022:        import org.kuali.core.util.KualiDecimal;
023:        import org.kuali.kfs.KFSConstants;
024:        import org.kuali.kfs.KFSKeyConstants;
025:        import org.kuali.module.gl.util.Message;
026:        import org.kuali.module.labor.LaborKeyConstants;
027:        import org.kuali.module.labor.bo.LaborTransaction;
028:        import org.kuali.module.labor.util.MessageBuilder;
029:
030:        /**
031:         * This class provides a set of utilities that can be used to validate a transaction in the field level.
032:         */
033:        public class TransactionFieldValidator {
034:
035:            /**
036:             * Checks if the given transaction contains valid university fiscal year
037:             * 
038:             * @param transaction the given transaction
039:             * @return null if the university fiscal year is valid; otherwise, return error message
040:             */
041:            public static Message checkUniversityFiscalYear(
042:                    LaborTransaction transaction) {
043:                Integer fiscalYear = transaction.getUniversityFiscalYear();
044:                if (fiscalYear == null) {
045:                    return MessageBuilder.buildErrorMessage(
046:                            KFSKeyConstants.ERROR_UNIV_FISCAL_YR_NOT_FOUND,
047:                            Message.TYPE_FATAL);
048:                } else if (transaction.getOption() == null) {
049:                    return MessageBuilder.buildErrorMessage(
050:                            KFSKeyConstants.ERROR_UNIV_FISCAL_YR_NOT_FOUND,
051:                            fiscalYear.toString(), Message.TYPE_FATAL);
052:                }
053:                return null;
054:            }
055:
056:            /**
057:             * Checks if the given transaction contains valid char of accounts code
058:             * 
059:             * @param transaction the given transaction
060:             * @return null if the char of accounts code is valid; otherwise, return error message
061:             */
062:            public static Message checkChartOfAccountsCode(
063:                    LaborTransaction transaction) {
064:                String chartOfAccountsCode = transaction
065:                        .getChartOfAccountsCode();
066:                if (StringUtils.isBlank(chartOfAccountsCode)
067:                        || transaction.getChart() == null) {
068:                    return MessageBuilder.buildErrorMessage(
069:                            KFSKeyConstants.ERROR_CHART_NOT_FOUND,
070:                            chartOfAccountsCode, Message.TYPE_FATAL);
071:                }
072:
073:                if (!transaction.getChart()
074:                        .isFinChartOfAccountActiveIndicator()) {
075:                    return MessageBuilder.buildErrorMessage(
076:                            KFSKeyConstants.ERROR_CHART_NOT_ACTIVE,
077:                            chartOfAccountsCode, Message.TYPE_FATAL);
078:                }
079:                return null;
080:            }
081:
082:            /**
083:             * Checks if the given transaction contains valid account number
084:             * 
085:             * @param transaction the given transaction
086:             * @return null if the account number is valid; otherwise, return error message
087:             */
088:            public static Message checkAccountNumber(
089:                    LaborTransaction transaction) {
090:                String accountNumber = transaction.getAccountNumber();
091:                if (StringUtils.isBlank(accountNumber)
092:                        || transaction.getAccount() == null) {
093:                    String chartOfAccountsCode = transaction
094:                            .getChartOfAccountsCode();
095:                    String accountKey = chartOfAccountsCode + "-"
096:                            + accountNumber;
097:                    return MessageBuilder.buildErrorMessage(
098:                            KFSKeyConstants.ERROR_ACCOUNT_NOT_FOUND,
099:                            accountKey, Message.TYPE_FATAL);
100:                }
101:                return null;
102:            }
103:
104:            /**
105:             * Checks if the given transaction contains valid sub account number
106:             * 
107:             * @param transaction the given transaction
108:             * @return null if the sub account number is valid; otherwise, return error message
109:             */
110:            public static Message checkSubAccountNumber(
111:                    LaborTransaction transaction) {
112:                return checkSubAccountNumber(transaction, null);
113:            }
114:
115:            /**
116:             * Checks if the given transaction contains valid sub account number
117:             * 
118:             * @param transaction the given transaction
119:             * @param exclusiveDocumentTypeCode inactive sub account can be OK if the document type of the given transaction is exclusiveDocumentTypeCode 
120:             * @return null if the sub account number is valid; otherwise, return error message
121:             */
122:            public static Message checkSubAccountNumber(
123:                    LaborTransaction transaction,
124:                    String exclusiveDocumentTypeCode) {
125:                String subAccountNumber = transaction.getSubAccountNumber();
126:                String chartOfAccountsCode = transaction
127:                        .getChartOfAccountsCode();
128:                String accountNumber = transaction.getAccountNumber();
129:                String documentTypeCode = transaction
130:                        .getFinancialDocumentTypeCode();
131:
132:                String subAccountKey = chartOfAccountsCode + "-"
133:                        + accountNumber + "-" + subAccountNumber;
134:                if (StringUtils.isBlank(subAccountNumber)) {
135:                    return MessageBuilder.buildErrorMessage(
136:                            KFSKeyConstants.ERROR_SUB_ACCOUNT_NOT_FOUND,
137:                            subAccountKey, Message.TYPE_FATAL);
138:                }
139:
140:                if (!KFSConstants.getDashSubAccountNumber().equals(
141:                        subAccountNumber)) {
142:                    if (transaction.getSubAccount() == null) {
143:                        return MessageBuilder.buildErrorMessage(
144:                                KFSKeyConstants.ERROR_SUB_ACCOUNT_NOT_FOUND,
145:                                subAccountKey, Message.TYPE_FATAL);
146:                    }
147:
148:                    if (!StringUtils.equals(documentTypeCode,
149:                            exclusiveDocumentTypeCode)) {
150:                        if (!transaction.getSubAccount()
151:                                .isSubAccountActiveIndicator()) {
152:                            return MessageBuilder
153:                                    .buildErrorMessage(
154:                                            KFSKeyConstants.ERROR_SUB_ACCOUNT_NOT_ACTIVE,
155:                                            subAccountKey, Message.TYPE_FATAL);
156:                        }
157:                    }
158:                }
159:                return null;
160:            }
161:
162:            /**
163:             * Checks if the given transaction contains valid account number
164:             * 
165:             * @param transaction the given transaction
166:             * @return null if the account number is valid; otherwise, return error message
167:             */
168:            public static Message checkFinancialObjectCode(
169:                    LaborTransaction transaction) {
170:                String objectCode = transaction.getFinancialObjectCode();
171:                if (StringUtils.isBlank(objectCode)) {
172:                    return MessageBuilder.buildErrorMessage(
173:                            KFSKeyConstants.ERROR_OBJECT_CODE_EMPTY,
174:                            Message.TYPE_FATAL);
175:                }
176:
177:                Integer fiscalYear = transaction.getUniversityFiscalYear();
178:                String chartOfAccountsCode = transaction
179:                        .getChartOfAccountsCode();
180:                String objectCodeKey = fiscalYear + "-" + chartOfAccountsCode
181:                        + "-" + objectCode;
182:                if (transaction.getFinancialObject() == null) {
183:                    return MessageBuilder.buildErrorMessage(
184:                            KFSKeyConstants.ERROR_OBJECT_CODE_NOT_FOUND,
185:                            objectCodeKey, Message.TYPE_FATAL);
186:                }
187:
188:                if (!transaction.getFinancialObject().isActive()) {
189:                    return MessageBuilder.buildErrorMessage(
190:                            KFSKeyConstants.ERROR_OBJECT_CODE_NOT_ACTIVE,
191:                            objectCodeKey, Message.TYPE_FATAL);
192:                }
193:                return null;
194:            }
195:
196:            /**
197:             * Checks if the given transaction contains valid sub object code
198:             * 
199:             * @param transaction the given transaction
200:             * @return null if the sub object code is valid; otherwise, return error message
201:             */
202:            public static Message checkFinancialSubObjectCode(
203:                    LaborTransaction transaction) {
204:                Integer fiscalYear = transaction.getUniversityFiscalYear();
205:                String chartOfAccountsCode = transaction
206:                        .getChartOfAccountsCode();
207:                String objectCode = transaction.getFinancialObjectCode();
208:                String subObjectCode = transaction.getFinancialSubObjectCode();
209:
210:                String subObjectCodeKey = fiscalYear + "-"
211:                        + chartOfAccountsCode + "-" + objectCode + "-"
212:                        + subObjectCode;
213:                if (StringUtils.isBlank(subObjectCode)) {
214:                    return MessageBuilder.buildErrorMessage(
215:                            KFSKeyConstants.ERROR_SUB_OBJECT_CODE_NOT_BE_NULL,
216:                            subObjectCodeKey, Message.TYPE_FATAL);
217:                }
218:
219:                if (!KFSConstants.getDashFinancialSubObjectCode().equals(
220:                        subObjectCode)) {
221:                    if (transaction.getFinancialSubObject() == null) {
222:                        return MessageBuilder
223:                                .buildErrorMessage(
224:                                        KFSKeyConstants.ERROR_SUB_OBJECT_CODE_NOT_BE_NULL,
225:                                        subObjectCodeKey, Message.TYPE_FATAL);
226:                    }
227:                }
228:                return null;
229:            }
230:
231:            /**
232:             * Checks if the given transaction contains valid balance type code
233:             * 
234:             * @param transaction the given transaction
235:             * @return null if the balance type code is valid; otherwise, return error message
236:             */
237:            public static Message checkFinancialBalanceTypeCode(
238:                    LaborTransaction transaction) {
239:                String balanceTypeCode = transaction
240:                        .getFinancialBalanceTypeCode();
241:                if (StringUtils.isBlank(balanceTypeCode)
242:                        || transaction.getBalanceType() == null) {
243:                    return MessageBuilder.buildErrorMessage(
244:                            KFSKeyConstants.ERROR_BALANCE_TYPE_NOT_FOUND,
245:                            balanceTypeCode, Message.TYPE_FATAL);
246:                }
247:                return null;
248:            }
249:
250:            /**
251:             * Checks if the given transaction contains valid object type code
252:             * 
253:             * @param transaction the given transaction
254:             * @return null if the object type code is valid; otherwise, return error message
255:             */
256:            public static Message checkFinancialObjectTypeCode(
257:                    LaborTransaction transaction) {
258:                String objectTypeCode = transaction
259:                        .getFinancialObjectTypeCode();
260:                if (StringUtils.isBlank(objectTypeCode)
261:                        || transaction.getObjectType() == null) {
262:                    return MessageBuilder.buildErrorMessage(
263:                            KFSKeyConstants.ERROR_OBJECT_TYPE_NOT_FOUND,
264:                            objectTypeCode, Message.TYPE_FATAL);
265:                }
266:                return null;
267:            }
268:
269:            /**
270:             * Checks if the given transaction contains university fiscal period code
271:             * 
272:             * @param transaction the given transaction
273:             * @return null if the university fiscal period code is valid; otherwise, return error message
274:             */
275:            public static Message checkUniversityFiscalPeriodCode(
276:                    LaborTransaction transaction) {
277:                String fiscalPeriodCode = transaction
278:                        .getUniversityFiscalPeriodCode();
279:                if (StringUtils.isBlank(fiscalPeriodCode)) {
280:                    return MessageBuilder.buildErrorMessage(
281:                            KFSKeyConstants.ERROR_ACCOUNTING_PERIOD_NOT_FOUND,
282:                            fiscalPeriodCode, Message.TYPE_FATAL);
283:                }
284:                return null;
285:            }
286:
287:            /**
288:             * Checks if the given transaction contains document type code
289:             * 
290:             * @param transaction the given transaction
291:             * @return null if the document type code is valid; otherwise, return error message
292:             */
293:            public static Message checkFinancialDocumentTypeCode(
294:                    LaborTransaction transaction) {
295:                String documentTypeCode = transaction
296:                        .getFinancialDocumentTypeCode();
297:                if (StringUtils.isBlank(documentTypeCode)
298:                        || transaction.getDocumentType() == null) {
299:                    return MessageBuilder.buildErrorMessage(
300:                            KFSKeyConstants.ERROR_DOCUMENT_TYPE_NOT_FOUND,
301:                            documentTypeCode, Message.TYPE_FATAL);
302:                }
303:                return null;
304:            }
305:
306:            /**
307:             * Checks if the given transaction contains document number
308:             * 
309:             * @param transaction the given transaction
310:             * @return null if the document number is valid; otherwise, return error message
311:             */
312:            public static Message checkFinancialDocumentNumber(
313:                    LaborTransaction transaction) {
314:                String documentNumber = transaction.getDocumentNumber();
315:                if (StringUtils.isBlank(documentNumber)) {
316:                    return MessageBuilder.buildErrorMessage(
317:                            KFSKeyConstants.ERROR_DOCUMENT_NUMBER_REQUIRED,
318:                            Message.TYPE_FATAL);
319:                }
320:                return null;
321:            }
322:
323:            /**
324:             * Checks if the given transaction contains transaction sequence number
325:             * 
326:             * @param transaction the given transaction
327:             * @return null if the transaction sequence number is valid; otherwise, return error message
328:             */
329:            public static Message checkTransactionLedgerEntrySequenceNumber(
330:                    LaborTransaction transaction) {
331:                Integer sequenceNumber = transaction
332:                        .getTransactionLedgerEntrySequenceNumber();
333:                if (sequenceNumber == null) {
334:                    return MessageBuilder.buildErrorMessage(
335:                            KFSKeyConstants.ERROR_SEQUENCE_NUMBER_NOT_BE_NULL,
336:                            Message.TYPE_FATAL);
337:                }
338:                return null;
339:            }
340:
341:            /**
342:             * Checks if the given transaction contains debit credit code
343:             * 
344:             * @param transaction the given transaction
345:             * @return null if the debit credit code is valid; otherwise, return error message
346:             */
347:            public static Message checkTransactionDebitCreditCode(
348:                    LaborTransaction transaction) {
349:                String[] validDebitCreditCode = { KFSConstants.GL_BUDGET_CODE,
350:                        KFSConstants.GL_CREDIT_CODE, KFSConstants.GL_DEBIT_CODE };
351:                String debitCreditCode = transaction
352:                        .getTransactionDebitCreditCode();
353:                if (!ArrayUtils.contains(validDebitCreditCode, debitCreditCode)) {
354:                    return MessageBuilder
355:                            .buildErrorMessage(
356:                                    KFSKeyConstants.ERROR_DEDIT_CREDIT_CODE_NOT_BE_NULL,
357:                                    Message.TYPE_FATAL);
358:                }
359:                return null;
360:            }
361:
362:            /**
363:             * Checks if the given transaction contains system origination code
364:             * 
365:             * @param transaction the given transaction
366:             * @return null if the system origination code is valid; otherwise, return error message
367:             */
368:            public static Message checkFinancialSystemOriginationCode(
369:                    LaborTransaction transaction) {
370:                String originationCode = transaction
371:                        .getFinancialSystemOriginationCode();
372:                if (StringUtils.isBlank(originationCode)) {
373:                    return MessageBuilder.buildErrorMessage(
374:                            KFSKeyConstants.ERROR_ORIGIN_CODE_NOT_FOUND,
375:                            Message.TYPE_FATAL);
376:                }
377:                return null;
378:            }
379:
380:            /**
381:             * Checks if the given transaction contains the posteable period code
382:             * 
383:             * @param transaction the given transaction
384:             * @param unpostableperidCodes the list of unpostable period code
385:             * @return null if the perid code of the transaction is not in unpostableperidCodes; otherwise, return error message
386:             */
387:            public static Message checkPostablePeridCode(
388:                    LaborTransaction transaction,
389:                    List<String> unpostableperidCodes) {
390:                String periodCode = transaction.getUniversityFiscalPeriodCode();
391:                if (unpostableperidCodes.contains(periodCode)) {
392:                    return MessageBuilder.buildErrorMessage(
393:                            LaborKeyConstants.ERROR_UNPOSTABLE_PERIOD_CODE,
394:                            periodCode, Message.TYPE_FATAL);
395:                }
396:                return null;
397:            }
398:
399:            /**
400:             * Checks if the given transaction contains the posteable balance type code
401:             * 
402:             * @param transaction the given transaction
403:             * @param unpostableBalanceTypeCodes the list of unpostable balance type codes
404:             * @return null if the balance type code of the transaction is not in unpostableBalanceTypeCodes; otherwise, return error
405:             *         message
406:             */
407:            public static Message checkPostableBalanceTypeCode(
408:                    LaborTransaction transaction,
409:                    List<String> unpostableBalanceTypeCodes) {
410:                String balanceTypeCode = transaction
411:                        .getFinancialBalanceTypeCode();
412:                if (unpostableBalanceTypeCodes.contains(balanceTypeCode)) {
413:                    return MessageBuilder.buildErrorMessage(
414:                            LaborKeyConstants.ERROR_UNPOSTABLE_BALANCE_TYPE,
415:                            balanceTypeCode, Message.TYPE_FATAL);
416:                }
417:                return null;
418:            }
419:
420:            /**
421:             * Checks if the transaction amount of the given transaction is ZERO
422:             * 
423:             * @param transaction the given transaction
424:             * @return null if the transaction amount is not ZERO or null; otherwise, return error message
425:             */
426:            public static Message checkZeroTotalAmount(
427:                    LaborTransaction transaction) {
428:                KualiDecimal amount = transaction
429:                        .getTransactionLedgerEntryAmount();
430:                if (amount == null || amount.isZero()) {
431:                    return MessageBuilder.buildErrorMessage(
432:                            LaborKeyConstants.ERROR_ZERO_TOTAL_AMOUNT,
433:                            Message.TYPE_FATAL);
434:                }
435:                return null;
436:            }
437:
438:            /**
439:             * Checks if the given transaction contains the posteable object code
440:             * 
441:             * @param transaction the given transaction
442:             * @param unpostableObjectCodes the list of unpostable object codes
443:             * @return null if the object code of the transaction is not in unpostableObjectCodes; otherwise, return error message
444:             */
445:            public static Message checkPostableObjectCode(
446:                    LaborTransaction transaction,
447:                    List<String> unpostableObjectCodes) {
448:                String objectCode = transaction.getFinancialObjectCode();
449:                if (unpostableObjectCodes.contains(objectCode)) {
450:                    return MessageBuilder.buildErrorMessage(
451:                            LaborKeyConstants.ERROR_UNPOSTABLE_OBJECT_CODE,
452:                            objectCode, Message.TYPE_FATAL);
453:                }
454:                return null;
455:            }
456:
457:            /**
458:             * Checks if the given transaction contains the valid employee id
459:             * 
460:             * @param transaction the given transaction
461:             * @param unpostableObjectCodes the list of unpostable object codes
462:             * @return null if the object code of the transaction is not in unpostableObjectCodes; otherwise, return error message
463:             */
464:            public static Message checkEmplid(LaborTransaction transaction) {
465:                String emplid = transaction.getEmplid();
466:                if (StringUtils.isBlank(emplid)) {
467:                    return MessageBuilder.buildErrorMessage(
468:                            LaborKeyConstants.MISSING_EMPLOYEE_ID,
469:                            Message.TYPE_FATAL);
470:                }
471:                return null;
472:            }
473:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.