Search in sources :

Example 16 with Text

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;
}
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 17 with Text

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;
}
Also used : OauthAuthorizeForm(org.orcid.pojo.ajaxForm.OauthAuthorizeForm) RequestInfoForm(org.orcid.pojo.ajaxForm.RequestInfoForm) Text(org.orcid.pojo.ajaxForm.Text) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 18 with Text

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;
}
Also used : OauthRegistrationForm(org.orcid.pojo.ajaxForm.OauthRegistrationForm) Text(org.orcid.pojo.ajaxForm.Text) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 19 with Text

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

Example 20 with Text

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;
}
Also used : WorkForm(org.orcid.pojo.ajaxForm.WorkForm) ArrayList(java.util.ArrayList) Text(org.orcid.pojo.ajaxForm.Text) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Text (org.orcid.pojo.ajaxForm.Text)24 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)15 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)15 ArrayList (java.util.ArrayList)8 RedirectUri (org.orcid.pojo.ajaxForm.RedirectUri)8 Test (org.junit.Test)6 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)5 Contributor (org.orcid.pojo.ajaxForm.Contributor)4 WorkForm (org.orcid.pojo.ajaxForm.WorkForm)4 HashSet (java.util.HashSet)3 BaseControllerTest (org.orcid.frontend.web.util.BaseControllerTest)3 SSOCredentials (org.orcid.pojo.ajaxForm.SSOCredentials)3 Locale (java.util.Locale)2 HttpSession (javax.servlet.http.HttpSession)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Visibility (org.orcid.jaxb.model.common_v2.Visibility)2 Work (org.orcid.jaxb.model.record_v2.Work)2 Checkbox (org.orcid.pojo.ajaxForm.Checkbox)2 Client (org.orcid.pojo.ajaxForm.Client)2 Date (org.orcid.pojo.ajaxForm.Date)2