Search in sources :

Example 66 with Email

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();
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) EmailEntity(org.orcid.persistence.jpa.entities.EmailEntity)

Example 67 with Email

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();
}
Also used : SalesForceManager(org.orcid.core.manager.SalesForceManager) SalesForceConnectionDao(org.orcid.persistence.dao.SalesForceConnectionDao) Date(java.util.Date) Member(org.orcid.core.salesforce.model.Member) EmailManager(org.orcid.core.manager.EmailManager) DateUtils(org.orcid.utils.DateUtils) MemberDetailsCacheKey(org.orcid.core.salesforce.cache.MemberDetailsCacheKey) StringUtils(org.apache.commons.lang3.StringUtils) ManagerReadOnlyBaseImpl(org.orcid.core.manager.read_only.impl.ManagerReadOnlyBaseImpl) Calendar(java.util.Calendar) SalesForceConnectionEntity(org.orcid.persistence.jpa.entities.SalesForceConnectionEntity) Map(java.util.Map) ContactRole(org.orcid.core.salesforce.model.ContactRole) SelfPopulatingCache(net.sf.ehcache.constructs.blocking.SelfPopulatingCache) Collection(java.util.Collection) Resource(javax.annotation.Resource) Opportunity(org.orcid.core.salesforce.model.Opportunity) SlugUtils(org.orcid.core.salesforce.model.SlugUtils) Collectors(java.util.stream.Collectors) List(java.util.List) MemberDetails(org.orcid.core.salesforce.model.MemberDetails) SourceManager(org.orcid.core.manager.SourceManager) Consortium(org.orcid.core.salesforce.model.Consortium) Optional(java.util.Optional) Contact(org.orcid.core.salesforce.model.Contact) Email(org.orcid.jaxb.model.record_v2.Email) ContactRoleType(org.orcid.core.salesforce.model.ContactRoleType) SubMember(org.orcid.core.salesforce.model.SubMember) ReleaseNameUtils(org.orcid.utils.ReleaseNameUtils) Collections(java.util.Collections) SalesForceDao(org.orcid.core.salesforce.dao.SalesForceDao) Email(org.orcid.jaxb.model.record_v2.Email) ContactRole(org.orcid.core.salesforce.model.ContactRole) Contact(org.orcid.core.salesforce.model.Contact)

Example 68 with Email

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);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_rc3.LastModifiedDate) Email(org.orcid.jaxb.model.record_rc3.Email)

Example 69 with Email

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);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_rc4.LastModifiedDate) Email(org.orcid.jaxb.model.record_rc4.Email)

Example 70 with Email

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);
    }
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Email(org.orcid.jaxb.model.record_v2.Email) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) CreditName(org.orcid.jaxb.model.message.CreditName) EmailEntity(org.orcid.persistence.jpa.entities.EmailEntity) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NotificationCustomEntity(org.orcid.persistence.jpa.entities.NotificationCustomEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) Notification(org.orcid.jaxb.model.notification_v2.Notification) DelegateSummary(org.orcid.jaxb.model.message.DelegateSummary) InvocationOnMock(org.mockito.invocation.InvocationOnMock) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) DelegationDetails(org.orcid.jaxb.model.message.DelegationDetails) HashSet(java.util.HashSet) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Email (org.orcid.jaxb.model.record_v2.Email)82 Test (org.junit.Test)78 Emails (org.orcid.jaxb.model.record_v2.Emails)49 Address (org.orcid.jaxb.model.record_v2.Address)41 Keyword (org.orcid.jaxb.model.record_v2.Keyword)41 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)41 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)41 OtherName (org.orcid.jaxb.model.record_v2.OtherName)39 Person (org.orcid.jaxb.model.record_v2.Person)35 Biography (org.orcid.jaxb.model.record_v2.Biography)34 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)33 Addresses (org.orcid.jaxb.model.record_v2.Addresses)31 Keywords (org.orcid.jaxb.model.record_v2.Keywords)31 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)31 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)31 Name (org.orcid.jaxb.model.record_v2.Name)30 Record (org.orcid.jaxb.model.record_v2.Record)19 ArrayList (java.util.ArrayList)18 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)18 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)18