use of org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup in project ORCID-Source by ORCID.
the class OrcidSecurityManagerImpl method checkAndFilter.
@Override
public void checkAndFilter(String orcid, ActivitiesSummary activities) {
if (activities == null) {
return;
}
// Check the token
isMyToken(orcid);
// Distinctions
if (activities.getDistinctions() != null) {
checkAndFilter(orcid, activities.getDistinctions().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
}
// Educations
if (activities.getEducations() != null) {
checkAndFilter(orcid, activities.getEducations().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
}
// Employments
if (activities.getEmployments() != null) {
checkAndFilter(orcid, activities.getEmployments().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
}
// Invited positions
if (activities.getInvitedPositions() != null) {
checkAndFilter(orcid, activities.getInvitedPositions().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
}
// Memberships
if (activities.getMemberships() != null) {
checkAndFilter(orcid, activities.getMemberships().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
}
// Qualifications
if (activities.getQualifications() != null) {
checkAndFilter(orcid, activities.getQualifications().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
}
// Services
if (activities.getServices() != null) {
checkAndFilter(orcid, activities.getServices().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
}
// Funding
if (activities.getFundings() != null) {
Iterator<FundingGroup> groupIt = activities.getFundings().getFundingGroup().iterator();
while (groupIt.hasNext()) {
FundingGroup group = groupIt.next();
// Filter the list of elements
checkAndFilter(orcid, group.getFundingSummary(), READ_FUNDING_REQUIRED_SCOPE, true);
// Clean external identifiers
if (group.getFundingSummary().isEmpty()) {
groupIt.remove();
} else {
filterExternalIdentifiers(group);
}
}
}
// PeerReviews
if (activities.getPeerReviews() != null) {
Iterator<PeerReviewGroup> groupIt = activities.getPeerReviews().getPeerReviewGroup().iterator();
while (groupIt.hasNext()) {
PeerReviewGroup group = groupIt.next();
// Filter the list of elements
checkAndFilter(orcid, group.getPeerReviewSummary(), READ_PEER_REVIEWS_REQUIRED_SCOPE, true);
if (group.getPeerReviewSummary().isEmpty()) {
groupIt.remove();
}
}
}
// Works
if (activities.getWorks() != null) {
Iterator<WorkGroup> groupIt = activities.getWorks().getWorkGroup().iterator();
while (groupIt.hasNext()) {
WorkGroup group = groupIt.next();
// Filter the list of elements
checkAndFilter(orcid, group.getWorkSummary(), READ_WORKS_REQUIRED_SCOPE, true);
// Clean external identifiers
if (group.getWorkSummary().isEmpty()) {
groupIt.remove();
} else {
filterExternalIdentifiers(group);
}
}
}
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ActivitiesSummaryTest 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);
assertNotNull(as.getPath());
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.PeerReviewGroup in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_PeerReviewsTest method testViewPeerReviews.
@Test
public void testViewPeerReviews() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewPeerReviews(ORCID);
assertNotNull(r);
PeerReviews peerReviews = (PeerReviews) r.getEntity();
assertNotNull(peerReviews);
assertEquals("/0000-0000-0000-0003/peer-reviews", peerReviews.getPath());
Utils.verifyLastModified(peerReviews.getLastModifiedDate());
assertNotNull(peerReviews.getPeerReviewGroup());
assertEquals(4, peerReviews.getPeerReviewGroup().size());
boolean found1 = false, found2 = false, found3 = false, found4 = false;
for (PeerReviewGroup group : peerReviews.getPeerReviewGroup()) {
Utils.verifyLastModified(group.getLastModifiedDate());
assertNotNull(group.getIdentifiers());
assertNotNull(group.getIdentifiers().getExternalIdentifier());
assertEquals(1, group.getIdentifiers().getExternalIdentifier().size());
assertNotNull(group.getPeerReviewSummary());
assertEquals(1, group.getPeerReviewSummary().size());
PeerReviewSummary summary = group.getPeerReviewSummary().get(0);
Utils.verifyLastModified(summary.getLastModifiedDate());
switch(group.getIdentifiers().getExternalIdentifier().get(0).getValue()) {
case "issn:0000009":
assertEquals("issn:0000009", summary.getGroupId());
assertEquals(Long.valueOf(9), summary.getPutCode());
found1 = true;
break;
case "issn:0000010":
assertEquals("issn:0000010", summary.getGroupId());
assertEquals(Long.valueOf(10), summary.getPutCode());
found2 = true;
break;
case "issn:0000011":
assertEquals("issn:0000011", summary.getGroupId());
assertEquals(Long.valueOf(11), summary.getPutCode());
found3 = true;
break;
case "issn:0000012":
assertEquals("issn:0000012", summary.getGroupId());
assertEquals(Long.valueOf(12), summary.getPutCode());
found4 = true;
break;
default:
fail("Invalid group id found: " + group.getIdentifiers().getExternalIdentifier().get(0).getValue());
break;
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_PeerReviewsTest method testAddPeerReview.
@Test
public void testAddPeerReview() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4444", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewActivities("4444-4444-4444-4444");
assertNotNull(response);
ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
assertNotNull(summary);
assertNotNull(summary.getPeerReviews());
assertNotNull(summary.getPeerReviews().getPeerReviewGroup());
assertEquals(1, summary.getPeerReviews().getPeerReviewGroup().size());
assertNotNull(summary.getPeerReviews().getPeerReviewGroup().get(0));
assertNotNull(summary.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary());
assertNotNull(summary.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0));
assertEquals("issn:0000001", summary.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getGroupId());
PeerReview peerReview = Utils.getPeerReview();
response = serviceDelegator.createPeerReview("4444-4444-4444-4444", peerReview);
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
Map<?, ?> map = response.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
List<?> resultWithPutCode = (List<?>) map.get("Location");
Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
response = serviceDelegator.viewActivities("4444-4444-4444-4444");
assertNotNull(response);
summary = (ActivitiesSummary) response.getEntity();
assertNotNull(summary);
Utils.verifyLastModified(summary.getLastModifiedDate());
assertNotNull(summary.getPeerReviews());
Utils.verifyLastModified(summary.getLastModifiedDate());
assertNotNull(summary.getPeerReviews().getPeerReviewGroup());
assertEquals(2, summary.getPeerReviews().getPeerReviewGroup().size());
boolean haveOld = false;
boolean haveNew = false;
for (PeerReviewGroup group : summary.getPeerReviews().getPeerReviewGroup()) {
Utils.verifyLastModified(group.getLastModifiedDate());
Utils.verifyLastModified(group.getPeerReviewSummary().get(0).getLastModifiedDate());
if ("issn:0000001".equals(group.getPeerReviewSummary().get(0).getGroupId())) {
haveOld = true;
} else {
assertEquals("issn:0000003", group.getPeerReviewSummary().get(0).getGroupId());
haveNew = true;
}
}
assertTrue(haveOld);
assertTrue(haveNew);
// Delete the new so it doesn't affect other tests
serviceDelegator.deletePeerReview("4444-4444-4444-4444", putCode);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup in project ORCID-Source by ORCID.
the class ActivityUtilsTest method getPeerReviews.
private PeerReviews getPeerReviews() {
PeerReviews x = new PeerReviews();
PeerReviewGroup g = new PeerReviewGroup();
PeerReviewSummary e = new PeerReviewSummary();
e.setPutCode(123L);
g.getPeerReviewSummary().add(e);
x.getPeerReviewGroup().add(g);
return x;
}
Aggregations