Search in sources :

Example 1 with TransformerContext

use of org.dataportabilityproject.transfer.microsoft.transformer.TransformerContext in project data-transfer-project by google.

the class ToGraphContactTransformer method copyPersonData.

private void copyPersonData(VCard card, Map<String, Object> contact, TransformerContext context) {
    // Addresses are lossy: there is no distinction in VCard between business and home addresses
    if (!card.getAddresses().isEmpty()) {
        safeSet("homeAddress", context.transform(LinkedHashMap.class, card.getAddresses().get(0)), contact);
    }
    card.getEmails().stream().filter(v -> v.getValue() != null).forEach(v -> addEmail(v, contact));
    card.getTelephoneNumbers().stream().filter(t -> t.getText() != null).forEach(telephone -> {
        for (TelephoneType telephoneType : telephone.getTypes()) {
            if (TelephoneType.CELL.equals(telephoneType)) {
                // this could overwrite some numbers since MS contacts only have one mobile
                contact.put("mobilePhone", telephone.getText());
            } else if (TelephoneType.WORK.equals(telephoneType)) {
                addPhone("businessPhones", telephone, contact);
            } else {
                addPhone("homePhones", telephone, contact);
            }
        }
    });
    if (card.getBirthday() != null) {
        safeSet("birthday", card.getBirthday().getText(), contact);
    }
}
Also used : VCard(ezvcard.VCard) TelephoneType(ezvcard.parameter.TelephoneType) TransformerContext(org.dataportabilityproject.transfer.microsoft.transformer.TransformerContext) BiFunction(java.util.function.BiFunction) Telephone(ezvcard.property.Telephone) StructuredName(ezvcard.property.StructuredName) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) List(java.util.List) TransformerHelper.safeSet(org.dataportabilityproject.transfer.microsoft.transformer.common.TransformerHelper.safeSet) Title(ezvcard.property.Title) Map(java.util.Map) Organization(ezvcard.property.Organization) Email(ezvcard.property.Email) Expertise(ezvcard.property.Expertise) TelephoneType(ezvcard.parameter.TelephoneType) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

VCard (ezvcard.VCard)1 TelephoneType (ezvcard.parameter.TelephoneType)1 Email (ezvcard.property.Email)1 Expertise (ezvcard.property.Expertise)1 Organization (ezvcard.property.Organization)1 StructuredName (ezvcard.property.StructuredName)1 Telephone (ezvcard.property.Telephone)1 Title (ezvcard.property.Title)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 BiFunction (java.util.function.BiFunction)1 TransformerContext (org.dataportabilityproject.transfer.microsoft.transformer.TransformerContext)1 TransformerHelper.safeSet (org.dataportabilityproject.transfer.microsoft.transformer.common.TransformerHelper.safeSet)1