use of org.orcid.jaxb.model.record_rc4.Work in project ORCID-Source by ORCID.
the class JSONWorkExternalIdentifiersConverterV2Test method getWork.
private Work getWork() throws JAXBException {
JAXBContext context = JAXBContext.newInstance(new Class[] { Work.class });
Unmarshaller unmarshaller = context.createUnmarshaller();
String name = "/record_2.0/samples/read_samples/work-full-2.0.xml";
InputStream inputStream = getClass().getResourceAsStream(name);
return (Work) unmarshaller.unmarshal(inputStream);
}
use of org.orcid.jaxb.model.record_rc4.Work in project ORCID-Source by ORCID.
the class SourceInActivitiesTest method getWork.
private Work getWork(String userOrcid) {
Work work = new Work();
WorkTitle title = new WorkTitle();
title.setTitle(new Title("Work " + System.currentTimeMillis()));
work.setWorkTitle(title);
work.setWorkType(org.orcid.jaxb.model.record_v2.WorkType.BOOK);
ExternalID extId = new ExternalID();
extId.setValue("111");
extId.setType(WorkExternalIdentifierType.DOI.value());
ExternalIDs extIdentifiers = new ExternalIDs();
extIdentifiers.getExternalIdentifier().add(extId);
work.setWorkExternalIdentifiers(extIdentifiers);
work = workManager.createWork(userOrcid, work, false);
return workManager.getWork(userOrcid, work.getPutCode());
}
use of org.orcid.jaxb.model.record_rc4.Work in project ORCID-Source by ORCID.
the class SourceInActivitiesTest method getWorkWithoutTitle.
private Work getWorkWithoutTitle(String userOrcid2, boolean validate) {
Work work = new Work();
work.setWorkType(org.orcid.jaxb.model.record_v2.WorkType.BOOK);
ExternalID extId = new ExternalID();
extId.setValue("111");
extId.setType(WorkExternalIdentifierType.DOI.value());
ExternalIDs extIdentifiers = new ExternalIDs();
extIdentifiers.getExternalIdentifier().add(extId);
work.setWorkExternalIdentifiers(extIdentifiers);
work = workManager.createWork(userOrcid, work, validate);
return workManager.getWork(userOrcid, work.getPutCode());
}
use of org.orcid.jaxb.model.record_rc4.Work 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_rc4.Work in project ORCID-Source by ORCID.
the class WorkManagerTest method testAddWorkToUnclaimedRecordPreserveWorkVisibility.
@Test
public void testAddWorkToUnclaimedRecordPreserveWorkVisibility() {
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
Work work = getWork(null);
work = workManager.createWork(unclaimedOrcid, work, true);
work = workManager.getWork(unclaimedOrcid, work.getPutCode());
assertNotNull(work);
assertEquals("Work title", work.getWorkTitle().getTitle().getContent());
assertEquals(Visibility.PUBLIC, work.getVisibility());
}
Aggregations