use of org.orcid.jaxb.model.common_v2.CreditName in project ORCID-Source by ORCID.
the class ValidateV2_1SamplesTest method unmarshallFromPath.
private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
Object obj = unmarshall(reader, type, schemaPath);
Object result = null;
if (ResearcherUrls.class.equals(type)) {
result = (ResearcherUrls) obj;
} else if (ResearcherUrl.class.equals(type)) {
result = (ResearcherUrl) obj;
} else if (PersonalDetails.class.equals(type)) {
result = (PersonalDetails) obj;
} else if (PersonExternalIdentifier.class.equals(type)) {
result = (PersonExternalIdentifier) obj;
} else if (PersonExternalIdentifiers.class.equals(type)) {
result = (PersonExternalIdentifiers) obj;
} else if (Biography.class.equals(type)) {
result = (Biography) obj;
} else if (Name.class.equals(type)) {
result = (Name) obj;
} else if (CreditName.class.equals(type)) {
result = (CreditName) obj;
} else if (OtherName.class.equals(type)) {
result = (OtherName) obj;
} else if (OtherNames.class.equals(type)) {
result = (OtherNames) obj;
} else if (Keywords.class.equals(type)) {
result = (Keywords) obj;
} else if (Keyword.class.equals(type)) {
result = (Keyword) obj;
} else if (Addresses.class.equals(type)) {
result = (Addresses) obj;
} else if (Address.class.equals(type)) {
result = (Address) obj;
} else if (Emails.class.equals(type)) {
result = (Emails) obj;
} else if (Email.class.equals(type)) {
result = (Email) obj;
} else if (Person.class.equals(type)) {
result = (Person) obj;
} else if (Deprecated.class.equals(type)) {
result = (Deprecated) obj;
} else if (Preferences.class.equals(type)) {
result = (Preferences) obj;
} else if (History.class.equals(type)) {
result = (History) obj;
} else if (Record.class.equals(type)) {
result = (Record) obj;
} else if (ActivitiesSummary.class.equals(type)) {
result = (ActivitiesSummary) obj;
} else if (Works.class.equals(type)) {
result = (Works) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
use of org.orcid.jaxb.model.common_v2.CreditName 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.common_v2.Visibility.LIMITED);
work.setWorkCitation(new org.orcid.jaxb.model.record_v2.Citation("Citation", CitationType.BIBTEX));
WorkContributors contributors = new WorkContributors();
org.orcid.jaxb.model.common_v2.Contributor contributor = new org.orcid.jaxb.model.common_v2.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.common_v2.CreditName 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_v2.CreditName in project ORCID-Source by ORCID.
the class OrcidSecurityManagerTestBase method createName.
protected Name createName(Visibility v) {
Name name = new Name();
name.setVisibility(v);
name.setCreditName(new CreditName("Credit Name"));
name.setFamilyName(new FamilyName("Family Name"));
name.setGivenNames(new GivenNames("Given Names"));
return name;
}
use of org.orcid.jaxb.model.common_v2.CreditName in project ORCID-Source by ORCID.
the class ValidateV2RC2SamplesTest method testUnmarshallCreditName.
@Test
public void testUnmarshallCreditName() throws SAXException, URISyntaxException {
CreditName creditName = (CreditName) unmarshallFromPath("/record_2.0_rc2/samples/credit-name-2.0_rc2.xml", CreditName.class, "/record_2.0_rc2/personal-details-2.0_rc2.xsd");
assertNotNull(creditName);
assertEquals("credit-name", creditName.getContent());
assertEquals(Visibility.PUBLIC.value(), creditName.getVisibility().value());
}
Aggregations