use of org.orcid.jaxb.model.message.Citation in project ORCID-Source by ORCID.
the class JpaJaxbEntityAdapterToOrcidProfileTest method checkOrcidWorks.
private void checkOrcidWorks(OrcidWorks orcidWorks) {
assertNotNull(orcidWorks);
List<OrcidWork> orcidWorkList = orcidWorks.getOrcidWork();
assertEquals(3, orcidWorkList.size());
boolean putCode1Found = false;
boolean putCode4Found = false;
for (OrcidWork orcidWork : orcidWorkList) {
if (orcidWork.getPutCode().equals("1")) {
putCode1Found = true;
assertEquals("1", orcidWork.getPutCode());
Citation workCitation = orcidWork.getWorkCitation();
assertNotNull(workCitation);
assertEquals("Bobby Ewing, ", workCitation.getCitation());
assertEquals(CitationType.FORMATTED_IEEE, workCitation.getWorkCitationType());
WorkContributors contributors = orcidWork.getWorkContributors();
assertNotNull(contributors);
assertEquals(2, contributors.getContributor().size());
assertEquals("Jaylen Kessler", contributors.getContributor().get(0).getCreditName().getContent());
assertEquals(Visibility.PUBLIC, contributors.getContributor().get(0).getCreditName().getVisibility());
assertEquals(Visibility.PUBLIC, orcidWork.getVisibility());
assertNull(orcidWork.getJournalTitle());
} else if (orcidWork.getPutCode().equals("3")) {
WorkContributors contributors = orcidWork.getWorkContributors();
assertNotNull(contributors);
assertEquals(1, contributors.getContributor().size());
assertEquals("0000-0003-0172-7925", contributors.getContributor().get(0).getContributorOrcid().getPath());
} else if (orcidWork.getPutCode().equals("4")) {
putCode4Found = true;
assertNotNull(orcidWork.getWorkTitle());
assertNotNull(orcidWork.getWorkTitle().getTitle());
assertEquals("A book with a Journal Title", orcidWork.getWorkTitle().getTitle().getContent());
assertNotNull(orcidWork.getJournalTitle());
assertEquals("My Journal Title", orcidWork.getJournalTitle().getContent());
assertNotNull(orcidWork.getPublicationDate());
assertNotNull(orcidWork.getPublicationDate().getDay());
assertNotNull(orcidWork.getPublicationDate().getMonth());
assertNotNull(orcidWork.getPublicationDate().getYear());
assertEquals("01", orcidWork.getPublicationDate().getDay().getValue());
assertEquals("02", orcidWork.getPublicationDate().getMonth().getValue());
assertEquals("2011", orcidWork.getPublicationDate().getYear().getValue());
assertNotNull(orcidWork.getWorkCitation());
assertEquals("Sue Ellen ewing", orcidWork.getWorkCitation().getCitation());
assertEquals(CitationType.FORMATTED_IEEE, orcidWork.getWorkCitation().getWorkCitationType());
assertNotNull(orcidWork.getWorkType());
assertEquals(WorkType.BOOK, orcidWork.getWorkType());
}
}
assertTrue(putCode1Found);
assertTrue(putCode4Found);
}
use of org.orcid.jaxb.model.message.Citation in project ORCID-Source by ORCID.
the class Jaxb2JpaAdapterImpl method getWorkEntity.
public WorkEntity getWorkEntity(OrcidWork orcidWork, WorkEntity workEntity) {
if (orcidWork != null) {
if (workEntity == null) {
String putCode = orcidWork.getPutCode();
if (StringUtils.isNotBlank(putCode) && !"-1".equals(putCode)) {
throw new IllegalArgumentException("Invalid put-code was supplied: " + putCode);
}
workEntity = new WorkEntity();
} else {
workEntity.clean();
}
Citation workCitation = orcidWork.getWorkCitation();
if (workCitation != null && StringUtils.isNotBlank(workCitation.getCitation()) && workCitation.getWorkCitationType() != null) {
workEntity.setCitation(workCitation.getCitation());
workEntity.setCitationType(CitationType.fromValue(workCitation.getWorkCitationType().value()));
}
// New way of doing work contributors
workEntity.setContributorsJson(getWorkContributorsJson(orcidWork.getWorkContributors()));
workEntity.setDescription(orcidWork.getShortDescription() != null ? orcidWork.getShortDescription() : null);
// New way of doing work external ids
workEntity.setExternalIdentifiersJson(getWorkExternalIdsJson(orcidWork));
workEntity.setPublicationDate(getWorkPublicationDate(orcidWork));
WorkTitle workTitle = orcidWork.getWorkTitle();
if (workTitle != null) {
workEntity.setSubtitle(workTitle.getSubtitle() != null ? workTitle.getSubtitle().getContent() : null);
workEntity.setTitle(workTitle.getTitle() != null ? workTitle.getTitle().getContent().trim() : null);
TranslatedTitle translatedTitle = workTitle.getTranslatedTitle();
if (translatedTitle != null) {
workEntity.setTranslatedTitle(StringUtils.isEmpty(translatedTitle.getContent()) ? null : translatedTitle.getContent());
workEntity.setTranslatedTitleLanguageCode(StringUtils.isEmpty(translatedTitle.getLanguageCode()) ? null : translatedTitle.getLanguageCode());
}
}
workEntity.setJournalTitle(orcidWork.getJournalTitle() != null ? orcidWork.getJournalTitle().getContent() : null);
workEntity.setLanguageCode(orcidWork.getLanguageCode() != null ? orcidWork.getLanguageCode() : null);
if (orcidWork.getCountry() != null && orcidWork.getCountry().getValue() != null) {
workEntity.setIso2Country(org.orcid.jaxb.model.common_v2.Iso3166Country.fromValue(orcidWork.getCountry().getValue().value()));
}
workEntity.setWorkUrl(orcidWork.getUrl() != null ? orcidWork.getUrl().getValue() : null);
if (orcidWork.getWorkType() != null) {
workEntity.setWorkType(org.orcid.jaxb.model.record_v2.WorkType.fromValue(orcidWork.getWorkType().value()));
}
if (orcidWork.getVisibility() != null) {
workEntity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(orcidWork.getVisibility().value()));
} else {
workEntity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
}
workEntity.setAddedToProfileDate(new Date());
//Set source
setSource(orcidWork.getSource(), workEntity);
if (workEntity.getDisplayIndex() == null) {
workEntity.setDisplayIndex(0L);
}
return workEntity;
}
return null;
}
use of org.orcid.jaxb.model.message.Citation in project ORCID-Source by ORCID.
the class Publication method getOrcidWork.
public OrcidWork getOrcidWork() {
initCrossRefContext();
OrcidWork orcidWork = new OrcidWork();
if (StringUtils.isNotBlank(doi)) {
WorkExternalIdentifier doiExtId = new WorkExternalIdentifier();
doiExtId.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
doiExtId.setWorkExternalIdentifierId(new WorkExternalIdentifierId(doi));
WorkExternalIdentifiers workExtIds = new WorkExternalIdentifiers();
orcidWork.setWorkExternalIdentifiers(workExtIds);
workExtIds.getWorkExternalIdentifier().add(doiExtId);
}
if (StringUtils.isNotBlank(title)) {
WorkTitle workTitle = new WorkTitle();
orcidWork.setWorkTitle(workTitle);
workTitle.setTitle(new Title(title));
}
// Will throw an IllegalArgumentException if not valid
CitationType cType = CitationType.fromValue(citationType);
Citation citation = new Citation(fullCitation, cType);
orcidWork.setWorkCitation(citation);
String publicationDateString = crossRefContext.getDate();
if (StringUtils.isNotBlank(publicationDateString)) {
XMLGregorianCalendar publicationDateGregCal = DateUtils.convertToXMLGregorianCalendar(publicationDateString);
if (publicationDateGregCal != null) {
Year publicationyear = new Year(publicationDateGregCal.getYear());
Month publicationMonth = publicationDateGregCal.getMonth() == DatatypeConstants.FIELD_UNDEFINED ? null : new Month(publicationDateGregCal.getMonth());
Day publicationDay = publicationDateGregCal.getDay() == DatatypeConstants.FIELD_UNDEFINED ? null : new Day(publicationDateGregCal.getDay());
orcidWork.setPublicationDate(new PublicationDate(publicationyear, publicationMonth, publicationDay));
}
}
String author = crossRefContext.getAuthor();
if (StringUtils.isNotBlank(author)) {
WorkContributors workContributors = new WorkContributors();
orcidWork.setWorkContributors(workContributors);
Contributor contributor = new Contributor();
workContributors.getContributor().add(contributor);
contributor.setCreditName(new CreditName(author));
ContributorAttributes contributorAttributes = new ContributorAttributes();
contributor.setContributorAttributes(contributorAttributes);
contributorAttributes.setContributorRole(ContributorRole.AUTHOR);
contributorAttributes.setContributorSequence(SequenceType.FIRST);
}
return orcidWork;
}
Aggregations