use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class OrcidIndexManagerImplTest method getStandardOrcidWithDoiInformation.
private OrcidProfile getStandardOrcidWithDoiInformation() {
OrcidProfile orcidProfile = getStandardOrcid();
OrcidWork orcidWork1 = orcidProfile.retrieveOrcidWorks().getOrcidWork().get(0);
OrcidWork orcidWork2 = orcidProfile.retrieveOrcidWorks().getOrcidWork().get(1);
OrcidWork orcidWork3 = orcidProfile.retrieveOrcidWorks().getOrcidWork().get(2);
WorkExternalIdentifiers work1ExternalIdentifiers = new WorkExternalIdentifiers();
WorkExternalIdentifier work1ExternalIdentifier1 = new WorkExternalIdentifier();
work1ExternalIdentifier1.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
work1ExternalIdentifier1.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work1-doi1"));
WorkExternalIdentifier work1ExternalIdentifier2 = new WorkExternalIdentifier();
work1ExternalIdentifier2.setWorkExternalIdentifierType(WorkExternalIdentifierType.PMID);
work1ExternalIdentifier2.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work1-pmid"));
work1ExternalIdentifiers.getWorkExternalIdentifier().add(work1ExternalIdentifier1);
work1ExternalIdentifiers.getWorkExternalIdentifier().add(work1ExternalIdentifier2);
orcidWork1.setWorkExternalIdentifiers(work1ExternalIdentifiers);
WorkExternalIdentifiers work2ExternalIdentifiers = new WorkExternalIdentifiers();
WorkExternalIdentifier work2ExternalIdentifier1 = new WorkExternalIdentifier();
work2ExternalIdentifier1.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
work2ExternalIdentifier1.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work2-doi1"));
WorkExternalIdentifier work2ExternalIdentifier2 = new WorkExternalIdentifier();
work2ExternalIdentifier2.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
work2ExternalIdentifier2.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work2-doi2"));
work2ExternalIdentifiers.getWorkExternalIdentifier().add(work2ExternalIdentifier1);
work2ExternalIdentifiers.getWorkExternalIdentifier().add(work2ExternalIdentifier2);
orcidWork2.setWorkExternalIdentifiers(work2ExternalIdentifiers);
WorkExternalIdentifiers work3ExternalIdentifiers = new WorkExternalIdentifiers();
WorkExternalIdentifier work3ExternalIdentifier1 = new WorkExternalIdentifier();
work3ExternalIdentifier1.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
work3ExternalIdentifier1.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work3-doi1"));
WorkExternalIdentifier work3ExternalIdentifier2 = new WorkExternalIdentifier();
work3ExternalIdentifier2.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
work3ExternalIdentifier2.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work3-doi2"));
work3ExternalIdentifiers.getWorkExternalIdentifier().add(work3ExternalIdentifier1);
work3ExternalIdentifiers.getWorkExternalIdentifier().add(work3ExternalIdentifier2);
orcidWork3.setWorkExternalIdentifiers(work3ExternalIdentifiers);
return orcidProfile;
}
use of org.orcid.jaxb.model.message.OrcidWork 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;
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class MarshallingTest method testMarshallingFullMessage.
@Test
public void testMarshallingFullMessage() throws JAXBException {
OrcidMessage orcidMessage = getOrcidMessage();
assertNotNull(orcidMessage);
OrcidProfile orcidProfile = orcidMessage.getOrcidProfile();
assertNotNull(orcidProfile);
assertEquals("4444-4444-4444-4446", orcidProfile.getOrcidIdentifier().getPath());
OrcidActivities orcidActivities = orcidProfile.getOrcidActivities();
assertNotNull(orcidActivities);
assertEquals(4, orcidActivities.getAffiliations().getAffiliation().size());
OrcidWorks orcidWorks = orcidProfile.retrieveOrcidWorks();
assertTrue(orcidWorks != null && orcidWorks.getOrcidWork().size() == 1);
OrcidWork orcidWork = orcidWorks.getOrcidWork().get(0);
assertEquals("journal-article", orcidWork.getWorkType().value());
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class CheckAndFixContributorNameVisibility method processOrcid.
private void processOrcid(final String orcid) {
LOG.info("Checking and fixing profile: {}", orcid);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
OrcidProfile orcidProfile = orcidProfileManager.retrieveOrcidProfile(orcid);
OrcidWorks orcidWorks = orcidProfile.retrieveOrcidWorks();
if (orcidWorks != null) {
for (OrcidWork orcidWork : orcidWorks.getOrcidWork()) {
WorkContributors workContributors = orcidWork.getWorkContributors();
if (workContributors != null) {
for (Contributor contributor : workContributors.getContributor()) {
ContributorOrcid contributorOrcid = contributor.getContributorOrcid();
if (contributorOrcid != null) {
String orcid = contributorOrcid.getPath();
ProfileEntity contributorProfile = profileDao.find(orcid);
if (contributorProfile.getRecordNameEntity() != null && contributorProfile.getRecordNameEntity().getVisibility() != null) {
if (!Visibility.PUBLIC.value().equals(contributorProfile.getRecordNameEntity().getVisibility().value())) {
contributor.setCreditName(null);
}
}
}
}
}
}
}
orcidProfileManager.updateOrcidProfile(orcidProfile);
}
});
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testAddOrcidWorksWhenDefaultVisibilityIsPublic.
@Test
@Transactional
@Rollback(true)
public void testAddOrcidWorksWhenDefaultVisibilityIsPublic() {
OrcidProfile profile1 = createBasicProfile();
OrcidHistory history = new OrcidHistory();
history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
profile1.setOrcidHistory(history);
history.setClaimed(new Claimed(true));
profile1.getOrcidInternal().getPreferences().setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(Visibility.PUBLIC));
orcidProfileManager.createOrcidProfile(profile1, false, false);
OrcidProfile profile2 = new OrcidProfile();
profile2.setOrcidIdentifier(TEST_ORCID);
OrcidWorks orcidWorks = new OrcidWorks();
profile2.setOrcidWorks(orcidWorks);
WorkTitle workTitle1 = new WorkTitle();
workTitle1.setTitle(new Title("Another Title"));
workTitle1.setSubtitle(new Subtitle("Journal of Cloud Spotting"));
OrcidWork work1 = createWork1(workTitle1);
Source source = new Source(TEST_ORCID);
work1.setSource(source);
orcidWorks.getOrcidWork().add(work1);
WorkTitle workTitle2 = new WorkTitle();
workTitle2.setTitle(new Title("New Title"));
workTitle2.setSubtitle(new Subtitle("Another New subtitle"));
OrcidWork work2 = createWork2(workTitle2);
orcidWorks.getOrcidWork().add(work2);
// Try to add a duplicate
WorkTitle workTitle3 = new WorkTitle();
workTitle3.setTitle(new Title("Further Title"));
workTitle3.setSubtitle(new Subtitle("Further subtitle"));
OrcidWork work3 = createWork3(workTitle3);
work3.setVisibility(Visibility.LIMITED);
orcidWorks.getOrcidWork().add(work3);
orcidProfileManager.addOrcidWorks(profile2);
OrcidProfile resultProfile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
assertEquals("Will", resultProfile.getOrcidBio().getPersonalDetails().getGivenNames().getContent());
List<OrcidWork> works = resultProfile.retrieveOrcidWorks().getOrcidWork();
assertEquals(4, works.size());
assertEquals("Another Title", works.get(0).getWorkTitle().getTitle().getContent());
assertEquals("Journal of Cloud Spotting", works.get(0).getWorkTitle().getSubtitle().getContent());
for (OrcidWork work : works) {
if ("Test Title".equals(work.getWorkTitle().getTitle().getContent()))
assertEquals(Visibility.PRIVATE, work.getVisibility());
else
assertEquals(Visibility.PUBLIC, work.getVisibility());
}
}
Aggregations