use of org.orcid.jaxb.model.v3.dev1.common.Contributor in project ORCID-Source by ORCID.
the class OrcidInfo method getWorkInfo.
/**
* Returns the work info for a given work id
*
* @param workId
* The id of the work
* @return the content of that work
*/
@RequestMapping(value = "/{orcid:(?:\\d{4}-){3,}\\d{3}[\\dX]}/getWorkInfo.json", method = RequestMethod.GET)
@ResponseBody
public WorkForm getWorkInfo(@PathVariable("orcid") String orcid, @RequestParam(value = "workId") Long workId) {
Map<String, String> languages = lm.buildLanguageMap(localeManager.getLocale(), false);
if (workId == null)
return null;
Work workObj = workManager.getWork(orcid, workId);
if (workObj != null) {
validateVisibility(workObj.getVisibility());
sourceUtils.setSourceName(workObj);
WorkForm work = WorkForm.valueOf(workObj);
// Set country name
if (!PojoUtil.isEmpty(work.getCountryCode())) {
Text countryName = Text.valueOf(retrieveIsoCountries().get(work.getCountryCode().getValue()));
work.setCountryName(countryName);
}
// Set language name
if (!PojoUtil.isEmpty(work.getLanguageCode())) {
Text languageName = Text.valueOf(languages.get(work.getLanguageCode().getValue()));
work.setLanguageName(languageName);
}
// Set translated title language name
if (work.getTranslatedTitle() != null && !StringUtils.isEmpty(work.getTranslatedTitle().getLanguageCode())) {
String languageName = languages.get(work.getTranslatedTitle().getLanguageCode());
work.getTranslatedTitle().setLanguageName(languageName);
}
if (work.getContributors() != null) {
for (Contributor contributor : work.getContributors()) {
if (!PojoUtil.isEmpty(contributor.getOrcid())) {
String contributorOrcid = contributor.getOrcid().getValue();
if (profileEntManager.orcidExists(contributorOrcid)) {
ProfileEntity profileEntity = profileEntityCacheManager.retrieve(contributorOrcid);
String publicContributorCreditName = activityManager.getPublicCreditName(profileEntity);
contributor.setCreditName(Text.valueOf(publicContributorCreditName));
}
}
}
}
return work;
}
return null;
}
use of org.orcid.jaxb.model.v3.dev1.common.Contributor in project ORCID-Source by ORCID.
the class FundingsController method createFundingIdList.
/**
* Create a funding id list and sorts a map associated with the list in in
* the session
*/
private List<String> createFundingIdList(HttpServletRequest request) {
Map<String, String> languages = lm.buildLanguageMap(getUserLocale(), false);
String orcid = getEffectiveUserOrcid();
List<Funding> fundings = profileFundingManager.getFundingList(orcid);
HashMap<String, FundingForm> fundingsMap = new HashMap<String, FundingForm>();
List<String> fundingIds = new ArrayList<String>();
if (fundings != null) {
for (Funding funding : fundings) {
try {
FundingForm form = FundingForm.valueOf(funding);
if (funding.getType() != null) {
form.setFundingTypeForDisplay(getMessage(buildInternationalizationKey(org.orcid.jaxb.model.message.FundingType.class, funding.getType().value())));
}
// Set translated title language name
if (!(funding.getTitle().getTranslatedTitle() == null) && !StringUtils.isEmpty(funding.getTitle().getTranslatedTitle().getLanguageCode())) {
String languageName = languages.get(funding.getTitle().getTranslatedTitle().getLanguageCode());
form.getFundingTitle().getTranslatedTitle().setLanguageName(languageName);
}
// Set the formatted amount
if (funding.getAmount() != null && StringUtils.isNotBlank(funding.getAmount().getContent())) {
BigDecimal bigDecimal = new BigDecimal(funding.getAmount().getContent());
String formattedAmount = formatAmountString(bigDecimal);
form.setAmount(Text.valueOf(formattedAmount));
}
if (form.getContributors() != null) {
for (Contributor contributor : form.getContributors()) {
if (!PojoUtil.isEmpty(contributor.getOrcid())) {
String contributorOrcid = contributor.getOrcid().getValue();
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);
contributor.setCreditName(Text.valueOf(publicContributorCreditName));
}
}
}
}
form.setCountryForDisplay(getMessage(buildInternationalizationKey(CountryIsoEntity.class, funding.getOrganization().getAddress().getCountry().name())));
String putCode = String.valueOf(funding.getPutCode());
fundingsMap.put(putCode, form);
fundingIds.add(putCode);
} catch (Exception e) {
LOGGER.error("Failed to parse as Funding. Put code" + funding.getPutCode(), e);
}
}
request.getSession().setAttribute(GRANT_MAP, fundingsMap);
}
return fundingIds;
}
use of org.orcid.jaxb.model.v3.dev1.common.Contributor in project ORCID-Source by ORCID.
the class ActivityValidatorTest method getFunding.
public Funding getFunding() {
Funding funding = new Funding();
Amount amount = new Amount();
amount.setContent("1000");
amount.setCurrencyCode("$");
funding.setAmount(amount);
FundingContributor contributor = new FundingContributor();
FundingContributorAttributes attributes = new FundingContributorAttributes();
attributes.setContributorRole(FundingContributorRole.LEAD);
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.setContributorAttributes(attributes);
contributor.setContributorOrcid(contributorOrcid);
FundingContributors contributors = new FundingContributors();
contributors.getContributor().add(contributor);
funding.setContributors(contributors);
funding.setDescription("description");
funding.setEndDate(getFuzzyDate());
funding.setExternalIdentifiers(getExternalIDs());
funding.setOrganization(getOrganization());
funding.setOrganizationDefinedType(new OrganizationDefinedFundingSubType("subtype"));
funding.setStartDate(getFuzzyDate());
FundingTitle title = new FundingTitle();
title.setTitle(new Title("title"));
title.setTranslatedTitle(new TranslatedTitle("translated title", "en"));
funding.setTitle(title);
funding.setType(FundingType.AWARD);
funding.setUrl(new Url("http://test.orcid.org"));
funding.setVisibility(Visibility.PUBLIC);
return funding;
}
use of org.orcid.jaxb.model.v3.dev1.common.Contributor in project ORCID-Source by ORCID.
the class V3WorkToCiteprocTranslator method translateFromWorkMetadata.
/**
* Use the ORCID work metadata to generate a *limited* citation. You'll most
* likely get a title, doi, url, date and author.
*
* Translates type according to https://docs.google.com/spreadsheets/d/
* 1h4nTF6DKNEpWcGNQVMDwt0ea09qmkBnkWisxkJE-li4/edit#gid=754644608
*
* Informed by mendley tranforms at
* http://support.mendeley.com/customer/portal/articles/364144-csl-type-
* mapping
*
* See also:
* http://docs.citationstyles.org/en/stable/specification.html#appendix-iii-
* types http://members.orcid.org/api/supported-work-types datacite and
* crossref mappings here:
* https://github.com/lagotto/lagotto/blob/master/config/initializers/
* constants.rb
* @param creditName
*
* @param worktype
* @return a CSLItemData, default CSLType.ARTICLE if cannot map type
*/
private CSLItemData translateFromWorkMetadata(Work work, String creditName) {
CSLItemDataBuilder builder = new CSLItemDataBuilder();
builder.title((work.getWorkTitle() != null) ? StringUtils.stripAccents(work.getWorkTitle().getTitle().getContent()) : "No Title");
String doi = extractID(work, WorkExternalIdentifierType.DOI);
String url = extractID(work, WorkExternalIdentifierType.URI);
if (doi != null) {
builder.DOI(doi);
}
if (url != null) {
builder.URL(url);
} else if (doi != null) {
builder.URL("http://doi.org/" + doi);
} else {
url = extractID(work, WorkExternalIdentifierType.HANDLE);
if (url != null) {
builder.URL(url);
}
}
if (work.getJournalTitle() != null) {
builder.containerTitle(StringUtils.stripAccents(work.getJournalTitle().getContent()));
}
List<String> names = new ArrayList<String>();
// TODO: Pass in credit name
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(StringUtils.stripAccents(c.getCreditName().getContent()));
}
}
}
CSLNameBuilder name = new CSLNameBuilder();
name.literal(Joiner.on(" and ").skipNulls().join(names));
builder.author(name.build());
// TODO: make it work with "Spring", "August", whatever...
if (work.getPublicationDate() != null) {
int year = 0;
int month = 0;
int day = 0;
try {
year = Integer.parseInt(work.getPublicationDate().getYear().getValue());
month = Integer.parseInt(work.getPublicationDate().getMonth().getValue());
day = Integer.parseInt(work.getPublicationDate().getDay().getValue());
} catch (Exception e) {
}
if (year > 0 && month > 0 && day > 0) {
builder.issued(year, month, day);
} else if (year > 0 && month > 0) {
builder.issued(year, month);
} else if (year > 0) {
builder.issued(year);
}
}
switch(work.getWorkType()) {
case ARTISTIC_PERFORMANCE:
break;
case BOOK:
builder.type(CSLType.BOOK);
break;
case BOOK_CHAPTER:
builder.type(CSLType.CHAPTER);
break;
case BOOK_REVIEW:
builder.type(CSLType.REVIEW_BOOK);
break;
case CONFERENCE_ABSTRACT:
builder.type(CSLType.PAPER_CONFERENCE);
break;
case CONFERENCE_PAPER:
builder.type(CSLType.PAPER_CONFERENCE);
break;
case CONFERENCE_POSTER:
builder.type(CSLType.PAPER_CONFERENCE);
break;
case DATA_SET:
builder.type(CSLType.DATASET);
break;
case DICTIONARY_ENTRY:
builder.type(CSLType.ENTRY_DICTIONARY);
break;
case DISSERTATION:
builder.type(CSLType.THESIS);
break;
case ENCYCLOPEDIA_ENTRY:
builder.type(CSLType.ENTRY_ENCYCLOPEDIA);
break;
case JOURNAL_ARTICLE:
builder.type(CSLType.ARTICLE_JOURNAL);
break;
case MAGAZINE_ARTICLE:
builder.type(CSLType.ARTICLE_MAGAZINE);
break;
case NEWSLETTER_ARTICLE:
builder.type(CSLType.ARTICLE_NEWSPAPER);
break;
case NEWSPAPER_ARTICLE:
builder.type(CSLType.ARTICLE_NEWSPAPER);
break;
case ONLINE_RESOURCE:
builder.type(CSLType.WEBPAGE);
break;
case REPORT:
builder.type(CSLType.REPORT);
break;
case WEBSITE:
builder.type(CSLType.WEBPAGE);
break;
case WORKING_PAPER:
builder.type(CSLType.ARTICLE);
break;
case DISCLOSURE:
case EDITED_BOOK:
case INVENTION:
case JOURNAL_ISSUE:
case LECTURE_SPEECH:
case LICENSE:
case MANUAL:
case OTHER:
case PATENT:
case REGISTERED_COPYRIGHT:
case RESEARCH_TECHNIQUE:
case RESEARCH_TOOL:
case SPIN_OFF_COMPANY:
case STANDARDS_AND_POLICY:
case SUPERVISED_STUDENT_PUBLICATION:
case TECHNICAL_STANDARD:
case TEST:
case TRADEMARK:
case TRANSLATION:
case UNDEFINED:
default:
// builder.type(CSLType.ARTICLE);
break;
}
return builder.build();
}
Aggregations