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);
}
}
Aggregations