Source Code Cross Referenced for PurApItemBase.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » purap » bo » 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.purap.bo 
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:
017:        package org.kuali.module.purap.bo;
018:
019:        import java.math.BigDecimal;
020:        import java.util.ArrayList;
021:        import java.util.HashMap;
022:        import java.util.LinkedHashMap;
023:        import java.util.List;
024:
025:        import org.kuali.core.bo.PersistableBusinessObjectBase;
026:        import org.kuali.core.util.KualiDecimal;
027:        import org.kuali.core.util.ObjectUtils;
028:        import org.kuali.core.util.TypedArrayList;
029:        import org.kuali.module.purap.PurapConstants;
030:        import org.kuali.module.purap.PurapPropertyConstants;
031:        import org.kuali.module.purap.util.PurApObjectUtils;
032:
033:        /**
034:         * Purap Item Base Business Object.
035:         */
036:        public abstract class PurApItemBase extends
037:                PersistableBusinessObjectBase implements  PurApItem {
038:
039:            private Integer itemIdentifier;
040:            private Integer itemLineNumber;
041:            private String capitalAssetTransactionTypeCode;
042:            private String itemUnitOfMeasureCode;
043:            private String itemCatalogNumber;
044:            private String itemDescription;
045:            private String itemCapitalAssetNoteText;
046:            private BigDecimal itemUnitPrice;
047:            private String itemTypeCode;
048:            private String itemAuxiliaryPartIdentifier;
049:            private String externalOrganizationB2bProductReferenceNumber;
050:            private String externalOrganizationB2bProductTypeName;
051:            private boolean itemAssignedToTradeInIndicator;
052:            private KualiDecimal extendedPrice; // not currently in DB
053:
054:            private List<PurApAccountingLine> sourceAccountingLines;
055:            private transient List<PurApAccountingLine> baselineSourceAccountingLines;
056:            private transient PurApAccountingLine newSourceLine;
057:
058:            private CapitalAssetTransactionType capitalAssetTransactionType;
059:            private ItemType itemType;
060:            private Integer purapDocumentIdentifier;
061:            private KualiDecimal itemQuantity;
062:
063:            /**
064:             * Default constructor.
065:             */
066:            public PurApItemBase() {
067:                itemTypeCode = PurapConstants.ItemTypeCodes.ITEM_TYPE_ITEM_CODE;
068:                sourceAccountingLines = new TypedArrayList(
069:                        getAccountingLineClass());
070:                baselineSourceAccountingLines = new TypedArrayList(
071:                        getAccountingLineClass());
072:                resetAccount();
073:            }
074:
075:            /**
076:             * @see org.kuali.module.purap.bo.PurApItem#getItemIdentifierString()
077:             */
078:            public String getItemIdentifierString() {
079:                String itemLineNumberString = (getItemLineNumber() != null ? getItemLineNumber()
080:                        .toString()
081:                        : "");
082:                String identifierString = (getItemType()
083:                        .isItemTypeAboveTheLineIndicator() ? "Item "
084:                        + itemLineNumberString : getItemType()
085:                        .getItemTypeDescription());
086:                return identifierString;
087:            }
088:
089:            public Integer getItemIdentifier() {
090:                return itemIdentifier;
091:            }
092:
093:            public void setItemIdentifier(Integer ItemIdentifier) {
094:                this .itemIdentifier = ItemIdentifier;
095:            }
096:
097:            public Integer getItemLineNumber() {
098:                return itemLineNumber;
099:            }
100:
101:            public void setItemLineNumber(Integer itemLineNumber) {
102:                this .itemLineNumber = itemLineNumber;
103:            }
104:
105:            public String getCapitalAssetTransactionTypeCode() {
106:                return capitalAssetTransactionTypeCode;
107:            }
108:
109:            public void setCapitalAssetTransactionTypeCode(
110:                    String capitalAssetTransactionTypeCode) {
111:                this .capitalAssetTransactionTypeCode = capitalAssetTransactionTypeCode;
112:            }
113:
114:            public String getItemUnitOfMeasureCode() {
115:                return itemUnitOfMeasureCode;
116:            }
117:
118:            public void setItemUnitOfMeasureCode(String itemUnitOfMeasureCode) {
119:                this .itemUnitOfMeasureCode = itemUnitOfMeasureCode;
120:            }
121:
122:            public String getItemCatalogNumber() {
123:                return itemCatalogNumber;
124:            }
125:
126:            public void setItemCatalogNumber(String itemCatalogNumber) {
127:                this .itemCatalogNumber = itemCatalogNumber;
128:            }
129:
130:            public String getItemDescription() {
131:                return itemDescription;
132:            }
133:
134:            public void setItemDescription(String itemDescription) {
135:                this .itemDescription = itemDescription;
136:            }
137:
138:            public String getItemCapitalAssetNoteText() {
139:                return itemCapitalAssetNoteText;
140:            }
141:
142:            public void setItemCapitalAssetNoteText(
143:                    String itemCapitalAssetNoteText) {
144:                this .itemCapitalAssetNoteText = itemCapitalAssetNoteText;
145:            }
146:
147:            public BigDecimal getItemUnitPrice() {
148:                // KULPURAP-1096 Setting scale on retrieval of unit price
149:                if (itemUnitPrice != null) {
150:                    if (itemUnitPrice.scale() < PurapConstants.DOLLAR_AMOUNT_MIN_SCALE) {
151:                        itemUnitPrice = itemUnitPrice.setScale(
152:                                PurapConstants.DOLLAR_AMOUNT_MIN_SCALE,
153:                                KualiDecimal.ROUND_BEHAVIOR);
154:                    } else if (itemUnitPrice.scale() > PurapConstants.UNIT_PRICE_MAX_SCALE) {
155:                        itemUnitPrice = itemUnitPrice.setScale(
156:                                PurapConstants.UNIT_PRICE_MAX_SCALE,
157:                                KualiDecimal.ROUND_BEHAVIOR);
158:                    }
159:                }
160:
161:                return itemUnitPrice;
162:            }
163:
164:            public void setItemUnitPrice(BigDecimal itemUnitPrice) {
165:                if (itemUnitPrice != null) {
166:                    if (itemUnitPrice.scale() < PurapConstants.DOLLAR_AMOUNT_MIN_SCALE) {
167:                        itemUnitPrice = itemUnitPrice.setScale(
168:                                PurapConstants.DOLLAR_AMOUNT_MIN_SCALE,
169:                                KualiDecimal.ROUND_BEHAVIOR);
170:                    } else if (itemUnitPrice.scale() > PurapConstants.UNIT_PRICE_MAX_SCALE) {
171:                        itemUnitPrice = itemUnitPrice.setScale(
172:                                PurapConstants.UNIT_PRICE_MAX_SCALE,
173:                                KualiDecimal.ROUND_BEHAVIOR);
174:                    }
175:                }
176:                this .itemUnitPrice = itemUnitPrice;
177:            }
178:
179:            public String getItemTypeCode() {
180:                return itemTypeCode;
181:            }
182:
183:            public void setItemTypeCode(String itemTypeCode) {
184:                this .itemTypeCode = itemTypeCode;
185:            }
186:
187:            public String getItemAuxiliaryPartIdentifier() {
188:                return itemAuxiliaryPartIdentifier;
189:            }
190:
191:            public void setItemAuxiliaryPartIdentifier(
192:                    String itemAuxiliaryPartIdentifier) {
193:                this .itemAuxiliaryPartIdentifier = itemAuxiliaryPartIdentifier;
194:            }
195:
196:            public String getExternalOrganizationB2bProductReferenceNumber() {
197:                return externalOrganizationB2bProductReferenceNumber;
198:            }
199:
200:            public void setExternalOrganizationB2bProductReferenceNumber(
201:                    String externalOrganizationB2bProductReferenceNumber) {
202:                this .externalOrganizationB2bProductReferenceNumber = externalOrganizationB2bProductReferenceNumber;
203:            }
204:
205:            public String getExternalOrganizationB2bProductTypeName() {
206:                return externalOrganizationB2bProductTypeName;
207:            }
208:
209:            public void setExternalOrganizationB2bProductTypeName(
210:                    String externalOrganizationB2bProductTypeName) {
211:                this .externalOrganizationB2bProductTypeName = externalOrganizationB2bProductTypeName;
212:            }
213:
214:            public boolean getItemAssignedToTradeInIndicator() {
215:                return itemAssignedToTradeInIndicator;
216:            }
217:
218:            public void setItemAssignedToTradeInIndicator(
219:                    boolean itemAssignedToTradeInIndicator) {
220:                this .itemAssignedToTradeInIndicator = itemAssignedToTradeInIndicator;
221:            }
222:
223:            public CapitalAssetTransactionType getCapitalAssetTransactionType() {
224:                return capitalAssetTransactionType;
225:            }
226:
227:            /**
228:             * Sets the capitalAssetTransactionType attribute.
229:             * 
230:             * @param capitalAssetTransactionType The capitalAssetTransactionType to set.
231:             * @deprecated
232:             */
233:            public void setCapitalAssetTransactionType(
234:                    CapitalAssetTransactionType capitalAssetTransactionType) {
235:                this .capitalAssetTransactionType = capitalAssetTransactionType;
236:            }
237:
238:            public ItemType getItemType() {
239:                if (ObjectUtils.isNull(itemType)) {
240:                    refreshReferenceObject(PurapPropertyConstants.ITEM_TYPE);
241:                }
242:                return itemType;
243:            }
244:
245:            /**
246:             * Sets the itemType attribute.
247:             * 
248:             * @param itemType The itemType to set.
249:             * @deprecated
250:             */
251:            public void setItemType(ItemType itemType) {
252:                this .itemType = itemType;
253:            }
254:
255:            public KualiDecimal getExtendedPrice() {
256:                return calculateExtendedPrice();
257:            }
258:
259:            public KualiDecimal calculateExtendedPrice() {
260:                KualiDecimal extendedPrice = KualiDecimal.ZERO;
261:                if (ObjectUtils.isNotNull(itemUnitPrice)) {
262:                    if (!this .itemType.isQuantityBasedGeneralLedgerIndicator()) {
263:                        // SERVICE ITEM: return unit price as extended price
264:                        extendedPrice = new KualiDecimal(this .itemUnitPrice
265:                                .toString());
266:                    } else if (ObjectUtils.isNotNull(this .getItemQuantity())) {
267:                        BigDecimal calcExtendedPrice = this .itemUnitPrice
268:                                .multiply(this .itemQuantity.bigDecimalValue());
269:                        // ITEM TYPE (qty driven): return (unitPrice x qty)
270:                        extendedPrice = new KualiDecimal(calcExtendedPrice);
271:                    }
272:                }
273:                return extendedPrice;
274:            }
275:
276:            public void setExtendedPrice(KualiDecimal extendedPrice) {
277:                this .extendedPrice = extendedPrice;
278:            }
279:
280:            public List<PurApAccountingLine> getSourceAccountingLines() {
281:                return sourceAccountingLines;
282:            }
283:
284:            public void setSourceAccountingLines(
285:                    List<PurApAccountingLine> accountingLines) {
286:                this .sourceAccountingLines = accountingLines;
287:            }
288:
289:            public List<PurApAccountingLine> getBaselineSourceAccountingLines() {
290:                return baselineSourceAccountingLines;
291:            }
292:
293:            public void setBaselineSourceAccountingLines(
294:                    List<PurApAccountingLine> baselineSourceLines) {
295:                this .baselineSourceAccountingLines = baselineSourceLines;
296:            }
297:
298:            /**
299:             * This implementation is coupled tightly with some underlying issues that the Struts PojoProcessor plugin has with how objects
300:             * get instantiated within lists. The first three lines are required otherwise when the PojoProcessor tries to automatically
301:             * inject values into the list, it will get an index out of bounds error if the instance at an index is being called and prior
302:             * instances at indices before that one are not being instantiated. So changing the code below will cause adding lines to break
303:             * if you add more than one item to the list.
304:             * 
305:             * @see org.kuali.core.document.FinancialDocument#getTargetAccountingLine(int)
306:             */
307:            public PurApAccountingLine getSourceAccountingLine(int index) {
308:                return (PurApAccountingLine) getSourceAccountingLines().get(
309:                        index);
310:            }
311:
312:            public PurApAccountingLine getBaselineSourceAccountingLine(int index) {
313:                return (PurApAccountingLine) getBaselineSourceAccountingLines()
314:                        .get(index);
315:            }
316:
317:            private PurApAccountingLine getNewAccount() throws RuntimeException {
318:
319:                PurApAccountingLine newAccount = null;
320:                try {
321:                    newAccount = (PurApAccountingLine) getAccountingLineClass()
322:                            .newInstance();
323:                } catch (InstantiationException e) {
324:                    throw new RuntimeException("Unable to get class");
325:                } catch (IllegalAccessException e) {
326:                    throw new RuntimeException("Unable to get class");
327:                } catch (NullPointerException e) {
328:                    throw new RuntimeException(
329:                            "Can't instantiate Purchasing Account from base");
330:                }
331:                return newAccount;
332:            }
333:
334:            public abstract Class getAccountingLineClass();
335:
336:            public void resetAccount() {
337:                // add a blank accounting line
338:                PurApAccountingLine purApAccountingLine = getNewAccount();
339:                setNewSourceLine(purApAccountingLine);
340:            }
341:
342:            /**
343:             * @see org.kuali.core.document.DocumentBase#buildListOfDeletionAwareLists()
344:             */
345:            @Override
346:            public List buildListOfDeletionAwareLists() {
347:                List managedLists = new ArrayList();
348:
349:                managedLists.add(getSourceAccountingLines());
350:
351:                return managedLists;
352:            }
353:
354:            /**
355:             * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
356:             */
357:            protected LinkedHashMap toStringMapper() {
358:                LinkedHashMap m = new LinkedHashMap();
359:                if (this .itemIdentifier != null) {
360:                    m.put("requisitionItemIdentifier", this .itemIdentifier
361:                            .toString());
362:                }
363:                return m;
364:            }
365:
366:            public PurApAccountingLine getNewSourceLine() {
367:                return newSourceLine;
368:            }
369:
370:            public void setNewSourceLine(PurApAccountingLine newAccountingLine) {
371:                this .newSourceLine = newAccountingLine;
372:            }
373:
374:            public Integer getPurapDocumentIdentifier() {
375:                return purapDocumentIdentifier;
376:            }
377:
378:            public void setPurapDocumentIdentifier(
379:                    Integer purapDocumentIdentifier) {
380:                this .purapDocumentIdentifier = purapDocumentIdentifier;
381:            }
382:
383:            public KualiDecimal getItemQuantity() {
384:                return itemQuantity;
385:            }
386:
387:            public void setItemQuantity(KualiDecimal itemQuantity) {
388:                this .itemQuantity = itemQuantity;
389:            }
390:
391:            public boolean isAccountListEmpty() {
392:                List<PurApAccountingLine> accounts = getSourceAccountingLines();
393:                if (ObjectUtils.isNotNull(accounts)) {
394:                    for (PurApAccountingLine element : accounts) {
395:                        if (!element.isEmpty()) {
396:                            return false;
397:                        }
398:                    }
399:                }
400:                return true;
401:            }
402:
403:            public PurApSummaryItem getSummaryItem() {
404:                PurApSummaryItem summaryItem = new PurApSummaryItem();
405:                PurApObjectUtils.populateFromBaseClass(PurApItemBase.class,
406:                        this , summaryItem, new HashMap());
407:                return summaryItem;
408:            }
409:
410:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.