Source Code Cross Referenced for MaintenancePreRulesBase.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 2006-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 org.apache.commons.lang.StringUtils;
019:        import org.kuali.core.document.Document;
020:        import org.kuali.core.document.MaintenanceDocument;
021:        import org.kuali.core.rules.PreRulesContinuationBase;
022:        import org.kuali.core.service.DocumentAuthorizationService;
023:        import org.kuali.core.service.KualiConfigurationService;
024:        import org.kuali.core.util.ObjectUtils;
025:        import org.kuali.kfs.KFSKeyConstants;
026:        import org.kuali.kfs.context.SpringContext;
027:        import org.kuali.module.chart.bo.Account;
028:        import org.kuali.module.chart.service.AccountService;
029:
030:        /**
031:         * General PreRules checks for all Maintenance docs that needs to occur while still in the Struts processing.
032:         */
033:        public class MaintenancePreRulesBase extends PreRulesContinuationBase {
034:
035:            private KualiConfigurationService configService;
036:            private AccountService accountService;
037:            private DocumentAuthorizationService documentAuthorizationService;
038:
039:            /**
040:             * Constructs a MaintenancePreRulesBase class and injects some services through setters
041:             * 
042:             * @TODO: should be fixed in the future to use Spring to inject these services
043:             */
044:            public MaintenancePreRulesBase() {
045:                // Pseudo-inject some services.
046:                //
047:                // This approach is being used to make it simpler to convert the Rule classes
048:                // to spring-managed with these services injected by Spring at some later date.
049:                // When this happens, just remove these calls to the setters with
050:                // SpringContext, and configure the bean defs for spring.
051:                setAccountService(SpringContext.getBean(AccountService.class));
052:                setConfigService(SpringContext
053:                        .getBean(KualiConfigurationService.class));
054:                setDocumentAuthorizationService(SpringContext
055:                        .getBean(DocumentAuthorizationService.class));
056:            }
057:
058:            public void setAccountService(AccountService accountService) {
059:                this .accountService = accountService;
060:            }
061:
062:            public void setConfigService(KualiConfigurationService configService) {
063:                this .configService = configService;
064:            }
065:
066:            /**
067:             * This is called from the rules service to execute our rules A hook is provided here for sub-classes to override the
068:             * {@link MaintenancePreRulesBase#doCustomPreRules(MaintenanceDocument)}
069:             * 
070:             * @see org.kuali.core.rules.PreRulesContinuationBase#doRules(org.kuali.core.document.Document)
071:             */
072:            public boolean doRules(Document document) {
073:                MaintenanceDocument maintenanceDocument = (MaintenanceDocument) document;
074:                return doCustomPreRules(maintenanceDocument);
075:            }
076:
077:            /**
078:             * This is a hook for sub-classes to implement their own pre-rules. Override to get hooked into main class
079:             * 
080:             * @param maintenanceDocument
081:             * @return true if rules pass
082:             */
083:            protected boolean doCustomPreRules(
084:                    MaintenanceDocument maintenanceDocument) {
085:                return true;
086:            }
087:
088:            /**
089:             * This method checks for continuation accounts, returns the continuation account if it is found, null otherwise
090:             * 
091:             * @param accName
092:             * @param chart
093:             * @param accountNumber
094:             * @param accountName
095:             * @param allowExpiredAccount
096:             * @return the continuation account if it is found, null otherwise
097:             */
098:            protected Account checkForContinuationAccount(String accName,
099:                    String chart, String accountNumber, String accountName,
100:                    boolean allowExpiredAccount) {
101:                Account result = checkForContinuationAccount(accName, chart,
102:                        accountNumber, accountName);
103:                if (!allowExpiredAccount) {
104:                    if (result.isExpired()) {
105:                        return null;
106:                    }
107:                }
108:                return result;
109:            }
110:
111:            /**
112:             * This method checks for continuation accounts and presents the user with a question regarding their use on this account.
113:             * 
114:             * @param accName
115:             * @param chart
116:             * @param accountNumber
117:             * @param accountName
118:             * @return
119:             */
120:            protected Account checkForContinuationAccount(String accName,
121:                    String chart, String accountNumber, String accountName) {
122:                if (LOG.isDebugEnabled()) {
123:                    LOG.debug("entering checkForContinuationAccounts("
124:                            + accountNumber + ")");
125:                }
126:                if (StringUtils.isBlank(accountNumber)
127:                        || StringUtils.isBlank(chart))
128:                    return null;
129:
130:                Account account = accountService.getByPrimaryId(chart,
131:                        accountNumber);
132:
133:                if (ObjectUtils.isNotNull(account) && !account.isExpired()) { // no need for a continuation account
134:                    return null;
135:                }
136:
137:                boolean useContinuationAccount = true;
138:
139:                while (ObjectUtils.isNotNull(account) && account.isExpired()
140:                        && useContinuationAccount) {
141:                    LOG.debug("Expired account: " + accountNumber);
142:                    String continuationAccountNumber = account
143:                            .getContinuationAccountNumber();
144:
145:                    useContinuationAccount = askOrAnalyzeYesNoQuestion(
146:                            "ContinuationAccount" + accName + accountNumber,
147:                            buildContinuationConfirmationQuestion(accName,
148:                                    accountNumber, continuationAccountNumber));
149:                    if (useContinuationAccount) {
150:                        String continuationChart = account
151:                                .getContinuationFinChrtOfAcctCd();
152:                        account = accountService.getByPrimaryId(
153:                                continuationChart, continuationAccountNumber);
154:
155:                        if (ObjectUtils.isNotNull(account)) {
156:                            accountNumber = account.getAccountNumber();
157:                        }
158:
159:                        if (LOG.isDebugEnabled()) {
160:                            LOG.debug("Selected continuation account: "
161:                                    + account);
162:                        }
163:                    }
164:                }
165:                return account;
166:
167:            }
168:
169:            /**
170:             * This method builds up the continuation account confirmation question that will be presented to the user
171:             * 
172:             * @param accName
173:             * @param expiredAccount
174:             * @param continuationAccount
175:             * @return the question to the user about the continuation account
176:             */
177:            protected String buildContinuationConfirmationQuestion(
178:                    String accName, String expiredAccount,
179:                    String continuationAccount) {
180:                String result = configService
181:                        .getPropertyString(KFSKeyConstants.QUESTION_CONTINUATION_ACCOUNT_SELECTION);
182:                result = StringUtils.replace(result, "{0}", accName);
183:                result = StringUtils.replace(result, "{1}", expiredAccount);
184:                result = StringUtils
185:                        .replace(result, "{2}", continuationAccount);
186:                return result;
187:            }
188:
189:            public AccountService getAccountService() {
190:                return accountService;
191:            }
192:
193:            public KualiConfigurationService getConfigService() {
194:                return configService;
195:            }
196:
197:            /**
198:             * Gets the documentAuthorizationService attribute.
199:             * 
200:             * @return Returns the documentAuthorizationService.
201:             */
202:            protected final DocumentAuthorizationService getDocumentAuthorizationService() {
203:                return documentAuthorizationService;
204:            }
205:
206:            /**
207:             * Sets the documentAuthorizationService attribute value.
208:             * 
209:             * @param documentAuthorizationService The documentAuthorizationService to set.
210:             */
211:            public final void setDocumentAuthorizationService(
212:                    DocumentAuthorizationService documentAuthorizationService) {
213:                this.documentAuthorizationService = documentAuthorizationService;
214:            }
215:
216:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.