Search in sources :

Example 1 with OrcidBio

use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.

the class T2OrcidApiServiceDelegatorTest method createStubOrcidMessage.

private OrcidMessage createStubOrcidMessage() {
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    OrcidBio orcidBio = new OrcidBio();
    orcidProfile.setOrcidBio(orcidBio);
    PersonalDetails personalDetails = new PersonalDetails();
    orcidBio.setPersonalDetails(personalDetails);
    GivenNames givenNames = new GivenNames("Test given names");
    personalDetails.setGivenNames(givenNames);
    CreditName creditName = new CreditName("Test credit name");
    personalDetails.setCreditName(creditName);
    creditName.setVisibility(Visibility.LIMITED);
    ContactDetails contactDetails = new ContactDetails();
    orcidBio.setContactDetails(contactDetails);
    return orcidMessage;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) GivenNames(org.orcid.jaxb.model.message.GivenNames) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) CreditName(org.orcid.jaxb.model.message.CreditName) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails)

Example 2 with OrcidBio

use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.

the class T2OrcidApiServiceDelegatorTest method testAddExternalIdentifiersToDeprecatedAccount.

@Test(expected = OrcidDeprecatedException.class)
public void testAddExternalIdentifiersToDeprecatedAccount() {
    SecurityContextTestUtils.setUpSecurityContext();
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    orcidMessage.setOrcidProfile(new OrcidProfile());
    orcidMessage.getOrcidProfile().setOrcidBio(new OrcidBio());
    ExternalIdentifiers extIds = new ExternalIdentifiers();
    ExternalIdentifier extId1 = new ExternalIdentifier();
    String commonName = "common-name-1-" + System.currentTimeMillis();
    extId1.setExternalIdCommonName(new ExternalIdCommonName(commonName));
    extId1.setExternalIdReference(new ExternalIdReference("ext-id-reference-1"));
    extId1.setExternalIdUrl(new ExternalIdUrl("http://test.orcid.org/" + System.currentTimeMillis()));
    extIds.getExternalIdentifier().add(extId1);
    orcidMessage.getOrcidProfile().getOrcidBio().setExternalIdentifiers(extIds);
    t2OrcidApiServiceDelegator.addExternalIdentifiers(mockedUriInfo, "4444-4444-4444-444X", orcidMessage);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ExternalIdCommonName(org.orcid.jaxb.model.message.ExternalIdCommonName) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) ExternalIdReference(org.orcid.jaxb.model.message.ExternalIdReference) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) FundingExternalIdentifiers(org.orcid.jaxb.model.message.FundingExternalIdentifiers) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers) ExternalIdUrl(org.orcid.jaxb.model.message.ExternalIdUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 3 with OrcidBio

use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.

the class OrcidMessageVersionConverterImplV1_1ToV1_2_rc1 method downgradeProfile.

private void downgradeProfile(OrcidProfile orcidProfile) {
    if (orcidProfile != null) {
        orcidProfile.setAffiliations(null);
        OrcidBio orcidBio = orcidProfile.getOrcidBio();
        if (orcidBio != null) {
            ContactDetails contactDetails = orcidBio.getContactDetails();
            if (contactDetails != null) {
                for (Email email : contactDetails.getEmail()) {
                    email.setSourceClientId(null);
                }
            }
            ExternalIdentifiers extIds = orcidBio.getExternalIdentifiers();
            if (extIds != null) {
                for (ExternalIdentifier extId : extIds.getExternalIdentifier()) {
                    extId.setSource(null);
                }
            }
        }
        if (orcidProfile.getOrcidActivities() != null) {
            if (orcidProfile.getOrcidActivities().getOrcidWorks() != null) {
                for (OrcidWork act : orcidProfile.getOrcidActivities().getOrcidWorks().getOrcidWork()) downGradeActivity(act);
            }
        }
    }
}
Also used : Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers)

Example 4 with OrcidBio

use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.

the class OrcidJaxbCopyManagerTest method testCopyUpdatedExternalIdentifiersToExistingPreservingVisibility.

@Test
public void testCopyUpdatedExternalIdentifiersToExistingPreservingVisibility() throws Exception {
    OrcidBio protectedOrcidBio = protectedOrcidMessage.getOrcidProfile().getOrcidBio();
    OrcidBio publicOrcidBio = publicOrcidMessage.getOrcidProfile().getOrcidBio();
    assertNull(publicOrcidBio.getExternalIdentifiers().getVisibility());
    assertEquals(Visibility.PUBLIC, protectedOrcidBio.getExternalIdentifiers().getVisibility());
    // first time save upgrades null to public
    orcidJaxbCopyManager.copyUpdatedExternalIdentifiersToExistingPreservingVisibility(publicOrcidBio, protectedOrcidBio);
    assertEquals(Visibility.PUBLIC, publicOrcidBio.getExternalIdentifiers().getVisibility());
    assertEquals(Visibility.PUBLIC, protectedOrcidBio.getExternalIdentifiers().getVisibility());
    // now changing the updated one propogates change
    protectedOrcidBio.getExternalIdentifiers().setVisibility(Visibility.LIMITED);
    orcidJaxbCopyManager.copyUpdatedExternalIdentifiersToExistingPreservingVisibility(publicOrcidBio, protectedOrcidBio);
    assertEquals(Visibility.LIMITED, publicOrcidBio.getExternalIdentifiers().getVisibility());
    assertEquals(Visibility.LIMITED, protectedOrcidBio.getExternalIdentifiers().getVisibility());
    // when existing is null - set to the value if existing
    publicOrcidBio.getExternalIdentifiers().setVisibility(null);
    protectedOrcidBio.getExternalIdentifiers().setVisibility(Visibility.LIMITED);
    orcidJaxbCopyManager.copyUpdatedExternalIdentifiersToExistingPreservingVisibility(publicOrcidBio, protectedOrcidBio);
    assertEquals(Visibility.LIMITED, publicOrcidBio.getExternalIdentifiers().getVisibility());
    assertEquals(Visibility.LIMITED, protectedOrcidBio.getExternalIdentifiers().getVisibility());
    // when existing is null - defaults to public and protected update
    // ignored?
    protectedOrcidBio.getExternalIdentifiers().setVisibility(Visibility.PRIVATE);
    orcidJaxbCopyManager.copyUpdatedExternalIdentifiersToExistingPreservingVisibility(publicOrcidBio, protectedOrcidBio);
    assertEquals(Visibility.PRIVATE, publicOrcidBio.getExternalIdentifiers().getVisibility());
    assertEquals(Visibility.PRIVATE, protectedOrcidBio.getExternalIdentifiers().getVisibility());
}
Also used : OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 5 with OrcidBio

use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.

the class OrcidJaxbCopyManagerTest method testUpdatedBiographyToExistingPreservingVisibility.

@Test
public void testUpdatedBiographyToExistingPreservingVisibility() throws Exception {
    OrcidBio existingOrcidBioProtected = protectedOrcidMessage.getOrcidProfile().getOrcidBio();
    OrcidBio updatedOrcidBioPublic = publicOrcidMessage.getOrcidProfile().getOrcidBio();
    assertEquals(Visibility.LIMITED, existingOrcidBioProtected.getBiography().getVisibility());
    String existingContent = "Josiah Stinkney Carberry is a fictional professor.";
    assertEquals(existingContent, existingOrcidBioProtected.getBiography().getContent().trim());
    assertNull(updatedOrcidBioPublic.getBiography().getVisibility());
    updatedOrcidBioPublic.setBiography(new Biography("A new bio"));
    updatedOrcidBioPublic.getBiography().setVisibility(Visibility.PRIVATE);
    orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingOrcidBioProtected, updatedOrcidBioPublic);
    // check that changes have propogated
    assertEquals(Visibility.PRIVATE, existingOrcidBioProtected.getBiography().getVisibility());
    assertEquals("A new bio", existingOrcidBioProtected.getBiography().getContent());
    // reset the variable and attempt to override the content and visibility
    updatedOrcidBioPublic = publicOrcidMessage.getOrcidProfile().getOrcidBio();
    updatedOrcidBioPublic.setBiography(new Biography("A new and impoved bio"));
    orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingOrcidBioProtected, updatedOrcidBioPublic);
    // check that the old values have been retained
    assertEquals(Visibility.PRIVATE, existingOrcidBioProtected.getBiography().getVisibility());
    assertEquals("A new bio", existingOrcidBioProtected.getBiography().getContent());
}
Also used : OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Biography(org.orcid.jaxb.model.message.Biography) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

OrcidBio (org.orcid.jaxb.model.message.OrcidBio)62 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)44 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)31 Test (org.junit.Test)30 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)23 GivenNames (org.orcid.jaxb.model.message.GivenNames)22 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)21 Email (org.orcid.jaxb.model.message.Email)20 FamilyName (org.orcid.jaxb.model.message.FamilyName)18 BaseTest (org.orcid.core.BaseTest)16 ExternalIdentifiers (org.orcid.jaxb.model.message.ExternalIdentifiers)16 CreditName (org.orcid.jaxb.model.message.CreditName)15 ExternalIdentifier (org.orcid.jaxb.model.message.ExternalIdentifier)15 ExternalIdReference (org.orcid.jaxb.model.message.ExternalIdReference)11 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)11 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)10 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)10 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)10 ExternalIdCommonName (org.orcid.jaxb.model.message.ExternalIdCommonName)9 OtherName (org.orcid.jaxb.model.message.OtherName)9