use of org.orcid.jaxb.model.record.summary_v2.PeerReviews 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);
// 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);
}
// 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.record.summary_v2.PeerReviews in project ORCID-Source by ORCID.
the class ConvertVrc3ToVrc4Test method upgradePeerReviewsToVrc3Test.
@Test
public void upgradePeerReviewsToVrc3Test() throws JAXBException {
JAXBContext jaxbContext1 = JAXBContext.newInstance(PeerReviews.class);
JAXBContext jaxbContext2 = JAXBContext.newInstance(org.orcid.jaxb.model.record.summary_rc4.PeerReviews.class);
Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
InputStream rc3Stream = ConvertVrc3ToVrc4Test.class.getClassLoader().getResourceAsStream("test-peer-reviews-2.0_rc3.xml");
InputStream rc4Stream = ConvertVrc3ToVrc4Test.class.getClassLoader().getResourceAsStream("test-peer-reviews-2.0_rc4.xml");
PeerReviews rc4PeerReviews = (PeerReviews) jaxbUnmarshaller.unmarshal(rc3Stream);
jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
org.orcid.jaxb.model.record.summary_rc4.PeerReviews rc4PeerReviews1 = (org.orcid.jaxb.model.record.summary_rc4.PeerReviews) jaxbUnmarshaller.unmarshal(rc4Stream);
V2Convertible result = versionConverterV2_0_rc3ToV2_0_rc4.upgrade(new V2Convertible(rc4PeerReviews, "v2_rc3"));
org.orcid.jaxb.model.record.summary_rc4.PeerReviews rc4PeerReviews2 = (org.orcid.jaxb.model.record.summary_rc4.PeerReviews) result.getObjectToConvert();
assertEquals(rc4PeerReviews1, rc4PeerReviews2);
}
use of org.orcid.jaxb.model.record.summary_v2.PeerReviews in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest method testGetPublicPeerReviews.
@Test
public void testGetPublicPeerReviews() {
Response r = serviceDelegator.viewPeerReviews(ORCID);
assertNotNull(r);
PeerReviews p = (PeerReviews) r.getEntity();
assertNotNull(p);
assertNotNull(p.getLastModifiedDate());
assertNotNull(p.getLastModifiedDate().getValue());
assertNotNull(p.getPeerReviewGroup());
assertEquals(1, p.getPeerReviewGroup().size());
assertNotNull(p.getPeerReviewGroup().get(0).getPeerReviewSummary());
assertEquals(1, p.getPeerReviewGroup().get(0).getPeerReviewSummary().size());
assertEquals(Long.valueOf(9), p.getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getPutCode());
assertNotNull(p.getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getLastModifiedDate());
assertNotNull(p.getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getLastModifiedDate().getValue());
}
use of org.orcid.jaxb.model.record.summary_v2.PeerReviews in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_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.record.summary_v2.PeerReviews in project ORCID-Source by ORCID.
the class ConvertV2ToV2_1Test method upgradePeerReviewsToV21Test.
@Test
public void upgradePeerReviewsToV21Test() throws JAXBException {
JAXBContext jaxbContext1 = JAXBContext.newInstance(PeerReviews.class);
JAXBContext jaxbContext2 = JAXBContext.newInstance(PeerReviews.class);
Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
InputStream v20Stream = ConvertV2ToV2_1Test.class.getClassLoader().getResourceAsStream("test-peer-reviews-2.0.xml");
InputStream v21Stream = ConvertV2ToV2_1Test.class.getClassLoader().getResourceAsStream("test-peer-reviews-2.1.xml");
PeerReviews v20PeerReviews = (PeerReviews) jaxbUnmarshaller.unmarshal(v20Stream);
jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
PeerReviews v21PeerReviews1 = (PeerReviews) jaxbUnmarshaller.unmarshal(v21Stream);
V2Convertible result = versionConverterV2_0ToV2_1.upgrade(new V2Convertible(v20PeerReviews, "v2.1"));
PeerReviews v21PeerReviews2 = (PeerReviews) result.getObjectToConvert();
assertEquals(v21PeerReviews1, v21PeerReviews2);
}
Aggregations