Search in sources :

Example 1 with Visibility

use of org.orcid.jaxb.model.v3.dev1.common.Visibility in project ORCID-Source by ORCID.

the class ManageProfileController method setProfileCountryJson.

@RequestMapping(value = "/countryForm.json", method = RequestMethod.POST)
@ResponseBody
public AddressesForm setProfileCountryJson(HttpServletRequest request, @RequestBody AddressesForm addressesForm) throws NoSuchRequestHandlingMethodException {
    addressesForm.setErrors(new ArrayList<String>());
    Map<String, String> countries = retrieveIsoCountries();
    if (addressesForm != null) {
        if (addressesForm.getAddresses() != null) {
            for (AddressForm form : addressesForm.getAddresses()) {
                if (form.getIso2Country() == null || form.getIso2Country().getValue() == null) {
                    form.getErrors().add(getMessage("common.invalid_country"));
                } else {
                    form.setCountryName(countries.get(form.getIso2Country().getValue().name()));
                }
                // Validate visibility is not null
                validateVisibility(form);
                copyErrors(form, addressesForm);
                copyErrors(form.getVisibility(), addressesForm);
            }
        }
        if (!addressesForm.getErrors().isEmpty()) {
            return addressesForm;
        }
        Addresses addresses = addressesForm.toAddresses();
        addressManager.updateAddresses(getCurrentUserOrcid(), addresses);
    }
    return addressesForm;
}
Also used : Addresses(org.orcid.jaxb.model.v3.dev1.record.Addresses) AddressForm(org.orcid.pojo.ajaxForm.AddressForm) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with Visibility

use of org.orcid.jaxb.model.v3.dev1.common.Visibility in project ORCID-Source by ORCID.

the class ManageProfileController method setNameFormJson.

@RequestMapping(value = "/nameForm.json", method = RequestMethod.POST)
@ResponseBody
public NamesForm setNameFormJson(@RequestBody NamesForm nf) throws NoSuchRequestHandlingMethodException {
    nf.setErrors(new ArrayList<String>());
    // Strip any html code from names before validating them
    if (!PojoUtil.isEmpty(nf.getFamilyName())) {
        nf.getFamilyName().setValue(OrcidStringUtils.stripHtml(nf.getFamilyName().getValue()));
    }
    if (!PojoUtil.isEmpty(nf.getGivenNames())) {
        nf.getGivenNames().setValue(OrcidStringUtils.stripHtml(nf.getGivenNames().getValue()));
    }
    if (!PojoUtil.isEmpty(nf.getCreditName())) {
        nf.getCreditName().setValue(OrcidStringUtils.stripHtml(nf.getCreditName().getValue()));
    }
    // Validate visibility is not null
    validateVisibility(nf);
    if (nf.getGivenNames() == null)
        nf.setGivenNames(new Text());
    givenNameValidate(nf.getGivenNames());
    copyErrors(nf.getGivenNames(), nf);
    copyErrors(nf.getVisibility(), nf);
    if (nf.getErrors().size() > 0)
        return nf;
    Name name = nf.toName();
    String orcid = getCurrentUserOrcid();
    if (recordNameManager.exists(orcid)) {
        recordNameManager.updateRecordName(orcid, name);
    } else {
        recordNameManager.createRecordName(orcid, name);
    }
    return nf;
}
Also used : Text(org.orcid.pojo.ajaxForm.Text) Name(org.orcid.jaxb.model.v3.dev1.record.Name) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with Visibility

use of org.orcid.jaxb.model.v3.dev1.common.Visibility in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV3Test method getFundings.

private Fundings getFundings(Visibility... vs) {
    Fundings fundings = new Fundings();
    for (Visibility v : vs) {
        FundingGroup g = new FundingGroup();
        FundingSummary s = new FundingSummary();
        s.setVisibility(v);
        g.getFundingSummary().add(s);
        fundings.getFundingGroup().add(g);
    }
    return fundings;
}
Also used : Fundings(org.orcid.jaxb.model.v3.dev1.record.summary.Fundings) FundingSummary(org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary) Visibility(org.orcid.jaxb.model.v3.dev1.common.Visibility) FundingGroup(org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup)

Example 4 with Visibility

use of org.orcid.jaxb.model.v3.dev1.common.Visibility in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV3Test method getPeerReviews.

private PeerReviews getPeerReviews(Visibility... vs) {
    PeerReviews peerReviews = new PeerReviews();
    for (Visibility v : vs) {
        PeerReviewGroup g = new PeerReviewGroup();
        PeerReviewSummary s = new PeerReviewSummary();
        s.setVisibility(v);
        g.getPeerReviewSummary().add(s);
        peerReviews.getPeerReviewGroup().add(g);
    }
    return peerReviews;
}
Also used : PeerReviewGroup(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup) PeerReviewSummary(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary) PeerReviews(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviews) Visibility(org.orcid.jaxb.model.v3.dev1.common.Visibility)

Example 5 with Visibility

use of org.orcid.jaxb.model.v3.dev1.common.Visibility in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV3Test method getWorks.

private Works getWorks(Visibility... vs) {
    Works works = new Works();
    for (Visibility v : vs) {
        WorkGroup g = new WorkGroup();
        WorkSummary s = new WorkSummary();
        s.setVisibility(v);
        g.getWorkSummary().add(s);
        works.getWorkGroup().add(g);
    }
    return works;
}
Also used : WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) Visibility(org.orcid.jaxb.model.v3.dev1.common.Visibility) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works)

Aggregations

Visibility (org.orcid.jaxb.model.v3.dev1.common.Visibility)44 ClientResponse (com.sun.jersey.api.client.ClientResponse)17 Test (org.junit.Test)17 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)14 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)12 Url (org.orcid.jaxb.model.v3.dev1.common.Url)11 OrcidError (org.orcid.jaxb.model.v3.dev1.error.OrcidError)11 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)11 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)11 HashMap (java.util.HashMap)10 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)10 Name (org.orcid.jaxb.model.v3.dev1.record.Name)7 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)7 Organization (org.orcid.jaxb.model.v3.dev1.common.Organization)6 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)6 Work (org.orcid.jaxb.model.v3.dev1.record.Work)6 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)6 Date (java.util.Date)5 OrcidDuplicatedElementException (org.orcid.core.exception.OrcidDuplicatedElementException)5