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