Search in sources :

Example 31 with Visibility

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

the class MemberV2ApiServiceImplV2_0_rc1 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_rc1.FundingContributor) Visibility(org.orcid.jaxb.model.common_rc1.Visibility)

Example 32 with Visibility

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

the class MemberV2ApiServiceImplV2_0_rc1 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_rc1.FundingContributor) Contributor(org.orcid.jaxb.model.common_rc1.Contributor) Visibility(org.orcid.jaxb.model.common_rc1.Visibility)

Example 33 with Visibility

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

the class MemberV2ApiServiceImplV2_0_rc2 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_rc2.FundingContributor) Visibility(org.orcid.jaxb.model.common_rc2.Visibility)

Example 34 with Visibility

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

the class MemberV2ApiServiceImplV2_0_rc3 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_rc3.FundingContributor) Contributor(org.orcid.jaxb.model.common_rc3.Contributor) Visibility(org.orcid.jaxb.model.common_rc3.Visibility)

Example 35 with Visibility

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

the class MigrateNamesAndBioToTheirOwnTables method migrateData.

private void migrateData() {
    LOG.debug("Starting migration process");
    List<Object[]> profileElements = Collections.emptyList();
    int counter = 0;
    int batchCount = 0;
    do {
        LOG.debug("About to fetch a batch from DB");
        profileElements = profileDao.findProfilesWhereNamesAreNotMigrated(batchSize);
        LOG.debug("Procesing batch, profiles processed so far: " + counter);
        for (final Object[] profileElement : profileElements) {
            String orcid = (String) profileElement[0];
            String givenNames = (String) profileElement[1];
            String familyName = (String) profileElement[2];
            String creditName = (String) profileElement[3];
            String namesVisibility = (String) profileElement[4];
            String biography = (String) profileElement[5];
            String biographyVisibility = (String) profileElement[6];
            String defaultVisibility = (String) profileElement[7];
            transactionTemplate.execute(new TransactionCallbackWithoutResult() {

                @Override
                protected void doInTransactionWithoutResult(TransactionStatus status) {
                    LOG.info("Migrating names for profile: {}", orcid);
                    if (!recordNameDao.exists(orcid)) {
                        ProfileEntity profile = new ProfileEntity(orcid);
                        RecordNameEntity recordName = new RecordNameEntity();
                        recordName.setProfile(profile);
                        recordName.setCreditName(creditName);
                        recordName.setFamilyName(familyName);
                        recordName.setGivenNames(givenNames);
                        if (PojoUtil.isEmpty(namesVisibility)) {
                            recordName.setVisibility(Visibility.fromValue(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility().value()));
                        } else {
                            recordName.setVisibility(Visibility.fromValue(namesVisibility));
                        }
                        recordNameDao.createRecordName(recordName);
                    }
                    LOG.info("Migrating biography for profile: {}", orcid);
                    if (!biographyDao.exists(orcid)) {
                        Visibility visibility = Visibility.fromValue(OrcidVisibilityDefaults.BIOGRAPHY_DEFAULT.getVisibility().value());
                        if (!PojoUtil.isEmpty(biographyVisibility)) {
                            visibility = Visibility.fromValue(biographyVisibility);
                        } else if (!PojoUtil.isEmpty(defaultVisibility)) {
                            visibility = Visibility.fromValue(defaultVisibility);
                        }
                        biographyDao.persistBiography(orcid, biography, visibility);
                    }
                }
            });
            counter += 1;
        }
        batchCount += 1;
        LOG.info("Batches processed so far: {}", String.valueOf(batchCount));
        //Stop if we ran the number of batches
        if (numberOfBatches > 0) {
            if (batchCount >= numberOfBatches) {
                profileElements = null;
            }
        }
    } while (profileElements != null && !profileElements.isEmpty());
    LOG.debug("Finished migration process");
}
Also used : RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) TransactionStatus(org.springframework.transaction.TransactionStatus) Visibility(org.orcid.jaxb.model.common_v2.Visibility) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity)

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