Source Code Cross Referenced for ContactWebEventProcessor.java in  » ERP-CRM-Financial » SourceTap-CRM » com » sourcetap » sfa » contact » 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.contact 
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.contact;
018:
019:        import java.util.HashMap;
020:        import java.util.Iterator;
021:        import java.util.List;
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.event.DataMatrix;
032:        import com.sourcetap.sfa.event.GenericEventProcessor;
033:        import com.sourcetap.sfa.event.GenericWebEventProcessor;
034:        import com.sourcetap.sfa.ui.UICache;
035:        import com.sourcetap.sfa.ui.UIWebScreenSection;
036:        import com.sourcetap.sfa.util.UserInfo;
037:
038:        /**
039:         * DOCUMENT ME!
040:         *
041:         */
042:        public class ContactWebEventProcessor extends GenericWebEventProcessor {
043:            public static final String module = ContactWebEventProcessor.class
044:                    .getName();
045:
046:            /**
047:             * DOCUMENT ME!
048:             *
049:             * @param userInfo 
050:             * @param uiWebScreenSection 
051:             * @param request 
052:             * @param response 
053:             * @param delegator 
054:             * @param eventProcessor 
055:             * @param dataMatrix 
056:             * @param uiCache 
057:             *
058:             * @return 
059:             */
060:            protected int preInsert(UserInfo userInfo,
061:                    UIWebScreenSection uiWebScreenSection,
062:                    HttpServletRequest request, HttpServletResponse response,
063:                    GenericDelegator delegator,
064:                    GenericEventProcessor eventProcessor,
065:                    DataMatrix dataMatrix, UICache uiCache) {
066:
067:                // If the screen section is on the composite account create window, need to copy the account ID
068:                // from the account to the contact.
069:
070:                if (request.getAttribute("com.sourcetap.sfa.account.accountId") != null) {
071:                    String accountId = (String) request
072:                            .getAttribute("com.sourcetap.sfa.account.accountId");
073:                    GenericValue contactGV = dataMatrix.getCurrentBuffer()
074:                            .getGenericValue(0, 0);
075:
076:                    contactGV.set("accountId", accountId);
077:                }
078:
079:                return STATUS_CONTINUE;
080:            }
081:
082:            /**
083:             * DOCUMENT ME!
084:             *
085:             * @param userInfo 
086:             * @param uiWebScreenSection 
087:             * @param request 
088:             * @param response 
089:             * @param delegator 
090:             * @param eventProcessor 
091:             * @param dataMatrix 
092:             * @param entityNameList 
093:             *
094:             * @return 
095:             */
096:            protected int postCreate(UserInfo userInfo,
097:                    UIWebScreenSection uiWebScreenSection,
098:                    HttpServletRequest request, HttpServletResponse response,
099:                    GenericDelegator delegator,
100:                    GenericEventProcessor eventProcessor,
101:                    DataMatrix dataMatrix, List entityNameList) {
102:
103:                GenericValue contactGV = dataMatrix.getCurrentBuffer()
104:                        .getGenericValue(0, 0);
105:                GenericValue addressGV = dataMatrix.getCurrentBuffer()
106:                        .getGenericValue(0, 1);
107:
108:                // Copy the account address to the new contact.  This is done here instead of the regular
109:                // event processor because the web event processor has to set the account ID fist so we
110:                // can use it to look up the address.
111:                if (contactGV.getString("accountId") != null) {
112:                    // The account ID is filled in.  Get it.
113:                    String accountId = contactGV.getString("accountId");
114:
115:                    HashMap accountFindMap = new HashMap();
116:                    accountFindMap.put("accountId", accountId);
117:
118:                    try {
119:
120:                        GenericValue accountGV = delegator.findByPrimaryKey(
121:                                "Account", accountFindMap);
122:
123:                        if (accountGV != null) {
124:
125:                            String phone = accountGV.getString("phone");
126:                            String fax = accountGV.getString("fax");
127:
128:                            contactGV.set("businessPhone", phone);
129:                            contactGV.set("faxPhone", fax);
130:                        }
131:                    } catch (GenericEntityException e) {
132:                        // An error occurred while looking for the account record.
133:                        Debug.logError(
134:                                "-->[ContactWebEventProcessor.postCreate] Error looking for account: "
135:                                        + e.getLocalizedMessage(), module);
136:                    }
137:
138:                    HashMap addressFindMap = new HashMap();
139:                    addressFindMap.put("addressOwnerId", accountId);
140:                    addressFindMap.put("isPrimary", "Y");
141:
142:                    try {
143:
144:                        List accountAddressGVL = delegator.findByAnd("Address",
145:                                addressFindMap);
146:
147:                        if (accountAddressGVL.size() > 0) {
148:                            // The account has an address.  Copy the address fields to the contact's address.
149:
150:                            Iterator accountAddressGVI = accountAddressGVL
151:                                    .iterator();
152:                            GenericValue accountAddressGV = (GenericValue) accountAddressGVI
153:                                    .next();
154:                            String mailingAddress = accountAddressGV
155:                                    .getString("mailingAddress");
156:                            String city = accountAddressGV.getString("city");
157:                            String state = accountAddressGV.getString("state");
158:                            String zip = accountAddressGV.getString("zip");
159:                            String country = accountAddressGV
160:                                    .getString("country");
161:
162:                            addressGV.set("mailingAddress", mailingAddress);
163:                            addressGV.set("city", city);
164:                            addressGV.set("state", state);
165:                            addressGV.set("zip", zip);
166:                            addressGV.set("country", country);
167:                        }
168:                    } catch (GenericEntityException e) {
169:                        // An error occurred while looking for the contact record. Don't set the account ID.
170:                        Debug.logError(
171:                                "-->[ContactWebEventProcessor.postCreate] Error looking for address: "
172:                                        + e.getLocalizedMessage(), module);
173:                    }
174:                }
175:
176:                return STATUS_CONTINUE;
177:            }
178:
179:            /**
180:             * DOCUMENT ME!
181:             *
182:             * @param userInfo 
183:             * @param uiWebScreenSection 
184:             * @param request 
185:             * @param response 
186:             * @param delegator 
187:             * @param eventProcessor 
188:             * @param dataMatrix 
189:             * @param uiCache 
190:             *
191:             * @return 
192:             */
193:            protected int postInsert(UserInfo userInfo,
194:                    UIWebScreenSection uiWebScreenSection,
195:                    HttpServletRequest request, HttpServletResponse response,
196:                    GenericDelegator delegator,
197:                    GenericEventProcessor eventProcessor,
198:                    DataMatrix dataMatrix, UICache uiCache) {
199:
200:                // Need to get the contact ID and store it
201:                // in the request object so the other event processors can read it and store
202:                //  it on the other entities being created.
203:                GenericValue contactGV = dataMatrix.getCurrentBuffer()
204:                        .getGenericValue(0, 0);
205:                String contactId = contactGV.getString("contactId");
206:
207:                request.setAttribute("com.sourcetap.sfa.contact.contactId",
208:                        contactId);
209:
210:                return STATUS_CONTINUE;
211:            }
212:
213:            /**
214:             * This function gets the application path to be used to reconstruct the URI when a
215:             * UI History record is logged.  Example: "/accounts"
216:             * @author  John Nutting
217:             * @param url The URL used to open the screen section
218:             * @return String containing the application path
219:             */
220:            protected String getUiHistoryAppPath(String url) {
221:                return "/contacts";
222:            }
223:
224:            /**
225:             * This function gets the description to store in the UI history table.  This description
226:             * will show up in the UI History drop list.
227:             * @author  John Nutting
228:             * @param dataMatrix DataMatrix object containing the data from the screen
229:             * @param delegator Generic delegator through which the data base is accessed
230:             * @param action The action being performed on the screen
231:             * @param uiWebScreenSection The UIWebScreenSection being used to construct the screen section
232:             * @return String containing the UI History description
233:             */
234:            protected String getUiHistoryDescription(DataMatrix dataMatrix,
235:                    GenericDelegator delegator, String action,
236:                    UIWebScreenSection uiWebScreenSection) {
237:                GenericValue primaryGV = dataMatrix.getCurrentBuffer()
238:                        .getGenericValue(0, 0);
239:
240:                return "Contact: " + primaryGV.getString("firstName") + " "
241:                        + primaryGV.getString("lastName");
242:            }
243:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.