Search in sources :

Example 46 with PeerReview

use of org.orcid.jaxb.model.record_rc4.PeerReview 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)

Example 47 with PeerReview

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

the class JpaJaxbPeerReviewAdapterTest method testToOrgAffiliationRelationEntity.

@Test
public void testToOrgAffiliationRelationEntity() throws JAXBException {
    PeerReview e = getPeerReview(true);
    assertNotNull(e);
    PeerReviewEntity pe = jpaJaxbPeerReviewAdapter.toPeerReviewEntity(e);
    assertNotNull(pe);
    //General info
    assertEquals(Long.valueOf(12345), pe.getId());
    assertEquals(Visibility.PRIVATE.value(), pe.getVisibility().value());
    assertEquals("{\"workExternalIdentifier\":[{\"relationship\":\"SELF\",\"url\":{\"value\":\"http://orcid.org\"},\"workExternalIdentifierType\":\"SOURCE_WORK_ID\",\"workExternalIdentifierId\":{\"content\":\"work:external-identifier-id\"}}]}", pe.getExternalIdentifiersJson());
    assertEquals("reviewer", pe.getRole().value());
    assertEquals("review", pe.getType().value());
    assertEquals("peer-review:url", pe.getUrl());
    //Dates
    assertEquals(Integer.valueOf(2), pe.getCompletionDate().getDay());
    assertEquals(Integer.valueOf(2), pe.getCompletionDate().getMonth());
    assertEquals(Integer.valueOf(1848), pe.getCompletionDate().getYear());
    // Source
    assertNull(pe.getSourceId());
    assertNull(pe.getClientSourceId());
    assertNull(pe.getElementSourceId());
    //Check org values
    assertEquals("common:name", pe.getOrg().getName());
    assertEquals("common:city", pe.getOrg().getCity());
    assertEquals("common:region", pe.getOrg().getRegion());
    assertEquals(Iso3166Country.AF.value(), pe.getOrg().getCountry().value());
    assertEquals("common:disambiguated-organization-identifier", pe.getOrg().getOrgDisambiguated().getSourceId());
    assertEquals("common:disambiguation-source", pe.getOrg().getOrgDisambiguated().getSourceType());
    //Check subject        
    assertEquals("{\"relationship\":\"SELF\",\"url\":{\"value\":\"http://orcid.org\"},\"workExternalIdentifierType\":\"DOI\",\"workExternalIdentifierId\":{\"content\":\"peer-review:subject-external-identifier-id\"}}", pe.getSubjectExternalIdentifiersJson());
    assertEquals("peer-review:subject-container-name", pe.getSubjectContainerName());
    assertEquals("peer-review:subject-name", pe.getSubjectName());
    assertEquals("peer-review:subject-translated-name", pe.getSubjectTranslatedName());
    assertEquals("en", pe.getSubjectTranslatedNameLanguageCode());
    assertEquals("peer-review:subject-url", pe.getSubjectUrl());
    assertEquals(WorkType.JOURNAL_ARTICLE, pe.getSubjectType());
    //Check group id
    assertEquals("orcid-generated:12345", pe.getGroupId());
}
Also used : PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Test(org.junit.Test)

Example 48 with PeerReview

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

the class ActivityValidatorTest method getPeerReview.

public PeerReview getPeerReview() {
    PeerReview peerReview = new PeerReview();
    peerReview.setCompletionDate(getFuzzyDate());
    peerReview.setExternalIdentifiers(getExternalIDs());
    peerReview.setGroupId("group-id");
    peerReview.setOrganization(getOrganization());
    peerReview.setRole(Role.CHAIR);
    peerReview.setSubjectContainerName(new Title("subject-container-name"));
    peerReview.setSubjectExternalIdentifier(getExternalID());
    peerReview.setSubjectName(getWorkTitle());
    peerReview.setSubjectType(WorkType.ARTISTIC_PERFORMANCE);
    peerReview.setSubjectUrl(new Url("http://test.orcid.org"));
    peerReview.setType(PeerReviewType.EVALUATION);
    peerReview.setUrl(new Url("http://test.orcid.org"));
    peerReview.setVisibility(Visibility.PUBLIC);
    return peerReview;
}
Also used : WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) Title(org.orcid.jaxb.model.common_v2.Title) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Url(org.orcid.jaxb.model.common_v2.Url)

Example 49 with PeerReview

use of org.orcid.jaxb.model.record_rc4.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.record_v2.PeerReview) Test(org.junit.Test)

Example 50 with PeerReview

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

the class ActivityValidatorTest method validatePeerReview_emptyExternalIdentifierValueTest.

@Test(expected = ActivityIdentifierValidationException.class)
public void validatePeerReview_emptyExternalIdentifierValueTest() {
    PeerReview pr = getPeerReview();
    pr.getExternalIdentifiers().getExternalIdentifier().get(0).setValue("");
    activityValidator.validatePeerReview(pr, null, true, true, Visibility.PUBLIC);
}
Also used : PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) 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