use of org.orcid.jaxb.model.message.WorkContributors in project ORCID-Source by ORCID.
the class OrcidProfileManagerContributorVisibilityTest method retrieveWorkContributorEntityDirectlyFromDb.
private Contributor retrieveWorkContributorEntityDirectlyFromDb(OrcidWork retrievedWork) {
WorkEntity workEntity = workDao.find(Long.valueOf(retrievedWork.getPutCode()));
String contributorsJson = workEntity.getContributorsJson();
WorkContributors workContributors = JsonUtils.readObjectFromJsonString(contributorsJson, WorkContributors.class);
assertNotNull(workContributors);
return workContributors.getContributor().get(0);
}
use of org.orcid.jaxb.model.message.WorkContributors in project ORCID-Source by ORCID.
the class JpaJaxbEntityAdapterToOrcidProfileTest method testToOrcidProfileWithNewWayOfDoingWorkContributors.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testToOrcidProfileWithNewWayOfDoingWorkContributors() {
ProfileEntity profileEntity = profileDao.find("4444-4444-4444-4445");
long start = System.currentTimeMillis();
OrcidProfile orcidProfile = adapter.toOrcidProfile(profileEntity);
System.out.println("Took: " + Long.toString(System.currentTimeMillis() - start));
List<OrcidWork> worksList = orcidProfile.getOrcidActivities().getOrcidWorks().getOrcidWork();
assertEquals(1, worksList.size());
OrcidWork orcidWork = worksList.get(0);
WorkContributors contributors = orcidWork.getWorkContributors();
assertNotNull(contributors);
List<Contributor> contributorList = contributors.getContributor();
assertEquals(1, contributorList.size());
Contributor contributor = contributorList.get(0);
assertEquals("Jason Contributor", contributor.getCreditName().getContent());
}
use of org.orcid.jaxb.model.message.WorkContributors 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