use of org.orcid.pojo.ajaxForm.Contributor in project ORCID-Source by ORCID.
the class WorksControllerTest method testGetWorkInfoWithContributors.
@Test
public void testGetWorkInfoWithContributors() throws Exception {
WorkForm work = worksController.getWorkInfo(Long.valueOf("5"));
assertNotNull(work);
assertNotNull(work.getContributors());
assertEquals(4, work.getContributors().size());
Contributor contributor = work.getContributors().get(0);
assertNull(contributor.getEmail());
assertEquals("Jaylen Kessler", contributor.getCreditName().getValue());
contributor = work.getContributors().get(1);
assertNull(contributor.getEmail());
assertEquals("John Smith", contributor.getCreditName().getValue());
contributor = work.getContributors().get(2);
assertNull(contributor.getEmail());
assertEquals("Credit Name", contributor.getCreditName().getValue());
// contributor is an ORCID user with private name
contributor = work.getContributors().get(3);
assertNull(contributor.getEmail());
assertNull(contributor.getCreditName().getValue());
}
use of org.orcid.pojo.ajaxForm.Contributor in project ORCID-Source by ORCID.
the class FundingsController method getFunding.
/**
* Returns a blank funding form
* */
@RequestMapping(value = "/funding.json", method = RequestMethod.GET)
@ResponseBody
public FundingForm getFunding() {
FundingForm result = new FundingForm();
result.setAmount(new Text());
result.setCurrencyCode(Text.valueOf(""));
result.setDescription(new Text());
result.setFundingName(new Text());
result.setFundingType(Text.valueOf(""));
result.setSourceName(new String());
OrgDefinedFundingSubType subtype = new OrgDefinedFundingSubType();
subtype.setAlreadyIndexed(false);
subtype.setSubtype(Text.valueOf(""));
result.setOrganizationDefinedFundingSubType(subtype);
FundingTitleForm title = new FundingTitleForm();
title.setTitle(new Text());
TranslatedTitleForm tt = new TranslatedTitleForm();
tt.setContent(new String());
tt.setLanguageCode(new String());
tt.setLanguageName(new String());
title.setTranslatedTitle(tt);
result.setFundingTitle(title);
result.setUrl(new Text());
ProfileEntity profile = profileEntityCacheManager.retrieve(getEffectiveUserOrcid());
Visibility v = Visibility.valueOf(profile.getActivitiesVisibilityDefault() == null ? org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.FUNDING_DEFAULT.getVisibility().value()) : profile.getActivitiesVisibilityDefault());
result.setVisibility(v);
Date startDate = new Date();
result.setStartDate(startDate);
startDate.setDay("");
startDate.setMonth("");
startDate.setYear("");
Date endDate = new Date();
result.setEndDate(endDate);
endDate.setDay("");
endDate.setMonth("");
endDate.setYear("");
// Set empty contributor
Contributor contr = new Contributor();
List<Contributor> contrList = new ArrayList<Contributor>();
Text rText = new Text();
rText.setValue("");
contr.setContributorRole(rText);
Text sText = new Text();
sText.setValue("");
contr.setContributorSequence(sText);
contrList.add(contr);
result.setContributors(contrList);
// Set empty external identifier
List<FundingExternalIdentifierForm> emptyExternalIdentifiers = new ArrayList<FundingExternalIdentifierForm>();
FundingExternalIdentifierForm f = new FundingExternalIdentifierForm();
f.setType(Text.valueOf(DEFAULT_FUNDING_EXTERNAL_IDENTIFIER_TYPE));
f.setUrl(new Text());
f.setValue(new Text());
f.setRelationship(Text.valueOf(Relationship.SELF.value()));
emptyExternalIdentifiers.add(f);
result.setExternalIdentifiers(emptyExternalIdentifiers);
result.setCity(new Text());
result.setCountry(Text.valueOf(""));
result.setRegion(new Text());
return result;
}
use of org.orcid.pojo.ajaxForm.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, profileEntityManager.getLastModified(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.pojo.ajaxForm.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, profileEntManager.getLastModified(orcid));
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 = activityCacheManager.getPublicCreditName(profileEntity);
contributor.setCreditName(Text.valueOf(publicContributorCreditName));
}
}
}
}
return work;
}
return null;
}
Aggregations