diff --git a/orcid-core/src/main/java/org/orcid/core/adapter/converter/PeerReviewSubjectTypeConverter.java b/orcid-core/src/main/java/org/orcid/core/adapter/converter/PeerReviewSubjectTypeConverter.java index 374539d99b5..f36983f3777 100644 --- a/orcid-core/src/main/java/org/orcid/core/adapter/converter/PeerReviewSubjectTypeConverter.java +++ b/orcid-core/src/main/java/org/orcid/core/adapter/converter/PeerReviewSubjectTypeConverter.java @@ -17,6 +17,9 @@ public WorkType convertFrom(String source, Type destinationType) { try { return WorkType.valueOf(source); } catch (IllegalArgumentException e) { + if(org.orcid.jaxb.model.common.WorkType.DISSERTATION_THESIS.name().equals(source)) { + return WorkType.DISSERTATION; + } return WorkType.OTHER; } } diff --git a/orcid-core/src/main/java/org/orcid/core/adapter/impl/MapperFacadeFactory.java b/orcid-core/src/main/java/org/orcid/core/adapter/impl/MapperFacadeFactory.java index cb56d1ea3ca..a68bf4f3b55 100644 --- a/orcid-core/src/main/java/org/orcid/core/adapter/impl/MapperFacadeFactory.java +++ b/orcid-core/src/main/java/org/orcid/core/adapter/impl/MapperFacadeFactory.java @@ -940,6 +940,13 @@ public void mapAtoB(PeerReview a, PeerReviewEntity b, MappingContext context) { b.setSubjectTranslatedNameLanguageCode((a.getSubjectName() == null || a.getSubjectName().getTranslatedTitle() == null) ? null : a.getSubjectName().getTranslatedTitle().getLanguageCode()); b.setSubjectContainerName(a.getSubjectContainerName() == null ? null : a.getSubjectContainerName().getContent()); + if(WorkType.DISSERTATION.equals(a.getSubjectType())) { + b.setSubjectType(org.orcid.jaxb.model.common.WorkType.DISSERTATION_THESIS.name()); + } else { + if(a.getSubjectType() != null) { + b.setSubjectType(a.getSubjectType().name()); + } + } } }); diff --git a/orcid-core/src/test/java/org/orcid/core/adapter/converter/PeerReviewSubjectTypeConverterTest.java b/orcid-core/src/test/java/org/orcid/core/adapter/converter/PeerReviewSubjectTypeConverterTest.java new file mode 100644 index 00000000000..7c44fd9edcf --- /dev/null +++ b/orcid-core/src/test/java/org/orcid/core/adapter/converter/PeerReviewSubjectTypeConverterTest.java @@ -0,0 +1,37 @@ +package org.orcid.core.adapter.converter; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.orcid.jaxb.model.record_v2.WorkType; +import org.orcid.test.OrcidJUnit4ClassRunner; +import org.springframework.test.context.ContextConfiguration; + +@RunWith(OrcidJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath:test-orcid-core-context.xml" }) +public class PeerReviewSubjectTypeConverterTest { + + private PeerReviewSubjectTypeConverter peerReviewSubjectTypeConverter = new PeerReviewSubjectTypeConverter(); + + @Test + public void testConvertTo() { + for(WorkType t : WorkType.values()) { + assertEquals(t.name(), peerReviewSubjectTypeConverter.convertTo(t, null)); + } + } + + @Test + public void testConvertFrom() { + for(WorkType t : WorkType.values()) { + assertEquals(t, peerReviewSubjectTypeConverter.convertFrom(t.name(), null)); + } + + assertEquals(WorkType.DISSERTATION, peerReviewSubjectTypeConverter.convertFrom(org.orcid.jaxb.model.common.WorkType.DISSERTATION_THESIS.name(), null)); + assertEquals(WorkType.OTHER, peerReviewSubjectTypeConverter.convertFrom(org.orcid.jaxb.model.common.WorkType.ANNOTATION.name(), null)); + assertEquals(WorkType.OTHER, peerReviewSubjectTypeConverter.convertFrom(org.orcid.jaxb.model.common.WorkType.DATA_MANAGEMENT_PLAN.name(), null)); + assertEquals(WorkType.OTHER, peerReviewSubjectTypeConverter.convertFrom(org.orcid.jaxb.model.common.WorkType.PHYSICAL_OBJECT.name(), null)); + assertEquals(WorkType.OTHER, peerReviewSubjectTypeConverter.convertFrom(org.orcid.jaxb.model.common.WorkType.PREPRINT.name(), null)); + assertEquals(WorkType.OTHER, peerReviewSubjectTypeConverter.convertFrom(org.orcid.jaxb.model.common.WorkType.SOFTWARE.name(), null)); + } +}