use of org.orcid.jaxb.model.record_v2.Citation in project ORCID-Source by ORCID.
the class WorkToCiteprocTranslatorTest method makeWork.
private Work makeWork(String bibtex) {
Work work = new Work();
Citation citation = new Citation();
citation.setWorkCitationType(CitationType.BIBTEX);
citation.setCitation(bibtex);
work.setWorkCitation(citation);
return work;
}
use of org.orcid.jaxb.model.record_v2.Citation in project ORCID-Source by ORCID.
the class BibtexManagerTest method testGenerateBibtexForSingleWorkFromCitationField.
@Test
public void testGenerateBibtexForSingleWorkFromCitationField() {
Work w = new Work();
Citation c = new Citation();
c.setWorkCitationType(CitationType.BIBTEX);
c.setCitation("HELLO");
w.setWorkCitation(c);
String bib = bibtexManager.generateBibtex(ORCID, w);
Assert.assertEquals("HELLO", bib);
}
use of org.orcid.jaxb.model.record_v2.Citation in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_WorksTest method testCleanEmptyFieldsOnWorks.
@Test
public void testCleanEmptyFieldsOnWorks() {
LastModifiedDate lmd = new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(System.currentTimeMillis()));
Work work = new Work();
work.setLastModifiedDate(lmd);
work.setWorkCitation(new Citation("", CitationType.FORMATTED_UNSPECIFIED));
WorkTitle title = new WorkTitle();
title.setTitle(new Title("My Work"));
title.setSubtitle(new Subtitle("My subtitle"));
title.setTranslatedTitle(new TranslatedTitle("", ""));
work.setWorkTitle(title);
ActivityUtils.cleanEmptyFields(work);
assertNotNull(work);
Utils.verifyLastModified(work.getLastModifiedDate());
assertNotNull(work.getWorkTitle());
assertNotNull(work.getWorkTitle().getTitle());
assertNotNull(work.getWorkTitle().getSubtitle());
assertEquals("My Work", work.getWorkTitle().getTitle().getContent());
assertEquals("My subtitle", work.getWorkTitle().getSubtitle().getContent());
assertNull(work.getWorkCitation());
assertNull(work.getWorkTitle().getTranslatedTitle());
}
use of org.orcid.jaxb.model.record_v2.Citation in project ORCID-Source by ORCID.
the class MapperFacadeFactory method getWorkMapperFacade.
public MapperFacade getWorkMapperFacade() {
MapperFactory mapperFactory = getNewMapperFactory();
ConverterFactory converterFactory = mapperFactory.getConverterFactory();
converterFactory.registerConverter("workExternalIdentifiersConverterId", new JSONWorkExternalIdentifiersConverterV2());
converterFactory.registerConverter("workContributorsConverterId", new JsonOrikaConverter<WorkContributors>());
ClassMapBuilder<Work, WorkEntity> workClassMap = mapperFactory.classMap(Work.class, WorkEntity.class);
workClassMap.byDefault();
workClassMap.field("putCode", "id");
addV2DateFields(workClassMap);
registerSourceConverters(mapperFactory, workClassMap);
workClassMap.field("journalTitle.content", "journalTitle");
workClassMap.field("workTitle.title.content", "title");
workClassMap.field("workTitle.translatedTitle.content", "translatedTitle");
workClassMap.field("workTitle.translatedTitle.languageCode", "translatedTitleLanguageCode");
workClassMap.field("workTitle.subtitle.content", "subtitle");
workClassMap.field("shortDescription", "description");
workClassMap.field("workCitation.workCitationType", "citationType");
workClassMap.field("workCitation.citation", "citation");
workClassMap.field("workType", "workType");
workClassMap.field("publicationDate", "publicationDate");
workClassMap.fieldMap("workExternalIdentifiers", "externalIdentifiersJson").converter("workExternalIdentifiersConverterId").add();
workClassMap.field("url.value", "workUrl");
workClassMap.fieldMap("workContributors", "contributorsJson").converter("workContributorsConverterId").add();
workClassMap.field("languageCode", "languageCode");
workClassMap.field("country.value", "iso2Country");
workClassMap.register();
ClassMapBuilder<WorkSummary, WorkEntity> workSummaryClassMap = mapperFactory.classMap(WorkSummary.class, WorkEntity.class);
registerSourceConverters(mapperFactory, workSummaryClassMap);
workSummaryClassMap.field("putCode", "id");
workSummaryClassMap.field("title.title.content", "title");
workSummaryClassMap.field("title.translatedTitle.content", "translatedTitle");
workSummaryClassMap.field("title.translatedTitle.languageCode", "translatedTitleLanguageCode");
workSummaryClassMap.field("type", "workType");
workSummaryClassMap.field("publicationDate", "publicationDate");
workSummaryClassMap.fieldMap("externalIdentifiers", "externalIdentifiersJson").converter("workExternalIdentifiersConverterId").add();
workSummaryClassMap.byDefault();
workSummaryClassMap.register();
ClassMapBuilder<WorkSummary, MinimizedWorkEntity> workSummaryMinimizedClassMap = mapperFactory.classMap(WorkSummary.class, MinimizedWorkEntity.class);
addV2CommonFields(workSummaryMinimizedClassMap);
registerSourceConverters(mapperFactory, workSummaryMinimizedClassMap);
workSummaryMinimizedClassMap.field("title.title.content", "title");
workSummaryMinimizedClassMap.field("title.translatedTitle.content", "translatedTitle");
workSummaryMinimizedClassMap.field("title.translatedTitle.languageCode", "translatedTitleLanguageCode");
workSummaryMinimizedClassMap.field("type", "workType");
workSummaryMinimizedClassMap.field("publicationDate.year.value", "publicationYear");
workSummaryMinimizedClassMap.field("publicationDate.month.value", "publicationMonth");
workSummaryMinimizedClassMap.field("publicationDate.day.value", "publicationDay");
workSummaryMinimizedClassMap.fieldMap("externalIdentifiers", "externalIdentifiersJson").converter("workExternalIdentifiersConverterId").add();
workSummaryMinimizedClassMap.byDefault();
workSummaryMinimizedClassMap.register();
ClassMapBuilder<Work, MinimizedWorkEntity> minimizedWorkClassMap = mapperFactory.classMap(Work.class, MinimizedWorkEntity.class);
minimizedWorkClassMap.byDefault();
registerSourceConverters(mapperFactory, minimizedWorkClassMap);
minimizedWorkClassMap.field("putCode", "id");
minimizedWorkClassMap.field("journalTitle.content", "journalTitle");
minimizedWorkClassMap.field("workTitle.title.content", "title");
minimizedWorkClassMap.field("workTitle.translatedTitle.content", "translatedTitle");
minimizedWorkClassMap.field("workTitle.translatedTitle.languageCode", "translatedTitleLanguageCode");
minimizedWorkClassMap.field("workTitle.subtitle.content", "subtitle");
minimizedWorkClassMap.field("shortDescription", "description");
minimizedWorkClassMap.field("workType", "workType");
minimizedWorkClassMap.field("publicationDate.year.value", "publicationYear");
minimizedWorkClassMap.field("publicationDate.month.value", "publicationMonth");
minimizedWorkClassMap.field("publicationDate.day.value", "publicationDay");
minimizedWorkClassMap.fieldMap("workExternalIdentifiers", "externalIdentifiersJson").converter("workExternalIdentifiersConverterId").add();
minimizedWorkClassMap.field("url.value", "workUrl");
minimizedWorkClassMap.register();
mapperFactory.classMap(PublicationDate.class, PublicationDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
return mapperFactory.getMapperFacade();
}
use of org.orcid.jaxb.model.record_v2.Citation in project ORCID-Source by ORCID.
the class ActivityUtilsTest method cleanBulkWorkTest.
@Test
public void cleanBulkWorkTest() {
// Test it cleans empty fields
WorkBulk bulk = new WorkBulk();
Work w = getEmptyWork();
bulk.getBulk().add(w);
assertNotNull(((Work) bulk.getBulk().get(0)).getWorkTitle().getTranslatedTitle());
assertNotNull(((Work) bulk.getBulk().get(0)).getWorkCitation());
assertNotNull(((Work) bulk.getBulk().get(0)).getWorkContributors().getContributor().get(0).getCreditName());
ActivityUtils.cleanEmptyFields(bulk);
assertNull(((Work) bulk.getBulk().get(0)).getWorkTitle().getTranslatedTitle());
assertNull(((Work) bulk.getBulk().get(0)).getWorkCitation());
assertNull(((Work) bulk.getBulk().get(0)).getWorkContributors().getContributor().get(0).getCreditName());
// Test it doesn't remove non empty fields
bulk = new WorkBulk();
w = getEmptyWork();
w.getWorkTitle().getTranslatedTitle().setContent("translated_title");
w.getWorkTitle().getTranslatedTitle().setLanguageCode("en_us");
w.getWorkCitation().setCitation("citation");
w.getWorkCitation().setWorkCitationType(CitationType.BIBTEX);
w.getWorkContributors().getContributor().get(0).getCreditName().setContent("credit_name");
bulk.getBulk().add(w);
assertEquals("translated_title", ((Work) bulk.getBulk().get(0)).getWorkTitle().getTranslatedTitle().getContent());
assertEquals("en_us", ((Work) bulk.getBulk().get(0)).getWorkTitle().getTranslatedTitle().getLanguageCode());
assertEquals("citation", ((Work) bulk.getBulk().get(0)).getWorkCitation().getCitation());
assertEquals(CitationType.BIBTEX, ((Work) bulk.getBulk().get(0)).getWorkCitation().getWorkCitationType());
assertEquals("credit_name", ((Work) bulk.getBulk().get(0)).getWorkContributors().getContributor().get(0).getCreditName().getContent());
ActivityUtils.cleanEmptyFields(bulk);
assertEquals("translated_title", ((Work) bulk.getBulk().get(0)).getWorkTitle().getTranslatedTitle().getContent());
assertEquals("en_us", ((Work) bulk.getBulk().get(0)).getWorkTitle().getTranslatedTitle().getLanguageCode());
assertEquals("citation", ((Work) bulk.getBulk().get(0)).getWorkCitation().getCitation());
assertEquals(CitationType.BIBTEX, ((Work) bulk.getBulk().get(0)).getWorkCitation().getWorkCitationType());
assertEquals("credit_name", ((Work) bulk.getBulk().get(0)).getWorkContributors().getContributor().get(0).getCreditName().getContent());
}
Aggregations