use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method viewWorks.
@Override
public Response viewWorks(String orcid) {
List<WorkSummary> worksList = workManagerReadOnly.getWorksSummaryList(orcid);
// Lets copy the list so we don't modify the cached collection
List<WorkSummary> filteredList = null;
if (worksList != null) {
filteredList = new ArrayList<WorkSummary>(worksList);
}
worksList = filteredList;
orcidSecurityManager.checkAndFilter(orcid, worksList, ScopePathType.ORCID_WORKS_READ_LIMITED);
Works works = workManager.groupWorks(worksList, false);
Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(works);
ActivityUtils.cleanEmptyFields(works);
ActivityUtils.setPathToWorks(works, orcid);
sourceUtils.setSourceName(works);
return Response.ok(works).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies.
@Test
public void testViewActitivies() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewActivities(ORCID);
boolean found1 = false, found2 = false, found3 = false, found4 = false;
ActivitiesSummary as = (ActivitiesSummary) response.getEntity();
assertNotNull(as);
assertEquals("/0000-0000-0000-0003/activities", as.getPath());
Utils.verifyLastModified(as.getLastModifiedDate());
assertNotNull(as.getEducations());
assertEquals(4, as.getEducations().getSummaries().size());
for (EducationSummary element : as.getEducations().getSummaries()) {
if (element.getPutCode().equals(Long.valueOf(20))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(21))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(22))) {
found3 = true;
} else if (element.getPutCode().equals(Long.valueOf(25))) {
found4 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
found1 = found2 = found3 = found4 = false;
assertNotNull(as.getEmployments());
assertEquals(4, as.getEmployments().getSummaries().size());
for (EmploymentSummary element : as.getEmployments().getSummaries()) {
if (element.getPutCode().equals(Long.valueOf(17))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(18))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(19))) {
found3 = true;
} else if (element.getPutCode().equals(Long.valueOf(23))) {
found4 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
found1 = found2 = found3 = found4 = false;
assertNotNull(as.getFundings());
assertEquals(4, as.getFundings().getFundingGroup().size());
for (FundingGroup group : as.getFundings().getFundingGroup()) {
assertEquals(1, group.getFundingSummary().size());
FundingSummary element = group.getFundingSummary().get(0);
if (element.getPutCode().equals(Long.valueOf(10))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(11))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(12))) {
found3 = true;
} else if (element.getPutCode().equals(Long.valueOf(13))) {
found4 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
found1 = found2 = found3 = found4 = false;
assertNotNull(as.getPeerReviews());
assertEquals(4, as.getPeerReviews().getPeerReviewGroup().size());
for (PeerReviewGroup group : as.getPeerReviews().getPeerReviewGroup()) {
assertEquals(1, group.getPeerReviewSummary().size());
PeerReviewSummary element = group.getPeerReviewSummary().get(0);
if (element.getPutCode().equals(Long.valueOf(9))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(10))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(11))) {
found3 = true;
} else if (element.getPutCode().equals(Long.valueOf(12))) {
found4 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
found1 = found2 = found3 = found4 = false;
assertNotNull(as.getWorks());
assertEquals(4, as.getWorks().getWorkGroup().size());
for (WorkGroup group : as.getWorks().getWorkGroup()) {
assertEquals(1, group.getWorkSummary().size());
WorkSummary element = group.getWorkSummary().get(0);
if (element.getPutCode().equals(Long.valueOf(11))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(12))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(13))) {
found3 = true;
} else if (element.getPutCode().equals(Long.valueOf(14))) {
found4 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ReadRecordTest method testActivities.
private void testActivities(ActivitiesSummary as, String orcid) {
boolean found1 = false, found2 = false, found3 = false;
// This is more an utility that will work only for 0000-0000-0000-0003
assertEquals("0000-0000-0000-0003", orcid);
assertNotNull(as);
assertEquals("/0000-0000-0000-0003/activities", as.getPath());
Utils.verifyLastModified(as.getLastModifiedDate());
assertNotNull(as.getEducations());
assertEquals(3, as.getEducations().getSummaries().size());
for (EducationSummary element : as.getEducations().getSummaries()) {
if (element.getPutCode().equals(Long.valueOf(20))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(21))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(22))) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
found1 = found2 = found3 = false;
assertNotNull(as.getEmployments());
assertEquals(3, as.getEmployments().getSummaries().size());
for (EmploymentSummary element : as.getEmployments().getSummaries()) {
if (element.getPutCode().equals(Long.valueOf(17))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(18))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(19))) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
found1 = found2 = found3 = false;
assertNotNull(as.getFundings());
assertEquals(3, as.getFundings().getFundingGroup().size());
for (FundingGroup group : as.getFundings().getFundingGroup()) {
assertEquals(1, group.getFundingSummary().size());
FundingSummary element = group.getFundingSummary().get(0);
if (element.getPutCode().equals(Long.valueOf(10))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(11))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(12))) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
found1 = found2 = found3 = false;
assertNotNull(as.getPeerReviews());
assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
for (PeerReviewGroup group : as.getPeerReviews().getPeerReviewGroup()) {
assertEquals(1, group.getPeerReviewSummary().size());
PeerReviewSummary element = group.getPeerReviewSummary().get(0);
if (element.getPutCode().equals(Long.valueOf(9))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(10))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(11))) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
found1 = found2 = found3 = false;
assertNotNull(as.getWorks());
assertEquals(3, as.getWorks().getWorkGroup().size());
for (WorkGroup group : as.getWorks().getWorkGroup()) {
assertEquals(1, group.getWorkSummary().size());
WorkSummary element = group.getWorkSummary().get(0);
if (element.getPutCode().equals(Long.valueOf(11))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(12))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(13))) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
found1 = found2 = found3 = false;
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_WorksTest method testViewWorkSummaryReadPublic.
@Test
public void testViewWorkSummaryReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewWorkSummary(ORCID, 11L);
WorkSummary element = (WorkSummary) r.getEntity();
assertNotNull(element);
assertEquals("/0000-0000-0000-0003/work/11", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_WorksTest method testAddWork.
@Test
public void testAddWork() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4445", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewActivities("4444-4444-4444-4445");
assertNotNull(response);
ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
assertNotNull(summary);
Utils.verifyLastModified(summary.getLastModifiedDate());
// Check works
assertNotNull(summary.getWorks());
assertNotNull(summary.getWorks().getWorkGroup());
assertEquals(1, summary.getWorks().getWorkGroup().size());
Utils.verifyLastModified(summary.getWorks().getLastModifiedDate());
assertNotNull(summary.getWorks().getWorkGroup().get(0));
Utils.verifyLastModified(summary.getWorks().getWorkGroup().get(0).getLastModifiedDate());
assertNotNull(summary.getWorks().getWorkGroup().get(0).getWorkSummary());
assertEquals(1, summary.getWorks().getWorkGroup().get(0).getWorkSummary().size());
String title = "work # 1 " + System.currentTimeMillis();
Work work = Utils.getWork(title);
response = serviceDelegator.createWork("4444-4444-4444-4445", work);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
Long putCode = Utils.getPutCode(response);
response = serviceDelegator.viewActivities("4444-4444-4444-4445");
assertNotNull(response);
summary = (ActivitiesSummary) response.getEntity();
assertNotNull(summary);
Utils.verifyLastModified(summary.getLastModifiedDate());
// Check works
assertNotNull(summary.getWorks());
assertNotNull(summary.getWorks().getWorkGroup());
assertEquals(2, summary.getWorks().getWorkGroup().size());
boolean haveOld = false;
boolean haveNew = false;
for (WorkGroup group : summary.getWorks().getWorkGroup()) {
Utils.verifyLastModified(group.getLastModifiedDate());
assertNotNull(group.getWorkSummary());
assertNotNull(group.getWorkSummary().get(0));
WorkSummary workSummary = group.getWorkSummary().get(0);
Utils.verifyLastModified(workSummary.getLastModifiedDate());
assertNotNull(workSummary.getTitle());
assertNotNull(workSummary.getTitle().getTitle());
if ("A Book With Contributors JSON".equals(workSummary.getTitle().getTitle().getContent())) {
haveOld = true;
} else if (title.equals(workSummary.getTitle().getTitle().getContent())) {
haveNew = true;
}
}
assertTrue(haveOld);
assertTrue(haveNew);
// Delete them
serviceDelegator.deleteWork("4444-4444-4444-4445", putCode);
}
Aggregations