Source Code Cross Referenced for OpportunityTeamSelectEP.java in  » ERP-CRM-Financial » SourceTap-CRM » com » sourcetap » sfa » opportunity » 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.opportunity 
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.opportunity;
018:
019:        import java.sql.Timestamp;
020:        import java.util.Calendar;
021:        import java.util.HashMap;
022:        import java.util.Iterator;
023:        import java.util.LinkedList;
024:        import java.util.List;
025:        import java.util.Map;
026:        import java.util.Vector;
027:
028:        import org.ofbiz.base.util.Debug;
029:        import org.ofbiz.entity.GenericDelegator;
030:        import org.ofbiz.entity.GenericEntityException;
031:        import org.ofbiz.entity.GenericValue;
032:        import org.ofbiz.entity.model.ModelEntity;
033:
034:        import com.sourcetap.sfa.event.DataMatrix;
035:        import com.sourcetap.sfa.event.GenericEventProcessor;
036:        import com.sourcetap.sfa.security.SecurityWrapper;
037:        import com.sourcetap.sfa.util.QueryInfo;
038:        import com.sourcetap.sfa.util.UserInfo;
039:
040:        /**
041:         * DOCUMENT ME!
042:         *
043:         */
044:        public class OpportunityTeamSelectEP extends GenericEventProcessor {
045:            public static final String module = OpportunityTeamSelectEP.class
046:                    .getName();
047:
048:            /**
049:             * DOCUMENT ME!
050:             *
051:             * @param userInfo 
052:             * @param mainEntityName 
053:             * @param method 
054:             * @param fields 
055:             * @param orderBy 
056:             * @param queryInfo  criteria to be used in search 
057:             * @param relatedSearchClauses 
058:             * @param delegator 
059:             * @param dataMatrix 
060:             *
061:             * @return 
062:             */
063:            public int retrieve(UserInfo userInfo, String mainEntityName,
064:                    int method, Map fields, List orderBy, QueryInfo queryInfo,
065:                    List relatedSearchClauses, GenericDelegator delegator,
066:                    DataMatrix dataMatrix) {
067:
068:                // The main entity is the TeamMember because it is the primary table we are going to update.
069:                List mainGVL = new LinkedList();
070:                GenericValue entityAccessGV = null;
071:
072:                // First get the deal or account ID from the entityClauses.
073:                String entityName = "";
074:                String entityId = "";
075:                String fieldName = "";
076:
077:                if (1 == 0)
078:                    throw new IllegalArgumentException(
079:                            "need to fix query clauses");
080:                /*        for (int entityClauseNbr = 0; entityClauseNbr < entityClauses.size();
081:                 entityClauseNbr++) {
082:                 EntityClause entityClause = (EntityClause) entityClauses.get(entityClauseNbr);
083:                 fieldName = entityClause.getFirstField();
084:
085:                 if (entityClause.getSecondEntity().trim().length() == 0) {
086:                 // This entity clause has a value, and could be a query parameter.  See if it's the dealId or accountId.
087:                 if (fieldName.equals("dealId")) {
088:                 entityId = (String) entityClause.getValue();
089:                 entityName = "Deal";
090:
091:                 break;
092:                 } else if (fieldName.equals("accountId")) {
093:                 entityId = (String) entityClause.getValue();
094:                 entityName = "Account";
095:
096:                 break;
097:                 }
098:                 }
099:                 }
100:                 */
101:                if (!entityId.equals("") && (entityId != null)
102:                        && !entityName.equals("") && (entityName != null)) {
103:                    // Found account ID or deal ID.  Next find the entity acccess record for the team tied to the account or deal.
104:                    HashMap entityAccessFindMap = new HashMap();
105:                    entityAccessFindMap.put("entityId", entityId);
106:                    entityAccessFindMap.put("entity", entityName);
107:                    entityAccessFindMap.put("partyEntityType", "Team");
108:
109:                    try {
110:                        List entityAccessGVL = delegator.findByAnd(
111:                                "EntityAccess", entityAccessFindMap);
112:                        Iterator entityAccessGVI = entityAccessGVL.iterator();
113:
114:                        if (entityAccessGVI.hasNext()) {
115:                            entityAccessGV = (GenericValue) entityAccessGVI
116:                                    .next();
117:
118:                            String teamId = entityAccessGV.getString("partyId");
119:
120:                            // Get the team members tied to this entity access record.
121:                            HashMap teamMemberFindMap = new HashMap();
122:                            teamMemberFindMap.put("teamId", teamId);
123:
124:                            try {
125:                                mainGVL = delegator.findByAnd("TeamMember",
126:                                        teamMemberFindMap);
127:                            } catch (GenericEntityException e) {
128:                                Debug
129:                                        .logError(
130:                                                "[OpportunityTeamSelectEP.retrieveMainEntity] An error occurred while searching for "
131:                                                        + "the team member records for the account or deal: "
132:                                                        + e
133:                                                                .getLocalizedMessage(),
134:                                                module);
135:
136:                                return STATUS_ERROR;
137:                            }
138:                        } else {
139:                            // No entity access record was found.  Assume no team member records are in the data base.
140:                            return STATUS_CONTINUE;
141:                        }
142:                    } catch (GenericEntityException e) {
143:                        Debug
144:                                .logError(
145:                                        "[OpportunityTeamSelectEP.retrieveMainEntity] An error occurred while searching for "
146:                                                + "the entity access record for the account or deal: "
147:                                                + e.getLocalizedMessage(),
148:                                        module);
149:
150:                        return STATUS_ERROR;
151:                    }
152:                } else {
153:                    // Neither the Account ID nor the Deal ID were found.  Assume no team member records are in the data base.
154:                    return STATUS_CONTINUE;
155:                }
156:
157:                // Put all the rows into the data matrix.
158:                Iterator mainGVI = mainGVL.iterator();
159:                int rowCount = 0;
160:
161:                while (mainGVI.hasNext()) {
162:                    rowCount++;
163:
164:                    GenericValue mainGV = (GenericValue) mainGVI.next();
165:
166:                    // For each instance of the main entity, start a vector of entities, and then
167:                    // retrieve the associated entities and add them also.
168:                    Vector outGVV = new Vector();
169:                    outGVV.add(mainGV);
170:
171:                    // Get the contact tied to this team member.
172:                    GenericValue contactGV = null;
173:
174:                    try {
175:                        contactGV = delegator.getRelatedOne("Contact", mainGV);
176:                    } catch (GenericEntityException e) {
177:                        Debug
178:                                .logError(
179:                                        "[OpportunityTeamSelectEP.retrieveMainEntity] An error occurred while searching for "
180:                                                + "the contact for a team member: "
181:                                                + e.getLocalizedMessage(),
182:                                        module);
183:
184:                        return STATUS_ERROR;
185:                    }
186:
187:                    // Get the team tied to this team member.
188:                    GenericValue teamGV = null;
189:
190:                    try {
191:                        teamGV = delegator.getRelatedOne("Team", mainGV);
192:                    } catch (GenericEntityException e) {
193:                        Debug
194:                                .logError(
195:                                        "[OpportunityTeamSelectEP.retrieveMainEntity] An error occurred while searching for "
196:                                                + "the team for a team member: "
197:                                                + e.getLocalizedMessage(),
198:                                        module);
199:
200:                        return STATUS_ERROR;
201:                    }
202:
203:                    // Get the deal or account.
204:                    GenericValue dealOrAccountGV = null;
205:                    HashMap dealOrAccountPkMap = new HashMap();
206:                    dealOrAccountPkMap.put(fieldName, entityId);
207:
208:                    try {
209:                        dealOrAccountGV = delegator.findByPrimaryKey(
210:                                entityName, dealOrAccountPkMap);
211:                    } catch (GenericEntityException e) {
212:                        Debug
213:                                .logError(
214:                                        "[OpportunityTeamSelectEP.retrieveMainEntity] An error occurred while searching for "
215:                                                + "the deal or account: "
216:                                                + e.getLocalizedMessage(),
217:                                        module);
218:
219:                        return STATUS_ERROR;
220:                    }
221:
222:                    // Add the data to the data matrix.
223:                    outGVV.add(contactGV);
224:                    outGVV.add(entityAccessGV);
225:                    outGVV.add(teamGV);
226:                    outGVV.add(dealOrAccountGV);
227:                    dataMatrix.getCurrentBuffer().addContentsRow(outGVV);
228:                }
229:
230:                return STATUS_CONTINUE;
231:            }
232:
233:            /**
234:             * DOCUMENT ME!
235:             *
236:             * @param primaryModelEntity 
237:             * @param removeMap 
238:             * @param userInfo 
239:             * @param delegator 
240:             *
241:             * @return 
242:             */
243:            protected int deleteOneSelect(ModelEntity primaryModelEntity,
244:                    HashMap removeMap, UserInfo userInfo,
245:                    GenericDelegator delegator) {
246:
247:                String contactId = ((String) removeMap.get("contactId") == null) ? ""
248:                        : (String) removeMap.get("contactId");
249:                String teamId = ((String) removeMap.get("teamId") == null) ? ""
250:                        : (String) removeMap.get("teamId");
251:
252:                SecurityWrapper.removeTeamMember(teamId, contactId, userInfo,
253:                        delegator);
254:
255:                return STATUS_CONTINUE;
256:            }
257:
258:            /**
259:             * DOCUMENT ME!
260:             *
261:             * @param primaryModelEntity 
262:             * @param createMap 
263:             * @param userInfo 
264:             * @param delegator 
265:             *
266:             * @return 
267:             */
268:            protected int insertOneSelect(ModelEntity primaryModelEntity,
269:                    HashMap createMap, UserInfo userInfo,
270:                    GenericDelegator delegator) {
271:
272:                String contactId = ((String) createMap.get("contactId") == null) ? ""
273:                        : (String) createMap.get("contactId");
274:                String teamId = ((String) createMap.get("teamId") == null) ? ""
275:                        : (String) createMap.get("teamId");
276:
277:                SecurityWrapper.addTeamMember(teamId, contactId, userInfo,
278:                        delegator);
279:
280:                return STATUS_CONTINUE;
281:            }
282:
283:            /**
284:             * DOCUMENT ME!
285:             *
286:             * @param userInfo 
287:             * @param delegator 
288:             * @param dataMatrix 
289:             *
290:             * @return 
291:             */
292:            protected int preUpdate(UserInfo userInfo,
293:                    GenericDelegator delegator, DataMatrix dataMatrix) {
294:
295:                Timestamp now = new Timestamp(Calendar.getInstance().getTime()
296:                        .getTime());
297:
298:                // Process all rows.
299:                for (int row = 0; row < dataMatrix.getCurrentBuffer()
300:                        .getRowCount(); row++) {
301:                    if (dataMatrix.getRowChanged(row)) {
302:                        GenericValue teamMemberGV = dataMatrix
303:                                .getCurrentBuffer().getGenericValue(row, 0);
304:
305:                        //				GenericValue contactGV = dataMatrix.getCurrentBuffer().getGenericValue(row, 1);
306:                        //				GenericValue entityAccessGV = dataMatrix.getCurrentBuffer().getGenericValue(row, 2);
307:                        //				GenericValue teamGV = dataMatrix.getCurrentBuffer().getGenericValue(row, 3);
308:                        //				GenericValue dealGV = dataMatrix.getCurrentBuffer().getGenericValue(row, 4);
309:                        // Set the time stamps.
310:                        teamMemberGV.set("modifiedDate", now);
311:
312:                        // Store the current user's party ID in the "modified by" field.
313:                        teamMemberGV.set("modifiedBy", userInfo.getPartyId());
314:                    }
315:                }
316:
317:                return STATUS_CONTINUE;
318:            }
319:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.