Search in sources :

Example 21 with CreditName

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());
}
Also used : OrcidBio(org.orcid.jaxb.model.message.OrcidBio) CreditName(org.orcid.jaxb.model.message.CreditName) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 22 with CreditName

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;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) SalesforceId(org.orcid.jaxb.model.message.SalesforceId) CreditName(org.orcid.jaxb.model.message.CreditName) OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) Claimed(org.orcid.jaxb.model.message.Claimed) Date(java.util.Date) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate)

Example 23 with CreditName

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;
}
Also used : PublicationDate(org.orcid.jaxb.model.message.PublicationDate) ContributorAttributes(org.orcid.jaxb.model.message.ContributorAttributes) WorkContributors(org.orcid.jaxb.model.message.WorkContributors) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) CreditName(org.orcid.jaxb.model.message.CreditName) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) Contributor(org.orcid.jaxb.model.message.Contributor) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Month(org.orcid.jaxb.model.message.Month) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) Year(org.orcid.jaxb.model.message.Year) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) CitationType(org.orcid.jaxb.model.message.CitationType) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) Citation(org.orcid.jaxb.model.message.Citation) Day(org.orcid.jaxb.model.message.Day)

Example 24 with CreditName

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

CreditName (org.orcid.jaxb.model.message.CreditName)24 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)14 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)14 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)14 GivenNames (org.orcid.jaxb.model.message.GivenNames)11 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)9 FamilyName (org.orcid.jaxb.model.message.FamilyName)9 OtherNames (org.orcid.jaxb.model.message.OtherNames)8 Email (org.orcid.jaxb.model.message.Email)7 Test (org.junit.Test)6 ExternalIdentifiers (org.orcid.jaxb.model.message.ExternalIdentifiers)6 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)6 Url (org.orcid.jaxb.model.message.Url)6 ExternalIdentifier (org.orcid.jaxb.model.message.ExternalIdentifier)5 Keyword (org.orcid.jaxb.model.message.Keyword)5 Keywords (org.orcid.jaxb.model.message.Keywords)5 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)5 WorkExternalIdentifiers (org.orcid.jaxb.model.message.WorkExternalIdentifiers)5 Biography (org.orcid.jaxb.model.message.Biography)4 Contributor (org.orcid.jaxb.model.message.Contributor)4