use of org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary in project ORCID-Source by ORCID.
the class ActivitiesSummaryManagerTest method testGetActivitiesSummary.
@Test
public void testGetActivitiesSummary() {
ActivitiesSummary summary = activitiesSummaryManager.getActivitiesSummary(ORCID);
assertNotNull(summary);
assertNotNull(summary.getEducations());
assertNotNull(summary.getEducations().getSummaries());
assertEquals(5, summary.getEducations().getSummaries().size());
assertNotNull(summary.getEmployments());
assertNotNull(summary.getEmployments().getSummaries());
assertEquals(5, summary.getEmployments().getSummaries().size());
assertNotNull(summary.getFundings());
assertNotNull(summary.getFundings().getFundingGroup());
assertEquals(5, summary.getFundings().getFundingGroup().size());
assertNotNull(summary.getPeerReviews());
assertNotNull(summary.getPeerReviews().getPeerReviewGroup());
assertEquals(5, summary.getPeerReviews().getPeerReviewGroup().size());
assertNotNull(summary.getWorks());
assertNotNull(summary.getWorks().getWorkGroup());
assertEquals(5, summary.getWorks().getWorkGroup().size());
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary in project ORCID-Source by ORCID.
the class RecordManagerTest method testGetPublicRecord.
@Test
public void testGetPublicRecord() {
Record record = recordManager.getPublicRecord(ORCID);
assertNotNull(record);
assertNotNull(record.getActivitiesSummary());
assertNotNull(record.getPerson());
Person person = record.getPerson();
assertNotNull(person);
assertNotNull(person.getExternalIdentifiers());
assertNotNull(person.getExternalIdentifiers().getExternalIdentifiers());
assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
assertEquals(Long.valueOf(13), person.getExternalIdentifiers().getExternalIdentifiers().get(0).getPutCode());
assertNotNull(person.getResearcherUrls());
assertNotNull(person.getResearcherUrls().getResearcherUrls());
assertEquals(1, person.getResearcherUrls().getResearcherUrls().size());
assertEquals(Long.valueOf(13), person.getResearcherUrls().getResearcherUrls().get(0).getPutCode());
assertNotNull(person.getOtherNames());
assertNotNull(person.getOtherNames().getOtherNames());
assertEquals(1, person.getOtherNames().getOtherNames().size());
assertEquals(Long.valueOf(13), person.getOtherNames().getOtherNames().get(0).getPutCode());
assertNotNull(person.getAddresses());
assertNotNull(person.getAddresses().getAddress());
assertEquals(1, person.getAddresses().getAddress().size());
assertEquals(Long.valueOf(9), person.getAddresses().getAddress().get(0).getPutCode());
assertNotNull(person.getKeywords());
assertNotNull(person.getKeywords().getKeywords());
assertEquals(1, person.getKeywords().getKeywords().size());
assertEquals(Long.valueOf(9), person.getKeywords().getKeywords().get(0).getPutCode());
assertNotNull(person.getEmails());
assertNotNull(person.getEmails().getEmails());
assertEquals(1, person.getEmails().getEmails().size());
assertEquals("public_0000-0000-0000-0003@test.orcid.org", person.getEmails().getEmails().get(0).getEmail());
assertNotNull(person.getBiography());
assertEquals(Visibility.PUBLIC, person.getBiography().getVisibility());
assertEquals("Biography for 0000-0000-0000-0003", person.getBiography().getContent());
assertNotNull(person.getName());
assertNotNull(person.getName().getCreditName());
assertEquals("Credit Name", person.getName().getCreditName().getContent());
assertNotNull(person.getName().getFamilyName());
assertEquals("Family Name", person.getName().getFamilyName().getContent());
assertNotNull(person.getName().getGivenNames());
assertEquals("Given Names", person.getName().getGivenNames().getContent());
assertEquals(Visibility.PUBLIC, person.getName().getVisibility());
ActivitiesSummary activities = record.getActivitiesSummary();
assertNotNull(activities.getEducations());
assertNotNull(activities.getEducations().getSummaries());
assertEquals(1, activities.getEducations().getSummaries().size());
assertEquals(Long.valueOf(20), activities.getEducations().getSummaries().get(0).getPutCode());
assertNotNull(activities.getEmployments());
assertNotNull(activities.getEmployments().getSummaries());
assertEquals(1, activities.getEmployments().getSummaries().size());
assertEquals(Long.valueOf(17), activities.getEmployments().getSummaries().get(0).getPutCode());
assertNotNull(activities.getFundings());
assertNotNull(activities.getFundings().getFundingGroup());
assertEquals(1, activities.getFundings().getFundingGroup().size());
assertEquals(Long.valueOf(10), activities.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getPutCode());
assertNotNull(activities.getPeerReviews());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup());
assertEquals(1, activities.getPeerReviews().getPeerReviewGroup().size());
assertEquals(Long.valueOf(9), activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getPutCode());
assertNotNull(activities.getWorks());
assertNotNull(activities.getWorks().getWorkGroup());
assertEquals(1, activities.getWorks().getWorkGroup().size());
assertEquals(Long.valueOf(11), activities.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getPutCode());
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary in project ORCID-Source by ORCID.
the class ActivityUtilsTest method cleanEmptyActivitiesSummaryTest.
@Test
public void cleanEmptyActivitiesSummaryTest() {
// Test it cleans empty fields
WorkSummary s = getEmptyWorkSummary();
ActivitiesSummary x = new ActivitiesSummary();
Works w = new Works();
WorkGroup g = new WorkGroup();
g.getWorkSummary().add(s);
w.getWorkGroup().add(g);
x.setWorks(w);
assertNotNull(x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle());
ActivityUtils.cleanEmptyFields(x);
assertNull(x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle());
// Test it doesn't remove non empty fields
s = getEmptyWorkSummary();
s.getTitle().getTranslatedTitle().setContent("test");
s.getTitle().getTranslatedTitle().setLanguageCode("en_us");
x = new ActivitiesSummary();
w = new Works();
g = new WorkGroup();
g.getWorkSummary().add(s);
w.getWorkGroup().add(g);
x.setWorks(w);
assertEquals("test", x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getContent());
assertEquals("en_us", x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getLanguageCode());
ActivityUtils.cleanEmptyFields(x);
assertEquals("test", x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getContent());
assertEquals("en_us", x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getLanguageCode());
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method viewActivities.
@Override
public Response viewActivities(String orcid) {
ActivitiesSummary as = activitiesSummaryManagerReadOnly.getActivitiesSummary(orcid);
orcidSecurityManager.checkAndFilter(orcid, as);
ActivityUtils.cleanEmptyFields(as);
ActivityUtils.setPathToActivity(as, orcid);
Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(as);
sourceUtils.setSourceName(as);
return Response.ok(as).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary in project ORCID-Source by ORCID.
the class WorksTest method testWorksWithPartOfRelationshipDontGetGrouped.
@Test
public void testWorksWithPartOfRelationshipDontGetGrouped() throws JSONException, InterruptedException, URISyntaxException {
long time = System.currentTimeMillis();
String accessTokenForClient1 = getAccessToken();
String accessTokenForClient2 = getAccessToken(getUser1OrcidId(), getUser1Password(), getScopes(ScopePathType.ACTIVITIES_UPDATE, ScopePathType.ACTIVITIES_READ_LIMITED), getClient2ClientId(), getClient2ClientSecret(), getClient2RedirectUri());
Work work1 = (Work) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/work-3.0_dev1.xml", Work.class);
work1.setPutCode(null);
work1.setSource(null);
work1.setVisibility(Visibility.PUBLIC);
work1.getExternalIdentifiers().getExternalIdentifier().clear();
org.orcid.jaxb.model.v3.dev1.record.WorkTitle title1 = new org.orcid.jaxb.model.v3.dev1.record.WorkTitle();
title1.setTitle(new Title("Work # 1" + time));
work1.setWorkTitle(title1);
ExternalID wExtId1 = new ExternalID();
wExtId1.setValue("Work Id " + time);
wExtId1.setType(WorkExternalIdentifierType.AGR.value());
wExtId1.setRelationship(Relationship.SELF);
wExtId1.setUrl(new Url("http://orcid.org/work#1"));
work1.getExternalIdentifiers().getExternalIdentifier().clear();
work1.getExternalIdentifiers().getExternalIdentifier().add(wExtId1);
Work work2 = (Work) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/work-3.0_dev1.xml", Work.class);
work2.setPutCode(null);
work2.setSource(null);
work2.setVisibility(Visibility.PUBLIC);
org.orcid.jaxb.model.v3.dev1.record.WorkTitle title2 = new org.orcid.jaxb.model.v3.dev1.record.WorkTitle();
title2.setTitle(new Title("Work # 2" + time));
work2.setWorkTitle(title2);
work2.getExternalIdentifiers().getExternalIdentifier().clear();
ExternalID wExtId2 = new ExternalID();
wExtId2.setValue("Work Id " + time);
wExtId2.setType(WorkExternalIdentifierType.AGR.value());
wExtId2.setRelationship(Relationship.PART_OF);
wExtId2.setUrl(new Url("http://orcid.org/work#2"));
work2.getExternalIdentifiers().getExternalIdentifier().clear();
work2.getExternalIdentifiers().getExternalIdentifier().add(wExtId2);
Work work3 = (Work) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/work-3.0_dev1.xml", Work.class);
work3.setPutCode(null);
work3.setSource(null);
work3.setVisibility(Visibility.PUBLIC);
org.orcid.jaxb.model.v3.dev1.record.WorkTitle title3 = new org.orcid.jaxb.model.v3.dev1.record.WorkTitle();
title3.setTitle(new Title("Work # 3" + time));
work3.setWorkTitle(title3);
work3.getExternalIdentifiers().getExternalIdentifier().clear();
ExternalID wExtId3 = new ExternalID();
wExtId3.setValue("Work Id " + time);
wExtId3.setType(WorkExternalIdentifierType.AGR.value());
wExtId3.setRelationship(Relationship.SELF);
wExtId3.setUrl(new Url("http://orcid.org/work#3"));
work3.getExternalIdentifiers().getExternalIdentifier().clear();
work3.getExternalIdentifiers().getExternalIdentifier().add(wExtId3);
// Add the three works
ClientResponse postResponse = memberV3Dev1ApiClient.createWorkXml(this.getUser1OrcidId(), work1, accessTokenForClient1);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
Long putCode1 = getPutCodeFromResponse(postResponse);
postResponse = memberV3Dev1ApiClient.createWorkXml(this.getUser1OrcidId(), work2, accessTokenForClient1);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
Long putCode2 = getPutCodeFromResponse(postResponse);
postResponse = memberV3Dev1ApiClient.createWorkXml(this.getUser1OrcidId(), work3, accessTokenForClient2);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
Long putCode3 = getPutCodeFromResponse(postResponse);
ClientResponse activitiesResponse = memberV3Dev1ApiClient.viewActivities(this.getUser1OrcidId(), accessTokenForClient1);
assertEquals(Response.Status.OK.getStatusCode(), activitiesResponse.getStatus());
ActivitiesSummary activities = activitiesResponse.getEntity(ActivitiesSummary.class);
assertNotNull(activities);
assertFalse(activities.getWorks().getWorkGroup().isEmpty());
WorkGroup work1Group = null;
WorkGroup work2Group = null;
WorkGroup work3Group = null;
boolean work1found = false;
boolean work2found = false;
boolean work3found = false;
for (WorkGroup group : activities.getWorks().getWorkGroup()) {
if (group.getIdentifiers().getExternalIdentifier() == null || group.getIdentifiers().getExternalIdentifier().isEmpty()) {
for (WorkSummary summary : group.getWorkSummary()) {
String title = summary.getTitle().getTitle().getContent();
if (("Work # 2" + time).equals(title)) {
work2found = true;
work2Group = group;
}
}
} else {
for (ExternalID id : group.getIdentifiers().getExternalIdentifier()) {
// If it is the ID is the one we are looking for
if (id.getValue().equals("Work Id " + time)) {
for (WorkSummary summary : group.getWorkSummary()) {
String title = summary.getTitle().getTitle().getContent();
if (("Work # 1" + time).equals(title)) {
work1found = true;
work1Group = group;
} else if (("Work # 3" + time).equals(title)) {
work3found = true;
work3Group = group;
}
}
}
}
}
}
assertTrue(work1found);
assertTrue(work2found);
assertTrue(work3found);
// Check that work # 1 and Work # 3 are in the same work
assertEquals(work1Group, work3Group);
// Check that work # 2 is not in the same group than group # 1
assertThat(work2Group, not(work1Group));
// Remove all created works
ClientResponse deleteResponse = memberV3Dev1ApiClient.deleteWorkXml(this.getUser1OrcidId(), putCode1, accessTokenForClient1);
assertNotNull(deleteResponse);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
deleteResponse = memberV3Dev1ApiClient.deleteWorkXml(this.getUser1OrcidId(), putCode2, accessTokenForClient1);
assertNotNull(deleteResponse);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
deleteResponse = memberV3Dev1ApiClient.deleteWorkXml(this.getUser1OrcidId(), putCode3, accessTokenForClient2);
assertNotNull(deleteResponse);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Aggregations