You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ha...@apache.org on 2008/07/21 06:15:44 UTC
svn commit: r678341 - in /ofbiz/trunk/applications:
content/ofbiz-component.xml content/servicedef/mca.xml
content/src/org/ofbiz/content/email/EmailServices.java
party/data/PartyTypeData.xml
Author: hansbak
Date: Sun Jul 20 21:15:42 2008
New Revision: 678341
URL: http://svn.apache.org/viewvc?rev=678341&view=rev
Log:
add new roles for communicationevents and properly assign them for incoming emails aded mca file
Added:
ofbiz/trunk/applications/content/servicedef/mca.xml (with props)
Modified:
ofbiz/trunk/applications/content/ofbiz-component.xml
ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java
ofbiz/trunk/applications/party/data/PartyTypeData.xml
Modified: ofbiz/trunk/applications/content/ofbiz-component.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/ofbiz-component.xml?rev=678341&r1=678340&r2=678341&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/ofbiz-component.xml (original)
+++ ofbiz/trunk/applications/content/ofbiz-component.xml Sun Jul 20 21:15:42 2008
@@ -52,6 +52,7 @@
<service-resource type="model" loader="main" location="servicedef/services_commevent.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_website.xml"/>
<service-resource type="eca" loader="main" location="servicedef/secas.xml"/>
+ <service-resource type="mca" loader="main" location="servicedef/mca.xml"/>
<webapp name="content"
title="Content"
server="default-server"
Added: ofbiz/trunk/applications/content/servicedef/mca.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/servicedef/mca.xml?rev=678341&view=auto
==============================================================================
--- ofbiz/trunk/applications/content/servicedef/mca.xml (added)
+++ ofbiz/trunk/applications/content/servicedef/mca.xml Sun Jul 20 21:15:42 2008
@@ -0,0 +1,8 @@
+<service-mca xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/service-mca.xsd">
+
+ <mca mail-rule-name="processIncomingEmail">
+ <action service="storeIncomingEmail" mode="sync"/>
+ </mca>
+
+</service-mca>
Propchange: ofbiz/trunk/applications/content/servicedef/mca.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/trunk/applications/content/servicedef/mca.xml
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author URL Id"
Propchange: ofbiz/trunk/applications/content/servicedef/mca.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java?rev=678341&r1=678340&r2=678341&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java Sun Jul 20 21:15:42 2008
@@ -485,7 +485,7 @@
*@param serviceContext Map containing the input parameters
*@return Map with the result of the service, the output parameters
*/
- public static Map storeEmailAsCommunication(DispatchContext dctx, Map serviceContext) {
+ public static Map storeEmailAsCommunication(DispatchContext dctx, Map serviceContext) {
LocalDispatcher dispatcher = dctx.getDispatcher();
GenericValue userLogin = (GenericValue) serviceContext.get("userLogin");
@@ -638,25 +638,6 @@
return tempResults;
}
- /*
- * Helper method to retrieve a combined list of party information from to, cc, and bcc email addresses
- */
- private static List getListOfParyInfoFromEmailAddresses(Address [] addressesTo, Address [] addressesCC, Address [] addressesBCC, GenericValue userLogin, LocalDispatcher dispatcher) throws GenericServiceException
- {
- List allResults = new ArrayList();
-
- //Get Party Info for To email addresses
- allResults.addAll(buildListOfPartyInfoFromEmailAddresses(addressesTo, userLogin, dispatcher));
-
- //Get Party Info for CC email addresses
- allResults.addAll(buildListOfPartyInfoFromEmailAddresses(addressesCC, userLogin, dispatcher));
-
- //Get Party Info for BCC email addresses
- allResults.addAll(buildListOfPartyInfoFromEmailAddresses(addressesBCC, userLogin, dispatcher));
-
- return allResults;
- }
-
public static String contentIndex = "";
private static Map addMessageBody( Map commEventMap, Multipart multipart)
throws MessagingException, IOException {
@@ -801,11 +782,15 @@
Debug.logInfo("Persisting New Email: " + aboutThisEmail, module);
}
- // get the 'To' partyId
- List allResults = getListOfParyInfoFromEmailAddresses(addressesTo, addressesCC, addressesBCC, userLogin, dispatcher);
- Iterator itr = allResults.iterator();
+
+ // get the related partId's
+ List toParties = buildListOfPartyInfoFromEmailAddresses(addressesTo, userLogin, dispatcher);
+ List ccParties = buildListOfPartyInfoFromEmailAddresses(addressesCC, userLogin, dispatcher);
+ List bccParties = buildListOfPartyInfoFromEmailAddresses(addressesBCC, userLogin, dispatcher);
+
//Get the first address from the list - this is the partyIdTo field of the CommunicationEvent
- if (!allResults.isEmpty()) {
+ if (!toParties.isEmpty()) {
+ Iterator itr = toParties.iterator();
Map firstAddressTo = (Map) itr.next();
partyIdTo = (String)firstAddressTo.get("partyId");
contactMechIdTo = (String)firstAddressTo.get("contactMechId");
@@ -882,7 +867,7 @@
if (orgCommEventId == null) orgCommEventId = parentCommEventId;
commEventMap.put("parentCommEventId", parentCommEventId);
commEventMap.put("origCommEventId", orgCommEventId);
- }
+ }
}
// Retrieve all the addresses from the email
@@ -964,31 +949,16 @@
result = dispatcher.runSync("createCommunicationEvent", commEventMap);
communicationEventId = (String)result.get("communicationEventId");
- // store attachements
+ // store attachments
if (contentType.startsWith("multipart") || contentType.startsWith("Multipart")) {
int attachmentCount = EmailWorker.addAttachmentsToCommEvent(message, communicationEventId, dispatcher, userLogin);
if (Debug.infoOn()) Debug.logInfo(attachmentCount + " attachments added to CommunicationEvent:" + communicationEventId,module);
}
- // For all other addresses create a CommunicationEventRole
- while (itr.hasNext()) {
- Map address = (Map) itr.next();
- String partyId = (String)address.get("partyId");
-
- // It's not clear what the "role" of this communication event should be, so we'll just put _NA_
- // check and see if this role was already created and ignore if true
- Map commEventRoleMap = UtilMisc.toMap("communicationEventId", communicationEventId, "partyId", partyId, "roleTypeId", "_NA_");
- GenericValue commEventRole = delegator.findByPrimaryKey("CommunicationEventRole", commEventRoleMap);
- if (commEventRole == null) {
- // Check if "_NA_" role exists for the partyId. If not, then first associate that role with the partyId
- GenericValue partyRole = delegator.findByPrimaryKey("PartyRole", UtilMisc.toMap("partyId", partyId, "roleTypeId", "_NA_"));
- if (partyRole == null) {
- dispatcher.runSync("createPartyRole", UtilMisc.<String, Object>toMap("partyId", partyId, "roleTypeId", "_NA_", "userLogin", userLogin));
- }
- Map input = UtilMisc.toMap("communicationEventId", communicationEventId, "partyId", partyId, "roleTypeId", "_NA_", "userLogin", userLogin, "contactMechId", (String)address.get("contactMechId"));
- dispatcher.runSync("createCommunicationEventRole", input);
- }
- }
+ // For all addresses create a CommunicationEventRoles
+ createCommEventRoles(userLogin, delegator, dispatcher, communicationEventId, toParties, "ADDRESSEE");
+ createCommEventRoles(userLogin, delegator, dispatcher, communicationEventId, ccParties, "CC");
+ createCommEventRoles(userLogin, delegator, dispatcher, communicationEventId, bccParties, "BCC");
Map results = ServiceUtil.returnSuccess();
results.put("communicationEventId", communicationEventId);
@@ -1008,4 +978,32 @@
return ServiceUtil.returnError(e.getMessage());
}
}
+
+ private static void createCommEventRoles(GenericValue userLogin, GenericDelegator delegator, LocalDispatcher dispatcher, String communicationEventId, List parties, String roleTypeId) {
+ // It's not clear what the "role" of this communication event should be, so we'll just put _NA_
+ // check and see if this role was already created and ignore if true
+ try {
+ Iterator it = parties.iterator();
+ while (it.hasNext()) {
+ Map result = (Map) it.next();
+ String partyId = (String) result.get("partyId");
+ GenericValue commEventRole = delegator.findByPrimaryKey("CommunicationEventRole",
+ UtilMisc.toMap("communicationEventId", communicationEventId, "partyId", partyId, "roleTypeId", roleTypeId));
+ if (commEventRole == null) {
+ // Check if the role exists for the partyId. If not, then first associate that role with the partyId
+ GenericValue partyRole = delegator.findByPrimaryKey("PartyRole", UtilMisc.toMap("partyId", partyId, "roleTypeId", roleTypeId));
+ if (partyRole == null) {
+ dispatcher.runSync("createPartyRole", UtilMisc.<String, Object>toMap("partyId", partyId, "roleTypeId", roleTypeId, "userLogin", userLogin));
+ }
+ Map input = UtilMisc.toMap("communicationEventId", communicationEventId, "partyId", partyId, "roleTypeId", roleTypeId, "userLogin", userLogin, "contactMechId", (String) result.get("contactMechId"));
+ dispatcher.runSync("createCommunicationEventRole", input);
+ }
+ }
+ } catch (GenericServiceException e) {
+ Debug.logError(e, module);
+ } catch (Exception e) {
+ Debug.logError(e, module);
+ }
+ }
+
}
Modified: ofbiz/trunk/applications/party/data/PartyTypeData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/data/PartyTypeData.xml?rev=678341&r1=678340&r2=678341&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/data/PartyTypeData.xml (original)
+++ ofbiz/trunk/applications/party/data/PartyTypeData.xml Sun Jul 20 21:15:42 2008
@@ -151,6 +151,7 @@
<RoleType description="Automated Agent" hasTable="N" parentTypeId="" roleTypeId="AUTOMATED_AGENT_ROLE"/>
<RoleType description="Calendar" hasTable="N" parentTypeId="" roleTypeId="CALENDAR_ROLE"/>
<RoleType description="Client" hasTable="N" parentTypeId="" roleTypeId="CLIENT"/>
+ <RoleType description="Communication Participant" hasTable="N" parentTypeId="" roleTypeId="COMMEVENT_ROLE"/>
<RoleType description="Consumer" hasTable="N" parentTypeId="" roleTypeId="CONSUMER"/>
<RoleType description="Contact" hasTable="N" parentTypeId="" roleTypeId="CONTACT"/>
<RoleType description="Contractor" hasTable="N" parentTypeId="" roleTypeId="CONTRACTOR"/>
@@ -176,9 +177,11 @@
<RoleType description="Workflow" hasTable="N" parentTypeId="" roleTypeId="WORKFLOW_ROLE"/>
<!-- second level role types -->
+ <RoleType description="Email To" hasTable="N" parentTypeId="COMMEVENT_ROLE" roleTypeId="ADDRESSEE"/>
<RoleType description="Association" hasTable="N" parentTypeId="ORGANIZATION_ROLE" roleTypeId="ASSOCIATION"/>
<RoleType description="Bill-From Vendor" hasTable="N" parentTypeId="VENDOR" roleTypeId="BILL_FROM_VENDOR"/>
<RoleType description="Bill-To Customer" hasTable="N" parentTypeId="CUSTOMER" roleTypeId="BILL_TO_CUSTOMER"/>
+ <RoleType description="Email BCC" hasTable="N" parentTypeId="COMMEVENT_ROLE" roleTypeId="BCC"/>
<RoleType description="Bulk Customer" hasTable="N" parentTypeId="CUSTOMER" roleTypeId="BULK_CUSTOMER"/>
<RoleType description="Calendar Attendee" hasTable="N" parentTypeId="CALENDAR_ROLE" roleTypeId="CAL_ATTENDEE"/>
<RoleType description="Calendar Delegate" hasTable="N" parentTypeId="CALENDAR_ROLE" roleTypeId="CAL_DELEGATE"/>
@@ -187,6 +190,7 @@
<RoleType description="Calendar Owner" hasTable="N" parentTypeId="CALENDAR_ROLE" roleTypeId="CAL_OWNER"/>
<RoleType description="Carrier" hasTable="N" parentTypeId="ORGANIZATION_ROLE" roleTypeId="CARRIER"/>
<RoleType description="Competitor" hasTable="N" parentTypeId="ORGANIZATION_ROLE" roleTypeId="COMPETITOR"/>
+ <RoleType description="Email CC." hasTable="N" parentTypeId="COMMEVENT_ROLE" roleTypeId="CC"/>
<RoleType description="Distributor" hasTable="N" parentTypeId="DISTRIBUTION_CHANNEL" roleTypeId="DISTRIBUTOR"/>
<RoleType description="Employee" hasTable="N" parentTypeId="PERSON_ROLE" roleTypeId="EMPLOYEE"/>
<RoleType description="End-User Customer" hasTable="N" parentTypeId="CUSTOMER" roleTypeId="END_USER_CUSTOMER"/>
@@ -302,6 +306,7 @@
<StatusItem description="Referred" sequenceId="22" statusCode="REFERRED" statusId="COM_REFERRED" statusTypeId="COM_EVENT_STATUS"/>
<StatusItem description="Cancelled" sequenceId="99" statusCode="CANCELLED" statusId="COM_CANCELLED" statusTypeId="COM_EVENT_STATUS"/>
<StatusValidChange condition="" statusId="COM_ENTERED" statusIdTo="COM_PENDING" transitionName="Set Pending"/>
+ <StatusValidChange condition="" statusId="COM_ENTERED" statusIdTo="COM_COMPLETE" transitionName="Complete"/>
<StatusValidChange condition="" statusId="COM_PENDING" statusIdTo="COM_READ" transitionName="Mark Read"/>
<StatusValidChange condition="" statusId="COM_PENDING" statusIdTo="COM_IN_PROGRESS" transitionName="Set In Progress"/>
<StatusValidChange condition="" statusId="COM_READ" statusIdTo="COM_IN_PROGRESS" transitionName="Set In Progress"/>