use of org.orcid.jaxb.model.v3.dev1.record.PersonalDetails in project ORCID-Source by ORCID.
the class SourceUtils method setSourceName.
public void setSourceName(PersonalDetails personalDetails) {
if (personalDetails == null) {
return;
}
if (personalDetails.getOtherNames() != null) {
OtherNames otherNames = personalDetails.getOtherNames();
setSourceName(otherNames);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.PersonalDetails in project ORCID-Source by ORCID.
the class Api3_0_Dev1LastModifiedDatesHelper method calculateLastModified.
public static void calculateLastModified(PersonalDetails personalDetails) {
if (personalDetails != null) {
calculateLastModified(personalDetails.getOtherNames());
LastModifiedDate l1 = personalDetails.getBiography() == null ? null : personalDetails.getBiography().getLastModifiedDate();
LastModifiedDate l2 = personalDetails.getName() == null ? null : personalDetails.getName().getLastModifiedDate();
LastModifiedDate l3 = personalDetails.getOtherNames() == null ? null : personalDetails.getOtherNames().getLastModifiedDate();
LastModifiedDate globalLatest = calculateLatest(l1, l2, l3);
personalDetails.setLastModifiedDate(globalLatest);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.PersonalDetails in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_PersonalDetailsTest method testReadPublicScope_PersonalDetails.
@Test
public void testReadPublicScope_PersonalDetails() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewPersonalDetails(ORCID);
assertNotNull(r);
assertEquals(PersonalDetails.class.getName(), r.getEntity().getClass().getName());
PersonalDetails p = (PersonalDetails) r.getEntity();
assertEquals("/0000-0000-0000-0003/personal-details", p.getPath());
Utils.verifyLastModified(p.getLastModifiedDate());
Utils.verifyLastModified(p.getBiography().getLastModifiedDate());
Utils.verifyLastModified(p.getName().getLastModifiedDate());
Utils.verifyLastModified(p.getOtherNames().getLastModifiedDate());
assertEquals("Biography for 0000-0000-0000-0003", p.getBiography().getContent());
assertEquals("Credit Name", p.getName().getCreditName().getContent());
assertEquals("Given Names", p.getName().getGivenNames().getContent());
assertEquals("Family Name", p.getName().getFamilyName().getContent());
assertEquals(3, p.getOtherNames().getOtherNames().size());
boolean found13 = false, found14 = false, found15 = false;
for (OtherName element : p.getOtherNames().getOtherNames()) {
if (element.getPutCode() == 13) {
found13 = true;
} else if (element.getPutCode() == 14) {
found14 = true;
} else if (element.getPutCode() == 15) {
found15 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found13);
assertTrue(found14);
assertTrue(found15);
String otherOrcid = "0000-0000-0000-0002";
SecurityContextTestUtils.setUpSecurityContext(otherOrcid, ScopePathType.READ_PUBLIC);
r = serviceDelegator.viewPersonalDetails(otherOrcid);
assertNotNull(r);
assertEquals(PersonalDetails.class.getName(), r.getEntity().getClass().getName());
p = (PersonalDetails) r.getEntity();
assertNull(p.getBiography());
assertNull(p.getName());
assertNotNull(p.getOtherNames());
assertTrue(p.getOtherNames().getOtherNames().isEmpty());
}
use of org.orcid.jaxb.model.v3.dev1.record.PersonalDetails in project ORCID-Source by ORCID.
the class PersonalDetailsTest method testGetWithMemberAPI.
@Test
public void testGetWithMemberAPI() throws Exception {
String accessToken = getAccessToken(getUser1OrcidId(), getUser1Password(), getScopes(ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE), getClient2ClientId(), getClient2ClientSecret(), getClient2RedirectUri());
assertNotNull(accessToken);
ClientResponse getPersonalDetailsResponse = memberV3Dev1ApiClient.viewPersonalDetailsXML(getUser1OrcidId(), accessToken);
assertNotNull(getPersonalDetailsResponse);
org.orcid.jaxb.model.v3.dev1.record.PersonalDetails personalDetails = getPersonalDetailsResponse.getEntity(org.orcid.jaxb.model.v3.dev1.record.PersonalDetails.class);
assertNotNull(personalDetails);
// Check bio
assertNotNull(personalDetails.getBiography());
assertEquals(getUser1Bio(), personalDetails.getBiography().getContent());
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC.value(), personalDetails.getBiography().getVisibility().value());
// Check other names
assertNotNull(personalDetails.getOtherNames());
assertNotNull(personalDetails.getOtherNames().getOtherNames());
boolean found1 = false, found2 = false;
for (org.orcid.jaxb.model.v3.dev1.record.OtherName otherName : personalDetails.getOtherNames().getOtherNames()) {
// Assert that PRIVATE ones belongs to himself
if (org.orcid.jaxb.model.v3.dev1.common.Visibility.PRIVATE.equals(otherName.getVisibility())) {
assertEquals(getClient2ClientId(), otherName.getSource().retrieveSourcePath());
}
if (otherName.getContent().equals(otherName1)) {
found1 = true;
} else if (otherName.getContent().equals(otherName2)) {
found2 = true;
}
}
assertTrue("found1: " + found1 + " found2: " + found2, found1 && found2);
// Check names
assertNotNull(personalDetails.getName());
assertNotNull(personalDetails.getName().getGivenNames());
assertEquals(getUser1GivenName(), personalDetails.getName().getGivenNames().getContent());
assertNotNull(personalDetails.getName().getFamilyName());
assertEquals(getUser1FamilyNames(), personalDetails.getName().getFamilyName().getContent());
assertNotNull(personalDetails.getName().getCreditName());
assertEquals(getUser1CreditName(), personalDetails.getName().getCreditName().getContent());
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC, personalDetails.getName().getVisibility());
// Change all to LIMITED
showMyOrcidPage();
changeNamesVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.LIMITED.name());
setOtherNamesVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.LIMITED);
changeBiography(null, org.orcid.jaxb.model.v3.dev1.common.Visibility.LIMITED.name());
// Verify they are still visible
getPersonalDetailsResponse = memberV3Dev1ApiClient.viewPersonalDetailsXML(getUser1OrcidId(), accessToken);
assertNotNull(getPersonalDetailsResponse);
personalDetails = getPersonalDetailsResponse.getEntity(org.orcid.jaxb.model.v3.dev1.record.PersonalDetails.class);
assertNotNull(personalDetails);
// Check bio
assertNotNull(personalDetails.getBiography());
assertEquals(getUser1Bio(), personalDetails.getBiography().getContent());
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Visibility.LIMITED.value(), personalDetails.getBiography().getVisibility().value());
// Check other names
assertNotNull(personalDetails.getOtherNames());
assertNotNull(personalDetails.getOtherNames().getOtherNames());
// Check other names
assertNotNull(personalDetails.getOtherNames());
assertNotNull(personalDetails.getOtherNames().getOtherNames());
found1 = false;
found2 = false;
for (org.orcid.jaxb.model.v3.dev1.record.OtherName otherName : personalDetails.getOtherNames().getOtherNames()) {
// Assert that PRIVATE ones belongs to himself
if (org.orcid.jaxb.model.v3.dev1.common.Visibility.PRIVATE.equals(otherName.getVisibility())) {
assertEquals(getClient2ClientId(), otherName.getSource().retrieveSourcePath());
}
if (otherName.getContent().equals(otherName1)) {
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Visibility.LIMITED, otherName.getVisibility());
found1 = true;
} else if (otherName.getContent().equals(otherName2)) {
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Visibility.LIMITED, otherName.getVisibility());
found2 = true;
}
}
assertTrue("found1: " + found1 + " found2: " + found2, found1 && found2);
// Check names
assertNotNull(personalDetails.getName());
assertNotNull(personalDetails.getName().getGivenNames());
assertEquals(getUser1GivenName(), personalDetails.getName().getGivenNames().getContent());
assertNotNull(personalDetails.getName().getFamilyName());
assertEquals(getUser1FamilyNames(), personalDetails.getName().getFamilyName().getContent());
assertNotNull(personalDetails.getName().getCreditName());
assertEquals(getUser1CreditName(), personalDetails.getName().getCreditName().getContent());
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Visibility.LIMITED, personalDetails.getName().getVisibility());
// Change all to PRIVATE
showMyOrcidPage();
changeNamesVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.PRIVATE.name());
setOtherNamesVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.PRIVATE);
changeBiography(null, org.orcid.jaxb.model.v3.dev1.common.Visibility.PRIVATE.name());
// Check nothing is visible
getPersonalDetailsResponse = memberV3Dev1ApiClient.viewPersonalDetailsXML(getUser1OrcidId(), accessToken);
assertNotNull(getPersonalDetailsResponse);
personalDetails = getPersonalDetailsResponse.getEntity(org.orcid.jaxb.model.v3.dev1.record.PersonalDetails.class);
assertNotNull(personalDetails);
assertNull(personalDetails.getBiography());
assertNull(personalDetails.getName());
assertNotNull(personalDetails.getOtherNames());
assertNotNull(personalDetails.getOtherNames().getOtherNames());
assertTrue(personalDetails.getOtherNames().getOtherNames().isEmpty());
// Change all to PUBLIC
showMyOrcidPage();
changeNamesVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC.name());
setOtherNamesVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC);
changeBiography(null, org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC.name());
}
use of org.orcid.jaxb.model.v3.dev1.record.PersonalDetails in project ORCID-Source by ORCID.
the class ValidateV3_dev1SamplesTest method unmarshallFromPath.
private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
Object obj = unmarshall(reader, type, schemaPath);
Object result = null;
if (ResearcherUrls.class.equals(type)) {
result = (ResearcherUrls) obj;
} else if (ResearcherUrl.class.equals(type)) {
result = (ResearcherUrl) obj;
} else if (PersonalDetails.class.equals(type)) {
result = (PersonalDetails) obj;
} else if (PersonExternalIdentifier.class.equals(type)) {
result = (PersonExternalIdentifier) obj;
} else if (PersonExternalIdentifiers.class.equals(type)) {
result = (PersonExternalIdentifiers) obj;
} else if (Biography.class.equals(type)) {
result = (Biography) obj;
} else if (Name.class.equals(type)) {
result = (Name) obj;
} else if (CreditName.class.equals(type)) {
result = (CreditName) obj;
} else if (OtherName.class.equals(type)) {
result = (OtherName) obj;
} else if (OtherNames.class.equals(type)) {
result = (OtherNames) obj;
} else if (Keywords.class.equals(type)) {
result = (Keywords) obj;
} else if (Keyword.class.equals(type)) {
result = (Keyword) obj;
} else if (Addresses.class.equals(type)) {
result = (Addresses) obj;
} else if (Address.class.equals(type)) {
result = (Address) obj;
} else if (Emails.class.equals(type)) {
result = (Emails) obj;
} else if (Email.class.equals(type)) {
result = (Email) obj;
} else if (Person.class.equals(type)) {
result = (Person) obj;
} else if (Deprecated.class.equals(type)) {
result = (Deprecated) obj;
} else if (Preferences.class.equals(type)) {
result = (Preferences) obj;
} else if (History.class.equals(type)) {
result = (History) obj;
} else if (Record.class.equals(type)) {
result = (Record) obj;
} else if (ActivitiesSummary.class.equals(type)) {
result = (ActivitiesSummary) obj;
} else if (Works.class.equals(type)) {
result = (Works) obj;
} else if (Education.class.equals(type)) {
result = (Education) obj;
} else if (Educations.class.equals(type)) {
result = (Educations) obj;
} else if (Employment.class.equals(type)) {
result = (Employment) obj;
} else if (Employments.class.equals(type)) {
result = (Employments) obj;
} else if (Distinction.class.equals(type)) {
result = (Distinction) obj;
} else if (Distinctions.class.equals(type)) {
result = (Distinctions) obj;
} else if (InvitedPosition.class.equals(type)) {
result = (InvitedPosition) obj;
} else if (InvitedPositions.class.equals(type)) {
result = (InvitedPositions) obj;
} else if (Membership.class.equals(type)) {
result = (Membership) obj;
} else if (Memberships.class.equals(type)) {
result = (Memberships) obj;
} else if (Qualification.class.equals(type)) {
result = (Qualification) obj;
} else if (Qualifications.class.equals(type)) {
result = (Qualifications) obj;
} else if (Service.class.equals(type)) {
result = (Service) obj;
} else if (Services.class.equals(type)) {
result = (Services) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
Aggregations