Search in sources :

Example 76 with Visibility

use of org.orcid.jaxb.model.common_rc3.Visibility in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV2Test 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.record.summary_v2.Fundings) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) Visibility(org.orcid.jaxb.model.common_v2.Visibility) FundingGroup(org.orcid.jaxb.model.record.summary_v2.FundingGroup)

Example 77 with Visibility

use of org.orcid.jaxb.model.common_rc3.Visibility in project ORCID-Source by ORCID.

the class MemberV2ApiServiceImplV2_0_rc2 method compareWorkAndCreditNameVisibility.

private void compareWorkAndCreditNameVisibility(Work work) {
    Visibility workVisibility = work.getVisibility();
    if (work.getWorkContributors() != null && work.getWorkContributors().getContributor() != null) {
        for (Contributor contributor : work.getWorkContributors().getContributor()) {
            if (contributor.getCreditName() != null && contributor.getCreditName().getVisibility() != null && contributor.getCreditName().getVisibility().isMoreRestrictiveThan(workVisibility)) {
                String title = (work.getWorkTitle() == null || work.getWorkTitle().getTitle() == null) ? null : work.getWorkTitle().getTitle().getContent();
                LOGGER.error("Client posting work '{}' with visibility ({}) less restrictive than its contributor credit name '{}' ({})", new Object[] { title, workVisibility, contributor.getCreditName().getContent(), contributor.getCreditName().getVisibility() });
            }
        }
    }
}
Also used : FundingContributor(org.orcid.jaxb.model.record_rc2.FundingContributor) Contributor(org.orcid.jaxb.model.common_rc2.Contributor) Visibility(org.orcid.jaxb.model.common_rc2.Visibility)

Example 78 with Visibility

use of org.orcid.jaxb.model.common_rc3.Visibility in project ORCID-Source by ORCID.

the class MemberV2ApiServiceImplV2_0_rc3 method compareFundingAndCreditNameVisibility.

private void compareFundingAndCreditNameVisibility(Funding funding) {
    Visibility fundingVisibility = funding.getVisibility();
    if (funding.getContributors() != null && funding.getContributors().getContributor() != null) {
        for (FundingContributor contributor : funding.getContributors().getContributor()) {
            if (contributor.getCreditName() != null && contributor.getCreditName().getVisibility() != null && contributor.getCreditName().getVisibility().isMoreRestrictiveThan(fundingVisibility)) {
                String title = (funding.getTitle() == null || funding.getTitle().getTitle() == null) ? null : funding.getTitle().getTitle().getContent();
                LOGGER.error("Client posting funding '{}' with visibility ({}) less restrictive than its contributor credit name '{}' ({})", new Object[] { title, fundingVisibility, contributor.getCreditName().getContent(), contributor.getCreditName().getVisibility() });
            }
        }
    }
}
Also used : FundingContributor(org.orcid.jaxb.model.record_rc3.FundingContributor) Visibility(org.orcid.jaxb.model.common_rc3.Visibility)

Example 79 with Visibility

use of org.orcid.jaxb.model.common_rc3.Visibility in project ORCID-Source by ORCID.

the class MigrateAddressData method migrateAddress.

private void migrateAddress() {
    LOG.debug("Starting migration process");
    List<Object[]> addressElements = Collections.emptyList();
    do {
        addressElements = addressDao.findAddressesToMigrate();
        for (final Object[] addressElement : addressElements) {
            String orcid = (String) addressElement[0];
            String countryCode = (String) addressElement[1];
            String visibilityValue = (String) addressElement[2];
            LOG.info("Migrating address for profile: {}", orcid);
            transactionTemplate.execute(new TransactionCallbackWithoutResult() {

                @Override
                protected void doInTransactionWithoutResult(TransactionStatus status) {
                    Visibility visibility = null;
                    try {
                        visibility = Visibility.fromValue(visibilityValue);
                    } catch (Exception e) {
                        visibility = Visibility.fromValue(OrcidVisibilityDefaults.COUNTRY_DEFAULT.getVisibility().value());
                    }
                    AddressEntity address = new AddressEntity();
                    address.setDateCreated(new Date());
                    address.setLastModified(new Date());
                    address.setUser(new ProfileEntity(orcid));
                    address.setIso2Country(Iso3166Country.fromValue(countryCode));
                    address.setSourceId(orcid);
                    address.setVisibility(visibility);
                    addressDao.persist(address);
                }
            });
        }
    } while (addressElements != null && !addressElements.isEmpty());
    LOG.debug("Finished migration process");
}
Also used : TransactionStatus(org.springframework.transaction.TransactionStatus) Visibility(org.orcid.jaxb.model.common_v2.Visibility) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) AddressEntity(org.orcid.persistence.jpa.entities.AddressEntity) Date(java.util.Date) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity)

Example 80 with Visibility

use of org.orcid.jaxb.model.common_rc3.Visibility in project ORCID-Source by ORCID.

the class PeerReviewManagerImpl method setIncomingPrivacy.

private void setIncomingPrivacy(PeerReviewEntity entity, ProfileEntity profile) {
    Visibility incomingVisibility = entity.getVisibility();
    Visibility defaultVisibility = profile.getActivitiesVisibilityDefault();
    if (profile.getClaimed()) {
        entity.setVisibility(defaultVisibility);
    } else if (incomingVisibility == null) {
        entity.setVisibility(Visibility.PRIVATE);
    }
}
Also used : Visibility(org.orcid.jaxb.model.common_v2.Visibility)

Aggregations

Visibility (org.orcid.jaxb.model.common_v2.Visibility)55 Test (org.junit.Test)36 ClientResponse (com.sun.jersey.api.client.ClientResponse)35 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)12 HashMap (java.util.HashMap)10 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)10 OrcidError (org.orcid.jaxb.model.error_rc1.OrcidError)9 Visibility (org.orcid.jaxb.model.common_rc2.Visibility)8 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)8 Date (java.util.Date)7 Visibility (org.orcid.jaxb.model.common_rc1.Visibility)7 Visibility (org.orcid.jaxb.model.common_rc3.Visibility)6 OrcidDuplicatedElementException (org.orcid.core.exception.OrcidDuplicatedElementException)5 Funding (org.orcid.jaxb.model.record_v2.Funding)5 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)5 Work (org.orcid.jaxb.model.record_v2.Work)5 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)5 Visibility (org.orcid.jaxb.model.common_rc4.Visibility)4 OrcidError (org.orcid.jaxb.model.error_rc3.OrcidError)4 OrgEntity (org.orcid.persistence.jpa.entities.OrgEntity)4