Search in sources :

Example 11 with Visibility

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

the class PublicAPISecurityManagerV3Test method getVisibilityTypeElement.

private VisibilityType getVisibilityTypeElement(Visibility v) {
    EducationSummary s = new EducationSummary();
    s.setVisibility(v);
    return s;
}
Also used : EducationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)

Example 12 with Visibility

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

the class PublicAPISecurityManagerV3Test method getMemberships.

private Memberships getMemberships(Visibility... vs) {
    Memberships e = new Memberships();
    for (Visibility v : vs) {
        MembershipSummary s = new MembershipSummary();
        s.setVisibility(v);
        e.getSummaries().add(s);
    }
    return e;
}
Also used : Memberships(org.orcid.jaxb.model.v3.dev1.record.summary.Memberships) Visibility(org.orcid.jaxb.model.v3.dev1.common.Visibility) MembershipSummary(org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)

Example 13 with Visibility

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

the class PublicAPISecurityManagerV3Test method getPersonalDetailsElement.

private PersonalDetails getPersonalDetailsElement(Visibility nameVisibility, Visibility bioVisiblity, Visibility otherNamesVisibility) {
    PersonalDetails p = new PersonalDetails();
    Name name = new Name();
    name.setVisibility(nameVisibility);
    p.setName(name);
    Biography bio = new Biography();
    bio.setVisibility(bioVisiblity);
    bio.setContent("Bio test");
    p.setBiography(bio);
    p.setOtherNames(getOtherNamesElement(otherNamesVisibility));
    return p;
}
Also used : Biography(org.orcid.jaxb.model.v3.dev1.record.Biography) PersonalDetails(org.orcid.jaxb.model.v3.dev1.record.PersonalDetails) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) Name(org.orcid.jaxb.model.v3.dev1.record.Name)

Example 14 with Visibility

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

the class PublicAPISecurityManagerV3Test method getPersonExternalIdentifiersElement.

private PersonExternalIdentifiers getPersonExternalIdentifiersElement(Visibility... vs) {
    PersonExternalIdentifiers elements = new PersonExternalIdentifiers();
    for (Visibility v : vs) {
        PersonExternalIdentifier element = new PersonExternalIdentifier();
        element.setVisibility(v);
        if (elements.getExternalIdentifiers() == null) {
            elements.setExternalIdentifiers(new ArrayList<PersonExternalIdentifier>());
        }
        elements.getExternalIdentifiers().add(element);
    }
    return elements;
}
Also used : PersonExternalIdentifiers(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers) Visibility(org.orcid.jaxb.model.v3.dev1.common.Visibility) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)

Example 15 with Visibility

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

the class ActivityValidator method validateFunding.

public void validateFunding(Funding funding, SourceEntity sourceEntity, boolean createFlag, boolean isApiRequest, Visibility originalVisibility) {
    FundingTitle title = funding.getTitle();
    if (title == null || title.getTitle() == null || StringUtils.isEmpty(title.getTitle().getContent())) {
        throw new ActivityTitleValidationException();
    }
    // translated title language code
    if (title != null && title.getTranslatedTitle() != null && !PojoUtil.isEmpty(title.getTranslatedTitle().getContent())) {
        // If translated title language code is null or invalid
        if (PojoUtil.isEmpty(title.getTranslatedTitle().getLanguageCode()) || !Arrays.stream(SiteConstants.AVAILABLE_ISO_LANGUAGES).anyMatch(title.getTranslatedTitle().getLanguageCode()::equals)) {
            Map<String, String> params = new HashMap<String, String>();
            String values = Arrays.stream(SiteConstants.AVAILABLE_ISO_LANGUAGES).collect(Collectors.joining(", "));
            params.put("type", "translated title -> language code");
            params.put("values", values);
            throw new ActivityTypeValidationException(params);
        }
    }
    if (isApiRequest) {
        if (funding.getExternalIdentifiers() == null || funding.getExternalIdentifiers().getExternalIdentifier() == null || funding.getExternalIdentifiers().getExternalIdentifier().isEmpty()) {
            throw new ActivityIdentifierValidationException();
        }
    }
    if (funding.getAmount() != null) {
        Amount amount = funding.getAmount();
        if (PojoUtil.isEmpty(amount.getCurrencyCode()) && !PojoUtil.isEmpty(amount.getContent())) {
            throw new OrcidValidationException("Please specify a currency code");
        } else if (!PojoUtil.isEmpty(amount.getCurrencyCode()) && PojoUtil.isEmpty(amount.getContent())) {
            throw new OrcidValidationException("Please specify an amount or remove the amount tag");
        }
    }
    if (funding.getPutCode() != null && createFlag) {
        Map<String, String> params = new HashMap<String, String>();
        if (sourceEntity != null) {
            params.put("clientName", sourceEntity.getSourceName());
        }
        throw new InvalidPutCodeException(params);
    }
    if (isApiRequest) {
        validateDisambiguatedOrg(funding);
    }
    // Check that we are not changing the visibility
    if (isApiRequest && !createFlag) {
        Visibility updatedVisibility = funding.getVisibility();
        validateVisibilityDoesntChange(updatedVisibility, originalVisibility);
    }
    externalIDValidator.validateFunding(funding.getExternalIdentifiers());
}
Also used : ActivityTitleValidationException(org.orcid.core.exception.ActivityTitleValidationException) HashMap(java.util.HashMap) InvalidPutCodeException(org.orcid.core.exception.InvalidPutCodeException) Amount(org.orcid.jaxb.model.v3.dev1.common.Amount) OrcidValidationException(org.orcid.core.exception.OrcidValidationException) ActivityTypeValidationException(org.orcid.core.exception.ActivityTypeValidationException) Visibility(org.orcid.jaxb.model.v3.dev1.common.Visibility) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException)

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