Source Code Cross Referenced for AwardRule.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » cg » 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.cg.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.cg.rules;
017:
018:        import java.util.Arrays;
019:        import java.util.Collection;
020:
021:        import org.apache.commons.lang.StringUtils;
022:        import org.apache.log4j.Logger;
023:        import org.kuali.core.document.MaintenanceDocument;
024:        import org.kuali.core.service.DataDictionaryService;
025:        import org.kuali.core.util.ObjectUtils;
026:        import org.kuali.kfs.KFSKeyConstants;
027:        import org.kuali.kfs.KFSPropertyConstants;
028:        import org.kuali.kfs.context.SpringContext;
029:        import org.kuali.module.cg.bo.Award;
030:        import org.kuali.module.cg.bo.AwardAccount;
031:        import org.kuali.module.cg.bo.AwardOrganization;
032:        import org.kuali.module.cg.bo.AwardProjectDirector;
033:
034:        /**
035:         * Rules for the Award maintenance document.
036:         */
037:        public class AwardRule extends CGMaintenanceDocumentRuleBase {
038:            protected static Logger LOG = org.apache.log4j.Logger
039:                    .getLogger(AwardRule.class);
040:
041:            private Award newAwardCopy;
042:
043:            private static final String GRANT_DESCRIPTION_NPT = "NPT";
044:            private static final String GRANT_DESCRIPTION_OPT = "OPT";
045:            private static final String[] NON_FED_GRANT_DESCS = new String[] {
046:                    GRANT_DESCRIPTION_NPT, GRANT_DESCRIPTION_OPT };
047:
048:            @Override
049:            protected boolean processCustomSaveDocumentBusinessRules(
050:                    MaintenanceDocument document) {
051:                LOG
052:                        .info("Entering AwardRule.processCustomSaveDocumentBusinessRules");
053:                processCustomRouteDocumentBusinessRules(document);
054:                LOG
055:                        .info("Leaving AwardRule.processCustomSaveDocumentBusinessRules");
056:                return true; // save despite error messages
057:            }
058:
059:            @Override
060:            protected boolean processCustomRouteDocumentBusinessRules(
061:                    MaintenanceDocument document) {
062:                LOG
063:                        .info("Entering AwardRule.processCustomRouteDocumentBusinessRules");
064:                boolean success = true;
065:                success &= checkProposal();
066:                success &= checkEndAfterBegin(newAwardCopy
067:                        .getAwardBeginningDate(), newAwardCopy
068:                        .getAwardEndingDate(),
069:                        KFSPropertyConstants.AWARD_ENDING_DATE);
070:                success &= checkPrimary(newAwardCopy.getAwardOrganizations(),
071:                        AwardOrganization.class,
072:                        KFSPropertyConstants.AWARD_ORGRANIZATIONS, Award.class);
073:                success &= checkPrimary(
074:                        newAwardCopy.getAwardProjectDirectors(),
075:                        AwardProjectDirector.class,
076:                        KFSPropertyConstants.AWARD_PROJECT_DIRECTORS,
077:                        Award.class);
078:                success &= checkAccounts();
079:                success &= checkProjectDirectorsExist(newAwardCopy
080:                        .getAwardProjectDirectors(),
081:                        AwardProjectDirector.class,
082:                        KFSPropertyConstants.AWARD_PROJECT_DIRECTORS);
083:                success &= checkProjectDirectorsExist(newAwardCopy
084:                        .getAwardAccounts(), AwardAccount.class,
085:                        KFSPropertyConstants.AWARD_ACCOUNTS);
086:                success &= checkProjectDirectorsStatuses(newAwardCopy
087:                        .getAwardProjectDirectors(),
088:                        AwardProjectDirector.class,
089:                        KFSPropertyConstants.AWARD_PROJECT_DIRECTORS);
090:                success &= checkFederalPassThrough();
091:                success &= checkAgencyNotEqualToFederalPassThroughAgency(
092:                        newAwardCopy.getAgency(), newAwardCopy
093:                                .getFederalPassThroughAgency(),
094:                        KFSPropertyConstants.AGENCY_NUMBER,
095:                        KFSPropertyConstants.FEDERAL_PASS_THROUGH_AGENCY_NUMBER);
096:                LOG
097:                        .info("Leaving AwardRule.processCustomRouteDocumentBusinessRules");
098:                return success;
099:            }
100:
101:            /**
102:             * checks to see if at least 1 award account exists
103:             * 
104:             * @return true if the award contains at least 1 {@link AwardAccount}, false otherwise
105:             */
106:            private boolean checkAccounts() {
107:                boolean success = true;
108:                Collection<AwardAccount> awardAccounts = newAwardCopy
109:                        .getAwardAccounts();
110:
111:                if (ObjectUtils.isNull(awardAccounts)
112:                        || awardAccounts.isEmpty()) {
113:                    String elementLabel = SpringContext.getBean(
114:                            DataDictionaryService.class)
115:                            .getCollectionElementLabel(Award.class.getName(),
116:                                    KFSPropertyConstants.AWARD_ACCOUNTS,
117:                                    AwardAccount.class);
118:                    putFieldError(KFSPropertyConstants.AWARD_ACCOUNTS,
119:                            KFSKeyConstants.ERROR_ONE_REQUIRED, elementLabel);
120:                    success = false;
121:                }
122:
123:                return success;
124:            }
125:
126:            /**
127:             * checks to see if:
128:             * <ol>
129:             * <li> a proposal has already been awarded
130:             * <li> a proposal is inactive
131:             * </ol>
132:             * 
133:             * @return
134:             */
135:            private boolean checkProposal() {
136:                boolean success = true;
137:                if (AwardRuleUtil.isProposalAwarded(newAwardCopy)) {
138:                    putFieldError(KFSPropertyConstants.PROPOSAL_NUMBER,
139:                            KFSKeyConstants.ERROR_AWARD_PROPOSAL_AWARDED,
140:                            newAwardCopy.getProposalNumber().toString());
141:                    success = false;
142:                }
143:                // SEE KULCG-315 for details on why this code is commented out.
144:                // else if (AwardRuleUtil.isProposalInactive(newAwardCopy)) {
145:                // putFieldError(KFSPropertyConstants.PROPOSAL_NUMBER, KFSKeyConstants.ERROR_AWARD_PROPOSAL_INACTIVE,
146:                // newAwardCopy.getProposalNumber().toString());
147:                // }
148:
149:                return success;
150:            }
151:
152:            /**
153:             * checks if the required federal pass through fields are filled in if the federal pass through indicator is yes
154:             * 
155:             * @return
156:             */
157:            private boolean checkFederalPassThrough() {
158:                boolean success = true;
159:                success = super .checkFederalPassThrough(newAwardCopy
160:                        .getFederalPassThroughIndicator(), newAwardCopy
161:                        .getAgency(), newAwardCopy
162:                        .getFederalPassThroughAgencyNumber(), Award.class,
163:                        KFSPropertyConstants.FEDERAL_PASS_THROUGH_INDICATOR);
164:
165:                if (newAwardCopy.getFederalPassThroughIndicator()) {
166:
167:                    String indicatorLabel = SpringContext
168:                            .getBean(DataDictionaryService.class)
169:                            .getAttributeErrorLabel(
170:                                    Award.class,
171:                                    KFSPropertyConstants.FEDERAL_PASS_THROUGH_INDICATOR);
172:                    if (null == newAwardCopy
173:                            .getFederalPassThroughFundedAmount()) {
174:                        String amountLabel = SpringContext
175:                                .getBean(DataDictionaryService.class)
176:                                .getAttributeErrorLabel(
177:                                        Award.class,
178:                                        KFSPropertyConstants.FEDERAL_PASS_THROUGH_FUNDED_AMOUNT);
179:                        putFieldError(
180:                                KFSPropertyConstants.FEDERAL_PASS_THROUGH_FUNDED_AMOUNT,
181:                                KFSKeyConstants.ERROR_FPT_AGENCY_NUMBER_REQUIRED,
182:                                new String[] { amountLabel, indicatorLabel });
183:                        success = false;
184:                    }
185:                    String grantDescCode = newAwardCopy.getGrantDescription()
186:                            .getGrantDescriptionCode();
187:                    if (StringUtils.isBlank(grantDescCode)
188:                            || !Arrays.asList(NON_FED_GRANT_DESCS).contains(
189:                                    grantDescCode)) {
190:                        String grantDescLabel = SpringContext
191:                                .getBean(DataDictionaryService.class)
192:                                .getAttributeErrorLabel(
193:                                        Award.class,
194:                                        KFSPropertyConstants.GRANT_DESCRIPTION_CODE);
195:                        putFieldError(
196:                                KFSPropertyConstants.GRANT_DESCRIPTION_CODE,
197:                                KFSKeyConstants.ERROR_GRANT_DESCRIPTION_INVALID_WITH_FED_PASS_THROUGH_AGENCY_INDICATOR_SELECTED);
198:                        success = false;
199:                    }
200:                }
201:                return success;
202:            }
203:
204:            /**
205:             * @see org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase#setupConvenienceObjects()
206:             */
207:            @Override
208:            public void setupConvenienceObjects() {
209:                // oldAward = (Award) super.getOldBo();
210:                newAwardCopy = (Award) super.getNewBo();
211:            }
212:
213:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.