use of org.orcid.core.salesforce.model.Contact in project ORCID-Source by ORCID.
the class SalesForceAdapterTest method testCreateSalesForceRecordFromContact.
@Test
public void testCreateSalesForceRecordFromContact() {
Contact contact = new Contact();
contact.setAccountId("1234");
JSONObject contactJson = salesForceAdapter.createSaleForceRecordFromContact(contact);
assertEquals("{\"AccountId\":\"1234\"}", contactJson.toString());
}
use of org.orcid.core.salesforce.model.Contact in project ORCID-Source by ORCID.
the class SalesForceAdapterTest method testCreateContactFromJson.
@Test
public void testCreateContactFromJson() throws IOException, JSONException {
String inputString = IOUtils.toString(getClass().getResourceAsStream("/org/orcid/core/salesforce/salesforce_contacts_list.json"));
JSONObject inputObject = new JSONObject(inputString);
JSONArray records = inputObject.getJSONArray("records");
JSONObject record = records.getJSONObject(0);
JSONObject contactRoles = record.getJSONObject("Membership_Contact_Roles__r");
JSONArray contactRoleRecords = contactRoles.getJSONArray("records");
JSONObject contactRole = contactRoleRecords.getJSONObject(0);
Contact contact = salesForceAdapter.createContactFromJson(contactRole);
assertEquals("Contact1FirstName Contact1LastName", contact.getName());
assertEquals("contact1@mailinator.com", contact.getEmail());
assertEquals(ContactRoleType.MAIN_CONTACT, contact.getRole().getRoleType());
assertTrue(contact.getRole().isVotingContact());
}
use of org.orcid.core.salesforce.model.Contact in project ORCID-Source by ORCID.
the class SalesForceAdapter method createContactsWithRolesFromJson.
public List<Contact> createContactsWithRolesFromJson(JSONObject object) {
try {
JSONObject firstRecord = extractFirstRecord(object);
JSONObject contactRoles = firstRecord.getJSONObject("Membership_Contact_Roles__r");
List<JSONObject> objectsList = extractObjectListFromRecords(contactRoles);
return objectsList.stream().map(e -> mapperFacade.map(e, Contact.class)).collect(Collectors.toList());
} catch (JSONException e) {
throw new RuntimeException("Error getting contacts with roles list from SalesForce JSON", e);
}
}
use of org.orcid.core.salesforce.model.Contact in project ORCID-Source by ORCID.
the class ResultContainer method findConsortium.
@RequestMapping(value = "/find-consortium.json", method = RequestMethod.GET)
@ResponseBody
public ConsortiumForm findConsortium(@RequestParam("id") String id) {
MemberDetails memberDetails = salesForceManager.retrieveDetails(id);
ConsortiumForm consortiumForm = ConsortiumForm.fromMemberDetails(memberDetails);
List<Contact> contactsList = salesForceManager.retrieveContactsByAccountId(id);
salesForceManager.addOrcidsToContacts(contactsList);
consortiumForm.setContactsList(contactsList);
consortiumForm.setRoleMap(generateSalesForceRoleMap());
return consortiumForm;
}
use of org.orcid.core.salesforce.model.Contact in project ORCID-Source by ORCID.
the class ManageConsortiumController method getContacts.
@RequestMapping(value = "/get-contacts.json", method = RequestMethod.GET)
@ResponseBody
public ContactsForm getContacts() {
String accountId = salesForceManager.retrieveAccountIdByOrcid(getCurrentUserOrcid());
ContactsForm contactsForm = new ContactsForm();
List<Contact> contactsList = salesForceManager.retrieveContactsByAccountId(accountId);
salesForceManager.addOrcidsToContacts(contactsList);
contactsForm.setContactsList(contactsList);
contactsForm.setRoleMap(generateSalesForceRoleMap());
return contactsForm;
}
Aggregations