use of org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviews in project ORCID-Source by ORCID.
the class PeerReviewManagerTest method testGroupPeerReviews_groupOnlyPublicPeerReviews1.
@Test
public void testGroupPeerReviews_groupOnlyPublicPeerReviews1() {
PeerReviewSummary s1 = getPeerReviewSummary("public-peer-review-group-id-1", "ext-id-1", Visibility.PUBLIC);
PeerReviewSummary s2 = getPeerReviewSummary("limited-peer-review-group-id-1", "ext-id-2", Visibility.LIMITED);
PeerReviewSummary s3 = getPeerReviewSummary("private-peer-review-group-id-1", "ext-id-3", Visibility.PRIVATE);
PeerReviewSummary s4 = getPeerReviewSummary("public-peer-review-group-id-2", "ext-id-4", Visibility.PUBLIC);
PeerReviewSummary s5 = getPeerReviewSummary("limited-peer-review-group-id-2", "ext-id-5", Visibility.LIMITED);
PeerReviewSummary s6 = getPeerReviewSummary("private-peer-review-group-id-2", "ext-id-6", Visibility.PRIVATE);
PeerReviewSummary s7 = getPeerReviewSummary("public-peer-review-group-id-3", "ext-id-7", Visibility.PUBLIC);
PeerReviewSummary s8 = getPeerReviewSummary("limited-peer-review-group-id-3", "ext-id-8", Visibility.LIMITED);
PeerReviewSummary s9 = getPeerReviewSummary("private-peer-review-group-id-3", "ext-id-9", Visibility.PRIVATE);
List<PeerReviewSummary> workList = Arrays.asList(s1, s2, s3, s4, s5, s6, s7, s8, s9);
/**
* They should be grouped as
*
* Group 1: Public 1
* Group 2: Public 2
* Group 3: Public 3
*/
PeerReviews peerReviews = peerReviewManager.groupPeerReviews(workList, true);
assertNotNull(peerReviews);
assertEquals(3, peerReviews.getPeerReviewGroup().size());
assertEquals(1, peerReviews.getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertEquals(1, peerReviews.getPeerReviewGroup().get(0).getPeerReviewSummary().size());
assertEquals("public-peer-review-group-id-1", peerReviews.getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals("public-peer-review-group-id-1", peerReviews.getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getGroupId());
assertEquals(1, peerReviews.getPeerReviewGroup().get(1).getIdentifiers().getExternalIdentifier().size());
assertEquals(1, peerReviews.getPeerReviewGroup().get(1).getPeerReviewSummary().size());
assertEquals("public-peer-review-group-id-2", peerReviews.getPeerReviewGroup().get(1).getIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals("public-peer-review-group-id-2", peerReviews.getPeerReviewGroup().get(1).getPeerReviewSummary().get(0).getGroupId());
assertEquals(1, peerReviews.getPeerReviewGroup().get(2).getIdentifiers().getExternalIdentifier().size());
assertEquals(1, peerReviews.getPeerReviewGroup().get(2).getPeerReviewSummary().size());
assertEquals("public-peer-review-group-id-3", peerReviews.getPeerReviewGroup().get(2).getIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals("public-peer-review-group-id-3", peerReviews.getPeerReviewGroup().get(2).getPeerReviewSummary().get(0).getGroupId());
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviews in project ORCID-Source by ORCID.
the class PeerReviewManagerTest method nonGroupableIdsGenerateEmptyIdsListTest.
@Test
public void nonGroupableIdsGenerateEmptyIdsListTest() {
PeerReviewSummary s1 = getPeerReviewSummary("Element 1", "ext-id-1", Visibility.PUBLIC);
PeerReviewSummary s2 = getPeerReviewSummary("Element 2", "ext-id-2", Visibility.LIMITED);
PeerReviewSummary s3 = getPeerReviewSummary("Element 3", "ext-id-3", Visibility.PRIVATE);
// Remove the grouping id from s1
s1.setGroupId(null);
List<PeerReviewSummary> peerReviewsList = Arrays.asList(s1, s2, s3);
/**
* They should be grouped as
*
* Group 1: Element 1
* Group 2: Element 2
* Group 3: Element 3
*/
PeerReviews peerReviews = peerReviewManager.groupPeerReviews(peerReviewsList, false);
assertNotNull(peerReviews);
assertEquals(3, peerReviews.getPeerReviewGroup().size());
boolean foundEmptyGroup = false;
boolean found2 = false;
boolean found3 = false;
for (PeerReviewGroup group : peerReviews.getPeerReviewGroup()) {
assertEquals(1, group.getPeerReviewSummary().size());
assertNotNull(group.getIdentifiers().getExternalIdentifier());
assertEquals(1, group.getIdentifiers().getExternalIdentifier().size());
if (group.getIdentifiers().getExternalIdentifier().get(0).getValue() == null) {
assertEquals("ext-id-1", group.getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
foundEmptyGroup = true;
} else if (group.getIdentifiers().getExternalIdentifier().get(0).getValue().equals("Element 2")) {
assertEquals("ext-id-2", group.getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
found2 = true;
} else if (group.getIdentifiers().getExternalIdentifier().get(0).getValue().equals("Element 3")) {
assertEquals("ext-id-3", group.getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
found3 = true;
} else {
fail("Invalid ext id found " + group.getIdentifiers().getExternalIdentifier().get(0).getValue());
}
}
assertTrue(foundEmptyGroup);
assertTrue(found2);
assertTrue(found3);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviews in project ORCID-Source by ORCID.
the class PeerReviewManagerImpl method createPeerReview.
@Override
public PeerReview createPeerReview(String orcid, PeerReview peerReview, boolean isApiRequest) {
SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
// If request comes from the API, perform the validations
if (isApiRequest) {
// Validate it have at least one ext id
activityValidator.validatePeerReview(peerReview, sourceEntity, true, isApiRequest, null);
List<PeerReviewEntity> peerReviews = peerReviewDao.getByUser(orcid, getLastModified(orcid));
// duplicates
if (!sourceEntity.getSourceId().equals(orcid)) {
if (peerReviews != null) {
for (PeerReviewEntity entity : peerReviews) {
PeerReview existing = jpaJaxbPeerReviewAdapter.toPeerReview(entity);
activityValidator.checkExternalIdentifiersForDuplicates(peerReview.getExternalIdentifiers(), existing.getExternalIdentifiers(), existing.getSource(), sourceEntity);
}
}
} else {
// check vocab of external identifiers
externalIDValidator.validateWorkOrPeerReview(peerReview.getExternalIdentifiers());
externalIDValidator.validateWorkOrPeerReview(peerReview.getSubjectExternalIdentifier());
}
validateGroupId(peerReview);
}
PeerReviewEntity entity = jpaJaxbPeerReviewAdapter.toPeerReviewEntity(peerReview);
// Updates the give organization with the latest organization from
// database
OrgEntity updatedOrganization = orgManager.getOrgEntity(peerReview);
entity.setOrg(updatedOrganization);
// Set the source
if (sourceEntity.getSourceProfile() != null) {
entity.setSourceId(sourceEntity.getSourceProfile().getId());
}
if (sourceEntity.getSourceClient() != null) {
entity.setClientSourceId(sourceEntity.getSourceClient().getId());
}
ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
entity.setProfile(profile);
setIncomingPrivacy(entity, profile);
DisplayIndexCalculatorHelper.setDisplayIndexOnNewEntity(entity, isApiRequest);
peerReviewDao.persist(entity);
peerReviewDao.flush();
notificationManager.sendAmendEmail(orcid, AmendedSection.PEER_REVIEW, createItemList(entity));
return jpaJaxbPeerReviewAdapter.toPeerReview(entity);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviews in project ORCID-Source by ORCID.
the class ActivitiesSummaryManagerReadOnlyImpl method getActivitiesSummary.
public ActivitiesSummary getActivitiesSummary(String orcid, boolean justPublic) {
ActivitiesSummary activities = new ActivitiesSummary();
// Set distinctions
List<DistinctionSummary> distinctionsList = affiliationsManager.getDistinctionSummaryList(orcid);
Distinctions distinctions = new Distinctions();
for (DistinctionSummary summary : distinctionsList) {
if (justPublic) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
distinctions.getSummaries().add(summary);
}
} else {
distinctions.getSummaries().add(summary);
}
}
activities.setDistinctions(distinctions);
// Set educations
List<EducationSummary> educationsList = affiliationsManager.getEducationSummaryList(orcid);
Educations educations = new Educations();
for (EducationSummary summary : educationsList) {
if (justPublic) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
educations.getSummaries().add(summary);
}
} else {
educations.getSummaries().add(summary);
}
}
activities.setEducations(educations);
// Set employments
List<EmploymentSummary> employmentList = affiliationsManager.getEmploymentSummaryList(orcid);
Employments employments = new Employments();
for (EmploymentSummary summary : employmentList) {
if (justPublic) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
employments.getSummaries().add(summary);
}
} else {
employments.getSummaries().add(summary);
}
}
activities.setEmployments(employments);
// Set invited positions
List<InvitedPositionSummary> invitedPositionsList = affiliationsManager.getInvitedPositionSummaryList(orcid);
InvitedPositions invitedPositions = new InvitedPositions();
for (InvitedPositionSummary summary : invitedPositionsList) {
if (justPublic) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
invitedPositions.getSummaries().add(summary);
}
} else {
invitedPositions.getSummaries().add(summary);
}
}
activities.setInvitedPositions(invitedPositions);
// Set memberships
List<MembershipSummary> membershipsList = affiliationsManager.getMembershipSummaryList(orcid);
Memberships memberships = new Memberships();
for (MembershipSummary summary : membershipsList) {
if (justPublic) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
memberships.getSummaries().add(summary);
}
} else {
memberships.getSummaries().add(summary);
}
}
activities.setMemberships(memberships);
// Set qualifications
List<QualificationSummary> qualificationsList = affiliationsManager.getQualificationSummaryList(orcid);
Qualifications qualifications = new Qualifications();
for (QualificationSummary summary : qualificationsList) {
if (justPublic) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
qualifications.getSummaries().add(summary);
}
} else {
qualifications.getSummaries().add(summary);
}
}
activities.setQualifications(qualifications);
// Set services
List<ServiceSummary> servicesList = affiliationsManager.getServiceSummaryList(orcid);
Services services = new Services();
for (ServiceSummary summary : servicesList) {
if (justPublic) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
services.getSummaries().add(summary);
}
} else {
services.getSummaries().add(summary);
}
}
activities.setServices(services);
// Set fundings
List<FundingSummary> fundingSummaries = fundingManager.getFundingSummaryList(orcid);
Fundings fundings = fundingManager.groupFundings(fundingSummaries, justPublic);
activities.setFundings(fundings);
// Set peer reviews
List<PeerReviewSummary> peerReviewSummaries = peerReviewManager.getPeerReviewSummaryList(orcid);
PeerReviews peerReviews = peerReviewManager.groupPeerReviews(peerReviewSummaries, justPublic);
activities.setPeerReviews(peerReviews);
// Set works
List<WorkSummary> workSummaries = workManager.getWorksSummaryList(orcid);
Works works = workManager.groupWorks(workSummaries, justPublic);
activities.setWorks(works);
return activities;
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviews in project ORCID-Source by ORCID.
the class SourceUtils method setSourceName.
public void setSourceName(ActivitiesSummary as) {
if (as == null) {
return;
}
if (as.getEducations() != null) {
Educations educations = as.getEducations();
List<EducationSummary> list = educations.getSummaries();
if (list != null) {
for (EducationSummary summary : list) {
setSourceName(summary);
}
}
}
if (as.getEmployments() != null) {
Employments employments = as.getEmployments();
List<EmploymentSummary> list = employments.getSummaries();
if (list != null) {
for (EmploymentSummary summary : list) {
setSourceName(summary);
}
}
}
if (as.getFundings() != null) {
Fundings fundings = as.getFundings();
List<FundingGroup> groups = fundings.getFundingGroup();
if (groups != null) {
for (FundingGroup group : groups) {
List<FundingSummary> summaryList = group.getFundingSummary();
if (summaryList != null) {
for (FundingSummary summary : summaryList) {
setSourceName(summary);
}
}
}
}
}
if (as.getPeerReviews() != null) {
PeerReviews peerReviews = as.getPeerReviews();
List<PeerReviewGroup> groups = peerReviews.getPeerReviewGroup();
if (groups != null) {
for (PeerReviewGroup group : groups) {
List<PeerReviewSummary> summaryList = group.getPeerReviewSummary();
if (summaryList != null) {
for (PeerReviewSummary summary : summaryList) {
setSourceName(summary);
}
}
}
}
}
if (as.getWorks() != null) {
Works works = as.getWorks();
List<WorkGroup> groups = works.getWorkGroup();
if (groups != null) {
for (WorkGroup group : groups) {
List<WorkSummary> summaryList = group.getWorkSummary();
if (summaryList != null) {
for (WorkSummary summary : summaryList) {
setSourceName(summary);
}
}
}
}
}
}
Aggregations