use of org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup 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.PeerReviewGroup 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 = memberV2ApiClient.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_v2.PeerReviewGroup in project ORCID-Source by ORCID.
the class MemberV2PerformanceTest method cleanActivities.
private void cleanActivities() throws JSONException, InterruptedException, URISyntaxException {
String token = getAccessToken();
// Remove all activities
ClientResponse activitiesResponse = memberV2ApiClient.viewActivities(this.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(this.getUser1OrcidId(), education.getPutCode(), token);
}
}
if (summary.getEmployments() != null && !summary.getEmployments().getSummaries().isEmpty()) {
for (EmploymentSummary employment : summary.getEmployments().getSummaries()) {
memberV2ApiClient.deleteEmploymentXml(this.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(this.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(this.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(this.getUser1OrcidId(), peerReview.getPutCode(), token);
}
}
}
}
use of org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV2Test method getPeerReviews.
private PeerReviews getPeerReviews(Visibility... vs) {
PeerReviews peerReviews = new PeerReviews();
for (Visibility v : vs) {
PeerReviewGroup g = new PeerReviewGroup();
PeerReviewSummary s = new PeerReviewSummary();
s.setVisibility(v);
g.getPeerReviewSummary().add(s);
peerReviews.getPeerReviewGroup().add(g);
}
return peerReviews;
}
use of org.orcid.jaxb.model.record.summary_v2.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);
// 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);
}
}
}
}
Aggregations