Search in sources :

Example 1 with Citation

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;
}
Also used : Work(org.orcid.jaxb.model.record_v2.Work) Citation(org.orcid.jaxb.model.record_v2.Citation)

Example 2 with Citation

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);
}
Also used : Work(org.orcid.jaxb.model.record_v2.Work) Citation(org.orcid.jaxb.model.record_v2.Citation) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 3 with Citation

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());
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Subtitle(org.orcid.jaxb.model.common_v2.Subtitle) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) Work(org.orcid.jaxb.model.record_v2.Work) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) Title(org.orcid.jaxb.model.common_v2.Title) Citation(org.orcid.jaxb.model.record_v2.Citation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 4 with Citation

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();
}
Also used : WorkContributors(org.orcid.jaxb.model.record_v2.WorkContributors) ConverterFactory(ma.glasnost.orika.converter.ConverterFactory) WorkEntity(org.orcid.persistence.jpa.entities.WorkEntity) MinimizedWorkEntity(org.orcid.persistence.jpa.entities.MinimizedWorkEntity) NotificationWorkEntity(org.orcid.persistence.jpa.entities.NotificationWorkEntity) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) JSONWorkExternalIdentifiersConverterV2(org.orcid.core.adapter.jsonidentifier.converter.JSONWorkExternalIdentifiersConverterV2) MinimizedWorkEntity(org.orcid.persistence.jpa.entities.MinimizedWorkEntity) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) Work(org.orcid.jaxb.model.record_v2.Work)

Example 5 with Citation

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());
}
Also used : WorkBulk(org.orcid.jaxb.model.record_v2.WorkBulk) Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test)

Aggregations

Work (org.orcid.jaxb.model.record_v2.Work)10 Test (org.junit.Test)5 Citation (org.orcid.jaxb.model.record_v2.Citation)5 WorkContributors (org.orcid.jaxb.model.record_v2.WorkContributors)4 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)4 Contributor (org.orcid.jaxb.model.common_v2.Contributor)3 Title (org.orcid.jaxb.model.common_v2.Title)3 TranslatedTitle (org.orcid.jaxb.model.common_v2.TranslatedTitle)3 ContributorOrcid (org.orcid.jaxb.model.common_v2.ContributorOrcid)2 CreditName (org.orcid.jaxb.model.common_v2.CreditName)2 Iso3166Country (org.orcid.jaxb.model.common_v2.Iso3166Country)2 PublicationDate (org.orcid.jaxb.model.common_v2.PublicationDate)2 Subtitle (org.orcid.jaxb.model.common_v2.Subtitle)2 FundingTitle (org.orcid.jaxb.model.record_v2.FundingTitle)2 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1