use of org.orcid.jaxb.model.common_rc1.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.common_rc1.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("http://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.common_rc1.Contributor in project ORCID-Source by ORCID.
the class ContributorUtilsTest method testFilterContributorPrivateDataForWorkWithInvalidOrcidRecord.
@Test
public void testFilterContributorPrivateDataForWorkWithInvalidOrcidRecord() {
when(profileEntityManager.orcidExists(anyString())).thenReturn(false);
Work work = getWorkWithOrcidContributor();
contributorUtils.filterContributorPrivateData(work);
Contributor contributor = work.getWorkContributors().getContributor().get(0);
assertNull(contributor.getContributorEmail());
assertEquals("original credit name", contributor.getCreditName().getContent());
}
use of org.orcid.jaxb.model.common_rc1.Contributor in project ORCID-Source by ORCID.
the class ContributorUtilsTest method getWorkContributorWithoutOrcid.
private WorkContributors getWorkContributorWithoutOrcid() {
Contributor contributor = new Contributor();
contributor.setContributorEmail(new ContributorEmail("never@show.this"));
contributor.setCreditName(new CreditName("original credit name"));
return new WorkContributors(Arrays.asList(contributor));
}
use of org.orcid.jaxb.model.common_rc1.Contributor in project ORCID-Source by ORCID.
the class ContributorUtilsTest method testFilterContributorPrivateDataForWorkWithPublicName.
@Test
public void testFilterContributorPrivateDataForWorkWithPublicName() {
when(profileEntityManager.orcidExists(anyString())).thenReturn(true);
when(profileEntityCacheManager.retrieve(anyString())).thenReturn(new ProfileEntity());
when(cacheManager.getPublicCreditName(any(ProfileEntity.class))).thenReturn("a public name");
Work work = getWorkWithOrcidContributor();
contributorUtils.filterContributorPrivateData(work);
Contributor contributor = work.getWorkContributors().getContributor().get(0);
assertNull(contributor.getContributorEmail());
assertEquals("a public name", contributor.getCreditName().getContent());
}
Aggregations