Search in sources :

Example 11 with Text

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

the class GroupAdministratorController method getClient.

@RequestMapping(value = "/client.json", method = RequestMethod.GET)
@ResponseBody
public Client getClient() {
    Client emptyClient = new Client();
    emptyClient.setDisplayName(new Text());
    emptyClient.setWebsite(new Text());
    emptyClient.setShortDescription(new Text());
    emptyClient.setClientId(new Text());
    emptyClient.setClientSecret(new Text());
    emptyClient.setType(new Text());
    emptyClient.setAllowAutoDeprecate(Checkbox.valueOf(false));
    ArrayList<RedirectUri> redirectUris = new ArrayList<RedirectUri>();
    RedirectUri emptyRedirectUri = new RedirectUri();
    emptyRedirectUri.setValue(new Text());
    emptyRedirectUri.setType(Text.valueOf(RedirectUriType.DEFAULT.value()));
    emptyRedirectUri.setActType(Text.valueOf(""));
    emptyRedirectUri.setGeoArea(Text.valueOf(""));
    redirectUris.add(emptyRedirectUri);
    emptyClient.setRedirectUris(redirectUris);
    return emptyClient;
}
Also used : ArrayList(java.util.ArrayList) Text(org.orcid.pojo.ajaxForm.Text) RedirectUri(org.orcid.pojo.ajaxForm.RedirectUri) OrcidClient(org.orcid.jaxb.model.clientgroup.OrcidClient) Client(org.orcid.pojo.ajaxForm.Client) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 12 with Text

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

the class ResultContainer method getEmptyGroup.

/**
     * Get an empty group
     * 
     * @return an empty group
     * */
@RequestMapping(value = "/member.json", method = RequestMethod.GET)
@ResponseBody
public Member getEmptyGroup() {
    Text empty = Text.valueOf("");
    Member group = new Member();
    group.setEmail(empty);
    group.setGroupName(empty);
    group.setGroupOrcid(empty);
    group.setSalesforceId(empty);
    // Set the default type as basic
    group.setType(Text.valueOf(MemberType.BASIC.value()));
    return group;
}
Also used : Text(org.orcid.pojo.ajaxForm.Text) Member(org.orcid.pojo.ajaxForm.Member) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 13 with Text

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

the class WorkspaceControllerTest method validateSmallerThanTest.

@Test
public void validateSmallerThanTest() {
    Text text = new Text();
    workspaceController.validateNoLongerThan(10, text);
    assertTrue(text.getErrors().isEmpty());
    text.setValue(tenCharsStr);
    workspaceController.validateNoLongerThan(10, text);
    assertTrue(text.getErrors().isEmpty());
    text.setValue(tenCharsStr + '!');
    workspaceController.validateNoLongerThan(10, text);
    assertEquals(workspaceController.getMessage("manualWork.length_less_X", 10), text.getErrors().get(0));
    text.setValue(tenCharsStr);
    text.setErrors(new ArrayList<String>());
    workspaceController.validateNoLongerThan(10, text);
    assertTrue(text.getErrors().isEmpty());
}
Also used : Text(org.orcid.pojo.ajaxForm.Text) Test(org.junit.Test)

Example 14 with Text

use of org.orcid.pojo.ajaxForm.Text 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 15 with Text

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

the class DeveloperToolsController method validateSSOCredentials.

/**
     * Validates the ssoCredentials object
     * 
     * @param ssoCredentials
     * @return true if any error is found in the ssoCredentials object
     * */
private boolean validateSSOCredentials(SSOCredentials ssoCredentials) {
    boolean hasErrors = false;
    Set<RedirectUri> redirectUris = ssoCredentials.getRedirectUris();
    if (PojoUtil.isEmpty(ssoCredentials.getClientName())) {
        if (ssoCredentials.getClientName() == null) {
            ssoCredentials.setClientName(new Text());
        }
        ssoCredentials.getClientName().setErrors(Arrays.asList(getMessage("manage.developer_tools.name_not_empty")));
        hasErrors = true;
    } else if (ssoCredentials.getClientName().getValue().length() > CLIENT_NAME_LENGTH) {
        ssoCredentials.getClientName().setErrors(Arrays.asList(getMessage("manage.developer_tools.name_too_long")));
        hasErrors = true;
    } else if (OrcidStringUtils.hasHtml(ssoCredentials.getClientName().getValue())) {
        ssoCredentials.getClientName().setErrors(Arrays.asList(getMessage("manage.developer_tools.name.html")));
        hasErrors = true;
    } else {
        ssoCredentials.getClientName().setErrors(new ArrayList<String>());
    }
    if (PojoUtil.isEmpty(ssoCredentials.getClientDescription())) {
        if (ssoCredentials.getClientDescription() == null) {
            ssoCredentials.setClientDescription(new Text());
        }
        ssoCredentials.getClientDescription().setErrors(Arrays.asList(getMessage("manage.developer_tools.description_not_empty")));
        hasErrors = true;
    } else if (OrcidStringUtils.hasHtml(ssoCredentials.getClientDescription().getValue())) {
        ssoCredentials.getClientDescription().setErrors(Arrays.asList(getMessage("manage.developer_tools.description.html")));
        hasErrors = true;
    } else {
        ssoCredentials.getClientDescription().setErrors(new ArrayList<String>());
    }
    if (PojoUtil.isEmpty(ssoCredentials.getClientWebsite())) {
        if (ssoCredentials.getClientWebsite() == null) {
            ssoCredentials.setClientWebsite(new Text());
        }
        ssoCredentials.getClientWebsite().setErrors(Arrays.asList(getMessage("manage.developer_tools.website_not_empty")));
        hasErrors = true;
    } else {
        List<String> errors = new ArrayList<String>();
        String[] schemes = { "http", "https", "ftp" };
        UrlValidator urlValidator = new UrlValidator(schemes);
        String websiteString = ssoCredentials.getClientWebsite().getValue();
        if (!urlValidator.isValid(websiteString))
            websiteString = "http://" + websiteString;
        // test validity again
        if (!urlValidator.isValid(websiteString)) {
            errors.add(getMessage("manage.developer_tools.invalid_website"));
        }
        ssoCredentials.getClientWebsite().setErrors(errors);
    }
    if (redirectUris == null || redirectUris.isEmpty()) {
        List<String> errors = new ArrayList<String>();
        errors.add(getMessage("manage.developer_tools.at_least_one"));
        ssoCredentials.setErrors(errors);
        hasErrors = true;
    } else {
        for (RedirectUri redirectUri : redirectUris) {
            List<String> errors = validateRedirectUri(redirectUri);
            if (errors != null) {
                redirectUri.setErrors(errors);
                hasErrors = true;
            }
        }
    }
    return hasErrors;
}
Also used : ArrayList(java.util.ArrayList) UrlValidator(org.apache.commons.validator.routines.UrlValidator) RedirectUri(org.orcid.pojo.ajaxForm.RedirectUri) Text(org.orcid.pojo.ajaxForm.Text)

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