Source Code Cross Referenced for ActivityWebEventProcessor.java in  » ERP-CRM-Financial » SourceTap-CRM » com » sourcetap » sfa » activity » 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.activity 
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.activity;
018:
019:        import java.sql.Timestamp;
020:        import java.util.Calendar;
021:        import java.util.HashMap;
022:        import java.util.List;
023:
024:        import javax.servlet.http.HttpServletRequest;
025:        import javax.servlet.http.HttpServletResponse;
026:
027:        import org.ofbiz.base.util.Debug;
028:        import org.ofbiz.entity.GenericDelegator;
029:        import org.ofbiz.entity.GenericEntityException;
030:        import org.ofbiz.entity.GenericValue;
031:
032:        import com.sourcetap.sfa.event.DataMatrix;
033:        import com.sourcetap.sfa.event.GenericEventProcessor;
034:        import com.sourcetap.sfa.event.GenericWebEventProcessor;
035:        import com.sourcetap.sfa.ui.UICache;
036:        import com.sourcetap.sfa.ui.UIWebScreenSection;
037:        import com.sourcetap.sfa.util.UserInfo;
038:
039:        /**
040:         * DOCUMENT ME!
041:         *
042:         */
043:        public class ActivityWebEventProcessor extends GenericWebEventProcessor {
044:            public static final String module = ActivityWebEventProcessor.class
045:                    .getName();
046:
047:            /**
048:             * DOCUMENT ME!
049:             *
050:             * @param userInfo 
051:             * @param uiWebScreenSection 
052:             * @param request 
053:             * @param response 
054:             * @param delegator 
055:             * @param eventProcessor 
056:             * @param dataMatrix 
057:             * @param uiCache 
058:             *
059:             * @return 
060:             */
061:            protected int preInsert(UserInfo userInfo,
062:                    UIWebScreenSection uiWebScreenSection,
063:                    HttpServletRequest request, HttpServletResponse response,
064:                    GenericDelegator delegator,
065:                    GenericEventProcessor eventProcessor,
066:                    DataMatrix dataMatrix, UICache uiCache) {
067:
068:                // If the screen section is on the composite account create window, need to copy the account ID
069:                // from the account to the activity.
070:
071:                if (request.getAttribute("com.sourcetap.sfa.account.accountId") != null) {
072:
073:                    String accountId = (String) request
074:                            .getAttribute("com.sourcetap.sfa.account.accountId");
075:                    GenericValue activityGV = dataMatrix.getCurrentBuffer()
076:                            .getGenericValue(0, 0);
077:
078:                    activityGV.set("accountId", accountId);
079:                }
080:
081:                return STATUS_CONTINUE;
082:            }
083:
084:            /**
085:             * DOCUMENT ME!
086:             *
087:             * @param userInfo 
088:             * @param uiWebScreenSection 
089:             * @param request 
090:             * @param response 
091:             * @param delegator 
092:             * @param eventProcessor 
093:             * @param dataMatrix 
094:             * @param uiCache 
095:             *
096:             * @return 
097:             */
098:            protected int postInsert(UserInfo userInfo,
099:                    UIWebScreenSection uiWebScreenSection,
100:                    HttpServletRequest request, HttpServletResponse response,
101:                    GenericDelegator delegator,
102:                    GenericEventProcessor eventProcessor,
103:                    DataMatrix dataMatrix, UICache uiCache) {
104:                // If the screen section is on the composite account or  contact create window, and a contact was created,
105:                // need to create an activity-contact record for the created activity and contact.
106:
107:                if (request.getAttribute("com.sourcetap.sfa.contact.contactId") != null) {
108:                    String contactId = (String) request
109:                            .getAttribute("com.sourcetap.sfa.contact.contactId");
110:                    GenericValue activityGV = dataMatrix.getCurrentBuffer()
111:                            .getGenericValue(0, 0);
112:                    String activityId = activityGV.getString("activityId");
113:
114:                    // Create the new ActivityContact generic value.
115:                    GenericValue activityContactGV = new GenericValue(delegator
116:                            .getModelEntity("ActivityContact"));
117:                    activityContactGV.setDelegator(delegator);
118:                    Timestamp currentTime = new Timestamp(Calendar
119:                            .getInstance().getTime().getTime());
120:                    activityContactGV.set("activityId", activityId);
121:                    activityContactGV.set("contactId", contactId);
122:                    activityContactGV.set("createdBy", userInfo.getPartyId());
123:                    activityContactGV.set("createdDate", currentTime);
124:                    activityContactGV.set("modifiedBy", userInfo.getPartyId());
125:                    activityContactGV.set("modifiedDate", currentTime);
126:
127:                    // Save the ActivityContact.
128:                    try {
129:                        delegator.create(activityContactGV);
130:                    } catch (GenericEntityException e) {
131:                        Debug
132:                                .logWarning(
133:                                        "Error inserting new ActivityContact. Save continued without inserting ActivityContact.",
134:                                        "postInsert");
135:                    }
136:                }
137:
138:                return STATUS_CONTINUE;
139:            }
140:
141:            /**
142:             * DOCUMENT ME!
143:             *
144:             * @param userInfo 
145:             * @param uiWebScreenSection 
146:             * @param request 
147:             * @param response 
148:             * @param delegator 
149:             * @param eventProcessor 
150:             * @param dataMatrix 
151:             * @param entityNameList 
152:             *
153:             * @return 
154:             */
155:            protected int postCreate(UserInfo userInfo,
156:                    UIWebScreenSection uiWebScreenSection,
157:                    HttpServletRequest request, HttpServletResponse response,
158:                    GenericDelegator delegator,
159:                    GenericEventProcessor eventProcessor,
160:                    DataMatrix dataMatrix, List entityNameList) {
161:
162:                GenericValue activityGV = dataMatrix.getCurrentBuffer()
163:                        .getGenericValue(0, 0);
164:
165:                // Set the Account ID.  This is done here instead of the regular event processor because the web event processor
166:                // has to set the contact, lead ID, or opportunity ID first so we can use it to look up the account.
167:                String accountId = "";
168:
169:                if (activityGV.getString("contactId") != null) {
170:                    // The contact ID is filled in.  Set the account ID.
171:                    String contactId = activityGV.getString("contactId");
172:
173:                    HashMap contactFindMap = new HashMap();
174:                    contactFindMap.put("contactId", contactId);
175:
176:                    try {
177:
178:                        GenericValue contactGV = delegator.findByPrimaryKey(
179:                                "Contact", contactFindMap);
180:
181:                        if (contactGV != null) {
182:
183:                            accountId = contactGV.getString("accountId");
184:                            activityGV.set("accountId", accountId);
185:                        }
186:                    } catch (GenericEntityException e) {
187:                        // An error occurred while looking for the contact record. Don't set the account ID.
188:                        Debug.logWarning("Error looking for contact: "
189:                                + e.getLocalizedMessage(), module);
190:                    }
191:                }
192:
193:                if (activityGV.getString("leadId") != null) {
194:                    // The lead ID is filled in.  Set the account ID.
195:                    String leadId = activityGV.getString("leadId");
196:
197:                    HashMap leadFindMap = new HashMap();
198:                    leadFindMap.put("leadId", leadId);
199:
200:                    try {
201:
202:                        GenericValue leadGV = delegator.findByPrimaryKey(
203:                                "Lead", leadFindMap);
204:
205:                        if (leadGV != null) {
206:
207:                            accountId = leadGV.getString("accountId");
208:                            activityGV.set("accountId", accountId);
209:                        }
210:                    } catch (GenericEntityException e) {
211:                        // An error occurred while looking for the lead record. Don't set the account ID.
212:                        Debug.logWarning("Error looking for lead: "
213:                                + e.getLocalizedMessage(), module);
214:                    }
215:                }
216:
217:                if (activityGV.getString("opportunityId") != null) {
218:                    // The contact ID is filled in.  Set the account ID.
219:                    String opportunityId = activityGV
220:                            .getString("opportunityId");
221:
222:                    HashMap dealFindMap = new HashMap();
223:                    dealFindMap.put("dealId", opportunityId);
224:
225:                    try {
226:
227:                        GenericValue dealGV = delegator.findByPrimaryKey(
228:                                "Deal", dealFindMap);
229:
230:                        if (dealGV != null) {
231:                            accountId = dealGV.getString("accountId");
232:                            activityGV.set("accountId", accountId);
233:                        }
234:                    } catch (GenericEntityException e) {
235:                        // An error occurred while looking for the contact record. Don't set the account ID.
236:                        Debug.logWarning("Error looking for contact: "
237:                                + e.getLocalizedMessage(), module);
238:                    }
239:                }
240:
241:                if ((accountId == null) || (accountId.length() < 1)) {
242:                    accountId = userInfo.getAccountId();
243:                    activityGV.set("accountId", accountId);
244:                }
245:
246:                return STATUS_CONTINUE;
247:            }
248:
249:            /**
250:             * This function gets the application path to be used to reconstruct the URI when a
251:             * UI History record is logged.  Example: "/accounts"
252:             * @author  John Nutting
253:             * @param url The URL used to open the screen section
254:             * @return String containing the application path
255:             */
256:            protected String getUiHistoryAppPath(String url) {
257:                return "/activities";
258:            }
259:
260:            /**
261:             * This function gets the description to store in the UI history table.  This description
262:             * will show up in the UI History drop list.
263:             * @author  John Nutting
264:             * @param dataMatrix DataMatrix object containing the data from the screen
265:             * @param delegator Generic delegator through which the data base is accessed
266:             * @param action The action being performed on the screen
267:             * @param uiWebScreenSection The UIWebScreenSection being used to construct the screen section
268:             * @return String containing the UI History description
269:             */
270:            protected String getUiHistoryDescription(DataMatrix dataMatrix,
271:                    GenericDelegator delegator, String action,
272:                    UIWebScreenSection uiWebScreenSection) {
273:                GenericValue primaryGV = dataMatrix.getCurrentBuffer()
274:                        .getGenericValue(0, 0);
275:
276:                return "Activity: "
277:                        + ((primaryGV.getString("activityName") == null) ? ""
278:                                : primaryGV.getString("activityName"));
279:            }
280:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.