use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testGetPublicEducationUsingToken.
// Education
@Test
public void testGetPublicEducationUsingToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewEducation(ORCID, 20L);
assertNotNull(r);
Education e = (Education) r.getEntity();
assertNotNull(e);
assertNotNull(e.getLastModifiedDate());
assertNotNull(e.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(20), e.getPutCode());
}
use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testViewEducations.
@Test
public void testViewEducations() {
Response response = serviceDelegator.viewEducations(ORCID);
assertNotNull(response);
Educations educations = (Educations) response.getEntity();
assertNotNull(educations);
assertEquals("/0000-0000-0000-0003/educations", educations.getPath());
assertNotNull(educations.getLastModifiedDate());
assertNotNull(educations.getLastModifiedDate().getValue());
assertEquals(1, educations.getSummaries().size());
EducationSummary education = educations.getSummaries().get(0);
assertEquals(Long.valueOf(20), education.getPutCode());
assertNotNull(education.getLastModifiedDate());
assertNotNull(education.getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/education/20", education.getPath());
assertEquals("PUBLIC Department", education.getDepartmentName());
assertEquals(Visibility.PUBLIC.value(), education.getVisibility().value());
assertEquals("APP-5555555555555555", education.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class AffiliationsController method addAffiliation.
/**
* Adds a new affiliations
*
* @param affiliationForm
*/
private void addAffiliation(AffiliationForm affiliationForm) {
Affiliation affiliation = affiliationForm.toAffiliation();
if (affiliation instanceof Distinction) {
affiliation = affiliationsManager.createDistinctionAffiliation(getCurrentUserOrcid(), (Distinction) affiliation, false);
} else if (affiliation instanceof Education) {
affiliation = affiliationsManager.createEducationAffiliation(getCurrentUserOrcid(), (Education) affiliation, false);
} else if (affiliation instanceof Employment) {
affiliation = affiliationsManager.createEmploymentAffiliation(getCurrentUserOrcid(), (Employment) affiliation, false);
} else if (affiliation instanceof InvitedPosition) {
affiliation = affiliationsManager.createInvitedPositionAffiliation(getCurrentUserOrcid(), (InvitedPosition) affiliation, false);
} else if (affiliation instanceof Membership) {
affiliation = affiliationsManager.createMembershipAffiliation(getCurrentUserOrcid(), (Membership) affiliation, false);
} else if (affiliation instanceof Qualification) {
affiliation = affiliationsManager.createQualificationAffiliation(getCurrentUserOrcid(), (Qualification) affiliation, false);
} else if (affiliation instanceof Service) {
affiliation = affiliationsManager.createServiceAffiliation(getCurrentUserOrcid(), (Service) affiliation, false);
} else {
throw new IllegalArgumentException("Invalid affiliation type: " + affiliation.getClass().getName());
}
affiliationForm.setPutCode(Text.valueOf(affiliation.getPutCode()));
}
use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class BlackBoxBaseV3_0_dev1 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;
} else if (Distinction.class.equals(type)) {
result = (Distinction) obj;
} else if (InvitedPosition.class.equals(type)) {
result = (InvitedPosition) obj;
} else if (Membership.class.equals(type)) {
result = (Membership) obj;
} else if (Qualification.class.equals(type)) {
result = (Qualification) obj;
} else if (Service.class.equals(type)) {
result = (Service) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class MemberV3Dev1Test method testUpdateEducationWithProfileCreationTokenWhenClaimedAndNotSource.
@Test
public void testUpdateEducationWithProfileCreationTokenWhenClaimedAndNotSource() throws JSONException, InterruptedException, URISyntaxException {
Education education = (Education) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/education-3.0_dev1.xml", Education.class);
education.setPutCode(null);
education.setVisibility(Visibility.PUBLIC);
String accessToken = getAccessToken();
ClientResponse postResponse = memberV3Dev1ApiClientImpl.createEducationXml(this.getUser1OrcidId(), education, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
String locationPath = postResponse.getLocation().getPath();
assertTrue("Location header path should match pattern, but was " + locationPath, locationPath.matches(".*/v3.0_dev1/" + this.getUser1OrcidId() + "/education/\\d+"));
ClientResponse getResponse = memberV3Dev1ApiClientImpl.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
Education gotEducation = getResponse.getEntity(Education.class);
assertEquals("department-name", gotEducation.getDepartmentName());
assertEquals("role-title", gotEducation.getRoleTitle());
gotEducation.setDepartmentName("updated dept. name");
gotEducation.setRoleTitle("updated role title");
String profileCreateToken = oauthHelper.getClientCredentialsAccessToken(this.getClient2ClientId(), this.getClient2ClientSecret(), ScopePathType.ORCID_PROFILE_CREATE);
ClientResponse putResponse = memberV3Dev1ApiClientImpl.updateLocationXml(postResponse.getLocation(), profileCreateToken, gotEducation);
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
ClientResponse getAfterUpdateResponse = memberV3Dev1ApiClientImpl.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
Education gotAfterUpdateEducation = getAfterUpdateResponse.getEntity(Education.class);
assertEquals("department-name", gotAfterUpdateEducation.getDepartmentName());
assertEquals("role-title", gotAfterUpdateEducation.getRoleTitle());
ClientResponse deleteResponse = memberV3Dev1ApiClientImpl.deleteEducationXml(this.getUser1OrcidId(), gotEducation.getPutCode(), accessToken);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Aggregations