use of org.orcid.pojo.ajaxForm.Visibility in project ORCID-Source by ORCID.
the class WorkspaceController method setOtherNamesFormJson.
@RequestMapping(value = "/my-orcid/otherNamesForms.json", method = RequestMethod.POST)
@ResponseBody
public OtherNamesForm setOtherNamesFormJson(@RequestBody OtherNamesForm onf) throws NoSuchRequestHandlingMethodException {
onf.setErrors(new ArrayList<String>());
ProfileEntity profile = profileEntityCacheManager.retrieve(getEffectiveUserOrcid());
Visibility defaultVisibility = Visibility.valueOf(profile.getActivitiesVisibilityDefault());
if (onf != null) {
Iterator<OtherNameForm> it = onf.getOtherNames().iterator();
while (it.hasNext()) {
OtherNameForm form = it.next();
if (PojoUtil.isEmpty(form.getContent())) {
it.remove();
continue;
}
if (form.getContent().length() > SiteConstants.MAX_LENGTH_255) {
form.setContent(form.getContent().substring(0, SiteConstants.MAX_LENGTH_255));
}
//Set default visibility in case it is null
if (form.getVisibility() == null || form.getVisibility().getVisibility() == null) {
form.setVisibility(defaultVisibility);
}
copyErrors(form, onf);
}
if (onf.getErrors().size() > 0) {
return onf;
}
OtherNames otherNames = onf.toOtherNames();
otherNameManager.updateOtherNames(getEffectiveUserOrcid(), otherNames);
}
return onf;
}
use of org.orcid.pojo.ajaxForm.Visibility 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.Visibility 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.Visibility in project ORCID-Source by ORCID.
the class WorkspaceController method setWebsitesFormJson.
/**
* Retrieve all external identifiers as a json string
* */
@RequestMapping(value = "/my-orcid/websitesForms.json", method = RequestMethod.POST)
@ResponseBody
public WebsitesForm setWebsitesFormJson(HttpServletRequest request, @RequestBody WebsitesForm ws) throws NoSuchRequestHandlingMethodException {
ws.setErrors(new ArrayList<String>());
ProfileEntity profile = profileEntityCacheManager.retrieve(getEffectiveUserOrcid());
Visibility defaultVisibility = Visibility.valueOf(profile.getActivitiesVisibilityDefault());
if (ws != null) {
Set<String> existingUrls = new HashSet<String>();
for (WebsiteForm w : ws.getWebsites()) {
//Clean old errors
w.setErrors(new ArrayList<String>());
//Validate
if (!validateUrl(w.getUrl())) {
w.getErrors().add(getMessage("common.invalid_url"));
}
if (isLongerThan(w.getUrlName(), SiteConstants.URL_MAX_LENGTH)) {
w.getErrors().add(getMessage("manualWork.length_less_X"));
}
//Check there are no duplicates
if (existingUrls.contains(w.getUrl())) {
w.getErrors().add(getMessage("researcher_url.error.duplicated", w.getUrl()));
} else {
existingUrls.add(w.getUrl());
}
//Set default visibility in case it is null
if (w.getVisibility() == null || w.getVisibility().getVisibility() == null) {
w.setVisibility(defaultVisibility);
}
copyErrors(w, ws);
}
if (ws.getErrors().size() > 0) {
return ws;
}
ResearcherUrls rUrls = ws.toResearcherUrls();
researcherUrlManager.updateResearcherUrls(getCurrentUserOrcid(), rUrls);
}
return ws;
}
use of org.orcid.pojo.ajaxForm.Visibility in project ORCID-Source by ORCID.
the class WorkspaceController method setKeywordsFormJson.
@RequestMapping(value = "/my-orcid/keywordsForms.json", method = RequestMethod.POST)
@ResponseBody
public KeywordsForm setKeywordsFormJson(HttpServletRequest request, @RequestBody KeywordsForm kf) throws NoSuchRequestHandlingMethodException {
kf.setErrors(new ArrayList<String>());
ProfileEntity profile = profileEntityCacheManager.retrieve(getEffectiveUserOrcid());
Visibility defaultVisibility = Visibility.valueOf(profile.getActivitiesVisibilityDefault());
if (kf != null) {
Iterator<KeywordForm> it = kf.getKeywords().iterator();
while (it.hasNext()) {
KeywordForm k = it.next();
if (!PojoUtil.isEmpty(k.getContent())) {
if (k.getContent().length() > SiteConstants.KEYWORD_MAX_LENGTH) {
k.setContent(k.getContent().substring(0, SiteConstants.KEYWORD_MAX_LENGTH));
}
} else {
it.remove();
}
//Set default visibility in case it is null
if (k.getVisibility() == null || k.getVisibility().getVisibility() == null) {
k.setVisibility(defaultVisibility);
}
copyErrors(k, kf);
}
if (kf.getErrors().size() > 0) {
return kf;
}
Keywords updatedKeywords = kf.toKeywords();
profileKeywordManager.updateKeywords(getCurrentUserOrcid(), updatedKeywords);
}
return kf;
}
Aggregations