Source Code Cross Referenced for BudgetNonpersonnelFormHelper.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » kra » budget » web » struts » form » 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.kra.budget.web.struts.form 
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.kra.budget.web.struts.form;
017:
018:        import java.util.ArrayList;
019:        import java.util.Collections;
020:        import java.util.HashMap;
021:        import java.util.Iterator;
022:        import java.util.List;
023:        import java.util.Map;
024:
025:        import org.kuali.core.util.KualiInteger;
026:        import org.kuali.module.kra.budget.bo.BudgetNonpersonnel;
027:        import org.kuali.module.kra.budget.bo.NonpersonnelCategory;
028:
029:        /**
030:         * This is used by the UI to get totals, counts, and other things needed to render the page properly.
031:         */
032:        public class BudgetNonpersonnelFormHelper {
033:
034:            // This map holds the individual NonpersonnelCategoryHelper objects.
035:            // The Key is the nonpersonnel category code, the value is (obviously) the NonpersonnelCategoryHelper
036:            Map nonpersonnelCategoryHelperMap = new HashMap();
037:
038:            /**
039:             * Constructs a BudgetNonpersonnelFormHelper.java. Default, no arg constructor
040:             */
041:            public BudgetNonpersonnelFormHelper() {
042:            }
043:
044:            /**
045:             * Constructs a BudgetNonpersonnelFormHelper.java based on data extracted from a BudgetForm. Added as a convienence.
046:             */
047:            public BudgetNonpersonnelFormHelper(BudgetForm budgetForm) {
048:                this (budgetForm.getCurrentTaskNumber(), budgetForm
049:                        .getCurrentPeriodNumber(), budgetForm
050:                        .getNonpersonnelCategories(),
051:                        budgetForm.getBudgetDocument().getBudget()
052:                                .getNonpersonnelItems(), true);
053:            }
054:
055:            /**
056:             * Constructs a BudgetNonpersonnelFormHelper.java based on data relevent data.
057:             */
058:            public BudgetNonpersonnelFormHelper(Integer currentTaskNumber,
059:                    Integer currentPeriodNumber, List nonpersonnelCategories,
060:                    List nonpersonnelItems, boolean includesModularExcluded) {
061:                this .refresh(nonpersonnelItems);
062:                setupNonpersonnelCategories(nonpersonnelCategories);
063:                addNonpersonnelItems(currentTaskNumber, currentPeriodNumber,
064:                        nonpersonnelItems, includesModularExcluded);
065:            }
066:
067:            /**
068:             * This ensures that on each page refresh the 3 amount fields are compared to 3 backup amount fields (*Duplicate). The purpose
069:             * of that is to detect a change in any of those fields and uncheck the respective copy over indicator. That is a functional
070:             * requirement.
071:             * 
072:             * @param nonpersonnelItems budgetForm.getBudgetDocument().getBudget().getNonpersonnelItems()
073:             */
074:            public void refresh(List nonpersonnelItems) {
075:                for (Iterator nonpersonnelItemsIter = nonpersonnelItems
076:                        .iterator(); nonpersonnelItemsIter.hasNext();) {
077:                    BudgetNonpersonnel budgetNonpersonnel = (BudgetNonpersonnel) nonpersonnelItemsIter
078:                            .next();
079:
080:                    // Check each of the three indicators, ignore if they are null (that's first page entry or items
081:                    // that are currently not displaied, don't care about that) and check if field was changed. If it
082:                    // was, unset the copy indicator.
083:                    if (budgetNonpersonnel.getAgencyRequestAmountBackup() != null
084:                            && !budgetNonpersonnel
085:                                    .getAgencyRequestAmountBackup().equals(
086:                                            budgetNonpersonnel
087:                                                    .getAgencyRequestAmount())) {
088:                        budgetNonpersonnel.setAgencyCopyIndicator(false);
089:                    }
090:
091:                    if (budgetNonpersonnel
092:                            .getBudgetInstitutionCostShareAmountBackup() != null
093:                            && !budgetNonpersonnel
094:                                    .getBudgetInstitutionCostShareAmountBackup()
095:                                    .equals(
096:                                            budgetNonpersonnel
097:                                                    .getBudgetInstitutionCostShareAmount())) {
098:                        budgetNonpersonnel
099:                                .setBudgetInstitutionCostShareCopyIndicator(false);
100:                    }
101:
102:                    if (budgetNonpersonnel
103:                            .getBudgetThirdPartyCostShareAmountBackup() != null
104:                            && !budgetNonpersonnel
105:                                    .getBudgetThirdPartyCostShareAmountBackup()
106:                                    .equals(
107:                                            budgetNonpersonnel
108:                                                    .getBudgetThirdPartyCostShareAmount())) {
109:                        budgetNonpersonnel
110:                                .setBudgetThirdPartyCostShareCopyIndicator(false);
111:                    }
112:
113:                    // Set the duplicate amounts to what we currently have so that the comparision can take place again
114:                    // next request.
115:                    budgetNonpersonnel
116:                            .setAgencyRequestAmountBackup(budgetNonpersonnel
117:                                    .getAgencyRequestAmount());
118:                    budgetNonpersonnel
119:                            .setBudgetInstitutionCostShareAmountBackup(budgetNonpersonnel
120:                                    .getBudgetInstitutionCostShareAmount());
121:                    budgetNonpersonnel
122:                            .setBudgetThirdPartyCostShareAmountBackup(budgetNonpersonnel
123:                                    .getBudgetThirdPartyCostShareAmount());
124:                }
125:            }
126:
127:            /**
128:             * This method aggregates Nonpesronnel Item data into the proper Category breakdown.
129:             * 
130:             * @param currentTaskNumber
131:             * @param currentPeriodNumber
132:             * @param nonpersonnelItems
133:             * @param includesModularExcluded
134:             */
135:            public void addNonpersonnelItems(Integer currentTaskNumber,
136:                    Integer currentPeriodNumber, List nonpersonnelItems,
137:                    boolean includesModularExcluded) {
138:                int itemIndex = 0;
139:                for (Iterator i = nonpersonnelItems.iterator(); i.hasNext(); itemIndex++) {
140:                    BudgetNonpersonnel nonpersonnelItem = (BudgetNonpersonnel) i
141:                            .next();
142:                    if (includesModularExcluded
143:                            || !nonpersonnelItem.getNonpersonnelObjectCode()
144:                                    .getNonpersonnelSubCategory()
145:                                    .isNonpersonnelModularExcludedIndicator()) {
146:                        String nonpersonnelItemCategoryCode = nonpersonnelItem
147:                                .getBudgetNonpersonnelCategoryCode();
148:                        if ((currentTaskNumber.intValue() == 0 && currentPeriodNumber
149:                                .intValue() == 0)
150:                                || (currentTaskNumber.intValue() == 0 && nonpersonnelItem
151:                                        .getBudgetPeriodSequenceNumber()
152:                                        .equals(currentPeriodNumber))
153:                                || (nonpersonnelItem
154:                                        .getBudgetTaskSequenceNumber().equals(
155:                                                currentTaskNumber) && currentPeriodNumber
156:                                        .intValue() == 0)
157:                                || (nonpersonnelItem
158:                                        .getBudgetTaskSequenceNumber().equals(
159:                                                currentTaskNumber) && nonpersonnelItem
160:                                        .getBudgetPeriodSequenceNumber()
161:                                        .equals(currentPeriodNumber))) {
162:                            if (nonpersonnelCategoryHelperMap
163:                                    .get(nonpersonnelItemCategoryCode) != null) {
164:                                NonpersonnelCategoryHelper categoryHelper = (NonpersonnelCategoryHelper) nonpersonnelCategoryHelperMap
165:                                        .get(nonpersonnelItemCategoryCode);
166:                                categoryHelper.add(nonpersonnelItem, itemIndex);
167:                            } else {
168:                                nonpersonnelCategoryHelperMap.put(
169:                                        nonpersonnelItemCategoryCode,
170:                                        new NonpersonnelCategoryHelper(
171:                                                nonpersonnelItem, itemIndex));
172:                            }
173:                        }
174:                    }
175:                }
176:            }
177:
178:            /**
179:             * This method sets up a NonpersonnelCategoryHelper object for each Nonpersonnel Category
180:             * 
181:             * @param nonpersonnelItems
182:             */
183:            public void setupNonpersonnelCategories(List nonpersonnelCategories) {
184:                for (Iterator i = nonpersonnelCategories.iterator(); i
185:                        .hasNext();) {
186:                    NonpersonnelCategory nonpersonnelCategory = (NonpersonnelCategory) i
187:                            .next();
188:                    if (nonpersonnelCategoryHelperMap.get(nonpersonnelCategory
189:                            .getCode()) == null) {
190:                        nonpersonnelCategoryHelperMap.put(nonpersonnelCategory
191:                                .getCode(), new NonpersonnelCategoryHelper(
192:                                nonpersonnelCategory));
193:                        Collections.sort(nonpersonnelCategory
194:                                .getNonpersonnelObjectCodes());
195:                    }
196:                }
197:            }
198:
199:            /**
200:             * Gets the budgetNonpersonnelHelperMap attribute.
201:             * 
202:             * @return Returns the budgetNonpersonnelHelperMap.
203:             */
204:            public Map getNonpersonnelCategoryHelperMap() {
205:                return nonpersonnelCategoryHelperMap;
206:            }
207:
208:            /**
209:             * Sets the budgetNonpersonnelHelperMap attribute value.
210:             * 
211:             * @param budgetNonpersonnelHelperMap The budgetNonpersonnelHelperMap to set.
212:             */
213:            public void setNonpersonnelCategoryHelperMap(
214:                    Map budgetNonpersonnelHelperMap) {
215:                this .nonpersonnelCategoryHelperMap = budgetNonpersonnelHelperMap;
216:            }
217:
218:            /**
219:             * Gets the agencyTotal for all budgetNonpersonnelHelperMap attributes.
220:             * 
221:             * @return Returns the agencyTotal for all budgetNonpersonnelHelperMap attributes.
222:             */
223:            public KualiInteger getNonpersonnelAgencyTotal() {
224:                Iterator iter = nonpersonnelCategoryHelperMap.values()
225:                        .iterator();
226:                KualiInteger agencyTotal = new KualiInteger(0);
227:
228:                while (iter.hasNext()) {
229:                    NonpersonnelCategoryHelper helper = (NonpersonnelCategoryHelper) iter
230:                            .next();
231:                    agencyTotal = agencyTotal.add(helper.getAgencyTotal());
232:                }
233:
234:                return agencyTotal;
235:            }
236:
237:            /**
238:             * Gets the univCostShareTotal for all budgetNonpersonnelHelperMap attributes.
239:             * 
240:             * @return Returns the univCostShareTotal for all budgetNonpersonnelHelperMap attributes.
241:             */
242:            public KualiInteger getNonpersonnelUnivCostShareTotal() {
243:                Iterator iter = nonpersonnelCategoryHelperMap.values()
244:                        .iterator();
245:                KualiInteger univCostShareTotal = new KualiInteger(0);
246:
247:                while (iter.hasNext()) {
248:                    NonpersonnelCategoryHelper helper = (NonpersonnelCategoryHelper) iter
249:                            .next();
250:                    univCostShareTotal = univCostShareTotal.add(helper
251:                            .getUnivCostShareTotal());
252:                }
253:
254:                return univCostShareTotal;
255:            }
256:
257:            /**
258:             * Gets the thirdPartyCostShareTotal for all budgetNonpersonnelHelperMap attributes.
259:             * 
260:             * @return Returns the thirdPartyCostShareTotal for all budgetNonpersonnelHelperMap attributes.
261:             */
262:            public KualiInteger getNonpersonnelThirdPartyCostShareTotal() {
263:                Iterator iter = nonpersonnelCategoryHelperMap.values()
264:                        .iterator();
265:                KualiInteger thirdPartyCostShareTotal = new KualiInteger(0);
266:
267:                while (iter.hasNext()) {
268:                    NonpersonnelCategoryHelper helper = (NonpersonnelCategoryHelper) iter
269:                            .next();
270:                    thirdPartyCostShareTotal = thirdPartyCostShareTotal
271:                            .add(helper.getThirdPartyCostShareTotal());
272:                }
273:
274:                return thirdPartyCostShareTotal;
275:            }
276:
277:            /**
278:             * This class holds information relevent to each NonpersonnelCategory. It tells the number of items, totals (agency, univ. cost
279:             * share, and third party cost share), and item indexes.
280:             */
281:
282:            public class NonpersonnelCategoryHelper {
283:
284:                private String nonpersonnelCategoryCode;
285:                private int numItems = 0;
286:                private KualiInteger agencyTotal = new KualiInteger(0);
287:                private KualiInteger univCostShareTotal = new KualiInteger(0);
288:                private KualiInteger thirdPartyCostShareTotal = new KualiInteger(
289:                        0);
290:                private List itemIndexes = new ArrayList();
291:
292:                /**
293:                 * Constructs a BudgetNonpersonnelFormHelper.java and initializes the NonpersonnelCategory that this helper helps
294:                 * 
295:                 * @param nonpersonnelCategory
296:                 */
297:                public NonpersonnelCategoryHelper(
298:                        NonpersonnelCategory nonpersonnelCategory) {
299:                    this .setNonpersonnelCategoryCode(nonpersonnelCategory
300:                            .getCode());
301:                }
302:
303:                /**
304:                 * Constructs a BudgetNonpersonnelFormHelper.java and initializes the NonpersonnelCategory via a NonpersonnelItem.
305:                 * 
306:                 * @param nonpersonnelCategory
307:                 */
308:                public NonpersonnelCategoryHelper(
309:                        BudgetNonpersonnel nonpersonnelItem, int itemIndex) {
310:                    this .setNonpersonnelCategoryCode(nonpersonnelItem
311:                            .getBudgetNonpersonnelCategoryCode());
312:                    this .add(nonpersonnelItem, itemIndex);
313:                }
314:
315:                /**
316:                 * This method adds appropriate data about a NonpersonnelItem to this NonpersonnelCategoryHelper
317:                 * 
318:                 * @param nonpersonnelItem
319:                 * @param itemIndex
320:                 */
321:                public void add(BudgetNonpersonnel nonpersonnelItem,
322:                        int itemIndex) {
323:                    this .numItems++;
324:                    if (nonpersonnelItem.getAgencyRequestAmount() != null)
325:                        agencyTotal = agencyTotal.add(nonpersonnelItem
326:                                .getAgencyRequestAmount());
327:
328:                    if (nonpersonnelItem.getBudgetInstitutionCostShareAmount() != null)
329:                        univCostShareTotal = univCostShareTotal
330:                                .add(nonpersonnelItem
331:                                        .getBudgetInstitutionCostShareAmount());
332:
333:                    if (nonpersonnelItem.getBudgetThirdPartyCostShareAmount() != null)
334:                        thirdPartyCostShareTotal = thirdPartyCostShareTotal
335:                                .add(nonpersonnelItem
336:                                        .getBudgetThirdPartyCostShareAmount());
337:
338:                    itemIndexes.add(Integer.toString(itemIndex));
339:                }
340:
341:                /**
342:                 * Gets the agencyTotal attribute.
343:                 * 
344:                 * @return Returns the agencyTotal.
345:                 */
346:                public KualiInteger getAgencyTotal() {
347:                    return agencyTotal;
348:                }
349:
350:                /**
351:                 * Sets the agencyTotal attribute value.
352:                 * 
353:                 * @param agencyTotal The agencyTotal to set.
354:                 */
355:                public void setAgencyTotal(KualiInteger agencyTotal) {
356:                    this .agencyTotal = agencyTotal;
357:                }
358:
359:                /**
360:                 * Gets the nonpersonnelCategoryCode attribute.
361:                 * 
362:                 * @return Returns the nonpersonnelCategoryCode.
363:                 */
364:                public String getNonpersonnelCategoryCode() {
365:                    return nonpersonnelCategoryCode;
366:                }
367:
368:                /**
369:                 * Sets the nonpersonnelCategoryCode attribute value.
370:                 * 
371:                 * @param nonpersonnelCategoryCode The nonpersonnelCategoryCode to set.
372:                 */
373:                public void setNonpersonnelCategoryCode(
374:                        String nonpersonnelCategoryCode) {
375:                    this .nonpersonnelCategoryCode = nonpersonnelCategoryCode;
376:                }
377:
378:                /**
379:                 * Gets the numItems attribute.
380:                 * 
381:                 * @return Returns the numItems.
382:                 */
383:                public int getNumItems() {
384:                    return numItems;
385:                }
386:
387:                /**
388:                 * Sets the numItems attribute value.
389:                 * 
390:                 * @param numItems The numItems to set.
391:                 */
392:                public void setNumItems(int numItems) {
393:                    this .numItems = numItems;
394:                }
395:
396:                /**
397:                 * Gets the thirdPartyCostShareTotal attribute.
398:                 * 
399:                 * @return Returns the thirdPartyCostShareTotal.
400:                 */
401:                public KualiInteger getThirdPartyCostShareTotal() {
402:                    return thirdPartyCostShareTotal;
403:                }
404:
405:                /**
406:                 * Sets the thirdPartyCostShareTotal attribute value.
407:                 * 
408:                 * @param thirdPartyCostShareTotal The thirdPartyCostShareTotal to set.
409:                 */
410:                public void setThirdPartyCostShareTotal(
411:                        KualiInteger thirdPartyCostShareTotal) {
412:                    this .thirdPartyCostShareTotal = thirdPartyCostShareTotal;
413:                }
414:
415:                /**
416:                 * Gets the univCostShareTotal attribute.
417:                 * 
418:                 * @return Returns the univCostShareTotal.
419:                 */
420:                public KualiInteger getUnivCostShareTotal() {
421:                    return univCostShareTotal;
422:                }
423:
424:                /**
425:                 * Sets the univCostShareTotal attribute value.
426:                 * 
427:                 * @param univCostShareTotal The univCostShareTotal to set.
428:                 */
429:                public void setUnivCostShareTotal(
430:                        KualiInteger univCostShareTotal) {
431:                    this .univCostShareTotal = univCostShareTotal;
432:                }
433:
434:                /**
435:                 * Gets the itemIndexes attribute.
436:                 * 
437:                 * @return Returns the itemIndexes.
438:                 */
439:                public List getItemIndexes() {
440:                    return itemIndexes;
441:                }
442:
443:                /**
444:                 * Sets the itemIndexes attribute value.
445:                 * 
446:                 * @param itemIndexes The itemIndexes to set.
447:                 */
448:                public void setItemIndexes(List itemIndexes) {
449:                    this.itemIndexes = itemIndexes;
450:                }
451:            }
452:        }
w__w__w__.j___a_va_2___s._c___o__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.