use of org.orcid.jaxb.model.message.CreditName in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerTest method testUpdateCreditNamePreservingVisibility.
@Test
public void testUpdateCreditNamePreservingVisibility() throws Exception {
OrcidBio existingOrcidBioProtected = protectedOrcidMessage.getOrcidProfile().getOrcidBio();
OrcidBio updatedOrcidBioPublic = publicOrcidMessage.getOrcidProfile().getOrcidBio();
PersonalDetails existingOrcidPersonalDetails = protectedOrcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails();
PersonalDetails updatedOrcidPersonalDetails = publicOrcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails();
// set default of credit to limited on existing and null on updated
// -should remain as limited and not 'downgrade'
assertEquals(existingOrcidPersonalDetails.getCreditName().getContent(), "J. S. Carberry");
assertEquals(Visibility.LIMITED, existingOrcidPersonalDetails.getCreditName().getVisibility());
updatedOrcidPersonalDetails.setCreditName(new CreditName("Don"));
updatedOrcidPersonalDetails.getCreditName().setVisibility(Visibility.PRIVATE);
orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingOrcidBioProtected, updatedOrcidBioPublic);
assertEquals(existingOrcidPersonalDetails.getCreditName().getContent(), "Don");
assertEquals(Visibility.PRIVATE, existingOrcidPersonalDetails.getCreditName().getVisibility());
updatedOrcidPersonalDetails.setCreditName(new CreditName("Jimmy"));
updatedOrcidPersonalDetails.getCreditName().setVisibility(null);
orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingOrcidBioProtected, updatedOrcidBioPublic);
assertEquals("Don", existingOrcidBioProtected.getPersonalDetails().getCreditName().getContent());
assertEquals(Visibility.PRIVATE, existingOrcidPersonalDetails.getCreditName().getVisibility());
}
use of org.orcid.jaxb.model.message.CreditName in project ORCID-Source by ORCID.
the class OrcidClientGroupManagerImpl method createGroupProfile.
private OrcidProfile createGroupProfile(OrcidClientGroup orcidClientGroup) {
OrcidProfile orcidProfile = new OrcidProfile();
orcidProfile.setType(OrcidType.GROUP);
orcidProfile.setGroupType(orcidClientGroup.getType());
OrcidHistory orcidHistory = new OrcidHistory();
orcidProfile.setOrcidHistory(orcidHistory);
orcidHistory.setClaimed(new Claimed(true));
orcidHistory.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
OrcidBio orcidBio = new OrcidBio();
orcidProfile.setOrcidBio(orcidBio);
PersonalDetails personalDetails = new PersonalDetails();
orcidBio.setPersonalDetails(personalDetails);
personalDetails.setCreditName(new CreditName(orcidClientGroup.getGroupName()));
ContactDetails contactDetails = new ContactDetails();
orcidBio.setContactDetails(contactDetails);
Email primaryEmail = new Email(orcidClientGroup.getEmail());
primaryEmail.setVisibility(Visibility.PRIVATE);
primaryEmail.setVerified(true);
contactDetails.addOrReplacePrimaryEmail(primaryEmail);
if (!PojoUtil.isEmpty(orcidClientGroup.getSalesforceId())) {
OrcidInternal orcidInternal = new OrcidInternal();
orcidInternal.setSalesforceId(new SalesforceId(orcidClientGroup.getSalesforceId()));
orcidProfile.setOrcidInternal(orcidInternal);
}
return orcidProfile;
}
use of org.orcid.jaxb.model.message.CreditName in project ORCID-Source by ORCID.
the class Publication method getOrcidWork.
public OrcidWork getOrcidWork() {
initCrossRefContext();
OrcidWork orcidWork = new OrcidWork();
if (StringUtils.isNotBlank(doi)) {
WorkExternalIdentifier doiExtId = new WorkExternalIdentifier();
doiExtId.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
doiExtId.setWorkExternalIdentifierId(new WorkExternalIdentifierId(doi));
WorkExternalIdentifiers workExtIds = new WorkExternalIdentifiers();
orcidWork.setWorkExternalIdentifiers(workExtIds);
workExtIds.getWorkExternalIdentifier().add(doiExtId);
}
if (StringUtils.isNotBlank(title)) {
WorkTitle workTitle = new WorkTitle();
orcidWork.setWorkTitle(workTitle);
workTitle.setTitle(new Title(title));
}
// Will throw an IllegalArgumentException if not valid
CitationType cType = CitationType.fromValue(citationType);
Citation citation = new Citation(fullCitation, cType);
orcidWork.setWorkCitation(citation);
String publicationDateString = crossRefContext.getDate();
if (StringUtils.isNotBlank(publicationDateString)) {
XMLGregorianCalendar publicationDateGregCal = DateUtils.convertToXMLGregorianCalendar(publicationDateString);
if (publicationDateGregCal != null) {
Year publicationyear = new Year(publicationDateGregCal.getYear());
Month publicationMonth = publicationDateGregCal.getMonth() == DatatypeConstants.FIELD_UNDEFINED ? null : new Month(publicationDateGregCal.getMonth());
Day publicationDay = publicationDateGregCal.getDay() == DatatypeConstants.FIELD_UNDEFINED ? null : new Day(publicationDateGregCal.getDay());
orcidWork.setPublicationDate(new PublicationDate(publicationyear, publicationMonth, publicationDay));
}
}
String author = crossRefContext.getAuthor();
if (StringUtils.isNotBlank(author)) {
WorkContributors workContributors = new WorkContributors();
orcidWork.setWorkContributors(workContributors);
Contributor contributor = new Contributor();
workContributors.getContributor().add(contributor);
contributor.setCreditName(new CreditName(author));
ContributorAttributes contributorAttributes = new ContributorAttributes();
contributor.setContributorAttributes(contributorAttributes);
contributorAttributes.setContributorRole(ContributorRole.AUTHOR);
contributorAttributes.setContributorSequence(SequenceType.FIRST);
}
return orcidWork;
}
use of org.orcid.jaxb.model.message.CreditName 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