Search in sources :

Example 46 with Emails

use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.

the class PersonDetailsManagerReadOnlyImpl method getPersonDetails.

@Override
public Person getPersonDetails(String orcid) {
    long lastModifiedTime = getLastModified(orcid);
    Person person = new Person();
    person.setName(recordNameManager.getRecordName(orcid));
    person.setBiography(biographyManager.getBiography(orcid));
    Addresses addresses = addressManager.getAddresses(orcid);
    if (addresses.getAddress() != null) {
        Addresses filteredAddresses = new Addresses();
        filteredAddresses.setAddress(new ArrayList<Address>(addresses.getAddress()));
        person.setAddresses(filteredAddresses);
    }
    PersonExternalIdentifiers extIds = externalIdentifierManager.getExternalIdentifiers(orcid);
    if (extIds.getExternalIdentifiers() != null) {
        PersonExternalIdentifiers filteredExtIds = new PersonExternalIdentifiers();
        filteredExtIds.setExternalIdentifiers(new ArrayList<PersonExternalIdentifier>(extIds.getExternalIdentifiers()));
        person.setExternalIdentifiers(filteredExtIds);
    }
    Keywords keywords = profileKeywordManager.getKeywords(orcid);
    if (keywords.getKeywords() != null) {
        Keywords filteredKeywords = new Keywords();
        filteredKeywords.setKeywords(new ArrayList<Keyword>(keywords.getKeywords()));
        person.setKeywords(filteredKeywords);
    }
    OtherNames otherNames = otherNameManager.getOtherNames(orcid);
    if (otherNames.getOtherNames() != null) {
        OtherNames filteredOtherNames = new OtherNames();
        filteredOtherNames.setOtherNames(new ArrayList<OtherName>(otherNames.getOtherNames()));
        person.setOtherNames(filteredOtherNames);
    }
    ResearcherUrls rUrls = researcherUrlManager.getResearcherUrls(orcid);
    if (rUrls.getResearcherUrls() != null) {
        ResearcherUrls filteredRUrls = new ResearcherUrls();
        filteredRUrls.setResearcherUrls(new ArrayList<ResearcherUrl>(rUrls.getResearcherUrls()));
        person.setResearcherUrls(filteredRUrls);
    }
    Emails emails = emailManager.getEmails(orcid);
    if (emails.getEmails() != null) {
        Emails filteredEmails = new Emails();
        filteredEmails.setEmails(new ArrayList<Email>(emails.getEmails()));
        person.setEmails(filteredEmails);
    }
    return person;
}
Also used : Keywords(org.orcid.jaxb.model.v3.dev1.record.Keywords) Email(org.orcid.jaxb.model.v3.dev1.record.Email) Address(org.orcid.jaxb.model.v3.dev1.record.Address) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) OtherNames(org.orcid.jaxb.model.v3.dev1.record.OtherNames) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) Addresses(org.orcid.jaxb.model.v3.dev1.record.Addresses) PersonExternalIdentifiers(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers) ResearcherUrls(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Emails(org.orcid.jaxb.model.v3.dev1.record.Emails) Person(org.orcid.jaxb.model.v3.dev1.record.Person)

Example 47 with Emails

use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.

the class ManageProfileController method validateDeprecateProfile.

@RequestMapping(value = "/validate-deprecate-profile.json", method = RequestMethod.POST)
@ResponseBody
public DeprecateProfile validateDeprecateProfile(@RequestBody DeprecateProfile deprecateProfile) {
    validateFormData(deprecateProfile);
    if (!deprecateProfile.getErrors().isEmpty()) {
        return deprecateProfile;
    }
    String currentUserOrcid = getCurrentUserOrcid();
    ProfileEntity primaryEntity = profileEntityCacheManager.retrieve(currentUserOrcid);
    ProfileEntity deprecatingEntity = getDeprecatingEntity(deprecateProfile);
    validateDeprecatingEntity(deprecatingEntity, primaryEntity, deprecateProfile);
    if (deprecateProfile.getErrors() != null && !deprecateProfile.getErrors().isEmpty()) {
        return deprecateProfile;
    }
    validateDeprecateAccountRequest(deprecateProfile, deprecatingEntity);
    if (deprecateProfile.getErrors() != null && !deprecateProfile.getErrors().isEmpty()) {
        return deprecateProfile;
    }
    Emails deprecatingEmails = emailManager.getEmails(deprecatingEntity.getId());
    Emails primaryEmails = emailManager.getEmails(primaryEntity.getId());
    String primaryAccountName = RecordNameUtils.getPublicName(primaryEntity.getRecordNameEntity());
    String deprecatingAccountName = RecordNameUtils.getPublicName(deprecatingEntity.getRecordNameEntity());
    deprecateProfile.setPrimaryAccountName(primaryAccountName);
    deprecateProfile.setPrimaryOrcid(currentUserOrcid);
    deprecateProfile.setDeprecatingAccountName(deprecatingAccountName);
    deprecateProfile.setDeprecatingOrcid(deprecatingEntity.getId());
    if (deprecatingEmails != null) {
        deprecateProfile.setDeprecatingEmails(deprecatingEmails.getEmails().stream().map(e -> e.getEmail()).collect(Collectors.toList()));
    }
    if (primaryEmails != null) {
        deprecateProfile.setPrimaryEmails(primaryEmails.getEmails().stream().map(e -> e.getEmail()).collect(Collectors.toList()));
    }
    return deprecateProfile;
}
Also used : Emails(org.orcid.jaxb.model.v3.dev1.record.Emails) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 48 with Emails

use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.

the class OrcidInfo method groupEmails.

private Map<String, List<Email>> groupEmails(Emails emails) {
    if (emails == null || emails.getEmails() == null) {
        return null;
    }
    Map<String, List<Email>> groups = new TreeMap<String, List<Email>>();
    for (Email e : emails.getEmails()) {
        if (groups.containsKey(e.getEmail())) {
            groups.get(e.getEmail()).add(e);
        } else {
            List<Email> list = new ArrayList<Email>();
            list.add(e);
            groups.put(e.getEmail(), list);
        }
    }
    return groups;
}
Also used : Email(org.orcid.jaxb.model.v3.dev1.record.Email) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap)

Example 49 with Emails

use of org.orcid.jaxb.model.v3.dev1.record.Emails 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(org.orcid.jaxb.model.common_v2.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");
    Email delegateEmail = new Email();
    delegateEmail.setEmail("delegate@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);
    when(mockEmailManager.findPrimaryEmail(delegateOrcid)).thenReturn(delegateEmail);
    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", delegateOrcid);
    }
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Email(org.orcid.jaxb.model.v3.dev1.record.Email) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) 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.v3.dev1.notification.Notification) InvocationOnMock(org.mockito.invocation.InvocationOnMock) HashSet(java.util.HashSet) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 50 with Emails

use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.

the class OrcidSecurityManager_EmailTest method testPerson_ReadLimited.

@Test
public void testPerson_ReadLimited() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_LIMITED);
    Email e1 = createEmail(Visibility.PUBLIC, CLIENT_2);
    Email e2 = createEmail(Visibility.LIMITED, CLIENT_2);
    Email e3 = createEmail(Visibility.PRIVATE, CLIENT_2);
    List<Email> emailList = new ArrayList<Email>(Arrays.asList(e1, e2, e3));
    Emails emails = new Emails();
    emails.setEmails(emailList);
    Person p = new Person();
    p.setEmails(emails);
    orcidSecurityManager.checkAndFilter(ORCID_1, p);
    assertNotNull(p);
    assertNotNull(p.getEmails());
    assertEquals(2, p.getEmails().getEmails().size());
    assertTrue(p.getEmails().getEmails().contains(e1));
    assertTrue(p.getEmails().getEmails().contains(e2));
    assertFalse(p.getEmails().getEmails().contains(e3));
}
Also used : Email(org.orcid.jaxb.model.v3.dev1.record.Email) ArrayList(java.util.ArrayList) Emails(org.orcid.jaxb.model.v3.dev1.record.Emails) Person(org.orcid.jaxb.model.v3.dev1.record.Person) Test(org.junit.Test)

Aggregations

Email (org.orcid.jaxb.model.v3.dev1.record.Email)59 Emails (org.orcid.jaxb.model.v3.dev1.record.Emails)56 Test (org.junit.Test)54 Address (org.orcid.jaxb.model.v3.dev1.record.Address)33 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)32 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)32 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)32 OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)32 Person (org.orcid.jaxb.model.v3.dev1.record.Person)32 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)32 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)32 Addresses (org.orcid.jaxb.model.v3.dev1.record.Addresses)31 Keywords (org.orcid.jaxb.model.v3.dev1.record.Keywords)31 PersonExternalIdentifiers (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers)31 ResearcherUrls (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls)31 Name (org.orcid.jaxb.model.v3.dev1.record.Name)27 Record (org.orcid.jaxb.model.v3.dev1.record.Record)15 ArrayList (java.util.ArrayList)13 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)13 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)13