Search in sources :

Example 81 with PeerReview

use of org.orcid.jaxb.model.record_rc1.PeerReview in project ORCID-Source by ORCID.

the class PeerReviewsController method addPeerReview.

private PeerReviewForm addPeerReview(PeerReviewForm peerReviewForm) {
    String userOrcid = getEffectiveUserOrcid();
    PeerReview peerReview = peerReviewForm.toPeerReview();
    peerReview = peerReviewManager.createPeerReview(userOrcid, peerReview, false);
    peerReviewForm = PeerReviewForm.valueOf(peerReview);
    return peerReviewForm;
}
Also used : PeerReview(org.orcid.jaxb.model.record_v2.PeerReview)

Example 82 with PeerReview

use of org.orcid.jaxb.model.record_rc1.PeerReview in project ORCID-Source by ORCID.

the class OrcidInfo method getPeerReviewsJson.

@RequestMapping(value = "/{orcid:(?:\\d{4}-){3,}\\d{3}[\\dX]}/peer-reviews.json")
@ResponseBody
public List<PeerReviewForm> getPeerReviewsJson(HttpServletRequest request, @PathVariable("orcid") String orcid, @RequestParam(value = "peerReviewIds") String peerReviewIdsStr) {
    Map<String, String> languages = lm.buildLanguageMap(localeManager.getLocale(), false);
    List<PeerReviewForm> peerReviews = new ArrayList<PeerReviewForm>();
    Map<Long, PeerReview> peerReviewMap = peerReviewMap(orcid, getLastModifiedTime(orcid));
    String[] peerReviewIds = peerReviewIdsStr.split(",");
    for (String id : peerReviewIds) {
        PeerReview peerReview = peerReviewMap.get(Long.valueOf(id));
        validateVisibility(peerReview.getVisibility());
        sourceUtils.setSourceName(peerReview);
        PeerReviewForm form = PeerReviewForm.valueOf(peerReview);
        // Set language name
        form.setCountryForDisplay(getMessage(buildInternationalizationKey(CountryIsoEntity.class, peerReview.getOrganization().getAddress().getCountry().name())));
        if (!PojoUtil.isEmpty(form.getTranslatedSubjectName())) {
            // Set translated title language name
            if (!StringUtils.isEmpty(form.getTranslatedSubjectName().getLanguageCode())) {
                String languageName = languages.get(form.getTranslatedSubjectName().getLanguageCode());
                form.getTranslatedSubjectName().setLanguageName(languageName);
            }
        }
        // the group id
        if (form.getGroupId() != null && !PojoUtil.isEmpty(form.getGroupId().getValue())) {
            GroupIdRecord groupId = groupIdRecordManager.findByGroupId(form.getGroupId().getValue()).get();
            form.setGroupIdPutCode(Text.valueOf(groupId.getPutCode()));
        }
        peerReviews.add(form);
    }
    return peerReviews;
}
Also used : GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) ArrayList(java.util.ArrayList) PeerReviewForm(org.orcid.pojo.ajaxForm.PeerReviewForm) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 83 with PeerReview

use of org.orcid.jaxb.model.record_rc1.PeerReview in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorImpl method viewPeerReview.

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

Example 84 with PeerReview

use of org.orcid.jaxb.model.record_rc1.PeerReview in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_PeerReviewsTest method testViewPrivatePeerReview.

@Test
public void testViewPrivatePeerReview() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4446", 4L);
    assertNotNull(response);
    PeerReview peerReview = (PeerReview) response.getEntity();
    assertNotNull(peerReview);
    assertEquals("/4444-4444-4444-4446/peer-review/4", peerReview.getPath());
    Utils.verifyLastModified(peerReview.getLastModifiedDate());
    assertEquals(Long.valueOf(4L), peerReview.getPutCode());
    assertNotNull(peerReview.getCompletionDate());
    assertEquals("01", peerReview.getCompletionDate().getDay().getValue());
    assertEquals("01", peerReview.getCompletionDate().getMonth().getValue());
    assertEquals("2015", peerReview.getCompletionDate().getYear().getValue());
    assertEquals("work:external-identifier-id#3", peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("private", peerReview.getVisibility().value());
    assertEquals("issn:0000003", peerReview.getGroupId());
}
Also used : Response(javax.ws.rs.core.Response) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 85 with PeerReview

use of org.orcid.jaxb.model.record_rc1.PeerReview in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_PeerReviewsTest method testAddPeerReview.

@Test
public void testAddPeerReview() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4444", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewActivities("4444-4444-4444-4444");
    assertNotNull(response);
    ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    assertNotNull(summary.getPeerReviews());
    assertNotNull(summary.getPeerReviews().getPeerReviewGroup());
    assertEquals(1, summary.getPeerReviews().getPeerReviewGroup().size());
    assertNotNull(summary.getPeerReviews().getPeerReviewGroup().get(0));
    assertNotNull(summary.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary());
    assertNotNull(summary.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0));
    assertEquals("issn:0000001", summary.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getGroupId());
    PeerReview peerReview = Utils.getPeerReview();
    response = serviceDelegator.createPeerReview("4444-4444-4444-4444", peerReview);
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    Map<?, ?> map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List<?> resultWithPutCode = (List<?>) map.get("Location");
    Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    response = serviceDelegator.viewActivities("4444-4444-4444-4444");
    assertNotNull(response);
    summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    Utils.verifyLastModified(summary.getLastModifiedDate());
    assertNotNull(summary.getPeerReviews());
    Utils.verifyLastModified(summary.getLastModifiedDate());
    assertNotNull(summary.getPeerReviews().getPeerReviewGroup());
    assertEquals(2, summary.getPeerReviews().getPeerReviewGroup().size());
    boolean haveOld = false;
    boolean haveNew = false;
    for (PeerReviewGroup group : summary.getPeerReviews().getPeerReviewGroup()) {
        Utils.verifyLastModified(group.getLastModifiedDate());
        Utils.verifyLastModified(group.getPeerReviewSummary().get(0).getLastModifiedDate());
        if ("issn:0000001".equals(group.getPeerReviewSummary().get(0).getGroupId())) {
            haveOld = true;
        } else {
            assertEquals("issn:0000003", group.getPeerReviewSummary().get(0).getGroupId());
            haveNew = true;
        }
    }
    assertTrue(haveOld);
    assertTrue(haveNew);
    // Delete the new so it doesn't affect other tests
    serviceDelegator.deletePeerReview("4444-4444-4444-4444", putCode);
}
Also used : Response(javax.ws.rs.core.Response) PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) List(java.util.List) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)71 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)68 ClientResponse (com.sun.jersey.api.client.ClientResponse)35 Response (javax.ws.rs.core.Response)17 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)17 DBUnitTest (org.orcid.test.DBUnitTest)17 Url (org.orcid.jaxb.model.common_v2.Url)11 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)10 ArrayList (java.util.ArrayList)9 PeerReview (org.orcid.jaxb.model.record_rc1.PeerReview)9 PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)8 BaseTest (org.orcid.core.BaseTest)6 Title (org.orcid.jaxb.model.common_v2.Title)6 WorkExternalIdentifier (org.orcid.jaxb.model.record_rc1.WorkExternalIdentifier)6 WorkExternalIdentifierId (org.orcid.jaxb.model.record_rc1.WorkExternalIdentifierId)6 PeerReview (org.orcid.jaxb.model.record_rc3.PeerReview)6 PeerReview (org.orcid.jaxb.model.record_rc4.PeerReview)6 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)6 Funding (org.orcid.jaxb.model.record_v2.Funding)6 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)6