use of org.orcid.jaxb.model.v3.dev1.common.Contributor 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.Contributor in project ORCID-Source by ORCID.
the class ActivityValidatorTest method getWork.
public Work getWork() {
Work work = new Work();
work.setCountry(new Country(Iso3166Country.US));
work.setJournalTitle(new Title("journal-title"));
work.setLanguageCode("en");
work.setPublicationDate(new PublicationDate(getFuzzyDate()));
work.setShortDescription("short-description");
work.setUrl(new Url("http://test.orcid.org"));
work.setVisibility(Visibility.PUBLIC);
work.setWorkCitation(new Citation("citation", CitationType.FORMATTED_HARVARD));
ContributorAttributes attributes = new ContributorAttributes();
attributes.setContributorRole(ContributorRole.ASSIGNEE);
attributes.setContributorSequence(SequenceType.FIRST);
ContributorOrcid contributorOrcid = new ContributorOrcid();
contributorOrcid.setHost("http://test.orcid.org");
contributorOrcid.setPath("0000-0000-0000-0000");
contributorOrcid.setUri("https://test.orcid.org/0000-0000-0000-0000");
Contributor contributor = new Contributor();
contributor.setContributorAttributes(attributes);
contributor.setContributorOrcid(contributorOrcid);
contributor.setCreditName(new CreditName("credit name"));
contributor.setContributorEmail(new ContributorEmail("email@test.orcid.org"));
WorkContributors contributors = new WorkContributors(Stream.of(contributor).collect(Collectors.toList()));
work.setWorkContributors(contributors);
work.setWorkExternalIdentifiers(getExternalIDs());
work.setWorkTitle(getWorkTitle());
work.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
return work;
}
use of org.orcid.jaxb.model.v3.dev1.common.Contributor in project ORCID-Source by ORCID.
the class BibtexManagerImpl method workToBibtex.
public String workToBibtex(Work work, String creditName) {
StringBuffer out = new StringBuffer();
switch(work.getWorkType()) {
case JOURNAL_ARTICLE:
out.append("@article{");
break;
case BOOK:
case BOOK_CHAPTER:
out.append("@book{");
break;
case CONFERENCE_PAPER:
case CONFERENCE_ABSTRACT:
case CONFERENCE_POSTER:
out.append("@conference{");
break;
default:
out.append("@misc{");
break;
}
// id
out.append(escapeStringForBibtex(creditName).replace(' ', '_') + work.getPutCode());
// title
out.append(",\ntitle={" + escapeStringForBibtex((work.getWorkTitle() != null) ? work.getWorkTitle().getTitle().getContent() : "No Title") + "}");
// journal title
if (work.getJournalTitle() != null) {
out.append(",\njournal={" + escapeStringForBibtex(work.getJournalTitle().getContent()) + "}");
}
// name
List<String> names = new ArrayList<String>();
names.add(creditName);
if (work.getWorkContributors() != null && work.getWorkContributors().getContributor() != null) {
for (Contributor c : work.getWorkContributors().getContributor()) {
if (c.getCreditName() != null && c.getCreditName().getContent() != null) {
names.add(c.getCreditName().getContent());
}
}
}
out.append(",\nauthor={" + escapeStringForBibtex(Joiner.on(" and ").skipNulls().join(names)) + "}");
// ids
String doi = extractID(work, WorkExternalIdentifierType.DOI);
String url = extractID(work, WorkExternalIdentifierType.URI);
if (doi != null) {
out.append(",\ndoi={" + escapeStringForBibtex(doi) + "}");
}
if (url != null) {
out.append(",\nurl={" + escapeStringForBibtex(url) + "}");
} else if (doi != null) {
out.append(",\nurl={" + escapeStringForBibtex("http://doi.org/" + doi) + "}");
} else {
url = extractID(work, WorkExternalIdentifierType.HANDLE);
if (url != null) {
out.append(",\nurl={" + escapeStringForBibtex(url) + "}");
}
}
String isbn = extractID(work, WorkExternalIdentifierType.ISBN);
if (isbn != null)
out.append(",\nisbn={" + escapeStringForBibtex(isbn) + "}");
String issn = extractID(work, WorkExternalIdentifierType.ISSN);
if (issn != null)
out.append(",\nissn={" + escapeStringForBibtex(issn) + "}");
// year
if (work.getPublicationDate() != null) {
int year = 0;
try {
year = Integer.parseInt(work.getPublicationDate().getYear().getValue());
} catch (Exception e) {
}
if (year > 0) {
out.append(",\nyear={" + year + "}");
}
}
out.append("\n}");
return out.toString();
}
use of org.orcid.jaxb.model.v3.dev1.common.Contributor in project ORCID-Source by ORCID.
the class ContributorUtils method filterContributorPrivateData.
public void filterContributorPrivateData(Funding funding) {
if (funding.getContributors() != null && funding.getContributors().getContributor() != null) {
for (FundingContributor contributor : funding.getContributors().getContributor()) {
contributor.setContributorEmail(null);
if (!PojoUtil.isEmpty(contributor.getContributorOrcid())) {
String contributorOrcid = contributor.getContributorOrcid().getPath();
if (profileEntityManager.orcidExists(contributorOrcid)) {
// contributor is an ORCID user - visibility of user's
// name in record must be taken into account
ProfileEntity profileEntity = profileEntityCacheManager.retrieve(contributorOrcid);
String publicContributorCreditName = cacheManager.getPublicCreditName(profileEntity);
CreditName creditName = new CreditName(publicContributorCreditName != null ? publicContributorCreditName : "");
contributor.setCreditName(creditName);
}
}
}
}
}
use of org.orcid.jaxb.model.v3.dev1.common.Contributor in project ORCID-Source by ORCID.
the class ContributorUtilsTest method testFilterContributorPrivateDataForFundingWithInvalidOrcidRecord.
@Test
public void testFilterContributorPrivateDataForFundingWithInvalidOrcidRecord() {
when(profileEntityManager.orcidExists(anyString())).thenReturn(false);
Funding funding = getFundingWithOrcidContributor();
contributorUtils.filterContributorPrivateData(funding);
FundingContributor contributor = funding.getContributors().getContributor().get(0);
assertNull(contributor.getContributorEmail());
assertEquals("original credit name", contributor.getCreditName().getContent());
}
Aggregations