use of edu.stanford.muse.AddressBookManager.MailingList in project epadd by ePADD.
the class EmailDocument method setOwners.
/*
This method combines the contacts corresponding to the passed email addresses and set the resultant contact as owner.
*/
public static void setOwners(Archive archive, Set<String> emailAddresses) {
AddressBook ab = archive.getAddressBook();
// get contacts for these email addresses.
Set<Contact> ofInterest = emailAddresses.stream().map(emailAddress -> ab.lookupByEmail(emailAddress)).collect(Collectors.toSet());
if (ofInterest.size() == 1) {
// if single element in the set ofInterest then simply set it as owner and recompute summary
Contact newowner = ofInterest.iterator().next();
ab.setContactForSelf(newowner);
ab.fillL1_SummaryObject(archive.getAllDocs());
} else {
// if multiple elements in the set ofInterest then
// combine them to create a new contact.
Contact newone = new Contact();
// MailingList ml=null;
ofInterest.forEach(contact -> {
newone.merge(contact);
// if(ml==null && ab.mailingListMap.containsKey(contact))
// ml = ab.mailingListMap.get(contact);
});
// set it as ML if any of the contact is ML.-- NOT DONE
// add contact to contactListForIds
ab.contactListForIds.add(newone);
// remove all these contacts (obtained from the input email addresses)
ab.removeContacts(ofInterest);
// set the newly create contact as owner.
ab.setContactForSelf(newone);
// recompute L1 summary,not needed now. Just make sure that the caller is invoking it after completion of this method.
// just to avoid unnecessary duplication of this call.
// ab.fillL1_SummaryObject(archive.getAllDocs());
}
}
Aggregations