Search in sources :

Example 91 with Visibility

use of org.orcid.jaxb.model.common_v2.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 92 with Visibility

use of org.orcid.jaxb.model.common_v2.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 93 with Visibility

use of org.orcid.jaxb.model.common_v2.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 94 with Visibility

use of org.orcid.jaxb.model.common_v2.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)

Example 95 with Visibility

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

the class OtherNameManagerImpl method setIncomingPrivacy.

private void setIncomingPrivacy(OtherNameEntity entity, ProfileEntity profile) {
    org.orcid.jaxb.model.common_v2.Visibility incomingOtherNameVisibility = entity.getVisibility();
    org.orcid.jaxb.model.common_v2.Visibility defaultOtherNamesVisibility = (profile.getActivitiesVisibilityDefault() == null) ? org.orcid.jaxb.model.common_v2.Visibility.PRIVATE : org.orcid.jaxb.model.common_v2.Visibility.fromValue(profile.getActivitiesVisibilityDefault().value());
    if (profile.getClaimed()) {
        entity.setVisibility(defaultOtherNamesVisibility);
    } else if (incomingOtherNameVisibility == null) {
        entity.setVisibility(org.orcid.jaxb.model.common_v2.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)37 ClientResponse (com.sun.jersey.api.client.ClientResponse)35 Url (org.orcid.jaxb.model.common_v2.Url)12 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)12 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 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)8 Date (java.util.Date)7 Visibility (org.orcid.jaxb.model.common_rc1.Visibility)7 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)7 Visibility (org.orcid.jaxb.model.common_rc3.Visibility)6 Funding (org.orcid.jaxb.model.record_v2.Funding)6 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)6 Work (org.orcid.jaxb.model.record_v2.Work)6 Education (org.orcid.jaxb.model.record_v2.Education)5 OrcidDuplicatedElementException (org.orcid.core.exception.OrcidDuplicatedElementException)4