use of org.orcid.jaxb.model.record_rc4.PersonalDetails in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegatorImpl method viewPersonalDetails.
@Override
public Response viewPersonalDetails(String orcid) {
PersonalDetails personalDetails = personalDetailsManagerReadOnly.getPersonalDetails(orcid);
orcidSecurityManager.checkAndFilter(orcid, personalDetails);
ElementUtils.setPathToPersonalDetails(personalDetails, orcid);
Api2_0_LastModifiedDatesHelper.calculateLastModified(personalDetails);
sourceUtils.setSourceName(personalDetails);
return Response.ok(personalDetails).build();
}
use of org.orcid.jaxb.model.record_rc4.PersonalDetails in project ORCID-Source by ORCID.
the class PersonalDetailsManagerReadOnlyImpl method getPublicPersonalDetails.
@Override
public PersonalDetails getPublicPersonalDetails(String orcid) {
Date lastModified = getLastModifiedDate(orcid);
long lastModifiedTime = (lastModified == null) ? 0 : lastModified.getTime();
PersonalDetails personalDetails = new PersonalDetails();
Biography bio = biographyManager.getPublicBiography(orcid, lastModifiedTime);
if (bio != null) {
personalDetails.setBiography(bio);
}
Name name = recordNameManager.getRecordName(orcid, lastModifiedTime);
if (name != null && !Visibility.PUBLIC.equals(name.getVisibility())) {
personalDetails.setName(null);
} else {
personalDetails.setName(name);
}
OtherNames otherNames = otherNameManager.getPublicOtherNames(orcid, lastModifiedTime);
OtherNames filteredOtherNames = new OtherNames();
personalDetails.setOtherNames(filteredOtherNames);
if (otherNames != null && otherNames.getOtherNames() != null && !otherNames.getOtherNames().isEmpty()) {
// Lets copy the list so we don't modify the cached collection
List<OtherName> filteredList = new ArrayList<OtherName>(otherNames.getOtherNames());
filteredOtherNames.setOtherNames(filteredList);
}
if (personalDetails.getLastModifiedDate() == null || personalDetails.getLastModifiedDate().getValue() == null) {
personalDetails.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(lastModified)));
}
return personalDetails;
}
use of org.orcid.jaxb.model.record_rc4.PersonalDetails in project ORCID-Source by ORCID.
the class BlackBoxBaseRC4 method unmarshallFromPath.
public Object unmarshallFromPath(String path, Class<?> type) {
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
Object obj = unmarshall(reader, type);
Object result = null;
if (Address.class.equals(type)) {
result = (Address) obj;
} else if (Education.class.equals(type)) {
result = (Education) obj;
} else if (Employment.class.equals(type)) {
result = (Employment) obj;
} else if (Funding.class.equals(type)) {
result = (Funding) obj;
} else if (Keyword.class.equals(type)) {
result = (Keyword) obj;
} else if (Work.class.equals(type)) {
result = (Work) obj;
} else if (PeerReview.class.equals(type)) {
result = (PeerReview) obj;
} else if (ResearcherUrl.class.equals(type)) {
result = (ResearcherUrl) obj;
} else if (PersonalDetails.class.equals(type)) {
result = (PersonalDetails) obj;
} else if (OtherName.class.equals(type)) {
result = (OtherName) obj;
} else if (PersonExternalIdentifier.class.equals(type)) {
result = (PersonExternalIdentifier) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
use of org.orcid.jaxb.model.record_rc4.PersonalDetails in project ORCID-Source by ORCID.
the class ValidateV2SamplesTest method testMarshallPersonalDetails.
@Test
public void testMarshallPersonalDetails() throws JAXBException, SAXException, URISyntaxException {
PersonalDetails object = (PersonalDetails) unmarshallFromPath("/record_2.0/samples/read_samples/personal-details-2.0.xml", PersonalDetails.class);
marshall(object, "/record_2.0/personal-details-2.0.xsd");
}
use of org.orcid.jaxb.model.record_rc4.PersonalDetails in project ORCID-Source by ORCID.
the class ValidateV2_1SamplesTest method testUnmarshallPersonalDetails.
@Test
public void testUnmarshallPersonalDetails() throws SAXException, URISyntaxException {
PersonalDetails personalDetails = (PersonalDetails) unmarshallFromPath("/record_2.1/samples/read_samples/personal-details-2.1.xml", PersonalDetails.class, "/record_2.1/personal-details-2.1.xsd");
assertNotNull(personalDetails);
// Check bio
assertNotNull(personalDetails.getBiography());
assertEquals("Biography", personalDetails.getBiography().getContent());
assertEquals(Visibility.PUBLIC.value(), personalDetails.getBiography().getVisibility().value());
// Check names
assertNotNull(personalDetails.getName());
assertNotNull(personalDetails.getName().getCreditName());
assertEquals("Credit Name", personalDetails.getName().getCreditName().getContent());
assertNotNull(personalDetails.getName().getGivenNames());
assertEquals("Give Names", personalDetails.getName().getGivenNames().getContent());
assertNotNull(personalDetails.getName().getFamilyName());
assertEquals("Family Name", personalDetails.getName().getFamilyName().getContent());
assertEquals(Visibility.PUBLIC.value(), personalDetails.getName().getVisibility().value());
// Check other names
assertNotNull(personalDetails.getOtherNames());
assertNotNull(personalDetails.getOtherNames().getOtherNames());
assertEquals(2, personalDetails.getOtherNames().getOtherNames().size());
validateSourceInHttps(personalDetails.getOtherNames().getOtherNames().get(0).getSource());
validateSourceInHttps(personalDetails.getOtherNames().getOtherNames().get(1).getSource());
assertEquals("Other Name #1", personalDetails.getOtherNames().getOtherNames().get(0).getContent());
assertEquals("Other Name #2", personalDetails.getOtherNames().getOtherNames().get(1).getContent());
assertEquals(Visibility.PUBLIC, personalDetails.getOtherNames().getOtherNames().get(0).getVisibility());
assertEquals(Visibility.LIMITED, personalDetails.getOtherNames().getOtherNames().get(1).getVisibility());
}
Aggregations