use of org.orcid.jaxb.model.v3.dev1.common.SourceOrcid in project ORCID-Source by ORCID.
the class WorkForm method toWork.
public Work toWork() {
Work work = new Work();
// Set work id
if (!PojoUtil.isEmpty(this.getPutCode())) {
work.setPutCode(Long.valueOf(this.getPutCode().getValue()));
}
// Set language
if (!PojoUtil.isEmpty(this.getLanguageCode())) {
work.setLanguageCode(this.getLanguageCode().getValue());
}
// Set type
if (!PojoUtil.isEmpty(this.getWorkType())) {
work.setWorkType(WorkType.fromValue(this.getWorkType().getValue()));
}
org.orcid.jaxb.model.v3.dev1.record.WorkTitle workTitle = new org.orcid.jaxb.model.v3.dev1.record.WorkTitle();
// Set title
if (!PojoUtil.isEmpty(this.getTitle())) {
workTitle.setTitle(new org.orcid.jaxb.model.v3.dev1.common.Title(this.getTitle().getValue()));
}
// Set translated title
if (this.getTranslatedTitle() != null && !PojoUtil.isEmpty(this.getTranslatedTitle().getContent())) {
org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle translatedTitle = new org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle();
translatedTitle.setContent(this.getTranslatedTitle().getContent());
translatedTitle.setLanguageCode(this.getTranslatedTitle().getLanguageCode());
workTitle.setTranslatedTitle(translatedTitle);
}
// Set subtitle
if (!PojoUtil.isEmpty(this.getSubtitle())) {
org.orcid.jaxb.model.v3.dev1.common.Subtitle subtitle = new org.orcid.jaxb.model.v3.dev1.common.Subtitle();
subtitle.setContent(this.getSubtitle().getValue());
workTitle.setSubtitle(subtitle);
}
work.setWorkTitle(workTitle);
// Set journal title
if (!PojoUtil.isEmpty(this.getJournalTitle())) {
work.setJournalTitle(new org.orcid.jaxb.model.v3.dev1.common.Title(this.getJournalTitle().getValue()));
}
// Set description
if (!PojoUtil.isEmpty(this.getShortDescription())) {
work.setShortDescription(this.getShortDescription().getValue());
}
// Set url
if (!PojoUtil.isEmpty(this.getUrl())) {
work.setUrl(new Url(this.getUrl().getValue()));
} else {
work.setUrl(new Url());
}
// Set visibility
if (this.getVisibility() != null && this.getVisibility().getVisibility() != null) {
work.setVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.fromValue(this.getVisibility().getVisibility().value()));
}
// Set country
if (!PojoUtil.isEmpty(this.getCountryCode())) {
work.setCountry(new org.orcid.jaxb.model.v3.dev1.common.Country(org.orcid.jaxb.model.v3.dev1.common.Iso3166Country.fromValue(this.getCountryCode().getValue())));
}
// Set publication date
if (this.getPublicationDate() != null) {
Integer yearInteger = PojoUtil.isEmpty(this.getPublicationDate().getYear()) ? null : Integer.valueOf(this.getPublicationDate().getYear());
Integer monthInteger = PojoUtil.isEmpty(this.getPublicationDate().getMonth()) ? null : Integer.valueOf(this.getPublicationDate().getMonth());
Integer dayInteger = PojoUtil.isEmpty(this.getPublicationDate().getDay()) ? null : Integer.valueOf(this.getPublicationDate().getDay());
org.orcid.jaxb.model.v3.dev1.common.Year year = null;
org.orcid.jaxb.model.v3.dev1.common.Month month = null;
org.orcid.jaxb.model.v3.dev1.common.Day day = null;
if (yearInteger != null) {
year = new org.orcid.jaxb.model.v3.dev1.common.Year(yearInteger);
}
if (monthInteger != null) {
month = new org.orcid.jaxb.model.v3.dev1.common.Month(monthInteger);
}
if (dayInteger != null) {
day = new org.orcid.jaxb.model.v3.dev1.common.Day(dayInteger);
}
work.setPublicationDate(new org.orcid.jaxb.model.v3.dev1.common.PublicationDate(year, month, day));
}
// Set citation
if (this.getCitation() != null) {
org.orcid.jaxb.model.v3.dev1.record.Citation citation = new org.orcid.jaxb.model.v3.dev1.record.Citation();
if (!PojoUtil.isEmpty(this.getCitation().getCitation())) {
citation.setCitation(this.getCitation().getCitation().getValue());
}
if (!PojoUtil.isEmpty(this.getCitation().getCitationType())) {
citation.setWorkCitationType(CitationType.fromValue(this.getCitation().getCitationType().getValue()));
}
work.setWorkCitation(citation);
}
// Set contributors
populateContributors(this, work);
// Set external identifiers
populateExternalIdentifiers(this, work);
// Set created date
if (!PojoUtil.isEmpty(this.getCreatedDate())) {
CreatedDate createdDate = new CreatedDate();
createdDate.setValue(DateUtils.convertToXMLGregorianCalendar(this.getCreatedDate().toJavaDate()));
work.setCreatedDate(createdDate);
}
// Set last modified
if (!PojoUtil.isEmpty(this.getLastModified())) {
org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate lastModified = new org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate();
lastModified.setValue(DateUtils.convertToXMLGregorianCalendar(this.getLastModified().toJavaDate()));
work.setLastModifiedDate(lastModified);
}
if (!PojoUtil.isEmpty(this.getSource())) {
org.orcid.jaxb.model.v3.dev1.common.Source source = new org.orcid.jaxb.model.v3.dev1.common.Source();
if (OrcidStringUtils.isClientId(this.getSource())) {
source.setSourceClientId(new SourceClientId(this.getSource()));
} else {
source.setSourceOrcid(new SourceOrcid(this.getSource()));
}
work.setSource(source);
}
return work;
}
use of org.orcid.jaxb.model.v3.dev1.common.SourceOrcid in project ORCID-Source by ORCID.
the class ActivityValidatorTest method validateDuplicatedExtIds_noDuplicatesTest.
/**
* VALIDATE DUPLICATED EXTERNAL IDENTIFIERS
*/
@SuppressWarnings("deprecation")
@Test
public void validateDuplicatedExtIds_noDuplicatesTest() {
SourceEntity source1 = mock(SourceEntity.class);
when(source1.getSourceName()).thenReturn("source name");
when(source1.getSourceId()).thenReturn("APP-00000000000000");
SourceOrcid sourceOrcid = new SourceOrcid();
sourceOrcid.setPath("0000-0000-0000-0000");
Source source2 = mock(Source.class);
when(source2.getSourceName()).thenReturn(new SourceName("other source name"));
when(source2.getSourceOrcid()).thenReturn(sourceOrcid);
ExternalIDs extIds1 = getExternalIDs();
ExternalIDs extIds2 = getExternalIDs();
activityValidator.checkExternalIdentifiersForDuplicates(extIds1, extIds2, source2, source1);
}
Aggregations