private void copyBusinessData(Map<String, Object> map, VCard card, TransformerContext context) { getMap("businessAddress", map) .ifPresent(v -> card.addAddress(context.transform(Address.class, v))); getMap("otherAddress", map) .ifPresent(v -> card.addAddress(context.transform(Address.class, v))); getString("jobTitle", map).ifPresent(card::addTitle); getString("companyName", map) .ifPresent( v -> { Organization organization = new Organization(); organization.getValues().add(v); card.addOrganization(organization); }); getString("profession", map).ifPresent(card::addExpertise); copyPhones("businessPhones", TelephoneType.WORK, map, card); }
private void copyBusinessData(VCard card, Map<String, Object> contact) { for (Title title : card.getTitles()) { if (title.getValue() == null) { continue; } // This can loose data but there are only two title types in MS contacts if (title.getType() != null && title.getType().equalsIgnoreCase("home")) { safeSet("title", card.getTitles(), contact); } else { safeSet("jobTitle", card.getTitles(), contact); } } // This can loose data but there is only one company name in MS contacts for (Organization organization : card.getOrganizations()) { for (String orgName : organization.getValues()) { contact.put("companyName", orgName); } } for (Expertise expertise : card.getExpertise()) { if (expertise.getValue() == null) { continue; } contact.put("profession", expertise.getValue()); // only set first one break; } }
Organization organization = vcard.getOrganization(); if (organization != null) { List<String> values = organization.getValues(); for (int i = 0; i < values.size(); i++) { n_company = values.get(i); } } } }
@Override protected Organization _parseHtml(HCardElement element, ParseContext context) { Organization property = new Organization(); String orgName = element.firstValue("organization-name"); if (orgName != null) { property.getValues().add(orgName); } String orgUnit = element.firstValue("organization-unit"); if (orgUnit != null) { property.getValues().add(orgUnit); } if (property.getValues().isEmpty()) { String value = element.value(); if (value.length() > 0) { property.getValues().add(value); } } return property; }
@Override protected JCardValue _writeJson(Organization property) { List<String> values = property.getValues(); if (values.isEmpty()) { return JCardValue.single(""); } if (values.size() == 1) { return JCardValue.single(values.get(0)); } return JCardValue.structured(values.toArray(new Object[0])); }
@Override protected Organization _parseText(String value, VCardDataType dataType, VCardParameters parameters, ParseContext context) { Organization property = new Organization(); List<String> values = VObjectPropertyValues.parseSemiStructured(value); property.getValues().addAll(values); return property; }
@Override protected void _writeXml(Organization property, XCardElement parent) { parent.append(VCardDataType.TEXT.getName().toLowerCase(), property.getValues()); }
@Override protected Organization _parseXml(XCardElement element, VCardParameters parameters, ParseContext context) { List<String> values = element.all(VCardDataType.TEXT); if (!values.isEmpty()) { Organization property = new Organization(); property.getValues().addAll(values); return property; } throw missingXmlElements(VCardDataType.TEXT); }
/** * <p> * Sets the hierarchy of departments to which the person belongs. * </p> * <p> * <b>Property name:</b> {@code ORG}<br> * <b>Supported versions:</b> {@code 2.1, 3.0, 4.0} * </p> * @param departments the ordered list of department(s), starting with the * broadest and ending with the most specific (e.g. "Google", "Gmail Team", * "Spam Detection Squad") or an empty arguments list to remove * @return the property object that was created * @see <a href="http://tools.ietf.org/html/rfc6350#page-40">RFC 6350 * p.40</a> * @see <a href="http://tools.ietf.org/html/rfc2426#page-20">RFC 2426 * p.20</a> * @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.19</a> */ public Organization setOrganization(String... departments) { Organization type = null; if (departments.length > 0) { type = new Organization(); type.getValues().addAll(Arrays.asList(departments)); } setOrganization(type); return type; }
@Override protected String _writeText(Organization property, WriteContext context) { boolean escapeCommas = (context.getVersion() != VCardVersion.V2_1); return VObjectPropertyValues.writeSemiStructured(property.getValues(), escapeCommas, context.isIncludeTrailingSemicolons()); }
@Override protected Organization _parseJson(JCardValue value, VCardDataType dataType, VCardParameters parameters, ParseContext context) { Organization property = new Organization(); StructuredValueIterator it = new StructuredValueIterator(value.asStructured()); while (it.hasNext()) { String next = it.nextValue(); if (next != null) { property.getValues().add(next); } } return property; } }