Author: sichen
Date: Fri Aug 25 16:59:22 2006 New Revision: 437027 URL: http://svn.apache.org/viewvc?rev=437027&view=rev Log: OFBIZ 182 - Add singleUse indicator to ContactList to allow for lists whose members should be contacted only once. Updated sendCommEventAsEmail to expire ContactListParty if singleUse = 'Y'. Modified: incubator/ofbiz/trunk/applications/marketing/config/MarketingUiLabels.properties incubator/ofbiz/trunk/applications/marketing/entitydef/entitymodel.xml incubator/ofbiz/trunk/applications/marketing/webapp/marketing/contact/ContactListForms.xml incubator/ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java Modified: incubator/ofbiz/trunk/applications/marketing/config/MarketingUiLabels.properties URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/marketing/config/MarketingUiLabels.properties?rev=437027&r1=437026&r2=437027&view=diff ============================================================================== --- incubator/ofbiz/trunk/applications/marketing/config/MarketingUiLabels.properties (original) +++ incubator/ofbiz/trunk/applications/marketing/config/MarketingUiLabels.properties Fri Aug 25 16:59:22 2006 @@ -28,6 +28,7 @@ ContactListContactMechTypeId=Contact Mechanisism Type Id ContactListCreate=Create New Contact List ContactListIsPublic=Is Public ? +ContactListIsSingleUse=Is Single Use ? ContactListOptInVerifyCode=Opt-In Verify Code ContactListOwnerPartyId=Owner Party Id ContactListParty=Contact List Party Modified: incubator/ofbiz/trunk/applications/marketing/entitydef/entitymodel.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/marketing/entitydef/entitymodel.xml?rev=437027&r1=437026&r2=437027&view=diff ============================================================================== --- incubator/ofbiz/trunk/applications/marketing/entitydef/entitymodel.xml (original) +++ incubator/ofbiz/trunk/applications/marketing/entitydef/entitymodel.xml Fri Aug 25 16:59:22 2006 @@ -146,6 +146,7 @@ <field name="description" type="description"></field> <field name="comments" type="comment"></field> <field name="isPublic" type="indicator"></field> + <field name="singleUse" type="indicator"><description>Wether members of the list should be contacted only once.</description></field> <field name="ownerPartyId" type="id"></field> <field name="verifyEmailFrom" type="long-varchar"></field> <field name="verifyEmailScreen" type="long-varchar"></field> Modified: incubator/ofbiz/trunk/applications/marketing/webapp/marketing/contact/ContactListForms.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/marketing/webapp/marketing/contact/ContactListForms.xml?rev=437027&r1=437026&r2=437027&view=diff ============================================================================== --- incubator/ofbiz/trunk/applications/marketing/webapp/marketing/contact/ContactListForms.xml (original) +++ incubator/ofbiz/trunk/applications/marketing/webapp/marketing/contact/ContactListForms.xml Fri Aug 25 16:59:22 2006 @@ -41,6 +41,11 @@ <option key="Y"/><option key="N"/> </drop-down> </field> + <field name="singleUse" title="${uiLabelMap.ContactListIsSingleUse}"> + <drop-down allow-empty="true"> + <option key="Y"/><option key="N"/> + </drop-down> + </field> <field name="contactMechTypeId" title="${uiLabelMap.ContactListContactMechTypeId}"> <drop-down> @@ -86,6 +91,7 @@ </field> <field name="contactListName" title="${uiLabelMap.ContactListContactListName}"><display/></field> <field name="isPublic" title="${uiLabelMap.ContactListIsPublic}"><display/></field> + <field name="singleUse" title="${uiLabelMap.ContactListIsSingleUse}"><display/></field> <field name="contactListTypeId" title="${uiLabelMap.ContactListContactListTypeId}"><display-entity entity-name="ContactListType"/></field> <field name="contactMechTypeId" title="${uiLabelMap.ContactListContactMechTypeId}"><display-entity entity-name="ContactMechType"/></field> Modified: incubator/ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java?rev=437027&r1=437026&r2=437027&view=diff ============================================================================== --- incubator/ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java (original) +++ incubator/ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java Fri Aug 25 16:59:22 2006 @@ -23,8 +23,10 @@ import java.util.List; import java.util.Map; import java.util.Locale; +import java.sql.Timestamp; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.entity.GenericDelegator; @@ -110,6 +112,10 @@ // there's actually a contact list here, so we want to be sending to the entire contact list GenericValue contactList = communicationEvent.getRelatedOne("ContactList"); + // set up some variables for single use lists + boolean singleUse = ("Y".equals(contactList.get("singleUse")) ? true : false); + Timestamp now = UtilDateTime.nowTimestamp(); + // find active, ACCEPTED parties in the contact list using a list iterator (because there can be a large number) EntityConditionList conditions = new EntityConditionList( UtilMisc.toList( new EntityExpr("contactListId", EntityOperator.EQUALS, contactList.get("contactListId")), @@ -117,7 +123,7 @@ new EntityExpr("preferredContactMechId", EntityOperator.NOT_EQUAL, null), EntityUtil.getFilterByDateExpr() ), EntityOperator.AND); - List fieldsToSelect = UtilMisc.toList("partyId", "preferredContactMechId"); + List fieldsToSelect = UtilMisc.toList("partyId", "preferredContactMechId", "contactListId", "fromDate"); EntityListIterator sendToPartiesIt = delegator.findListIteratorByCondition("ContactListParty", conditions, null, fieldsToSelect, null, new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true)); @@ -136,7 +142,16 @@ Map tmpResult = dispatcher.runSync("sendMail", sendMailParams); if (ServiceUtil.isError(tmpResult)) { errorMessages.add(ServiceUtil.getErrorMessage(tmpResult)); + } else if (singleUse) { + // expire the ContactListParty if the list is single use and sendEmail finishes successfully + tmpResult = dispatcher.runSync("updateContactListParty", UtilMisc.toMap("contactListId", nextSendToParty.get("contactListId"), + "partyId", nextSendToParty.get("partyId"), "fromDate", nextSendToParty.get("fromDate"), + "thruDate", now, "userLogin", userLogin)); + if (ServiceUtil.isError(tmpResult)) { + errorMessages.add(ServiceUtil.getErrorMessage(tmpResult)); + } } + } sendToPartiesIt.close(); } |
Free forum by Nabble | Edit this page |