private String createPeopleFile( String baseUrl, String containerUrl, Map<String, VCard> importedPeople, SolidUtilities utilities) throws Exception { Model peopleModel = ModelFactory.createDefaultModel(); Resource indexResource = peopleModel.createResource("index.ttl#this"); for (String insertedId : importedPeople.keySet()) { VCard insertedPerson = importedPeople.get(insertedId); String relativePath = insertedId.replace(containerUrl, ""); Resource personResource = peopleModel.createResource(relativePath + "#this"); if (insertedPerson.getFormattedName() != null) { personResource.addProperty(VCARD4.fn, insertedPerson.getFormattedName().getValue()); } personResource.addProperty( peopleModel.createProperty(VCARD4.NS, "inAddressBook"), indexResource); } return utilities.postContent( baseUrl + containerUrl, "people", BASIC_RESOURCE_TYPE, peopleModel); }
@Override protected FormattedName _parseValue(String value) { return new FormattedName(value); } }
@Override public FormattedName copy() { return new FormattedName(this); } }
r.addProperty(VCARD4.fn, vcard.getFormattedName().getValue());
/** * <p> * Sets the person's full name. * </p> * <p> * <b>Property name:</b> {@code FN}<br> * <b>Supported versions:</b> {@code 2.1, 3.0, 4.0} * </p> * @param formattedName the formatted name (e.g. "John Doe") or null to * remove * @return the property object that was created * @see <a href="http://tools.ietf.org/html/rfc6350#page-28">RFC 6350 * p.28</a> * @see <a href="http://tools.ietf.org/html/rfc2426#page-8">RFC 2426 p.8</a> * @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.9</a> */ public FormattedName setFormattedName(String formattedName) { FormattedName type = (formattedName == null) ? null : new FormattedName(formattedName); setFormattedName(type); return type; }
@Test public void testFromRDF() { VCard vcard = SolidContactsExport.parsePerson(getPersonResource(TestData.RDF_TEST_DATA1)); assertWithMessage("Formatted Name is correct") .that(vcard.getFormattedName().getValue()) .isEqualTo("Cool Kid 1"); assertWithMessage("Note is correct") .that(vcard.getNotes().get(0).getValue()) .isEqualTo("This is a note for Cool Kid 1"); assertWithMessage("One email found") .that(vcard.getEmails()) .hasSize(1); assertWithMessage("email is correct") .that(vcard.getEmails().get(0).getValue()) .isEqualTo("a@b.com"); }
private void checkEquality(VCard input, VCard output) { String name = input.getFormattedName().getValue(); assertWithMessage("Structured names match") .that(output.getStructuredName()) .isEqualTo(input.getStructuredName()); assertWithMessage("Formatted names match for %s", name) .that(output.getFormattedName()) .isEqualTo(input.getFormattedName()); assertWithMessage("telephone numbers match for %s", name) .that(output.getTelephoneNumbers()) .containsAllIn(input.getTelephoneNumbers()); assertWithMessage("emails match for %s", name) .that(output.getEmails()) .containsAllIn(input.getEmails()); } }
String fullName = vcard.getFormattedName().getValue(); String phone = ""; for (Telephone telephone : vcard.getTelephoneNumbers()) {
String refCardId = formattedName.getValue(); GenericValue partyIdentification = EntityQuery.use(delegator).from("PartyIdentification").where("partyIdentificationTypeId", "VCARD_FN_ORIGIN", "idValue", refCardId).queryFirst(); if (partyIdentification != null) { createPartyIdentificationMap.put("partyId", resp.get("partyId")); createPartyIdentificationMap.put("partyIdentificationTypeId", "VCARD_FN_ORIGIN"); createPartyIdentificationMap.put("idValue", formattedName.getValue()); resp = dispatcher.runSync("createPartyIdentification", createPartyIdentificationMap); if (ServiceUtil.isError(resp)) {