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'.

git-svn-id: https://svn.apache.org/repos/asf/incubator/ofbiz/trunk@437027 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Si Chen
2006-08-25 23:59:22 +00:00
parent b6d1e3c3b1
commit 986affa86f
4 changed files with 24 additions and 1 deletions
@@ -28,6 +28,7 @@ ContactListContactListTypeId=Contact List Type Id
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
@@ -146,6 +146,7 @@ under the License.
<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>
@@ -41,6 +41,11 @@ under the License.
<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 @@ under the License.
</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>
@@ -23,8 +23,10 @@ import java.util.LinkedList;
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 @@ public class CommunicationEventServices {
// 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 @@ public class CommunicationEventServices {
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 @@ public class CommunicationEventServices {
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();
}