use of org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers 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);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ExternalIdentifiersTest method testReadPublicScope_ExternalIdentifiers.
@Test
public void testReadPublicScope_ExternalIdentifiers() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
// Public works
Response r = serviceDelegator.viewExternalIdentifiers(ORCID);
assertNotNull(r);
assertEquals(PersonExternalIdentifiers.class.getName(), r.getEntity().getClass().getName());
PersonExternalIdentifiers p = (PersonExternalIdentifiers) r.getEntity();
assertNotNull(p);
assertEquals("/0000-0000-0000-0003/external-identifiers", p.getPath());
Utils.verifyLastModified(p.getLastModifiedDate());
assertEquals(3, p.getExternalIdentifiers().size());
boolean found13 = false, found14 = false, found15 = false;
for (PersonExternalIdentifier element : p.getExternalIdentifiers()) {
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);
r = serviceDelegator.viewExternalIdentifier(ORCID, 13L);
assertNotNull(r);
assertEquals(PersonExternalIdentifier.class.getName(), r.getEntity().getClass().getName());
// Limited am the source of should work
serviceDelegator.viewExternalIdentifier(ORCID, 14L);
// Limited fail
try {
serviceDelegator.viewExternalIdentifier(ORCID, 16L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
// Private am the source of should work
serviceDelegator.viewExternalIdentifier(ORCID, 15L);
// Private fail
try {
serviceDelegator.viewExternalIdentifier(ORCID, 17L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
}
use of org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV3Test method filterExternalIdentifiersTest.
@Test
public void filterExternalIdentifiersTest() {
PersonExternalIdentifiers x = getPersonExternalIdentifiersElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC);
assertEquals(3, x.getExternalIdentifiers().size());
publicAPISecurityManagerV3.filter(x);
assertEquals(3, x.getExternalIdentifiers().size());
assertAllArePublic(x.getExternalIdentifiers());
x = getPersonExternalIdentifiersElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.LIMITED);
assertEquals(3, x.getExternalIdentifiers().size());
publicAPISecurityManagerV3.filter(x);
assertEquals(2, x.getExternalIdentifiers().size());
assertAllArePublic(x.getExternalIdentifiers());
x = getPersonExternalIdentifiersElement(Visibility.PUBLIC, Visibility.LIMITED, Visibility.PRIVATE);
assertEquals(3, x.getExternalIdentifiers().size());
publicAPISecurityManagerV3.filter(x);
assertEquals(1, x.getExternalIdentifiers().size());
assertAllArePublic(x.getExternalIdentifiers());
x = getPersonExternalIdentifiersElement(Visibility.PRIVATE, Visibility.LIMITED, Visibility.PRIVATE);
assertEquals(3, x.getExternalIdentifiers().size());
publicAPISecurityManagerV3.filter(x);
assertTrue(x.getExternalIdentifiers().isEmpty());
}
use of org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers in project ORCID-Source by ORCID.
the class PersonDetailsManagerReadOnlyImpl method getPersonDetails.
@Override
public Person getPersonDetails(String orcid) {
long lastModifiedTime = getLastModified(orcid);
Person person = new Person();
person.setName(recordNameManager.getRecordName(orcid));
person.setBiography(biographyManager.getBiography(orcid));
Addresses addresses = addressManager.getAddresses(orcid);
if (addresses.getAddress() != null) {
Addresses filteredAddresses = new Addresses();
filteredAddresses.setAddress(new ArrayList<Address>(addresses.getAddress()));
person.setAddresses(filteredAddresses);
}
PersonExternalIdentifiers extIds = externalIdentifierManager.getExternalIdentifiers(orcid);
if (extIds.getExternalIdentifiers() != null) {
PersonExternalIdentifiers filteredExtIds = new PersonExternalIdentifiers();
filteredExtIds.setExternalIdentifiers(new ArrayList<PersonExternalIdentifier>(extIds.getExternalIdentifiers()));
person.setExternalIdentifiers(filteredExtIds);
}
Keywords keywords = profileKeywordManager.getKeywords(orcid);
if (keywords.getKeywords() != null) {
Keywords filteredKeywords = new Keywords();
filteredKeywords.setKeywords(new ArrayList<Keyword>(keywords.getKeywords()));
person.setKeywords(filteredKeywords);
}
OtherNames otherNames = otherNameManager.getOtherNames(orcid);
if (otherNames.getOtherNames() != null) {
OtherNames filteredOtherNames = new OtherNames();
filteredOtherNames.setOtherNames(new ArrayList<OtherName>(otherNames.getOtherNames()));
person.setOtherNames(filteredOtherNames);
}
ResearcherUrls rUrls = researcherUrlManager.getResearcherUrls(orcid);
if (rUrls.getResearcherUrls() != null) {
ResearcherUrls filteredRUrls = new ResearcherUrls();
filteredRUrls.setResearcherUrls(new ArrayList<ResearcherUrl>(rUrls.getResearcherUrls()));
person.setResearcherUrls(filteredRUrls);
}
Emails emails = emailManager.getEmails(orcid);
if (emails.getEmails() != null) {
Emails filteredEmails = new Emails();
filteredEmails.setEmails(new ArrayList<Email>(emails.getEmails()));
person.setEmails(filteredEmails);
}
return person;
}
use of org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers in project ORCID-Source by ORCID.
the class OrcidInfo method groupExternalIdentifiers.
private LinkedHashMap<String, List<PersonExternalIdentifier>> groupExternalIdentifiers(PersonExternalIdentifiers personExternalIdentifiers) {
if (personExternalIdentifiers == null || personExternalIdentifiers.getExternalIdentifiers() == null) {
return null;
}
LinkedHashMap<String, List<PersonExternalIdentifier>> groups = new LinkedHashMap<String, List<PersonExternalIdentifier>>();
for (PersonExternalIdentifier ei : personExternalIdentifiers.getExternalIdentifiers()) {
String pairKey = ei.getType() + ":" + ei.getValue();
if (groups.containsKey(pairKey)) {
groups.get(pairKey).add(ei);
} else {
List<PersonExternalIdentifier> list = new ArrayList<PersonExternalIdentifier>();
list.add(ei);
groups.put(pairKey, list);
}
}
return groups;
}
Aggregations