Source Code Cross Referenced for ProcurementCardLoadTransactionsServiceImpl.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » financial » service » impl » 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.financial.service.impl 
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.financial.service.impl;
017:
018:        import java.io.FileInputStream;
019:        import java.io.FileNotFoundException;
020:        import java.io.IOException;
021:        import java.util.Collection;
022:        import java.util.HashMap;
023:        import java.util.List;
024:
025:        import org.apache.commons.io.IOUtils;
026:        import org.kuali.core.service.BusinessObjectService;
027:        import org.kuali.kfs.batch.BatchInputFileType;
028:        import org.kuali.kfs.exceptions.XMLParseException;
029:        import org.kuali.kfs.service.BatchInputFileService;
030:        import org.kuali.module.financial.bo.ProcurementCardTransaction;
031:        import org.kuali.module.financial.service.ProcurementCardLoadTransactionsService;
032:
033:        /**
034:         * This is the default implementation of the ProcurementCardLoadTransactionsService interface.
035:         * Handles loading, parsing, and storing of incoming procurement card batch files.
036:         * 
037:         * @see org.kuali.module.financial.service.ProcurementCardCreateDocumentService
038:         */
039:        public class ProcurementCardLoadTransactionsServiceImpl implements 
040:                ProcurementCardLoadTransactionsService {
041:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
042:                    .getLogger(ProcurementCardLoadTransactionsServiceImpl.class);
043:
044:            private BusinessObjectService businessObjectService;
045:            private BatchInputFileService batchInputFileService;
046:            private BatchInputFileType procurementCardInputFileType;
047:
048:            /**
049:             * Validates and parses the given file, then stores transactions into a temp table.
050:             * 
051:             * @param fileName The name of the file to be parsed.
052:             * @return This method always returns true.  An exception is thrown if a problem occurs while loading the file.
053:             * 
054:             * @see org.kuali.module.financial.service.ProcurementCardCreateDocumentService#loadProcurementCardFile()
055:             */
056:            public boolean loadProcurementCardFile(String fileName) {
057:                FileInputStream fileContents;
058:                try {
059:                    fileContents = new FileInputStream(fileName);
060:                } catch (FileNotFoundException e1) {
061:                    LOG.error("file to parse not found " + fileName, e1);
062:                    throw new RuntimeException(
063:                            "Cannot find the file requested to be parsed "
064:                                    + fileName + " " + e1.getMessage(), e1);
065:                }
066:
067:                Collection pcardTransactions = null;
068:                try {
069:                    byte[] fileByteContent = IOUtils.toByteArray(fileContents);
070:                    pcardTransactions = (Collection) batchInputFileService
071:                            .parse(procurementCardInputFileType,
072:                                    fileByteContent);
073:                } catch (IOException e) {
074:                    LOG.error("error while getting file bytes:  "
075:                            + e.getMessage(), e);
076:                    throw new RuntimeException(
077:                            "Error encountered while attempting to get file bytes: "
078:                                    + e.getMessage(), e);
079:                } catch (XMLParseException e) {
080:                    LOG.error("Error parsing xml " + e.getMessage());
081:                    throw new RuntimeException("Error parsing xml "
082:                            + e.getMessage(), e);
083:                }
084:
085:                if (pcardTransactions == null || pcardTransactions.isEmpty()) {
086:                    LOG.warn("No PCard transactions in input file " + fileName);
087:                }
088:
089:                loadTransactions((List) pcardTransactions);
090:
091:                LOG.info("Total transactions loaded: "
092:                        + Integer.toString(pcardTransactions.size()));
093:                return true;
094:            }
095:
096:            /**
097:             * Calls businessObjectService to remove all the procurement card transaction rows from the transaction load table.
098:             */
099:            public void cleanTransactionsTable() {
100:                businessObjectService.deleteMatching(
101:                        ProcurementCardTransaction.class, new HashMap());
102:            }
103:
104:            /**
105:             * Loads all the parsed XML transactions into the temp transaction table.
106:             * 
107:             * @param transactions List of ProcurementCardTransactions to load.
108:             */
109:            private void loadTransactions(List transactions) {
110:                businessObjectService.save(transactions);
111:            }
112:
113:            /**
114:             * Sets the businessObjectService attribute value.
115:             * @param businessObjectService The businessObjectService to set.
116:             */
117:            public void setBusinessObjectService(
118:                    BusinessObjectService businessObjectService) {
119:                this .businessObjectService = businessObjectService;
120:            }
121:
122:            /**
123:             * Sets the batchInputFileService attribute value.
124:             * @param batchInputFileService The batchInputFileService to set.
125:             */
126:            public void setBatchInputFileService(
127:                    BatchInputFileService batchInputFileService) {
128:                this .batchInputFileService = batchInputFileService;
129:            }
130:
131:            /**
132:             * Sets the procurementCardInputFileType attribute value.
133:             * @param procurementCardInputFileType The procurementCardInputFileType to set.
134:             */
135:            public void setProcurementCardInputFileType(
136:                    BatchInputFileType procurementCardInputFileType) {
137:                this.procurementCardInputFileType = procurementCardInputFileType;
138:            }
139:
140:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.