Skip to content

Commit

Permalink
Peer review subject types dissertation to dissertation thesis (#7006)
Browse files Browse the repository at this point in the history
* Deactivated records should get 409 on GET requests

* On Peer reviews, the subject type 'DISSERTATION' should be stored as the V3 version 'DISSERTATION_THESIS'

* Fix NPE
  • Loading branch information
amontenegro authored Mar 13, 2024
1 parent 293f4f5 commit d3cda46
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public WorkType convertFrom(String source, Type<WorkType> 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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
});

Expand Down
Original file line number Diff line number Diff line change
@@ -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));
}
}

0 comments on commit d3cda46

Please sign in to comment.