Source Code Cross Referenced for TestDataLoader.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » labor » util » 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.labor.util 
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.labor.util;
017:
018:        import static org.kuali.module.gl.bo.OriginEntrySource.LABOR_BACKUP;
019:        import static org.kuali.module.gl.bo.OriginEntrySource.LABOR_SCRUBBER_VALID;
020:
021:        import java.sql.Date;
022:        import java.util.ArrayList;
023:        import java.util.Arrays;
024:        import java.util.List;
025:        import java.util.Properties;
026:
027:        import org.apache.commons.lang.ArrayUtils;
028:        import org.apache.commons.lang.StringUtils;
029:        import org.kuali.core.service.BusinessObjectService;
030:        import org.kuali.kfs.KFSConstants;
031:        import org.kuali.module.gl.bo.OriginEntryGroup;
032:        import org.kuali.module.gl.web.TestDataGenerator;
033:        import org.kuali.module.labor.bo.LaborLedgerPendingEntry;
034:        import org.kuali.module.labor.bo.LaborOriginEntry;
035:        import org.kuali.module.labor.service.LaborOriginEntryService;
036:        import org.kuali.module.labor.service.impl.LaborScrubberProcess;
037:        import org.kuali.module.labor.util.testobject.PendingLedgerEntryForTesting;
038:
039:        public class TestDataLoader {
040:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
041:                    .getLogger(LaborScrubberProcess.class);
042:
043:            private Properties properties;
044:            private String fieldNames;
045:            private String fieldLength;
046:            private String deliminator;
047:
048:            private List<String> keyFieldList;
049:            private List<String> fieldLengthList;
050:
051:            private BusinessObjectService businessObjectService;
052:            private LaborOriginEntryService laborOriginEntryService;
053:
054:            public TestDataLoader() {
055:                String messageFileName = "test/src/org/kuali/module/labor/testdata/message.properties";
056:                String propertiesFileName = "test/src/org/kuali/module/labor/testdata/laborTransaction.properties";
057:
058:                properties = (new TestDataGenerator(propertiesFileName,
059:                        messageFileName)).getProperties();
060:                fieldNames = properties.getProperty("fieldNames");
061:                fieldLength = properties.getProperty("fieldLength");
062:                deliminator = properties.getProperty("deliminator");
063:
064:                LaborSpringContext.initializeApplicationContext();
065:                keyFieldList = Arrays.asList(StringUtils.split(fieldNames,
066:                        deliminator));
067:                fieldLengthList = Arrays.asList(StringUtils.split(fieldLength,
068:                        deliminator));
069:                businessObjectService = LaborSpringContext
070:                        .getBean(BusinessObjectService.class);
071:
072:                laborOriginEntryService = LaborSpringContext
073:                        .getBean(LaborOriginEntryService.class);
074:            }
075:
076:            public int loadTransactionIntoPendingEntryTable() {
077:                int numberOfInputData = Integer.valueOf(properties
078:                        .getProperty("numOfData"));
079:                int[] fieldLength = this .getFieldLength(fieldLengthList);
080:                return this .loadInputData("data", numberOfInputData,
081:                        keyFieldList, fieldLength);
082:            }
083:
084:            public int loadTransactionIntoOriginEntryTable(
085:                    OriginEntryGroup group) {
086:                int numberOfInputData = Integer.valueOf(properties
087:                        .getProperty("numOfData"));
088:                businessObjectService.save(group);
089:
090:                int[] fieldLength = this .getFieldLength(fieldLengthList);
091:                List<LaborOriginEntry> originEntries = this .loadInputData(
092:                        LaborOriginEntry.class, "data", numberOfInputData,
093:                        keyFieldList, fieldLength);
094:                for (LaborOriginEntry entry : originEntries) {
095:                    entry.setEntryGroupId(group.getId());
096:                }
097:
098:                businessObjectService.save(originEntries);
099:                return originEntries.size();
100:            }
101:
102:            private int loadInputData(String propertyKeyPrefix,
103:                    int numberOfInputData, List<String> keyFieldList,
104:                    int[] fieldLength) {
105:                int count = 0;
106:                for (int i = 1; i <= numberOfInputData; i++) {
107:                    String propertyKey = propertyKeyPrefix + i;
108:                    PendingLedgerEntryForTesting inputData = new PendingLedgerEntryForTesting();
109:                    ObjectUtil.populateBusinessObject(inputData, properties,
110:                            propertyKey, fieldLength, keyFieldList);
111:
112:                    if (businessObjectService.countMatching(
113:                            LaborLedgerPendingEntry.class, inputData
114:                                    .getPrimaryKeyMap()) <= 0) {
115:                        inputData
116:                                .setFinancialDocumentApprovedCode(KFSConstants.PENDING_ENTRY_APPROVED_STATUS_CODE.APPROVED);
117:                        businessObjectService.save(inputData);
118:                        count++;
119:                    }
120:                }
121:                return count;
122:            }
123:
124:            private List loadInputData(Class clazz, String propertyKeyPrefix,
125:                    int numberOfInputData, List<String> keyFieldList,
126:                    int[] fieldLength) {
127:                List inputDataList = new ArrayList();
128:                for (int i = 1; i <= numberOfInputData; i++) {
129:                    String propertyKey = propertyKeyPrefix + i;
130:                    try {
131:                        Object inputData = clazz.newInstance();
132:                        ObjectUtil.populateBusinessObject(inputData,
133:                                properties, propertyKey, fieldLength,
134:                                keyFieldList);
135:
136:                        inputDataList.add(inputData);
137:                    } catch (Exception e) {
138:                        e.printStackTrace();
139:                    }
140:                }
141:                return inputDataList;
142:            }
143:
144:            private int[] getFieldLength(List<String> fieldLengthList) {
145:                int[] fieldLengthArray = new int[fieldLengthList.size()];
146:                for (int i = 0; i < fieldLengthArray.length; i++) {
147:                    fieldLengthArray[i] = Integer.valueOf(fieldLengthList
148:                            .get(i).trim());
149:                }
150:                return fieldLengthArray;
151:            }
152:
153:            public static void main(String[] args) {
154:                TestDataLoader testDataLoader = new TestDataLoader();
155:                Date groupCreationDate = new Date(0);
156:
157:                if (ArrayUtils.isEmpty(args) || args.length < 2) {
158:                    System.out
159:                            .println("The program requires at least two arguments.");
160:                    return;
161:                }
162:
163:                if (!StringUtils.isAlphanumeric(args[0])) {
164:                    System.out
165:                            .println("The first argument should be a number.");
166:                    return;
167:                }
168:
169:                for (int numOfRound = Integer.parseInt(args[0]); numOfRound > 0; numOfRound--) {
170:                    if (ArrayUtils.contains(args, "poster")) {
171:                        OriginEntryGroup group = new OriginEntryGroup();
172:                        group.setSourceCode(LABOR_SCRUBBER_VALID);
173:                        group.setValid(true);
174:                        group.setScrub(false);
175:                        group.setProcess(true);
176:                        group.setDate(groupCreationDate);
177:                        int numOfData = testDataLoader
178:                                .loadTransactionIntoOriginEntryTable(group);
179:                        System.out
180:                                .println("Number of Origin Entries for Poster = "
181:                                        + numOfData);
182:                    }
183:
184:                    if (ArrayUtils.contains(args, "scrubber")) {
185:                        OriginEntryGroup group = new OriginEntryGroup();
186:                        group.setSourceCode(LABOR_BACKUP);
187:                        group.setValid(true);
188:                        group.setScrub(true);
189:                        group.setProcess(true);
190:                        group.setDate(groupCreationDate);
191:                        int numOfData = testDataLoader
192:                                .loadTransactionIntoOriginEntryTable(group);
193:                        System.out
194:                                .println("Number of Origin Entries for Scrubber = "
195:                                        + numOfData);
196:                    }
197:
198:                    if (ArrayUtils.contains(args, "pending")) {
199:                        int numOfData = testDataLoader
200:                                .loadTransactionIntoPendingEntryTable();
201:                        System.out.println("Number of Pending Entries = "
202:                                + numOfData);
203:                    }
204:                }
205:                System.exit(0);
206:            }
207:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.