Search in sources :

Example 6 with Text

use of org.orcid.pojo.ajaxForm.Text in project ORCID-Source by ORCID.

the class GroupAdministratorController method getEmptyRedirectUri.

@RequestMapping(value = "/get-empty-redirect-uri.json", method = RequestMethod.GET)
@ResponseBody
public RedirectUri getEmptyRedirectUri(HttpServletRequest request) {
    RedirectUri result = new RedirectUri();
    result.setValue(new Text());
    result.setType(Text.valueOf(RedirectUriType.DEFAULT.value()));
    result.setActType(Text.valueOf(""));
    result.setGeoArea(Text.valueOf(""));
    return result;
}
Also used : RedirectUri(org.orcid.pojo.ajaxForm.RedirectUri) Text(org.orcid.pojo.ajaxForm.Text) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with Text

use of org.orcid.pojo.ajaxForm.Text in project ORCID-Source by ORCID.

the class DeveloperToolsController method getEmptyRedirectUri.

@RequestMapping(value = "/get-empty-redirect-uri.json", method = RequestMethod.GET)
@ResponseBody
public RedirectUri getEmptyRedirectUri(HttpServletRequest request) {
    RedirectUri result = new RedirectUri();
    result.setValue(new Text());
    result.setActType(Text.valueOf(""));
    result.setGeoArea(Text.valueOf(""));
    result.setType(Text.valueOf(RedirectUriType.DEFAULT.name()));
    return result;
}
Also used : RedirectUri(org.orcid.pojo.ajaxForm.RedirectUri) Text(org.orcid.pojo.ajaxForm.Text) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 8 with Text

use of org.orcid.pojo.ajaxForm.Text in project ORCID-Source by ORCID.

the class WorksController method getWorkInfo.

/**
     * Returns a blank work
     */
@RequestMapping(value = "/getWorkInfo.json", method = RequestMethod.GET)
@ResponseBody
public WorkForm getWorkInfo(@RequestParam(value = "workId") Long workId) {
    Map<String, String> countries = retrieveIsoCountries();
    Map<String, String> languages = lm.buildLanguageMap(localeManager.getLocale(), false);
    if (workId == null)
        return null;
    long lastModifiedTime = profileEntityManager.getLastModified(getEffectiveUserOrcid());
    Work work = workManager.getWork(this.getEffectiveUserOrcid(), workId, lastModifiedTime);
    if (work != null) {
        WorkForm workForm = WorkForm.valueOf(work);
        if (workForm.getPublicationDate() == null) {
            initializePublicationDate(workForm);
        } else {
            if (workForm.getPublicationDate().getDay() == null) {
                workForm.getPublicationDate().setDay(new String());
            }
            if (workForm.getPublicationDate().getMonth() == null) {
                workForm.getPublicationDate().setMonth(new String());
            }
            if (workForm.getPublicationDate().getYear() == null) {
                workForm.getPublicationDate().setYear(new String());
            }
        }
        // Set country name
        if (!PojoUtil.isEmpty(workForm.getCountryCode())) {
            Text countryName = Text.valueOf(countries.get(workForm.getCountryCode().getValue()));
            workForm.setCountryName(countryName);
        }
        // Set language name
        if (!PojoUtil.isEmpty(workForm.getLanguageCode())) {
            Text languageName = Text.valueOf(languages.get(workForm.getLanguageCode().getValue()));
            workForm.setLanguageName(languageName);
        }
        // Set translated title language name
        if (!(workForm.getTranslatedTitle() == null) && !StringUtils.isEmpty(workForm.getTranslatedTitle().getLanguageCode())) {
            String languageName = languages.get(workForm.getTranslatedTitle().getLanguageCode());
            workForm.getTranslatedTitle().setLanguageName(languageName);
        }
        if (workForm.getContributors() != null) {
            for (Contributor contributor : workForm.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));
                    }
                }
            }
        }
        return workForm;
    }
    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 9 with Text

use of org.orcid.pojo.ajaxForm.Text in project ORCID-Source by ORCID.

the class WorksController method workWorkExternalIdentifiersValidate.

@RequestMapping(value = "/work/workExternalIdentifiersValidate.json", method = RequestMethod.POST)
@ResponseBody
public WorkForm workWorkExternalIdentifiersValidate(@RequestBody WorkForm work) {
    for (WorkExternalIdentifier wId : work.getWorkExternalIdentifiers()) {
        if (wId.getWorkExternalIdentifierId() == null)
            wId.setWorkExternalIdentifierId(new Text());
        if (wId.getWorkExternalIdentifierType() == null)
            wId.setWorkExternalIdentifierType(new Text());
        wId.getWorkExternalIdentifierId().setErrors(new ArrayList<String>());
        wId.getWorkExternalIdentifierType().setErrors(new ArrayList<String>());
        // if has id type must be specified
        if (wId.getWorkExternalIdentifierId().getValue() != null && !wId.getWorkExternalIdentifierId().getValue().trim().equals("") && (wId.getWorkExternalIdentifierType().getValue() == null || wId.getWorkExternalIdentifierType().getValue().equals(""))) {
            setError(wId.getWorkExternalIdentifierType(), "NotBlank.currentWorkExternalIds.idType");
        } else if (wId.getWorkExternalIdentifierId().getValue() != null && wId.getWorkExternalIdentifierId().getValue().length() > 2084) {
            setError(wId.getWorkExternalIdentifierId(), "manualWork.length_less_2084");
        }
        // if type is set a id must set
        if (wId.getWorkExternalIdentifierType().getValue() != null && !wId.getWorkExternalIdentifierType().getValue().trim().equals("") && (wId.getWorkExternalIdentifierId().getValue() == null || wId.getWorkExternalIdentifierId().getValue().trim().equals(""))) {
            setError(wId.getWorkExternalIdentifierId(), "NotBlank.currentWorkExternalIds.id");
        }
        Map<String, IdentifierType> types = identifierTypeManager.fetchIdentifierTypesByAPITypeName(getLocale());
        if (wId.getWorkExternalIdentifierType().getValue() != null && !wId.getWorkExternalIdentifierType().getValue().trim().isEmpty() && !types.keySet().contains(wId.getWorkExternalIdentifierType().getValue())) {
            setError(wId.getWorkExternalIdentifierType(), "manualWork.id_invalid");
        }
    }
    return work;
}
Also used : Text(org.orcid.pojo.ajaxForm.Text) WorkExternalIdentifier(org.orcid.pojo.ajaxForm.WorkExternalIdentifier) IdentifierType(org.orcid.pojo.IdentifierType) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 10 with Text

use of org.orcid.pojo.ajaxForm.Text in project ORCID-Source by ORCID.

the class WorksController method initializeFields.

private void initializeFields(WorkForm w) {
    if (w.getVisibility() == null) {
        ProfileEntity profile = profileEntityCacheManager.retrieve(getEffectiveUserOrcid());
        Visibility v = profile.getActivitiesVisibilityDefault() == null ? Visibility.fromValue(OrcidVisibilityDefaults.WORKS_DEFAULT.getVisibility().value()) : profile.getActivitiesVisibilityDefault();
        w.setVisibility(v);
    }
    if (w.getTitle() == null) {
        w.setTitle(new Text());
    }
    if (w.getSubtitle() == null) {
        w.setSubtitle(new Text());
    }
    if (w.getTranslatedTitle() == null) {
        TranslatedTitleForm tt = new TranslatedTitleForm();
        tt.setContent(new String());
        tt.setLanguageCode(new String());
        tt.setLanguageName(new String());
        w.setTranslatedTitle(tt);
    }
    if (PojoUtil.isEmpty(w.getJournalTitle())) {
        Text jt = new Text();
        jt.setRequired(false);
        w.setJournalTitle(jt);
    }
    if (PojoUtil.isEmpty(w.getWorkCategory())) {
        Text wCategoryText = new Text();
        wCategoryText.setValue(new String());
        wCategoryText.setRequired(true);
        w.setWorkCategory(wCategoryText);
    }
    if (PojoUtil.isEmpty(w.getWorkType())) {
        Text wTypeText = new Text();
        wTypeText.setValue(new String());
        wTypeText.setRequired(true);
        w.setWorkType(wTypeText);
    }
    initializePublicationDate(w);
    if (w.getWorkExternalIdentifiers() == null || w.getWorkExternalIdentifiers().isEmpty()) {
        WorkExternalIdentifier wei = new WorkExternalIdentifier();
        Text wdiType = new Text();
        wdiType.setValue(new String());
        wei.setWorkExternalIdentifierId(new Text());
        wei.setWorkExternalIdentifierType(wdiType);
        wei.setRelationship(Text.valueOf(Relationship.SELF.value()));
        List<WorkExternalIdentifier> wdiL = new ArrayList<WorkExternalIdentifier>();
        wdiL.add(wei);
        w.setWorkExternalIdentifiers(wdiL);
    }
    if (PojoUtil.isEmpty(w.getUrl())) {
        w.setUrl(new Text());
    }
    if (w.getContributors() == null || w.getContributors().isEmpty()) {
        List<Contributor> contrList = new ArrayList<Contributor>();
        w.setContributors(contrList);
    }
    if (PojoUtil.isEmpty(w.getShortDescription())) {
        w.setShortDescription(new Text());
    }
    if (PojoUtil.isEmpty(w.getLanguageCode())) {
        Text lc = new Text();
        lc.setRequired(false);
        w.setLanguageCode(lc);
    }
    if (PojoUtil.isEmpty(w.getLanguageName())) {
        Text ln = new Text();
        ln.setRequired(false);
        w.setLanguageName(ln);
    }
    if (PojoUtil.isEmpty(w.getCountryCode())) {
        w.setCountryCode(new Text());
    }
    if (PojoUtil.isEmpty(w.getCountryName())) {
        w.setCountryName(new Text());
    }
}
Also used : ArrayList(java.util.ArrayList) Contributor(org.orcid.pojo.ajaxForm.Contributor) Visibility(org.orcid.jaxb.model.common_v2.Visibility) Text(org.orcid.pojo.ajaxForm.Text) WorkExternalIdentifier(org.orcid.pojo.ajaxForm.WorkExternalIdentifier) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) TranslatedTitleForm(org.orcid.pojo.ajaxForm.TranslatedTitleForm)

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