Search in sources :

Example 6 with PeerReviews

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());
}
Also used : PeerReviewSummary(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary) PeerReviews(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviews) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 7 with PeerReviews

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);
}
Also used : PeerReviewGroup(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup) PeerReviewSummary(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary) PeerReviews(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviews) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 8 with PeerReviews

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);
}
Also used : SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity)

Example 9 with PeerReviews

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;
}
Also used : Memberships(org.orcid.jaxb.model.v3.dev1.record.summary.Memberships) Fundings(org.orcid.jaxb.model.v3.dev1.record.summary.Fundings) PeerReviews(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviews) Distinctions(org.orcid.jaxb.model.v3.dev1.record.summary.Distinctions) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) FundingSummary(org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary) DistinctionSummary(org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works) ServiceSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary) Employments(org.orcid.jaxb.model.v3.dev1.record.summary.Employments) Services(org.orcid.jaxb.model.v3.dev1.record.summary.Services) InvitedPositionSummary(org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary) QualificationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary) EducationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary) Educations(org.orcid.jaxb.model.v3.dev1.record.summary.Educations) EmploymentSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary) InvitedPositions(org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositions) MembershipSummary(org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary) Qualifications(org.orcid.jaxb.model.v3.dev1.record.summary.Qualifications)

Example 10 with PeerReviews

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);
                    }
                }
            }
        }
    }
}
Also used : PeerReviewGroup(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup) Fundings(org.orcid.jaxb.model.v3.dev1.record.summary.Fundings) PeerReviews(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviews) FundingGroup(org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup) Employments(org.orcid.jaxb.model.v3.dev1.record.summary.Employments) WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) EducationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary) Educations(org.orcid.jaxb.model.v3.dev1.record.summary.Educations) FundingSummary(org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary) EmploymentSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works)

Aggregations

PeerReviews (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviews)19 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)15 Test (org.junit.Test)12 PeerReviewGroup (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup)9 PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)5 Response (javax.ws.rs.core.Response)4 BaseTest (org.orcid.core.BaseTest)4 FundingGroup (org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup)4 WorkGroup (org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup)4 DBUnitTest (org.orcid.test.DBUnitTest)4 ArrayList (java.util.ArrayList)3 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)3 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)3 Educations (org.orcid.jaxb.model.v3.dev1.record.summary.Educations)3 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)3 Employments (org.orcid.jaxb.model.v3.dev1.record.summary.Employments)3 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)3 Fundings (org.orcid.jaxb.model.v3.dev1.record.summary.Fundings)3 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)3 Works (org.orcid.jaxb.model.v3.dev1.record.summary.Works)3