Search in sources :

Example 26 with Contact

use of edu.stanford.muse.AddressBookManager.Contact in project epadd by ePADD.

the class IndexUtils method selectDocsByContact.

private static Set<Document> selectDocsByContact(AddressBook ab, Collection<EmailDocument> docs, Set<Contact> cset) {
    if (cset == null)
        return new LinkedHashSet<>();
    Set<String> cnames = new LinkedHashSet<>();
    Set<String> cemails = new LinkedHashSet<>();
    for (Contact c : cset) {
        cnames.addAll(c.getNames());
        cemails.addAll(c.getEmails());
    }
    return selectDocsByContact(ab, docs, cnames, cemails);
}
Also used : Contact(edu.stanford.muse.AddressBookManager.Contact)

Example 27 with Contact

use of edu.stanford.muse.AddressBookManager.Contact in project epadd by ePADD.

the class IndexUtils method computeDetailedFacetsForMessageBrowsing.

/**
 * Compute facet list for message browsing screen.
 */
public static Map<String, Collection<DetailedFacetItem>> computeDetailedFacetsForMessageBrowsing(Collection<Document> docs, Archive archive) {
    AddressBook addressBook = archive.addressBook;
    Map<String, Collection<DetailedFacetItem>> facetMap = new LinkedHashMap<>();
    if (addressBook != null) {
        // people
        Map<Contact, DetailedFacetItem> peopleMap = partitionDocsByPerson(docs, addressBook);
        facetMap.put("correspondent", peopleMap.values());
        // direction (sender: only one if anything with owner)
        Map<String, DetailedFacetItem> directionMap = partitionDocsByDirection(docs, addressBook);
        if (// this size can at max be 1 when there is at least one message sent from the owner
        directionMap.size() > 0)
            facetMap.put("sender", directionMap.values());
        /*
			--No longer need this code as restriction, reviewed etc. are handled by labels--
			// flags -- provide them only if they have at least 2 types in these docs. if all docs have the same value for a particular flag, no point showing it.
			Map<String, DetailedFacetItem> doNotTransferMap = partitionDocsByDoNotTransfer(docs);
			if  (doNotTransferMap.size() > 1)
			facetMap.put("transfer", doNotTransferMap.values());

			Map<String, DetailedFacetItem> transferWithRestrictionsMap = partitionDocsByTransferWithRestrictions(docs);
			if  (transferWithRestrictionsMap.size() > 1)
				facetMap.put("restrictions", transferWithRestrictionsMap.values());
			Map<String, DetailedFacetItem> reviewedMap = partitionDocsByReviewed(docs);
			if  (reviewedMap.size() > 1)
				facetMap.put("reviewed", reviewedMap.values());
			*/
        // facet for restriction labels
        Map<String, DetailedFacetItem> restrlabels = partitionDocsByLabelTypes(docs, archive, LabelManager.LabType.RESTRICTION);
        facetMap.put("Restriction Labels", restrlabels.values());
        // facet for general labels
        Map<String, DetailedFacetItem> genlabels = partitionDocsByLabelTypes(docs, archive, LabelManager.LabType.GENERAL);
        facetMap.put("General Labels", genlabels.values());
        // facet for accession IDs- only in modes other than appraisal
        if (!ModeConfig.isAppraisalMode()) {
            Map<String, DetailedFacetItem> accIDs = partitionDocsByAccessionID(docs, archive);
            facetMap.put("Accessions", accIDs.values());
        }
        Map<String, DetailedFacetItem> annotationPresenceMap = partitionDocsByAnnotationPresence(docs, archive);
        facetMap.put("Annotations", annotationPresenceMap.values());
        // attachments
        if (!ModeConfig.isPublicMode()) {
            Map<String, DetailedFacetItem> attachmentTypesMap = partitionDocsByAttachmentType(archive, docs);
            facetMap.put("attachment type", attachmentTypesMap.values());
        }
    }
    if (!ModeConfig.isPublicMode()) {
        Map<String, DetailedFacetItem> folderNameMap = partitionDocsByFolder(docs);
        if (folderNameMap.size() > 0)
            facetMap.put("folders", folderNameMap.values());
    }
    // sort so that in each topic, the heaviest facets are first
    for (String s : facetMap.keySet()) {
        Collection<DetailedFacetItem> detailedFacets = facetMap.get(s);
        List<DetailedFacetItem> list = new ArrayList<>(detailedFacets);
        Collections.sort(list);
        facetMap.put(s, list);
    }
    return facetMap;
}
Also used : AddressBook(edu.stanford.muse.AddressBookManager.AddressBook) Contact(edu.stanford.muse.AddressBookManager.Contact)

Aggregations

Contact (edu.stanford.muse.AddressBookManager.Contact)27 AddressBook (edu.stanford.muse.AddressBookManager.AddressBook)10 InternetAddress (javax.mail.internet.InternetAddress)7 Address (javax.mail.Address)6 JSONObject (org.json.JSONObject)5 Blob (edu.stanford.muse.datacache.Blob)4 Pair (edu.stanford.muse.util.Pair)4 Util (edu.stanford.muse.util.Util)4 java.util (java.util)4 Collectors (java.util.stream.Collectors)4 JSONArray (org.json.JSONArray)4 LinkedHashMultimap (com.google.common.collect.LinkedHashMultimap)3 Multimap (com.google.common.collect.Multimap)3 EmailUtils (edu.stanford.muse.util.EmailUtils)3 LogManager (org.apache.logging.log4j.LogManager)3 Logger (org.apache.logging.log4j.Logger)3 MailingList (edu.stanford.muse.AddressBookManager.MailingList)2 AnnotationManager (edu.stanford.muse.AnnotationManager.AnnotationManager)2 Config (edu.stanford.muse.Config)2 BlobStore (edu.stanford.muse.datacache.BlobStore)2