use of org.orcid.core.salesforce.model.Contact in project ORCID-Source by ORCID.
the class SalesForceManagerImplTest method testUpdateContact2.
@Test
public void testUpdateContact2() {
// Switch from main to technical contact
Contact contact = new Contact();
contact.setId("contact2Id");
contact.setAccountId("account1");
ContactRole role = new ContactRole(ContactRoleType.TECHNICAL_CONTACT);
role.setId("contact2Idrole1Id");
contact.setRole(role);
salesForceManager.updateContact(contact);
verify(salesForceDao, times(1)).createContactRole(argThat(r -> {
return "contact2Id".equals(r.getContactId()) && "account1Id".equals(r.getAccountId()) && ContactRoleType.TECHNICAL_CONTACT.equals(r.getRoleType());
}));
verify(salesForceDao, times(1)).removeContactRole(eq("contact2Idrole1Id"));
}
use of org.orcid.core.salesforce.model.Contact in project ORCID-Source by ORCID.
the class SalesForceAdapterTest method testCreateContactsFromJson.
@Test
public void testCreateContactsFromJson() throws IOException, JSONException {
String inputString = IOUtils.toString(getClass().getResourceAsStream("/org/orcid/core/salesforce/salesforce_contacts_list.json"));
JSONObject inputObject = new JSONObject(inputString);
List<Contact> contactsList = salesForceAdapter.createContactsWithRolesFromJson(inputObject);
assertEquals(2, contactsList.size());
Contact contact = contactsList.get(0);
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 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;
}
use of org.orcid.core.salesforce.model.Contact in project ORCID-Source by ORCID.
the class ManageConsortiumController method validateContacts.
@RequestMapping(value = "/validate-contacts.json", method = RequestMethod.POST)
@ResponseBody
public ContactsForm validateContacts(@RequestBody ContactsForm contactsForm) {
List<String> errors = contactsForm.getErrors();
errors.clear();
int agreementSignatoryContactCount = 0;
int mainContactCount = 0;
int votingContactCount = 0;
for (Contact contact : contactsForm.getContactsList()) {
if (ContactRoleType.AGREEMENT_SIGNATORY.equals(contact.getRole().getRoleType())) {
agreementSignatoryContactCount++;
}
if (ContactRoleType.MAIN_CONTACT.equals(contact.getRole().getRoleType())) {
mainContactCount++;
}
if (contact.getRole().isVotingContact()) {
votingContactCount++;
}
}
if (agreementSignatoryContactCount == 0) {
errors.add(getMessage("manage_consortium.contacts_must_have_agreement_signatory_contact"));
}
if (agreementSignatoryContactCount > 1) {
errors.add(getMessage("manage_consortium.contacts_must_not_have_more_than_one_agreement_signatory_contact"));
}
if (mainContactCount == 0) {
errors.add(getMessage("manage_consortium.contacts_must_have_main_contact"));
}
if (mainContactCount > 1) {
errors.add(getMessage("manage_consortium.contacts_must_not_have_more_than_one_main_contact"));
}
if (votingContactCount == 0) {
errors.add(getMessage("manage_consortium.contacts_must_have_voting_contact"));
}
if (votingContactCount > 1) {
errors.add(getMessage("manage_consortium.contacts_must_not_have_more_than_one_voting_contact"));
}
return contactsForm;
}
use of org.orcid.core.salesforce.model.Contact in project ORCID-Source by ORCID.
the class GetContactsFromSalesForceByAccountId method main.
@SuppressWarnings("resource")
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("orcid-core-context.xml");
SalesForceManager salesForceManager = (SalesForceManager) context.getBean("salesForceManager");
List<Contact> contacts = salesForceManager.retrieveContactsByAccountId(args[0]);
System.out.println(contacts);
System.exit(0);
}
Aggregations