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;
}
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;
}
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;
}
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);
}
}
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));
}
Aggregations