Search in sources :

Example 31 with PeerReviewSummary

use of org.orcid.jaxb.model.record.summary_rc2.PeerReviewSummary in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies_PeerReviewReadLimited_NoSource.

@Test
public void testViewActitivies_PeerReviewReadLimited_NoSource() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, "APP-5555555555555556", ScopePathType.PEER_REVIEW_READ_LIMITED);
    Response response = serviceDelegator.viewActivities(ORCID);
    ActivitiesSummary as = (ActivitiesSummary) response.getEntity();
    assertNotNull(as);
    assertNotNull(as.getPath());
    Utils.verifyLastModified(as.getLastModifiedDate());
    // Only public educations
    assertNotNull(as.getEducations());
    assertEquals(1, as.getEducations().getSummaries().size());
    assertEquals(Long.valueOf(20), as.getEducations().getSummaries().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getEducations().getSummaries().get(0).getVisibility());
    // Only public employments
    assertNotNull(as.getEmployments());
    assertEquals(1, as.getEmployments().getSummaries().size());
    assertEquals(Long.valueOf(17), as.getEmployments().getSummaries().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getEmployments().getSummaries().get(0).getVisibility());
    // Only public funding
    assertNotNull(as.getFundings());
    assertEquals(1, as.getFundings().getFundingGroup().size());
    assertEquals(1, as.getFundings().getFundingGroup().get(0).getFundingSummary().size());
    assertEquals(Long.valueOf(10), as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getVisibility());
    // Limited peer reviews
    boolean found1 = false, found2 = false, found3 = false;
    assertNotNull(as.getPeerReviews());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    for (PeerReviewGroup group : as.getPeerReviews().getPeerReviewGroup()) {
        assertEquals(1, group.getPeerReviewSummary().size());
        PeerReviewSummary element = group.getPeerReviewSummary().get(0);
        if (element.getPutCode().equals(Long.valueOf(9))) {
            assertEquals(Visibility.PUBLIC, element.getVisibility());
            found1 = true;
        } else if (element.getPutCode().equals(Long.valueOf(10))) {
            assertEquals(Visibility.LIMITED, element.getVisibility());
            found2 = true;
        } else if (element.getPutCode().equals(Long.valueOf(12))) {
            assertEquals(Visibility.LIMITED, element.getVisibility());
            found3 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    // Only public works
    assertNotNull(as.getWorks());
    assertEquals(1, as.getWorks().getWorkGroup().size());
    assertEquals(1, as.getWorks().getWorkGroup().get(0).getWorkSummary().size());
    assertEquals(Long.valueOf(11), as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 32 with PeerReviewSummary

use of org.orcid.jaxb.model.record.summary_rc2.PeerReviewSummary in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_PeerReviewsTest method testViewPeerReviews.

@Test
public void testViewPeerReviews() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewPeerReviews(ORCID);
    assertNotNull(r);
    PeerReviews peerReviews = (PeerReviews) r.getEntity();
    assertNotNull(peerReviews);
    assertEquals("/0000-0000-0000-0003/peer-reviews", peerReviews.getPath());
    Utils.verifyLastModified(peerReviews.getLastModifiedDate());
    assertNotNull(peerReviews.getPeerReviewGroup());
    assertEquals(4, peerReviews.getPeerReviewGroup().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    for (PeerReviewGroup group : peerReviews.getPeerReviewGroup()) {
        Utils.verifyLastModified(group.getLastModifiedDate());
        assertNotNull(group.getIdentifiers());
        assertNotNull(group.getIdentifiers().getExternalIdentifier());
        assertEquals(1, group.getIdentifiers().getExternalIdentifier().size());
        assertNotNull(group.getPeerReviewSummary());
        assertEquals(1, group.getPeerReviewSummary().size());
        PeerReviewSummary summary = group.getPeerReviewSummary().get(0);
        Utils.verifyLastModified(summary.getLastModifiedDate());
        switch(group.getIdentifiers().getExternalIdentifier().get(0).getValue()) {
            case "issn:0000009":
                assertEquals("issn:0000009", summary.getGroupId());
                assertEquals(Long.valueOf(9), summary.getPutCode());
                found1 = true;
                break;
            case "issn:0000010":
                assertEquals("issn:0000010", summary.getGroupId());
                assertEquals(Long.valueOf(10), summary.getPutCode());
                found2 = true;
                break;
            case "issn:0000011":
                assertEquals("issn:0000011", summary.getGroupId());
                assertEquals(Long.valueOf(11), summary.getPutCode());
                found3 = true;
                break;
            case "issn:0000012":
                assertEquals("issn:0000012", summary.getGroupId());
                assertEquals(Long.valueOf(12), summary.getPutCode());
                found4 = true;
                break;
            default:
                fail("Invalid group id found: " + group.getIdentifiers().getExternalIdentifier().get(0).getValue());
                break;
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
}
Also used : Response(javax.ws.rs.core.Response) PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) PeerReviews(org.orcid.jaxb.model.record.summary_v2.PeerReviews) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 33 with PeerReviewSummary

use of org.orcid.jaxb.model.record.summary_rc2.PeerReviewSummary in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_PeerReviewsTest method testViewPeerReviewSummaryReadPublic.

@Test
public void testViewPeerReviewSummaryReadPublic() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewPeerReviewSummary("4444-4444-4444-4446", Long.valueOf(1));
    PeerReviewSummary element = (PeerReviewSummary) r.getEntity();
    assertNotNull(element);
    assertEquals("/4444-4444-4444-4446/peer-review/1", element.getPath());
    Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
Also used : Response(javax.ws.rs.core.Response) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 34 with PeerReviewSummary

use of org.orcid.jaxb.model.record.summary_rc2.PeerReviewSummary in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_PeerReviewsTest method testViewPeerReviewSummary.

@Test
public void testViewPeerReviewSummary() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewPeerReviewSummary("4444-4444-4444-4446", Long.valueOf(1));
    assertNotNull(response);
    PeerReviewSummary peerReview = (PeerReviewSummary) response.getEntity();
    assertNotNull(peerReview);
    assertEquals("/4444-4444-4444-4446/peer-review/1", peerReview.getPath());
    Utils.verifyLastModified(peerReview.getLastModifiedDate());
    assertEquals(Long.valueOf("1"), 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#1", peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("APP-5555555555555555", peerReview.getSource().retrieveSourcePath());
    assertEquals("public", peerReview.getVisibility().value());
}
Also used : Response(javax.ws.rs.core.Response) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 35 with PeerReviewSummary

use of org.orcid.jaxb.model.record.summary_rc2.PeerReviewSummary in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getPeerReviewMapperFacade.

public MapperFacade getPeerReviewMapperFacade() {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    ConverterFactory converterFactory = mapperFactory.getConverterFactory();
    converterFactory.registerConverter("workExternalIdentifiersConverterId", new WorkExternalIDsConverter());
    converterFactory.registerConverter("workExternalIdentifierConverterId", new PeerReviewWorkExternalIDConverter());
    //do same as work
    ClassMapBuilder<PeerReview, PeerReviewEntity> classMap = mapperFactory.classMap(PeerReview.class, PeerReviewEntity.class);
    addV2CommonFields(classMap);
    registerSourceConverters(mapperFactory, classMap);
    classMap.field("url.value", "url");
    classMap.field("organization.name", "org.name");
    classMap.field("organization.address.city", "org.city");
    classMap.field("organization.address.region", "org.region");
    classMap.field("organization.address.country", "org.country");
    classMap.field("organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier", "org.orgDisambiguated.sourceId");
    classMap.field("organization.disambiguatedOrganization.disambiguationSource", "org.orgDisambiguated.sourceType");
    classMap.field("groupId", "groupId");
    classMap.field("subjectType", "subjectType");
    classMap.field("subjectUrl.value", "subjectUrl");
    classMap.field("subjectName.title.content", "subjectName");
    classMap.field("subjectName.translatedTitle.content", "subjectTranslatedName");
    classMap.field("subjectName.translatedTitle.languageCode", "subjectTranslatedNameLanguageCode");
    classMap.field("subjectContainerName.content", "subjectContainerName");
    classMap.fieldMap("externalIdentifiers", "externalIdentifiersJson").converter("workExternalIdentifiersConverterId").add();
    classMap.fieldMap("subjectExternalIdentifier", "subjectExternalIdentifiersJson").converter("workExternalIdentifierConverterId").add();
    classMap.register();
    ClassMapBuilder<PeerReviewSummary, PeerReviewEntity> peerReviewSummaryClassMap = mapperFactory.classMap(PeerReviewSummary.class, PeerReviewEntity.class);
    addV2CommonFields(peerReviewSummaryClassMap);
    registerSourceConverters(mapperFactory, peerReviewSummaryClassMap);
    peerReviewSummaryClassMap.fieldMap("externalIdentifiers", "externalIdentifiersJson").converter("workExternalIdentifiersConverterId").add();
    peerReviewSummaryClassMap.field("organization.name", "org.name");
    peerReviewSummaryClassMap.field("organization.address.city", "org.city");
    peerReviewSummaryClassMap.field("organization.address.region", "org.region");
    peerReviewSummaryClassMap.field("organization.address.country", "org.country");
    peerReviewSummaryClassMap.field("organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier", "org.orgDisambiguated.sourceId");
    peerReviewSummaryClassMap.field("organization.disambiguatedOrganization.disambiguationSource", "org.orgDisambiguated.sourceType");
    peerReviewSummaryClassMap.register();
    mapperFactory.classMap(FuzzyDate.class, CompletionDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
    return mapperFactory.getMapperFacade();
}
Also used : PeerReviewWorkExternalIDConverter(org.orcid.core.adapter.impl.jsonidentifiers.PeerReviewWorkExternalIDConverter) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) WorkExternalIDsConverter(org.orcid.core.adapter.impl.jsonidentifiers.WorkExternalIDsConverter) ConverterFactory(ma.glasnost.orika.converter.ConverterFactory) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview)

Aggregations

PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)64 Test (org.junit.Test)59 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)43 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)43 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)43 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)43 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)37 ClientResponse (com.sun.jersey.api.client.ClientResponse)20 PeerReviewGroup (org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup)17 PeerReviews (org.orcid.jaxb.model.record.summary_v2.PeerReviews)16 Address (org.orcid.jaxb.model.record_v2.Address)16 Email (org.orcid.jaxb.model.record_v2.Email)16 Keyword (org.orcid.jaxb.model.record_v2.Keyword)16 OtherName (org.orcid.jaxb.model.record_v2.OtherName)16 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)16 Record (org.orcid.jaxb.model.record_v2.Record)16 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)16 Addresses (org.orcid.jaxb.model.record_v2.Addresses)15 Biography (org.orcid.jaxb.model.record_v2.Biography)15 Emails (org.orcid.jaxb.model.record_v2.Emails)15