use of org.orcid.jaxb.model.record.summary_rc1.EducationSummary in project ORCID-Source by ORCID.
the class PublicV2Test method cleanActivities.
public void cleanActivities() throws JSONException, InterruptedException, URISyntaxException {
// Remove all activities
String token = getAccessToken();
ClientResponse activitiesResponse = memberV2ApiClient.viewActivities(getUser1OrcidId(), token);
assertNotNull(activitiesResponse);
ActivitiesSummary summary = activitiesResponse.getEntity(ActivitiesSummary.class);
assertNotNull(summary);
if (summary.getEducations() != null && !summary.getEducations().getSummaries().isEmpty()) {
for (EducationSummary education : summary.getEducations().getSummaries()) {
memberV2ApiClient.deleteEducationXml(getUser1OrcidId(), education.getPutCode(), token);
}
}
if (summary.getEmployments() != null && !summary.getEmployments().getSummaries().isEmpty()) {
for (EmploymentSummary employment : summary.getEmployments().getSummaries()) {
memberV2ApiClient.deleteEmploymentXml(getUser1OrcidId(), employment.getPutCode(), token);
}
}
if (summary.getFundings() != null && !summary.getFundings().getFundingGroup().isEmpty()) {
for (FundingGroup group : summary.getFundings().getFundingGroup()) {
for (FundingSummary funding : group.getFundingSummary()) {
memberV2ApiClient.deleteFundingXml(getUser1OrcidId(), funding.getPutCode(), token);
}
}
}
if (summary.getWorks() != null && !summary.getWorks().getWorkGroup().isEmpty()) {
for (WorkGroup group : summary.getWorks().getWorkGroup()) {
for (WorkSummary work : group.getWorkSummary()) {
memberV2ApiClient.deleteWorkXml(getUser1OrcidId(), work.getPutCode(), token);
}
}
}
if (summary.getPeerReviews() != null && !summary.getPeerReviews().getPeerReviewGroup().isEmpty()) {
for (PeerReviewGroup group : summary.getPeerReviews().getPeerReviewGroup()) {
for (PeerReviewSummary peerReview : group.getPeerReviewSummary()) {
memberV2ApiClient.deletePeerReviewXml(getUser1OrcidId(), peerReview.getPutCode(), token);
}
}
}
}
use of org.orcid.jaxb.model.record.summary_rc1.EducationSummary in project ORCID-Source by ORCID.
the class PublicV2Test method checkEducation.
public void checkEducation(String readPublicToken) throws JSONException, InterruptedException, URISyntaxException {
Education educationToCreate = (Education) unmarshallFromPath("/record_2.0_rc1/samples/education-2.0_rc1.xml", Education.class);
educationToCreate.setPutCode(null);
educationToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.PUBLIC);
String accessToken = getAccessToken();
ClientResponse postResponse = memberV2ApiClient.createEducationXml(getUser1OrcidId(), educationToCreate, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
String path = postResponse.getLocation().getPath();
String putCode = path.substring(path.lastIndexOf('/') + 1, path.length());
ClientResponse getEducationResponse = null;
if (readPublicToken != null) {
getEducationResponse = publicV2ApiClient.viewEducationXml(getUser1OrcidId(), putCode, readPublicToken);
} else {
getEducationResponse = publicV2ApiClient.viewEducationXml(getUser1OrcidId(), putCode);
}
assertNotNull(getEducationResponse);
checkResponse(getEducationResponse);
Education education = getEducationResponse.getEntity(Education.class);
assertNotNull(education);
assertEquals("education:department-name", education.getDepartmentName());
ClientResponse getEducationSummaryResponse = null;
if (readPublicToken != null) {
getEducationSummaryResponse = publicV2ApiClient.viewEducationSummaryXml(getUser1OrcidId(), putCode, readPublicToken);
} else {
getEducationSummaryResponse = publicV2ApiClient.viewEducationSummaryXml(getUser1OrcidId(), putCode);
}
assertNotNull(getEducationSummaryResponse);
checkResponse(getEducationSummaryResponse);
EducationSummary summary = getEducationSummaryResponse.getEntity(EducationSummary.class);
assertNotNull(summary);
assertEquals("education:department-name", summary.getDepartmentName());
}
use of org.orcid.jaxb.model.record.summary_rc1.EducationSummary in project ORCID-Source by ORCID.
the class PublicV2Test method checkPublicActivities.
public void checkPublicActivities(String readPublicToken) throws JSONException, InterruptedException, URISyntaxException {
createActivities();
ClientResponse activitiesResponse = null;
if (readPublicToken != null) {
activitiesResponse = publicV2ApiClient.viewActivities(getUser1OrcidId(), readPublicToken);
} else {
activitiesResponse = publicV2ApiClient.viewActivities(getUser1OrcidId());
}
assertNotNull(activitiesResponse);
ActivitiesSummary summary = activitiesResponse.getEntity(ActivitiesSummary.class);
assertNotNull(summary);
assertNotNull("There are no educations, please verify users default visibility is public", summary.getEducations());
assertFalse(summary.getEducations().getSummaries().isEmpty());
boolean found0 = false, found3 = false;
for (EducationSummary education : summary.getEducations().getSummaries()) {
if (education.getDepartmentName() != null) {
if (education.getDepartmentName().equals("Education # 0")) {
found0 = true;
} else if (education.getDepartmentName().equals("Education # 3")) {
found3 = true;
}
}
}
assertTrue("One of the educations was not found: 0(" + found0 + ") 3(" + found3 + "), please verify users default visibility is public", found0 == found3 == true);
assertNotNull("There are no employment, please verify users default visibility is public", summary.getEmployments());
assertFalse(summary.getEmployments().getSummaries().isEmpty());
found0 = found3 = false;
for (EmploymentSummary employment : summary.getEmployments().getSummaries()) {
if (employment.getDepartmentName() != null) {
if (employment.getDepartmentName().equals("Employment # 0")) {
found0 = true;
} else if (employment.getDepartmentName().equals("Employment # 3")) {
found3 = true;
}
}
}
assertTrue("One of the employments was not found: 0(" + found0 + ") 3(" + found3 + "), please verify users default visibility is public", found0 == found3 == true);
assertNotNull(summary.getFundings());
found0 = found3 = false;
for (FundingGroup group : summary.getFundings().getFundingGroup()) {
for (FundingSummary funding : group.getFundingSummary()) {
if (funding.getTitle() != null && funding.getTitle().getTitle() != null) {
if (funding.getTitle().getTitle().getContent().equals("Funding # 0")) {
found0 = true;
} else if (funding.getTitle().getTitle().getContent().equals("Funding # 3")) {
found3 = true;
}
}
}
}
assertTrue("One of the fundings was not found: 0(" + found0 + ") 3(" + found3 + "), please verify users default visibility is public", found0 == found3 == true);
assertNotNull(summary.getWorks());
found0 = found3 = false;
for (WorkGroup group : summary.getWorks().getWorkGroup()) {
for (WorkSummary work : group.getWorkSummary()) {
if (work.getTitle().getTitle().getContent().equals("Work # 0")) {
found0 = true;
} else if (work.getTitle().getTitle().getContent().equals("Work # 3")) {
found3 = true;
}
}
}
assertTrue("One of the works was not found: 0(" + found0 + ") 3(" + found3 + "), please verify users default visibility is public", found0 == found3 == true);
assertNotNull(summary.getPeerReviews());
found0 = found3 = false;
for (PeerReviewGroup group : summary.getPeerReviews().getPeerReviewGroup()) {
for (PeerReviewSummary peerReview : group.getPeerReviewSummary()) {
if (peerReview.getCompletionDate() != null && peerReview.getCompletionDate().getYear() != null) {
if (peerReview.getCompletionDate().getYear().getValue().equals("1000")) {
found0 = true;
} else if (peerReview.getCompletionDate().getYear().getValue().equals("4000")) {
found3 = true;
}
}
}
}
assertTrue("One of the peer reviews was not found: 0(" + found0 + ") 3(" + found3 + "), please verify users default visibility is public", found0 == found3 == true);
}
use of org.orcid.jaxb.model.record.summary_rc1.EducationSummary in project ORCID-Source by ORCID.
the class RecordTest method testViewRecordFromMemberAPI.
@Test
public void testViewRecordFromMemberAPI() throws InterruptedException, JSONException {
String accessToken = getAccessToken();
assertNotNull(accessToken);
ClientResponse response = memberV2_1ApiClient.viewRecord(getUser1OrcidId(), accessToken);
assertNotNull(response);
assertEquals("invalid " + response, 200, response.getStatus());
Record record = response.getEntity(Record.class);
assertNotNull(record);
assertNotNull(record.getOrcidIdentifier());
assertEquals(getUser1OrcidId(), record.getOrcidIdentifier().getPath());
//Check the visibility of every activity that exists
if (record.getActivitiesSummary() != null) {
//Educations
if (record.getActivitiesSummary().getEducations() != null) {
Educations e = record.getActivitiesSummary().getEducations();
if (e.getSummaries() != null) {
for (EducationSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
//If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
//Employments
if (record.getActivitiesSummary().getEmployments() != null) {
Employments e = record.getActivitiesSummary().getEmployments();
if (e.getSummaries() != null) {
for (EmploymentSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
//If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
//Fundings
if (record.getActivitiesSummary().getFundings() != null) {
Fundings f = record.getActivitiesSummary().getFundings();
List<FundingGroup> groups = f.getFundingGroup();
if (groups != null) {
for (FundingGroup fGroup : groups) {
List<FundingSummary> summaries = fGroup.getFundingSummary();
if (summaries != null) {
for (FundingSummary s : summaries) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
//If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
}
}
//PeerReviews
if (record.getActivitiesSummary().getPeerReviews() != null) {
PeerReviews p = record.getActivitiesSummary().getPeerReviews();
List<PeerReviewGroup> groups = p.getPeerReviewGroup();
if (groups != null) {
for (PeerReviewGroup pGroup : groups) {
List<PeerReviewSummary> summaries = pGroup.getPeerReviewSummary();
if (summaries != null) {
for (PeerReviewSummary s : summaries) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
//If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
}
}
//Works
if (record.getActivitiesSummary().getWorks() != null) {
Works w = record.getActivitiesSummary().getWorks();
List<WorkGroup> groups = w.getWorkGroup();
if (groups != null) {
for (WorkGroup wGroup : groups) {
List<WorkSummary> summaries = wGroup.getWorkSummary();
if (summaries != null) {
for (WorkSummary s : summaries) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
//If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
}
}
}
//Check the visibility of every biography elements that exists
if (record.getPerson() != null) {
//Address
if (record.getPerson().getAddresses() != null) {
Addresses addresses = record.getPerson().getAddresses();
List<Address> list = addresses.getAddress();
if (list != null) {
for (Address o : list) {
assertNotNull(o.getSource());
assertNotNull(o.getVisibility());
Visibility v = o.getVisibility();
//If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), o.getSource().retrieveSourcePath());
}
}
}
}
//Biography
if (record.getPerson().getBiography() != null) {
Biography b = record.getPerson().getBiography();
if (b != null) {
assertNotNull(b.getVisibility());
if (Visibility.PRIVATE.equals(b.getVisibility())) {
fail("Visibility is private");
}
}
}
//Emails
if (record.getPerson().getEmails() != null) {
Emails emails = record.getPerson().getEmails();
List<Email> list = emails.getEmails();
if (list != null) {
for (Email e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
fail("Email " + e.getEmail() + " is private");
}
}
}
}
//External identifiers
if (record.getPerson().getExternalIdentifiers() != null) {
PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
if (list != null) {
for (PersonExternalIdentifier e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
//Keywords
if (record.getPerson().getKeywords() != null) {
Keywords keywords = record.getPerson().getKeywords();
List<Keyword> list = keywords.getKeywords();
if (list != null) {
for (Keyword e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
//Name
if (record.getPerson().getName() != null) {
Name name = record.getPerson().getName();
if (Visibility.PRIVATE.equals(name.getVisibility())) {
fail("Name is private");
}
}
//Other names
if (record.getPerson().getOtherNames() != null) {
OtherNames otherNames = record.getPerson().getOtherNames();
List<OtherName> list = otherNames.getOtherNames();
if (list != null) {
for (OtherName e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
//Researcher urls
if (record.getPerson().getResearcherUrls() != null) {
ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
List<ResearcherUrl> list = rUrls.getResearcherUrls();
if (list != null) {
for (ResearcherUrl e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
}
}
use of org.orcid.jaxb.model.record.summary_rc1.EducationSummary in project ORCID-Source by ORCID.
the class RecordTest method testViewRecordFromPublicAPI.
@Test
public void testViewRecordFromPublicAPI() {
ClientResponse response = publicV2_1ApiClient.viewRecordXML(getUser1OrcidId());
assertNotNull(response);
assertEquals("invalid " + response, 200, response.getStatus());
Record record = response.getEntity(Record.class);
assertNotNull(record);
assertNotNull(record.getOrcidIdentifier());
assertEquals(getUser1OrcidId(), record.getOrcidIdentifier().getPath());
//Check the visibility of every activity that exists
if (record.getActivitiesSummary() != null) {
if (record.getActivitiesSummary() != null) {
//Educations
if (record.getActivitiesSummary().getEducations() != null) {
Educations e = record.getActivitiesSummary().getEducations();
if (e.getSummaries() != null) {
for (EducationSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
//Employments
if (record.getActivitiesSummary().getEmployments() != null) {
Employments e = record.getActivitiesSummary().getEmployments();
if (e.getSummaries() != null) {
for (EmploymentSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
//Fundings
if (record.getActivitiesSummary().getFundings() != null) {
Fundings f = record.getActivitiesSummary().getFundings();
List<FundingGroup> groups = f.getFundingGroup();
if (groups != null) {
for (FundingGroup fGroup : groups) {
List<FundingSummary> summaries = fGroup.getFundingSummary();
if (summaries != null) {
for (FundingSummary s : summaries) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
}
}
//PeerReviews
if (record.getActivitiesSummary().getPeerReviews() != null) {
PeerReviews p = record.getActivitiesSummary().getPeerReviews();
List<PeerReviewGroup> groups = p.getPeerReviewGroup();
if (groups != null) {
for (PeerReviewGroup pGroup : groups) {
List<PeerReviewSummary> summaries = pGroup.getPeerReviewSummary();
if (summaries != null) {
for (PeerReviewSummary s : summaries) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
}
}
//Works
if (record.getActivitiesSummary().getWorks() != null) {
Works w = record.getActivitiesSummary().getWorks();
List<WorkGroup> groups = w.getWorkGroup();
if (groups != null) {
for (WorkGroup wGroup : groups) {
List<WorkSummary> summaries = wGroup.getWorkSummary();
if (summaries != null) {
for (WorkSummary s : summaries) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
}
}
}
}
//Check the visibility of every biography elements that exists
if (record.getPerson() != null) {
//Address
if (record.getPerson().getAddresses() != null) {
Addresses addresses = record.getPerson().getAddresses();
List<Address> list = addresses.getAddress();
if (list != null) {
for (Address o : list) {
assertNotNull(o.getSource());
assertEquals(Visibility.PUBLIC, o.getVisibility());
}
}
}
//Biography
if (record.getPerson().getBiography() != null) {
Biography b = record.getPerson().getBiography();
if (b != null) {
assertNotNull(b.getVisibility());
assertEquals(Visibility.PUBLIC, b.getVisibility());
}
}
//Emails
if (record.getPerson().getEmails() != null) {
Emails emails = record.getPerson().getEmails();
List<Email> list = emails.getEmails();
if (list != null) {
for (Email e : list) {
assertNotNull(e.getVisibility());
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
//External identifiers
if (record.getPerson().getExternalIdentifiers() != null) {
PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
if (list != null) {
for (PersonExternalIdentifier e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
//Keywords
if (record.getPerson().getKeywords() != null) {
Keywords keywords = record.getPerson().getKeywords();
List<Keyword> list = keywords.getKeywords();
if (list != null) {
for (Keyword e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
//Name
if (record.getPerson().getName() != null) {
Name name = record.getPerson().getName();
assertEquals(Visibility.PUBLIC, name.getVisibility());
}
//Other names
if (record.getPerson().getOtherNames() != null) {
OtherNames otherNames = record.getPerson().getOtherNames();
List<OtherName> list = otherNames.getOtherNames();
if (list != null) {
for (OtherName e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
//Researcher urls
if (record.getPerson().getResearcherUrls() != null) {
ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
List<ResearcherUrl> list = rUrls.getResearcherUrls();
if (list != null) {
for (ResearcherUrl e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
}
}
Aggregations