Search in sources :

Example 26 with PeerReview

use of org.orcid.jaxb.model.v3.dev1.record.PeerReview in project ORCID-Source by ORCID.

the class PeerReviewManagerTest method displayIndexIsSetTo_0_FromAPI.

@Test
public void displayIndexIsSetTo_0_FromAPI() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    PeerReview p1 = getPeerReview("fromAPI-1");
    p1 = peerReviewManager.createPeerReview(claimedOrcid, p1, true);
    PeerReviewEntity p = peerReviewDao.find(p1.getPutCode());
    assertNotNull(91);
    assertEquals(Long.valueOf(0), p.getDisplayIndex());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 27 with PeerReview

use of org.orcid.jaxb.model.v3.dev1.record.PeerReview in project ORCID-Source by ORCID.

the class ActivityValidatorTest method validatePeerReview_invalidPeerReviewTypeTest.

@Test(expected = ActivityTypeValidationException.class)
public void validatePeerReview_invalidPeerReviewTypeTest() {
    PeerReview pr = getPeerReview();
    pr.setType(null);
    activityValidator.validatePeerReview(pr, null, true, true, Visibility.PUBLIC);
}
Also used : PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) Test(org.junit.Test)

Example 28 with PeerReview

use of org.orcid.jaxb.model.v3.dev1.record.PeerReview in project ORCID-Source by ORCID.

the class ActivityValidatorTest method validatePeerReview_validPeerReviewTest.

/**
 * VALIDATE PEER REVIEW
 */
@Test
public void validatePeerReview_validPeerReviewTest() {
    PeerReview pr = getPeerReview();
    activityValidator.validatePeerReview(pr, null, true, true, Visibility.PUBLIC);
}
Also used : PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) Test(org.junit.Test)

Example 29 with PeerReview

use of org.orcid.jaxb.model.v3.dev1.record.PeerReview 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 30 with PeerReview

use of org.orcid.jaxb.model.v3.dev1.record.PeerReview in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorImpl method viewPeerReview.

@Override
public Response viewPeerReview(String orcid, Long putCode) {
    PeerReview peerReview = peerReviewManagerReadOnly.getPeerReview(orcid, putCode);
    publicAPISecurityManagerV3.checkIsPublic(peerReview);
    ActivityUtils.setPathToActivity(peerReview, orcid);
    sourceUtilsReadOnly.setSourceName(peerReview);
    return Response.ok(peerReview).build();
}
Also used : PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview)

Aggregations

PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)66 Test (org.junit.Test)49 Response (javax.ws.rs.core.Response)20 DBUnitTest (org.orcid.test.DBUnitTest)20 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)12 PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)9 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)9 Url (org.orcid.jaxb.model.v3.dev1.common.Url)8 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)8 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)8 Work (org.orcid.jaxb.model.v3.dev1.record.Work)7 BaseTest (org.orcid.core.BaseTest)6 Title (org.orcid.jaxb.model.v3.dev1.common.Title)6 Education (org.orcid.jaxb.model.v3.dev1.record.Education)6 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)6 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)6 ArrayList (java.util.ArrayList)5 Day (org.orcid.jaxb.model.v3.dev1.common.Day)5 Month (org.orcid.jaxb.model.v3.dev1.common.Month)5 Year (org.orcid.jaxb.model.v3.dev1.common.Year)5