Search in sources :

Example 76 with PeerReview

use of org.orcid.jaxb.model.record_rc2.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 77 with PeerReview

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

the class ActivityManagerImpl method pubPeerReviewsMap.

public LinkedHashMap<Long, PeerReview> pubPeerReviewsMap(String orcid) {
    List<PeerReview> peerReviews = peerReviewManager.findPeerReviews(orcid);
    LinkedHashMap<Long, PeerReview> peerReviewMap = new LinkedHashMap<>();
    if (peerReviews != null) {
        if (!peerReviews.isEmpty()) {
            for (PeerReview peerReview : peerReviews) {
                if (peerReview.getVisibility().equals(Visibility.PUBLIC)) {
                    peerReviewMap.put(peerReview.getPutCode(), peerReview);
                }
            }
        }
    }
    return peerReviewMap;
}
Also used : PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) LinkedHashMap(java.util.LinkedHashMap)

Example 78 with PeerReview

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

the class PublicProfileVisibilityTest method peerReviewPrivacyTest.

@Test
public void peerReviewPrivacyTest() throws InterruptedException, JSONException, URISyntaxException {
    // Create peer review group
    String accessToken = getAccessToken(getScopes(ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE, ScopePathType.ACTIVITIES_READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE));
    List<GroupIdRecord> groups = createGroupIds();
    assertNotNull(groups);
    assertTrue(groups.size() > 0);
    GroupIdRecord g1 = groups.get(0);
    // Create peer review
    long time = System.currentTimeMillis();
    PeerReview peerReview = new PeerReview();
    peerReview.setGroupId(g1.getGroupId());
    ExternalIDs extIds = new ExternalIDs();
    peerReview.setExternalIdentifiers(extIds);
    peerReview.getExternalIdentifiers().getExternalIdentifier().clear();
    ExternalID wExtId = new ExternalID();
    wExtId.setValue("Work Id " + time);
    wExtId.setType(WorkExternalIdentifierType.AGR.value());
    wExtId.setRelationship(Relationship.SELF);
    peerReview.getExternalIdentifiers().getExternalIdentifier().add(wExtId);
    Organization organization = new Organization();
    organization.setName("My org name " + System.currentTimeMillis());
    OrganizationAddress address = new OrganizationAddress();
    address.setCity("Imagination city");
    address.setCountry(Iso3166Country.US);
    organization.setAddress(address);
    peerReview.setOrganization(organization);
    peerReview.setRole(Role.CHAIR);
    peerReview.setType(PeerReviewType.EVALUATION);
    peerReview.setCompletionDate(new FuzzyDate(new Year(2016), new Month(1), new Day(1)));
    ClientResponse postResponse = memberV2ApiClient.createPeerReviewXml(this.getUser1OrcidId(), peerReview, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
    ClientResponse getResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
    peerReview = getResponse.getEntity(PeerReview.class);
    showMyOrcidPage();
    changePeerReviewVisibility(g1.getName(), Visibility.PRIVATE.name());
    try {
        // Verify it doesn't appear in the public page
        showPublicProfilePage(getUser1OrcidId());
        peerReviewAppearsInPublicPage(g1.getName());
        fail();
    } catch (Exception e) {
    }
    showMyOrcidPage();
    changePeerReviewVisibility(g1.getName(), Visibility.LIMITED.name());
    try {
        // Verify it doesn't appear in the public page
        showPublicProfilePage(getUser1OrcidId());
        peerReviewAppearsInPublicPage(g1.getName());
        fail();
    } catch (Exception e) {
    }
    showMyOrcidPage();
    changePeerReviewVisibility(g1.getName(), Visibility.PUBLIC.name());
    showPublicProfilePage(getUser1OrcidId());
    peerReviewAppearsInPublicPage(g1.getName());
    // Rollback
    ClientResponse deleteResponse = memberV2ApiClient.deletePeerReviewXml(this.getUser1OrcidId(), peerReview.getPutCode(), accessToken);
    assertNotNull(deleteResponse);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) Organization(org.orcid.jaxb.model.common_v2.Organization) GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) OrganizationAddress(org.orcid.jaxb.model.common_v2.OrganizationAddress) FuzzyDate(org.orcid.jaxb.model.common_v2.FuzzyDate) URISyntaxException(java.net.URISyntaxException) JSONException(org.codehaus.jettison.json.JSONException) Month(org.orcid.jaxb.model.common_v2.Month) Year(org.orcid.jaxb.model.common_v2.Year) Day(org.orcid.jaxb.model.common_v2.Day) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Test(org.junit.Test)

Example 79 with PeerReview

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

the class JpaJaxbPeerReviewAdapterTest method fromOrgAffiliationRelationEntityToEducation.

@Test
public void fromOrgAffiliationRelationEntityToEducation() {
    PeerReviewEntity entity = getPeerReviewEntity();
    assertNotNull(entity);
    PeerReview peerReview = jpaJaxbPeerReviewAdapter.toPeerReview(entity);
    assertNotNull(peerReview);
    assertEquals(Long.valueOf(12345), peerReview.getPutCode());
    assertEquals("private", peerReview.getVisibility().value());
    assertEquals("orcid-generated:12345", peerReview.getGroupId());
    // Subject
    assertNotNull(peerReview.getSubjectExternalIdentifier());
    assertEquals("peer-review:subject-external-identifier-id", peerReview.getSubjectExternalIdentifier().getValue());
    assertEquals("source-work-id", peerReview.getSubjectExternalIdentifier().getType());
    assertEquals("peer-review:subject-container-name", peerReview.getSubjectContainerName().getContent());
    assertEquals("peer-review:subject-name", peerReview.getSubjectName().getTitle().getContent());
    assertEquals("peer-review:subject-translated-name", peerReview.getSubjectName().getTranslatedTitle().getContent());
    assertEquals("en", peerReview.getSubjectName().getTranslatedTitle().getLanguageCode());
    assertEquals(WorkType.BOOK_REVIEW.value(), peerReview.getSubjectType().value());
    assertEquals("peer-review:subject-url", peerReview.getSubjectUrl().getValue());
    // Fields
    assertNotNull(peerReview.getExternalIdentifiers());
    assertNotNull(peerReview.getExternalIdentifiers().getExternalIdentifier());
    assertEquals(1, peerReview.getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals("peer-review:external-identifier-id", peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("source-work-id", peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
    assertEquals(Role.MEMBER.value(), peerReview.getRole().value());
    assertEquals(PeerReviewType.EVALUATION.value(), peerReview.getType().value());
    assertEquals("peer-review:url", peerReview.getUrl().getValue());
    assertNotNull(peerReview.getCompletionDate());
    assertEquals("2015", peerReview.getCompletionDate().getYear().getValue());
    assertEquals("01", peerReview.getCompletionDate().getMonth().getValue());
    assertEquals("01", peerReview.getCompletionDate().getDay().getValue());
    assertNotNull(peerReview.getOrganization());
    assertEquals("org:name", peerReview.getOrganization().getName());
    assertNotNull(peerReview.getOrganization().getAddress());
    assertEquals("org:city", peerReview.getOrganization().getAddress().getCity());
    assertEquals("org:region", peerReview.getOrganization().getAddress().getRegion());
    assertNotNull(peerReview.getSource());
    assertEquals("APP-000000001", peerReview.getSource().retrieveSourcePath());
}
Also used : PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Test(org.junit.Test)

Example 80 with PeerReview

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

the class JSONPeerReviewWorkExternalIdentifierConverterV2Test method testConvertTo.

@Test
public void testConvertTo() throws JAXBException {
    PeerReview peerReview = getPeerReview();
    assertEquals("{\"relationship\":\"SELF\",\"url\":{\"value\":\"http://orcid.org\"},\"workExternalIdentifierType\":\"DOI\",\"workExternalIdentifierId\":{\"content\":\"peer-review:subject-external-identifier-id\"}}", converter.convertTo(peerReview.getSubjectExternalIdentifier(), null));
}
Also used : PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)72 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)66 ClientResponse (com.sun.jersey.api.client.ClientResponse)35 Response (javax.ws.rs.core.Response)17 DBUnitTest (org.orcid.test.DBUnitTest)17 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)16 Url (org.orcid.jaxb.model.common_v2.Url)10 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)10 PeerReview (org.orcid.jaxb.model.record_rc1.PeerReview)9 PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)8 ArrayList (java.util.ArrayList)7 BaseTest (org.orcid.core.BaseTest)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 Funding (org.orcid.jaxb.model.record_v2.Funding)6 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)6 Title (org.orcid.jaxb.model.common_v2.Title)5 Education (org.orcid.jaxb.model.record_v2.Education)5