use of org.orcid.pojo.ajaxForm.Text in project ORCID-Source by ORCID.
the class AffiliationsController method getAffiliation.
/**
* Returns a blank affiliation form
* */
@RequestMapping(value = "/affiliation.json", method = RequestMethod.GET)
@ResponseBody
public AffiliationForm getAffiliation(HttpServletRequest request) {
AffiliationForm affiliationForm = new AffiliationForm();
ProfileEntity profile = profileEntityCacheManager.retrieve(getCurrentUserOrcid());
Visibility v = Visibility.valueOf(profile.getActivitiesVisibilityDefault() == null ? org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.FUNDING_DEFAULT.getVisibility().value()) : profile.getActivitiesVisibilityDefault());
affiliationForm.setVisibility(v);
Text affiliationName = new Text();
affiliationForm.setAffiliationName(affiliationName);
affiliationName.setRequired(true);
Text city = new Text();
affiliationForm.setCity(city);
Text region = new Text();
affiliationForm.setRegion(region);
Text country = new Text();
affiliationForm.setCountry(country);
country.setValue("");
country.setRequired(true);
Text department = new Text();
affiliationForm.setDepartmentName(department);
Text roleTitle = new Text();
affiliationForm.setRoleTitle(roleTitle);
Text affiliationType = new Text();
affiliationForm.setAffiliationType(affiliationType);
affiliationType.setValue("");
Date startDate = new Date();
affiliationForm.setStartDate(startDate);
startDate.setDay("");
startDate.setMonth("");
startDate.setYear("");
Date endDate = new Date();
affiliationForm.setEndDate(endDate);
endDate.setDay("");
endDate.setMonth("");
endDate.setYear("");
affiliationForm.setOrgDisambiguatedId(new Text());
return affiliationForm;
}
use of org.orcid.pojo.ajaxForm.Text in project ORCID-Source by ORCID.
the class OauthGenericCallsController method getEmptyAuthorizeForm.
@RequestMapping(value = "/oauth/custom/authorize/empty.json", method = RequestMethod.GET)
@ResponseBody
public OauthAuthorizeForm getEmptyAuthorizeForm(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {
OauthAuthorizeForm empty = new OauthAuthorizeForm();
Text emptyText = Text.valueOf(StringUtils.EMPTY);
empty.setPassword(emptyText);
empty.setUserName(emptyText);
RequestInfoForm requestInfoForm = getRequestInfoForm(request);
if (requestInfoForm != null) {
if (!PojoUtil.isEmpty(requestInfoForm.getUserId())) {
empty.setUserName(Text.valueOf(requestInfoForm.getUserId()));
}
}
return empty;
}
use of org.orcid.pojo.ajaxForm.Text in project ORCID-Source by ORCID.
the class OauthRegistrationController method getRegister.
@RequestMapping(value = "/oauth/custom/register/empty.json", method = RequestMethod.GET)
@ResponseBody
public OauthRegistrationForm getRegister(HttpServletRequest request, HttpServletResponse response) {
// Remove the session hash if needed
if (request.getSession().getAttribute(RegistrationController.GRECAPTCHA_SESSION_ATTRIBUTE_NAME) != null) {
request.getSession().removeAttribute(RegistrationController.GRECAPTCHA_SESSION_ATTRIBUTE_NAME);
}
OauthRegistrationForm empty = new OauthRegistrationForm(registrationController.getRegister(request, response));
// Creation type in oauth will always be member referred
empty.setCreationType(Text.valueOf(CreationMethod.MEMBER_REFERRED.value()));
Text emptyText = Text.valueOf(StringUtils.EMPTY);
empty.setPassword(emptyText);
return empty;
}
use of org.orcid.pojo.ajaxForm.Text 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;
}
use of org.orcid.pojo.ajaxForm.Text in project ORCID-Source by ORCID.
the class OrcidInfo method getWorkJson.
@RequestMapping(value = "/{orcid:(?:\\d{4}-){3,}\\d{3}[\\dX]}/works.json")
@ResponseBody
public List<WorkForm> getWorkJson(HttpServletRequest request, @PathVariable("orcid") String orcid, @RequestParam(value = "workIds") String workIdsStr) {
Map<String, String> countries = retrieveIsoCountries();
Map<String, String> languages = lm.buildLanguageMap(localeManager.getLocale(), false);
HashMap<Long, WorkForm> minimizedWorksMap = activityCacheManager.pubMinWorksMap(orcid, getLastModifiedTime(orcid));
List<WorkForm> works = new ArrayList<WorkForm>();
String[] workIds = workIdsStr.split(",");
for (String workId : workIds) {
if (minimizedWorksMap.containsKey(Long.valueOf(workId))) {
WorkForm work = minimizedWorksMap.get(Long.valueOf(workId));
validateVisibility(work.getVisibility());
if (!PojoUtil.isEmpty(work.getCountryCode())) {
Text countryName = Text.valueOf(countries.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);
}
works.add(work);
}
}
return works;
}
Aggregations