Source Code Cross Referenced for GenericImportEventProcessor.java in  » ERP-CRM-Financial » SourceTap-CRM » com » sourcetap » sfa » event » 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 » SourceTap CRM » com.sourcetap.sfa.event 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * 
003:         * Copyright (c) 2004 SourceTap - www.sourcetap.com
004:         *
005:         *  The contents of this file are subject to the SourceTap Public License 
006:         * ("License"); You may not use this file except in compliance with the 
007:         * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
008:         * Software distributed under the License is distributed on an  "AS IS"  basis,
009:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
010:         * the specific language governing rights and limitations under the License.
011:         *
012:         * The above copyright notice and this permission notice shall be included
013:         * in all copies or substantial portions of the Software.
014:         *
015:         */
016:
017:        package com.sourcetap.sfa.event;
018:
019:        import java.util.Iterator;
020:        import java.util.List;
021:        import java.util.Vector;
022:
023:        import javax.servlet.http.HttpServletRequest;
024:        import javax.servlet.http.HttpServletResponse;
025:
026:        import org.ofbiz.base.util.Debug;
027:        import org.ofbiz.entity.GenericDelegator;
028:        import org.ofbiz.entity.GenericEntityException;
029:        import org.ofbiz.entity.GenericValue;
030:
031:        import com.sourcetap.sfa.ui.UICache;
032:        import com.sourcetap.sfa.ui.UIScreenSection;
033:        import com.sourcetap.sfa.ui.UIWebScreenSection;
034:        import com.sourcetap.sfa.util.UserInfo;
035:
036:        /**
037:         * DOCUMENT ME!
038:         *
039:         */
040:        public class GenericImportEventProcessor {
041:            public static final int STATUS_ERROR = -1;
042:            public static final int STATUS_CANCEL = 0;
043:            public static final int STATUS_CONTINUE = 1;
044:            private static final boolean TIMER = false;
045:            public static final String module = GenericImportEventProcessor.class
046:                    .getName();
047:
048:            public GenericImportEventProcessor() {
049:            }
050:
051:            //-------------------------------------------------------------------------
052:            // INSERT - Inserts a new set of entities into the data base.
053:            //-------------------------------------------------------------------------
054:            public int processInsert(UserInfo userInfo,
055:                    UIWebScreenSection uiWebScreenSection,
056:                    HttpServletRequest request, HttpServletResponse response,
057:                    GenericDelegator delegator,
058:                    GenericEventProcessor eventProcessor,
059:                    DataMatrix dataMatrix, Vector dataValues,
060:                    Vector importFields, UICache uiCache)
061:                    throws GenericEntityException {
062:
063:                int status = STATUS_CONTINUE;
064:
065:                //TODO TO DO validateData( uiWebScreenSection, dataValues, importFields, )
066:
067:                status = eventProcessor.processCreate(userInfo,
068:                        uiWebScreenSection.getEntityNameList(), delegator,
069:                        dataMatrix);
070:
071:                if (status != STATUS_CONTINUE) {
072:                    return status;
073:                }
074:
075:                // Pre fill the data matrix from the info entered on the screen.
076:                dataMatrix.addRowFromArray(0, dataValues, importFields,
077:                        uiWebScreenSection);
078:
079:                // Trigger the pre-insert event.
080:                status = this .preInsert(userInfo, uiWebScreenSection, request,
081:                        response, delegator, eventProcessor, dataMatrix,
082:                        uiCache);
083:
084:                if (status != STATUS_CONTINUE) {
085:                    return status;
086:                }
087:
088:                // Trigger the insert event.
089:                status = this .insert(userInfo, uiWebScreenSection, request,
090:                        response, delegator, eventProcessor, dataMatrix,
091:                        uiCache);
092:
093:                if (status != STATUS_CONTINUE) {
094:                    return status;
095:                }
096:
097:                // Trigger the post-insert event.
098:                status = this .postInsert(userInfo, uiWebScreenSection, request,
099:                        response, delegator, eventProcessor, dataMatrix,
100:                        uiCache);
101:
102:                return status;
103:            }
104:
105:            /**
106:             * DOCUMENT ME!
107:             *
108:             * @param userInfo 
109:             * @param uiWebScreenSection 
110:             * @param request 
111:             * @param response 
112:             * @param delegator 
113:             * @param eventProcessor 
114:             * @param dataMatrix 
115:             * @param uiCache 
116:             *
117:             * @return 
118:             */
119:            protected int preInsert(UserInfo userInfo,
120:                    UIWebScreenSection uiWebScreenSection,
121:                    HttpServletRequest request, HttpServletResponse response,
122:                    GenericDelegator delegator,
123:                    GenericEventProcessor eventProcessor,
124:                    DataMatrix dataMatrix, UICache uiCache) {
125:
126:                return STATUS_CONTINUE;
127:            }
128:
129:            /**
130:             * DOCUMENT ME!
131:             *
132:             * @param userInfo 
133:             * @param uiWebScreenSection 
134:             * @param request 
135:             * @param response 
136:             * @param delegator 
137:             * @param eventProcessor 
138:             * @param dataMatrix 
139:             * @param uiCache 
140:             *
141:             * @return 
142:             *
143:             * @throws GenericEntityException 
144:             */
145:            protected int insert(UserInfo userInfo,
146:                    UIWebScreenSection uiWebScreenSection,
147:                    HttpServletRequest request, HttpServletResponse response,
148:                    GenericDelegator delegator,
149:                    GenericEventProcessor eventProcessor,
150:                    DataMatrix dataMatrix, UICache uiCache)
151:                    throws GenericEntityException {
152:
153:                int status = eventProcessor.processInsert(userInfo, delegator,
154:                        dataMatrix);
155:
156:                Debug.logVerbose("Data matrix after insert: "
157:                        + dataMatrix.getCurrentBuffer().getContents()
158:                                .toString(), module);
159:
160:                return status;
161:            }
162:
163:            /**
164:             * DOCUMENT ME!
165:             *
166:             * @param userInfo 
167:             * @param uiWebScreenSection 
168:             * @param request 
169:             * @param response 
170:             * @param delegator 
171:             * @param eventProcessor 
172:             * @param dataMatrix 
173:             * @param uiCache 
174:             *
175:             * @return 
176:             */
177:            protected int postInsert(UserInfo userInfo,
178:                    UIWebScreenSection uiWebScreenSection,
179:                    HttpServletRequest request, HttpServletResponse response,
180:                    GenericDelegator delegator,
181:                    GenericEventProcessor eventProcessor,
182:                    DataMatrix dataMatrix, UICache uiCache) {
183:
184:                return STATUS_CONTINUE;
185:            }
186:
187:            //-------------------------------------------------------------------------
188:            // CREATE - Creates a blank set of entities to prepare for an INSERT.
189:            //-------------------------------------------------------------------------
190:            protected int processCreate(UserInfo userInfo,
191:                    UIWebScreenSection uiWebScreenSection,
192:                    HttpServletRequest request, HttpServletResponse response,
193:                    GenericDelegator delegator,
194:                    GenericEventProcessor eventProcessor, DataMatrix dataMatrix)
195:                    throws GenericEntityException {
196:
197:                int status = STATUS_CONTINUE;
198:
199:                // Create a List of entity names from which the empty entities will be created.
200:                //		if (DEBUG) Debug.logVerbose("[create] About to create an empty generic value vector List.");
201:                List entityNameList = uiWebScreenSection.getEntityNameList();
202:
203:                // Trigger the pre-create event.
204:                status = this .preCreate(userInfo, uiWebScreenSection, request,
205:                        response, delegator, eventProcessor, dataMatrix,
206:                        entityNameList);
207:
208:                if (status != STATUS_CONTINUE) {
209:                    return status;
210:                }
211:
212:                // Trigger the create event.
213:                status = this .create(userInfo, uiWebScreenSection, request,
214:                        response, delegator, eventProcessor, dataMatrix,
215:                        entityNameList);
216:
217:                if (status != STATUS_CONTINUE) {
218:                    return status;
219:                }
220:
221:                // Trigger the post-create event.
222:                status = this .postCreate(userInfo, uiWebScreenSection, request,
223:                        response, delegator, eventProcessor, dataMatrix,
224:                        entityNameList);
225:
226:                return status;
227:            }
228:
229:            /**
230:             * DOCUMENT ME!
231:             *
232:             * @param userInfo 
233:             * @param uiWebScreenSection 
234:             * @param request 
235:             * @param response 
236:             * @param delegator 
237:             * @param eventProcessor 
238:             * @param dataMatrix 
239:             * @param entityNameList 
240:             *
241:             * @return 
242:             */
243:            protected int preCreate(UserInfo userInfo,
244:                    UIWebScreenSection uiWebScreenSection,
245:                    HttpServletRequest request, HttpServletResponse response,
246:                    GenericDelegator delegator,
247:                    GenericEventProcessor eventProcessor,
248:                    DataMatrix dataMatrix, List entityNameList) {
249:
250:                return STATUS_CONTINUE;
251:            }
252:
253:            /**
254:             * DOCUMENT ME!
255:             *
256:             * @param userInfo 
257:             * @param uiWebScreenSection 
258:             * @param request 
259:             * @param response 
260:             * @param delegator 
261:             * @param eventProcessor 
262:             * @param dataMatrix 
263:             * @param entityNameList 
264:             *
265:             * @return 
266:             *
267:             * @throws GenericEntityException 
268:             */
269:            protected int create(UserInfo userInfo,
270:                    UIWebScreenSection uiWebScreenSection,
271:                    HttpServletRequest request, HttpServletResponse response,
272:                    GenericDelegator delegator,
273:                    GenericEventProcessor eventProcessor,
274:                    DataMatrix dataMatrix, List entityNameList)
275:                    throws GenericEntityException {
276:
277:                int status = eventProcessor.processCreate(userInfo,
278:                        entityNameList, delegator, dataMatrix);
279:
280:                // For each attribute in the data matrix, look for HTML parameters in the
281:                // request object to set default values.
282:                Vector genericValueVector = dataMatrix.getCurrentBuffer()
283:                        .getContentsRow(0);
284:
285:                for (int entityNbr = 0; entityNbr < genericValueVector.size(); entityNbr++) {
286:                    GenericValue gV = (GenericValue) genericValueVector
287:                            .get(entityNbr);
288:                    String entityName = gV.getEntityName();
289:
290:                    //			List fieldNames = gV.getModelEntity().getNoPkFieldNames();
291:                    List fieldNames = gV.getModelEntity().getAllFieldNames();
292:                    Iterator fieldNameI = fieldNames.iterator();
293:
294:                    while (fieldNameI.hasNext()) {
295:                        String fieldName = (String) fieldNameI.next();
296:
297:                        if (request.getParameter(fieldName) != null) {
298:                            // A parameter was passed in to set this value. Store it in the data matrix.
299:                            String defaultValue = request
300:                                    .getParameter(fieldName);
301:                            EventUtility.storeValue(gV, fieldName,
302:                                    defaultValue, delegator);
303:                        } else {
304:                            // Check for a parameter with the entity name as a prefix.
305:                            String parameterName = entityName + "_" + fieldName;
306:
307:                            if (request.getParameter(parameterName) != null) {
308:                                // A parameter was passed in to set this value. Store it in the data matrix.
309:                                String defaultValue = request
310:                                        .getParameter(parameterName);
311:                                EventUtility.storeValue(gV, fieldName,
312:                                        defaultValue, delegator);
313:                            }
314:                        }
315:                    }
316:                }
317:
318:                return status;
319:            }
320:
321:            /**
322:             * DOCUMENT ME!
323:             *
324:             * @param userInfo 
325:             * @param uiWebScreenSection 
326:             * @param request 
327:             * @param response 
328:             * @param delegator 
329:             * @param eventProcessor 
330:             * @param dataMatrix 
331:             * @param entityNameList 
332:             *
333:             * @return 
334:             */
335:            protected int postCreate(UserInfo userInfo,
336:                    UIWebScreenSection uiWebScreenSection,
337:                    HttpServletRequest request, HttpServletResponse response,
338:                    GenericDelegator delegator,
339:                    GenericEventProcessor eventProcessor,
340:                    DataMatrix dataMatrix, List entityNameList) {
341:
342:                return STATUS_CONTINUE;
343:            }
344:
345:            /**
346:             * DOCUMENT ME!
347:             *
348:             * @param userInfo 
349:             * @param screenName 
350:             * @param sectionName 
351:             * @param delegator 
352:             * @param uiCache 
353:             *
354:             * @return 
355:             *
356:             * @throws GenericEntityException 
357:             */
358:            public UIWebScreenSection getUiWebScreenSection(UserInfo userInfo,
359:                    String screenName, String sectionName,
360:                    GenericDelegator delegator, UICache uiCache)
361:                    throws GenericEntityException {
362:
363:                return UIWebScreenSection.getUiWebScreenSection(userInfo,
364:                        screenName, sectionName, delegator, uiCache);
365:            }
366:
367:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.