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();
}
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());
}
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;
}
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);
}
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);
}
Aggregations