use of org.orcid.jaxb.model.v3.dev1.common.PublicationDate in project ORCID-Source by ORCID.
the class WorkFormTest method getWork.
private Work getWork() {
Work work = new Work();
work.setCountry(new Country(Iso3166Country.US));
work.setJournalTitle(new Title("Journal title"));
work.setLanguageCode("en");
work.setPutCode(Long.valueOf("1"));
work.setShortDescription("Short description");
work.setSource(new org.orcid.jaxb.model.v3.dev1.common.Source("0000-0000-0000-0000"));
work.setUrl(new Url("http://myurl.com"));
work.setVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC);
org.orcid.jaxb.model.v3.dev1.record.Citation citation = new org.orcid.jaxb.model.v3.dev1.record.Citation();
citation.setCitation("Citation");
citation.setWorkCitationType(CitationType.FORMATTED_UNSPECIFIED);
work.setWorkCitation(citation);
WorkTitle title = new WorkTitle();
title.setTitle(new Title("Title"));
title.setTranslatedTitle(new org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle("Translated Title", "es"));
title.setSubtitle(new Subtitle("Subtitle"));
work.setWorkTitle(title);
work.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
Date date = new Date();
date.setDay("1");
date.setMonth("1");
date.setYear("2015");
GregorianCalendar calendar = date.toCalendar();
work.setCreatedDate(new CreatedDate(datatypeFactory.newXMLGregorianCalendar(calendar)));
date = new Date();
date.setDay("2");
date.setMonth("2");
date.setYear("2015");
calendar = date.toCalendar();
work.setLastModifiedDate(new LastModifiedDate(datatypeFactory.newXMLGregorianCalendar(calendar)));
work.setPublicationDate(new PublicationDate(new Year(2015), new Month(3), new Day(3)));
org.orcid.jaxb.model.v3.dev1.record.WorkContributors contributors = new org.orcid.jaxb.model.v3.dev1.record.WorkContributors();
org.orcid.jaxb.model.v3.dev1.common.Contributor contributor = new org.orcid.jaxb.model.v3.dev1.common.Contributor();
org.orcid.jaxb.model.v3.dev1.common.ContributorAttributes attributes = new org.orcid.jaxb.model.v3.dev1.common.ContributorAttributes();
attributes.setContributorRole(org.orcid.jaxb.model.v3.dev1.common.ContributorRole.CO_INVENTOR);
attributes.setContributorSequence(org.orcid.jaxb.model.v3.dev1.record.SequenceType.FIRST);
contributor.setContributorAttributes(attributes);
contributor.setContributorEmail(null);
ContributorOrcid contributorOrcid = new ContributorOrcid("Contributor orcid");
contributorOrcid.setUri("Contributor uri");
contributor.setContributorOrcid(contributorOrcid);
CreditName creditName = new CreditName("Contributor credit name");
contributor.setCreditName(creditName);
contributors.getContributor().add(contributor);
work.setWorkContributors(contributors);
ExternalIDs externalIdentifiers = new ExternalIDs();
ExternalID extId = new ExternalID();
extId.setValue("External Identifier ID");
extId.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.ASIN.value());
extId.setRelationship(Relationship.SELF);
externalIdentifiers.getExternalIdentifier().add(extId);
work.setWorkExternalIdentifiers(externalIdentifiers);
return work;
}
use of org.orcid.jaxb.model.v3.dev1.common.PublicationDate in project ORCID-Source by ORCID.
the class WorkFormTest method getWorkForm.
private WorkForm getWorkForm() {
WorkForm form = new WorkForm();
form.setCitation(new Citation("Citation", "formatted-unspecified"));
List<Contributor> çontributors = new ArrayList<Contributor>();
Contributor contributor = new Contributor();
contributor.setContributorRole(Text.valueOf("co_inventor"));
contributor.setContributorSequence(Text.valueOf("first"));
contributor.setCreditName(Text.valueOf("Contributor credit name"));
contributor.setEmail(null);
contributor.setOrcid(Text.valueOf("Contributor orcid"));
contributor.setUri(Text.valueOf("Contributor uri"));
çontributors.add(contributor);
form.setContributors(çontributors);
form.setCountryCode(Text.valueOf("US"));
Date createdDate = new Date();
createdDate.setDay("1");
createdDate.setMonth("1");
createdDate.setYear("2015");
form.setCreatedDate(createdDate);
form.setJournalTitle(Text.valueOf("Journal title"));
form.setLanguageCode(Text.valueOf("en"));
Date lastModifiedDate = new Date();
lastModifiedDate.setDay("2");
lastModifiedDate.setMonth("2");
lastModifiedDate.setYear("2015");
form.setLastModified(lastModifiedDate);
Date publicationDate = new Date();
publicationDate.setDay("03");
publicationDate.setMonth("03");
publicationDate.setYear("2015");
form.setPublicationDate(publicationDate);
form.setDateSortString(PojoUtil.createDateSortString(null, FuzzyDate.valueOf(2015, 3, 3)));
form.setPutCode(Text.valueOf("1"));
form.setShortDescription(Text.valueOf("Short description"));
form.setSource("0000-0000-0000-0000");
form.setSubtitle(Text.valueOf("Subtitle"));
form.setTitle(Text.valueOf("Title"));
form.setTranslatedTitle(new TranslatedTitleForm("Translated Title", "es"));
form.setUrl(Text.valueOf("http://myurl.com"));
form.setVisibility(Visibility.valueOf(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC));
List<WorkExternalIdentifier> extIds = new ArrayList<WorkExternalIdentifier>();
WorkExternalIdentifier extId = new WorkExternalIdentifier();
extId.setWorkExternalIdentifierId(Text.valueOf("External Identifier ID"));
extId.setWorkExternalIdentifierType(Text.valueOf("asin"));
extId.setRelationship(Text.valueOf(Relationship.SELF.value()));
extIds.add(extId);
form.setWorkExternalIdentifiers(extIds);
form.setWorkType(Text.valueOf("artistic-performance"));
WorkCategory category = WorkCategory.fromWorkType(WorkType.fromValue(form.getWorkType().getValue()));
form.setWorkCategory(Text.valueOf(category.value()));
return form;
}
use of org.orcid.jaxb.model.v3.dev1.common.PublicationDate in project ORCID-Source by ORCID.
the class WorkForm method valueOf.
public static WorkForm valueOf(Work work) {
if (work == null)
return null;
WorkForm w = new WorkForm();
// Set work id
if (work.getPutCode() != null) {
w.setPutCode(Text.valueOf(work.getPutCode()));
}
// Set language
if (!PojoUtil.isEmpty(work.getLanguageCode())) {
w.setLanguageCode(Text.valueOf(work.getLanguageCode()));
}
// Set type
if (work.getWorkType() != null) {
w.setWorkType(Text.valueOf(work.getWorkType().value()));
// Set category
WorkCategory category = WorkCategory.fromWorkType(work.getWorkType());
w.setWorkCategory(Text.valueOf(category.value()));
}
if (work.getWorkTitle() != null) {
// Set title
if (work.getWorkTitle().getTitle() != null) {
w.setTitle(Text.valueOf(work.getWorkTitle().getTitle().getContent()));
}
// Set translated title
if (work.getWorkTitle().getTranslatedTitle() != null) {
TranslatedTitleForm tt = new TranslatedTitleForm();
tt.setContent(work.getWorkTitle().getTranslatedTitle().getContent());
tt.setLanguageCode(work.getWorkTitle().getTranslatedTitle().getLanguageCode());
w.setTranslatedTitle(tt);
}
// Set subtitle
if (work.getWorkTitle().getSubtitle() != null) {
w.setSubtitle(Text.valueOf(work.getWorkTitle().getSubtitle().getContent()));
}
}
// Set journal title
if (work.getJournalTitle() != null) {
w.setJournalTitle(Text.valueOf(work.getJournalTitle().getContent()));
}
// Set description
if (work.getShortDescription() != null) {
w.setShortDescription(Text.valueOf(work.getShortDescription()));
}
// Set url
if (work.getUrl() != null) {
w.setUrl(Text.valueOf(work.getUrl().getValue()));
}
// Set visibility
if (work.getVisibility() != null) {
w.setVisibility(Visibility.valueOf(work.getVisibility()));
}
// Set country
if (work.getCountry() != null && work.getCountry().getValue() != null) {
w.setCountryCode(Text.valueOf(work.getCountry().getValue().value()));
}
// Set publication date
FuzzyDate fuzzyPublicationDate = null;
if (work.getPublicationDate() != null) {
org.orcid.jaxb.model.v3.dev1.common.PublicationDate publicationDate = work.getPublicationDate();
Integer year = PojoUtil.isEmpty(publicationDate.getYear()) ? null : Integer.valueOf(publicationDate.getYear().getValue());
Integer month = PojoUtil.isEmpty(publicationDate.getMonth()) ? null : Integer.valueOf(publicationDate.getMonth().getValue());
Integer day = PojoUtil.isEmpty(publicationDate.getDay()) ? null : Integer.valueOf(publicationDate.getDay().getValue());
if (year != null && year == 0) {
year = null;
}
if (month != null && month == 0) {
month = null;
}
if (day != null && day == 0) {
day = null;
}
fuzzyPublicationDate = FuzzyDate.valueOf(year, month, day);
w.setPublicationDate(Date.valueOf(fuzzyPublicationDate));
}
w.setDateSortString(PojoUtil.createDateSortString(null, fuzzyPublicationDate));
// Set citation
if (work.getWorkCitation() != null) {
Citation citation = new Citation();
if (!PojoUtil.isEmpty(work.getWorkCitation().getCitation())) {
citation.setCitation(Text.valueOf(work.getWorkCitation().getCitation()));
}
if (work.getWorkCitation().getWorkCitationType() != null) {
citation.setCitationType(Text.valueOf(work.getWorkCitation().getWorkCitationType().value()));
}
w.setCitation(citation);
}
// Set contributors
populateContributors(work, w);
// Set external identifiers
populateExternalIdentifiers(work, w);
// Set created date
w.setCreatedDate(Date.valueOf(work.getCreatedDate()));
// Set last modified
w.setLastModified(Date.valueOf(work.getLastModifiedDate()));
if (work.getSource() != null) {
// Set source
w.setSource(work.getSource().retrieveSourcePath());
if (work.getSource().getSourceName() != null) {
w.setSourceName(work.getSource().getSourceName().getContent());
}
}
return w;
}
use of org.orcid.jaxb.model.v3.dev1.common.PublicationDate in project ORCID-Source by ORCID.
the class WorkFormTest method getWork.
public static Work getWork() {
Work work = new Work();
work.setCountry(new Country(Iso3166Country.US));
Date date = new Date();
work.setCreatedDate(new CreatedDate(DateUtils.convertToXMLGregorianCalendar(date)));
work.setJournalTitle(new Title("Journal Title"));
work.setLanguageCode("EN");
work.setPublicationDate(new PublicationDate(new Year(2015), new Month(1), new Day(1)));
work.setPutCode(Long.valueOf("12345"));
work.setShortDescription("Short description");
work.setUrl(new Url("http://test.com"));
work.setVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.LIMITED);
work.setWorkCitation(new org.orcid.jaxb.model.v3.dev1.record.Citation("Citation", CitationType.BIBTEX));
WorkContributors contributors = new WorkContributors();
org.orcid.jaxb.model.v3.dev1.common.Contributor contributor = new org.orcid.jaxb.model.v3.dev1.common.Contributor();
contributor.setCreditName(new CreditName("Credit name"));
contributor.setContributorOrcid(new ContributorOrcid("0000-0000-0000-0000"));
ContributorAttributes att = new ContributorAttributes();
att.setContributorRole(ContributorRole.ASSIGNEE);
att.setContributorSequence(SequenceType.FIRST);
contributor.setContributorAttributes(att);
contributors.getContributor().add(contributor);
work.setWorkContributors(contributors);
ExternalIDs weis = new ExternalIDs();
ExternalID wei = new ExternalID();
wei.setRelationship(Relationship.SELF);
wei.setUrl(new Url("http://test.com"));
wei.setValue("ID");
wei.setType(WorkExternalIdentifierType.AGR.value());
weis.getExternalIdentifier().add(wei);
work.setWorkExternalIdentifiers(weis);
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title("Work Title"));
workTitle.setSubtitle(new Subtitle("Subtitle"));
TranslatedTitle translated = new TranslatedTitle("Translated", "US");
workTitle.setTranslatedTitle(translated);
work.setWorkTitle(workTitle);
work.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
return work;
}
use of org.orcid.jaxb.model.v3.dev1.common.PublicationDate in project ORCID-Source by ORCID.
the class MapperFacadeFactory method getWorkMapperFacade.
public MapperFacade getWorkMapperFacade() {
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
ConverterFactory converterFactory = mapperFactory.getConverterFactory();
converterFactory.registerConverter("workExternalIdentifiersConverterId", new JSONWorkExternalIdentifiersConverterV3(norm, localeManager));
converterFactory.registerConverter("workContributorsConverterId", new JsonOrikaConverter<WorkContributors>());
ClassMapBuilder<Work, WorkEntity> workClassMap = mapperFactory.classMap(Work.class, WorkEntity.class);
workClassMap.byDefault();
workClassMap.field("putCode", "id");
addV3DateFields(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("journalTitle.content", "journalTitle");
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);
addV3CommonFields(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();
}
Aggregations