Search in sources :

Example 1 with Visibility

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;
}
Also used : OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) Visibility(org.orcid.pojo.ajaxForm.Visibility) OtherNameForm(org.orcid.pojo.ajaxForm.OtherNameForm) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with Visibility

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;
}
Also used : FundingForm(org.orcid.pojo.ajaxForm.FundingForm) ArrayList(java.util.ArrayList) Contributor(org.orcid.pojo.ajaxForm.Contributor) Text(org.orcid.pojo.ajaxForm.Text) FundingTitleForm(org.orcid.pojo.ajaxForm.FundingTitleForm) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) Date(org.orcid.pojo.ajaxForm.Date) Visibility(org.orcid.pojo.ajaxForm.Visibility) FundingExternalIdentifierForm(org.orcid.pojo.ajaxForm.FundingExternalIdentifierForm) TranslatedTitleForm(org.orcid.pojo.ajaxForm.TranslatedTitleForm) OrgDefinedFundingSubType(org.orcid.pojo.ajaxForm.OrgDefinedFundingSubType) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with Visibility

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;
}
Also used : AffiliationForm(org.orcid.pojo.ajaxForm.AffiliationForm) Visibility(org.orcid.pojo.ajaxForm.Visibility) Text(org.orcid.pojo.ajaxForm.Text) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) Date(org.orcid.pojo.ajaxForm.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with Visibility

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;
}
Also used : WebsiteForm(org.orcid.pojo.ajaxForm.WebsiteForm) ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls) Visibility(org.orcid.pojo.ajaxForm.Visibility) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) HashSet(java.util.HashSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with Visibility

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;
}
Also used : KeywordForm(org.orcid.pojo.ajaxForm.KeywordForm) Keywords(org.orcid.jaxb.model.record_v2.Keywords) Visibility(org.orcid.pojo.ajaxForm.Visibility) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)5 Visibility (org.orcid.pojo.ajaxForm.Visibility)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)5 Date (org.orcid.pojo.ajaxForm.Date)2 Text (org.orcid.pojo.ajaxForm.Text)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Keywords (org.orcid.jaxb.model.record_v2.Keywords)1 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)1 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)1 AffiliationForm (org.orcid.pojo.ajaxForm.AffiliationForm)1 Contributor (org.orcid.pojo.ajaxForm.Contributor)1 FundingExternalIdentifierForm (org.orcid.pojo.ajaxForm.FundingExternalIdentifierForm)1 FundingForm (org.orcid.pojo.ajaxForm.FundingForm)1 FundingTitleForm (org.orcid.pojo.ajaxForm.FundingTitleForm)1 KeywordForm (org.orcid.pojo.ajaxForm.KeywordForm)1 OrgDefinedFundingSubType (org.orcid.pojo.ajaxForm.OrgDefinedFundingSubType)1 OtherNameForm (org.orcid.pojo.ajaxForm.OtherNameForm)1 TranslatedTitleForm (org.orcid.pojo.ajaxForm.TranslatedTitleForm)1