use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.
the class MapperFacadeFactory method getEmailMapperFacade.
public MapperFacade getEmailMapperFacade() {
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
ClassMapBuilder<Email, EmailEntity> emailClassMap = mapperFactory.classMap(Email.class, EmailEntity.class);
emailClassMap.byDefault();
emailClassMap.field("email", "id");
emailClassMap.field("primary", "primary");
emailClassMap.field("verified", "verified");
addV2DateFields(emailClassMap);
registerSourceConverters(mapperFactory, emailClassMap);
emailClassMap.register();
return mapperFactory.getMapperFacade();
}
use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.
the class SalesForceManagerImpl method createContact.
@Override
public void createContact(Contact contact) {
String accountId = retrieveAccountIdByOrcid(sourceManager.retrieveRealUserOrcid());
contact.setAccountId(accountId);
if (StringUtils.isBlank(contact.getEmail())) {
String contactOrcid = contact.getOrcid();
Email primaryEmail = emailManager.getEmails(contactOrcid, getLastModified(contactOrcid)).getEmails().stream().filter(e -> e.isPrimary()).findFirst().get();
contact.setEmail(primaryEmail.getEmail());
}
List<Contact> existingContacts = salesForceDao.retrieveAllContactsByAccountId(accountId);
Optional<Contact> existingContact = existingContacts.stream().filter(c -> contact.getOrcid().equals(c.getOrcid())).findFirst();
String contactId = existingContact.isPresent() ? existingContact.get().getId() : salesForceDao.createContact(contact);
ContactRole contactRole = new ContactRole();
contactRole.setContactId(contactId);
contactRole.setRoleType(ContactRoleType.OTHER_CONTACT);
contactRole.setAccountId(contact.getAccountId());
salesForceDao.createContactRole(contactRole);
// Need to make more granular!
evictAll();
}
use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.
the class Api2_0_rc3_LastModifiedDatesHelper method calculateLastModified.
public static void calculateLastModified(Emails emails) {
if (emails != null && emails.getEmails() != null && !emails.getEmails().isEmpty()) {
LastModifiedDate latest = null;
for (Email email : emails.getEmails()) {
if (email.getLastModifiedDate() != null && email.getLastModifiedDate().after(latest)) {
latest = email.getLastModifiedDate();
}
}
emails.setLastModifiedDate(latest);
}
}
use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.
the class Api2_0_rc4_LastModifiedDatesHelper method calculateLastModified.
public static void calculateLastModified(Emails emails) {
if (emails != null && emails.getEmails() != null && !emails.getEmails().isEmpty()) {
LastModifiedDate latest = null;
for (Email email : emails.getEmails()) {
if (email.getLastModifiedDate() != null && email.getLastModifiedDate().after(latest)) {
latest = email.getLastModifiedDate();
}
}
emails.setLastModifiedDate(latest);
}
}
use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.
the class NotificationManagerTest method testAddedDelegatesSentCorrectEmail.
@Test
public void testAddedDelegatesSentCorrectEmail() throws JAXBException, IOException, URISyntaxException {
TargetProxyHelper.injectIntoProxy(notificationManager, "profileEntityCacheManager", mockProfileEntityCacheManager);
TargetProxyHelper.injectIntoProxy(notificationManager, "emailManager", mockEmailManager);
TargetProxyHelper.injectIntoProxy(notificationManager, "profileDao", mockProfileDao);
TargetProxyHelper.injectIntoProxy(notificationManager, "notificationDao", mockNotificationDao);
TargetProxyHelper.injectIntoProxy(notificationManager, "notificationAdapter", mockNotificationAdapter);
final String orcid = "0000-0000-0000-0003";
String delegateOrcid = "1234-5678-1234-5678";
ProfileEntity profile = new ProfileEntity();
RecordNameEntity recordName = new RecordNameEntity();
recordName.setCreditName("My credit name");
recordName.setVisibility(Visibility.PUBLIC);
profile.setRecordNameEntity(recordName);
profile.setSendAdministrativeChangeNotifications(true);
profile.setSendChangeNotifications(true);
profile.setSendMemberUpdateRequests(true);
profile.setSendOrcidNews(true);
EmailEntity emailEntity = new EmailEntity();
emailEntity.setId("test@email.com");
emailEntity.setPrimary(true);
emailEntity.setCurrent(true);
Set<EmailEntity> emails = new HashSet<EmailEntity>();
emails.add(emailEntity);
profile.setEmails(emails);
SourceEntity sourceEntity = new SourceEntity(new ClientDetailsEntity("APP-5555555555555555"));
when(sourceManager.retrieveSourceEntity()).thenReturn(sourceEntity);
when(sourceManager.retrieveSourceOrcid()).thenReturn("APP-5555555555555555");
when(mockNotificationAdapter.toNotificationEntity(Mockito.any(Notification.class))).thenReturn(new NotificationCustomEntity());
Email email = new Email();
email.setEmail("test@email.com");
when(mockProfileEntityCacheManager.retrieve(Mockito.anyString())).thenAnswer(new Answer<ProfileEntity>() {
@Override
public ProfileEntity answer(InvocationOnMock invocation) throws Throwable {
profile.setId(invocation.getArgument(0));
return profile;
}
});
when(mockProfileDao.find(Mockito.anyString())).thenAnswer(new Answer<ProfileEntity>() {
@Override
public ProfileEntity answer(InvocationOnMock invocation) throws Throwable {
profile.setId(invocation.getArgument(0));
return profile;
}
});
when(mockEmailManager.findPrimaryEmail(orcid)).thenReturn(email);
DelegationDetails firstNewDelegate = new DelegationDetails();
DelegateSummary firstNewDelegateSummary = new DelegateSummary();
firstNewDelegateSummary.setCreditName(new CreditName("Jimmy Dove"));
firstNewDelegate.setDelegateSummary(firstNewDelegateSummary);
firstNewDelegateSummary.setOrcidIdentifier(new OrcidIdentifier(delegateOrcid));
for (org.orcid.jaxb.model.common_v2.Locale locale : org.orcid.jaxb.model.common_v2.Locale.values()) {
profile.setLocale(locale);
notificationManager.sendNotificationToAddedDelegate("0000-0000-0000-0003", firstNewDelegate);
}
}
Aggregations